From a9c8f4e5ef71611349dc8ff165163de8419f831b Mon Sep 17 00:00:00 2001 From: wgroeneveld Date: Tue, 7 Aug 2018 09:35:53 +0200 Subject: [PATCH] pointer address ipv dereferenced value --- src/engine/gba_engine.cpp | 8 ++++---- src/engine/gba_engine.h | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/engine/gba_engine.cpp b/src/engine/gba_engine.cpp index 9db2b3e..acc78ba 100644 --- a/src/engine/gba_engine.cpp +++ b/src/engine/gba_engine.cpp @@ -8,7 +8,7 @@ #include "allocator.h" int x = 0; -void onvblank() { +void GBAEngine::onVBlank() { REG_IME = 0; unsigned short tempInterruptState = REG_IF; @@ -82,8 +82,8 @@ void GBAEngine::queueSound(const s8 *data, int totalSamples, int sampleRate, Sou REG_SNDDSCNT |= control.ControlFlags; // output to both sides, reset fifo REG_SNDSTAT = SSTAT_ENABLE; // enable all sound - *(control.DMASourceAddress) = (u32) data; - *(control.DMADestinationAddress) = *(control.FiFoBuffer); + *(control.DMASourceAddress) = (u32) data; // WARNING - these are pointers to the address! + *(control.DMADestinationAddress) = (u32) control.FiFoBuffer; *(control.DMAControl) = DMA_DST_FIXED | DMA_REPEAT | DMA_32 | DMA_SYNC_TO_TIMER | DMA_ENABLE; u16 ticksPerSample = CLOCK / sampleRate; // divide the clock (ticks/second) by the sample rate (samples/second) @@ -101,7 +101,7 @@ GBAEngine::GBAEngine() { // setup interrupt control flags for vblank IRQing REG_DISPSTAT |= DISPLAY_INTERRUPT_VBLANK_ENABLE; REG_IE |= INTERRUPT_VBLANK; - *IRQ_CALLBACK = (u32) &onvblank; + *IRQ_CALLBACK = (u32) &GBAEngine::onVBlank; //REG_IME = 1; REG_SNDDSCNT = 0; diff --git a/src/engine/gba_engine.h b/src/engine/gba_engine.h index 4ae69c3..d9cf89b 100644 --- a/src/engine/gba_engine.h +++ b/src/engine/gba_engine.h @@ -33,8 +33,6 @@ struct SoundControl { u16 ControlFlags; }; -void onvblank(); - class GBAEngine { private: // WHY raw pointers? the engine does the transition and cleanup work itself @@ -56,6 +54,7 @@ private: void cleanupPreviousScene(); void queueSound(const s8* data, int totalSamples, int sampleRate, SoundControl control); + static void onVBlank(); public: GBAEngine();