Merge pull request #207 from abnormalhare/main

mg_setup.c functions complete
This commit is contained in:
gamemasterplc 2024-03-11 23:55:46 -05:00 committed by GitHub
commit ed0aa74ec5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 531 additions and 6 deletions

View file

@ -5304,7 +5304,7 @@ statusLayout1Vs3 = .data:0x8013AD64; // type:object size:0x30 scope:local data:f
statusLayout2Vs2 = .data:0x8013AD94; // type:object size:0x30 scope:local data:float
luckyMessTbl = .data:0x8013ADC4; // type:object size:0x24 scope:local
jumptable_8013ADE8 = .data:0x8013ADE8; // type:object size:0x20 scope:local
cursorYTbl = .data:0x8013AE08; // type:object size:0x20 scope:local
hiliteYTbl = .data:0x8013AE08; // type:object size:0x10 scope:local
hiliteColTbl = .data:0x8013AE28; // type:object size:0xC scope:local
hostMesTbl = .data:0x8013AE38; // type:object size:0x90 scope:local
houseMdlTbl = .data:0x8013AEC8; // type:object size:0x30 scope:local

View file

@ -3,12 +3,14 @@
#include "game/objsub.h"
#include "game/wipe.h"
#include "game/flag.h"
#include "game/window.h"
#include "game/board/main.h"
#include "game/board/audio.h"
#include "game/board/player.h"
#include "game/board/space.h"
#include "game/board/ui.h"
#include "game/board/tutorial.h"
#include "game/board/window.h"
// structs
typedef struct structActiveMG {
@ -39,13 +41,15 @@ typedef struct bitcopy {
s8 unk_03;
s16 unk_04;
u8 unk_06;
s32 unk_08;
u8 unk_07;
f32 unk_08;
unkSubstructR31* unk_0C;
} bitcopy;
// bss
static structActiveMG activeMG[4];
static s16 mgListAll[0x20];
static s16 mgPlay4P[8];
// data
static s32 mgSetupSprTbl[13] = {
@ -81,13 +85,25 @@ static s32 luckyMessTbl[9] = {
// sbss
static u8 mgType;
static s32 luckyF;
static f32 hilitePos;
static s16 mgNext;
static u8 mgPlayBattleLen;
static u8 mgPlay2Vs2Len;
static u8 mgPlay1Vs3Len;
static u8 mgPlay4PLen;
static s16 mgPlay1Vs3[3];
static s16 mgPlay2Vs2[3];
static s16 mgPlayBattle[2];
static u8 hiliteTimer;
static u8 hiliteBlinkLen;
static u8 hiliteShowF;
static omObjData* mgSetupObj;
static Process* mgSetupProc;
// sdata
// sdata2
// sdata
static u8 luckyValue = 0xFF;
static s8 cursorPos = 0xFF;
// determined functions
void BoardMGSetupExec(void);
@ -102,12 +118,12 @@ static void UpdateMGSetup(omObjData*);
static void CenterStatus(bitcopy*, omObjData*);
static void SeparateStatus(bitcopy*, omObjData*);
static void PopupVS(bitcopy*, omObjData*);
// ...
static void FallMGType(bitcopy*, omObjData*);
static void LuckyMGFall(bitcopy*, omObjData*);
static void HideLuckyValue(void);
static void UpdateLuckyValue(bitcopy*, omObjData*);
static void UpdateMGList(bitcopy*, omObjData*);
static void HideLuckyValue(void);
// ...
s32 BoardMGSetupPlayPush(s32, s16);
void BoardMGSetupPlayPop(s32, s16);
@ -797,3 +813,512 @@ static void PopupVS(bitcopy* arg0, omObjData* arg1) {
}
}
}
static void FallMGType(bitcopy* arg0, omObjData* arg1) {
Vec sp10;
s16 sp8[3] = { 3, 1, 2 };
Vec* temp_r4;
Vec* temp_r5;
s16 temp_r30;
bitcopy* temp_r29;
unkSubstructR31* temp_r31;
temp_r31 = arg0->unk_0C;
temp_r30 = sp8[mgType];
if (arg0->unk_02 == 0) {
HuSprAttrReset(temp_r31->unk_00[0], temp_r30, 4);
temp_r31->unk_1C[0][temp_r30].y = -284.0f;
temp_r31->unk_1C[1][temp_r30].y = -128.0f;
arg0->unk_02 = 1;
}
PSVECSubtract(&temp_r31->unk_1C[1][temp_r30], &temp_r31->unk_1C[0][temp_r30], &sp10);
if (PSVECMag(&sp10) <= 1.0f) {
temp_r31->unk_1C[0][temp_r30] = temp_r31->unk_1C[1][temp_r30];
temp_r29 = (bitcopy*) mgSetupObj->work;
temp_r29->field00_bit1 = 7;
temp_r29->unk_02 = 0;
temp_r29->unk_03 = 0;
temp_r29->unk_04 = 0;
} else {
PSVECScale(&sp10, &sp10, 0.1f);
PSVECAdd(&sp10, &temp_r31->unk_1C[0][temp_r30], &temp_r31->unk_1C[0][temp_r30]);
}
HuSprPosSet(temp_r31->unk_00[0], temp_r30, temp_r31->unk_1C[0][temp_r30].x, temp_r31->unk_1C[0][temp_r30].y);
}
static void LuckyMGFall(bitcopy* arg0, omObjData* arg1) {
u16 spC;
u16 spA;
s16 sp8[3] = { 3, 1, 2 };
Vec* temp_r25;
Vec* temp_r27;
Vec* temp_r28;
s16 temp_r24;
bitcopy* temp_r26;
u8 temp_r0;
unkSubstructR31* temp_r29;
f32 var_f30;
temp_r29 = arg0->unk_0C;
temp_r24 = sp8[mgType];
temp_r28 = &temp_r29->unk_1C[0][4];
temp_r25 = &temp_r29->unk_1C[1][4];
temp_r27 = &temp_r29->unk_1C[0][temp_r24];
switch (arg0->unk_02) {
case 0:
HuSprAttrReset(temp_r29->unk_00[0], 4, 4);
temp_r28->y = -284.0f;
temp_r25->y = -128.0f;
arg0->unk_02 = 1;
break;
case 1:
temp_r28->y += 10.0f;
if (temp_r25->y < temp_r28->y) {
arg0->unk_02 = 2;
arg0->unk_03 = 0;
temp_r28->y = temp_r25->y;
HuAudFXPlay(0x35D);
}
break;
case 2:
temp_r27->y += 10.0f;
if (328.0f < temp_r27->y) {
HuSprAttrReset(temp_r29->unk_00[0], temp_r24, 4);
temp_r26 = (bitcopy*) mgSetupObj->work;
temp_r26->field00_bit1 = 7;
temp_r26->unk_02 = 0;
temp_r26->unk_03 = 0;
temp_r26->unk_04 = 0;
} else if (arg0->unk_03 < 0x1E) {
OSs8tof32(&arg0->unk_03, &var_f30);
HuSprZRotSet(temp_r29->unk_00[0], temp_r24, var_f30);
arg0->unk_03++;
}
break;
}
HuSprPosSet(temp_r29->unk_00[0], 4, temp_r28->x, temp_r28->y);
HuSprPosSet(temp_r29->unk_00[0], temp_r24, temp_r27->x, temp_r27->y);
}
static void HideLuckyValue(void) {
f32 var_f31;
bitcopy* temp;
unkSubstructR31* temp_r31;
temp = (bitcopy*) mgSetupObj->work;
temp_r31 = temp->unk_0C;
for (var_f31 = 1.0f; var_f31 > 0.1f; var_f31 -= 0.1f) {
HuSprTPLvlSet(temp_r31->unk_00[0], 8, var_f31);
HuSprTPLvlSet(temp_r31->unk_00[0], 9, var_f31);
HuPrcVSleep();
}
HuSprAttrSet(temp_r31->unk_00[0], 8, 4);
HuSprAttrSet(temp_r31->unk_00[0], 9, 4);
}
static inline s32 GWMGUnk32Get(void) {
return GWSystem.unk_32;
}
void UpdateLuckyValue(bitcopy* arg0, omObjData* arg1) {
s32 var_r23;
f32 temp_f29;
s32 temp_r3;
bitcopy* temp_r26;
unkSubstructR31* temp_r27;
f32 temp_f28;
u8 spC;
temp_r27 = arg0->unk_0C;
switch (arg0->unk_02) {
case 0:
HuSprAttrReset(temp_r27->unk_00[0], 8, 4);
HuSprAttrReset(temp_r27->unk_00[0], 9, 4);
HuSprAttrSet(temp_r27->unk_00[0], 8, 8);
HuSprAttrSet(temp_r27->unk_00[0], 9, 8);
HuSprPosSet(temp_r27->unk_00[0], 8, 0.0f, 0.0f);
HuSprPosSet(temp_r27->unk_00[0], 9, 0.0f, 0.0f);
HuSprScaleSet(temp_r27->unk_00[0], 8, 0.001f, 0.001f);
HuSprScaleSet(temp_r27->unk_00[0], 9, 0.001f, 0.001f);
HuSprBankSet(temp_r27->unk_00[0], 9, 1);
arg0->unk_04 = 0;
arg0->unk_02 = 1;
arg0->unk_03 = 0;
temp_r3 = BoardRandMod(0x64U);
if (temp_r3 < 0x55) {
GWSystem.unk_32 = 2;
return;
}
if (temp_r3 >= 0x5F) return;
GWSystem.unk_32 = 3;
return;
case 1:
if (arg0->unk_03 < 0x5A) {
OSu8tof32((u8*) &arg0->unk_03, &temp_f28);
temp_f29 = sin((M_PI * temp_f28) / 180.0);
HuSprScaleSet(temp_r27->unk_00[0], 8, temp_f29, temp_f29);
HuSprScaleSet(temp_r27->unk_00[0], 9, temp_f29, temp_f29);
arg0->unk_03 += 2;
return;
}
arg0->unk_02 = 2;
arg0->unk_06 = BoardRandMod(0xCU) + 0x12;
arg0->unk_03 = 0;
arg0->unk_08 = 0.8f;
return;
case 2:
arg0->unk_08 *= 0.97f;
hilitePos += arg0->unk_08;
if (hilitePos >= 3.0f) {
hilitePos = 0.0f;
}
OSf32tos8(&hilitePos, (s8*)&spC);
if (spC != luckyValue) {
HuAudFXPlay(0x304);
luckyValue = spC;
}
HuSprBankSet(temp_r27->unk_00[0], 9, luckyValue);
if (arg0->unk_08 < 0.05f) {
if (luckyValue != GWMGUnk32Get() - 1) {
arg0->unk_08 *= 1.0309278f;
return;
}
HuAudFXPlay(0x305);
HuAudFXPlay(0x357);
HuAudFXPlay(0x358);
arg0->unk_02 = 3;
arg0->unk_03 = 0;
arg0->unk_04 = 0;
return;
}
break;
case 3:
arg0->unk_04 += 8;
if (arg0->unk_04 >= 0x438) {
temp_r26 = (bitcopy*) mgSetupObj->work;
temp_r26->field00_bit1 = 7;
temp_r26->unk_02 = 0;
temp_r26->unk_03 = 0;
temp_r26->unk_04 = 0;
return;
}
temp_f28 = (arg0->unk_04 % 360);
temp_f29 = (1.0 + (0.5 * sin((M_PI * temp_f28) / 180.0)));
HuSprScaleSet(temp_r27->unk_00[0], 8, temp_f29, temp_f29);
HuSprScaleSet(temp_r27->unk_00[0], 9, temp_f29, temp_f29);
break;
}
}
static f32 cursorYTbl[4] = {
64.0f, 88.0f, 112.0f, 136.0f
};
static f32 hiliteYTbl[4] = {
60.0f, 84.0f, 108.0f, 132.0f
};
static GXColor hiliteColTbl[3] = {
{ 0xF8, 0xF2, 0x13, 0x00 },
{ 0xF8, 0xF2, 0x13, 0x00 },
{ 0xF8, 0xF2, 0x13, 0x00 }
};
void UpdateMGList(bitcopy* arg0, omObjData* arg1) {
f32 sp1C;
f32 sp18;
s32 sp14;
f32 var_f26;
f32 var_f25;
f32 var_f24;
f32 temp_f27;
s32 temp_r22;
s16 temp_r3;
s8 var_r17;
GXColor* temp_r18;
s32 var_r23;
bitcopy* temp_r21;
unkSubstructR31* temp_r24;
temp_r24 = arg0->unk_0C;
temp_r22 = mgType + 5;
switch (arg0->unk_02) { /* irregular */
case 0:
HuSprAttrSet(temp_r24->unk_00[0], temp_r22, 8);
HuSprAttrReset(temp_r24->unk_00[0], temp_r22, 4);
HuSprPosSet(temp_r24->unk_00[0], temp_r22, 0.0f, 32.0f);
HuSprScaleSet(temp_r24->unk_00[0], temp_r22, 0.001f, 0.001f);
arg0->unk_04 = 0;
arg0->unk_02 = 1;
arg0->unk_03 = 0;
hilitePos = 0.0f;
for (var_r23 = 0; var_r23 < arg0->field01_bit0; var_r23++) {
HuWinMesSizeCancelCRSet(1);
HuWinMesMaxSizeGet(1, &sp18, activeMG[var_r23].unk_04);
var_f25 = 152.0f;
var_f24 = 280.0f + (var_r23 * 0x18);
temp_r3 = HuWinCreate(var_f25, var_f24, sp18, sp1C, 0);
HuWinBGTPLvlSet(temp_r3, 0.0f);
HuWinMesSpeedSet(temp_r3, 0);
HuWinDispOff(temp_r3);
HuWinAttrSet(temp_r3, 0x100U);
if (activeMG[var_r23].unk_03 != 0) {
sp14 = activeMG[var_r23].unk_04;
} else {
sp14 = 0x90001;
}
HuWinMesSet(temp_r3, sp14);
activeMG[var_r23].unk_00 = temp_r3;
}
return;
case 1:
if (arg0->unk_03 < 0x5A) {
OSu8tof32((u8*) &arg0->unk_03, &var_f26);
temp_f27 = sin((M_PI * var_f26) / 180.0);
arg0->unk_03 += 3;
HuSprScaleSet(temp_r24->unk_00[0], temp_r22, temp_f27, temp_f27);
return;
}
for (var_r23 = 0; var_r23 < arg0->field01_bit0; var_r23++) {
HuWinDispOn(activeMG[var_r23].unk_00);
}
HuSprAttrReset(temp_r24->unk_00[0], 0xA, 4);
HuSprAttrSet(temp_r24->unk_00[0], 0xA, 8);
HuSprPosSet(temp_r24->unk_00[0], 0xA, -148.0f, cursorYTbl[0]);
temp_r18 = &hiliteColTbl[mgType];
HuSprAttrReset(temp_r24->unk_00[0], 0xC, 4);
HuSprPosSet(temp_r24->unk_00[0], 0xC, 0.0f, hiliteYTbl[0]);
HuSprTPLvlSet(temp_r24->unk_00[0], 0xC, 0.7f);
HuSprScaleSet(temp_r24->unk_00[0], 0xC, 32.0f, 3.5f);
HuSprColorSet(temp_r24->unk_00[0], 0xC, temp_r18->r, temp_r18->g, temp_r18->b);
arg0->unk_02 = 2;
arg0->unk_03 = 0;
arg0->unk_08 = 0.7f;
arg0->unk_07 = 0x23 - BoardRandMod(0x1EU);
return;
case 2:
hilitePos += arg0->unk_08;
if (hilitePos >= arg0->field01_bit0) {
hilitePos = 0.0f;
}
OSf32tos8(&hilitePos, &var_r17);
if (var_r17 != cursorPos) {
HuAudFXPlay(0x304);
cursorPos = var_r17;
}
HuSprPosSet(temp_r24->unk_00[0], 0xA, -148.0f, cursorYTbl[cursorPos]);
HuSprPosSet(temp_r24->unk_00[0], 0xC, 0.0f, hiliteYTbl[cursorPos]);
if (arg0->unk_07 != 0) {
arg0->unk_07--;
return;
}
arg0->unk_02 = 3;
return;
case 3:
arg0->unk_08 *= 0.97f;
hilitePos += arg0->unk_08;
if (hilitePos >= arg0->field01_bit0) {
hilitePos = 0.0f;
}
OSf32tos8(&hilitePos, &var_r17);
if (var_r17 != cursorPos) {
HuAudFXPlay(0x304);
cursorPos = var_r17;
}
HuSprPosSet(temp_r24->unk_00[0], 0xA, -148.0f, cursorYTbl[cursorPos]);
HuSprPosSet(temp_r24->unk_00[0], 0xC, 0.0f, hiliteYTbl[cursorPos]);
if (!(arg0->unk_08 < (0.02f + (0.02f * BoardRandFloat())))) return; // weird hacky garbage
HuAudFXPlay(0x305);
arg0->unk_02 = 4;
arg0->unk_03 = 0;
hiliteTimer = 0;
hiliteShowF = 1;
hiliteBlinkLen = 5;
mgNext = activeMG[cursorPos].unk_02;
HuWinMesSet(activeMG[cursorPos].unk_00, activeMG[cursorPos].unk_04);
return;
case 4:
if (arg0->unk_03++ > 0x78U) {
HuSprAttrSet(temp_r24->unk_00[0], 0xA, 4);
HuSprAttrSet(temp_r24->unk_00[0], 0xC, 4);
for (var_r23 = 0; var_r23 < arg0->field01_bit0; var_r23++) {
HuWinDispOff(activeMG[var_r23].unk_00);
}
arg0->unk_02 = 5;
arg0->unk_03 = 0;
return;
}
if (hiliteTimer < hiliteBlinkLen) {
hiliteTimer++;
} else {
hiliteShowF ^= 1;
hiliteTimer = 0;
}
if (hiliteShowF != 0) {
HuSprAttrReset(temp_r24->unk_00[0], 0xC, 4);
return;
}
HuSprAttrSet(temp_r24->unk_00[0], 0xC, 4);
return;
case 5:
if (arg0->unk_03 < 0x5A) {
OSu8tof32((u8*) &arg0->unk_03, &var_f26);
temp_f27 = (1.0 + (2.0 * sin((M_PI * var_f26) / 180.0)));
arg0->unk_03 += 4;
if (arg0->unk_03 > 0x5A) {
arg0->unk_03 = 0x5A;
}
HuSprScaleSet(temp_r24->unk_00[0], temp_r22, temp_f27, temp_f27);
if (arg0->unk_03 > 0x3C) {
HuSprTPLvlSet(temp_r24->unk_00[0], temp_r22, (90.0f - arg0->unk_03) / 30.0f);
return;
}
} else {
HuSprAttrSet(temp_r24->unk_00[0], temp_r22, 4);
for (var_r23 = 0; var_r23 < arg0->field01_bit0; var_r23++) {
HuWinDispOff(activeMG[var_r23].unk_00);
}
arg0->unk_03 = 0;
arg0->unk_02 = 6;
temp_r21 = (bitcopy*) mgSetupObj->work;
temp_r21->field00_bit1 = 7;
temp_r21->unk_02 = 0;
temp_r21->unk_03 = 0;
temp_r21->unk_04 = 0;
}
break;
}
}
void BoardMGSetupPlayClear(void) {
mgPlay4PLen = mgPlay1Vs3Len = mgPlay2Vs2Len = mgPlayBattleLen = 0;
memset(mgPlay4P, 0, 0x10);
memset(mgPlay1Vs3, 0, 6);
memset(mgPlay2Vs2, 0, 6);
memset(mgPlayBattle, 0, 4);
}
s32 BoardMGSetupPlayPush(s32 arg0, s16 arg1) {
s16* var_r31;
s16 var_r30;
s16 var_r29;
switch (arg0) {
case 0:
var_r29 = 8;
var_r31 = mgPlay4P;
break;
case 1:
var_r29 = 3;
var_r31 = mgPlay1Vs3;
break;
case 2:
var_r29 = 3;
var_r31 = mgPlay2Vs2;
break;
case 4:
var_r29 = 2;
var_r31 = mgPlayBattle;
break;
default:
return 0;
}
var_r30 = 0;
while (var_r30 < var_r29) {
if (arg1 == var_r31[var_r30]) {
return 1;
}
var_r30++;
}
return 0;
}
void BoardMGSetupPlayPop(s32 arg0, s16 arg1) {
s16 var_r29;
s16 temp_r28;
u8* var_r31;
s16* var_r30;
switch (arg0) { /* irregular */
case 0:
var_r31 = &mgPlay4PLen;
var_r29 = 8;
var_r30 = mgPlay4P;
break;
case 1:
var_r31 = &mgPlay1Vs3Len;
var_r29 = 3;
var_r30 = mgPlay1Vs3;
break;
case 2:
var_r31 = &mgPlay2Vs2Len;
var_r29 = 3;
var_r30 = mgPlay2Vs2;
break;
case 4:
var_r31 = &mgPlayBattleLen;
var_r29 = 2;
var_r30 = mgPlayBattle;
break;
default:
return;
}
temp_r28 = *var_r31;
var_r30[temp_r28] = arg1;
*var_r31 = temp_r28 + 1;
if (*var_r31 >= var_r29) {
*var_r31 = 0;
}
return;
}
void BoardMGSetupTutorialExec(void) {
s32 spC;
s32 sp8;
s16 var_r30;
s16* temp_r31;
s32 temp_r0;
s32 var_r26;
bitcopy* temp_r24;
bitcopy* temp_r25;
bitcopy* temp_r27;
bitcopy* temp_r29;
bitcopy* temp_r28;
*boardTutorialData = 1;
BoardFilterFadeInit(0x1E, 0xA0U);
for (var_r26 = 0; var_r26 < 4; var_r26++) {
activeMG[var_r26].unk_00 = -1;
activeMG[var_r26].unk_04 = 0;
}
CreateMGSetup();
while (setupObjGet() != 7) {
HuPrcVSleep();
}
temp_r29 = (bitcopy*) mgSetupObj->work;
temp_r29->field00_bit1 = 1;
temp_r29->unk_02 = 0;
temp_r29->unk_03 = 0;
temp_r29->unk_04 = 0;
while (setupObjGet() != 7) {
HuPrcVSleep();
}
temp_r28 = (bitcopy*) mgSetupObj->work;
temp_r28->field00_bit1 = 6;
temp_r28->unk_02 = 0;
temp_r28->unk_03 = 0;
temp_r28->unk_04 = 0;
while (setupObjGet() != 7) {
HuPrcVSleep();
}
temp_r24 = (bitcopy*) mgSetupObj->work;
temp_r24->field00_bit0 = 1;
BoardFilterFadeOut(0x1E);
HuPrcSleep(0x1E);
}