Decompile portalFindBbox

This commit is contained in:
Ryan Dwyer 2022-04-24 20:41:11 +10:00
parent 788d303f0a
commit 4dd72b7124
4 changed files with 72 additions and 106 deletions

View File

@ -16791,71 +16791,36 @@ bool func0f164f9c(struct coord *arg0, struct coord *arg1, struct coord *arg2, st
return true;
}
GLOBAL_ASM(
glabel func0f165004
.late_rodata
glabel var7f1b76c8
.word 0x7f7fffff
glabel var7f1b76cc
.word 0xff7fffff
.text
/* f165004: 3c017f1b */ lui $at,%hi(var7f1b76c8)
/* f165008: c42076c8 */ lwc1 $f0,%lo(var7f1b76c8)($at)
/* f16500c: 3c017f1b */ lui $at,%hi(var7f1b76cc)
/* f165010: c42276cc */ lwc1 $f2,%lo(var7f1b76cc)($at)
/* f165014: e4a00000 */ swc1 $f0,0x0($a1)
/* f165018: e4a00004 */ swc1 $f0,0x4($a1)
/* f16501c: e4a00008 */ swc1 $f0,0x8($a1)
/* f165020: 3c03800a */ lui $v1,%hi(g_BgPortals)
/* f165024: e4c20000 */ swc1 $f2,0x0($a2)
/* f165028: e4c20004 */ swc1 $f2,0x4($a2)
/* f16502c: e4c20008 */ swc1 $f2,0x8($a2)
/* f165030: 8c634cc8 */ lw $v1,%lo(g_BgPortals)($v1)
/* f165034: 000470c0 */ sll $t6,$a0,0x3
/* f165038: 00003825 */ or $a3,$zero,$zero
/* f16503c: 006e7821 */ addu $t7,$v1,$t6
/* f165040: 95f80000 */ lhu $t8,0x0($t7)
/* f165044: 240c000c */ addiu $t4,$zero,0xc
/* f165048: 03031021 */ addu $v0,$t8,$v1
/* f16504c: 90590000 */ lbu $t9,0x0($v0)
/* f165050: 00402025 */ or $a0,$v0,$zero
/* f165054: 1b20001c */ blez $t9,.L0f1650c8
/* f165058: 00004025 */ or $t0,$zero,$zero
.L0f16505c:
/* f16505c: 00804825 */ or $t1,$a0,$zero
/* f165060: 00a05025 */ or $t2,$a1,$zero
/* f165064: 00c05825 */ or $t3,$a2,$zero
.L0f165068:
/* f165068: c5200004 */ lwc1 $f0,0x4($t1)
/* f16506c: c5440000 */ lwc1 $f4,0x0($t2)
/* f165070: 25080004 */ addiu $t0,$t0,0x4
/* f165074: 25290004 */ addiu $t1,$t1,0x4
/* f165078: 4604003c */ c.lt.s $f0,$f4
/* f16507c: 00000000 */ nop
/* f165080: 45020003 */ bc1fl .L0f165090
/* f165084: c5660000 */ lwc1 $f6,0x0($t3)
/* f165088: e5400000 */ swc1 $f0,0x0($t2)
/* f16508c: c5660000 */ lwc1 $f6,0x0($t3)
.L0f165090:
/* f165090: 254a0004 */ addiu $t2,$t2,0x4
/* f165094: 4600303c */ c.lt.s $f6,$f0
/* f165098: 00000000 */ nop
/* f16509c: 45000002 */ bc1f .L0f1650a8
/* f1650a0: 00000000 */ nop
/* f1650a4: e5600000 */ swc1 $f0,0x0($t3)
.L0f1650a8:
/* f1650a8: 150cffef */ bne $t0,$t4,.L0f165068
/* f1650ac: 256b0004 */ addiu $t3,$t3,0x4
/* f1650b0: 90430000 */ lbu $v1,0x0($v0)
/* f1650b4: 24e70001 */ addiu $a3,$a3,0x1
/* f1650b8: 2484000c */ addiu $a0,$a0,0xc
/* f1650bc: 00e3082a */ slt $at,$a3,$v1
/* f1650c0: 5420ffe6 */ bnezl $at,.L0f16505c
/* f1650c4: 00004025 */ or $t0,$zero,$zero
.L0f1650c8:
/* f1650c8: 03e00008 */ jr $ra
/* f1650cc: 00000000 */ nop
);
void portalFindBbox(s32 portalnum, struct coord *bbmin, struct coord *bbmax)
{
struct portalvertices *pvertices;
s32 i;
s32 j;
bbmin->x = MAXFLOAT;
bbmin->y = MAXFLOAT;
bbmin->z = MAXFLOAT;
bbmax->x = MINFLOAT;
bbmax->y = MINFLOAT;
bbmax->z = MINFLOAT;
pvertices = (struct portalvertices *)((u32)g_BgPortals + g_BgPortals[portalnum].verticesoffset);
for (i = 0; i < pvertices->count; i++) {
for (j = 0; j < 3; j++) {
f32 value = pvertices->vertices[i].f[j];
if (value < bbmin->f[j]) {
bbmin->f[j] = value;
}
if (value > bbmax->f[j]) {
bbmax->f[j] = value;
}
}
}
}
GLOBAL_ASM(
glabel func0f1650d0
@ -16954,7 +16919,7 @@ glabel func0f1650d0
/* f165228: 02202025 */ or $a0,$s1,$zero
.L0f16522c:
/* f16522c: 02a02825 */ or $a1,$s5,$zero
/* f165230: 0fc59401 */ jal func0f165004
/* f165230: 0fc59401 */ jal portalFindBbox
/* f165234: 02c03025 */ or $a2,$s6,$zero
/* f165238: 02a02025 */ or $a0,$s5,$zero
/* f16523c: 02c02825 */ or $a1,$s6,$zero

View File

@ -307,10 +307,10 @@ bool explosionCreate(struct prop *sourceprop, struct coord *exppos, s16 *exproom
s32 portalnum;
s32 indexplus1;
s32 indexplus2;
struct coord sp104;
struct coord spf8;
struct coord spec;
struct coord spe0;
struct coord portalbbmin;
struct coord portalbbmax;
struct coord portal2bbmin;
struct coord portal2bbmax;
struct coord spd4;
struct coord spc8;
s16 otherroom;
@ -389,9 +389,9 @@ bool explosionCreate(struct prop *sourceprop, struct coord *exppos, s16 *exproom
for (k = 0; k < g_Rooms[exproom].numportals; k++) {
portalnum = g_RoomPortals[g_Rooms[exproom].roomportallistoffset + k];
func0f165004(portalnum, &sp104, &spf8);
portalFindBbox(portalnum, &portalbbmin, &portalbbmax);
if (func0f164f9c(&sp104, &spf8, &spd4, &spc8)) {
if (func0f164f9c(&portalbbmin, &portalbbmax, &spd4, &spc8)) {
otherroom2 = -1;
index = 0;
@ -428,74 +428,74 @@ bool explosionCreate(struct prop *sourceprop, struct coord *exppos, s16 *exproom
indexplus1 = (index + 1) % 3;
indexplus2 = (index + 2) % 3;
value1 = spf8.f[indexplus1] - sp104.f[indexplus1];
value2 = spf8.f[indexplus2] - sp104.f[indexplus2];
value1 = portalbbmax.f[indexplus1] - portalbbmin.f[indexplus1];
value2 = portalbbmax.f[indexplus2] - portalbbmin.f[indexplus2];
if (value2 < value1) {
value1 = value2;
}
sp104.f[index] -= value1;
spf8.f[index] += value1;
portalbbmin.f[index] -= value1;
portalbbmax.f[index] += value1;
if (sp104.f[index] < g_Rooms[exproom].bbmin[index]) {
sp104.f[index] = g_Rooms[exproom].bbmin[index];
if (portalbbmin.f[index] < g_Rooms[exproom].bbmin[index]) {
portalbbmin.f[index] = g_Rooms[exproom].bbmin[index];
}
if (spf8.f[index] > g_Rooms[exproom].bbmax[index]) {
spf8.f[index] = g_Rooms[exproom].bbmax[index];
if (portalbbmax.f[index] > g_Rooms[exproom].bbmax[index]) {
portalbbmax.f[index] = g_Rooms[exproom].bbmax[index];
}
if (sp104.f[index] > g_Rooms[otherroom].bbmin[index]) {
sp104.f[index] = g_Rooms[otherroom].bbmin[index];
if (portalbbmin.f[index] > g_Rooms[otherroom].bbmin[index]) {
portalbbmin.f[index] = g_Rooms[otherroom].bbmin[index];
}
if (spf8.f[index] < g_Rooms[otherroom].bbmax[index]) {
spf8.f[index] = g_Rooms[otherroom].bbmax[index];
if (portalbbmax.f[index] < g_Rooms[otherroom].bbmax[index]) {
portalbbmax.f[index] = g_Rooms[otherroom].bbmax[index];
}
for (j = 0; j < g_Rooms[otherroom].numportals; j++) {
portalnum2 = g_RoomPortals[g_Rooms[otherroom].roomportallistoffset + j];
if (portalnum2 != portalnum) {
func0f165004(portalnum2, &spec, &spe0);
portalFindBbox(portalnum2, &portal2bbmin, &portal2bbmax);
if (spec.f[indexplus1] <= sp104.f[indexplus1] + 10.0f * mult
&& spec.f[indexplus2] <= sp104.f[indexplus2] + 10.0f * mult
&& spe0.f[indexplus1] >= spf8.f[indexplus1] - 10.0f * mult
&& spe0.f[indexplus2] >= spf8.f[indexplus2] - 10.0f * mult) {
if (portal2bbmin.f[indexplus1] <= portalbbmin.f[indexplus1] + 10.0f * mult
&& portal2bbmin.f[indexplus2] <= portalbbmin.f[indexplus2] + 10.0f * mult
&& portal2bbmax.f[indexplus1] >= portalbbmax.f[indexplus1] - 10.0f * mult
&& portal2bbmax.f[indexplus2] >= portalbbmax.f[indexplus2] - 10.0f * mult) {
if (otherroom == g_BgPortals[portalnum2].roomnum1) {
otherroom2 = g_BgPortals[portalnum2].roomnum2;
} else {
otherroom2 = g_BgPortals[portalnum2].roomnum1;
}
if (sp104.f[index] > g_Rooms[otherroom2].bbmin[index]) {
sp104.f[index] = g_Rooms[otherroom2].bbmin[index];
if (portalbbmin.f[index] > g_Rooms[otherroom2].bbmin[index]) {
portalbbmin.f[index] = g_Rooms[otherroom2].bbmin[index];
}
if (spf8.f[index] < g_Rooms[otherroom2].bbmax[index]) {
spf8.f[index] = g_Rooms[otherroom2].bbmax[index];
if (portalbbmax.f[index] < g_Rooms[otherroom2].bbmax[index]) {
portalbbmax.f[index] = g_Rooms[otherroom2].bbmax[index];
}
break;
}
}
}
sp104.f[0] *= mult;
sp104.f[1] *= mult;
sp104.f[2] *= mult;
portalbbmin.f[0] *= mult;
portalbbmin.f[1] *= mult;
portalbbmin.f[2] *= mult;
spf8.f[0] *= mult;
spf8.f[1] *= mult;
spf8.f[2] *= mult;
portalbbmax.f[0] *= mult;
portalbbmax.f[1] *= mult;
portalbbmax.f[2] *= mult;
exp->bbs[exp->numbb].bbmin.x = sp104.f[0];
exp->bbs[exp->numbb].bbmin.y = sp104.f[1];
exp->bbs[exp->numbb].bbmin.z = sp104.f[2];
exp->bbs[exp->numbb].bbmax.x = spf8.f[0];
exp->bbs[exp->numbb].bbmax.y = spf8.f[1];
exp->bbs[exp->numbb].bbmax.z = spf8.f[2];
exp->bbs[exp->numbb].bbmin.x = portalbbmin.f[0];
exp->bbs[exp->numbb].bbmin.y = portalbbmin.f[1];
exp->bbs[exp->numbb].bbmin.z = portalbbmin.f[2];
exp->bbs[exp->numbb].bbmax.x = portalbbmax.f[0];
exp->bbs[exp->numbb].bbmax.y = portalbbmax.f[1];
exp->bbs[exp->numbb].bbmax.z = portalbbmax.f[2];
exp->bbs[exp->numbb].room = otherroom;
exp->bbs[exp->numbb].room2 = otherroom2;

View File

@ -17,6 +17,7 @@
#define S32_MAX 2147483647
#define U32_MAX 4294967295
#define MINFLOAT ((float)-3.40282346638528860e+38)
#define MAXFLOAT ((float)3.40282346638528860e+38)
#define ABS(val) ((val) > 0 ? (val) : -(val))

View File

@ -100,7 +100,7 @@ void func0f164c64(s32 roomnum);
void portalSetEnabled(s32 portal, bool enable);
s32 func0f164e8c(struct coord *arg0, struct coord *arg1);
bool func0f164f9c(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct coord *arg3);
void func0f165004(s32 portalnum, struct coord *arg1, struct coord *arg2);
void portalFindBbox(s32 portalnum, struct coord *bbmin, struct coord *bbmax);
void func0f1650d0(struct coord *lower, struct coord *upper, s16 *rooms, s32 arg3, s32 arg4);
#endif