diff --git a/configure.py b/configure.py index 4b9440b4..8a124957 100644 --- a/configure.py +++ b/configure.py @@ -388,7 +388,7 @@ config.libs = [ Object(NonMatching, "game/board/last5.c"), Object(NonMatching, "game/board/pause.c"), Object(Matching, "game/board/com_path.c"), - Object(NonMatching, "game/board/tutorial.c"), + Object(Matching, "game/board/tutorial.c"), Object(NonMatching, "game/kerent.c"), ], }, diff --git a/include/REL/w10Dll.h b/include/REL/w10Dll.h index 967ae094..c334d7ac 100644 --- a/include/REL/w10Dll.h +++ b/include/REL/w10Dll.h @@ -45,7 +45,7 @@ typedef struct w10DllUnk04 { extern s16 lbl_1_bss_20; extern s16 lbl_1_bss_22[]; extern s16 lbl_1_bss_20; -extern s32 boardTutorialData; +extern s32 boardTutorialData[4]; void fn_1_C10(s16); void fn_1_1FB0(void); diff --git a/include/board_unsplit.h b/include/board_unsplit.h index 131f4462..9bbef96f 100644 --- a/include/board_unsplit.h +++ b/include/board_unsplit.h @@ -23,9 +23,9 @@ void BoardStatusShowSetAll(s32); void BoardMGSetupTutorialExec(void); void BoardBooHouseTutorialExec(void); void BoardStatusItemSet(s32); -void BoardTutorialItemSet(s32); +void BoardTutorialItemSet(s8); void BoardCharWheelSetTarget(s32); -void BoardTutorialDirInputSet(s32, s32, s32); +void BoardTutorialDirInputSet(s8, s8, s16); void BoardSpaceStarSetIndex(s32); s32 BoardModelRotYSet(s16, f32); f32 BoardModelRotYGet(s16); @@ -54,7 +54,7 @@ void BoardLotteryHostSet(s16); void BoardStarHostSet(s16); void BoardBooHouseHostSet(s16); void BoardTutorialHookSet(void*); -void BoardTutorialBlockSetPos(s32, s32); +void BoardTutorialBlockSetPos(s32, s8); s32 BoardCameraRotGet(Vec*); s32 BoardModelScaleSet(s16, f32, f32, f32); s32 BoardIsKill(void); diff --git a/include/game/board/com.h b/include/game/board/com.h index 1d6a605b..a75d35ab 100755 --- a/include/game/board/com.h +++ b/include/game/board/com.h @@ -10,6 +10,7 @@ void BoardComKeySetDown(void); s8 BoardComPreferItemGet(s32 arg0, s8 *arg1, s8 arg2); s8 BoardComPreferItemCheck(s32 arg0, s8 arg1, s8 arg2, s8 arg3); s32 BoardComItemWeightGet(s32 arg0, s32 arg1); +s32 BoardComTutorialItemGet(s32 arg0); s32 BoardComUseItemSet(s32 arg0, s32 arg1); BOOL BoardComUseItemCheck(s32 arg0); s32 BoardComJunctionInputGet(s32 arg0, Vec *arg1, s32 arg2, float *arg3); diff --git a/include/game/board/tutorial.h b/include/game/board/tutorial.h index 2d8368f1..3b63c2ae 100755 --- a/include/game/board/tutorial.h +++ b/include/game/board/tutorial.h @@ -3,6 +3,27 @@ #include "dolphin/types.h" +void BoardTutorialInit(void); +void BoardTutorialKill(void); +void BoardTutorialHookSet(void *arg0); +void BoardTutorialHookExec(s16 arg0, s32 arg1); +void BoardTutorialPlayerInit(void); +void BoardTutorialWorkSave(void); +void BoardTutorialWorkRestore(void); +void BoardTutorialDirInputSet(s8 arg0, s8 arg1, s16 arg2); +void BoardTutorialBlockSetPos(s32 arg0, s8 arg1); +void BoardTutorialItemSet(s8 arg0); +void BoardTutorialHostSet(s16 arg0); +void BoardTutorialHostHide(s8 arg0); + +extern s32 boardTutorialData[4]; +extern s8 boardTutorialDirInputX; +extern s8 boardTutorialDirInputY; +extern s16 boardTutorialDirInputTime; +extern s32 boardTutorialBlockPos; +extern s8 boardTutorialBlockItem; +extern s8 boardTutorialBlockF; extern s8 boardTutorialUseItem; +extern s8 boardTutorialF; #endif diff --git a/src/REL/w10Dll/tutorial.c b/src/REL/w10Dll/tutorial.c index 99a728ec..a9886915 100644 --- a/src/REL/w10Dll/tutorial.c +++ b/src/REL/w10Dll/tutorial.c @@ -108,7 +108,7 @@ void fn_1_1834(void) { void fn_1_18BC(void) { fn_1_BA0(0x2E0028); fn_1_BA0(0x2E0029); - boardTutorialData = 0; + boardTutorialData[0] = 0; BoardStatusItemSet(0); } diff --git a/src/game/board/basic_space.c b/src/game/board/basic_space.c index 23dcceda..894f5e31 100644 --- a/src/game/board/basic_space.c +++ b/src/game/board/basic_space.c @@ -1,6 +1,7 @@ #include "game/board/basic_space.h" #include "game/board/main.h" #include "game/board/player.h" +#include "game/board/tutorial.h" #include "game/data.h" #include "game/flag.h" #include "game/object.h" @@ -34,7 +35,6 @@ static void CoinChgSeparate(omObjData*, coinChg*); static void CoinChgShow(omObjData*, coinChg*); static void CoinChgDisappear(omObjData*, coinChg*); -extern void BoardTutorialHookExec(s16, s32); extern void BoardCameraViewSet(s32); extern void BoardPlayerPosGet(s32, Vec*); extern void BoardModelPosGet(s16, Vec*); diff --git a/src/game/board/main.c b/src/game/board/main.c index 93bf8b68..4caa8d88 100644 --- a/src/game/board/main.c +++ b/src/game/board/main.c @@ -10,6 +10,7 @@ #include "game/hsfdraw.h" #include "game/board/main.h" #include "game/board/player.h" +#include "game/board/tutorial.h" #include "game/pad.h" #include "game/msm.h" @@ -61,8 +62,6 @@ extern s32 BoardSpacePosGet(s32 layer, s32 space, Vec *pos); extern void BoardMGSetupPlayClear(void); extern void BoardStartExec(void); -extern s8 boardTutorialF; - static void InitBoardFunc(omObjData *object); static void ExecBoardFunc(omObjData *object); static void KillBoardFunc(omObjData *object); diff --git a/src/game/board/player.c b/src/game/board/player.c index 1b97cccc..5a2b70af 100644 --- a/src/game/board/player.c +++ b/src/game/board/player.c @@ -2,6 +2,7 @@ #include "game/objsub.h" #include "game/board/com.h" #include "game/board/roll.h" +#include "game/board/tutorial.h" #include "game/board/view.h" //// #include "game/board/ui.h" @@ -32,8 +33,6 @@ extern f32 BoardModelMotionMaxTimeGet(s16); extern void BoardModelMotionTimeRangeSet(s16, s32, s32); extern void BoardModelAttrSet(s16, s32); extern void BoardModelAttrReset(s16, s32); -//// #include "game/board/tutorial.h" -extern BoardTutorialHookExec(s16, s32); //// #include "game/board/com.h" //// #include "game/board/overhead.h" //// #include "game/chrman.h" @@ -44,9 +43,6 @@ extern s8 HuPadStkX[4]; extern s8 HuPadStkY[4]; extern u16 HuPadBtnDown[4]; extern u8 HuPadDStk[4]; -extern s16 boardTutorialDirInputTime; -extern s8 boardTutorialDirInputX; -extern s8 boardTutorialDirInputY; //// #include "game/board/view.h" //// diff --git a/src/game/board/roll.c b/src/game/board/roll.c index dfb26bf1..56acfdee 100755 --- a/src/game/board/roll.c +++ b/src/game/board/roll.c @@ -40,7 +40,6 @@ typedef struct { s32 BoardRollResizeCheck(void); s32 BoardPauseActiveCheck(void); -void BoardTutorialHookExec(s16, s32); static void RollMain(void); static void DiceCreate(s32 arg0); diff --git a/src/game/board/space.c b/src/game/board/space.c index 3bccfbd6..4ee4583a 100644 --- a/src/game/board/space.c +++ b/src/game/board/space.c @@ -3,6 +3,7 @@ #include "game/board/main.h" #include "game/board/player.h" #include "game/board/space.h" +#include "game/board/tutorial.h" #include "game/hsfman.h" #include "game/data.h" #include "game/sprite.h" @@ -51,9 +52,6 @@ static s16 starPlatMdl = -1; static s32 ExecPipeSpace(s32 player, s32 space); -extern s8 boardTutorialBlockF; -extern s32 boardTutorialBlockPos; - void BoardSpaceWalkEventFuncSet(BoardSpaceEventFunc func) { diff --git a/src/game/board/tutorial.c b/src/game/board/tutorial.c new file mode 100755 index 00000000..5bdca944 --- /dev/null +++ b/src/game/board/tutorial.c @@ -0,0 +1,138 @@ +#include "game/board/tutorial.h" +#include "game/flag.h" +#include "game/gamework_data.h" +#include "game/process.h" +#include "game/board/main.h" +#include "game/board/model.h" + +s32 boardTutorialData[4]; // maybe a single s32 + padding? +static void (*tutorialHook)(s16, s32); +s8 boardTutorialDirInputX; +s8 boardTutorialDirInputY; +s16 boardTutorialDirInputTime; +s32 boardTutorialBlockPos; +s8 boardTutorialBlockItem; +s8 boardTutorialBlockF; +s8 boardTutorialUseItem; +static s16 hostMdl; +s8 boardTutorialF; +static Process *tutorialProcess; +static void *playerCfgCopy; +static void *playerCopy; +static void *systemCopy; +static void *gameStatCopy; + +static void TutorialProcFunc(void) { + while (1) { + if (_CheckFlag(0x10010)) { + BoardTutorialHookExec(0x1E, 0); + } + HuPrcVSleep(); + } +} + +void BoardTutorialInit(void) { + boardTutorialDirInputTime = -1; + boardTutorialBlockF = 0; + boardTutorialUseItem = -1; + tutorialHook = NULL; + tutorialProcess = NULL; + boardTutorialF = 0; + if (_CheckFlag(0x1000B)) { + tutorialProcess = HuPrcChildCreate(TutorialProcFunc, 0x2002, 0x2000, 0, boardMainProc); + } +} + +void BoardTutorialKill(void) { + if (_CheckFlag(0x1000B)) { + if (tutorialProcess) { + HuPrcKill(tutorialProcess); + } + boardTutorialF = 0; + } +} + +void BoardTutorialHookSet(void *arg0) { + tutorialHook = arg0; +} + +void BoardTutorialHookExec(s16 arg0, s32 arg1) { + if (tutorialHook) { + tutorialHook(arg0, arg1); + } +} + +void BoardTutorialPlayerInit(void) { + s32 i; + + for (i = 0; i < 4; i++) { + GWPlayer[i].com = 1; + GWPlayerCfg[i].iscom = 1; + } + GWSystem.board = 6; +} + +void BoardTutorialWorkSave(void) { + OSReport("-O-O-O-O-O-O-O Tutorial Save Work\n"); + if (gameStatCopy) { + HuMemDirectFree(gameStatCopy); + } + if (systemCopy) { + HuMemDirectFree(systemCopy); + } + if (playerCopy) { + HuMemDirectFree(playerCopy); + } + if (playerCfgCopy) { + HuMemDirectFree(playerCfgCopy); + } + gameStatCopy = HuMemDirectMalloc(HEAP_SYSTEM, sizeof(GWGameStat)); + systemCopy = HuMemDirectMalloc(HEAP_SYSTEM, sizeof(GWSystem)); + playerCopy = HuMemDirectMalloc(HEAP_SYSTEM, sizeof(GWPlayer)); + playerCfgCopy = HuMemDirectMalloc(HEAP_SYSTEM, sizeof(GWPlayerCfg)); + memcpy(gameStatCopy, &GWGameStat, sizeof(GWGameStat)); + memcpy(systemCopy, &GWSystem, sizeof(GWSystem)); + memcpy(playerCopy, GWPlayer, sizeof(GWPlayer)); + memcpy(playerCfgCopy, GWPlayerCfg, sizeof(GWPlayerCfg)); +} + +void BoardTutorialWorkRestore(void) { + OSReport("-O-O-O-O-O-O-O Tutorial Load Work\n"); + memcpy(&GWGameStat, gameStatCopy, sizeof(GWGameStat)); + memcpy(&GWSystem, systemCopy, sizeof(GWSystem)); + memcpy(GWPlayer, playerCopy, sizeof(GWPlayer)); + memcpy(GWPlayerCfg, playerCfgCopy, sizeof(GWPlayerCfg)); + HuMemDirectFree(gameStatCopy); + HuMemDirectFree(systemCopy); + HuMemDirectFree(playerCopy); + HuMemDirectFree(playerCfgCopy); + gameStatCopy = NULL; + systemCopy = NULL; + playerCopy = NULL; + playerCfgCopy = NULL; +} + +void BoardTutorialDirInputSet(s8 arg0, s8 arg1, s16 arg2) { + boardTutorialDirInputX = arg0; + boardTutorialDirInputY = arg1; + boardTutorialDirInputTime = arg2; +} + +void BoardTutorialBlockSetPos(s32 arg0, s8 arg1) { + boardTutorialBlockF = 1; + boardTutorialBlockPos = arg0; + boardTutorialBlockItem = arg1; + BoardSpaceBlockPosSet(); +} + +void BoardTutorialItemSet(s8 arg0) { + boardTutorialUseItem = arg0; +} + +void BoardTutorialHostSet(s16 arg0) { + hostMdl = arg0; +} + +void BoardTutorialHostHide(s8 arg0) { + BoardModelVisibilitySet(hostMdl, arg0); +} diff --git a/src/game/board/ui.c b/src/game/board/ui.c index fa0e6c56..f2e3e1bc 100755 --- a/src/game/board/ui.c +++ b/src/game/board/ui.c @@ -9,10 +9,12 @@ #include "game/pad.h" #include "game/process.h" #include "game/window.h" +#include "game/board/com.h" #include "game/board/item.h" #include "game/board/main.h" #include "game/board/model.h" #include "game/board/player.h" +#include "game/board/tutorial.h" #include "board_unsplit.h" #include "math.h" @@ -93,12 +95,9 @@ typedef struct { } UnkUiWork04; void BoardPlayerSparkSet(s32); -void BoardTutorialHookExec(s16, s32); void BoardBowserSuitMotionCreate(void); s16 BoardBowserSuitPlayerModelGet(void); void CharModelLayerSetAll(s32); -s32 BoardComTutorialItemGet(s32); -void BoardTutorialHostHide(s32); static void KillAllBoardStatus(void); static void CreateBoardStatusSprite(s32 arg0, UnkUiStatusStruct *arg1); diff --git a/src/game/board/warp.c b/src/game/board/warp.c index 52d00063..e623e207 100644 --- a/src/game/board/warp.c +++ b/src/game/board/warp.c @@ -1,8 +1,10 @@ #include "game/board/warp.h" #include "game/board/main.h" #include "game/board/player.h" +#include "game/board/tutorial.h" #include "game/wipe.h" #include "game/gamework_data.h" +#include "game/hsfdraw.h" #include "game/hsfex.h" #include "game/objsub.h" #include "board_unsplit.h" @@ -22,13 +24,8 @@ extern s32 BoardCharWheelResultGet(void); extern f32 BoardModelMotionTimeGet(s16); extern void BoardModelHookReset(s16); extern s32 BoardModelHookSet(s16, char*, s16); -extern void BoardPlayerPosSet(s32, f32, f32, f32); -extern void BoardPlayerRotYSet(s32, f32); -extern void Hu3DModelObjPosGet(s16, char*, Vec*); extern s32 BoardModelMotionEndCheck(s16); -extern s32 boardTutorialData[4]; - static Vec warpPos; static s8 warpState; diff --git a/src/game/wipe.c b/src/game/wipe.c index 451e6fb5..7d4cbea0 100644 --- a/src/game/wipe.c +++ b/src/game/wipe.c @@ -2,8 +2,7 @@ #include "game/wipe.h" #include "game/memory.h" #include "game/flag.h" - -extern s8 boardTutorialF; +#include "game/board/tutorial.h" s16 HuSysVWaitGet(s16 old);