fix m2ctx.py, add asm_sizes.py, decomp gateguy funcs, various other things

This commit is contained in:
Rainchus 2023-04-18 03:33:00 -05:00
parent 07f30f3ecc
commit a982212b42
15 changed files with 3444 additions and 49 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
.gitmodules vendored Normal file → Executable file
View File

2459
ctx.c Normal file

File diff suppressed because it is too large Load Diff

0
diff.py Normal file → Executable file
View File

View File

@ -109,8 +109,8 @@ typedef struct {
/* 16 (0x10) 800D1118 */ u8 curSpaceIndex;
/* 17 (0x11) 800D1119 */ u8 nextChainIndex;
/* 18 (0x12) 800D111A */ u8 nextSpaceIndex;
/* 19 (0x13) 800D111B */ u8 unk1ChainIndex;
/* 20 (0x14) 800D111C */ u8 unk1SpaceIndex;
/* 19 (0x13) 800D111B */ s8 unk1ChainIndex;
/* 20 (0x14) 800D111C */ s8 unk1SpaceIndex;
/* 21 (0x15) 800D111D */ s8 reverseChainIndex;
/* 22 (0x16) 800D111E */ s8 reverseSpaceIndex;

View File

@ -48,7 +48,7 @@ segments:
- [0xEFC0, c, gameman]
- [0xF610, asm, graphics]
- [0xFCA0, asm, hmfload]
- [0x12E20, asm]
- [0x12E20, c]
- [0x13F90, asm]
- [0x14EA0, asm]
- [0x19C30, asm]
@ -82,7 +82,7 @@ segments:
- [0x527E0, asm]
- [0x52F30, asm, "sprman"]
- [0x58000, asm, "sprput"]
- [0x5ACF0, asm]
- [0x5ACF0, c]
- [0x62750, asm]
- [0x66E70, asm]
- [0x67000, asm]
@ -1407,7 +1407,7 @@ segments:
start: 0x3D8930
vram: 0x801059A0
subsegments:
- [0x3D8930, asm]
- [0x3D8930, c]
- [0x3D8960, asm]
- [0x3D8A70, bin] # data
@ -1418,8 +1418,8 @@ segments:
start: 0x3D8A90
vram: 0x801059A0
subsegments:
- [0x3D8A90, asm]
- [0x3D8AC0, asm]
- [0x3D8A90, c]
- [0x3D8AC0, c]
- [0x3EB7D0, bin] # data
- dir: overlays/board_arrowhead_intro

90
src/12E20.c Normal file
View File

@ -0,0 +1,90 @@
#include "common.h"
#include "common_structs.h"
typedef struct unk_struct {
f32 unk0;
f32 unk4;
f32 unk8;
f32 unkC;
f32 unk10;
f32 unk14;
f32 unk18;
f32 unk1C;
f32 unk20;
f32 unk24;
f32 unk28;
f32 unk2C;
f32 unk30;
char unk_34[0x1C];
f32 unk_50;
char unk_44[0x1DC];
} unk_struct;
extern unk_struct* D_800A0550_A1150;
typedef f32 Matrix4f[4][4];
f32 func_8008E3F0_8EFF0(f32);
f32 func_8008EF20_8FB20(f32);
void guLookAtF(f32 mf[4][4], f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp);
INCLUDE_ASM(s32, "12E20", Hu3DCamInit);
INCLUDE_ASM(s32, "12E20", func_800123F4_12FF4);
INCLUDE_ASM(s32, "12E20", func_80012408_13008);
INCLUDE_ASM(s32, "12E20", func_8001247C_1307C);
INCLUDE_ASM(s32, "12E20", func_800124BC_130BC);
INCLUDE_ASM(s32, "12E20", func_80012508_13108);
INCLUDE_ASM(s32, "12E20", func_80012564_13164);
INCLUDE_ASM(s32, "12E20", func_80012640_13240);
INCLUDE_ASM(s32, "12E20", func_800127C4_133C4);
INCLUDE_ASM(s32, "12E20", func_80012888_13488);
INCLUDE_ASM(s32, "12E20", func_800128BC_134BC);
INCLUDE_ASM(s32, "12E20", func_800128EC_134EC);
void func_8001291C_1351C(s16 index, vec3f *arg1, vec3f *arg2) { //Convert3Dto2D
Matrix4f sp28;
f32 temp_f20;
f32 temp_f22;
f32 temp_f24;
f32 temp_f28;
f32 temp_f2;
f32 temp_f30;
unk_struct *temp_s0;
temp_s0 = &D_800A0550_A1150[index];
guLookAtF(sp28, temp_s0->unk10, temp_s0->unk14, temp_s0->unk18, temp_s0->unk1C, temp_s0->unk20, temp_s0->unk24, temp_s0->unk28, temp_s0->unk2C, temp_s0->unk30);
temp_f30 = arg1->x;
temp_f28 = arg1->y;
temp_f2 = arg1->z;
temp_f30 -= temp_s0->unk10;
temp_f28 -= temp_s0->unk14;
temp_f2 -= temp_s0->unk18;
temp_f24 = ((temp_f30 * sp28[0][0]) + (temp_f28 * sp28[1][0])) + (temp_f2 * sp28[2][0]);
temp_f22 = ((temp_f30 * sp28[0][1]) + (temp_f28 * sp28[1][1])) + (temp_f2 * sp28[2][1]);
temp_f20 = ((temp_f30 * sp28[0][2]) + (temp_f28 * sp28[1][2])) + (temp_f2 * sp28[2][2]);
temp_f30 = func_8008EF20_8FB20(temp_s0->unk_50 / 2.0f) / func_8008E3F0_8EFF0(temp_s0->unk_50 / 2.0f) * temp_f20 * (4.0f / 3.0f);
temp_f28 = (func_8008EF20_8FB20(temp_s0->unk_50 / 2.0f) / func_8008E3F0_8EFF0(temp_s0->unk_50 / 2.0f)) * temp_f20;
arg2->x = (temp_f24 * (160.0f / (-temp_f30))) + 160.0f;
arg2->y = ((temp_f22 * (120.0f / temp_f28)) + 120.0f);
}
INCLUDE_ASM(s32, "12E20", func_80012B14_13714);
INCLUDE_ASM(s32, "12E20", func_80012D0C_1390C);
INCLUDE_ASM(s32, "12E20", func_80012E54_13A54);
INCLUDE_ASM(s32, "12E20", func_80013320_13F20);
INCLUDE_ASM(s32, "12E20", func_80013350_13F50);

256
src/5ACF0.c Normal file
View File

@ -0,0 +1,256 @@
#include "common.h"
typedef struct TextWindow {
/* 0x00 */ u8 unk_00;
/* 0x01 */ char unk_01[3];
/* 0x04 */ char unk_04;
/* 0x05 */ u8 unk_05;
/* 0x06 */ char unk_06[0x0A];
/* 0x10 */ u8 unk_10;
/* 0x11 */ char unk_11[3];
/* 0x14 */ char unk_14[4];
/* 0x18 */ s16 unk_18;
/* 0x1A */ s16 unk_1A;
/* 0x1C */ char unk_1C[0x10];
/* 0x2C */ s16 unk_2C;
/* 0x2E */ s16 unk_2E;
/* 0x30 */ char unk_30[4];
/* 0x34 */ s16 unk_34;
/* 0x36 */ char unk_36[0x77];
/* 0xAD */ s8 usingStringIDBool[5]; //unknown size
/* 0xB2 */ s8 unk_B2[6]; //unknown size
/* 0xB8 */ s32 unk_B8[4];
/* 0xC8 */ char unk_C8[0x1B4];
} TextWindow; //sizeof 0x27C
extern TextWindow* D_800CC69C;
s32 func_800364DC_370DC(u32);
void func_800365E8_371E8(u32);
INCLUDE_ASM(s32, "5ACF0", func_8005A0F0_5ACF0);
INCLUDE_ASM(s32, "5ACF0", func_8005A32C_5AF2C);
INCLUDE_ASM(s32, "5ACF0", func_8005A37C_5AF7C);
INCLUDE_ASM(s32, "5ACF0", func_8005A3C0_5AFC0);
INCLUDE_ASM(s32, "5ACF0", func_8005A428_5B028);
INCLUDE_ASM(s32, "5ACF0", func_8005A51C_5B11C);
INCLUDE_ASM(s32, "5ACF0", func_8005A54C_5B14C);
INCLUDE_ASM(s32, "5ACF0", func_8005A580_5B180);
INCLUDE_ASM(s32, "5ACF0", func_8005A5B0_5B1B0);
INCLUDE_ASM(s32, "5ACF0", func_8005A5EC_5B1EC);
INCLUDE_ASM(s32, "5ACF0", func_8005A61C_5B21C);
INCLUDE_ASM(s32, "5ACF0", func_8005A674_5B274);
INCLUDE_ASM(s32, "5ACF0", func_8005A6B0_5B2B0);
INCLUDE_ASM(s32, "5ACF0", func_8005A968_5B568);
INCLUDE_ASM(s32, "5ACF0", func_8005B040_5BC40);
INCLUDE_ASM(s32, "5ACF0", func_8005B238_5BE38);
INCLUDE_ASM(s32, "5ACF0", func_8005B43C_5C03C);
INCLUDE_ASM(s32, "5ACF0", func_8005B5EC_5C1EC);
INCLUDE_ASM(s32, "5ACF0", func_8005B614_5C214);
INCLUDE_ASM(s32, "5ACF0", func_8005B63C_5C23C);
INCLUDE_ASM(s32, "5ACF0", func_8005B68C_5C28C);
void func_8005B6BC_5C2BC(s16 win_id, u32 arg1, s8 arg2) {
TextWindow* textWindow = &D_800CC69C[win_id];
if (textWindow->unk_B8[arg2] != 0) {
if (textWindow->usingStringIDBool[arg2] != 0) {
func_800365E8_371E8(textWindow->unk_B8[arg2]);
}
}
if (0x80000000 < arg1) {
textWindow->usingStringIDBool[arg2] = 0;
textWindow->unk_B8[arg2] = arg1;
} else {
textWindow->usingStringIDBool[arg2] = 1;
textWindow->unk_B8[arg2] = func_800364DC_370DC(arg1);
}
textWindow->unk_B2[arg2] = -1;
}
INCLUDE_ASM(s32, "5ACF0", func_8005B7B8_5C3B8);
INCLUDE_ASM(s32, "5ACF0", func_8005B8F8_5C4F8);
INCLUDE_ASM(s32, "5ACF0", func_8005B974_5C574);
INCLUDE_ASM(s32, "5ACF0", func_8005BA28_5C628);
INCLUDE_ASM(s32, "5ACF0", func_8005BA54_5C654);
INCLUDE_ASM(s32, "5ACF0", func_8005BA90_5C690);
INCLUDE_ASM(s32, "5ACF0", func_8005BB18_5C718);
INCLUDE_ASM(s32, "5ACF0", func_8005BBC0_5C7C0);
INCLUDE_ASM(s32, "5ACF0", func_8005BCA4_5C8A4);
INCLUDE_ASM(s32, "5ACF0", func_8005BDA8_5C9A8);
INCLUDE_ASM(s32, "5ACF0", func_8005BDFC_5C9FC);
INCLUDE_ASM(s32, "5ACF0", func_8005BE30_5CA30);
INCLUDE_ASM(s32, "5ACF0", func_8005BEE0_5CAE0);
INCLUDE_ASM(s32, "5ACF0", func_8005BF70_5CB70);
INCLUDE_ASM(s32, "5ACF0", func_8005C02C_5CC2C);
INCLUDE_ASM(s32, "5ACF0", func_8005C060_5CC60);
INCLUDE_ASM(s32, "5ACF0", func_8005C154_5CD54);
INCLUDE_ASM(s32, "5ACF0", func_8005C190_5CD90);
INCLUDE_ASM(s32, "5ACF0", func_8005CC18_5D818);
INCLUDE_ASM(s32, "5ACF0", func_8005CC3C_5D83C);
INCLUDE_ASM(s32, "5ACF0", func_8005CCF0_5D8F0);
INCLUDE_ASM(s32, "5ACF0", func_8005CD38_5D938);
INCLUDE_ASM(s32, "5ACF0", func_8005CD84_5D984);
INCLUDE_ASM(s32, "5ACF0", func_8005CE10_5DA10);
INCLUDE_ASM(s32, "5ACF0", func_8005CEB0_5DAB0);
INCLUDE_ASM(s32, "5ACF0", func_8005CF94_5DB94);
INCLUDE_ASM(s32, "5ACF0", func_8005CFE0_5DBE0);
INCLUDE_ASM(s32, "5ACF0", func_8005D294_5DE94);
INCLUDE_ASM(s32, "5ACF0", func_8005D2D4_5DED4);
INCLUDE_ASM(s32, "5ACF0", func_8005D2FC_5DEFC);
INCLUDE_ASM(s32, "5ACF0", func_8005D30C_5DF0C);
INCLUDE_ASM(s32, "5ACF0", func_8005D83C_5E43C);
INCLUDE_ASM(s32, "5ACF0", func_8005DAA4_5E6A4);
INCLUDE_ASM(s32, "5ACF0", func_8005DC94_5E894);
INCLUDE_ASM(s32, "5ACF0", func_8005DD14_5E914);
INCLUDE_ASM(s32, "5ACF0", func_8005DD54_5E954);
INCLUDE_ASM(s32, "5ACF0", func_8005DDDC_5E9DC);
INCLUDE_ASM(s32, "5ACF0", func_8005E0C0_5ECC0);
INCLUDE_ASM(s32, "5ACF0", func_8005E1A8_5EDA8);
INCLUDE_ASM(s32, "5ACF0", func_8005E1D8_5EDD8);
INCLUDE_ASM(s32, "5ACF0", func_8005E348_5EF48);
INCLUDE_ASM(s32, "5ACF0", func_8005EEE4_5FAE4);
INCLUDE_ASM(s32, "5ACF0", func_8005F364_5FF64);
INCLUDE_ASM(s32, "5ACF0", func_8005F524_60124);
INCLUDE_ASM(s32, "5ACF0", func_8005F698_60298);
INCLUDE_ASM(s32, "5ACF0", func_8005F744_60344);
INCLUDE_ASM(s32, "5ACF0", func_8005F784_60384);
INCLUDE_ASM(s32, "5ACF0", func_8005F7F4_603F4);
INCLUDE_ASM(s32, "5ACF0", func_8005F904_60504);
INCLUDE_ASM(s32, "5ACF0", func_8005F918_60518);
INCLUDE_ASM(s32, "5ACF0", func_8005FA90_60690);
INCLUDE_ASM(s32, "5ACF0", func_8005FBA4_607A4);
INCLUDE_ASM(s32, "5ACF0", func_8005FBF8_607F8);
INCLUDE_ASM(s32, "5ACF0", func_8005FE54_60A54);
INCLUDE_ASM(s32, "5ACF0", func_8005FE90_60A90);
INCLUDE_ASM(s32, "5ACF0", func_8005FFA8_60BA8);
INCLUDE_ASM(s32, "5ACF0", func_800600C0_60CC0);
INCLUDE_ASM(s32, "5ACF0", func_8006010C_60D0C);
void func_80060144_60D44(void) {
}
INCLUDE_ASM(s32, "5ACF0", func_8006014C_60D4C);
INCLUDE_ASM(s32, "5ACF0", func_80060174_60D74);
INCLUDE_ASM(s32, "5ACF0", func_800601BC_60DBC);
INCLUDE_ASM(s32, "5ACF0", func_8006022C_60E2C);
INCLUDE_ASM(s32, "5ACF0", func_80060290_60E90);
INCLUDE_ASM(s32, "5ACF0", func_8006034C_60F4C);
INCLUDE_ASM(s32, "5ACF0", func_80060388_60F88);
INCLUDE_ASM(s32, "5ACF0", func_80060394_60F94);
INCLUDE_ASM(s32, "5ACF0", func_800604A8_610A8);
INCLUDE_ASM(s32, "5ACF0", func_800605A4_611A4);
INCLUDE_ASM(s32, "5ACF0", func_80060848_61448);
INCLUDE_ASM(s32, "5ACF0", func_80060858_61458);
INCLUDE_ASM(s32, "5ACF0", func_80060880_61480);
INCLUDE_ASM(s32, "5ACF0", func_80060C14_61814);
INCLUDE_ASM(s32, "5ACF0", func_80060DEC_619EC);
INCLUDE_ASM(s32, "5ACF0", func_80060EA8_61AA8);
INCLUDE_ASM(s32, "5ACF0", func_8006105C_61C5C);
INCLUDE_ASM(s32, "5ACF0", func_800610E0_61CE0);
INCLUDE_ASM(s32, "5ACF0", func_80061100_61D00);
INCLUDE_ASM(s32, "5ACF0", func_80061188_61D88);
INCLUDE_ASM(s32, "5ACF0", func_80061388_61F88);
INCLUDE_ASM(s32, "5ACF0", func_800615B8_621B8);
INCLUDE_ASM(s32, "5ACF0", func_80061934_62534);
INCLUDE_ASM(s32, "5ACF0", func_80061A5C_6265C);

View File

@ -0,0 +1,12 @@
#include "GateGuy.h"
typedef struct board_overlay_entrypoint {
s16 index;
void* fn;
} board_overlay_entrypoint;
extern board_overlay_entrypoint D_801186E0_3EB7D0[];
void func_801059A0_3D8A90(void) {
func_800359E0_365E0(&D_801186E0_3EB7D0, D_800A1764_A2364);
}

View File

@ -0,0 +1,354 @@
#include "GateGuy.h"
void func_801059D0_3D8AC0(void) {
D_800CDD58 = 1;
D_800D037C = 0;
func_80047B80_48780(HuPrcGetCurrent(), 0x80);
func_80100CEC(gPlayers[gCurrentPlayerIndex].controller);
func_80047BAC_487AC(HuPrcGetCurrent(), 0x80);
D_800CDD58 = 0;
D_800D037C = 1;
}
void func_80105A58_3D8B48(void) {
while (func_800E88FC() != 0) {
HuPrcVSleep();
}
HuPrcVSleep();
D_80119470 = func_800E1824(0, 0xA0, 1);
D_80119474 = func_800E1824(0xD, 0xAE, 1);
D_80119478 = func_800E1824(1, 0xBC, 1);
D_8011947C = func_800E1824(3, 0xCA, 1);
HuPrcSleep(3);
D_800CDD58 = 1;
D_800D51F8 = 1;
}
void func_80105B10_3D8C00(void) {
D_800CDD58 = 0;
D_800D51F8 = 0;
func_800E1854(D_80119470);
func_800E1854(D_80119474);
func_800E1854(D_80119478);
func_800E1854(D_8011947C);
}
void func_80105B64_3D8C54(void) {
D_800CD059 = 0;
HuObjInit(0xA, 0);
func_80048228_48E28(0x5A, 0, 0x4190);
}
void func_80105B9C_3D8C8C(void) {
s8 sp10;
s8 sp11;
HuObjInit(0xA, 0);
func_800E94D0();
func_800E9B10(0x13, 0x241);
func_800E9F4C(0x1C, &sp10, &sp11);
func_800ECD0C(0, sp10, sp11);
func_800E9F4C(0x1B, &sp10, &sp11);
func_800ECD0C(1, sp10, sp11);
gPlayers[0].unk1ChainIndex = -1;
gPlayers[0].unk1SpaceIndex = -1;
gPlayers[1].unk1ChainIndex = -1;
gPlayers[1].unk1SpaceIndex = -1;
func_800E9D9C();
func_800E9564();
D_800CD0B0.unk_04 = 5;
D_800CD0B0.unk_02 = 0;
func_800EA760();
func_8004819C_48D9C(1);
}
void func_80105C64_3D8D54(s32 arg0, s32 arg1, unkStruct01* arg2) {
f32 temp_f20;
func_800EB708(arg0, arg1, arg2);
temp_f20 = func_800D76D0(arg2) + 15.0f;
arg2->unk_00 = func_8008EF20_8FB20(temp_f20);
arg2->unk_08 = func_8008E3F0_8EFF0(temp_f20);
}
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80105CC0_3D8DB0);
void* func_80105EB0_3D8FA0(unkStruct04* arg0) {
unkStruct03* temp_v0;
unkStruct02* temp_v0_2;
temp_v0 = func_80047EA0_48AA0(&func_80105CC0_3D8DB0, 0xA, 0, 0x40);
temp_v0_2 = HuMemMemoryAlloc(temp_v0->unk_18, sizeof(unkStruct02));
temp_v0->unk_8C = temp_v0_2;
temp_v0_2->unk_00.x = arg0->unk_0C.x;
temp_v0_2->unk_00.y = arg0->unk_0C.y;
temp_v0_2->unk_00.z = arg0->unk_0C.z;
return temp_v0;
}
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80105F20_3D9010);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801060D0_3D91C0);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010615C_3D924C);
void func_80106240_3D9330(void) {
func_800FC8C4(&D_80105540);
}
void func_80106260_3D9350(s32 arg0, unkStruct05* arg1, s32 arg2, f32 arg3) {
arg3 = arg3 + 0.5f;
if (arg2 & 9) {
func_800EC1E4(&D_80105540, arg0 + 0xC, &D_80105540, arg3);
} else {
func_800EC1E4(&D_80105540, arg1->unk_24 + 0xC, &D_80105540, arg3);
}
}
void func_801062C0_3D93B0(s32 arg0, unkStruct05* arg1, s32 arg2, f32 arg3) {
if (arg2 & 9) {
func_800EBF2C(&D_80105540, arg0 + 0xC, &D_80105540);
} else {
func_800EBF2C(&D_80105540, arg1->unk_24 + 0xC, &D_80105540);
}
}
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80106308_3D93F8);
unkStruct03* func_8010645C_3D954C(s32 arg0, s32 arg1) {
unkStruct03* temp_v0;
unkStruct06* temp_v0_2;
temp_v0 = func_80047EA0_48AA0(&func_80106308_3D93F8, 0xA, 0, 0x40);
temp_v0_2 = HuMemMemoryAlloc(temp_v0->unk_18, sizeof(unkStruct06));
temp_v0->unk_8C = temp_v0_2;
temp_v0_2->unk_00 = arg0;
temp_v0_2->unk_04 = arg1;
return temp_v0;
}
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801064C8_3D95B8);
void* func_80106740_3D9830(s32 arg0) {
object* temp_v0;
temp_v0 = func_800D8010(arg0 & 0xFF, 0);
func_8001C258_1CE58(*temp_v0->unk3C->unk40, 0x180, 0);
func_8001C8E4_1D4E4(*temp_v0->unk3C->unk40, 0x1800);
func_8001C448_1D048(*temp_v0->unk3C->unk40);
func_800D8944(temp_v0);
func_800D8F0C(temp_v0);
func_8001C814_1D414(*temp_v0->unk3C->unk40, 2, 1);
return temp_v0;
}
void func_801067D4_3D98C4(object* arg0, s32 arg1) {
func_800D8E88();
func_8001C814_1D414(*arg0->unk3C->unk40, 3, 0);
func_80089A20_8A620(&arg0->coords, arg1);
}
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80106828_3D9918);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80107188_3DA278);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801079B8_3DAAA8);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80107EBC_3DAFAC);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801084A4_3DB594);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80108550_3DB640);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80109404_3DC4F4);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80109888_3DC978);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010A210_3DD300);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010AAB0_3DDBA0);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010AD48_3DDE38);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010AFB4_3DE0A4);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010B130_3DE220);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010B480_3DE570);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010B4C0_3DE5B0);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010B528_3DE618);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010B53C_3DE62C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010B54C_3DE63C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010BCD4_3DEDC4);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010CE68_3DFF58);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010D424_3E0514);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010D95C_3E0A4C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010D9F4_3E0AE4);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010DA84_3E0B74);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010DB00_3E0BF0);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010DB2C_3E0C1C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010DC04_3E0CF4);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010DCA8_3E0D98);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010DD3C_3E0E2C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010DDEC_3E0EDC);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010DF68_3E1058);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010E008_3E10F8);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010E1B4_3E12A4);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010E2CC_3E13BC);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010E2F8_3E13E8);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010E348_3E1438);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010E3F8_3E14E8);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010E574_3E1664);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010E614_3E1704);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010E7C0_3E18B0);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010E8D8_3E19C8);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010E904_3E19F4);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010E954_3E1A44);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010EA74_3E1B64);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010EAD4_3E1BC4);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010EB44_3E1C34);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010EB88_3E1C78);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010EC78_3E1D68);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010ED20_3E1E10);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010EDA0_3E1E90);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010EFBC_3E20AC);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010F12C_3E221C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8010F99C_3E2A8C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80110068_3E3158);
void func_80110B7C_3E3C6C(void) {
unkStruct07* temp_s0;
temp_s0 = func_800F375C(-1);
if (func_800F3750() == 0 && !(temp_s0->unk_17 & 4)) {
func_800F38DC(-1, -1, 2);
func_80110068_3E3158(0);
}
}
void func_80110BD8_3E3CC8(void) {
unkStruct07* temp_s0;
temp_s0 = func_800F375C(-1);
if ((func_800F3750() == 1) && !(temp_s0->unk_17 & 4)) {
func_800F38DC(-1, -1, 2);
func_80110068_3E3158(1);
}
}
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80110C3C_3E3D2C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80111DFC_3E4EEC);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801123E8_3E54D8);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801124D8_3E55C8);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80112514_3E5604);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80112590_3E5680);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801125CC_3E56BC);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8011264C_3E573C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801129C8_3E5AB8);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80112BB4_3E5CA4);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80112DA0_3E5E90);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801135D8_3E66C8);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801138D0_3E69C0);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8011390C_3E69FC);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80113CAC_3E6D9C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801147FC_3E78EC);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80115850_3E8940);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801159F8_3E8AE8);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80116484_3E9574);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80117480_3EA570);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80117624_3EA714);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801179AC_3EAA9C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80117D3C_3EAE2C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80117DDC_3EAECC);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80117E7C_3EAF6C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80117ED8_3EAFC8);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80117FFC_3EB0EC);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80118058_3EB148);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80118178_3EB268);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801181C4_3EB2B4);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80118210_3EB300);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_8011825C_3EB34C);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801182A8_3EB398);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_801182E4_3EB3D4);
void func_80118320_3EB410(void) {
}
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80118328_3EB418);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80118414_3EB504);
INCLUDE_ASM(s32, "overlays/board_gate_guy/3D8AC0", func_80118530_3EB620);

View File

@ -0,0 +1,123 @@
#include "common.h"
#include "process.h"
#include "common_structs.h"
typedef struct unkStruct {
s16 unk_00;
s16 unk_02;
s16 unk_04;
} unkStruct;
typedef struct unkStruct01 {
f32 unk_00;
char unk_04[4];
f32 unk_08;
} unkStruct01;
typedef struct unkStruct02 {
vec3f unk_00;
char unk_0C[4];
} unkStruct02;
struct heap_node
{
s32 size; // 0000
u8 heap_constant; // 0004
u8 used; // bool // 0005
struct heap_node *prev; // 0008
struct heap_node *next; // 000C
};
typedef struct unkStruct03 {
char unk_00[0x18];
struct heap_node* unk_18;
char unk_1C[0x70];
unkStruct02* unk_8C;
} unkStruct03;
typedef struct unkStruct04 {
char unk_00[0x0C];
vec3f unk_0C;
} unkStruct04;
typedef struct unkStruct05 {
char unk_00[0x24];
s32 unk_24;
} unkStruct05;
typedef struct unkStruct06 {
s32 unk_00;
s32 unk_04;
f32 unk_08;
char unk_0C[4];
} unkStruct06;
typedef struct unkStruct07 {
char unk_00[0x17];
u8 unk_17;
} unkStruct07;
void func_800359E0_365E0(void*, s16);
extern s16 D_800A1764_A2364;
extern s8 gCurrentPlayerIndex;
extern player gPlayers[4];
void func_80047B80_48780(struct process*, s32);
void func_80047BAC_487AC(struct process*, s32);
void func_80100CEC(u8);
extern s16 D_800CDD58;
extern s16 D_800D037C;
s32 func_800E1824(s32, s32, s32);
s32 func_800E88FC(void);
extern s16 D_800D51F8;
extern s32 D_80119470;
extern s32 D_80119474;
extern s32 D_80119478;
extern s32 D_8011947C;
void func_800E1854(s32);
extern s16 D_800D51F8;
extern s32 D_80119470;
extern s32 D_80119474;
extern s32 D_80119478;
extern s32 D_8011947C;
void HuObjInit(s32, s32);
void func_80048228_48E28(s32, s32, s32);
extern s8 D_800CD059;
void func_8004819C_48D9C(s32);
void func_800E94D0(void);
void func_800E9564(void);
void func_800E9B10(s32, s32);
void func_800E9D9C(void);
void func_800E9F4C(s32, s8*, s8*);
void func_800EA760(void);
void func_800ECD0C(s32, s8, s8);
f32 func_8008E3F0_8EFF0(f32);
f32 func_8008EF20_8FB20(f32);
f32 func_800D76D0(void*);
void func_800EB708(s32, s32, unkStruct01*);
void * HuMemMemoryAlloc(struct heap_node * heap, s32 size);
unkStruct03* func_80047EA0_48AA0(void*, s32, s32, s32);
void func_80105CC0_3D8DB0(void); //probably takes object as arg
void func_800FC8C4(void*);
extern s32 D_80105540;
void func_800EC1E4(void*, s32, void*, f32);
extern s32 D_80105540;
extern unkStruct D_800CD0B0;
void func_800EBF2C(void*, s32, void*);
void func_80106308_3D93F8(void);
void func_8001C258_1CE58(s16, s32, s32);
void func_8001C448_1D048(s16);
void func_8001C814_1D414(s16, s32, s32);
void func_8001C8E4_1D4E4(s16, s32);
void* func_800D8010(s32, s32);
void func_800D8944(void*);
void func_800D8F0C(void*);
void func_80089A20_8A620(vec3f*, s32);
void func_800D8E88(void);
s16 func_800F3750(void);
void* func_800F375C(s32);
void func_800F38DC(s32, s32, s32);
void func_80110068_3E3158(s32);
s16 func_800F3750(void);
void* func_800F375C(s32);
void func_800F38DC(s32, s32, s32);
void func_80110068_3E3158(s32);

View File

@ -0,0 +1,15 @@
#include "common.h"
typedef struct board_overlay_entrypoint {
s16 index;
void* fn;
} board_overlay_entrypoint;
void func_800359E0_365E0(void*, s16);
extern s16 D_800A1764_A2364;
extern board_overlay_entrypoint D_80105AE0_3D8A70[];
void func_801059A0_3D8930(void) {
//func_800359E0_365E0 is ExecBoardScene from mp1
func_800359E0_365E0(D_80105AE0_3D8A70, D_800A1764_A2364);
}

View File

@ -434,3 +434,5 @@ _Ldunscale = 0x800843EC;
_Genld = 0x80084484;
guNormalize = 0x80082B00;
gCurrentPlayerIndex = 0x800CD067;
guLookAtF = 0x80088210;

79
tools/asm_sizes.py Executable file
View File

@ -0,0 +1,79 @@
#! /usr/bin/python3
import json
import glob
import os
import argparse
from enum import IntEnum
script_dir = os.path.dirname(os.path.realpath(__file__))
asm_dir = script_dir + "/../asm/nonmatchings"
modes = [ "min", "max", "avg", "total", "size" ]
sizes = {}
funcs = {}
# Calculate the number of instructions in a .s file
def calc_insns(f_path):
ret = 0
with open(f_path) as f:
f_lines = f.readlines()
for line in f_lines:
if line.startswith("/* "):
ret += 1
funcs[f_path.split("/")[-1][:-2]] = ret
return ret
# Calculate different data points for each .c files and store them as a Tuple
def do_dir(root, dir):
max = 0
min = 0
total = 0
files = glob.glob(os.path.join(root, dir) + "/*.s")
for f in files:
amt = calc_insns(f)
if amt > max:
max = amt
if min == 0 or amt < min:
min = amt
total += amt
avg = 0 if len(files) == 0 else total / len(files)
sizes[root + "/" + dir] = ((min, max, total, avg, len(files)))
parser = argparse.ArgumentParser(description="A tool to receive information about the number of non-matching .s files "
+"per .c file, or the size of .s files, measured by their number of instructions. "
+"Option -p is used by default if no option is specified.")
group = parser.add_mutually_exclusive_group()
group.add_argument("-f", "--files", help="Default. Print the number of non-matching .s files per .c file, ordered by size.", action='store_true', required=False)
group.add_argument("-a", "--alphabetical", help="Print the size of .s files, ordered by name.", action='store_true', required=False)
group.add_argument("-s", "--size", help="Print the size of .s files, ordered by size.", action='store_true', required=False)
parser.add_argument("-l", "--limit", help="Only print the .c --files that are greater than or equal to the value.", type=int, default=0, required=False)
parser.add_argument("-m", "--mode", help="Switches between output modes for --files. Allowed values are: {min, max, avg, total, size}.", choices=modes, default="size", metavar='', required=False)
args = parser.parse_args()
if __name__ == "__main__":
for root, dirs, files in os.walk(asm_dir):
for asm_dir in dirs:
do_dir(root, asm_dir)
if args.alphabetical:
print(json.dumps(dict(sorted(funcs.items(), key=lambda f: f[0])), indent=4))
elif args.size:
print(json.dumps(dict(sorted(funcs.items(), key=lambda f: f[1])), indent=4))
else:
for thing in sorted(sizes.keys(), key=lambda x: sizes[x][modes.index(args.mode)]):
val = sizes[thing][modes.index(args.mode)]
if val > args.limit:
print(thing.split("nonmatchings/")[1].ljust(50) + str(val))

87
tools/m2ctx.py Normal file → Executable file
View File

@ -1,67 +1,72 @@
#!/usr/bin/python3
# Generates a "context" file for use with mips_to_c
# ./m2ctx.py file.c [output.c]
#!/usr/bin/env python3
import argparse
import os
import sys
import subprocess
from pathlib import Path
import tempfile
script_dir = os.path.dirname(os.path.realpath(__file__))
root_dir = os.path.abspath(os.path.join(script_dir, ".."))
src_dir = root_dir + "src/"
# Project-specific
CPP_FLAGS = [
"-Iinclude",
"-Isrc",
"-Ibuild/include",
"-Iinclude/engine",
"-D_LANGUAGE_C",
"-DF3DEX_GBI_2",
"-D_MIPS_SZLONG=32",
"-D__attribute__(...)=",
"-D__asm__(...)=",
"-ffreestanding",
"-DM2CTX",
]
def get_c_dir(dirname):
for root, dirs, files in os.walk(src_dir):
for directory in dirs:
if directory == dirname:
return os.path.join(root, directory)
def get_c_file(directory):
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(".c") and "data" not in file:
return file
def import_c_file(in_file):
def import_c_file(in_file) -> str:
in_file = os.path.relpath(in_file, root_dir)
cpp_command = ["gcc", "-E", "-P", "-Iinclude", "-Isrc","-D_LANGUAGE_C",
"-ffreestanding", "-DF3DEX_GBI_2", "-D_MIPS_SZLONG=32", "-DSCRIPT(...)={}", in_file]
cpp_command = ["gcc", "-E", "-P", "-dM", *CPP_FLAGS, in_file]
cpp_command2 = ["gcc", "-E", "-P", *CPP_FLAGS, in_file]
with tempfile.NamedTemporaryFile(suffix=".c") as tmp:
stock_macros = subprocess.check_output(["gcc", "-E", "-P", "-dM", tmp.name], cwd=root_dir, encoding="utf-8")
out_text = ""
try:
return subprocess.check_output(cpp_command, cwd=root_dir, encoding="utf-8")
out_text += subprocess.check_output(cpp_command, cwd=root_dir, encoding="utf-8")
out_text += subprocess.check_output(cpp_command2, cwd=root_dir, encoding="utf-8")
except subprocess.CalledProcessError:
print(
"Failed to preprocess input file, when running command:\n"
+ cpp_command,
+ ' '.join(cpp_command),
file=sys.stderr,
)
sys.exit(1)
if not out_text:
print("Output is empty - aborting")
sys.exit(1)
for line in stock_macros.strip().splitlines():
out_text = out_text.replace(line + "\n", "")
return out_text
def main():
if len(sys.argv) > 1:
c_file_path = Path.cwd() / sys.argv[1]
if len(sys.argv) > 2:
out_file_path = Path.cwd() / sys.argv[2]
m2ctx(c_file_path, out_file_path)
parser = argparse.ArgumentParser(
description="""Create a context file which can be used for mips_to_c"""
)
parser.add_argument(
"c_file",
help="""File from which to create context""",
)
args = parser.parse_args()
output = import_c_file(args.c_file)
def m2ctx(c_file_path, out_file_path):
processed = import_c_file(c_file_path)
processed_lines = processed.split("\n")
output = []
for line in processed_lines:
if ("__attribute__" not in line
and "__asm" not in line):
output.append(line)
with open(out_file_path, "w", encoding="UTF-8") as f:
f.write("\n".join(output))
with open(os.path.join(root_dir, "ctx.c"), "w", encoding="UTF-8") as f:
f.write(output)
if __name__ == "__main__":