From ef4b60d384a1c398adf6e8e3021f799dba90434a Mon Sep 17 00:00:00 2001 From: Raf <> Date: Tue, 30 Jul 2024 16:57:17 +0800 Subject: [PATCH] portx64: audio system changes --- include/PR/n_libaudio.h | 12 +++++++++++- src/game/propsndstop.c | 1 + src/lib/mp3/mp3.h | 3 +++ src/lib/naudio/n_reverb.c | 8 ++++---- src/lib/snd.c | 10 +++++++--- src/lib/ultra/audio/synthInternals.h | 3 +++ 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/include/PR/n_libaudio.h b/include/PR/n_libaudio.h index 4f82c2471..5a06e9558 100644 --- a/include/PR/n_libaudio.h +++ b/include/PR/n_libaudio.h @@ -256,7 +256,7 @@ typedef struct { ALOscStop stopOsc; ALSeqMarker *loopStart; ALSeqMarker *loopEnd; - s32 loopCount; /* -1 = loop forever, 0 = no loop */ + intptr_t loopCount; /* -1 = loop forever, 0 = no loop */ u8 unk88; u8 unk89; } N_ALSeqPlayer; @@ -284,9 +284,19 @@ typedef struct { ALOscInit initOsc; ALOscUpdate updateOsc; ALOscStop stopOsc; + +#ifdef PLATFORM_64BIT + s32 _pad1_; + f32 unk7c; + s32 _pad2_; + f32 unk80; +#else f32 unk7c; f32 unk80; +#endif + void *queue; + u8 unk88; u8 unk89; } N_ALCSPlayer; diff --git a/src/game/propsndstop.c b/src/game/propsndstop.c index 93f2df6a1..4891021cb 100644 --- a/src/game/propsndstop.c +++ b/src/game/propsndstop.c @@ -8,6 +8,7 @@ void psStop(void) { + if (g_SndDisabled) return; s32 i; for (i = 0; i < (IS4MB() ? 30 : 40); i++) { diff --git a/src/lib/mp3/mp3.h b/src/lib/mp3/mp3.h index 14ac2c6f6..eab395a1c 100644 --- a/src/lib/mp3/mp3.h +++ b/src/lib/mp3/mp3.h @@ -7,6 +7,9 @@ struct mp3decfourbytes { u8 bytes[2]; s8 unk02; s8 unk03; +#ifdef PLATFORM_64BIT + u32 _pad_; +#endif }; struct asistream_scalefac { diff --git a/src/lib/naudio/n_reverb.c b/src/lib/naudio/n_reverb.c index 39657dd89..98c5e30b9 100644 --- a/src/lib/naudio/n_reverb.c +++ b/src/lib/naudio/n_reverb.c @@ -47,8 +47,8 @@ Acmd *n_alFxPull(s32 sampleOffset, Acmd *p, s32 arg2) for (i = 0; i < r->section_count; i++) { d = &r->delay[i]; /* get the ALDelay structure */ - in_ptr = &r->input[j][-d->input]; - out_ptr = &r->input[j][-d->output]; + in_ptr = &r->input[j][(s32)-d->input]; + out_ptr = &r->input[j][(s32)-d->output]; if (var8009c346[arg2] && var8009c344[arg2]) { d->ffcoef = -d->ffcoef; @@ -253,7 +253,7 @@ Acmd *_n_loadOutputBuffer(ALFx *r, ALDelay *d, s32 arg2, s32 buff, Acmd *p) fincount = d->rs->delta + (fratio * (f32)incount); count = (s32) fincount; d->rs->delta = fincount - (f32)count; - out_ptr = &r->input[arg2][-(d->output - d->rsdelta)]; + out_ptr = &r->input[arg2][(s32)-(d->output - d->rsdelta)]; ramalign = ((intptr_t)out_ptr & 0x7) >> 1; ptr = _n_loadBuffer(r, arg2, out_ptr - ramalign, rbuff, count + ramalign, ptr); @@ -265,7 +265,7 @@ Acmd *_n_loadOutputBuffer(ALFx *r, ALDelay *d, s32 arg2, s32 buff, Acmd *p) d->rs->first = 0; d->rsdelta += count - incount; } else { - out_ptr = &r->input[arg2][-d->output]; + out_ptr = &r->input[arg2][(s32)-d->output]; ptr = _n_loadBuffer(r, arg2, out_ptr, buff, FIXED_SAMPLE, ptr); } diff --git a/src/lib/snd.c b/src/lib/snd.c index e130cdb0f..6beac208b 100644 --- a/src/lib/snd.c +++ b/src/lib/snd.c @@ -105,6 +105,8 @@ s32 var8005dddc = 0; u8 *g_SndGuardStringPtr = NULL; +uintptr_t* g_SeqRomAddrs; + enum audioconfig_e { AUDIOCONFIG_00, AUDIOCONFIG_01, @@ -1526,8 +1528,10 @@ void sndInit(void) dmaExec(g_SeqTable, (romptr_t) REF_SEG _sequencesSegmentRomStart, (len + 0xf) & ~0xf); // Promote segment-relative offsets to ROM addresses + g_SeqRomAddrs = mempAlloc(g_SeqTable->count * sizeof(uintptr_t), MEMPOOL_PERMANENT); + for (i = 0; i < g_SeqTable->count; i++) { - g_SeqTable->entries[i].romaddr += (romptr_t) REF_SEG _sequencesSegmentRomStart; + g_SeqRomAddrs[i] = g_SeqTable->entries[i].romaddr + (romptr_t) REF_SEG _sequencesSegmentRomStart; } synconfig.maxVVoices = 44; @@ -1639,7 +1643,7 @@ bool seqPlay(struct seqinstance *seq, s32 tracknum) return false; } - if (g_SeqTable->entries[seq->tracknum].romaddr < 0x10000) { + if (g_SeqRomAddrs[seq->tracknum] < 0x10000) { return false; } @@ -1688,7 +1692,7 @@ bool seqPlay(struct seqinstance *seq, s32 tracknum) binstart = seq->data; zipstart = binstart + binlen - ziplen; - dmaExec(zipstart, g_SeqTable->entries[seq->tracknum].romaddr, ziplen); + dmaExec(zipstart, g_SeqRomAddrs[seq->tracknum], ziplen); ziplen = rzipInflate(zipstart, binstart, scratch); } diff --git a/src/lib/ultra/audio/synthInternals.h b/src/lib/ultra/audio/synthInternals.h index 4e9dbd31e..89ab4cf7e 100644 --- a/src/lib/ultra/audio/synthInternals.h +++ b/src/lib/ultra/audio/synthInternals.h @@ -107,6 +107,9 @@ typedef struct ALParam_s { } yetstillmoredata; s32 unk1c; s32 unk20; +#ifdef PLATFORM_64BIT + u8 _pad_[8]; +#endif } ALParam; typedef struct {