diff --git a/config/GMPE01_00/symbols.txt b/config/GMPE01_00/symbols.txt index 2cae51f6..1962b6c5 100644 --- a/config/GMPE01_00/symbols.txt +++ b/config/GMPE01_00/symbols.txt @@ -1290,7 +1290,7 @@ KillBoardModel = .text:0x8006F944; // type:function size:0x178 scope:local CreateBoardModel = .text:0x8006FABC; // type:function size:0x194 scope:local CreateBoardModelMotion = .text:0x8006FC50; // type:function size:0x12C scope:local BoardWinInit = .text:0x8006FD7C; // type:function size:0x24 -lbl_8006FDA0 = .text:0x8006FDA0; // type:function size:0x34 +fn_8006FDA0 = .text:0x8006FDA0; // type:function size:0x34 BoardWinKillAll = .text:0x8006FDD4; // type:function size:0x24 BoardWinDestroy = .text:0x8006FDF8; // type:function size:0x6C BoardWinProc = .text:0x8006FE64; // type:function size:0x514 @@ -6326,7 +6326,7 @@ winWait = .sbss:0x801D3F86; // type:object size:0x1 scope:local data:byte winPause = .sbss:0x801D3F87; // type:object size:0x1 scope:local data:byte disablePlayer = .sbss:0x801D3F88; // type:object size:0x1 scope:local data:byte winPosIdx = .sbss:0x801D3F89; // type:object size:0x1 scope:local data:byte -winFrame = .sbss:0x801D3F8A; // type:object size:0x1 scope:local data:byte +winPortrait = .sbss:0x801D3F8A; // type:object size:0x1 scope:local data:byte autoPickF = .sbss:0x801D3F8B; // type:object size:0x1 scope:local data:byte winChoice = .sbss:0x801D3F8C; // type:object size:0x1 scope:local data:byte lbl_801D3F90 = .sbss:0x801D3F90; // type:object size:0x8 diff --git a/configure.py b/configure.py index 7099d2cd..26ffbe76 100644 --- a/configure.py +++ b/configure.py @@ -362,7 +362,7 @@ config.libs = [ Object(NonMatching, "game/board/main.c"), Object(NonMatching, "game/board/player.c"), Object(NonMatching, "game/board/model.c"), - Object(NonMatching, "game/board/window.c"), + Object(Matching, "game/board/window.c"), Object(NonMatching, "game/board/speaker.c"), Object(NonMatching, "game/board/com.c"), Object(NonMatching, "game/board/overhead.c"), diff --git a/include/functions.h b/include/functions.h index 2e9beefc..77a17cad 100644 --- a/include/functions.h +++ b/include/functions.h @@ -43,10 +43,6 @@ void MGSeqKillAll(void); void MGSeqPracticeStart(void); void fn_8004D6F4(s16 arg); -void BoardWinCreate(s16, s32, s32); -void BoardWinKill(void); -void BoardWinWait(void); - s32 rand8(void); void BoardCameraTargetSetModel(s16 model); diff --git a/include/game/board/basic_space.h b/include/game/board/basic_space.h index cc7b5a9f..b89f97cb 100644 --- a/include/game/board/basic_space.h +++ b/include/game/board/basic_space.h @@ -1,3 +1,6 @@ +#ifndef _BOARD_BASIC_SPACE_H +#define _BOARD_BASIC_SPACE_H + #include "common.h" #include "math.h" #include "game/process.h" @@ -6,9 +9,10 @@ extern Process *boardObjMan; - void BoardEventLandBlue(s32, s16); void BoardEventLandRed(s32, s16); s8 BoardCoinChgCreate(Vec*, s8); s32 BoardCoinChgExist(s32); -void BoardCoinChgHide(s32); \ No newline at end of file +void BoardCoinChgHide(s32); + +#endif diff --git a/include/game/board/window.h b/include/game/board/window.h new file mode 100644 index 00000000..2d18f4a8 --- /dev/null +++ b/include/game/board/window.h @@ -0,0 +1,35 @@ +#ifndef _BOARD_WINDOW_H +#define _BOARD_WINDOW_H + +#include "common.h" +#include "game/window.h" +#include "game/process.h" +#include "game/gamework.h" + +void BoardWinInit(void); +void fn_8006FDA0(f32*); +void BoardWinKillAll(void); +void BoardWinDestroy(void); +void BoardWinProc(void); +int BoardWinChoiceGet(void); +void BoardWinCreateChoice(s32, s32, s32, s32); +void BoardWinCreate(s32, s32, s32); +void BoardWinInsertMesSet(s32, s32); +void BoardWinWait(void); +void BoardWinKill(void); +void BoardWinSetAttr(s32); +void BoardWinResetAttr(s32); +void BoardWinChoiceDisable(s32); +void BoardWinKeyWait(void); +int BoardWinSpeedGet(void); +void BoardWinSpeedSet(s32); +s16 BoardWinChoiceNowGet(void); +void BoardWinPriSet(s16); +s16 BoardWinChoiceNowGet2(void); +s32 BoardWinPortraitGet(void); +s32 BoardWinPortraitGetStar(void); +void BoardWinPlayerSet(s32); +void BoardWinStartComKeySet(void); +void BoardWinComKeyFuncSet(void (*)); + +#endif \ No newline at end of file diff --git a/include/game/window.h b/include/game/window.h index 1fbff332..bf0f81d1 100644 --- a/include/game/window.h +++ b/include/game/window.h @@ -126,7 +126,7 @@ void HuWinMesMaxSizeGet(s16 mess_num, float *size, ...); void HuWinInsertMesSizeGet(s32 mess, s16 index); void HuWinMesSizeCancelCRSet(s32 cancel_cr); void HuWinMesMaxSizeBetGet(float *size, u32 start, u32 end); -s32 HuWinKeyWaitNumGet(u32 mess); +s16 HuWinKeyWaitNumGet(u32 mess); void HuWinPushKeySet(s16 window, s16 push_key); void HuWinDisablePlayerSet(s16 window, u8 player); void HuWinDisablePlayerReset(s16 window, u8 player); diff --git a/src/REL/w10Dll/host.c b/src/REL/w10Dll/host.c index 496640d6..68edcfbb 100644 --- a/src/REL/w10Dll/host.c +++ b/src/REL/w10Dll/host.c @@ -1,5 +1,6 @@ #include "REL/w10Dll.h" #include "game/data.h" +#include "game/board/window.h" s32 lbl_1_data_78[2] = { MAKE_DATA_NUM(DATADIR_W10, 16), @@ -21,7 +22,7 @@ void fn_1_AEC(void) { } void fn_1_BA0(s32 arg0) { - s32 var_r31; + s16 var_r31; switch (lbl_1_bss_1C) { case 0: diff --git a/src/game/board/window.c b/src/game/board/window.c new file mode 100644 index 00000000..90c7479b --- /dev/null +++ b/src/game/board/window.c @@ -0,0 +1,428 @@ +#include "game/board/window.h" + +extern s32 BoardPlayerIsAllCom(void); +extern Process* boardMainProc; + +static s8 winChoice; +static s8 autoPickF; +static s8 winPortrait; +static s8 winPosIdx; +static u8 disablePlayer; +static s8 winPause; +static s8 winWait; +static s16 winPrio; +static s16 messSpeed; +static s16 defaultChoice; +static s32 winMess; +static s32 winAttr; +f32 lbl_801D3F70[2]; +static void (*comKeyFunc)(); +static Process* winProc; +static s32 choiceDisableTbl[0x10]; +static u32 winInsertMesTbl[8]; + +static s32 PortraitTbl[] = { + 0, 4, 2, 3, + 7, 6, 0, 12, + 12, +}; +static s32 StarPortraitTbl[] = { + 13, 16, 14, 15, + 18, 6, 13, 12, + 12 +}; + +static s16 windowID = -1; +const s8 lbl_801D5318[4] = {0, 1, 4, 0}; + +void BoardWinInit(void) { + HuWinInit(1); +} + +void fn_8006FDA0(f32* arg0) { + if (arg0 != 0) { + lbl_801D3F70[0] = arg0[0]; + lbl_801D3F70[1] = arg0[1]; + return; + } + lbl_801D3F70[0] = lbl_801D3F70[1] = 0.0f; +} + +void BoardWinKillAll(void) { + BoardWinKill(); + HuWinAllKill(); +} + +void BoardWinDestroy(void) { + if (windowID >= 0) { + if (winPortrait == -1) { + HuWinExCleanup(windowID); + } else { + HuWinExCleanup(windowID); + winPortrait = -1; + } + windowID = -1; + } + winMess = 0; + winProc = 0; +} + +void BoardWinProc(void) { + f32 sp10[2]; + f32 sp8[2]; + s32 var_r31; + f32* temp_r29; + f32* temp_r30; + WindowData *var_r28 = NULL; + + f32 var_50[7][2] = { + {384.0f, 64.0f}, {432.0f, 192.0f}, + {504.0f, 96.0f}, {432.0f, 128.0f}, + {288.0f, 192.0f}, {432.0f, 96.0f}, + {432.0f, 96.0f}, + }; + f32 var_18[7][2] = { + {96.0f, 328.0f}, {72.0f, 128.0f}, + {36.0f, 344.0f}, {128.0f, 312.0f}, + {144.0f, 144.0f}, {128.0f, 264.0f}, + {128.0f, 75.0f}, + }; + + if (windowID < 0) { + temp_r30 = var_50[winPosIdx]; + temp_r29 = var_18[winPosIdx]; + HuWinMesMaxSizeGet(1, sp10, winMess); + if (sp10[0] <= temp_r30[0]) { + sp10[0] = temp_r30[0]; + sp8[0] = temp_r29[0]; + } else { + sp8[0] = -10000.0f; + } + if (sp10[1] <= temp_r30[1]) { + sp10[1] = temp_r30[1]; + } + sp8[1] = temp_r29[1]; + if ((winPosIdx == 5) || (winPosIdx == 6)) { + windowID = HuWinExCreateStyled(sp8[0], sp8[1], sp10[0], sp10[1], -1, 1); + HuWinMesPalSet(windowID, 7, 0, 0, 0); + } else if (winPortrait == -1) { + windowID = HuWinExCreate(sp8[0], sp8[1], sp10[0], sp10[1], -1); + } else { + windowID = HuWinExCreate(sp8[0], sp8[1], sp10[0], sp10[1], winPortrait); + } + if (windowID == -1) { + HuPrcEnd(); + } + if (_CheckFlag(0x1000B) != 0) { + HuWinPriSet(windowID, 3); + } + } + if (disablePlayer != 0) { + HuWinDisablePlayerSet(windowID, disablePlayer); + } + if (winPrio != -1) { + HuWinPriSet(windowID, winPrio); + } + if (winPortrait == -1) { + HuWinExAnimIn(windowID); + } else { + HuWinExAnimIn(windowID); + } + HuWinMesSpeedSet(windowID, messSpeed); + HuWinMesSet(windowID, winMess); + + for (var_r31 = 0; var_r31 < 8; var_r31++) { + if (winInsertMesTbl[var_r31] != -1) { + HuWinInsertMesSet(windowID, winInsertMesTbl[var_r31], var_r31); + } + } + HuWinAttrSet(windowID, winAttr); + + for (var_r31 = 0; var_r31 < 0x10; var_r31++) { + if (choiceDisableTbl[var_r31] != 0) { + HuWinChoiceDisable(windowID, var_r31); + } + } + if (autoPickF != 0) { + BoardWinStartComKeySet(); + if (comKeyFunc != 0) { + comKeyFunc(); + } + } else if ((_CheckFlag(0x1000B) != 0) && ((winPosIdx == 5) || (winPosIdx == 6))) { + var_r28 = &winData[windowID]; + var_r28->active_pad = 0xF; + HuWinComKeyWait(-1, -1, -1, -1, 0); + } else { + BoardWinStartComKeySet(); + } + HuWinMesWait(windowID); + if (winWait != 0) { + HuWinKeyWaitEntry(windowID); + HuWinMesWait(windowID); + } + if (winPause != 0) { + HuPrcSleep(-1); + } + if (defaultChoice != -1) { + winChoice = HuWinChoiceGet(windowID, defaultChoice); + } + if (winPortrait != -1) { + HuWinExAnimOut(windowID); + } + HuPrcEnd(); +} + +int BoardWinChoiceGet(void) { + return winChoice; +} + +void BoardWinPause(void) { + winPause = 1; +} + +void BoardWinCreateChoice(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + s32 var_r31; + SystemState* temp_r3; + s32 var_r30; + + + winPosIdx = arg0; + winChoice = 0; + defaultChoice = arg3; + winPortrait = arg2; + winAttr = 0; + autoPickF = 1; + winWait = 0; + comKeyFunc = NULL; + disablePlayer = 0; + winPrio = -1; + winPause = 0; + HuWinComKeyReset(); + + for (var_r31 = 0; var_r31 < 0x10; var_r31++) { + choiceDisableTbl[var_r31] = 0; + } + + for (var_r31 = 0; var_r31 < 8; var_r31++) { + winInsertMesTbl[var_r31] = -1; + } + if (winProc == 0) { + winProc = HuPrcChildCreate(&BoardWinProc, 0x2009, 0x4000, 0, boardMainProc); + HuPrcDestructorSet2(winProc, &BoardWinDestroy); + } + winMess = arg1; + if (GWSystem.mess_speed == 3) { + GWSystem.mess_speed = 1; + } + var_r30 = GWSystem.mess_speed; + BoardWinSpeedSet(var_r30); + BoardWinPlayerSet(GWSystem.player_curr); +} + +void BoardWinCreate(s32 arg0, s32 arg1, s32 arg2) { + s32 var_r30; + s32 var_r31; + void* temp_r3; + + winPosIdx = arg0; + winChoice = 0; + defaultChoice = -1; + winPortrait = arg2; + winAttr = 0; + autoPickF = 1; + winWait = 0; + comKeyFunc = NULL; + disablePlayer = 0; + winPrio = -1; + winPause = 0; + HuWinComKeyReset(); + + for (var_r31 = 0; var_r31 < 0x10; var_r31++) { + choiceDisableTbl[var_r31] = 0; + } + + for (var_r31 = 0; var_r31 < 8; var_r31++) { + winInsertMesTbl[var_r31] = -1; + } + if (winProc == 0) { + winProc = HuPrcChildCreate(&BoardWinProc, 0x2009U, 0x4000U, 0, boardMainProc); + HuPrcDestructorSet2(winProc, &BoardWinDestroy); + } + winMess = arg1; + if (GWSystem.mess_speed == 3) { + GWSystem.mess_speed = 1; + } + var_r30 = GWSystem.mess_speed; + BoardWinSpeedSet(var_r30); + BoardWinPlayerSet(GWSystem.player_curr); + autoPickF = 0; +} + +void BoardWinInsertMesSet(s32 value, s32 index) { + winInsertMesTbl[index] = value; +} + +static inline BOOL BoardWinDone(void) { + if(winProc != NULL) { + return 0; + } else { + return 1; + } +} + +void BoardWinWait(void) { + while(!BoardWinDone()) { + HuPrcVSleep(); + } +} + +void BoardWinKill(void) { + if (winProc != 0) { + HuPrcKill(winProc); + winProc = NULL; + } +} + +void BoardWinSetAttr(s32 arg0) { + winAttr |= arg0; + if (windowID >= 0) { + HuWinAttrSet(windowID, winAttr); + } +} + +void BoardWinResetAttr(s32 arg0) { + winAttr &= ~arg0; + if (windowID >= 0) { + HuWinAttrSet(windowID, winAttr); + } +} + +void BoardWinChoiceDisable(s32 index) { + choiceDisableTbl[index] = 1; +} + +void BoardWinKeyWait(void) { + winWait = 1; +} + +int BoardWinSpeedGet(void) { + s32 temp_r31; + + if (GWSystem.mess_speed == 3) { + GWSystem.mess_speed = 1; + } + temp_r31 = GWSystem.mess_speed; + return lbl_801D5318[temp_r31]; +} + +void BoardWinSpeedSet(s32 arg0) { + messSpeed = lbl_801D5318[arg0]; + if (windowID != -1) { + HuWinMesSpeedSet(windowID, messSpeed); + } +} + +s16 BoardWinChoiceNowGet(void) { + if (windowID == -1) { + return -1; + } + return HuWinChoiceNowGet(windowID); +} + +void BoardWinPriSet(s16 arg0) { + winPrio = arg0; + if (windowID != -1) { + HuWinPriSet(windowID, arg0); + } +} + +s16 BoardWinChoiceNowGet2(void) { + if (windowID == -1) { + return -1; + } + return HuWinChoiceNowGet(windowID); +} + +s32 BoardWinPortraitGet(void) { + s32 temp = GWSystem.board; + return PortraitTbl[temp]; +} + +s32 BoardWinPortraitGetStar(void) { + s32 temp = GWSystem.board; + return StarPortraitTbl[temp]; +} + +void BoardWinPlayerSet(s32 arg0) { + s32 temp_r0; + s32 i; + + if (arg0 == -1) { + temp_r0 = GWSystem.story; + if (temp_r0 != 1) { + for (i = 0, disablePlayer = i; i < 4; i++) { + if (GWPlayer[i].com != 0) { + disablePlayer |= 1 << GWPlayer[i].port; + } + } + } else { + disablePlayer = 0; + } + } else if (GWPlayer[arg0].com != 0) { + disablePlayer = 0xF; + } else { + disablePlayer = ~(1 << GWPlayer[arg0].port); + } + if (_CheckFlag(0x1000BU) != 0) { + disablePlayer = 0; + } + if (windowID != -1) { + HuWinDisablePlayerSet(windowID, disablePlayer); + } +} + +void BoardWinStartComKeySet(void) { + s32 sp8[4]; + s16 temp_r28; + s32 temp_r30; + s32 var_r31; + s32 temp_r29; + + if (BoardPlayerIsAllCom() != 0) { + sp8[0] = sp8[1] = sp8[2] = sp8[3] = 0x100; + } else { + if (GWSystem.player_curr == -1) { + if ((GWPlayer[0].com == 0) || (GWPlayer[1].com == 0) || (GWPlayer[2].com == 0) || (GWPlayer[3].com == 0)) { + return; + } + } else if (GWPlayer[GWSystem.player_curr].com == 0) { + return; + } + if (GWSystem.player_curr != -1) { + for (var_r31 = 0; var_r31 < 4; var_r31++) { + temp_r29 = GWPlayer[var_r31].port; + if (GWSystem.player_curr == var_r31) { + sp8[temp_r29] = 0x100; + } else { + sp8[temp_r29] = 0; + } + } + } else { + for (var_r31 = 0; var_r31 < 4; var_r31++) { + sp8[var_r31] = 0x100; + } + } + } + temp_r28 = GWMessSpeedGet(); + temp_r30 = HuWinKeyWaitNumGet(winMess); + if (temp_r30 != 0) { + HuWinComKeyReset(); + for (var_r31 = 0; var_r31 < temp_r30; var_r31++) { + HuWinComKeyWait(sp8[0], sp8[1], sp8[2], sp8[3], (s32)temp_r28); + } + } +} + +void BoardWinComKeyFuncSet(void (*func)) { + comKeyFunc = func; +} \ No newline at end of file diff --git a/src/game/hsfman.c b/src/game/hsfman.c index 4731a093..6ad3ea7e 100644 --- a/src/game/hsfman.c +++ b/src/game/hsfman.c @@ -3,8 +3,8 @@ ModelData Hu3DData[0x200]; CameraData Hu3DCamera[0x10]; -s16 layerNum[8]; -void (*layerHook[8])(s16); +static s16 layerNum[8]; +static void (*layerHook[8])(s16); AnimData *reflectAnim[5]; AnimData *hiliteAnim[4]; ThreeDProjectionStruct Hu3DProjection[4]; @@ -15,6 +15,7 @@ Mtx Hu3DCameraMtxXPose; LightData Hu3DGlobalLight[0x8]; LightData Hu3DLocalLight[0x20]; Mtx lbl_8018D39C; + GXColor BGColor; s16 reflectMapNo; AnimData *toonAnim; @@ -27,7 +28,7 @@ s16 Hu3DCameraBit; HsfData* Hu3DMallocNo; s16 Hu3DPauseF; u16 Hu3DCameraExistF; -u16 NoSyncF; +static u16 NoSyncF; s32 modelKillAllF; #include "refMapData0.inc" diff --git a/src/game/window.c b/src/game/window.c index 9e51c867..78a63ead 100644 --- a/src/game/window.c +++ b/src/game/window.c @@ -1741,8 +1741,8 @@ static s32 GetMesMaxSizeSub2(WindowData *window, u8 *mess_data) { return mess_w; } -s32 HuWinKeyWaitNumGet(u32 mess) { - s32 wait_num; +s16 HuWinKeyWaitNumGet(u32 mess) { + s16 wait_num; u8 *mess_data; if (mess > 0x80000000) {