GB: Improve reset reliability
Jeffrey Pfau jeffrey@endrift.com
Fri, 19 Feb 2016 22:59:36 -0800
4 files changed,
27 insertions(+),
11 deletions(-)
M
src/gb/audio.c
→
src/gb/audio.c
@@ -56,6 +56,7 @@ audio->nextEvent = 0;
audio->nextCh1 = 0; audio->nextCh2 = 0; audio->nextCh3 = 0; + audio->fadeCh3 = 0; audio->nextCh4 = 0; audio->ch1 = (struct GBAudioChannel1) { .envelope = { .dead = 2 } }; audio->ch2 = (struct GBAudioChannel2) { .envelope = { .dead = 2 } };@@ -66,6 +67,9 @@ audio->nextFrame = 0;
audio->frame = 0; audio->nextSample = 0; audio->sampleInterval = 128; + audio->lastLeft = 0; + audio->lastRight = 0; + audio->clock = 0; audio->volumeRight = 0; audio->volumeLeft = 0; audio->ch1Right = false;
M
src/gb/memory.c
→
src/gb/memory.c
@@ -56,16 +56,6 @@ gb->memory.sram = 0;
gb->memory.mbcType = GB_MBC_NONE; gb->memory.mbc = 0; - gb->memory.dmaNext = INT_MAX; - gb->memory.dmaRemaining = 0; - gb->memory.hdmaNext = INT_MAX; - gb->memory.hdmaRemaining = 0; - - memset(gb->memory.hram, 0, sizeof(gb->memory.hram)); - - gb->memory.sramAccess = false; - gb->memory.rtcAccess = false; - gb->memory.rtcLatched = 0; gb->memory.rtc = NULL; GBIOInit(gb);@@ -89,7 +79,26 @@ gb->memory.currentBank = 1;
gb->memory.sramCurrentBank = 0; gb->memory.sramBank = gb->memory.sram; - memset(&gb->video.oam, 0, sizeof(gb->video.oam)); + gb->memory.ime = false; + gb->memory.ie = 0; + + gb->memory.dmaNext = INT_MAX; + gb->memory.dmaRemaining = 0; + gb->memory.dmaSource = 0; + gb->memory.dmaDest = 0; + gb->memory.hdmaNext = INT_MAX; + gb->memory.hdmaRemaining = 0; + gb->memory.hdmaSource = 0; + gb->memory.hdmaDest = 0; + gb->memory.isHdma = false; + + gb->memory.sramAccess = false; + gb->memory.rtcAccess = false; + gb->memory.activeRtcReg = 0; + gb->memory.rtcLatched = 0; + memset(&gb->memory.rtcRegs, 0, sizeof(gb->memory.rtcRegs)); + + memset(&gb->memory.hram, 0, sizeof(gb->memory.hram)); const struct GBCartridge* cart = (const struct GBCartridge*) &gb->memory.rom[0x100]; switch (cart->type) {
M
src/gb/timer.c
→
src/gb/timer.c
@@ -12,6 +12,8 @@ void GBTimerReset(struct GBTimer* timer) {
timer->nextDiv = GB_DMG_DIV_PERIOD; // TODO: GBC differences timer->nextTima = INT_MAX; timer->nextEvent = GB_DMG_DIV_PERIOD; + timer->eventDiff = 0; + timer->timaPeriod = 1024; } int32_t GBTimerProcessEvents(struct GBTimer* timer, int32_t cycles) {
M
src/gb/video.c
→
src/gb/video.c
@@ -62,6 +62,7 @@ GBVideoSwitchBank(video, 0);
video->renderer->vram = video->vram; memset(&video->oam, 0, sizeof(video->oam)); video->renderer->oam = &video->oam; + memset(&video->palette, 0, sizeof(video->palette)); video->renderer->deinit(video->renderer); video->renderer->init(video->renderer, video->p->model);