Matched game/board/battle

This commit is contained in:
mrshigure 2024-03-07 07:00:04 -08:00
parent 71a8dcf814
commit 9c5b9da592
8 changed files with 891 additions and 81 deletions

View file

@ -387,7 +387,7 @@ config.libs = [
Object(Matching, "game/board/block.c"),
Object(Matching, "game/board/item.c"),
Object(NonMatching, "game/board/bowser.c"),
Object(NonMatching, "game/board/battle.c"),
Object(Matching, "game/board/battle.c"),
Object(NonMatching, "game/board/fortune.c"),
Object(Matching, "game/board/boo.c"),
Object(NonMatching, "game/board/mg_setup.c"),

View file

@ -32,7 +32,6 @@ s32 BoardCameraRotGet(Vec*);
s32 BoardIsKill(void);
void BoardBowserExec(s32 player, s32 space);
void BoardBattleExec(s32 player, s32 space);
void BoardFortuneExec(s32 player, s32 space);
#endif

8
include/game/board/battle.h Executable file
View file

@ -0,0 +1,8 @@
#ifndef _BOARD_BATTLE_H
#define _BOARD_BATTLE_H
#include "dolphin/types.h"
void BoardBattleExec(s32 player, s32 space);
#endif

832
src/game/board/battle.c Executable file
View file

@ -0,0 +1,832 @@
#include "game/board/battle.h"
#include "game/audio.h"
#include "game/chrman.h"
#include "game/data.h"
#include "game/gamework.h"
#include "game/object.h"
#include "game/objsub.h"
#include "game/process.h"
#include "game/wipe.h"
#include "game/board/audio.h"
#include "game/board/main.h"
#include "game/board/model.h"
#include "game/board/player.h"
#include "game/board/tutorial.h"
#include "game/board/ui.h"
#include "game/board/window.h"
#define ABS(x) ((x) < 0 ? -(x) : (x))
typedef struct {
struct {
u8 unk00_field0 : 1;
u8 unk00_field1 : 2;
};
s8 unk01;
s16 unk02;
s16 unk04[4];
} ExplodeWork;
typedef struct {
struct {
u8 unk00_field0 : 1;
u8 unk00_field1 : 4;
u8 unk00_field2 : 1;
u8 unk00_field3 : 1;
};
u8 unk01;
s8 unk02;
s8 unk03;
s8 unk04;
char unk05[3];
s16 unk08;
} BattleWork;
extern s32 BoardMGSetupPlayPush(s32, s16);
extern void BoardMGSetupPlayPop(s32, s16);
static void DestroyBattle(void);
static void ExecBattle(void);
static void TakeCoins(void);
static void InitExplode(void);
static s32 CheckExplode(void);
static void UpdateExplode(omObjData *arg0);
static void CreateBattleMain(void);
static void UpdateBattleMain(omObjData *arg0);
static void DescendBattleBomb(BattleWork *arg0, omObjData *arg1);
static void EndBattle(BattleWork *arg0, omObjData *arg1);
static void ShowBattleGame(BattleWork *arg0, omObjData *arg1);
static void RaiseBattleGame(BattleWork *arg0, omObjData *arg1);
static void UpdateBattleCoin(BattleWork *arg0, omObjData *arg1);
static void ShowBattleCoin(BattleWork *arg0, omObjData *arg1);
static void InitBattleGameSpr(BattleWork *arg0, omObjData *arg1);
static void HideBattleSpr(void);
static void VibratePad(BattleWork *arg0, omObjData *arg1);
static void StopBattleBomb(void);
static s32 GetBattleBombState(void);
static void SetBattleBombState(s32 arg0);
static void SetBattleCoinValue(void);
static s16 battleMGList[8];
static s8 currPlayer;
static s8 coinTakeMax;
static u8 mgChoice;
static s16 currSpace;
static s8 battleCoinIdx;
static s8 battleMGIdx[2];
static char totalCoinStr[8];
static float battleCoinSpeed;
static float battleCoinPosF;
static omObjData *explodeObj;
static omObjData *battleObj;
static Process *battleProc;
static const s8 battleCoinTbl[] = {
0x05, 0x0A, 0x14, 0x1E, 0x32
};
static float battleCursorPosTbl[] = {
144.0f, 330.0f, 0.0f,
432.0f, 330.0f, 0.0f
};
static s32 bombFXTbl[] = {
0x00000123,
0x00000163,
0x000001A3,
0x000001E3,
0x00000223,
0x00000263,
0x000002A3,
0x000002E3
};
static s16 battleSprPrioTbl[] = {
1000, 990, 1000, 980,
980, 970, 970, 970,
970, 970, 970
};
void BoardBattleExec(s32 player, s32 space) {
if (_CheckFlag(0x1000B)) {
HuAudFXPlay(0x34A);
BoardCameraViewSet(2);
BoardPlayerMotBlendSet(player, 0, 0xF);
while (!BoardPlayerMotBlendCheck(player)) {
HuPrcVSleep();
}
BoardCameraMotionWait();
BoardTutorialHookExec(0xF, 0);
GWPlayer[player].color = 3;
return;
}
currPlayer = player;
currSpace = space;
battleProc = HuPrcChildCreate(ExecBattle, 0x2004, 0x3800, 0, boardMainProc);
HuPrcDestructorSet2(battleProc, DestroyBattle);
while (battleProc) {
HuPrcVSleep();
}
GWPlayer[player].color = 3;
}
static void DestroyBattle(void) {
HuDataDirClose(0x10000);
battleProc = NULL;
}
static void ExecBattle(void) {
s16 temp_r28;
s16 var_r26;
s32 temp_r22;
s32 var_r21;
s32 var_r30;
s32 var_r31;
s32 var_r25;
s32 var_r24;
s32 var_r23;
MgInfo *var_r29;
s32 var_r27 = 0;
s32 sp8[] = {
0x00750000,
0x00760000,
0x00770000,
0x00780000,
0x00790000,
0x007A0000,
0x007B0000,
0x007C0000,
0x007D0000
};
var_r29 = mgInfoTbl;
for (var_r31 = var_r30 = 0; var_r29->ovl != (u16) OVL_INVALID; var_r29++, var_r31++) {
if (var_r29->type == 4) {
battleMGList[var_r30] = var_r31 + 401;
var_r30++;
}
}
for (var_r30 = 0; var_r30 < 2; var_r30++) {
while (1) {
var_r31 = BoardRandMod(6);
temp_r28 = battleMGList[var_r31];
if (GWMGListGet() == 2) {
if (GWMGCustomGet(temp_r28) == 0) {
continue;
}
} else {
if (GWMGListGet() == 1) {
var_r29 = &mgInfoTbl[temp_r28 - 401];
if (!(var_r29->flag & 1)) {
continue;
}
} else if (BoardMGSetupPlayPush(4, temp_r28) != 0) {
continue;
}
}
if (var_r30 == 1 && var_r31 == battleMGIdx[var_r30 - 1]) {
continue;
}
break;
}
battleMGIdx[var_r30] = var_r31;
BoardMGSetupPlayPop(4, temp_r28);
}
if (_CheckFlag(0x10004)) {
BoardStatusItemSet(1);
WipeCreate(1, 0, -1);
while (WipeStatGet() != 0) {
HuPrcVSleep();
}
_ClearFlag(0x1001C);
HuPrcSleep(0x3C);
HuPrcEnd();
}
HuAudFXPlay(0x34A);
omVibrate(GWSystem.player_curr, 0xC, 6, 6);
BoardAudSeqPause(0, 1, 0x1F4);
temp_r22 = BoardDataDirReadAsync(0x10000);
BoardCameraViewSet(3);
BoardCameraMotionWait();
BoardPlayerMotBlendSet(currPlayer, 0, 0xF);
while (!BoardPlayerMotBlendCheck(currPlayer)) {
HuPrcVSleep();
}
BoardDataAsyncWait(temp_r22);
SetBattleCoinValue();
BoardMusStart(1, 4, 0x7F, 0);
omVibrate(GWSystem.player_curr, 0xC, 6, 6);
InitExplode();
while (CheckExplode() == 0) {
HuPrcVSleep();
}
HuPrcSleep(30);
CreateBattleMain();
while (GetBattleBombState() != 8) {
HuPrcVSleep();
}
var_r26 = 0;
for (var_r31 = 0; var_r31 < 4; var_r31++) {
if (BoardPlayerCoinsGet(var_r31) >= 10) {
var_r26 = 1;
break;
}
}
if (var_r26 == 0) {
BoardWinCreate(2, 0x20001, 1);
BoardWinWait();
BoardWinKill();
var_r27 = 1;
} else {
HuAudFXPlay(0x4F);
BoardWinCreate(2, 0x20000, 1);
BoardWinWait();
BoardWinKill();
SetBattleBombState(3);
while (GetBattleBombState() != 8) {
HuPrcVSleep();
}
SetBattleBombState(4);
while (GetBattleBombState() != 8) {
HuPrcVSleep();
}
TakeCoins();
if (GWPlayer[currPlayer].com) {
if (BoardRandFloat() < 0.5f) {
var_r23 = 0;
} else {
var_r23 = 1;
}
var_r25 = var_r23;
HuPrcSleep(0x3C);
} else {
var_r25 = -1;
}
SetBattleBombState(5);
BoardPickerCreate(currPlayer, 2, battleCursorPosTbl, var_r25);
BoardPickerBackFlagSet(0);
while (!BoardPickerDoneCheck()) {
HuPrcVSleep();
}
mgChoice = BoardPickerChoiceGet();
SetBattleBombState(6);
while (GetBattleBombState() != 8) {
HuPrcVSleep();
}
BoardAudSeqFadeOut(1, 1000);
BoardMusVolPanSet(0, 0, 1);
BoardAudSeqPause(0, 0, 1);
if (var_r27 == 0) {
HuDataDirClose(0x70000);
HuDataDirClose(0x20000);
HuDataDirClose(sp8[GWBoardGet()]);
HuPrcSleep(2);
temp_r28 = battleMGList[battleMGIdx[mgChoice]];
GWMGAvailSet(temp_r28);
GWSystem.mg_next = temp_r28 - 401;
if (_CheckFlag(0xB)) {
var_r24 = 0x140000;
} else {
var_r24 = mgInfoTbl[temp_r28 - 401].data_dir;
}
var_r21 = BoardDataDirReadAsync(var_r24);
}
_SetFlag(0x1000E);
WipeColorSet(0xFF, 0xFF, 0xFF);
WipeCreate(2, 0, -1);
while (WipeStatGet() != 0) {
HuPrcVSleep();
}
HuAudFXAllStop();
_SetFlag(0x1001C);
HideBattleSpr();
for (var_r31 = 0; var_r31 < 4; var_r31++) {
BoardPlayerMotionStart(var_r31, 1, 0x40000001);
}
BoardDataAsyncWait(var_r21);
if (var_r27 == 0) {
_SetFlag(0x10004);
BoardNextOvlSet(OVL_INST);
BoardFilterFadeOut(30);
StopBattleBomb();
HuPrcEnd();
}
}
BoardAudSeqFadeOut(1, 1000);
SetBattleBombState(1);
while (GetBattleBombState() != 8) {
HuPrcVSleep();
}
StopBattleBomb();
for (var_r31 = 0; var_r31 < 4; var_r31++) {
BoardRotateDiceNumbers(var_r31);
BoardPlayerVoiceEnableSet(var_r31, 6, 1);
}
BoardAudSeqPause(0, 0, 1000);
HuPrcEnd();
}
static void TakeCoins(void) {
u16 var_r30;
s32 temp_r26;
s32 var_r25;
s32 var_r24;
s32 var_r29;
s32 var_r28;
s32 var_r27;
s32 i;
for (var_r30 = i = 0; i < 4; i++) {
temp_r26 = BoardPlayerCoinsGet(i);
if (temp_r26 >= coinTakeMax) {
var_r30 += coinTakeMax;
} else {
var_r30 += temp_r26;
}
}
if (coinTakeMax >= 50) {
var_r27 = 1;
} else if (coinTakeMax >= 20) {
var_r27 = 3;
} else {
var_r27 = 6;
}
for (i = 0; i < 4; i++) {
if (BoardPlayerCoinsGet(i) < coinTakeMax) {
var_r25 = BoardPlayerCoinsGet(i);
} else {
var_r25 = coinTakeMax;
}
GWPlayer[i].coins_battle = var_r25;
}
for (var_r29 = 0; var_r29 < coinTakeMax; var_r29++) {
for (var_r28 = i = 0; i < 4; i++) {
BoardPlayerCoinsAdd(i, -1);
var_r28 += BoardPlayerCoinsGet(i);
}
if (var_r28 <= 0) {
break;
}
HuAudFXPlay(0xE);
HuPrcSleep(var_r27);
}
HuAudFXPlay(0xF);
sprintf(totalCoinStr, "%d", var_r30);
if (var_r30 != coinTakeMax * 4) {
var_r24 = 0x20003;
} else {
var_r24 = 0x20002;
}
BoardWinCreate(2, var_r24, 1);
BoardWinInsertMesSet((u32) totalCoinStr, 0);
BoardWinWait();
BoardWinKill();
}
static void InitExplode(void) {
Vec sp14;
Vec sp8;
s32 i;
ExplodeWork *temp_r31;
float sp20[4][2] = {
{ -50.0f, -50.0f },
{ 50.0f, -50.0f },
{ -50.0f, 50.0f },
{ 50.0f, 50.0f }
};
BoardPlayerPosGet(currPlayer, &sp14);
explodeObj = omAddObjEx(boardObjMan, 0x101, 0, 0, -1, UpdateExplode);
temp_r31 = OM_GET_WORK_PTR(explodeObj, ExplodeWork);
temp_r31->unk00_field0 = 0;
temp_r31->unk00_field1 = 0;
temp_r31->unk01 = 0x10;
temp_r31->unk02 = BoardModelCreate(0x20026, NULL, 0);
BoardModelLayerSet(temp_r31->unk02, 2);
explodeObj->trans.x = sp14.x;
explodeObj->trans.y = sp14.y - 100.0f;
explodeObj->trans.z = sp14.z;
BoardModelPosSet(temp_r31->unk02, explodeObj->trans.x, explodeObj->trans.y, explodeObj->trans.z);
BoardModelMotionStart(temp_r31->unk02, 0, 0x40000001);
for (i = 0; i < 4; i++) {
temp_r31->unk04[i] = BoardModelCreate(0x70066, NULL, 0);
sp8.x = sp14.x + sp20[i][0];
sp8.y = sp14.y;
sp8.z = sp14.z + sp20[i][1];
BoardModelPosSetV(temp_r31->unk04[i], &sp8);
BoardModelLayerSet(temp_r31->unk04[i], 2);
}
HuAudFXPlay(0x33C);
}
static s32 CheckExplode(void) {
ExplodeWork *temp_r31 = OM_GET_WORK_PTR(explodeObj, ExplodeWork);
return temp_r31->unk00_field1;
}
static void UpdateExplode(omObjData *arg0) {
Vec sp14;
Vec sp8;
float temp_f31;
ExplodeWork *temp_r30;
Mtx sp20;
s32 i;
(void) 1000.0f; // TODO: 1000.0f needs to appear right before 20.0f in sdata2 to match.
temp_r30 = OM_GET_WORK_PTR(arg0, ExplodeWork);
if (temp_r30->unk00_field0 != 0 || BoardIsKill()) {
BoardModelKill(temp_r30->unk02);
for (i = 0; i < 4; i++) {
BoardModelKill(temp_r30->unk04[i]);
}
explodeObj = NULL;
omDelObjEx(HuPrcCurrentGet(), arg0);
return;
}
switch (temp_r30->unk00_field1) {
case 0:
if (temp_r30->unk01 == 0) {
for (i = 0; i < 4; i++) {
if (currSpace == GWPlayer[i].space_curr) {
temp_f31 = 20.0f * BoardRandFloat();
HuAudFXPlay(bombFXTbl[GWPlayer[i].character]);
BoardPlayerMotionShiftSet(i, 6, temp_f31, 8.0f, 0x40000001);
}
}
CharModelLayerSetAll(2);
}
if (temp_r30->unk01-- <= 0) {
arg0->trans.y += 50.0f;
if (arg0->trans.y >= 800.0f) {
arg0->scale.x = 288.0f;
arg0->scale.y = -128.0f;
arg0->scale.z = 1000.0f;
for (i = 0; i < 4; i++) {
BoardModelVisibilitySet(temp_r30->unk04[i], 0);
}
temp_r30->unk00_field1 = 2;
}
}
break;
case 3:
BoardModelVisibilitySet(temp_r30->unk02, 0);
temp_r30->unk00_field0 = 1;
break;
case 2:
BoardCameraRotGet(&sp8);
PSMTXRotRad(sp20, 'x', MTXDegToRad(sp8.x + 10.0f));
BoardModelMtxSet(temp_r30->unk02, &sp20);
BoardModelRotSet(temp_r30->unk02, 0.0f, 0.0f, 0.0f);
sp14.x = arg0->scale.x;
sp14.y = arg0->scale.y;
sp14.z = arg0->scale.z;
Hu3D2Dto3D(&sp14, 1, &sp14);
arg0->trans.x = sp14.x;
arg0->trans.y = sp14.y;
arg0->trans.z = sp14.z;
break;
}
BoardModelPosSet(temp_r30->unk02, arg0->trans.x, arg0->trans.y, arg0->trans.z);
}
static void CreateBattleMain(void) {
s16 sp8;
s32 var_r29;
s32 i;
BattleWork *temp_r31;
s32 spC[] = {
0x00010000,
0x00010001,
0x00010002,
0x00010003,
0x00010003,
0x00010004,
0x00010005,
0x00010006,
0x00010007,
0x00010008,
0x00010009
};
battleObj = omAddObjEx(boardObjMan, 0x101, 0, 0, -1, UpdateBattleMain);
temp_r31 = OM_GET_WORK_PTR(battleObj, BattleWork);
temp_r31->unk00_field0 = 0;
temp_r31->unk00_field2 = 0;
temp_r31->unk01 = 0;
temp_r31->unk02 = 2;
temp_r31->unk03 = 2;
temp_r31->unk04 = 0;
temp_r31->unk00_field3 = 0;
temp_r31->unk00_field1 = 0;
battleCoinSpeed = 1.0f;
battleCoinPosF = 5.0f * BoardRandFloat();
coinTakeMax = 0;
temp_r31->unk08 = HuSprGrpCreate(11);
for (i = 0; i < 11; i++) {
var_r29 = spC[i];
BoardSpriteCreate(var_r29, battleSprPrioTbl[i], 0, &sp8);
HuSprGrpMemberSet(temp_r31->unk08, i, sp8);
HuSprAttrSet(temp_r31->unk08, i, 9);
HuSprAttrSet(temp_r31->unk08, i, 4);
}
HuSprGrpPosSet(temp_r31->unk08, 288.0f, 240.0f);
battleObj->trans.x = -308.0f;
BoardFilterFadeInit(0x1E, 0xA0);
}
static void UpdateBattleMain(omObjData *arg0) {
BattleWork *temp_r30;
ExplodeWork *temp_r29;
float var_f31;
temp_r30 = OM_GET_WORK_PTR(arg0, BattleWork);
if (temp_r30->unk00_field0 != 0 || BoardIsKill()) {
HuSprGrpKill(temp_r30->unk08);
battleObj = NULL;
omDelObjEx(HuPrcCurrentGet(), arg0);
return;
}
switch (temp_r30->unk00_field1) {
case 0:
DescendBattleBomb(temp_r30, arg0);
break;
case 1:
EndBattle(temp_r30, arg0);
break;
case 2:
ShowBattleGame(temp_r30, arg0);
break;
case 3:
RaiseBattleGame(temp_r30, arg0);
break;
case 4:
UpdateBattleCoin(temp_r30, arg0);
break;
case 5:
InitBattleGameSpr(temp_r30, arg0);
break;
case 6:
VibratePad(temp_r30, arg0);
break;
case 7:
ShowBattleCoin(temp_r30, arg0);
break;
case 8:
break;
}
var_f31 = arg0->trans.x + 240.0f;
temp_r29 = OM_GET_WORK_PTR(explodeObj, ExplodeWork);
if (temp_r29->unk00_field1 == 2) {
explodeObj->scale.x = 288.0f;
explodeObj->scale.y = var_f31;
explodeObj->scale.z = 1000.0f;
}
HuSprPosSet(temp_r30->unk08, 0, 0.0f, arg0->trans.y);
HuSprScaleSet(temp_r30->unk08, 0, arg0->trans.z, arg0->trans.z);
}
static void DescendBattleBomb(BattleWork *arg0, omObjData *arg1) {
float temp_f31 = -132.0f - arg1->trans.x;
if (temp_f31 < 0.1f) {
arg1->trans.x = -132.0f;
arg0->unk00_field1 = 2;
} else {
arg1->trans.x += 0.3f * temp_f31;
}
}
static void EndBattle(BattleWork *arg0, omObjData *arg1) {
float temp_f31 = 548.0f - arg1->trans.x;
if (temp_f31 < 0.1f) {
BoardFilterFadeOut(30);
arg0->unk00_field1 = 8;
} else {
arg1->trans.x += 0.3f * temp_f31;
}
}
static void ShowBattleGame(BattleWork *arg0, omObjData *arg1) {
float var_r29;
if (arg0->unk01 == 0) {
if (BoardFilterFadePauseCheck() != 0) {
arg0->unk01 = 1;
arg1->trans.z = 0.01f;
arg1->trans.y = 0.0f;
HuSprAttrReset(arg0->unk08, 0, 4);
HuSprPosSet(arg0->unk08, 0, 0.0f, 0.0f);
} else {
return;
}
}
if (arg0->unk01 >= 90) {
arg0->unk00_field1 = 8;
arg0->unk01 = 90;
}
OSs8tof32((s8*) &arg0->unk01, &var_r29);
arg1->trans.z = sin(var_r29 * M_PI / 180.0);
arg0->unk01 += 4;
}
static void RaiseBattleGame(BattleWork *arg0, omObjData *arg1) {
float temp_f31 = -60.0f - arg1->trans.y;
if (ABS(temp_f31) < 0.1f) {
arg1->trans.y = -60.0f;
arg0->unk00_field1 = 8;
} else {
arg1->trans.y += 0.2f * temp_f31;
}
}
static void UpdateBattleCoin(BattleWork *arg0, omObjData *arg1) {
s8 temp_r28;
if (arg0->unk00_field2 != 0) {
if (arg0->unk03++ < arg0->unk02) {
arg0->unk04++;
if (arg0->unk04 > 20) {
arg0->unk04 = 20;
}
return;
}
if (arg0->unk00_field3 == 0 && arg0->unk04 >= 20 && BoardRandMod(100) > 50) {
arg0->unk00_field3 = 1;
}
arg0->unk03 = 0;
if (arg0->unk00_field3 != 0) {
arg0->unk02 += 4;
if (arg0->unk02 > 30) {
arg0->unk02 = 30;
}
}
OSf32tos8(&battleCoinPosF, &temp_r28);
if (arg0->unk02 >= 30 && temp_r28 == battleCoinIdx) {
arg0->unk00_field1 = 7;
arg0->unk01 = 0;
coinTakeMax = battleCoinTbl[temp_r28];
HuAudFXPlay(0x305);
} else {
battleCoinPosF += 1.0f;
HuAudFXPlay(0x304);
if (battleCoinPosF >= 5.0f) {
battleCoinPosF = 0.0f;
}
}
HuSprBankSet(arg0->unk08, 1, temp_r28);
return;
}
HuSprAttrReset(arg0->unk08, 2, 4);
HuSprAttrReset(arg0->unk08, 1, 5);
HuSprPosSet(arg0->unk08, 2, 0.0f, 40.0f);
HuSprPosSet(arg0->unk08, 1, 34.0f, 40.0f);
HuSprScaleSet(arg0->unk08, 1, 0.9f, 0.9f);
arg0->unk00_field2 = 1;
arg0->unk01 = 0;
arg1->rot.x = 50.0f;
}
static void ShowBattleCoin(BattleWork *arg0, omObjData *arg1) {
float temp_f29;
float var_f30;
if (arg0->unk01 >= 90) {
arg0->unk01 = 0;
arg0->unk00_field1 = 8;
var_f30 = 90.0f;
} else {
arg0->unk01++;
OSu8tof32(&arg0->unk01, &var_f30);
}
if (coinTakeMax != 50) {
var_f30 *= 6.0f;
} else {
var_f30 *= 10.0f;
}
while (var_f30 > 180.0f) {
var_f30 -= 180.0f;
}
temp_f29 = 0.8999999761581421 + sin(var_f30 * M_PI / 180.0);
HuSprScaleSet(arg0->unk08, 1, temp_f29, temp_f29);
}
static void InitBattleGameSpr(BattleWork *arg0, omObjData *arg1) {
s8 temp_r30;
s8 temp_r29;
float sp8[2][2] = {
{ -130.0f, 30.0f },
{ 130.0f, 30.0f }
};
temp_r30 = battleMGIdx[0];
temp_r29 = battleMGIdx[1];
HuSprAttrReset(arg0->unk08, 3, 4);
HuSprAttrReset(arg0->unk08, 4, 4);
HuSprAttrReset(arg0->unk08, temp_r30 + 5, 4);
HuSprAttrReset(arg0->unk08, temp_r29 + 5, 4);
HuSprPosSet(arg0->unk08, 3, sp8[0][0], sp8[0][1]);
HuSprPosSet(arg0->unk08, 4, sp8[1][0], sp8[1][1]);
HuSprPosSet(arg0->unk08, temp_r30 + 5, sp8[0][0], sp8[0][1]);
HuSprPosSet(arg0->unk08, temp_r29 + 5, sp8[1][0], sp8[1][1]);
arg0->unk00_field1 = 8;
}
static void HideBattleSpr(void) {
BattleWork *temp_r30 = OM_GET_WORK_PTR(battleObj, BattleWork);
s32 i;
for (i = 0; i < 11; i++) {
HuSprAttrSet(temp_r30->unk08, i, 4);
}
}
static void VibratePad(BattleWork *arg0, omObjData *arg1) {
s32 i;
for (i = 0; i < 4; i++) {
omVibrate(i, 0xC, 0xC, 0);
}
arg0->unk00_field1 = 8;
}
static void StopBattleBomb(void) {
if (battleObj) {
OM_GET_WORK_PTR(battleObj, BattleWork)->unk00_field0 = 1;
}
}
static s32 GetBattleBombState(void) {
return OM_GET_WORK_PTR(battleObj, BattleWork)->unk00_field1;
}
static void SetBattleBombState(s32 arg0) {
BattleWork *var_r31 = OM_GET_WORK_PTR(battleObj, BattleWork);
var_r31->unk00_field1 = arg0;
var_r31->unk01 = 0;
}
static s8 battleChanceTbl[][3][5] = {
{
{ 0x0A, 0x55, 0x05, 0x00, 0x00 },
{ 0x0A, 0x4B, 0x0F, 0x00, 0x00 },
{ 0x0A, 0x41, 0x19, 0x00, 0x00 },
},
{
{ 0x05, 0x46, 0x14, 0x05, 0x00 },
{ 0x05, 0x3C, 0x19, 0x0A, 0x00 },
{ 0x05, 0x32, 0x1E, 0x0A, 0x00 },
},
{
{ 0x05, 0x3C, 0x14, 0x0A, 0x05 },
{ 0x05, 0x2D, 0x1E, 0x0F, 0x05 },
{ 0x05, 0x23, 0x1E, 0x14, 0x0A },
},
{
{ 0x05, 0x2D, 0x1E, 0x0F, 0x05 },
{ 0x05, 0x1E, 0x23, 0x14, 0x0A },
{ 0x05, 0x14, 0x23, 0x19, 0x0F }
}
};
static void SetBattleCoinValue(void) {
s32 temp_r26;
s32 temp_r25;
s32 var_r28;
s32 var_r29;
s32 var_r30;
s32 var_r27;
s32 i;
var_r30 = -1;
for (i = 0; i < 4; i++) {
if (BoardPlayerCoinsGet(i) > var_r30) {
var_r30 = BoardPlayerCoinsGet(i);
}
}
if (var_r30 >= 50) {
var_r29 = 3;
} else if (var_r30 >= 30) {
var_r29 = 2;
} else if (var_r30 >= 20) {
var_r29 = 1;
} else {
var_r29 = 0;
}
temp_r25 = 3.0f * ((float) GWSystem.turn / GWSystem.max_turn);
temp_r26 = BoardRandMod(100);
var_r27 = var_r28 = 0;
for (i = 4; i >= 0; i--) {
var_r28 += battleChanceTbl[var_r29][temp_r25][i];
if (temp_r26 < var_r28) {
var_r27 = i;
break;
}
}
battleCoinIdx = var_r27;
}

View file

@ -510,7 +510,7 @@ static BOOL CheckSwapUse(s32 player, s32 item) {
character = GWPlayer[player].character;
switch (diff) {
case 0:
chance = 0x32;
chance = 0x32;
break;
case 1:
chance = 0x19;

View file

@ -11,20 +11,17 @@
#include "game/window.h"
#include "game/wipe.h"
#include "game/board/audio.h"
#include "game/board/boo.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/star.h"
#include "game/board/ui.h"
#include "game/board/window.h"
#include "game/board/view.h"
#include "game/board/star.h"
#include "game/board/boo.h"
void BoardCharWheelWait(void);
typedef struct {
/* 0x00 */ s16 unk00;
/* 0x02 */ s16 unk02;
@ -52,9 +49,10 @@ typedef struct {
/* 0x04 */ Vec unk10;
} UnkGenieCameraStruct; // Size 0x1C
u32 frandmod(u32);
void BoardBowserSuitInit(s32);
s16 BoardBowserSuitPlayerModelGet(void);
extern u32 frandmod(u32);
extern void BoardBowserSuitInit(s32);
extern s16 BoardBowserSuitPlayerModelGet(void);
extern void BoardCharWheelWait(void);
static void ItemProcess(void);
static void RestoreProcess(void);
@ -93,14 +91,12 @@ static void RestoreItemMiniSuper(void);
static void RestoreItemMegaSuper(void);
static void RestoreItemBowser(void);
// BSS
static Vec booBallScale;
static Vec booBallPos;
static Vec booCamUp;
static Vec booCamTarget;
static Vec booCamPos;
// SBSS
static s16 itemBagItems[3];
static s8 currItemRestore;
static s8 currItem;
@ -110,16 +106,13 @@ static s32 suitCommonMot[2];
static s16 booBallMdl;
static float booBallAlpha;
static char booCoinStr[8];
// ...
static float genieFov;
static AnimData *genieParticleAnim;
static s16 geniePlayerMot[3];
static Process *itemProc;
// SDATA
s32 lbl_801D37A0[2] = { 0x00070075, -1 };
// DATA
static void (*itemFuncTbl[])(void) = {
ExecItemMini,
ExecItemMega,
@ -137,7 +130,6 @@ static void (*itemFuncTbl[])(void) = {
ExecItemBag
};
// DATA + 0x38
static void (*itemRestoreFuncTbl[])(void) = {
RestoreItemMini,
RestoreItemMega,
@ -155,7 +147,6 @@ static void (*itemRestoreFuncTbl[])(void) = {
RestoreItemNull
};
// DATA + 0x70
static s32 itemMdlTbl[] = {
0x0007006D,
0x0007006E,
@ -173,12 +164,10 @@ static s32 itemMdlTbl[] = {
0x0007007B
};
// DATA + 0xA8
static s32 forceMoveSfxTbl[] = {
0x38, 0x45, 0x42, 0x4D, 0x48, 0x3F
};
// DATA + 0xC0
static s32 callMotTbl[] = {
0x005F0052,
0x001A0052,
@ -190,10 +179,6 @@ static s32 callMotTbl[] = {
0x00810052
};
// DATA + 0xE0
// callHookTbl items
// DATA + 0x178
static char *callHookTbl[] = {
"c000m01-itemhook-r",
"c001m01-itemhook-r",
@ -205,7 +190,6 @@ static char *callHookTbl[] = {
"c007m01-itemhook-r"
};
// DATA + 0x198
static s32 callAttackMotTbl[] = {
0x0075001F,
0x00760005,
@ -215,7 +199,6 @@ static s32 callAttackMotTbl[] = {
0x007A0013
};
// DATA + 0x1B0
static s32 callAttackMotTbl2[] = {
0x00750020,
0x00760006,
@ -225,7 +208,6 @@ static s32 callAttackMotTbl2[] = {
0x007A0014
};
// DATA + 0x1C8
static s32 suitMotTbl[][2] = {
{ 0x00040001, 0x00040002 },
{ 0x00040004, 0x00040005 },
@ -301,7 +283,7 @@ static void ItemSizeShowAnim(void) {
BoardModelRotSetV(suitMdl, &spC);
BoardModelPosSetV(suitMdl, &sp24);
for (i = 0; i < 120; i++) {
sp24.y += 3.0 * sin(M_PI * var_f31 / 180.0);
sp24.y += 3.0 * sin(var_f31 * M_PI / 180.0);
BoardModelPosSetV(suitMdl, &sp24);
var_f31 += 9.0f;
if (var_f31 >= 360.0f) {
@ -334,7 +316,7 @@ static void ItemRotProc(void) {
while (1) {
if (temp_r31->unk00 == 0) {
sp14 = sp20;
sp14.y += temp_r31->unk04 * sin(M_PI * temp_r31->unk0C / 180.0);
sp14.y += temp_r31->unk04 * sin(temp_r31->unk0C * M_PI / 180.0);
BoardModelPosSetV(temp_r31->unk02, &sp14);
temp_r31->unk0C += temp_r31->unk08;
if (temp_r31->unk0C >= 360.0f) {
@ -446,8 +428,8 @@ static void BoardUiInlineFunc02(void) {
static inline void BoardUiInlineFunc03(s32 arg0) {
Vec sp8;
Vec sp14;
s32 space = GWPlayer[arg0].space_curr;
s32 space = GWPlayer[arg0].space_curr;
BoardSpacePosGet(0, space, &sp14);
BoardPlayerPosGet(arg0, &sp8);
BoardPlayerPosLerpStart(arg0, &sp8, &sp14, 0x14);
@ -774,7 +756,7 @@ static void ExecItemHammer(void) {
}
static void ExecItemPipe(void) {
Vec spE4[2];
Vec spE4[2];
Vec spCC[2];
Vec spB4[2];
Vec spA8;
@ -987,10 +969,10 @@ static void ExecItemPipe(void) {
for (var_r31 = 0; var_r31 < 2; var_r31++) {
BoardModelKill(sp30[var_r31]);
}
HuPrcKill(NULL);
while (1) {
HuPrcVSleep();
}
HuPrcKill(NULL);
while (1) {
HuPrcVSleep();
}
}
static void ExecItemSwap(void) {
@ -1140,12 +1122,12 @@ static void ExecItemSwap(void) {
for (var_r31 = 0; var_r31 < 0x3C; var_r31++) {
for (var_r30 = 0; var_r30 < var_r28 / 2; var_r30++) {
sp6C = sp1A4[var_r30];
sp6C.x += 3.0 * sin((M_PI * (frand() % 360)) / 180.0);
sp6C.y += 3.0 * sin((M_PI * (frand() % 360)) / 180.0);
sp6C.x += 3.0 * sin((frand() % 360) * M_PI / 180.0);
sp6C.y += 3.0 * sin((frand() % 360) * M_PI / 180.0);
BoardModelPosSetV(sp54[var_r30], &sp6C);
sp6C = sp180[var_r30];
sp6C.x += 3.0 * sin((M_PI * (frand() % 360)) / 180.0);
sp6C.y += 3.0 * sin((M_PI * (frand() % 360)) / 180.0);
sp6C.x += 3.0 * sin((frand() % 360) * M_PI / 180.0);
sp6C.y += 3.0 * sin((frand() % 360) * M_PI / 180.0);
BoardModelPosSetV(sp54[var_r30 + 3], &sp6C);
}
HuPrcSleep(2);
@ -1227,8 +1209,8 @@ static void ExecItemSpark(void) {
s32 temp_r28;
s16 temp_r30;
s32 i;
(void)106.0;
(void)106.0;
temp_r30 = BoardModelCreate(0x70067, NULL, 0);
BoardModelLayerSet(temp_r30, 3);
BoardModelVisibilitySet(temp_r30, 0);
@ -1279,8 +1261,8 @@ static void ExecItemSpark(void) {
BoardSpaceRotGet(0, GWPlayer[currItemRestore].space_curr, &sp20);
BoardModelRotSetV(suitMdl, &sp20);
BoardModelPosGet(suitMdl, &sp2C);
sp2C.z += 106.0 * sin(M_PI * sp20.x / 180.0);
sp2C.x -= 106.0 * sin(M_PI * sp20.z / 180.0);
sp2C.z += 106.0 * sin(sp20.x * M_PI / 180.0);
sp2C.x -= 106.0 * sin(sp20.z * M_PI / 180.0);
BoardModelPosSetV(suitMdl, &sp2C);
HuAudFXPlay(0x31B);
BoardModelMotionStart(suitMdl, 1, 0);
@ -1335,7 +1317,6 @@ static void ExecItemLight(void) {
}
}
// https://decomp.me/scratch/gbgTk
static void ExecItemWhistle(void) {
Vec spF0[4];
Vec spC0[4];
@ -1354,22 +1335,21 @@ static void ExecItemWhistle(void) {
s16 sp8;
float var_f30;
float var_f31;
s32 temp_r23;
char *temp_r22;
s32 temp_r23;
char *temp_r22;
s32 temp_r18;
s16 temp_r17;
s16 temp_r17;
s16 temp_r21;
s16 temp_r20;
s32 temp_r31;
s16 temp_r28;
s16 temp_r19;
s32 var_r26;
s16 temp_r19;
s32 var_r26;
s16 var_r25;
s16 var_r27;
s32 var_r29;
s32 var_r31;
var_r31 = GWPlayerCfg[currItemRestore].character;
temp_r23 = BoardPlayerMotionCreate(currItemRestore, callMotTbl[var_r31]);
temp_r22 = callHookTbl[var_r31];
@ -1379,7 +1359,7 @@ static void ExecItemWhistle(void) {
temp_r19 = GWBoardGet();
temp_r21 = BoardModelMotionCreate(temp_r28, callAttackMotTbl[temp_r19]);
temp_r20 = BoardModelMotionCreate(temp_r28, callAttackMotTbl2[temp_r19]);
var_f31 = 360.0f * (0.003921569f * (s32)((u8) frand()));
var_f31 = 0.003921569f * (frand() & 0xFF) * 360.0f;
spA8.x = spA8.y = spA8.z = 0.5f;
for (var_r31 = 0; var_r31 < 4; var_r31++) {
sp20[var_r31] = BoardModelCreate(0x20027, NULL, 1);
@ -1387,9 +1367,9 @@ static void ExecItemWhistle(void) {
temp_r17 = BoardModelMotionCreate(sp20[var_r31], 0x20028);
BoardModelMotionStart(sp20[var_r31], temp_r17, 0x40000001);
sp28[var_r31] = 120.0f;
spF0[var_r31].x = spB4.x + 120.0 * sin(M_PI * var_f31 / 180.0);
spF0[var_r31].x = spB4.x + 120.0 * sin(var_f31 * M_PI / 180.0);
spF0[var_r31].y = 1000.0f + spB4.y + 100.0f * var_r31;
spF0[var_r31].z = spB4.z + 120.0 * cos(M_PI * var_f31 / 180.0);
spF0[var_r31].z = spB4.z + 120.0 * cos(var_f31 * M_PI / 180.0);
spC0[var_r31].x = spC0[var_r31].z = 0.0f;
spC0[var_r31].y = var_f31 + 90.0f;
if (spC0[var_r31].y >= 360.0f) {
@ -1508,8 +1488,8 @@ static void ExecItemWhistle(void) {
if (spC0[var_r31].y >= 360.0f) {
spC0[var_r31].y -= 360.0f;
}
spF0[var_r31].x = spB4.x + 120.0 * sin(M_PI * sp38[var_r31] / 180.0);
spF0[var_r31].z = spB4.z + 120.0 * cos(M_PI * sp38[var_r31] / 180.0);
spF0[var_r31].x = spB4.x + 120.0 * sin(sp38[var_r31] * M_PI / 180.0);
spF0[var_r31].z = spB4.z + 120.0 * cos(sp38[var_r31] * M_PI / 180.0);
BoardModelPosSetV(sp20[var_r31], &spF0[var_r31]);
BoardModelRotSetV(sp20[var_r31], &spC0[var_r31]);
}
@ -1541,8 +1521,8 @@ static void ExecItemWhistle(void) {
spF0[var_r31].y = spB4.y;
sp48[var_r31] = -1.0f;
}
spF0[var_r31].x = spB4.x + sp28[var_r31] * sin(M_PI * sp38[var_r31] / 180.0);
spF0[var_r31].z = spB4.z + sp28[var_r31] * cos(M_PI * sp38[var_r31] / 180.0);
spF0[var_r31].x = spB4.x + sp28[var_r31] * sin(sp38[var_r31] * M_PI / 180.0);
spF0[var_r31].z = spB4.z + sp28[var_r31] * cos(sp38[var_r31] * M_PI / 180.0);
BoardModelPosSetV(sp20[var_r31], &spF0[var_r31]);
}
}
@ -1571,7 +1551,7 @@ static void ExecItemWhistle(void) {
BoardModelKill(sp20[var_r31]);
}
BoardModelMotionKill(temp_r28, temp_r21);
BoardModelMotionKill(temp_r28, temp_r20);
BoardModelMotionKill(temp_r28, temp_r20);
BoardStarShowNext(currItemRestore);
HuPrcKill(NULL);
while (1) {
@ -1654,9 +1634,9 @@ static void ExecItemBowser(void) {
}
static s32 booMotTbl[3] = {
0x00020018,
0x00020016,
-1
0x00020018,
0x00020016,
-1
};
static inline void ExecItemBooBallInlineFunc01(s32 speed) {
@ -1715,7 +1695,7 @@ static inline void ExecItemBooBallInlineFunc02(s32 speed) {
BoardModelPosSetV(booBallMdl, &booBallPos);
HuPrcVSleep();
}
booBallPos.y = sp20.y + 20.0f;
booBallPos.y = sp20.y + 20.0f;
booBallScale.x = booBallScale.y = booBallScale.z = 1.0f;
booBallAlpha = 255.0f;
BoardModelPosSetV(booBallMdl, &booBallPos);
@ -1723,7 +1703,6 @@ static inline void ExecItemBooBallInlineFunc02(s32 speed) {
BoardModelAlphaSet(booBallMdl, booBallAlpha);
}
// https://decomp.me/scratch/0M6lm
static void ExecItemBooBall(void) {
UnkItemShowProcStruct spA0;
UnkItemShowProcStruct sp80;
@ -1747,7 +1726,6 @@ static void ExecItemBooBall(void) {
BoardModelLayerSet(booBallMdl, 2);
BoardModelAttrSet(booBallMdl, 2);
BoardModelVisibilitySet(booBallMdl, 0);
// Inline? (same pattern in ExecItemGenie)
spA0.unk02 = suitMdl;
spA0.unk04 = 4.0f;
spA0.unk08 = 3.0f;
@ -1755,17 +1733,14 @@ static void ExecItemBooBall(void) {
spA0.unk1C = 1;
HuAudFXPlay(0x350);
temp_r17 = ItemShowProc(&spA0, NULL);
// ======================================
BoardModelPosGet(suitMdl, &booBallPos);
ExecItemBooBallInlineFunc02(60);
// Inline? =================================
sp80.unk02 = booBallMdl;
sp80.unk04 = 4.0f;
sp80.unk08 = 4.0f;
sp80.unk10 = sp80.unk14 = sp80.unk18 = 0.0f;
sp80.unk1C = 1;
sp1C = BoardUiInlineFunc05(&sp80);
// ======================================
BoardMusStart(1, 1, 0x7F, 0);
HuAudFXPlay(0x4C);
BoardWinCreate(2, 0x120015, 3);
@ -1791,14 +1766,14 @@ static void ExecItemBooBall(void) {
do {
BoardWinCreateChoice(4, 0x120018, 3, 0);
BoardWinAttrSet(0x10);
if (BoardPlayerCoinsGet(currItemRestore) < 0x32 || var_r28 == 0) {
if (BoardPlayerCoinsGet(currItemRestore) < 50 || var_r28 == 0) {
BoardWinChoiceDisable(1);
}
if (var_r26 == 0) {
BoardWinChoiceDisable(0);
}
if (GWPlayer[currItemRestore].com) {
if (var_r28 != 0 && BoardPlayerCoinsGet(currItemRestore) >= 0x32) {
if (var_r28 != 0 && BoardPlayerCoinsGet(currItemRestore) >= 50) {
BoardComKeySetDown();
} else {
BoardComKeySetUp();
@ -1944,9 +1919,9 @@ static void ExecItemBooBall(void) {
static void ForceConsts(void)
{
(void)-0.5f;
(void)40.0f;
(void)125.0f;
(void)-0.5f;
(void)40.0f;
(void)125.0f;
}
static void LampParticleUpdate(s32 arg0, ParticleData *arg1) {
@ -2071,7 +2046,6 @@ static void GenieParticleUpdate(s32 arg0, ParticleData *arg1) {
}
}
// DATA + 0x224
static Vec shadowPos = { 0.0f, 4500.0f, 500.0f };
static Vec shadowTarget = { 0.0f, 0.9f, -0.1f };
static Vec shadowUp = { 0.0f, 0.0f, 500.0f };
@ -2136,7 +2110,6 @@ static void GenieCameraCalc(UnkGenieCameraStruct *arg0, s32 arg1, float arg2, Ve
}
}
// DATA + 0x248
static s32 armUpMotTbl[] = {
0x005F005C,
0x001A005C,
@ -2148,7 +2121,6 @@ static s32 armUpMotTbl[] = {
0x0081005C
};
// DATA + 0x268
static s32 scareMotTbl[] = {
0x005F001C,
0x001A001C,
@ -2160,7 +2132,6 @@ static s32 scareMotTbl[] = {
0x0081001C
};
// DATA + 0x288
static s32 impactMotTbl[] = {
0x005F005E,
0x001A005E,
@ -2172,7 +2143,6 @@ static s32 impactMotTbl[] = {
0x0081005E
};
// DATA + 0x2A8
static UnkGenieCameraStruct cameraDataTbl[] = {
60.0f, { 0.0f, 100.0f, 950.0f }, { 0.0f, 100.0f, 600.0f },
60.0f, { -353.0f, 100.0f, 662.5f }, { 0.0f, 100.0f, 600.0f },
@ -2187,7 +2157,6 @@ static UnkGenieCameraStruct cameraDataTbl[] = {
5.0f, { 0.0f, 100.0f, -200.0f }, { 0.0f, 500.0f, 600.0f }
};
// DATA + 0x3DC
static s32 genieMotTbl[] = {
0x0007007D,
0x0007007E,
@ -2594,7 +2563,7 @@ static void ExecItemBagShow(void) {
break;
}
sp8 = sp14;
sp8.y += 15.0 * sin(M_PI * var_f31 / 180.0);
sp8.y += 15.0 * sin(var_f31 * M_PI / 180.0);
BoardModelPosSetV(suitMdl, &sp8);
var_f31 += 36.0f;
HuPrcVSleep();

View file

@ -8,6 +8,7 @@
#include "string.h"
#include "game/hsfman.h"
#include "game/hsfdraw.h"
#include "game/board/battle.h"
#include "game/board/lottery.h"
#include "game/board/main.h"
#include "game/board/model.h"

View file

@ -1,5 +1,6 @@
#include "game/gamework_data.h"
#include "game/flag.h"
#include "game/board/battle.h"
#include "game/board/lottery.h"
#include "game/board/main.h"
#include "game/board/model.h"