Code cleanup

This commit is contained in:
KiritoDv 2024-11-03 11:17:04 -06:00
parent 6393690103
commit 40ffb3d0b4
8 changed files with 23 additions and 26 deletions

View file

@ -134,7 +134,7 @@ extern OSMesg sSerialEventBuff[1];
extern OSMesgQueue gMainThreadMesgQueue;
extern OSMesg sMainThreadMsgBuff[32];
extern OSMesgQueue gTaskMesgQueue;
extern OSMesg sTaskMsgBuff[128];
extern OSMesg sTaskMsgBuff[16];
extern OSMesgQueue gAudioVImesgQueue;
extern OSMesg sAudioVImsgBuff[1];
extern OSMesgQueue gAudioTaskMesgQueue;

View file

@ -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;

View file

@ -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) {

View file

@ -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) {

View file

@ -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;

View file

@ -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];

View file

@ -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:

View file

@ -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;