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
- 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:

View File

@ -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);

View File

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

View File

@ -435,8 +435,44 @@ void GBReset(struct LR35902Core* cpu) {
cpu->d = 0;
gb->timer.internalDiv = 0;
int nextDiv = 0;
gb->cpuBlocked = false;
gb->earlyExit = false;
gb->doubleSpeed = 0;
if (gb->yankedRomSize) {
gb->memory.romSize = gb->yankedRomSize;
gb->yankedRomSize = 0;
}
gb->sgbBit = -1;
gb->currentSgbBits = 0;
memset(gb->sgbPacket, 0, sizeof(gb->sgbPacket));
mTimingClear(&gb->timing);
GBMemoryReset(gb);
GBVideoReset(&gb->video);
GBTimerReset(&gb->timer);
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;
@ -505,35 +541,20 @@ void GBReset(struct LR35902Core* cpu) {
cpu->sp = 0xFFFE;
cpu->pc = 0x100;
mTimingDeschedule(&gb->timing, &gb->timer.event);
mTimingSchedule(&gb->timing, &gb->timer.event, 0);
if (gb->biosVf) {
GBUnmapBIOS(gb);
}
}
gb->cpuBlocked = false;
gb->earlyExit = false;
gb->doubleSpeed = 0;
cpu->memory.setActiveRegion(cpu, cpu->pc);
if (gb->yankedRomSize) {
gb->memory.romSize = gb->yankedRomSize;
gb->yankedRomSize = 0;
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;
}
gb->sgbBit = -1;
gb->currentSgbBits = 0;
memset(gb->sgbPacket, 0, sizeof(gb->sgbPacket));
mTimingClear(&gb->timing);
GBMemoryReset(gb);
GBVideoReset(&gb->video);
GBTimerReset(&gb->timer);
mTimingSchedule(&gb->timing, &gb->timer.event, nextDiv);
GBIOReset(gb);
GBAudioReset(&gb->audio);
GBSIOReset(&gb->sio);
GBSavedataUnmask(gb);
}
void GBDetectModel(struct GB* gb) {

View File

@ -420,10 +420,7 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t 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);