Skip to content

Commit

Permalink
Improve ISX compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
LIJI32 committed Oct 3, 2024
1 parent 6eeba2f commit e13048d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Core/gb.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,12 @@ int GB_load_isx(GB_gameboy_t *gb, const char *path)

READ(address);
address = LE16(address);
address &= 0x3FFF;
if (bank) {
address &= 0x3FFF;
}
else {
address &= 0x7FFF;
}

READ(length);
length = LE16(length);
Expand Down Expand Up @@ -710,6 +715,17 @@ done:;
}
}

// Inject a correct checksum, the official linker doesn't always fix it, which breaks the official boot ROMs
uint8_t original_checksum = gb->rom[0x14d];
gb->rom[0x14d] = 0;
for (unsigned addr = 0x0134; addr <= 0x014C; addr++) {
gb->rom[0x14d] -= gb->rom[addr] + 1;
}

if (original_checksum != gb->rom[0x14d]) {
GB_log(gb, "This ROM's header checksum has been automatically corrected\n");
}

if (old_rom) {
free(old_rom);
}
Expand Down

0 comments on commit e13048d

Please sign in to comment.