Matched game/audio

This commit is contained in:
mrshigure 2023-12-23 08:01:08 -08:00
parent 89f85e6d42
commit 8d61eaeda4
9 changed files with 846 additions and 32 deletions

View file

@ -6143,12 +6143,12 @@ Snd3DSpeedOffset = .sbss:0x801D3D24; // type:object size:0x4 data:float
Snd3DStartDisOffset = .sbss:0x801D3D28; // type:object size:0x4 data:float
Snd3DFrontSurDisOffset = .sbss:0x801D3D2C; // type:object size:0x4 data:float
Snd3DBackSurDisOffset = .sbss:0x801D3D30; // type:object size:0x4 data:float
HuAuxBVol = .sbss:0x801D3D34; // type:object size:0x1 data:byte
HuAuxAVol = .sbss:0x801D3D35; // type:object size:0x1 data:byte
HuAuxBVol = .sbss:0x801D3D34; // type:object size:0x1 data:byte scope:local
HuAuxAVol = .sbss:0x801D3D35; // type:object size:0x1 data:byte scope:local
auxBNoBak = .sbss:0x801D3D38; // type:object size:0x4 scope:local data:4byte
auxANoBak = .sbss:0x801D3D3C; // type:object size:0x4 scope:local data:4byte
sndGroupBak = .sbss:0x801D3D40; // type:object size:0x2 scope:local data:2byte
Hu3DAudVol = .sbss:0x801D3D42; // type:object size:0x6 scope:local data:2byte
Hu3DAudVol = .sbss:0x801D3D42; // type:object size:0x2 scope:local data:2byte
Meshno = .sbss:0x801D3D48; // type:object size:0x4 scope:local data:4byte
Meshcnt = .sbss:0x801D3D4C; // type:object size:0x4 scope:local data:4byte
normtop = .sbss:0x801D3D50; // type:object size:0x4 scope:local data:4byte

View file

@ -258,7 +258,7 @@ config.libs = [
Object(NonMatching, "game/objsysobj.c"),
Object(NonMatching, "game/objdll.c"),
Object(Matching, "game/frand.c"),
Object(NonMatching, "game/audio.c"),
Object(Matching, "game/audio.c"),
Object(NonMatching, "game/EnvelopeExec.c"),
Object(NonMatching, "game/minigame_seq.c"),
Object(Matching, "game/ovllist.c"),

View file

@ -13,9 +13,12 @@ typedef struct player_config {
} PlayerConfig;
typedef struct wipe_state {
u8 unk[52];
char unk00[0x30];
float unk30;
float duration;
u8 unk2[20];
char unk38[0x11];
u8 unk49;
char unk4A[2];
} WipeState;

View file

@ -11,7 +11,7 @@ void Hu3DBGColorSet(u8, u8, u8);
void Hu3DCameraCreate(s32);
void Hu3DCameraPerspectiveSet(s32, f32, f32, f32, f32);
void Hu3DCameraViewportSet(s32, f32, f32, f32, f32, f32, f32);
void HuAudFadeOut(int arg0);
void HuAudFadeOut(s32 arg0);
void WipeCreate(char dir, char type, short duration);
u8 WipeStatGet(void);

59
include/game/audio.h Normal file
View file

@ -0,0 +1,59 @@
#ifndef _GAME_AUDIO_H
#define _GAME_AUDIO_H
#include "common.h"
void HuAudInit(void);
s32 HuAudStreamPlay(void);
void HuAudStreamVolSet(s16 vol);
void HuAudStreamPauseOn(void);
void HuAudStreamPauseOff(void);
void HuAudStreamFadeOut(void);
void HuAudAllStop(void);
void HuAudFadeOut(s32 arg0);
s32 HuAudFXPlay(s32 arg0);
s32 HuAudFXPlayVol(s32 arg0, s16 arg1);
s32 HuAudFXPlayVolPan(s32 arg0, s16 arg1, s16 arg2);
void HuAudFXStop(s32 arg0);
void HuAudFXAllStop(void);
void HuAudFXFadeOut(s32 arg0, s32 arg1);
void HuAudFXPanning(s32 arg0, s16 arg1);
void HuAudFXListnerSet(s32 arg0, s32 arg1, float arg2, float arg3);
void HuAudFXListnerSetEX(s32 arg0, s32 arg1, float sndDist, float sndSpeed, float arg4, float arg5, float arg6);
void HuAudFXListnerUpdate(s32 arg0, s32 arg1);
s32 HuAudFXEmiterPlay(s32 arg0, Vec *arg1);
void HuAudFXEmiterUpDate(s32 arg0, Vec *arg1);
void HuAudFXListnerKill(void);
void HuAudFXPauseAll(s32 arg0);
s32 HuAudFXStatusGet(s32 arg0);
s32 HuAudFXPitchSet(s32 arg0, s16 arg1);
s32 HuAudFXVolSet(s32 arg0, s16 arg1);
s32 HuAudSeqPlay(s16 arg0);
void HuAudSeqStop(s32 arg0);
void HuAudSeqFadeOut(s32 arg0, s32 arg1);
void HuAudSeqAllFadeOut(s32 arg0);
void HuAudSeqAllStop(void);
void HuAudSeqPauseAll(s32 arg0);
void HuAudSeqPause(s32 arg0, s32 arg1, s32 arg2);
s32 HuAudSeqMidiCtrlGet(s32 arg0, s8 arg1, s8 arg2);
s32 HuAudSStreamPlay(s16 arg0);
void HuAudSStreamStop(s32 arg0);
void HuAudSStreamFadeOut(s32 arg0, s32 arg1);
void HuAudSStreamAllFadeOut(s32 arg0);
void HuAudSStreamAllStop(void);
s32 HuAudSStreamStatGet(s32 arg0);
void HuAudDllSndGrpSet(u16 ovl);
void HuAudSndGrpSetSet(s16 arg0);
void HuAudSndGrpSet(s16 arg0);
void HuAudSndCommonGrpSet(s16 arg0, s32 arg1);
void HuAudAUXSet(s32 arg0, s32 arg1);
void HuAudAUXVolSet(s8 arg0, s8 arg1);
void HuAudVoiceInit(s16 ovl);
void HuAudPlayerVoicePlay(s16 arg0, s16 arg1);
void HuAudPlayerVoicePlayPos(s16 arg0, s16 arg1, Vec *arg2);
void HuAudPlayerVoicePlayEntry(s16 arg0, s16 arg1);
s32 HuAudCharVoicePlay(s16 arg0, s16 arg1);
s32 HuAudCharVoicePlayPos(s16 arg0, s16 arg1, Vec *arg2);
void HuAudCharVoicePlayEntry(s16 arg0, s16 arg1);
#endif

70
include/game/msm.h Normal file
View file

@ -0,0 +1,70 @@
#ifndef _GAME_MSM_H
#define _GAME_MSM_H
#include "common.h"
typedef struct {
s32 unk00;
s32 unk04;
char unk08[4];
char *unk0C;
char *unk10;
s32 unk14;
s32 unk18;
s32 unk1C;
void *unk20;
s32 unk24;
} UnkMsmStruct_00; // Size 0x28
typedef struct {
/* 0x00 */ s32 unk00;
/* 0x04 */ s8 unk04;
/* 0x05 */ s8 unk05;
/* 0x06 */ s16 unk06;
/* 0x08 */ char unk08[1];
/* 0x09 */ s8 unk09;
/* 0x0A */ s8 unk0A;
/* 0x0B */ char unk0B[5];
/* 0x10 */ Vec unk10;
} UnkMsmStruct_01; // Size 0x1C
typedef struct {
/* 0x00 */ s32 unk00;
/* 0x04 */ float startDis;
/* 0x08 */ float frontSurDis;
/* 0x0C */ float backSurDis;
} UnkMsmStruct_02; // Size (min: 0x10, max: 0x1C)
void msmSysSetOutputMode(s32 arg0);
void msmSysSetAux(s32 arg0, s32 arg1);
s32 msmSysGetSampSize(s32 arg0);
s32 msmSysDelGroupAll(void);
s32 msmSysDelGroupBase(s32 arg0);
void msmSysLoadGroupBase(s32 arg0, void *arg1);
s32 msmSysLoadGroupSet(s32 arg0, void *arg1);
s32 msmSysInit(char **arg0, UnkMsmStruct_00 *arg1);
s32 msmMusGetMidiCtrl(s32 arg0, s32 arg1, s32 arg2);
s32 msmMusGetNumPlay(s32 arg0);
s32 msmMusGetStatus(s32 arg0);
void msmMusPauseAll(s32 arg0, s32 arg1);
void msmMusPause(s32 arg0, s32 arg1, s32 arg2);
void msmMusStopAll(s32 arg0, s32 arg1);
void msmMusStop(s32 arg0, s32 arg1);
s32 msmMusPlay(s32 arg0, s32 arg1);
void msmSeDelListener(void);
void msmSeUpdataListener(s32 arg0, s32 arg1);
void msmSeSetListener(s32 arg0, s32 arg1, float arg2, float arg3, UnkMsmStruct_02 *arg4);
s32 msmSeGetEntryID(s32 arg0, void *arg1);
s32 msmSeGetNumPlay(s32 arg0);
s32 msmSeGetStatus(s32 arg0);
s32 msmSeSetParam(s32 arg0, UnkMsmStruct_01 *arg1);
void msmSePauseAll(s32 arg0, s32 arg1);
void msmSeStopAll(s32 arg0, s32 arg1);
void msmSeStop(s32 arg0, s32 arg1);
s32 msmSePlay(s32 arg0, UnkMsmStruct_01 *arg1);
s32 msmStreamGetStatus(s32 arg0);
void msmStreamPauseAll(s32 arg0);
void msmStreamStop(s32 arg0, s32 arg1);
s32 msmStreamPlay(s16 arg0, s32 *arg1);
#endif

View file

@ -15,7 +15,7 @@ extern PlayerConfig GWPlayerCfg[4];
extern u32 DirDataSize;
extern u32 totalPolyCnted;
extern char fadeStat;
extern u8 fadeStat;
extern PlayerState GWPlayer[4];
extern SystemState GWSystem;

686
src/game/audio.c Normal file
View file

@ -0,0 +1,686 @@
#include "game/audio.h"
#include "game/memory.h"
#include "game/msm.h"
#include "game/object.h"
typedef struct {
/* 0x00 */ s16 unk00;
/* 0x02 */ s16 unk02;
/* 0x04 */ s32 unk04;
/* 0x08 */ s32 unk08;
/* 0x0C */ s8 unk0C;
/* 0x0D */ s8 unk0D;
} sndGrpTableData;
static s32 HuSePlay(s32 arg0, UnkMsmStruct_01 *arg1);
extern s16 omSysExitReq;
static s32 charVoiceGroupStat[8];
static s32 sndFXBuf[64][2];
static s16 Hu3DAudVol;
static s16 sndGroupBak;
static s32 auxANoBak;
static s32 auxBNoBak;
static s8 HuAuxAVol;
static s8 HuAuxBVol;
float Snd3DBackSurDisOffset;
float Snd3DFrontSurDisOffset;
float Snd3DStartDisOffset;
float Snd3DSpeedOffset;
float Snd3DDistOffset;
s32 musicOffF;
u8 fadeStat;
static char *lbl_8012E9AC[] = {
"sound/MPNGC02.son",
"sound/MPNGC16.son",
""
};
void HuAudInit(void) {
UnkMsmStruct_00 sp8;
s32 temp_r3;
s16 i;
sp8.unk20 = HuMemDirectMalloc(HEAP_MUSIC, 0x13FC00);
sp8.unk24 = 0x13FC00;
sp8.unk0C = "/sound/mpgcsnd.msm";
sp8.unk10 = "/sound/mpgcstr.pdt";
sp8.unk14 = 0;
sp8.unk18 = 0;
sp8.unk1C = 0;
sp8.unk00 = 1;
sp8.unk04 = 0x808000;
temp_r3 = msmSysInit(&sp8.unk0C, &sp8);
if (temp_r3 < 0) {
OSReport("MSM(Sound Manager) Error:Error Code %d\n", temp_r3);
while (1);
}
if (OSGetSoundMode() == 0) {
msmSysSetOutputMode(0);
} else {
msmSysSetOutputMode(2);
}
for (i = 0; i < 64; i++) {
sndFXBuf[i][0] = -1;
}
for (i = 0; i < 8; i++) {
charVoiceGroupStat[i] = 0;
}
sndGroupBak = -1;
auxANoBak = auxBNoBak = -1;
fadeStat = 0;
musicOffF = 0;
}
s32 HuAudStreamPlay(void) {
return 0;
}
void HuAudStreamVolSet(s16 vol) {
AISetStreamVolLeft(vol);
AISetStreamVolRight(vol);
Hu3DAudVol = vol;
}
void HuAudStreamPauseOn(void) {
AISetStreamPlayState(0);
}
void HuAudStreamPauseOff(void) {
AISetStreamPlayState(1);
}
void HuAudStreamFadeOut(void) {
}
void HuAudAllStop(void) {
HuAudSeqAllStop();
HuAudFXAllStop();
HuAudSStreamAllStop();
}
void HuAudFadeOut(s32 arg0) {
HuAudFXAllStop();
HuAudSeqAllFadeOut(arg0);
HuAudSStreamAllFadeOut(arg0);
}
s32 HuAudFXPlay(s32 arg0) {
WipeState *temp_r31 = &wipeData;
if (omSysExitReq != 0 || (wipeData.unk49 == 2 && temp_r31->unk30 / temp_r31->duration > 0.5)) {
return 0;
}
return HuAudFXPlayVolPan(arg0, 0x7F, 0x40);
}
s32 HuAudFXPlayVol(s32 arg0, s16 arg1) {
if (omSysExitReq != 0) {
return 0;
}
return HuAudFXPlayVolPan(arg0, arg1, 0x40);
}
s32 HuAudFXPlayVolPan(s32 arg0, s16 arg1, s16 arg2) {
UnkMsmStruct_01 sp10;
if (omSysExitReq != 0) {
return 0;
}
sp10.unk00 = 3;
sp10.unk04 = arg1;
sp10.unk05 = arg2;
return HuSePlay(arg0, &sp10);
}
void HuAudFXStop(s32 arg0) {
msmSeStop(arg0, 0);
}
void HuAudFXAllStop(void) {
msmSeStopAll(0, 0);
}
void HuAudFXFadeOut(s32 arg0, s32 arg1) {
msmSeStop(arg0, arg1);
}
void HuAudFXPanning(s32 arg0, s16 arg1) {
UnkMsmStruct_01 sp10;
if (omSysExitReq == 0) {
sp10.unk00 = 2;
sp10.unk05 = arg1;
msmSeSetParam(arg0, &sp10);
}
}
void HuAudFXListnerSet(s32 arg0, s32 arg1, float arg2, float arg3) {
if (omSysExitReq == 0) {
HuAudFXListnerSetEX(arg0, arg1,
arg2 + Snd3DDistOffset,
arg3 + Snd3DSpeedOffset,
Snd3DStartDisOffset,
Snd3DFrontSurDisOffset + (0.25 * arg2 + Snd3DStartDisOffset),
Snd3DBackSurDisOffset + (0.25 * arg2 + Snd3DStartDisOffset));
}
}
void HuAudFXListnerSetEX(s32 arg0, s32 arg1, float sndDist, float sndSpeed, float arg4, float arg5, float arg6) {
UnkMsmStruct_02 sp1C;
if (omSysExitReq == 0) {
sp1C.unk00 = 7;
sp1C.startDis = arg4 + Snd3DStartDisOffset;
sp1C.frontSurDis = arg5 + Snd3DFrontSurDisOffset;
sp1C.backSurDis = arg6 + Snd3DBackSurDisOffset;
msmSeSetListener(arg0, arg1, sndDist + Snd3DDistOffset, sndSpeed + Snd3DSpeedOffset, &sp1C);
OSReport("//////////////////////////////////\n");
OSReport("sndDist %f\n", sndDist);
OSReport("sndSpeed %f\n", sndSpeed);
OSReport("startDis %f\n", sp1C.startDis);
OSReport("frontSurDis %f\n", sp1C.frontSurDis);
OSReport("backSurDis %f\n", sp1C.backSurDis);
OSReport("//////////////////////////////////\n");
}
}
void HuAudFXListnerUpdate(s32 arg0, s32 arg1) {
if (omSysExitReq == 0) {
msmSeUpdataListener(arg0, arg1);
}
}
s32 HuAudFXEmiterPlay(s32 arg0, Vec *arg1) {
UnkMsmStruct_01 spC;
if (omSysExitReq != 0) {
return 0;
}
spC.unk00 = 0x40;
spC.unk10.x = arg1->x;
spC.unk10.y = arg1->y;
spC.unk10.z = arg1->z;
return HuSePlay(arg0, &spC);
}
void HuAudFXEmiterUpDate(s32 arg0, Vec *arg1) {
UnkMsmStruct_01 spC;
if (omSysExitReq == 0) {
spC.unk00 = 0x40;
spC.unk10.x = arg1->x;
spC.unk10.y = arg1->y;
spC.unk10.z = arg1->z;
msmSeSetParam(arg0, &spC);
}
}
void HuAudFXListnerKill(void) {
msmSeDelListener();
}
void HuAudFXPauseAll(s32 arg0) {
msmSePauseAll(arg0, 0x64);
}
s32 HuAudFXStatusGet(s32 arg0) {
return msmSeGetStatus(arg0);
}
s32 HuAudFXPitchSet(s32 arg0, s16 arg1) {
UnkMsmStruct_01 sp10;
if (omSysExitReq != 0) {
return 0;
}
sp10.unk00 = 4;
sp10.unk06 = arg1;
return msmSeSetParam(arg0, &sp10);
}
s32 HuAudFXVolSet(s32 arg0, s16 arg1) {
UnkMsmStruct_01 sp10;
if (omSysExitReq != 0) {
return 0;
}
sp10.unk00 = 1;
sp10.unk04 = arg1;
return msmSeSetParam(arg0, &sp10);
}
s32 HuAudSeqPlay(s16 arg0) {
s32 temp_r31;
if (musicOffF != 0 || omSysExitReq != 0) {
return 0;
}
temp_r31 = msmMusPlay(arg0, 0);
return temp_r31;
}
void HuAudSeqStop(s32 arg0) {
if (musicOffF != 0 || omSysExitReq != 0) {
return;
}
msmMusStop(arg0, 0);
}
void HuAudSeqFadeOut(s32 arg0, s32 arg1) {
if (musicOffF == 0) {
msmMusStop(arg0, arg1);
}
}
void HuAudSeqAllFadeOut(s32 arg0) {
s16 i;
for (i = 0; i < 4; i++) {
if (msmMusGetStatus(i) == 2) {
msmMusStop(i, arg0);
}
}
}
void HuAudSeqAllStop(void) {
msmMusStopAll(0, 0);
}
void HuAudSeqPauseAll(s32 arg0) {
msmMusPauseAll(arg0, 0x64);
}
void HuAudSeqPause(s32 arg0, s32 arg1, s32 arg2) {
if (musicOffF != 0 || omSysExitReq != 0) {
return;
}
msmMusPause(arg0, arg1, arg2);
}
s32 HuAudSeqMidiCtrlGet(s32 arg0, s8 arg1, s8 arg2) {
if (musicOffF != 0 || omSysExitReq != 0) {
return 0;
}
return msmMusGetMidiCtrl(arg0, arg1, arg2);
}
s32 HuAudSStreamPlay(s16 arg0) {
s32 spC;
s32 temp_r31;
if (musicOffF != 0 || omSysExitReq != 0) {
return 0;
}
spC = 0;
temp_r31 = msmStreamPlay(arg0, &spC);
return temp_r31;
}
void HuAudSStreamStop(s32 arg0) {
if (musicOffF == 0) {
msmStreamStop(arg0, 0);
}
}
void HuAudSStreamFadeOut(s32 arg0, s32 arg1) {
if (musicOffF == 0) {
msmStreamStop(arg0, arg1);
}
}
void HuAudSStreamAllFadeOut(s32 arg0) {
msmStreamPauseAll(arg0);
}
void HuAudSStreamAllStop(void) {
msmStreamPauseAll(0);
}
s32 HuAudSStreamStatGet(s32 arg0) {
return msmStreamGetStatus(arg0);
}
sndGrpTableData sndGrpTable[] = {
{ OVL_BOOT , 0xFFFF, 0, 1, 0xFF, 0xFF },
{ OVL_INST , 0xFFFF, 0, 1, 0xFF, 0xFF },
{ OVL_M401 , 0x0012, 0, 2, 0x40, 0x40 },
{ OVL_M402 , 0x0013, 0, 3, 0x30, 0x20 },
{ OVL_M403 , 0x0014, 0, 1, 0xFF, 0xFF },
{ OVL_M404 , 0x0015, 0, 1, 0xFF, 0xFF },
{ OVL_M405 , 0x0016, 0, 1, 0x40, 0x20 },
{ OVL_M406 , 0x0017, 0, 1, 0xFF, 0xFF },
{ OVL_M407 , 0x0018, 0, 1, 0xFF, 0xFF },
{ OVL_M408 , 0x0019, 0, 1, 0xFF, 0xFF },
{ OVL_M409 , 0x001A, 0, 4, 0xFF, 0xFF },
{ OVL_M410 , 0x001B, 0, 1, 0xFF, 0xFF },
{ OVL_M411 , 0x001C, 0, 1, 0xFF, 0xFF },
{ OVL_M412 , 0x001D, 0, 1, 0xFF, 0xFF },
{ OVL_M413 , 0x001E, 0, 1, 0xFF, 0xFF },
{ OVL_M414 , 0x001F, 0, 1, 0xFF, 0xFF },
{ OVL_M415 , 0x0020, 0, 1, 0xFF, 0xFF },
{ OVL_M416 , 0x0021, 0, 1, 0xFF, 0xFF },
{ OVL_M417 , 0x0022, 0, 1, 0xFF, 0xFF },
{ OVL_M418 , 0x0023, 0, 1, 0x40, 0x40 },
{ OVL_M419 , 0x0024, 0, 6, 0xFF, 0xFF },
{ OVL_M420 , 0x0025, 0, 1, 0xFF, 0xFF },
{ OVL_M421 , 0x0026, 0, 1, 0xFF, 0xFF },
{ OVL_M422 , 0x0027, 0, 1, 0xFF, 0xFF },
{ OVL_M423 , 0x0028, 0, 1, 0xFF, 0xFF },
{ OVL_M424 , 0x0029, 0, 1, 0xFF, 0xFF },
{ OVL_M425 , 0x002A, 0, 1, 0xFF, 0xFF },
{ OVL_M426 , 0x002B, 0, 1, 0xFF, 0xFF },
{ OVL_M427 , 0x002C, 0, 1, 0x40, 0x48 },
{ OVL_M428 , 0x002D, 0, 1, 0xFF, 0xFF },
{ OVL_M429 , 0x002E, 0, 1, 0xFF, 0xFF },
{ OVL_M430 , 0x002F, 0, 1, 0xFF, 0xFF },
{ OVL_M431 , 0x0030, 0, 1, 0xFF, 0xFF },
{ OVL_M432 , 0x0031, 0, 1, 0x30, 0x20 },
{ OVL_M433 , 0x0032, 0, 1, 0xFF, 0xFF },
{ OVL_M434 , 0x0033, 0, 1, 0xFF, 0xFF },
{ OVL_M435 , 0x0034, 0, 9, 0x20, 0x40 },
{ OVL_M436 , 0x0035, 0, 10, 0x20, 0x40 },
{ OVL_M437 , 0x0036, 0, 1, 0x20, 0x40 },
{ OVL_M438 , 0x0037, 0, 11, 0xFF, 0xFF },
{ OVL_M439 , 0x0038, 0, 12, 0x30, 0x20 },
{ OVL_M440 , 0x0039, 0, 1, 0xFF, 0xFF },
{ OVL_M441 , 0x003A, 0, 1, 0xFF, 0xFF },
{ OVL_M442 , 0x003B, 0, 1, 0xFF, 0xFF },
{ OVL_M443 , 0x003C, 0, 1, 0xFF, 0xFF },
{ OVL_M444 , 0x003D, 0, 1, 0xFF, 0xFF },
{ OVL_M445 , 0x003E, 0, 1, 0xFF, 0xFF },
{ OVL_M446 , 0x003F, 0, 1, 0xFF, 0xFF },
{ OVL_M447 , 0x0040, 0, 1, 0xFF, 0xFF },
{ OVL_M448 , 0x0041, 0, 1, 0xFF, 0xFF },
{ OVL_M449 , 0x0042, 0, 1, 0xFF, 0xFF },
{ OVL_M450 , 0x0043, 0, 13, 0x40, 0x40 },
{ OVL_M451 , 0x0044, 0, 1, 0xFF, 0xFF },
{ OVL_M453 , 0x0045, 0, 1, 0xFF, 0xFF },
{ OVL_M455 , 0x0046, 0, 1, 0xFF, 0xFF },
{ OVL_M456 , 0x0047, 0, 1, 0xFF, 0xFF },
{ OVL_M457 , 0x0048, 0, 14, 0x40, 0x20 },
{ OVL_M458 , 0x0049, 0, 15, 0x40, 0x20 },
{ OVL_M459 , 0x004A, 0, 1, 0xFF, 0xFF },
{ OVL_M460 , 0x004B, 0, 1, 0xFF, 0xFF },
{ OVL_M461 , 0x004C, 0, 1, 0xFF, 0xFF },
{ OVL_M462 , 0x004D, 0, 1, 0xFF, 0xFF },
{ OVL_M463 , 0x004E, 0, 1, 0xFF, 0xFF },
{ OVL_MENT , 0xFFFF, 0, 1, 0xFF, 0xFF },
{ OVL_MGMODE , 0x0001, 0, 1, 0xFF, 0xFF },
{ OVL_MODESEL , 0x0000, 0, 1, 0xFF, 0xFF },
{ OVL_MODELTEST, 0x0012, 0, 1, 0xFF, 0xFF },
{ OVL_MSETUP , 0x0000, 0, 1, 0xFF, 0xFF },
{ OVL_MSTORY , 0x0005, 0, 1, 0xFF, 0xFF },
{ OVL_MSTORY2 , 0x0005, 0, 1, 0xFF, 0xFF },
{ OVL_MSTORY3 , 0x0008, 0, 1, 0xFF, 0xFF },
{ OVL_NIS , 0x0009, 0, 1, 0xFF, 0xFF },
{ OVL_OPTION , 0xFFFF, 0, 1, 0xFF, 0xFF },
{ OVL_PRESENT , 0xFFFF, 0, 1, 0xFF, 0xFF },
{ OVL_RESULT , 0xFFFF, 0, 1, 0xFF, 0xFF },
{ OVL_SAF , 0x0000, 0, 2, 0x7F, 0x7F },
{ OVL_SELMENU , 0x0000, 0, 1, 0xFF, 0xFF },
{ OVL_W01 , 0x0009, 0, 1, 0xFF, 0xFF },
{ OVL_W02 , 0x000A, 0, 1, 0xFF, 0xFF },
{ OVL_W03 , 0x000B, 0, 1, 0xFF, 0xFF },
{ OVL_W04 , 0x000C, 0, 1, 0xFF, 0xFF },
{ OVL_W05 , 0x000D, 0, 1, 0xFF, 0xFF },
{ OVL_W06 , 0x000E, 0, 1, 0xFF, 0xFF },
{ OVL_W10 , 0x000F, 0, 1, 0xFF, 0xFF },
{ OVL_W20 , 0x0010, 0, 1, 0xFF, 0xFF },
{ OVL_W21 , 0x0011, 0, 1, 0xFF, 0xFF },
{ OVL_MPEX , 0x0004, 0, 1, 0xFF, 0xFF },
{ OVL_ZTAR , 0xFFFF, 0, 1, 0xFF, 0xFF },
{ OVL_E3SETUP , 0x0000, 0, 1, 0xFF, 0xFF },
{ OVL_STAFF , 0xFFFF, 0, 1, 0xFF, 0xFF },
{ OVL_INVALID , 0xFFFF, 0, 1, 0x00, 0x00 }
};
void HuAudDllSndGrpSet(u16 ovl) {
sndGrpTableData *var_r31;
s16 var_r29;
var_r31 = sndGrpTable;
while (1) {
if (var_r31->unk00 == ovl) {
var_r29 = var_r31->unk02;
break;
}
if (var_r31->unk00 == OVL_INVALID) {
var_r29 = 0x12;
break;
}
var_r31++;
}
if (var_r29 != -1) {
OSReport("SOUND ##########################\n");
HuAudSndGrpSetSet(var_r29);
if (var_r31->unk04 != auxANoBak || var_r31->unk08 != auxBNoBak) {
msmSysSetAux(var_r31->unk04, var_r31->unk08);
OSReport("Change AUX %d,%d\n", var_r31->unk04, var_r31->unk08);
auxANoBak = var_r31->unk04;
auxBNoBak = var_r31->unk08;
HuPrcVSleep();
}
HuAudAUXVolSet(var_r31->unk0C, var_r31->unk0D);
OSReport("##########################\n");
}
}
void HuAudSndGrpSetSet(s16 arg0) {
void *temp_r3;
OSTick temp_r31;
s32 temp_r26;
s32 temp_r27;
if (sndGroupBak != arg0) {
msmMusStopAll(1, 0);
msmSeStopAll(1, 0);
temp_r31 = OSGetTick();
while ((msmMusGetNumPlay(1) != 0 || msmSeGetNumPlay(1) != 0)
&& OSTicksToMilliseconds(OSGetTick() - temp_r31) < 500);
OSReport("%d\n", OSTicksToMilliseconds(OSGetTick() - temp_r31));
if (OSTicksToMilliseconds(OSGetTick() - temp_r31) >= 500) {
temp_r26 = msmSeGetNumPlay(1);
OSReport("Timed Out! Mus %d:SE %d\n", msmMusGetNumPlay(1), temp_r26);
}
OSReport("GroupSet %d\n", arg0);
sndGroupBak = arg0;
temp_r27 = msmSysDelGroupAll();
temp_r3 = HuMemDirectMalloc(HEAP_DATA, msmSysGetSampSize(1));
temp_r27 = msmSysLoadGroupSet(arg0, temp_r3);
OSReport("***********GroupSet Error %d\n", temp_r27);
HuMemDirectFree(temp_r3);
}
}
void HuAudSndGrpSet(s16 arg0) {
void *temp_r3;
temp_r3 = HuMemDirectMalloc(HEAP_DATA, msmSysGetSampSize(arg0));
msmSysLoadGroup(arg0, temp_r3, 0);
HuMemDirectFree(temp_r3);
}
void HuAudSndCommonGrpSet(s16 arg0, s32 arg1) {
s16 temp_r30;
OSTick temp_r27;
void *temp_r3;
s16 i;
for (i = 0; i < 8; i++) {
charVoiceGroupStat[i] = 0;
}
msmMusStopAll(1, 0);
msmSeStopAll(1, 0);
temp_r27 = OSGetTick();
while ((msmMusGetNumPlay(1) != 0 || msmSeGetNumPlay(1) != 0)
&& OSTicksToMilliseconds(OSGetTick() - temp_r27) < 500);
OSReport("CommonGrpSet %d\n", arg0);
if (arg1 != 0) {
temp_r30 = msmSysDelGroupBase(0);
if (temp_r30 < 0) {
OSReport("Del Group Error %d\n", temp_r30);
}
}
temp_r3 = HuMemDirectMalloc(HEAP_DATA, msmSysGetSampSize(arg0));
msmSysLoadGroupBase(arg0, temp_r3);
HuMemDirectFree(temp_r3);
sndGroupBak = -1;
}
void HuAudAUXSet(s32 arg0, s32 arg1) {
if (arg0 == -1) {
arg0 = 0;
}
if (arg1 == -1) {
arg1 = 1;
}
msmSysSetAux(arg0, arg1);
}
void HuAudAUXVolSet(s8 arg0, s8 arg1) {
HuAuxAVol = arg0;
HuAuxBVol = arg1;
}
void HuAudVoiceInit(s16 ovl) {
sndGrpTableData *var_r29;
OSTick temp_r23;
s16 temp_r26;
s16 temp_r25;
s16 temp_r30;
s16 var_r27;
void *temp_r3;
s16 i;
if (ovl != OVL_INVALID) {
var_r29 = sndGrpTable;
while (1) {
if (var_r29->unk00 == ovl && var_r29->unk02 == -1) {
return;
}
if (var_r29->unk00 == OVL_INVALID) {
break;
}
var_r29++;
}
}
for (i = var_r27 = 0; i < 4; i++) {
temp_r30 = GWPlayerCfg[i].character;
if (temp_r30 < 0 || temp_r30 >= 8 || temp_r30 == 0xFF || charVoiceGroupStat[temp_r30] != 0) {
var_r27++;
}
}
if (var_r27 < 4) {
for (i = 0; i < 8; i++) {
charVoiceGroupStat[i] = 0;
}
msmMusStopAll(1, 0);
msmSeStopAll(1, 0);
temp_r23 = OSGetTick();
while ((msmMusGetNumPlay(1) != 0 || msmSeGetNumPlay(1) != 0)
&& OSTicksToMilliseconds(OSGetTick() - temp_r23) < 500);
OSReport("############CharGrpSet\n");
temp_r25 = msmSysDelGroupBase(0);
if (temp_r25 < 0) {
OSReport("Del Group Error %d\n", temp_r25);
} else {
OSReport("Del Group OK\n");
}
for (i = 0; i < 4; i++) {
temp_r30 = GWPlayerCfg[i].character;
if (temp_r30 >= 0 && temp_r30 < 8 && temp_r30 != 0xFF) {
charVoiceGroupStat[temp_r30] = 1;
temp_r26 = temp_r30 + 0xA;
temp_r3 = HuMemDirectMalloc(HEAP_DATA, msmSysGetSampSize(temp_r26));
msmSysLoadGroupBase(temp_r26, temp_r3);
HuMemDirectFree(temp_r3);
}
}
sndGroupBak = -1;
}
}
void HuAudPlayerVoicePlay(s16 arg0, s16 arg1) {
s16 temp_r31 = GWPlayerCfg[arg0].character;
HuAudCharVoicePlay(temp_r31, arg1);
}
void HuAudPlayerVoicePlayPos(s16 arg0, s16 arg1, Vec *arg2) {
s16 temp_r31 = GWPlayerCfg[arg0].character;
HuAudCharVoicePlayPos(temp_r31, arg1, arg2);
}
void HuAudPlayerVoicePlayEntry(s16 arg0, s16 arg1) {
s16 temp_r31 = GWPlayerCfg[arg0].character;
HuAudCharVoicePlayEntry(temp_r31, arg1);
}
s32 HuAudCharVoicePlay(s16 arg0, s16 arg1) {
UnkMsmStruct_01 spC;
if (omSysExitReq != 0) {
return 0;
}
arg1 += (arg0 << 6);
spC.unk00 = 0;
if (HuAuxAVol != -1) {
spC.unk00 |= 0x10;
}
if (HuAuxBVol != -1) {
spC.unk00 |= 0x20;
}
spC.unk09 = HuAuxAVol;
spC.unk0A = HuAuxBVol;
return HuSePlay(arg1, &spC);
}
s32 HuAudCharVoicePlayPos(s16 arg0, s16 arg1, Vec *arg2) {
UnkMsmStruct_01 spC;
if (omSysExitReq != 0) {
return 0;
}
arg1 += (arg0 << 6);
spC.unk00 = 0x40;
if (HuAuxAVol != -1) {
spC.unk00 |= 0x10;
}
if (HuAuxBVol != -1) {
spC.unk00 |= 0x20;
}
spC.unk09 = HuAuxAVol;
spC.unk0A = HuAuxBVol;
spC.unk10.x = arg2->x;
spC.unk10.y = arg2->y;
spC.unk10.z = arg2->z;
return HuSePlay(arg1, &spC);
}
void HuAudCharVoicePlayEntry(s16 arg0, s16 arg1) {
s32 spC[30]; // size unknown (min: 30, max: 33)
u16 temp_r29;
u16 i;
arg1 += (arg0 << 6);
temp_r29 = msmSeGetEntryID(arg1, spC);
for (i = 0; i < temp_r29; i++) {
msmSeStop(spC[i], 0);
}
}
static s32 HuSePlay(s32 arg0, UnkMsmStruct_01 *arg1) {
s32 temp_r3;
temp_r3 = msmSePlay(arg0, arg1);
if (temp_r3 < 0) {
OSReport("#########SE Entry Error<SE %d:ErrorNo %d>\n", arg0, temp_r3);
}
return temp_r3;
}

View file

@ -11,8 +11,6 @@
#include "stdarg.h"
#include "string.h"
#define M_PI 3.141592653589793
typedef struct {
/* 0x00 */ AnimData **anim;
/* 0x04 */ s16 bank;
@ -27,28 +25,26 @@ typedef struct {
/* 0x04 */ u32 player[4];
} keyBufData; // Size 0x14
static void MesDispFunc(SpriteData*);
static u8 winBGMake(AnimData*, AnimData*);
static void MesDispFunc(SpriteData *sprite);
static u8 winBGMake(AnimData *bg, AnimData *frame);
static void HuWinProc(void);
static void HuWinDrawMes(s16 arg0);
static s32 HuWinCR(WindowData* arg0);
static void _HuWinHomeClear(WindowData* arg0);
static void HuWinKeyWait(s16 arg0);
static s16 HuWinSpcFontEntry(WindowData* arg0, s16 arg1, s16 arg2, s16 arg3);
static void HuWinSpcFontClear(WindowData* arg0);
static void HuWinChoice(WindowData* arg0);
static void GetMesMaxSizeSub(u32 arg0);
static s32 GetMesMaxSizeSub2(WindowData* arg0, u8* arg1);
static void HuWinDrawMes(s16 window);
static s32 HuWinCR(WindowData *window);
static void _HuWinHomeClear(WindowData *window);
static void HuWinKeyWait(s16 window);
static s16 HuWinSpcFontEntry(WindowData *window, s16 entry, s16 x, s16 y);
static void HuWinSpcFontClear(WindowData *window);
static void HuWinChoice(WindowData *window);
static void GetMesMaxSizeSub(u32 mess);
static s32 GetMesMaxSizeSub2(WindowData *window, u8 *mess_data);
void* HuAR_DVDtoARAM(s32);
void* HuAR_ARAMtoMRAMFileRead(s32, s32, s32);
void *HuAR_DVDtoARAM(s32);
void *HuAR_ARAMtoMRAMFileRead(s32, s32, s32);
s32 HuAudFXPlay(s32);
void HuAR_ARAMtoMRAM(void*);
void HuDataDirClose(s32);
void* HuDataReadNum(s32, s32);
void mtxTransCat(Mtx, float, float, float);
void* MessData_MesPtrGet(void*, u32);
void *MessData_MesPtrGet(void*, u32);
extern u16 HuPadBtn[4];
extern u8 HuPadDStkRep[4];
@ -62,7 +58,7 @@ static AnimData *cursorAnim;
static AnimData *cardAnimA;
static AnimData *cardAnimB;
static Process *winProc;
void* messDataPtr;
void *messDataPtr;
static s32 messDataNo;
static s16 winMaxWidth;
static s16 winMaxHeight;
@ -179,7 +175,7 @@ static s32 frameFileTbl[] = {
MAKE_DATA_NUM(DATADIR_WIN, 6)
};
static char* mesDataTbl[] = {
static char *mesDataTbl[] = {
"mess/mini.dat",
"mess/board.dat",
"mess/mini_e.dat",
@ -210,7 +206,7 @@ void HuWindowInit(void) {
void HuWinInit(s32 mess_data_no) {
s16 i;
void* anim_data;
void *anim_data;
s8 language;
if (!winProc) {
@ -872,7 +868,7 @@ void HuWinHomeClear(s16 window) {
}
void HuWinKeyWaitEntry(s16 window) {
WindowData* window_ptr = &winData[window];
WindowData *window_ptr = &winData[window];
if (window_ptr->attr & 0x400) {
window_ptr->stat = 0;
@ -883,7 +879,7 @@ void HuWinKeyWaitEntry(s16 window) {
}
static void HuWinKeyWait(s16 window) {
WindowData* window_ptr = &winData[window];
WindowData *window_ptr = &winData[window];
if (window_ptr->push_key & HuWinActivePadGet(window_ptr)) {
window_ptr->key_down = HuWinActivePadGet(window_ptr);
@ -921,7 +917,7 @@ static void HuWinSpcFontPosSet(WindowData *window, s16 index, s16 x, s16 y) {
HuSprPosSet(window->group, index, x - window->w / 2, y - window->h / 2);
}
static void HuWinSpcFontClear(WindowData* window) {
static void HuWinSpcFontClear(WindowData *window) {
s16 i;
for (i=10; i<30; i++) {