fruit-bat / pico-zxspectrum

ZX Spectrum for Raspberry Pico Pi RP2040
486 stars 54 forks source link

Timings and beeper sound #184

Open retrofan11 opened 3 weeks ago

retrofan11 commented 3 weeks ago

Hi, First of all, I want to thank you and congratulate you for this great emulator! I've tested it on a Waveshare RP2040 PiZero board and it's already great, but I'd like to ask if there's room for improvement in two important areas, timings and beeper sound quality?

Most demos/games/test programs show similar problems with image display in border, eg. TV Game, Aquaplane, several ULA tests (BorderTrix, Rotatrix etc), Timing tests 48k for example cannot even recognize early/late timing and refuses to work. I saw that you managed to fix the very tricky game Ringo and I was wondering if there is anything that can be done to further fix the timings, including the border, so many fine demos or games and other software that relies on precise timings will work properly ?

Beeper sound is another thing I would mention, because there is a lot of noises, crackling, buzzing and similar artifacts in the background during reproduction (eg. Heartland main tune), while the AY sound emulation is very high quality and very clean sound. I really don't have any other complaints, it's easy and simple to use, thanks again for your efforts and I hope there will be more good news about this emulator in the future. Also I attached an archive of test programs that I have collected over the years and may be useful for future testing. Tests.zip Cheers.

fruit-bat commented 3 weeks ago

Many thanks for the test programs (and complements), when I get chance I will go through those and see if there are improvements I can make. I don't want to get your hopes up too much on the video side, I don't have room for a frame buffer and hence didn't put that much effort into precision sync with the CPU... but I will see what I can do!

I do think I could probably improve the beeper sound. Problems usually occur when programs on the spectrum use PWM, which can then get very distorted due the the emulator sampling. I made half an attempt to improve this by 'smoothing' the beeper output; it might be better to use a 'proper' 1st/2nd order digital low-pass filter.

I'm glad you find it easy to use. The RP2040 feels unique in the way it can interface so nicely with the outside world.

retrofan11 commented 3 weeks ago

Thanks for the reply, really appreciate it. In the meantime I found another Pico based Spectrum emulator, but it only supports the very rare Murmulator dev-board with VGA output and costs much more (50eur) than this waveshare board. https://github.com/DnCraptor/pico-spec I haven't had a chance to try it, but maybe you can get some new hints for further improvement of your emulator. Cheers.

fruit-bat commented 1 week ago

Made a start on a better beep sound here: https://github.com/fruit-bat/pico-zxspectrum/tree/feature/buzzer_lpf

I need to do more testing on it before I merge it back.

fruit-bat commented 1 week ago

Build released. Let me know if it has improved at all (I don't have a Waveshare board to try).

retrofan11 commented 1 week ago

Build released. Let me know if it has improved at all (I don't have a Waveshare board to try).

Just tested the new build and I have good news and bad news. The good news is, that most of the background noise and similar unwanted effects are gone. Unfortunately, the bad news is, that at the same time, the sound has disappeared in a number of games. The most obvious example are Odin games (Robin of the Wood, Heartland, ICUPS), where the sound in the main menu is completely missing, but it worked on the previous version with certain noises and similar side effects. This will certainly affect other games and demos, which use this or similar technique (quieter but high-quality multichannel sound). Most other games I try, certainly sound cleaner, but I think these losses still outweigh the benefits. I also checked some other games that rely on multicolor effects, for example, the famous Uridium does not correctly display the rainbow effect in the title screen and high score table, and there are certainly more games that use similar effects. btw, this waveshare board has expanded flash memory to 16Mb, but I don't know if it can be useful for improving these timing issues or not... I also attached a great "8-channels" demo with excellent beeper melodies, but unfortunately it doesn't produce any sound here, so it can be a good test tool. Cheers. 8-channels.zip

fruit-bat commented 1 week ago

Many thanks for the detailed feedback. I will see if I can get the demo working.

fruit-bat commented 6 days ago

Cor, 8-channels is a difficult one to get working... made some progress. Its a little quiet on the demo but sounds ok-ish. I don't how load it plays on real hardware.

ZxSpectrumPiZero_720x576x50Hz.zip

If you get chance, let me know if you think it is better. I might be able to get a bit more volume if I keep playing around with it; its tricky to do without it distorting.

retrofan11 commented 6 days ago

This time I have very good news. I somehow assumed that if you fix this demo, that other problematic games, made with a similar technique, will also work, and that's what happened. :) Everything I tried worked wonderfully, including games and demos with tricky beeper engines, including all Odin games. You don't need to worry about the quieter sound, that's normal with this technique and it works like that on real hardware too. As far as I'm concerned, everything sounds great already, when I compared it with reliable windows emulators and I wouldn't touch anything here. I can only congratulate you, you've done a stunnig job here! Also, I continued to test other games with different multicolor effects and so far they all suffer greatly from timing issues, e.g. all games made with the Nirvana engine as well as other games that use similar tricks like Uridium, Old Tower, Snake Escape, Dreamwalker, Multi Dude, El Stompo etc... For testing timing issues, the well-known game from the 80s Vectron is very suitable, which after loading shows blue stripes all over the screen and the border, perfectly aligned. Right now these stripes in the border are one row higher than they should be, which tells me that you are actually very close to a solution here as well. Anyway, thank you very much for fixing the beeper sound, it's a really big step forward and I hope there also will be good news for all these games, which rely on precise timing. You can count on me for any kind of waveshare board testing in the future. Cheers.

fruit-bat commented 4 days ago

Fantastic, I will merge the changes back and do another full build. Many thanks for the testing and detailed feedback.

When I get chance, I will have a go at some of the video timing issues... and appreciate your offer to test on the waveshare board.

8tpercent commented 3 days ago

I've a waveshare board so can also test.

BTW beeper 2 update yesterday works great as the beeper update from a few days ago broke the normal tape loading noise ie. gone.

Fab work.