diff --git a/src/gba/gba-io.c b/src/gba/gba-io.c index 59c2ec678..217ee8c25 100644 --- a/src/gba/gba-io.c +++ b/src/gba/gba-io.c @@ -355,10 +355,6 @@ void GBAIOWrite32(struct GBA* gba, uint32_t address, uint32_t value) { uint16_t GBAIORead(struct GBA* gba, uint32_t address) { switch (address) { - case REG_DISPSTAT: - return gba->memory.io[REG_DISPSTAT >> 1] | GBAVideoReadDISPSTAT(&gba->video); - break; - case REG_TM0CNT_LO: GBATimerUpdateRegister(gba, 0); break; @@ -390,6 +386,7 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) { // Write-only register return 0; case REG_DISPCNT: + case REG_DISPSTAT: case REG_VCOUNT: case REG_BG0CNT: case REG_BG1CNT: diff --git a/src/gba/gba-video.c b/src/gba/gba-video.c index 3fd89e7cc..63bc9a304 100644 --- a/src/gba/gba-video.c +++ b/src/gba/gba-video.c @@ -134,6 +134,8 @@ int32_t GBAVideoProcessEvents(struct GBAVideo* video, int32_t cycles) { video->eventDiff = 0; } + video->p->memory.io[REG_DISPSTAT >> 1] &= 0xFFF8; + video->p->memory.io[REG_DISPSTAT >> 1] |= (video->inVblank) | (video->inHblank << 1) | (video->vcounter << 2); return video->nextEvent; } @@ -154,10 +156,6 @@ void GBAVideoWriteDISPSTAT(struct GBAVideo* video, uint16_t value) { } } -uint16_t GBAVideoReadDISPSTAT(struct GBAVideo* video) { - return (video->inVblank) | (video->inHblank << 1) | (video->vcounter << 2); -} - static void GBAVideoDummyRendererInit(struct GBAVideoRenderer* renderer) { (void)(renderer); // Nothing to do diff --git a/src/gba/gba-video.h b/src/gba/gba-video.h index d75bc9f6c..1bd752128 100644 --- a/src/gba/gba-video.h +++ b/src/gba/gba-video.h @@ -218,7 +218,6 @@ void GBAVideoAssociateRenderer(struct GBAVideo* video, struct GBAVideoRenderer* int32_t GBAVideoProcessEvents(struct GBAVideo* video, int32_t cycles); void GBAVideoWriteDISPSTAT(struct GBAVideo* video, uint16_t value); -uint16_t GBAVideoReadDISPSTAT(struct GBAVideo* video); struct GBASerializedState; void GBAVideoSerialize(struct GBAVideo* video, struct GBASerializedState* state);