Swan

Struggling with Fuse or trying to find an emulator with a specific feature. Ask your questions here.
Post Reply
User avatar
Zoran
Drutt
Posts: 18
Joined: Fri Aug 16, 2019 12:56 pm

Swan

Post by Zoran »

New emulator: https://github.com/zoran-vucenovic/swan

It's named Swan... I have had hard time with thinking of a cool name, so during development I named it SWAN (Still Without A Name), until I find a real name. So... it is the name.

For a start, I made Windows (64 and 32 bit) releases (https://github.com/zoran-vucenovic/swan/releases). I am going to release Linux builds soon. You can compile for Linux yourself, see the notes about compiling in the project page.
To have sound you need portaudio library (see the notes in project front page, or wiki

Swan emulates 48k model only.
As I owned 48k Speccy, I wanted to create my own emulator for this machine. The focus was on accuracy of emulation, not on supporting other models.

Swan supports mapping of any PC key to any Speccy key (as games often have very peculiar keys, so I thought of this as a very important feature).

Please try... :)
User avatar
8BitAG
Dynamite Dan
Posts: 1498
Joined: Sun Dec 17, 2017 9:25 pm
Contact:

Re: Swan

Post by 8BitAG »

There was a similarly named adventure writing system, back in the day, called SWAN too. ;)
8-bit Text Adventure Gamer - games - research.
User avatar
ZXDunny
Manic Miner
Posts: 498
Joined: Tue Nov 14, 2017 3:45 pm

Re: Swan

Post by ZXDunny »

I accuracy is your bag then you probably should join the discord: https://discord.gg/45W4bUB

Our emulation chat has probably the biggest set of tests for all models of Speccies on the net by now, and it's very active with emulator development chat.
User avatar
Zoran
Drutt
Posts: 18
Joined: Fri Aug 16, 2019 12:56 pm

Re: Swan

Post by Zoran »

ZXDunny wrote: Sun Nov 06, 2022 10:10 am I accuracy is your bag then you probably should join the discord: https://discord.gg/45W4bUB

Our emulation chat has probably the biggest set of tests for all models of Speccies on the net by now, and it's very active with emulator development chat.
Thanks, I logged in there now and I am going to take a look around.
TheMartian
Microbot
Posts: 100
Joined: Wed Feb 03, 2021 5:18 am

Re: Swan

Post by TheMartian »

Zoran wrote: Sat Nov 05, 2022 11:19 pm New emulator: https://github.com/zoran-vucenovic/swan

It's named Swan... I have had hard time with thinking of a cool name, so during development I named it SWAN (Still Without A Name), until I find a real name. So... it is the name.

For a start, I made Windows (64 and 32 bit) releases (https://github.com/zoran-vucenovic/swan/releases). I am going to release Linux builds soon. You can compile for Linux yourself, see the notes about compiling in the project page.
To have sound you need portaudio library (see the notes in project front page, or wiki

Swan emulates 48k model only.
As I owned 48k Speccy, I wanted to create my own emulator for this machine. The focus was on accuracy of emulation, not on supporting other models.

Swan supports mapping of any PC key to any Speccy key (as games often have very peculiar keys, so I thought of this as a very important feature).

Please try... :)
Written in Pascal... There are retrogeeks and then there are heroes... Congratulations!
TheMartian
Microbot
Posts: 100
Joined: Wed Feb 03, 2021 5:18 am

Re: Swan

Post by TheMartian »

I'm trying it a bit and it looks *very* solid!

The CPU emulation is really accurate, ula48.tap and FPGA48all.tap pass with flying colours. Plus, all the recent discoveries regarding incomplete block instructions are implemented (z80full from z80tests-1.2 passes ok)

The sound sometimes seems to lag a bit after resetting the Spectrum. I've built it in my Ubuntu laptop. Looks like after muting the sound for a bit and then unmuting it syncs again.

The snow effect is not implemented, but you've got info for that in the forum. :)

Also, I think that the EAR/MIC feedback is not implemented. You've got the info here: https://worldofspectrum.net/faq/referen ... erence.htm
Bit 6 of IN-Port 0xfe is the EAR input bit. The value read from this port is not trivial, as can be seen from the following program:

10 OUT 254,BIN 11101111
20 PRINT IN 254
30 OUT 254,BIN 11111111
40 PRINT IN 254
50 GOTO 10

For a correct test do not press any key while running, and have no EAR input.

If the output is 191,255,191,255 etc, you are on real Spectrum Issue 3.
If output is always 191 or always 255, change the value in line 10 to BIN 11100111.
If output is then 191,255,191,255 etc, then you are on Spectrum Issue 2.
If output is still always 191 or always 255 you are on Spectrum emulator.
This is so the first Abu Simbel Profanation releases work. Now the only way to enter the game is to press 3 while the tape is running.

Regarding the UI, it looks simple and clean, I like it. Try running it with a dark theme, though; it looks like some text tags don't have much contrast.

Apart from these details, it's a really good emulator!

Great job!
TheMartian
Microbot
Posts: 100
Joined: Wed Feb 03, 2021 5:18 am

Re: Swan

Post by TheMartian »

TheMartian wrote: Sun Nov 06, 2022 7:08 pm Also, I think that the EAR/MIC feedback is not implemented.
After trying the BASIC program:
10 OUT 254, BIN 11101111: PRINT IN 254
20 OUT 254, BIN 11111111: PRINT IN 254
30 GO TO 10

It behaves like a issue 3 machine, returning 191,255,191,255... However, I think the change in EAR following a MIC change happens instantaneously, instead of having a little delay caused by the RC charge of the EAR/MIC circuitry. I guess this is why Abu Simbel Profanation doesn't start.

Here: issue3.tap

On an issue3, running with 6 should return 255, but running with 7 should return 191. (I should run this test on a real 48K to be sure, though :lol: )
beginner
Drutt
Posts: 37
Joined: Sat May 21, 2022 10:23 pm

Re: Swan

Post by beginner »

Hello @Zoran ,

I played a bit with Swan. I like it :) . +1 for Pascal ;) .
The sound lagging, mentioned by @TheMartian, reproduced during my testing too.

I had a similar issue at some point. In my case it was caused by an audio buffer being saturated too quickly. Maybe it helps.

Great work!
User avatar
Zoran
Drutt
Posts: 18
Joined: Fri Aug 16, 2019 12:56 pm

Re: Swan

Post by Zoran »

Thank you, TheMartian and the.beginner.
I could reproduce sound problems in Linux on a slow virtual machine with low resources.
I just tried with enlarging the buffer used by portaudio callback function, but it didn't seem to get much.

I'm going to play more... I'll see if this article might help me more...
TheMartian
Microbot
Posts: 100
Joined: Wed Feb 03, 2021 5:18 am

Re: Swan

Post by TheMartian »

Zoran wrote: Tue Nov 08, 2022 8:11 am I could reproduce sound problems in Linux on a slow virtual machine with low resources.
I just tried with enlarging the buffer used by portaudio callback function, but it didn't seem to get much.

I'm going to play more... I'll see if this article might help me more...
IMHO it is not "latency", but rather that something happens when you reset the Speccy, that increases the delay or something. Maybe you're stopping and restarting the sound playback or something? Or you start a new sound buffer on reset, instead of continuing the buffer in use until it's full?
User avatar
Zoran
Drutt
Posts: 18
Joined: Fri Aug 16, 2019 12:56 pm

Re: Swan

Post by Zoran »

TheMartian wrote: Tue Nov 08, 2022 11:02 am Or you start a new sound buffer on reset, instead of continuing the buffer in use until it's full?
Yes, that is so now -- the sound is stopped, then started again, with new buffer.
Hm... I thought it would not be wrong to do that... Normally, Spectrum would not continue with playing the old sound when restarted. And, the workaround you mentioned in previous post:
TheMartian wrote: Sun Nov 06, 2022 7:08 pmLooks like after muting the sound for a bit and then unmuting it syncs again.
actually does just that -- stops the sound and then starts it again, with new buffer.

As a first thing, I'm going to try with removing this sound restarting with each Spectrum resetting; I should make sure it does not have any unwanted impact on other code. And I just have no time now, probably this evening. I'll ask you to test then. Thanks a lot.
TheMartian
Microbot
Posts: 100
Joined: Wed Feb 03, 2021 5:18 am

Re: Swan

Post by TheMartian »

Zoran wrote: Tue Nov 08, 2022 2:19 pm Yes, that is so now -- the sound is stopped, then started again, with new buffer.
Hm... I thought it would not be wrong to do that... Normally, Spectrum would not continue with playing the old sound when restarted. And, the workaround you mentioned in previous post:
actually does just that -- stops the sound and then starts it again, with new buffer.

As a first thing, I'm going to try with removing this sound restarting with each Spectrum resetting; I should make sure it does not have any unwanted impact on other code. And I just have no time now, probably this evening. I'll ask you to test then. Thanks a lot.
The idea behind completing the sound buffer instead of using a new one is because in real life sound is not sent in blocks. The Z80 reset can happen at any time, and this makes it run the ROM from $0000, and in just 7 CPU instructions it's setting the ULA sound bit low (and the border white).

I guess that when you mute/unmute the sound, you just start playing sound from scratch: Create a new buffer and then play it, and so on. This restores the normal delay because the sound card has already run out of samples to play. However, if you create a new buffer on reset, the sound card will play the entire old buffer, then start with the new one, adding a bit of delay.

I'll be happy to test the new version of the emulator when you have it. :) Glad to help. Getting the sound right is quite tricky... :)
User avatar
Zoran
Drutt
Posts: 18
Joined: Fri Aug 16, 2019 12:56 pm

Re: Swan

Post by Zoran »

Hello!

New version of Swan 0.9.2-beta:

- Improved emulation accuracy (Tests collected by redcode (ZjoyKiLer) were really helpful!)

- Sound lagging on Linux seems to be solved (@TheMartian -- whenever portaudio gets stopped, now it is always terminated -- so terminating, not just stopping portaudio seems to have solved this :? ).

- added loading and saving szx snapshot format
- added drag and drop files support
- added autosaving snapshots, quick going back in time and browsing saved snapshots (see details).

Precompiled binaries are released for
- Linux 64 bit, choose gtk2 or qt5 widgetset library (please note that for qt5, libqt5pas library has to be installed)
- Windows 64 and 32 bit
Post Reply