diff --git a/config/GMPE01_00/symbols.txt b/config/GMPE01_00/symbols.txt index b4c32041..46f0f314 100644 --- a/config/GMPE01_00/symbols.txt +++ b/config/GMPE01_00/symbols.txt @@ -5212,9 +5212,9 @@ lbl_80139DA8 = .data:0x80139DA8; // type:object size:0xA data:string itemPrioTbl = .data:0x80139DB2; // type:object size:0x8C scope:local rankItemGroupTbl = .data:0x80139E3E; // type:object size:0x18 scope:local cursorPosTbl = .data:0x80139E58; // type:object size:0x30 scope:local data:float -comInputDraw1 = .data:0x80139E88; // type:object size:0xEE scope:local -comInputDraw2 = .data:0x80139F76; // type:object size:0xBA scope:local -comInputBall = .data:0x8013A030; // type:object size:0xCE scope:local +comInputDraw1 = .data:0x80139E88; // type:object size:0xEE scope:local data:2byte +comInputDraw2 = .data:0x80139F76; // type:object size:0xBA scope:local data:2byte +comInputBall = .data:0x8013A030; // type:object size:0xCE scope:local data:2byte lbl_8013A0FE = .data:0x8013A0FE; // type:object size:0xC data:string lbl_8013A10A = .data:0x8013A10A; // type:object size:0xA data:string lbl_8013A114 = .data:0x8013A114; // type:object size:0x9 data:string @@ -5903,7 +5903,7 @@ lotterySpr = .sdata:0x801D3732; // type:object size:0x2 scope:local data:2byte lotteryInstWin = .sdata:0x801D3734; // type:object size:0x2 scope:local data:2byte gripMdl = .sdata:0x801D3736; // type:object size:0x4 scope:local data:2byte turnMot = .sdata:0x801D373A; // type:object size:0x2 scope:local data:2byte -ballMdl = .sdata:0x801D373C; // type:object size:0x8 scope:local +ballMdl = .sdata:0x801D373C; // type:object size:0x8 scope:local data:2byte loseMot = .sdata:0x801D3744; // type:object size:0x2 scope:local data:2byte ticketSprGrp = .sdata:0x801D3746; // type:object size:0x2 scope:local data:2byte warpSpringMdl = .sdata:0x801D3748; // type:object size:0x2 scope:local data:2byte diff --git a/configure.py b/configure.py index 42a02138..dd61dd7c 100644 --- a/configure.py +++ b/configure.py @@ -368,7 +368,7 @@ config.libs = [ Object(Matching, "game/board/view.c"), Object(NonMatching, "game/board/space.c"), Object(NonMatching, "game/board/shop.c"), - Object(NonMatching, "game/board/lottery.c"), + Object(Matching, "game/board/lottery.c"), Object(Matching, "game/board/basic_space.c"), Object(Matching, "game/board/warp.c"), Object(NonMatching, "game/board/char_wheel.c"), diff --git a/include/board_unsplit.h b/include/board_unsplit.h index 4115581c..2c7dcf01 100644 --- a/include/board_unsplit.h +++ b/include/board_unsplit.h @@ -14,26 +14,12 @@ typedef void (*BoardLightHook)(void); s32 BoardSpacePosGet(s32, s32, Vec*); void BoardShopTutorialExec(s32); -void BoardLotteryTutorialExec(void); void BoardMGSetupTutorialExec(void); void BoardBooHouseTutorialExec(void); void BoardCharWheelSetTarget(s32); void BoardSpaceStarSetIndex(s32); -s32 BoardModelRotYSet(s16, f32); -f32 BoardModelRotYGet(s16); -s32 BoardModelLayerSet(s16, u8); -s16 BoardModelIDGet(s16); -s32 BoardModelScaleSetV(s16, Vec*); void BoardLightHookSet(BoardLightHook set, BoardLightHook reset); -s16 BoardModelCreate(s32, s32*, s32); -void BoardModelKill(s16); s32 fn_8006DDE8(s16, f32); -s32 BoardModelMotionStart(s16, s32, u32); -s32 BoardModelMotionSpeedSet(s16, f32); -s32 BoardModelPosSetV(s16, Vec*); -s32 BoardModelPosSet(s16, f32, f32, f32); -s32 BoardModelRotSetV(s16 arg0, Vec* arg1); -s32 BoardModelVisibilitySet(s16, s32); void BoardSpaceWalkEventFuncSet(BoardSpaceEventFunc func); void BoardSpaceWalkMiniEventFuncSet(BoardSpaceEventFunc func); void BoardSpaceLandEventFuncSet(BoardSpaceEventFunc func); @@ -41,13 +27,9 @@ s32 BoardSpaceFlagSearch(s32, u32); void BoardSpaceInit(s32); void BoardSpaceDestroy(void); void BoardShopHostSet(s16); -void BoardLotteryHostSet(s16); void BoardBooHouseHostSet(s16); s32 BoardCameraRotGet(Vec*); -s32 BoardModelScaleSet(s16, f32, f32, f32); s32 BoardIsKill(void); -void BoardModelMtxSet(s16, Mtx*); -s32 BoardModelRotSet(s16, f32, f32, f32); void BoardBowserExec(s32 player, s32 space); void BoardBattleExec(s32 player, s32 space); diff --git a/include/game/audio.h b/include/game/audio.h index 09fd50cf..58a9f20d 100644 --- a/include/game/audio.h +++ b/include/game/audio.h @@ -20,7 +20,7 @@ void HuAudFXFadeOut(s32 arg0, s32 arg1); void HuAudFXPanning(s32 arg0, s16 arg1); void HuAudFXListnerSet(Vec* arg0, Vec* arg1, float arg2, float arg3); void HuAudFXListnerSetEX(Vec* arg0, Vec* arg1, float sndDist, float sndSpeed, float arg4, float arg5, float arg6); -void HuAudFXListnerUpdate(s32 arg0, s32 arg1); +void HuAudFXListnerUpdate(Vec *arg0, Vec *arg1); s32 HuAudFXEmiterPlay(s32 arg0, Vec *arg1); void HuAudFXEmiterUpDate(s32 arg0, Vec *arg1); void HuAudFXListnerKill(void); diff --git a/include/game/board/lottery.h b/include/game/board/lottery.h new file mode 100755 index 00000000..d292db5f --- /dev/null +++ b/include/game/board/lottery.h @@ -0,0 +1,13 @@ +#ifndef _BOARD_LOTTERY_H +#define _BOARD_LOTTERY_H + +#include "dolphin/types.h" + +void BoardLotteryHostSet(s16 arg0); +s16 BoardLotteryHostGet(void); +void BoardLotteryExec(void); +void BoardLotteryInit(void); +void BoardLotteryKill(void); +void BoardLotteryTutorialExec(void); + +#endif diff --git a/include/game/board/model.h b/include/game/board/model.h index 479194e6..8fa317bd 100644 --- a/include/game/board/model.h +++ b/include/game/board/model.h @@ -1,5 +1,5 @@ -#ifndef _BOARD_WARP_H -#define _BOARD_WARP_H +#ifndef _BOARD_MODEL_H +#define _BOARD_MODEL_H #include "game/hsfman.h" #include "game/data.h" @@ -40,13 +40,16 @@ s32 BoardModelMotionStartEndSet(s16 model, s16 start, s16 end); s32 BoardModelMotionStart(s16 model, s32 slot, u32 attr); s32 BoardModelMotionShiftSet(s16 model, s32 motion, float time, float shift_time, u32 attr); s32 BoardModelAttrSet(s16 model, u32 attr); +s32 BoardModelAttrReset(s16 model, u32 attr); s32 BoardModelMotionTimeSet(s16 model, float time); float BoardModelMotionTimeGet(s16 model); float BoardModelMotionMaxTimeGet(s16 model); s32 BoardModelMotionSpeedSet(s16 model, float speed); s32 BoardModelMotionEndCheck(s16 model); s32 BoardModelAlphaSet(s16 model, u8 alpha); +s32 BoardModelMtxSet(s16 model, Mtx *src); s32 BoardModelRotYSet(s16 model, float rot); +float BoardModelRotYGet(s16 model); s32 BoardModelPosSet(s16 model, float x, float y, float z); s32 BoardModelPosSetV(s16 model, Vec *pos); s32 BoardModelRotSet(s16 model, float x, float y, float z); diff --git a/include/game/gamework_data.h b/include/game/gamework_data.h index c0333d13..874b1e71 100644 --- a/include/game/gamework_data.h +++ b/include/game/gamework_data.h @@ -58,6 +58,7 @@ typedef struct player_state { u16 character : 4; u16 auto_size : 2; u16 field00_bit9 : 1; + u16 field00_bitA : 6; }; /* 0x02 */ struct { u8 team : 1; diff --git a/include/game/msm.h b/include/game/msm.h index 75f35f19..1885d41e 100644 --- a/include/game/msm.h +++ b/include/game/msm.h @@ -69,7 +69,7 @@ void msmMusStopAll(s32 arg0, s32 arg1); void msmMusStop(s32 arg0, s32 arg1); s32 msmMusPlay(s32 arg0, UnkMsmStruct_03 *arg1); void msmSeDelListener(void); -void msmSeUpdataListener(s32 arg0, s32 arg1); +void msmSeUpdataListener(Vec *arg0, Vec *arg1); void msmSeSetListener(Vec* arg0, Vec* arg1, float arg2, float arg3, UnkMsmStruct_02 *arg4); s32 msmSeGetEntryID(s32 arg0, void *arg1); s32 msmSeGetNumPlay(s32 arg0); diff --git a/src/REL/w03Dll/main.c b/src/REL/w03Dll/main.c index 732301f8..8671684d 100644 --- a/src/REL/w03Dll/main.c +++ b/src/REL/w03Dll/main.c @@ -1,9 +1,13 @@ #include "dolphin.h" #include "REL/executor.h" -#include "game/process.h" +#include "game/audio.h" #include "game/data.h" #include "game/gamework_data.h" +#include "game/process.h" +#include "game/wipe.h" #include "REL/w03Dll.h" +#include "game/board/lottery.h" +#include "game/board/model.h" #include "game/board/space.h" #include "game/board/star.h" #include "game/object.h" @@ -12,9 +16,6 @@ #include "board_unsplit.h" #include "game/hsfman.h" -s32 BoardModelPosSet(s16, f32, f32, f32); -s32 BoardModelMotionStart(s16, s32, u32); - void fn_8005B150(void*, void*); void fn_1_740(void); void fn_1_E0(void); @@ -35,14 +36,6 @@ extern const VoidFunc _ctors[]; extern const VoidFunc _dtors[]; -f32 BoardModelMotionTimeGet(s16); -s16 BoardModelCreate(s32, s32*, s32); -void BoardModelKill(s16); -void BoardModelMotionStartEndSet(s16, s32, s32); -void Hu3DFogSet(f32, f32, u8, u8, u8); -void HuAudFXListnerSetEX(Vec* arg0, Vec* arg1, float sndDist, float sndSpeed, float arg4, float arg5, float arg6); -u8 WipeStatGet(void); - //DATA w03StructUnk0 lbl_1_data_0[] = { {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f}, DATA_MAKE_NUM(DATADIR_W03, 0x0004)}, @@ -328,7 +321,7 @@ void fn_1_B5C(s32 arg0) { } BoardModelAttrSet(lbl_1_bss_C[0], 0x40000001); BoardModelMotionTimeSet(lbl_1_bss_C[0], var_f31); - BoardModelMotionStartEndSet(lbl_1_bss_C[0], (s32) var_f31, (s32) var_f28); + BoardModelMotionStartEndSet(lbl_1_bss_C[0], var_f31, var_f28); } void fn_1_CF4(void) { diff --git a/src/REL/w03Dll/mg_coin.c b/src/REL/w03Dll/mg_coin.c index e76ce248..c73112fd 100644 --- a/src/REL/w03Dll/mg_coin.c +++ b/src/REL/w03Dll/mg_coin.c @@ -4,6 +4,7 @@ #include "REL/w03Dll.h" #include "board_unsplit.h" #include "game/board/main.h" +#include "game/board/model.h" #include "game/board/player.h" extern u16 HuPadBtnDown[4]; @@ -67,9 +68,6 @@ double cos(double x); double atan2(double y, double x); extern s16 MGSeqCreate(s32, ...); u8 MGSeqStatGet(s16); -float BoardModelMotionTimeGet(s16 model); -float BoardModelMotionMaxTimeGet(s16 model); -s32 BoardModelMotionShiftSet(s16 model, s32 motion, float time, float shift_time, u32 attr); void Hu3DModelObjPosGet(s16 arg0, char *arg1, Vec *arg2); //DATA @@ -206,7 +204,7 @@ s32 fn_1_7D18(s32 arg0) { BoardSpacePosGet(0, temp_r28, &sp38); PSVECSubtract(&sp38, &sp2C, &sp20); PSVECNormalize(&sp20, &sp20); - BoardPlayerRotYSet(arg0, 180.0 * (atan2(-sp20.x, -sp20.z) / 3.141592653589793)); + BoardPlayerRotYSet(arg0, 180.0 * (atan2(-sp20.x, -sp20.z) / M_PI)); HuPrcSleep(0x1E); model = BoardModelIDGet(lbl_1_bss_C[7]); Hu3DModelObjPosGet(model, phei_str, &sp38); @@ -215,15 +213,15 @@ s32 fn_1_7D18(s32 arg0) { } else { var_f31 = 39.0f; } - sp38.x = sp38.x + (var_f31 * sin((3.141592653589793 * (180.0f + BoardModelRotYGet(lbl_1_data_456))) / 180.0)); - sp38.z = sp38.z + (var_f31 * cos((3.141592653589793 * (180.0f + BoardModelRotYGet(lbl_1_data_456))) / 180.0)); + sp38.x = sp38.x + (var_f31 * sin((M_PI * (180.0f + BoardModelRotYGet(lbl_1_data_456))) / 180.0)); + sp38.z = sp38.z + (var_f31 * cos((M_PI * (180.0f + BoardModelRotYGet(lbl_1_data_456))) / 180.0)); BoardPlayerPosGet(arg0, &sp2C); BoardPlayerPosLerpStart(arg0, &sp2C, &sp38, 0x14); while (GWPlayer[arg0].moving != 0) { BoardModelPosGet(lbl_1_bss_C[10], &sp2C); BoardPlayerPosGet(arg0, &sp38); PSVECSubtract(&sp38, &sp2C, &sp20); - arctan = atan2(sp20.x, sp20.z) / 3.141592653589793 * 180.0; + arctan = atan2(sp20.x, sp20.z) / M_PI * 180.0; BoardModelRotYSet(lbl_1_bss_C[10], arctan); HuPrcVSleep(); } @@ -482,7 +480,7 @@ void fn_1_8C08(omObjData* arg0, someBits3* arg1) { BoardPlayerMotionSpeedSet(arg1->unk00_bit5, 0.0f); BoardModelAttrSet(lbl_1_bss_C[7], 0x40000002); BoardModelAttrSet(lbl_1_data_456, 0x40000002); - arg1->unk00_bit1 = 2; + arg1->unk00_bit1 = 2; arg1->unk1 = 0x3C; arg1->unk2 = 0; } @@ -549,7 +547,7 @@ void fn_1_9044(omObjData* arg0, someBits3* arg1) { } } } - sp8.z = arg0->trans.x * sin((3.141592653589793 * arg0->trans.y) / 180.0); + sp8.z = arg0->trans.x * sin((M_PI * arg0->trans.y) / 180.0); BoardModelRotSetV(lbl_1_data_456, &sp8); } @@ -580,7 +578,7 @@ void fn_1_9230(s32 arg0) { BoardModelPosGet(lbl_1_bss_C[10], &sp20); BoardPlayerPosGet(arg0, &sp14); PSVECSubtract(&sp14, &sp20, &sp8); - rotY = atan2(sp8.x, sp8.z) / 3.141592653589793 * 180.0; + rotY = atan2(sp8.x, sp8.z) / M_PI * 180.0; BoardModelRotYSet(lbl_1_bss_C[10], rotY); HuPrcVSleep(); } @@ -712,8 +710,8 @@ void fn_1_97F8(s32 arg0) { } temp_r31 = &temp_r30->unk_0C[i]; temp_r31->unk0 = 1; - temp_r31->unk8.x = sp8.x + (50.0f * sin((3.141592653589793 * var_f31) / 180.0)); - temp_r31->unk8.z = sp8.z + (50.0f * cos((3.141592653589793 * var_f31) / 180.0)); + temp_r31->unk8.x = sp8.x + (50.0f * sin((M_PI * var_f31) / 180.0)); + temp_r31->unk8.z = sp8.z + (50.0f * cos((M_PI * var_f31) / 180.0)); temp_r31->unk8.y = 600.0f + sp8.y + (500.0f * BoardRandFloat()); temp_r31->unk1 = 0; temp_r31->unk4 = BoardRandFloat() * 360.0f; diff --git a/src/REL/w03Dll/mg_item.c b/src/REL/w03Dll/mg_item.c index d9bfc3be..6740b263 100644 --- a/src/REL/w03Dll/mg_item.c +++ b/src/REL/w03Dll/mg_item.c @@ -5,6 +5,7 @@ #include "game/gamework_data.h" #include "REL/w03Dll.h" #include "game/board/main.h" +#include "game/board/model.h" #include "game/board/space.h" #include "game/object.h" #include "game/objsub.h" @@ -54,7 +55,7 @@ typedef struct w03UnkMG { /* 0x10 */ s16 unk_10; /* 0x12 */ s16 unk_12; /* 0x14 */ s16 unk_14; - /* 0x16 */ s16 unk_16; + /* 0x16 */ s16 unk_16; } w03UnkMG; //external symbols @@ -64,23 +65,13 @@ extern Process *boardObjMan; extern u16 HuPadBtnDown[4]; //function signatures -s32 BoardModelMotionShiftSet(s16, s32, f32, f32, u32); s32 BoardVecDAngleCalcRange(float *value, float min, float range); void BoardCameraQuakeSet(s32 duration, float strength); s16 MGSeqCreate(s32, ...); u8 MGSeqStatGet(s16); -f32 BoardPlayerRotYGet(s32); -f32 BoardModelMotionTimeGet(s16); s32 BoardVecMinDistCheck(Vec *vec1, Vec *vec2, float min_dist); -s32 BoardModelScaleGet(s16 model, Vec *dst); -s32 BoardModelMotionTimeSet(s16 model, float time); -s32 BoardDAngleCalcRange(float *value, float min, float range); -u32 BoardRandMod(u32 value); -void BoardModelMotionStartEndSet(s16, s32, s32); void Hu3DModelObjPosGet(s16 arg0, char *arg1, Vec *arg2); -s32 BoardModelPosGet(s16 model, Vec *dst); s16 Hu3DMotionShiftIDGet(s16 arg0); -f32 BoardPlayerMotionTimeGet(s32); s32 frand(void); void fn_1_BE30(s32 arg0, ParticleData* arg1); @@ -654,7 +645,7 @@ void fn_1_B0A4(s32 arg0) { temp_r30->unk00_bit4 = arg0; for (i = 0; i < 3;) { - spC[i] = BoardRandMod(14); + spC[i] = BoardRandMod(14); if ((spC[i] != 10) && (spC[i] != 13)) { for (j = 0; j < i; j++) { if (spC[i] == spC[j]) { diff --git a/src/REL/w03Dll/river.c b/src/REL/w03Dll/river.c index 64b99a24..b77ebef2 100644 --- a/src/REL/w03Dll/river.c +++ b/src/REL/w03Dll/river.c @@ -3,6 +3,7 @@ #include "REL/w03Dll.h" #include "board_unsplit.h" #include "game/board/main.h" +#include "game/board/model.h" #include "game/board/player.h" double sin(double x); @@ -10,14 +11,8 @@ double cos(double x); double atan2(double y, double x); s16 BoardModelIDGet(s16 model); void Hu3DModelObjPosGet(s16 arg0, char *arg1, Vec *arg2); -float BoardModelMotionTimeGet(s16 model); -s32 BoardModelMotionShiftSet(s16 model, s32 motion, float time, float shift_time, u32 attr); -void BoardPlayerPosSet(s32, f32, f32, f32); -s32 BoardModelHookSet(s16 model, char *name, s16 hook); -#define OM_GET_WORK_PTR(object, type) ((type *)(&((object)->work[0]))) - extern s16 lbl_1_bss_C[14]; extern s16 boardPlayerMdl[4]; @@ -244,9 +239,7 @@ s32 fn_1_6898(s32 arg0) { return 1; } -float BoardModelRotYGet(s16 model); s32 BoardDAngleCalcRange(float *value, float min, float range); -float BoardModelRotYGet(s16 model); void fn_1_6B98(s32 arg0) { Vec sp30; diff --git a/src/REL/w03Dll/smoke.c b/src/REL/w03Dll/smoke.c index 65a1088e..c9731903 100644 --- a/src/REL/w03Dll/smoke.c +++ b/src/REL/w03Dll/smoke.c @@ -3,6 +3,7 @@ #include "REL/w03Dll.h" #include "board_unsplit.h" #include "game/board/main.h" +#include "game/board/model.h" typedef struct w03UnkWorkStruct { s16 unk_00[5]; @@ -16,7 +17,6 @@ extern Process *boardObjMan; extern s16 lbl_1_data_1E0; void fn_1_79E0(omObjData* arg0); -f32 BoardModelMotionMaxTimeGet(s16); char kemuri1[] = "kemuri1"; char kemuri2[] = "kemuri2"; diff --git a/src/REL/w03Dll/statue.c b/src/REL/w03Dll/statue.c index 38273508..f5b5fd67 100644 --- a/src/REL/w03Dll/statue.c +++ b/src/REL/w03Dll/statue.c @@ -5,8 +5,9 @@ #include "game/gamework_data.h" #include "REL/w03Dll.h" #include "game/audio.h" -#include "game/board/space.h" +#include "game/board/model.h" #include "game/board/player.h" +#include "game/board/space.h" #include "game/board/ui.h" #include "board_unsplit.h" #include "game/hsfman.h" @@ -26,12 +27,7 @@ void fn_1_2AC0(void); void fn_1_2818(void); void fn_1_2A40(void); void fn_1_2B44(void); -s32 BoardDAngleCalcRange(f32*, f32, f32); -s32 BoardPlayerMotBlendCheck(s32); -f32 BoardPlayerRotYGet(s32); -void BoardConfettiCreate(Point3d*, s16, f32); double atan2(double y, double x); -f32 BoardModelMotionTimeGet(s16); //DATA s16 lbl_1_data_280 = -1; diff --git a/src/REL/w10Dll/host.c b/src/REL/w10Dll/host.c index ce7465a1..275264d2 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/model.h" #include "game/board/tutorial.h" #include "game/board/window.h" diff --git a/src/REL/w10Dll/main.c b/src/REL/w10Dll/main.c index 9bd9f796..c38b242f 100644 --- a/src/REL/w10Dll/main.c +++ b/src/REL/w10Dll/main.c @@ -1,6 +1,8 @@ #include "include/REL/w10Dll.h" #include "game/data.h" #include "game/hsfman.h" +#include "game/board/lottery.h" +#include "game/board/model.h" #include "game/board/star.h" #include "game/board/tutorial.h" diff --git a/src/REL/w10Dll/scene.c b/src/REL/w10Dll/scene.c index 881ea98b..0570fce7 100644 --- a/src/REL/w10Dll/scene.c +++ b/src/REL/w10Dll/scene.c @@ -1,5 +1,7 @@ #include "include/REL/w10Dll.h" +#include "game/board/lottery.h" #include "game/board/main.h" +#include "game/board/model.h" #include "game/board/star.h" #include "game/board/tutorial.h" #include "game/board/ui.h" @@ -185,7 +187,7 @@ void fn_1_13A4(void) { fn_1_C10(0); fn_1_BA0(0x2E002B); sp8.x = -33.0f; - sp8.y = sp8.z = 0.0f; + sp8.y = sp8.z = 0.0f; temp_r3_2 = BoardSpaceFlagSearch(0, 0x80000); BoardSpacePosGet(0, temp_r3_2, &sp14); BoardModelPosSetV(lbl_1_bss_0->unk8, &sp14); diff --git a/src/game/audio.c b/src/game/audio.c index ca9ddb0a..2a1e1dd5 100644 --- a/src/game/audio.c +++ b/src/game/audio.c @@ -190,7 +190,7 @@ void HuAudFXListnerSetEX(Vec* arg0, Vec* arg1, float sndDist, float sndSpeed, fl } } -void HuAudFXListnerUpdate(s32 arg0, s32 arg1) { +void HuAudFXListnerUpdate(Vec *arg0, Vec *arg1) { if (omSysExitReq == 0) { msmSeUpdataListener(arg0, arg1); } diff --git a/src/game/board/basic_space.c b/src/game/board/basic_space.c index 894f5e31..7dc7f24b 100644 --- a/src/game/board/basic_space.c +++ b/src/game/board/basic_space.c @@ -1,5 +1,6 @@ #include "game/board/basic_space.h" #include "game/board/main.h" +#include "game/board/model.h" #include "game/board/player.h" #include "game/board/tutorial.h" #include "game/data.h" @@ -37,7 +38,6 @@ static void CoinChgDisappear(omObjData*, coinChg*); extern void BoardCameraViewSet(s32); extern void BoardPlayerPosGet(s32, Vec*); -extern void BoardModelPosGet(s16, Vec*); extern void BoardPlayerMotionEndWait(s32); extern void BoardPlayerCoinsAdd(s32, s32); extern void BoardRotateDiceNumbers(s32); diff --git a/src/game/board/lottery.c b/src/game/board/lottery.c new file mode 100755 index 00000000..e08f6781 --- /dev/null +++ b/src/game/board/lottery.c @@ -0,0 +1,2013 @@ +#include "game/board/lottery.h" +#include "game/audio.h" +#include "game/chrman.h" +#include "game/data.h" +#include "game/esprite.h" +#include "game/gamework_data.h" +#include "game/hsfdraw.h" +#include "game/hsfex.h" +#include "game/hsfman.h" +#include "game/objsub.h" +#include "game/pad.h" +#include "game/process.h" +#include "game/sprite.h" +#include "game/board/audio.h" +#include "game/board/com.h" +#include "game/board/main.h" +#include "game/board/model.h" +#include "game/board/player.h" +#include "game/board/space.h" +#include "game/board/tutorial.h" +#include "game/board/ui.h" +#include "game/board/window.h" + +#include "math.h" + +#define ABS(x) (((x) < 0) ? -(x) : (x)) + +typedef struct { + struct { + u8 unk00_field0 : 1; + s8 unk00_field1 : 1; + u8 unk00_field2 : 4; + }; + u8 unk01; + s16 unk02; + s16 unk04; + char unk06[2]; + AnimData *unk08; +} TicketWork; + +typedef struct { + struct { + u8 unk00_field0 : 1; + }; + s8 unk01; + s8 unk02; + s8 unk03; + u8 unk04; + char unk05[1]; + s16 unk06; + s16 unk08; +} LotteryTicketPickWork; + +extern s32 BoardShopHostGet(void); + +static void CreateModel(void); +static void KillModel(void); +static void DestroyLottery(void); +static void ExecLottery(void); +static void DoMiniJumpUp(s32 arg0); +static void DoMiniJumpDown(s32 arg0); +static void PayEnterFee(s32 arg0); +static void ShowTicket(void); +static void SetupTicket(s32 arg0); +static void ExecBallGame(void); +static void SetBallPrize(void); +static void ExecBallPrize(void); +static void ExecScratchTicket(s32 arg0); +static void ExecScratch(void); +static void KillScratch(void); +static void ExecScratchSpr(omObjData *arg0); +static void HideScratchSpr(void); +static void InitScratchSpr(void); +static void ExecScratchPick(omObjData *arg0); +static void InitScratchPick(void); +static void InitTicketPrizes(void); +static void ExecTicketFocus(s32 arg0); +static BOOL ScratchTicketCheckDone(AnimBmpData *arg0); +static u16 TicketGetPixel(u16 arg0, u16 arg1, u16 arg2); +static s32 TicketUpdate(AnimBmpData *arg0, Vec *arg1, s32 arg2); +static void ExecCoinPrize(void); +static void ExecItemPrize(void); +static void KillCoin(void); +static void ExecPrize(void); +static void ExecLose(s32 arg0); +static void CreateLotteryWin(s32 arg0); +static void KillLotteryWin(void); + +static s16 lotteryMdl[6]; +static s8 coinF[12]; +static s16 coinMdl[10]; + +static s32 lotteryMessBase; +static s16 lotterySpace; +static s8 currPrize; +s8 lbl_801D401B; +static s8 comLotteryType; +static s8 comLotteryWinType; +static u8 comInputPos; +static s32 handUpdateF; +// ... +static omObjData *lotteryTicketPickObj; +static s8 (*comInputDrawP)[2]; +Process *lotteryProc; + +static s16 hostMdl = -1; +static s16 lotteryMot[4] = { -1, -1, -1, -1 }; +static s16 lotterySpr = -1; +static s16 lotteryInstWin = -1; +static s16 gripMdl[2] = { 0, 0 }; +static s16 turnMot = -1; +static s16 ballMdl[4] = { -1, -1, -1, -1 }; +static s16 loseMot = -1; +static s16 ticketSprGrp = -1; + +static s8 comInputDraw1[][2] = { + { 0x0B, 0xF8 }, { 0x2B, 0xDD }, { 0x2A, 0xDC }, { 0x2B, 0xDC }, + { 0x2B, 0xDC }, { 0x29, 0xDB }, { 0x24, 0xD6 }, { 0x02, 0xE8 }, + { 0x00, 0x00 }, { 0xFC, 0x02 }, { 0xD8, 0x27 }, { 0xD8, 0x28 }, + { 0xD8, 0x28 }, { 0xD8, 0x27 }, { 0xDA, 0x29 }, { 0xDE, 0x2C }, + { 0xE4, 0x31 }, { 0xF0, 0x3A }, { 0x00, 0x3C }, { 0x06, 0x3A }, + { 0x1B, 0x32 }, { 0x23, 0x2B }, { 0x24, 0x2A }, { 0x25, 0x29 }, + { 0x26, 0x29 }, { 0x28, 0x27 }, { 0x28, 0x27 }, { 0x28, 0x26 }, + { 0x28, 0x26 }, { 0x2E, 0x20 }, { 0x39, 0x11 }, { 0x48, 0x00 }, + { 0x48, 0x00 }, { 0x35, 0xEA }, { 0x29, 0xDB }, { 0x24, 0xD5 }, + { 0x17, 0xCB }, { 0x00, 0xB8 }, { 0x00, 0xB8 }, { 0x00, 0xB8 }, + { 0x00, 0xB8 }, { 0x00, 0xB8 }, { 0xEB, 0xCA }, { 0xD6, 0xDB }, + { 0xD6, 0xDB }, { 0xD4, 0xDE }, { 0xD1, 0xE2 }, { 0xC4, 0xF2 }, + { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xB8, 0x00 }, + { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xC1, 0x0B }, + { 0xC6, 0x10 }, { 0xC9, 0x14 }, { 0xCB, 0x16 }, { 0xCB, 0x17 }, + { 0xCE, 0x1A }, { 0xD1, 0x1E }, { 0xD5, 0x23 }, { 0xD4, 0x22 }, + { 0xDB, 0x29 }, { 0xF5, 0x3E }, { 0x00, 0x48 }, { 0x00, 0x42 }, + { 0x0D, 0x3D }, { 0x24, 0x2A }, { 0x29, 0x26 }, { 0x29, 0x26 }, + { 0x29, 0x25 }, { 0x2D, 0x21 }, { 0x34, 0x18 }, { 0x40, 0x09 }, + { 0x48, 0x00 }, { 0x48, 0x00 }, { 0x43, 0xFA }, { 0x33, 0xE6 }, + { 0x29, 0xDB }, { 0x1B, 0xCF }, { 0x05, 0xBD }, { 0x00, 0xB8 }, + { 0x00, 0xB8 }, { 0x00, 0xB8 }, { 0xFB, 0xBD }, { 0xDD, 0xD5 }, + { 0xD6, 0xDC }, { 0xD6, 0xDC }, { 0xD4, 0xDE }, { 0xCB, 0xE9 }, + { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xC5, 0x0F }, + { 0xD0, 0x1D }, { 0xD5, 0x23 }, { 0xDC, 0x2A }, { 0xF0, 0x3B }, + { 0x00, 0x3D }, { 0x08, 0x3F }, { 0x15, 0x36 }, { 0x24, 0x2A }, + { 0x29, 0x26 }, { 0x2A, 0x24 }, { 0x30, 0x1C }, { 0x3B, 0x0F }, + { 0x48, 0x00 }, { 0x48, 0x00 }, { 0x3E, 0xF4 }, { 0x2D, 0xE0 }, + { 0x22, 0xD4 }, { 0x02, 0xBB }, { 0x00, 0xB8 }, { 0xFB, 0xBD }, + { 0xD9, 0xD8 }, { 0xD4, 0xDE }, { 0x7F, 0x7F } +}; + +static s8 comInputDraw2[][2] = { + { 0x07, 0x00 }, { 0x1F, 0x00 }, { 0x3A, 0x00 }, { 0x48, 0x00 }, + { 0x48, 0x00 }, { 0x48, 0x00 }, { 0x48, 0x00 }, { 0x48, 0x00 }, + { 0x43, 0xFA }, { 0x35, 0xEA }, { 0x2A, 0xDB }, { 0x1A, 0xCE }, + { 0x00, 0xB9 }, { 0x00, 0xB8 }, { 0x00, 0xB8 }, { 0x00, 0xB8 }, + { 0x00, 0xBA }, { 0xE9, 0xCC }, { 0xD5, 0xDD }, { 0xD4, 0xDE }, + { 0xD4, 0xDE }, { 0xD0, 0xE3 }, { 0xBD, 0xFB }, { 0xB8, 0x00 }, + { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xB8, 0x00 }, + { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xBC, 0x03 }, { 0xC2, 0x0C }, + { 0xCB, 0x17 }, { 0xD5, 0x23 }, { 0xD8, 0x27 }, { 0xF0, 0x3A }, + { 0x00, 0x43 }, { 0x18, 0x34 }, { 0x29, 0x26 }, { 0x29, 0x26 }, + { 0x29, 0x26 }, { 0x29, 0x25 }, { 0x29, 0x26 }, { 0x29, 0x25 }, + { 0x29, 0x25 }, { 0x2C, 0x22 }, { 0x31, 0x1B }, { 0x39, 0x12 }, + { 0x47, 0x00 }, { 0x48, 0x00 }, { 0x48, 0x00 }, { 0x37, 0xEC }, + { 0x26, 0xD7 }, { 0x00, 0xB8 }, { 0x00, 0xB8 }, { 0x00, 0xB8 }, + { 0x00, 0xB8 }, { 0x00, 0xB8 }, { 0x00, 0xB8 }, { 0xFB, 0xBD }, + { 0xE5, 0xCE }, { 0xD6, 0xDC }, { 0xD6, 0xDC }, { 0xD6, 0xDC }, + { 0xD5, 0xDD }, { 0xD2, 0xE0 }, { 0xCC, 0xE8 }, { 0xC4, 0xF2 }, + { 0xBE, 0xFA }, { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xB8, 0x00 }, + { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xB8, 0x00 }, + { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xB8, 0x00 }, + { 0xC7, 0x12 }, { 0xD8, 0x27 }, { 0xF6, 0x3E }, { 0x00, 0x47 }, + { 0x00, 0x44 }, { 0x05, 0x42 }, { 0x16, 0x35 }, { 0x28, 0x27 }, + { 0x29, 0x26 }, { 0x29, 0x26 }, { 0x29, 0x26 }, { 0x29, 0x26 }, + { 0x7F, 0x7F } +}; + +static s8 comInputBall[][2] = { + { 0xE5, 0x00 }, { 0xC0, 0x03 }, { 0xBC, 0x04 }, { 0xBC, 0x03 }, + { 0xBF, 0x07 }, { 0xC3, 0x0C }, { 0xCB, 0x17 }, { 0xD5, 0x24 }, + { 0xDE, 0x2C }, { 0xF9, 0x3E }, { 0x00, 0x48 }, { 0x00, 0x45 }, + { 0x06, 0x40 }, { 0x21, 0x2C }, { 0x28, 0x27 }, { 0x28, 0x26 }, + { 0x29, 0x25 }, { 0x30, 0x1D }, { 0x43, 0x05 }, { 0x48, 0x00 }, + { 0x33, 0xE7 }, { 0x24, 0xD6 }, { 0x07, 0xBF }, { 0x00, 0xB8 }, + { 0x00, 0xB8 }, { 0xE4, 0xCF }, { 0xD4, 0xDE }, { 0xC6, 0xF0 }, + { 0xB8, 0x00 }, { 0xC7, 0x11 }, { 0xD2, 0x20 }, { 0xD5, 0x24 }, + { 0xD6, 0x25 }, { 0xD8, 0x27 }, { 0xE1, 0x2E }, { 0x00, 0x43 }, + { 0x00, 0x48 }, { 0x00, 0x44 }, { 0x1D, 0x30 }, { 0x28, 0x27 }, + { 0x28, 0x27 }, { 0x2C, 0x22 }, { 0x39, 0x12 }, { 0x48, 0x00 }, + { 0x34, 0xE8 }, { 0x23, 0xD5 }, { 0x0A, 0xC1 }, { 0x00, 0xB8 }, + { 0x00, 0xB8 }, { 0xF4, 0xC3 }, { 0xD4, 0xDE }, { 0xC3, 0xF4 }, + { 0xB8, 0x00 }, { 0xC6, 0x10 }, { 0xD3, 0x21 }, { 0xD6, 0x25 }, + { 0xD8, 0x27 }, { 0xDF, 0x2D }, { 0xEA, 0x36 }, { 0x00, 0x48 }, + { 0x00, 0x48 }, { 0x00, 0x48 }, { 0x17, 0x35 }, { 0x28, 0x27 }, + { 0x29, 0x25 }, { 0x33, 0x19 }, { 0x48, 0x00 }, { 0x48, 0x00 }, + { 0x34, 0xE8 }, { 0x23, 0xD5 }, { 0x00, 0xB9 }, { 0x00, 0xB8 }, + { 0x00, 0xB8 }, { 0xFA, 0xBE }, { 0xD4, 0xDE }, { 0xC8, 0xED }, + { 0xB8, 0x00 }, { 0xB8, 0x00 }, { 0xC0, 0x09 }, { 0xD0, 0x1C }, + { 0xD6, 0x24 }, { 0xDC, 0x2A }, { 0xED, 0x38 }, { 0x00, 0x48 }, + { 0x00, 0x48 }, { 0x00, 0x48 }, { 0x1B, 0x31 }, { 0x28, 0x27 }, + { 0x29, 0x26 }, { 0x2D, 0x21 }, { 0x3D, 0x0C }, { 0x48, 0x00 }, + { 0x33, 0xE7 }, { 0x20, 0xD3 }, { 0x00, 0xB8 }, { 0x00, 0xB8 }, + { 0x00, 0xBB }, { 0xDB, 0xD7 }, { 0xD4, 0xDE }, { 0xD3, 0xDF }, + { 0xBB, 0xFD }, { 0xB8, 0x00 }, { 0x7F, 0x7F } +}; + +void BoardLotteryHostSet(s16 arg0) { + hostMdl = arg0; +} + +s16 BoardLotteryHostGet(void) { + return hostMdl; +} + +void BoardLotteryExec(void) { + if (BoardPlayerSizeGet(GWSystem.player_curr) == 2) { + return; + } + BoardDiceDigit2DShowSet(0); + lotteryProc = HuPrcChildCreate(ExecLottery, 0x2003, 0x3800, 0, boardMainProc); + HuPrcDestructorSet2(lotteryProc, DestroyLottery); + while (lotteryProc) { + HuPrcVSleep(); + } + BoardDiceDigit2DShowSet(1); +} + +void BoardLotteryInit(void) { + Vec sp14; + Vec sp8; + s32 i; + + for (i = 0; i < 5; i++) { + lotteryMdl[i] = -1; + } + for (i = 0; i < 4; i++) { + lotteryMot[i] = -1; + } + for (i = 0; i < 4; i++) { + ballMdl[i] = -1; + } + turnMot = -1; + loseMot = -1; + if (GWBoardGet() != 8) { + BoardModelVisibilitySet(BoardLotteryHostGet(), 0); + BoardSpaceLinkTransformGet(0x10000000, &sp14, &sp8, NULL); + lotteryMdl[0] = BoardModelCreate(0x50000, NULL, 0); + BoardModelMotionStart(lotteryMdl[0], 0, 0); + BoardModelMotionSpeedSet(lotteryMdl[0], 0.0f); + BoardModelPosSetV(lotteryMdl[0], &sp14); + BoardModelRotSetV(lotteryMdl[0], &sp8); + HuDataDirClose(0x50000); + } +} + +static void CreateModel(void) { + s32 i; + s32 sp10[4] = { 0x00050005, 0x00050006, 0x00050007, 0x00050008 }; + s32 sp8[2] = { 0x00050003, 0x00050004 }; + s32 sp20[9][4] = { + { 0x00020001, 0x00020002, 0x00020003, 0x00020004 }, + { 0x00020009, 0x0002000A, 0x0002000B, 0x0002000C }, + { 0x0002000E, 0x0002000F, 0x00020010, 0x00020011 }, + { 0x00020018, 0x00020019, 0x0002001A, 0x0002001B }, + { 0x0002001D, 0x0002001E, 0x0002001F, 0x00020020 }, + { 0x00020022, 0x00020023, 0x00020024, 0x00020025 }, + { 0x0002000E, 0x0002000F, 0x00020010, 0x00020011 }, + { 0x0002002A, 0x0002002B, 0x0002002C, 0x0002002D }, + { 0x0002002A, 0x0002002B, 0x0002002C, 0x0002002D } + }; + + lotteryMdl[1] = BoardModelCreate(0x50001, NULL, 0); + fn_8006DDE8(lotteryMdl[1], -1.0f); + BoardModelMotionSpeedSet(lotteryMdl[1], 0.0f); + lotteryMdl[2] = BoardModelCreate(0x50002, NULL, 0); + BoardModelVisibilitySet(lotteryMdl[2], 0); + fn_8006DDE8(lotteryMdl[2], -1.0f); + BoardModelMotionStart(lotteryMdl[2], 0, 0); + BoardModelMotionSpeedSet(lotteryMdl[2], 0.0f); + for (i = 0; i < 4; i++) { + ballMdl[i] = BoardModelCreate(sp10[i], NULL, 0); + BoardModelVisibilitySet(ballMdl[i], 0); + fn_8006DDE8(ballMdl[i], -1.0f); + } + for (i = 0; i < 2; i++) { + gripMdl[i] = BoardModelCreate(sp8[i], NULL, 0); + BoardModelVisibilitySet(gripMdl[i], 0); + fn_8006DDE8(gripMdl[i], -1.0f); + BoardModelMotionSpeedSet(gripMdl[i], 0.0f); + } + lotteryMdl[3] = BoardModelCreate(0x50011, NULL, 0); + BoardModelVisibilitySet(lotteryMdl[3], 0); + fn_8006DDE8(lotteryMdl[3], -1.0f); + BoardModelPosSet(BoardLotteryHostGet(), 0.0f, 0.0f, 0.0f); + BoardModelVisibilitySet(BoardLotteryHostGet(), 1); + for (i = 0; i < 4; i++) { + lotteryMot[i] = BoardModelMotionCreate(BoardLotteryHostGet(), sp20[GWBoardGet()][i]); + } + BoardModelMotionStart(BoardLotteryHostGet(), lotteryMot[0], 0x40000001); + BoardModelHookSet(lotteryMdl[0], "toto_heyhoo", BoardLotteryHostGet()); + BoardModelHookSet(lotteryMdl[0], "toto_gara", lotteryMdl[1]); + BoardModelHookSet(lotteryMdl[0], "toto_efe", lotteryMdl[2]); + BoardModelHookSet(lotteryMdl[0], "toto_chibidai", lotteryMdl[3]); + BoardModelHookSet(lotteryMdl[1], "toto_grip", gripMdl[0]); + BoardModelHookSet(lotteryMdl[1], "toto_grip1", gripMdl[1]); +} + +static void KillModel(void) { + s32 i; + + if (lotteryMdl[1] != -1) { + BoardModelHookReset(lotteryMdl[0]); + } + BoardModelMotionStart(BoardLotteryHostGet(), 1, 0x40000001); + if (turnMot != -1) { + BoardPlayerMotionKill(GWSystem.player_curr, turnMot); + turnMot = -1; + } + for (i = 0; i < 4; i++) { + if (lotteryMot[i] != -1) { + BoardModelMotionKill(BoardLotteryHostGet(), lotteryMot[i]); + lotteryMot[i] = -1; + } + } + for (i = 0; i < 4; i++) { + if (ballMdl[i] != -1) { + BoardModelKill(ballMdl[i]); + ballMdl[i] = -1; + } + } + for (i = 0; i < 2; i++) { + if (gripMdl[i] != -1) { + BoardModelKill(gripMdl[i]); + gripMdl[i] = -1; + } + } + for (i = 0; i < 5; i++) { + if (i != 0 && lotteryMdl[i] != -1) { + BoardModelKill(lotteryMdl[i]); + lotteryMdl[i] = -1; + } + } + BoardModelVisibilitySet(BoardLotteryHostGet(), 0); +} + +void BoardLotteryKill(void) { + if (lotteryProc) { + HuPrcKill(lotteryProc); + } + if (lotteryMdl[0] != -1) { + BoardModelKill(lotteryMdl[0]); + lotteryMdl[0] = -1; + } +} + +static void DestroyLottery(void) { + s32 i; + + for (i = 0; i < 4; i++) { + if (i != GWSystem.player_curr) { + BoardPlayerMotBlendSet(i, 0, 7); + } + } + if (loseMot != -1) { + BoardPlayerMotionKill(GWSystem.player_curr, loseMot); + loseMot = -1; + } + KillLotteryWin(); + BoardConfettiKill(); + BoardWinKill(); + KillScratch(); + KillCoin(); + HuDataDirClose(0x50000); + lotteryProc = NULL; +} + +static void ExecLottery(void) { + Vec sp38; + Vec sp2C; + Vec sp20; + Vec sp14; + Vec sp8; + s16 temp_r26; + s16 temp_r28; + u32 var_r25; + s32 var_r27; + s32 temp_r31; + s32 i; + s32 temp_r29; + + switch (GWBoardGet()) { + case 0: + lotteryMessBase = 0x60002; + break; + case 1: + lotteryMessBase = 0x6000F; + break; + case 2: + lotteryMessBase = 0x6001C; + break; + case 3: + lotteryMessBase = 0x60029; + break; + case 4: + lotteryMessBase = 0x60036; + break; + case 5: + lotteryMessBase = 0x60043; + break; + case 6: + lotteryMessBase = 0x60002; + break; + case 7: + lotteryMessBase = 0x60052; + break; + case 8: + lotteryMessBase = 0x60052; + break; + } + temp_r29 = BoardDataDirReadAsync(0x50000); + temp_r31 = GWSystem.player_curr; + temp_r28 = GWPlayer[temp_r31].space_curr; + BoardRotateDiceNumbers(temp_r31); + BoardWinCreateChoice(0, 0x60000, -1, 0); + if (GWPlayer[temp_r31].com) { + if (BoardPlayerCoinsGet(temp_r31) >= 5) { + BoardComKeySetLeft(); + } else { + BoardComKeySetRight(); + } + } + BoardWinWait(); + if (BoardWinChoiceGet() != 0) { + if (temp_r29 != -1) { + BoardDataAsyncWait(temp_r29); + } + HuPrcEnd(); + } + if (BoardPlayerCoinsGet(temp_r31) < 5) { + BoardWinCreate(0, 0x60001, -1); + BoardWinWait(); + BoardWinKill(); + if (temp_r29 != -1) { + BoardDataAsyncWait(temp_r29); + } + HuPrcEnd(); + } + BoardWinKill(); + if (temp_r29 != -1) { + BoardDataAsyncWait(temp_r29); + } + BoardModelMotionStart(BoardLotteryHostGet(), 1, 0x40000001); + BoardAudSeqPause(0, 1, 1000); + CreateModel(); + BoardStatusShowSetAll(0); + lotterySpace = BoardSpaceLinkFlagSearch(0, temp_r28, 0x02000000); + BoardSpacePosGet(0, temp_r28, &sp38); + BoardSpacePosGet(0, lotterySpace, &sp2C); + PSVECSubtract(&sp2C, &sp38, &sp20); + if (GWBoardGet() == 2 || GWBoardGet() == 3) { + PSVECScale(&sp20, &sp20, 0.95f); + PSVECAdd(&sp20, &sp38, &sp2C); + } + temp_r26 = 180.0 * (atan2(-sp20.x, -sp20.z) / M_PI); + if (BoardPlayerSizeGet(temp_r31) == 1) { + BoardModelVisibilitySet(gripMdl[0], 0); + BoardModelVisibilitySet(gripMdl[1], 1); + } else { + BoardModelVisibilitySet(gripMdl[0], 1); + BoardModelVisibilitySet(gripMdl[1], 0); + } + sp14.x = -3.0f; + sp14.y = temp_r26; + sp14.z = 0.0f; + sp8.x = 0.0f; + sp8.y = 200.0f; + sp8.z = 0.0f; + BoardCameraMotionStartEx(lotteryMdl[0], &sp14, &sp8, 1300.0f, -1.0f, 0x1B); + if (BoardPlayerSizeGet(temp_r31) == 1) { + BoardModelVisibilitySet(lotteryMdl[3], 1); + } + omVibrate(temp_r31, 0xC, 6, 6); + HuAudFXPlay(0x331); + HuAudFXPlay(0x344); + BoardModelMotionStart(lotteryMdl[0], 0, 0); + while (!BoardModelMotionEndCheck(lotteryMdl[0])) { + HuPrcVSleep(); + } + BoardModelMotionShiftSet(BoardLotteryHostGet(), lotteryMot[3], 0.0f, 10.0f, 0); + BoardPlayerRotSet(temp_r31, 0.0f, temp_r26, 0.0f); + BoardPlayerPosLerpStart(temp_r31, &sp38, &sp2C, 0x14); + while (GWPlayer[temp_r31].moving) { + HuPrcVSleep(); + } + if (BoardPlayerSizeGet(temp_r31) == 1) { + DoMiniJumpUp(temp_r31); + } + BoardPlayerPosGet(temp_r31, &sp2C); + for (i = 0; i < 4; i++) { + if (i != temp_r31) { + BoardPlayerPosGet(i, &sp38); + PSVECSubtract(&sp2C, &sp38, &sp20); + PSVECNormalize(&sp20, &sp20); + BoardPlayerMotBlendSet(i, 180.0 * (atan2(sp20.x, sp20.z) / M_PI), 7); + } + } + BoardMusStart(1, 2, 0x7F, 0); + BoardRotateDiceNumbers(temp_r31); + while (!BoardStatusStopCheck(temp_r31)) { + HuPrcVSleep(); + } + BoardModelMotionShiftSet(BoardLotteryHostGet(), lotteryMot[0], 0.0f, 10.0f, 0x40000001); + if (GWPlayer[temp_r31].field00_bit9 == 0 && GWSystem.max_turn - GWSystem.turn >= 5) { + SetupTicket(temp_r31); + ShowTicket(); + var_r27 = 1; + } else { + var_r27 = 0; + } + if (GWBoardGet() == 7 || GWBoardGet() == 8) { + var_r27 = 0; + } + PayEnterFee(var_r27); + var_r25 = BoardRandMod(100) & 0xFF; + if (var_r25 < 50) { + ExecBallGame(); + } else { + ExecScratch(); + } + ExecPrize(); + if (BoardPlayerSizeGet(temp_r31) == 1) { + DoMiniJumpDown(temp_r31); + } + BoardPlayerMoveBetween(temp_r31, lotterySpace, temp_r28); + while (GWPlayer[temp_r31].moving) { + HuPrcVSleep(); + } + BoardRotateDiceNumbers(temp_r31); + BoardModelVisibilitySet(ballMdl[currPrize & 3], 0); + BoardAudSeqFadeOut(1, 1000); + BoardCameraTargetPlayerSet(temp_r31); + BoardCameraViewSet(1); + BoardStatusShowSet(temp_r31, 0); + BoardModelMotionStart(lotteryMdl[0], 0, 0x40000004); + while (!BoardModelMotionEndCheck(lotteryMdl[0])) { + HuPrcVSleep(); + } + BoardModelMotionSpeedSet(lotteryMdl[0], 0.0f); + BoardModelAttrReset(lotteryMdl[0], 0x40000004); + HuAudFXPlay(0x32F); + KillModel(); + BoardStatusShowSetAll(1); + BoardAudSeqPause(0, 0, 1000); + HuPrcEnd(); +} + +static void DoMiniJumpUp(s32 arg0) { + Mtx sp34; + Vec sp28; + Vec sp1C; + Vec sp10; + float temp_f29; + float temp_f30; + float var_f27; + s16 var_r27; + s16 temp_r26; + s16 i; + + var_r27 = BoardModelIDGet(lotteryMdl[0]); + Hu3DModelObjMtxGet(var_r27, "toto_chibidai", sp34); + Hu3DMtxTransGet(sp34, &sp28); + BoardPlayerMotionStart(arg0, 4, 0); + temp_f29 = BoardPlayerMotionMaxTimeGet(arg0); + BoardPlayerPosGet(arg0, &sp1C); + sp28.y += 52.5308f; + PSVECSubtract(&sp28, &sp1C, &sp10); + sp10.x /= temp_f29; + sp10.z /= temp_f29; + sp10.y /= temp_f29; + OSf32tos16(&temp_f29, &temp_r26); + for (i = 0; i < temp_r26; i++) { + OSs16tof32(&i, &temp_f30); + if (i < 4) { + var_f27 = 5.0f; + } else { + var_f27 = 0.0f; + } + sp1C.x += sp10.x; + sp1C.y += sp10.y + var_f27 - 0.016666668f * temp_f30 * temp_f30; + sp1C.z += sp10.z; + BoardPlayerPosSetV(arg0, &sp1C); + HuPrcVSleep(); + } + sp1C.y = sp28.y; + BoardPlayerPosSetV(arg0, &sp1C); + BoardRotateDiceNumbers(arg0); +} + +static void DoMiniJumpDown(s32 arg0) { + Vec sp24; + Vec sp18; + Vec spC; + float temp_f31; + float var_f29; + s16 i; + + BoardPlayerPosGet(arg0, &sp18); + BoardSpacePosGet(0, lotterySpace, &sp24); + PSVECSubtract(&sp24, &sp18, &spC); + BoardPlayerMotionStart(arg0, 4, 0); + spC.x /= 30.0f; + spC.z /= 30.0f; + for (i = 0; i < 30; i++) { + OSs16tof32(&i, &temp_f31); + if (i < 3) { + var_f29 = 10.0f; + } else { + var_f29 = 0.0f; + } + sp18.x += spC.x; + sp18.y += var_f29 + -0.016666668f * temp_f31 * temp_f31 * 0.75f; + sp18.z += spC.z; + if (sp24.y > sp18.y) { + sp18.y = sp24.y; + break; + } + BoardPlayerPosSetV(arg0, &sp18); + HuPrcVSleep(); + } + BoardPlayerMotionStart(arg0, 5, 0); + BoardPlayerPosSetV(arg0, &sp24); + while (!BoardPlayerMotionEndCheck(arg0)) { + HuPrcVSleep(); + } +} + +static void PayEnterFee(s32 arg0) { + s32 var_r29; + s32 temp_r31; + s32 i; + + temp_r31 = GWSystem.player_curr; + BoardStatusShowSetForce(temp_r31); + BoardStatusShowSet(temp_r31, 1); + if (arg0 != 0) { + var_r29 = lotteryMessBase + 0xC; + } else { + var_r29 = lotteryMessBase; + } + BoardWinCreate(2, var_r29, BoardWinPortraitGet()); + BoardWinWait(); + BoardWinKill(); + while (!BoardStatusStopCheck(temp_r31)) { + HuPrcVSleep(); + } + for (i = 0; i < 5; i++) { + BoardPlayerCoinsAdd(temp_r31, -1); + HuAudFXPlay(0xE); + HuPrcSleep(6); + } + HuAudFXPlay(0xF); + BoardStatusShowSet(temp_r31, 0); +} + +static void ShowTicket(void) { + s16 sp10; + s16 spE; + s16 spC; + s16 spA; + s8 sp8; + float var_f31; + s16 temp_r31; + s32 var_r29; + s32 i; + u8 *var_r28; + s32 sp14[] = { + 0x00050015, + 0x00050016, + 0x00050017, + 0x00050018, + 0x00050019, + 0x0005001A, + 0x0005001B, + 0x0005001C + }; + + if (GWBoardGet() == 7 || GWBoardGet() == 8) { + return; + } + sp8 = GWPlayer[GWSystem.player_curr].field00_bitA; + var_r28 = (u8*) &sp8; + temp_r31 = HuSprGrpCreate(4); + BoardSpriteCreate(0x50014, 0x7531, 0, &spA); + HuSprGrpMemberSet(temp_r31, 0, spA); + HuSprAttrSet(temp_r31, 0, 9); + HuSprPosSet(temp_r31, 0, 288.0f, 240.0f); + HuSprTPLvlSet(temp_r31, 0, 0.0f); + var_r29 = GWPlayer[(*var_r28 >> 4) & 3].character; + BoardSpriteCreate(sp14[var_r29], 0x7530, 0, &spC); + HuSprGrpMemberSet(temp_r31, 1, spC); + HuSprAttrSet(temp_r31, 1, 9); + HuSprPosSet(temp_r31, 1, 200.0f, 237.0f); + HuSprTPLvlSet(temp_r31, 1, 0.0f); + var_r29 = GWPlayer[(*var_r28 >> 2) & 3].character; + BoardSpriteCreate(sp14[var_r29], 0x7530, 0, &spE); + HuSprGrpMemberSet(temp_r31, 2, spE); + HuSprAttrSet(temp_r31, 2, 9); + HuSprPosSet(temp_r31, 2, 294.0f, 237.0f); + HuSprTPLvlSet(temp_r31, 2, 0.0f); + var_r29 = GWPlayer[*var_r28 & 3].character; + BoardSpriteCreate(sp14[var_r29], 0x7530, 0, &sp10); + HuSprGrpMemberSet(temp_r31, 3, sp10); + HuSprAttrSet(temp_r31, 3, 9); + HuSprPosSet(temp_r31, 3, 388.0f, 237.0f); + HuSprTPLvlSet(temp_r31, 3, 0.0f); + BoardWinCreate(2, lotteryMessBase + 10, BoardWinPortraitGet()); + BoardWinWait(); + for (var_f31 = 0.0f; var_f31 <= 1.0f; var_f31 += 0.15f) { + if (var_f31 >= 1.0f) { + var_f31 = 1.0f; + } + for (i = 0; i < 4; i++) { + HuSprTPLvlSet(temp_r31, i, var_f31); + } + HuPrcVSleep(); + } + BoardWinCreate(2, lotteryMessBase + 11, BoardWinPortraitGet()); + BoardWinWait(); + BoardWinKill(); + for (var_f31 = 1.0f; var_f31 > 0.0f; var_f31 -= 0.15f) { + if (var_f31 < 0.0f) { + var_f31 = 0.0f; + } + for (i = 0; i < 4; i++) { + HuSprTPLvlSet(temp_r31, i, var_f31); + } + HuPrcVSleep(); + } + HuSprGrpKill(temp_r31); + (void) var_r29; // Required to match +} + +static void SetupTicket(s32 arg0) { + u8 sp8[4]; + u8 var_r29; + s32 var_r28; + s32 var_r30; + s32 var_r31; + + for (var_r30 = var_r31 = 0; var_r31 < 4; var_r31++) { + if (arg0 != var_r31 && GWPlayer[var_r31].field00_bit9 != 0) { + sp8[var_r30] = GWPlayer[var_r31].field00_bitA; + var_r30++; + } + } + for (var_r28 = 0; var_r28 < 1000; var_r28++) { + var_r29 = BoardRandMod(0x40) & 0x3F; + for (var_r31 = 0; var_r30 != 0 && var_r31 < var_r30; var_r31++) { + if (sp8[var_r31] == var_r29) { + var_r29 = 0x80; + break; + } + } + if (var_r29 != 0x80) { + break; + } + } + GWPlayer[arg0].field00_bitA = var_r29; + GWPlayer[arg0].field00_bit9 = 1; +} + +static void LotteryInlineFunc00(s32 arg0, s32 arg1) { + s32 sp20[2] = { 0x00050012, 0x00050013 }; + s16 sp10[2] = { 0x0098, 0x0078 }; + s16 sp14[2] = { 0x0078, 0x0078 }; + Vec sp34; + float temp_f30; + s16 var_r30; + + sp34.x = (sp14[arg0] / 2) + 32; + if (arg1 == 0) { + sp34.y = -sp10[arg0] / 2; + temp_f30 = 4.0f; + if (lotterySpr == -1) { + lotterySpr = espEntry(sp20[arg0], 0x7531, 0); + espAttrSet(lotterySpr, 1); + } + } else { + sp34.y = (sp10[arg0] / 2) + 40; + temp_f30 = -4.0f; + } + for (var_r30 = sp10[arg0] + 40; var_r30 > 0; var_r30 -= 4) { + sp34.y += temp_f30; + espPosSet(lotterySpr, sp34.x, sp34.y); + HuPrcVSleep(); + } + if (arg1 != 0 && lotterySpr >= 0) { + espKill(lotterySpr); + lotterySpr = -1; + } +} + +static void ExecBallGame(void) { + Vec sp4C; + float temp_f24; + float var_f23; + float var_f25; + float var_f26; + float var_f27; + float var_f19; + float var_f28; + s32 var_r22; + s32 var_r21; + s32 var_r20 = 0; + s32 temp_r25; + s32 var_r24; + s32 temp_r27; + u8 var_r26; + s8 var_r17; + s8 spB; + s8 spA; + s8 sp9; + s8 *temp_r23; + s32 sp58[] = { + 0x005F001D, + 0x001A001D, + 0x006D001D, + 0x008A001D, + 0x0085001D, + 0x0011001D, + 0x000D001D, + 0x0081001D + }; + + temp_r27 = GWSystem.player_curr; + currPrize = -1; + sp4C.x = 0.0f; + sp4C.y = 210.0f; + sp4C.z = 0.0f; + BoardCameraMotionStartEx(lotteryMdl[0], NULL, &sp4C, 980.0f, -1.0f, 0x15); + LotteryInlineFunc00(0, 0); + BoardCameraMotionWait(); + BoardWinCreate(2, lotteryMessBase + 1, BoardWinPortraitGet()); + BoardWinWait(); + BoardWinKill(); + HuPrcSleep(0x12); + CreateLotteryWin(0); + turnMot = BoardPlayerMotionCreate(temp_r27, sp58[GWPlayer[temp_r27].character]); + BoardPlayerMotionSpeedSet(temp_r27, 0.0f); + BoardModelAttrSet(lotteryMdl[1], 0x40000001); + BoardModelMotionSpeedSet(lotteryMdl[1], 0.0f); + BoardModelMotionTimeSet(lotteryMdl[1], 0.0f); + BoardModelAttrSet(gripMdl[0], 0x40000001); + BoardModelAttrSet(gripMdl[1], 0x40000001); + BoardPlayerMotionShiftSet(temp_r27, turnMot, 0.0f, 8.0f, 0x40000001); + BoardPlayerMotionSpeedSet(temp_r27, 0.0f); + temp_f24 = BoardModelMotionMaxTimeGet(lotteryMdl[1]); + temp_f24 -= 4.0f; + comInputPos = 0; + var_r20 = 0; + spB = spA = sp9 = var_r17 = 0; + var_r26 = var_f28 = var_f27 = var_f25 = var_f23 = var_r21 = 0; + HuPrcSleep(0x18); + var_r24 = var_r22 = 0; + while (1) { + HuPrcVSleep(); + BoardModelMotionSpeedSet(lotteryMdl[1], var_f28); + BoardModelMotionSpeedSet(gripMdl[0], var_f28); + BoardModelMotionSpeedSet(gripMdl[1], var_f28); + BoardPlayerMotionSpeedSet(temp_r27, var_f28); + if (var_r22 != 0 && var_f28 <= 0.1f) { + BoardModelMotionSpeedSet(lotteryMdl[1], 0.0f); + BoardModelMotionSpeedSet(gripMdl[0], 0.0f); + BoardModelMotionSpeedSet(gripMdl[1], 0.0f); + BoardPlayerMotionSpeedSet(temp_r27, 0.0f); + break; + } + if (var_r24 == 0) { + if (BoardModelMotionTimeGet(lotteryMdl[1]) >= temp_f24) { + var_r21++; + if ((var_r26++) != 0 || var_r21 >= 1 || var_r20 != 0) { + var_r22 = 1; + if (currPrize == -1) { + var_f27 *= 128.0f; + OSf32tos8(&var_f27, &lbl_801D401B); + SetBallPrize(); + } + } + var_r24 = 1; + } + } + if (var_r24 != 0 && BoardModelMotionTimeGet(lotteryMdl[1]) < 2.0f) { + var_r24 = 0; + } + if (var_r22 == 0) { + var_r17 = spB; + sp9 = spA; + if (!GWPlayer[temp_r27].com) { + temp_r25 = GWPlayer[temp_r27].port; + spB = HuPadStkX[temp_r25]; + spA = HuPadStkY[temp_r25]; + } else { + temp_r23 = comInputBall[comInputPos++]; + spB = temp_r23[0]; + spA = temp_r23[1]; + } + } else { + spB = spA = 0; + } + if (spB == 0x7F || spA == 0x7F) { + var_r20 = 1; + } else { + if ((abs(spB) < 57.600002f && abs(spA) < 57.600002f) || (var_r17 == spB && sp9 == spA) || (spB == 0 && spA == 0)) { + var_f28 *= 0.93f; + var_f27 *= 0.8f; + if (var_f27 < 0.01f && var_r26 != 0) { + var_r26--; + } + } else { + OSs8tof32(&spB, &var_f26); + OSs8tof32(&spA, &var_f19); + var_f25 = 180.0 * (atan2(var_f26, var_f19) / M_PI); + if (var_f25 < 0.0f) { + var_f25 += 360.0f; + } + if (var_f25 < 20.0f) { + HuAudFXPlay(0x333); + } + var_f26 = var_f25 - var_f23; + if (!(var_f26 < 0.0f)) { + if (ABS(var_f26) > 30.0f) { + var_f26 = 10.0f; + } + var_f27 += 0.01f * var_f26; + if (var_f28 + var_f27 < 2.0f) { + var_f28 += var_f27; + } else { + var_f28 = 2.0f; + } + } + } + } + var_f23 = var_f25; + } + KillLotteryWin(); + LotteryInlineFunc00(0, 1); +} + +static void SetBallPrize(void) { + Process *sp8; + s32 temp_r31; + + while (1) { + temp_r31 = BoardRandMod(100); + if (temp_r31 > 97) { + currPrize = 0; + } else if (temp_r31 > 87) { + currPrize = 1; + } else if (temp_r31 > 67) { + currPrize = 2; + } else { + currPrize = 3; + } + if (GWSystem.max_turn - GWSystem.turn != 0 || currPrize != 2) { + break; + } + } + sp8 = HuPrcChildCreate(ExecBallPrize, 0x2004, 0x3800, 0, lotteryProc); +} + +static void ExecBallPrize(void) { + Vec sp30; + Vec sp24; + Vec sp18; + Vec spC; + float var_f25; + float temp_f28; + float temp_f27; + float temp_f26; + float var_f29; + float var_f30; + s32 var_r28; + s16 temp_r29; + s16 var_r27; + s16 sp8; + HsfObject *temp_r3; + Mtx sp6C; + Mtx sp3C; + + var_r28 = 0; + HuAudFXPlay(0x34C); + temp_r29 = ballMdl[currPrize & 3]; + BoardModelPosGet(lotteryMdl[0], &sp30); + BoardModelRotGet(lotteryMdl[0], &sp18); + PSMTXRotRad(sp6C, 'Y', MTXDegToRad(sp18.y)); + var_r27 = BoardModelIDGet(lotteryMdl[0]); + temp_r3 = Hu3DModelObjPtrGet(var_r27, "toto_gara"); + temp_f28 = sp30.y + temp_r3->data.curr.pos.y + 100.0f; + PSMTXTrans(sp3C, temp_r3->data.curr.pos.x, temp_r3->data.curr.pos.y + 210.0f, temp_r3->data.curr.pos.z + -40.0f); + PSMTXConcat(sp6C, sp3C, sp3C); + Hu3DMtxTransGet(sp3C, &spC); + PSVECAdd(&spC, &sp30, &sp30); + BoardModelVisibilitySet(temp_r29, 1); + sp24.x = 10.5f; + sp24.y = -3.0f; + sp24.z = 0.0f; + PSMTXMultVec(sp6C, &sp24, &sp24); + var_f29 = 0.0f; + var_f30 = 1.8f; + temp_f27 = 0.016666668f; + sp8 = 0; + while (1) { + OSs16tof32(&sp8, &var_f25); + temp_f26 = 4.9f * (2.0f * var_f25 - temp_f27) * temp_f27; + sp24.y -= temp_f26; + sp24.x *= 0.92f; + sp24.z *= 0.92f; + PSVECAdd(&sp24, &sp30, &sp30); + var_f29 += sp24.z; + if (sp30.y - 25.0f < temp_f28) { + if (var_r28 == 0) { + HuAudFXPlay(0x334); + var_r28 = 1; + } + sp30.y = 25.0f + temp_f28 + temp_f26 * var_f30; + if (var_f30 > 0.0f) { + var_f30 -= 0.1f; + } + } + BoardModelPosSetV(temp_r29, &sp30); + BoardModelRotSet(temp_r29, 0.0f, var_f29, 0.0f); + HuPrcVSleep(); + sp8++; + } +} + +const s32 lbl_8011DFD0[] = { + 0x0007001E, + 0x0007001F, + 0x00070020, + 0x00070021, + 0x00070022, + 0x00070023, + 0x00070024, + 0x00070025 +}; + +const s32 lbl_8011DFF0[] = { + 0x00050009, + 0x0005000A, + 0x0005000B, + 0x0005000C, + 0x0005000D, + 0x0005000E, + 0x0005000F, + 0x00050010 +}; + +const s32 lbl_8011E010[] = { + 0x0005001D, + 0x0005001E, + 0x0005001F, + 0x00050020 +}; + +static omObjData *ticketObj[12] = { NULL }; +static s8 ticketPrize[12] = { 0 }; +static Vec handLastPos = { 0.0f, 0.0f, 0.0f }; + +static s32 loseSoundTbl[] = { + 0x0000012E, + 0x0000016E, + 0x000001AE, + 0x000001EE, + 0x0000022E, + 0x0000026E, + 0x000002AE, + 0x000002EE +}; + +static s32 loseMotTbl[] = { + 0x005F0033, + 0x001A0033, + 0x006D0033, + 0x008A0033, + 0x00850033, + 0x00110033, + 0x000D0033, + 0x00810033 +}; + +static void ExecScratchTicket(s32 arg0) { + Vec sp24; + Vec sp18; + Vec spC; + u16 var_r29; + u16 var_r28; + s16 *temp_r25; + s32 var_r24; + s32 temp_r27; + u16 var_r23; + omObjData *var_r22; + TicketWork *temp_r30; + AnimBmpData *temp_r31; + + var_r24 = GWPlayer[GWSystem.player_curr].character; + var_r22 = ticketObj[arg0]; + temp_r30 = OM_GET_WORK_PTR(var_r22, TicketWork); + lotteryMdl[4] = BoardModelCreate(lbl_8011DFF0[var_r24], NULL, 0); + BoardModelLayerSet(lotteryMdl[4], 6); + BoardModelPassSet(lotteryMdl[4], 0); + BoardCameraDirGet(&spC); + BoardModelRotYSet(lotteryMdl[4], 180.0 * (atan2(-spC.x, -spC.z) / M_PI)); + BoardModelScaleSet(lotteryMdl[4], 3.0f, 3.0f, 3.0f); + sp24.x = 320.0f; + sp24.y = 480.0f; + sp24.z = 500.0f; + CreateLotteryWin(1); + while (1) { + HuPrcVSleep(); + if (sp24.y <= 240.0f) { + break; + } + sp24.y -= 4.0f; + Hu3D2Dto3D(&sp24, 1, &sp18); + BoardModelPosSetV(lotteryMdl[4], &sp18); + } + comInputPos = 0; + if (BoardRandMod(100) < 50) { + comInputDrawP = comInputDraw1; + } else { + comInputDrawP = comInputDraw2; + } + temp_r27 = HuAudFXPlay(0x335); + HuAudFXVolSet(temp_r27, 0); + while (1) { + HuPrcVSleep(); + if (TicketUpdate(temp_r30->unk08->bmp, &sp24, temp_r27) != 0) { + break; + } + if (ScratchTicketCheckDone(temp_r30->unk08->bmp)) { + break; + } + } + HuAudFXStop(temp_r27); + while (1) { + HuPrcVSleep(); + if (sp24.y >= 480.0f) { + break; + } + sp24.y += 4.0f; + Hu3D2Dto3D(&sp24, 1, &sp18); + BoardModelPosSetV(lotteryMdl[4], &sp18); + } + BoardModelVisibilitySet(lotteryMdl[4], 0); + temp_r31 = temp_r30->unk08->bmp; + temp_r25 = temp_r31->data; + for (var_r28 = 0; var_r28 < temp_r31->sizeY; var_r28++) { + for (var_r29 = 0; var_r29 < temp_r31->sizeX; var_r29++) { + var_r23 = TicketGetPixel(temp_r31->sizeX, var_r29, var_r28); + temp_r25[var_r23] = 0; + } + HuPrcVSleep(); + } + KillLotteryWin(); + BoardModelKill(lotteryMdl[4]); + lotteryMdl[4] = -1; +} + +static void ExecScratch(void) { + TicketWork *temp_r28; + float var_f31; + s32 temp_curr; + s32 temp_r31; + + currPrize = -1; + BoardFilterFadeInit(0x1E, 0xA0); + InitTicketPrizes(); + InitScratchSpr(); + temp_curr = GWSystem.player_curr; + if (GWPlayer[temp_curr].com) { + comLotteryType = BoardRandMod(4); + comLotteryWinType = BoardRandMod(3); + } + BoardWinCreate(2, lotteryMessBase + 9, BoardWinPortraitGet()); + BoardWinWait(); + BoardWinKill(); + CreateLotteryWin(2); + InitScratchPick(); + while (currPrize == -1) { + HuPrcVSleep(); + } + temp_r31 = currPrize; + currPrize = ticketPrize[temp_r31]; + ExecTicketFocus(temp_r31); + KillLotteryWin(); + LotteryInlineFunc00(1, 0); + ExecScratchTicket(temp_r31); + LotteryInlineFunc00(1, 1); + temp_r28 = OM_GET_WORK_PTR(ticketObj[temp_r31], TicketWork); + for (var_f31 = 1.0f; var_f31 > 0.0f; var_f31 -= 0.078125f) { + if (var_f31 < 0.0f) { + var_f31 = 0.0f; + } + HuSprTPLvlSet(ticketSprGrp, temp_r28->unk00_field2, var_f31); + HuPrcVSleep(); + } + HideScratchSpr(); + BoardFilterFadeOut(30); +} + +static void KillScratch(void) { + if (ticketSprGrp != -1) { + HuSprGrpKill(ticketSprGrp); + ticketSprGrp = -1; + } + if (lotteryTicketPickObj) { + OM_GET_WORK_PTR(lotteryTicketPickObj, LotteryTicketPickWork)->unk00_field0 = 1; + } + memset(ticketObj, 0, sizeof(ticketObj)); +} + +static void ExecScratchSpr(omObjData *arg0) { + Vec sp20; + Vec sp14; + Vec sp8; + s32 temp_r29; + TicketWork *temp_r30; + + temp_r30 = OM_GET_WORK_PTR(arg0, TicketWork); + if (temp_r30->unk00_field0 != 0 || BoardIsKill()) { + temp_r29 = temp_r30->unk00_field2; + HuSprAttrSet(ticketSprGrp, temp_r29, 4); + HuSprAttrSet(ticketSprGrp, temp_r29 + 12, 4); + ticketObj[temp_r29] = NULL; + omDelObjEx(HuPrcCurrentGet(), arg0); + return; + } + if (temp_r30->unk01 != 0) { + temp_r30->unk01--; + return; + } + sp14.x = arg0->trans.x; + sp14.y = arg0->trans.y; + sp20.x = arg0->rot.x; + sp20.y = arg0->rot.y; + PSVECSubtract(&sp14, &sp20, &sp8); + if (ABS(sp8.x) < 1.0f && ABS(sp8.y) < 1.0f) { + sp8 = sp14; + temp_r30->unk00_field1 = 1; + } else { + PSVECScale(&sp8, &sp8, 0.2f); + PSVECAdd(&sp20, &sp8, &sp8); + temp_r30->unk00_field1 = 0; + } + HuSprPosSet(ticketSprGrp, temp_r30->unk00_field2, sp8.x, sp8.y); + HuSprPosSet(ticketSprGrp, temp_r30->unk00_field2 + 12, sp8.x, sp8.y); + arg0->rot.x = sp8.x; + arg0->rot.y = sp8.y; +} + +static void HideScratchSpr(void) { + s32 i; + + for (i = 0; i < 12; i++) { + if (ticketObj[i]) { + OM_GET_WORK_PTR(ticketObj[i], TicketWork)->unk00_field0 = 1; + } + } +} + +static void InitScratchSpr(void) { + Vec sp18; + Vec spC; + omObjData *temp_r31; + TicketWork *temp_r29; + s32 temp_curr; + s16 temp_r28; + s16 sp8; + s16 i; + + temp_curr = GWSystem.player_curr; + BoardPlayerRotGet(temp_curr, &sp18); + memset(ticketObj, 0, sizeof(ticketObj)); + BoardCameraRotGet(&spC); + temp_r28 = HuSprGrpCreate(0x18); + ticketSprGrp = temp_r28; + for (i = 0; i < 12; i++) { + temp_r31 = omAddObjEx(boardObjMan, 0x101, 0, 0, -1, ExecScratchSpr); + ticketObj[i] = temp_r31; + temp_r29 = OM_GET_WORK_PTR(temp_r31, TicketWork); + temp_r29->unk00_field0 = 0; + temp_r29->unk00_field2 = i; + temp_r29->unk01 = (i / 4) * 2; + temp_r29->unk02 = temp_r29->unk04 = -1; + temp_r31->trans.x = 107.0f + 110.0f * (i % 4); + temp_r31->trans.y = 98.0f + 110.0f * (i / 4); + temp_r31->rot.x = -56.0f; + temp_r31->rot.y = temp_r31->trans.y; + BoardSpriteCreate(lbl_8011E010[ticketPrize[i]], 0x157C, NULL, &sp8); + HuSprGrpMemberSet(temp_r28, i, sp8); + HuSprPosSet(temp_r28, i, temp_r31->rot.x, temp_r31->rot.y); + HuSprAttrSet(temp_r28, i, 8); + temp_r29->unk02 = sp8; + BoardSpriteCreate(0x50021, 0x1388, &temp_r29->unk08, &sp8); + HuSprGrpMemberSet(temp_r28, i + 12, sp8); + HuSprPosSet(temp_r28, i + 12, temp_r31->rot.x, temp_r31->rot.y); + HuSprAttrSet(temp_r28, i + 12, 8); + temp_r29->unk04 = sp8; + } + HuSprGrpDrawNoSet(temp_r28, 0x40); +} + +static inline u32 ExecStratchPickInlineFunc(LotteryTicketPickWork *temp_r29) { + s32 var_r21; + s32 temp_r23; + u32 var_r26; + + var_r21 = GWSystem.player_curr; + var_r26 = 0; + if (!GWPlayer[var_r21].com) { + temp_r23 = GWPlayer[GWSystem.player_curr].port; + var_r26 = HuPadDStkRep[temp_r23] | HuPadBtnDown[temp_r23]; + } else if (comLotteryType != temp_r29->unk02) { + var_r26 = 2; + } else if (comLotteryWinType != temp_r29->unk03) { + var_r26 = 4; + } else if (comLotteryType == temp_r29->unk02 && comLotteryWinType == temp_r29->unk03) { + var_r26 = 0x100; + } + return var_r26; +} + +static void ExecScratchPick(omObjData *arg0) { + float var_f29; + float var_f28; + s8 var_r28; + s8 var_r25; + s8 var_r24; + u32 var_r26; + LotteryTicketPickWork *temp_r29; + + temp_r29 = OM_GET_WORK_PTR(arg0, LotteryTicketPickWork); + if (temp_r29->unk00_field0 || BoardIsKill()) { + HuSprGrpKill(temp_r29->unk08); + lotteryTicketPickObj = 0; + omDelObjEx(HuPrcCurrentGet(), arg0); + return; + } + if (temp_r29->unk04 != 0) { + temp_r29->unk04--; + return; + } + var_r25 = var_r24 = 0; + var_r26 = ExecStratchPickInlineFunc(temp_r29); + if (var_r26 == 0x100) { + currPrize = (temp_r29->unk02 + (temp_r29->unk03 * 4)); + temp_r29->unk00_field0 = 1; + HuAudFXPlay(2); + return; + } + var_r28 = 0; + if (var_r26 == 8) { + var_r24 = -1; + var_r28 = 1; + } + if (var_r26 == 4) { + var_r24 = 1; + var_r28 = 1; + } + if (var_r26 == 1) { + var_r25 = -1; + var_r28 = 1; + } + if (var_r26 == 2) { + var_r25 = 1; + var_r28 = 1; + } + if ((var_r25 != 0 || var_r24 != 0) && GWPlayer[GWSystem.player_curr].com) { + temp_r29->unk04 = 0x14; + } + temp_r29->unk02 += var_r25; + temp_r29->unk03 += var_r24; + if (temp_r29->unk02 < 0) { + temp_r29->unk02 = 0; + var_r28 = 0; + } else if (temp_r29->unk03 < 0) { + temp_r29->unk03 = 0; + var_r28 = 0; + } + if (temp_r29->unk02 >= 4) { + temp_r29->unk02 = 3; + var_r28 = 0; + } else if (temp_r29->unk03 >= 3) { + temp_r29->unk03 = 2; + var_r28 = 0; + } + if (var_r28 != 0) { + HuAudFXPlay(0); + } + OSs8tof32(&temp_r29->unk02, &var_f29); + OSs8tof32(&temp_r29->unk03, &var_f28); + var_f29 = 107.0f + 110.0f * var_f29 - 32.0f + 16.0f; + var_f28 = 98.0f + 110.0f * var_f28 + 32.0f - 24.0f; + HuSprPosSet(temp_r29->unk08, 0, var_f29, var_f28); +} + +static void InitScratchPick(void) { + float temp_f31 = 91.0f; + float temp_f30 = 106.0f; + omObjData *temp_r30; + LotteryTicketPickWork *var_r31; + + temp_r30 = omAddObjEx(boardObjMan, 0x101, 0, 0, -1, ExecScratchPick); + lotteryTicketPickObj = temp_r30; + var_r31 = OM_GET_WORK_PTR(temp_r30, LotteryTicketPickWork); + var_r31->unk02 = var_r31->unk03 = 0; + var_r31->unk04 = 6; + var_r31->unk00_field0 = 0; + var_r31->unk01 = GWPlayer[GWSystem.player_curr].character; + var_r31->unk08 = HuSprGrpCreate(1); + BoardSpriteCreate(lbl_8011DFD0[var_r31->unk01], 0x1388, 0, &var_r31->unk06); + HuSprGrpMemberSet(var_r31->unk08, 0, var_r31->unk06); + HuSprAttrSet(var_r31->unk08, 0, 8); + HuSprPosSet(var_r31->unk08, 0, temp_f31, temp_f30); + HuSprGrpDrawNoSet(var_r31->unk08, 0x40); +} + +static void InitTicketPrizes(void) { + s32 temp_r31; + s32 i; + + memset(ticketPrize, 3, sizeof(ticketPrize)); + for (i = 0; i < 3; i++) { + do { + temp_r31 = BoardRandMod(12); + } while (ticketPrize[temp_r31] != 3); + ticketPrize[temp_r31] = i; + if (GWSystem.max_turn - GWSystem.turn == 0 && i == 2) { + ticketPrize[temp_r31] = 3; + } + } +} + +static void ExecTicketFocus(s32 arg0) { + float var_f31; + float temp_f30; + omObjData *var_r30; + TicketWork *temp_r29; + s32 i; + + var_r30 = ticketObj[arg0]; + var_r30->trans.x = 288.0f; + var_r30->trans.y = 240.0f; + for (i = 0; i < 12; i++) { + if (i != arg0) { + OM_GET_WORK_PTR(ticketObj[i], TicketWork)->unk00_field0 = 1; + } + } + temp_r29 = OM_GET_WORK_PTR(ticketObj[arg0], TicketWork); + for (var_f31 = 0.0f; var_f31 < 90.0f; var_f31 += 2.0f) { + temp_f30 = 1.0 + 1.2999999523162842 * sin(var_f31 * M_PI / 180.0); + HuSprScaleSet(ticketSprGrp, temp_r29->unk00_field2, temp_f30, temp_f30); + HuSprScaleSet(ticketSprGrp, temp_r29->unk00_field2 + 12, temp_f30, temp_f30); + HuPrcVSleep(); + } +} + +static BOOL ScratchTicketCheckDone(AnimBmpData *arg0) { + s32 var_r29; + s32 var_r31; + s32 var_r30; + u16 *var_r28; + + var_r28 = arg0->data; + for (var_r29 = var_r30 = 0; var_r30 < arg0->sizeY; var_r30++) { + for (var_r31 = 0; var_r31 < arg0->sizeX; var_r31++) { + if (var_r28[var_r31 + var_r30 * arg0->sizeX] == 0) { + var_r29++; + } + } + } + if (var_r29 >= arg0->sizeX * arg0->sizeY - 300) { + return TRUE; + } else { + return FALSE; + } +} + +static u16 TicketGetPixel(u16 arg0, u16 arg1, u16 arg2) { + u16 var_r31; + u16 var_r30; + u16 var_r29; + u16 var_r28; + + var_r29 = (arg1 & 3); + var_r28 = (arg2 & 3); + var_r31 = (arg1 >> 2); + var_r30 = (arg2 >> 2); + return var_r29 + (var_r28 << 2) + ((var_r31 + var_r30 * (arg0 >> 2)) << 4); +} + +static s32 TicketUpdate(AnimBmpData *arg0, Vec *arg1, s32 arg2) { + Vec sp48; + Vec sp3C; + float temp_f25; + float temp_f20; + s32 var_r18; + s16 var_r17; + s32 var_r21; + s32 var_r20; + s8 *temp_r19; + s16 *sp38; + s32 sp34; + s16 sp26; + s16 sp24; + s16 sp22; + s8 spD; + + if (GWPlayer[GWSystem.player_curr].com) { + temp_r19 = comInputDrawP[comInputPos++]; + if (temp_r19[0] == 0x7F && temp_r19[1] == 0x7F) { + return -1; + } + OSs8tof32(&temp_r19[0], &sp48.x); + OSs8tof32(&temp_r19[1], &sp48.y); + } else { + sp34 = GWPlayer[GWSystem.player_curr].port; + sp48.x = HuPadStkX[sp34]; + sp48.y = HuPadStkY[sp34]; + } + sp48.z = 0.0f; + if (sp48.x == 0.0f && sp48.y == 0.0f) { + handLastPos = *arg1; + handUpdateF = 0; + HuAudFXVolSet(arg2, 0); + return 0; + } + if (handUpdateF == 0) { + handUpdateF = 1; + } + PSVECNormalize(&sp48, &sp48); + temp_f20 = atan2f(sp48.x, -sp48.y); + sp48.x = sin(temp_f20); + sp48.y = cos(temp_f20); + temp_f25 = 127.0f * PSVECMag(&sp48); + OSf32tos8(&temp_f25, &spD); + HuAudFXVolSet(arg2, spD); + sp48.x *= 8.0f; + sp48.y *= 8.0f; + PSVECAdd(&sp48, arg1, &sp3C); + var_r18 = 0; + if (sp3C.x < 192.0f) { + sp3C.x = 192.0f; + var_r18 = 1; + } + if (sp3C.y < 192.0f) { + sp3C.y = 192.0f; + var_r18 = 1; + } + if (sp3C.x >= 384.0f) { + sp3C.x = 384.0f; + var_r18 = 1; + } + if (sp3C.y >= 288.0f) { + sp3C.y = 288.0f; + var_r18 = 1; + } + if (var_r18 != 0) { + HuAudFXVolSet(arg2, 0); + } + *arg1 = sp3C; + Hu3D2Dto3D(&sp3C, 1, &sp3C); + BoardModelPosSetV(lotteryMdl[4], &sp3C); + sp3C = *arg1; + sp3C.x -= 192.0f; + sp3C.y -= 192.0f; + sp3C.x *= arg0->sizeX / 192.0f; + sp3C.y *= arg0->sizeY / 96.0f; + sp24 = arg0->sizeX; + sp38 = arg0->data; + for (var_r20 = -8; var_r20 < 9; var_r20++) { + for (var_r21 = -8; var_r21 < 9; var_r21++) { + OSf32tos16(&sp3C.x, &var_r17); + OSf32tos16(&sp3C.y, &sp26); + if (var_r17 + var_r21 < arg0->sizeX && sp26 + var_r20 < arg0->sizeY && var_r17 + var_r21 >= 0 && sp26 + var_r20 >= 0) { + var_r17 += var_r21; + sp26 += var_r20; + sp22 = TicketGetPixel(sp24, var_r17, sp26); + if (sp22 < arg0->sizeX * arg0->sizeY) { + sp38[sp22] = 0; + } + } + } + } + DCFlushRange(arg0->data, (u32) (arg0->sizeX * arg0->sizeY * 2) >> 3); + handLastPos = *arg1; + return 0; +} + +static s32 ExecCoinPrizeInlineFunc(void) { + s32 i; + + for (i = 0; i < 10; i++) { + if (coinF[i] == 0) { + return i; + } + } + return -1; +} + +static void ExecCoinPrize(void) { + Vec sp64[10]; + Vec sp8; + float sp3C[10]; + float sp14[10]; + float var_f31; + s32 var_r26; + s32 var_r28; + s32 temp_r27; + s32 var_r30; + s32 i; + + temp_r27 = GWSystem.player_curr; + if (currPrize == 0) { + var_r28 = 100; + } else { + var_r28 = 30; + } + memset(coinMdl, 0, sizeof(coinMdl)); + memset(coinF, 0, 10); + BoardPlayerPosGet(temp_r27, &sp8); + var_f31 = 150.0f + sp8.y; + if (BoardPlayerSizeGet(temp_r27) == 1) { + var_f31 = 110.0f + (52.5308f + (0.3f * var_f31)); + } + for (i = 0; i < 10; i++) { + coinMdl[i] = BoardModelCreate(0x7000A, NULL, 0); + BoardModelVisibilitySet(coinMdl[i], 0); + } + while (1) { + HuPrcVSleep(); + if (var_r28 > 0) { + var_r30 = ExecCoinPrizeInlineFunc(); + if (var_r30 != -1) { + coinF[var_r30] = 1; + sp64[var_r30].x = sp8.x + 100.0f * (BoardRandFloat() - 0.5f); + sp64[var_r30].y = sp8.y + 700.0f; + sp64[var_r30].z = sp8.z + 100.0f * (BoardRandFloat() - 0.5f); + sp14[var_r30] = -20.0f + -10.0f * BoardRandFloat(); + sp3C[var_r30] = BoardRandMod(360); + BoardModelVisibilitySet(coinMdl[var_r30], 1); + BoardModelScaleSet(coinMdl[var_r30], 0.5f, 0.5f, 0.5f); + var_r28--; + } + } else { + var_r26 = 0; + for (i = 0; i < 10; i++) { + if (coinF[i] != 0) { + var_r26 = 1; + } + } + if (var_r26 == 0) { + return; + } + } + for (i = 0; i < 10; i++) { + if (coinF[i] != 0) { + if (sp64[i].y < var_f31) { + sp64[i].y = var_f31; + CharModelLayerSetAll(2); + CharModelCoinEffectCreate(1, &sp64[i]); + BoardModelVisibilitySet(coinMdl[i], 0); + coinF[i] = 0; + BoardPlayerCoinsAdd(temp_r27, 1); + HuAudFXPlay(7); + omVibrate(temp_r27, 0xC, 6, 6); + } else { + BoardModelPosSetV(coinMdl[i], &sp64[i]); + BoardModelRotSet(coinMdl[i], 0.0f, sp3C[i], 0.0f); + sp3C[i] = BoardDAngleCalc(45.0f + sp3C[i]); + sp64[i].y += sp14[i]; + } + } + } + } +} + +static void ExecItemPrize(void) { + Vec sp20; + Vec sp14; + float temp_f29; + float var_f28; + float var_f30; + float var_f31; + s32 temp_r26; + s32 var_r28; + s32 temp_r29; + s16 *var_r31; + s16 i; + s32 spC[2] = { + 0x0007006F, + 0x00070070 + }; + s8 sp8[2] = { + 0x02, 0x03 + }; + + temp_r29 = GWSystem.player_curr; + var_r28 = (BoardRandFloat() < 0.5f) ? 1 : 0; + memset(coinMdl, 0, sizeof(coinMdl)); + var_r31 = &coinMdl[0]; + *var_r31 = BoardModelCreate(spC[var_r28], NULL, 0); + var_f30 = BoardPlayerRotYGet(temp_r29); + BoardModelRotYSet(*var_r31, var_f30); + BoardModelScaleSet(*var_r31, 1.0f, 1.0f, 1.0f); + BoardSpacePosGet(0, GWPlayer[temp_r29].space_curr, &sp20); + BoardPlayerPosGet(temp_r29, &sp14); + sp14.y = sp20.y; + sp20 = sp14; + sp14.y += 700.0f; + sp20.y += 280.0f; + temp_f29 = (sp20.y - sp14.y) / 60.0f; + temp_r26 = HuAudFXPlay(0x35F); + for (i = 0; i < 60; i++) { + sp14.y += temp_f29; + BoardModelPosSetV(*var_r31, &sp14); + HuPrcVSleep(); + } + HuPrcSleep(30); + BoardPlayerPosGet(temp_r29, &sp20); + if (BoardPlayerSizeGet(temp_r29) == 0) { + sp20.y += 100.0f; + } else { + sp20.y += 30.000002f; + } + temp_f29 = (sp20.y - sp14.y) / 30.0f; + var_f28 = 0.0f; + HuAudFXPlay(0x30D); + for (i = 0; i < 30; i++) { + sp14.y += temp_f29; + var_f30 = BoardDAngleCalc(15.0f + var_f30); + var_f31 = cos(var_f28 * M_PI / 180.0); + if (var_f31 <= 0.0f) { + var_f31 = 0.01f; + } + var_f28 += 3.3333333f; + BoardModelPosSetV(*var_r31, &sp14); + BoardModelRotYSet(*var_r31, var_f30); + BoardModelScaleSet(*var_r31, var_f31, var_f31, var_f31); + HuPrcVSleep(); + } + HuAudFXStop(temp_r26); + BoardModelKill(*var_r31); + *var_r31 = -1; + BoardPlayerItemAdd(GWSystem.player_curr, sp8[var_r28]); + omVibrate(GWSystem.player_curr, 0xC, 6, 6); +} + +static void KillCoin(void) { + s32 i; + + for (i = 0; i < 10; i++) { + BoardModelKill(coinMdl[i]); + coinMdl[i] = -1; + } +} + +static void ExecPrize(void) { + Vec sp14; + Vec sp8; + s16 var_r29; + s16 var_r23; + s32 var_r26; + s32 var_r28; + s32 var_r27; + s32 temp_r30; + s32 var_r31; + s32 i; + s32 var_r24; + + var_r28 = -1; + var_r29 = 0; + var_r27 = -1; + sp14.x = 0.0f; + sp14.y = 200.0f; + sp14.z = 0.0f; + BoardCameraMotionStartEx(lotteryMdl[0], 0, &sp14, 1300.0f, -1.0f, 0x15); + temp_r30 = GWSystem.player_curr; + BoardStatusShowSetForce(temp_r30); + BoardStatusShowSet(temp_r30, 1); + for (var_r24 = i = 0; i < 3; i++) { + if (GWPlayer[GWSystem.player_curr].items[i] != -1) { + var_r24++; + } + } + var_r31 = currPrize; + if (var_r31 == 0) { + BoardModelVisibilitySet(lotteryMdl[2], 1); + BoardModelMotionStart(lotteryMdl[2], 0, 0x40000001); + BoardModelMotionSpeedSet(lotteryMdl[2], 2.0f); + } + var_r26 = 0; + switch (var_r31) { + case 0: + var_r28 = lotteryMessBase + 2; + var_r29 = 7; + var_r26 = 0x64; + break; + case 1: + var_r28 = lotteryMessBase + 4; + var_r29 = 7; + var_r26 = 0x50; + break; + case 2: + var_r28 = lotteryMessBase + 5; + if (var_r24 < 3) { + var_r29 = 7; + var_r26 = 0x50; + } else { + var_r29 = 8; + } + break; + case 3: + var_r28 = lotteryMessBase + 7; + var_r29 = 8; + break; + } + if (var_r31 != 3) { + HuAudFXPlay(0x332); + } + if (var_r29 == 7) { + BoardModelMotionShiftSet(BoardLotteryHostGet(), lotteryMot[1], 0.0f, 10.0f, 0x40000001); + } + if (var_r26 != 0) { + BoardPlayerPosGet(temp_r30, &sp8); + sp8.y = 700.0f; + BoardConfettiCreate(&sp8, var_r26, 150.0f); + } + if (var_r31 == 0 || var_r31 == 1) { + BoardAudSeqPause(1, 1, 0x1F4); + HuPrcSleep(0x14); + if (var_r31 == 0) { + var_r27 = HuAudSStreamPlay(0xA); + } else { + var_r27 = HuAudSStreamPlay(9); + } + } + var_r23 = (s32) BoardPlayerRotYGet(temp_r30) + 180; + BoardPlayerMotBlendSet(temp_r30, var_r23, 0xF); + while (!BoardPlayerMotBlendCheck(temp_r30)) { + HuPrcVSleep(); + } + if (var_r31 == 0 || var_r31 == 1) { + while (HuAudSStreamStatGet(var_r27) != 0) { + HuPrcVSleep(); + } + var_r27 = -1; + BoardAudSeqPause(1, 0, 1000); + } + BoardWinCreate(2, var_r28, BoardWinPortraitGet()); + BoardWinWait(); + if (var_r31 == 2) { + if (var_r24 == 3) { + BoardWinCreate(2, lotteryMessBase + 6, BoardWinPortraitGet()); + BoardWinWait(); + } else { + BoardAudSeqPause(1, 1, 1000); + HuPrcSleep(0x30); + var_r27 = HuAudSStreamPlay(2); + } + } + if (var_r29 == 8) { + HuAudFXPlay(loseSoundTbl[GWPlayer[temp_r30].character]); + BoardPlayerVoiceEnableSet(temp_r30, var_r29, 0); + } + BoardPlayerMotionShiftSet(temp_r30, var_r29, 0.0f, 8.0f, 0); + switch (var_r31) { + case 0: + case 1: + ExecCoinPrize(); + break; + case 2: + if (var_r24 < 3) { + ExecItemPrize(); + } else { + var_r31 = 3; + } + break; + } + if (var_r27 != -1) { + while (HuAudSStreamStatGet(var_r27) != 0) { + HuPrcVSleep(); + } + var_r27 = -1; + BoardAudSeqPause(1, 0, 1000); + } + while (!BoardPlayerMotionEndCheck(temp_r30)) { + HuPrcVSleep(); + } + if (var_r31 != 3) { + var_r28 = lotteryMessBase + 3; + } else { + var_r28 = lotteryMessBase + 8; + } + BoardModelMotionShiftSet(BoardLotteryHostGet(), lotteryMot[2], 0.0f, 10.0f, 0x40000001); + BoardWinCreate(2, var_r28, BoardWinPortraitGet()); + BoardWinWait(); + BoardWinKill(); + if (var_r26 != 0) { + BoardConfettiStop(); + } + if (var_r31 == 3) { + ExecLose(temp_r30); + } +} + +static void ExecLose(s32 arg0) { + s32 temp_r30; + + temp_r30 = GWPlayer[arg0].character; + loseMot = BoardPlayerMotionCreate(arg0, loseMotTbl[temp_r30]); + BoardPlayerMotionShiftSet(arg0, loseMot, 0.0f, 10.0f, 0); + HuPrcSleep(10); + while (!BoardPlayerMotionEndCheck(arg0)) { + HuPrcVSleep(); + } +} + +static void CreateLotteryWin(s32 arg0) { + float sp8[2]; + float temp_f30; + float var_f31; + s32 var_r31; + + temp_f30 = -10000.0f; + if (arg0 == 0) { + var_r31 = 0x60050; + var_f31 = 352.0f; + } else if (arg0 == 1) { + var_f31 = 352.0f; + var_r31 = 0x60051; + } else { + var_f31 = 364.0f; + var_r31 = 0x200016; + } + HuWinMesMaxSizeGet(1, sp8, var_r31); + lotteryInstWin = HuWinCreate(temp_f30, var_f31, sp8[0], sp8[1], 0); + HuWinBGTPLvlSet(lotteryInstWin, 0.0f); + HuWinMesSpeedSet(lotteryInstWin, 0); + HuWinMesSet(lotteryInstWin, var_r31); +} + +static void KillLotteryWin(void) { + if (lotteryInstWin != -1) { + HuWinKill(lotteryInstWin); + lotteryInstWin = -1; + } +} + +void BoardLotteryTutorialExec(void) { + Vec sp38; + Vec sp2C; + Vec sp20; + Vec sp14; + Vec sp8; + s16 temp_r29; + s16 temp_r28; + s16 temp_r31; + s32 temp_r30; + + temp_r30 = BoardDataDirReadAsync(0x50000); + temp_r31 = BoardSpaceFlagSearch(0, 0x10000000); + if (temp_r30 != -1) { + BoardDataAsyncWait(temp_r30); + } + BoardModelMotionStart(BoardLotteryHostGet(), 1, 0x40000001); + CreateModel(); + temp_r29 = BoardSpaceLinkFlagSearch(0, temp_r31, 0x02000000); + BoardSpacePosGet(0, temp_r31, &sp38); + BoardSpacePosGet(0, temp_r29, &sp2C); + PSVECSubtract(&sp2C, &sp38, &sp20); + PSVECNormalize(&sp20, &sp20); + temp_r28 = 180.0 * (atan2(-sp20.x, -sp20.z) / M_PI); + sp14.x = -3.0f; + sp14.y = temp_r28; + sp14.z = 0.0f; + sp8.x = 0.0f; + sp8.y = 200.0f; + sp8.z = 0.0f; + BoardCameraMotionStartEx(lotteryMdl[0], &sp14, &sp8, 1300.0f, -1.0f, 0x15); + HuAudFXPlay(0x331); + HuAudFXPlay(0x344); + BoardModelMotionStart(lotteryMdl[0], 0, 0); + while (!BoardModelMotionEndCheck(lotteryMdl[0])) { + HuPrcVSleep(); + } + BoardModelMotionShiftSet(BoardLotteryHostGet(), lotteryMot[3], 0.0f, 10.0f, 0); + HuPrcSleep(10); + while (!BoardModelMotionEndCheck(BoardShopHostGet())) { + HuPrcVSleep(); + } + BoardModelMotionShiftSet(BoardLotteryHostGet(), lotteryMot[0], 0.0f, 10.0f, 0x40000001); + BoardTutorialHookExec(0x1C, 0); + BoardModelMotionShiftSet(BoardLotteryHostGet(), lotteryMot[2], 0.0f, 10.0f, 0x40000001); + HuPrcSleep(30); + BoardModelMotionStart(lotteryMdl[0], 0, 0x40000004); + while (!BoardModelMotionEndCheck(lotteryMdl[0])) { + HuPrcVSleep(); + } + BoardModelMotionSpeedSet(lotteryMdl[0], 0.0f); + BoardModelAttrReset(lotteryMdl[0], 0x40000004); + HuAudFXPlay(0x32F); + KillModel(); +} diff --git a/src/game/board/main.c b/src/game/board/main.c index 900c5738..41990f14 100644 --- a/src/game/board/main.c +++ b/src/game/board/main.c @@ -8,7 +8,9 @@ #include "string.h" #include "game/hsfman.h" #include "game/hsfdraw.h" +#include "game/board/lottery.h" #include "game/board/main.h" +#include "game/board/model.h" #include "game/board/pause.h" #include "game/board/player.h" #include "game/board/tutorial.h" @@ -58,7 +60,6 @@ static CameraView camViewTbl[] = { }; -extern void BoardModelPosGet(s16 model, Vec *pos); extern s32 BoardSpacePosGet(s32 layer, s32 space, Vec *pos); extern void BoardMGSetupPlayClear(void); diff --git a/src/game/board/space.c b/src/game/board/space.c index e117bf18..25a278ec 100644 --- a/src/game/board/space.c +++ b/src/game/board/space.c @@ -1,6 +1,8 @@ #include "game/gamework_data.h" #include "game/flag.h" +#include "game/board/lottery.h" #include "game/board/main.h" +#include "game/board/model.h" #include "game/board/player.h" #include "game/board/space.h" #include "game/board/star.h" @@ -14,9 +16,6 @@ #include "string.h" -extern s16 BoardModelCreate(s32 file, s32 *data, s32 arg3); -extern s16 BoardModelIDGet(s16 model); - static BoardSpace spaceData[2][256]; s16 boardSpaceStarTbl[8]; static GXTexObj spaceHiliteTex; @@ -834,7 +833,7 @@ static void DrawSpaces(ModelData *model, Mtx matrix) if(player_pos.y-space_curr->pos.y < 0.0f) { y_dist = -(player_pos.y-space_curr->pos.y); } else { - y_dist = player_pos.y-space_curr->pos.y; + y_dist = player_pos.y-space_curr->pos.y; } if(y_dist < 10.0f) { space_hilite = space_curr; diff --git a/src/game/board/star.c b/src/game/board/star.c index 59815c40..ed98fcb8 100755 --- a/src/game/board/star.c +++ b/src/game/board/star.c @@ -717,8 +717,8 @@ void BoardStarShowNext(s32 arg0) { Hu3D2Dto3D(&sp44, 1, &sp44); BoardModelPosSetV(BoardStarHostMdlGet(), &sp44); BoardCameraRotGet(&sp2C); - PSMTXRotRad(sp5C, 'y', 0.17453292f); - PSMTXRotRad(sp8C, 'x', 0.017453292f * sp2C.x); + PSMTXRotRad(sp5C, 'y', MTXDegToRad(10.0f)); + PSMTXRotRad(sp8C, 'x', MTXDegToRad(sp2C.x)); PSMTXConcat(sp8C, sp5C, spBC); BoardModelMtxSet(BoardStarHostMdlGet(), &spBC); BoardModelRotSet(BoardStarHostMdlGet(), 0.0f, 0.0f, 0.0f); diff --git a/src/game/board/view.c b/src/game/board/view.c index 46dc6f6d..1d11d83c 100755 --- a/src/game/board/view.c +++ b/src/game/board/view.c @@ -578,8 +578,8 @@ static void UpdateOverheadView(omObjData *arg0) { sp20.y = var_r29[1]; sp20.z = 1000.0f; BoardCameraRotGet(&sp8); - PSMTXRotRad(sp5C, 0x78, sp8.x * 0.017453292f); - PSMTXRotRad(sp2C, 0x79, sp8.y * 0.017453292f); + PSMTXRotRad(sp5C, 'x', MTXDegToRad(sp8.x)); + PSMTXRotRad(sp2C, 'y', MTXDegToRad(sp8.y)); PSMTXConcat(sp2C, sp5C, sp2C); BoardModelMtxSet(temp_r31->unk04, &sp2C); Hu3D2Dto3D(&sp20, 1, &sp20); diff --git a/src/game/board/warp.c b/src/game/board/warp.c index e623e207..f5b45068 100644 --- a/src/game/board/warp.c +++ b/src/game/board/warp.c @@ -1,5 +1,6 @@ #include "game/board/warp.h" #include "game/board/main.h" +#include "game/board/model.h" #include "game/board/player.h" #include "game/board/tutorial.h" #include "game/wipe.h" @@ -21,10 +22,6 @@ extern void BoardCharWheelInit(s32, s32); extern void BoardCharWheelSpeedSet(f32); extern void BoardCharWheelWait(void); extern s32 BoardCharWheelResultGet(void); -extern f32 BoardModelMotionTimeGet(s16); -extern void BoardModelHookReset(s16); -extern s32 BoardModelHookSet(s16, char*, s16); -extern s32 BoardModelMotionEndCheck(s16); static Vec warpPos;