diff --git a/src/audio/audio_heap.c b/src/audio/audio_heap.c index e85f195f..0f8f75bd 100644 --- a/src/audio/audio_heap.c +++ b/src/audio/audio_heap.c @@ -558,6 +558,8 @@ void AudioHeap_ClearCurrentAiBuffer(void) { } } +extern s16 audio_buffer[]; + s32 AudioHeap_ResetStep(void) { s32 i; s32 j; @@ -597,11 +599,7 @@ s32 AudioHeap_ResetStep(void) { gResetFadeoutFramesLeft--; AudioHeap_UpdateReverbs(); } else { - for (i = 0; i < 3; i++) { - for (j = 0; j < AIBUF_LEN; j++) { - gAiBuffers[i][j] = 0; - } - } + memset(audio_buffer, 0, (1056 * 2 * 3) * 2 * 2); gResetFadeoutFramesLeft = 4 / sp24; gAudioResetStep--; break; // needed to match @@ -619,12 +617,7 @@ s32 AudioHeap_ResetStep(void) { case 1: AudioHeap_Init(); gAudioResetStep = 0; - for (i = 0; i < 3; i++) { - gAiBuffLengths[i] = gAudioBufferParams.maxAiBufferLength; - for (j = 0; j < AIBUF_LEN; j++) { - gAiBuffers[i][j] = 0; - } - } + memset(audio_buffer, 0, (1056 * 2 * 3) * 2 * 2); break; } if (gAudioResetStep < 3) { diff --git a/src/audio/mixer.c b/src/audio/mixer.c index b677c267..6d2d4fb6 100644 --- a/src/audio/mixer.c +++ b/src/audio/mixer.c @@ -16,10 +16,9 @@ #define ROUND_DOWN_16(v) ((v) & ~0xf) //#define DMEM_BUF_SIZE (0x1000 - 0x0330 - 0x10 - 0x40) -//#define DMEM_BUF_SIZE (0x1000 - 0x450 - 0x40) -#define DMEM_BUF_SIZE 0xC90 -#define BUF_U8(a) (rspa.buf.as_u8 + ((a)-0x450)) -#define BUF_S16(a) (rspa.buf.as_s16 + ((a)-0x450) / sizeof(int16_t)) +#define DMEM_BUF_SIZE 0xC80 +#define BUF_U8(a) (rspa.buf.as_u8 + ((a)-0x0330)) +#define BUF_S16(a) (rspa.buf.as_s16 + ((a)-0x0330) / sizeof(int16_t)) static struct { uint16_t in; @@ -133,7 +132,7 @@ void aInterleaveImpl(uint16_t dest, uint16_t left, uint16_t right, uint16_t c) { return; } - int count = ROUND_UP_32(rspa.nbytes) >> 3; + int count = ROUND_UP_16(rspa.nbytes) >> 2; int16_t *l = BUF_S16(left); int16_t *r = BUF_S16(right); diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 4c254c97..572d42ec 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -68,7 +68,7 @@ GameEngine::GameEngine() { } this->context = - Ship::Context::CreateInstance("Starship", "ship", "starship.cfg.json", OTRFiles, {}, 3, { 44100, 1024, 2480 }); + Ship::Context::CreateInstance("Starship", "ship", "starship.cfg.json", OTRFiles, {}, 3, { 44100, 1056, 1056 * 2 }); auto loader = context->GetResourceManager()->GetResourceLoader(); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, @@ -150,10 +150,11 @@ void GameEngine::StartFrame() const { } #define SAMPLES_HIGH 1056 -#define SAMPLES_LOW 890 +#define SAMPLES_LOW 880 #define NUM_AUDIO_CHANNELS 2 #define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 3) +extern "C" s16 audio_buffer[SAMPLES_PER_FRAME * 2 * 2] = { 0 }; extern "C" s32 audBuffer = 0;