GB: Skip BIOS option now works

This commit is contained in:
Vicki Pfau 2018-01-08 08:39:26 -08:00
parent 20506226c9
commit caea7e0700
5 changed files with 103 additions and 78 deletions

View File

@ -50,6 +50,7 @@ Misc:
- GBA: Improve multiboot image detection - GBA: Improve multiboot image detection
- GB MBC: Remove erroneous bank 0 wrapping - GB MBC: Remove erroneous bank 0 wrapping
- GBA Cheats: Allow multiple ROM patches in the same slot - GBA Cheats: Allow multiple ROM patches in the same slot
- GB: Skip BIOS option now works
0.6.1: (2017-10-01) 0.6.1: (2017-10-01)
Bugfixes: Bugfixes:

View File

@ -145,6 +145,8 @@ void GBCreate(struct GB* gb);
void GBDestroy(struct GB* gb); void GBDestroy(struct GB* gb);
void GBReset(struct LR35902Core* cpu); void GBReset(struct LR35902Core* cpu);
void GBSkipBIOS(struct GB* gb);
void GBUnmapBIOS(struct GB* gb);
void GBDetectModel(struct GB* gb); void GBDetectModel(struct GB* gb);
void GBUpdateIRQs(struct GB* gb); void GBUpdateIRQs(struct GB* gb);

View File

@ -451,6 +451,10 @@ static void _GBCoreReset(struct mCore* core) {
#endif #endif
LR35902Reset(core->cpu); LR35902Reset(core->cpu);
if (core->opts.skipBios) {
GBSkipBIOS(core->board);
}
} }
static void _GBCoreRunFrame(struct mCore* core) { static void _GBCoreRunFrame(struct mCore* core) {

View File

@ -435,84 +435,11 @@ void GBReset(struct LR35902Core* cpu) {
cpu->d = 0; cpu->d = 0;
gb->timer.internalDiv = 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->cpuBlocked = false;
gb->earlyExit = false; gb->earlyExit = false;
gb->doubleSpeed = 0; gb->doubleSpeed = 0;
cpu->memory.setActiveRegion(cpu, cpu->pc);
if (gb->yankedRomSize) { if (gb->yankedRomSize) {
gb->memory.romSize = gb->yankedRomSize; gb->memory.romSize = gb->yankedRomSize;
gb->yankedRomSize = 0; gb->yankedRomSize = 0;
@ -527,15 +454,109 @@ void GBReset(struct LR35902Core* cpu) {
GBMemoryReset(gb); GBMemoryReset(gb);
GBVideoReset(&gb->video); GBVideoReset(&gb->video);
GBTimerReset(&gb->timer); 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); GBIOReset(gb);
GBAudioReset(&gb->audio); GBAudioReset(&gb->audio);
GBSIOReset(&gb->sio); GBSIOReset(&gb->sio);
cpu->memory.setActiveRegion(cpu, cpu->pc);
GBSavedataUnmask(gb); 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) { void GBDetectModel(struct GB* gb) {
if (gb->model != GB_MODEL_AUTODETECT) { if (gb->model != GB_MODEL_AUTODETECT) {
return; return;

View File

@ -420,10 +420,7 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) {
value = gb->video.stat; value = gb->video.stat;
break; break;
case 0x50: case 0x50:
if (gb->memory.romBase < gb->memory.rom || gb->memory.romBase > &gb->memory.rom[gb->memory.romSize - 1]) { GBUnmapBIOS(gb);
free(gb->memory.romBase);
gb->memory.romBase = gb->memory.rom;
}
if (gb->model >= GB_MODEL_CGB && gb->memory.io[REG_UNK4C] < 0x80) { if (gb->model >= GB_MODEL_CGB && gb->memory.io[REG_UNK4C] < 0x80) {
gb->model = GB_MODEL_DMG; gb->model = GB_MODEL_DMG;
GBVideoDisableCGB(&gb->video); GBVideoDisableCGB(&gb->video);