Label much of MSM (#535)

This commit is contained in:
Liam Coleman 2025-01-15 23:40:36 -06:00 committed by GitHub
parent f6ca7da943
commit 77da4907df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 2207 additions and 2190 deletions

View file

@ -3568,15 +3568,15 @@ msmStreamSetOutputMode = .text:0x8011A61C; // type:function size:0x114
msmStreamAmemFree = .text:0x8011A730; // type:function size:0x68 msmStreamAmemFree = .text:0x8011A730; // type:function size:0x68
msmStreamAmemAlloc = .text:0x8011A798; // type:function size:0x10C msmStreamAmemAlloc = .text:0x8011A798; // type:function size:0x10C
msmStreamInit = .text:0x8011A8A4; // type:function size:0x2A8 msmStreamInit = .text:0x8011A8A4; // type:function size:0x2A8
msmStreamPauseOff = .text:0x8011AB4C; // type:function size:0x2B8 msmStreamPauseOff = .text:0x8011AB4C; // type:function size:0x2B8 scope:local
msmStreamPauseOn = .text:0x8011AE04; // type:function size:0x1AC msmStreamPauseOn = .text:0x8011AE04; // type:function size:0x1AC scope:local
msmStreamPauseFade = .text:0x8011AFB0; // type:function size:0x2E8 scope:local msmStreamPauseFade = .text:0x8011AFB0; // type:function size:0x2E8 scope:local
msmStreamFade = .text:0x8011B298; // type:function size:0x33C scope:local msmStreamFade = .text:0x8011B298; // type:function size:0x33C scope:local
msmStreamStopSub = .text:0x8011B5D4; // type:function size:0x13C scope:local msmStreamStopSub = .text:0x8011B5D4; // type:function size:0x13C scope:local
msmStreamSetParamSub = .text:0x8011B710; // type:function size:0xE0 scope:local msmStreamSetParamSub = .text:0x8011B710; // type:function size:0xE0 scope:local
msmStreamPackStartStereo = .text:0x8011B7F0; // type:function size:0x448 msmStreamPackStartStereo = .text:0x8011B7F0; // type:function size:0x448 scope:local
msmStreamPackStartMono = .text:0x8011BC38; // type:function size:0x2DC msmStreamPackStartMono = .text:0x8011BC38; // type:function size:0x2DC scope:local
msmStreamSlotOff = .text:0x8011BF14; // type:function size:0xD0 msmStreamSlotOff = .text:0x8011BF14; // type:function size:0xD0 scope:local
msmStreamData = .text:0x8011BFE4; // type:function size:0x320 scope:local msmStreamData = .text:0x8011BFE4; // type:function size:0x320 scope:local
msmStreamDvdCallback = .text:0x8011C304; // type:function size:0x4A8 scope:local msmStreamDvdCallback = .text:0x8011C304; // type:function size:0x4A8 scope:local
msmStreamDvdCallback2 = .text:0x8011C7AC; // type:function size:0x188 scope:local msmStreamDvdCallback2 = .text:0x8011C7AC; // type:function size:0x188 scope:local

View file

@ -3568,15 +3568,15 @@ msmStreamSetOutputMode = .text:0x8011A61C; // type:function size:0x114
msmStreamAmemFree = .text:0x8011A730; // type:function size:0x68 msmStreamAmemFree = .text:0x8011A730; // type:function size:0x68
msmStreamAmemAlloc = .text:0x8011A798; // type:function size:0x10C msmStreamAmemAlloc = .text:0x8011A798; // type:function size:0x10C
msmStreamInit = .text:0x8011A8A4; // type:function size:0x2A8 msmStreamInit = .text:0x8011A8A4; // type:function size:0x2A8
msmStreamPauseOff = .text:0x8011AB4C; // type:function size:0x2B8 msmStreamPauseOff = .text:0x8011AB4C; // type:function size:0x2B8 scope:local
msmStreamPauseOn = .text:0x8011AE04; // type:function size:0x1AC msmStreamPauseOn = .text:0x8011AE04; // type:function size:0x1AC scope:local
msmStreamPauseFade = .text:0x8011AFB0; // type:function size:0x2E8 msmStreamPauseFade = .text:0x8011AFB0; // type:function size:0x2E8 scope:local
msmStreamFade = .text:0x8011B298; // type:function size:0x33C msmStreamFade = .text:0x8011B298; // type:function size:0x33C scope:local
msmStreamStopSub = .text:0x8011B5D4; // type:function size:0x13C scope:local msmStreamStopSub = .text:0x8011B5D4; // type:function size:0x13C scope:local
msmStreamSetParamSub = .text:0x8011B710; // type:function size:0xE0 scope:local msmStreamSetParamSub = .text:0x8011B710; // type:function size:0xE0 scope:local
msmStreamPackStartStereo = .text:0x8011B7F0; // type:function size:0x448 msmStreamPackStartStereo = .text:0x8011B7F0; // type:function size:0x448 scope:local
msmStreamPackStartMono = .text:0x8011BC38; // type:function size:0x2DC msmStreamPackStartMono = .text:0x8011BC38; // type:function size:0x2DC scope:local
msmStreamSlotOff = .text:0x8011BF14; // type:function size:0xD0 msmStreamSlotOff = .text:0x8011BF14; // type:function size:0xD0 scope:local
msmStreamData = .text:0x8011BFE4; // type:function size:0x320 scope:local msmStreamData = .text:0x8011BFE4; // type:function size:0x320 scope:local
msmStreamDvdCallback = .text:0x8011C304; // type:function size:0x4A8 scope:local msmStreamDvdCallback = .text:0x8011C304; // type:function size:0x4A8 scope:local
msmStreamDvdCallback2 = .text:0x8011C7AC; // type:function size:0x188 scope:local msmStreamDvdCallback2 = .text:0x8011C7AC; // type:function size:0x188 scope:local

View file

@ -3,6 +3,7 @@
#include "dolphin.h" #include "dolphin.h"
#include "musyx/musyx.h" #include "musyx/musyx.h"
#include "game/msm_data.h"
#define MSM_SEPARAM_NONE 0 #define MSM_SEPARAM_NONE 0
#define MSM_SEPARAM_VOL (1 << 0) #define MSM_SEPARAM_VOL (1 << 0)
@ -40,25 +41,24 @@
#define MSM_ERR_READFAIL -2 #define MSM_ERR_READFAIL -2
#define MSM_ERR_OUTOFMEM -10 #define MSM_ERR_OUTOFMEM -10
#define MSM_ERR_OUTOFAMEM -20 #define MSM_ERR_OUTOFAMEM -20
#define MSM_ERR_INITFAIL -20 #define MSM_ERR_INITFAIL -30
#define MSM_ERR_1E -30
#define MSM_ERR_INVALID_AUXPARAM -31 #define MSM_ERR_INVALID_AUXPARAM -31
#define MSM_ERR_20 -32 #define MSM_ERR_GRP_FAILPUSH -32
#define MSM_ERR_PLAYFAIL -33 #define MSM_ERR_PLAYFAIL -33
#define MSM_ERR_22 -34 #define MSM_LISTENER_NO_UPDATA -34
#define MSM_ERR_STREAMALLOC_FAIL -35 #define MSM_ERR_STREAMALLOC_FAIL -35
#define MSM_ERR_INSTALLED -36 #define MSM_ERR_INSTALLED -36
#define MSM_ERR_64 -100 #define MSM_ERR_64 -100
#define MSM_ERR_65 -101 #define MSM_ERR_STACK_OVERFLOW -101
#define MSM_ERR_GRP_NOTLOADED -103 #define MSM_ERR_GRP_NOTLOADED -103
#define MSM_ERR_6E -110 #define MSM_ERR_CHANLIMIT -110
#define MSM_ERR_6F -111 #define MSM_ERR_INVALIDSE -111
#define MSM_ERR_INVALIDID -120 #define MSM_ERR_INVALIDID -120
#define MSM_ERR_INVALIDFILE -121 #define MSM_ERR_INVALIDFILE -121
#define MSM_ERR_REMOVEDID -122 #define MSM_ERR_REMOVEDID -122
#define MSM_ERR_MUSGRP_NOTLOADED -123 #define MSM_ERR_MUSGRP_NOTLOADED -123
#define MSM_ERR_OUTOFMUS -130 #define MSM_ERR_OUTOFMUS -130
#define MSM_ERR_8C -140 #define MSM_ERR_RANGE_STREAM -140
#define MSM_VOL_MAX 127 #define MSM_VOL_MAX 127
#define MSM_PAN_LEFT 32 #define MSM_PAN_LEFT 32
@ -132,19 +132,6 @@ typedef struct msmSeParam_s {
Vec pos; Vec pos;
} MSM_SEPARAM; } MSM_SEPARAM;
typedef struct msmSe_s {
u16 groupId;
u16 fxId;
s8 vol;
s8 pan;
s16 pitchBend;
u8 span;
u8 reverb;
u8 chorus;
s8 doppler;
s8 comp;
u8 pad[3];
} MSMSE;
typedef struct msmSeListener_s { typedef struct msmSeListener_s {
s32 flag; s32 flag;
@ -173,10 +160,11 @@ typedef struct msmStreamParam_s {
} MSM_STREAMPARAM; } MSM_STREAMPARAM;
s32 msmSysInit(MSM_INIT *init, MSM_ARAM *aram); s32 msmSysInit(MSM_INIT *init, MSM_ARAM *aram);
s32 msmSysSetOutputMode(SND_OUTPUTMODE mode); BOOL msmSysSetOutputMode(SND_OUTPUTMODE mode);
s32 msmSysDelGroupAll(void); s32 msmSysDelGroupAll(void);
s32 msmSysGetSampSize(BOOL baseGrp); s32 msmSysGetSampSize(BOOL baseGrp);
s32 msmSysDelGroupBase(s32 grpNum); s32 msmSysDelGroupBase(s32 grpNum);
s32 msmSysSetAux(s32 auxA, s32 auxB);
s32 msmSeSetParam(int seNo, MSM_SEPARAM *param); s32 msmSeSetParam(int seNo, MSM_SEPARAM *param);
int msmSePlay(int seId, MSM_SEPARAM *param); int msmSePlay(int seId, MSM_SEPARAM *param);
@ -190,6 +178,8 @@ void msmSeDelListener(void);
s32 msmSeGetStatus(int seNo); s32 msmSeGetStatus(int seNo);
s32 msmSeGetNumPlay(BOOL baseGrp); s32 msmSeGetNumPlay(BOOL baseGrp);
s32 msmSeGetEntryID(s32 seId, int *seNo); s32 msmSeGetEntryID(s32 seId, int *seNo);
void msmSeSetMasterVolume(s32 vol);
MSM_SE* msmSeGetIndexPtr(s32 seId);
int msmMusPlay(int musId, MSM_MUSPARAM *musParam); int msmMusPlay(int musId, MSM_MUSPARAM *musParam);
s32 msmMusStop(int musNo, s32 speed); s32 msmMusStop(int musNo, s32 speed);
@ -199,6 +189,8 @@ s32 msmMusGetMidiCtrl(int musNo, s32 channel, s32 ctrl);
void msmMusStopAll(BOOL checkGrp, s32 speed); void msmMusStopAll(BOOL checkGrp, s32 speed);
s32 msmMusGetStatus(int musNo); s32 msmMusGetStatus(int musNo);
s32 msmMusGetNumPlay(BOOL baseGrp); s32 msmMusGetNumPlay(BOOL baseGrp);
s32 msmMusSetParam(s32 musNo, MSM_MUSPARAM *param);
void msmMusSetMasterVolume(s32 vol);
int msmStreamPlay(int streamId, MSM_STREAMPARAM *streamParam); int msmStreamPlay(int streamId, MSM_STREAMPARAM *streamParam);
s32 msmStreamStop(int streamNo, s32 speed); s32 msmStreamStop(int streamNo, s32 speed);
@ -207,5 +199,7 @@ s32 msmStreamPause(int streamNo, BOOL pause, s32 speed);
void msmStreamStopAll(s32 speed); void msmStreamStopAll(s32 speed);
s32 msmStreamGetStatus(int streamNo); s32 msmStreamGetStatus(int streamNo);
void msmStreamSetMasterVolume(s32 arg0);
void msmStreamSetOutputMode(s32 outputMode);
#endif #endif

185
include/game/msm_data.h Normal file
View file

@ -0,0 +1,185 @@
#ifndef _MSM_DATA_H
#define _MSM_DATA_H
#include "dolphin.h"
#include "musyx/musyx.h"
#define MSM_STREAM_FLAG_STEREO 0x1
#define MSM_STREAM_FLAG_LOOP 0x2
#define MSM_FILE_VERSION 2
#define MSM_PDT_FILE_VERSION 1
typedef struct MSMHeader_s {
s32 magic;
s32 version;
s32 endOfs;
s32 endSize;
s32 infoOfs;
u32 infoSize;
s32 auxParamOfs;
u32 auxParamSize;
s32 grpInfoOfs;
s32 grpInfoSize;
s32 musOfs;
s32 musSize;
s32 seOfs;
s32 seSize;
s32 grpDataOfs;
s32 grpDataSize;
s32 sampOfs;
s32 sampSize;
s32 dummyMusOfs;
s32 dummyMusSize;
s32 grpSetOfs;
s32 grpSetSize;
s32 pad[2];
} MSM_HEADER; // sizeof 0x60
typedef struct MSMInfo_s {
s8 voices;
s8 music;
s8 sfx;
s8 grpMax;
s16 musMax;
s16 seMax;
s8 musChanMax;
s8 stackDepthA;
s8 stackDepthB;
s8 surroundF;
s8 unkC[2];
s8 auxParamA;
s8 auxParamB;
s32 minMem;
s32 aramSize;
s32 grpBufSizeA;
s32 grpBufSizeB;
s32 dummyMusSize;
s32 unk24;
s8 baseGrpNum;
s8 baseGrp[23];
} MSM_INFO;
typedef struct {
u32 tempDisableFX;
f32 coloration;
f32 mix;
f32 time;
f32 damping;
f32 preDelay;
f32 crosstalk;
} MSM_AUXPARAM_REVERBHI;
typedef struct {
u32 tempDisableFX;
f32 coloration;
f32 mix;
f32 time;
f32 damping;
f32 preDelay;
f32 crosstalk;
} MSM_AUXPARAM_REVERBSTD;
typedef struct {
u32 baseDelay;
u32 variation;
u32 period;
} MSM_AUXPARAM_CHORUS;
typedef struct {
u32 delay[3];
u32 feedback[3];
u32 output[3];
} MSM_AUXPARAM_DELAY;
typedef struct MSMAuxParam_s {
s8 type;
u8 pad[3];
union {
MSM_AUXPARAM_REVERBHI revHi;
MSM_AUXPARAM_REVERBSTD revStd;
MSM_AUXPARAM_CHORUS chorus;
MSM_AUXPARAM_DELAY delay;
};
} MSM_AUXPARAM;
typedef struct MSMSe_s {
SND_GROUPID gid;
SND_FXID fxId;
s8 vol;
s8 pan;
s16 pitchBend;
u8 span;
u8 reverb;
u8 chorus;
s8 emitterF;
s8 emiComp;
u8 pad[3];
} MSM_SE;
typedef struct MSMMus_s {
SND_GROUPID sgid;
SND_SONGID sid;
s32 songOfs;
s32 songSize;
s8 songGrp;
s8 vol;
u8 pad[2];
} MSM_MUS; // Size 0x10
typedef struct MSMGrpHead_s {
s32 poolOfs;
s32 projOfs;
s32 sdirOfs;
s32 sngOfs;
} MSM_GRP_HEAD;
typedef struct MSMGrpInfo_s {
SND_GROUPID gid;
s8 stackNo;
s8 subGrpId;
s32 dataOfs;
s32 dataSize;
s32 sampOfs;
s32 sampSize;
u8 pad[12];
} MSM_GRP_INFO;
typedef struct MSMGrpSet_s {
s8 numGrpSet;
s8 grpSetW;
s8 data[1];
} MSM_GRP_SET;
typedef struct MSMStreamHeader_s {
s16 version;
s16 streamMax;
s32 chanMax;
s32 sampleFrq;
s32 maxBufs;
u32 streamPackListOfs;
u32 adpcmParamOfs;
u32 streamPackOfs;
u32 sampleOfs;
} MSM_STREAM_HEADER;
typedef struct MSMStream_s {
s32 sampleOfs;
s16 adpcmParamIdx;
u16 pad;
} MSM_STREAM;
typedef struct MSMStreamPack_s {
s8 flag;
s8 vol;
s8 pan;
s8 span;
s8 auxA;
s8 auxB;
u16 frq;
u32 loopOfsEnd;
u32 loopOfsStart;
MSM_STREAM stream[2];
} MSM_STREAM_PACK; // Size unknown
#endif

View file

@ -3,8 +3,8 @@
#include "dolphin/types.h" #include "dolphin/types.h"
void msmMemFree(void *); void msmMemFree(void *ptr);
void *msmMemAlloc(u32); void *msmMemAlloc(u32 sze);
void msmMemInit(void *, u32); void msmMemInit(void *ptr, u32 size);
#endif #endif

View file

@ -16,6 +16,6 @@ s32 msmMusPause(int musNo, BOOL pause, s32 speed);
void msmMusStopAll(BOOL checkGrp, s32 speed); void msmMusStopAll(BOOL checkGrp, s32 speed);
s32 msmMusStop(int musNo, s32 speed); s32 msmMusStop(int musNo, s32 speed);
int msmMusPlay(int musId, MSM_MUSPARAM* musParam); int msmMusPlay(int musId, MSM_MUSPARAM* musParam);
s32 msmMusInit(sysData* arg0, DVDFileInfo* arg1); s32 msmMusInit(MSM_SYS* arg0, DVDFileInfo* arg1);
#endif #endif

View file

@ -5,7 +5,7 @@
#include "msm/msmsys.h" #include "msm/msmsys.h"
void msmSePeriodicProc(void); void msmSePeriodicProc(void);
MSMSE* msmSeGetIndexPtr(s32 arg0); MSM_SE* msmSeGetIndexPtr(s32 arg0);
void msmSeDelListener(void); void msmSeDelListener(void);
s32 msmSeUpdataListener(Vec* pos, Vec* heading); s32 msmSeUpdataListener(Vec* pos, Vec* heading);
s32 msmSeSetListener(Vec* pos, Vec* heading, float sndDist, float sndSpeed, MSM_SELISTENER* listener); s32 msmSeSetListener(Vec* pos, Vec* heading, float sndDist, float sndSpeed, MSM_SELISTENER* listener);
@ -18,6 +18,6 @@ void msmSePauseAll(BOOL pause, s32 speed);
void msmSeStopAll(BOOL checkGrp, s32 speed); void msmSeStopAll(BOOL checkGrp, s32 speed);
s32 msmSeStop(int seNo, s32 speed); s32 msmSeStop(int seNo, s32 speed);
int msmSePlay(int seId, MSM_SEPARAM* param); int msmSePlay(int seId, MSM_SEPARAM* param);
s32 msmSeInit(sysData* arg0, DVDFileInfo* arg1); s32 msmSeInit(MSM_SYS* arg0, DVDFileInfo* arg1);
#endif #endif

View file

@ -13,10 +13,6 @@ void msmStreamSetOutputMode(s32 arg0);
void msmStreamAmemFree(void); void msmStreamAmemFree(void);
s32 msmStreamAmemAlloc(void); s32 msmStreamAmemAlloc(void);
s32 msmStreamInit(char* arg0); s32 msmStreamInit(char* arg0);
void msmStreamPauseOff(s32 arg0);
void msmStreamPauseOn(s32 streamNo, s32 arg1);
s32 msmStreamPackStartStereo(s32 arg0, MSM_STREAMPARAM* arg1, s32 arg2);
s32 msmStreamPackStartMono(s32 arg0, MSM_STREAMPARAM* arg1, s32 arg2);
void msmStreamSlotOff(s32 streamNo);
#endif #endif

View file

@ -5,167 +5,63 @@
#include "dolphin.h" #include "dolphin.h"
typedef struct { #define MSM_AUX_REVERBHI 0
u32 tempDisableFX; #define MSM_AUX_REVERBSTD 1
f32 coloration; #define MSM_AUX_CHORUS 2
f32 mix; #define MSM_AUX_DELAY 3
f32 time;
f32 damping;
f32 preDelay;
f32 crosstalk;
} SubStructRev;
typedef struct { #define MSM_AUXNO_NULL -2
u32 baseDelay; #define MSM_AUXNO_UNSET -1
u32 variation;
u32 period;
} SubStructCh;
typedef struct {
u32 delay[3];
u32 feedback[3];
u32 output[3];
} SubDelay;
typedef struct _unkSubStruct {
s8 unk0;
union {
SubStructRev rev;
SubStructCh ch;
SubDelay delay;
};
} unkSubStruct;
typedef union { typedef union {
SND_AUX_REVERBHI revHi; SND_AUX_REVERBHI revHi;
SND_AUX_REVERBSTD revStd; SND_AUX_REVERBSTD revStd;
SND_AUX_CHORUS ch; SND_AUX_CHORUS chorus;
SND_AUX_DELAY delay; SND_AUX_DELAY delay;
} UnkSndAuxUnion; // Size 0x1E0 } MSM_AUX; // Size 0x1E0
typedef struct _unkSubStruct3 { typedef struct MSMGrpWork_s {
char unk[0x4]; s8 grpId;
s32 unk4; s8 baseGrpF;
char unk8[0x8]; u32 num;
s32 unk10; // offset void *buf;
u32 unk14; // length } MSM_GRP_STACK;
s32 unk18; // offset
u32 unk1C; // length
s32 unk20;
s32 unk24;
s32 unk28;
s32 unk2C;
s32 unk30;
s32 unk34;
s32 unk38;
char unk3C[4];
s32 unk40;
char unk44[4];
s32 unk48;
char unk4C[4];
s32 unk50;
s32 unk54;
char unk58[8];
} unkSubStruct3; // sizeof 0x60
typedef struct _unkStruct3 { typedef struct MSMSys_s {
s32 unk0; s32 msmEntryNum;
s32 unk4; s8 outputMode;
s32 unk8;
} unkStruct3;
typedef struct _sndInitData {
s8 unk0;
s8 unk1;
s8 unk2;
s8 unk3;
s16 unk4;
s16 unk6;
s8 unk8;
s8 unk9;
s8 unkA;
s8 unkB;
char unkC[2];
s8 unkE;
s8 unkF;
u32 unk10;
s32 unk14;
s32 unk18;
s32 unk1C;
s32 unk20;
char unk24[4];
s8 unk28;
s8 unk29[10]; // size unknown
} sndInitData;
typedef struct {
/* 0x00 */ s8 unk00;
/* 0x01 */ s8 unk01;
/* 0x02 */ char unk02[2];
/* 0x04 */ u32 unk04;
/* 0x08 */ void *unk08;
} UnkStructSys43C; // Size 0xC
typedef struct _unkStruct4 {
SND_GROUPID unk0;
s8 unk2;
s8 unk3;
s32 unk4;
s32 unk8;
s32 unkC;
s32 unk10;
char unk14[0xC];
} unkStruct4; // Size 0x20
typedef struct {
/* 0x00 */ s8 unk00;
/* 0x01 */ s8 unk01;
/* 0x02 */ s8 unk02[1]; // unknown array length
} UnkSys3F0Struct; // Size unknown
typedef struct _sysData {
s32 unk0;
s8 unk4;
s8 unk5; s8 unk5;
s8 unk6; s8 unk6;
s8 unk7; s8 arInitF;
s32 unk8; s32 aramP;
unkSubStruct3 *unkC; MSM_HEADER *header;
sndInitData *unk10; MSM_INFO *info;
unkSubStruct *unk14; MSM_AUXPARAM *auxParam;
s8 unk18[2]; s8 auxParamNo[2];
s8 unk1A; MSM_AUX aux[2]; // 0: userA, 1: userB
s8 unk1B; s8 grpMax;
UnkSndAuxUnion unk1C[2]; // 0: userA, 1: userB s32 grpNum;
s8 unk3DC; u32 sampSize;
char unk3DD[3]; u32 sampSizeBase;
s32 unk3E0; MSM_GRP_INFO *grpInfo;
u32 unk3E4; MSM_GRP_SET *grpSet;
u32 unk3E8; s8 baseGrpNum;
unkStruct4 *unk3EC; MSM_GRP_HEAD *grpData[15];
UnkSys3F0Struct *unk3F0; s8 grpStackAMax;
s8 unk3F4; u8 grpStackADepth;
unkStruct3 *unk3F8[1]; // unknown array length s8 grpStackAOfs;
char unk3FC[0x38]; void *grpBufA;
s8 unk434; MSM_GRP_STACK grpStackA[4];
u8 unk435; s8 grpStackBMax;
s8 unk436; u8 grpStackBDepth;
char unk437[1]; s8 grpStackBOfs;
void *unk438; void *grpBufB;
UnkStructSys43C unk43C[1]; // unknown array length MSM_GRP_STACK grpStackB[10];
char unk448[0x24]; s32 irqDepth;
s8 unk46C; BOOL irqState;
u8 unk46D; AIDCallback oldAIDCallback;
s8 unk46E; s32 timer;
char unk46F[1]; } MSM_SYS;
void *unk470;
UnkStructSys43C unk474[1]; // unknown array length
char unk480[0x6C];
s32 unk4EC;
BOOL unk4F0;
AIDCallback unk4F4;
s32 unk4F8;
} sysData;
s32 msmSysSearchGroupStack(s32 arg0, s32 arg1); s32 msmSysSearchGroupStack(s32 arg0, s32 arg1);
s32 msmSysGroupInit(DVDFileInfo *arg0); s32 msmSysGroupInit(DVDFileInfo *arg0);
@ -176,8 +72,7 @@ void *msmSysGetGroupDataPtr(s32 arg0);
BOOL msmSysCheckLoadGroupID(s32 arg0); BOOL msmSysCheckLoadGroupID(s32 arg0);
void msmSysRegularProc(void); void msmSysRegularProc(void);
s32 msmSysGetOutputMode(void); s32 msmSysGetOutputMode(void);
s32 msmSysSetOutputMode(SND_OUTPUTMODE mode); BOOL msmSysSetOutputMode(SND_OUTPUTMODE mode);
s32 msmSysSetAux(s32 arg0, s32 arg1);
s32 msmSysGetSampSize(BOOL baseGrp); s32 msmSysGetSampSize(BOOL baseGrp);
s32 msmSysDelGroupAll(void); s32 msmSysDelGroupAll(void);
s32 msmSysDelGroupBase(s32 grpNum); s32 msmSysDelGroupBase(s32 grpNum);

View file

@ -1,133 +1,132 @@
#include "msm/msmmem.h" #include "msm/msmmem.h"
typedef struct _unkStruct { typedef struct MSMBlock_s {
struct _unkStruct* prev; struct MSMBlock_s* prev;
struct _unkStruct* next; struct MSMBlock_s* next;
u32 unk8; u32 freeSize;
u32 unkC; u32 size;
void* unk10; void* ptr;
void* unk14; char pad[12];
char unk18[0x8]; } MSMBLOCK;
} unkStruct;
typedef struct _unkMemStruct { typedef struct MSMMem_s {
unkStruct* unk0; void *ptr;
u32 unk4; u32 size;
unkStruct* unk8; MSMBLOCK *head;
unkStruct unkC; MSMBLOCK first;
} unkMemStruct; } MSM_MEM;
static unkMemStruct mem; static MSM_MEM mem;
void msmMemFree(void* arg0) { void msmMemFree(void* ptr) {
unkStruct* temp_r6; MSMBLOCK* block;
unkStruct* temp_r7; MSMBLOCK* blockPrev;
unkStruct* temp_r8; MSMBLOCK* blockNext;
unkStruct* temp_r5; MSMBLOCK* blockHead;
unkStruct* temp; MSMBLOCK* base;
temp = arg0; base = ptr;
temp_r6 = &temp[-1]; block = &base[-1];
temp_r7 = temp_r6->prev; blockPrev = block->prev;
temp_r8 = temp_r6->next; blockNext = block->next;
if (mem.unk0 > temp_r6 || ((u32)mem.unk0 + (u32)mem.unk4) <= (u32)temp_r6) { if (mem.ptr > block || ((u32)mem.ptr + (u32)mem.size) <= (u32)block) {
return; return;
} }
if ((temp_r7->next != temp_r6) || (temp_r6->unk10 != arg0) || (temp_r8 && (temp_r8->prev != temp_r6))) { if ((blockPrev->next != block) || (block->ptr != ptr) || (blockNext && (blockNext->prev != block))) {
return; return;
} }
temp_r7->unkC += temp_r6->unk8 + temp_r6->unkC; blockPrev->size += block->freeSize + block->size;
temp_r7->next = temp_r8; blockPrev->next = blockNext;
temp_r5 = mem.unk8; blockHead = mem.head;
if ((temp_r5 == temp_r6) || (temp_r5->unkC < temp_r7->unkC)) { if ((blockHead == block) || (blockHead->size < blockPrev->size)) {
mem.unk8 = temp_r7; mem.head = blockPrev;
} }
if (temp_r8) { if (blockNext) {
temp_r8->prev = temp_r7; blockNext->prev = blockPrev;
if (mem.unk8->unkC < temp_r8->unkC) { if (mem.head->size < blockNext->size) {
mem.unk8 = temp_r8; mem.head = blockNext;
} }
} }
} }
void* msmMemAlloc(u32 arg0) { void* msmMemAlloc(u32 size) {
s32 temp_r0; s32 alignOfs;
u32 var_r5; u32 freeSize;
u32 var_r7; u32 allocSize;
unkStruct* temp_r5; MSMBLOCK* block;
unkStruct* var_r8; MSMBLOCK* blockPrev;
unkStruct* temp_r9; MSMBLOCK* blockNext;
var_r7 = arg0 + 0x20; allocSize = size + 0x20;
temp_r0 = var_r7 & 0x1F; alignOfs = allocSize & 0x1F;
if (temp_r0 != 0) { if (alignOfs) {
var_r7 += 0x20 - temp_r0; allocSize += 0x20 - alignOfs;
} }
if (mem.unk8->unkC >= var_r7) { if (mem.head->size >= allocSize) {
var_r8 = mem.unk8; blockPrev = mem.head;
} else { } else {
var_r8 = &mem.unkC; blockPrev = &mem.first;
do { do {
if (var_r8->unkC >= var_r7) break; if (blockPrev->size >= allocSize) break;
var_r8 = var_r8->next; blockPrev = blockPrev->next;
} while (var_r8); } while (blockPrev);
if (!var_r8) { if (!blockPrev) {
return NULL; return NULL;
} }
} }
var_r5 = var_r8->unk8; freeSize = blockPrev->freeSize;
if (var_r5 != 0) { if (freeSize != 0) {
var_r5 -= 0x20; freeSize -= 0x20;
} }
temp_r5 = (void*)((u32)var_r8->unk10 + (var_r5)); block = (void*)((u32)blockPrev->ptr + (freeSize));
temp_r9 = var_r8->next; blockNext = blockPrev->next;
if ((mem.unk0 > temp_r5) || ((void*)((u32)mem.unk0 + (u32)mem.unk4) <= temp_r5)) { if ((mem.ptr > block) || ((void*)((u32)mem.ptr + (u32)mem.size) <= block)) {
return NULL; return NULL;
} }
temp_r5->unk8 = var_r7; block->freeSize = allocSize;
temp_r5->unkC = var_r8->unkC - var_r7; block->size = blockPrev->size - allocSize;
temp_r5->unk10 = (temp_r5 + 1); block->ptr = (block + 1);
temp_r5->prev = var_r8; block->prev = blockPrev;
temp_r5->next = temp_r9; block->next = blockNext;
mem.unk8 = temp_r5; mem.head = block;
var_r8->unkC = 0; blockPrev->size = 0;
var_r8->next = temp_r5; blockPrev->next = block;
if (temp_r9) { if (blockNext) {
temp_r9->prev = temp_r5; blockNext->prev = block;
if (mem.unk8->unkC < temp_r9->unkC) { if (mem.head->size < blockNext->size) {
mem.unk8 = temp_r9; mem.head = blockNext;
} }
} }
return temp_r5->unk10; return block->ptr;
} }
void msmMemInit(void* arg0, u32 arg1) { void msmMemInit(void* ptr, u32 size) {
unkStruct* temp_r7; MSMBLOCK* block;
s32 temp; s32 ofs;
temp = (s32)arg0 & 0x1F; ofs = (s32)ptr & 0x1F;
switch (temp) { switch (ofs) {
default: default:
temp = 0x20 - temp; ofs = 0x20 - ofs;
break; break;
case 0: case 0:
temp = 0; ofs = 0;
break; break;
} }
mem.unk0 = (void*)((s32)arg0 + temp); mem.ptr = (void*)((s32)ptr + ofs);
temp = (s32)arg0 + arg1; ofs = (s32)ptr + size;
mem.unk4 = ((temp - (s32)mem.unk0) & ~0x1F); mem.size = ((ofs - (s32)mem.ptr) & ~0x1F);
temp_r7 = &mem.unkC; block = &mem.first;
temp_r7->unk8 = 0; block->freeSize = 0;
temp_r7->unkC = mem.unk4; block->size = mem.size;
temp_r7->unk10 = mem.unk0; block->ptr = mem.ptr;
temp_r7->prev = NULL; block->prev = NULL;
temp_r7->next = NULL; block->next = NULL;
mem.unk8 = &mem.unkC; mem.head = &mem.first;
} }

View file

@ -1,150 +1,127 @@
#include "msm/msmmus.h" #include "msm/msmmus.h"
#include "msm/msmmem.h" #include "msm/msmmem.h"
typedef struct { typedef struct MusPlayer_s {
/* 0x00 */ s16 unk00; /* 0x00 */ s16 musId;
/* 0x02 */ s8 unk02; /* 0x02 */ s8 baseVol;
/* 0x03 */ s8 unk03; /* 0x03 */ s8 vol;
/* 0x04 */ s8 unk04; /* 0x04 */ s8 status;
/* 0x05 */ s8 unk05; /* 0x05 */ s8 busyF;
/* 0x06 */ char unk06[2]; /* 0x08 */ SND_SEQID seqId;
/* 0x08 */ SND_SEQID unk08; /* 0x0C */ void* songBuf;
/* 0x0C */ void* unk0C; /* 0x10 */ void* arrfile;
/* 0x10 */ void* unk10; /* 0x14 */ volatile s32 fadeMaxTime;
/* 0x14 */ volatile s32 unk14; /* 0x18 */ s32 fadeTime;
/* 0x18 */ s32 unk18; /* 0x1C */ s8 fadeVol;
/* 0x1C */ s8 unk1C; /* 0x20 */ volatile s32 pauseOnMaxTime;
/* 0x1D */ char unk1D[3]; /* 0x24 */ s32 pauseOnTime;
/* 0x20 */ volatile s32 unk20; /* 0x28 */ s8 pauseOnVol;
/* 0x24 */ s32 unk24; /* 0x2C */ volatile s32 pauseOffMaxTime;
/* 0x28 */ s8 unk28; /* 0x30 */ s32 pauseOffTime;
/* 0x29 */ char unk29[3]; /* 0x28 */ s8 pauseOffVol;
/* 0x2C */ volatile s32 unk2C; /* 0x35 */ volatile s8 startVol;
/* 0x30 */ s32 unk30; /* 0x36 */ s8 targetVol;
/* 0x34 */ char unk34[1]; /* 0x38 */ SND_PLAYPARA playPara;
/* 0x35 */ volatile s8 unk35; } MUS_PLAYER; // Size 0x58
/* 0x36 */ s8 unk36;
/* 0x37 */ char unk37[1];
/* 0x38 */ SND_PLAYPARA unk38;
} msmMusStruct00; // Size 0x58
typedef struct { static struct {
/* 0x00 */ u16 unk00; /* 0x000 */ s16 musMax;
/* 0x02 */ s16 unk02; /* 0x002 */ s8 musChanMax;
/* 0x04 */ s32 unk04; /* 0x003 */ s8 baseGrpNumPlay;
/* 0x08 */ s32 unk08; /* 0x004 */ s8 numPlay;
/* 0x0C */ s8 unk0C; /* 0x008 */ s32 msmEntryNum;
/* 0x0D */ s8 unk0D; /* 0x00C */ MSM_MUS *musData;
/* 0x0E */ char unk0E[2]; /* 0x010 */ s32 dummyMusOfs;
} msmMusStruct01; // Size 0x10 /* 0x014 */ void* musBuf;
/* 0x018 */ MUS_PLAYER player[4];
} mus;
typedef struct { static void msmMusPauseSub(MUS_PLAYER* player, BOOL pause, s32 speed) {
/* 0x000 */ s16 unk00; s32 time;
/* 0x002 */ s8 unk02;
/* 0x003 */ s8 unk03;
/* 0x004 */ s8 unk04;
/* 0x005 */ char unk05[3];
/* 0x008 */ s32 unk08;
/* 0x00C */ msmMusStruct01* unk0C;
/* 0x010 */ s32 unk10;
/* 0x014 */ void* unk14;
/* 0x018 */ msmMusStruct00 unk18[1]; // unknown length
/* 0x01C */ char unk70[0x108];
} msmMusStruct02; // Size 0x178
typedef struct { time = speed / 15;
/* 0x00 */ char unk00[0xC];
/* 0x0C */ s32 unk0C;
} UnkGroupDataPtr; // Size unknown
static msmMusStruct02 mus;
static void msmMusPauseSub(msmMusStruct00* arg0, BOOL pause, s32 speed) {
s32 temp_r30;
temp_r30 = speed / 15;
if (pause) { if (pause) {
if (arg0->unk04 == 2) { if (player->status == MSM_MUS_PLAY) {
if (temp_r30 != 0) { if (time != 0) {
arg0->unk24 = temp_r30; player->pauseOnTime = time;
arg0->unk20 = temp_r30; player->pauseOnMaxTime = time;
arg0->unk28 = 0x7F; player->pauseOnVol = 127;
} else { } else {
sndSeqPause(arg0->unk08); sndSeqPause(player->seqId);
arg0->unk28 = 0; player->pauseOnVol = 0;
} }
arg0->unk04 = 3; player->status = MSM_MUS_PAUSE;
} }
} else { } else {
if (arg0->unk04 == 3) { if (player->status == MSM_MUS_PAUSE) {
if (temp_r30 != 0) { if (time != 0) {
if (arg0->unk20 != 0) { if (player->pauseOnMaxTime != 0) {
arg0->unk20 = -temp_r30; player->pauseOnMaxTime = -time;
} else { } else {
sndSeqContinue(arg0->unk08); sndSeqContinue(player->seqId);
arg0->unk20 = -temp_r30; player->pauseOnMaxTime = -time;
arg0->unk24 = 0; player->pauseOnTime = 0;
arg0->unk28 = 0; player->pauseOnVol = 0;
} }
} else { } else {
sndSeqContinue(arg0->unk08); sndSeqContinue(player->seqId);
arg0->unk28 = 0x7F; player->pauseOnVol = 127;
sndSeqVolume(arg0->unk02 * arg0->unk03 * arg0->unk1C * arg0->unk28 / 2048383, 0, arg0->unk08, 0); sndSeqVolume(player->baseVol * player->vol * player->fadeVol * player->pauseOnVol / (127*127*127), 0, player->seqId, 0);
} }
arg0->unk04 = 2; player->status = MSM_MUS_PLAY;
} }
} }
} }
static void msmMusPauseFade(msmMusStruct00* arg0) { static void msmMusPauseFade(MUS_PLAYER *player) {
if (arg0->unk20 > 0) { if (player->pauseOnMaxTime > 0) {
if (--arg0->unk24 == 0) { if (--player->pauseOnTime == 0) {
arg0->unk20 = 0; player->pauseOnMaxTime = 0;
arg0->unk28 = 0; player->pauseOnVol = 0;
sndSeqPause(arg0->unk08); sndSeqPause(player->seqId);
} else { } else {
arg0->unk28 = arg0->unk24 * 0x7F / arg0->unk20; player->pauseOnVol = player->pauseOnTime * 127 / player->pauseOnMaxTime;
sndSeqVolume(arg0->unk02 * arg0->unk03 * arg0->unk1C * arg0->unk28 / 2048383, 0, arg0->unk08, 0); sndSeqVolume(player->baseVol * player->vol * player->fadeVol * player->pauseOnVol / (127*127*127), 0, player->seqId, 0);
} }
} else if (arg0->unk20 < 0) { } else if (player->pauseOnMaxTime < 0) {
if (++arg0->unk24 >= -arg0->unk20) { if (++player->pauseOnTime >= -player->pauseOnMaxTime) {
arg0->unk20 = 0; player->pauseOnMaxTime = 0;
arg0->unk28 = 0x7F; player->pauseOnVol = 127;
} else { } else {
arg0->unk28 = arg0->unk24 * 0x7F / -arg0->unk20; player->pauseOnVol = player->pauseOnTime * 127 / -player->pauseOnMaxTime;
} }
sndSeqVolume(arg0->unk02 * arg0->unk03 * arg0->unk1C * arg0->unk28 / 2048383, 0, arg0->unk08, 0); sndSeqVolume(player->baseVol * player->vol * player->fadeVol * player->pauseOnVol / (127*127*127), 0, player->seqId, 0);
} }
} }
static void msmMusFade(msmMusStruct00* arg0) { static void msmMusFade(MUS_PLAYER *player) {
if (arg0->unk04 != 2) { if (player->status != MSM_MUS_PLAY) {
return; return;
} }
if (arg0->unk14 > 0) { if (player->fadeMaxTime > 0) {
if (--arg0->unk18 == 0) { if (--player->fadeTime == 0) {
if (arg0->unk04 != 0) { if (player->status != 0) {
arg0->unk14 = 0; player->fadeMaxTime = 0;
if (arg0->unk14 != 0) { if (player->fadeMaxTime != 0) {
arg0->unk18 = arg0->unk14; player->fadeTime = player->fadeMaxTime;
arg0->unk1C = 0x7F; player->fadeVol = 127;
} else { } else {
sndSeqStop(arg0->unk08); sndSeqStop(player->seqId);
arg0->unk04 = 1; player->status = 1;
} }
} }
} else { } else {
arg0->unk1C = arg0->unk18 * 0x7F / arg0->unk14; player->fadeVol = player->fadeTime * 127 / player->fadeMaxTime;
sndSeqVolume(arg0->unk02 * arg0->unk03 * arg0->unk1C * arg0->unk28 / 2048383, 0, arg0->unk08, 0); sndSeqVolume(player->baseVol * player->vol * player->fadeVol * player->pauseOnVol / (127*127*127), 0, player->seqId, 0);
} }
} else if (arg0->unk14 < 0) { } else if (player->fadeMaxTime < 0) {
if (++arg0->unk18 >= -arg0->unk14) { if (++player->fadeTime >= -player->fadeMaxTime) {
arg0->unk14 = 0; player->fadeMaxTime = 0;
arg0->unk1C = 0x7F; player->fadeVol = 127;
} else { } else {
arg0->unk1C = arg0->unk18 * 0x7F / -arg0->unk14; player->fadeVol = player->fadeTime * 127 / -player->fadeMaxTime;
} }
sndSeqVolume(arg0->unk02 * arg0->unk03 * arg0->unk1C * arg0->unk28 / 2048383, 0, arg0->unk08, 0); sndSeqVolume(player->baseVol * player->vol * player->fadeVol * player->pauseOnVol / (127*127*127), 0, player->seqId, 0);
} }
} }
@ -152,54 +129,54 @@ void msmMusFdoutEnd(void) {
} }
void msmMusPeriodicProc(void) { void msmMusPeriodicProc(void) {
s32 var_r26; s32 i;
msmMusStruct00* temp_r25; MUS_PLAYER* player;
mus.unk04 = mus.unk03 = 0; mus.numPlay = mus.baseGrpNumPlay = 0;
for (var_r26 = 0; var_r26 < mus.unk02; var_r26++) { for (i = 0; i < mus.musChanMax; i++) {
temp_r25 = &mus.unk18[var_r26]; player = &mus.player[i];
if (temp_r25->unk05 != 0) { if (player->busyF != FALSE) {
continue; continue;
} }
switch (temp_r25->unk04) { switch (player->status) {
case 1: case MSM_MUS_STOP:
case 2: case MSM_MUS_PLAY:
if (sndSeqGetValid(temp_r25->unk08) == FALSE) { if (sndSeqGetValid(player->seqId) == FALSE) {
temp_r25->unk04 = 0; player->status = 0;
} }
break; break;
} }
if (temp_r25->unk04 == 0) { if (player->status == MSM_MUS_DONE) {
continue; continue;
} }
if (msmSysCheckBaseGroup(mus.unk0C[temp_r25->unk00].unk00) != 0) { if (msmSysCheckBaseGroup(mus.musData[player->musId].sgid) != 0) {
mus.unk04++; mus.numPlay++;
} else { } else {
mus.unk03++; mus.baseGrpNumPlay++;
} }
msmMusPauseFade(temp_r25); msmMusPauseFade(player);
if (temp_r25->unk04 == 2 && temp_r25->unk2C != 0) { if (player->status == MSM_MUS_PLAY && player->pauseOffMaxTime != 0) {
if (++temp_r25->unk30 >= temp_r25->unk2C) { if (++player->pauseOffTime >= player->pauseOffMaxTime) {
temp_r25->unk2C = 0; player->pauseOffMaxTime = 0;
temp_r25->unk02 = temp_r25->unk36; player->baseVol = player->targetVol;
} else { } else {
temp_r25->unk02 = temp_r25->unk35 + temp_r25->unk30 * (temp_r25->unk36 - temp_r25->unk35) / temp_r25->unk2C; player->baseVol = player->startVol + player->pauseOffTime * (player->targetVol - player->startVol) / player->pauseOffMaxTime;
} }
sndSeqVolume(temp_r25->unk02 * temp_r25->unk03 * temp_r25->unk1C * temp_r25->unk28 / 2048383, 0, temp_r25->unk08, 0); sndSeqVolume(player->baseVol * player->vol * player->fadeVol * player->pauseOnVol / (127*127*127), 0, player->seqId, 0);
} }
msmMusFade(temp_r25); msmMusFade(player);
} }
} }
s32 msmMusGetMidiCtrl(int musNo, s32 channel, s32 ctrl) { s32 msmMusGetMidiCtrl(int musNo, s32 channel, s32 ctrl) {
msmMusStruct00* temp_ptr; MUS_PLAYER *player;
if (musNo < 0 || musNo >= mus.unk02) { if (musNo < 0 || musNo >= mus.musChanMax) {
return MSM_ERR_OUTOFMUS; return MSM_ERR_OUTOFMUS;
} }
temp_ptr = &mus.unk18[musNo]; player = &mus.player[musNo];
if (sndSeqGetValid(temp_ptr->unk08) == TRUE) { if (sndSeqGetValid(player->seqId) == TRUE) {
return sndSeqGetMidiCtrl(temp_ptr->unk08, channel & 0xF, ctrl); return sndSeqGetMidiCtrl(player->seqId, channel & 0xF, ctrl);
} }
return 0; return 0;
} }
@ -207,135 +184,135 @@ s32 msmMusGetMidiCtrl(int musNo, s32 channel, s32 ctrl) {
s32 msmMusGetNumPlay(BOOL baseGrp) { s32 msmMusGetNumPlay(BOOL baseGrp) {
switch (baseGrp) { switch (baseGrp) {
case FALSE: case FALSE:
return mus.unk03 + mus.unk04; return mus.baseGrpNumPlay + mus.numPlay;
default: default:
return mus.unk03; return mus.baseGrpNumPlay;
} }
} }
s32 msmMusGetStatus(int musNo) { s32 msmMusGetStatus(int musNo) {
if (musNo < 0 || musNo >= mus.unk02) { if (musNo < 0 || musNo >= mus.musChanMax) {
return MSM_ERR_OUTOFMUS; return MSM_ERR_OUTOFMUS;
} }
return mus.unk18[musNo].unk04; return mus.player[musNo].status;
} }
void msmMusSetMasterVolume(s32 arg0) { void msmMusSetMasterVolume(s32 vol) {
sndMasterVolume(arg0 & 0x7F, 0, 1, 0); sndMasterVolume(vol & 127, 0, 1, 0);
} }
s32 msmMusSetParam(s32 arg0, MSM_MUSPARAM* arg1) { s32 msmMusSetParam(s32 musNo, MSM_MUSPARAM *param) {
msmMusStruct00* temp_r31; MUS_PLAYER* player;
if (arg0 < 0 || arg0 >= mus.unk02) { if (musNo < 0 || musNo >= mus.musChanMax) {
return MSM_ERR_OUTOFMUS; return MSM_ERR_OUTOFMUS;
} }
temp_r31 = &mus.unk18[arg0]; player = &mus.player[musNo];
if (arg1->flag & MSM_MUSPARAM_VOL) { if (param->flag & MSM_MUSPARAM_VOL) {
temp_r31->unk2C = arg1->fadeSpeed / 15; player->pauseOffMaxTime = param->fadeSpeed / 15;
if (temp_r31->unk2C != 0) { if (player->pauseOffMaxTime != 0) {
temp_r31->unk05 = 1; player->busyF = 1;
temp_r31->unk30 = 0; player->pauseOffTime = 0;
temp_r31->unk35 = temp_r31->unk02; player->startVol = player->baseVol;
temp_r31->unk36 = arg1->vol & 0x7F; player->targetVol = param->vol & 127;
temp_r31->unk05 = 0; player->busyF = 0;
} else { } else {
temp_r31->unk02 = arg1->vol & 0x7F; player->baseVol = param->vol & 127;
sndSeqVolume(temp_r31->unk02 * temp_r31->unk03 * temp_r31->unk1C * temp_r31->unk28 / 2048383, 0, temp_r31->unk08, 0); sndSeqVolume(player->baseVol * player->vol * player->fadeVol * player->pauseOnVol / (127*127*127), 0, player->seqId, 0);
} }
} }
if (arg1->flag & MSM_MUSPARAM_SPEED) { if (param->flag & MSM_MUSPARAM_SPEED) {
sndSeqSpeed(temp_r31->unk08, (arg1->speed << 8) / 100); sndSeqSpeed(player->seqId, (param->speed << 8) / 100);
} }
return 0; return 0;
} }
void msmMusPauseAll(BOOL pause, s32 speed) { void msmMusPauseAll(BOOL pause, s32 speed) {
s32 var_r27; s32 var_r27;
msmMusStruct00* temp_r26; MUS_PLAYER* player;
for (var_r27 = 0; var_r27 < mus.unk02; var_r27++) { for (var_r27 = 0; var_r27 < mus.musChanMax; var_r27++) {
temp_r26 = &mus.unk18[var_r27]; player = &mus.player[var_r27];
if (temp_r26->unk04 != 0) { if (player->status != MSM_MUS_DONE) {
temp_r26->unk05 = 1; player->busyF = TRUE;
msmMusPauseSub(temp_r26, pause, speed); msmMusPauseSub(player, pause, speed);
temp_r26->unk05 = 0; player->busyF = FALSE;
} }
} }
} }
s32 msmMusPause(int musNo, BOOL pause, s32 speed) { s32 msmMusPause(int musNo, BOOL pause, s32 speed) {
msmMusStruct00* temp_r31; MUS_PLAYER *player;
if (musNo < 0 || musNo >= mus.unk02) { if (musNo < 0 || musNo >= mus.musChanMax) {
return MSM_ERR_OUTOFMUS; return MSM_ERR_OUTOFMUS;
} }
temp_r31 = &mus.unk18[musNo]; player = &mus.player[musNo];
temp_r31->unk05 = 1; player->busyF = TRUE;
msmMusPauseSub(temp_r31, pause, speed); msmMusPauseSub(player, pause, speed);
temp_r31->unk05 = 0; player->busyF = FALSE;
return 0; return 0;
} }
void msmMusStopAll(BOOL checkGrp, s32 speed) { void msmMusStopAll(BOOL checkGrp, s32 speed) {
s32 var_r28; s32 i;
msmMusStruct00* temp_r27; MUS_PLAYER *player;
for (var_r28 = 0; var_r28 < mus.unk02; var_r28++) { for (i = 0; i < mus.musChanMax; i++) {
temp_r27 = &mus.unk18[var_r28]; player = &mus.player[i];
if (temp_r27->unk04 == 0) { if (player->status == 0) {
continue; continue;
} }
temp_r27->unk05 = 1; player->busyF = TRUE;
switch (checkGrp) { switch (checkGrp) {
case FALSE: case FALSE:
if (temp_r27->unk04 != 0) { if (player->status != 0) {
temp_r27->unk14 = speed / 15; player->fadeMaxTime = speed / 15;
if (temp_r27->unk14 != 0) { if (player->fadeMaxTime != 0) {
temp_r27->unk18 = temp_r27->unk14; player->fadeTime = player->fadeMaxTime;
temp_r27->unk1C = 0x7F; player->fadeVol = 127;
} else { } else {
sndSeqStop(temp_r27->unk08); sndSeqStop(player->seqId);
temp_r27->unk04 = 1; player->status = 1;
} }
} }
break; break;
default: default:
if (msmSysCheckBaseGroup(mus.unk0C[temp_r27->unk00].unk00) == 0 && temp_r27->unk04 != 0) { if (msmSysCheckBaseGroup(mus.musData[player->musId].sgid) == 0 && player->status != 0) {
temp_r27->unk14 = speed / 15; player->fadeMaxTime = speed / 15;
if (temp_r27->unk14 != 0) { if (player->fadeMaxTime != 0) {
temp_r27->unk18 = temp_r27->unk14; player->fadeTime = player->fadeMaxTime;
temp_r27->unk1C = 0x7F; player->fadeVol = 127;
} else { } else {
sndSeqStop(temp_r27->unk08); sndSeqStop(player->seqId);
temp_r27->unk04 = 1; player->status = 1;
} }
} }
break; break;
} }
temp_r27->unk05 = 0; player->busyF = FALSE;
} }
} }
s32 msmMusStop(int musNo, s32 speed) { s32 msmMusStop(int musNo, s32 speed) {
msmMusStruct00* temp_r30; MUS_PLAYER* player;
if (musNo < 0 || musNo >= mus.unk02) { if (musNo < 0 || musNo >= mus.musChanMax) {
return MSM_ERR_OUTOFMUS; return MSM_ERR_OUTOFMUS;
} }
temp_r30 = &mus.unk18[musNo]; player = &mus.player[musNo];
temp_r30->unk05 = 1; player->busyF = TRUE;
if (temp_r30->unk04 != 0) { if (player->status != 0) {
temp_r30->unk14 = speed / 15; player->fadeMaxTime = speed / 15;
if (temp_r30->unk14 != 0) { if (player->fadeMaxTime != 0) {
temp_r30->unk18 = temp_r30->unk14; player->fadeTime = player->fadeMaxTime;
temp_r30->unk1C = 0x7F; player->fadeVol = 127;
} else { } else {
sndSeqStop(temp_r30->unk08); sndSeqStop(player->seqId);
temp_r30->unk04 = 1; player->status = MSM_MUS_STOP;
} }
} }
temp_r30->unk05 = 0; player->busyF = FALSE;
return 0; return 0;
} }
@ -343,124 +320,124 @@ int msmMusPlay(int musId, MSM_MUSPARAM* musParam) {
s32 var_r30; s32 var_r30;
int var_r29; int var_r29;
s32 temp_r3_3; s32 temp_r3_3;
UnkGroupDataPtr* temp_r3_2; MSM_GRP_HEAD* temp_r3_2;
msmMusStruct01* temp_r28; MSM_MUS* temp_r28;
msmMusStruct00* temp_r27; MUS_PLAYER* temp_r27;
DVDFileInfo sp10; DVDFileInfo sp10;
if (musId < 0 || musId >= mus.unk00) { if (musId < 0 || musId >= mus.musMax) {
return MSM_ERR_INVALIDID; return MSM_ERR_INVALIDID;
} }
temp_r28 = &mus.unk0C[musId]; temp_r28 = &mus.musData[musId];
if (temp_r28->unk00 == 0xFFFF) { if (temp_r28->sgid == 0xFFFF) {
return MSM_ERR_REMOVEDID; return MSM_ERR_REMOVEDID;
} }
if (msmSysCheckLoadGroupID(temp_r28->unk00) == 0) { if (msmSysCheckLoadGroupID(temp_r28->sgid) == 0) {
return MSM_ERR_GRP_NOTLOADED; return MSM_ERR_GRP_NOTLOADED;
} }
var_r30 = (musParam != NULL) ? musParam->flag : 0; var_r30 = (musParam != NULL) ? musParam->flag : 0;
var_r29 = (var_r30 & MSM_MUSPARAM_CHAN) ? musParam->chan : 0; var_r29 = (var_r30 & MSM_MUSPARAM_CHAN) ? musParam->chan : 0;
if (var_r29 < 0 || var_r29 >= mus.unk02) { if (var_r29 < 0 || var_r29 >= mus.musChanMax) {
return MSM_ERR_OUTOFMUS; return MSM_ERR_OUTOFMUS;
} }
temp_r27 = &mus.unk18[var_r29]; temp_r27 = &mus.player[var_r29];
if (temp_r27->unk04 != 0) { if (temp_r27->status != 0) {
sndSeqStop(temp_r27->unk08); sndSeqStop(temp_r27->seqId);
} }
if (temp_r28->unk0C < 0) { if (temp_r28->songGrp < 0) {
if (temp_r27->unk00 != musId) { if (temp_r27->musId != musId) {
if (msmFioOpen(mus.unk08, &sp10) != 1) { if (msmFioOpen(mus.msmEntryNum, &sp10) != 1) {
return MSM_ERR_OPENFAIL; return MSM_ERR_OPENFAIL;
} }
if (msmFioRead(&sp10, temp_r27->unk0C, temp_r28->unk08, temp_r28->unk04 + mus.unk10) < 0) { if (msmFioRead(&sp10, temp_r27->songBuf, temp_r28->songSize, temp_r28->songOfs + mus.dummyMusOfs) < 0) {
msmFioClose(&sp10); msmFioClose(&sp10);
return MSM_ERR_READFAIL; return MSM_ERR_READFAIL;
} }
msmFioClose(&sp10); msmFioClose(&sp10);
temp_r27->unk10 = temp_r27->unk0C; temp_r27->arrfile = temp_r27->songBuf;
} }
} else { } else {
temp_r3_2 = msmSysGetGroupDataPtr(temp_r28->unk0C); temp_r3_2 = msmSysGetGroupDataPtr(temp_r28->songGrp);
if (temp_r3_2 == NULL) { if (temp_r3_2 == NULL) {
return MSM_ERR_MUSGRP_NOTLOADED; return MSM_ERR_MUSGRP_NOTLOADED;
} }
temp_r27->unk10 = (void*) ((u32) temp_r3_2 + temp_r3_2->unk0C + temp_r28->unk04); temp_r27->arrfile = (void*) ((u32) temp_r3_2 + temp_r3_2->sngOfs + temp_r28->songOfs);
} }
temp_r27->unk05 = 1; temp_r27->busyF = 1;
temp_r27->unk03 = temp_r28->unk0D; temp_r27->vol = temp_r28->vol;
temp_r27->unk2C = 0; temp_r27->pauseOffMaxTime = 0;
temp_r27->unk20 = 0; temp_r27->pauseOnMaxTime = 0;
temp_r27->unk14 = 0; temp_r27->fadeMaxTime = 0;
temp_r27->unk28 = 0x7F; temp_r27->pauseOnVol = 127;
temp_r27->unk1C = 0x7F; temp_r27->fadeVol = 127;
temp_r27->unk38.flags = 4; temp_r27->playPara.flags = 4;
temp_r27->unk38.volume.time = 0; temp_r27->playPara.volume.time = 0;
temp_r27->unk02 = (var_r30 & MSM_MUSPARAM_VOL) ? musParam->vol : 0x7F; temp_r27->baseVol = (var_r30 & MSM_MUSPARAM_VOL) ? musParam->vol : 127;
temp_r27->unk38.volume.target = temp_r27->unk03 * temp_r27->unk1C * temp_r27->unk02 / 16129; temp_r27->playPara.volume.target = temp_r27->vol * temp_r27->fadeVol * temp_r27->baseVol / 16129;
if (var_r30 & MSM_MUSPARAM_PAUSE) { if (var_r30 & MSM_MUSPARAM_PAUSE) {
temp_r27->unk38.flags |= 0x10; temp_r27->playPara.flags |= 0x10;
} }
if (var_r30 & MSM_MUSPARAM_SPEED) { if (var_r30 & MSM_MUSPARAM_SPEED) {
temp_r27->unk38.flags |= 2; temp_r27->playPara.flags |= 2;
temp_r27->unk38.speed = musParam->speed * 256 / 100; temp_r27->playPara.speed = musParam->speed * 256 / 100;
} }
if (var_r30 & MSM_MUSPARAM_FADESPEED) { if (var_r30 & MSM_MUSPARAM_FADESPEED) {
temp_r27->unk14 = -(musParam->fadeSpeed / 15); temp_r27->fadeMaxTime = -(musParam->fadeSpeed / 15);
if (temp_r27->unk14 != 0) { if (temp_r27->fadeMaxTime != 0) {
temp_r27->unk18 = 0; temp_r27->fadeTime = 0;
temp_r27->unk1C = 0; temp_r27->fadeVol = 0;
temp_r27->unk38.volume.target = 0; temp_r27->playPara.volume.target = 0;
} }
} }
temp_r3_3 = sndSeqPlayEx(temp_r28->unk00, temp_r28->unk02, temp_r27->unk10, &temp_r27->unk38, 0); temp_r3_3 = sndSeqPlay(temp_r28->sgid, temp_r28->sid, temp_r27->arrfile, &temp_r27->playPara);
if (temp_r3_3 == SND_ID_ERROR) { if (temp_r3_3 == SND_ID_ERROR) {
temp_r27->unk05 = 0; temp_r27->busyF = 0;
return MSM_ERR_PLAYFAIL; return MSM_ERR_PLAYFAIL;
} }
temp_r27->unk08 = temp_r3_3; temp_r27->seqId = temp_r3_3;
temp_r27->unk00 = musId; temp_r27->musId = musId;
temp_r27->unk04 = (temp_r27->unk38.flags & 0x10) ? 3 : 2; temp_r27->status = (temp_r27->playPara.flags & 0x10) ? 3 : 2;
temp_r27->unk05 = 0; temp_r27->busyF = 0;
return var_r29; return var_r29;
} }
s32 msmMusInit(sysData* arg0, DVDFileInfo* arg1) { s32 msmMusInit(MSM_SYS* arg0, DVDFileInfo* arg1) {
s32 temp_r4; s32 temp_r4;
s32 var_r8; s32 var_r8;
mus.unk00 = 0; mus.musMax = 0;
mus.unk02 = 0; mus.musChanMax = 0;
mus.unk04 = 0; mus.numPlay = 0;
mus.unk03 = 0; mus.baseGrpNumPlay = 0;
if (arg0->unk10->unk4 == 0) { if (arg0->info->musMax == 0) {
return 0; return 0;
} }
temp_r4 = arg0->unkC->unk2C; temp_r4 = arg0->header->musSize;
if (temp_r4 == 0) { if (temp_r4 == 0) {
return 0; return 0;
} }
if ((mus.unk0C = msmMemAlloc(temp_r4)) == NULL) { if ((mus.musData = msmMemAlloc(temp_r4)) == NULL) {
return MSM_ERR_OUTOFMEM; return MSM_ERR_OUTOFMEM;
} }
if (msmFioRead(arg1, mus.unk0C, arg0->unkC->unk2C, arg0->unkC->unk28) < 0) { if (msmFioRead(arg1, mus.musData, arg0->header->musSize, arg0->header->musOfs) < 0) {
return MSM_ERR_READFAIL; return MSM_ERR_READFAIL;
} }
temp_r4 = arg0->unk10->unk20; temp_r4 = arg0->info->dummyMusSize;
if (temp_r4 != 0) { if (temp_r4 != 0) {
if ((mus.unk14 = msmMemAlloc(temp_r4 * arg0->unk10->unk8)) == NULL) { if ((mus.musBuf = msmMemAlloc(temp_r4 * arg0->info->musChanMax)) == NULL) {
return MSM_ERR_OUTOFMEM; return MSM_ERR_OUTOFMEM;
} }
} else { } else {
mus.unk14 = NULL; mus.musBuf = NULL;
} }
mus.unk00 = arg0->unk10->unk4; mus.musMax = arg0->info->musMax;
mus.unk02 = arg0->unk10->unk8; mus.musChanMax = arg0->info->musChanMax;
mus.unk10 = arg0->unkC->unk48; mus.dummyMusOfs = arg0->header->dummyMusOfs;
mus.unk08 = arg0->unk0; mus.msmEntryNum = arg0->msmEntryNum;
for (var_r8 = 0; var_r8 < mus.unk02; var_r8++) { for (var_r8 = 0; var_r8 < mus.musChanMax; var_r8++) {
mus.unk18[var_r8].unk0C = (void*) ((u32) mus.unk14 + arg0->unk10->unk20 * var_r8); mus.player[var_r8].songBuf = (void*) ((u32) mus.musBuf + arg0->info->dummyMusSize * var_r8);
mus.unk18[var_r8].unk00 = -1; mus.player[var_r8].musId = -1;
mus.unk18[var_r8].unk05 = 0; mus.player[var_r8].busyF = 0;
} }
return 0; return 0;
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff