MiSTer-devel / S32X_MiSTer

Sega 32X implementation for MiSTer
53 stars 19 forks source link

Fix Gen memory read lock preventing SH from executing (Knuckles Chaotix) #50

Closed YLFAndy closed 9 months ago

YLFAndy commented 9 months ago

Two states have locking conditions for SH if Gen memory busy status doesn't get released. In this PR I have added a default state of not busy to the state MBUS_IDLE (subsequent read states set the MBUS to busy, so this only falls through if no actual memory access takes place) and I've set it explicitly at the end of all MBUS_FINISH calls as if there's a genesis error, it shouldn't prevent execution from being handed back to SH. Most games do more calls to Gen as far as I can tell, however KC loads text elements then nothing happens until a game is started on the Gen side, so because it blocks the SH just stops executing until start is pressed.

I am very new at this. So please go over the changes carefully before/if contemplating merge! I feel they are correct and allow the ROM_WAIT code to function but bypass hangs where the state change isn't properly completed. But as someone who very recently started learning, there's a high chance I'm incorrect or have introduced other bugs. I have tested with a number of games and don't notice any negative impact, but I am a novice.

Additionally - this is all still using the branch's Genesis code. This will be nullified if/when the Nuke MD components needed to make S32X work are pulled in.

Some other findings: Setting the MBUS_AS_N register for just MBUS_FINISH results in Knuckles and Chaotix playing the intro correctly once, however upon second play it exhibits the same locked behavior (gated on the AS_N_SYNC[0] register check in IF.sv @ 838). Setting it default to 1 (not waiting) in the state change to MBUS_IDLE fixes this and as far as I can tell, every logic check correctly sets it to busy within the code so this just provides a fallthrough.

Again, this might be entirely wrong and I strongly hope that someone with more experience can review it and provide input or, best case, confirm.

S32X_unstable_20231007_197e54.zip

YLFAndy commented 9 months ago

Also, if someone can squash commits - I had to branch to remove my personal branch's CLI changes and those commits are polluting the PR.