diff --git a/src/apu.c b/src/apu.c index 0f4517e..92e40b0 100644 --- 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 index ae4e8b5..f077b17 100644 --- 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 index 1e533d4..6811b41 100644 --- 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);