From 399edfc8c9456692cf2437a1b2212dcb106dbce4 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 21 Nov 2021 11:19:51 +1000 Subject: [PATCH] Improve mismatch of snd0000ee88 --- src/game/chr/chraction.c | 4 ++-- src/include/bss.h | 1 - src/include/constants.h | 2 +- src/include/types.h | 2 +- src/lib/sched.c | 2 ++ src/lib/snd.c | 28 +++++++++++++++++----------- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/game/chr/chraction.c b/src/game/chr/chraction.c index 2e4b9c978..73310a701 100644 --- a/src/game/chr/chraction.c +++ b/src/game/chr/chraction.c @@ -3350,7 +3350,7 @@ void chrBeginDeath(struct chrdata *chr, struct coord *dir, f32 relangle, s32 hit mult2 = gsetGetStrength(gset); - if (mult2 <= 0 && (chr->chrflags & CHRCFLAG_00008000)) { + if (mult2 <= 0 && (chr->chrflags & CHRCFLAG_DIEWITHFORCE)) { mult2 = 6; } @@ -3403,7 +3403,7 @@ void chrBeginDeath(struct chrdata *chr, struct coord *dir, f32 relangle, s32 hit mult3 = gsetGetStrength(gset); - if (mult3 <= 0 && (chr->chrflags & CHRCFLAG_00008000)) { + if (mult3 <= 0 && (chr->chrflags & CHRCFLAG_DIEWITHFORCE)) { mult3 = 6; } diff --git a/src/include/bss.h b/src/include/bss.h index 59353e0ab..00265c50b 100644 --- a/src/include/bss.h +++ b/src/include/bss.h @@ -32,7 +32,6 @@ extern s32 g_SndMaxFxBusses; extern struct seqinstance g_SeqInstances[3]; extern ALHeap g_SndHeap; extern u32 var80095200; -extern struct var80095210 var80095210; extern OSMesgQueue g_PiMesgQueue; extern struct g_vars g_Vars; extern u8 **var8009a874; diff --git a/src/include/constants.h b/src/include/constants.h index 5e46ee204..3628997ae 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -496,7 +496,7 @@ #define CHRCFLAG_UNEXPLODABLE 0x00001000 #define CHRCFLAG_NOSHADOW 0x00002000 #define CHRCFLAG_HAS_SPECIAL_DEATH_ANIMATION 0x00004000 -#define CHRCFLAG_00008000 0x00008000 // Not used in scripts +#define CHRCFLAG_DIEWITHFORCE 0x00008000 // When killed with a weak weapon, fling the chr as if it was a strong weapon #define CHRCFLAG_00010000 0x00010000 // Related to dead people in intro cutscenes #define CHRCFLAG_FORCEAUTOAIM 0x00020000 // Allow auto aim even if chr is unarmed #define CHRCFLAG_00040000 0x00040000 // Used a lot diff --git a/src/include/types.h b/src/include/types.h index 6d4386daf..4c9b94714 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -7029,7 +7029,7 @@ struct var80095210 { u16 *soundnums; u8 unk04[45]; u16 unk32[45]; - u8 unk90[0x2cc]; + u8 unk8c[0x2d0]; struct var80095210_35c unk35c[1]; u8 unk364[0x3d88]; }; diff --git a/src/lib/sched.c b/src/lib/sched.c index 870ecc5d7..8e6157995 100644 --- a/src/lib/sched.c +++ b/src/lib/sched.c @@ -337,6 +337,8 @@ void __scHandleRetrace(OSSched *sc) schedRenderCrashPeriodically(sc->frameCount); } +extern struct var80095210 var80095210; + /** * __scHandleTasks is called both on retrace and when the RDP completes a task. */ diff --git a/src/lib/snd.c b/src/lib/snd.c index 20691d593..7fdd3419a 100644 --- a/src/lib/snd.c +++ b/src/lib/snd.c @@ -1368,28 +1368,31 @@ glabel snd0000ee88 ); #endif +// Mismatch: +// Goal calculates the address of var80095210.unk35c twice. +// The below demonstrates similar codegen by not adding arg1 to the return value. //struct var80095210_35c *snd0000ee88(u32 segoffset, u16 arg1) //{ //#if VERSION >= VERSION_NTSC_1_0 -// s32 i; -// s32 sum1; -// s32 sum2; -// u32 stack; -// u8 spaf[0x40]; +// u8 spaf[0x50]; // u8 sp5f[0x50]; // u32 *s2 = (u32 *)ALIGN16((u32)spaf); // u32 *s1 = (u32 *)ALIGN16((u32)sp5f); -// u32 stack2; +// s32 i; +// s32 sum1; +// s32 sum2; +// +// segoffset += (u32)&_sfxctlSegmentRomStart; // // do { -// dmaExecHighPriority(s2, (u32)&_sfxctlSegmentRomStart + segoffset, 0x40); +// dmaExecHighPriority(s2, segoffset, 0x40); // sum1 = 0; // // for (i = 0; i < 16U; i++) { // sum1 += s2[i]; // } // -// dmaExecHighPriority(s1, (u32)&_sfxctlSegmentRomStart + segoffset, 0x40); +// dmaExecHighPriority(s1, segoffset, 0x40); // sum2 = 0; // // for (i = 0; i < 16U; i++) { @@ -1400,12 +1403,15 @@ glabel snd0000ee88 // u8 sp5f[0x50]; // u32 *s1 = (u32 *)ALIGN16((u32)sp5f); // -// dmaExecHighPriority(s1, (u32)&_sfxctlSegmentRomStart + segoffset, 0x40); +// segoffset += (u32)&_sfxctlSegmentRomStart; +// +// dmaExecHighPriority(s1, segoffset, 0x40); //#endif // // var80095210.unk35c[arg1] = *(struct var80095210_35c *)s1; // -// return &var80095210.unk35c[arg1]; +// //return &var80095210.unk35c[arg1]; +// return (struct var80095210_35c *)((u32)&var80095210 + 0x35c); //} #if VERSION >= VERSION_NTSC_1_0 @@ -2718,7 +2724,7 @@ void sndTick(void) if (g_SndGuardStringPtr != NULL) { if (strcmp(g_SndGuardStringPtr, &g_SndGuardString) != 0) { -#if VERSION <= VERSION_NTSC_1_0 +#if VERSION < VERSION_NTSC_1_0 crashSetMessage("Snd Heap Check FAILED"); CRASH(); #endif