all repos — mgba @ caea7e070015060014409ce804e1851f4983f800

mGBA Game Boy Advance Emulator

GB: Skip BIOS option now works
Vicki Pfau vi@endrift.com
Mon, 08 Jan 2018 08:39:26 -0800
commit

caea7e070015060014409ce804e1851f4983f800

parent

20506226c9f73791bf4070ae2fcb63e4ee18dec9

5 files changed, 103 insertions(+), 78 deletions(-)

jump to
M CHANGESCHANGES

@@ -50,6 +50,7 @@ - Qt: Add option to disable FPS display

- GBA: Improve multiboot image detection - GB MBC: Remove erroneous bank 0 wrapping - GBA Cheats: Allow multiple ROM patches in the same slot + - GB: Skip BIOS option now works 0.6.1: (2017-10-01) Bugfixes:
M include/mgba/internal/gb/gb.hinclude/mgba/internal/gb/gb.h

@@ -145,6 +145,8 @@ void GBCreate(struct GB* gb);

void GBDestroy(struct GB* gb); void GBReset(struct LR35902Core* cpu); +void GBSkipBIOS(struct GB* gb); +void GBUnmapBIOS(struct GB* gb); void GBDetectModel(struct GB* gb); void GBUpdateIRQs(struct GB* gb);
M src/gb/core.csrc/gb/core.c

@@ -451,6 +451,10 @@ }

#endif LR35902Reset(core->cpu); + + if (core->opts.skipBios) { + GBSkipBIOS(core->board); + } } static void _GBCoreRunFrame(struct mCore* core) {
M src/gb/gb.csrc/gb/gb.c

@@ -435,83 +435,10 @@ cpu->b = 0;

cpu->d = 0; gb->timer.internalDiv = 0; - int nextDiv = 0; - if (!gb->biosVf) { - switch (gb->model) { - case GB_MODEL_AUTODETECT: // Silence warnings - gb->model = GB_MODEL_DMG; - case GB_MODEL_DMG: - cpu->a = 1; - cpu->f.packed = 0xB0; - cpu->c = 0x13; - cpu->e = 0xD8; - cpu->h = 1; - cpu->l = 0x4D; - gb->timer.internalDiv = 0xABC; - nextDiv = 4; - break; - case GB_MODEL_SGB: - cpu->a = 1; - cpu->f.packed = 0x00; - cpu->c = 0x14; - cpu->e = 0x00; - cpu->h = 0xC0; - cpu->l = 0x60; - gb->timer.internalDiv = 0xABC; - nextDiv = 4; - break; - case GB_MODEL_MGB: - cpu->a = 0xFF; - cpu->f.packed = 0xB0; - cpu->c = 0x13; - cpu->e = 0xD8; - cpu->h = 1; - cpu->l = 0x4D; - gb->timer.internalDiv = 0xABC; - nextDiv = 4; - break; - case GB_MODEL_SGB2: - cpu->a = 0xFF; - cpu->f.packed = 0x00; - cpu->c = 0x14; - cpu->e = 0x00; - cpu->h = 0xC0; - cpu->l = 0x60; - gb->timer.internalDiv = 0xABC; - nextDiv = 4; - break; - case GB_MODEL_AGB: - cpu->a = 0x11; - cpu->b = 1; - cpu->f.packed = 0x00; - cpu->c = 0; - cpu->e = 0x08; - cpu->h = 0; - cpu->l = 0x7C; - gb->timer.internalDiv = 0x1EA; - nextDiv = 0xC; - break; - case GB_MODEL_CGB: - cpu->a = 0x11; - cpu->f.packed = 0x80; - cpu->c = 0; - cpu->e = 0x08; - cpu->h = 0; - cpu->l = 0x7C; - gb->timer.internalDiv = 0x1EA; - nextDiv = 0xC; - break; - } - - cpu->sp = 0xFFFE; - cpu->pc = 0x100; - } gb->cpuBlocked = false; gb->earlyExit = false; gb->doubleSpeed = 0; - - cpu->memory.setActiveRegion(cpu, cpu->pc); if (gb->yankedRomSize) { gb->memory.romSize = gb->yankedRomSize;

@@ -527,13 +454,107 @@

GBMemoryReset(gb); GBVideoReset(&gb->video); GBTimerReset(&gb->timer); - mTimingSchedule(&gb->timing, &gb->timer.event, nextDiv); + if (!gb->biosVf) { + GBSkipBIOS(gb); + } else { + mTimingSchedule(&gb->timing, &gb->timer.event, 0); + } GBIOReset(gb); GBAudioReset(&gb->audio); GBSIOReset(&gb->sio); + cpu->memory.setActiveRegion(cpu, cpu->pc); + GBSavedataUnmask(gb); +} + +void GBSkipBIOS(struct GB* gb) { + struct LR35902Core* cpu = gb->cpu; + int nextDiv = 0; + + switch (gb->model) { + case GB_MODEL_AUTODETECT: // Silence warnings + gb->model = GB_MODEL_DMG; + case GB_MODEL_DMG: + cpu->a = 1; + cpu->f.packed = 0xB0; + cpu->c = 0x13; + cpu->e = 0xD8; + cpu->h = 1; + cpu->l = 0x4D; + gb->timer.internalDiv = 0xABC; + nextDiv = 4; + break; + case GB_MODEL_SGB: + cpu->a = 1; + cpu->f.packed = 0x00; + cpu->c = 0x14; + cpu->e = 0x00; + cpu->h = 0xC0; + cpu->l = 0x60; + gb->timer.internalDiv = 0xABC; + nextDiv = 4; + break; + case GB_MODEL_MGB: + cpu->a = 0xFF; + cpu->f.packed = 0xB0; + cpu->c = 0x13; + cpu->e = 0xD8; + cpu->h = 1; + cpu->l = 0x4D; + gb->timer.internalDiv = 0xABC; + nextDiv = 4; + break; + case GB_MODEL_SGB2: + cpu->a = 0xFF; + cpu->f.packed = 0x00; + cpu->c = 0x14; + cpu->e = 0x00; + cpu->h = 0xC0; + cpu->l = 0x60; + gb->timer.internalDiv = 0xABC; + nextDiv = 4; + break; + case GB_MODEL_AGB: + cpu->a = 0x11; + cpu->b = 1; + cpu->f.packed = 0x00; + cpu->c = 0; + cpu->e = 0x08; + cpu->h = 0; + cpu->l = 0x7C; + gb->timer.internalDiv = 0x1EA; + nextDiv = 0xC; + break; + case GB_MODEL_CGB: + cpu->a = 0x11; + cpu->f.packed = 0x80; + cpu->c = 0; + cpu->e = 0x08; + cpu->h = 0; + cpu->l = 0x7C; + gb->timer.internalDiv = 0x1EA; + nextDiv = 0xC; + break; + } + + cpu->sp = 0xFFFE; + cpu->pc = 0x100; + + mTimingDeschedule(&gb->timing, &gb->timer.event); + mTimingSchedule(&gb->timing, &gb->timer.event, 0); + + if (gb->biosVf) { + GBUnmapBIOS(gb); + } +} + +void GBUnmapBIOS(struct GB* gb) { + if (gb->memory.romBase < gb->memory.rom || gb->memory.romBase > &gb->memory.rom[gb->memory.romSize - 1]) { + free(gb->memory.romBase); + gb->memory.romBase = gb->memory.rom; + } } void GBDetectModel(struct GB* gb) {
M src/gb/io.csrc/gb/io.c

@@ -420,10 +420,7 @@ GBVideoWriteSTAT(&gb->video, value);

value = gb->video.stat; break; case 0x50: - if (gb->memory.romBase < gb->memory.rom || gb->memory.romBase > &gb->memory.rom[gb->memory.romSize - 1]) { - free(gb->memory.romBase); - gb->memory.romBase = gb->memory.rom; - } + GBUnmapBIOS(gb); if (gb->model >= GB_MODEL_CGB && gb->memory.io[REG_UNK4C] < 0x80) { gb->model = GB_MODEL_DMG; GBVideoDisableCGB(&gb->video);