floooh / chips

8-bit chip and system emulators in standalone C headers
zlib License
960 stars 73 forks source link

Z80 BUSACK/BUSREQ/RESET pins #60

Open carmiker opened 2 years ago

carmiker commented 2 years ago

Based on a comment in z80.h it looks like there are plans to implement the RESET pin, but I am curious if there are plans to emulate the BUSACK and BUSREQ pins (useful for Sega Mega Drive).

floooh commented 2 years ago

Ah, I didn't know the MegaDrive uses BUSACK/BUSEQ, first system I know of!

No plans at the moment, since I'm currently busy with non-emulator stuff. I guess it would need to work similar to the WAIT handling (except that it needs to be checked each clock cycle? - I haven't looked yet into how BUSREQ works).

One thing I've been thinking about is to add a few config-defines to the header to switch on or off certain implementation features (for instance the WAIT handling is quite expensive, but many emulated systems don't even use wait states). The BUSREQ handling would probably be even more expensive, but also isn't needed by most systems.

carmiker commented 2 years ago

I've not done the deep dive to find out exactly what happens cycle by cycle for BUSREQ and RESET handling, but I have done a (very crude) implementation in my Sega multi-emulator which I'm currently adding Mega Drive support to, and it generally works: https://gitlab.com/jgemu/cega/-/blob/master/src/cega_z80.c