GB Video: Add HDMA

This commit is contained in:
Jeffrey Pfau 2016-02-17 20:00:23 -08:00
parent 371f6913e7
commit 526a9ce446
2 changed files with 9 additions and 1 deletions

View File

@ -339,10 +339,14 @@ void _GBMemoryHDMAService(struct GB* gb) {
gb->cpu->cycles += 2;
if (gb->memory.hdmaRemaining) {
gb->memory.hdmaNext += 2;
} else {
if (gb->memory.isHdma) {
--gb->memory.io[REG_HDMA5];
} else {
gb->memory.io[REG_HDMA5] |= 0x80;
}
}
}
uint8_t GBDMALoad8(struct LR35902Core* cpu, uint16_t address) {
struct GB* gb = (struct GB*) cpu->master;

View File

@ -178,6 +178,10 @@ int32_t GBVideoProcessEvents(struct GBVideo* video, int32_t cycles) {
video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT);
GBUpdateIRQs(video->p);
}
if (video->ly < GB_VIDEO_VERTICAL_PIXELS && video->p->memory.isHdma && video->p->memory.io[REG_HDMA5] != 0xFF) {
video->p->memory.hdmaRemaining = 0x10;
video->p->memory.hdmaNext = video->p->cpu->cycles;
}
break;
}
video->stat = GBRegisterSTATSetMode(video->stat, video->mode);