Update DMA timings, and higher priority DMAs always take precedence, regardless of timing

This commit is contained in:
Jeffrey Pfau 2014-01-28 21:56:14 -08:00
parent d5bd521313
commit a72c77a3df
1 changed files with 5 additions and 5 deletions

View File

@ -647,10 +647,10 @@ void GBAMemoryRunHblankDMAs(struct GBAMemory* memory, int32_t cycles) {
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
dma = &memory->dma[i]; dma = &memory->dma[i];
if (dma->enable && dma->timing == DMA_TIMING_HBLANK) { if (dma->enable && dma->timing == DMA_TIMING_HBLANK) {
dma->nextEvent = memory->p->cpu.cycles; dma->nextEvent = cycles;
} }
} }
GBAMemoryUpdateDMAs(memory, -cycles); GBAMemoryUpdateDMAs(memory, 0);
} }
void GBAMemoryRunVblankDMAs(struct GBAMemory* memory, int32_t cycles) { void GBAMemoryRunVblankDMAs(struct GBAMemory* memory, int32_t cycles) {
@ -659,10 +659,10 @@ void GBAMemoryRunVblankDMAs(struct GBAMemory* memory, int32_t cycles) {
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
dma = &memory->dma[i]; dma = &memory->dma[i];
if (dma->enable && dma->timing == DMA_TIMING_VBLANK) { if (dma->enable && dma->timing == DMA_TIMING_VBLANK) {
dma->nextEvent = memory->p->cpu.cycles; dma->nextEvent = cycles;
} }
} }
GBAMemoryUpdateDMAs(memory, -cycles); GBAMemoryUpdateDMAs(memory, 0);
} }
int32_t GBAMemoryRunDMAs(struct GBAMemory* memory, int32_t cycles) { int32_t GBAMemoryRunDMAs(struct GBAMemory* memory, int32_t cycles) {
@ -688,7 +688,7 @@ void GBAMemoryUpdateDMAs(struct GBAMemory* memory, int32_t cycles) {
struct GBADMA* dma = &memory->dma[i]; struct GBADMA* dma = &memory->dma[i];
if (dma->nextEvent != INT_MAX) { if (dma->nextEvent != INT_MAX) {
dma->nextEvent -= cycles; dma->nextEvent -= cycles;
if (dma->enable && memory->nextDMA >= dma->nextEvent) { if (dma->enable) {
memory->activeDMA = i; memory->activeDMA = i;
memory->nextDMA = dma->nextEvent; memory->nextDMA = dma->nextEvent;
} }