diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 7f82585b1..3aab014ce 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -422,7 +422,7 @@ f32 bmoveCalculateLookahead(void) spf0.y = g_Vars.currentplayer->prop->pos.y - 30; spf0.z = g_Vars.currentplayer->prop->pos.z; - func00018148(&g_Vars.currentplayer->prop->pos, &spf0, + portal00018148(&g_Vars.currentplayer->prop->pos, &spf0, g_Vars.currentplayer->prop->rooms, spe0, NULL, 0); sp150.x = sp100.x * 400 + spf0.x; @@ -447,13 +447,13 @@ f32 bmoveCalculateLookahead(void) spbc.y = sp100.y * value + spf0.y; spbc.z = sp100.z * value + spf0.z; - func00018148(&spf0, &spbc, spe0, spa0, NULL, 0); + portal00018148(&spf0, &spbc, spe0, spa0, NULL, 0); spb0.x = spbc.x; spb0.y = spbc.y - 400; spb0.z = spbc.z; - func00018148(&spbc, &spb0, spa0, sp90, sp80, 7); + portal00018148(&spbc, &spb0, spa0, sp90, sp80, 7); if ( #if VERSION >= VERSION_NTSC_1_0 diff --git a/src/game/bondview.c b/src/game/bondview.c index 6dc62ef3b..b0728841a 100644 --- a/src/game/bondview.c +++ b/src/game/bondview.c @@ -761,12 +761,14 @@ Gfx *bviewDrawFisheye(Gfx *gdl, u32 colour, u32 alpha, s32 shuttertime60, s8 sta f32 fullradius; s32 one = 1; s32 spec; - f32 tmp; + u8 alpha2; #if VERSION >= VERSION_PAL_FINAL && PAL s32 vpadding; #endif + f32 tmp; + #if VERSION >= VERSION_PAL_FINAL viewtop = viGetViewTop(); viewheight = viGetViewHeight(); @@ -862,12 +864,11 @@ Gfx *bviewDrawFisheye(Gfx *gdl, u32 colour, u32 alpha, s32 shuttertime60, s8 sta } } else { f32 f22 = 1.0f; - u8 alpha; for (i = viewtop; i < viewtop + viewheight; i++) { if (hit == EYESPYHIT_DAMAGE) { - alpha = (random() % 120) + 120; - colour = 0xff333300 | (alpha & 0xff); + alpha2 = (random() % 120) + 120; + colour = 0xff333300 | (alpha2 & 0xff); f22 = ((random() % 32) + 220.0f) * (1.0f / 256.0f); gDPSetEnvColorViaWord(gdl++, colour); diff --git a/src/game/chraction.c b/src/game/chraction.c index 6f8e1d8c0..e25ccd3c3 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -5342,7 +5342,7 @@ bool chrIsRoomOffScreen(struct chrdata *chr, struct coord *waypos, s16 *wayrooms if (offscreen) { for (i = 0; i < PLAYERCOUNT(); i++) { - func00018148(waypos, &g_Vars.players[i]->prop->pos, wayrooms, sp50, 0, 0); + portal00018148(waypos, &g_Vars.players[i]->prop->pos, wayrooms, sp50, 0, 0); if (arrayIntersects(g_Vars.players[i]->prop->rooms, sp50)) { offscreen = false; diff --git a/src/game/player.c b/src/game/player.c index d8db82081..3094036df 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -5722,7 +5722,7 @@ void player0f0c1840(struct coord *pos, struct coord *up, struct coord *look, str s32 room; if (rooms2 != NULL && *rooms2 != -1) { - func00018148(pos2, pos, rooms2, sp54, NULL, 0); + portal00018148(pos2, pos, rooms2, sp54, NULL, 0); // Remove values from sp54 (room numbers) if that room doesn't contain // the coord, and shuffle the array back when removing values. diff --git a/src/game/prop.c b/src/game/prop.c index dc54cba06..693cb59de 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -677,8 +677,8 @@ struct prop *shotCalculateHits(s32 handnum, bool arg1, struct coord *arg2, struc hitpos.z = shotdata.gunpos.z + shotdata.dir.z * 65536; } - func00018148(&playerprop->pos, &shotdata.gunpos, playerprop->rooms, spc8, 0, 0); - func00018148(&shotdata.gunpos, &hitpos, spc8, spb8, rooms, 30); + portal00018148(&playerprop->pos, &shotdata.gunpos, playerprop->rooms, spc8, 0, 0); + portal00018148(&shotdata.gunpos, &hitpos, spc8, spb8, rooms, 30); if (shotdata.gset.weaponnum != WEAPON_FARSIGHT || g_Vars.currentplayer->visionmode != VISIONMODE_XRAY) { roomsptr = rooms; @@ -6986,7 +6986,7 @@ void func0f065d1c(struct coord *pos, s16 *rooms, struct coord *newpos, s16 *newr s32 index; s32 i; - func00018148(pos, newpos, rooms, stackrooms, morerooms, arg5); + portal00018148(pos, newpos, rooms, stackrooms, morerooms, arg5); index = 0; diff --git a/src/game/propobj.c b/src/game/propobj.c index 20c4138f8..560f73c1c 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -6594,7 +6594,7 @@ bool func0f06cd00(struct defaultobj *obj, struct coord *pos, struct coord *arg2, if ((prop->pos.x != pos->x || prop->pos.y != pos->y || prop->pos.z != pos->z) && (obj->hidden & OBJHFLAG_AIRBORNE) && (obj->projectile->flags & PROJECTILEFLAG_00000004)) { - func00018148(&prop->pos, &sp1c4, prop->rooms, &spb8, &spcc, 20); + portal00018148(&prop->pos, &sp1c4, prop->rooms, &spb8, &spcc, 20); ptr = spcc; @@ -39920,7 +39920,7 @@ glabel var7f1aa5a8 /* f07a89c: 13200024 */ beqz $t9,.L0f07a930 /* f07a8a0: 27a7012c */ addiu $a3,$sp,0x12c /* f07a8a4: afa00010 */ sw $zero,0x10($sp) -/* f07a8a8: 0c006052 */ jal func00018148 +/* f07a8a8: 0c006052 */ jal portal00018148 /* f07a8ac: afa00014 */ sw $zero,0x14($sp) /* f07a8b0: 0fc4f92a */ jal chrIsUsingPaintball /* f07a8b4: 8fa40110 */ lw $a0,0x110($sp) @@ -40882,7 +40882,7 @@ glabel var7f1aa5a8 /* f07aa3c: 13200024 */ beqz $t9,.PB0f07aad0 /* f07aa40: 27a7012c */ addiu $a3,$sp,0x12c /* f07aa44: afa00010 */ sw $zero,0x10($sp) -/* f07aa48: 0c0062e6 */ jal func00018148 +/* f07aa48: 0c0062e6 */ jal portal00018148 /* f07aa4c: afa00014 */ sw $zero,0x14($sp) /* f07aa50: 0fc4fe8e */ jal chrIsUsingPaintball /* f07aa54: 8fa40110 */ lw $a0,0x110($sp) @@ -41844,7 +41844,7 @@ glabel var7f1aa5a8 /* f07a89c: 13200024 */ beqz $t9,.L0f07a930 /* f07a8a0: 27a7012c */ addiu $a3,$sp,0x12c /* f07a8a4: afa00010 */ sw $zero,0x10($sp) -/* f07a8a8: 0c006052 */ jal func00018148 +/* f07a8a8: 0c006052 */ jal portal00018148 /* f07a8ac: afa00014 */ sw $zero,0x14($sp) /* f07a8b0: 0fc4f92a */ jal chrIsUsingPaintball /* f07a8b4: 8fa40110 */ lw $a0,0x110($sp) @@ -42806,7 +42806,7 @@ glabel var7f1aa5a8 /* f07a89c: 13200024 */ beqz $t9,.L0f07a930 /* f07a8a0: 27a7012c */ addiu $a3,$sp,0x12c /* f07a8a4: afa00010 */ sw $zero,0x10($sp) -/* f07a8a8: 0c006052 */ jal func00018148 +/* f07a8a8: 0c006052 */ jal portal00018148 /* f07a8ac: afa00014 */ sw $zero,0x14($sp) /* f07a8b0: 0fc4f92a */ jal chrIsUsingPaintball /* f07a8b4: 8fa40110 */ lw $a0,0x110($sp) diff --git a/src/game/splat.c b/src/game/splat.c index 5484b89b4..6ea472372 100644 --- a/src/game/splat.c +++ b/src/game/splat.c @@ -272,7 +272,7 @@ glabel var7f1b6030 /* f149340: afa00010 */ sw $zero,0x10($sp) /* f149344: afa00014 */ sw $zero,0x14($sp) /* f149348: 25e40008 */ addiu $a0,$t7,0x8 -/* f14934c: 0c006052 */ jal func00018148 +/* f14934c: 0c006052 */ jal portal00018148 /* f149350: 25e60028 */ addiu $a2,$t7,0x28 /* f149354: 27b80540 */ addiu $t8,$sp,0x540 /* f149358: 2419001f */ addiu $t9,$zero,0x1f @@ -281,7 +281,7 @@ glabel var7f1b6030 /* f149364: 27a400bc */ addiu $a0,$sp,0xbc /* f149368: 27a50514 */ addiu $a1,$sp,0x514 /* f14936c: 27a60530 */ addiu $a2,$sp,0x530 -/* f149370: 0c006052 */ jal func00018148 +/* f149370: 0c006052 */ jal portal00018148 /* f149374: 27a70520 */ addiu $a3,$sp,0x520 /* f149378: 87a80540 */ lh $t0,0x540($sp) /* f14937c: 2401ffff */ addiu $at,$zero,-1 diff --git a/src/include/data.h b/src/include/data.h index df0ed9bf0..74206cf35 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -40,7 +40,6 @@ extern struct audiorussmapping g_AudioRussMappings[]; extern struct audioconfig g_AudioConfigs[]; extern bool var8005eedc; extern f32 var8005ef10[2]; -extern u32 var8005ef20; extern s32 g_NumGlobalAilists; extern s32 g_NumLvAilists; extern u32 var8005ef40; diff --git a/src/include/lib/lib_17ce0.h b/src/include/lib/lib_17ce0.h index 5f49a7e27..fe5295bbe 100644 --- a/src/include/lib/lib_17ce0.h +++ b/src/include/lib/lib_17ce0.h @@ -5,8 +5,8 @@ #include "types.h" u32 func00017ce0(void); -u32 func00017dc4(void); +void func00017dc4(s16 *rooms, s32 roomnum); s32 portal00017e30(s32 portalnum, struct coord *arg1, struct coord *arg2); -void func00018148(struct coord *pos, struct coord *pos2, s16 *rooms, s16 *arg3, s16 *arg4, s32 arg5); +void portal00018148(struct coord *pos, struct coord *pos2, s16 *rooms, s16 *arg3, s16 *arg4, s32 arg5); #endif diff --git a/src/include/types.h b/src/include/types.h index ba3d8ebbc..1b1476389 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -239,132 +239,6 @@ struct g_vars { /*000508*/ u32 unk000508; /*00050c*/ u32 unk00050c; /*000510*/ f32 unk000510; - /*000514*/ u32 unk000514; - /*000518*/ u32 unk000518; - /*00051c*/ u32 unk00051c; - /*000520*/ u32 unk000520; - /*000524*/ u32 unk000524; - /*000528*/ u32 unk000528; - /*00052c*/ u32 unk00052c; - /*000530*/ u32 unk000530; - /*000534*/ u32 unk000534; - /*000538*/ u32 unk000538; - /*00053c*/ u32 unk00053c; - /*000540*/ u32 unk000540; - /*000544*/ u32 unk000544; - /*000548*/ u32 unk000548; - /*00054c*/ u32 unk00054c; - /*000550*/ u32 unk000550; - /*000554*/ u32 unk000554; - /*000558*/ u32 unk000558; - /*00055c*/ u32 unk00055c; - /*000560*/ u32 unk000560; - /*000564*/ u32 unk000564; - /*000568*/ u32 unk000568; - /*00056c*/ u32 unk00056c; - /*000570*/ u32 unk000570; - /*000574*/ u32 unk000574; - /*000578*/ u32 unk000578; - /*00057c*/ u32 unk00057c; - /*000580*/ u32 unk000580; - /*000584*/ u32 unk000584; - /*000588*/ u32 unk000588; - /*00058c*/ u32 unk00058c; - /*000590*/ u32 unk000590; - /*000594*/ u32 unk000594; - /*000598*/ u32 unk000598; - /*00059c*/ u32 unk00059c; - /*0005a0*/ u32 unk0005a0; - /*0005a4*/ u32 unk0005a4; - /*0005a8*/ u32 unk0005a8; - /*0005ac*/ u32 unk0005ac; - /*0005b0*/ u32 unk0005b0; - /*0005b4*/ u32 unk0005b4; - /*0005b8*/ u32 unk0005b8; - /*0005bc*/ u32 unk0005bc; - /*0005c0*/ u32 unk0005c0; - /*0005c4*/ u32 unk0005c4; - /*0005c8*/ u32 unk0005c8; - /*0005cc*/ u32 unk0005cc; - /*0005d0*/ u32 unk0005d0; - /*0005d4*/ u32 unk0005d4; - /*0005d8*/ u32 unk0005d8; - /*0005dc*/ u32 unk0005dc; - /*0005e0*/ u32 unk0005e0; - /*0005e4*/ u32 unk0005e4; - /*0005e8*/ u32 unk0005e8; - /*0005ec*/ u32 unk0005ec; - /*0005f0*/ u32 unk0005f0; - /*0005f4*/ u32 unk0005f4; - /*0005f8*/ u32 unk0005f8; - /*0005fc*/ u32 unk0005fc; - /*000600*/ u32 unk000600; - /*000604*/ u32 unk000604; - /*000608*/ u32 unk000608; - /*00060c*/ u32 unk00060c; - /*000610*/ u32 unk000610; - /*000614*/ u32 unk000614; - /*000618*/ u32 unk000618; - /*00061c*/ u32 unk00061c; - /*000620*/ u32 unk000620; - /*000624*/ u32 unk000624; - /*000628*/ u32 unk000628; - /*00062c*/ u32 unk00062c; - /*000630*/ u32 unk000630; - /*000634*/ u32 unk000634; - /*000638*/ u32 unk000638; - /*00063c*/ u32 unk00063c; - /*000640*/ u32 unk000640; - /*000644*/ u32 unk000644; - /*000648*/ u32 unk000648; - /*00064c*/ u32 unk00064c; - /*000650*/ u32 unk000650; - /*000654*/ u32 unk000654; - /*000658*/ u32 unk000658; - /*00065c*/ u32 unk00065c; - /*000660*/ u32 unk000660; - /*000664*/ u32 unk000664; - /*000668*/ u32 unk000668; - /*00066c*/ u32 unk00066c; - /*000670*/ u32 unk000670; - /*000674*/ u32 unk000674; - /*000678*/ u32 unk000678; - /*00067c*/ u32 unk00067c; - /*000680*/ u32 unk000680; - /*000684*/ u32 unk000684; - /*000688*/ u32 unk000688; - /*00068c*/ u32 unk00068c; - /*000690*/ u32 unk000690; - /*000694*/ u32 unk000694; - /*000698*/ u32 unk000698; - /*00069c*/ u32 unk00069c; - /*0006a0*/ u32 unk0006a0; - /*0006a4*/ u32 unk0006a4; - /*0006a8*/ u32 unk0006a8; - /*0006ac*/ u32 unk0006ac; - /*0006b0*/ u32 unk0006b0; - /*0006b4*/ u32 unk0006b4; - /*0006b8*/ u32 unk0006b8; - /*0006bc*/ u32 unk0006bc; - /*0006c0*/ u32 unk0006c0; - /*0006c4*/ u32 unk0006c4; - /*0006c8*/ u32 unk0006c8; - /*0006cc*/ u32 unk0006cc; - /*0006d0*/ u32 unk0006d0; - /*0006d4*/ u32 unk0006d4; - /*0006d8*/ u32 unk0006d8; - /*0006dc*/ u32 unk0006dc; - /*0006e0*/ u32 unk0006e0; - /*0006e4*/ u32 unk0006e4; - /*0006e8*/ u32 unk0006e8; - /*0006ec*/ u32 unk0006ec; - /*0006f0*/ u32 unk0006f0; - /*0006f4*/ u32 unk0006f4; - /*0006f8*/ u32 unk0006f8; - /*0006fc*/ u32 unk0006fc; - /*000700*/ u32 unk000700; - /*000704*/ u32 unk000704; - /*000708*/ u8 unk000708[0x1a8]; }; struct weaponobj; diff --git a/src/lib/collision.c b/src/lib/collision.c index 494e73ebb..e5b4aa06e 100644 --- a/src/lib/collision.c +++ b/src/lib/collision.c @@ -7621,7 +7621,7 @@ bool cd0002d6ac(struct coord *pos, s16 *rooms, struct coord *targetpos, u32 type s16 sp44[21]; s16 sp34[8]; - func00018148(pos, targetpos, rooms, sp34, sp44, 20); + portal00018148(pos, targetpos, rooms, sp34, sp44, 20); return cd0002d15c(pos, targetpos, sp44, types, 4, 0, arg4, arg5, arg6); } @@ -7648,7 +7648,7 @@ bool cd0002d7c0(struct coord *pos, s16 *rooms, struct coord *arg2, u32 arg3, u32 s16 sp44[21]; s16 sp34[8]; - func00018148(pos, arg2, rooms, sp34, sp44, 20); + portal00018148(pos, arg2, rooms, sp34, sp44, 20); return cd0002d3b0(pos, arg2, sp44, arg3, 4, 0, arg4, ymax, ymin); } @@ -7657,7 +7657,7 @@ s32 cd0002d840(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 { s16 rooms[21]; - func00018148(arg0, arg2, arg1, arg3, rooms, 20); + portal00018148(arg0, arg2, arg1, arg3, rooms, 20); return cd0002d15c(arg0, arg2, rooms, types, 4, 0, arg5, ymax, ymin); } @@ -7710,7 +7710,7 @@ s32 cd0002da50(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 { s16 rooms[21]; - func00018148(arg0, arg2, arg1, arg3, rooms, 20); + portal00018148(arg0, arg2, arg1, arg3, rooms, 20); return cd0002d3b0(arg0, arg2, rooms, types, 4, 0, arg5, ymax, ymin); } @@ -7721,7 +7721,7 @@ s32 cd0002dac8(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 struct coord sp40; s32 result; - func00018148(arg0, arg2, arg1, arg3, rooms, 20); + portal00018148(arg0, arg2, arg1, arg3, rooms, 20); result = cd0002d3b0(arg0, arg2, rooms, types, 4, 0, arg6, ymax, ymin); @@ -7741,7 +7741,7 @@ bool cd0002db98(struct coord *viewpos, s16 *rooms, struct coord *targetpos, u32 s16 sp44[21]; s16 sp34[8]; - func00018148(viewpos, targetpos, rooms, sp34, sp44, 20); + portal00018148(viewpos, targetpos, rooms, sp34, sp44, 20); return cd0002d15c(viewpos, targetpos, sp44, types, arg4, 1, 1, 0, 0); } @@ -7794,7 +7794,7 @@ s32 cdTestAToB4(struct coord *pos, s16 *rooms, struct coord *pos2, u32 types, u1 s16 sp44[21]; s16 sp34[8]; - func00018148(pos, pos2, rooms, sp34, sp44, 20); + portal00018148(pos, pos2, rooms, sp34, sp44, 20); return cd0002d3b0(pos, pos2, sp44, types, arg4, 1, 1, 0, 0); } @@ -7808,7 +7808,7 @@ s32 cd0002de34(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 { s16 rooms[21]; - func00018148(arg0, arg2, arg1, arg3, rooms, 20); + portal00018148(arg0, arg2, arg1, arg3, rooms, 20); return cd0002d15c(arg0, arg2, rooms, types, arg5, 1, 1, 0, 0); } diff --git a/src/lib/lib_17ce0.c b/src/lib/lib_17ce0.c index 66eb41427..2f0a03549 100644 --- a/src/lib/lib_17ce0.c +++ b/src/lib/lib_17ce0.c @@ -7,7 +7,9 @@ #include "data.h" #include "types.h" -u32 var8005ef20 = 0xfe000000; +u8 var8005ef20 = 254; + +u8 var8009a4e0[456][2]; GLOBAL_ASM( glabel func00017ce0 @@ -218,257 +220,102 @@ s32 portal00017e30(s32 portalnum, struct coord *arg1, struct coord *arg2) return (value1 < (var800a4ccc + portalnum)->unk0c) ? 1 : 2; } -GLOBAL_ASM( -glabel func00018148 -/* 18148: 27bdff30 */ addiu $sp,$sp,-208 -/* 1814c: afa400d0 */ sw $a0,0xd0($sp) -/* 18150: afa500d4 */ sw $a1,0xd4($sp) -/* 18154: afbf003c */ sw $ra,0x3c($sp) -/* 18158: afbe0038 */ sw $s8,0x38($sp) -/* 1815c: afb70034 */ sw $s7,0x34($sp) -/* 18160: afb60030 */ sw $s6,0x30($sp) -/* 18164: afb5002c */ sw $s5,0x2c($sp) -/* 18168: afb40028 */ sw $s4,0x28($sp) -/* 1816c: afb30024 */ sw $s3,0x24($sp) -/* 18170: afb20020 */ sw $s2,0x20($sp) -/* 18174: afb1001c */ sw $s1,0x1c($sp) -/* 18178: afb00018 */ sw $s0,0x18($sp) -/* 1817c: afa700dc */ sw $a3,0xdc($sp) -/* 18180: 27a5006c */ addiu $a1,$sp,0x6c -/* 18184: 2404ffff */ addiu $a0,$zero,-1 -/* 18188: 27a8009c */ addiu $t0,$sp,0x9c -/* 1818c: 27a2005c */ addiu $v0,$sp,0x5c -/* 18190: 00c01825 */ or $v1,$a2,$zero -.L00018194: -/* 18194: 846e0000 */ lh $t6,0x0($v1) -/* 18198: 24420002 */ addiu $v0,$v0,0x2 -/* 1819c: 0045082b */ sltu $at,$v0,$a1 -/* 181a0: a50e0000 */ sh $t6,0x0($t0) -/* 181a4: 846f0000 */ lh $t7,0x0($v1) -/* 181a8: 25080002 */ addiu $t0,$t0,0x2 -/* 181ac: a44ffffe */ sh $t7,-0x2($v0) -/* 181b0: 84780000 */ lh $t8,0x0($v1) -/* 181b4: 14980003 */ bne $a0,$t8,.L000181c4 -/* 181b8: 00000000 */ nop -/* 181bc: 10000004 */ b .L000181d0 -/* 181c0: 0000b825 */ or $s7,$zero,$zero -.L000181c4: -/* 181c4: 1420fff3 */ bnez $at,.L00018194 -/* 181c8: 24630002 */ addiu $v1,$v1,0x2 -/* 181cc: 0000b825 */ or $s7,$zero,$zero -.L000181d0: -/* 181d0: 3c198006 */ lui $t9,%hi(var8005ef20) -/* 181d4: 9339ef20 */ lbu $t9,%lo(var8005ef20)($t9) -/* 181d8: 3c018006 */ lui $at,%hi(var8005ef20) -/* 181dc: 27be007c */ addiu $s8,$sp,0x7c -/* 181e0: 27290001 */ addiu $t1,$t9,0x1 -/* 181e4: a029ef20 */ sb $t1,%lo(var8005ef20)($at) -/* 181e8: 240100ff */ addiu $at,$zero,0xff -/* 181ec: 312a00ff */ andi $t2,$t1,0xff -/* 181f0: 15410010 */ bne $t2,$at,.L00018234 -/* 181f4: 3c14800a */ lui $s4,%hi(g_BgPortals) -/* 181f8: 3c038008 */ lui $v1,%hi(g_NumPortalThings) -/* 181fc: 8c63fc40 */ lw $v1,%lo(g_NumPortalThings)($v1) -/* 18200: 3c0b800a */ lui $t3,%hi(g_Vars+0x520) -/* 18204: 2562a4e0 */ addiu $v0,$t3,%lo(g_Vars+0x520) -/* 18208: 18600008 */ blez $v1,.L0001822c -/* 1820c: 00036040 */ sll $t4,$v1,0x1 -/* 18210: 01822821 */ addu $a1,$t4,$v0 -/* 18214: 240300ff */ addiu $v1,$zero,0xff -.L00018218: -/* 18218: 24420002 */ addiu $v0,$v0,0x2 -/* 1821c: 0045082b */ sltu $at,$v0,$a1 -/* 18220: 1420fffd */ bnez $at,.L00018218 -/* 18224: a043fffe */ sb $v1,-0x2($v0) -/* 18228: 0000b825 */ or $s7,$zero,$zero -.L0001822c: -/* 1822c: 3c018006 */ lui $at,%hi(var8005ef20) -/* 18230: a020ef20 */ sb $zero,%lo(var8005ef20)($at) -.L00018234: -/* 18234: 26944cc8 */ addiu $s4,$s4,%lo(g_BgPortals) -/* 18238: 87b5009c */ lh $s5,0x9c($sp) -.L0001823c: -/* 1823c: a7a4007c */ sh $a0,0x7c($sp) -/* 18240: 00006840 */ sll $t5,$zero,0x1 -/* 18244: 12a40058 */ beq $s5,$a0,.L000183a8 -/* 18248: 27ae009c */ addiu $t6,$sp,0x9c -/* 1824c: 01ae7821 */ addu $t7,$t5,$t6 -/* 18250: afaf0044 */ sw $t7,0x44($sp) -/* 18254: 0015c8c0 */ sll $t9,$s5,0x3 -.L00018258: -/* 18258: 0335c821 */ addu $t9,$t9,$s5 -/* 1825c: 3c18800a */ lui $t8,%hi(g_Rooms) -/* 18260: 8f184928 */ lw $t8,%lo(g_Rooms)($t8) -/* 18264: 0019c880 */ sll $t9,$t9,0x2 -/* 18268: 0335c823 */ subu $t9,$t9,$s5 -/* 1826c: 0019c880 */ sll $t9,$t9,0x2 -/* 18270: 03191021 */ addu $v0,$t8,$t9 -/* 18274: 8449000e */ lh $t1,0xe($v0) -/* 18278: 80560005 */ lb $s6,0x5($v0) -/* 1827c: 3c0c800a */ lui $t4,%hi(g_RoomPortals) -/* 18280: 8d8c4ce0 */ lw $t4,%lo(g_RoomPortals)($t4) -/* 18284: 00095040 */ sll $t2,$t1,0x1 -/* 18288: 1ac0003e */ blez $s6,.L00018384 -/* 1828c: 014c9821 */ addu $s3,$t2,$t4 -.L00018290: -/* 18290: 86720000 */ lh $s2,0x0($s3) -/* 18294: 3c0d800a */ lui $t5,%hi(g_Vars+0x520) -/* 18298: 25ada4e0 */ addiu $t5,$t5,%lo(g_Vars+0x520) -/* 1829c: 00125840 */ sll $t3,$s2,0x1 -/* 182a0: 016d8821 */ addu $s1,$t3,$t5 -/* 182a4: 3c028006 */ lui $v0,%hi(var8005ef20) -/* 182a8: 9042ef20 */ lbu $v0,%lo(var8005ef20)($v0) -/* 182ac: 922e0000 */ lbu $t6,0x0($s1) -/* 182b0: 02402025 */ or $a0,$s2,$zero -/* 182b4: 504e0007 */ beql $v0,$t6,.L000182d4 -/* 182b8: 92230001 */ lbu $v1,0x1($s1) -/* 182bc: a2220000 */ sb $v0,0x0($s1) -/* 182c0: 8fa500d0 */ lw $a1,0xd0($sp) -/* 182c4: 0c005f8c */ jal portal00017e30 -/* 182c8: 8fa600d4 */ lw $a2,0xd4($sp) -/* 182cc: a2220001 */ sb $v0,0x1($s1) -/* 182d0: 92230001 */ lbu $v1,0x1($s1) -.L000182d4: -/* 182d4: 24010001 */ addiu $at,$zero,0x1 -/* 182d8: 50600026 */ beqzl $v1,.L00018374 -/* 182dc: 26f70001 */ addiu $s7,$s7,0x1 -/* 182e0: 54610012 */ bnel $v1,$at,.L0001832c -/* 182e4: 24010002 */ addiu $at,$zero,0x2 -/* 182e8: 8e8f0000 */ lw $t7,0x0($s4) -/* 182ec: 001280c0 */ sll $s0,$s2,0x3 -/* 182f0: 03c02025 */ or $a0,$s8,$zero -/* 182f4: 01f01021 */ addu $v0,$t7,$s0 -/* 182f8: 84580002 */ lh $t8,0x2($v0) -/* 182fc: 56b8000b */ bnel $s5,$t8,.L0001832c -/* 18300: 24010002 */ addiu $at,$zero,0x2 -/* 18304: 0c005f71 */ jal func00017dc4 -/* 18308: 84450004 */ lh $a1,0x4($v0) -/* 1830c: 8e990000 */ lw $t9,0x0($s4) -/* 18310: 27a4005c */ addiu $a0,$sp,0x5c -/* 18314: 03304821 */ addu $t1,$t9,$s0 -/* 18318: 0c005f71 */ jal func00017dc4 -/* 1831c: 85250004 */ lh $a1,0x4($t1) -/* 18320: a2200001 */ sb $zero,0x1($s1) -/* 18324: 300300ff */ andi $v1,$zero,0xff -/* 18328: 24010002 */ addiu $at,$zero,0x2 -.L0001832c: -/* 1832c: 54610011 */ bnel $v1,$at,.L00018374 -/* 18330: 26f70001 */ addiu $s7,$s7,0x1 -/* 18334: 8e8a0000 */ lw $t2,0x0($s4) -/* 18338: 001280c0 */ sll $s0,$s2,0x3 -/* 1833c: 03c02025 */ or $a0,$s8,$zero -/* 18340: 01501021 */ addu $v0,$t2,$s0 -/* 18344: 844c0004 */ lh $t4,0x4($v0) -/* 18348: 56ac000a */ bnel $s5,$t4,.L00018374 -/* 1834c: 26f70001 */ addiu $s7,$s7,0x1 -/* 18350: 0c005f71 */ jal func00017dc4 -/* 18354: 84450002 */ lh $a1,0x2($v0) -/* 18358: 8e8b0000 */ lw $t3,0x0($s4) -/* 1835c: 27a4005c */ addiu $a0,$sp,0x5c -/* 18360: 01706821 */ addu $t5,$t3,$s0 -/* 18364: 0c005f71 */ jal func00017dc4 -/* 18368: 85a50002 */ lh $a1,0x2($t5) -/* 1836c: a2200001 */ sb $zero,0x1($s1) -/* 18370: 26f70001 */ addiu $s7,$s7,0x1 -.L00018374: -/* 18374: 16f6ffc6 */ bne $s7,$s6,.L00018290 -/* 18378: 26730002 */ addiu $s3,$s3,0x2 -/* 1837c: 0000b825 */ or $s7,$zero,$zero -/* 18380: 2404ffff */ addiu $a0,$zero,-1 -.L00018384: -/* 18384: 8fae0044 */ lw $t6,0x44($sp) -/* 18388: 27b800bc */ addiu $t8,$sp,0xbc -/* 1838c: 25cf0002 */ addiu $t7,$t6,0x2 -/* 18390: afaf0044 */ sw $t7,0x44($sp) -/* 18394: 85f50000 */ lh $s5,0x0($t7) -/* 18398: 52a40004 */ beql $s5,$a0,.L000183ac -/* 1839c: 87b9007c */ lh $t9,0x7c($sp) -/* 183a0: 55f8ffad */ bnel $t7,$t8,.L00018258 -/* 183a4: 0015c8c0 */ sll $t9,$s5,0x3 -.L000183a8: -/* 183a8: 87b9007c */ lh $t9,0x7c($sp) -.L000183ac: -/* 183ac: 27a8009c */ addiu $t0,$sp,0x9c -/* 183b0: 27a3007c */ addiu $v1,$sp,0x7c -/* 183b4: 5099000f */ beql $a0,$t9,.L000183f4 -/* 183b8: 87ac009c */ lh $t4,0x9c($sp) -.L000183bc: -/* 183bc: 84620000 */ lh $v0,0x0($v1) -/* 183c0: 24630002 */ addiu $v1,$v1,0x2 -/* 183c4: 27a9009c */ addiu $t1,$sp,0x9c -/* 183c8: 14820003 */ bne $a0,$v0,.L000183d8 -/* 183cc: a5020000 */ sh $v0,0x0($t0) -/* 183d0: 10000004 */ b .L000183e4 -/* 183d4: 0000b825 */ or $s7,$zero,$zero -.L000183d8: -/* 183d8: 1469fff8 */ bne $v1,$t1,.L000183bc -/* 183dc: 25080002 */ addiu $t0,$t0,0x2 -/* 183e0: 0000b825 */ or $s7,$zero,$zero -.L000183e4: -/* 183e4: 87aa007c */ lh $t2,0x7c($sp) -/* 183e8: 548aff94 */ bnel $a0,$t2,.L0001823c -/* 183ec: 87b5009c */ lh $s5,0x9c($sp) -/* 183f0: 87ac009c */ lh $t4,0x9c($sp) -.L000183f4: -/* 183f4: 27ab009c */ addiu $t3,$sp,0x9c -/* 183f8: 8fad00dc */ lw $t5,0xdc($sp) -/* 183fc: 508c0010 */ beql $a0,$t4,.L00018440 -/* 18400: 8fae00dc */ lw $t6,0xdc($sp) -/* 18404: 00172040 */ sll $a0,$s7,0x1 -/* 18408: 008b4021 */ addu $t0,$a0,$t3 -/* 1840c: 01a41821 */ addu $v1,$t5,$a0 -/* 18410: 2404ffff */ addiu $a0,$zero,-1 -/* 18414: 85020000 */ lh $v0,0x0($t0) -/* 18418: 26f70001 */ addiu $s7,$s7,0x1 -.L0001841c: -/* 1841c: 2ae10007 */ slti $at,$s7,0x7 -/* 18420: 25080002 */ addiu $t0,$t0,0x2 -/* 18424: 24630002 */ addiu $v1,$v1,0x2 -/* 18428: 10200004 */ beqz $at,.L0001843c -/* 1842c: a462fffe */ sh $v0,-0x2($v1) -/* 18430: 85020000 */ lh $v0,0x0($t0) -/* 18434: 5482fff9 */ bnel $a0,$v0,.L0001841c -/* 18438: 26f70001 */ addiu $s7,$s7,0x1 -.L0001843c: -/* 1843c: 8fae00dc */ lw $t6,0xdc($sp) -.L00018440: -/* 18440: 8fa600e0 */ lw $a2,0xe0($sp) -/* 18444: 00177840 */ sll $t7,$s7,0x1 -/* 18448: 01cfc021 */ addu $t8,$t6,$t7 -/* 1844c: 10c00013 */ beqz $a2,.L0001849c -/* 18450: a7040000 */ sh $a0,0x0($t8) -/* 18454: 8fa500e4 */ lw $a1,0xe4($sp) -/* 18458: 0000b825 */ or $s7,$zero,$zero -/* 1845c: 27a2005c */ addiu $v0,$sp,0x5c -/* 18460: 18a0000b */ blez $a1,.L00018490 -/* 18464: 00c01825 */ or $v1,$a2,$zero -/* 18468: 2404ffff */ addiu $a0,$zero,-1 -.L0001846c: -/* 1846c: 84590000 */ lh $t9,0x0($v0) -/* 18470: 24420002 */ addiu $v0,$v0,0x2 -/* 18474: a4790000 */ sh $t9,0x0($v1) -/* 18478: 8449fffe */ lh $t1,-0x2($v0) -/* 1847c: 50890005 */ beql $a0,$t1,.L00018494 -/* 18480: 00175040 */ sll $t2,$s7,0x1 -/* 18484: 26f70001 */ addiu $s7,$s7,0x1 -/* 18488: 16e5fff8 */ bne $s7,$a1,.L0001846c -/* 1848c: 24630002 */ addiu $v1,$v1,0x2 -.L00018490: -/* 18490: 00175040 */ sll $t2,$s7,0x1 -.L00018494: -/* 18494: 00ca6021 */ addu $t4,$a2,$t2 -/* 18498: a5840000 */ sh $a0,0x0($t4) -.L0001849c: -/* 1849c: 8fbf003c */ lw $ra,0x3c($sp) -/* 184a0: 8fb00018 */ lw $s0,0x18($sp) -/* 184a4: 8fb1001c */ lw $s1,0x1c($sp) -/* 184a8: 8fb20020 */ lw $s2,0x20($sp) -/* 184ac: 8fb30024 */ lw $s3,0x24($sp) -/* 184b0: 8fb40028 */ lw $s4,0x28($sp) -/* 184b4: 8fb5002c */ lw $s5,0x2c($sp) -/* 184b8: 8fb60030 */ lw $s6,0x30($sp) -/* 184bc: 8fb70034 */ lw $s7,0x34($sp) -/* 184c0: 8fbe0038 */ lw $s8,0x38($sp) -/* 184c4: 03e00008 */ jr $ra -/* 184c8: 27bd00d0 */ addiu $sp,$sp,0xd0 -); +void portal00018148(struct coord *pos1, struct coord *pos2, s16 *rooms1, s16 *rooms2, s16 *rooms3, s32 arg5) +{ + s32 i; + s32 j; + s32 roomnum; + s32 numportals; + s16 *portalnums; + s16 rooms9c[16]; + s16 rooms7c[16]; + s16 rooms5c[16]; + + for (i = 0; i < 8; i++) { + rooms9c[i] = rooms1[i]; + rooms5c[i] = rooms1[i]; + + if (rooms1[i] == -1) { + break; + } + } + + var8005ef20++; + + if (var8005ef20 == 255) { + for (i = 0; i < g_NumPortalThings; i++) { + var8009a4e0[i][0] = 0xff; + } + + var8005ef20 = 0; + } + + do { + rooms7c[0] = -1; + + for (j = 0; (roomnum = rooms9c[j]) != -1 && j < 16; j++) { + numportals = g_Rooms[roomnum].numportals; + portalnums = &g_RoomPortals[g_Rooms[roomnum].roomportallistoffset]; + + for (i = 0; i < numportals; i++) { + s32 portalnum = *portalnums; + u8 *s1 = var8009a4e0[portalnum]; + + if (s1[0] != var8005ef20) { + s1[0] = var8005ef20; + s1[1] = portal00017e30(portalnum, pos1, pos2); + } + + if (s1[1] != 0) { + if (s1[1] == 1) { + if (roomnum == g_BgPortals[portalnum].roomnum1) { + func00017dc4(rooms7c, g_BgPortals[portalnum].roomnum2); + func00017dc4(rooms5c, g_BgPortals[portalnum].roomnum2); + s1[1] = 0; + } + } + + if (s1[1] == 2) { + if (roomnum == g_BgPortals[portalnum].roomnum2) { + func00017dc4(rooms7c, g_BgPortals[portalnum].roomnum1); + func00017dc4(rooms5c, g_BgPortals[portalnum].roomnum1); + s1[1] = 0; + } + } + } + + portalnums++; + } + } + + if (rooms7c[0] == -1) { + break; + } + + for (i = 0; i < 16; i++) { + rooms9c[i] = rooms7c[i]; + + if (rooms7c[i] == -1) { + break; + } + } + } while (rooms7c[0] != -1); + + for (i = 0; i < 7 && rooms9c[i] != -1; i++) { + rooms2[i] = rooms9c[i]; + } + + rooms2[i] = -1; + + if (rooms3 != NULL) { + for (i = 0; i < arg5; i++) { + rooms3[i] = rooms5c[i]; + + if (rooms5c[i] == -1) { + break; + } + } + + rooms3[i] = -1; + } +}