Decompile func0f089a94

This commit is contained in:
Ryan Dwyer 2022-04-07 21:36:11 +10:00
parent f703416714
commit ff23074f9b
8 changed files with 116 additions and 187 deletions

View File

@ -1432,7 +1432,7 @@ void chrRemove(struct prop *prop, bool delete)
func0f14159c(prop);
func0f0926bc(prop, 1, 0xffff);
shieldhitsRemoveByProp(prop);
func0f089a94(0, model);
func0f089a94(VTXSTORETYPE_CHRVTX, model);
propDeregisterRooms(prop);
if (g_Vars.stagenum == STAGE_CITRAINING) {

View File

@ -6228,7 +6228,7 @@ void objFree(struct defaultobj *obj, bool freeprop, bool canregen)
propDeregisterRooms(obj->prop);
if (obj->prop->type != PROPTYPE_DOOR) {
func0f089a94(true, obj->model);
func0f089a94(1, obj->model);
}
modelFree(obj->model);
@ -76027,142 +76027,66 @@ bool func0f0899dc(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3)
return false;
}
GLOBAL_ASM(
glabel func0f089a94
/* f089a94: 27bdffc0 */ addiu $sp,$sp,-64
/* f089a98: afbf003c */ sw $ra,0x3c($sp)
/* f089a9c: afbe0038 */ sw $s8,0x38($sp)
/* f089aa0: afb70034 */ sw $s7,0x34($sp)
/* f089aa4: afb60030 */ sw $s6,0x30($sp)
/* f089aa8: afb5002c */ sw $s5,0x2c($sp)
/* f089aac: afb40028 */ sw $s4,0x28($sp)
/* f089ab0: afb30024 */ sw $s3,0x24($sp)
/* f089ab4: afb20020 */ sw $s2,0x20($sp)
/* f089ab8: afb1001c */ sw $s1,0x1c($sp)
/* f089abc: afb00018 */ sw $s0,0x18($sp)
/* f089ac0: 8cb60008 */ lw $s6,0x8($a1)
/* f089ac4: 00a09825 */ or $s3,$a1,$zero
/* f089ac8: 0080a825 */ or $s5,$a0,$zero
/* f089acc: 8ed00000 */ lw $s0,0x0($s6)
/* f089ad0: 2414000c */ addiu $s4,$zero,0xc
/* f089ad4: 24170008 */ addiu $s7,$zero,0x8
/* f089ad8: 12000059 */ beqz $s0,.L0f089c40
/* f089adc: 241e0012 */ addiu $s8,$zero,0x12
/* f089ae0: 96020000 */ lhu $v0,0x0($s0)
.L0f089ae4:
/* f089ae4: 02602025 */ or $a0,$s3,$zero
/* f089ae8: 304e00ff */ andi $t6,$v0,0xff
/* f089aec: 11d70039 */ beq $t6,$s7,.L0f089bd4
/* f089af0: 00000000 */ nop
/* f089af4: 11de003b */ beq $t6,$s8,.L0f089be4
/* f089af8: 02602025 */ or $a0,$s3,$zero
/* f089afc: 24010017 */ addiu $at,$zero,0x17
/* f089b00: 11c1003c */ beq $t6,$at,.L0f089bf4
/* f089b04: 02602025 */ or $a0,$s3,$zero
/* f089b08: 24010018 */ addiu $at,$zero,0x18
/* f089b0c: 11c10003 */ beq $t6,$at,.L0f089b1c
/* f089b10: 02602025 */ or $a0,$s3,$zero
/* f089b14: 1000003a */ b .L0f089c00
/* f089b18: 8e020014 */ lw $v0,0x14($s0)
.L0f089b1c:
/* f089b1c: 8e110004 */ lw $s1,0x4($s0)
/* f089b20: 0c006a87 */ jal modelGetNodeRwData
/* f089b24: 02002825 */ or $a1,$s0,$zero
/* f089b28: 00409025 */ or $s2,$v0,$zero
/* f089b2c: 02c02025 */ or $a0,$s6,$zero
/* f089b30: 0fc20706 */ jal modelIsNodeNotTvscreen
/* f089b34: 02002825 */ or $a1,$s0,$zero
/* f089b38: 10400024 */ beqz $v0,.L0f089bcc
/* f089b3c: 00000000 */ nop
/* f089b40: 8e22000c */ lw $v0,0xc($s1)
/* f089b44: 8e450000 */ lw $a1,0x0($s2)
/* f089b48: 50450007 */ beql $v0,$a1,.L0f089b68
/* f089b4c: 86380010 */ lh $t8,0x10($s1)
/* f089b50: 0fc4a606 */ jal vtxstoreFree
/* f089b54: 02a02025 */ or $a0,$s5,$zero
/* f089b58: 8e2f000c */ lw $t7,0xc($s1)
/* f089b5c: ae4f0000 */ sw $t7,0x0($s2)
/* f089b60: 8e22000c */ lw $v0,0xc($s1)
/* f089b64: 86380010 */ lh $t8,0x10($s1)
.L0f089b68:
/* f089b68: 8e450008 */ lw $a1,0x8($s2)
/* f089b6c: 24010001 */ addiu $at,$zero,0x1
/* f089b70: 03140019 */ multu $t8,$s4
/* f089b74: 0000c812 */ mflo $t9
/* f089b78: 00594021 */ addu $t0,$v0,$t9
/* f089b7c: 25090007 */ addiu $t1,$t0,0x7
/* f089b80: 352a0007 */ ori $t2,$t1,0x7
/* f089b84: 394b0007 */ xori $t3,$t2,0x7
/* f089b88: 11650010 */ beq $t3,$a1,.L0f089bcc
/* f089b8c: 00000000 */ nop
/* f089b90: 16a10003 */ bne $s5,$at,.L0f089ba0
/* f089b94: 24040002 */ addiu $a0,$zero,0x2
/* f089b98: 10000001 */ b .L0f089ba0
/* f089b9c: 24040003 */ addiu $a0,$zero,0x3
.L0f089ba0:
/* f089ba0: 0fc4a606 */ jal vtxstoreFree
/* f089ba4: 00000000 */ nop
/* f089ba8: 862d0010 */ lh $t5,0x10($s1)
/* f089bac: 8e2c000c */ lw $t4,0xc($s1)
/* f089bb0: 01b40019 */ multu $t5,$s4
/* f089bb4: 00007012 */ mflo $t6
/* f089bb8: 018e7821 */ addu $t7,$t4,$t6
/* f089bbc: 25f80007 */ addiu $t8,$t7,0x7
/* f089bc0: 37190007 */ ori $t9,$t8,0x7
/* f089bc4: 3b280007 */ xori $t0,$t9,0x7
/* f089bc8: ae480008 */ sw $t0,0x8($s2)
.L0f089bcc:
/* f089bcc: 1000000c */ b .L0f089c00
/* f089bd0: 8e020014 */ lw $v0,0x14($s0)
.L0f089bd4:
/* f089bd4: 0c0071e1 */ jal model0001c784
/* f089bd8: 02002825 */ or $a1,$s0,$zero
/* f089bdc: 10000008 */ b .L0f089c00
/* f089be0: 8e020014 */ lw $v0,0x14($s0)
.L0f089be4:
/* f089be4: 0c0071f4 */ jal model0001c7d0
/* f089be8: 02002825 */ or $a1,$s0,$zero
/* f089bec: 10000004 */ b .L0f089c00
/* f089bf0: 8e020014 */ lw $v0,0x14($s0)
.L0f089bf4:
/* f089bf4: 0c007207 */ jal modelAttachHead
/* f089bf8: 02002825 */ or $a1,$s0,$zero
/* f089bfc: 8e020014 */ lw $v0,0x14($s0)
.L0f089c00:
/* f089c00: 10400003 */ beqz $v0,.L0f089c10
/* f089c04: 00000000 */ nop
/* f089c08: 1000000b */ b .L0f089c38
/* f089c0c: 00408025 */ or $s0,$v0,$zero
.L0f089c10:
/* f089c10: 12000009 */ beqz $s0,.L0f089c38
/* f089c14: 00000000 */ nop
/* f089c18: 8e02000c */ lw $v0,0xc($s0)
.L0f089c1c:
/* f089c1c: 50400004 */ beqzl $v0,.L0f089c30
/* f089c20: 8e100008 */ lw $s0,0x8($s0)
/* f089c24: 10000004 */ b .L0f089c38
/* f089c28: 00408025 */ or $s0,$v0,$zero
/* f089c2c: 8e100008 */ lw $s0,0x8($s0)
.L0f089c30:
/* f089c30: 5600fffa */ bnezl $s0,.L0f089c1c
/* f089c34: 8e02000c */ lw $v0,0xc($s0)
.L0f089c38:
/* f089c38: 5600ffaa */ bnezl $s0,.L0f089ae4
/* f089c3c: 96020000 */ lhu $v0,0x0($s0)
.L0f089c40:
/* f089c40: 8fbf003c */ lw $ra,0x3c($sp)
/* f089c44: 8fb00018 */ lw $s0,0x18($sp)
/* f089c48: 8fb1001c */ lw $s1,0x1c($sp)
/* f089c4c: 8fb20020 */ lw $s2,0x20($sp)
/* f089c50: 8fb30024 */ lw $s3,0x24($sp)
/* f089c54: 8fb40028 */ lw $s4,0x28($sp)
/* f089c58: 8fb5002c */ lw $s5,0x2c($sp)
/* f089c5c: 8fb60030 */ lw $s6,0x30($sp)
/* f089c60: 8fb70034 */ lw $s7,0x34($sp)
/* f089c64: 8fbe0038 */ lw $s8,0x38($sp)
/* f089c68: 03e00008 */ jr $ra
/* f089c6c: 27bd0040 */ addiu $sp,$sp,0x40
);
void func0f089a94(s32 vtxstoretype, struct model *model)
{
struct modelfiledata *modeldef = model->filedata;
struct modelnode *node = modeldef->rootnode;
while (node) {
u32 type = node->type & 0xff;
union modelrodata *rodata;
union modelrwdata *rwdata;
s32 newtype;
switch (type) {
case MODELNODETYPE_DL:
rodata = node->rodata;
rwdata = modelGetNodeRwData(model, node);
if (modelIsNodeNotTvscreen(modeldef, node)) {
if (rwdata->dl.vertices != rodata->dl.vertices) {
vtxstoreFree(vtxstoretype, rwdata->dl.vertices);
rwdata->dl.vertices = rodata->dl.vertices;
}
if ((u32)rwdata->dl.colours != ALIGN8((u32)rodata->dl.vertices + rodata->dl.numvertices * sizeof(struct gfxvtx))) {
if (vtxstoretype == VTXSTORETYPE_OBJVTX) {
newtype = VTXSTORETYPE_OBJCOL;
} else {
newtype = VTXSTORETYPE_CHRCOL;
}
vtxstoreFree(newtype, rwdata->dl.colours);
rwdata->dl.colours = (struct colour *)ALIGN8((u32)rodata->dl.vertices + rodata->dl.numvertices * sizeof(struct gfxvtx));
}
}
break;
case MODELNODETYPE_DISTANCE:
model0001c784(model, node);
break;
case MODELNODETYPE_TOGGLE:
model0001c7d0(model, node);
break;
case MODELNODETYPE_HEADSPOT:
modelAttachHead(model, node);
break;
}
if (node->child) {
node = node->child;
} else {
while (node) {
if (node->next) {
node = node->next;
break;
}
node = node->parent;
}
}
}
}
struct prop *hatApplyToChr(struct hatobj *hat, struct chrdata *chr, struct modelfiledata *filedata, struct prop *prop, struct model *model)
{

View File

@ -33,7 +33,7 @@ const char var7f1b54c0[] = "vtxstore: Out of vertices type %d wanted %d free %d
const char var7f1b5508[] = "vtxstore: freevertices type %d, list %x\n";
const char var7f1b5534[] = "freevertices: address not found in array %x\n";
struct var8007e3d0 var8007e3d0[] = {
struct vtxstoretype g_VtxstoreTypes[] = {
{ 3000, 120, 3000, 80, 0, 0, 500, 20, 12, 0, 0, 0, 0 },
{ 1500, 40, 500, 20, 0, 0, 500, 20, 12, 0, 0, 0, 0 },
{ 6000, 120, 6000, 80, 0, 0, 1000, 20, 4, 0, 0, 0, 0 },
@ -101,26 +101,26 @@ void vtxstoreTick(void)
s32 i;
s32 j;
if (var8007e3d0[1].val2 < var8007e3d0[1].val1 >> 2) {
for (i = 0; i < var8007e3d0[1].numallocated - 1; i++) {
if (var8007e3d0[1].unk24[i].unk0e > 0) {
for (j = i + 1; j < var8007e3d0[1].numallocated; j++) {
if (var8007e3d0[1].unk24[j].unk0e > 0
&& var8007e3d0[1].unk24[i].unk04 == var8007e3d0[1].unk24[j].unk04
&& var8007e3d0[1].unk24[i].unk08 == var8007e3d0[1].unk24[j].unk08) {
s32 size = ALIGN16(var8007e3d0[1].unk24[j].unk0c * 0x0c);
vtxstoreFixRefs(var8007e3d0[1].unk24[j].unk00, var8007e3d0[1].unk24[i].unk00);
var8007e3d0[1].unk24[i].unk0e += var8007e3d0[1].unk24[j].unk0e;
memaFree(var8007e3d0[1].unk24[j].unk00, size);
var8007e3d0[1].unk24[j].unk0e = 0;
var8007e3d0[1].val2 += var8007e3d0[1].unk24[j].unk0c;
if (g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].val2 < g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].val1 >> 2) {
for (i = 0; i < g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].numallocated - 1; i++) {
if (g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[i].unk0e > 0) {
for (j = i + 1; j < g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].numallocated; j++) {
if (g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[j].unk0e > 0
&& g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[i].unk04 == g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[j].unk04
&& g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[i].unk08 == g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[j].unk08) {
s32 size = ALIGN16(g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[j].unk0c * 0x0c);
vtxstoreFixRefs(g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[j].unk00, g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[i].unk00);
g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[i].unk0e += g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[j].unk0e;
memaFree(g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[j].unk00, size);
g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[j].unk0e = 0;
g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].val2 += g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].unk24[j].unk0c;
}
}
}
}
}
if (var8007e3d0[1].val2 < var8007e3d0[1].val1 >> 2) {
if (g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].val2 < g_VtxstoreTypes[VTXSTORETYPE_OBJVTX].val1 >> 2) {
func0f091030();
}
}
@ -140,27 +140,27 @@ void *vtxstoreAllocate(s32 count, s32 index, s32 arg2, s32 arg3)
}
#endif
if (count <= var8007e3d0[index].val2) {
for (i = 0; i < var8007e3d0[index].numallocated; i++) {
if (var8007e3d0[index].unk24[i].unk0e == 0) {
if (count <= g_VtxstoreTypes[index].val2) {
for (i = 0; i < g_VtxstoreTypes[index].numallocated; i++) {
if (g_VtxstoreTypes[index].unk24[i].unk0e == 0) {
size = ALIGN16(count * 0xc);
var8007e3d0[index].unk24[i].unk00 = memaAlloc(size);
g_VtxstoreTypes[index].unk24[i].unk00 = memaAlloc(size);
#if VERSION < VERSION_NTSC_1_0
if (!var8007e3d0[index].unk24[i].unk00) {
if (!g_VtxstoreTypes[index].unk24[i].unk00) {
bgGarbageCollectRooms(size, false);
var8007e3d0[index].unk24[i].unk00 = memaAlloc(size);
g_VtxstoreTypes[index].unk24[i].unk00 = memaAlloc(size);
}
#endif
if (var8007e3d0[index].unk24[i].unk00) {
var8007e3d0[index].unk24[i].unk0c = count;
var8007e3d0[index].unk24[i].unk0e = 1;
var8007e3d0[index].unk24[i].unk04 = arg2;
var8007e3d0[index].unk24[i].unk08 = arg3;
var8007e3d0[index].val2 -= count;
if (g_VtxstoreTypes[index].unk24[i].unk00) {
g_VtxstoreTypes[index].unk24[i].unk0c = count;
g_VtxstoreTypes[index].unk24[i].unk0e = 1;
g_VtxstoreTypes[index].unk24[i].unk04 = arg2;
g_VtxstoreTypes[index].unk24[i].unk08 = arg3;
g_VtxstoreTypes[index].val2 -= count;
return var8007e3d0[index].unk24[i].unk00;
return g_VtxstoreTypes[index].unk24[i].unk00;
}
return NULL;
@ -212,21 +212,21 @@ void *vtxstoreAllocate(s32 count, s32 index, s32 arg2, s32 arg3)
return NULL;
}
void vtxstoreFree(s32 arg0, void *arg1)
void vtxstoreFree(s32 type, void *arg1)
{
s32 i;
for (i = 0; i < var8007e3d0[arg0].numallocated; i++) {
if (var8007e3d0[arg0].unk24[i].unk0e > 0 && arg1 == var8007e3d0[arg0].unk24[i].unk00) {
var8007e3d0[arg0].unk24[i].unk0e--;
for (i = 0; i < g_VtxstoreTypes[type].numallocated; i++) {
if (g_VtxstoreTypes[type].unk24[i].unk0e > 0 && arg1 == g_VtxstoreTypes[type].unk24[i].unk00) {
g_VtxstoreTypes[type].unk24[i].unk0e--;
if (var8007e3d0[arg0].unk24[i].unk0e) {
if (g_VtxstoreTypes[type].unk24[i].unk0e) {
return;
}
memaFree(var8007e3d0[arg0].unk24[i].unk00, ALIGN16(var8007e3d0[arg0].unk24[i].unk0c * 0xc));
memaFree(g_VtxstoreTypes[type].unk24[i].unk00, ALIGN16(g_VtxstoreTypes[type].unk24[i].unk0c * 0xc));
var8007e3d0[arg0].val2 += var8007e3d0[arg0].unk24[i].unk0c;
g_VtxstoreTypes[type].val2 += g_VtxstoreTypes[type].unk24[i].unk0c;
return;
}
}

View File

@ -14,26 +14,26 @@ void vtxstoreReset(void)
for (i = 0; i < 4; i++) {
if (PLAYERCOUNT() >= 2) {
val = var8007e3d0[i].valifmp;
num = var8007e3d0[i].numifmp;
val = g_VtxstoreTypes[i].valifmp;
num = g_VtxstoreTypes[i].numifmp;
} else if (g_Vars.stagenum >= STAGE_TITLE) {
val = var8007e3d0[i].valifspecial;
num = var8007e3d0[i].numifspecial;
val = g_VtxstoreTypes[i].valifspecial;
num = g_VtxstoreTypes[i].numifspecial;
} else {
val = var8007e3d0[i].valifsp;
num = var8007e3d0[i].numifsp;
val = g_VtxstoreTypes[i].valifsp;
num = g_VtxstoreTypes[i].numifsp;
}
if (num > 0) {
var8007e3d0[i].unk24 = mempAlloc(num * sizeof(struct var8007e3d0_data), MEMPOOL_STAGE);
g_VtxstoreTypes[i].unk24 = mempAlloc(num * sizeof(struct var8007e3d0_data), MEMPOOL_STAGE);
}
for (j = 0; j < num; j++) {
var8007e3d0[i].unk24[j].unk0e = 0;
g_VtxstoreTypes[i].unk24[j].unk0e = 0;
}
var8007e3d0[i].numallocated = num;
var8007e3d0[i].val1 = val;
var8007e3d0[i].val2 = val;
g_VtxstoreTypes[i].numallocated = num;
g_VtxstoreTypes[i].val1 = val;
g_VtxstoreTypes[i].val2 = val;
}
}

View File

@ -4124,6 +4124,11 @@
#define VOICEBOX_MALE2 2
#define VOICEBOX_FEMALE 3
#define VTXSTORETYPE_CHRVTX 0
#define VTXSTORETYPE_OBJVTX 1
#define VTXSTORETYPE_CHRCOL 2
#define VTXSTORETYPE_OBJCOL 3
#define WAYMODE_INIT 0
#define WAYMODE_LOST1 1
#define WAYMODE_RETRY 2

View File

@ -416,7 +416,7 @@ extern u32 var8007dbd0;
extern struct coord g_TeleportToPos;
extern struct coord g_TeleportToUp;
extern struct coord g_TeleportToLook;
extern struct var8007e3d0 var8007e3d0[];
extern struct vtxstoretype g_VtxstoreTypes[];
extern s32 g_ExplosionShakeTotalTimer;
extern s32 g_ExplosionShakeIntensityTimer;
extern f32 g_ExplosionDamageReceivedScale;

View File

@ -261,7 +261,7 @@ void currentPlayerQueuePickupWeaponHudmsg(u32 weaponnum, bool dual);
s32 propPickupByPlayer(struct prop *prop, bool showhudmsg);
s32 objTestForPickup(struct prop *prop);
bool func0f0899dc(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3);
void func0f089a94(bool arg0, struct model *model);
void func0f089a94(s32 vtxstoretype, struct model *model);
struct prop *hatApplyToChr(struct hatobj *hat, struct chrdata *chr, struct modelfiledata *filedata, struct prop *prop, struct model *model);
void hatLoadAndApplyToChr(struct hatobj *hat, struct chrdata *chr);
void hatAssignToChr(struct hatobj *hat, struct chrdata *chr);

View File

@ -6103,7 +6103,7 @@ struct var8007e3d0_data {
s16 unk0e;
};
struct var8007e3d0 {
struct vtxstoretype {
s32 valifsp;
s32 numifsp;
s32 valifmp;