all repos — mgba @ 1cb054ec67ea7b1e7e9162c1e74bd4ab254efb74

mGBA Game Boy Advance Emulator

GB Video: Setting LYC=LY during mode 2 should trigger an IRQ
Jeffrey Pfau jeffrey@endrift.com
Tue, 20 Sep 2016 10:44:49 -0700
commit

1cb054ec67ea7b1e7e9162c1e74bd4ab254efb74

parent

575a37fd832f457b3ac6684e37f79928dcf9da9f

4 files changed, 15 insertions(+), 1 deletions(-)

jump to
M CHANGESCHANGES

@@ -1,6 +1,7 @@

0.6.0: (Future) Bugfixes: - GB MBC: Fix MBC7 when size is incorrectly specified + - GB Video: Setting LYC=LY during mode 2 should trigger an IRQ Misc: - All: Only update version info if needed
M src/gb/io.csrc/gb/io.c

@@ -341,7 +341,6 @@ case REG_JOYP:

case REG_SB: case REG_TIMA: case REG_TMA: - case REG_LYC: // Handled transparently by the registers break; case REG_TAC:

@@ -356,6 +355,9 @@ // TODO: handle GBC differences

GBVideoProcessDots(&gb->video); value = gb->video.renderer->writeVideoRegister(gb->video.renderer, address, value); GBVideoWriteLCDC(&gb->video, value); + break; + case REG_LYC: + GBVideoWriteLYC(&gb->video, value); break; case REG_DMA: GBMemoryDMA(gb, value << 8);
M src/gb/video.csrc/gb/video.c

@@ -312,6 +312,16 @@ GBUpdateIRQs(video->p);

} } +void GBVideoWriteLYC(struct GBVideo* video, uint8_t value) { + if (video->mode == 2) { + video->stat = GBRegisterSTATSetLYC(video->stat, value == video->ly); + if (GBRegisterSTATIsLYCIRQ(video->stat) && value == video->ly) { + video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); + GBUpdateIRQs(video->p); + } + } +} + void GBVideoWritePalette(struct GBVideo* video, uint16_t address, uint8_t value) { static const uint16_t dmgPalette[4] = { 0x7FFF, 0x56B5, 0x294A, 0x0000}; if (video->p->model < GB_MODEL_CGB) {
M src/gb/video.hsrc/gb/video.h

@@ -135,6 +135,7 @@ void GBVideoProcessDots(struct GBVideo* video);

void GBVideoWriteLCDC(struct GBVideo* video, GBRegisterLCDC value); void GBVideoWriteSTAT(struct GBVideo* video, GBRegisterSTAT value); +void GBVideoWriteLYC(struct GBVideo* video, uint8_t value); void GBVideoWritePalette(struct GBVideo* video, uint16_t address, uint8_t value); void GBVideoSwitchBank(struct GBVideo* video, uint8_t value);