From 05a178c55af8949a80913c8049df0a939ffb67c3 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 3 Nov 2019 07:32:50 +1000 Subject: [PATCH] Match chrGetTargetSomething --- src/game/game_000000.c | 48 ++++++++------------------------- src/include/gvars/gvars.h | 56 +++++++++++++++++++++++++-------------- 2 files changed, 47 insertions(+), 57 deletions(-) diff --git a/src/game/game_000000.c b/src/game/game_000000.c index a75e778ed..3867197f5 100644 --- a/src/game/game_000000.c +++ b/src/game/game_000000.c @@ -46899,44 +46899,18 @@ glabel func0f028834 /* f028880: 00000000 */ sll $zero,$zero,0x0 ); -GLOBAL_ASM( -glabel chrGetTargetSomething -/* f028884: 8482017e */ lh $v0,0x17e($a0) -/* f028888: 2401ffff */ addiu $at,$zero,-1 -/* f02888c: 3c09800a */ lui $t1,0x800a -/* f028890: 14410009 */ bne $v0,$at,.L0f0288b8 -/* f028894: 000240c0 */ sll $t0,$v0,0x3 -/* f028898: 948e032e */ lhu $t6,0x32e($a0) -/* f02889c: 3c19800a */ lui $t9,0x800a -/* f0288a0: 000e7b82 */ srl $t7,$t6,0xe -/* f0288a4: 000fc080 */ sll $t8,$t7,0x2 -/* f0288a8: 0338c821 */ addu $t9,$t9,$t8 -/* f0288ac: 8f39a024 */ lw $t9,-0x5fdc($t9) -/* f0288b0: 03e00008 */ jr $ra -/* f0288b4: 8f2200bc */ lw $v0,0xbc($t9) -.L0f0288b8: -/* f0288b8: 8d29a2f8 */ lw $t1,-0x5d08($t1) -/* f0288bc: 01024021 */ addu $t0,$t0,$v0 -/* f0288c0: 000840c0 */ sll $t0,$t0,0x3 -/* f0288c4: 01091821 */ addu $v1,$t0,$t1 -/* f0288c8: 03e00008 */ jr $ra -/* f0288cc: 00601025 */ or $v0,$v1,$zero -); +struct targetsomething *chrGetTargetSomething(struct chrdata *chr) +{ + struct targetsomething *ret; -// Mismatch because the way it calculates the offset into g_Vars.targets is -// different. -//struct targetsomething *chrGetTargetSomething(struct chrdata *chr) -//{ -// struct targetsomething *ret; -// -// if (chr->target == -1) { -// ret = g_Vars.players[(u32)chr->BITFIELD.shorts[1] >> 14]->targetsomething; -// } else { -// ret = &g_Vars.targets[chr->target]; -// } -// -// return ret; -//} + if (chr->target == -1) { + ret = g_Vars.players[(u32)chr->BITFIELD.shorts[1] >> 14]->targetsomething; + } else { + ret = g_Vars.targets + chr->target; + } + + return ret; +} GLOBAL_ASM( glabel func0f0288d0 diff --git a/src/include/gvars/gvars.h b/src/include/gvars/gvars.h index 903c66f34..f3d696ae4 100644 --- a/src/include/gvars/gvars.h +++ b/src/include/gvars/gvars.h @@ -220,26 +220,42 @@ struct g_vars { /*00032c*/ u32 unk00032c; /*000330*/ u32 unk000330; /*000334*/ u32 unk000334; - /*000338*/ struct targetsomething targets[2]; // array length unknown - ///*000338*/ struct targetsomething *targets[24]; // array length unknown - ///*000380*/ u32 unk000380; - ///*000384*/ u32 unk000384; - ///*000388*/ u32 unk000388; - ///*00038c*/ u32 unk00038c; - ///*000390*/ u32 unk000390; - ///*000394*/ u32 unk000394; - ///*000398*/ u32 unk000398; - ///*00039c*/ u32 unk00039c; - ///*0003a0*/ u32 unk0003a0; - ///*0003a4*/ u32 unk0003a4; - ///*0003a8*/ u32 unk0003a8; - ///*0003ac*/ u32 unk0003ac; - ///*0003b0*/ u32 unk0003b0; - ///*0003b4*/ u32 unk0003b4; - ///*0003b8*/ u32 unk0003b8; - ///*0003bc*/ u32 unk0003bc; - ///*0003c0*/ u32 unk0003c0; - ///*0003c4*/ u32 unk0003c4; + /*000338*/ struct targetsomething *targets; + /*00033c*/ u32 unk00033c; + /*000340*/ u32 unk000340; + /*000344*/ u32 unk000344; + /*000348*/ u32 unk000348; + /*00034c*/ u32 unk00034c; + /*000350*/ u32 unk000350; + /*000354*/ u32 unk000354; + /*000358*/ u32 unk000358; + /*00035c*/ u32 unk00035c; + /*000360*/ u32 unk000360; + /*000364*/ u32 unk000364; + /*000368*/ u32 unk000368; + /*00036c*/ u32 unk00036c; + /*000370*/ u32 unk000370; + /*000374*/ u32 unk000374; + /*000378*/ u32 unk000378; + /*00037c*/ u32 unk00037c; + /*000380*/ u32 unk000380; + /*000384*/ u32 unk000384; + /*000388*/ u32 unk000388; + /*00038c*/ u32 unk00038c; + /*000390*/ u32 unk000390; + /*000394*/ u32 unk000394; + /*000398*/ u32 unk000398; + /*00039c*/ u32 unk00039c; + /*0003a0*/ u32 unk0003a0; + /*0003a4*/ u32 unk0003a4; + /*0003a8*/ u32 unk0003a8; + /*0003ac*/ u32 unk0003ac; + /*0003b0*/ u32 unk0003b0; + /*0003b4*/ u32 unk0003b4; + /*0003b8*/ u32 unk0003b8; + /*0003bc*/ u32 unk0003bc; + /*0003c0*/ u32 unk0003c0; + /*0003c4*/ u32 unk0003c4; /*0003c8*/ u32 unk0003c8; /*0003cc*/ u32 unk0003cc; /*0003d0*/ u32 unk0003d0;