all repos — mgba @ 69a0372133bc1f7b806a23ecf89f8fb9c12f00c1

mGBA Game Boy Advance Emulator

GBA: Trim non-movie ROMs to 32 MiB if applicable
Vicki Pfau vi@endrift.com
Fri, 17 Jan 2020 20:44:00 -0800
commit

69a0372133bc1f7b806a23ecf89f8fb9c12f00c1

parent

c0fa8256a2003941fdb9d23ca4ced1c8d2074a75

2 files changed, 21 insertions(+), 3 deletions(-)

jump to
M CHANGESCHANGES

@@ -118,6 +118,7 @@ - Wii: Fix game fast-forwarding after slowing down

- Wii: Improve audio buffering (fixes mgba.io/i/1617) Misc: - GB Memory: Support manual SRAM editing (fixes mgba.io/i/1580) + - GBA: Trim non-movie ROMs to 32 MiB if applicable - GBA Audio: Redo channel 4 batching for GBA only - GBA I/O: Stop logging several harmless invalid register reads - Debugger: Separate aliases from main commands
M src/gba/gba.csrc/gba/gba.c

@@ -238,8 +238,16 @@ gba->idleDetectionFailures = 0;

gba->debug = false; memset(gba->debugString, 0, sizeof(gba->debugString)); - if (gba->pristineRomSize > SIZE_CART0) { - GBAMatrixReset(gba); + + + if (gba->romVf && gba->pristineRomSize > SIZE_CART0) { + char ident; + gba->romVf->seek(gba->romVf, 0xAC, SEEK_SET); + gba->romVf->read(gba->romVf, &ident, 1); + gba->romVf->seek(gba->romVf, 0, SEEK_SET); + if (ident == 'M') { + GBAMatrixReset(gba); + } } }

@@ -376,12 +384,21 @@ gba->pristineRomSize = vf->size(vf);

vf->seek(vf, 0, SEEK_SET); if (gba->pristineRomSize > SIZE_CART0) { gba->isPristine = false; - gba->memory.romSize = 0x01000000; #ifdef FIXED_ROM_BUFFER gba->memory.rom = romBuffer; #else gba->memory.rom = anonymousMemoryMap(SIZE_CART0); #endif + char ident; + vf->seek(vf, 0xAC, SEEK_SET); + vf->read(vf, &ident, 1); + vf->seek(vf, 0, SEEK_SET); + if (ident == 'M') { + gba->memory.romSize = 0x01000000; + } else { + gba->memory.romSize = SIZE_CART0; + vf->read(vf, gba->memory.rom, SIZE_CART0); + } } else { gba->isPristine = true; gba->memory.rom = vf->map(vf, gba->pristineRomSize, MAP_READ);