mgba-emu / mgba

mGBA Game Boy Advance Emulator
https://mgba.io/
Mozilla Public License 2.0
5.67k stars 777 forks source link

Pokemon FireRed ROM Hack - Game crashes on real hardware but not mGBA #1884

Open Skeli789 opened 4 years ago

Skeli789 commented 4 years ago

I'm not sure if this is worth reporting as it was borne out of a bug, but nonetheless I figured there was no harm.

I was testing the ROM Hack I'm working on, when I noticed that the game was crashing at a certain point using the 3DS's Virtual Console, but mysteriously not on mGBA (0.8.3 for Windows 10 downloaded from the official site). I tracked down the origin of the problem to the game attempting to load garbage data as a compressed sprite sheet. For reference, the game was trying to load the data at 0x8260A38 as a compressed sprite sheet (which caused it to try to load compressed sprite tiles at 0x000A0009). This data was unchanged from a vanilla FireRed ROM. Since 0xA0009 isn't actually part of the GBA's memory map (according to Tonc, anyway), I'm guessing the crash happened due to the different way mGBA and the Virtual Console handle the default data in that memory section.

endrift commented 4 years ago

I can't do much on this without the hack in question.

Does it crash if you use the BIOS?

Skeli789 commented 4 years ago

The version of the hack that had the bug was never made public, but I've fixed the issue so it's no longer a worry.

Is there anything specific I need to do to boot the game with the BIOS? I tried selecting the Boot BIOS button both with and without the ROM loaded, but the game doesn't crash.

endrift commented 4 years ago

Go to settings, and make sure you have the BIOS set up in the proper section. You can verify it's being used by unchecking the skip BIOS option.

Regardless, if it's a difference from hardware I'd like to fix it.

Skeli789 commented 4 years ago

Okay, so mGBA refused to boot my game with the BIOS loaded in. I thought it may have been an issue with the BIOS I was using, but FireRed booted just fine.

If it helps, I can upload the game somewhere along with the save file I was using and send the links to you by email.

endrift commented 4 years ago

If you can just do the patch (not the whole ROM) that would work great.

Skeli789 commented 4 years ago

Okay, I sent it to the email listed on your GitHub.

endrift commented 3 years ago

This appears to be because it's trying to read a buffer in the middle of the AGBPrint region. Though AGBPrint is disabled at the time, it'd been previously enabled, which changes how that region of memory reads out. This may be a bug in mGBA, but it'll be rather hard to determine the right behavior here due to the fact that public cartridges don't support AGBPrint, and this is an advanced debugging feature. Further, this only affects 32 MiB ROMs, and there are only a handful of those that ever shipped officially.