diff --git a/src/gb/audio.c b/src/gb/audio.c index f16f909b4..b26850b3a 100644 --- a/src/gb/audio.c +++ b/src/gb/audio.c @@ -56,6 +56,7 @@ void GBAudioReset(struct GBAudio* audio) { 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 @@ void GBAudioReset(struct GBAudio* audio) { 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; diff --git a/src/gb/memory.c b/src/gb/memory.c index 1e82efbf6..6fe4144cc 100644 --- a/src/gb/memory.c +++ b/src/gb/memory.c @@ -56,16 +56,6 @@ void GBMemoryInit(struct GB* gb) { 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 @@ void GBMemoryReset(struct GB* gb) { 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) { diff --git a/src/gb/timer.c b/src/gb/timer.c index f9a05beeb..881632205 100644 --- a/src/gb/timer.c +++ b/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) { diff --git a/src/gb/video.c b/src/gb/video.c index e9a0758c4..cb06dce48 100644 --- a/src/gb/video.c +++ b/src/gb/video.c @@ -62,6 +62,7 @@ void GBVideoReset(struct GBVideo* video) { 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);