Start on board/main.c

This commit is contained in:
gamemasterplc 2024-01-01 22:34:17 -06:00
parent eea75a7068
commit 8c951b693c
16 changed files with 679 additions and 48 deletions

View file

@ -1,7 +1,7 @@
InitBoard = .text:0x00000000; // type:function size:0x30 scope:local InitBoard = .text:0x00000000; // type:function size:0x30 scope:local
_prolog = .text:0x00000030; // type:function size:0x64 scope:global _prolog = .text:0x00000030; // type:function size:0x64 scope:global
_epilog = .text:0x00000094; // type:function size:0x4C scope:global _epilog = .text:0x00000094; // type:function size:0x4C scope:global
BoardInit = .text:0x000000E0; // type:function size:0x4BC BoardCreate = .text:0x000000E0; // type:function size:0x4BC
BoardDestroy = .text:0x0000059C; // type:function size:0x194 BoardDestroy = .text:0x0000059C; // type:function size:0x194
fn_1_730 = .text:0x00000730; // type:function size:0x44 fn_1_730 = .text:0x00000730; // type:function size:0x44
fn_1_774 = .text:0x00000774; // type:function size:0x4 fn_1_774 = .text:0x00000774; // type:function size:0x4

View file

@ -1,7 +1,7 @@
InitBoard = .text:0x00000000; // type:function size:0x30 scope:local InitBoard = .text:0x00000000; // type:function size:0x30 scope:local
_prolog = .text:0x00000030; // type:function size:0x64 scope:global _prolog = .text:0x00000030; // type:function size:0x64 scope:global
_epilog = .text:0x00000094; // type:function size:0x4C scope:global _epilog = .text:0x00000094; // type:function size:0x4C scope:global
BoardInit = .text:0x000000E0; // type:function size:0x4F4 BoardCreate = .text:0x000000E0; // type:function size:0x4F4
BoardDestroy = .text:0x000005D4; // type:function size:0x158 BoardDestroy = .text:0x000005D4; // type:function size:0x158
fn_1_72C = .text:0x0000072C; // type:function size:0x44 fn_1_72C = .text:0x0000072C; // type:function size:0x44
fn_1_770 = .text:0x00000770; // type:function size:0x4 fn_1_770 = .text:0x00000770; // type:function size:0x4

View file

@ -1,7 +1,7 @@
InitBoard = .text:0x00000000; // type:function size:0x30 scope:local InitBoard = .text:0x00000000; // type:function size:0x30 scope:local
_prolog = .text:0x00000030; // type:function size:0x64 scope:global _prolog = .text:0x00000030; // type:function size:0x64 scope:global
_epilog = .text:0x00000094; // type:function size:0x4C scope:global _epilog = .text:0x00000094; // type:function size:0x4C scope:global
BoardInit = .text:0x000000E0; // type:function size:0x660 BoardCreate = .text:0x000000E0; // type:function size:0x660
BoardDestroy = .text:0x00000740; // type:function size:0x144 BoardDestroy = .text:0x00000740; // type:function size:0x144
fn_1_884 = .text:0x00000884; // type:function size:0x6C fn_1_884 = .text:0x00000884; // type:function size:0x6C
fn_1_8F0 = .text:0x000008F0; // type:function size:0x20 fn_1_8F0 = .text:0x000008F0; // type:function size:0x20

View file

@ -22,9 +22,9 @@ REL/w10Dll/host.c:
REL/w10Dll/scene.c: REL/w10Dll/scene.c:
.text start:0x00000D2C end:0x0000176C .text start:0x00000D2C end:0x0000176C
.rodata start:0x00000048 end:0x00000050 .rodata start:0x00000048 end:0x00000058
REL/w10Dll/tutorial.c: REL/w10Dll/tutorial.c:
.text start:0x0000176C end:0x0000206C .text start:0x0000176C end:0x0000206C
.rodata start:0x00000050 end:0x00000070 .rodata start:0x00000058 end:0x00000070
.data start:0x00000098 end:0x000002D4 .data start:0x00000098 end:0x000002D4

View file

@ -1,7 +1,7 @@
InitBoard = .text:0x00000000; // type:function size:0x30 scope:local InitBoard = .text:0x00000000; // type:function size:0x30 scope:local
_prolog = .text:0x00000030; // type:function size:0x64 scope:global _prolog = .text:0x00000030; // type:function size:0x64 scope:global
_epilog = .text:0x00000094; // type:function size:0x4C scope:global _epilog = .text:0x00000094; // type:function size:0x4C scope:global
BoardInit = .text:0x000000E0; // type:function size:0x5F8 BoardCreate = .text:0x000000E0; // type:function size:0x5F8
BoardDestroy = .text:0x000006D8; // type:function size:0x1E8 BoardDestroy = .text:0x000006D8; // type:function size:0x1E8
fn_1_8C0 = .text:0x000008C0; // type:function size:0x44 fn_1_8C0 = .text:0x000008C0; // type:function size:0x44
fn_1_904 = .text:0x00000904; // type:function size:0x4 fn_1_904 = .text:0x00000904; // type:function size:0x4

View file

@ -1009,11 +1009,11 @@ BoardPauseEnableSet = .text:0x8005B6F0; // type:function size:0x74
BoardPauseEnableGet = .text:0x8005B764; // type:function size:0x48 BoardPauseEnableGet = .text:0x8005B764; // type:function size:0x48
BoardSaveInit = .text:0x8005B7AC; // type:function size:0x524 BoardSaveInit = .text:0x8005B7AC; // type:function size:0x524
BoardStoryConfigSet = .text:0x8005BCD0; // type:function size:0x160 BoardStoryConfigSet = .text:0x8005BCD0; // type:function size:0x160
BoardConfigSet = .text:0x8005BE30; // type:function size:0x160 BoardPartyConfigSet = .text:0x8005BE30; // type:function size:0x160
DestroyMainFunc = .text:0x8005BF90; // type:function size:0xC scope:local DestroyMainFunc = .text:0x8005BF90; // type:function size:0xC scope:local
MainFunc = .text:0x8005BF9C; // type:function size:0x7D0 scope:local MainFunc = .text:0x8005BF9C; // type:function size:0x7D0 scope:local
BoardTurnNext = .text:0x8005C76C; // type:function size:0x8C BoardTurnNext = .text:0x8005C76C; // type:function size:0x8C
BoardIsTurnCont = .text:0x8005C7F8; // type:function size:0x28C BoardTurnStartExec = .text:0x8005C7F8; // type:function size:0x28C
BoardNextOvlSet = .text:0x8005CA84; // type:function size:0xC4 BoardNextOvlSet = .text:0x8005CA84; // type:function size:0xC4
BoardIsStarted = .text:0x8005CB48; // type:function size:0x8C BoardIsStarted = .text:0x8005CB48; // type:function size:0x8C
CreateBoard = .text:0x8005CBD4; // type:function size:0x410 scope:local CreateBoard = .text:0x8005CBD4; // type:function size:0x410 scope:local
@ -1034,9 +1034,9 @@ BoardCameraPointDirGet = .text:0x8005D6D0; // type:function size:0xBC
BoardCameraSet = .text:0x8005D78C; // type:function size:0x28 BoardCameraSet = .text:0x8005D78C; // type:function size:0x28
BoardCameraVisibleSet = .text:0x8005D7B4; // type:function size:0x50 BoardCameraVisibleSet = .text:0x8005D7B4; // type:function size:0x50
BoardCameraOffsetSet = .text:0x8005D804; // type:function size:0x30 BoardCameraOffsetSet = .text:0x8005D804; // type:function size:0x30
BoardCameraTargetSetPlayer = .text:0x8005D834; // type:function size:0xB4 BoardCameraTargetPlayerSet = .text:0x8005D834; // type:function size:0xB4
BoardCameraTargetSetModel = .text:0x8005D8E8; // type:function size:0x40 BoardCameraTargetModelSet = .text:0x8005D8E8; // type:function size:0x40
BoardCameraSTargetetSpace = .text:0x8005D928; // type:function size:0x44 BoardCameraTargetSpaceSet = .text:0x8005D928; // type:function size:0x44
BoardCameraVecCalcFuncSet = .text:0x8005D96C; // type:function size:0x28 BoardCameraVecCalcFuncSet = .text:0x8005D96C; // type:function size:0x28
BoardCameraQuakeSet = .text:0x8005D994; // type:function size:0x3C BoardCameraQuakeSet = .text:0x8005D994; // type:function size:0x3C
BoardCameraQuakeReset = .text:0x8005D9D0; // type:function size:0x3C BoardCameraQuakeReset = .text:0x8005D9D0; // type:function size:0x3C
@ -1073,12 +1073,12 @@ BoardRandInit = .text:0x8005FAF8; // type:function size:0x24
BoardRand = .text:0x8005FB1C; // type:function size:0x24 BoardRand = .text:0x8005FB1C; // type:function size:0x24
BoardRandMod = .text:0x8005FB40; // type:function size:0x50 BoardRandMod = .text:0x8005FB40; // type:function size:0x50
BoardRandFloat = .text:0x8005FB90; // type:function size:0x58 BoardRandFloat = .text:0x8005FB90; // type:function size:0x58
BoardVecMagXZCalc = .text:0x8005FBE8; // type:function size:0x134 BoardVecDistXZCalc = .text:0x8005FBE8; // type:function size:0x134
BoardVecMagXZCheck = .text:0x8005FD1C; // type:function size:0x15C BoardVecMaxDistXZCheck = .text:0x8005FD1C; // type:function size:0x15C
BoardVecCalcDAngleVec = .text:0x8005FE78; // type:function size:0x7C BoardVecCalcDAngleVec = .text:0x8005FE78; // type:function size:0x7C
BoardVecCalcDAngle = .text:0x8005FEF4; // type:function size:0x34 BoardVecCalcDAngle = .text:0x8005FEF4; // type:function size:0x34
BoardVecCalcDAngleMod = .text:0x8005FF28; // type:function size:0x1C0 BoardVecCalcDAngleMod = .text:0x8005FF28; // type:function size:0x1C0
BoardVecMag2Check = .text:0x800600E8; // type:function size:0x6C BoardVecMinDistCheck = .text:0x800600E8; // type:function size:0x6C
BoardFilterFadeOut = .text:0x80060154; // type:function size:0xD4 BoardFilterFadeOut = .text:0x80060154; // type:function size:0xD4
BoardFilterFadeIn = .text:0x80060228; // type:function size:0x174 BoardFilterFadeIn = .text:0x80060228; // type:function size:0x174
BoardFilterFadeIsDone = .text:0x8006039C; // type:function size:0x5C BoardFilterFadeIsDone = .text:0x8006039C; // type:function size:0x5C
@ -1193,10 +1193,10 @@ UpdateDiceDigit2D = .text:0x80068B88; // type:function size:0x278 scope:local
BoardPlayerBtnDownWait = .text:0x80068E00; // type:function size:0x6C BoardPlayerBtnDownWait = .text:0x80068E00; // type:function size:0x6C
BoardPlayerAutoSizeSet = .text:0x80068E6C; // type:function size:0x9C BoardPlayerAutoSizeSet = .text:0x80068E6C; // type:function size:0x9C
BoardPlayerAutoSizeGet = .text:0x80068F08; // type:function size:0x40 BoardPlayerAutoSizeGet = .text:0x80068F08; // type:function size:0x40
fn_80068F48 = .text:0x80068F48; // type:function size:0x1C BoardPlayerMoveAwayIsDone = .text:0x80068F48; // type:function size:0x1C
fn_80068F64 = .text:0x80068F64; // type:function size:0x224 BoardPlayerMoveAwayStart = .text:0x80068F64; // type:function size:0x224
fn_80069188 = .text:0x80069188; // type:function size:0x40 BoardPlayerCurrMoveAwayStart = .text:0x80069188; // type:function size:0x40
fn_800691C8 = .text:0x800691C8; // type:function size:0x100 MoveAwayObjFunc = .text:0x800691C8; // type:function size:0x100 scope:local
BoardBowserSuitInit = .text:0x800692C8; // type:function size:0x1A4 BoardBowserSuitInit = .text:0x800692C8; // type:function size:0x1A4
BoardBowserSuitKill = .text:0x8006946C; // type:function size:0x128 BoardBowserSuitKill = .text:0x8006946C; // type:function size:0x128
BoardBowserSuitModelGet = .text:0x80069594; // type:function size:0x8 BoardBowserSuitModelGet = .text:0x80069594; // type:function size:0x8
@ -5806,7 +5806,7 @@ saveMessWin = .sdata:0x801D3650; // type:object size:0x4 scope:local data:4byte
SR_PushTime = .sdata:0x801D3658; // type:object size:0x8 scope:local data:2byte SR_PushTime = .sdata:0x801D3658; // type:object size:0x8 scope:local data:2byte
SR_ResetPad = .sdata:0x801D3660; // type:object size:0x1 scope:local data:byte SR_ResetPad = .sdata:0x801D3660; // type:object size:0x1 scope:local data:byte
Xfb = .sdata:0x801D3664; // type:object size:0x8 scope:local data:4byte Xfb = .sdata:0x801D3664; // type:object size:0x8 scope:local data:4byte
boardNextScene = .sdata:0x801D3670; // type:object size:0x4 scope:local data:4byte nextOvl = .sdata:0x801D3670; // type:object size:0x4 scope:local data:4byte
filterColor = .sdata:0x801D3674; // type:object size:0x4 scope:local data:byte filterColor = .sdata:0x801D3674; // type:object size:0x4 scope:local data:byte
lbl_801D3678 = .sdata:0x801D3678; // type:object size:0x8 lbl_801D3678 = .sdata:0x801D3678; // type:object size:0x8
suitMdl = .sdata:0x801D3680; // type:object size:0x2 scope:local data:2byte suitMdl = .sdata:0x801D3680; // type:object size:0x2 scope:local data:2byte
@ -6305,9 +6305,9 @@ bowserSuitObj = .sbss:0x801D3F24; // type:object size:0x4 scope:local data:4byte
junctionMask = .sbss:0x801D3F28; // type:object size:0x4 scope:local data:4byte junctionMask = .sbss:0x801D3F28; // type:object size:0x4 scope:local data:4byte
junctionObj = .sbss:0x801D3F2C; // type:object size:0x4 scope:local data:4byte junctionObj = .sbss:0x801D3F2C; // type:object size:0x4 scope:local data:4byte
diceDigit2DObj = .sbss:0x801D3F30; // type:object size:0x4 scope:local data:4byte diceDigit2DObj = .sbss:0x801D3F30; // type:object size:0x4 scope:local data:4byte
lbl_801D3F34 = .sbss:0x801D3F34; // type:object size:0x4 data:4byte moveAwayObj = .sbss:0x801D3F34; // type:object size:0x4 scope:local data:4byte
junctionArrowRot = .sbss:0x801D3F38; // type:object size:0x8 scope:local junctionArrowRot = .sbss:0x801D3F38; // type:object size:0x8 scope:local
lbl_801D3F40 = .sbss:0x801D3F40; // type:object size:0x4 data:byte moveAwayPlayer = .sbss:0x801D3F40; // type:object size:0x4 scope:local data:byte
rollType = .sbss:0x801D3F44; // type:object size:0x1 scope:local data:byte rollType = .sbss:0x801D3F44; // type:object size:0x1 scope:local data:byte
playerMot = .sbss:0x801D3F46; // type:object size:0x8 scope:local playerMot = .sbss:0x801D3F46; // type:object size:0x8 scope:local
boardPlayerMdl = .sbss:0x801D3F4E; // type:object size:0x8 boardPlayerMdl = .sbss:0x801D3F4E; // type:object size:0x8

View file

@ -12,9 +12,9 @@ typedef void (*VoidFunc)(void);
extern const VoidFunc _ctors[]; extern const VoidFunc _ctors[];
extern const VoidFunc _dtors[]; extern const VoidFunc _dtors[];
extern void BoardCommonInit(VoidFunc init, VoidFunc destroy); extern void BoardCommonInit(VoidFunc create, VoidFunc destroy);
extern void BoardInit(void); extern void BoardCreate(void);
extern void BoardDestroy(void); extern void BoardDestroy(void);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -14,10 +14,10 @@ typedef struct player_config {
typedef struct system_state { typedef struct system_state {
/* 0x00 */ struct { /* 0x00 */ struct {
u8 story : 1; u8 party : 1;
u8 team : 1; u8 team : 1;
}; };
/* 0x01 */ s8 diff_story; /* 0x01 */ u8 diff_story;
/* 0x02 */ struct { /* 0x02 */ struct {
u16 bonus_star : 1; u16 bonus_star : 1;
u16 explain_mg : 1; u16 explain_mg : 1;
@ -26,8 +26,8 @@ typedef struct system_state {
u16 mess_speed : 2; u16 mess_speed : 2;
u16 save_mode : 2; u16 save_mode : 2;
}; };
/* 0x04 */ s8 turn; /* 0x04 */ u8 turn;
/* 0x05 */ s8 max_turn; /* 0x05 */ u8 max_turn;
/* 0x06 */ u8 star_flag; /* 0x06 */ u8 star_flag;
/* 0x07 */ u8 star_total; /* 0x07 */ u8 star_total;
/* 0x08 */ struct { /* 0x08 */ struct {
@ -37,13 +37,14 @@ typedef struct system_state {
/* 0x09 */ s8 last5_effect; /* 0x09 */ s8 last5_effect;
/* 0x0A */ s8 player_curr; /* 0x0A */ s8 player_curr;
/* 0x0B */ char unk0B[3]; /* 0x0B */ char unk0B[3];
/* 0x0E */ s16 hidden_block_pos; /* 0x0E */ s16 block_pos;
/* 0x10 */ u8 ATTRIBUTE_ALIGN(4) board_data[32]; /* 0x10 */ u8 ATTRIBUTE_ALIGN(4) board_data[32];
/* 0x30 */ u8 mess_delay; /* 0x30 */ u8 mess_delay;
/* 0x31 */ struct { /* 0x31 */ struct {
u8 field31_bit0 : 4; u8 field31_bit0 : 4;
u8 field31_bit4 : 4;
}; };
/* 0x32 */ char unk_32[0x2]; /* 0x32 */ s8 unk_32;
/* 0x34 */ u16 mg_next; /* 0x34 */ u16 mg_next;
/* 0x36 */ s16 mg_next_extra; /* 0x36 */ s16 mg_next_extra;
/* 0x38 */ s16 unk_38; /* 0x38 */ s16 unk_38;
@ -53,10 +54,11 @@ typedef struct system_state {
typedef struct player_state { typedef struct player_state {
/* 0x00 */ struct { /* 0x00 */ struct {
u8 diff : 2; u16 diff : 2;
u8 com : 1; u16 com : 1;
u8 character : 4; u16 character : 4;
u8 auto_size : 2; u16 auto_size : 2;
u16 field00_bit9 : 1;
}; };
/* 0x02 */ struct { /* 0x02 */ struct {
u8 team : 1; u8 team : 1;
@ -67,14 +69,14 @@ typedef struct player_state {
/* 0x04 */ s8 port; /* 0x04 */ s8 port;
/* 0x05 */ s8 items[3]; /* 0x05 */ s8 items[3];
/* 0x08 */ struct { /* 0x08 */ struct {
u8 color : 2; u16 color : 2;
u8 moving : 1; u16 moving : 1;
u8 field08_bit3 : 1; u16 field08_bit3 : 1;
u8 show_next : 1; u16 show_next : 1;
u8 size : 2; u16 size : 2;
u8 field08_bit7 : 2; u16 field08_bit7 : 2;
u8 rank : 2; u16 rank : 2;
u8 bowser_suit : 1; u16 bowser_suit : 1;
}; };
/* 0x0A */ s8 roll; /* 0x0A */ s8 roll;
/* 0x0C */ s16 space_curr; /* 0x0C */ s16 space_curr;

View file

@ -203,7 +203,7 @@ f32 PSVECDistance(const Vec* a, const Vec* b);
#endif #endif
// TODO // TODO
#if defined( MTX_USE_PS) && 0 #if defined( MTX_USE_PS)
#define VECAdd PSVECAdd #define VECAdd PSVECAdd
#define VECSubtract PSVECSubtract #define VECSubtract PSVECSubtract
#define VECScale PSVECScale #define VECScale PSVECScale

View file

@ -45,7 +45,7 @@ void fn_8004D6F4(s16 arg);
s32 rand8(void); s32 rand8(void);
void BoardCameraTargetSetModel(s16 model); void BoardCameraTargetModelSet(s16 model);
void BoardCameraStartMotion2(s16, Vec*, s32, f32, f32, s32); void BoardCameraStartMotion2(s16, Vec*, s32, f32, f32, s32);
void BoardCameraMotionWait(void); void BoardCameraMotionWait(void);
void BoardSpacePosGet(s32, s32, Vec*); void BoardSpacePosGet(s32, s32, Vec*);
@ -65,7 +65,6 @@ f32 BoardModelRotYGet(s32);
void BoardModelLayerSet(s16, s32); void BoardModelLayerSet(s16, s32);
void BoardTutorialHostSet(s16); void BoardTutorialHostSet(s16);
s32 BoardModelIDGet(s16); s32 BoardModelIDGet(s16);
void BoardCommonInit(void*, void*);
void BoardModelScaleSetV(s32, Vec*); void BoardModelScaleSetV(s32, Vec*);
void BoardLightHookSet(void*, void*); void BoardLightHookSet(void*, void*);
s16 BoardModelCreate(s32, void*, s32); s16 BoardModelCreate(s32, void*, s32);

View file

@ -85,6 +85,8 @@ void omDLLNumEnd(s16 ovl, s16 arg2);
void omSysPauseEnable(BOOL flag); void omSysPauseEnable(BOOL flag);
void omSystemKeyCheckSetup(Process *objman_process);
extern omObjData *omDBGSysKeyObj; extern omObjData *omDBGSysKeyObj;
extern Process *omwatchproc; extern Process *omwatchproc;
extern OverlayID omnextovl; extern OverlayID omnextovl;

View file

@ -1,7 +1,7 @@
#include "REL/board_executor.h" #include "REL/board_executor.h"
static void InitBoard(void) { static void InitBoard(void) {
BoardCommonInit(BoardInit, BoardDestroy); BoardCommonInit(BoardCreate, BoardDestroy);
} }
int _prolog(void) { int _prolog(void) {

View file

@ -65,7 +65,7 @@ inline s32 get_current_board(void) {
return GWSystem.board; return GWSystem.board;
} }
void BoardInit(void) { void BoardCreate(void) {
f32 sp10; f32 sp10;
f32 spC[2]; f32 spC[2];
s32 sp8; s32 sp8;

View file

@ -210,7 +210,7 @@ void fn_1_13A4(void) {
BoardCameraStartMotion2(lbl_1_bss_0->unk8, &sp8, 0, 3200.0f, -1.0f, 0x1E); BoardCameraStartMotion2(lbl_1_bss_0->unk8, &sp8, 0, 3200.0f, -1.0f, 0x1E);
BoardCameraMotionWait(); BoardCameraMotionWait();
fn_1_BA0(0x2E0032); fn_1_BA0(0x2E0032);
BoardCameraTargetSetModel(fn_80083F84()); BoardCameraTargetModelSet(fn_80083F84());
BoardCameraMotionWait(); BoardCameraMotionWait();
fn_1_BA0(0x2E0033); fn_1_BA0(0x2E0033);
fn_1_BA0(0x2E0034); fn_1_BA0(0x2E0034);

628
src/game/board/main.c Normal file
View file

@ -0,0 +1,628 @@
#include "common.h"
#include "math.h"
#include "game/object.h"
#include "game/flag.h"
#include "game/data.h"
#include "game/wipe.h"
typedef void (*VoidFunc)(void);
omObjData *boardMainObj;
u32 boardRandSeed;
static omObjData *last5GfxObj;
static omObjData *confettiObj;
static omObjData *filterObj;
void *boardTurnStartFunc;
u32 lbl_801D3F00;
u32 lbl_801D3EFC;
u32 lbl_801D3EF8;
VoidFunc boardTurnFunc;
void *boardLightSetHook;
void *boardLightResetHook;
static VoidFunc destroyFunc;
static VoidFunc createFunc;
static BOOL cameraUseBackup;
static omObjData *tauntObj;
static omObjData *cameraObj;
Process *boardObjMan;
Process *boardMainProc;
static OverlayID nextOvl = OVL_INVALID;
extern void BoardPlayerCoinsSet(s32 player, s32 value);
extern void BoardPlayerAutoSizeSet(s32 player, s32 value);
extern void fn_800A4A7C(void);
extern void fn_800A6EE4(void);
extern s8 boardTutorialF;
void BoardKill(void);
static void InitBoardFunc(omObjData *object);
static void ExecBoardFunc(omObjData *object);
static void KillBoardFunc(omObjData *object);
static void MainFunc(void);
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;
}
void BoardCommonInit(VoidFunc create, VoidFunc destroy)
{
omSysPauseEnable(FALSE);
if(!_CheckFlag(FLAG_ID_MAKE(1, 0))) {
_SetFlag(FLAG_ID_MAKE(1, 0));
_ClearFlag(FLAG_ID_MAKE(2, 1));
_ClearFlag(FLAG_ID_MAKE(2, 3));
_ClearFlag(FLAG_ID_MAKE(2, 0));
_ClearFlag(FLAG_ID_MAKE(2, 2));
_ClearFlag(FLAG_ID_MAKE(2, 4));
_ClearFlag(FLAG_ID_MAKE(2, 5));
_ClearFlag(FLAG_ID_MAKE(1, 6));
_ClearFlag(FLAG_ID_MAKE(1, 9));
_ClearFlag(FLAG_ID_MAKE(0, 8));
_ClearFlag(FLAG_ID_MAKE(0, 10));
fn_800A4A7C();
}
nextOvl = OVL_INVALID;
_SetFlag(FLAG_ID_MAKE(1, 28));
_SetFlag(FLAG_ID_MAKE(1, 14));
_ClearFlag(FLAG_ID_MAKE(1, 16));
_ClearFlag(FLAG_ID_MAKE(1, 17));
_ClearFlag(FLAG_ID_MAKE(1, 18));
_ClearFlag(FLAG_ID_MAKE(1, 19));
_ClearFlag(FLAG_ID_MAKE(1, 20));
_ClearFlag(FLAG_ID_MAKE(1, 21));
_ClearFlag(FLAG_ID_MAKE(1, 23));
_ClearFlag(FLAG_ID_MAKE(1, 24));
_ClearFlag(FLAG_ID_MAKE(1, 25));
_ClearFlag(FLAG_ID_MAKE(1, 27));
createFunc = create;
destroyFunc = destroy;
boardTurnFunc = NULL;
lbl_801D3EFC = 0;
lbl_801D3F00 = 0;
lbl_801D3EF8 = 0;
boardTurnStartFunc = NULL;
boardObjMan = omInitObjMan(64, 8192);
omSystemKeyCheckSetup(boardObjMan);
boardMainObj = omAddObjEx(boardObjMan, 0, 0, 0, 1, InitBoardFunc);
switch(omcurovl) {
case OVL_W01:
GWSystem.board = 0;
break;
case OVL_W02:
GWSystem.board = 1;
break;
case OVL_W03:
GWSystem.board = 2;
break;
case OVL_W04:
GWSystem.board = 3;
break;
case OVL_W05:
GWSystem.board = 4;
break;
case OVL_W06:
GWSystem.board = 5;
break;
case OVL_W10:
GWSystem.board = 6;
break;
case OVL_W20:
GWSystem.board = 7;
break;
case OVL_W21:
GWSystem.board = 8;
break;
}
}
static void InitBoardFunc(omObjData *object)
{
boardMainProc = HuPrcChildCreate(MainFunc, 8194, 0x6000, 0, boardObjMan);
HuPrcDestructorSet2(boardMainProc, DestroyMainFunc);
object->func = ExecBoardFunc;
}
static void ExecBoardFunc(omObjData *object)
{
if(!_CheckFlag(FLAG_ID_MAKE(1, 16))) {
return;
}
if(!_CheckFlag(FLAG_ID_MAKE(1, 17))) {
if(omSysExitReq) {
BoardKill();
} else {
if(BoardPauseReqCheck()) {
BoardPauseStart();
} else {
return;
}
}
} else {
if(boardMainProc) {
HuPrcKill(boardMainProc);
}
object->func = KillBoardFunc;
}
}
static void KillBoardFunc(omObjData *object)
{
if(boardMainProc) {
return;
}
if(WipeStatGet()) {
return;
return_alt:
return;
} else {
if(HuARDMACheck()) {
goto return_alt;
}
if(nextOvl != OVL_INVALID) {
omOvlCallEx(nextOvl, 1, 0, 0);
} else {
if(_CheckFlag(FLAG_ID_MAKE(1, 11))) {
BoardTutorialKill();
BoardTutorialWorkRestore();
}
_ClearFlag(FLAG_ID_MAKE(1, 0));
HuARDirFree(MAKE_DIR_NUM(DATADIR_BOARD));
if(_CheckFlag(FLAG_ID_MAKE(1, 27))) {
omOvlReturnEx(2, 1);
} else {
omOvlReturnEx(1, 1);
}
}
}
}
void BoardKill(void)
{
_SetFlag(FLAG_ID_MAKE(1, 28));
_SetFlag(FLAG_ID_MAKE(1, 14));
if(_CheckFlag(FLAG_ID_MAKE(1, 11))) {
BoardTutorialHookExec(29, 0);
}
HuAudFXAllStop();
if(!BoardIsStarted()) {
WipeCreate(WIPE_MODE_OUT, WIPE_TYPE_NORMAL, -1);
boardTutorialF = 1;
while(WipeStatGet()) {
HuPrcVSleep();
}
}
_SetFlag(FLAG_ID_MAKE(1, 17));
HuPrcKill(boardMainProc);
DestroyBoard();
}
s32 BoardIsKill(void)
{
return (_CheckFlag(FLAG_ID_MAKE(1, 17))) ? 1 : 0;
}
void BoardPauseEnableSet(s32 value)
{
if(_CheckFlag(FLAG_ID_MAKE(1, 11))) {
_SetFlag(FLAG_ID_MAKE(1, 25));
omSysPauseEnable(FALSE);
} else {
if(value) {
_SetFlag(FLAG_ID_MAKE(1, 25));
} else {
_ClearFlag(FLAG_ID_MAKE(1, 25));
}
}
}
s32 BoardPauseEnableGet()
{
return (_CheckFlag(FLAG_ID_MAKE(1, 25))) ? 1 : 0;
}
void BoardSaveInit(s32 board)
{
int i;
GWSystem.board = board;
_ClearFlag(FLAG_ID_MAKE(1, 0));
_ClearFlag(FLAG_ID_MAKE(1, 1));
_ClearFlag(FLAG_ID_MAKE(1, 5));
_ClearFlag(FLAG_ID_MAKE(1, 4));
_ClearFlag(FLAG_ID_MAKE(1, 6));
_ClearFlag(FLAG_ID_MAKE(1, 2));
_ClearFlag(FLAG_ID_MAKE(1, 9));
_ClearFlag(FLAG_ID_MAKE(1, 7));
_ClearFlag(FLAG_ID_MAKE(1, 8));
_ClearFlag(FLAG_ID_MAKE(0, 8));
_ClearFlag(FLAG_ID_MAKE(1, 12));
_ClearFlag(FLAG_ID_MAKE(1, 3));
GWSystem.turn = 1;
GWSystem.star_flag = 0;
GWSystem.star_pos = 0;
GWSystem.star_total = 1;
GWSystem.last5_effect = 0;
GWSystem.player_curr = -1;
GWSystem.field31_bit0 = 0;
GWSystem.field31_bit4 = 0;
GWSystem.unk_32 = 1;
GWSystem.mg_next = 0;
GWSystem.mg_next_extra = 0;
GWSystem.unk_38 = 0;
GWSystem.block_pos = 0;
memset(GWSystem.board_data, 0, 32);
for(i=0; i<4; i++) {
BoardPlayerAutoSizeSet(i, 0);
GWPlayer[i].field00_bit9 = 0;
GWPlayer[i].color = 0;
GWPlayer[i].bowser_suit = 0;
GWPlayer[i].field08_bit3 = 0;
GWPlayer[i].space_shock = 0;
GWPlayer[i].field02_bit1 = 0;
GWPlayer[i].show_next = 1;
BoardPlayerCoinsSet(i, 0);
if(_CheckFlag(FLAG_ID_MAKE(1, 11))) {
GWSystem.team = 0;
}
GWPlayer[i].blue_count = 0;
GWPlayer[i].red_count = 0;
GWPlayer[i].question_count = 0;
GWPlayer[i].fortune_count = 0;
GWPlayer[i].bowser_count = 0;
GWPlayer[i].battle_count = 0;
GWPlayer[i].mushroom_count = 0;
GWPlayer[i].warp_count = 0;
GWPlayer[i].coins_mg = 0;
GWPlayer[i].coins_total = 0;
GWPlayer[i].coins_max = 0;
GWPlayer[i].stars_max = 0;
GWPlayer[i].coins_battle = 0;
GWPlayer[i].unk_26 = 0;
GWPlayer[i].coins_mg_gain = 0;
GWPlayer[i].items[0] = -1;
GWPlayer[i].items[1] = -1;
GWPlayer[i].items[2] = -1;
if(!BoardPartyFlagGet() || _CheckFlag(FLAG_ID_MAKE(1, 11))) {
GWStarsSet(i, 0);
} else {
GWStarsSet(i, BoardHandicapGet(i));
}
}
}
void BoardStoryConfigSet(s32 mg_type, s32 diff_story)
{
GWSystem.party = 0;
GWSystem.team = 0;
GWSystem.diff_story = diff_story;
GWSystem.bonus_star = 0;
GWSystem.mg_type = mg_type;
GWPlayer[0].handicap = 0;
GWPlayer[1].handicap = 0;
GWPlayer[2].handicap = 0;
GWPlayer[3].handicap = 0;
GWSystem.max_turn = 15;
memset(GWPlayer, 0, 4*sizeof(PlayerState));
_ClearFlag(FLAG_ID_MAKE(0, 2));
_ClearFlag(FLAG_ID_MAKE(0, 3));
_ClearFlag(FLAG_ID_MAKE(0, 4));
_ClearFlag(FLAG_ID_MAKE(0, 5));
_ClearFlag(FLAG_ID_MAKE(0, 6));
_ClearFlag(FLAG_ID_MAKE(0, 7));
_ClearFlag(FLAG_ID_MAKE(1, 11));
_SetFlag(FLAG_ID_MAKE(0, 11));
_SetFlag(FLAG_ID_MAKE(1, 10));
}
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)
{
GWSystem.party = 1;
GWSystem.team = team;
GWSystem.diff_story = 0;
GWSystem.bonus_star = bonus_star;
GWSystem.mg_type = mg_type;
GWSystem.max_turn = max_turn;
memset(GWPlayer, 0, 4*sizeof(PlayerState));
GWPlayer[0].handicap = p1_handicap;
GWPlayer[1].handicap = p2_handicap;
GWPlayer[2].handicap = p3_handicap;
GWPlayer[3].handicap = p4_handicap;
_ClearFlag(FLAG_ID_MAKE(1, 11));
_SetFlag(FLAG_ID_MAKE(0, 11));
_SetFlag(FLAG_ID_MAKE(1, 10));
}
static void DestroyMainFunc(void)
{
boardMainProc = NULL;
}
static void MainFunc(void)
{
s32 i;
s32 fade_enable, turn_cont, fade_type;
fade_enable = 0;
turn_cont = 0;
BoardPauseEnableSet(1);
if(_CheckFlag(FLAG_ID_MAKE(0, 10))) {
_ClearFlag(FLAG_ID_MAKE(0, 10));
_SetFlag(FLAG_ID_MAKE(1, 16));
BoardKill();
HuPrcSleep(-1);
}
_ClearFlag(FLAG_ID_MAKE(0, 10));
BoardTutorialInit();
if(_CheckFlag(FLAG_ID_MAKE(1, 11))) {
BoardTutorialWorkSave();
BoardTutorialPlayerInit();
GWSystem.mess_speed = 1;
GWSystem.mess_delay = 32;
}
CreateBoard();
if(!_CheckFlag(FLAG_ID_MAKE(1, 1))) {
GWSystem.player_curr = -1;
fn_800A6EE4();
GWSystem.player_curr = 0;
fade_enable = 1;
_SetFlag(FLAG_ID_MAKE(1, 1));
} else {
fade_enable = 0;
}
if(BoardIsTurnCont()) {
turn_cont = 1;
}
if((int)(GWSystem.max_turn-GWSystem.turn) < 5 && GWSystem.player_curr == 0 && !turn_cont) {
if(!_CheckFlag(FLAG_ID_MAKE(0, 8))) {
fn_800A9708();
_SetFlag(FLAG_ID_MAKE(0, 8));
} else {
BoardLast5GfxInit();
}
}
if(!turn_cont) {
fade_type = 1;
} else {
fade_type = 0;
}
_ClearFlag(FLAG_ID_MAKE(1, 28));
do {
BoardStatusShowSetAll(1);
if(BoardCurrGet() == 5 && GWSystem.player_curr == 0 && !turn_cont && boardTurnFunc) {
GWSystem.player_curr = -1;
boardTurnFunc();
GWSystem.player_curr = 0;
}
fn_80070D84();
for(i=GWSystem.player_curr; i<4; i++) {
if(BoardCurrGet() == 7 || BoardCurrGet() == 8) {
if((int)(GWSystem.max_turn-GWSystem.turn) < 5 && i == 0 && !turn_cont) {
BoardLast5GfxInit();
_SetFlag(FLAG_ID_MAKE(0, 8));
}
}
if(_CheckFlag(FLAG_ID_MAKE(1, 6))) {
BoardPlayerTurnExec(i);
} else {
if(!turn_cont) {
BoardCameraVisibleSet(0);
GWSystem.player_curr = i;
BoardCameraTargetModelSet(i);
BoardCameraMotionWait();
{
Vec pos;
BoardSpacePosGet(0, GWPlayer[i].space_curr, &pos);
BoardPlayerPosSetV(i, &pos);
}
while(WipeStatGet()) {
HuPrcVSleep();
}
if(!fade_enable) {
if(!fade_type) {
WipeCreate(WIPE_MODE_IN, WIPE_TYPE_CROSS, 30);
while(WipeStatGet()) {
HuPrcVSleep();
}
} else {
fade_type = 0;
WipeCreate(WIPE_MODE_IN, WIPE_TYPE_NORMAL, 21);
while(WipeStatGet()) {
HuPrcVSleep();
}
}
} else {
fade_enable = 0;
}
BoardPlayerTurnExec(i);
}
}
turn_cont = 0;
if(_CheckFlag(FLAG_ID_MAKE(1, 11))) {
BoardTutorialHookExec(9, 0);
}
if(i != 3 || _CheckFlag(FLAG_ID_MAKE(1, 11))) {
WipeColorSet(255, 255, 255);
WipeCreate(WIPE_MODE_OUT, WIPE_TYPE_CROSS, 1);
while(WipeStatGet()) {
HuPrcVSleep();
}
BoardPlayerCurrMoveAwayStart(GWPlayer[i].space_curr, 1);
fade_type = 0;
} else {
if(BoardCurrGet() == 7 || BoardCurrGet() == 8) {
if(GWSystem.turn != GWSystem.max_turn) {
WipeColorSet(255, 255, 255);
WipeCreate(WIPE_MODE_OUT, WIPE_TYPE_CROSS, 1);
while(WipeStatGet()) {
HuPrcVSleep();
}
BoardPlayerCurrMoveAwayStart(GWPlayer[i].space_curr, 1);
fade_type = 0;
}
} else {
WipeColorSet(0, 0, 0);
WipeCreate(WIPE_MODE_OUT, WIPE_TYPE_NORMAL, 21);
while(WipeStatGet()) {
HuPrcVSleep();
}
}
}
BoardPlayerPostTurnHookExec(i);
}
if(BoardCurrGet() == 7 || BoardCurrGet() == 8) {
GWSystem.player_curr = 0;
if(BoardTurnNext()) {
fn_80070EE8(0, 500);
BoardKill();
HuPrcEnd();
HuPrcSleep(-1);
}
} else {
_SetFlag(FLAG_ID_MAKE(1, 28));
_SetFlag(FLAG_ID_MAKE(1, 14));
BoardPauseEnableSet(1);
_CheckFlag(FLAG_ID_MAKE(1, 9));
if(_CheckFlag(FLAG_ID_MAKE(2, 0)) || _CheckFlag(FLAG_ID_MAKE(1, 11)) ) {
for(i=0; i<4; i++) {
GWPlayer[i].color = 0;
}
GWSystem.player_curr = (GWSystem.player_curr+1)&3;
} else {
fn_800A1A34();
HuPrcSleep(-1);
}
}
} while(1);
}
BOOL BoardTurnNext(void)
{
s32 i;
for(i=0; i<4; i++) {
GWPlayer[i].color = 0;
}
GWSystem.turn++;
if(GWSystem.turn > GWSystem.max_turn) {
return 1;
} else {
return 0;
}
}
void BoardNextOvlSet(OverlayID overlay)
{
nextOvl = overlay;
fn_80070EE8(0, 1000);
BoardKill();
}
BOOL BoardIsStarted(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;
} else {
return 0;
}
}
static void CreateBoard(void)
{
}
static void DestroyBoard(void)
{
}
u32 BoardRand(void)
{
boardRandSeed = (boardRandSeed*0x19660D)+(0x3C6EF35F);
return boardRandSeed;
}
u32 BoardRandMod(u32 value)
{
return (BoardRand() & 0x7FFFFFFF)%value;
}
float BoardRandFloat(void)
{
float value;
*((u32 *)&value) = (BoardRand() & 0x7FFFFF)|0x3F800000;
return value-1.0f;
}
float BoardVecDistXZCalc(Vec *vec1, Vec *vec2)
{
float x = vec1->x-vec2->x;
float z = vec1->z-vec2->z;
return sqrtf((x*x)+(z*z));
}
s32 BoardVecMaxDistXZCheck(Vec *vec1, Vec *vec2, float max_dist)
{
float z = vec1->z-vec2->z;
float x = vec1->x-vec2->x;
float dist = sqrtf((x*x)+(z*z));
if(dist <= max_dist) {
return 1;
} else {
return 0;
}
}
s32 BoardVecMinDistCheck(Vec *vec1, Vec *vec2, float min_dist)
{
Vec temp;
Mtx temp_mtx;
VECSubtract(vec1, vec2, &temp);
if(VECSquareMag(&temp) >= (min_dist*min_dist)) {
return 0;
} else {
return 1;
}
}
s32 BoardDataDirReadAsync(s32 data_num)
{
s32 status = HuDataDirReadAsync(data_num);
return status;
}
void BoardDataAsyncWait(s32 status)
{
if(status == -1) {
return;
}
while(!HuDataGetAsyncStat(status)) {
HuPrcVSleep();
}
}

View file

@ -356,7 +356,7 @@ void BoardWinPlayerSet(s32 player) {
s32 i; s32 i;
if (player == -1) { if (player == -1) {
temp = GWSystem.story; temp = GWSystem.party;
if (temp != 1) { if (temp != 1) {
for (i = 0, disablePlayer = i; i < 4; i++) { for (i = 0, disablePlayer = i; i < 4; i++) {
if (GWPlayer[i].com != 0) { if (GWPlayer[i].com != 0) {