mirror of https://github.com/mgba-emu/mgba.git
GB: Improve reset reliability
This commit is contained in:
parent
0557caad98
commit
8071a52505
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue