all repos — mgba @ ae71a7ec19ebb539a4b9c950b4102d29f7642924

mGBA Game Boy Advance Emulator

GBA: Cap out the ROM loaded size
Jeffrey Pfau jeffrey@endrift.com
Wed, 10 Dec 2014 01:44:22 -0800
commit

ae71a7ec19ebb539a4b9c950b4102d29f7642924

parent

3d5e0f29fa3050e11dfe9db6411c88ca85f9ab5a

1 files changed, 4 insertions(+), 1 deletions(-)

jump to
M src/gba/gba.csrc/gba/gba.c

@@ -424,7 +424,10 @@ void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char* fname) {

gba->romVf = vf; gba->pristineRomSize = vf->seek(vf, 0, SEEK_END); vf->seek(vf, 0, SEEK_SET); - gba->pristineRom = vf->map(vf, SIZE_CART0, MAP_READ); + if (gba->pristineRomSize > SIZE_CART0) { + gba->pristineRomSize = SIZE_CART0; + } + gba->pristineRom = vf->map(vf, gba->pristineRomSize, MAP_READ); gba->memory.rom = gba->pristineRom; gba->activeFile = fname; gba->memory.romSize = gba->pristineRomSize;