From fc69cdce60f9aee4782e1b21d75fd7b6c2dfa19b Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 23 Sep 2016 23:11:11 -0700 Subject: [PATCH] GBA Video: Clean up unused timers --- CHANGES | 1 + src/gba/video.c | 26 +------------------------- src/gba/video.h | 4 ---- 3 files changed, 2 insertions(+), 29 deletions(-) diff --git a/CHANGES b/CHANGES index 6d328eb92..c4339e5a9 100644 --- a/CHANGES +++ b/CHANGES @@ -29,6 +29,7 @@ Misc: - SDL: Remove scancode key input - GB Video: Improved video timings - All: Split out install locations for Libretro and OpenEmu + - GBA Video: Clean up unused timers 0.5.0: (2016-09-19) Features: diff --git a/src/gba/video.c b/src/gba/video.c index 95e9e8209..8facba880 100644 --- a/src/gba/video.c +++ b/src/gba/video.c @@ -81,10 +81,6 @@ void GBAVideoReset(struct GBAVideo* video) { video->nextEvent = video->nextHblank; video->eventDiff = 0; - video->nextHblankIRQ = 0; - video->nextVblankIRQ = 0; - video->nextVcounterIRQ = 0; - video->frameCounter = 0; video->frameskipCounter = 0; @@ -122,8 +118,6 @@ int32_t GBAVideoProcessEvents(struct GBAVideo* video, int32_t cycles) { if (video->nextEvent <= 0) { int32_t lastEvent = video->nextEvent; video->nextHblank -= video->eventDiff; - video->nextHblankIRQ -= video->eventDiff; - video->nextVcounterIRQ -= video->eventDiff; video->eventDiff = 0; uint16_t dispstat = video->p->memory.io[REG_DISPSTAT >> 1]; @@ -142,7 +136,6 @@ int32_t GBAVideoProcessEvents(struct GBAVideo* video, int32_t cycles) { dispstat = GBARegisterDISPSTATFillVcounter(dispstat); if (GBARegisterDISPSTATIsVcounterIRQ(dispstat)) { GBARaiseIRQ(video->p, IRQ_VCOUNTER); - video->nextVcounterIRQ += VIDEO_TOTAL_LENGTH; } } else { dispstat = GBARegisterDISPSTATClearVcounter(dispstat); @@ -159,7 +152,6 @@ int32_t GBAVideoProcessEvents(struct GBAVideo* video, int32_t cycles) { if (video->frameskipCounter <= 0) { video->renderer->finishFrame(video->renderer); } - video->nextVblankIRQ = video->nextEvent + VIDEO_TOTAL_LENGTH; GBAMemoryRunVblankDMAs(video->p, lastEvent); if (GBARegisterDISPSTATIsVblankIRQ(dispstat)) { GBARaiseIRQ(video->p, IRQ_VBLANK); @@ -181,7 +173,6 @@ int32_t GBAVideoProcessEvents(struct GBAVideo* video, int32_t cycles) { dispstat = GBARegisterDISPSTATFillInHblank(dispstat); video->nextEvent = video->nextHblank + VIDEO_HBLANK_LENGTH; video->nextHblank = video->nextEvent + VIDEO_HDRAW_LENGTH; - video->nextHblankIRQ = video->nextHblank; if (video->vcount < VIDEO_VERTICAL_PIXELS && video->frameskipCounter <= 0) { video->renderer->drawScanline(video->renderer, video->vcount); @@ -202,16 +193,7 @@ int32_t GBAVideoProcessEvents(struct GBAVideo* video, int32_t cycles) { void GBAVideoWriteDISPSTAT(struct GBAVideo* video, uint16_t value) { video->p->memory.io[REG_DISPSTAT >> 1] &= 0x7; video->p->memory.io[REG_DISPSTAT >> 1] |= value; - - uint16_t dispstat = video->p->memory.io[REG_DISPSTAT >> 1]; - - if (GBARegisterDISPSTATIsVcounterIRQ(dispstat)) { - // FIXME: this can be too late if we're in the middle of an Hblank - video->nextVcounterIRQ = video->nextHblank + VIDEO_HBLANK_LENGTH + (GBARegisterDISPSTATGetVcountSetting(dispstat) - video->vcount) * VIDEO_HORIZONTAL_LENGTH; - if (video->nextVcounterIRQ < video->nextEvent) { - video->nextVcounterIRQ += VIDEO_TOTAL_LENGTH; - } - } + // TODO: Does a VCounter IRQ trigger on write? } static void GBAVideoDummyRendererInit(struct GBAVideoRenderer* renderer) { @@ -317,9 +299,6 @@ void GBAVideoSerialize(const struct GBAVideo* video, struct GBASerializedState* STORE_32(video->nextEvent, 0, &state->video.nextEvent); STORE_32(video->eventDiff, 0, &state->video.eventDiff); STORE_32(video->nextHblank, 0, &state->video.nextHblank); - STORE_32(video->nextHblankIRQ, 0, &state->video.nextHblankIRQ); - STORE_32(video->nextVblankIRQ, 0, &state->video.nextVblankIRQ); - STORE_32(video->nextVcounterIRQ, 0, &state->video.nextVcounterIRQ); STORE_32(video->frameCounter, 0, &state->video.frameCounter); } @@ -338,9 +317,6 @@ void GBAVideoDeserialize(struct GBAVideo* video, const struct GBASerializedState LOAD_32(video->nextEvent, 0, &state->video.nextEvent); LOAD_32(video->eventDiff, 0, &state->video.eventDiff); LOAD_32(video->nextHblank, 0, &state->video.nextHblank); - LOAD_32(video->nextHblankIRQ, 0, &state->video.nextHblankIRQ); - LOAD_32(video->nextVblankIRQ, 0, &state->video.nextVblankIRQ); - LOAD_32(video->nextVcounterIRQ, 0, &state->video.nextVcounterIRQ); LOAD_32(video->frameCounter, 0, &state->video.frameCounter); LOAD_16(video->vcount, REG_VCOUNT, state->io); video->renderer->reset(video->renderer); diff --git a/src/gba/video.h b/src/gba/video.h index ec73800d9..886b2af69 100644 --- a/src/gba/video.h +++ b/src/gba/video.h @@ -187,10 +187,6 @@ struct GBAVideo { int32_t nextEvent; int32_t eventDiff; - int32_t nextHblankIRQ; - int32_t nextVblankIRQ; - int32_t nextVcounterIRQ; - uint16_t palette[SIZE_PALETTE_RAM >> 1]; uint16_t* vram; union GBAOAM oam;