From 9ac6f6d3bfe2566c2e5960f5f9b6167d8e0a4ae9 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 16 Apr 2013 07:18:25 -0700 Subject: [PATCH] Start implementing IRQ --- src/gba/gba-video.c | 8 +++++--- src/gba/gba.c | 4 ++++ src/gba/gba.h | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/gba/gba-video.c b/src/gba/gba-video.c index c94e81d16..1b49bf4d2 100644 --- a/src/gba/gba-video.c +++ b/src/gba/gba-video.c @@ -1,5 +1,7 @@ #include "gba-video.h" +#include "gba.h" + #include static void GBAVideoDummyRendererInit(struct GBAVideoRenderer* renderer); @@ -61,7 +63,7 @@ int32_t GBAVideoProcessEvents(struct GBAVideo* video, int32_t cycles) { video->nextVblankIRQ = video->nextEvent + VIDEO_TOTAL_LENGTH; //video->cpu.mmu.runVblankDmas(); if (video->vblankIRQ) { - //video->cpu.irq.raiseIRQ(video->cpu.irq.IRQ_VBLANK); + GBARaiseIRQ(video->p, IRQ_VBLANK); } //video->vblankCallback(); break; @@ -76,7 +78,7 @@ int32_t GBAVideoProcessEvents(struct GBAVideo* video, int32_t cycles) { video->vcounter = video->vcount == video->vcountSetting; if (video->vcounter && video->vcounterIRQ) { - //video->cpu.irq.raiseIRQ(video->cpu.irq.IRQ_VCOUNTER); + GBARaiseIRQ(video->p, IRQ_VCOUNTER); video->nextVcounterIRQ += VIDEO_TOTAL_LENGTH; } @@ -95,7 +97,7 @@ int32_t GBAVideoProcessEvents(struct GBAVideo* video, int32_t cycles) { //video->cpu.mmu.runHblankDmas(); } if (video->hblankIRQ) { - //video->cpu.irq.raiseIRQ(video->cpu.irq.IRQ_HBLANK); + GBARaiseIRQ(video->p, IRQ_HBLANK); } } diff --git a/src/gba/gba.c b/src/gba/gba.c index 1294ca33a..c63692112 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -86,6 +86,10 @@ void GBALoadROM(struct GBA* gba, int fd) { // TODO: error check } +void GBARaiseIRQ(struct GBA* gba, enum GBAIRQ irq) { + GBALog(GBA_LOG_STUB, "Attempting to raise IRQ"); +} + void GBALog(int level, const char* format, ...) { va_list args; va_start(args, format); diff --git a/src/gba/gba.h b/src/gba/gba.h index 896d909cd..7f5dbeede 100644 --- a/src/gba/gba.h +++ b/src/gba/gba.h @@ -6,6 +6,23 @@ #include "gba-memory.h" #include "gba-video.h" +enum GBAIRQ { + IRQ_VBLANK = 0x0, + IRQ_HBLANK = 0x1, + IRQ_VCOUNTER = 0x2, + IRQ_TIMER0 = 0x3, + IRQ_TIMER1 = 0x4, + IRQ_TIMER2 = 0x5, + IRQ_TIMER3 = 0x6, + IRQ_SIO = 0x7, + IRQ_DMA0 = 0x8, + IRQ_DMA1 = 0x9, + IRQ_DMA2 = 0xA, + IRQ_DMA3 = 0xB, + IRQ_KEYPAD = 0xC, + IRQ_GAMEPAK = 0xD +}; + enum GBAError { GBA_NO_ERROR = 0, GBA_OUT_OF_MEMORY = -1 @@ -41,6 +58,8 @@ void GBAMemoryDeinit(struct GBAMemory* memory); void GBABoardInit(struct GBABoard* board); void GBABoardReset(struct ARMBoard* board); +void GBARaiseIRQ(struct GBA* gba, enum GBAIRQ irq); + void GBAAttachDebugger(struct GBA* gba, struct ARMDebugger* debugger); void GBALoadROM(struct GBA* gba, int fd);