From 49a51164a01a2ef63192785be170a44562deabd6 Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Mon, 22 Apr 2024 15:19:47 -0500 Subject: [PATCH] Add various minigame macros --- include/REL/modeltestDll.h | 3 --- include/game/gamework_data.h | 3 +++ include/game/minigame_seq.h | 37 ++++++++++++++++++++++++++++++++++++ src/REL/m407dll/main.c | 18 +++++++++--------- src/REL/modeltestDll/main.c | 17 +++++++++-------- src/REL/w01Dll/mg_item.c | 4 ++-- src/REL/w03Dll/mg_coin.c | 4 ++-- src/REL/w03Dll/mg_item.c | 4 ++-- src/REL/w06Dll/mg_item.c | 4 ++-- src/game/minigame_seq.c | 22 ++++++++++----------- 10 files changed, 77 insertions(+), 39 deletions(-) diff --git a/include/REL/modeltestDll.h b/include/REL/modeltestDll.h index 0715ad9b..d0b4ccc3 100644 --- a/include/REL/modeltestDll.h +++ b/include/REL/modeltestDll.h @@ -35,13 +35,10 @@ extern Point3d Center; extern f32 CZoom; void fn_1_29C(); void fn_1_28F8(Point3d * arg0, Point3d * arg1); -extern void omOutView(); void fn_1_37DC(omObjData*); void fn_1_439C(omObjData*); void fn_1_46F0(); -s16 MGSeqCreate(s16, ...); -void MGSeqParamSet(s16, s16, s16); typedef void (omObjFunc2)(struct om_obj_data *); omObjFunc2 fn_1_F9C; diff --git a/include/game/gamework_data.h b/include/game/gamework_data.h index 35303b96..5b3d2a26 100644 --- a/include/game/gamework_data.h +++ b/include/game/gamework_data.h @@ -310,4 +310,7 @@ static inline void GWPlayerCoinWinSet(s32 player, s16 value) } } +#define GWPlayerCoinWinAdd(player, value) GWPlayerCoinWinSet((player), GWPlayerCoinWinGet((player))+(value)) +#define GWPlayerCoinCollectAdd(player, value) GWPlayerCoinCollectSet((player), GWPlayerCoinCollectGet((player))+(value)) + #endif diff --git a/include/game/minigame_seq.h b/include/game/minigame_seq.h index ba4a2322..4bfd3107 100644 --- a/include/game/minigame_seq.h +++ b/include/game/minigame_seq.h @@ -4,6 +4,43 @@ #include "game/object.h" #include "stdarg.h" +#define MG_SEQ_TYPE_TIMER 1 +#define MG_SEQ_TYPE_AUTO 3 +#define MG_SEQ_TYPE_1VS3 4 +#define MG_SEQ_TYPE_WIN 5 +#define MG_SEQ_TYPE_BATTLE 6 +#define MG_SEQ_TYPE_STORY 7 +#define MG_SEQ_TYPE_4P 8 +#define MG_SEQ_TYPE_2VS2 9 +#define MG_SEQ_TYPE_PINBALL 10 +#define MG_SEQ_TYPE_BOWSER 11 +#define MG_SEQ_TYPE_ALTWIN 12 +#define MG_SEQ_TYPE_DRAW 13 +#define MG_SEQ_TYPE_RECORD 14 + +#define MG_SEQ_WIN_TYPE_WIN 3 +#define MG_SEQ_WIN_TYPE_LOSE 4 +#define MG_SEQ_WIN_TYPE_CHAMPION 5 + +#define MG_SEQ_WORD_START 0 +#define MG_SEQ_WORD_FINISH 1 +#define MG_SEQ_WORD_DRAW 2 + +#define MGSeqTimerCreate(value) MGSeqCreate(MG_SEQ_TYPE_TIMER, (value), -1, -1) +#define MGSeqTimerCreateXY(value, x, y) MGSeqCreate(MG_SEQ_TYPE_TIMER, (value), (int)(x), (int)(y)) +#define MGSeqStartCreate() MGSeqCreate(MG_SEQ_TYPE_AUTO, MG_SEQ_WORD_START) +#define MGSeqFinishCreate() MGSeqCreate(MG_SEQ_TYPE_AUTO, MG_SEQ_WORD_FINISH) +#define MGSeqDrawCreate() MGSeqCreate(MG_SEQ_TYPE_AUTO, MG_SEQ_WORD_DRAW) +#define MGSeqStartCreateType(type) MGSeqCreate((type), MG_SEQ_WORD_START) +#define MGSeqFinishCreateType(type) MGSeqCreate((type), MG_SEQ_WORD_FINISH) +#define MGSeqDrawCreateType(type) MGSeqCreate((type), MG_SEQ_WORD_DRAW) +#define MGSeqWinCreate(player_1, player_2, player_3, player_4) MGSeqCreate(MG_SEQ_TYPE_WIN, MG_SEQ_WIN_TYPE_WIN, (player_1), (player_2), (player_3), (player_4)) +#define MGSeqLoseCreate(player_1, player_2, player_3, player_4) MGSeqCreate(MG_SEQ_TYPE_WIN, MG_SEQ_WIN_TYPE_LOSE, (player_1), (player_2), (player_3), (player_4)) +#define MGSeqChampionCreate(player_1, player_2, player_3, player_4) MGSeqCreate(MG_SEQ_TYPE_ALTWIN, MG_SEQ_WIN_TYPE_CHAMPION, (player_1), (player_2), (player_3), (player_4)) +#define MGSeqRecordCreate(value) MGSeqCreate(MG_SEQ_TYPE_RECORD, (value)) + + + typedef struct seq_work SeqWork; typedef int (*SeqUpdateFunc)(SeqWork *work); diff --git a/src/REL/m407dll/main.c b/src/REL/m407dll/main.c index 0336a620..7be29e78 100644 --- a/src/REL/m407dll/main.c +++ b/src/REL/m407dll/main.c @@ -211,7 +211,7 @@ void fn_1_4E8C(void) { temp_r31 = lbl_1_bss_397C->data; if (temp_r31->unk_06 == -1) { - temp_r31->unk_06 = MGSeqCreate(3, 0); + temp_r31->unk_06 = MGSeqStartCreate(); temp_r31->unk_44 = HuAudSeqPlay(0x46); fn_1_2564(); for (i = 0; i < 4; i++) { @@ -222,7 +222,7 @@ void fn_1_4E8C(void) { MGSeqKill(temp_r31->unk_06); temp_r31->unk_06 = -1; temp_r31->unk_10 = 0x258; - temp_r31->unk_08 = MGSeqCreate(1, temp_r31->unk_10 / 60, -1, -1); + temp_r31->unk_08 = MGSeqTimerCreate(temp_r31->unk_10 / 60); fn_1_1E4(); fn_1_4C3C(3); } @@ -299,7 +299,7 @@ void fn_1_52AC(void) { temp_r31 = lbl_1_bss_397C->data; if (temp_r31->unk_04 == 0) { - temp_r31->unk_06 = MGSeqCreate(3, 1); + temp_r31->unk_06 = MGSeqFinishCreate(); temp_r31->unk_04++; HuAudSeqFadeOut(temp_r31->unk_44, 100); } @@ -362,7 +362,7 @@ void fn_1_5574(void) { temp_r31 = lbl_1_bss_397C->data; if (temp_r31->unk_04 == 0) { GWMGRecordSet(1, fn_1_28D4()); - temp_r31->unk_06 = MGSeqCreate(14, fn_1_28D4()); + temp_r31->unk_06 = MGSeqRecordCreate(fn_1_28D4()); fn_1_5F40(1); temp_r31->unk_04++; return; @@ -384,15 +384,15 @@ void fn_1_5630(void) { } } if (temp_r31->unk_24 == 0) { - temp_r31->unk_06 = MGSeqCreate(3, 2); + temp_r31->unk_06 = MGSeqDrawCreate(); HuAudSStreamPlay(4); } else { - temp_r31->unk_06 = MGSeqCreate(5, 3, fn_1_4C0(temp_r31->unk_1C[0]), fn_1_4C0(temp_r31->unk_1C[1]), fn_1_4C0(temp_r31->unk_1C[2]), fn_1_4C0(temp_r31->unk_1C[3])); + temp_r31->unk_06 = MGSeqWinCreate(fn_1_4C0(temp_r31->unk_1C[0]), fn_1_4C0(temp_r31->unk_1C[1]), fn_1_4C0(temp_r31->unk_1C[2]), fn_1_4C0(temp_r31->unk_1C[3])); for (i = 0; i < ARRAY_COUNT(temp_r31->unk_1C); i++) { if (temp_r31->unk_1C[i] != -1) { fn_1_3C4(temp_r31->unk_1C[i]); - GWPlayerCoinWinSet(temp_r31->unk_1C[i], GWPlayerCoinWinGet(temp_r31->unk_1C[i])+10); - } + GWPlayerCoinWinAdd(temp_r31->unk_1C[i], 10); + } } HuAudSStreamPlay(1); } @@ -500,7 +500,7 @@ void fn_1_5BB0(void) { temp_r31 = lbl_1_bss_397C->data; if (temp_r31->unk_04 == 0) { - temp_r31->unk_06 = MGSeqCreate(3, 2); + temp_r31->unk_06 = MGSeqDrawCreate(); temp_r31->unk_04++; } if (MGSeqStatGet(temp_r31->unk_06) == 0) { diff --git a/src/REL/modeltestDll/main.c b/src/REL/modeltestDll/main.c index e877c495..c2609edb 100644 --- a/src/REL/modeltestDll/main.c +++ b/src/REL/modeltestDll/main.c @@ -11,6 +11,7 @@ #include "game/window.h" #include "game/gamework_data.h" #include "game/sprite.h" +#include "game/minigame_seq.h" #include "REL/modeltestDll.h" @@ -287,7 +288,7 @@ void fn_1_29C(omObjData * arg0) HuSprExecLayerSet(0x40, 1); HuSprGrpDrawNoSet(lbl_1_bss_99C, 0x40); lbl_1_bss_458 = 0x293; - lbl_1_bss_45A[0] = MGSeqCreate(1, lbl_1_bss_458 / 60, -1, -1); + lbl_1_bss_45A[0] = MGSeqTimerCreate(lbl_1_bss_458 / 60); temp_r29 = HuDataSelHeapReadNum(0x120001, 0x10000000, 2); temp_r28 = HuSprAnimRead(temp_r29); lbl_1_bss_888 = Hu3DParManCreate(temp_r28, 0x3E8, &lbl_1_data_208); @@ -505,27 +506,27 @@ void fn_1_F9C(struct om_obj_data * omData) } if ((HuPadBtnDown[0] & PAD_BUTTON_B) != 0) { - var_r30 = MGSeqCreate(teropPatterns.unk0[lbl_1_bss_24], 0); + var_r30 = MGSeqStartCreateType(teropPatterns.unk0[lbl_1_bss_24]); } if ((HuPadBtnDown[0] & PAD_BUTTON_A) != 0) { - var_r30 = MGSeqCreate(teropPatterns.unk0[lbl_1_bss_24], 2); + var_r30 = MGSeqDrawCreateType(teropPatterns.unk0[lbl_1_bss_24]); } if ((HuPadBtnDown[0] & PAD_BUTTON_Y) != 0) { - var_r30 = MGSeqCreate(0xE, 0x3B); + var_r30 = MGSeqRecordCreate(59); } if ((HuPadBtnDown[0] & (PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT | PAD_BUTTON_UP | PAD_BUTTON_DOWN)) != 0) { if ((HuPadBtnDown[0] & PAD_BUTTON_UP) != 0) { - MGSeqCreate(0xC, 5, GWPlayerCfg[0].character, -1, -1, -1); + MGSeqChampionCreate(GWPlayerCfg[0].character, -1, -1, -1); } if ((HuPadBtnDown[0] & PAD_BUTTON_LEFT) != 0) { - MGSeqCreate(0xC, 5, GWPlayerCfg[0].character, GWPlayerCfg[1].character, -1, -1); + MGSeqChampionCreate(GWPlayerCfg[0].character, GWPlayerCfg[1].character, -1, -1); } if ((HuPadBtnDown[0] & PAD_BUTTON_DOWN) != 0) { - MGSeqCreate(0xC, 5, GWPlayerCfg[0].character, GWPlayerCfg[1].character, GWPlayerCfg[2].character, -1); + MGSeqChampionCreate(GWPlayerCfg[0].character, GWPlayerCfg[1].character, GWPlayerCfg[2].character, -1); } if ((HuPadBtnDown[0] & PAD_BUTTON_RIGHT) != 0) { - MGSeqCreate(0xC, 5, GWPlayerCfg[0].character, GWPlayerCfg[1].character, GWPlayerCfg[2].character, GWPlayerCfg[3].character); + MGSeqChampionCreate(GWPlayerCfg[0].character, GWPlayerCfg[1].character, GWPlayerCfg[2].character, GWPlayerCfg[3].character); } } fontcolor = 5; diff --git a/src/REL/w01Dll/mg_item.c b/src/REL/w01Dll/mg_item.c index 5a1b133a..79acc244 100755 --- a/src/REL/w01Dll/mg_item.c +++ b/src/REL/w01Dll/mg_item.c @@ -337,7 +337,7 @@ static void fn_1_E914(omObjData *arg0) { lbl_1_bss_7FC[i]->func = fn_1_FED0; } BoardPlayerMotionShiftSet(lbl_1_bss_7E4, lbl_1_bss_7B8, 0.0f, 5.0f, 0x40000001); - lbl_1_bss_7D6 = MGSeqCreate(3, 0); + lbl_1_bss_7D6 = MGSeqStartCreate(); BoardMusStart(1, 0xE, 0x7F, 0); arg0->func = fn_1_ECD4; } @@ -359,7 +359,7 @@ static void fn_1_ECD4(omObjData *arg0) { arg0->func = fn_1_EED8; lbl_1_bss_7D2 = 5; lbl_1_bss_7D0 = 60; - lbl_1_bss_7D4 = MGSeqCreate(1, lbl_1_bss_7D2, 0x120, 0x40); + lbl_1_bss_7D4 = MGSeqTimerCreateXY(lbl_1_bss_7D2, 288, 64); } BoardModelMotionSpeedSet(lbl_1_bss_6C4[17], lbl_1_bss_7EC); BoardModelMotionSpeedSet(lbl_1_bss_6C4[18], lbl_1_bss_7E8); diff --git a/src/REL/w03Dll/mg_coin.c b/src/REL/w03Dll/mg_coin.c index e9238dc7..a52e5570 100644 --- a/src/REL/w03Dll/mg_coin.c +++ b/src/REL/w03Dll/mg_coin.c @@ -209,7 +209,7 @@ void fn_1_8140(s32 arg0) { fn_1_81E0(arg0); BoardMusStart(1, 0x16, 0x7F, 0); - temp_r31 = MGSeqCreate(3, 0); + temp_r31 = MGSeqStartCreate(); while (MGSeqStatGet(temp_r31)) { HuPrcVSleep(); @@ -305,7 +305,7 @@ void fn_1_84A8(s32 arg0) { temp_r31 = OM_GET_WORK_PTR(lbl_1_bss_144, someBits3); temp_r31->unk00_bit1 = arg0; if (arg0 == 0) { - temp_r31->unk_04 = MGSeqCreate(1, temp_r31->unk2, 0x120, 0x40); + temp_r31->unk_04 = MGSeqTimerCreateXY(temp_r31->unk2, 288, 64); } } } diff --git a/src/REL/w03Dll/mg_item.c b/src/REL/w03Dll/mg_item.c index ea7c19b3..4a4ab195 100644 --- a/src/REL/w03Dll/mg_item.c +++ b/src/REL/w03Dll/mg_item.c @@ -345,7 +345,7 @@ void fn_1_A44C(s32 arg0) { s32 temp_r28; BoardMusStart(1, 0x17, 0x7F, 0); - temp_r30 = MGSeqCreate(3, 0); + temp_r30 = MGSeqStartCreate(); while (MGSeqStatGet(temp_r30) != 0) { HuPrcVSleep(); @@ -434,7 +434,7 @@ void fn_1_A7A0(s32 arg0) { temp_r31->unk00_bit1 = 0; temp_r31->unk1 = 5U; temp_r31->unk2 = 0x3C; - temp_r31->unk4 = MGSeqCreate(1, temp_r31->unk1, 0x120, 0x40); + temp_r31->unk4 = MGSeqTimerCreateXY(temp_r31->unk1, 288, 64); fn_1_BB74(lbl_1_bss_194); lbl_1_bss_18C = fn_1_AE4C(arg0, lbl_1_bss_194); } diff --git a/src/REL/w06Dll/mg_item.c b/src/REL/w06Dll/mg_item.c index cf6d9691..a0e93a6d 100755 --- a/src/REL/w06Dll/mg_item.c +++ b/src/REL/w06Dll/mg_item.c @@ -295,7 +295,7 @@ static void fn_1_15CC(s32 arg0) { s32 var_r31; BoardMusStart(1, 0x26, 0x7F, 0); - temp_r26 = MGSeqCreate(3, 0); + temp_r26 = MGSeqStartCreate(); while (MGSeqStatGet(temp_r26) != 0) { HuPrcVSleep(); } @@ -1072,7 +1072,7 @@ static void fn_1_4070(void) { temp_r31->unk00_field0 = 0; temp_r31->unk01 = 5; temp_r31->unk02 = 60; - temp_r31->unk04 = MGSeqCreate(1, temp_r31->unk01, 0x120, 0x40); + temp_r31->unk04 = MGSeqTimerCreateXY(temp_r31->unk01, 288, 64); } static void fn_1_4124(void) { diff --git a/src/game/minigame_seq.c b/src/game/minigame_seq.c index dceadba4..6834f870 100644 --- a/src/game/minigame_seq.c +++ b/src/game/minigame_seq.c @@ -83,15 +83,15 @@ static s32 seqType2SprTbl[6] = { }; static s16 mgSeqTypeTbl[9] = { - 8, - 4, - 9, - 11, - 6, - 10, - 7, - 11, - 7 + MG_SEQ_TYPE_4P, + MG_SEQ_TYPE_1VS3, + MG_SEQ_TYPE_2VS2, + MG_SEQ_TYPE_BOWSER, + MG_SEQ_TYPE_BATTLE, + MG_SEQ_TYPE_PINBALL, + MG_SEQ_TYPE_STORY, + MG_SEQ_TYPE_BOWSER, + MG_SEQ_TYPE_STORY }; static char lbl_8012F336[] = { @@ -252,9 +252,9 @@ s16 MGSeqCreate(s16 type, ...) s16 ret; va_list params; va_start(params, type); - if(type == 3) { + if(type == MG_SEQ_TYPE_AUTO) { if(GWSystem.mg_next == 0xFFFF) { - type = 8; + type = MG_SEQ_TYPE_4P; } else { type = mgSeqTypeTbl[mgInfoTbl[GWSystem.mg_next].type]; }