AY emulation testing

Struggling with Fuse or trying to find an emulator with a specific feature. Ask your questions here.
User avatar
Pegaz
Microbot
Posts: 160
Joined: Mon Nov 13, 2017 1:44 pm

Re: AY emulation testing

Post by Pegaz » Fri Oct 12, 2018 8:36 pm

Woody did a lot more than that.
When Ramsoft people revealed new ULA feature (four bright shades), ten years ago, Woody managed to implement this feature in SpecEmu in just a few days.
https://www.worldofspectrum.org/forums/ ... rlace-demo
https://www.worldofspectrum.org/forums/ ... edirect/p1

And this is not his only contribution to a better Spectrum emulation...
0 x

User avatar
djnzx48
Microbot
Posts: 195
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: AY emulation testing

Post by djnzx48 » Sat Oct 13, 2018 4:58 am

I'm sorry, I hope I didn't come across as ungrateful towards emulator developers. It's just hard to get motivation for using these features and quirks when the most popular emulators don't support them and they haven't been updated in years.
1 x

zx81
Berk
Posts: 46
Joined: Sat Feb 17, 2018 9:33 pm

Re: AY emulation testing

Post by zx81 » Sat Oct 13, 2018 10:15 am

Ast A. Moore wrote: 8. No emulator is, of course, capable of displaying the Spectrum output at its native 50 fps. This isn’t the fault of any particular emulator, naturally, but rather the systems they runs on: most modern computers are locked to a 60 Hz refresh rate.
That's not exactly true, my friend... :)

The frame frequency on a 48k model is 50.0801 Hz and on a 128k model is 50.0211 Hz. These frequencies are basically impossible to reach on a TV or monitor where you can't control such frequencies (50 or 59.94 Hz, not 60 Hz). To get a precise 50 Hz refresh, the emulator needs to run slowly than real thing.

FPGA-based emulators, like the ZX-Uno, are capable to control the TV frame generation, so the "recreated" 48k runs at real speed. But, because the internal clocks have various limitations, the 128k model runs 8000 Hz away from real machine.

In ZXBaremulator the 48k model runs at the correct speed. So, when you configures the HDMI mode to 576i@50 Hz, you can see the interlaced effects without any trick in code, but with a small defect caused by the slightly different frequencies between TV and emulated Spectrum (50 vs 50.0801). For 128k models, the Raspberry only have a 1-Mhz timer, and I can't get the needed precision (a 128k frame lasts 19.99156356 ms), so it emulates frames of 19.991 ms long.

In theory, you can configure a HDMI mode with exact frequencies, but isn't easy to generate the needed numbers and can depend a bit of every TV-set, so I don't want to try this way. After all, the interlaced modes are "emulated" by modern TV-sets, and every model handles this with his own method.

I'm curious about the AY quality in ZXBaremulator, if somebody can try... ;)
0 x

User avatar
Pegaz
Microbot
Posts: 160
Joined: Mon Nov 13, 2017 1:44 pm

Re: AY emulation testing

Post by Pegaz » Sat Oct 13, 2018 11:00 am

zx81 wrote:
Sat Oct 13, 2018 10:15 am

In theory, you can configure a HDMI mode with exact frequencies, but isn't easy to generate the needed numbers and can depend a bit of every TV-set, so I don't want to try this way. After all, the interlaced modes are "emulated" by modern TV-sets, and every model handles this with his own method.

I'm curious about the AY quality in ZXBaremulator, if somebody can try... ;)
Yes, I also came to a similar conclusion.
Actually, there are two ways, which allow me a perfectly smooth scroll on raspberry pi, at least on my TV set.
The first mthod is using the Unreal Speccy Portable emulator, as well as the latest beta version of your Baremulator for Pi 1 / Zero.
We've already talked about that and what you've said, in such a case Spectrum works slightly slower, for that difference between 50Hz vs 50.0801 Hz.
I recently discovered another method, which also gives an excellent result with Fuse version for Retroarch frontend on Raspberry Pi.
In this case, its possible to set the exact frequency at 50.0801 Hz in options and the result is also a perfectly smooth scroll without any interruptions.
I dont know if this particular settings is really precise or not, but in reality it works great.

btw, you previously wrote that the exact frequency for 48k Spectrum is 50.0802 Hz, so I'm interested in what is the correct number?
0 x

zx81
Berk
Posts: 46
Joined: Sat Feb 17, 2018 9:33 pm

Re: AY emulation testing

Post by zx81 » Sat Oct 13, 2018 11:42 am

Pegaz wrote:
Sat Oct 13, 2018 11:00 am
btw, you previously wrote that the exact frequency for 48k Spectrum is 50.0802 Hz, so I'm interested in what is the correct number?
3500000 / 69888 = 50.08012821
0 x

User avatar
djnzx48
Microbot
Posts: 195
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: AY emulation testing

Post by djnzx48 » Sun Oct 14, 2018 4:01 am

What about the more recent LCD monitors that support FreeSync or G-Sync adaptive sync? They can be set to arbitrary refresh rates, so couldn't you obtain a proper 50Hz display using one?
0 x

User avatar
djnzx48
Microbot
Posts: 195
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: AY emulation testing

Post by djnzx48 » Thu Oct 25, 2018 8:52 am

I've made some simple fixes for a few emulators to fix wrong-sounding AY without needing in-game workarounds. To be safe I won't distribute the patched executables here, but you can apply the patches quite easily using a hex editor. I used Frhed but there are a number of free ones available. Make sure you make backups first in case you make a mistake.

You may have to run the editor as administrator if you're editing files contained in Program Files. Once you've opened the file, press Ctrl+G to goto the address starting with '0x' - note that all the addresses are in hex. Then enter the new values on the rest of the line. Repeat this for the other address and values. Finally, save the file and if all has gone well you should now have improved AY sound.

Here are the patches:

Spectaculator 8.0: the file to edit is ay8912.dll in the Spectaculator\drivers directory.

Code: Select all

0x2063: E9 FA 08 00 00 90 90
0x2962: 0F B6 71 52 D1 E6 8B 51 78 E9 FA F6 FF FF
SpecEmu 3.1.b120516: the file to edit is specemu.exe. (I know it's an old version but it's the newest one I could find.)

Code: Select all

0x2025:  E9 0A C1 02 00
0x2E134: 14 00 D1 E0 88 46 20 E9 EA 3E FD FF
ZXSpin 0.7s: the file to edit is ZXSpin.exe.

Code: Select all

0x9078A: D1 E0 88 46 13 8B 86 90 00 00 00 E9 0E 10 06
0xF179F: E9 E6 EF F9 FF 00 90 90 90
The results:

Image

And that's it. I also have a working fix for ZXSpin 0.666 but the executable is packed, so applying the patch is not so simple. I'll put the fix for that here if I can get it to work.
0 x

hikoki
Manic Miner
Posts: 286
Joined: Thu Nov 16, 2017 10:54 am

Re: AY emulation testing

Post by hikoki » Thu Oct 25, 2018 9:26 am

there you have a newer SpecEmu
SpecEmu - 3.1.b160318

@Woodster google drive links don't expire ;) thanks!
1 x

Post Reply