summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKiritoDv <kiritodev01@gmail.com>2024-11-03 11:17:04 -0600
committerKiritoDv <kiritodev01@gmail.com>2024-11-03 11:17:04 -0600
commit40ffb3d0b49f9ef948ee6bb5f2794eb2e4d97787 (patch)
treef44f310a3855d9f9ae1c9daf72d62f585af331cb /src
parent6393690103b49b5ecbc44bc5bf53355d050a54a0 (diff)
Code cleanup
Diffstat (limited to 'src')
-rw-r--r--src/audio/audio_heap.c11
-rw-r--r--src/audio/audio_load.c14
-rw-r--r--src/audio/audio_synthesis.c2
-rw-r--r--src/audio/audio_thread.c10
-rw-r--r--src/buffers.c2
-rw-r--r--src/port/Engine.h6
-rw-r--r--src/sys/sys_main.c2
7 files changed, 22 insertions, 25 deletions
diff --git a/src/audio/audio_heap.c b/src/audio/audio_heap.c
index 0ae951de..1e15902b 100644
--- a/src/audio/audio_heap.c
+++ b/src/audio/audio_heap.c
@@ -148,7 +148,6 @@ void* AudioHeap_Alloc(AudioAllocPool* pool, u32 size) {
void AudioHeap_InitPool(AudioAllocPool* pool, void* ramAddr, u32 size) {
pool->curRamAddr = pool->startRamAddr = (u8*) ramAddr;
- size *= 4;
pool->size = size - ((uintptr_t) ramAddr & 0xF);
pool->numEntries = 0;
}
@@ -657,9 +656,9 @@ void AudioHeap_Init(void) {
gAudioBufferParams.minAiBufferLength = gAudioBufferParams.samplesPerFrameTarget - 0x10;
gAudioBufferParams.maxAiBufferLength = gAudioBufferParams.samplesPerFrameTarget + 0x10;
- gAudioBufferParams.ticksPerUpdate = ((gAudioBufferParams.samplesPerFrameTarget + 0x10) / 0xD0) + 1;
+ gAudioBufferParams.ticksPerUpdate = ((gAudioBufferParams.samplesPerFrameTarget + 0x10) / 192);
gAudioBufferParams.samplesPerTick =
- (gAudioBufferParams.samplesPerFrameTarget / gAudioBufferParams.ticksPerUpdate) & ~7;
+ (gAudioBufferParams.samplesPerFrameTarget / (gAudioBufferParams.ticksPerUpdate + 1)) & ~7;
gAudioBufferParams.samplesPerTickMax = gAudioBufferParams.samplesPerTick + 8;
gAudioBufferParams.samplesPerTickMin = gAudioBufferParams.samplesPerTick - 8;
gAudioBufferParams.resampleRate = 32000.0f / (s32) gAudioBufferParams.samplingFrequency;
@@ -673,9 +672,9 @@ void AudioHeap_Init(void) {
gAudioBufferParams.maxAiBufferLength *= gAudioBufferParams.count;
gAudioBufferParams.minAiBufferLength *= gAudioBufferParams.count;
gAudioBufferParams.ticksPerUpdate *= gAudioBufferParams.count;
-// if (gAudioBufferParams.count >= 2) {
-// gAudioBufferParams.maxAiBufferLength -= 0x10;
-// }
+ if (gAudioBufferParams.count >= 2) {
+ gAudioBufferParams.maxAiBufferLength -= 0x10;
+ }
gMaxAudioCmds = (gNumNotes * 20 * gAudioBufferParams.ticksPerUpdate) + (spec->numReverbs * 32) + 480;
persistentSize = spec->persistentSeqCacheSize + spec->persistentFontCacheSize +
spec->persistentSampleBankCacheSize + spec->persistentSampleCacheSize + 0x10;
diff --git a/src/audio/audio_load.c b/src/audio/audio_load.c
index ef464289..860ccfd9 100644
--- a/src/audio/audio_load.c
+++ b/src/audio/audio_load.c
@@ -238,7 +238,7 @@ void* AudioLoad_SyncLoadSeqFonts(s32 seqId, u32* outFontId) {
s32 fontId = 0xFF;
s32 numFonts = gSeqFontTable[index++];
void* soundFontData;
-
+
for (numFonts; numFonts > 0; numFonts--) {
fontId = gSeqFontTable[index++];
soundFontData = AudioLoad_SyncLoadFont(fontId);
@@ -489,7 +489,7 @@ void* AudioLoad_SyncLoadFont(s32 fontId) {
}
if (didAllocate == 1) {
- AudioLoad_RelocateFontAndPreloadSamples(fontId, fontData, &relocInfo, AUDIOLOAD_SYNC);
+ AudioLoad_RelocateFontAndPreloadSamples(fontId, fontData, &relocInfo, AUDIOLOAD_SYNC);
}
return fontData;
@@ -608,8 +608,7 @@ void AudioLoad_RelocateFont(s32 fontId, uintptr_t fontBaseAddr, SampleBankRelocI
printf("fontId: %d\n", fontId);
SoundFont* font = Audio_LoadFont(table->entries[fontId]);
- gSoundFontList[fontId].drums = font->drums;
- gSoundFontList[fontId].instruments = font->instruments;
+ gSoundFontList[fontId] = *font;
}
void AudioLoad_SyncDma(uintptr_t devAddr, u8* ramAddr, u32 size, s32 medium) {
@@ -1262,7 +1261,6 @@ s32 AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, uintptr_t fontDataAddr,
s32 inProgress;
isAsync = 0;
-// printf("Relocating font %d\n", fontId);
inProgress = false;
if (gPreloadSampleStackTop != 0) {
inProgress = true;
@@ -1276,9 +1274,9 @@ s32 AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, uintptr_t fontDataAddr,
size = 0;
-// for (i = 0; i < gNumUsedSamples; i++) {
-// size += ALIGN16(gUsedSamples[i]->size);
-// }
+ for (i = 0; i < gNumUsedSamples; i++) {
+ size += ALIGN16(gUsedSamples[i]->size);
+ }
for (i = 0; i < gNumUsedSamples; i++) {
if (gPreloadSampleStackTop == 120) {
diff --git a/src/audio/audio_synthesis.c b/src/audio/audio_synthesis.c
index f7fb4d0f..e9a7d99d 100644
--- a/src/audio/audio_synthesis.c
+++ b/src/audio/audio_synthesis.c
@@ -644,7 +644,7 @@ Acmd* func_80009B64(Acmd* aList, s32* cmdCount, s16* aiBufStart, s32 aiBufLen) {
}
aiBufPtr = (s32*) aiBufStart;
- for (i = gAudioBufferParams.ticksPerUpdate - 1; i > 0; i--) {
+ for (i = gAudioBufferParams.ticksPerUpdate; i > 0; i--) {
if (i == 1) {
chunkLen = aiBufLen;
} else if ((aiBufLen / i) >= gAudioBufferParams.samplesPerTickMax) {
diff --git a/src/audio/audio_thread.c b/src/audio/audio_thread.c
index 5ad07a87..406f3fb6 100644
--- a/src/audio/audio_thread.c
+++ b/src/audio/audio_thread.c
@@ -10,11 +10,11 @@ OSMesgQueue sAudioTaskStartQueue;
OSMesgQueue sThreadCmdProcQueue;
OSMesgQueue sAudioSpecQueue;
OSMesgQueue sAudioResetQueue;
-AudioCmd gThreadCmdBuffer[1024];
-OSMesg sAudioTaskStartMsg[200];
-OSMesg sThreadCmdProcMsg[200];
-OSMesg sAudioSpecMsg[200];
-OSMesg sAudioResetMsg[200];
+AudioCmd gThreadCmdBuffer[256];
+OSMesg sAudioTaskStartMsg[1];
+OSMesg sThreadCmdProcMsg[4];
+OSMesg sAudioSpecMsg[1];
+OSMesg sAudioResetMsg[1];
u8 gThreadCmdWritePos = 0;
u8 gThreadCmdReadPos = 0;
diff --git a/src/buffers.c b/src/buffers.c
index c989a3f2..2c55c737 100644
--- a/src/buffers.c
+++ b/src/buffers.c
@@ -3,7 +3,7 @@
u8 gOSYieldData[OS_YIELD_DATA_SIZE];
FrameBuffer gZBuffer; // z buffer
u8 gTaskOutputBuffer[0x30000];
-u8 gAudioHeap[0xB0000 * 2];
+u8 gAudioHeap[0xB0000];
u16 gTextureRenderBuffer[0x3C40];
u16 gFillBuffer[3 * SCREEN_WIDTH];
FrameBuffer gFrameBuffers[3];
diff --git a/src/port/Engine.h b/src/port/Engine.h
index d914dba0..e222330d 100644
--- a/src/port/Engine.h
+++ b/src/port/Engine.h
@@ -15,11 +15,11 @@ struct GamePool {
#include <Fast3D/gfx_pc.h>
#include "libultraship/src/Context.h"
-#define SAMPLES_HIGH 752
-#define SAMPLES_LOW 720
+#define SAMPLES_HIGH 544
+#define SAMPLES_LOW 528
#define AUDIO_FRAMES_PER_UPDATE 2
#define NUM_AUDIO_CHANNELS 2
-#define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 3)
+#define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 2)
class GameEngine {
public:
diff --git a/src/sys/sys_main.c b/src/sys/sys_main.c
index 9082a9c5..dbe173a4 100644
--- a/src/sys/sys_main.c
+++ b/src/sys/sys_main.c
@@ -22,7 +22,7 @@ OSMesg sSerialEventBuff[1];
OSMesgQueue gMainThreadMesgQueue;
OSMesg sMainThreadMsgBuff[32];
OSMesgQueue gTaskMesgQueue;
-OSMesg sTaskMsgBuff[128];
+OSMesg sTaskMsgBuff[16];
OSMesgQueue gAudioVImesgQueue;
OSMesg sAudioVImsgBuff[1];
OSMesgQueue gAudioTaskMesgQueue;