mirror of
https://github.com/n64decomp/perfect_dark.git
synced 2024-12-12 08:26:11 +00:00
Replace a heap of literals, mostly in sound code
This commit is contained in:
parent
a780b5f179
commit
cef885db72
@ -208,7 +208,7 @@ struct fx {
|
||||
s16 unk00;
|
||||
s16 unk02;
|
||||
s32 unk04;
|
||||
s16 unk08[8];
|
||||
s16 unk08[16];
|
||||
};
|
||||
|
||||
typedef struct N_ALVoiceState_s {
|
||||
|
@ -33,8 +33,8 @@ void chrmgrReset(void)
|
||||
g_ChrIndexes = NULL;
|
||||
var80062960 = mempAlloc(ALIGN16(15 * sizeof(struct var80062960)), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < 20; i++) {
|
||||
var8009ccc0[i] = (void *)ALIGN64(mempAlloc(0x240, MEMPOOL_STAGE));
|
||||
for (i = 0; i < ARRAYCOUNT(var8009ccc0); i++) {
|
||||
var8009ccc0[i] = (void *)ALIGN64(mempAlloc(16 * 16 * sizeof(u16) + 0x40, MEMPOOL_STAGE));
|
||||
}
|
||||
|
||||
resetSomeStageThings();
|
||||
@ -54,8 +54,8 @@ void chrmgrConfigure(s32 numchrs)
|
||||
}
|
||||
|
||||
g_NumChrs = 0;
|
||||
g_Chrnums = mempAlloc(ALIGN16(g_NumChrSlots * 2), MEMPOOL_STAGE);
|
||||
g_ChrIndexes = mempAlloc(ALIGN16(g_NumChrSlots * 2), MEMPOOL_STAGE);
|
||||
g_Chrnums = mempAlloc(ALIGN16(g_NumChrSlots * sizeof(g_Chrnums[0])), MEMPOOL_STAGE);
|
||||
g_ChrIndexes = mempAlloc(ALIGN16(g_NumChrSlots * sizeof(g_ChrIndexes[0])), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < g_NumChrSlots; i++) {
|
||||
g_Chrnums[i] = -1;
|
||||
|
@ -13,7 +13,7 @@ void coverAllocateSpecial(u16 *specialcovernums)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
g_SpecialCoverNums = mempAlloc(ALIGN16(g_NumSpecialCovers * sizeof(u16)), MEMPOOL_STAGE);
|
||||
g_SpecialCoverNums = mempAlloc(ALIGN16(g_NumSpecialCovers * sizeof(g_SpecialCoverNums[0])), MEMPOOL_STAGE);
|
||||
|
||||
if (g_SpecialCoverNums != NULL) {
|
||||
for (i = 0; i < g_NumSpecialCovers; i++) {
|
||||
@ -34,9 +34,9 @@ void setupPrepareCover(void)
|
||||
RoomNum inrooms[21];
|
||||
RoomNum aboverooms[21];
|
||||
|
||||
g_CoverFlags = mempAlloc(ALIGN16(numcovers * sizeof(u16)), MEMPOOL_STAGE);
|
||||
g_CoverRooms = mempAlloc(ALIGN16(numcovers * sizeof(s32)), MEMPOOL_STAGE);
|
||||
g_CoverCandidates = mempAlloc(ALIGN16(numcovers * 0x10), MEMPOOL_STAGE);
|
||||
g_CoverFlags = mempAlloc(ALIGN16(numcovers * sizeof(g_CoverFlags[0])), MEMPOOL_STAGE);
|
||||
g_CoverRooms = mempAlloc(ALIGN16(numcovers * sizeof(g_CoverRooms[0])), MEMPOOL_STAGE);
|
||||
g_CoverCandidates = mempAlloc(ALIGN16(numcovers * sizeof(g_CoverCandidates[0])), MEMPOOL_STAGE);
|
||||
|
||||
g_NumSpecialCovers = 0;
|
||||
g_SpecialCoverNums = NULL;
|
||||
|
@ -532,10 +532,10 @@ void titleInitPdLogo(void)
|
||||
|
||||
{
|
||||
struct coord coord = {0, 0, 0};
|
||||
g_ModelStates[MODEL_NLOGO].modeldef = modeldefLoad(g_ModelStates[MODEL_NLOGO].fileid, nextaddr, 0x47800, 0);
|
||||
g_ModelStates[MODEL_NLOGO].modeldef = modeldefLoad(g_ModelStates[MODEL_NLOGO].fileid, nextaddr, TITLE_ALLOCSIZE, 0);
|
||||
size = ALIGN64(fileGetLoadedSize(g_ModelStates[MODEL_NLOGO].fileid));
|
||||
nextaddr += size;
|
||||
remaining = 0x47800 - size;
|
||||
remaining = TITLE_ALLOCSIZE - size;
|
||||
modelAllocateRwData(g_ModelStates[MODEL_NLOGO].modeldef);
|
||||
|
||||
g_TitleModel = modelmgrInstantiateModelWithAnim(g_ModelStates[MODEL_NLOGO].modeldef);
|
||||
@ -1782,7 +1782,7 @@ void titleInitNintendoLogo(void)
|
||||
{
|
||||
struct coord coord = {0, 0, 0};
|
||||
|
||||
g_ModelStates[MODEL_NINTENDOLOGO].modeldef = modeldefLoad(g_ModelStates[MODEL_NINTENDOLOGO].fileid, nextaddr, 0x47800, 0);
|
||||
g_ModelStates[MODEL_NINTENDOLOGO].modeldef = modeldefLoad(g_ModelStates[MODEL_NINTENDOLOGO].fileid, nextaddr, TITLE_ALLOCSIZE, 0);
|
||||
|
||||
modelAllocateRwData(g_ModelStates[MODEL_NINTENDOLOGO].modeldef);
|
||||
g_TitleModel = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_NINTENDOLOGO].modeldef);
|
||||
@ -1941,7 +1941,7 @@ void titleInitRareLogo(void)
|
||||
{
|
||||
struct coord coord = {0, 0, 0};
|
||||
|
||||
g_ModelStates[MODEL_RARELOGO].modeldef = modeldefLoad(g_ModelStates[MODEL_RARELOGO].fileid, nextaddr, 0x47800, 0);
|
||||
g_ModelStates[MODEL_RARELOGO].modeldef = modeldefLoad(g_ModelStates[MODEL_RARELOGO].fileid, nextaddr, TITLE_ALLOCSIZE, 0);
|
||||
|
||||
modelAllocateRwData(g_ModelStates[MODEL_RARELOGO].modeldef);
|
||||
g_TitleModel = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_RARELOGO].modeldef);
|
||||
|
@ -21,7 +21,7 @@ void titleReset(void)
|
||||
g_TitleNextMode = TITLEMODE_SKIP;
|
||||
}
|
||||
|
||||
var8009cca0 = mempAlloc(0x47800, MEMPOOL_STAGE);
|
||||
var8009cca0 = mempAlloc(TITLE_ALLOCSIZE, MEMPOOL_STAGE);
|
||||
|
||||
getitleReset();
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "data.h"
|
||||
#include "types.h"
|
||||
|
||||
#define TITLE_ALLOCSIZE 1024 * 286
|
||||
|
||||
extern u32 var800624d4;
|
||||
extern u32 var800624d8;
|
||||
extern u32 var800624dc;
|
||||
|
@ -5788,7 +5788,6 @@ typedef struct AudioInfo_s {
|
||||
short *data; /* Output data pointer */
|
||||
short frameSamples; /* # of samples synthesized in this frame */
|
||||
OSScTask task; /* scheduler structure */
|
||||
AudioMsg msg; /* completion message */
|
||||
} AudioInfo;
|
||||
|
||||
typedef struct {
|
||||
@ -5896,12 +5895,7 @@ struct mp3vars {
|
||||
/*0x38*/ struct mp3thing *var8009c3c8;
|
||||
/*0x3c*/ s32 var8009c3cc;
|
||||
/*0x40*/ s32 var8009c3d0;
|
||||
|
||||
union {
|
||||
/*0x44*/ u32 *var8009c3d4;
|
||||
/*0x44*/ u32 *var8009c3d4_arr[1];
|
||||
};
|
||||
|
||||
/*0x44*/ u32 *var8009c3d4[1];
|
||||
/*0x48*/ u32 var8009c3d8;
|
||||
/*0x4c*/ void *var8009c3dc;
|
||||
/*0x50*/ u32 var8009c3e0;
|
||||
@ -5913,18 +5907,6 @@ struct mp3vars {
|
||||
/*0x61*/ u8 var8009c3f1;
|
||||
};
|
||||
|
||||
struct sndcache {
|
||||
/*0x0000*/ u16 *indexes; // indexed by sfxnum, value is cache index (0-44) or 0xffff
|
||||
/*0x0004*/ u8 refcounts[45];
|
||||
/*0x0032*/ u16 ages[45];
|
||||
/*0x008c*/ ALEnvelope envelopes[45];
|
||||
/*0x035c*/ ALKeyMap keymaps[45];
|
||||
/*0x046c*/ ALWaveTable wavetables[45];
|
||||
/*0x07f0*/ ALADPCMBook books[45];
|
||||
/*0x3658*/ ALADPCMloop loops[45];
|
||||
/*0x3e14*/ ALSound sounds[45];
|
||||
};
|
||||
|
||||
struct rdptask {
|
||||
OSScTask sctask;
|
||||
u16 *framebuffer;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <ultra64.h>
|
||||
#include "lib/boot.h"
|
||||
#include "lib/sched.h"
|
||||
#include "naudio/n_synthInternals.h"
|
||||
#include "constants.h"
|
||||
#include "bss.h"
|
||||
#include "lib/audiodma.h"
|
||||
@ -85,8 +86,8 @@ void amgrCreate(ALSynConfig *config)
|
||||
g_AmgrFreqPerTick++;
|
||||
}
|
||||
|
||||
g_AmgrFreqPerTick = g_AmgrFreqPerTick / 184 * 184 + 184;
|
||||
var800918dc = g_AmgrFreqPerTick - 184;
|
||||
g_AmgrFreqPerTick = g_AmgrFreqPerTick / SAMPLES * SAMPLES + SAMPLES;
|
||||
var800918dc = g_AmgrFreqPerTick - SAMPLES;
|
||||
var800918e4 = g_AmgrFreqPerTick + 80;
|
||||
var8005cf94 = 0;
|
||||
|
||||
@ -108,8 +109,7 @@ void amgrCreate(ALSynConfig *config)
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAYCOUNT(g_AudioManager.audioInfo); i++) {
|
||||
// @todo: Find out why AudioInfo is only 0x60
|
||||
g_AudioManager.audioInfo[i] = alHeapAlloc(&g_SndHeap, 1, 0x60);
|
||||
g_AudioManager.audioInfo[i] = alHeapAlloc(&g_SndHeap, 1, sizeof(AudioInfo));
|
||||
g_AudioManager.audioInfo[i]->frameSamples = 0;
|
||||
g_AudioManager.audioInfo[i]->data = alHeapAlloc(&g_SndHeap, 1, PAL ? 3688 : 1024 * 3);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include <ultra64.h>
|
||||
#include <n_libaudio.h>
|
||||
#include "naudio/n_abi.h"
|
||||
#include "ultra/audio/synthInternals.h"
|
||||
#include "naudio/n_synthInternals.h"
|
||||
#include "lib/mp3.h"
|
||||
#include "mp3/mp3.h"
|
||||
#include "types.h"
|
||||
@ -42,19 +44,18 @@ void mp3Init(ALHeap *heap)
|
||||
#endif
|
||||
|
||||
g_AsiStream = alHeapAlloc(heap, sizeof(struct asistream), 1);
|
||||
var8005f6f8 = alHeapAlloc(heap, 1, 0x2200);
|
||||
var8005f6fc = alHeapAlloc(heap, 1, 0x2200);
|
||||
var8005f6f8 = alHeapAlloc(heap, 1, 34 * 256 * sizeof(var8005f6f8[0]));
|
||||
var8005f6fc = alHeapAlloc(heap, 1, 34 * 256 * sizeof(var8005f6fc[0]));
|
||||
|
||||
var8009c6d8 = alHeapAlloc(heap, 256 * sizeof(f32), 1);
|
||||
var8009c6dc = alHeapAlloc(heap, 256 * sizeof(f32), 1);
|
||||
var8009c6d8 = alHeapAlloc(heap, 256 * sizeof(var8009c6d8[0]), 1);
|
||||
var8009c6dc = alHeapAlloc(heap, 256 * sizeof(var8009c6dc[0]), 1);
|
||||
var8009c640 = alHeapAlloc(heap, 10500 * sizeof(struct mp3decfourbytes), 1);
|
||||
var8009c644 = alHeapAlloc(heap, 8192 * sizeof(f32), 1);
|
||||
var8009c644 = alHeapAlloc(heap, 8192 * sizeof(var8009c644[0]), 1);
|
||||
|
||||
mp3mainInit();
|
||||
|
||||
g_Mp3Vars.var8009c398 = alHeapAlloc(heap, 1, 0x50);
|
||||
*(u8 **)((uintptr_t)&g_Mp3Vars+0x44) = alHeapAlloc(heap, 1, 0x440);
|
||||
|
||||
g_Mp3Vars.var8009c398 = alHeapAlloc(heap, 1, ALIGN16(sizeof(ALEnvMixer)));
|
||||
g_Mp3Vars.var8009c3d4[0] = alHeapAlloc(heap, 1, 0x440);
|
||||
g_Mp3Vars.var8009c3e0 = 0;
|
||||
g_Mp3Vars.var8009c3e4 = 0x7fff;
|
||||
g_Mp3Vars.var8009c3ec = g_Mp3Vars.var8009c3ee = 0x40;
|
||||
@ -169,8 +170,8 @@ s32 func00037fc0(s32 arg0, Acmd **cmd)
|
||||
struct mp3thing *sp58;
|
||||
struct mp3thing *sp54 = NULL;
|
||||
s32 sp50;
|
||||
s32 sp4c = 0x4e0;
|
||||
s32 sp48 = 0x650;
|
||||
s32 sp4c = N_AL_MAIN_L_OUT;
|
||||
s32 sp48 = N_AL_MAIN_R_OUT;
|
||||
|
||||
if (g_Mp3Vars.var8009c3ec != g_Mp3Vars.var8009c3ee) {
|
||||
sp60 = g_Mp3Vars.var8009c3ee - g_Mp3Vars.var8009c3ec;
|
||||
@ -201,7 +202,7 @@ s32 func00037fc0(s32 arg0, Acmd **cmd)
|
||||
g_Mp3Vars.var8009c3d0 = 0;
|
||||
g_Mp3Vars.var8009c3d8 = 0;
|
||||
|
||||
bzero(*(u32 **)&g_Mp3Vars.var8009c3d4, 0x440);
|
||||
bzero(g_Mp3Vars.var8009c3d4[0], 0x440);
|
||||
}
|
||||
} else {
|
||||
g_Mp3Vars.var8009c3f0--;
|
||||
@ -234,7 +235,7 @@ s32 func00037fc0(s32 arg0, Acmd **cmd)
|
||||
g_Mp3Vars.var8009c3c8 = sp58;
|
||||
|
||||
for (i = 0; i < sp5c; i++) {
|
||||
acmd08((*cmd)++, osVirtualToPhysical(g_Mp3Vars.var8009c3d4_arr[i]));
|
||||
acmd08((*cmd)++, osVirtualToPhysical(g_Mp3Vars.var8009c3d4[i]));
|
||||
acmd07((*cmd)++, g_Mp3Vars.var8009c3d8, osVirtualToPhysical(sp58));
|
||||
|
||||
sp58++;
|
||||
@ -283,7 +284,7 @@ s32 func00037fc0(s32 arg0, Acmd **cmd)
|
||||
func00038924(&g_Mp3Vars);
|
||||
|
||||
if (!g_Mp3Vars.var8009c3f1) {
|
||||
aClearBuffer((*cmd)++, 0x4e0, 0x2e0);
|
||||
aClearBuffer((*cmd)++, N_AL_MAIN_L_OUT, N_AL_TEMP_2);
|
||||
|
||||
if (g_Mp3Vars.var8009c3b4) {
|
||||
g_Mp3Vars.var8009c3b4 = 0;
|
||||
@ -302,7 +303,7 @@ s32 func00037fc0(s32 arg0, Acmd **cmd)
|
||||
n_aEnvMixer((*cmd)++, 0, 0, osVirtualToPhysical(g_Mp3Vars.var8009c398));
|
||||
}
|
||||
|
||||
g_Mp3Vars.samples += 184;
|
||||
g_Mp3Vars.samples += SAMPLES;
|
||||
|
||||
if (g_Mp3Vars.samples > g_Mp3Vars.var8009c3bc) {
|
||||
g_Mp3Vars.samples = g_Mp3Vars.var8009c3bc;
|
||||
@ -356,7 +357,7 @@ void func00038924(struct mp3vars *vars)
|
||||
}
|
||||
|
||||
vars->samples = 0;
|
||||
vars->var8009c3bc = (vars->var8009c3e8 + 183) / 184 * 184;
|
||||
vars->var8009c3bc = SAMPLE184(vars->var8009c3e8);
|
||||
vars->var8009c3b4 = 1;
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ ALMicroTime __n_CSPVoiceHandler(void *node)
|
||||
ALFxRef fx = func0003e5b8(seqp->nextEvent.msg.evt19.unk00);
|
||||
|
||||
if (fx) {
|
||||
func0003e674((struct fx *) fx, seqp->nextEvent.msg.evt19.unk01, &seqp->nextEvent.msg.evt19.param);
|
||||
func0003e674(fx, seqp->nextEvent.msg.evt19.unk01, &seqp->nextEvent.msg.evt19.param);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -175,11 +175,11 @@ void n_alFxNew(ALFx **fx_ar, ALSynConfig *c, s16 bus, ALHeap *hp)
|
||||
r->base[1] = alHeapAlloc(hp, r->length, sizeof(s16));
|
||||
r->input[1] = r->base[1];
|
||||
|
||||
for (k=0; k < r->length; k++) {
|
||||
for (k = 0; k < r->length; k++) {
|
||||
r->base[0][k] = r->base[1][k] = 0;
|
||||
}
|
||||
|
||||
for ( i=0; i<r->section_count; i++ ){
|
||||
for (i = 0; i < r->section_count; i++) {
|
||||
d = &r->delay[i];
|
||||
d->input = param[j++];
|
||||
d->output = param[j++];
|
||||
|
@ -32,15 +32,14 @@ Acmd *n_alMainBusPull(s32 sampleOffset, Acmd *p)
|
||||
aMix(ptr++, 0, 0x7fff, N_AL_AUX_L_OUT, N_AL_MAIN_L_OUT);
|
||||
}
|
||||
|
||||
if (n_syn->auxBus[i].unk44->unk02 > 0) {
|
||||
if (n_syn->auxBus[i].unk44->fx.unk02 > 0) {
|
||||
struct auxbus44 *bus44 = n_syn->auxBus[i].unk44;
|
||||
|
||||
if (bus44->unk28) {
|
||||
// @todo: Remove cast
|
||||
func0003ba64((struct fx *)bus44, n_syn->outputRate);
|
||||
func0003ba64(&bus44->fx, n_syn->outputRate);
|
||||
}
|
||||
|
||||
n_aLoadADPCM(ptr++, 32, osVirtualToPhysical(&bus44->unk08));
|
||||
n_aLoadADPCM(ptr++, 32, osVirtualToPhysical(&bus44->fx.unk08));
|
||||
|
||||
n_aPoleFilter(ptr++, 0, N_AL_MAIN_L_OUT, 0, osVirtualToPhysical(bus44->unk2c) & 0xffffff);
|
||||
n_aPoleFilter(ptr++, 0, N_AL_MAIN_R_OUT, 0, osVirtualToPhysical(bus44->unk30) & 0xffffff);
|
||||
|
@ -41,7 +41,7 @@ void n_alSndpNew(ALSndpConfig *config)
|
||||
g_SndPlayer->sndState = ptr;
|
||||
|
||||
// Init the event queue
|
||||
ptr = alHeapAlloc(config->heap, 1, config->maxEvents * 0x1c);
|
||||
ptr = alHeapAlloc(config->heap, 1, config->maxEvents * sizeof(N_ALEventListItem));
|
||||
n_alEvtqNew(&g_SndPlayer->evtq, ptr, config->maxEvents);
|
||||
|
||||
g_SndpFreeStatesHead = g_SndPlayer->sndState;
|
||||
|
@ -99,10 +99,6 @@ typedef struct N_PVoice_s {
|
||||
u8 unk8c;
|
||||
u16 unk8e;
|
||||
struct fx fx;
|
||||
s32 unka8;
|
||||
s32 unkac;
|
||||
s32 unkb0;
|
||||
s32 unkb4;
|
||||
s32 unkb8;
|
||||
void *unkbc; // size 8
|
||||
} N_PVoice;
|
||||
@ -123,25 +119,14 @@ typedef struct N_ALMainBus_s {
|
||||
N_ALFilter filter;
|
||||
} N_ALMainBus;
|
||||
|
||||
// Suspected to be the same as struct fx, but auxbus44 is too big to fit inside N_PVoice.
|
||||
// Maybe auxbus44 contains struct fx at unk00, then adds unk30 and unk34?
|
||||
struct auxbus44 {
|
||||
u16 unk00;
|
||||
s16 unk02;
|
||||
u32 unk04;
|
||||
u32 unk08;
|
||||
u32 unk0c;
|
||||
u32 unk10;
|
||||
u32 unk14;
|
||||
u32 unk18;
|
||||
u32 unk1c;
|
||||
u32 unk20;
|
||||
u32 unk24;
|
||||
struct fx fx;
|
||||
u32 unk28;
|
||||
void *unk2c; // size 8
|
||||
void *unk30; // size 8
|
||||
POLEF_STATE *unk2c;
|
||||
POLEF_STATE *unk30;
|
||||
u32 unk34;
|
||||
};
|
||||
|
||||
typedef struct N_ALAuxBus_s {
|
||||
ALFilter filter;
|
||||
s32 sourceCount;
|
||||
|
@ -36,18 +36,18 @@ void n_alSynNew(ALSynConfig *c)
|
||||
for (i = 0; i < n_syn->maxAuxBusses; i++) {
|
||||
n_syn->auxBus[i].sourceCount = 0;
|
||||
n_syn->auxBus[i].maxSources = c->maxPVoices;
|
||||
n_syn->auxBus[i].sources = alHeapAlloc(hp, c->maxPVoices, 4);
|
||||
n_syn->auxBus[i].sources = alHeapAlloc(hp, c->maxPVoices, sizeof(void *));
|
||||
|
||||
if (c->fxTypes[i]) {
|
||||
n_syn->auxBus[i].fx = n_alSynAllocFX(i, c, hp);
|
||||
} else {
|
||||
n_syn->auxBus[i].fx = 0;
|
||||
n_syn->auxBus[i].fx = NULL;
|
||||
}
|
||||
|
||||
n_syn->auxBus[i].unk44 = alHeapAlloc(hp, 1, sizeof(struct auxbus44));
|
||||
n_syn->auxBus[i].unk44->unk02 = 0;
|
||||
n_syn->auxBus[i].unk44->unk2c = alHeapAlloc(hp, 1, 8);
|
||||
n_syn->auxBus[i].unk44->unk30 = alHeapAlloc(hp, 1, 8);
|
||||
n_syn->auxBus[i].unk44->fx.unk02 = 0;
|
||||
n_syn->auxBus[i].unk44->unk2c = alHeapAlloc(hp, 1, sizeof(POLEF_STATE));
|
||||
n_syn->auxBus[i].unk44->unk30 = alHeapAlloc(hp, 1, sizeof(POLEF_STATE));
|
||||
}
|
||||
|
||||
/******* main new *******************************/
|
||||
|
@ -352,7 +352,7 @@ void __scHandleRetrace(OSSched *sc)
|
||||
schedRenderCrashPeriodically(sc->frameCount);
|
||||
}
|
||||
|
||||
extern struct sndcache g_SndCache;
|
||||
extern u8 g_SndCache;
|
||||
|
||||
/**
|
||||
* __scHandleTasks is called both on retrace and when the RDP completes a task.
|
||||
@ -411,7 +411,7 @@ void __scHandleTasks(OSSched *sc)
|
||||
}
|
||||
|
||||
if (checksum != CHECKSUM_PLACEHOLDER) {
|
||||
u8 *addr = (u8 *) &g_SndCache;
|
||||
u8 *addr = &g_SndCache;
|
||||
|
||||
for (i = 0; i < 40; i++) {
|
||||
addr[4 + i] = 0xff;
|
||||
|
@ -23,6 +23,24 @@
|
||||
#include "data.h"
|
||||
#include "types.h"
|
||||
|
||||
#define MAX_SEQ_SIZE_4MB 1024 * 14
|
||||
#define MAX_SEQ_SIZE_8MB 1024 * 18
|
||||
|
||||
#define NUM_CACHE_SLOTS 45
|
||||
#define NUM_KEYTHINGS 9
|
||||
|
||||
struct sndcache {
|
||||
/*0x0000*/ u16 *indexes; // indexed by sfxnum, value is cache index (0-44) or 0xffff
|
||||
/*0x0004*/ u8 refcounts[NUM_CACHE_SLOTS];
|
||||
/*0x0032*/ u16 ages[NUM_CACHE_SLOTS];
|
||||
/*0x008c*/ ALEnvelope envelopes[NUM_CACHE_SLOTS];
|
||||
/*0x035c*/ ALKeyMap keymaps[NUM_CACHE_SLOTS];
|
||||
/*0x046c*/ ALWaveTable wavetables[NUM_CACHE_SLOTS];
|
||||
/*0x07f0*/ ALADPCMBook books[NUM_CACHE_SLOTS];
|
||||
/*0x3658*/ ALADPCMloop loops[NUM_CACHE_SLOTS];
|
||||
/*0x3e14*/ ALSound sounds[NUM_CACHE_SLOTS];
|
||||
};
|
||||
|
||||
struct curmp3 {
|
||||
union soundnumhack sfxref;
|
||||
u32 playing;
|
||||
@ -882,7 +900,7 @@ void sndSetSfxVolume(u16 volume)
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 9; i++) {
|
||||
for (i = 0; i < NUM_KEYTHINGS; i++) {
|
||||
func00033f44(i, volume);
|
||||
}
|
||||
|
||||
@ -899,7 +917,7 @@ void snd0000ea80(u16 volume)
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 9; i++) {
|
||||
for (i = 0; i < NUM_KEYTHINGS; i++) {
|
||||
func00033f44(i, volume);
|
||||
}
|
||||
}
|
||||
@ -976,7 +994,7 @@ void sndLoadSfxCtl(void)
|
||||
g_SndCache.indexes[i] = -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < 45; i++) {
|
||||
for (i = 0; i < NUM_CACHE_SLOTS; i++) {
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
g_SndCache.ages[i] = 1;
|
||||
#else
|
||||
@ -992,7 +1010,7 @@ void sndIncrementAges(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < 45; i++) {
|
||||
for (i = 0; i < NUM_CACHE_SLOTS; i++) {
|
||||
if (g_SndCache.refcounts[i] == 0 && g_SndCache.ages[i] < 32000) {
|
||||
g_SndCache.ages[i]++;
|
||||
}
|
||||
@ -1314,7 +1332,7 @@ ALSound *sndLoadSound(s16 soundnum)
|
||||
oldestindex = -1;
|
||||
oldestage = 0;
|
||||
|
||||
for (i = 0; i < 45; i++) {
|
||||
for (i = 0; i < NUM_CACHE_SLOTS; i++) {
|
||||
if (g_SndCache.refcounts[i] == 0) {
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
if (g_SndCache.ages[i] > oldestage) {
|
||||
@ -1383,9 +1401,9 @@ void seqInit(struct seqinstance *seq)
|
||||
func00030c98(&config);
|
||||
|
||||
if (IS4MB()) {
|
||||
g_SeqBufferSize = 0x3800;
|
||||
g_SeqBufferSize = MAX_SEQ_SIZE_4MB;
|
||||
} else {
|
||||
g_SeqBufferSize = 0x4800;
|
||||
g_SeqBufferSize = MAX_SEQ_SIZE_8MB;
|
||||
}
|
||||
|
||||
seq->data = alHeapAlloc(&g_SndHeap, 1, g_SeqBufferSize);
|
||||
@ -1398,7 +1416,7 @@ void seqInit(struct seqinstance *seq)
|
||||
|
||||
void sndAddRef(ALSound *sound)
|
||||
{
|
||||
if (sound >= &g_SndCache.sounds[0] && sound <= &g_SndCache.sounds[44]) {
|
||||
if (sound >= &g_SndCache.sounds[0] && sound <= &g_SndCache.sounds[NUM_CACHE_SLOTS - 1]) {
|
||||
s32 cacheindex = sound - g_SndCache.sounds;
|
||||
g_SndCache.refcounts[cacheindex]++;
|
||||
}
|
||||
@ -1406,7 +1424,7 @@ void sndAddRef(ALSound *sound)
|
||||
|
||||
void sndRemoveRef(ALSound *sound)
|
||||
{
|
||||
if (sound >= &g_SndCache.sounds[0] && sound <= &g_SndCache.sounds[44]) {
|
||||
if (sound >= &g_SndCache.sounds[0] && sound <= &g_SndCache.sounds[NUM_CACHE_SLOTS - 1]) {
|
||||
s32 cacheindex = sound - g_SndCache.sounds;
|
||||
g_SndCache.refcounts[cacheindex]--;
|
||||
}
|
||||
@ -1417,7 +1435,7 @@ void sndInit(void)
|
||||
ALSndpConfig sndpconfig;
|
||||
ALSynConfig synconfig;
|
||||
#if VERSION >= VERSION_PAL_BETA
|
||||
u32 settings[3];
|
||||
u32 settings[3];
|
||||
#endif
|
||||
|
||||
#if VERSION >= VERSION_JPN_FINAL
|
||||
@ -1469,7 +1487,7 @@ void sndInit(void)
|
||||
|
||||
// Allocate some space at the start of the heap for a string identifier.
|
||||
// This might be used to determine if the heap has overflowed.
|
||||
g_SndGuardStringPtr = alHeapAlloc(&g_SndHeap, 1, 32);
|
||||
g_SndGuardStringPtr = alHeapAlloc(&g_SndHeap, 1, ALIGN16(sizeof(g_SndGuardString)));
|
||||
strcpy(g_SndGuardStringPtr, g_SndGuardString);
|
||||
|
||||
// Load sfx.ctl
|
||||
@ -1492,7 +1510,7 @@ void sndInit(void)
|
||||
|
||||
len = g_SeqTable->count * sizeof(struct seqtableentry) + 4;
|
||||
g_SeqTable = alHeapDBAlloc(0, 0, &g_SndHeap, 1, len);
|
||||
dmaExec(g_SeqTable, (romptr_t) &_sequencesSegmentRomStart, (len + 0xf) & 0xfffffff0);
|
||||
dmaExec(g_SeqTable, (romptr_t) &_sequencesSegmentRomStart, (len + 0xf) & ~0xf);
|
||||
|
||||
// Promote segment-relative offsets to ROM addresses
|
||||
for (i = 0; i < g_SeqTable->count; i++) {
|
||||
@ -1514,7 +1532,7 @@ void sndInit(void)
|
||||
sndpconfig.maxEvents = 64;
|
||||
sndpconfig.maxStates = 64;
|
||||
sndpconfig.maxSounds = 20;
|
||||
sndpconfig.unk10 = 9;
|
||||
sndpconfig.unk10 = NUM_KEYTHINGS;
|
||||
sndpconfig.heap = &g_SndHeap;
|
||||
|
||||
#if VERSION >= VERSION_PAL_BETA
|
||||
@ -1537,7 +1555,7 @@ void sndInit(void)
|
||||
osSyncPrintf("RWI : MP3 player Initialising Done\n");
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (i = 0; i < ARRAYCOUNT(g_SeqInstances); i++) {
|
||||
seqInit(&g_SeqInstances[i]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user