mmitch / gbsplay

gameboy sound player
https://mmitch.github.io/gbsplay/
Other
98 stars 20 forks source link

'Unknown opcode' when playing some songs #28

Closed cyberic99 closed 4 years ago

cyberic99 commented 4 years ago

When trying to play or dump the registers of this .gbs file, I get this error after 4 seconds:

Unknown opcode d3.

I used this command:

gbsplay -o iodumper "Paragon 5 Music Album (2002)(Paragon 5).gbs"  11 11

Here is the file:

Paragon 5 Music Album (2002)(Paragon 5).gbs.zip

Thank you Eric

ranma commented 4 years ago

I think it's a bug in the emulation somewhere, looks like execution is going off the rails. FWIW the full ROM is at http://www.pouet.net/prod.php?which=1793

ranma commented 4 years ago

So, it's actually a buggy .gbs file, which trips over how gbsplay loads the data into memory: The header specifies that the code should be loaded at address 0x04d0. It should thus not make any assumptions above data in memory before that area.

However it ends up loading data from address 0x0498, which just so happens to contain bits of the header, so it is not "zero" as the code expects. It ends up doing an out-of-bounds jumptable read, reading a bad jump address.

However the reason the header is mapped into the rom together with the code is historical at this point (It hasn't changed since https://github.com/mmitch/gbsplay/commit/b9b5043aa193f13c8148359a2303318e19e83ba3).