Decompile smokeInit

This commit is contained in:
Ryan Dwyer 2021-01-07 09:57:43 +10:00
parent d3c5c29d4f
commit 2d28a20703
7 changed files with 44 additions and 105 deletions

View File

@ -34,7 +34,7 @@ void explosionsInit(void)
for (i = 0; i < g_MaxExplosions; i++) {
g_Explosions[i].prop = NULL;
for (j = 0; j < 40; j++) {
for (j = 0; j < ARRAYCOUNT(g_Explosions[i].parts); j++) {
g_Explosions[i].parts[j].frame = 0;
}
}

View File

@ -16,7 +16,7 @@ void smokeFree(void)
s32 i;
if (g_Smokes) {
for (i = 0; i < g_NumSmokes; i++) {
for (i = 0; i < g_MaxSmokes; i++) {
if (g_Smokes[i].prop) {
func0f0605c4(g_Smokes[i].prop);
propHide(g_Smokes[i].prop);

View File

@ -11,89 +11,28 @@
#include "lib/lib_121e0.h"
#include "types.h"
GLOBAL_ASM(
glabel smokeInit
/* f013130: 3c0e8009 */ lui $t6,%hi(g_Is4Mb)
/* f013134: 91ce0af0 */ lbu $t6,%lo(g_Is4Mb)($t6)
/* f013138: 27bdffe8 */ addiu $sp,$sp,-24
/* f01313c: 24010001 */ addiu $at,$zero,0x1
/* f013140: 15c10006 */ bne $t6,$at,.L0f01315c
/* f013144: afbf0014 */ sw $ra,0x14($sp)
/* f013148: 3c08800a */ lui $t0,%hi(g_NumSmokes)
/* f01314c: 25083444 */ addiu $t0,$t0,%lo(g_NumSmokes)
/* f013150: 240f000a */ addiu $t7,$zero,0xa
/* f013154: 10000005 */ b .L0f01316c
/* f013158: ad0f0000 */ sw $t7,0x0($t0)
.L0f01315c:
/* f01315c: 3c08800a */ lui $t0,%hi(g_NumSmokes)
/* f013160: 25083444 */ addiu $t0,$t0,%lo(g_NumSmokes)
/* f013164: 24180014 */ addiu $t8,$zero,0x14
/* f013168: ad180000 */ sw $t8,0x0($t0)
.L0f01316c:
/* f01316c: 3c19800a */ lui $t9,%hi(g_Vars+0x4b4)
/* f013170: 8f39a474 */ lw $t9,%lo(g_Vars+0x4b4)($t9)
/* f013174: 3c05800a */ lui $a1,%hi(g_Smokes)
/* f013178: 24a53440 */ addiu $a1,$a1,%lo(g_Smokes)
/* f01317c: 2b21005a */ slti $at,$t9,0x5a
/* f013180: 54200003 */ bnezl $at,.L0f013190
/* f013184: 8d020000 */ lw $v0,0x0($t0)
/* f013188: ad000000 */ sw $zero,0x0($t0)
/* f01318c: 8d020000 */ lw $v0,0x0($t0)
.L0f013190:
/* f013190: 54400004 */ bnezl $v0,.L0f0131a4
/* f013194: 00022080 */ sll $a0,$v0,0x2
/* f013198: 1000002c */ b .L0f01324c
/* f01319c: aca00000 */ sw $zero,0x0($a1)
/* f0131a0: 00022080 */ sll $a0,$v0,0x2
.L0f0131a4:
/* f0131a4: 00822023 */ subu $a0,$a0,$v0
/* f0131a8: 00042080 */ sll $a0,$a0,0x2
/* f0131ac: 00822021 */ addu $a0,$a0,$v0
/* f0131b0: 000420c0 */ sll $a0,$a0,0x3
/* f0131b4: 00822023 */ subu $a0,$a0,$v0
/* f0131b8: 00042080 */ sll $a0,$a0,0x2
/* f0131bc: 0c0048f2 */ jal malloc
/* f0131c0: 24050004 */ addiu $a1,$zero,0x4
/* f0131c4: 3c08800a */ lui $t0,%hi(g_NumSmokes)
/* f0131c8: 25083444 */ addiu $t0,$t0,%lo(g_NumSmokes)
/* f0131cc: 8d090000 */ lw $t1,0x0($t0)
/* f0131d0: 3c05800a */ lui $a1,%hi(g_Smokes)
/* f0131d4: 24a53440 */ addiu $a1,$a1,%lo(g_Smokes)
/* f0131d8: aca20000 */ sw $v0,0x0($a1)
/* f0131dc: 1920001b */ blez $t1,.L0f01324c
/* f0131e0: 00002025 */ or $a0,$zero,$zero
/* f0131e4: 44800000 */ mtc1 $zero,$f0
/* f0131e8: 00003025 */ or $a2,$zero,$zero
/* f0131ec: 24030190 */ addiu $v1,$zero,0x190
/* f0131f0: 8caa0000 */ lw $t2,0x0($a1)
.L0f0131f4:
/* f0131f4: 00001025 */ or $v0,$zero,$zero
/* f0131f8: 01465821 */ addu $t3,$t2,$a2
/* f0131fc: ad600000 */ sw $zero,0x0($t3)
.L0f013200:
/* f013200: 00046880 */ sll $t5,$a0,0x2
/* f013204: 01a46823 */ subu $t5,$t5,$a0
/* f013208: 000d6880 */ sll $t5,$t5,0x2
/* f01320c: 01a46821 */ addu $t5,$t5,$a0
/* f013210: 8cac0000 */ lw $t4,0x0($a1)
/* f013214: 000d68c0 */ sll $t5,$t5,0x3
/* f013218: 01a46823 */ subu $t5,$t5,$a0
/* f01321c: 000d6880 */ sll $t5,$t5,0x2
/* f013220: 018d7021 */ addu $t6,$t4,$t5
/* f013224: 01c27821 */ addu $t7,$t6,$v0
/* f013228: 24420028 */ addiu $v0,$v0,0x28
/* f01322c: 1443fff4 */ bne $v0,$v1,.L0f013200
/* f013230: e5e00014 */ swc1 $f0,0x14($t7)
/* f013234: 8d180000 */ lw $t8,0x0($t0)
/* f013238: 24840001 */ addiu $a0,$a0,0x1
/* f01323c: 24c6019c */ addiu $a2,$a2,0x19c
/* f013240: 0098082a */ slt $at,$a0,$t8
/* f013244: 5420ffeb */ bnezl $at,.L0f0131f4
/* f013248: 8caa0000 */ lw $t2,0x0($a1)
.L0f01324c:
/* f01324c: 8fbf0014 */ lw $ra,0x14($sp)
/* f013250: 27bd0018 */ addiu $sp,$sp,0x18
/* f013254: 03e00008 */ jr $ra
/* f013258: 00000000 */ nop
/* f01325c: 00000000 */ nop
);
void smokeInit(void)
{
s32 i;
s32 j;
g_MaxSmokes = IS4MB() ? 10 : 20;
if (g_Vars.stagenum >= STAGE_TITLE) {
g_MaxSmokes = 0;
}
if (g_MaxSmokes == 0) {
g_Smokes = NULL;
} else {
g_Smokes = malloc(g_MaxSmokes * sizeof(struct smoke), 4);
for (i = 0; i < g_MaxSmokes; i++) {
g_Smokes[i].prop = NULL;
for (j = 0; j < ARRAYCOUNT(g_Smokes[i].parts); j++) {
g_Smokes[i].parts[j].size = 0;
}
}
}
}

View File

@ -1031,7 +1031,7 @@ glabel smokeCreate
/* f12e214: 00008825 */ or $s1,$zero,$zero
/* f12e218: 00009025 */ or $s2,$zero,$zero
/* f12e21c: 13000003 */ beqz $t8,.L0f12e22c
/* f12e220: 3c08800a */ lui $t0,%hi(g_NumSmokes)
/* f12e220: 3c08800a */ lui $t0,%hi(g_MaxSmokes)
/* f12e224: 10000001 */ b .L0f12e22c
/* f12e228: 24110001 */ addiu $s1,$zero,0x1
.L0f12e22c:
@ -1051,7 +1051,7 @@ glabel smokeCreate
/* f12e25c: 10000001 */ b .L0f12e264
/* f12e260: 240d0001 */ addiu $t5,$zero,0x1
.L0f12e264:
/* f12e264: 8d083444 */ lw $t0,%lo(g_NumSmokes)($t0)
/* f12e264: 8d083444 */ lw $t0,%lo(g_MaxSmokes)($t0)
/* f12e268: 00004825 */ or $t1,$zero,$zero
/* f12e26c: 00003825 */ or $a3,$zero,$zero
/* f12e270: 1900003b */ blez $t0,.L0f12e360
@ -1086,13 +1086,13 @@ glabel smokeCreate
/* f12e2dc: 5321001e */ beql $t9,$at,.L0f12e358
/* f12e2e0: 00e8082a */ slt $at,$a3,$t0
/* f12e2e4: 032c0019 */ multu $t9,$t4
/* f12e2e8: 3c08800a */ lui $t0,%hi(g_NumSmokes)
/* f12e2e8: 3c08800a */ lui $t0,%hi(g_MaxSmokes)
/* f12e2ec: 00007012 */ mflo $t6
/* f12e2f0: 016e7821 */ addu $t7,$t3,$t6
/* f12e2f4: 85f80000 */ lh $t8,0x0($t7)
/* f12e2f8: a4780004 */ sh $t8,0x4($v1)
/* f12e2fc: 10000015 */ b .L0f12e354
/* f12e300: 8d083444 */ lw $t0,%lo(g_NumSmokes)($t0)
/* f12e300: 8d083444 */ lw $t0,%lo(g_MaxSmokes)($t0)
/* f12e304: 2a01000f */ slti $at,$s0,0xf
.L0f12e308:
/* f12e308: 14200012 */ bnez $at,.L0f12e354
@ -1107,12 +1107,12 @@ glabel smokeCreate
/* f12e32c: 55210009 */ bnel $t1,$at,.L0f12e354
/* f12e330: 25290001 */ addiu $t1,$t1,0x1
/* f12e334: 032c0019 */ multu $t9,$t4
/* f12e338: 3c08800a */ lui $t0,%hi(g_NumSmokes)
/* f12e338: 3c08800a */ lui $t0,%hi(g_MaxSmokes)
/* f12e33c: 00007012 */ mflo $t6
/* f12e340: 016e7821 */ addu $t7,$t3,$t6
/* f12e344: 85f80000 */ lh $t8,0x0($t7)
/* f12e348: a4580004 */ sh $t8,0x4($v0)
/* f12e34c: 8d083444 */ lw $t0,%lo(g_NumSmokes)($t0)
/* f12e34c: 8d083444 */ lw $t0,%lo(g_MaxSmokes)($t0)
/* f12e350: 25290001 */ addiu $t1,$t1,0x1
.L0f12e354:
/* f12e354: 00e8082a */ slt $at,$a3,$t0
@ -1198,7 +1198,7 @@ glabel smokeCreate
// s32 i;
//
// // 270
// for (i = 0; i < g_NumSmokes; i++) {
// for (i = 0; i < g_MaxSmokes; i++) {
// if (g_Smokes[i].prop == NULL) {
// smoke = &g_Smokes[i];
// break;
@ -1264,7 +1264,7 @@ bool func0f12e454(struct coord *pos, s16 *rooms, s16 type, u32 arg4)
s32 i;
s32 j;
for (i = 0; i < g_NumSmokes; i++) {
for (i = 0; i < g_MaxSmokes; i++) {
if (g_Smokes[i].prop
&& g_Smokes[i].unk06_07 == arg4
&& g_Smokes[i].type >= SMOKETYPE_MUZZLE_PISTOL
@ -1312,7 +1312,7 @@ bool smokeCreateAtPropIfNecessary(struct prop *prop, struct coord *pos, s16 *roo
}
if (checksmokes) {
for (i = 0; i < g_NumSmokes; i++) {
for (i = 0; i < g_MaxSmokes; i++) {
if (g_Smokes[i].prop && g_Smokes[i].srcprop == prop) {
bool fail = false;
@ -1356,7 +1356,7 @@ void smokeClearForProp(struct prop *prop)
{
s32 i;
for (i = 0; i < g_NumSmokes; i++) {
for (i = 0; i < g_MaxSmokes; i++) {
if (g_Smokes[i].prop && g_Smokes[i].srcprop == prop && g_Smokes[i].unk06_07 == false) {
g_Smokes[i].age = g_SmokeTypes[g_Smokes[i].type].duration;
g_Smokes[i].srcprop = NULL;
@ -2119,8 +2119,8 @@ Gfx *smokeRender(struct prop *prop, Gfx *gdl, bool withalpha)
GLOBAL_ASM(
glabel func0f12f5f8
/* f12f5f8: 3c03800a */ lui $v1,%hi(g_NumSmokes)
/* f12f5fc: 8c633444 */ lw $v1,%lo(g_NumSmokes)($v1)
/* f12f5f8: 3c03800a */ lui $v1,%hi(g_MaxSmokes)
/* f12f5fc: 8c633444 */ lw $v1,%lo(g_MaxSmokes)($v1)
/* f12f600: 27bdfff0 */ addiu $sp,$sp,-16
/* f12f604: afb1000c */ sw $s1,0xc($sp)
/* f12f608: afb00008 */ sw $s0,0x8($sp)
@ -2155,12 +2155,12 @@ glabel func0f12f5f8
/* f12f678: 51b80009 */ beql $t5,$t8,.L0f12f6a0
/* f12f67c: 0043082a */ slt $at,$v0,$v1
/* f12f680: 03110019 */ multu $t8,$s1
/* f12f684: 3c03800a */ lui $v1,%hi(g_NumSmokes)
/* f12f684: 3c03800a */ lui $v1,%hi(g_MaxSmokes)
/* f12f688: 0000c812 */ mflo $t9
/* f12f68c: 02197021 */ addu $t6,$s0,$t9
/* f12f690: 85cf0000 */ lh $t7,0x0($t6)
/* f12f694: a4cf0004 */ sh $t7,0x4($a2)
/* f12f698: 8c633444 */ lw $v1,%lo(g_NumSmokes)($v1)
/* f12f698: 8c633444 */ lw $v1,%lo(g_MaxSmokes)($v1)
/* f12f69c: 0043082a */ slt $at,$v0,$v1
.L0f12f6a0:
/* f12f6a0: 1420ffe6 */ bnez $at,.L0f12f63c

View File

@ -1974,7 +1974,7 @@ void frEndSession(bool hidetargets)
}
// Remove smoke
for (i = 0; i < g_NumSmokes; i++) {
for (i = 0; i < g_MaxSmokes; i++) {
g_Smokes[i].age = 256;
for (j = 0; j < 10; j++) {

View File

@ -14944,7 +14944,7 @@ s32 g_MaxExplosions = 0;
u32 var800a3438 = 0;
u32 var800a343c = 0;
struct smoke *g_Smokes = NULL;
s32 g_NumSmokes = 0;
s32 g_MaxSmokes = 0;
u32 var800a3448 = 0;
u32 var800a344c = 0;
u32 var800a3450 = 0;

View File

@ -664,7 +664,7 @@ extern u32 var800a3420;
extern struct explosion *g_Explosions;
extern s32 g_MaxExplosions;
extern struct smoke *g_Smokes;
extern s32 g_NumSmokes;
extern s32 g_MaxSmokes;
extern u32 var800a3448;
extern u32 var800a3488;
extern struct spark g_Sparks[100];