diff --git a/src/gb/audio.c b/src/gb/audio.c index 6bf7dde84..63af6bc1a 100644 --- a/src/gb/audio.c +++ b/src/gb/audio.c @@ -936,7 +936,7 @@ static void _updateChannel4(struct mTiming* timing, void* user, uint32_t cyclesL uint32_t last = 0; uint32_t now = cycles; - uint32_t next = cycles - cyclesLate; + int32_t next = cycles - cyclesLate; if (audio->style == GB_AUDIO_GBA) { last = ch->lastEvent; diff --git a/src/gb/core.c b/src/gb/core.c index 3647a043b..11d3f11ed 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -508,7 +508,7 @@ static void _GBCoreReset(struct mCore* core) { bios = NULL; } } - if (bios) { + if (found && bios) { GBLoadBIOS(gb, bios); } } diff --git a/src/gb/video.c b/src/gb/video.c index 4757a69d7..0859b13c9 100644 --- a/src/gb/video.c +++ b/src/gb/video.c @@ -187,7 +187,7 @@ void GBVideoAssociateRenderer(struct GBVideo* video, struct GBVideoRenderer* ren video->renderer->init(video->renderer, video->p->model, video->sgbBorders); } -static bool _statIRQAsserted(struct GBVideo* video, GBRegisterSTAT stat) { +static bool _statIRQAsserted(GBRegisterSTAT stat) { // TODO: variable for the IRQ line value? if (GBRegisterSTATIsLYCIRQ(stat) && GBRegisterSTATIsLYC(stat)) { return true; @@ -236,20 +236,20 @@ void _endMode0(struct mTiming* timing, void* context, uint32_t cyclesLate) { mTimingDeschedule(&video->p->timing, &video->frameEvent); mTimingSchedule(&video->p->timing, &video->frameEvent, -cyclesLate); - if (!_statIRQAsserted(video, oldStat) && GBRegisterSTATIsOAMIRQ(video->stat)) { + if (!_statIRQAsserted(oldStat) && GBRegisterSTATIsOAMIRQ(video->stat)) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); } video->p->memory.io[REG_IF] |= (1 << GB_IRQ_VBLANK); } video->stat = GBRegisterSTATSetMode(video->stat, video->mode); - if (!_statIRQAsserted(video, oldStat) && _statIRQAsserted(video, video->stat)) { + if (!_statIRQAsserted(oldStat) && _statIRQAsserted(video->stat)) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); } // LYC stat is delayed 1 T-cycle oldStat = video->stat; video->stat = GBRegisterSTATSetLYC(video->stat, lyc == video->ly); - if (!_statIRQAsserted(video, oldStat) && _statIRQAsserted(video, video->stat)) { + if (!_statIRQAsserted(oldStat) && _statIRQAsserted(video->stat)) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); } @@ -287,7 +287,7 @@ void _endMode1(struct mTiming* timing, void* context, uint32_t cyclesLate) { GBRegisterSTAT oldStat = video->stat; video->stat = GBRegisterSTATSetMode(video->stat, video->mode); video->stat = GBRegisterSTATSetLYC(video->stat, lyc == video->p->memory.io[REG_LY]); - if (!_statIRQAsserted(video, oldStat) && _statIRQAsserted(video, video->stat)) { + if (!_statIRQAsserted(oldStat) && _statIRQAsserted(video->stat)) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); GBUpdateIRQs(video->p); } @@ -305,7 +305,7 @@ void _endMode2(struct mTiming* timing, void* context, uint32_t cyclesLate) { video->modeEvent.callback = _endMode3; GBRegisterSTAT oldStat = video->stat; video->stat = GBRegisterSTATSetMode(video->stat, video->mode); - if (!_statIRQAsserted(video, oldStat) && _statIRQAsserted(video, video->stat)) { + if (!_statIRQAsserted(oldStat) && _statIRQAsserted(video->stat)) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); GBUpdateIRQs(video->p); } @@ -326,7 +326,7 @@ void _endMode3(struct mTiming* timing, void* context, uint32_t cyclesLate) { video->modeEvent.callback = _endMode0; GBRegisterSTAT oldStat = video->stat; video->stat = GBRegisterSTATSetMode(video->stat, video->mode); - if (!_statIRQAsserted(video, oldStat) && _statIRQAsserted(video, video->stat)) { + if (!_statIRQAsserted(oldStat) && _statIRQAsserted(video->stat)) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); GBUpdateIRQs(video->p); } @@ -416,7 +416,7 @@ void GBVideoWriteLCDC(struct GBVideo* video, GBRegisterLCDC value) { GBRegisterSTAT oldStat = video->stat; video->stat = GBRegisterSTATSetMode(video->stat, 0); video->stat = GBRegisterSTATSetLYC(video->stat, video->ly == video->p->memory.io[REG_LYC]); - if (!_statIRQAsserted(video, oldStat) && _statIRQAsserted(video, video->stat)) { + if (!_statIRQAsserted(oldStat) && _statIRQAsserted(video->stat)) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); GBUpdateIRQs(video->p); } @@ -447,7 +447,7 @@ void GBVideoWriteSTAT(struct GBVideo* video, GBRegisterSTAT value) { if (!GBRegisterLCDCIsEnable(video->p->memory.io[REG_LCDC]) || video->p->model >= GB_MODEL_CGB) { return; } - if (!_statIRQAsserted(video, oldStat) && video->mode < 3) { + if (!_statIRQAsserted(oldStat) && video->mode < 3) { // TODO: variable for the IRQ line value? video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); GBUpdateIRQs(video->p); @@ -458,7 +458,7 @@ void GBVideoWriteLYC(struct GBVideo* video, uint8_t value) { GBRegisterSTAT oldStat = video->stat; if (GBRegisterLCDCIsEnable(video->p->memory.io[REG_LCDC])) { video->stat = GBRegisterSTATSetLYC(video->stat, value == video->ly); - if (!_statIRQAsserted(video, oldStat) && _statIRQAsserted(video, video->stat)) { + if (!_statIRQAsserted(oldStat) && _statIRQAsserted(video->stat)) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); GBUpdateIRQs(video->p); }