From 2a1c4b808dedd6f54d7daca57d20115c90a16685 Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Sat, 6 Jan 2024 15:28:47 -0600 Subject: [PATCH 1/8] Remove certain common headers common.h fully removed. common_structs.h incorporated into new game/gamework_data.h header along with parts of variables.h (Other parts were moved to more appropriate headers). functions.h split into unsplit.h and board_unsplit.h --- include/REL/w10Dll.h | 10 ++-- include/{functions.h => board_unsplit.h} | 46 +------------------ include/common.h | 9 ---- include/game/armem.h | 2 +- include/game/audio.h | 4 +- include/game/board/basic_space.h | 5 +- include/game/board/warp.h | 9 ++-- include/game/board/window.h | 2 - include/game/data.h | 1 + .../gamework_data.h} | 10 ++-- include/game/hsfanim.h | 1 - include/game/hsfman.h | 2 +- include/game/msm.h | 2 +- include/game/saveload.h | 2 +- include/unsplit.h | 30 ++++++++++++ include/variables.h | 20 -------- src/REL/_minigameDLL/_minigameDLL.c | 1 - src/REL/bootDll/nintendo_data.c | 1 - src/game/audio.c | 2 +- src/game/board/basic_space.c | 4 +- src/game/board/warp.c | 3 ++ src/game/board/window.c | 1 + src/game/data.c | 1 - src/game/decode.c | 1 - src/game/dvd.c | 1 - src/game/flag.c | 3 +- src/game/frand.c | 2 +- src/game/gamework.c | 2 +- src/game/init.c | 1 - src/game/main.c | 2 +- src/game/malloc.c | 1 - src/game/memory.c | 1 - src/game/messdata.c | 2 +- src/game/objmain.c | 3 +- src/game/ovllist.c | 1 - src/game/pad.c | 1 - src/game/printfunc.c | 1 - src/game/process.c | 1 - src/game/saveload.c | 1 + src/game/sprman.c | 1 - src/game/sprput.c | 2 +- src/game/window.c | 2 +- 42 files changed, 77 insertions(+), 120 deletions(-) rename include/{functions.h => board_unsplit.h} (57%) delete mode 100644 include/common.h rename include/{common_structs.h => game/gamework_data.h} (95%) create mode 100644 include/unsplit.h delete mode 100644 include/variables.h diff --git a/include/REL/w10Dll.h b/include/REL/w10Dll.h index 37d0b59e..967ae094 100644 --- a/include/REL/w10Dll.h +++ b/include/REL/w10Dll.h @@ -1,7 +1,10 @@ -#include "common.h" +#include "game/gamework_data.h" #include "dolphin.h" #include "REL/executor.h" #include "game/process.h" +#include "game/window.h" +#include "board_unsplit.h" +#include "unsplit.h" #define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0])) @@ -27,11 +30,6 @@ typedef struct w10DllUnk01 { f32 unk10; } w10DllUnk01; //sizeof ? -typedef struct m456DllUnk02 { - char unk00[0x5C]; - w10DllUnk01* unk5C; -} m456DllUnk02; //sizeof ? - typedef struct w10DllUnk03 { s16 unk0; s16 unk2; diff --git a/include/functions.h b/include/board_unsplit.h similarity index 57% rename from include/functions.h rename to include/board_unsplit.h index 8eebbadc..a8aa1322 100644 --- a/include/functions.h +++ b/include/board_unsplit.h @@ -1,49 +1,7 @@ -#ifndef _FUNCTIONS_H_ -#define _FUNCTIONS_H_ +#ifndef _UNSPLIT_BOARD_H +#define _UNSPLIT_BOARD_H #include "dolphin.h" -#include "common_structs.h" - -void Hu3DLayerHookSet(short layer, void (*func)(short layer)); -void Hu3D2Dto3D(Vec*, s32, Vec*); -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(s32 arg0); - -void Hu3DModelPosSet(s16 index, float x, float y, float z); -void Hu3DModelRotSet(s16 index, float x, float y, float z); -void Hu3DModelScaleSet(s16 index, float x, float y, float z); - -void espInit(void); -void espScaleSet(s16, f32, f32); -s16 espEntry(s32, s32, s32); -void espDispOff(s16); -void espKill(s16); -void espDispOn(s16); -void espPosSet(s16, f32, f32); - -void HuWinAllKill(void); -void HuWinKill(s16); -void HuWinPriSet(s16, s16); -void HuWinHomeClear(s16); -void HuWinMesPalSet(s16, u8, u8, u8, u8); -void HuWinMesSet(s16, u32); -void HuWinMesSpeedSet(s16, s16); -void HuWinMesMaxSizeGet(s16, f32*, ...); -s16 HuWinCreate(float x, float y, s16 w, s16 h, s16 frame); - -void HuAudFXListnerKill(void); -void HuAudDllSndGrpSet(u16 ovl); -void HuAudVoiceInit(s16 ovl); - -void MGSeqKillAll(void); - -void MGSeqPracticeStart(void); -void fn_8004D6F4(s16 arg); - -s32 rand8(void); void BoardCameraTargetModelSet(s16 model); void BoardCameraMotionStartEx(s16, Vec *, Vec *, f32, f32, s16); diff --git a/include/common.h b/include/common.h deleted file mode 100644 index 4875c13a..00000000 --- a/include/common.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _COMMON_H_ -#define _COMMON_H_ - -#include "types.h" -#include "common_structs.h" -#include "functions.h" -#include "variables.h" - -#endif \ No newline at end of file diff --git a/include/game/armem.h b/include/game/armem.h index df62b322..81b8e95c 100644 --- a/include/game/armem.h +++ b/include/game/armem.h @@ -1,7 +1,7 @@ #ifndef _GAME_ARMEM_H #define _GAME_ARMEM_H -#include "common.h" +#include "dolphin.h" #include "game/memory.h" #include "game/data.h" diff --git a/include/game/audio.h b/include/game/audio.h index feb6b44e..5c058fee 100644 --- a/include/game/audio.h +++ b/include/game/audio.h @@ -1,7 +1,7 @@ #ifndef _GAME_AUDIO_H #define _GAME_AUDIO_H -#include "common.h" +#include "dolphin.h" void HuAudInit(void); s32 HuAudStreamPlay(void); @@ -56,4 +56,6 @@ s32 HuAudCharVoicePlay(s16 arg0, s16 arg1); s32 HuAudCharVoicePlayPos(s16 arg0, s16 arg1, Vec *arg2); void HuAudCharVoicePlayEntry(s16 arg0, s16 arg1); +extern u8 fadeStat; + #endif diff --git a/include/game/board/basic_space.h b/include/game/board/basic_space.h index b89f97cb..4b9eb529 100644 --- a/include/game/board/basic_space.h +++ b/include/game/board/basic_space.h @@ -1,11 +1,8 @@ #ifndef _BOARD_BASIC_SPACE_H #define _BOARD_BASIC_SPACE_H -#include "common.h" -#include "math.h" +#include "dolphin.h" #include "game/process.h" -#include "game/audio.h" -#include "game/object.h" extern Process *boardObjMan; diff --git a/include/game/board/warp.h b/include/game/board/warp.h index 6d9d8b2e..36f70547 100644 --- a/include/game/board/warp.h +++ b/include/game/board/warp.h @@ -1,7 +1,8 @@ -#include "common.h" +#ifndef _BOARD_WARP_H +#define _BOARD_WARP_H + #include "game/process.h" #include "game/wipe.h" -#include "math.h" void fn_80080D54(s32); void fn_80080DF8(void); @@ -10,4 +11,6 @@ void fn_800810A4(s32); void fn_800811BC(s32); void fn_80081278(s32); void fn_80081428(s32); -void fn_800814CC(s32); \ No newline at end of file +void fn_800814CC(s32); + +#endif \ No newline at end of file diff --git a/include/game/board/window.h b/include/game/board/window.h index c278da62..b77cc8c0 100644 --- a/include/game/board/window.h +++ b/include/game/board/window.h @@ -1,10 +1,8 @@ #ifndef _BOARD_WINDOW_H #define _BOARD_WINDOW_H -#include "common.h" #include "game/window.h" #include "game/process.h" -#include "game/gamework.h" typedef void (*BoardWinComKeyFunc)(); diff --git a/include/game/data.h b/include/game/data.h index 36791bf4..612f11fb 100644 --- a/include/game/data.h +++ b/include/game/data.h @@ -63,5 +63,6 @@ void *HuDataReadNumHeapShortForce(s32 data_id, s32 num, HeapID heap); void HuDecodeData(void *src, void *dst, u32 size, int decode_type); +extern u32 DirDataSize; #endif \ No newline at end of file diff --git a/include/common_structs.h b/include/game/gamework_data.h similarity index 95% rename from include/common_structs.h rename to include/game/gamework_data.h index e2d63c34..ab9433fe 100644 --- a/include/common_structs.h +++ b/include/game/gamework_data.h @@ -1,7 +1,6 @@ -#ifndef _COMMON_STRUCTS_H -#define _COMMON_STRUCTS_H +#ifndef _GAMEWORK_DATA_H +#define _GAMEWORK_DATA_H -#include "types.h" #include "dolphin.h" typedef struct player_config { @@ -143,4 +142,9 @@ typedef struct game_stat { }; } GameStat; +extern PlayerConfig GWPlayerCfg[4]; +extern PlayerState GWPlayer[4]; +extern SystemState GWSystem; +extern GameStat GWGameStat; + #endif diff --git a/include/game/hsfanim.h b/include/game/hsfanim.h index d519a890..46c41f0a 100644 --- a/include/game/hsfanim.h +++ b/include/game/hsfanim.h @@ -1,7 +1,6 @@ #ifndef GAME_HSFANIM_H #define GAME_HSFANIM_H -#include "common.h" #include "game/hsfformat.h" #include "game/hsfman.h" #include "game/sprite.h" diff --git a/include/game/hsfman.h b/include/game/hsfman.h index 02f151da..aeb7e68d 100644 --- a/include/game/hsfman.h +++ b/include/game/hsfman.h @@ -1,7 +1,6 @@ #ifndef _GAME_HSFMAN_H #define _GAME_HSFMAN_H -#include "common.h" #include "math.h" #include "game/memory.h" #include "game/hsfanim.h" @@ -283,6 +282,7 @@ extern MotionData Hu3DMotion[0x100]; extern u32 totalMatCnt; extern u32 totalMatCnted; extern u32 totalPolyCnt; +extern u32 totalPolyCnted; extern u32 totalTexCacheCnt; extern u32 totalTexCacheCnted; extern u32 totalTexCnt; diff --git a/include/game/msm.h b/include/game/msm.h index 826c4f80..f1c0f006 100644 --- a/include/game/msm.h +++ b/include/game/msm.h @@ -1,7 +1,7 @@ #ifndef _GAME_MSM_H #define _GAME_MSM_H -#include "common.h" +#include "dolphin.h" typedef struct { s32 unk00; diff --git a/include/game/saveload.h b/include/game/saveload.h index 9581fbcd..10b3af30 100644 --- a/include/game/saveload.h +++ b/include/game/saveload.h @@ -1,7 +1,7 @@ #ifndef _GAME_SAVELOAD_H #define _GAME_SAVELOAD_H -#include "common.h" +#include "dolphin.h" s32 SLFileOpen(char *arg0); s32 SLFileCreate(char *arg0, u32 arg1, void *arg2); diff --git a/include/unsplit.h b/include/unsplit.h new file mode 100644 index 00000000..06e6374f --- /dev/null +++ b/include/unsplit.h @@ -0,0 +1,30 @@ +#ifndef _UNSPLIT_H +#define _UNSPLIT_H + +#include "dolphin.h" + +void Hu3D2Dto3D(Vec*, s32, Vec*); +void HuAudFadeOut(s32 arg0); + +void Hu3DModelPosSet(s16 index, float x, float y, float z); +void Hu3DModelRotSet(s16 index, float x, float y, float z); +void Hu3DModelScaleSet(s16 index, float x, float y, float z); + +void espInit(void); +void espScaleSet(s16, f32, f32); +s16 espEntry(s32, s32, s32); +void espDispOff(s16); +void espKill(s16); +void espDispOn(s16); +void espPosSet(s16, f32, f32); + +void HuAudFXListnerKill(void); +void HuAudDllSndGrpSet(u16 ovl); +void HuAudVoiceInit(s16 ovl); + +void MGSeqKillAll(void); + +void MGSeqPracticeStart(void); +void fn_8004D6F4(s16 arg); + +#endif diff --git a/include/variables.h b/include/variables.h deleted file mode 100644 index fdb9b433..00000000 --- a/include/variables.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _VARIABLES_H -#define _VARIABLES_H - -#include "dolphin.h" -#include "common_structs.h" - - -extern PlayerConfig GWPlayerCfg[4]; - - -extern u32 DirDataSize; - -extern u32 totalPolyCnted; -extern u8 fadeStat; - -extern PlayerState GWPlayer[4]; -extern SystemState GWSystem; -extern GameStat GWGameStat; - -#endif diff --git a/src/REL/_minigameDLL/_minigameDLL.c b/src/REL/_minigameDLL/_minigameDLL.c index 8b5be5a5..0100af99 100644 --- a/src/REL/_minigameDLL/_minigameDLL.c +++ b/src/REL/_minigameDLL/_minigameDLL.c @@ -1,4 +1,3 @@ -#include "common.h" #include "REL/executor.h" #include "dolphin/os.h" diff --git a/src/REL/bootDll/nintendo_data.c b/src/REL/bootDll/nintendo_data.c index 4e7ff5f1..5cb14723 100644 --- a/src/REL/bootDll/nintendo_data.c +++ b/src/REL/bootDll/nintendo_data.c @@ -1,4 +1,3 @@ -#include "common.h" #include "game/data.h" #include "logoNintendoData.inc" diff --git a/src/game/audio.c b/src/game/audio.c index 07a75580..25b3006b 100644 --- a/src/game/audio.c +++ b/src/game/audio.c @@ -3,7 +3,7 @@ #include "game/msm.h" #include "game/object.h" #include "game/wipe.h" - +#include "game/gamework_data.h" typedef struct { /* 0x00 */ s16 unk00; diff --git a/src/game/board/basic_space.c b/src/game/board/basic_space.c index 9b96f26c..6df6c406 100644 --- a/src/game/board/basic_space.c +++ b/src/game/board/basic_space.c @@ -1,7 +1,9 @@ #include "game/board/basic_space.h" #include "game/data.h" #include "game/flag.h" - +#include "game/object.h" +#include "game/gamework_data.h" +#include "board_unsplit.h" #include "math.h" typedef struct bit_copy { diff --git a/src/game/board/warp.c b/src/game/board/warp.c index 511edae7..96f4c8fe 100644 --- a/src/game/board/warp.c +++ b/src/game/board/warp.c @@ -1,4 +1,7 @@ #include "game/board/warp.h" +#include "game/gamework_data.h" +#include "board_unsplit.h" +#include "math.h" extern void omVibrate(s16, s16, s16, s16); extern void fn_800816CC(s32, s32); diff --git a/src/game/board/window.c b/src/game/board/window.c index 576ab58b..8bd41ae7 100644 --- a/src/game/board/window.c +++ b/src/game/board/window.c @@ -1,4 +1,5 @@ #include "game/board/window.h" +#include "game/gamework_data.h" extern s32 BoardPlayerIsAllCom(void); extern Process* boardMainProc; diff --git a/src/game/data.c b/src/game/data.c index 575805d9..5f55fd6f 100644 --- a/src/game/data.c +++ b/src/game/data.c @@ -1,4 +1,3 @@ -#include "common.h" #include "game/data.h" #include "game/armem.h" #include "dolphin/dvd.h" diff --git a/src/game/decode.c b/src/game/decode.c index b55eb9ef..575249b6 100644 --- a/src/game/decode.c +++ b/src/game/decode.c @@ -1,4 +1,3 @@ -#include "common.h" #include "game/data.h" #include "dolphin/os.h" diff --git a/src/game/dvd.c b/src/game/dvd.c index 31d58430..506924ae 100644 --- a/src/game/dvd.c +++ b/src/game/dvd.c @@ -1,4 +1,3 @@ -#include "common.h" #include "game/dvd.h" #include "game/data.h" diff --git a/src/game/flag.c b/src/game/flag.c index c9b8c8d4..f5168ef5 100644 --- a/src/game/flag.c +++ b/src/game/flag.c @@ -1,4 +1,5 @@ -#include "common.h" +#include "dolphin.h" +#include "game/gamework_data.h" static u8 _Sys_Flag[16]; diff --git a/src/game/frand.c b/src/game/frand.c index 3cee1af9..ca352d6d 100644 --- a/src/game/frand.c +++ b/src/game/frand.c @@ -1,4 +1,4 @@ -#include "common.h" +#include "dolphin.h" static u32 frand_seed; diff --git a/src/game/gamework.c b/src/game/gamework.c index 5673067b..3bf28b97 100644 --- a/src/game/gamework.c +++ b/src/game/gamework.c @@ -1,6 +1,6 @@ -#include "common.h" #include "string.h" #include "game/gamework.h" +#include "game/gamework_data.h" #include "game/flag.h" GameStat GWGameStatDefault; diff --git a/src/game/init.c b/src/game/init.c index 443afebd..465a5bef 100644 --- a/src/game/init.c +++ b/src/game/init.c @@ -1,4 +1,3 @@ -#include "common.h" #include "game/init.h" #include "dolphin/os.h" #include "dolphin/gx.h" diff --git a/src/game/main.c b/src/game/main.c index 92d38265..1e0e3415 100644 --- a/src/game/main.c +++ b/src/game/main.c @@ -1,4 +1,4 @@ -#include "common.h" +#include "game/gamework_data.h" #include "game/dvd.h" #include "game/printfunc.h" #include "game/object.h" diff --git a/src/game/malloc.c b/src/game/malloc.c index 4ae860e2..4eb3be59 100644 --- a/src/game/malloc.c +++ b/src/game/malloc.c @@ -1,4 +1,3 @@ -#include "common.h" #include "game/memory.h" #include "game/init.h" #include "dolphin/os.h" diff --git a/src/game/memory.c b/src/game/memory.c index 56201187..d7c0374d 100644 --- a/src/game/memory.c +++ b/src/game/memory.c @@ -1,4 +1,3 @@ -#include "common.h" #include "game/memory.h" #include "dolphin/os.h" diff --git a/src/game/messdata.c b/src/game/messdata.c index b09116d0..b2d2c25a 100644 --- a/src/game/messdata.c +++ b/src/game/messdata.c @@ -1,4 +1,4 @@ -#include "common.h" +#include "dolphin.h" static void *MessData_MesDataGet(void *messdata, u32 id) { diff --git a/src/game/objmain.c b/src/game/objmain.c index afe4efb8..f253bf13 100644 --- a/src/game/objmain.c +++ b/src/game/objmain.c @@ -1,4 +1,5 @@ -#include "common.h" +#include "game/audio.h" +#include "game/hsfman.h" #include "game/printfunc.h" #include "game/object.h" #include "game/pad.h" diff --git a/src/game/ovllist.c b/src/game/ovllist.c index d20c6245..e64fdd34 100644 --- a/src/game/ovllist.c +++ b/src/game/ovllist.c @@ -1,4 +1,3 @@ -#include "common.h" #include "game/dvd.h" #include "game/object.h" diff --git a/src/game/pad.c b/src/game/pad.c index 38b3e0c1..139e879f 100644 --- a/src/game/pad.c +++ b/src/game/pad.c @@ -1,4 +1,3 @@ -#include "common.h" #include "dolphin.h" #include "game/msm.h" #include "game/pad.h" diff --git a/src/game/printfunc.c b/src/game/printfunc.c index bf8a9c4e..b1924299 100644 --- a/src/game/printfunc.c +++ b/src/game/printfunc.c @@ -1,4 +1,3 @@ -#include "common.h" #include "dolphin.h" #include "game/printfunc.h" #include "game/init.h" diff --git a/src/game/process.c b/src/game/process.c index 20d286f5..00811161 100644 --- a/src/game/process.c +++ b/src/game/process.c @@ -1,4 +1,3 @@ -#include "common.h" #include "game/process.h" #include "game/memory.h" #include "dolphin/os.h" diff --git a/src/game/saveload.c b/src/game/saveload.c index dce185aa..e12b3f39 100644 --- a/src/game/saveload.c +++ b/src/game/saveload.c @@ -4,6 +4,7 @@ #include "game/window.h" #include "game/flag.h" #include "game/card.h" +#include "game/gamework_data.h" #include "string.h" diff --git a/src/game/sprman.c b/src/game/sprman.c index dbe1da85..5728d60b 100644 --- a/src/game/sprman.c +++ b/src/game/sprman.c @@ -1,4 +1,3 @@ -#include "common.h" #include "game/sprite.h" #include "game/memory.h" #include "game/init.h" diff --git a/src/game/sprput.c b/src/game/sprput.c index 075ab771..faf8ea73 100644 --- a/src/game/sprput.c +++ b/src/game/sprput.c @@ -1,5 +1,5 @@ -#include "common.h" #include "game/sprite.h" +#include "game/hsfman.h" #include "game/init.h" #include "dolphin/mtx.h" #include "dolphin/gx.h" diff --git a/src/game/window.c b/src/game/window.c index 78a63ead..92d30fa4 100644 --- a/src/game/window.c +++ b/src/game/window.c @@ -1,4 +1,4 @@ -#include "common.h" +#include "game/gamework_data.h" #include "game/window.h" #include "game/sprite.h" From b2186e5d098a342f4a58bfb071afc13f9a2aebca Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Sat, 6 Jan 2024 21:00:11 -0600 Subject: [PATCH 2/8] Create main and player headers --- config/GMPE01_00/symbols.txt | 4 +- include/game/board/main.h | 132 ++++++++++++++++++++++++++++++++ include/game/board/player.h | 43 +++++++++++ include/game/gamework_data.h | 2 +- src/game/board/main.c | 138 ++++++--------------------------- src/game/board/player.c | 144 ++++++++++++++++------------------- 6 files changed, 266 insertions(+), 197 deletions(-) create mode 100644 include/game/board/main.h create mode 100644 include/game/board/player.h diff --git a/config/GMPE01_00/symbols.txt b/config/GMPE01_00/symbols.txt index fe79ab23..cbb9305b 100644 --- a/config/GMPE01_00/symbols.txt +++ b/config/GMPE01_00/symbols.txt @@ -1015,7 +1015,7 @@ MainFunc = .text:0x8005BF9C; // type:function size:0x7D0 scope:local BoardTurnNext = .text:0x8005C76C; // type:function size:0x8C ExecTurnStart = .text:0x8005C7F8; // type:function size:0x28C scope:local BoardNextOvlSet = .text:0x8005CA84; // type:function size:0xC4 -BoardIsStarted = .text:0x8005CB48; // type:function size:0x8C +BoardStartCheck = .text:0x8005CB48; // type:function size:0x8C CreateBoard = .text:0x8005CBD4; // type:function size:0x410 scope:local DestroyBoard = .text:0x8005CFE4; // type:function size:0x128 scope:local BoardLightHookSet = .text:0x8005D10C; // type:function size:0xC @@ -1195,7 +1195,7 @@ BoardPlayerAutoSizeSet = .text:0x80068E6C; // type:function size:0x9C BoardPlayerAutoSizeGet = .text:0x80068F08; // type:function size:0x40 BoardPlayerMoveAwayIsDone = .text:0x80068F48; // type:function size:0x1C BoardPlayerMoveAwayStart = .text:0x80068F64; // type:function size:0x224 -BoardPlayerCurrMoveAwayStart = .text:0x80069188; // type:function size:0x40 +BoardPlayerMoveAwayStartCurr = .text:0x80069188; // type:function size:0x40 MoveAwayObjFunc = .text:0x800691C8; // type:function size:0x100 scope:local BoardBowserSuitInit = .text:0x800692C8; // type:function size:0x1A4 BoardBowserSuitKill = .text:0x8006946C; // type:function size:0x128 diff --git a/include/game/board/main.h b/include/game/board/main.h new file mode 100644 index 00000000..d3506e72 --- /dev/null +++ b/include/game/board/main.h @@ -0,0 +1,132 @@ +#ifndef _BOARD_MAIN_H +#define _BOARD_MAIN_H + +#include "game/gamework_data.h" +#include "game/object.h" +#include "game/data.h" +#include "dolphin.h" + +typedef struct board_focus_data { + u16 view_type; + s16 time; + s16 max_time; + float fov_start; + float fov_end; + float zoom_start; + float zoom_end; + Vec rot_start; + Vec rot_end; + Vec target_start; + Vec target_end; +} BoardFocusData; + +typedef struct board_camera_data { + struct { + u8 hide_all : 1; + u8 moving : 1; + u8 quaking : 1; + }; + u16 mask; + s16 target_mdl; + s16 target_space; + s32 quake_timer; + float quake_strength; + float fov; + float near; + float far; + float aspect; + float viewport_x; + float viewport_y; + float viewport_w; + float viewport_h; + float viewport_near; + float viewport_far; + Vec pos; + Vec up; + Vec target; + Vec offset; + Vec rot; + float zoom; + void (*pos_calc)(struct board_camera_data *); + BoardFocusData focus; +} BoardCameraData; + +static inline s32 BoardCurrGet() +{ + return GWSystem.board; +} + +static inline s32 BoardPartyFlagGet() +{ + s32 value = GWSystem.party; + return value; +} + +extern BoardCameraData boardCamera; +extern Process *boardObjMan; +extern Process *boardMainProc; +extern u32 boardRandSeed; +extern omObjData *boardMainObj; + +typedef void (*BoardFunc)(void); + +typedef void (*BoardLightHook)(void); +typedef void (*BoardCameraPosCalcFunc)(BoardCameraData *camera); + +void BoardCommonInit(BoardFunc create, BoardFunc destroy); +void BoardKill(void); +s32 BoardIsKill(void); +void BoardPauseEnableSet(s32 value); +s32 BoardPauseEnableGet(); +void BoardSaveInit(s32 board); +void BoardStoryConfigSet(s32 mg_type, s32 diff_story); +void BoardPartyConfigSet(s32 team, s32 bonus_star, s32 mg_type, s32 max_turn, s32 p1_handicap, s32 p2_handicap, s32 p3_handicap, s32 p4_handicap); +BOOL BoardTurnNext(void); +void BoardNextOvlSet(OverlayID overlay); +s32 BoardStartCheck(void); +void BoardCameraBackup(void); +void BoardCameraRestore(void); +void BoardCameraScissorSet(s32 x, s32 y, s32 w, s32 h); +void BoardCameraViewSet(s32 type); +s32 BoardCameraPosGet(Vec *dst); +s32 BoardCameraTargetGet(Vec *dst); +s32 BoardCameraRotGet(Vec *dst); +float BoardCameraZoomGet(); +s32 BoardCameraDirGet(Vec *dst); +s32 BoardCameraPointDirGet(Vec *point, Vec *dst); +void BoardCameraMaskSet(u16 mask); +void BoardCameraMoveSet(s32 move); +void BoardCameraOffsetSet(float x, float y, float z); +void BoardCameraTargetPlayerSet(s32 player); +void BoardCameraTargetModelSet(s16 model); +void BoardCameraTargetSpaceSet(s32 space); +void BoardCameraPosCalcFuncSet(BoardCameraPosCalcFunc func); +void BoardCameraQuakeSet(s32 duration, float strength); +void BoardCameraQuakeReset(); +void BoardCameraTargetSet(float x, float y, float z); +void BoardCameraPosSet(float x, float y, float z); +void BoardCameraXRotZoomSet(float zoom, float x_rot); +void BoardCameraZoomSet(float zoom); +void BoardCameraRotSet(float x, float y); +void BoardCameraNearFarSet(float near, float far); +void BoardCameraNearFarGet(float *near, float *far); +void BoardCameraMotionStart(s16 model_target, Vec *rot_target, float zoom_target, float fov_target); +void BoardCameraMotionStartEx(s16 model_target, Vec *rot_target, Vec *offset_end, float zoom_target, float fov_target, s16 max_time); +void BoardCameraFovSet(float fov); +s32 BoardCameraCullCheck(Vec *point, float radius); +s32 BoardCameraMotionIsDone(void); +void BoardCameraMotionWait(void); +void BoardCameraInit(void); +float BoardArcSin(float value); +float BoardArcCos(float value); +void BoardRandInit(void); +u32 BoardRand(void); +u32 BoardRandMod(u32 value); +float BoardRandFloat(void); +float BoardVecDistXZCalc(Vec *vec1, Vec *vec2); +s32 BoardVecMaxDistXZCheck(Vec *vec1, Vec *vec2, float max_dist); +s32 BoardVecMinDistCheck(Vec *vec1, Vec *vec2, float min_dist); +s32 BoardDataDirReadAsync(s32 data_num); +void BoardDataAsyncWait(s32 status); + +#endif \ No newline at end of file diff --git a/include/game/board/player.h b/include/game/board/player.h new file mode 100644 index 00000000..d1fd124a --- /dev/null +++ b/include/game/board/player.h @@ -0,0 +1,43 @@ +#ifndef _BOARD_PLAYER_H +#define _BOARD_PLAYER_H + +#include "game/gamework_data.h" + +extern s16 boardPlayerMdl[4]; + +static inline s16 BoardPlayerHandicapGet(s32 player) +{ + return GWPlayer[player].handicap; +} + +static inline s32 BoardPlayerGetCurrIdx() +{ + return GWSystem.player_curr; +} + +static inline PlayerState *BoardPlayerGet(s32 player) +{ + return &GWPlayer[player]; +} + +static inline PlayerState *BoardPlayerGetCurr() +{ + return &GWPlayer[BoardPlayerGetCurrIdx()]; +} + +static inline s16 BoardPlayerModelGet(s32 player) +{ + PlayerState *player_ptr = BoardPlayerGet(player); + return boardPlayerMdl[player_ptr->player_idx]; +} + +static inline s16 BoardPlayerModelGetCurr() +{ + PlayerState *player = BoardPlayerGetCurr(); + return boardPlayerMdl[player->player_idx]; +} + +void BoardPlayerCoinsSet(s32 player, s32 value); +void BoardPlayerAutoSizeSet(s32 player, s32 value); + +#endif \ No newline at end of file diff --git a/include/game/gamework_data.h b/include/game/gamework_data.h index ab9433fe..5a16cdd6 100644 --- a/include/game/gamework_data.h +++ b/include/game/gamework_data.h @@ -57,7 +57,7 @@ typedef struct player_state { u16 com : 1; u16 character : 4; u16 auto_size : 2; - u16 field01_bit9 : 1; + u16 field00_bit9 : 1; }; /* 0x02 */ struct { u8 team : 1; diff --git a/src/game/board/main.c b/src/game/board/main.c index cb4f33bd..4aa316e9 100644 --- a/src/game/board/main.c +++ b/src/game/board/main.c @@ -1,4 +1,5 @@ -#include "common.h" +#include "board_unsplit.h" +#include "game/gamework_data.h" #include "math.h" #include "game/object.h" #include "game/flag.h" @@ -6,52 +7,8 @@ #include "game/wipe.h" #include "string.h" #include "game/hsfman.h" - - -typedef struct board_focus_data { - u16 view_type; - s16 time; - s16 max_time; - float fov_start; - float fov_end; - float zoom_start; - float zoom_end; - Vec rot_start; - Vec rot_end; - Vec target_start; - Vec target_end; -} BoardFocusData; - -typedef struct board_camera_data { - struct { - u8 hide_all : 1; - u8 moving : 1; - u8 quaking : 1; - }; - u16 mask; - s16 target_mdl; - s16 target_space; - s32 quake_timer; - float quake_strength; - float fov; - float near; - float far; - float aspect; - float viewport_x; - float viewport_y; - float viewport_w; - float viewport_h; - float viewport_near; - float viewport_far; - Vec pos; - Vec up; - Vec target; - Vec offset; - Vec rot; - float zoom; - void (*pos_calc)(struct board_camera_data *camera); - BoardFocusData focus; -} BoardCameraData; +#include "game/board/main.h" +#include "game/board/player.h" typedef struct camera_view { s16 x_rot; @@ -59,7 +16,6 @@ typedef struct camera_view { s16 fov; } CameraView; -typedef void (*VoidFunc)(void); omObjData *boardMainObj; u32 boardRandSeed; @@ -70,11 +26,11 @@ void *boardTurnStartFunc; u32 lbl_801D3F00; u32 lbl_801D3EFC; u32 lbl_801D3EF8; -VoidFunc boardTurnFunc; -void *boardLightSetHook; -void *boardLightResetHook; -static VoidFunc destroyFunc; -static VoidFunc createFunc; +BoardFunc boardTurnFunc; +BoardLightHook boardLightSetHook; +BoardLightHook boardLightResetHook; +static BoardFunc destroyFunc; +static BoardFunc createFunc; static BOOL cameraUseBackup; static omObjData *tauntObj; static omObjData *cameraObj; @@ -95,8 +51,7 @@ static CameraView camViewTbl[] = { { -33, 3200, 25 }, }; -extern void BoardPlayerCoinsSet(s32 player, s32 value); -extern void BoardPlayerAutoSizeSet(s32 player, s32 value); + extern void BoardModelPosGet(s16 model, Vec *pos); extern void BoardSpacePosGet(s32 layer, s32 space, Vec *pos); @@ -134,49 +89,6 @@ static void DestroyMainFunc(void); static void CreateBoard(void); static void DestroyBoard(void); -static inline s32 BoardCurrGet() -{ - return GWSystem.board; -} - -static inline s32 BoardPartyFlagGet() -{ - s32 value = GWSystem.party; - return value; -} - -static inline s16 BoardHandicapGet(s32 player) -{ - return GWPlayer[player].handicap; -} - -static inline s32 BoardPlayerCurrGetIdx() -{ - return GWSystem.player_curr; -} - -static inline PlayerState *BoardPlayerGet(s32 player) -{ - return &GWPlayer[player]; -} - -static inline PlayerState *BoardPlayerCurrGet() -{ - return &GWPlayer[BoardPlayerCurrGetIdx()]; -} - -static inline s16 BoardPlayerModelGet(s32 player) -{ - PlayerState *player_ptr = BoardPlayerGet(player); - return boardPlayerMdl[player_ptr->player_idx]; -} - -static inline s16 BoardPlayerCurrModelGet() -{ - PlayerState *player = BoardPlayerCurrGet(); - return boardPlayerMdl[player->player_idx]; -} - static inline int GWMGTypeGet() { return GWSystem.mg_type; @@ -187,10 +99,9 @@ static inline int GWMessSpeedGet() return GWSystem.mess_speed; } +#define BOARD_FABS(value) ((value < 0) ? -(value) : (value)) -#define BoardFAbs(value) ((value < 0) ? -(value) : (value)) - -void BoardCommonInit(VoidFunc create, VoidFunc destroy) +void BoardCommonInit(BoardFunc create, BoardFunc destroy) { omSysPauseEnable(FALSE); if(!_CheckFlag(FLAG_ID_MAKE(1, 0))) { @@ -339,7 +250,7 @@ void BoardKill(void) BoardTutorialHookExec(29, 0); } HuAudFXAllStop(); - if(!BoardIsStarted()) { + if(!BoardStartCheck()) { WipeCreate(WIPE_MODE_OUT, WIPE_TYPE_NORMAL, -1); boardTutorialF = 1; while(WipeStatGet()) { @@ -439,7 +350,7 @@ void BoardSaveInit(s32 board) if(!BoardPartyFlagGet() || _CheckFlag(FLAG_ID_MAKE(1, 11))) { GWStarsSet(i, 0); } else { - GWStarsSet(i, BoardHandicapGet(i)); + GWStarsSet(i, BoardPlayerHandicapGet(i)); } } } @@ -599,7 +510,7 @@ static void MainFunc(void) while(WipeStatGet()) { HuPrcVSleep(); } - BoardPlayerCurrMoveAwayStart(GWPlayer[i].space_curr, 1); + BoardPlayerMoveAwayStartCurr(GWPlayer[i].space_curr, 1); fade_type = 0; } else { if(BoardCurrGet() == 7 || BoardCurrGet() == 8) { @@ -609,7 +520,7 @@ static void MainFunc(void) while(WipeStatGet()) { HuPrcVSleep(); } - BoardPlayerCurrMoveAwayStart(GWPlayer[i].space_curr, 1); + BoardPlayerMoveAwayStartCurr(GWPlayer[i].space_curr, 1); fade_type = 0; } } else { @@ -669,7 +580,7 @@ void BoardNextOvlSet(OverlayID overlay) BoardKill(); } -BOOL BoardIsStarted(void) +s32 BoardStartCheck(void) { if(_CheckFlag(FLAG_ID_MAKE(1, 2)) || _CheckFlag(FLAG_ID_MAKE(1, 3)) || _CheckFlag(FLAG_ID_MAKE(1, 4)) || _CheckFlag(FLAG_ID_MAKE(1, 5)) || _CheckFlag(FLAG_ID_MAKE(1, 6))) { return 1; @@ -868,7 +779,7 @@ void BoardCameraViewSet(s32 type) } else { size = 1.0f; } - BoardCameraTargetModelSet(BoardPlayerCurrModelGet()); + BoardCameraTargetModelSet(BoardPlayerModelGetCurr()); BoardPlayerPosGet(GWSystem.player_curr, &focus->target_end); BoardCameraOffsetSet(0.0f, 100.0f*size, 0.0f); focus->target_end.y += 100.0f*size; @@ -1022,7 +933,7 @@ void BoardCameraTargetSpaceSet(s32 space) camera->offset.x = camera->offset.y = camera->offset.z = 0; } -void BoardCameraPosCalcFuncSet(void (*func)(struct board_camera_data *camera)) +void BoardCameraPosCalcFuncSet(BoardCameraPosCalcFunc func) { BoardCameraData *camera = &boardCamera; if(!camera) { @@ -1042,7 +953,7 @@ void BoardCameraQuakeSet(s32 duration, float strength) camera->quake_timer = duration; } -void BoardCameraQuakeReset(s32 duration, float strength) +void BoardCameraQuakeReset() { BoardCameraData *camera = &boardCamera; camera->quaking = 0; @@ -1093,7 +1004,6 @@ void BoardCameraNearFarSet(float near, float far) camera->far = far; } - void BoardCameraNearFarGet(float *near, float *far) { BoardCameraData *camera = &boardCamera; @@ -1180,7 +1090,7 @@ s32 BoardCameraCullCheck(Vec *point, float radius) } BoardCameraPointDirGet(point, &pos); dot = VECDotProduct(&dir, &pos); - if(BoardFAbs(dot) < cos((camera->fov*M_PI)/180)) { + if(BOARD_FABS(dot) < cos((camera->fov*M_PI)/180)) { return 0; } else { return 1; @@ -1365,7 +1275,7 @@ float BoardArcSin(float value) s32 sign; if(value < 0) { sign = 1; - value = BoardFAbs(value); + value = BOARD_FABS(value); } else { sign = 0; } @@ -1378,14 +1288,14 @@ float BoardArcSin(float value) result = 1.0f-atanf((float)sqrtf(1-(value*value))/value); } if(sign) { - result = BoardFAbs(result); + result = BOARD_FABS(result); } return result; } float BoardArcCos(float value) { - if(BoardFAbs(value) > 1) { + if(BOARD_FABS(value) > 1) { return 0; } return 1.0f-BoardArcSin(value); diff --git a/src/game/board/player.c b/src/game/board/player.c index aee15dac..4e07a8e6 100644 --- a/src/game/board/player.c +++ b/src/game/board/player.c @@ -1,19 +1,12 @@ -#include "common.h" +#include "board_unsplit.h" +#include "game/gamework_data.h" #include "game/gamework.h" #include "game/window.h" #include "game/object.h" #include "game/process.h" +#include "game/board/player.h" +#include "game/board/main.h" -//// #include "game/board/main.h" -extern s32 BoardIsStarted(void); -extern void BoardCameraMoveSet(s32); -extern void BoardCameraViewSet(s32); -extern void BoardPauseEnableSet(s32); -extern void BoardCameraTargetPlayerSet(s32); -extern void BoardCameraOffsetSet(float, float, float); -extern void BoardCameraTargetModelSet(s16); -extern void BoardCameraTargetPlayerSet(s32); -extern Process* boardObjMan; //// #include "game/board/space.h" extern s32 BoardSpaceFlagPosGet(s32, s32, u32); extern void BoardSpaceDirPosGet(s32, s32, Vec*); @@ -176,15 +169,6 @@ static s16 suitMdl = -1; static s16 suitPlayerMdl = -1; static s16 suitCurrMot = -1; -inline PlayerState* GetPlayer(s32 index) { - return &GWPlayer[index]; -} - -inline s16 GetBoardPlayer(s32 index) { - PlayerState *player = GetPlayer(index); - return boardPlayerMdl[player->player_idx]; -} - s32 BoardRollTypeGet(void) { return rollType; } @@ -225,7 +209,7 @@ void BoardPlayerInit(void) { BoardPlayerSizeSet(var_r31, 0); GWPlayer[var_r31].color = 0; GWPlayer[var_r31].bowser_suit = 0; - GWPlayer[var_r31].field01_bit9 = 0; + GWPlayer[var_r31].field00_bit9 = 0; GWPlayer[var_r31].field08_bit3 = 0; } return; @@ -241,7 +225,7 @@ void BoardPlayerInit(void) { } void BoardPlayerModelInit(void) { - s32 sp64[0x10]; + s32 sp64[14]; s32 var_r31; s32 var_r30; s32 temp_r29; @@ -319,7 +303,7 @@ void BoardPlayerModelKill(void) { PlayerState* temp_r29; for (var_r31 = 0; var_r31 < 4; var_r31++) { - temp_r30 = GetPlayer(var_r31); + temp_r30 = BoardPlayerGet(var_r31); if (boardPlayerMdl[temp_r30->player_idx] != -1) { BoardModelKill(boardPlayerMdl[temp_r30->player_idx]); boardPlayerMdl[temp_r30->player_idx] = -1; @@ -333,22 +317,22 @@ void BoardPlayerModelKill(void) { } void BoardPlayerLayerSet(s32 arg0, s32 arg1) { - BoardModelLayerSet(GetBoardPlayer(arg0), arg1); + BoardModelLayerSet(BoardPlayerModelGet(arg0), arg1); } void BoardPlayerCameraSet(s32 arg0, u16 arg1) { - BoardModelCameraSet(GetBoardPlayer(arg0), arg1); + BoardModelCameraSet(BoardPlayerModelGet(arg0), arg1); } void fn_80062A40(s32 arg0, f32 arg8) { - fn_8006DDE8(GetBoardPlayer(arg0), arg8); + fn_8006DDE8(BoardPlayerModelGet(arg0), arg8); } void BoardPlayerExistCheck(s32 arg0, s32 arg1) { if (arg1 == 0) { - BoardModelExistCheck(GetBoardPlayer(arg0), 0); + BoardModelExistCheck(BoardPlayerModelGet(arg0), 0); } else { - BoardModelExistCheck(GetBoardPlayer(arg0), 1); + BoardModelExistCheck(BoardPlayerModelGet(arg0), 1); } } @@ -358,7 +342,7 @@ s32 BoardPlayerItemAdd(s32 arg0, s32 arg1) { s32 var_r31; var_r29 = -1; - var_r30 = GetPlayer(arg0); + var_r30 = BoardPlayerGet(arg0); for (var_r31 = 0; var_r31 < 3; var_r31++) { if (GWPlayer[arg0].items[var_r31] == -1) { HuAudFXPlay(0x360); @@ -375,7 +359,7 @@ s32 BoardPlayerItemRemove(s32 arg0, s32 arg1) { s32 temp_r29; PlayerState* temp_r28; - temp_r28 = GetPlayer(arg0); + temp_r28 = BoardPlayerGet(arg0); temp_r29 = temp_r28->items[arg1]; if (temp_r28->items[arg1] == -1) { return temp_r29; @@ -447,15 +431,15 @@ void BoardPlayerCurrSpacePosDirGet(s32 arg0, Point3d* arg1) { } void BoardPlayerAmbSet(s32 arg0, f32 arg8, f32 arg9, f32 argA) { - BoardModelAmbSet(GetBoardPlayer(arg0), arg8, arg9, argA); + BoardModelAmbSet(BoardPlayerModelGet(arg0), arg8, arg9, argA); } void BoardPlayerMtxSet(s32 arg0, Mtx arg1) { - BoardModelMtxSet(GetBoardPlayer(arg0), arg1); + BoardModelMtxSet(BoardPlayerModelGet(arg0), arg1); } void BoardPlayerPosSetV(s32 arg0, Vec* arg1) { - BoardModelPosSetV(GetBoardPlayer(arg0), arg1); + BoardModelPosSetV(BoardPlayerModelGet(arg0), arg1); if (GWPlayer[arg0].bowser_suit != 0) { BoardModelPosSetV(suitMdl, arg1); @@ -463,7 +447,7 @@ void BoardPlayerPosSetV(s32 arg0, Vec* arg1) { } void BoardPlayerPosSet(s32 arg0, f32 arg8, f32 arg9, f32 argA) { - BoardModelPosSet(GetBoardPlayer(arg0), arg8, arg9, argA); + BoardModelPosSet(BoardPlayerModelGet(arg0), arg8, arg9, argA); if (GWPlayer[arg0].bowser_suit != 0) { BoardModelPosSet(suitMdl, arg8, arg9, argA); @@ -471,11 +455,11 @@ void BoardPlayerPosSet(s32 arg0, f32 arg8, f32 arg9, f32 argA) { } void BoardPlayerPosGet(s32 arg0, Vec* arg1) { - BoardModelPosGet(GetBoardPlayer(arg0), arg1); + BoardModelPosGet(BoardPlayerModelGet(arg0), arg1); } void BoardPlayerRotSetV(s32 arg0, Vec* arg1) { - BoardModelRotSetV(GetBoardPlayer(arg0), arg1); + BoardModelRotSetV(BoardPlayerModelGet(arg0), arg1); if (GWPlayer[arg0].bowser_suit != 0) { BoardModelRotSetV(suitMdl, arg1); @@ -483,7 +467,7 @@ void BoardPlayerRotSetV(s32 arg0, Vec* arg1) { } void BoardPlayerRotSet(s32 arg0, f32 arg8, f32 arg9, f32 argA) { - BoardModelRotSet(GetBoardPlayer(arg0), arg8, arg9, argA); + BoardModelRotSet(BoardPlayerModelGet(arg0), arg8, arg9, argA); if (GWPlayer[arg0].bowser_suit != 0) { BoardModelRotSet(suitMdl, arg8, arg9, argA); @@ -491,7 +475,7 @@ void BoardPlayerRotSet(s32 arg0, f32 arg8, f32 arg9, f32 argA) { } void BoardPlayerRotGet(s32 arg0, Vec* arg1) { - BoardModelRotGet(GetBoardPlayer(arg0), arg1); + BoardModelRotGet(BoardPlayerModelGet(arg0), arg1); } void BoardPlayerRotYSet(s32 arg0, f32 arg8) { @@ -501,7 +485,7 @@ void BoardPlayerRotYSet(s32 arg0, f32 arg8) { if (arg8 > 360.0f) { arg8 -= 360.0f; } - BoardModelRotYSet(GetBoardPlayer(arg0), arg8); + BoardModelRotYSet(BoardPlayerModelGet(arg0), arg8); if (GWPlayer[arg0].bowser_suit != 0) { BoardModelRotYSet(suitMdl, arg8); } @@ -513,47 +497,47 @@ f32 BoardPlayerRotYGet(s32 arg0) { if (GWPlayer[arg0].bowser_suit != 0) { var_f31 = BoardModelRotYGet(suitMdl); } else { - var_f31 = BoardModelRotYGet(GetBoardPlayer(arg0)); + var_f31 = BoardModelRotYGet(BoardPlayerModelGet(arg0)); } return var_f31; } void BoardPlayerScaleSetV(s32 arg0, Vec* arg1) { - BoardModelScaleSetV(GetBoardPlayer(arg0), arg1); + BoardModelScaleSetV(BoardPlayerModelGet(arg0), arg1); } void BoardPlayerScaleSet(s32 arg0, f32 arg8, f32 arg9, f32 argA) { - BoardModelScaleSet(GetBoardPlayer(arg0), arg8, arg9, argA); + BoardModelScaleSet(BoardPlayerModelGet(arg0), arg8, arg9, argA); } void BoardPlayerScaleGet(s32 arg0, s32 *arg1) { - BoardModelScaleGet(GetBoardPlayer(arg0), arg1); + BoardModelScaleGet(BoardPlayerModelGet(arg0), arg1); } s16 BoardPlayerCurrMotionGet(s32 arg0) { - PlayerState* player = GetPlayer(arg0); + PlayerState* player = BoardPlayerGet(arg0); return playerMot[player->player_idx]; } void BoardPlayerVoiceEnableSet(s32 arg0, s32 arg1, s32 arg2) { - BoardModelVoiceEnableSet(GetBoardPlayer(arg0), arg1, arg2); + BoardModelVoiceEnableSet(BoardPlayerModelGet(arg0), arg1, arg2); } void BoardPlayerMotionCreate(s32 arg0, s32 arg1) { - BoardModelMotionCreate(GetBoardPlayer(arg0), arg1); + BoardModelMotionCreate(BoardPlayerModelGet(arg0), arg1); } void BoardPlayerMotionKill(s32 arg0, s32 arg1) { - BoardModelMotionKill(GetBoardPlayer(arg0), arg1); + BoardModelMotionKill(BoardPlayerModelGet(arg0), arg1); } void BoardPlayerMotionEndCheck(s32 arg0) { - BoardModelMotionEndCheck(GetBoardPlayer(arg0)); + BoardModelMotionEndCheck(BoardPlayerModelGet(arg0)); } void BoardPlayerMotionEndWait(s32 arg0) { - while (BoardModelMotionEndCheck(GetBoardPlayer(arg0)) == 0) { + while (BoardModelMotionEndCheck(BoardPlayerModelGet(arg0)) == 0) { HuPrcVSleep(); } } @@ -562,11 +546,11 @@ void BoardPlayerMotionStart(s32 arg0, s32 arg1, s32 arg2) { PlayerState* player; s32 temp_r29; - player = GetPlayer(arg0); + player = BoardPlayerGet(arg0); if (arg1 == 0) { } if (arg1 != playerMot[player->player_idx]) { - temp_r29 = BoardModelMotionStart(GetBoardPlayer(arg0), arg1, arg2); + temp_r29 = BoardModelMotionStart(BoardPlayerModelGet(arg0), arg1, arg2); if (temp_r29 == 0) { playerMot[player->player_idx] = arg1; } @@ -577,11 +561,11 @@ void BoardPlayerMotionShiftSet(s32 arg0, s32 arg1, f32 arg8, f32 arg9, s32 arg2) PlayerState* player; s32 temp_r29; - player = GetPlayer(arg0); + player = BoardPlayerGet(arg0); if (arg1 == 0) { } if (arg1 != playerMot[player->player_idx]) { - temp_r29 = BoardModelMotionShiftSet(GetBoardPlayer(arg0), arg1, arg8, arg9, arg2); + temp_r29 = BoardModelMotionShiftSet(BoardPlayerModelGet(arg0), arg1, arg8, arg9, arg2); if (temp_r29 == 0) { playerMot[player->player_idx] = arg1; } @@ -589,31 +573,31 @@ void BoardPlayerMotionShiftSet(s32 arg0, s32 arg1, f32 arg8, f32 arg9, s32 arg2) } void BoardPlayerMotionSpeedSet(s32 arg0, f32 arg8) { - BoardModelMotionSpeedSet(GetBoardPlayer(arg0), arg8); + BoardModelMotionSpeedSet(BoardPlayerModelGet(arg0), arg8); } void BoardPlayerMotionTimeSet(s32 arg0, f32 arg8) { - BoardModelMotionTimeSet(GetBoardPlayer(arg0), arg8); + BoardModelMotionTimeSet(BoardPlayerModelGet(arg0), arg8); } f32 BoardPlayerMotionTimeGet(s32 arg0) { - BoardModelMotionTimeGet(GetBoardPlayer(arg0)); + BoardModelMotionTimeGet(BoardPlayerModelGet(arg0)); } f32 BoardPlayerMotionMaxTimeGet(s32 arg0) { - BoardModelMotionMaxTimeGet(GetBoardPlayer(arg0)); + BoardModelMotionMaxTimeGet(BoardPlayerModelGet(arg0)); } void BoardPlayerMotionTimeRangeSet(s32 arg0, f32 arg8, f32 arg9) { - BoardModelMotionTimeRangeSet(GetBoardPlayer(arg0), arg8, arg9); + BoardModelMotionTimeRangeSet(BoardPlayerModelGet(arg0), arg8, arg9); } void BoardPlayerModelAttrSet(s32 arg0, s32 arg1) { - BoardModelAttrSet(GetBoardPlayer(arg0), arg1); + BoardModelAttrSet(BoardPlayerModelGet(arg0), arg1); } void BoardPlayerModelAttrReset(s32 arg0, s32 arg1) { - BoardModelAttrReset(GetBoardPlayer(arg0), arg1); + BoardModelAttrReset(BoardPlayerModelGet(arg0), arg1); } void BoardPlayerCoinsSet(s32 arg0, s32 arg1) { @@ -628,7 +612,7 @@ void BoardPlayerCoinsAdd(s32 arg0, s32 arg1) { PlayerState* player; s16 coins; - player = GetPlayer(arg0); + player = BoardPlayerGet(arg0); if ((arg1 > 0) && (player->coins_total < 0x3E7)) { player->coins_total += arg1; if (player->coins_total > 0x3E7) { @@ -646,7 +630,7 @@ void BoardPlayerSizeSet(s32 arg0, s32 arg1) { PlayerState* temp_r27; Vec temp_r4[3] = { { 1, 1, 1 }, { 0.3, 0.3, 0.3 }, { 2.5, 2.5, 2.5 } }; - temp_r27 = GetPlayer(arg0); + temp_r27 = BoardPlayerGet(arg0); temp_r27->size = arg1; if (arg1 == 2) { CharModelSetStepType(GWPlayer[arg0].character, 4); @@ -655,13 +639,13 @@ void BoardPlayerSizeSet(s32 arg0, s32 arg1) { } else { CharModelSetStepType(GWPlayer[arg0].character, 0); } - BoardModelScaleSetV(GetBoardPlayer(arg0), &temp_r4[arg1]); + BoardModelScaleSetV(BoardPlayerModelGet(arg0), &temp_r4[arg1]); } s32 BoardPlayerSizeGet(s32 arg0) { PlayerState* temp_r30; - temp_r30 = GetPlayer(arg0); + temp_r30 = BoardPlayerGet(arg0); if (temp_r30 != 0) { arg0 = temp_r30->size; } @@ -696,22 +680,22 @@ s32 BoardPlayerTeamFind(s32 arg0) { return var_r31; } -s32 BoardPlayerRankCalc(s32 arg0) { - s32 temp_r29; - s32 var_r30; - s32 var_r31; - s32 sp8[4]; +s32 BoardPlayerRankCalc(s32 player) { + s32 coins; + s32 rank; + s32 i; + s32 score[4]; - for (var_r31 = 0; var_r31 < 4; var_r31++) { - temp_r29 = GWCoinsGet(var_r31); - sp8[var_r31] = temp_r29 | (GWStarsGet(var_r31) << 0xA); + for (i = 0; i < 4; i++) { + coins = GWCoinsGet(i); + score[i] = coins | (GWStarsGet(i) << 0xA); } - for (var_r30 = 0, var_r31 = 0; var_r31 < 4; var_r31++) { - if ((var_r31 != arg0) && (sp8[arg0] < sp8[var_r31])) { - var_r30++; + for (rank = 0, i = 0; i < 4; i++) { + if ((i != player) && (score[player] < score[i])) { + rank++; } } - return var_r30; + return rank; } void BoardPlayerPreTurnHookSet(s32 arg0, s32 (*arg1)()) { @@ -913,12 +897,12 @@ void BoardPlayerSizeRestore(s32 arg0) { s32 var_r28; s32 var_r27; - temp_r24 = GetPlayer(arg0); + temp_r24 = BoardPlayerGet(arg0); if (temp_r24 != 0) { var_r28 = temp_r24->size; } if (var_r28 != 0) { - temp_r23 = GetPlayer(arg0); + temp_r23 = BoardPlayerGet(arg0); if (temp_r23 != 0) { var_r27 = temp_r23->size; } @@ -945,8 +929,8 @@ void BoardPlayerZoomRestore(s32 arg0) { Vec sp18; Vec spC; - sp8 = GetPlayer(arg0); - BoardModelPosGet(GetBoardPlayer(arg0), &spC); + sp8 = BoardPlayerGet(arg0); + BoardModelPosGet(BoardPlayerModelGet(arg0), &spC); temp_r27 = GWPlayer[arg0].space_curr; var_r31 = GWSystem.player_curr; if (var_r31 == -1) { From ce59e5a3d7ebff69fd1951c33ec7965a33c0572a Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Sat, 6 Jan 2024 21:33:46 -0600 Subject: [PATCH 3/8] Clean up warp code --- config/GMPE01_00/symbols.txt | 42 ++--- include/game/board/player.h | 4 + include/game/board/warp.h | 9 +- src/game/board/basic_space.c | 4 +- src/game/board/warp.c | 309 +++++++++++++++++------------------ src/game/board/window.c | 5 +- 6 files changed, 180 insertions(+), 193 deletions(-) diff --git a/config/GMPE01_00/symbols.txt b/config/GMPE01_00/symbols.txt index cbb9305b..d5ff628b 100644 --- a/config/GMPE01_00/symbols.txt +++ b/config/GMPE01_00/symbols.txt @@ -1484,8 +1484,8 @@ fn_8007F6BC = .text:0x8007F6BC; // type:function size:0xA4 fn_8007F760 = .text:0x8007F760; // type:function size:0xFC fn_8007F85C = .text:0x8007F85C; // type:function size:0x38 fn_8007F894 = .text:0x8007F894; // type:function size:0x2BC -BoardEventLandBlue = .text:0x8007FB50; // type:function size:0x184 -BoardEventLandRed = .text:0x8007FCD4; // type:function size:0x19C +BoardLandBlueExec = .text:0x8007FB50; // type:function size:0x184 +BoardLandRedExec = .text:0x8007FCD4; // type:function size:0x19C BoardCoinChgCreate = .text:0x8007FE70; // type:function size:0x1E8 BoardCoinChgExist = .text:0x80080058; // type:function size:0x6C BoardCoinChgHide = .text:0x800800C4; // type:function size:0x60 @@ -1495,14 +1495,14 @@ CoinChgAppear = .text:0x800804F8; // type:function size:0x1B8 scope:local CoinChgSeparate = .text:0x800806B0; // type:function size:0x29C scope:local CoinChgShow = .text:0x8008094C; // type:function size:0x1A8 scope:local CoinChgDisappear = .text:0x80080AF4; // type:function size:0x260 scope:local -fn_80080D54 = .text:0x80080D54; // type:function size:0xA4 -fn_80080DF8 = .text:0x80080DF8; // type:function size:0x250 -fn_80081048 = .text:0x80081048; // type:function size:0x5C -fn_800810A4 = .text:0x800810A4; // type:function size:0x118 -fn_800811BC = .text:0x800811BC; // type:function size:0xBC -fn_80081278 = .text:0x80081278; // type:function size:0x1B0 -fn_80081428 = .text:0x80081428; // type:function size:0xA4 -fn_800814CC = .text:0x800814CC; // type:function size:0x200 +BoardWarpExec = .text:0x80080D54; // type:function size:0xA4 +WarpProcess = .text:0x80080DF8; // type:function size:0x250 scope:local +WarpKill = .text:0x80081048; // type:function size:0x5C scope:local +WarpInit = .text:0x800810A4; // type:function size:0x118 scope:local +WarpLaunch = .text:0x800811BC; // type:function size:0xBC scope:local +WarpStartImpact = .text:0x80081278; // type:function size:0x1B0 scope:local +WarpFall = .text:0x80081428; // type:function size:0xA4 scope:local +WarpImpact = .text:0x800814CC; // type:function size:0x200 scope:local fn_800816CC = .text:0x800816CC; // type:function size:0x11C fn_800817E8 = .text:0x800817E8; // type:function size:0x34 fn_8008181C = .text:0x8008181C; // type:function size:0x50 @@ -5542,7 +5542,7 @@ lbl_801A4A74 = .bss:0x801A4A74; // type:object size:0x1C lbl_801A4A90 = .bss:0x801A4A90; // type:object size:0xC data:2byte lbl_801A4A9C = .bss:0x801A4A9C; // type:object size:0xC lbl_801A4AA8 = .bss:0x801A4AA8; // type:object size:0x18 data:2byte -lbl_801A4AC0 = .bss:0x801A4AC0; // type:object size:0x10 +warpPos = .bss:0x801A4AC0; // type:object size:0x10 scope:local lbl_801A4AD0 = .bss:0x801A4AD0; // type:object size:0x10 data:4byte lbl_801A4AE0 = .bss:0x801A4AE0; // type:object size:0x10 itemMdlId = .bss:0x801A4AF0; // type:object size:0x18 scope:local @@ -5849,9 +5849,9 @@ lbl_801D373A = .sdata:0x801D373A; // type:object size:0x2 data:2byte lbl_801D373C = .sdata:0x801D373C; // type:object size:0x8 lbl_801D3744 = .sdata:0x801D3744; // type:object size:0x2 data:2byte lbl_801D3746 = .sdata:0x801D3746; // type:object size:0x2 data:2byte -lbl_801D3748 = .sdata:0x801D3748; // type:object size:0x2 data:2byte -lbl_801D374A = .sdata:0x801D374A; // type:object size:0x2 data:2byte -lbl_801D374C = .sdata:0x801D374C; // type:object size:0x4 +warpSpringMdl = .sdata:0x801D3748; // type:object size:0x2 scope:local data:2byte +warpImpactMdl = .sdata:0x801D374A; // type:object size:0x2 scope:local data:2byte +warpImpactPlayer = .sdata:0x801D374C; // type:object size:0x4 scope:local lbl_801D3750 = .sdata:0x801D3750; // type:object size:0x8 lbl_801D3758 = .sdata:0x801D3758; // type:object size:0x1 data:byte lbl_801D375A = .sdata:0x801D375A; // type:object size:0x2 data:2byte @@ -6370,13 +6370,13 @@ lbl_801D401B = .sbss:0x801D401B; // type:object size:0x1 data:byte lbl_801D401C = .sbss:0x801D401C; // type:object size:0x1 data:byte lbl_801D401E = .sbss:0x801D401E; // type:object size:0x2 data:2byte lbl_801D4020 = .sbss:0x801D4020; // type:object size:0x8 data:4byte -lbl_801D4028 = .sbss:0x801D4028; // type:object size:0x4 data:4byte -lbl_801D402C = .sbss:0x801D402C; // type:object size:0x4 data:float -lbl_801D4030 = .sbss:0x801D4030; // type:object size:0x4 data:float -lbl_801D4034 = .sbss:0x801D4034; // type:object size:0x2 data:2byte -lbl_801D4036 = .sbss:0x801D4036; // type:object size:0x1 data:byte -lbl_801D4037 = .sbss:0x801D4037; // type:object size:0x1 data:byte -lbl_801D4038 = .sbss:0x801D4038; // type:object size:0x8 data:byte +warpProcess = .sbss:0x801D4028; // type:object size:0x4 scope:local data:4byte +warpYVel = .sbss:0x801D402C; // type:object size:0x4 scope:local data:float +warpYFloor = .sbss:0x801D4030; // type:object size:0x4 scope:local data:float +warpSpace = .sbss:0x801D4034; // type:object size:0x2 scope:local data:2byte +warpImpactCnt = .sbss:0x801D4036; // type:object size:0x1 scope:local data:byte +warpTarget = .sbss:0x801D4037; // type:object size:0x1 scope:local data:byte +warpState = .sbss:0x801D4038; // type:object size:0x1 scope:local data:byte lbl_801D4040 = .sbss:0x801D4040; // type:object size:0x4 data:4byte lbl_801D4044 = .sbss:0x801D4044; // type:object size:0x2 data:2byte lbl_801D4048 = .sbss:0x801D4048; // type:object size:0x4 data:float diff --git a/include/game/board/player.h b/include/game/board/player.h index d1fd124a..5c91d2d8 100644 --- a/include/game/board/player.h +++ b/include/game/board/player.h @@ -37,7 +37,11 @@ static inline s16 BoardPlayerModelGetCurr() return boardPlayerMdl[player->player_idx]; } +s32 BoardPlayerIsAllCom(void); +void BoardPlayerRotSet(s32, f32, f32, f32); +void BoardPlayerPosGet(s32, Vec*); void BoardPlayerCoinsSet(s32 player, s32 value); void BoardPlayerAutoSizeSet(s32 player, s32 value); +void BoardPlayerMotionStart(s16, s32, s32); #endif \ No newline at end of file diff --git a/include/game/board/warp.h b/include/game/board/warp.h index 36f70547..8b118caf 100644 --- a/include/game/board/warp.h +++ b/include/game/board/warp.h @@ -4,13 +4,6 @@ #include "game/process.h" #include "game/wipe.h" -void fn_80080D54(s32); -void fn_80080DF8(void); -void fn_80081048(void); -void fn_800810A4(s32); -void fn_800811BC(s32); -void fn_80081278(s32); -void fn_80081428(s32); -void fn_800814CC(s32); +void BoardWarpExec(s32 player, s16 space); #endif \ No newline at end of file diff --git a/src/game/board/basic_space.c b/src/game/board/basic_space.c index 6df6c406..ff565d27 100644 --- a/src/game/board/basic_space.c +++ b/src/game/board/basic_space.c @@ -63,7 +63,7 @@ static s32 coinDigitMdl[10] = { MAKE_DATA_NUM(DATADIR_BOARD, 21), }; -void BoardEventLandBlue(s32 player, s16 space) { +void BoardLandBlueExec(s32 player, s16 space) { Vec pos; s32 i; s8 coin_chg; @@ -104,7 +104,7 @@ void BoardEventLandBlue(s32 player, s16 space) { BoardRotateDiceNumbers(player); } -void BoardEventLandRed(s32 player, s16 space) { +void BoardLandRedExec(s32 player, s16 space) { Vec pos; s32 i; s8 coin_chg; diff --git a/src/game/board/warp.c b/src/game/board/warp.c index 96f4c8fe..2be517d8 100644 --- a/src/game/board/warp.c +++ b/src/game/board/warp.c @@ -1,8 +1,19 @@ #include "game/board/warp.h" +#include "game/board/main.h" +#include "game/board/player.h" +#include "game/wipe.h" #include "game/gamework_data.h" #include "board_unsplit.h" +#include "unsplit.h" #include "math.h" +static void WarpInit(s32); +static void WarpLaunch(s32); +static void WarpStartImpact(s32); +static void WarpFall(s32); +static void WarpImpact(s32); + + extern void omVibrate(s16, s16, s16, s16); extern void fn_800816CC(s32, s32); extern void fn_80081884(f32); @@ -15,102 +26,94 @@ extern void BoardPlayerPosSet(s32, f32, f32, f32); extern void BoardPlayerRotYSet(s32, f32); extern void Hu3DModelObjPosGet(s16, char*, Vec*); extern s32 BoardModelMotionEndCheck(s16); -extern void BoardPlayerPosSetV(s32, Point3d*); -void BoardPlayerRotSet(s32, f32, f32, f32); -void BoardCameraMoveSet(s32); -void BoardCameraTargetSpaceSet(s16); -extern void BoardRotateDiceNumbers(s32); -extern void BoardPlayerPosGet(s32, Vec*); -void BoardPlayerMotionStart(s16, s32, s32); -extern Process* boardMainProc; extern s32 boardTutorialData[4]; -extern s16 boardPlayerMdl[4]; -Vec lbl_801A4AC0; +static Vec warpPos; -s8 lbl_801D4038; -s8 lbl_801D4037; -s8 lbl_801D4036; -s16 lbl_801D4034; -f32 lbl_801D4030; -f32 lbl_801D402C; -Process* lbl_801D4028; +static s8 warpState; +static s8 warpTarget; +static s8 warpImpactCnt; +static s16 warpSpace; +static f32 warpYFloor; +static f32 warpYVel; +static Process* warpProcess; -s16 lbl_801D3748 = 0xFFFF; -s16 lbl_801D374A = 0xFFFF; -s8 lbl_801D374C[4] = {-1, -1, -1, -1}; -char lbl_801D3750[] = "warp01"; +static s16 warpSpringMdl = -1; +static s16 warpImpactMdl = -1; +static s8 warpImpactPlayer[4] = {-1, -1, -1, -1}; -void fn_80080D54(s32 arg0) { - omVibrate(arg0, 0xC, 4, 2); - lbl_801D4028 = HuPrcChildCreate(fn_80080DF8, 0x2003U, 0x3800U, 0, boardMainProc); - HuPrcDestructorSet2(lbl_801D4028, fn_80081048); +static void WarpProcess(void); +static void WarpKill(void); - while (lbl_801D4028 != NULL) { +void BoardWarpExec(s32 player, s16 space) { + omVibrate(player, 12, 4, 2); + warpProcess = HuPrcChildCreate(WarpProcess, 8195, 14336, 0, boardMainProc); + HuPrcDestructorSet2(warpProcess, WarpKill); + + while (warpProcess != NULL) { HuPrcVSleep(); } - GWPlayer[arg0].color = 3; + GWPlayer[player].color = 3; } -void fn_80080DF8(void) { - s32 currPlayer; - f32 var_f1; - s32 temp_r3[8] = {291, 355, 419, 483, 547, 611, 675, 739}; +void WarpProcess(void) { + s32 curr_player; + s32 warp_sound[8] = {291, 355, 419, 483, 547, 611, 675, 739}; - lbl_801D4038 = 0; - currPlayer = GWSystem.player_curr; - HuAudFXPlay(0x34A); + warpState = 0; + curr_player = GWSystem.player_curr; + HuAudFXPlay(842); BoardCameraViewSet(3); BoardCameraMotionWait(); - BoardPlayerAnimBlendSet(currPlayer, 0, 15); + BoardPlayerAnimBlendSet(curr_player, 0, 15); - while (BoardPlayerAnimBlendCheck(currPlayer) == 0) { + while (BoardPlayerAnimBlendCheck(curr_player) == 0) { HuPrcVSleep(); } - BoardRotateDiceNumbers(currPlayer); + BoardRotateDiceNumbers(curr_player); if (_CheckFlag(0x1000B) != 0) { - BoardTutorialHookExec(0x12, 0); + BoardTutorialHookExec(18, 0); boardTutorialData[0] = 0; } - fn_800816CC(currPlayer, 3); + fn_800816CC(curr_player, 3); fn_80081884(18.0f); fn_8008181C(); - lbl_801D4037 = fn_8008186C(); + warpTarget = fn_8008186C(); BoardCameraViewSet(1); BoardCameraMotionWait(); - fn_800810A4(currPlayer); + WarpInit(curr_player); while (1) { - switch (lbl_801D4038) { + switch (warpState) { case 0: - if (BoardModelMotionTimeGet(lbl_801D3748) < 15.0f) { + if (BoardModelMotionTimeGet(warpSpringMdl) < 15.0f) { break; } - BoardModelHookReset(lbl_801D3748); - Hu3DModelObjPosGet(BoardModelIDGet(lbl_801D3748), lbl_801D3750, &lbl_801A4AC0); - BoardSpacePosGet(0, GWPlayer[currPlayer].space_curr, &lbl_801A4AC0); - lbl_801A4AC0.y += 700.0f; - BoardPlayerPosSetV(currPlayer, &lbl_801A4AC0); - lbl_801D4038 = 1; - HuAudFXPlay(temp_r3[GWPlayer[currPlayer].character]); + BoardModelHookReset(warpSpringMdl); + Hu3DModelObjPosGet(BoardModelIDGet(warpSpringMdl), "warp01", &warpPos); + BoardSpacePosGet(0, GWPlayer[curr_player].space_curr, &warpPos); + warpPos.y += 700.0f; + BoardPlayerPosSetV(curr_player, &warpPos); + warpState = 1; + HuAudFXPlay(warp_sound[GWPlayer[curr_player].character]); break; case 1: - fn_800811BC(currPlayer); + WarpLaunch(curr_player); break; case 2: - if (BoardModelMotionEndCheck(lbl_801D3748) == 0) break; - lbl_801D4038 = 6; + if (BoardModelMotionEndCheck(warpSpringMdl) == 0) break; + warpState = 6; break; case 3: - fn_80081278(currPlayer); + WarpStartImpact(curr_player); break; case 4: - fn_80081428(currPlayer); + WarpFall(curr_player); break; case 5: - fn_800814CC(currPlayer); + WarpImpact(curr_player); break; case 6: HuPrcEnd(); @@ -120,147 +123,135 @@ void fn_80080DF8(void) { } } -void fn_80081048(void) { - if (lbl_801D3748 != -1) { - BoardModelKill(lbl_801D3748); - lbl_801D3748 = -1; +void WarpKill(void) { + if (warpSpringMdl != -1) { + BoardModelKill(warpSpringMdl); + warpSpringMdl = -1; } - if (lbl_801D374A != -1) { - BoardModelKill(lbl_801D374A); - lbl_801D374A = -1; + if (warpImpactMdl != -1) { + BoardModelKill(warpImpactMdl); + warpImpactMdl = -1; } - lbl_801D4028 = NULL; + warpProcess = NULL; } -static inline PlayerState* GetPlayer(s32 index) { - return &GWPlayer[index]; +static void WarpInit(s32 player) { + Vec pos; + s16 player_mdl = BoardPlayerModelGet(player); + + warpSpringMdl = BoardModelCreate(MAKE_DATA_NUM(DATADIR_BOARD, 1), NULL, 0); + BoardSpacePosGet(0, GWPlayer[player].space_curr, &pos); + warpYFloor = 1500.0f + pos.y; + BoardModelLayerSet(warpSpringMdl, 2); + BoardCameraTargetModelSet(warpSpringMdl); + BoardModelMotionStart(warpSpringMdl, 0, 0); + BoardModelHookSet(warpSpringMdl, "warp01", player_mdl); + BoardModelPosSetV(warpSpringMdl, &pos); + HuAudFXPlay(835); + BoardPlayerRotYSet(player, 0.0f); + BoardPlayerPosSet(player, 0.0f, 0.0f, 0.0f); + BoardRotateDiceNumbers(player); } -static inline s16 GetBoardPlayer(s32 index) { - PlayerState *player = GetPlayer(index); - return boardPlayerMdl[player->player_idx]; -} +static void WarpLaunch(s32 player) { -void fn_800810A4(s32 arg0) { - Point3d sp8; - s16 temp_r30 = GetBoardPlayer(arg0); - - lbl_801D3748 = BoardModelCreate(0x70001, NULL, 0); - BoardSpacePosGet(0, GWPlayer[arg0].space_curr, &sp8); - lbl_801D4030 = 1500.0f + sp8.y; - BoardModelLayerSet(lbl_801D3748, 2); - BoardCameraTargetModelSet(lbl_801D3748); - BoardModelMotionStart(lbl_801D3748, 0, 0); - BoardModelHookSet(lbl_801D3748, lbl_801D3750, temp_r30); - BoardModelPosSetV(lbl_801D3748, &sp8); - HuAudFXPlay(0x343); - BoardPlayerRotYSet(arg0, 0.0f); - BoardPlayerPosSet(arg0, 0.0f, 0.0f, 0.0f); - BoardRotateDiceNumbers(arg0); -} - -void fn_800811BC(s32 arg0) { - f32 temp_f1; - - lbl_801A4AC0.y += 20.0f; - BoardPlayerPosSetV(arg0, &lbl_801A4AC0); - if (!(lbl_801A4AC0.y < lbl_801D4030)) { + warpPos.y += 20.0f; + BoardPlayerPosSetV(player, &warpPos); + if (!(warpPos.y < warpYFloor)) { WipeColorSet(0U, 0U, 0U); - WipeCreate(2, 0, 0x15); + WipeCreate(2, 0, 21); while (WipeStatGet() != 0) { HuPrcVSleep(); } - lbl_801A4AC0.y = lbl_801D4030; - BoardModelVisibilitySet(lbl_801D3748, 0); - lbl_801D4038 = 3; + warpPos.y = warpYFloor; + BoardModelVisibilitySet(warpSpringMdl, 0); + warpState = 3; } } -void fn_80081278(s32 arg0) { - f32 temp_f1; - s32 var_r31; +static void WarpStartImpact(s32 player) { + s32 i; - lbl_801D4034 = GWPlayer[lbl_801D4037].space_curr; - GWPlayer[arg0].space_curr = lbl_801D4034; - BoardSpacePosGet(0, lbl_801D4034, &lbl_801A4AC0); - lbl_801D4030 = lbl_801A4AC0.y; - lbl_801A4AC0.y += 1500.0f; - BoardPlayerPosSetV(arg0, &lbl_801A4AC0); - BoardPlayerRotSet(arg0, 180.0f, 180.0f, 0.0f); + warpSpace = GWPlayer[warpTarget].space_curr; + GWPlayer[player].space_curr = warpSpace; + BoardSpacePosGet(0, warpSpace, &warpPos); + warpYFloor = warpPos.y; + warpPos.y += 1500.0f; + BoardPlayerPosSetV(player, &warpPos); + BoardPlayerRotSet(player, 180.0f, 180.0f, 0.0f); - for (var_r31 = 0, lbl_801D4036 = var_r31; var_r31 < 4; var_r31++) { - if (lbl_801D4034 == GWPlayer[var_r31].space_curr) { - lbl_801D374C[lbl_801D4036] = var_r31; - lbl_801D4036++; + for (i = 0, warpImpactCnt = i; i < 4; i++) { + if (warpSpace == GWPlayer[i].space_curr) { + warpImpactPlayer[warpImpactCnt] = i; + warpImpactCnt++; } } - lbl_801D374A = BoardModelCreate(0x70002, NULL, 0); - BoardModelVisibilitySet(lbl_801D374A, 0); - BoardModelMotionSpeedSet(lbl_801D374A, 0.0f); + warpImpactMdl = BoardModelCreate(MAKE_DATA_NUM(DATADIR_BOARD, 2), NULL, 0); + BoardModelVisibilitySet(warpImpactMdl, 0); + BoardModelMotionSpeedSet(warpImpactMdl, 0.0f); BoardCameraMoveSet(0); - BoardCameraTargetSpaceSet(lbl_801D4034); + BoardCameraTargetSpaceSet(warpSpace); HuPrcSleep(1); WipeCreate(1, 0, 0x15); while (WipeStatGet() != 0) { HuPrcVSleep(); } BoardCameraMoveSet(1); - lbl_801D402C = -10.0f; - lbl_801D4038 = 4; + warpYVel = -10.0f; + warpState = 4; } -void fn_80081428(s32 arg0) { - lbl_801D402C += -2.0f; - lbl_801A4AC0.y += lbl_801D402C; - if (lbl_801A4AC0.y <= (150.0f + lbl_801D4030)) { - lbl_801A4AC0.y = lbl_801D4030; - lbl_801D4038 = 5; - HuAudFXPlay(0x345); - HuAudFXPlay(0x33D); +static void WarpFall(s32 player) { + warpYVel += -2.0f; + warpPos.y += warpYVel; + if (warpPos.y <= (150.0f + warpYFloor)) { + warpPos.y = warpYFloor; + warpState = 5; + HuAudFXPlay(837); + HuAudFXPlay(829); } - BoardPlayerPosSetV(arg0, &lbl_801A4AC0); + BoardPlayerPosSetV(player, &warpPos); } -void fn_800814CC(s32 arg0) { - Vec sp18; - Point3d spC; - s16 sp8; - f32 temp_f29; +static void WarpImpact(s32 player) { + Vec pos; + Vec pos_player; + s16 temp; + f32 speed; f32 temp_f30; - f32 var_f31; - s16 var_r31; - s32 temp_r30; + f32 angle; + s16 i; - sp18.x = 288.0f; - sp18.y = 240.0f; - sp18.z = 700.0f; - Hu3D2Dto3D(&sp18, 1, &sp18); - BoardModelPosSetV(lbl_801D374A, &sp18); - BoardModelVisibilitySet(lbl_801D374A, 1); - BoardModelMotionStart(lbl_801D374A, 0, 0x40000001); + pos.x = 288.0f; + pos.y = 240.0f; + pos.z = 700.0f; + Hu3D2Dto3D(&pos, 1, &pos); + BoardModelPosSetV(warpImpactMdl, &pos); + BoardModelVisibilitySet(warpImpactMdl, 1); + BoardModelMotionStart(warpImpactMdl, 0, 0x40000001); - for (var_r31 = 0; var_r31 < lbl_801D4036; var_r31++) { - temp_r30 = lbl_801D374C[var_r31]; - omVibrate(temp_r30, 0xC, 4, 2); - BoardPlayerMotionStart(temp_r30, 6, 0x40000001); + for (i = 0; i < warpImpactCnt; i++) { + s32 player = warpImpactPlayer[i]; + omVibrate(player, 0xC, 4, 2); + BoardPlayerMotionStart(player, 6, 0x40000001); } - BoardPlayerRotSet(arg0, 0.0f, 0.0f, 0.0f); - BoardPlayerPosGet(arg0, &spC); - spC.y = lbl_801D4030; - BoardPlayerPosSetV(arg0, &spC); - temp_f29 = 4.0f; + BoardPlayerRotSet(player, 0.0f, 0.0f, 0.0f); + BoardPlayerPosGet(player, &pos_player); + pos_player.y = warpYFloor; + BoardPlayerPosSetV(player, &pos_player); + speed = 4.0f; - for (var_f31 = 0.0f, sp8 = var_f31; var_f31 < 180.0f; var_f31 += temp_f29) { - temp_f30 = sin((M_PI * var_f31) / 180.0); - BoardModelScaleSet(lbl_801D374A, 0.5f + temp_f30, 0.5f + temp_f30, 0.5f + temp_f30); + for (angle = 0.0f, temp = angle; angle < 180.0f; angle += speed) { + temp_f30 = sin((M_PI * angle) / 180.0); + BoardModelScaleSet(warpImpactMdl, 0.5f + temp_f30, 0.5f + temp_f30, 0.5f + temp_f30); HuPrcVSleep(); } - BoardModelVisibilitySet(lbl_801D374A, 0); - HuPrcSleep(0x3C); + BoardModelVisibilitySet(warpImpactMdl, 0); + HuPrcSleep(60); - for (var_r31 = 0; var_r31 < lbl_801D4036; var_r31++) { - BoardRotateDiceNumbers(lbl_801D374C[var_r31]); + for (i = 0; i < warpImpactCnt; i++) { + BoardRotateDiceNumbers(warpImpactPlayer[i]); } - lbl_801D4038 = 6; + warpState = 6; } \ No newline at end of file diff --git a/src/game/board/window.c b/src/game/board/window.c index 8bd41ae7..3137125b 100644 --- a/src/game/board/window.c +++ b/src/game/board/window.c @@ -1,9 +1,8 @@ #include "game/board/window.h" +#include "game/board/main.h" +#include "game/board/player.h" #include "game/gamework_data.h" -extern s32 BoardPlayerIsAllCom(void); -extern Process* boardMainProc; - static s8 winChoice; static s8 autoPickF; static s8 winPortrait; From 4ef79abcb54d0b3e913a1f9016f66be9dfd03233 Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Sat, 6 Jan 2024 23:48:26 -0600 Subject: [PATCH 4/8] Start decompiling board/space.c --- config/GMPE01_00/symbols.txt | 18 +-- src/game/board/space.c | 301 +++++++++++++++++++++++++++++++++++ 2 files changed, 310 insertions(+), 9 deletions(-) create mode 100644 src/game/board/space.c diff --git a/config/GMPE01_00/symbols.txt b/config/GMPE01_00/symbols.txt index d5ff628b..40a78089 100644 --- a/config/GMPE01_00/symbols.txt +++ b/config/GMPE01_00/symbols.txt @@ -1385,22 +1385,22 @@ BoardSpaceFlagGet = .text:0x80074138; // type:function size:0x48 BoardSpaceTypeGet = .text:0x80074180; // type:function size:0x48 BoardSpaceTypeSet = .text:0x800741C8; // type:function size:0x48 BoardSpacePosGet = .text:0x80074210; // type:function size:0x8C -BoardSpaceDirPosGet = .text:0x8007429C; // type:function size:0x2C8 +BoardSpaceCornerPosGet = .text:0x8007429C; // type:function size:0x2C8 BoardSpaceRotGet = .text:0x80074564; // type:function size:0x8C BoardSpaceFlagSearch = .text:0x800745F0; // type:function size:0xA0 BoardSpaceFlagPosGet = .text:0x80074690; // type:function size:0x134 BoardSpaceLinkFlagSearch = .text:0x800747C4; // type:function size:0x134 -BoardSpaceLinkGet = .text:0x800748F8; // type:function size:0x148 -BoardSpaceLinkTargetGet = .text:0x80074A40; // type:function size:0x104 -BoardSpaceLinkSearch = .text:0x80074B44; // type:function size:0x110 -BoardSpaceTransformGet = .text:0x80074C54; // type:function size:0x1FC +BoardSpaceLinkTypeListGet = .text:0x800748F8; // type:function size:0x148 +BoardSpaceLinkTargetListGet = .text:0x80074A40; // type:function size:0x104 +BoardSpaceLinkTypeSearch = .text:0x80074B44; // type:function size:0x110 +BoardSpaceLinkTransformGet = .text:0x80074C54; // type:function size:0x1FC BoardSpaceStarSet = .text:0x80074E50; // type:function size:0x1BC BoardSpaceStarSetIndex = .text:0x8007500C; // type:function size:0x4AC -BoardSpaceStarNextGet = .text:0x800754B8; // type:function size:0x344 -BoardSpaceStarRandomGet = .text:0x800757FC; // type:function size:0x9C +BoardSpaceStarGetNext = .text:0x800754B8; // type:function size:0x344 +BoardSpaceStarGetRandom = .text:0x800757FC; // type:function size:0x9C BoardSpaceStarMove = .text:0x80075898; // type:function size:0xF0 BoardSpaceStarGet = .text:0x80075988; // type:function size:0x1C -BoardSpaceStarCurrGet = .text:0x800759A4; // type:function size:0x3C +BoardSpaceStarGetCurr = .text:0x800759A4; // type:function size:0x3C BoardSpaceStarCheck = .text:0x800759E0; // type:function size:0x110 BoardSpaceLandExec = .text:0x80075AF0; // type:function size:0x474 BoardSpaceWalkExec = .text:0x80075F64; // type:function size:0x2A4 @@ -5533,7 +5533,7 @@ winInsertMesTbl = .bss:0x8019D998; // type:object size:0x20 scope:local choiceDisableTbl = .bss:0x8019D9B8; // type:object size:0x40 scope:local lbl_8019D9F8 = .bss:0x8019D9F8; // type:object size:0xC data:float lbl_8019DA04 = .bss:0x8019DA04; // type:object size:0xC data:4byte -SpaceData = .bss:0x8019DA10; // type:object size:0x7000 scope:local data:float +spaceData = .bss:0x8019DA10; // type:object size:0x7000 scope:local data:float boardSpaceStarTbl = .bss:0x801A4A10; // type:object size:0x10 spaceTex = .bss:0x801A4A20; // type:object size:0x20 scope:local spaceHiliteTex = .bss:0x801A4A40; // type:object size:0x20 scope:local diff --git a/src/game/board/space.c b/src/game/board/space.c new file mode 100644 index 00000000..de7ac506 --- /dev/null +++ b/src/game/board/space.c @@ -0,0 +1,301 @@ +#include "game/gamework_data.h" +#include "game/flag.h" +#include "math.h" + +extern s16 fn_80083F84(void); +extern void BoardModelPosSetV(s16 model, Vec *pos); + +typedef s32 (*BoardSpaceEventFunc)(void); + +typedef struct board_space { + Vec pos; + u32 flag; + Vec scale; + Vec rot; + u16 type; + u16 link_cnt; + u16 link[5]; +} BoardSpace; + +static GXTexObj spaceHiliteTex; +static GXTexObj spaceTex; +s16 boardSpaceStarTbl[8]; +static BoardSpace spaceData[2][256]; + +static s16 spaceCnt[2]; +static u32 spaceAttr[2]; +static void *spaceTexData; +static void *spaceHiliteTexData; +static GXTexFmt spaceTexFmt; +static GXTexFmt spaceHiliteTexFmt; +s16 lbl_801D3FC4[4]; +static BoardSpaceEventFunc landEventFunc; +static BoardSpaceEventFunc walkMiniEventFunc; +static BoardSpaceEventFunc walkEventFunc; +static s32 spaceDrawCnt; +static s16 spaceDrawF; + +static s16 spaceDrawMdl = -1; +static s16 starMdl = -1; + +s32 BoardSpaceRotGet(s32 layer, s32 index, Vec *rot); + +void BoardSpaceWalkEventFuncSet(BoardSpaceEventFunc func) +{ + walkEventFunc = func; +} + +void BoardSpaceWalkMiniEventFuncSet(BoardSpaceEventFunc func) +{ + walkMiniEventFunc = func; +} + +void BoardSpaceLandEventFuncSet(BoardSpaceEventFunc func) +{ + landEventFunc = func; +} + +s32 BoardSpaceWalkEventExec(void) +{ + s32 ret = -1; + if(walkEventFunc) { + ret = walkEventFunc(); + } + return ret; +} + +s32 BoardSpaceWalkMiniEventExec(void) +{ + s32 ret = -1; + if(walkMiniEventFunc) { + _SetFlag(FLAG_ID_MAKE(1, 8)); + ret = walkMiniEventFunc(); + _ClearFlag(FLAG_ID_MAKE(1, 8)); + } + return ret; +} + +s16 BoardSpaceCountGet(s32 layer) +{ + return spaceCnt[layer]; +} + +BoardSpace *BoardSpaceGet(s32 layer, s32 index) +{ + if(index <= 0 || index > spaceCnt[layer]) { + return NULL; + } else { + return &spaceData[layer][index-1]; + } +} + +void BoardSpaceAttrSet(s32 layer, u32 attr) +{ + spaceAttr[layer] |= attr; +} + +void BoardSpaceAttrReset(s32 layer, u32 attr) +{ + spaceAttr[layer] &= ~attr; +} + +u32 BoardSpaceFlagGet(s32 layer, s32 index) +{ + if(index <= 0 || index > spaceCnt[layer]) { + return 0; + } else { + return spaceData[layer][index-1].flag; + } +} + +u16 BoardSpaceTypeGet(s32 layer, s32 index) +{ + if(index <= 0 || index > spaceCnt[layer]) { + return 0; + } else { + return spaceData[layer][index-1].type; + } +} + +void BoardSpaceTypeSet(s32 layer, s32 index, int type) +{ + if(index <= 0 || index > spaceCnt[layer]) { + return; + } else { + spaceData[layer][index-1].type = type; + } +} + +s32 BoardSpacePosGet(s32 layer, s32 index, Vec *pos) +{ + BoardSpace *space = BoardSpaceGet(layer, index); + if(!space) { + return -1; + } else { + *pos = space->pos; + return 0; + } +} + +void BoardSpaceCornerPosGet(s32 index, s32 corner, Vec *pos) +{ + Vec corner_ofs; + Vec rot; + s8 corner_pos[4][2] = {{-1, -1}, {1, -1}, {-1, 1}, {1, 1}}; + BoardSpaceRotGet(0, index, &rot); + BoardSpacePosGet(0, index, pos); + corner_ofs.x = corner_pos[corner][0]*80.0f; + corner_ofs.y = 0; + corner_ofs.z = corner_pos[corner][1]*80.0f; + corner_ofs.x = (cos((M_PI*rot.z)/180)*corner_ofs.x)+(sin((M_PI*rot.z)/180)*corner_ofs.y); + corner_ofs.y = (cos((M_PI*rot.x)/180)*cos((M_PI*rot.z)/180)*corner_ofs.y) + +(sin((M_PI*rot.z)/180)*corner_ofs.x) + +(sin((M_PI*-rot.x)/180)*corner_ofs.z); + corner_ofs.z = (sin((M_PI*rot.x)/180)*corner_ofs.y)+(cos((M_PI*rot.x)/180)*corner_ofs.z); + pos->x += corner_ofs.x; + pos->y += corner_ofs.y; + pos->z += corner_ofs.z; +} + +s32 BoardSpaceRotGet(s32 layer, s32 index, Vec *rot) +{ + BoardSpace *space = BoardSpaceGet(layer, index); + if(!space) { + return -1; + } else { + *rot = space->rot; + return 0; + } +} + +s32 BoardSpaceFlagSearch(s32 layer, u32 flag) +{ + s32 i; + for(i=0; iflag & flag) == flag) { + return space-(&spaceData[layer][0])+1; + } + } + return -1; +} + +s32 BoardSpaceFlagPosGet(s32 layer, u32 flag, Vec *pos) +{ + s32 space = BoardSpaceFlagSearch(layer, flag); + if(space == -1) { + return -1; + } + if(pos) { + BoardSpacePosGet(layer, space, pos); + } + return space; +} + +s32 BoardSpaceLinkFlagSearch(s32 layer, s32 index, u32 flag) +{ + BoardSpace *space = BoardSpaceGet(layer, index); + s32 i; + if(!space) { + return -1; + } + for(i=0; ilink_cnt; i++) { + BoardSpace *link_space = BoardSpaceGet(layer, space->link[i]); + if(link_space->flag & flag) { + return link_space-&spaceData[layer][0]+1; + } + } + return -1; +} + +s32 BoardSpaceLinkTypeListGet(s32 layer, s32 index, int type, s16 *list) +{ + s32 count; + BoardSpace *space = BoardSpaceGet(layer, index); + s32 i; + if(!space) { + return -1; + } + for(count=i=0; ilink_cnt; i++) { + BoardSpace *link_space = BoardSpaceGet(layer, space->link[i]); + if(link_space->type == type && count < 4) { + list[count] = link_space-&spaceData[layer][0]+1; + count++; + } + } + return count; +} + +s32 BoardSpaceLinkTargetListGet(s32 layer, s32 target, s16 *list) +{ + s32 i, j; + s32 count; + BoardSpace *space; + memset(list, 0, 4*sizeof(s16)); + space = &spaceData[layer][0]; + for(count=i=0; ilink_cnt; j++) { + if(space->link[j] == target && count < 4) { + list[count++] = space-&spaceData[layer][0]+1; + } + } + } + return count; +} + +s32 BoardSpaceLinkTypeSearch(s32 layer, s32 target, u16 type) +{ + s32 i; + BoardSpace *space = BoardSpaceGet(layer, target); + if(!space) { + return -1; + } + for(i=0; ilink_cnt; i++) { + BoardSpace *link_space = BoardSpaceGet(layer, space->link[i]); + if(link_space->type == type) { + return space->link[i]; + } + } + return -1; +} + +s32 BoardSpaceLinkTransformGet(s32 flag, Vec *pos, Vec *rot, Vec *scale) +{ + s32 i; + s32 space_flag = BoardSpaceFlagSearch(0, flag); + BoardSpace *space = BoardSpaceGet(0, space_flag); + + for(i=0; ilink_cnt; i++) { + BoardSpace *link_space = BoardSpaceGet(0, space->link[i]); + BoardSpace *src_space; + if(!(link_space->flag & 0x2000000)) { + continue; + } + src_space = BoardSpaceGet(0, link_space->link[0]); + if(pos) { + *pos = src_space->pos; + } + if(rot) { + *rot = src_space->rot; + } + if(scale) { + *scale = src_space->scale; + } + return 0; + } + return -1; +} + +void BoardSpaceStarSet(s32 space) +{ + s16 space_platid; + BoardSpace *space_plat; + Vec pos; + BoardSpaceTypeSet(0, space, 8); + space_platid = BoardSpaceLinkFlagSearch(0, space, 0x04000000); + space_plat = BoardSpaceGet(0, space_platid); + if(space_plat) { + pos = space_plat->pos; + } + BoardModelPosSetV(fn_80083F84(), &pos); +} \ No newline at end of file From b91dcdc903cb78b437716ac2ce1ec270cf18e327 Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Sun, 7 Jan 2024 09:46:39 -0600 Subject: [PATCH 5/8] Decompile star space functions --- src/game/board/space.c | 224 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 217 insertions(+), 7 deletions(-) diff --git a/src/game/board/space.c b/src/game/board/space.c index de7ac506..0943cb03 100644 --- a/src/game/board/space.c +++ b/src/game/board/space.c @@ -1,5 +1,7 @@ #include "game/gamework_data.h" #include "game/flag.h" +#include "game/board/main.h" + #include "math.h" extern s16 fn_80083F84(void); @@ -39,6 +41,8 @@ static s16 spaceDrawMdl = -1; static s16 starMdl = -1; s32 BoardSpaceRotGet(s32 layer, s32 index, Vec *rot); +s32 BoardSpaceStarGet(s32 index); +s32 BoardSpaceStarGetCurr(void); void BoardSpaceWalkEventFuncSet(BoardSpaceEventFunc func) { @@ -108,7 +112,7 @@ u32 BoardSpaceFlagGet(s32 layer, s32 index) } } -u16 BoardSpaceTypeGet(s32 layer, s32 index) +int BoardSpaceTypeGet(s32 layer, s32 index) { if(index <= 0 || index > spaceCnt[layer]) { return 0; @@ -194,13 +198,14 @@ s32 BoardSpaceFlagPosGet(s32 layer, u32 flag, Vec *pos) s32 BoardSpaceLinkFlagSearch(s32 layer, s32 index, u32 flag) { + BoardSpace *link_space; BoardSpace *space = BoardSpaceGet(layer, index); s32 i; if(!space) { return -1; } for(i=0; ilink_cnt; i++) { - BoardSpace *link_space = BoardSpaceGet(layer, space->link[i]); + link_space = BoardSpaceGet(layer, space->link[i]); if(link_space->flag & flag) { return link_space-&spaceData[layer][0]+1; } @@ -289,13 +294,218 @@ s32 BoardSpaceLinkTransformGet(s32 flag, Vec *pos, Vec *rot, Vec *scale) void BoardSpaceStarSet(s32 space) { s16 space_platid; - BoardSpace *space_plat; Vec pos; + BoardSpace *space_plat; BoardSpaceTypeSet(0, space, 8); space_platid = BoardSpaceLinkFlagSearch(0, space, 0x04000000); - space_plat = BoardSpaceGet(0, space_platid); - if(space_plat) { - pos = space_plat->pos; - } + BoardSpacePosGet(0, space_platid, &pos); BoardModelPosSetV(fn_80083F84(), &pos); +} + +static inline s16 BoardStarMdlGet(void) +{ + return starMdl; +} + +static inline s32 BoardStarSpaceTypeGet(s16 index) +{ + return BoardSpaceTypeGet(0, BoardSpaceStarGet(index)); +} + +void BoardSpaceStarSetIndex(s32 index) +{ + Vec pos; + Vec rot; + s16 space; + if(_CheckFlag(FLAG_ID_MAKE(1, 1))) { + BoardSpaceTypeSet(0, boardSpaceStarTbl[GWSystem.star_pos], 1); + } + GWSystem.star_pos = index & 0x7; + BoardSpaceStarSet(BoardSpaceStarGetCurr()); + space = BoardSpaceLinkFlagSearch(0, BoardSpaceStarGetCurr(), 0x04000000); + BoardSpacePosGet(0, space, &pos); + BoardModelPosSetV(BoardStarMdlGet(), &pos); + BoardSpaceRotGet(0, space, &rot); + BoardModelRotYSet(BoardStarMdlGet(), rot.y); + BoardModelVisibilitySet(BoardStarMdlGet(), 1); +} + +s32 BoardSpaceStarGetNext(void) +{ + s16 random_pos; + s16 star_total; + s16 star_pos; + star_total = GWSystem.star_total; + star_pos = GWSystem.star_pos; + if(BoardCurrGet() == 5) { + s16 i; + s32 count; + s32 last_free; + last_free = -1; + for(count=i=0; i<8; i++) { + if((1 << i) & GWSystem.star_flag) { + count++; + } else { + last_free = i; + } + } + if(count == 7) { + if(BoardSpaceTypeGet(0, BoardSpaceStarGet(last_free)) == 10) { + GWSystem.star_flag = 0; + } + } + } + begin: + random_pos = BoardRandMod(8); + if(star_pos == random_pos || BoardStarSpaceTypeGet(random_pos) == 10) { + goto begin; + } + switch(GWSystem.board) { + case 0: + if(star_total >= 2) { + break; + } + if(random_pos != 6 && random_pos != 7) { + break; + } + goto begin; + + case 1: + if(star_total >= 2) { + break; + } + if(random_pos != 6 && random_pos != 7) { + break; + } + goto begin; + + case 2: + if(star_total == 1) { + if(random_pos < 3 || random_pos > 5) { + break; + } + goto begin; + } else { + if(star_total != 2) { + break; + } + if(random_pos != 3 && random_pos != 4) { + break; + } + goto begin; + } + + case 3: + if(star_total == 1) { + if(random_pos < 5 || random_pos > 7) { + break; + } + goto begin; + } else { + if(star_total != 2) { + break; + } + if(random_pos == 5) { + goto begin; + } + break; + } + + case 4: + if(star_total == 1) { + if(random_pos <= 1 || random_pos >= 4) { + goto begin; + } + } + break; + + case 5: + if(star_total == 1) { + if(random_pos == 1 || random_pos == 4 || random_pos == 5) { + goto begin; + } + } + if(star_total != 2) { + break; + } + if(random_pos == 5) { + goto begin; + } + } + if((1 << random_pos) & GWSystem.star_flag) { + goto begin; + } + return random_pos; +} + +s32 BoardSpaceStarGetRandom(s32 excl_pos) +{ + s8 new_pos; + int i; + for(i=0; i<1024; i++) { + new_pos = BoardRandMod(8); + if(new_pos == GWSystem.star_pos) { + continue; + } + if(GWSystem.turn == 1 && new_pos <= 2) { + continue; + } + if(new_pos != excl_pos) { + break; + } + } + return new_pos; +} + +//Fix GWSystem.star_total truncation and double GWSystem load +void BoardSpaceStarMove(void) +{ + u8 star_total; + s16 star_pos; + s16 star_next; + if(_CheckFlag(FLAG_ID_MAKE(1, 1))) { + star_pos = GWSystem.star_pos; + GWSystem.star_flag |= (u8)(1 << star_pos); + if(GWSystem.star_flag == 0xFF) { + GWSystem.star_flag = 0; + } + if(GWSystem.star_total >= 99) { + star_total = 99; + GWSystem.star_total = star_total; + } else { + star_total = GWSystem.star_total; + GWSystem.star_total = (u8)(1+star_total); + } + } + star_next = BoardSpaceStarGetNext(); + BoardSpaceStarSetIndex(star_next); +} + +s32 BoardSpaceStarGet(s32 index) +{ + return boardSpaceStarTbl[index & 0x7]; +} + +s32 BoardSpaceStarGetCurr(void) +{ + return BoardSpaceStarGet(GWSystem.star_pos); +} + +s32 BoardSpaceStarCheck(s32 index) +{ + s32 ret; + BoardSpace *space = BoardSpaceGet(0, index); + BoardSpace *star_space; + if(BoardCurrGet() == 7 || BoardCurrGet() == 8) { + ret = 0; + goto end; + } + star_space = BoardSpaceGet(0, boardSpaceStarTbl[GWSystem.star_pos]); + if(space == star_space) { + ret = 1; + } else { + ret = 0; + } + end: + return ret; } \ No newline at end of file From bbafa85ac0b712333278a7d9546e56a93d275730 Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Sun, 7 Jan 2024 11:28:33 -0600 Subject: [PATCH 6/8] Decompile BoardSpaceLandExec Also labeled some more functions --- config/GMPE01_00/symbols.txt | 24 ++++---- include/board_unsplit.h | 2 +- include/game/gamework_data.h | 16 +++--- src/REL/w10Dll/scene.c | 2 +- src/game/board/space.c | 103 ++++++++++++++++++++++++++++++++--- 5 files changed, 118 insertions(+), 29 deletions(-) diff --git a/config/GMPE01_00/symbols.txt b/config/GMPE01_00/symbols.txt index 40a78089..447770c7 100644 --- a/config/GMPE01_00/symbols.txt +++ b/config/GMPE01_00/symbols.txt @@ -1404,8 +1404,8 @@ BoardSpaceStarGetCurr = .text:0x800759A4; // type:function size:0x3C BoardSpaceStarCheck = .text:0x800759E0; // type:function size:0x110 BoardSpaceLandExec = .text:0x80075AF0; // type:function size:0x474 BoardSpaceWalkExec = .text:0x80075F64; // type:function size:0x2A4 -BoardSpaceHiddenBlockExec = .text:0x80076208; // type:function size:0x180 -BoardSpacePipeJumpExec = .text:0x80076388; // type:function size:0x268 +BoardSpaceBlockExec = .text:0x80076208; // type:function size:0x180 +BoardSpacePipeExec = .text:0x80076388; // type:function size:0x268 BoardSpaceTypeForce = .text:0x800765F0; // type:function size:0x5C BoardSpaceHide = .text:0x8007664C; // type:function size:0x48 DrawSpaces = .text:0x80076694; // type:function size:0x9E8 scope:local @@ -1418,7 +1418,7 @@ fn_80077AAC = .text:0x80077AAC; // type:function size:0x8 fn_80077AB4 = .text:0x80077AB4; // type:function size:0x8 fn_80077ABC = .text:0x80077ABC; // type:function size:0xD4 fn_80077B90 = .text:0x80077B90; // type:function size:0xA0 -fn_80077C30 = .text:0x80077C30; // type:function size:0x9C +BoardShopExec = .text:0x80077C30; // type:function size:0x9C fn_80077CCC = .text:0x80077CCC; // type:function size:0x800 fn_800784CC = .text:0x800784CC; // type:function size:0xD4 fn_800785A0 = .text:0x800785A0; // type:function size:0x1B4 @@ -1448,7 +1448,7 @@ fn_8007A330 = .text:0x8007A330; // type:function size:0x30 fn_8007A360 = .text:0x8007A360; // type:function size:0x4DC fn_8007A83C = .text:0x8007A83C; // type:function size:0x8 fn_8007A844 = .text:0x8007A844; // type:function size:0x8 -fn_8007A84C = .text:0x8007A84C; // type:function size:0x8C +BoardLotteryExec = .text:0x8007A84C; // type:function size:0x8C fn_8007A8D8 = .text:0x8007A8D8; // type:function size:0x16C fn_8007AA44 = .text:0x8007AA44; // type:function size:0x3B4 fn_8007ADF8 = .text:0x8007ADF8; // type:function size:0x1FC @@ -1520,7 +1520,7 @@ fn_80082888 = .text:0x80082888; // type:function size:0x224 fn_80082AAC = .text:0x80082AAC; // type:function size:0x10 fn_80082ABC = .text:0x80082ABC; // type:function size:0x148 fn_80082C04 = .text:0x80082C04; // type:function size:0x8C -fn_80082C90 = .text:0x80082C90; // type:function size:0xA4 +BoardMushroomExec = .text:0x80082C90; // type:function size:0xA4 fn_80082D34 = .text:0x80082D34; // type:function size:0x38C fn_800830C0 = .text:0x800830C0; // type:function size:0x58 fn_80083118 = .text:0x80083118; // type:function size:0x118 @@ -1542,8 +1542,8 @@ fn_80083E14 = .text:0x80083E14; // type:function size:0x38 fn_80083E4C = .text:0x80083E4C; // type:function size:0x48 fn_80083E94 = .text:0x80083E94; // type:function size:0x48 fn_80083EDC = .text:0x80083EDC; // type:function size:0xA8 -fn_80083F84 = .text:0x80083F84; // type:function size:0x8 -fn_80083F8C = .text:0x80083F8C; // type:function size:0xCC +BoardStarHostMdlGet = .text:0x80083F84; // type:function size:0x8 +BoardStarExec = .text:0x80083F8C; // type:function size:0xCC fn_80084058 = .text:0x80084058; // type:function size:0x8F4 fn_8008494C = .text:0x8008494C; // type:function size:0x84 fn_800849D0 = .text:0x800849D0; // type:function size:0x160 @@ -1653,7 +1653,7 @@ SetItemWindowCurr = .text:0x8008D9E8; // type:function size:0xA4 scope:local UpdateItemWindow = .text:0x8008DA8C; // type:function size:0x350 scope:local CreatePickerWindow = .text:0x8008DDDC; // type:function size:0x148 scope:local KillPickerWindow = .text:0x8008DF24; // type:function size:0x44 scope:local -fn_8008DF68 = .text:0x8008DF68; // type:function size:0x84 +BoardBlockExec = .text:0x8008DF68; // type:function size:0x84 fn_8008DFEC = .text:0x8008DFEC; // type:function size:0x358 fn_8008E344 = .text:0x8008E344; // type:function size:0x54 fn_8008E398 = .text:0x8008E398; // type:function size:0x1F4 @@ -1709,7 +1709,7 @@ fn_800972A4 = .text:0x800972A4; // type:function size:0x2C fn_800972D0 = .text:0x800972D0; // type:function size:0x2C fn_800972FC = .text:0x800972FC; // type:function size:0x2C fn_80097328 = .text:0x80097328; // type:function size:0x284 -fn_800975AC = .text:0x800975AC; // type:function size:0x144 +BoardBowserExec = .text:0x800975AC; // type:function size:0x144 fn_800976F0 = .text:0x800976F0; // type:function size:0x28C fn_8009797C = .text:0x8009797C; // type:function size:0x208 fn_80097B84 = .text:0x80097B84; // type:function size:0x1DC @@ -1764,7 +1764,7 @@ fn_8009B2B0 = .text:0x8009B2B0; // type:function size:0x80 fn_8009B330 = .text:0x8009B330; // type:function size:0xD8 fn_8009B408 = .text:0x8009B408; // type:function size:0x6C fn_8009B474 = .text:0x8009B474; // type:function size:0x60 -fn_8009B4D4 = .text:0x8009B4D4; // type:function size:0x124 +BoardBattleExec = .text:0x8009B4D4; // type:function size:0x124 fn_8009B5F8 = .text:0x8009B5F8; // type:function size:0x2C fn_8009B624 = .text:0x8009B624; // type:function size:0x708 fn_8009BD2C = .text:0x8009BD2C; // type:function size:0x1D4 @@ -1786,7 +1786,7 @@ fn_8009CF84 = .text:0x8009CF84; // type:function size:0x24 fn_8009CFA8 = .text:0x8009CFA8; // type:function size:0x10 fn_8009CFB8 = .text:0x8009CFB8; // type:function size:0x34 fn_8009CFEC = .text:0x8009CFEC; // type:function size:0x15C -fn_8009D148 = .text:0x8009D148; // type:function size:0x124 +BoardFortuneExec = .text:0x8009D148; // type:function size:0x124 fn_8009D26C = .text:0x8009D26C; // type:function size:0x74 fn_8009D2E0 = .text:0x8009D2E0; // type:function size:0xC fn_8009D2EC = .text:0x8009D2EC; // type:function size:0x340 @@ -1873,7 +1873,7 @@ fn_800A4F6C = .text:0x800A4F6C; // type:function size:0x8 fn_800A4F74 = .text:0x800A4F74; // type:function size:0x8 fn_800A4F7C = .text:0x800A4F7C; // type:function size:0xB4 fn_800A5030 = .text:0x800A5030; // type:function size:0x50 -fn_800A5080 = .text:0x800A5080; // type:function size:0x94 +BoardBooHouseExec = .text:0x800A5080; // type:function size:0x94 fn_800A5114 = .text:0x800A5114; // type:function size:0x538 fn_800A564C = .text:0x800A564C; // type:function size:0xF0 fn_800A573C = .text:0x800A573C; // type:function size:0xFC diff --git a/include/board_unsplit.h b/include/board_unsplit.h index a8aa1322..5f16e89e 100644 --- a/include/board_unsplit.h +++ b/include/board_unsplit.h @@ -9,7 +9,7 @@ void BoardCameraMotionWait(void); void BoardSpacePosGet(s32, s32, Vec*); void fn_8007A360(s32); void fn_8007F894(void); -s16 fn_80083F84(void); +s16 BoardStarHostMdlGet(void); void BoardStatusShowSetAll(s32); void fn_800A4C88(void); void fn_800A6B10(void); diff --git a/include/game/gamework_data.h b/include/game/gamework_data.h index 5a16cdd6..d86c21c1 100644 --- a/include/game/gamework_data.h +++ b/include/game/gamework_data.h @@ -83,14 +83,14 @@ typedef struct player_state { /* 0x0E */ s16 space_prev; /* 0x10 */ s16 space_next; /* 0x12 */ s16 space_shock; -/* 0x14 */ u8 blue_count; -/* 0x15 */ u8 red_count; -/* 0x16 */ u8 question_count; -/* 0x17 */ u8 fortune_count; -/* 0x18 */ u8 bowser_count; -/* 0x19 */ u8 battle_count; -/* 0x1A */ u8 mushroom_count; -/* 0x1B */ u8 warp_count; +/* 0x14 */ s8 blue_count; +/* 0x15 */ s8 red_count; +/* 0x16 */ s8 question_count; +/* 0x17 */ s8 fortune_count; +/* 0x18 */ s8 bowser_count; +/* 0x19 */ s8 battle_count; +/* 0x1A */ s8 mushroom_count; +/* 0x1B */ s8 warp_count; /* 0x1C */ s16 coins; /* 0x1E */ s16 coins_mg; /* 0x20 */ s16 coins_total; diff --git a/src/REL/w10Dll/scene.c b/src/REL/w10Dll/scene.c index b400f41e..43b09f0a 100644 --- a/src/REL/w10Dll/scene.c +++ b/src/REL/w10Dll/scene.c @@ -210,7 +210,7 @@ void fn_1_13A4(void) { BoardCameraMotionStartEx(lbl_1_bss_0->unk8, &sp8, NULL, 3200.0f, -1.0f, 30); BoardCameraMotionWait(); fn_1_BA0(0x2E0032); - BoardCameraTargetModelSet(fn_80083F84()); + BoardCameraTargetModelSet(BoardStarHostMdlGet()); BoardCameraMotionWait(); fn_1_BA0(0x2E0033); fn_1_BA0(0x2E0034); diff --git a/src/game/board/space.c b/src/game/board/space.c index 0943cb03..0ce123e6 100644 --- a/src/game/board/space.c +++ b/src/game/board/space.c @@ -4,7 +4,7 @@ #include "math.h" -extern s16 fn_80083F84(void); +extern s16 BoardStarHostMdlGet(void); extern void BoardModelPosSetV(s16 model, Vec *pos); typedef s32 (*BoardSpaceEventFunc)(void); @@ -293,13 +293,13 @@ s32 BoardSpaceLinkTransformGet(s32 flag, Vec *pos, Vec *rot, Vec *scale) void BoardSpaceStarSet(s32 space) { - s16 space_platid; + s16 host_space; Vec pos; BoardSpace *space_plat; BoardSpaceTypeSet(0, space, 8); - space_platid = BoardSpaceLinkFlagSearch(0, space, 0x04000000); - BoardSpacePosGet(0, space_platid, &pos); - BoardModelPosSetV(fn_80083F84(), &pos); + host_space = BoardSpaceLinkFlagSearch(0, space, 0x04000000); + BoardSpacePosGet(0, host_space, &pos); + BoardModelPosSetV(BoardStarHostMdlGet(), &pos); } static inline s16 BoardStarMdlGet(void) @@ -473,8 +473,7 @@ void BoardSpaceStarMove(void) star_total = 99; GWSystem.star_total = star_total; } else { - star_total = GWSystem.star_total; - GWSystem.star_total = (u8)(1+star_total); + star_total = GWSystem.star_total++; } } star_next = BoardSpaceStarGetNext(); @@ -508,4 +507,94 @@ s32 BoardSpaceStarCheck(s32 index) } end: return ret; +} + +void BoardSpaceLandExec(s32 player, s32 space) +{ + BoardSpace *space_ptr = BoardSpaceGet(0, space); + switch(space_ptr->type) { + case 1: + GWPlayer[player].blue_count++; + if(GWPlayer[player].blue_count > 99) { + GWPlayer[player].blue_count = 99; + } + BoardLandBlueExec(player, space); + break; + + case 2: + GWPlayer[player].red_count++; + if(GWPlayer[player].red_count > 99) { + GWPlayer[player].red_count = 99; + } + BoardLandRedExec(player, space); + break; + + case 3: + GWPlayer[player].bowser_count++; + if(GWPlayer[player].bowser_count > 99) { + GWPlayer[player].bowser_count = 99; + } + BoardBowserExec(player, space); + break; + + case 4: + GWPlayer[player].mushroom_count++; + if(GWPlayer[player].mushroom_count > 99) { + GWPlayer[player].mushroom_count = 99; + } + BoardMushroomExec(player, space); + break; + + case 5: + GWPlayer[player].battle_count++; + if(GWPlayer[player].battle_count > 99) { + GWPlayer[player].battle_count = 99; + } + BoardBattleExec(player, space); + break; + + case 6: + GWPlayer[player].question_count++; + if(GWPlayer[player].question_count > 99) { + GWPlayer[player].question_count = 99; + } + if(_CheckFlag(FLAG_ID_MAKE(1, 11))) { + HuAudFXPlay(842); + BoardCameraViewSet(2); + BoardPlayerAnimBlendSet(player, 0, 15); + while(!BoardPlayerAnimBlendCheck(player)) { + HuPrcVSleep(); + } + BoardCameraMotionWait(); + BoardTutorialHookExec(16, 0); + } else { + if(landEventFunc) { + HuAudFXPlay(842); + omVibrate(player, 12, 4, 2); + landEventFunc(); + } + } + GWPlayer[player].color = 3; + break; + + case 7: + GWPlayer[player].fortune_count++; + if(GWPlayer[player].fortune_count > 99) { + GWPlayer[player].fortune_count = 99; + } + BoardFortuneExec(player, space); + break; + + case 9: + GWPlayer[player].warp_count++; + if(GWPlayer[player].warp_count > 99) { + GWPlayer[player].warp_count = 99; + } + BoardWarpExec(player, space); + break; + + case 8: + BoardStarExec(player, space); + break; + } } \ No newline at end of file From 3c8cc0d46c9d52d10d87641de2759ed8496f8fe4 Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Sun, 7 Jan 2024 11:33:50 -0600 Subject: [PATCH 7/8] Introduce space.h header --- include/game/board/basic_space.h | 3 -- include/game/board/space.h | 52 ++++++++++++++++++++++++++++++++ src/game/board/basic_space.c | 1 + src/game/board/space.c | 19 +++--------- 4 files changed, 57 insertions(+), 18 deletions(-) create mode 100644 include/game/board/space.h diff --git a/include/game/board/basic_space.h b/include/game/board/basic_space.h index 4b9eb529..38924130 100644 --- a/include/game/board/basic_space.h +++ b/include/game/board/basic_space.h @@ -2,9 +2,6 @@ #define _BOARD_BASIC_SPACE_H #include "dolphin.h" -#include "game/process.h" - -extern Process *boardObjMan; void BoardEventLandBlue(s32, s16); void BoardEventLandRed(s32, s16); diff --git a/include/game/board/space.h b/include/game/board/space.h new file mode 100644 index 00000000..911507de --- /dev/null +++ b/include/game/board/space.h @@ -0,0 +1,52 @@ +#ifndef _BOARD_SPACE_H +#define _BOARD_SPACE_H + +#include "dolphin.h" + +#define BOARD_SPACE_LINKMAX 4 + +typedef s32 (*BoardSpaceEventFunc)(void); + +typedef struct board_space { + Vec pos; + u32 flag; + Vec scale; + Vec rot; + u16 type; + u16 link_cnt; + u16 link[BOARD_SPACE_LINKMAX+1]; +} BoardSpace; + +void BoardSpaceWalkEventFuncSet(BoardSpaceEventFunc func); +void BoardSpaceWalkMiniEventFuncSet(BoardSpaceEventFunc func); +void BoardSpaceLandEventFuncSet(BoardSpaceEventFunc func); +s32 BoardSpaceWalkEventExec(void); +s32 BoardSpaceWalkMiniEventExec(void); +s16 BoardSpaceCountGet(s32 layer); +s16 BoardSpaceCountGet(s32 layer); +BoardSpace *BoardSpaceGet(s32 layer, s32 index); +void BoardSpaceAttrSet(s32 layer, u32 attr); +void BoardSpaceAttrReset(s32 layer, u32 attr); +u32 BoardSpaceFlagGet(s32 layer, s32 index); +s32 BoardSpaceTypeGet(s32 layer, s32 index); +void BoardSpaceTypeSet(s32 layer, s32 index, s32 type); +s32 BoardSpacePosGet(s32 layer, s32 index, Vec *pos); +void BoardSpaceCornerPosGet(s32 index, s32 corner, Vec *pos); +s32 BoardSpaceFlagSearch(s32 layer, u32 flag); +s32 BoardSpaceFlagPosGet(s32 layer, u32 flag, Vec *pos); +s32 BoardSpaceLinkFlagSearch(s32 layer, s32 index, u32 flag); +s32 BoardSpaceLinkTypeListGet(s32 layer, s32 index, s32 type, s16 *list); +s32 BoardSpaceLinkTargetListGet(s32 layer, s32 target, s16 *list); +s32 BoardSpaceLinkTypeSearch(s32 layer, s32 target, u16 type); +s32 BoardSpaceLinkTransformGet(s32 flag, Vec *pos, Vec *rot, Vec *scale); +void BoardSpaceStarSet(s32 space); +void BoardSpaceStarSetIndex(s32 index); +s32 BoardSpaceStarGetNext(void); +s32 BoardSpaceStarGetRandom(s32 excl_pos); +void BoardSpaceStarMove(void); +s32 BoardSpaceStarGet(s32 index); +s32 BoardSpaceStarGetCurr(void); +s32 BoardSpaceStarCheck(s32 index); +void BoardSpaceLandExec(s32 player, s32 space); + +#endif diff --git a/src/game/board/basic_space.c b/src/game/board/basic_space.c index ff565d27..3fbb9bfb 100644 --- a/src/game/board/basic_space.c +++ b/src/game/board/basic_space.c @@ -1,4 +1,5 @@ #include "game/board/basic_space.h" +#include "game/board/main.h" #include "game/data.h" #include "game/flag.h" #include "game/object.h" diff --git a/src/game/board/space.c b/src/game/board/space.c index 0ce123e6..fb32b91d 100644 --- a/src/game/board/space.c +++ b/src/game/board/space.c @@ -1,23 +1,13 @@ #include "game/gamework_data.h" #include "game/flag.h" #include "game/board/main.h" +#include "game/board/space.h" #include "math.h" extern s16 BoardStarHostMdlGet(void); extern void BoardModelPosSetV(s16 model, Vec *pos); -typedef s32 (*BoardSpaceEventFunc)(void); - -typedef struct board_space { - Vec pos; - u32 flag; - Vec scale; - Vec rot; - u16 type; - u16 link_cnt; - u16 link[5]; -} BoardSpace; static GXTexObj spaceHiliteTex; static GXTexObj spaceTex; @@ -112,7 +102,7 @@ u32 BoardSpaceFlagGet(s32 layer, s32 index) } } -int BoardSpaceTypeGet(s32 layer, s32 index) +s32 BoardSpaceTypeGet(s32 layer, s32 index) { if(index <= 0 || index > spaceCnt[layer]) { return 0; @@ -121,7 +111,7 @@ int BoardSpaceTypeGet(s32 layer, s32 index) } } -void BoardSpaceTypeSet(s32 layer, s32 index, int type) +void BoardSpaceTypeSet(s32 layer, s32 index, s32 type) { if(index <= 0 || index > spaceCnt[layer]) { return; @@ -213,7 +203,7 @@ s32 BoardSpaceLinkFlagSearch(s32 layer, s32 index, u32 flag) return -1; } -s32 BoardSpaceLinkTypeListGet(s32 layer, s32 index, int type, s16 *list) +s32 BoardSpaceLinkTypeListGet(s32 layer, s32 index, s32 type, s16 *list) { s32 count; BoardSpace *space = BoardSpaceGet(layer, index); @@ -457,7 +447,6 @@ s32 BoardSpaceStarGetRandom(s32 excl_pos) return new_pos; } -//Fix GWSystem.star_total truncation and double GWSystem load void BoardSpaceStarMove(void) { u8 star_total; From fd7e3e68b605ee5cf7597a40da41e3921f85015e Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Sun, 7 Jan 2024 11:35:12 -0600 Subject: [PATCH 8/8] Use BOARD_SPACE_LINKMAX --- src/game/board/space.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/board/space.c b/src/game/board/space.c index fb32b91d..ff4a96a2 100644 --- a/src/game/board/space.c +++ b/src/game/board/space.c @@ -213,7 +213,7 @@ s32 BoardSpaceLinkTypeListGet(s32 layer, s32 index, s32 type, s16 *list) } for(count=i=0; ilink_cnt; i++) { BoardSpace *link_space = BoardSpaceGet(layer, space->link[i]); - if(link_space->type == type && count < 4) { + if(link_space->type == type && count < BOARD_SPACE_LINKMAX) { list[count] = link_space-&spaceData[layer][0]+1; count++; } @@ -226,11 +226,11 @@ s32 BoardSpaceLinkTargetListGet(s32 layer, s32 target, s16 *list) s32 i, j; s32 count; BoardSpace *space; - memset(list, 0, 4*sizeof(s16)); + memset(list, 0, BOARD_SPACE_LINKMAX*sizeof(s16)); space = &spaceData[layer][0]; for(count=i=0; ilink_cnt; j++) { - if(space->link[j] == target && count < 4) { + if(space->link[j] == target && count < BOARD_SPACE_LINKMAX) { list[count++] = space-&spaceData[layer][0]+1; } }