shonumi / gbe-plus

DMG/GBC/GBA emulator and experimental NDS emulator.
GNU General Public License v2.0
530 stars 80 forks source link

[GBA] LoZ: Minish Cap Link won't roll #44

Closed shonumi closed 7 years ago

shonumi commented 7 years ago

When assuming control of Link, in GBE+ he can't seem to roll with the R button no matter what. No text in the upper-right hand shows up, and pressing the R button does nothing either.

LOZMC

Here, Link is clearly walking, but unable to roll. Fwiw though, most people don't roll around in their own houses...

No idea what the source could be. Pretty sure it's nothing related to input, but still that would be a good start (at least disassemble the code involved with input handling and see what it expects).

shonumi commented 7 years ago

Related -> https://bitbucket.org/elemental/emumaster/commits/f348cacd3f3af59b217f622a6c6ea6688c5bbf0a

The game reads from BIOS, and expects the value 0xC0. That's the byte BIOS reads are supposed to return after an IRQ has happened. u8 reads aren't checked for BIOS reading, so that could very well be the issue with GBE+ (u16 and u32 reads should be fine, need to double check).

At any rate, hacking/forcing BIOS reads from 0x39 to read as 0xC0 fixes this issue.

shonumi commented 7 years ago

This is weird behavior, to be sure. Looks like anti-piracy? Other than doing a fancy NOP, there's no real value to reading from the BIOS when outside of the BIOS. Pokemon R/S/E do this, and it messes up the ladders in Granite Cave if BIOS reads aren't correct (by correct, probably non-zero, else future BIOS revisions would have potentially borked the games if looking for a specific value).

By that same token, not being able to roll isn't a game breaker in Minish Cap, but it's pretty annoying. Never seen an 8-bit read to the BIOS, and realistically only Nintendo would really know 100% what the behavior should be for stuff like that.