mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
alFxNew Updates from libreultra (#197)
* Fix many warnings, mostly when using funcitons without including headers, and mostly in libultra files. Included a few warning ignores as well * Add another warning fix * Update alFxNew from libreultra's drvrNew.c file, to have some better matches and warning fixes * Match alFxNew * Redo the trailing comma, and a slight bit of documentation added * Rename alLoadPull file to match what it's called in libreultra, alAdpcmPull * Forgot to change the name in the GLOBAL_ASM * Potentially identify a function name, but don't commit to it yet
This commit is contained in:
@@ -41,8 +41,8 @@ GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/func_800CB2D4.s")
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/func_800CB498.s")
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/alLoadParam.s")
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/alRaw16Pull.s")
|
||||
//Called by alLoadPull
|
||||
//Called by alAdpcmPull. _decodeChunk?
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/func_800CBAC0.s")
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/alLoadPull.s")
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/alAdpcmPull.s")
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/alResampleParam.s")
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/alResamplePull.s")
|
||||
|
||||
+156
-42
@@ -1,10 +1,31 @@
|
||||
/* The comment below is needed for this file to be picked up by generate_ld */
|
||||
/* RAM_POS: 0x80064950 */
|
||||
/*====================================================================
|
||||
* drvrNew.c
|
||||
*
|
||||
* Copyright 1993, Silicon Graphics, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
|
||||
* Inc.; the contents of this file may not be disclosed to third
|
||||
* parties, copied or duplicated in any form, in whole or in part,
|
||||
* without the prior written permission of Silicon Graphics, Inc.
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND:
|
||||
* Use, duplication or disclosure by the Government is subject to
|
||||
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
|
||||
* in Technical Data and Computer Software clause at DFARS
|
||||
* 252.227-7013, and/or in similar or successor clauses in the FAR,
|
||||
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
|
||||
* Copyright Laws of the United States.
|
||||
*====================================================================*/
|
||||
|
||||
#include "types.h"
|
||||
#include "macros.h"
|
||||
#include "libultra_internal.h"
|
||||
#include "audio_internal.h"
|
||||
#include "audio.h"
|
||||
#include "src/memory.h"
|
||||
|
||||
/*
|
||||
* WARNING: THE FOLLOWING CONSTANT MUST BE KEPT IN SYNC
|
||||
@@ -18,7 +39,8 @@
|
||||
*/
|
||||
#define ms *(((s32)((f32)44.1))&~0x7)
|
||||
|
||||
s32 SMALLROOM_PARAMS[26] = {
|
||||
|
||||
static s32 SMALLROOM_PARAMS[26] = {
|
||||
/* sections length */
|
||||
3, 100 ms,
|
||||
/* chorus chorus filter
|
||||
@@ -28,7 +50,7 @@ s32 SMALLROOM_PARAMS[26] = {
|
||||
0, 60 ms, 5000, 0, 0, 0, 0, 0x5000
|
||||
};
|
||||
|
||||
s32 BIGROOM_PARAMS[34] = {
|
||||
static s32 BIGROOM_PARAMS[34] = {
|
||||
/* sections length */
|
||||
4, 100 ms,
|
||||
/* chorus chorus filter
|
||||
@@ -39,7 +61,7 @@ s32 BIGROOM_PARAMS[34] = {
|
||||
0, 94 ms, 8000, 0, 0, 0, 0, 0x5000
|
||||
};
|
||||
|
||||
s32 ECHO_PARAMS[10] = {
|
||||
static s32 ECHO_PARAMS[10] = {
|
||||
/* sections length */
|
||||
1, 200 ms,
|
||||
/* chorus chorus filter
|
||||
@@ -47,7 +69,7 @@ s32 ECHO_PARAMS[10] = {
|
||||
0, 179 ms, 12000, 0, 0x7fff, 0, 0, 0
|
||||
};
|
||||
|
||||
s32 CHORUS_PARAMS[10] = {
|
||||
static s32 CHORUS_PARAMS[10] = {
|
||||
/* sections length */
|
||||
1, 20 ms,
|
||||
/* chorus chorus filter
|
||||
@@ -55,7 +77,7 @@ s32 CHORUS_PARAMS[10] = {
|
||||
0, 5 ms, 0x4000, 0, 0x7fff, 7600, 700, 0
|
||||
};
|
||||
|
||||
s32 FLANGE_PARAMS[10] = {
|
||||
static s32 FLANGE_PARAMS[10] = {
|
||||
/* sections length */
|
||||
1, 20 ms,
|
||||
/* chorus chorus filter
|
||||
@@ -63,26 +85,13 @@ s32 FLANGE_PARAMS[10] = {
|
||||
0, 5 ms, 0, 0x5fff, 0x7fff, 380, 500, 0
|
||||
};
|
||||
|
||||
s32 NULL_PARAMS[10] = {
|
||||
static s32 NULL_PARAMS[10] = {
|
||||
0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
extern s32 alAuxBusPull;
|
||||
extern s32 alAuxBusParam;
|
||||
extern s32 alEnvMixerPull;
|
||||
extern s32 alEnvmixerParam;
|
||||
extern s32 alLoadParam;
|
||||
extern s32 alLoadPull;
|
||||
extern s32 alResampleParam;
|
||||
extern s32 alResamplePull;
|
||||
extern s32 alMainBusParam;
|
||||
extern s32 alMainBusPull;
|
||||
extern s32 alSaveParam;
|
||||
extern s32 alSavePull;
|
||||
|
||||
void init_lpfilter(ALLowPass *lp)
|
||||
{
|
||||
void init_lpfilter(ALLowPass *lp) {
|
||||
s32 i, temp;
|
||||
s16 fc;
|
||||
f64 ffc, fcoef;
|
||||
@@ -104,11 +113,86 @@ void init_lpfilter(ALLowPass *lp)
|
||||
}
|
||||
}
|
||||
|
||||
GLOBAL_ASM("lib/asm/non_matchings/alFxNew/alFxNew.s")
|
||||
//This function differs from libreultra's, but still mostly the same
|
||||
void alFxNew(ALFx *r, ALSynConfig *c, s16 bus, UNUSED ALHeap *hp) {
|
||||
u16 i, j, k;
|
||||
s32 *param = 0;
|
||||
ALFilter *f = (ALFilter *) r;
|
||||
ALDelay *d;
|
||||
alFilterNew(f, 0, alFxParam, AL_FX);
|
||||
f->handler = alFxPull;
|
||||
r->paramHdl = (ALSetFXParam)alFxParamHdl;
|
||||
switch (c->fxType[bus]) {
|
||||
case AL_FX_SMALLROOM: param = SMALLROOM_PARAMS; break;
|
||||
case AL_FX_BIGROOM: param = BIGROOM_PARAMS; break;
|
||||
case AL_FX_ECHO: param = ECHO_PARAMS; break;
|
||||
case AL_FX_CHORUS: param = CHORUS_PARAMS; break;
|
||||
case AL_FX_FLANGE: param = FLANGE_PARAMS; break;
|
||||
case AL_FX_CUSTOM: param = (&c->params)[bus]; break;
|
||||
default: param = NULL_PARAMS; break;
|
||||
}
|
||||
j = 0;
|
||||
r->section_count = param[j++];
|
||||
r->length = param[j++];
|
||||
r->delay = allocate_from_main_pool_safe(sizeof(ALDelay) * r->section_count, COLOR_TAG_CYAN);
|
||||
r->base = allocate_from_main_pool_safe(sizeof(s16) * r->length, COLOR_TAG_CYAN);
|
||||
r->input = r->base;
|
||||
for ( k=0; k < r->length; k++)
|
||||
r->base[k] = 0;
|
||||
for ( i=0; i<r->section_count; i++ ) {
|
||||
d = &r->delay[i];
|
||||
d->input = param[j++];
|
||||
d->output = param[j++];
|
||||
d->fbcoef = param[j++];
|
||||
d->ffcoef = param[j++];
|
||||
d->gain = param[j++];
|
||||
if (param[j]) {
|
||||
#define RANGE 2.0
|
||||
//d->rsinc = ((f32) param[j++])/0xffffff;
|
||||
d->rsinc = ((((f32)param[j++])/1000) * RANGE)/c->outputRate;
|
||||
/*
|
||||
* the following constant is derived from:
|
||||
*
|
||||
* ratio = 2^(cents/1200)
|
||||
*
|
||||
* and therefore for hundredths of a cent
|
||||
* x
|
||||
* ln(ratio) = ---------------
|
||||
* (120,000)/ln(2)
|
||||
* where
|
||||
* 120,000/ln(2) = 173123.40...
|
||||
*/
|
||||
#define CONVERT 173123.404906676
|
||||
#define LENGTH (d->output - d->input)
|
||||
d->rsgain = (((f32) param[j++])/CONVERT) * LENGTH;
|
||||
d->rsval = 1.0;
|
||||
d->rsdelta = 0.0;
|
||||
d->rs = allocate_from_main_pool_safe(sizeof(ALResampler), COLOR_TAG_CYAN);
|
||||
d->rs->state = allocate_from_main_pool_safe(sizeof(RESAMPLE_STATE), COLOR_TAG_CYAN);
|
||||
d->rs->delta = 0.0;
|
||||
d->rs->first = 1;
|
||||
} else {
|
||||
d->rs = 0;
|
||||
j++;
|
||||
j++;
|
||||
}
|
||||
if (param[j]) {
|
||||
d->lp = allocate_from_main_pool_safe(sizeof(ALLowPass), COLOR_TAG_CYAN);
|
||||
d->lp->fstate = allocate_from_main_pool_safe(sizeof(POLEF_STATE), COLOR_TAG_CYAN);
|
||||
d->lp->fc = param[j++];
|
||||
init_lpfilter(d->lp);
|
||||
} else {
|
||||
d->lp = 0;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void alEnvmixerNew(ALEnvMixer *e, ALHeap *hp) {
|
||||
alFilterNew((ALFilter *) e, alEnvmixerPull, alEnvmixerParam, AL_ENVMIX);
|
||||
|
||||
e->state = alHeapAlloc(hp, 1, sizeof(ENVMIX_STATE));
|
||||
|
||||
void alEnvmixerNew(ALEnvMixer *e, s32 arg1) {
|
||||
alFilterNew(e, &alEnvMixerPull, &alEnvmixerParam, 4);
|
||||
e->state = alHeapDBAlloc(0, 0, arg1, 1, 0x50);
|
||||
e->first = 1;
|
||||
e->motion = AL_STOPPED;
|
||||
e->volume = 1;
|
||||
@@ -120,6 +204,8 @@ void alEnvmixerNew(ALEnvMixer *e, s32 arg1) {
|
||||
e->wetamt = 0;
|
||||
e->lratm = 1;
|
||||
e->lratl = 0;
|
||||
e->lratm = 1;
|
||||
e->lratl = 0;
|
||||
e->delta = 0;
|
||||
e->segEnd = 0;
|
||||
e->pan = 0;
|
||||
@@ -128,44 +214,72 @@ void alEnvmixerNew(ALEnvMixer *e, s32 arg1) {
|
||||
e->sources = 0;
|
||||
}
|
||||
|
||||
void alLoadNew(ALLoadFilter *arg0, s32 (*arg1)(s32*), s32 arg2) {
|
||||
alFilterNew(arg0, &alLoadPull, &alLoadParam, 0);
|
||||
arg0->state = alHeapDBAlloc(0, 0, arg2, 1, 0x20);
|
||||
arg0->lstate = alHeapDBAlloc(0, 0, arg2, 1, 0x20);
|
||||
arg0->dma = arg1(&arg0->dmaState);
|
||||
arg0->lastsam = 0;
|
||||
arg0->first = 1;
|
||||
arg0->memin = 0;
|
||||
void alLoadNew(ALLoadFilter *f, ALDMANew dmaNew, ALHeap *hp) {
|
||||
UNUSED s32 i;
|
||||
|
||||
/*
|
||||
* init filter superclass
|
||||
*/
|
||||
|
||||
alFilterNew((ALFilter *) f, alAdpcmPull, alLoadParam, AL_ADPCM);
|
||||
|
||||
f->state = alHeapAlloc(hp, 1, sizeof(ADPCM_STATE));
|
||||
f->lstate = alHeapAlloc(hp, 1, sizeof(ADPCM_STATE));
|
||||
|
||||
f->dma = dmaNew(&f->dmaState);
|
||||
|
||||
/*
|
||||
* init the adpcm state
|
||||
*/
|
||||
f->lastsam = 0;
|
||||
f->first = 1;
|
||||
f->memin = 0;
|
||||
}
|
||||
|
||||
void alResampleNew(ALResampler *r, ALHeap *hp) {
|
||||
alFilterNew(r, &alResamplePull, &alResampleParam, 1);
|
||||
r->state = alHeapDBAlloc(0, 0, hp, 1, 0x20);
|
||||
r->first = 1;
|
||||
alFilterNew((ALFilter *) r, alResamplePull, alResampleParam, AL_RESAMPLE);
|
||||
|
||||
/*
|
||||
* Init resampler state
|
||||
*/
|
||||
r->state = alHeapAlloc(hp, 1, sizeof(RESAMPLE_STATE));
|
||||
r->delta = 0.0;
|
||||
r->first = 1;
|
||||
r->motion = AL_STOPPED;
|
||||
r->ratio = 1.0;
|
||||
r->upitch = 0;
|
||||
r->ctrlList = 0;
|
||||
r->ctrlTail = 0;
|
||||
r->delta = 0.0f;
|
||||
r->ratio = 1.0f;
|
||||
|
||||
/* state in the ucode is initialized by the A_INIT flag */
|
||||
}
|
||||
|
||||
void alAuxBusNew(ALAuxBus *m, void *sources, s32 maxSources) {
|
||||
alFilterNew(m, &alAuxBusPull, &alAuxBusParam, 6);
|
||||
alFilterNew((ALFilter *) m, alAuxBusPull, alAuxBusParam, AL_AUXBUS);
|
||||
m->sourceCount = 0;
|
||||
m->maxSources = maxSources;
|
||||
m->sources = sources;
|
||||
m->sources = (ALFilter **)sources;
|
||||
}
|
||||
|
||||
void alMainBusNew(ALMainBus *m, void *sources, s32 maxSources) {
|
||||
alFilterNew(m, &alMainBusPull, &alMainBusParam, 7);
|
||||
alFilterNew((ALFilter *) m, alMainBusPull, alMainBusParam, AL_MAINBUS);
|
||||
m->sourceCount = 0;
|
||||
m->maxSources = maxSources;
|
||||
m->sources = sources;
|
||||
m->sources = (ALFilter **)sources;
|
||||
}
|
||||
|
||||
void alSaveNew(ALSave *f) {
|
||||
alFilterNew(f, &alSavePull, &alSaveParam, AL_SAVE);
|
||||
/*
|
||||
* init filter superclass
|
||||
*/
|
||||
|
||||
alFilterNew((ALFilter *) f, alSavePull, alSaveParam, AL_SAVE);
|
||||
|
||||
/*
|
||||
* init the save state, which is a virtual dram address
|
||||
*/
|
||||
|
||||
f->dramout = 0;
|
||||
f->first = 1;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,13 +6,10 @@
|
||||
#include "audio_internal.h"
|
||||
|
||||
#ifdef NON_EQUIVALENT
|
||||
void alFxNew(ALFx *r, ALSynConfig *c, s16 bus);
|
||||
s32 alFxParam(void *filter, s32 paramID, void *param);
|
||||
s32 alMainBusParam(void *filter, s32 paramID, void *param);
|
||||
// This is very close to matching.
|
||||
ALFxRef *alSynAllocFX(ALSynth *s, s16 bus, ALSynConfig *c, ALHeap *hp)
|
||||
{
|
||||
alFxNew(s->auxBus[bus].fx, c, bus);
|
||||
alFxNew(s->auxBus[bus].fx, c, bus, hp);
|
||||
alFxParam(s->auxBus[bus].fx, AL_FILTER_SET_SOURCE,
|
||||
&s->auxBus[bus]);
|
||||
alMainBusParam(s->mainBus, AL_FILTER_ADD_SOURCE, s->auxBus[bus].fx);
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@
|
||||
#include "viint.h"
|
||||
#include "PR/sptask.h"
|
||||
#include "osint.h"
|
||||
#include "macros.h"
|
||||
|
||||
#define _osVirtualToPhysical(ptr) \
|
||||
if (ptr != NULL) { \
|
||||
@@ -53,7 +54,7 @@ void osSpTaskLoad(OSTask *intp) {
|
||||
;
|
||||
}
|
||||
|
||||
void osSpTaskStartGo(OSTask *tp) {
|
||||
void osSpTaskStartGo(UNUSED OSTask *tp) {
|
||||
while (__osSpDeviceBusy());
|
||||
|
||||
__osSpSetStatus(SP_SET_INTR_BREAK | SP_CLR_SSTEP | SP_CLR_BROKE | SP_CLR_HALT);
|
||||
|
||||
Reference in New Issue
Block a user