GBA: Trim non-movie ROMs to 32 MiB if applicable

This commit is contained in:
Vicki Pfau 2020-01-17 20:44:00 -08:00
parent c0fa8256a2
commit 69a0372133
2 changed files with 21 additions and 3 deletions

View File

@ -118,6 +118,7 @@ Other fixes:
- 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

View File

@ -238,8 +238,16 @@ void GBAReset(struct ARMCore* cpu) {
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 @@ bool GBALoadROM(struct GBA* gba, struct VFile* 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);