Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Games feel fast on a Bobricius board #198

Open
Loccy opened this issue Dec 19, 2024 · 10 comments
Open

Games feel fast on a Bobricius board #198

Loccy opened this issue Dec 19, 2024 · 10 comments

Comments

@Loccy
Copy link

Loccy commented Dec 19, 2024

Have been looking through past issues and docs trying to see if I should expect more accurate emulation than I get, but it's not entirely clear. Issue 113 seems to suggest that while it's not cycle accurate it should be more accurate than my experience has been. I've got a Bobricius ZX48/128 board in an old rubber key case. Am running out of VGA, using the 60Hz version as I don't like the way the 50Hz looks on most of my screens (big black borders everywhere). I would say that everything is about 10-20% faster than it should be, tested on Manic Miner and Cybernoid. AY sound has some curious distortion too on the Cybernoid music - hard to describe but chunks of the percussion is well off.

I've also tried the 50Hz build and that seems the same, with the added "bonus" of those big black borders.

Is this a normal experience or is there something I'm missing? Was hoping this would be a direct swap-in for an original Spectrum board, at least good enough to pass muster for most games, but this is a bit of a show-stopper :(

@fruit-bat
Copy link
Owner

Please understand that this is not a commercial project. I wrote a bit of software, which I thought people might enjoy. Where people have asked me to add support for their boards, I have had a go.

The RP2040 is a microcontroller, and there are limitations in what can be achieved. Possibly, other projects have done better.

There is no frame buffer, so on the 60Hz builds, interrupts occur at this rate. There is a menu option to count cpu cycles... but either way, there will be inaccuracies. The 50Hz builds are a little better... but 50hz on a modern display is not the same as an old CRT.

@Loccy
Copy link
Author

Loccy commented Dec 20, 2024

Oh, no, don't get me wrong, that wasn't intended as critical - I was just trying to find out whether what I'm seeing is normal or not. I've got the CPU cycles option enabled so I was hoping to see something that felt close to the original. Am not super bothered about cycle level accuracy. I just wanted to know whether it is "normal" for (say) Manic Miner to feel 10-15% faster than stock? And also is it normal for this to be the case seemingly regardless of whether I use 50Hz builds or enable the CPU cycles counting?

@fruit-bat
Copy link
Owner

fruit-bat commented Dec 20, 2024

Possibly a couple of issues. The emulation is clocked against the timer interrupt for the audio which I have been having a few other issues with. I am working on some pio versions without an interrupt which may work better.

I'm also a bit lax in counting memory access wait states accurately, which may correspond to a speedup.

@Loccy
Copy link
Author

Loccy commented Dec 20, 2024

So, see below my incredibly unscientific testing using the Manic Miner air supply as a timer.

PXL_20241220_142300699
PXL_20241220_144210634

Left hand side Spectrum and screen is original hardware, right hand side is a Bobricius board. Top pic is at 60Hz, bottom at 50Hz, in both cases running the ZxSpectrumPicomputerVgaAukBob_xxxx.uf2 firmware from commit abfd402. Both running at 3.5MHz. On the 60Hz I had "count CPU cycles" on, on the 50Hz I had "sync to display".

50Hz or 60Hz, they both seem to run at a comparable speed regardless insofar as when the air runs out on the Pi-based Spectrum the real Spectrum's air has just got into the red. Obviously I started the games both at the same time. So the speed is consistent (to the end-user's eye, at least) across the different refresh rates and even across the two different CPU interrupt modes. That consistent speed is just faster than it should be.

(Edit: I also built the latest main branch, just to see if that was any different. Didn't do the full length of the air bar but the emulated Spectrum was clearly still running fast)

@fruit-bat
Copy link
Owner

Thanks for the detail. Please would you test these builds for me and let me know if they match the real hardware better (I've not owned a real Speccy for a long time)?

This is a just a hack, I've slowed it down overall by about 10% (or tried to).

ZxSpectrumPicomputerVgaAukBob_90percent.zip

@Loccy
Copy link
Author

Loccy commented Dec 23, 2024

Thanks for that - just to let you know it won't be until the New Year that I'll be able to test this, as my Spectrums are at the office and I'm away for the hols. But will check it out as soon as I get back.

@fruit-bat
Copy link
Owner

Note to myself: I need a framework in which I can easily add wait states to memory accesses, based on memory address. Probably needs changes to the Z80 emulator.

@fruit-bat
Copy link
Owner

Note to myself: https://en.wikipedia.org/wiki/Contended_memory

@Loccy
Copy link
Author

Loccy commented Jan 2, 2025

So, we still seem to be running a touch fast using the same highly scientific testing methodology:

PXL_20250102_173550789
PXL_20250102_174050323

There didn't seem to be any difference (timing-wise) between 50 and 60Hz. When the emulated Spectrum ran out of air, the real Spectrum's air was just a pixel or so to the right of the S in "High Score" in both cases.

It is much closer - possibly getting close enough that I wouldn't have noticed if this had been the first build I'd ever run (it probably wouldn't have occurred to me to put it side-by-side with a real Spectrum). But still a tad off. 11%, perhaps?

@Loccy
Copy link
Author

Loccy commented Jan 8, 2025

Note to myself: https://en.wikipedia.org/wiki/Contended_memory

This one gives a LOT more detail (most of which I don't understand in the slightest) https://sinclair.wiki.zxnet.co.uk/wiki/Contended_memory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants