commit 9df5bb924bfd9e24e168409be2d7917ed70cf8b1
parent f76f8cf6ef51248d7f3a88d87b419f7d4bc9b337
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date: Thu, 8 Apr 2021 21:22:27 +0100
Made devapu static to emulator.c
Diffstat:
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/apu.c b/src/apu.c
@@ -13,8 +13,6 @@ WITH REGARD TO THIS SOFTWARE.
#include "uxn.h"
#include "apu.h"
-extern Device *devapu;
-
static Uint32 note_advances[12] = {
0x82d01286 / (SAMPLE_FREQUENCY / 30), /* C7 */
0x8a976073 / (SAMPLE_FREQUENCY / 30),
@@ -47,7 +45,7 @@ render_note(Apu *apu, Uxn *u, int note_i, Sint16 *samples, int n_samples)
if(apu->queue->i == apu->queue->n) {
apu->queue->i = apu->queue->n = 0;
if(!apu->queue->finishes) {
- u->ram.dat[devapu->addr + 0xa] = note_i;
+ u->ram.dat[apu->channel_addr] = note_i;
evaluxn(u, wv->vector);
}
}
diff --git a/src/apu.h b/src/apu.h
@@ -40,6 +40,7 @@ typedef struct {
Queue *queue;
Note *notes;
int n_notes;
+ Uint16 channel_addr;
} Apu;
void apu_render(Apu *apu, Uxn *u, Sint16 *samples, int n_samples);
diff --git a/src/emulator.c b/src/emulator.c
@@ -25,8 +25,7 @@ static SDL_Renderer *gRenderer;
static SDL_Texture *gTexture;
static Ppu ppu;
static Apu apu;
-static Device *devsystem, *devscreen, *devmouse, *devkey, *devctrl;
-Device *devapu;
+static Device *devsystem, *devscreen, *devmouse, *devkey, *devctrl, *devapu;
#pragma mark - Helpers
@@ -421,6 +420,7 @@ main(int argc, char **argv)
devmouse = portuxn(&u, 0x06, "mouse", ppnil);
portuxn(&u, 0x07, "file", file_poke);
devapu = portuxn(&u, 0x08, "audio", audio_poke);
+ apu.channel_addr = devapu->addr + 0xa;
portuxn(&u, 0x09, "midi", ppnil);
portuxn(&u, 0x0a, "datetime", datetime_poke);
portuxn(&u, 0x0b, "---", ppnil);