From 47364e47691f6aa04ad51a11652518e4685391c1 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 21 Jan 2016 19:43:40 -0800 Subject: [PATCH] GB Video: Implement LYC --- src/gb/video.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gb/video.c b/src/gb/video.c index bc2e47360..62f9d56ca 100644 --- a/src/gb/video.c +++ b/src/gb/video.c @@ -88,13 +88,17 @@ int32_t GBVideoProcessEvents(struct GBVideo* video, int32_t cycles) { case 0: ++video->ly; video->p->memory.io[REG_LY] = video->ly; + int lyc = video->p->memory.io[REG_LYC]; + video->stat = GBRegisterSTATSetLYC(video->stat, lyc == video->ly); + if (GBRegisterSTATIsLYCIRQ(video->stat) && lyc == video->ly) { + video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); + } if (video->ly < GB_VIDEO_VERTICAL_PIXELS) { video->renderer->drawScanline(video->renderer, video->ly); video->nextMode = GB_VIDEO_MODE_2_LENGTH; video->mode = 2; if (GBRegisterSTATIsOAMIRQ(video->stat)) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); - GBUpdateIRQs(video->p); } } else { video->nextMode = GB_VIDEO_HORIZONTAL_LENGTH; @@ -105,8 +109,8 @@ int32_t GBVideoProcessEvents(struct GBVideo* video, int32_t cycles) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); } video->p->memory.io[REG_IF] |= (1 << GB_IRQ_VBLANK); - GBUpdateIRQs(video->p); } + GBUpdateIRQs(video->p); break; case 1: ++video->ly;