diff --git a/config/GMPE01_00/rels/m446dll/symbols.txt b/config/GMPE01_00/rels/m446dll/symbols.txt index 7e0435f7..f8c844dd 100644 --- a/config/GMPE01_00/rels/m446dll/symbols.txt +++ b/config/GMPE01_00/rels/m446dll/symbols.txt @@ -36,7 +36,7 @@ fn_1_1FFC = .text:0x00001FFC; // type:function size:0x68 fn_1_2064 = .text:0x00002064; // type:function size:0x18 fn_1_207C = .text:0x0000207C; // type:function size:0x58 fn_1_20D4 = .text:0x000020D4; // type:function size:0x338 -fn_1_240C = .text:0x0000240C; // type:function size:0x27C +m446CardCreate = .text:0x0000240C; // type:function size:0x27C fn_1_2688 = .text:0x00002688; // type:function size:0xA4 fn_1_272C = .text:0x0000272C; // type:function size:0x68 fn_1_2794 = .text:0x00002794; // type:function size:0x68 @@ -56,8 +56,8 @@ fn_1_3064 = .text:0x00003064; // type:function size:0x11C fn_1_3180 = .text:0x00003180; // type:function size:0x58 fn_1_31D8 = .text:0x000031D8; // type:function size:0x2C8 fn_1_34A0 = .text:0x000034A0; // type:function size:0x260 -fn_1_3700 = .text:0x00003700; // type:function size:0x154 -fn_1_3854 = .text:0x00003854; // type:function size:0x5C +m446DeckPushCard = .text:0x00003700; // type:function size:0x154 +m446DeckPopCard = .text:0x00003854; // type:function size:0x5C fn_1_38B0 = .text:0x000038B0; // type:function size:0x30 fn_1_38E0 = .text:0x000038E0; // type:function size:0x10 fn_1_38F0 = .text:0x000038F0; // type:function size:0x34 @@ -150,17 +150,17 @@ lbl_1_rodata_C0 = .rodata:0x000000C0; // type:object size:0x4 scope:local data:f lbl_1_rodata_C4 = .rodata:0x000000C4; // type:object size:0x4 scope:local data:float lbl_1_rodata_C8 = .rodata:0x000000C8; // type:object size:0x4 scope:local data:float lbl_1_rodata_CC = .rodata:0x000000CC; // type:object size:0x4 scope:local data:float -lbl_1_rodata_D0 = .rodata:0x000000D0; // type:object size:0x28 -lbl_1_rodata_F8 = .rodata:0x000000F8; // type:object size:0x4 data:float -lbl_1_rodata_FC = .rodata:0x000000FC; // type:object size:0x4 data:float -lbl_1_rodata_100 = .rodata:0x00000100; // type:object size:0x4 data:float -lbl_1_rodata_108 = .rodata:0x00000108; // type:object size:0x8 data:double -lbl_1_rodata_110 = .rodata:0x00000110; // type:object size:0x8 data:double -lbl_1_rodata_118 = .rodata:0x00000118; // type:object size:0x8 data:double -lbl_1_rodata_120 = .rodata:0x00000120; // type:object size:0x4 data:float -lbl_1_rodata_124 = .rodata:0x00000124; // type:object size:0x4 data:float -lbl_1_rodata_128 = .rodata:0x00000128; // type:object size:0x8 data:double -lbl_1_rodata_130 = .rodata:0x00000130; // type:object size:0x4 data:float +lbl_1_rodata_D0 = .rodata:0x000000D0; // type:object size:0x28 scope:local +lbl_1_rodata_F8 = .rodata:0x000000F8; // type:object size:0x4 scope:local data:float +lbl_1_rodata_FC = .rodata:0x000000FC; // type:object size:0x4 scope:local data:float +lbl_1_rodata_100 = .rodata:0x00000100; // type:object size:0x4 scope:local data:float +lbl_1_rodata_108 = .rodata:0x00000108; // type:object size:0x8 scope:local data:double +lbl_1_rodata_110 = .rodata:0x00000110; // type:object size:0x8 scope:local data:double +lbl_1_rodata_118 = .rodata:0x00000118; // type:object size:0x8 scope:local data:double +lbl_1_rodata_120 = .rodata:0x00000120; // type:object size:0x4 scope:local data:float +lbl_1_rodata_124 = .rodata:0x00000124; // type:object size:0x4 scope:local data:float +lbl_1_rodata_128 = .rodata:0x00000128; // type:object size:0x8 scope:local data:double +lbl_1_rodata_130 = .rodata:0x00000130; // type:object size:0x4 scope:local data:float lbl_1_rodata_138 = .rodata:0x00000138; // type:object size:0x4 data:float lbl_1_rodata_13C = .rodata:0x0000013C; // type:object size:0x4 data:float lbl_1_rodata_140 = .rodata:0x00000140; // type:object size:0x4 data:float @@ -259,8 +259,8 @@ jumptable_1_data_E4 = .data:0x000000E4; // type:object size:0x68 scope:local lbl_1_data_150 = .data:0x00000150; // type:object size:0xC lbl_1_data_15C = .data:0x0000015C; // type:object size:0x20 scope:local jumptable_1_data_17C = .data:0x0000017C; // type:object size:0x2C scope:local -lbl_1_data_1A8 = .data:0x000001A8; // type:object size:0x1F data:string -lbl_1_data_1C7 = .data:0x000001C7; // type:object size:0x1F +lbl_1_data_1A8 = .data:0x000001A8; // type:object size:0x1F scope:local data:string +lbl_1_data_1C7 = .data:0x000001C7; // type:object size:0x1F scope:local data:string lbl_1_data_1E8 = .data:0x000001E8; // type:object size:0x1E data:string lbl_1_data_206 = .data:0x00000206; // type:object size:0x22 lbl_1_data_228 = .data:0x00000228; // type:object size:0x24 diff --git a/configure.py b/configure.py index 3868f7ee..251f8db7 100644 --- a/configure.py +++ b/configure.py @@ -1169,7 +1169,7 @@ config.libs = [ Object(Matching, "REL/executor.c"), Object(NonMatching, "REL/m446dll/main.c"), Object(Matching, "REL/m446dll/card.c"), - Object(NonMatching, "REL/m446dll/deck.c"), + Object(Matching, "REL/m446dll/deck.c"), Object(NonMatching, "REL/m446dll/table.c"), Object(NonMatching, "REL/m446dll/player.c"), Object(NonMatching, "REL/m446dll/camera.c"), diff --git a/include/REL/m446Dll.h b/include/REL/m446Dll.h index 0b6c014d..0b500985 100644 --- a/include/REL/m446Dll.h +++ b/include/REL/m446Dll.h @@ -45,7 +45,7 @@ typedef struct _unkStruct { } unkStruct; typedef struct _unkStruct2 { - s32 *unk0; + struct _unkStruct4 **unk0; s32 unk4; s32 unk8; } unkStruct2; @@ -88,6 +88,11 @@ typedef struct _unkStruct4 { f32 unk94; } unkStruct4; +typedef struct _unkStruct5 { + unkStruct2* unk0; + Vec unk4; +} unkStruct5; + typedef void (*m446Func1)(unkStruct *); typedef void (*m446Func4)(unkStruct4 *); @@ -131,9 +136,9 @@ extern void fn_1_18B0(unkStruct*); extern void fn_1_19D4(void); extern unkStruct2* fn_1_1C64(s32); extern void fn_1_1CF8(unkStruct2*); -extern s32 fn_1_1D30(unkStruct2*, s32); -extern s32 fn_1_1D6C(unkStruct2*, s32*); -extern s32 fn_1_1DA8(unkStruct2*, s32*); +extern s32 fn_1_1D30(unkStruct2*, unkStruct4*); +extern s32 fn_1_1D6C(unkStruct2*, unkStruct4**); +extern s32 fn_1_1DA8(unkStruct2*, unkStruct4**); extern BOOL fn_1_1DDC(unkStruct2*); extern s32 fn_1_1DEC(unkStruct2*); extern unkStruct3* fn_1_1DF4(unkStruct4*); @@ -148,7 +153,7 @@ extern s32 fn_1_1FFC(s8*, s8*, s32); extern s32 fn_1_2064(void); extern void fn_1_207C(void); extern void fn_1_20D4(void); -extern unkStruct4* fn_1_240C(s32); +extern unkStruct4* m446CardCreate(s32); extern void fn_1_2688(unkStruct4*); extern void fn_1_272C(unkStruct4*); extern void fn_1_2794(unkStruct4*); diff --git a/src/REL/m446Dll/card.c b/src/REL/m446Dll/card.c index cbb5667f..8bad6063 100644 --- a/src/REL/m446Dll/card.c +++ b/src/REL/m446Dll/card.c @@ -33,7 +33,7 @@ void fn_1_1CF8(unkStruct2* arg0) { HuMemDirectFree(arg0); } -s32 fn_1_1D30(unkStruct2* arg0, s32 arg1) { +s32 fn_1_1D30(unkStruct2* arg0, unkStruct4* arg1) { if (arg0->unk4 <= arg0->unk8) { return 0; } else { @@ -43,21 +43,21 @@ s32 fn_1_1D30(unkStruct2* arg0, s32 arg1) { } } -s32 fn_1_1D6C(unkStruct2* arg0, s32* arg1) { +s32 fn_1_1D6C(unkStruct2* arg0, unkStruct4** arg1) { if (arg0->unk8 <= 0) { return 0; } else { arg0->unk8--; - arg1[0] = arg0->unk0[arg0->unk8]; + *arg1 = arg0->unk0[arg0->unk8]; return 1; } } -s32 fn_1_1DA8(unkStruct2* arg0, s32* arg1) { +s32 fn_1_1DA8(unkStruct2* arg0, unkStruct4** arg1) { if (arg0->unk8 <= 0) { return 0; } else { - arg1[0] = *(&arg0->unk0[arg0->unk8] - 1); + *arg1 = *(&arg0->unk0[arg0->unk8] - 1); return 1; } } @@ -246,7 +246,7 @@ void fn_1_20D4(void) { } } -unkStruct4* fn_1_240C(s32 arg0) { +unkStruct4* m446CardCreate(s32 arg0) { unkStruct4* temp_r31; unkStruct3* temp_r30; diff --git a/src/REL/m446Dll/deck.c b/src/REL/m446Dll/deck.c new file mode 100644 index 00000000..75ae1bce --- /dev/null +++ b/src/REL/m446Dll/deck.c @@ -0,0 +1,191 @@ +#include "REL/m446Dll.h" + +#include "math.h" + +// bss +u32 lbl_1_bss_20[2]; + +// data +static const s32 lbl_1_rodata_D0[5][2] = { + {1, 5}, {0, 5}, {2, 5}, {3, 5}, {4, 3} +}; + +unkStruct5* fn_1_3064(void); +// ... +s32 m446DeckPushCard(unkStruct5*, unkStruct4*, s32); +s32 fn_1_38F0(void); + +unkStruct5* fn_1_3064(void) { + unkStruct4* var_r27; + s32 var_r28; + s32 var_r29; + s32 var_r30; + unkStruct5* temp_r3; + + temp_r3 = HuMemDirectMallocNum(HEAP_SYSTEM, 0x10, 0x10000000); + if (!temp_r3) { + return NULL; + } + temp_r3->unk0 = fn_1_1C64(0x17); + if (!temp_r3->unk0) { + HuMemDirectFree(temp_r3); + return NULL; + } + temp_r3->unk4.x = 0.0f; + temp_r3->unk4.y = 85.0f; + temp_r3->unk4.z = 0.0f; + + for (var_r28 = 0, var_r30 = 0; var_r30 < 5; var_r30++) { + for (var_r29 = 0; var_r29 < lbl_1_rodata_D0[var_r30][1]; var_r29++, var_r28++) { + var_r27 = m446CardCreate(lbl_1_rodata_D0[var_r30][0]); + m446DeckPushCard(temp_r3, var_r27, 0); + } + } + return temp_r3; +} + +void fn_1_3180(unkStruct2** arg0) { // typing nightmare + unkStruct4* sp8; + + while (fn_1_1D6C(*arg0, &sp8) != 0) { + fn_1_2688(sp8); + } + fn_1_1CF8(*arg0); + HuMemDirectFree(arg0); +} + +void fn_1_31D8(unkStruct2** arg0, unkStruct4** arg1, s32* arg2, s32 arg3) { + Vec sp10; + unkStruct4 *spC; + f32 var_f30; + f32 var_f31; + s32 var_r29; + s32 var_r31; + + HuAudFXPlay(0x765); + var_f30 = 360.0f / fn_1_1DEC(*arg0); + if (fn_1_38F0() % 2 != 0) { + var_f30 = -var_f30; + } + + var_f31 = fn_1_38F0() % 360; + var_r29 = 0; + var_r31 = 0; + while (fn_1_1D6C(*arg0, &spC) != 0) { + if (arg3 != 0) { + sp10 = spC->unk10; + sp10.x = ((25.0 * cos((M_PI * var_f31) / 180.0)) - (25.0 * sin((M_PI * var_f31) / 180.0))); + sp10.z = ((25.0 * cos((M_PI * var_f31) / 180.0)) + (25.0 * sin((M_PI * var_f31) / 180.0))); + sp10.y = 81.0f + (0.1f * var_r31); + fn_1_2890(spC, &sp10, 0x12, var_r29 += 3); + var_f31 += var_f30; + } + arg1[var_r31++] = spC; + } + *arg2 = var_r31; +} + +void fn_1_34A0(unkStruct5* arg0, unkStruct4** arg1, s32 arg2, s32 arg3) { + Vec sp10; + unkStruct4* spC; + s32 temp_r30; + s32 var_r22; + s32 var_r25; + s32 var_r24; + s32 temp_r23; + unkStruct2* temp_r28; + s32 var_r27; + + temp_r23 = arg2; + HuAudFXPlay(0x766); + temp_r28 = fn_1_1C64(6); + var_r27 = 0; + do { + + do { + temp_r30 = fn_1_38F0() % temp_r23; + spC = arg1[temp_r30]; + } while (!spC); + + if (spC->unk0 != 4) { + if ((var_r27 % 3) == 0) { + var_r25 = spC->unk0; + } else if ((var_r27 % 3) == 1) { + var_r22 = spC->unk0; + if (spC->unk0 == var_r25) { + continue; + } + } else if ((spC->unk0 == var_r25) || (spC->unk0 == var_r22)) continue; + arg1[temp_r30] = NULL; + fn_1_1D30(temp_r28, spC); + var_r27++; + } + } while (fn_1_1DEC(temp_r28) < 6); + var_r24 = 0; + do { + if (arg2 > 6) { + do { + temp_r30 = fn_1_38F0() % temp_r23; + spC = arg1[temp_r30]; + } while (!spC); + arg1[temp_r30] = NULL; + } else { + fn_1_1D6C(temp_r28, &spC); + } + fn_1_1D30(arg0->unk0, spC); + sp10 = arg0->unk4; + sp10.y += 0.5f * fn_1_1DEC(arg0->unk0); + if (arg3 != 0) { + fn_1_2890(spC, &sp10, 0x12, var_r24 += 3); + } else { + spC->unk10 = sp10; + } + arg2--; + } while (arg2 != 0); + fn_1_1CF8(temp_r28); +} + +s32 m446DeckPushCard(unkStruct5* arg0, unkStruct4* arg1, s32 arg2) { + Vec sp18; + Vec spC; + + if (fn_1_1D30(arg0->unk0, arg1) == 0) { + OSReport("[!] m446DeckPushCard ERROR...\n"); + return 0; + } + sp18 = arg0->unk4; + sp18.y += 0.5f * fn_1_1DEC(arg0->unk0); + spC = arg1->unk34; + spC.y = 0.0f; + switch (arg2) { + case 2: + fn_1_27FC(arg1, &sp18, 0x3C); + fn_1_2928(arg1, &spC, 0x3C); + break; + default: + arg1->unk10 = sp18; + arg1->unk34 = spC; + } + return 1; +} + +s32 m446DeckPopCard(unkStruct2** arg0, unkStruct4** arg1) { + if (fn_1_1D6C(*arg0, arg1) == 0) { + OSReport("[!] m446DeckPopCard ERROR...\n"); + return 0; + } else { + return 1; + } +} + +void fn_1_38B0(unkStruct2** arg0) { + fn_1_1DEC(*arg0); +} + +void fn_1_38E0(u32 arg0) { + lbl_1_bss_20[0] = arg0; +} + +s32 fn_1_38F0(void) { + return ((lbl_1_bss_20[0] = (lbl_1_bss_20[0] * 0x41C64E6D) + 0x3039) >> 16) % 32768; +} \ No newline at end of file diff --git a/src/REL/m446Dll/main.c b/src/REL/m446Dll/main.c index a73dd34e..837c0d0f 100644 --- a/src/REL/m446Dll/main.c +++ b/src/REL/m446Dll/main.c @@ -10,18 +10,13 @@ #include "game/frand.h" #include "game/minigame_seq.h" -// card.c -extern s32 fn_1_2064(void); -extern void fn_1_207C(void); -extern void fn_1_20D4(void); -extern void fn_1_2EC0(unkSubStruct2*, s32); // deck.c extern void fn_1_3180(s32); extern void fn_1_31D8(s32, s32*, s32*, s32); extern s32 fn_1_38E0(void); extern s32 fn_1_3064(void); extern void fn_1_34A0(s32, s32*, s32, s32); -extern void fn_1_3700(s32, unkSubStruct2*, s32); +extern void m446DeckPushCard(s32, unkSubStruct2*, s32); // table.c extern s32 fn_1_3924(void); extern void fn_1_393C(void); @@ -280,7 +275,7 @@ void fn_1_53C(unkStruct* arg0) { for (var_r29 = 0; var_r29 < 2; var_r29++) { for (var_r30 = 0; var_r30 < 3; var_r30++) { - fn_1_3854(arg0->unk28, &arg0->unk34); + m446DeckPopCard(arg0->unk28, &arg0->unk34); fn_1_51B8(arg0->unk2C[var_r29], arg0->unk34, 1); fn_1_2EC0(arg0->unk34, 0); } @@ -309,7 +304,7 @@ void fn_1_53C(unkStruct* arg0) { if (arg0->unk34->unk4 != 0) break; fn_1_46AC(arg0->unk20); - while (fn_1_3854(arg0->unk28, &arg0->unk34) != 0) { + while (m446DeckPopCard(arg0->unk28, &arg0->unk34) != 0) { fn_1_3BF0(arg0->unk20, arg0->unk34, 1); } fn_1_46D0(arg0->unk20); @@ -581,7 +576,7 @@ void fn_1_CA0(unkStruct* arg0) { fn_1_3FD0(arg0->unk20, var_r29, &arg0->unk34); if (arg0->unk34) { fn_1_3EB4(arg0->unk20, arg0->unk34, 4); - fn_1_3700(arg0->unk28, arg0->unk34, 2); + m446DeckPushCard(arg0->unk28, arg0->unk34, 2); } } arg0->unk10 = 18; @@ -605,7 +600,7 @@ void fn_1_CA0(unkStruct* arg0) { case 20: if (arg0->unk14++ >= 120) { for (var_r29 = 0; var_r29 < 3; var_r29++) { - fn_1_3854(arg0->unk28, &arg0->unk34); + m446DeckPopCard(arg0->unk28, &arg0->unk34); fn_1_51B8(var_r30, arg0->unk34, 1); fn_1_2EC0(arg0->unk34, 0); } @@ -627,7 +622,7 @@ void fn_1_CA0(unkStruct* arg0) { if (arg0->unk34->unk70 == 0 && arg0->unk34->unk78 == 0 && arg0->unk34->unk74 == 0 && arg0->unk34->unk4 == 0) { fn_1_46AC(arg0->unk20); - while (fn_1_3854(arg0->unk28, &arg0->unk34)) { + while (m446DeckPopCard(arg0->unk28, &arg0->unk34)) { fn_1_3BF0(arg0->unk20, arg0->unk34, 1); } fn_1_46D0(arg0->unk20);