Rodrigodd / gameroy

A Game Boy emulator, disassembler and debugger, written in Rust
Apache License 2.0
266 stars 6 forks source link

Possible Inaccuracy in SRAM emulation #10

Closed diabl0w closed 5 months ago

diabl0w commented 5 months ago

Hi, i've been trying your emulator to run Gen 1 Pokemon glitches. One of the most popular glitches is the 'SRAM Glitch'. It does not seem to be working on yoir emulator. I tried both the android and desktop linux versions

Rodrigodd commented 5 months ago

Your link has the following comment:

Even if the player does not have an existing save file (e.g. on a fresh cart), it is still recommended to clear the save file anyway. Clearing the save file will set the SRAM to all 0xFF bytes, which guarantees that this glitch will give the player an expanded party. On the other hand, the contents of uninitialized SRAM is unpredictable: There is a good chance it will be 0xFF anyway, but it can also be something else. In particular, some emulators initialize the SRAM to 0x00, which means even if this glitch succeeded, it will not give the player an expanded party.

I believe my emulator is initializing the content of RAM to 0x00 instead of the expected 0xFF.

Can you check if clearing the save file makes the glitch work? Or if you are already doing that.

diabl0w commented 5 months ago

Your link has the following comment:

Even if the player does not have an existing save file (e.g. on a fresh cart), it is still recommended to clear the save file anyway. Clearing the save file will set the SRAM to all 0xFF bytes, which guarantees that this glitch will give the player an expanded party. On the other hand, the contents of uninitialized SRAM is unpredictable: There is a good chance it will be 0xFF anyway, but it can also be something else. In particular, some emulators initialize the SRAM to 0x00, which means even if this glitch succeeded, it will not give the player an expanded party.

I believe my emulator is initializing the content of RAM to 0x00 instead of the expected 0xFF.

Can you check if clearing the save file makes the glitch work? Or if you are already doing that.

very good catch! i apologize for not noticing that. it does indeed work now, thank you

EDIT: not sure if initializing as 0xFF would be considered more accurate emulation behavior, so ill leave this up to you to close if you choose to or not

Rodrigodd commented 5 months ago

Fixed in https://github.com/Rodrigodd/gameroy/commit/3d3bb7ce0a017e2a00e89738891c72eb8038ef1f, thanks for the report!