diff --git a/src/game/game_00c490.c b/src/game/game_00c490.c index 38ee00e30..1fa164822 100644 --- a/src/game/game_00c490.c +++ b/src/game/game_00c490.c @@ -92,8 +92,8 @@ glabel func0f00c490 .L0f00c52c: /* f00c52c: 14820006 */ bne $a0,$v0,.L0f00c548 /* f00c530: 3c0b800a */ lui $t3,%hi(g_Menus+0x2000) -/* f00c534: 3c0b800a */ lui $t3,%hi(var8009ce54) -/* f00c538: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) +/* f00c534: 3c0b800a */ lui $t3,%hi(g_NumMonitorThings) +/* f00c538: 256bce54 */ addiu $t3,$t3,%lo(g_NumMonitorThings) /* f00c53c: 240d0028 */ addiu $t5,$zero,0x28 /* f00c540: 10000004 */ b .L0f00c554 /* f00c544: ad6d0000 */ sw $t5,%lo(g_Menus+0x2000)($t3) @@ -159,8 +159,8 @@ glabel func0f00c490 /* f00c628: 3c08800a */ lui $t0,%hi(var8009ce48) /* f00c62c: 3c09800a */ lui $t1,%hi(var8009ce4c) /* f00c630: 3c0a800a */ lui $t2,%hi(g_NumProjectiles) -/* f00c634: 3c0b800a */ lui $t3,%hi(var8009ce54) -/* f00c638: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) +/* f00c634: 3c0b800a */ lui $t3,%hi(g_NumMonitorThings) +/* f00c638: 256bce54 */ addiu $t3,$t3,%lo(g_NumMonitorThings) /* f00c63c: 254ace50 */ addiu $t2,$t2,%lo(g_NumProjectiles) /* f00c640: 2529ce4c */ addiu $t1,$t1,%lo(var8009ce4c) /* f00c644: 2508ce48 */ addiu $t0,$t0,%lo(var8009ce48) @@ -191,8 +191,8 @@ glabel func0f00c490 /* f00c6a4: 3c08800a */ lui $t0,%hi(var8009ce48) /* f00c6a8: 3c09800a */ lui $t1,%hi(var8009ce4c) /* f00c6ac: 3c0a800a */ lui $t2,%hi(g_NumProjectiles) -/* f00c6b0: 3c0b800a */ lui $t3,%hi(var8009ce54) -/* f00c6b4: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) +/* f00c6b0: 3c0b800a */ lui $t3,%hi(g_NumMonitorThings) +/* f00c6b4: 256bce54 */ addiu $t3,$t3,%lo(g_NumMonitorThings) /* f00c6b8: 254ace50 */ addiu $t2,$t2,%lo(g_NumProjectiles) /* f00c6bc: 2529ce4c */ addiu $t1,$t1,%lo(var8009ce4c) /* f00c6c0: 2508ce48 */ addiu $t0,$t0,%lo(var8009ce48) @@ -243,8 +243,8 @@ glabel func0f00c490 /* f00c764: 3c08800a */ lui $t0,%hi(var8009ce48) /* f00c768: 3c09800a */ lui $t1,%hi(var8009ce4c) /* f00c76c: 3c0a800a */ lui $t2,%hi(g_NumProjectiles) -/* f00c770: 3c0b800a */ lui $t3,%hi(var8009ce54) -/* f00c774: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) +/* f00c770: 3c0b800a */ lui $t3,%hi(g_NumMonitorThings) +/* f00c774: 256bce54 */ addiu $t3,$t3,%lo(g_NumMonitorThings) /* f00c778: 254ace50 */ addiu $t2,$t2,%lo(g_NumProjectiles) /* f00c77c: 2529ce4c */ addiu $t1,$t1,%lo(var8009ce4c) /* f00c780: 2508ce48 */ addiu $t0,$t0,%lo(var8009ce48) @@ -291,8 +291,8 @@ glabel func0f00c490 /* f00c814: 2484ce60 */ addiu $a0,$a0,%lo(var8009ce60) /* f00c818: 3c09800a */ lui $t1,%hi(var8009ce4c) /* f00c81c: 3c0a800a */ lui $t2,%hi(g_NumProjectiles) -/* f00c820: 3c0b800a */ lui $t3,%hi(var8009ce54) -/* f00c824: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) +/* f00c820: 3c0b800a */ lui $t3,%hi(g_NumMonitorThings) +/* f00c824: 256bce54 */ addiu $t3,$t3,%lo(g_NumMonitorThings) /* f00c828: 254ace50 */ addiu $t2,$t2,%lo(g_NumProjectiles) /* f00c82c: 2529ce4c */ addiu $t1,$t1,%lo(var8009ce4c) /* f00c830: ac820000 */ sw $v0,0x0($a0) @@ -335,8 +335,8 @@ glabel func0f00c490 /* f00c8b8: 3c04800a */ lui $a0,%hi(var8009ce64) /* f00c8bc: 2484ce64 */ addiu $a0,$a0,%lo(var8009ce64) /* f00c8c0: 3c0a800a */ lui $t2,%hi(g_NumProjectiles) -/* f00c8c4: 3c0b800a */ lui $t3,%hi(var8009ce54) -/* f00c8c8: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) +/* f00c8c4: 3c0b800a */ lui $t3,%hi(g_NumMonitorThings) +/* f00c8c8: 256bce54 */ addiu $t3,$t3,%lo(g_NumMonitorThings) /* f00c8cc: 254ace50 */ addiu $t2,$t2,%lo(g_NumProjectiles) /* f00c8d0: ac820000 */ sw $v0,0x0($a0) /* f00c8d4: 1b00000c */ blez $t8,.L0f00c908 @@ -377,8 +377,8 @@ glabel func0f00c490 /* f00c954: 8d590000 */ lw $t9,0x0($t2) /* f00c958: 3c05800a */ lui $a1,%hi(g_Projectiles) /* f00c95c: 24a5ce68 */ addiu $a1,$a1,%lo(g_Projectiles) -/* f00c960: 3c0b800a */ lui $t3,%hi(var8009ce54) -/* f00c964: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) +/* f00c960: 3c0b800a */ lui $t3,%hi(g_NumMonitorThings) +/* f00c964: 256bce54 */ addiu $t3,$t3,%lo(g_NumMonitorThings) /* f00c968: aca20000 */ sw $v0,0x0($a1) /* f00c96c: 1b20000d */ blez $t9,.L0f00c9a4 /* f00c970: 8fa3001c */ lw $v1,0x1c($sp) @@ -398,8 +398,8 @@ glabel func0f00c490 .L0f00c9a4: /* f00c9a4: 8d620000 */ lw $v0,0x0($t3) /* f00c9a8: 14400004 */ bnez $v0,.L0f00c9bc -/* f00c9ac: 3c04800a */ lui $a0,%hi(var8009ce6c) -/* f00c9b0: 2484ce6c */ addiu $a0,$a0,%lo(var8009ce6c) +/* f00c9ac: 3c04800a */ lui $a0,%hi(g_MonitorThings) +/* f00c9b0: 2484ce6c */ addiu $a0,$a0,%lo(g_MonitorThings) /* f00c9b4: 1000001e */ b .L0f00ca30 /* f00c9b8: ac800000 */ sw $zero,0x0($a0) .L0f00c9bc: @@ -412,11 +412,11 @@ glabel func0f00c490 /* f00c9d4: 24050004 */ addiu $a1,$zero,0x4 /* f00c9d8: 0c0048f2 */ jal malloc /* f00c9dc: afa3001c */ sw $v1,0x1c($sp) -/* f00c9e0: 3c0b800a */ lui $t3,%hi(var8009ce54) -/* f00c9e4: 256bce54 */ addiu $t3,$t3,%lo(var8009ce54) +/* f00c9e0: 3c0b800a */ lui $t3,%hi(g_NumMonitorThings) +/* f00c9e4: 256bce54 */ addiu $t3,$t3,%lo(g_NumMonitorThings) /* f00c9e8: 8d6d0000 */ lw $t5,0x0($t3) -/* f00c9ec: 3c04800a */ lui $a0,%hi(var8009ce6c) -/* f00c9f0: 2484ce6c */ addiu $a0,$a0,%lo(var8009ce6c) +/* f00c9ec: 3c04800a */ lui $a0,%hi(g_MonitorThings) +/* f00c9f0: 2484ce6c */ addiu $a0,$a0,%lo(g_MonitorThings) /* f00c9f4: ac820000 */ sw $v0,0x0($a0) /* f00c9f8: 8fa3001c */ lw $v1,0x1c($sp) /* f00c9fc: 19a0000c */ blez $t5,.L0f00ca30 @@ -1472,9 +1472,9 @@ void setupSingleMonitor(struct singlemonitorobj *monitor, s32 cmdindex) } prop = func0f06a550(monitor); - monitor->base.projectile = func0f0686f0(); + monitor->base.monitorthing = monitorthingGetNew(); - if (prop && monitor->base.projectile) { + if (prop && monitor->base.monitorthing) { monitor->base.hidden |= OBJHFLAG_00000040; modelSetUnk14(monitor->base.model, monitor->base.model->unk14 * scale); monitor->base.model->attachedto = owner->model; @@ -1499,7 +1499,7 @@ void setupSingleMonitor(struct singlemonitorobj *monitor, s32 cmdindex) spa4.z = -spa4.z; func000166dc(&spa4, &sp24); - func00015be4(&sp64, &sp24, (Mtxf *)&monitor->base.projectile->unk004); + func00015be4(&sp64, &sp24, &monitor->base.monitorthing->matrix); } } else { setupGenericObject(&monitor->base, cmdindex); diff --git a/src/game/propobj.c b/src/game/propobj.c index 9fc42414a..75d17f378 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -2853,40 +2853,21 @@ glabel func0f0686e0 /* f0686ec: ac8f0000 */ sw $t7,0x0($a0) ); -GLOBAL_ASM( -glabel func0f0686f0 -/* f0686f0: 3c03800a */ lui $v1,%hi(var8009ce54) -/* f0686f4: 8c63ce54 */ lw $v1,%lo(var8009ce54)($v1) -/* f0686f8: 00001025 */ or $v0,$zero,$zero -/* f0686fc: 00002025 */ or $a0,$zero,$zero -/* f068700: 18600014 */ blez $v1,.L0f068754 -/* f068704: 3c05800a */ lui $a1,%hi(var8009ce6c) -/* f068708: 8ca5ce6c */ lw $a1,%lo(var8009ce6c)($a1) -.L0f06870c: -/* f06870c: 8cae0000 */ lw $t6,0x0($a1) -/* f068710: 31cf0001 */ andi $t7,$t6,0x1 -/* f068714: 51e0000b */ beqzl $t7,.L0f068744 -/* f068718: 24420001 */ addiu $v0,$v0,0x1 -/* f06871c: 3c03800a */ lui $v1,%hi(var8009ce6c) -/* f068720: 2463ce6c */ addiu $v1,$v1,%lo(var8009ce6c) -/* f068724: aca00000 */ sw $zero,0x0($a1) -/* f068728: 8c780000 */ lw $t8,0x0($v1) -/* f06872c: 0304c821 */ addu $t9,$t8,$a0 -/* f068730: af200044 */ sw $zero,0x44($t9) -/* f068734: 8c680000 */ lw $t0,0x0($v1) -/* f068738: 03e00008 */ jr $ra -/* f06873c: 00881021 */ addu $v0,$a0,$t0 -/* f068740: 24420001 */ addiu $v0,$v0,0x1 -.L0f068744: -/* f068744: 0043082a */ slt $at,$v0,$v1 -/* f068748: 24840048 */ addiu $a0,$a0,0x48 -/* f06874c: 1420ffef */ bnez $at,.L0f06870c -/* f068750: 24a50048 */ addiu $a1,$a1,72 -.L0f068754: -/* f068754: 00001025 */ or $v0,$zero,$zero -/* f068758: 03e00008 */ jr $ra -/* f06875c: 00000000 */ nop -); +struct monitorthing *monitorthingGetNew(void) +{ + s32 i; + + for (i = 0; i < g_NumMonitorThings; i++) { + if (g_MonitorThings[i].flags & 0x00000001) { + g_MonitorThings[i].flags = 0; + g_MonitorThings[i].unk044 = NULL; + + return &g_MonitorThings[i]; + } + } + + return NULL; +} GLOBAL_ASM( glabel func0f068760 @@ -10305,7 +10286,7 @@ glabel func0f06ef44 /* f06ef68: 31f80002 */ andi $t8,$t7,0x2 /* f06ef6c: 53000047 */ beqzl $t8,.L0f06f08c /* f06ef70: 00001025 */ or $v0,$zero,$zero -/* f06ef74: 0fc1a1bc */ jal func0f0686f0 +/* f06ef74: 0fc1a1bc */ jal monitorthingGetNew /* f06ef78: 8c900004 */ lw $s0,0x4($a0) /* f06ef7c: 10400042 */ beqz $v0,.L0f06f088 /* f06ef80: ae020048 */ sw $v0,0x48($s0) diff --git a/src/gvars/gvars.c b/src/gvars/gvars.c index faa3f756a..80a1ee0a4 100644 --- a/src/gvars/gvars.c +++ b/src/gvars/gvars.c @@ -14646,13 +14646,13 @@ u32 var8009ce44 = 0; u32 var8009ce48 = 0; u32 var8009ce4c = 0; s32 g_NumProjectiles = 0; -u32 var8009ce54 = 0; +s32 g_NumMonitorThings = 0; u32 var8009ce58 = 0; u32 var8009ce5c = 0; u32 var8009ce60 = 0; u32 var8009ce64 = 0; struct projectile *g_Projectiles = NULL; -u32 var8009ce6c = 0; +struct monitorthing *g_MonitorThings = NULL; u32 var8009ce70 = 0; u32 var8009ce74 = 0; u32 var8009ce78 = 0; diff --git a/src/include/game/propobj.h b/src/include/game/propobj.h index b6dc87f8c..53b5ad7da 100644 --- a/src/include/game/propobj.h +++ b/src/include/game/propobj.h @@ -66,7 +66,7 @@ struct projectile *projectileGetNew(void); void func0f0685e4(struct prop *prop); u32 func0f068694(void); u32 func0f0686e0(void); -struct projectile *func0f0686f0(void); +struct monitorthing *monitorthingGetNew(void); u32 func0f068760(void); u32 func0f0687b8(struct defaultobj *obj); u32 func0f0687e4(void); diff --git a/src/include/gvars/gvars.h b/src/include/gvars/gvars.h index 1cdacbc02..0356e7d3f 100644 --- a/src/include/gvars/gvars.h +++ b/src/include/gvars/gvars.h @@ -564,13 +564,13 @@ extern u32 var8009ce44; extern u32 var8009ce48; extern u32 var8009ce4c; extern s32 g_NumProjectiles; -extern u32 var8009ce54; +extern s32 g_NumMonitorThings; extern u32 var8009ce58; extern u32 var8009ce5c; extern u32 var8009ce60; extern u32 var8009ce64; extern struct projectile *g_Projectiles; -extern u32 var8009ce6c; +extern struct monitorthing *g_MonitorThings; extern u32 var8009ce78; extern u32 var8009ce88; extern struct monitorscreen var8009ce98; diff --git a/src/include/types.h b/src/include/types.h index dde476c19..867144f7a 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -1112,6 +1112,12 @@ struct projectile { /*0x108*/ u32 unk108; }; +struct monitorthing { + /*0x000*/ u32 flags; + /*0x004*/ Mtxf matrix; + /*0x044*/ struct projectile *unk044; +}; + struct monitorscreen { /*0x00*/ u32 unk00; /*0x04*/ u32 unk04; @@ -1177,7 +1183,10 @@ struct defaultobj { /*0x1c*/ f32 realrot[9]; /*0x40*/ u32 hidden; /*0x44*/ struct geo *geo; - /*0x48*/ struct projectile *projectile; + union { + /*0x48*/ struct projectile *projectile; + /*0x48*/ struct monitorthing *monitorthing; + }; /*0x4c*/ s16 damage; /*0x4e*/ s16 maxdamage; /*0x50*/ u8 shadecol[4];