From 8cba85d48e5b473f24324452d925debfe521dbe1 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 2 Jun 2021 19:26:02 +1000 Subject: [PATCH] Decompile propsTickPadEffects --- src/files/setup/setupsho.c | 24 +-- src/game/game_00c490.c | 10 +- src/game/lv.c | 6 +- src/game/prop.c | 341 ++++++++----------------------- src/game/propobj.c | 4 +- src/game/smoke/smoke.c | 26 +-- src/include/constants.h | 12 +- src/include/data.h | 4 +- src/include/game/prop.h | 2 +- src/include/game/smoke/smoke.h | 4 +- src/include/game/sparks/sparks.h | 2 +- src/include/types.h | 6 +- 12 files changed, 131 insertions(+), 310 deletions(-) diff --git a/src/files/setup/setupsho.c b/src/files/setup/setupsho.c index d073ccd5d..3b2d33986 100644 --- a/src/files/setup/setupsho.c +++ b/src/files/setup/setupsho.c @@ -456,18 +456,18 @@ u32 props[] = { pad_effect(PADEFFECT_SPARKS, 0x0123) pad_effect(PADEFFECT_SPARKS, 0x0124) pad_effect(PADEFFECT_SPARKS, 0x0125) - pad_effect(PADEFFECT_SMOKE_TEMPORARY, 0x0025) - pad_effect(PADEFFECT_SMOKE_TEMPORARY, 0x008c) - pad_effect(PADEFFECT_SMOKE_TEMPORARY, 0x0028) - pad_effect(PADEFFECT_SMOKE_TEMPORARY, 0x0029) - pad_effect(PADEFFECT_SMOKE_TEMPORARY, 0x002a) - pad_effect(PADEFFECT_SMOKE_TEMPORARY, 0x0023) - pad_effect(PADEFFECT_SMOKE_TEMPORARY, 0x0027) - pad_effect(PADEFFECT_SMOKE_TEMPORARY, 0x0026) - pad_effect(PADEFFECT_SMOKE_TEMPORARY, 0x0006) - pad_effect(PADEFFECT_SMOKE_TEMPORARY, 0x00d9) - pad_effect(PADEFFECT_SMOKE_TEMPORARY, 0x00a3) - pad_effect(PADEFFECT_SMOKE_TEMPORARY, 0x000c) + pad_effect(PADEFFECT_OUTROSMOKE, 0x0025) + pad_effect(PADEFFECT_OUTROSMOKE, 0x008c) + pad_effect(PADEFFECT_OUTROSMOKE, 0x0028) + pad_effect(PADEFFECT_OUTROSMOKE, 0x0029) + pad_effect(PADEFFECT_OUTROSMOKE, 0x002a) + pad_effect(PADEFFECT_OUTROSMOKE, 0x0023) + pad_effect(PADEFFECT_OUTROSMOKE, 0x0027) + pad_effect(PADEFFECT_OUTROSMOKE, 0x0026) + pad_effect(PADEFFECT_OUTROSMOKE, 0x0006) + pad_effect(PADEFFECT_OUTROSMOKE, 0x00d9) + pad_effect(PADEFFECT_OUTROSMOKE, 0x00a3) + pad_effect(PADEFFECT_OUTROSMOKE, 0x000c) endprops }; diff --git a/src/game/game_00c490.c b/src/game/game_00c490.c index f3027fda9..3fd21c353 100644 --- a/src/game/game_00c490.c +++ b/src/game/game_00c490.c @@ -2710,8 +2710,8 @@ void setupLoadFiles(s32 stagenum) u16 filenum; bool modified; - var80069960 = 0; - var80069964 = 0xffffffff; + g_PadEffects = NULL; + g_LastPadEffectIndex = -1; g_DoorScale = 1; @@ -3426,10 +3426,10 @@ void setupParseObjects(s32 stagenum) case OBJTYPE_PADEFFECT: { struct padeffectobj *padeffect = (struct padeffectobj *)obj; - if (var80069964 == -1) { - var80069960 = padeffect; + if (g_LastPadEffectIndex == -1) { + g_PadEffects = padeffect; } - var80069964++; + g_LastPadEffectIndex++; } break; case OBJTYPE_MINE: diff --git a/src/game/lv.c b/src/game/lv.c index f43d3853d..f1a923919 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -8144,7 +8144,7 @@ glabel var7f1b8ed0pf /* f16d890: 00000000 */ nop /* f16d894: 0fc0764c */ jal func0f01d860 /* f16d898: 00000000 */ nop -/* f16d89c: 0fc19017 */ jal func0f063dcc +/* f16d89c: 0fc19017 */ jal propsTickPadEffects /* f16d8a0: 00000000 */ nop /* f16d8a4: 0c0039b9 */ jal mainGetStageNum /* f16d8a8: 00000000 */ nop @@ -8520,7 +8520,7 @@ void lvTick(void) func00011d84(); func0f01d860(); - func0f063dcc(); + propsTickPadEffects(); if (mainGetStageNum() == STAGE_CITRAINING) { struct trainingdata *trainingdata = dtGetData(); @@ -9744,7 +9744,7 @@ glabel lvTick /* f1677fc: 00000000 */ sll $zero,$zero,0x0 /* f167800: 0fc07550 */ jal func0f01d860 /* f167804: 00000000 */ sll $zero,$zero,0x0 -/* f167808: 0fc18c10 */ jal func0f063dcc +/* f167808: 0fc18c10 */ jal propsTickPadEffects /* f16780c: 00000000 */ sll $zero,$zero,0x0 /* f167810: 0c003c59 */ jal mainGetStageNum /* f167814: 00000000 */ sll $zero,$zero,0x0 diff --git a/src/game/prop.c b/src/game/prop.c index bcf7e6a7b..48d376d6f 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -6384,267 +6384,86 @@ glabel propsTick // func0f02472c(); //} -GLOBAL_ASM( -glabel func0f063dcc -.late_rodata -glabel var7f1a9f18 -.word func0f063dcc+0xa8 # f063e74 -glabel var7f1a9f1c -.word func0f063dcc+0x364 # f064130 -glabel var7f1a9f20 -.word func0f063dcc+0x2fc # f0640c8 -glabel var7f1a9f24 -.word func0f063dcc+0xa8 # f063e74 -glabel var7f1a9f28 -.word func0f063dcc+0x2fc # f0640c8 -glabel var7f1a9f2c -.word func0f063dcc+0x2d4 # f0640a0 -.text -/* f063dcc: 27bdff08 */ addiu $sp,$sp,-248 -/* f063dd0: 3c028007 */ lui $v0,%hi(var80069964) -/* f063dd4: 8c429964 */ lw $v0,%lo(var80069964)($v0) -/* f063dd8: afbf006c */ sw $ra,0x6c($sp) -/* f063ddc: afb60068 */ sw $s6,0x68($sp) -/* f063de0: afb50064 */ sw $s5,0x64($sp) -/* f063de4: afb40060 */ sw $s4,0x60($sp) -/* f063de8: afb3005c */ sw $s3,0x5c($sp) -/* f063dec: afb20058 */ sw $s2,0x58($sp) -/* f063df0: afb10054 */ sw $s1,0x54($sp) -/* f063df4: afb00050 */ sw $s0,0x50($sp) -/* f063df8: 044000d4 */ bltz $v0,.L0f06414c -/* f063dfc: f7b40048 */ sdc1 $f20,0x48($sp) -/* f063e00: 044000d2 */ bltz $v0,.L0f06414c -/* f063e04: 0000b025 */ or $s6,$zero,$zero -/* f063e08: 3c01bf80 */ lui $at,0xbf80 -/* f063e0c: 4481a000 */ mtc1 $at,$f20 -/* f063e10: 0000a025 */ or $s4,$zero,$zero -/* f063e14: 27b5008c */ addiu $s5,$sp,0x8c -/* f063e18: 27b300b8 */ addiu $s3,$sp,0xb8 -/* f063e1c: 27b20090 */ addiu $s2,$sp,0x90 -/* f063e20: 27b100a0 */ addiu $s1,$sp,0xa0 -.L0f063e24: -/* f063e24: 3c0e8007 */ lui $t6,%hi(var80069960) -/* f063e28: 8dce9960 */ lw $t6,%lo(var80069960)($t6) -/* f063e2c: 24050040 */ addiu $a1,$zero,0x40 -/* f063e30: 02203025 */ or $a2,$s1,$zero -/* f063e34: 028e8021 */ addu $s0,$s4,$t6 -/* f063e38: 0fc456ac */ jal padUnpack -/* f063e3c: 8e040008 */ lw $a0,0x8($s0) -/* f063e40: 0fc575ba */ jal roomIsVisibleByAnyPlayer -/* f063e44: 8fa400e8 */ lw $a0,0xe8($sp) -/* f063e48: 104000b9 */ beqz $v0,.L0f064130 -/* f063e4c: 00000000 */ nop -/* f063e50: 8e020004 */ lw $v0,0x4($s0) -/* f063e54: 2c410006 */ sltiu $at,$v0,0x6 -/* f063e58: 102000b5 */ beqz $at,.L0f064130 -/* f063e5c: 00027880 */ sll $t7,$v0,0x2 -/* f063e60: 3c017f1b */ lui $at,%hi(var7f1a9f18) -/* f063e64: 002f0821 */ addu $at,$at,$t7 -/* f063e68: 8c2f9f18 */ lw $t7,%lo(var7f1a9f18)($at) -/* f063e6c: 01e00008 */ jr $t7 -/* f063e70: 00000000 */ nop -/* f063e74: 8fb800e8 */ lw $t8,0xe8($sp) -/* f063e78: 2419ffff */ addiu $t9,$zero,-1 -/* f063e7c: a7b9008e */ sh $t9,0x8e($sp) -/* f063e80: a7b8008c */ sh $t8,0x8c($sp) -/* f063e84: 8e040008 */ lw $a0,0x8($s0) -/* f063e88: 2405000a */ addiu $a1,$zero,0xa -/* f063e8c: 0fc456ac */ jal padUnpack -/* f063e90: 02203025 */ or $a2,$s1,$zero -/* f063e94: c7a400b8 */ lwc1 $f4,0xb8($sp) -/* f063e98: c7a800bc */ lwc1 $f8,0xbc($sp) -/* f063e9c: c7b000c0 */ lwc1 $f16,0xc0($sp) -/* f063ea0: 46002187 */ neg.s $f6,$f4 -/* f063ea4: 46004287 */ neg.s $f10,$f8 -/* f063ea8: 46008487 */ neg.s $f18,$f16 -/* f063eac: e7a60090 */ swc1 $f6,0x90($sp) -/* f063eb0: e7aa0094 */ swc1 $f10,0x94($sp) -/* f063eb4: 0c004b70 */ jal random -/* f063eb8: e7b20098 */ swc1 $f18,0x98($sp) -/* f063ebc: 304907ff */ andi $t1,$v0,0x7ff -/* f063ec0: 2d210033 */ sltiu $at,$t1,0x33 -/* f063ec4: 1020001e */ beqz $at,.L0f063f40 -/* f063ec8: 87a4008c */ lh $a0,0x8c($sp) -/* f063ecc: 240a0009 */ addiu $t2,$zero,0x9 -/* f063ed0: afaa0014 */ sw $t2,0x14($sp) -/* f063ed4: 00002825 */ or $a1,$zero,$zero -/* f063ed8: 02203025 */ or $a2,$s1,$zero -/* f063edc: 02403825 */ or $a3,$s2,$zero -/* f063ee0: 0fc4be7c */ jal sparksCreate -/* f063ee4: afb30010 */ sw $s3,0x10($sp) -/* f063ee8: 0fc25480 */ jal func0f095200 -/* f063eec: 00000000 */ nop -/* f063ef0: 00023400 */ sll $a2,$v0,0x10 -/* f063ef4: 00065c03 */ sra $t3,$a2,0x10 -/* f063ef8: 240cffff */ addiu $t4,$zero,-1 -/* f063efc: 240dffff */ addiu $t5,$zero,-1 -/* f063f00: afad002c */ sw $t5,0x2c($sp) -/* f063f04: afac0010 */ sw $t4,0x10($sp) -/* f063f08: 01603025 */ or $a2,$t3,$zero -/* f063f0c: 00002025 */ or $a0,$zero,$zero -/* f063f10: 00002825 */ or $a1,$zero,$zero -/* f063f14: 2407ffff */ addiu $a3,$zero,-1 -/* f063f18: afa00014 */ sw $zero,0x14($sp) -/* f063f1c: afa00018 */ sw $zero,0x18($sp) -/* f063f20: afa0001c */ sw $zero,0x1c($sp) -/* f063f24: afb10020 */ sw $s1,0x20($sp) -/* f063f28: e7b40024 */ swc1 $f20,0x24($sp) -/* f063f2c: afb50028 */ sw $s5,0x28($sp) -/* f063f30: e7b40030 */ swc1 $f20,0x30($sp) -/* f063f34: e7b40034 */ swc1 $f20,0x34($sp) -/* f063f38: 0fc24e7e */ jal func0f0939f8 -/* f063f3c: e7b40038 */ swc1 $f20,0x38($sp) -.L0f063f40: -/* f063f40: 0c004b70 */ jal random -/* f063f44: 00000000 */ nop -/* f063f48: 304e07ff */ andi $t6,$v0,0x7ff -/* f063f4c: 2dc10010 */ sltiu $at,$t6,0x10 -/* f063f50: 10200026 */ beqz $at,.L0f063fec -/* f063f54: 87a4008c */ lh $a0,0x8c($sp) -/* f063f58: 240f0009 */ addiu $t7,$zero,0x9 -/* f063f5c: afaf0014 */ sw $t7,0x14($sp) -/* f063f60: 00002825 */ or $a1,$zero,$zero -/* f063f64: 02203025 */ or $a2,$s1,$zero -/* f063f68: 02403825 */ or $a3,$s2,$zero -/* f063f6c: 0fc4be7c */ jal sparksCreate -/* f063f70: afb30010 */ sw $s3,0x10($sp) -/* f063f74: 2418000a */ addiu $t8,$zero,0xa -/* f063f78: afb80014 */ sw $t8,0x14($sp) -/* f063f7c: 87a4008c */ lh $a0,0x8c($sp) -/* f063f80: 00002825 */ or $a1,$zero,$zero -/* f063f84: 02203025 */ or $a2,$s1,$zero -/* f063f88: 02403825 */ or $a3,$s2,$zero -/* f063f8c: 0fc4be7c */ jal sparksCreate -/* f063f90: afb30010 */ sw $s3,0x10($sp) -/* f063f94: 0fc25480 */ jal func0f095200 -/* f063f98: 00000000 */ nop -/* f063f9c: 00023400 */ sll $a2,$v0,0x10 -/* f063fa0: 0006cc03 */ sra $t9,$a2,0x10 -/* f063fa4: 2409ffff */ addiu $t1,$zero,-1 -/* f063fa8: 240affff */ addiu $t2,$zero,-1 -/* f063fac: afaa002c */ sw $t2,0x2c($sp) -/* f063fb0: afa90010 */ sw $t1,0x10($sp) -/* f063fb4: 03203025 */ or $a2,$t9,$zero -/* f063fb8: 00002025 */ or $a0,$zero,$zero -/* f063fbc: 00002825 */ or $a1,$zero,$zero -/* f063fc0: 2407ffff */ addiu $a3,$zero,-1 -/* f063fc4: afa00014 */ sw $zero,0x14($sp) -/* f063fc8: afa00018 */ sw $zero,0x18($sp) -/* f063fcc: afa0001c */ sw $zero,0x1c($sp) -/* f063fd0: afb10020 */ sw $s1,0x20($sp) -/* f063fd4: e7b40024 */ swc1 $f20,0x24($sp) -/* f063fd8: afb50028 */ sw $s5,0x28($sp) -/* f063fdc: e7b40030 */ swc1 $f20,0x30($sp) -/* f063fe0: e7b40034 */ swc1 $f20,0x34($sp) -/* f063fe4: 0fc24e7e */ jal func0f0939f8 -/* f063fe8: e7b40038 */ swc1 $f20,0x38($sp) -.L0f063fec: -/* f063fec: 0c004b70 */ jal random -/* f063ff0: 00000000 */ nop -/* f063ff4: 304b07ff */ andi $t3,$v0,0x7ff -/* f063ff8: 2d610006 */ sltiu $at,$t3,0x6 -/* f063ffc: 1020004c */ beqz $at,.L0f064130 -/* f064000: 87a4008c */ lh $a0,0x8c($sp) -/* f064004: 240c0009 */ addiu $t4,$zero,0x9 -/* f064008: afac0014 */ sw $t4,0x14($sp) -/* f06400c: 00002825 */ or $a1,$zero,$zero -/* f064010: 02203025 */ or $a2,$s1,$zero -/* f064014: 02403825 */ or $a3,$s2,$zero -/* f064018: 0fc4be7c */ jal sparksCreate -/* f06401c: afb30010 */ sw $s3,0x10($sp) -/* f064020: 240d000b */ addiu $t5,$zero,0xb -/* f064024: afad0014 */ sw $t5,0x14($sp) -/* f064028: 87a4008c */ lh $a0,0x8c($sp) -/* f06402c: 00002825 */ or $a1,$zero,$zero -/* f064030: 02203025 */ or $a2,$s1,$zero -/* f064034: 02403825 */ or $a3,$s2,$zero -/* f064038: 0fc4be7c */ jal sparksCreate -/* f06403c: afb30010 */ sw $s3,0x10($sp) -/* f064040: 0fc25480 */ jal func0f095200 -/* f064044: 00000000 */ nop -/* f064048: 00023400 */ sll $a2,$v0,0x10 -/* f06404c: 00067403 */ sra $t6,$a2,0x10 -/* f064050: 240fffff */ addiu $t7,$zero,-1 -/* f064054: 2418ffff */ addiu $t8,$zero,-1 -/* f064058: afb8002c */ sw $t8,0x2c($sp) -/* f06405c: afaf0010 */ sw $t7,0x10($sp) -/* f064060: 01c03025 */ or $a2,$t6,$zero -/* f064064: 00002025 */ or $a0,$zero,$zero -/* f064068: 00002825 */ or $a1,$zero,$zero -/* f06406c: 2407ffff */ addiu $a3,$zero,-1 -/* f064070: afa00014 */ sw $zero,0x14($sp) -/* f064074: afa00018 */ sw $zero,0x18($sp) -/* f064078: afa0001c */ sw $zero,0x1c($sp) -/* f06407c: afb10020 */ sw $s1,0x20($sp) -/* f064080: e7b40024 */ swc1 $f20,0x24($sp) -/* f064084: afb50028 */ sw $s5,0x28($sp) -/* f064088: e7b40030 */ swc1 $f20,0x30($sp) -/* f06408c: e7b40034 */ swc1 $f20,0x34($sp) -/* f064090: 0fc24e7e */ jal func0f0939f8 -/* f064094: e7b40038 */ swc1 $f20,0x38($sp) -/* f064098: 10000025 */ b .L0f064130 -/* f06409c: 00000000 */ nop -/* f0640a0: 3c19800a */ lui $t9,%hi(g_Vars+0x2ac) -/* f0640a4: 8f39a26c */ lw $t9,%lo(g_Vars+0x2ac)($t9) -/* f0640a8: 24010006 */ addiu $at,$zero,0x6 -/* f0640ac: 57210028 */ bnel $t9,$at,.L0f064150 -/* f0640b0: 8fbf006c */ lw $ra,0x6c($sp) -/* f0640b4: 0fc256d9 */ jal objectiveIsAllComplete -/* f0640b8: 00000000 */ nop -/* f0640bc: 50400024 */ beqzl $v0,.L0f064150 -/* f0640c0: 8fbf006c */ lw $ra,0x6c($sp) -/* f0640c4: 8e020004 */ lw $v0,0x4($s0) -/* f0640c8: 24010002 */ addiu $at,$zero,0x2 -/* f0640cc: 10410007 */ beq $v0,$at,.L0f0640ec -/* f0640d0: 24080014 */ addiu $t0,$zero,0x14 -/* f0640d4: 24010004 */ addiu $at,$zero,0x4 -/* f0640d8: 10410003 */ beq $v0,$at,.L0f0640e8 -/* f0640dc: 24010005 */ addiu $at,$zero,0x5 -/* f0640e0: 54410003 */ bnel $v0,$at,.L0f0640f0 -/* f0640e4: 8fa900e8 */ lw $t1,0xe8($sp) -.L0f0640e8: -/* f0640e8: 24080015 */ addiu $t0,$zero,0x15 -.L0f0640ec: -/* f0640ec: 8fa900e8 */ lw $t1,0xe8($sp) -.L0f0640f0: -/* f0640f0: 240affff */ addiu $t2,$zero,-1 -/* f0640f4: a7aa008a */ sh $t2,0x8a($sp) -/* f0640f8: a7a90088 */ sh $t1,0x88($sp) -/* f0640fc: 8e040008 */ lw $a0,0x8($s0) -/* f064100: afa80084 */ sw $t0,0x84($sp) -/* f064104: 2405000a */ addiu $a1,$zero,0xa -/* f064108: 0fc456ac */ jal padUnpack -/* f06410c: 02203025 */ or $a2,$s1,$zero -/* f064110: 8fa80084 */ lw $t0,0x84($sp) -/* f064114: 02002025 */ or $a0,$s0,$zero -/* f064118: 02202825 */ or $a1,$s1,$zero -/* f06411c: 00083c00 */ sll $a3,$t0,0x10 -/* f064120: 00075c03 */ sra $t3,$a3,0x10 -/* f064124: 01603825 */ or $a3,$t3,$zero -/* f064128: 0fc4b9d3 */ jal func0f12e74c -/* f06412c: 27a60088 */ addiu $a2,$sp,0x88 -.L0f064130: -/* f064130: 3c0c8007 */ lui $t4,%hi(var80069964) -/* f064134: 8d8c9964 */ lw $t4,%lo(var80069964)($t4) -/* f064138: 26d60001 */ addiu $s6,$s6,0x1 -/* f06413c: 2694000c */ addiu $s4,$s4,0xc -/* f064140: 0196082a */ slt $at,$t4,$s6 -/* f064144: 1020ff37 */ beqz $at,.L0f063e24 -/* f064148: 00000000 */ nop -.L0f06414c: -/* f06414c: 8fbf006c */ lw $ra,0x6c($sp) -.L0f064150: -/* f064150: d7b40048 */ ldc1 $f20,0x48($sp) -/* f064154: 8fb00050 */ lw $s0,0x50($sp) -/* f064158: 8fb10054 */ lw $s1,0x54($sp) -/* f06415c: 8fb20058 */ lw $s2,0x58($sp) -/* f064160: 8fb3005c */ lw $s3,0x5c($sp) -/* f064164: 8fb40060 */ lw $s4,0x60($sp) -/* f064168: 8fb50064 */ lw $s5,0x64($sp) -/* f06416c: 8fb60068 */ lw $s6,0x68($sp) -/* f064170: 03e00008 */ jr $ra -/* f064174: 27bd00f8 */ addiu $sp,$sp,0xf8 -); +void propsTickPadEffects(void) +{ + s32 i; + struct pad pad; + u32 stack; + struct coord up; + s16 rooms[2]; + s16 rooms2[2]; + s32 type; + + if (g_LastPadEffectIndex >= 0) { + for (i = 0; i <= g_LastPadEffectIndex; i++) { + struct padeffectobj *effect = &g_PadEffects[i]; + + padUnpack(effect->pad, PADFIELD_ROOM, &pad); + + if (roomIsVisibleByAnyPlayer(pad.room)) { + switch (effect->effect) { + case PADEFFECT_SPARKS: + case PADEFFECT_SPARKS2: + rooms[0] = pad.room; + rooms[1] = -1; + + padUnpack(effect->pad, PADFIELD_POS | PADFIELD_UP, &pad); + + up.x = -pad.up.x; + up.y = -pad.up.y; + up.z = -pad.up.z; + + if ((random() % 2048) <= 50) { + sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, 9); + func0f0939f8(NULL, NULL, func0f095200(), -1, -1, 0, 0, 0, &pad.pos, -1, rooms, -1, -1, -1, -1); + } + + if ((random() % 2048) <= 15) { + sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, 9); + sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, 10); + func0f0939f8(NULL, NULL, func0f095200(), -1, -1, 0, 0, 0, &pad.pos, -1, rooms, -1, -1, -1, -1); + } + + if ((random() % 2048) <= 5) { + sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, 9); + sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, 11); + func0f0939f8(NULL, NULL, func0f095200(), -1, -1, 0, 0, 0, &pad.pos, -1, rooms, -1, -1, -1, -1); + } + break; + case PADEFFECT_OUTROSMOKE: + if (g_Vars.tickmode != TICKMODE_CUTSCENE || !objectiveIsAllComplete()) { + // @bug: This should be a break rather than a return. + // Because of this, subsequent pad effects won't tick. + return; + } + // fall-through + case PADEFFECT_SPLASH: + case PADEFFECT_SMOKE: + type = SMOKETYPE_WATER; + + switch (effect->effect) { + case PADEFFECT_SPLASH: + type = SMOKETYPE_WATER; + break; + case PADEFFECT_SMOKE: + case PADEFFECT_OUTROSMOKE: + type = SMOKETYPE_DEBRIS; + break; + } + + rooms2[0] = pad.room; + rooms2[1] = -1; + + padUnpack(effect->pad, PADFIELD_POS | PADFIELD_UP, &pad); + smokeCreateAtPadEffect(effect, &pad.pos, rooms2, type); + break; + case PADEFFECT_01: + break; + } + } + } + } +} void propSetCollisionsEnabled(struct prop *prop, s32 enable) { diff --git a/src/game/propobj.c b/src/game/propobj.c index e6a3ce6ac..e866c0443 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -154,8 +154,8 @@ f32 var80069950 = 1; f32 var80069954 = 1; f32 var80069958 = 1; f32 g_AmmoMultiplier = 1; -struct padeffectobj *var80069960 = NULL; -s32 var80069964 = -1; +struct padeffectobj *g_PadEffects = NULL; +s32 g_LastPadEffectIndex = -1; struct autogunobj *g_ThrownLaptops = NULL; struct beam *g_ThrownLaptopBeams = NULL; s32 g_MaxThrownLaptops = 0; diff --git a/src/game/smoke/smoke.c b/src/game/smoke/smoke.c index 3fcce3ee9..dfe4fd3f7 100644 --- a/src/game/smoke/smoke.c +++ b/src/game/smoke/smoke.c @@ -1276,14 +1276,14 @@ glabel smokeCreate // smoke->prop = prop; // smoke->age = 0; // smoke->type = type; -// smoke->srcprop = NULL; +// smoke->source = NULL; // } // } // // return smoke; //} -bool func0f12e454(struct coord *pos, s16 *rooms, s16 type, u32 arg4) +bool func0f12e454(struct coord *pos, s16 *rooms, s16 type, u32 srcispadeffect) { struct smoke *smoke; s32 i; @@ -1291,7 +1291,7 @@ bool func0f12e454(struct coord *pos, s16 *rooms, s16 type, u32 arg4) for (i = 0; i < g_MaxSmokes; i++) { if (g_Smokes[i].prop - && g_Smokes[i].unk06_07 == arg4 + && g_Smokes[i].srcispadeffect == srcispadeffect && g_Smokes[i].type >= SMOKETYPE_MUZZLE_PISTOL && g_Smokes[i].type <= SMOKETYPE_MUZZLE_REAPER) { bool fail = false; @@ -1313,7 +1313,7 @@ bool func0f12e454(struct coord *pos, s16 *rooms, s16 type, u32 arg4) smoke = smokeCreate(pos, rooms, type); if (smoke) { - smoke->unk06_07 = arg4; + smoke->srcispadeffect = srcispadeffect; return true; } @@ -1325,7 +1325,7 @@ bool func0f12e454(struct coord *pos, s16 *rooms, s16 type, u32 arg4) * smoke parts have a size of zero. Perhaps the caller is supposed to check if * this function returns false and reuse the zero-sized smoke parts if so? */ -bool smokeCreateAtPropIfNecessary(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, u32 arg4) +bool smokeCreateWithSource(void *source, struct coord *pos, s16 *rooms, s16 type, bool srcispadeffect) { struct smoke *smoke; s32 i; @@ -1338,7 +1338,7 @@ bool smokeCreateAtPropIfNecessary(struct prop *prop, struct coord *pos, s16 *roo if (checksmokes) { for (i = 0; i < g_MaxSmokes; i++) { - if (g_Smokes[i].prop && g_Smokes[i].srcprop == prop) { + if (g_Smokes[i].prop && g_Smokes[i].source == source) { bool fail = false; if (g_Smokes[i].age < g_SmokeTypes[g_Smokes[i].type].duration) { @@ -1359,8 +1359,8 @@ bool smokeCreateAtPropIfNecessary(struct prop *prop, struct coord *pos, s16 *roo smoke = smokeCreate(pos, rooms, type); if (smoke) { - smoke->srcprop = prop; - smoke->unk06_07 = arg4; + smoke->source = source; + smoke->srcispadeffect = srcispadeffect; return true; } @@ -1369,12 +1369,12 @@ bool smokeCreateAtPropIfNecessary(struct prop *prop, struct coord *pos, s16 *roo void smokeCreateAtProp(struct prop *prop, s16 type) { - smokeCreateAtPropIfNecessary(prop, &prop->pos, prop->rooms, type, false); + smokeCreateWithSource(prop, &prop->pos, prop->rooms, type, false); } -void func0f12e74c(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, u32 arg4) +void smokeCreateAtPadEffect(struct padeffectobj *effect, struct coord *pos, s16 *rooms, s16 type) { - smokeCreateAtPropIfNecessary(prop, pos, rooms, type, true); + smokeCreateWithSource(effect, pos, rooms, type, true); } void smokeClearForProp(struct prop *prop) @@ -1382,9 +1382,9 @@ void smokeClearForProp(struct prop *prop) s32 i; for (i = 0; i < g_MaxSmokes; i++) { - if (g_Smokes[i].prop && g_Smokes[i].srcprop == prop && g_Smokes[i].unk06_07 == false) { + if (g_Smokes[i].prop && g_Smokes[i].source == prop && g_Smokes[i].srcispadeffect == false) { g_Smokes[i].age = g_SmokeTypes[g_Smokes[i].type].duration; - g_Smokes[i].srcprop = NULL; + g_Smokes[i].source = NULL; } } } diff --git a/src/include/constants.h b/src/include/constants.h index 919e384ba..0c1103546 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -3090,12 +3090,12 @@ #define PAD_PRESET 9000 -#define PADEFFECT_SPARKS 0x00 -#define PADEFFECT_01 0x01 // used only in Escape on a pad containing nothing -#define PADEFFECT_SPLASH 0x02 -#define PADEFFECT_SPARKS2 0x03 -#define PADEFFECT_SMOKE 0x04 -#define PADEFFECT_SMOKE_TEMPORARY 0x05 +#define PADEFFECT_SPARKS 0 +#define PADEFFECT_01 1 // Unimplemented +#define PADEFFECT_SPLASH 2 +#define PADEFFECT_SPARKS2 3 // Same as PADEFFECT_SPARKS +#define PADEFFECT_SMOKE 4 +#define PADEFFECT_OUTROSMOKE 5 // Like smoke, but only shows in cutscenes and only if all objectives are complete #define PADFIELD_POS 0x0002 #define PADFIELD_LOOK 0x0004 diff --git a/src/include/data.h b/src/include/data.h index 5052812c1..d489217c5 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -251,8 +251,8 @@ extern f32 var80069950; extern f32 var80069954; extern f32 var80069958; extern f32 g_AmmoMultiplier; -extern struct padeffectobj *var80069960; -extern s32 var80069964; +extern struct padeffectobj *g_PadEffects; +extern s32 g_LastPadEffectIndex; extern struct autogunobj *g_ThrownLaptops; extern struct beam *g_ThrownLaptopBeams; extern s32 g_MaxThrownLaptops; diff --git a/src/include/game/prop.h b/src/include/game/prop.h index e066d5685..7a95df7ca 100644 --- a/src/include/game/prop.h +++ b/src/include/game/prop.h @@ -34,7 +34,7 @@ bool currentPlayerInteract(bool eyespy); void propPause(struct prop *prop); void propUnpause(struct prop *prop); void propsTick(u32 islastplayer); -void func0f063dcc(void); +void propsTickPadEffects(void); void propSetCollisionsEnabled(struct prop *prop, bool enable); void func0f0641f4(void); f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f32 *arg4, s32 arg5, bool cangangsta, s32 arg7); diff --git a/src/include/game/smoke/smoke.h b/src/include/game/smoke/smoke.h index c48c4fe56..6c3b7dd4e 100644 --- a/src/include/game/smoke/smoke.h +++ b/src/include/game/smoke/smoke.h @@ -7,9 +7,9 @@ Gfx *smokeRenderPart(struct smoke *smoke, struct smokepart *part, Gfx *gdl, struct coord *coord, f32 size); struct smoke *smokeCreate(struct coord *pos, s16 *rooms, s16 type); bool func0f12e454(struct coord *pos, s16 *rooms, s16 type, u32 arg4); -bool smokeCreateAtPropIfNecessary(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, u32 arg4); +bool smokeCreateWithSource(void *source, struct coord *pos, s16 *rooms, s16 type, bool srcispadeffect); void smokeCreateAtProp(struct prop *prop, s16 type); -void func0f12e74c(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, u32 arg4); +void smokeCreateAtPadEffect(struct padeffectobj *effect, struct coord *pos, s16 *rooms, s16 type); void smokeClearForProp(struct prop *prop); struct smoke *smokeCreateSimple(struct coord *pos, s16 *rooms, s16 type); u32 func0f12e848(struct prop *prop); diff --git a/src/include/game/sparks/sparks.h b/src/include/game/sparks/sparks.h index 5a4f92e61..7929c1ba0 100644 --- a/src/include/game/sparks/sparks.h +++ b/src/include/game/sparks/sparks.h @@ -6,7 +6,7 @@ u32 func0f12f6c0(void); void sparkgroupEnsureFreeSparkSlot(struct sparkgroup *group); -void sparksCreate(s32 room, struct prop *prop, struct coord *pos, struct coord *arg3, s32 arg4, s32 arg5); +void sparksCreate(s32 room, struct prop *prop, struct coord *pos, struct coord *arg3, struct coord *dir, s32 arg5); Gfx *sparksRender(Gfx *gdl); #endif diff --git a/src/include/types.h b/src/include/types.h index e71385e63..e98f06ef6 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -2004,6 +2004,8 @@ struct hovercarobj { // objtype 0x37 struct padeffectobj { // objtype 0x38 u32 unk00; + s32 effect; + s32 pad; }; struct chopperobj { // objtype 0x39 @@ -4930,10 +4932,10 @@ struct smoke { /*0x000*/ struct prop *prop; // Prop of the smoke itself /*0x004*/ s16 age; /*0x006*/ u16 type : 7; - /*0x006*/ u16 unk06_07 : 1; + /*0x006*/ u16 srcispadeffect : 1; /*0x007*/ u16 unk06_08 : 8; /*0x008*/ struct smokepart parts[10]; - /*0x198*/ struct prop *srcprop; // Prop of the thing generating smoke + /*0x198*/ void *source; // The thing generating smoke. Can be prop or padeffect }; struct textoverride {