From c00c81fb456d72bd0baf5ee8cddf4875774333bb Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 27 Aug 2020 17:54:37 +1000 Subject: [PATCH] Decompile func0f158140 --- src/game/game_157db0.c | 31 ++---- src/gvars/gvars.c | 2 +- src/include/game/game_157db0.h | 2 +- src/include/gvars/gvars.h | 2 +- src/include/types.h | 192 +++------------------------------ 5 files changed, 25 insertions(+), 204 deletions(-) diff --git a/src/game/game_157db0.c b/src/game/game_157db0.c index 16eacaeea..11d6ff24c 100644 --- a/src/game/game_157db0.c +++ b/src/game/game_157db0.c @@ -317,27 +317,16 @@ void func0f158108(s32 index, u8 *arg1, u8 *arg2) *arg2 = var800a4cc4[index].unk11; } -GLOBAL_ASM( -glabel func0f158140 -/* f158140: 3c0e800a */ lui $t6,%hi(var800a4ce8) -/* f158144: 8dce4ce8 */ lw $t6,%lo(var800a4ce8)($t6) -/* f158148: 00047880 */ sll $t7,$a0,0x2 -/* f15814c: 3c188008 */ lui $t8,%hi(var8007fc3c) -/* f158150: 01cf1021 */ addu $v0,$t6,$t7 -/* f158154: 94590000 */ lhu $t9,0x0($v0) -/* f158158: 9718fc3c */ lhu $t8,%lo(var8007fc3c)($t8) -/* f15815c: 3c09800a */ lui $t1,%hi(var800a4640) -/* f158160: 2403003c */ addiu $v1,$zero,0x3c -/* f158164: 17190002 */ bne $t8,$t9,.L0f158170 -/* f158168: 25294640 */ addiu $t1,$t1,%lo(var800a4640) -/* f15816c: 84430002 */ lh $v1,0x2($v0) -.L0f158170: -/* f158170: 00034080 */ sll $t0,$v1,0x2 -/* f158174: 01034023 */ subu $t0,$t0,$v1 -/* f158178: 00084080 */ sll $t0,$t0,0x2 -/* f15817c: 03e00008 */ jr $ra -/* f158180: 01091021 */ addu $v0,$t0,$t1 -); +struct var800a4640_00 *func0f158140(s32 arg0) +{ + s32 index = 60; + + if (var8007fc3c == var800a4ce8[arg0].unk00) { + index = var800a4ce8[arg0].unk02; + } + + return &var800a4640.unk000[index]; +} GLOBAL_ASM( glabel func0f158184 diff --git a/src/gvars/gvars.c b/src/gvars/gvars.c index 11e80a317..f06765ecc 100644 --- a/src/gvars/gvars.c +++ b/src/gvars/gvars.c @@ -16675,7 +16675,7 @@ u32 var800a4cd8 = 0; u32 var800a4cdc = 0; u32 var800a4ce0 = 0; s16 var800a4ce4[2] = {0}; -u32 var800a4ce8 = 0; +struct var800a4ce8 *var800a4ce8 = NULL; struct portalthing *g_PortalThings = NULL; struct var800a4cf0 var800a4cf0 = {0}; u32 var800a4d00 = 0; diff --git a/src/include/game/game_157db0.h b/src/include/game/game_157db0.h index 4d7163aea..309e68c33 100644 --- a/src/include/game/game_157db0.h +++ b/src/include/game/game_157db0.h @@ -6,7 +6,7 @@ u32 func0f157db0(void); void func0f157e94(s32 room, s32 arg1, struct screenbox *arg2); void func0f158108(s32 index, u8 *arg1, u8 *arg2); -u32 func0f158140(void); +struct var800a4640_00 *func0f158140(s32 index); u32 func0f158184(void); u32 func0f158400(void); u32 func0f158884(void); diff --git a/src/include/gvars/gvars.h b/src/include/gvars/gvars.h index abaddff97..7cc36f050 100644 --- a/src/include/gvars/gvars.h +++ b/src/include/gvars/gvars.h @@ -734,7 +734,7 @@ extern struct portalcmd *g_PortalCommands; extern u32 var800a4cd8; extern u32 var800a4ce0; extern s16 var800a4ce4[2]; -extern u32 var800a4ce8; +extern struct var800a4ce8 *var800a4ce8; extern struct portalthing *g_PortalThings; extern struct var800a4cf0 var800a4cf0; extern u32 var800a4d00; diff --git a/src/include/types.h b/src/include/types.h index 4fcaa9601..fd9ee29c8 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -5919,187 +5919,14 @@ struct screenbox { s16 ymax; }; +struct var800a4640_00 { + u32 unk00; + u32 unk04; + u32 unk08; +}; + struct var800a4640 { - /*0x000*/ u32 unk000; - /*0x004*/ u32 unk004; - /*0x008*/ u32 unk008; - /*0x00c*/ u32 unk00c; - /*0x010*/ u32 unk010; - /*0x014*/ u32 unk014; - /*0x018*/ u32 unk018; - /*0x01c*/ u32 unk01c; - /*0x020*/ u32 unk020; - /*0x024*/ u32 unk024; - /*0x028*/ u32 unk028; - /*0x02c*/ u32 unk02c; - /*0x030*/ u32 unk030; - /*0x034*/ u32 unk034; - /*0x038*/ u32 unk038; - /*0x03c*/ u32 unk03c; - /*0x040*/ u32 unk040; - /*0x044*/ u32 unk044; - /*0x048*/ u32 unk048; - /*0x04c*/ u32 unk04c; - /*0x050*/ u32 unk050; - /*0x054*/ u32 unk054; - /*0x058*/ u32 unk058; - /*0x05c*/ u32 unk05c; - /*0x060*/ u32 unk060; - /*0x064*/ u32 unk064; - /*0x068*/ u32 unk068; - /*0x06c*/ u32 unk06c; - /*0x070*/ u32 unk070; - /*0x074*/ u32 unk074; - /*0x078*/ u32 unk078; - /*0x07c*/ u32 unk07c; - /*0x080*/ u32 unk080; - /*0x084*/ u32 unk084; - /*0x088*/ u32 unk088; - /*0x08c*/ u32 unk08c; - /*0x090*/ u32 unk090; - /*0x094*/ u32 unk094; - /*0x098*/ u32 unk098; - /*0x09c*/ u32 unk09c; - /*0x0a0*/ u32 unk0a0; - /*0x0a4*/ u32 unk0a4; - /*0x0a8*/ u32 unk0a8; - /*0x0ac*/ u32 unk0ac; - /*0x0b0*/ u32 unk0b0; - /*0x0b4*/ u32 unk0b4; - /*0x0b8*/ u32 unk0b8; - /*0x0bc*/ u32 unk0bc; - /*0x0c0*/ u32 unk0c0; - /*0x0c4*/ u32 unk0c4; - /*0x0c8*/ u32 unk0c8; - /*0x0cc*/ u32 unk0cc; - /*0x0d0*/ u32 unk0d0; - /*0x0d4*/ u32 unk0d4; - /*0x0d8*/ u32 unk0d8; - /*0x0dc*/ u32 unk0dc; - /*0x0e0*/ u32 unk0e0; - /*0x0e4*/ u32 unk0e4; - /*0x0e8*/ u32 unk0e8; - /*0x0ec*/ u32 unk0ec; - /*0x0f0*/ u32 unk0f0; - /*0x0f4*/ u32 unk0f4; - /*0x0f8*/ u32 unk0f8; - /*0x0fc*/ u32 unk0fc; - /*0x100*/ u32 unk100; - /*0x104*/ u32 unk104; - /*0x108*/ u32 unk108; - /*0x10c*/ u32 unk10c; - /*0x110*/ u32 unk110; - /*0x114*/ u32 unk114; - /*0x118*/ u32 unk118; - /*0x11c*/ u32 unk11c; - /*0x120*/ u32 unk120; - /*0x124*/ u32 unk124; - /*0x128*/ u32 unk128; - /*0x12c*/ u32 unk12c; - /*0x130*/ u32 unk130; - /*0x134*/ u32 unk134; - /*0x138*/ u32 unk138; - /*0x13c*/ u32 unk13c; - /*0x140*/ u32 unk140; - /*0x144*/ u32 unk144; - /*0x148*/ u32 unk148; - /*0x14c*/ u32 unk14c; - /*0x150*/ u32 unk150; - /*0x154*/ u32 unk154; - /*0x158*/ u32 unk158; - /*0x15c*/ u32 unk15c; - /*0x160*/ u32 unk160; - /*0x164*/ u32 unk164; - /*0x168*/ u32 unk168; - /*0x16c*/ u32 unk16c; - /*0x170*/ u32 unk170; - /*0x174*/ u32 unk174; - /*0x178*/ u32 unk178; - /*0x17c*/ u32 unk17c; - /*0x180*/ u32 unk180; - /*0x184*/ u32 unk184; - /*0x188*/ u32 unk188; - /*0x18c*/ u32 unk18c; - /*0x190*/ u32 unk190; - /*0x194*/ u32 unk194; - /*0x198*/ u32 unk198; - /*0x19c*/ u32 unk19c; - /*0x1a0*/ u32 unk1a0; - /*0x1a4*/ u32 unk1a4; - /*0x1a8*/ u32 unk1a8; - /*0x1ac*/ u32 unk1ac; - /*0x1b0*/ u32 unk1b0; - /*0x1b4*/ u32 unk1b4; - /*0x1b8*/ u32 unk1b8; - /*0x1bc*/ u32 unk1bc; - /*0x1c0*/ u32 unk1c0; - /*0x1c4*/ u32 unk1c4; - /*0x1c8*/ u32 unk1c8; - /*0x1cc*/ u32 unk1cc; - /*0x1d0*/ u32 unk1d0; - /*0x1d4*/ u32 unk1d4; - /*0x1d8*/ u32 unk1d8; - /*0x1dc*/ u32 unk1dc; - /*0x1e0*/ u32 unk1e0; - /*0x1e4*/ u32 unk1e4; - /*0x1e8*/ u32 unk1e8; - /*0x1ec*/ u32 unk1ec; - /*0x1f0*/ u32 unk1f0; - /*0x1f4*/ u32 unk1f4; - /*0x1f8*/ u32 unk1f8; - /*0x1fc*/ u32 unk1fc; - /*0x200*/ u32 unk200; - /*0x204*/ u32 unk204; - /*0x208*/ u32 unk208; - /*0x20c*/ u32 unk20c; - /*0x210*/ u32 unk210; - /*0x214*/ u32 unk214; - /*0x218*/ u32 unk218; - /*0x21c*/ u32 unk21c; - /*0x220*/ u32 unk220; - /*0x224*/ u32 unk224; - /*0x228*/ u32 unk228; - /*0x22c*/ u32 unk22c; - /*0x230*/ u32 unk230; - /*0x234*/ u32 unk234; - /*0x238*/ u32 unk238; - /*0x23c*/ u32 unk23c; - /*0x240*/ u32 unk240; - /*0x244*/ u32 unk244; - /*0x248*/ u32 unk248; - /*0x24c*/ u32 unk24c; - /*0x250*/ u32 unk250; - /*0x254*/ u32 unk254; - /*0x258*/ u32 unk258; - /*0x25c*/ u32 unk25c; - /*0x260*/ u32 unk260; - /*0x264*/ u32 unk264; - /*0x268*/ u32 unk268; - /*0x26c*/ u32 unk26c; - /*0x270*/ u32 unk270; - /*0x274*/ u32 unk274; - /*0x278*/ u32 unk278; - /*0x27c*/ u32 unk27c; - /*0x280*/ u32 unk280; - /*0x284*/ u32 unk284; - /*0x288*/ u32 unk288; - /*0x28c*/ u32 unk28c; - /*0x290*/ u32 unk290; - /*0x294*/ u32 unk294; - /*0x298*/ u32 unk298; - /*0x29c*/ u32 unk29c; - /*0x2a0*/ u32 unk2a0; - /*0x2a4*/ u32 unk2a4; - /*0x2a8*/ u32 unk2a8; - /*0x2ac*/ u32 unk2ac; - /*0x2b0*/ u32 unk2b0; - /*0x2b4*/ u32 unk2b4; - /*0x2b8*/ u32 unk2b8; - /*0x2bc*/ u32 unk2bc; - /*0x2c0*/ u32 unk2c0; - /*0x2c4*/ u32 unk2c4; - /*0x2c8*/ u32 unk2c8; - /*0x2cc*/ u32 unk2cc; + /*0x000*/ struct var800a4640_00 unk000[60]; /*0x2d0*/ s16 unk2d0; /*0x2d2*/ u8 unk2d2; /*0x2d3*/ u8 unk2d3; @@ -6418,4 +6245,9 @@ struct var8009da60 { f32 unk2c; }; +struct var800a4ce8 { + u16 unk00; + s16 unk02; +}; + #endif