MiSTer-devel / C128_MiSTer

https://misterfpga.org
41 stars 8 forks source link

Z80 cycle accuracy #37

Open Jusalak opened 2 months ago

Jusalak commented 2 months ago

Can C128 MiSTer do Z80 raster-related things accurately? See the attached program. That defies current software emulators. Pretty cool if it could. a_little_128_raster_interrupt_demo.zip

eriks5 commented 1 month ago

It also defies the MiSTer core 😕. All it does is change the second row of characters to white and then halts.

WIN_20240730_11_06_58_Pro

I've run it on a real C128 and it does work there. Can you explain how it's doing what it's doing? Any ideas of what's breaking it? Is the original source code available for reference?

eriks5 commented 1 month ago

Seemingly related topics/issues:

WIN_20240730_11_39_58_Pro

eriks5 commented 1 month ago

Hang was due to an incorrect address decoding in bank 2. With the MMU fixed, it now does this:

WIN_20240730_15_45_44_Pro

So.. it's close. But not perfect

Jusalak commented 1 month ago

The demo is basic raster programming stuff but done with Z80, at VICE repository there is C128 Z80 timing suite which is worth looking at. At VICE #1979 there are other testprograms with sources which are worth checking. Bank #2 was used because of Z80 access to 38h INT vector.

eriks5 commented 1 month ago

The Z80 I/O timing is now correct.

WIN_20240807_19_49_25_Pro

The Z80<->8502 switch timing is still 1 or 2 cycles off, and why is eluding me for now. I might release as-is and come back to this later.

Thanks for your great little test programs over at the Vice issue tracker. Really helped me a lot in getting the I/O timing right.

Jusalak commented 1 week ago

Good work! Did you check also going across the bad lines? Testprogs for PAL attached (were also in the VICE thread). testcpuswitch.zip

eriks5 commented 1 week ago

Yes bad lines work correctly. CPU and VIC access the RAM in the same way as real hardware on the MiSTer, so if bad lines wouldn't work correctly the VIC would display garbage or CPU would crash because it executes VIC data.