bsnes icon indicating copy to clipboard operation
bsnes copied to clipboard

Incorrect SGB Joypad Incrementing Behavior (Breaks Gamera - Daikaijuu Kuuchuu Kessen)

Open CasualPokePlayer opened this issue 2 years ago • 0 comments

A bit of a forward from https://github.com/mgba-emu/mgba/issues/2202, but bsnes seems to suffer the same incorrect behavior that mGBA + other HLE SGB emulators have with incrementing the SGB Joypad number.

Simply be, this game expects to be able to increment the joypad number without writing $30 in between joypad reads. This is possible since all that is needed to increment the joypad number is P15 going from low to high, nothing else. The "lock" behavior currently in I believe was a simple misinterpretation of endrift's test results (re: https://github.com/bsnes-emu/bsnes/commit/90f094b931a225108970902ac00ffabe2a9eaf44) going off the assumption that you need to write $30 to increment the joypad number (which was something someone came up with in the Pandocs, with no discernible source of this claim besides an implication from Nintendo documentation).

I wrote a test to prove this, which can be found here: sgb-mlt-test.zip https://github.com/CasualPokePlayer/test-roms/blob/sgb-mlt-test/src/intro.asm

The results show that simple P15 low to highs will increment the joypad number, and implementing such behavior in other emus still pass endrift's previous tests. The fix is ultimately fairly simple here anyways.

On a minor slightly unrelated note, it seems like reads of joyp are also broken in the way that the written P14 and P15 bits do not get correctly set and are always read as low, which is incorrect. Might be something Sameboy needs to fix? I don't know /shrug

CasualPokePlayer avatar Sep 08 '21 06:09 CasualPokePlayer