From 5d4decdba0cf8503fd813e9f300e3f448ed4b94b Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 1 Jun 2021 17:32:00 +1000 Subject: [PATCH] Attempt to decompile propsTick --- src/game/bondmove.c | 10 +- src/game/chr/chr.c | 24 +- src/game/chr/chraction.c | 6 +- src/game/chr/chraicommands.c | 4 +- src/game/explosions/explosions.c | 6 +- src/game/game_00c240.c | 14 +- src/game/game_00c490.c | 2 +- src/game/game_0b69d0.c | 22 +- src/game/game_190260.c | 14 +- src/game/hudmsg.c | 18 +- src/game/lv.c | 14 +- src/game/mplayer/ingame.c | 2 +- src/game/mplayer/mplayer.c | 8 +- src/game/mplayer/scenarios.c | 2 +- src/game/prop.c | 711 +++++++++++++++++++++-- src/game/propobj.c | 22 +- src/game/smoke/smoke.c | 4 +- src/include/constants.h | 9 +- src/include/data.h | 2 +- src/include/game/chr/chr.h | 6 +- src/include/game/explosions/explosions.h | 2 +- src/include/game/game_0b69d0.h | 4 +- src/include/game/game_190260.h | 2 +- src/include/game/prop.h | 4 +- src/include/game/propobj.h | 2 +- src/include/game/smoke/smoke.h | 2 +- src/include/types.h | 32 +- src/lib/main.c | 8 +- 28 files changed, 776 insertions(+), 180 deletions(-) diff --git a/src/game/bondmove.c b/src/game/bondmove.c index deb4a81bc..4fda24779 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -3338,8 +3338,8 @@ glabel var7f1ad8e4 .L0f0caa4c: /* f0caa4c: 8f281a24 */ lw $t0,0x1a24($t9) /* f0caa50: 150000b5 */ bnez $t0,.L0f0cad28 -/* f0caa54: 3c098006 */ lui $t1,%hi(var8005d9d0) -/* f0caa58: 8d29d9d0 */ lw $t1,%lo(var8005d9d0)($t1) +/* f0caa54: 3c098006 */ lui $t1,%hi(g_MainIsEndscreen) +/* f0caa58: 8d29d9d0 */ lw $t1,%lo(g_MainIsEndscreen)($t1) /* f0caa5c: 3c014270 */ lui $at,0x4270 /* f0caa60: 152000b1 */ bnez $t1,.L0f0cad28 /* f0caa64: 00000000 */ nop @@ -6489,8 +6489,8 @@ glabel var7f1ad8e4 .L0f0caa4c: /* f0caa4c: 8f281a24 */ lw $t0,0x1a24($t9) /* f0caa50: 150000b5 */ bnez $t0,.L0f0cad28 -/* f0caa54: 3c098006 */ lui $t1,%hi(var8005d9d0) -/* f0caa58: 8d29d9d0 */ lw $t1,%lo(var8005d9d0)($t1) +/* f0caa54: 3c098006 */ lui $t1,%hi(g_MainIsEndscreen) +/* f0caa58: 8d29d9d0 */ lw $t1,%lo(g_MainIsEndscreen)($t1) /* f0caa5c: 3c014270 */ lui $at,0x4270 /* f0caa60: 152000b1 */ bnez $t1,.L0f0cad28 /* f0caa64: 00000000 */ nop @@ -11535,7 +11535,7 @@ glabel var7f1ad8e4 // } // // // aa48 -// if (g_Vars.currentplayer->pausemode == PAUSEMODE_UNPAUSED && var8005d9d0 == 0) { +// if (g_Vars.currentplayer->pausemode == PAUSEMODE_UNPAUSED && g_MainIsEndscreen == 0) { // spb0 = 60; // // // FarSight in secondary function diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index f6c79c551..1e4cb2cff 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -104,14 +104,14 @@ u32 var800629cc = 0x00000000; u32 var800629d0 = 0x00000000; u32 var800629d4 = 0x00000000; -void func0f01e250(void) +void propsTick2(void) { s32 i; struct prop *prop; struct prop *next; struct prop *next2; s32 done; - s32 value; + s32 tickop; for (i = 0; i < PLAYERCOUNT(); i++) { g_Vars.players[i]->bondextrapos.x = 0; @@ -127,27 +127,27 @@ void func0f01e250(void) do { next = prop->next; done = next == g_Vars.list2head; - value = 0; + tickop = TICKOP_NONE; if (prop->type == PROPTYPE_CHR) { - value = propchrDoFireslotThing(prop); + tickop = chrTickBeams(prop); } else if (prop->type == PROPTYPE_OBJ || prop->type == PROPTYPE_WEAPON || prop->type == PROPTYPE_DOOR) { - value = func0f07e474(prop); + tickop = func0f07e474(prop); } else if (prop->type == PROPTYPE_EXPLOSION) { - value = func0f12bbdc(prop); + tickop = func0f12bbdc(prop); } else if (prop->type == PROPTYPE_SMOKE) { - value = func0f12e848(prop); + tickop = func0f12e848(prop); } else if (prop->type == PROPTYPE_PLAYER) { - value = func0f0c228c(prop); + tickop = playerTickBeams(prop); } - if (value == 5) { + if (tickop == TICKOP_5) { next2 = next; } else { next2 = prop->next; done = next2 == g_Vars.list2head; - if (value == 3) { + if (tickop == TICKOP_RETICK) { propRemoveFromCurrentList(prop); propAppendToList1(prop); @@ -156,7 +156,7 @@ void func0f01e250(void) done = false; } } else { - func0f062b64(prop, value); + propExecuteTickOperation(prop, tickop); } } @@ -6939,7 +6939,7 @@ u32 var80062a40 = 0x00000000; u32 var80062a44 = 0x00000000; u8 var80062a48[] = { 64, 10, 10 }; -bool propchrDoFireslotThing(struct prop *prop) +bool chrTickBeams(struct prop *prop) { struct chrdata *chr = prop->chr; diff --git a/src/game/chr/chraction.c b/src/game/chr/chraction.c index 3e715bce2..f4844c70a 100644 --- a/src/game/chr/chraction.c +++ b/src/game/chr/chraction.c @@ -23211,9 +23211,9 @@ void func0f0482cc(u32 ailistid) prop = g_Vars.list1head; while (prop) { - prop->unk38 = 0xffff; - prop->unk3a = 0; - prop->unk3c = 2; + prop->lastupdateframe = 0xffff; + prop->propupdate240 = 0; + prop->propupdate60err = 2; prop = prop->next; } diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index e1798dbd9..23b912cba 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -429,7 +429,7 @@ bool aiChrDoAnimation(void) #endif } - chr->prop->unk3a = 0; + chr->prop->propupdate240 = 0; } chrTryStartAnim(chr, anim_id, fstartframe, fendframe, cmd[8], cmd[9], speed); @@ -2372,7 +2372,7 @@ bool aiGiveObjectToChr(void) #endif something = func0f088840(obj->prop, 0); - func0f062b64(obj->prop, something); + propExecuteTickOperation(obj->prop, something); playernum = propGetPlayerNum(chr->prop); obj2->hidden = (playernum << 28) | (obj2->hidden & 0x0fffffff); setCurrentPlayerNum(prevplayernum); diff --git a/src/game/explosions/explosions.c b/src/game/explosions/explosions.c index 014a5c507..7c674871e 100644 --- a/src/game/explosions/explosions.c +++ b/src/game/explosions/explosions.c @@ -399,7 +399,7 @@ glabel var7f1b5584 /* f12a184: 001080c0 */ sll $s0,$s0,0x3 /* f12a188: 01f0c021 */ addu $t8,$t7,$s0 /* f12a18c: 8f040000 */ lw $a0,0x0($t8) -/* f12a190: 0fc18ad9 */ jal func0f062b64 +/* f12a190: 0fc18ad9 */ jal propExecuteTickOperation /* f12a194: 00e02825 */ or $a1,$a3,$zero /* f12a198: 8e390000 */ lw $t9,0x0($s1) /* f12a19c: 03306021 */ addu $t4,$t9,$s0 @@ -5093,7 +5093,7 @@ glabel var7f1b55a8 ); #endif -u32 explosionUpdateZ(struct prop *prop) +u32 explosionTick(struct prop *prop) { Mtxf *matrix = currentPlayerGetMatrix1740(); @@ -5107,7 +5107,7 @@ u32 explosionUpdateZ(struct prop *prop) prop->flags |= PROPFLAG_40 | PROPFLAG_02; - return 0; + return TICKOP_NONE; } Gfx *explosionRender(struct prop *prop, Gfx *gdl, bool withalpha) diff --git a/src/game/game_00c240.c b/src/game/game_00c240.c index b19f597cf..549b90689 100644 --- a/src/game/game_00c240.c +++ b/src/game/game_00c240.c @@ -32,16 +32,16 @@ void gvarsInitProps(void) func0f00c390(); if (g_Vars.normmplayerisrunning) { - g_Vars.numpropstateindexes = 4; + g_Vars.numpropstates = 4; } else { - g_Vars.numpropstateindexes = 7; + g_Vars.numpropstates = 7; } - g_Vars.nextpropstateindex = 0; - g_Vars.unk00035a = 0; - g_Vars.unk00035b = 0; - g_Vars.unk00035c = 0xfffe; - g_Vars.unk00035e = 0xffff; + g_Vars.allocstateindex = 0; + g_Vars.runstateindex = 0; + g_Vars.alwaystick = 0; + g_Vars.updateframe = 0xfffe; + g_Vars.prevupdateframe = 0xffff; for (i = 0; i < ARRAYCOUNT(g_Vars.propstates); i++) { g_Vars.propstates[i].propcount = 0; diff --git a/src/game/game_00c490.c b/src/game/game_00c490.c index a3a53576a..95e7e5154 100644 --- a/src/game/game_00c490.c +++ b/src/game/game_00c490.c @@ -1354,7 +1354,7 @@ void setupSingleMonitor(struct singlemonitorobj *monitor, s32 cmdindex) scale = monitor->base.extrascale * (1.0f / 256.0f); if (g_Vars.normmplayerisrunning || g_Vars.lvmpbotlevel) { - monitor->base.hidden2 |= OBJH2FLAG_04; + monitor->base.hidden2 |= OBJH2FLAG_CANREGEN; } prop = func0f06a550(&monitor->base); diff --git a/src/game/game_0b69d0.c b/src/game/game_0b69d0.c index 782e9c690..4fb70ef3c 100644 --- a/src/game/game_0b69d0.c +++ b/src/game/game_0b69d0.c @@ -4536,7 +4536,7 @@ bool func0f0bc4c0(void) return true; } - return (g_InCutscene && !var8005d9d0) || menuGetRoot() == MENUROOT_COOPCONTINUE; + return (g_InCutscene && !g_MainIsEndscreen) || menuGetRoot() == MENUROOT_COOPCONTINUE; } #endif @@ -4547,7 +4547,7 @@ s16 currentPlayerGetViewportWidth(void) #if VERSION >= VERSION_NTSC_1_0 if (func0f0bc4c0() == 0) #else - if ((!g_InCutscene || var8005d9d0) && menuGetRoot() != MENUROOT_COOPCONTINUE) + if ((!g_InCutscene || g_MainIsEndscreen) && menuGetRoot() != MENUROOT_COOPCONTINUE) #endif { if (PLAYERCOUNT() >= 3) { @@ -4586,7 +4586,7 @@ s16 currentPlayerGetViewportLeft(void) #if VERSION >= VERSION_NTSC_1_0 s32 something = !func0f0bc4c0(); #else - s32 something = !((g_InCutscene && !var8005d9d0) || menuGetRoot() == MENUROOT_COOPCONTINUE); + s32 something = !((g_InCutscene && !g_MainIsEndscreen) || menuGetRoot() == MENUROOT_COOPCONTINUE); #endif s16 left; @@ -4627,7 +4627,7 @@ s16 currentPlayerGetViewportHeight(void) #if VERSION >= VERSION_NTSC_1_0 && !func0f0bc4c0() #else - && !((g_InCutscene && !var8005d9d0) || menuGetRoot() == MENUROOT_COOPCONTINUE) + && !((g_InCutscene && !g_MainIsEndscreen) || menuGetRoot() == MENUROOT_COOPCONTINUE) #endif ) { s16 tmp = g_ViModes[g_ViMode].fullheight; @@ -4679,7 +4679,7 @@ s16 currentPlayerGetViewportTop(void) #if VERSION >= VERSION_NTSC_1_0 && !func0f0bc4c0() #else - && !((g_InCutscene && !var8005d9d0) || menuGetRoot() == MENUROOT_COOPCONTINUE) + && !((g_InCutscene && !g_MainIsEndscreen) || menuGetRoot() == MENUROOT_COOPCONTINUE) #endif ) { top = g_ViModes[g_ViMode].fulltop; @@ -7901,10 +7901,10 @@ glabel var7f1ad6ac .L0f0bdca8: /* f0bdca8: 3c0f8007 */ lui $t7,%hi(g_InCutscene) /* f0bdcac: 8def0764 */ lw $t7,%lo(g_InCutscene)($t7) -/* f0bdcb0: 3c188006 */ lui $t8,%hi(var8005d9d0) +/* f0bdcb0: 3c188006 */ lui $t8,%hi(g_MainIsEndscreen) /* f0bdcb4: 55e0000a */ bnezl $t7,.L0f0bdce0 /* f0bdcb8: 8e6b0284 */ lw $t3,0x284($s3) -/* f0bdcbc: 8f18d9d0 */ lw $t8,%lo(var8005d9d0)($t8) +/* f0bdcbc: 8f18d9d0 */ lw $t8,%lo(g_MainIsEndscreen)($t8) /* f0bdcc0: 57000007 */ bnezl $t8,.L0f0bdce0 /* f0bdcc4: 8e6b0284 */ lw $t3,0x284($s3) /* f0bdcc8: 8e700284 */ lw $s0,0x284($s3) @@ -12456,7 +12456,7 @@ glabel var7f1ad6ac // // dc9c // if ((g_Vars.tickmode == TICKMODE_0 || g_Vars.tickmode == TICKMODE_NORMAL) // && g_InCutscene == 0 -// && var8005d9d0 == 0) { +// && g_MainIsEndscreen == 0) { // g_Vars.currentplayer->bondviewlevtime60 += g_Vars.lvupdate240_60; // } // @@ -15300,7 +15300,7 @@ s32 getMissionTime(void) #endif } -s32 func0f0c228c(struct prop *prop) +s32 playerTickBeams(struct prop *prop) { beamTick(&g_Vars.players[propGetPlayerNum(prop)]->hands[0].beam); beamTick(&g_Vars.players[propGetPlayerNum(prop)]->hands[1].beam); @@ -15322,7 +15322,7 @@ s32 func0f0c228c(struct prop *prop) #if VERSION >= VERSION_PAL_FINAL GLOBAL_ASM( -glabel func0f0c2364 +glabel playerTick .late_rodata glabel var7f1ad700 .word 0x40c907a9 @@ -15816,7 +15816,7 @@ glabel var7f1ad710 ); #else GLOBAL_ASM( -glabel func0f0c2364 +glabel playerTick .late_rodata glabel var7f1ad700 .word 0x40c907a9 diff --git a/src/game/game_190260.c b/src/game/game_190260.c index bb7121bdd..8f93ff43a 100644 --- a/src/game/game_190260.c +++ b/src/game/game_190260.c @@ -986,7 +986,7 @@ u32 propobjHandlePickupByAibot(struct prop *prop, struct chrdata *chr) func0f0939f8(NULL, prop, SFX_PICKUP_AMMO, -1, -1, 1024, 0, 0, 0, -1, 0, -1, -1, -1, -1); - objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_04); + objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_CANREGEN); if (qty) { dprint(); @@ -1037,7 +1037,7 @@ u32 propobjHandlePickupByAibot(struct prop *prop, struct chrdata *chr) func0f0939f8(NULL, prop, SFX_PICKUP_AMMO, -1, -1, 1024, 0, 0, 0, -1, 0, -1, -1, -1, -1); - objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_04); + objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_CANREGEN); } return 2; case OBJTYPE_WEAPON: @@ -1078,7 +1078,7 @@ u32 propobjHandlePickupByAibot(struct prop *prop, struct chrdata *chr) result = 1; } - objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_04); + objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_CANREGEN); } return result; @@ -1091,7 +1091,7 @@ u32 propobjHandlePickupByAibot(struct prop *prop, struct chrdata *chr) -1, 1024, 0, 0, 0, -1, 0, -1, -1, -1, -1); chrSetShield(chr, shield->amount * 8); - objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_04); + objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_CANREGEN); } return 3; case OBJTYPE_BASIC: @@ -2549,7 +2549,7 @@ void func0f19124c(struct chrdata *chr) || obj->projectile->unk090) { if (mpObjIsSafe(obj)) { if (func0f190be4(prop, chr)) { - func0f062b64(prop, 1); + propExecuteTickOperation(prop, 1); } else { dprint(); } @@ -3737,11 +3737,11 @@ glabel var7f1b8ef0 #endif // Mismatch: updateable is calculated differently -//bool aibotTick(struct prop *prop) +//s32 aibotTick(struct prop *prop) //{ // struct chrdata *chr = prop->chr; // struct aibot *aibot = chr->aibot; -// bool result = false; +// s32 result = TICKOP_NONE; // bool updateable; // f32 oldangle; // f32 newangle; diff --git a/src/game/hudmsg.c b/src/game/hudmsg.c index 79124ead3..4d31e83a9 100644 --- a/src/game/hudmsg.c +++ b/src/game/hudmsg.c @@ -3147,8 +3147,8 @@ glabel var7f1adec0 /* f0dea48: 8ce7a028 */ lw $a3,%lo(g_Vars+0x68)($a3) /* f0dea4c: 13200007 */ beqz $t9,.L0f0dea6c /* f0dea50: 8d08a02c */ lw $t0,%lo(g_Vars+0x6c)($t0) -/* f0dea54: 3c0f8006 */ lui $t7,%hi(var8005d9d0) -/* f0dea58: 8defd9d0 */ lw $t7,%lo(var8005d9d0)($t7) +/* f0dea54: 3c0f8006 */ lui $t7,%hi(g_MainIsEndscreen) +/* f0dea58: 8defd9d0 */ lw $t7,%lo(g_MainIsEndscreen)($t7) /* f0dea5c: 55e00004 */ bnezl $t7,.L0f0dea70 /* f0dea60: 8c6201cc */ lw $v0,0x1cc($v1) /* f0dea64: 10000002 */ b .L0f0dea70 @@ -3199,10 +3199,10 @@ glabel var7f1adec0 .L0f0deafc: /* f0deafc: 3c198007 */ lui $t9,%hi(g_InCutscene) /* f0deb00: 8f390764 */ lw $t9,%lo(g_InCutscene)($t9) -/* f0deb04: 3c0f8006 */ lui $t7,%hi(var8005d9d0) +/* f0deb04: 3c0f8006 */ lui $t7,%hi(g_MainIsEndscreen) /* f0deb08: 53200005 */ beqzl $t9,.L0f0deb20 /* f0deb0c: 906e0000 */ lbu $t6,0x0($v1) -/* f0deb10: 8defd9d0 */ lw $t7,%lo(var8005d9d0)($t7) +/* f0deb10: 8defd9d0 */ lw $t7,%lo(g_MainIsEndscreen)($t7) /* f0deb14: 11e00018 */ beqz $t7,.L0f0deb78 /* f0deb18: 00000000 */ nop /* f0deb1c: 906e0000 */ lbu $t6,0x0($v1) @@ -3364,11 +3364,11 @@ glabel var7f1adec0 /* f0ded38: 15e1001b */ bne $t7,$at,.L0f0deda8 /* f0ded3c: 3c0e8007 */ lui $t6,%hi(g_InCutscene) /* f0ded40: 8dce0764 */ lw $t6,%lo(g_InCutscene)($t6) -/* f0ded44: 3c188006 */ lui $t8,%hi(var8005d9d0) +/* f0ded44: 3c188006 */ lui $t8,%hi(g_MainIsEndscreen) /* f0ded48: 3c198009 */ lui $t9,%hi(g_Is4Mb) /* f0ded4c: 11c00004 */ beqz $t6,.L0f0ded60 /* f0ded50: 00000000 */ nop -/* f0ded54: 8f18d9d0 */ lw $t8,%lo(var8005d9d0)($t8) +/* f0ded54: 8f18d9d0 */ lw $t8,%lo(g_MainIsEndscreen)($t8) /* f0ded58: 13000013 */ beqz $t8,.L0f0deda8 /* f0ded5c: 00000000 */ nop .L0f0ded60: @@ -7011,8 +7011,8 @@ glabel var7f1adef4 /* f0dfb78: 8d290764 */ lw $t1,%lo(g_InCutscene)($t1) /* f0dfb7c: 1120000a */ beqz $t1,.L0f0dfba8 /* f0dfb80: 00000000 */ nop -/* f0dfb84: 3c0a8006 */ lui $t2,%hi(var8005d9d0) -/* f0dfb88: 8d4ad9d0 */ lw $t2,%lo(var8005d9d0)($t2) +/* f0dfb84: 3c0a8006 */ lui $t2,%hi(g_MainIsEndscreen) +/* f0dfb88: 8d4ad9d0 */ lw $t2,%lo(g_MainIsEndscreen)($t2) /* f0dfb8c: 15400006 */ bnez $t2,.L0f0dfba8 /* f0dfb90: 00000000 */ nop /* f0dfb94: 3c0b800a */ lui $t3,%hi(g_Vars+0x28c) @@ -8698,7 +8698,7 @@ glabel var7f1adef4 // // b4c // if ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) // && g_InCutscene -// && var8005d9d0 == 0 +// && g_MainIsEndscreen == 0 // && g_Vars.currentplayernum == 0) { // // ba4 // spdc = false; diff --git a/src/game/lv.c b/src/game/lv.c index dcce9a6aa..6b01cd985 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -2468,7 +2468,7 @@ glabel var7f1b8e7cpf /* f16ad38: 00409825 */ move $s3,$v0 /* f16ad3c: 0fc010c5 */ jal func0f004314 /* f16ad40: 00000000 */ nop -/* f16ad44: 0fc18ca3 */ jal func0f06302c +/* f16ad44: 0fc18ca3 */ jal propsTick /* f16ad48: 02202025 */ move $a0,$s1 /* f16ad4c: 0fc619c9 */ jal scenarioCallback14 /* f16ad50: 00002025 */ move $a0,$zero @@ -3882,7 +3882,7 @@ Gfx *lvRender(Gfx *gdl) gdl = func0f11f984(gdl); roomsTick(); func0f004314(); - func0f06302c(islastplayer); + propsTick(islastplayer); scenarioCallback14(NULL); func0f0601b0(); autoaimTick(); @@ -5054,7 +5054,7 @@ glabel var7f1b1fd4nb /* f164a40: 00409825 */ or $s3,$v0,$zero /* f164a44: 0fc01017 */ jal func0f004314 /* f164a48: 00000000 */ sll $zero,$zero,0x0 -/* f164a4c: 0fc188ac */ jal func0f06302c +/* f164a4c: 0fc188ac */ jal propsTick /* f164a50: 02202025 */ or $a0,$s1,$zero /* f164a54: 0fc5ff30 */ jal scenarioCallback14 /* f164a58: 00002025 */ or $a0,$zero,$zero @@ -8137,7 +8137,7 @@ glabel var7f1b8ed0pf /* f16d878: 8f39d670 */ lw $t9,-0x2990($t9) /* f16d87c: 17200003 */ bnez $t9,.PF0f16d88c /* f16d880: 00000000 */ nop -/* f16d884: 0fc078dc */ jal func0f01e250 +/* f16d884: 0fc078dc */ jal propsTick2 /* f16d888: 00000000 */ nop .PF0f16d88c: /* f16d88c: 0c0046c5 */ jal func00011d84 @@ -8514,8 +8514,8 @@ void lvTick(void) menuTickAll(); scenarioTick(); - if (var8005d9d0 == 0) { - func0f01e250(); + if (!g_MainIsEndscreen) { + propsTick2(); } func00011d84(); @@ -9737,7 +9737,7 @@ glabel lvTick /* f1677e4: 8deff2f0 */ lw $t7,-0xd10($t7) /* f1677e8: 15e00003 */ bnez $t7,.NB0f1677f8 /* f1677ec: 00000000 */ sll $zero,$zero,0x0 -/* f1677f0: 0fc077cc */ jal func0f01e250 +/* f1677f0: 0fc077cc */ jal propsTick2 /* f1677f4: 00000000 */ sll $zero,$zero,0x0 .NB0f1677f8: /* f1677f8: 0c004848 */ jal func00011d84 diff --git a/src/game/mplayer/ingame.c b/src/game/mplayer/ingame.c index 2d616ca7d..1c5fb7ea8 100644 --- a/src/game/mplayer/ingame.c +++ b/src/game/mplayer/ingame.c @@ -634,7 +634,7 @@ void mpPushPauseDialog(void) u32 prevplayernum = g_MpPlayerNum; #if VERSION >= VERSION_NTSC_1_0 - if (g_MpSetup.paused != MPPAUSEMODE_GAMEOVER && var8005d9d0 == 0) + if (g_MpSetup.paused != MPPAUSEMODE_GAMEOVER && g_MainIsEndscreen == 0) #endif { g_MpPlayerNum = g_Vars.currentplayerstats->mpindex; diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index a8bb416c6..3c5e654ae 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -2059,8 +2059,8 @@ glabel mpRenderModalText /* f189928: 100000e0 */ b .L0f189cac /* f18992c: afa200a0 */ sw $v0,0xa0($sp) .L0f189930: -/* f189930: 3c098006 */ lui $t1,%hi(var8005d9d0) -/* f189934: 8d29d9d0 */ lw $t1,%lo(var8005d9d0)($t1) +/* f189930: 3c098006 */ lui $t1,%hi(g_MainIsEndscreen) +/* f189934: 8d29d9d0 */ lw $t1,%lo(g_MainIsEndscreen)($t1) /* f189938: 552000dd */ bnezl $t1,.L0f189cb0 /* f18993c: 8fbf0034 */ lw $ra,0x34($sp) /* f189940: 144000da */ bnez $v0,.L0f189cac @@ -2434,8 +2434,8 @@ glabel mpRenderModalText /* f189928: 100000e0 */ b .L0f189cac /* f18992c: afa200a0 */ sw $v0,0xa0($sp) .L0f189930: -/* f189930: 3c098006 */ lui $t1,%hi(var8005d9d0) -/* f189934: 8d29d9d0 */ lw $t1,%lo(var8005d9d0)($t1) +/* f189930: 3c098006 */ lui $t1,%hi(g_MainIsEndscreen) +/* f189934: 8d29d9d0 */ lw $t1,%lo(g_MainIsEndscreen)($t1) /* f189938: 552000dd */ bnezl $t1,.L0f189cb0 /* f18993c: 8fbf0034 */ lw $ra,0x34($sp) /* f189940: 144000da */ bnez $v0,.L0f189cac diff --git a/src/game/mplayer/scenarios.c b/src/game/mplayer/scenarios.c index b8844f34e..18ce770d4 100644 --- a/src/game/mplayer/scenarios.c +++ b/src/game/mplayer/scenarios.c @@ -12458,7 +12458,7 @@ s32 chrGiveUplink(struct chrdata *chr, struct prop *prop) func0f087d10(WEAPON_DATAUPLINK); #if VERSION >= VERSION_NTSC_1_0 - objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_04); + objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_CANREGEN); return 1; #else return 4; diff --git a/src/game/prop.c b/src/game/prop.c index 034cd48d1..bf36e2871 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -175,23 +175,23 @@ struct prop *propAllocate(void) prop->timetoregen = 0; prop->rooms[0] = -1; prop->chr = NULL; - prop->propstateindex = g_Vars.nextpropstateindex; + prop->propstateindex = g_Vars.allocstateindex; prop->unk3e = 0; - prop->unk3f_00 = 1; + prop->forcetick = true; prop->unk3f_02 = 0; prop->inlist1 = false; - prop->unk3f_01 = 0; - prop->unk38 = 0xffff; - prop->unk3a = 0; - prop->unk3c = 2; + prop->backgrounded = false; + prop->lastupdateframe = 0xffff; + prop->propupdate240 = 0; + prop->propupdate60err = 2; prop->unk40 = 0; prop->unk44 = 0; g_Vars.propstates[prop->propstateindex].propcount++; - g_Vars.nextpropstateindex++; + g_Vars.allocstateindex++; - if (g_Vars.nextpropstateindex >= g_Vars.numpropstateindexes) { - g_Vars.nextpropstateindex = 0; + if (g_Vars.allocstateindex >= g_Vars.numpropstates) { + g_Vars.allocstateindex = 0; } return prop; @@ -2530,11 +2530,11 @@ void handsTickAttack(void) } } -void func0f062b64(struct prop *prop, s32 arg1) +void propExecuteTickOperation(struct prop *prop, s32 op) { - if (arg1 == 1) { + if (op == TICKOP_FREE) { if ((prop->type == PROPTYPE_WEAPON || prop->type == PROPTYPE_OBJ) - && prop->obj && (prop->obj->hidden2 & OBJH2FLAG_04)) { + && prop->obj && (prop->obj->hidden2 & OBJH2FLAG_CANREGEN)) { struct defaultobj *obj = prop->obj; prop->timetoregen = PALDOWN(1200); @@ -2556,11 +2556,11 @@ void func0f062b64(struct prop *prop, s32 arg1) propHide(prop); propFree(prop); } - } else if (arg1 == 2) { + } else if (op == TICKOP_DISABLE) { func0f065c44(prop); propRemoveFromCurrentList(prop); propHide(prop); - } else if (arg1 == 4) { + } else if (op == TICKOP_GIVETOPLAYER) { func0f065c44(prop); propRemoveFromCurrentList(prop); propHide(prop); @@ -2721,7 +2721,7 @@ void func0f062dd0(void) bool currentPlayerInteract(bool eyespy) { struct prop *prop; - bool value = false; + bool op = TICKOP_NONE; prop = currentPlayerFindPropForInteract(eyespy); @@ -2729,10 +2729,10 @@ bool currentPlayerInteract(bool eyespy) switch (prop->type) { case PROPTYPE_OBJ: case PROPTYPE_WEAPON: - value = propobjInteract(prop); + op = propobjInteract(prop); break; case PROPTYPE_DOOR: - value = propdoorInteract(prop); + op = propdoorInteract(prop); break; case PROPTYPE_CHR: case PROPTYPE_EYESPY: @@ -2742,7 +2742,7 @@ bool currentPlayerInteract(bool eyespy) break; } - func0f062b64(prop, value); + propExecuteTickOperation(prop, op); return false; } @@ -2810,25 +2810,74 @@ void propMoveFromList2To1(struct prop *prop) propPrependToList1(prop); } -u32 var80069884 = 0x00000001; -u32 var80069888 = 0x01010101; -u32 var8006988c = 0x01000101; -u32 var80069890 = 0x01010100; -u32 var80069894 = 0x00010101; -u32 var80069898 = 0x01010000; -u32 var8006989c = 0x00000000; -u32 var800698a0 = 0x00000100; -u32 var800698a4 = 0x00000000; -u32 var800698a8 = 0x01010000; -u32 var800698ac = 0x00000101; -u32 var800698b0 = 0x01000101; -u32 var800698b4 = 0x00000000; -u32 var800698b8 = 0x00000100; -u32 var800698bc = 0x00000001; +// 0 = will tick when backgrounded +// 1 = will not tick when backgrounded +u8 g_ObjsPausedWhenBackgrounded[] = { + 0, // dummy element because objects are 1-indexed + 0, // OBJTYPE_DOOR + 0, // OBJTYPE_DOORSCALE + 1, // OBJTYPE_BASIC + 1, // OBJTYPE_KEY + 1, // OBJTYPE_ALARM + 1, // OBJTYPE_CCTV + 1, // OBJTYPE_AMMOCRATE + 1, // OBJTYPE_WEAPON + 0, // OBJTYPE_CHR + 1, // OBJTYPE_SINGLEMONITOR + 1, // OBJTYPE_MULTIMONITOR + 1, // OBJTYPE_HANGINGMONITORS + 1, // OBJTYPE_AUTOGUN + 1, // OBJTYPE_LINKGUNS + 0, // OBJTYPE_DEBRIS + 0, // OBJTYPE_10 + 1, // OBJTYPE_HAT + 1, // OBJTYPE_GRENADEPROB + 1, // OBJTYPE_LINKLIFTDOOR + 1, // OBJTYPE_MULTIAMMOCRATE + 1, // OBJTYPE_SHIELD + 0, // OBJTYPE_TAG + 0, // OBJTYPE_BEGINOBJECTIVE + 0, // OBJTYPE_ENDOBJECTIVE + 0, // OBJECTIVETYPE_DESTROYOBJ + 0, // OBJECTIVETYPE_COMPFLAGS + 0, // OBJECTIVETYPE_FAILFLAGS + 0, // OBJECTIVETYPE_COLLECTOBJ + 0, // OBJECTIVETYPE_THROWOBJ + 1, // OBJECTIVETYPE_HOLOGRAPH + 0, // OBJECTIVETYPE_1F + 0, // OBJECTIVETYPE_ENTERROOM + 0, // OBJECTIVETYPE_ATTACHOBJ + 0, // OBJTYPE_22 + 0, // OBJTYPE_BRIEFING + 1, // OBJTYPE_GASBOTTLE + 1, // OBJTYPE_RENAMEOBJ + 0, // OBJTYPE_PADLOCKEDDOOR + 0, // OBJTYPE_TRUCK + 0, // OBJTYPE_HELI + 0, // OBJTYPE_29 + 1, // OBJTYPE_GLASS + 1, // OBJTYPE_SAFE + 1, // OBJTYPE_SAFEITEM + 0, // OBJTYPE_TANK + 1, // OBJTYPE_CAMERAPOS + 1, // OBJTYPE_TINTEDGLASS + 0, // OBJTYPE_LIFT + 0, // OBJTYPE_CONDITIONALSCENERY + 0, // OBJTYPE_BLOCKEDPATH + 0, // OBJTYPE_HOVERBIKE + 0, // OBJTYPE_END + 0, // OBJTYPE_HOVERPROP + 1, // OBJTYPE_FAN + 0, // OBJTYPE_HOVERCAR + 0, // OBJTYPE_PADEFFECT + 0, // OBJTYPE_CHOPPER + 0, // OBJTYPE_MINE + 1, // OBJTYPE_ESCASTEP +}; #if VERSION >= VERSION_PAL_FINAL GLOBAL_ASM( -glabel func0f06302c +glabel propsTick .late_rodata glabel var7f1ab184pf .word 0x3f99999a @@ -3221,7 +3270,7 @@ glabel var7f1ab190pf .PF0f0637e0: /* f0637e0: 54610006 */ bnel $v1,$at,.PF0f0637fc /* f0637e4: 24010008 */ li $at,0x8 -/* f0637e8: 0fc4b436 */ jal explosionUpdateZ +/* f0637e8: 0fc4b436 */ jal explosionTick /* f0637ec: 02002025 */ move $a0,$s0 /* f0637f0: 10000010 */ b .PF0f063834 /* f0637f4: 00403025 */ move $a2,$v0 @@ -3229,7 +3278,7 @@ glabel var7f1ab190pf .PF0f0637fc: /* f0637fc: 54610006 */ bnel $v1,$at,.PF0f063818 /* f063800: 24010006 */ li $at,0x6 -/* f063804: 0fc4bf31 */ jal smokeUpdateZ +/* f063804: 0fc4bf31 */ jal smokeTick /* f063808: 02002025 */ move $a0,$s0 /* f06380c: 10000009 */ b .PF0f063834 /* f063810: 00403025 */ move $a2,$v0 @@ -3239,7 +3288,7 @@ glabel var7f1ab190pf /* f06381c: 962e035e */ lhu $t6,0x35e($s1) /* f063820: 0fc5260c */ jal splatTick /* f063824: 02002025 */ move $a0,$s0 -/* f063828: 0fc30a3b */ jal func0f0c2364 +/* f063828: 0fc30a3b */ jal playerTick /* f06382c: 02002025 */ move $a0,$s0 /* f063830: 00403025 */ move $a2,$v0 .PF0f063834: @@ -3396,7 +3445,7 @@ glabel var7f1ab190pf .PF0f063a60: /* f063a60: 54610006 */ bnel $v1,$at,.PF0f063a7c /* f063a64: 24010008 */ li $at,0x8 -/* f063a68: 0fc4b436 */ jal explosionUpdateZ +/* f063a68: 0fc4b436 */ jal explosionTick /* f063a6c: 02002025 */ move $a0,$s0 /* f063a70: 10000010 */ b .PF0f063ab4 /* f063a74: 00403025 */ move $a2,$v0 @@ -3404,7 +3453,7 @@ glabel var7f1ab190pf .PF0f063a7c: /* f063a7c: 54610006 */ bnel $v1,$at,.PF0f063a98 /* f063a80: 24010006 */ li $at,0x6 -/* f063a84: 0fc4bf31 */ jal smokeUpdateZ +/* f063a84: 0fc4bf31 */ jal smokeTick /* f063a88: 02002025 */ move $a0,$s0 /* f063a8c: 10000009 */ b .PF0f063ab4 /* f063a90: 00403025 */ move $a2,$v0 @@ -3414,7 +3463,7 @@ glabel var7f1ab190pf /* f063a9c: 8faf0034 */ lw $t7,0x34($sp) /* f063aa0: 0fc5260c */ jal splatTick /* f063aa4: 02002025 */ move $a0,$s0 -/* f063aa8: 0fc30a3b */ jal func0f0c2364 +/* f063aa8: 0fc30a3b */ jal playerTick /* f063aac: 02002025 */ move $a0,$s0 /* f063ab0: 00403025 */ move $a2,$v0 .PF0f063ab4: @@ -3484,7 +3533,7 @@ glabel var7f1ab190pf /* f063b9c: 10000004 */ b .PF0f063bb0 /* f063ba0: afa0004c */ sw $zero,0x4c($sp) .PF0f063ba4: -/* f063ba4: 0fc18b71 */ jal func0f062b64 +/* f063ba4: 0fc18b71 */ jal propExecuteTickOperation /* f063ba8: afa20060 */ sw $v0,0x60($sp) /* f063bac: 8fa20060 */ lw $v0,0x60($sp) .PF0f063bb0: @@ -3827,7 +3876,7 @@ glabel var7f1ab190pf ); #elif VERSION >= VERSION_NTSC_1_0 GLOBAL_ASM( -glabel func0f06302c +glabel propsTick /* f06302c: 27bdff68 */ addiu $sp,$sp,-152 /* f063030: afb10018 */ sw $s1,0x18($sp) /* f063034: 3c11800a */ lui $s1,%hi(g_Vars) @@ -4207,7 +4256,7 @@ glabel func0f06302c .L0f063574: /* f063574: 54610006 */ bnel $v1,$at,.L0f063590 /* f063578: 24010008 */ addiu $at,$zero,0x8 -/* f06357c: 0fc4b16a */ jal explosionUpdateZ +/* f06357c: 0fc4b16a */ jal explosionTick /* f063580: 02002025 */ or $a0,$s0,$zero /* f063584: 10000010 */ b .L0f0635c8 /* f063588: 00403025 */ or $a2,$v0,$zero @@ -4215,7 +4264,7 @@ glabel func0f06302c .L0f063590: /* f063590: 54610006 */ bnel $v1,$at,.L0f0635ac /* f063594: 24010006 */ addiu $at,$zero,0x6 -/* f063598: 0fc4bc61 */ jal smokeUpdateZ +/* f063598: 0fc4bc61 */ jal smokeTick /* f06359c: 02002025 */ or $a0,$s0,$zero /* f0635a0: 10000009 */ b .L0f0635c8 /* f0635a4: 00403025 */ or $a2,$v0,$zero @@ -4225,7 +4274,7 @@ glabel func0f06302c /* f0635b0: 962e035e */ lhu $t6,0x35e($s1) /* f0635b4: 0fc522e0 */ jal splatTick /* f0635b8: 02002025 */ or $a0,$s0,$zero -/* f0635bc: 0fc308d9 */ jal func0f0c2364 +/* f0635bc: 0fc308d9 */ jal playerTick /* f0635c0: 02002025 */ or $a0,$s0,$zero /* f0635c4: 00403025 */ or $a2,$v0,$zero .L0f0635c8: @@ -4345,10 +4394,10 @@ glabel func0f06302c /* f063768: 24010007 */ addiu $at,$zero,0x7 .L0f06376c: /* f06376c: 8e020004 */ lw $v0,0x4($s0) -/* f063770: 3c188007 */ lui $t8,%hi(var80069884) +/* f063770: 3c188007 */ lui $t8,%hi(g_ObjsPausedWhenBackgrounded) /* f063774: 90590003 */ lbu $t9,0x3($v0) /* f063778: 0319c021 */ addu $t8,$t8,$t9 -/* f06377c: 93189884 */ lbu $t8,%lo(var80069884)($t8) +/* f06377c: 93189884 */ lbu $t8,%lo(g_ObjsPausedWhenBackgrounded)($t8) /* f063780: 57000006 */ bnezl $t8,.L0f06379c /* f063784: 860d0002 */ lh $t5,0x2($s0) /* f063788: 0fc1f9d6 */ jal objTick @@ -4376,7 +4425,7 @@ glabel func0f06302c .L0f0637dc: /* f0637dc: 54610006 */ bnel $v1,$at,.L0f0637f8 /* f0637e0: 24010008 */ addiu $at,$zero,0x8 -/* f0637e4: 0fc4b16a */ jal explosionUpdateZ +/* f0637e4: 0fc4b16a */ jal explosionTick /* f0637e8: 02002025 */ or $a0,$s0,$zero /* f0637ec: 10000010 */ b .L0f063830 /* f0637f0: 00403025 */ or $a2,$v0,$zero @@ -4384,7 +4433,7 @@ glabel func0f06302c .L0f0637f8: /* f0637f8: 54610006 */ bnel $v1,$at,.L0f063814 /* f0637fc: 24010006 */ addiu $at,$zero,0x6 -/* f063800: 0fc4bc61 */ jal smokeUpdateZ +/* f063800: 0fc4bc61 */ jal smokeTick /* f063804: 02002025 */ or $a0,$s0,$zero /* f063808: 10000009 */ b .L0f063830 /* f06380c: 00403025 */ or $a2,$v0,$zero @@ -4394,7 +4443,7 @@ glabel func0f06302c /* f063818: 8faf0034 */ lw $t7,0x34($sp) /* f06381c: 0fc522e0 */ jal splatTick /* f063820: 02002025 */ or $a0,$s0,$zero -/* f063824: 0fc308d9 */ jal func0f0c2364 +/* f063824: 0fc308d9 */ jal playerTick /* f063828: 02002025 */ or $a0,$s0,$zero /* f06382c: 00403025 */ or $a2,$v0,$zero .L0f063830: @@ -4461,7 +4510,7 @@ glabel func0f06302c /* f06390c: 10000004 */ b .L0f063920 /* f063910: afa0004c */ sw $zero,0x4c($sp) .L0f063914: -/* f063914: 0fc18ad9 */ jal func0f062b64 +/* f063914: 0fc18ad9 */ jal propExecuteTickOperation /* f063918: afa20060 */ sw $v0,0x60($sp) /* f06391c: 8fa20060 */ lw $v0,0x60($sp) .L0f063920: @@ -4804,7 +4853,7 @@ glabel func0f06302c ); #else GLOBAL_ASM( -glabel func0f06302c +glabel propsTick /* f0622b0: 27bdff68 */ addiu $sp,$sp,-152 /* f0622b4: afb10018 */ sw $s1,0x18($sp) /* f0622b8: 3c11800a */ lui $s1,0x800a @@ -5180,7 +5229,7 @@ glabel func0f06302c .NB0f0627e8: /* f0627e8: 54610006 */ bnel $v1,$at,.NB0f062804 /* f0627ec: 24010008 */ addiu $at,$zero,0x8 -/* f0627f0: 0fc49c4e */ jal explosionUpdateZ +/* f0627f0: 0fc49c4e */ jal explosionTick /* f0627f4: 02002025 */ or $a0,$s0,$zero /* f0627f8: 10000010 */ beqz $zero,.NB0f06283c /* f0627fc: 00403025 */ or $a2,$v0,$zero @@ -5188,7 +5237,7 @@ glabel func0f06302c .NB0f062804: /* f062804: 54610006 */ bnel $v1,$at,.NB0f062820 /* f062808: 24010006 */ addiu $at,$zero,0x6 -/* f06280c: 0fc4a745 */ jal smokeUpdateZ +/* f06280c: 0fc4a745 */ jal smokeTick /* f062810: 02002025 */ or $a0,$s0,$zero /* f062814: 10000009 */ beqz $zero,.NB0f06283c /* f062818: 00403025 */ or $a2,$v0,$zero @@ -5198,7 +5247,7 @@ glabel func0f06302c /* f062824: 962e035e */ lhu $t6,0x35e($s1) /* f062828: 0fc50cd4 */ jal splatTick /* f06282c: 02002025 */ or $a0,$s0,$zero -/* f062830: 0fc2ffcb */ jal func0f0c2364 +/* f062830: 0fc2ffcb */ jal playerTick /* f062834: 02002025 */ or $a0,$s0,$zero /* f062838: 00403025 */ or $a2,$v0,$zero .NB0f06283c: @@ -5349,7 +5398,7 @@ glabel func0f06302c .NB0f062a50: /* f062a50: 54610006 */ bnel $v1,$at,.NB0f062a6c /* f062a54: 24010008 */ addiu $at,$zero,0x8 -/* f062a58: 0fc49c4e */ jal explosionUpdateZ +/* f062a58: 0fc49c4e */ jal explosionTick /* f062a5c: 02002025 */ or $a0,$s0,$zero /* f062a60: 10000010 */ beqz $zero,.NB0f062aa4 /* f062a64: 00403025 */ or $a2,$v0,$zero @@ -5357,7 +5406,7 @@ glabel func0f06302c .NB0f062a6c: /* f062a6c: 54610006 */ bnel $v1,$at,.NB0f062a88 /* f062a70: 24010006 */ addiu $at,$zero,0x6 -/* f062a74: 0fc4a745 */ jal smokeUpdateZ +/* f062a74: 0fc4a745 */ jal smokeTick /* f062a78: 02002025 */ or $a0,$s0,$zero /* f062a7c: 10000009 */ beqz $zero,.NB0f062aa4 /* f062a80: 00403025 */ or $a2,$v0,$zero @@ -5367,7 +5416,7 @@ glabel func0f06302c /* f062a8c: 8faf0034 */ lw $t7,0x34($sp) /* f062a90: 0fc50cd4 */ jal splatTick /* f062a94: 02002025 */ or $a0,$s0,$zero -/* f062a98: 0fc2ffcb */ jal func0f0c2364 +/* f062a98: 0fc2ffcb */ jal playerTick /* f062a9c: 02002025 */ or $a0,$s0,$zero /* f062aa0: 00403025 */ or $a2,$v0,$zero .NB0f062aa4: @@ -5434,7 +5483,7 @@ glabel func0f06302c /* f062b80: 10000004 */ beqz $zero,.NB0f062b94 /* f062b84: afa0004c */ sw $zero,0x4c($sp) .NB0f062b88: -/* f062b88: 0fc1877a */ jal func0f062b64 +/* f062b88: 0fc1877a */ jal propExecuteTickOperation /* f062b8c: afa20060 */ sw $v0,0x60($sp) /* f062b90: 8fa20060 */ lw $v0,0x60($sp) .NB0f062b94: @@ -5777,6 +5826,546 @@ glabel func0f06302c ); #endif +/** + * Figure out which props need to update their state on this tick, and do so. + * + * Props are split into two classes: foreground and background props. Foreground + * props are generally props that are near the player. These ones are updated on + * every tick. Background props are props elsewhere in the stage. These ones are + * updated less frequently by assigning them to one of 7 timeslots and only + * updating one timeslot per frame (in multiplayer, only 4 timeslots are used). + * + * Timeslots and propstates are the same thing. It is likely that the original + * code called them propstates. The propstate structs are used to track timing + * information so all props in that timeslot can be updated using the correct + * multipliers. + * + * Each time all timeslots have been updated (ie. every 7 or 4 frames) the + * timeslots are redistributed among the props, to handle situations where props + * have been allocated or freed during gameplay. This redistribution is done by + * categorising each prop into one of four categories: + * + * - foreground chrs + * - background chrs + * - foreground non-chrs + * - background non-chrs + * + * Timeslots are then assigned evenly within those categories. This method + * ensures that there aren't an uneven amount of props being updated on any + * given frame, which helps give a consistent frame rate. + */ +// Mismatch: +// 290: Duplicate write of &g_Vars.propstates[index] (t2) to sp34 +// 6fc and 864: Uses two instructions to reload addres of g_Vars.lvupdate240freal even though s1 could be used +// 938: Loads s4 and s1 loaded with constant values despite them already having those values +//void propsTick(u32 islastplayer) +//{ +// struct prop *prop; +// struct prop *end; +// s32 savedlvupdate240; +// s32 savedlvupdate240_60; +// f32 savedlvupdate240f; +// f32 savedlvupdate240freal; +// s32 savedslotupdate240; +// s32 savedslotupdate240_60; +// f32 savedslotupdate240f; +// struct prop *sp60; // 60 +// struct prop *next; // 5c +// s32 op; +// u8 index; +// u8 flags; +// s32 score; +// bool done; // 4c +// s32 i; +// +// g_Vars.unk00043c = 0; +// +//#if VERSION >= VERSION_NTSC_1_0 +// var8009cdac = 0; +// var8009cdb0 = 0; +//#endif +// +// // 068 +// if (islastplayer) { +// g_Vars.prevupdateframe = g_Vars.updateframe; +// g_Vars.updateframe++; +// +// if (g_Vars.updateframe == 0xffffffff) { +// g_Vars.updateframe = 0; +// } +// } +// +// // 090 +// savedlvupdate240 = g_Vars.lvupdate240; +// savedlvupdate240_60 = g_Vars.lvupdate240_60; +// savedlvupdate240f = g_Vars.lvupdate240f; +// savedlvupdate240freal = g_Vars.lvupdate240freal; +// +// for (i = 0; i < g_Vars.numpropstates; i++) { +// g_Vars.propstates[i].slotupdate240 += g_Vars.lvupdate240; +// } +// +// // 0ec +// g_Vars.runstateindex++; +// +// // 108 +// if (g_Vars.runstateindex >= g_Vars.numpropstates) { +// g_Vars.runstateindex = 0; +// } +// +// index = g_Vars.runstateindex; +// +// // 118 +// g_Vars.propstates[index].slotupdate60error = (g_Vars.propstates[index].slotupdate240 + g_Vars.propstates[index].slotupdate60error) & 3; +// savedslotupdate240 = g_Vars.propstates[index].slotupdate240; +// savedslotupdate240_60 = savedslotupdate240 + 2; +// savedslotupdate240_60 >>= 2; +// savedslotupdate240f = savedslotupdate240 * 0.25f; +// +// for (i = 0; i < g_Vars.numpropstates; i++) { +// // 184 +// g_Vars.propstates[i].propcount = 0; +// g_Vars.propstates[i].chrpropcount = 0; +// g_Vars.propstates[i].foregroundpropcount = 0; +// g_Vars.propstates[i].foregroundchrpropcount = 0; +// } +// +// // 1ac +// if (g_Vars.currentplayerindex == 0) { +// prop = g_Vars.props; +// end = &g_Vars.props[g_Vars.maxprops]; +// +// while (prop < end) { +// flags = prop->flags; +// +// if (flags & PROPFLAG_02) { +// flags &= ~PROPFLAG_02; +// } +// +// if (flags & PROPFLAG_40) { +// flags |= PROPFLAG_80; +// flags &= ~PROPFLAG_40; +// } else if (flags & PROPFLAG_80) { +// flags &= ~PROPFLAG_80; +// } +// +// (prop++)->flags = flags | PROPFLAG_08; +// } +// } else { +// // 23c +// prop = g_Vars.props; +// end = &g_Vars.props[g_Vars.maxprops]; +// +// while (prop < end) { +// flags = prop->flags; +// +// if (flags & PROPFLAG_02) { +// flags &= ~PROPFLAG_02; +// } +// +// prop->flags = flags; +// prop++; +// } +// } +// +// // 294 +// done = false; +// prop = g_Vars.list1head; +// +// while (!done) { +// s16 *rooms; +// op = TICKOP_NONE; +// next = prop->next; +// done = prop->next == g_Vars.list2head; +// +// if (g_Vars.tickmode != TICKMODE_NORMAL) { +// score = 1; +// } else { +// score = g_Vars.alwaystick; +// } +// +// rooms = prop->rooms; +// +// for (i = 0; *rooms != -1; i++) { +// if (g_Rooms[*rooms].flags & ROOMFLAG_VISIBLEBYPLAYER) { +// score++; +// } +// rooms++; +// } +// +// if (score == 0) { +// if (prop->type == PROPTYPE_PLAYER) { +// score++; +// } else if (prop->type == PROPTYPE_OBJ || prop->type == PROPTYPE_WEAPON) { +// if (prop->obj->hidden & OBJHFLAG_AIRBORNE) { +// score++; +// } +// } +// +// if (score == 0) { +// if ((prop->flags & (PROPFLAG_TANGIBLE | PROPFLAG_80)) == (PROPFLAG_TANGIBLE | PROPFLAG_80)) { +// score++; +// } else if (prop->forcetick) { +// score++; +// prop->forcetick = false; +// } else if (prop->unk3f_02) { +// score++; +// } else { +// rooms = prop->rooms; +// +// for (i = 0; *rooms != -1; i++) { +// if (g_Rooms[*rooms].flags & ROOMFLAG_VISIBLEBYAIBOT) { +// break; +// } +// +// rooms++; +// } +// +// if (*rooms != -1) { +// score++; +// } +// } +// } +// } +// +// prop->propupdate240 += g_Vars.lvupdate240; +// +// // 41c +// if (score > 0) { +// // The prop is in the foreground +// if (prop->lastupdateframe != g_Vars.prevupdateframe) { +// g_Vars.lvupdate240 = prop->propupdate240; +// g_Vars.lvupdate240_60 = prop->propupdate240 + prop->propupdate60err; +// prop->propupdate60err = g_Vars.lvupdate240_60 & 3; +// g_Vars.lvupdate240_60 >>= 2; +// g_Vars.lvupdate240f = g_Vars.lvupdate240 * 0.25f; +// g_Vars.lvupdate240freal = PALUPF(g_Vars.lvupdate240f); +// } else { +// g_Vars.lvupdate240 = savedlvupdate240; +// g_Vars.lvupdate240_60 = savedlvupdate240_60; +// g_Vars.lvupdate240f = savedlvupdate240f; +// g_Vars.lvupdate240freal = savedlvupdate240freal; +// } +// +// // 4a8 +// prop->unk3e = 0; +// +// if (prop->type == PROPTYPE_CHR) { +// struct chrdata *chr = prop->chr; +// +// splatTick(prop); +// +// if (chr && chr->aibot) { +// op = aibotTick(prop); +// } else { +// op = func0f023098(prop); +// } +// +// g_Vars.propstates[prop->propstateindex].foregroundchrpropcount++; +// } else { +// g_Vars.propstates[prop->propstateindex].foregroundpropcount++; +// +// if (prop->type == PROPTYPE_OBJ || prop->type == PROPTYPE_WEAPON || prop->type == PROPTYPE_DOOR) { +// op = objTick(prop); +// } else if (prop->type == PROPTYPE_EXPLOSION) { +// op = explosionTick(prop); +// } else if (prop->type == PROPTYPE_SMOKE) { +// op = smokeTick(prop); +// } else if (prop->type == PROPTYPE_PLAYER) { +// splatTick(prop); +// op = playerTick(prop); +// } +// } +// +// if (prop->lastupdateframe != g_Vars.prevupdateframe) { +// g_Vars.lvupdate240 = savedlvupdate240; +// g_Vars.lvupdate240_60 = savedlvupdate240_60; +// g_Vars.lvupdate240f = savedlvupdate240f; +// g_Vars.lvupdate240freal = savedlvupdate240f; +// } +// +// prop->lastupdateframe = g_Vars.updateframe; +// prop->propupdate240 = 0; +// prop->backgrounded = false; +// } else { +// // The prop is in the background +// // 61c +// if (prop->type == PROPTYPE_CHR) { +// g_Vars.propstates[prop->propstateindex].chrpropcount++; +// } else { +// g_Vars.propstates[prop->propstateindex].propcount++; +// } +// +// // 670 +// if (index == prop->propstateindex) { +// if (prop->lastupdateframe != g_Vars.propstates[index].lastupdateframe) { +// g_Vars.lvupdate240 = prop->propupdate240; +// g_Vars.lvupdate240_60 = prop->propupdate240 + prop->propupdate60err; +// prop->propupdate60err = g_Vars.lvupdate240_60 & 3; +// g_Vars.lvupdate240_60 >>= 2; +// g_Vars.lvupdate240f = g_Vars.lvupdate240 * 0.25f; +// g_Vars.lvupdate240freal = PALUPF(g_Vars.lvupdate240f); +// } else { +// g_Vars.lvupdate240 = savedslotupdate240; +// g_Vars.lvupdate240_60 = savedslotupdate240_60; +// g_Vars.lvupdate240f = savedslotupdate240f; +// g_Vars.lvupdate240freal = PALUPF(savedslotupdate240f); +// } +// +// // 704 +// if (prop->type == PROPTYPE_CHR) { +// struct chrdata *chr = prop->chr; +// +// splatTick(prop); +// +// if (chr && chr->aibot) { +// op = aibotTick(prop); +// } else { +// op = func0f023098(prop); +// } +// } else if (prop->type == PROPTYPE_OBJ || prop->type == PROPTYPE_WEAPON || prop->type == PROPTYPE_DOOR) { +// struct defaultobj *obj = prop->obj; +// +// if (!g_ObjsPausedWhenBackgrounded[obj->type]) { +// op = objTick(prop); +// } else if (prop->timetoregen <= 0) { +// prop->unk3e++; +// +// if (prop->unk3e > g_Vars.numpropstates - 1) { +// propPrependToList2(prop); +// op = TICKOP_5; +// } +// } +// } else if (prop->type == PROPTYPE_EXPLOSION) { +// op = explosionTick(prop); +// } else if (prop->type == PROPTYPE_SMOKE) { +// op = smokeTick(prop); +// } else if (prop->type == PROPTYPE_PLAYER) { +// splatTick(prop); +// op = playerTick(prop); +// } +// +// // 844 +// if (g_Vars.propstates[index].lastupdateframe != prop->lastupdateframe) { +// g_Vars.lvupdate240 = savedslotupdate240; +// g_Vars.lvupdate240_60 = savedslotupdate240_60; +// g_Vars.lvupdate240f = savedslotupdate240f; +// g_Vars.lvupdate240freal = PALUPF(savedslotupdate240f); +// } +// +// prop->lastupdateframe = g_Vars.updateframe; +// prop->propupdate240 = 0; +// prop->backgrounded = true; +// } +// } +// +// g_Vars.lvupdate240 = savedlvupdate240; +// g_Vars.lvupdate240_60 = savedlvupdate240_60; +// g_Vars.lvupdate240f = savedlvupdate240f; +// g_Vars.lvupdate240freal = savedlvupdate240freal; +// +// // 8a0 +// if (op == TICKOP_5) { +// // Use the prop->next value that was taken at the start of the tick +// sp60 = next; +// } else { +// // Use the current prop->next value +// sp60 = prop->next; +// done = sp60 == g_Vars.list2head; +// +// if (op == TICKOP_RETICK) { +// prop->lastupdateframe = 0xffff; +// prop->forcetick = true; +// +// propRemoveFromCurrentList(prop); +// propAppendToList1(prop); +// +// if (done) { +// sp60 = prop; +// done = false; +// } +// } else { +// propExecuteTickOperation(prop, op); +// } +// } +// +// prop = sp60; +// } +// +// // 93c +// // Redistribute propstates +// if (g_Vars.currentplayerindex == 0 && g_Vars.runstateindex == 0) { +// u16 least; +// u16 most; +// u8 mostindex; +// u8 leastindex; +// +// // 958 +// // propcount +// leastindex = mostindex = g_Vars.numpropstates; +// least = 0x7fff; +// most = 0; +// +// for (i = 0; i < g_Vars.numpropstates; i++) { +// if (g_Vars.propstates[i].propcount < least) { +// least = g_Vars.propstates[i].propcount; +// leastindex = i; +// } +// +// if (g_Vars.propstates[i].propcount > most) { +// most = g_Vars.propstates[i].propcount; +// mostindex = i; +// } +// } +// +// // 9c4 +// i = (g_Vars.propstates[(s32)mostindex].propcount - g_Vars.propstates[(s32)leastindex].propcount) >> 1; +// +// // 9f0 +// if (i != 0) { +// prop = g_Vars.list1head; +// +// while (prop != g_Vars.list2head) { +// if (prop->propstateindex == mostindex && prop->backgrounded == 1 && prop->type != PROPTYPE_CHR) { +// prop->propstateindex = leastindex; +// i--; +// +// if (i == 0) { +// break; +// } +// } +// +// prop = prop->next; +// } +// } +// +// // a60 +// // foregroundpropcount +// leastindex = mostindex = g_Vars.numpropstates; +// least = 0x7fff; +// most = 0; +// +// for (i = 0; i < g_Vars.numpropstates; i++) { +// if (g_Vars.propstates[i].foregroundpropcount < least) { +// least = g_Vars.propstates[i].foregroundpropcount; +// leastindex = i; +// } +// +// if (g_Vars.propstates[i].foregroundpropcount > most) { +// most = g_Vars.propstates[i].foregroundpropcount; +// mostindex = i; +// } +// } +// +// i = (g_Vars.propstates[(s32)mostindex].foregroundpropcount - g_Vars.propstates[(s32)leastindex].foregroundpropcount) >> 1; +// +// if (i != 0) { +// prop = g_Vars.list1head; +// +// while (prop != g_Vars.list2head) { +// if (mostindex == prop->propstateindex && prop->backgrounded == 0 && prop->type != PROPTYPE_CHR) { +// prop->propstateindex = leastindex; +// i--; +// +// if (i == 0) { +// break; +// } +// } +// +// prop = prop->next; +// } +// } +// +// // chrpropcount +// leastindex = mostindex = g_Vars.numpropstates; +// least = 0x7fff; +// most = 0; +// +// for (i = 0; i < g_Vars.numpropstates; i++) { +// if (g_Vars.propstates[i].chrpropcount < least) { +// least = g_Vars.propstates[i].chrpropcount; +// leastindex = i; +// } +// +// if (g_Vars.propstates[i].chrpropcount > most) { +// most = g_Vars.propstates[i].chrpropcount; +// mostindex = i; +// } +// } +// +// i = (g_Vars.propstates[(s32)mostindex].chrpropcount - g_Vars.propstates[(s32)leastindex].chrpropcount) >> 1; +// +// if (i != 0) { +// prop = g_Vars.list1head; +// +// while (prop != g_Vars.list2head) { +// if (mostindex == prop->propstateindex && prop->backgrounded == 1 && prop->type == PROPTYPE_CHR) { +// prop->propstateindex = leastindex; +// i--; +// +// if (i == 0) { +// break; +// } +// } +// +// prop = prop->next; +// } +// } +// +// // foregroundchrpropcount +// leastindex = mostindex = g_Vars.numpropstates; +// least = 0x7fff; +// most = 0; +// +// for (i = 0; i < g_Vars.numpropstates; i++) { +// if (g_Vars.propstates[i].foregroundchrpropcount < least) { +// least = g_Vars.propstates[i].foregroundchrpropcount; +// leastindex = i; +// } +// +// if (g_Vars.propstates[i].foregroundchrpropcount > most) { +// most = g_Vars.propstates[i].foregroundchrpropcount; +// mostindex = i; +// } +// } +// +// i = (g_Vars.propstates[(s32)mostindex].foregroundchrpropcount - g_Vars.propstates[(s32)leastindex].foregroundchrpropcount) >> 1; +// +// if (i != 0) { +// prop = g_Vars.list1head; +// +// while (prop != g_Vars.list2head) { +// if (mostindex == prop->propstateindex && prop->backgrounded == 0 && prop->type == PROPTYPE_CHR) { +// prop->propstateindex = leastindex; +// i--; +// +// if (i == 0) { +// break; +// } +// } +// +// prop = prop->next; +// } +// } +// } +// +// g_Vars.lvupdate240 = savedlvupdate240; +// g_Vars.lvupdate240_60 = savedlvupdate240_60; +// g_Vars.lvupdate240f = savedlvupdate240f; +// g_Vars.lvupdate240freal = savedlvupdate240freal; +// +// g_Vars.propstates[index].slotupdate240 = 0; +// g_Vars.propstates[index].lastupdateframe = g_Vars.updateframe; +// +// if (islastplayer) { +// alarmTick(); +// func0f093508(); +// func0f066054(); +// } +// +// func0f02472c(); +//} + GLOBAL_ASM( glabel func0f063dcc .late_rodata @@ -6163,7 +6752,7 @@ glabel var7f1a9f4c /* f06434c: 02002025 */ or $a0,$s0,$zero /* f064350: 00402825 */ or $a1,$v0,$zero .L0f064354: -/* f064354: 0fc18ad9 */ jal func0f062b64 +/* f064354: 0fc18ad9 */ jal propExecuteTickOperation /* f064358: 02002025 */ or $a0,$s0,$zero /* f06435c: 86220002 */ lh $v0,0x2($s1) /* f064360: 26310002 */ addiu $s1,$s1,0x2 @@ -6290,7 +6879,7 @@ glabel var7f1a9f4c /* f0635b4: 02002025 */ or $a0,$s0,$zero /* f0635b8: 00402825 */ or $a1,$v0,$zero .NB0f0635bc: -/* f0635bc: 0fc1877a */ jal func0f062b64 +/* f0635bc: 0fc1877a */ jal propExecuteTickOperation /* f0635c0: 02002025 */ or $a0,$s0,$zero /* f0635c4: 86220002 */ lh $v0,0x2($s1) /* f0635c8: 26310002 */ addiu $s1,$s1,0x2 diff --git a/src/game/propobj.c b/src/game/propobj.c index ae092165f..f1462d7b0 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -6202,7 +6202,7 @@ void func0f06ac90(struct prop *prop) * Child objects such as attached knives and mines will always have their props * freed. */ -void objRemove2(struct defaultobj *obj, bool freeprop, bool onlyunref) +void objRemove2(struct defaultobj *obj, bool freeprop, bool regen) { struct prop *child; @@ -6343,7 +6343,7 @@ void objRemove2(struct defaultobj *obj, bool freeprop, bool onlyunref) child = next; } - if (!onlyunref) { + if (!regen) { if (obj->prop->parent) { objDetach(obj->prop); } @@ -15364,7 +15364,7 @@ void func0f0706f8(struct prop *prop, bool arg1) struct prop *child; if (obj->hidden & OBJHFLAG_REAPABLE) { - objRemove2(obj, true, obj->hidden2 & OBJH2FLAG_04); + objRemove2(obj, true, obj->hidden2 & OBJH2FLAG_CANREGEN); } else { prop->flags &= ~PROPFLAG_02; func0f07063c(prop, arg1); @@ -46304,7 +46304,7 @@ u32 func0f07e474(struct prop *prop) escastepTick(prop); } - return 0; + return TICKOP_NONE; } s32 objTick(struct prop *prop) @@ -46316,7 +46316,7 @@ s32 objTick(struct prop *prop) bool pass2; struct prop *child; struct prop *next; - s32 result = 0; + s32 result = TICKOP_NONE; bool sp572 = false; u32 playercount = PLAYERCOUNT(); bool sp564 = true; @@ -46329,7 +46329,7 @@ s32 objTick(struct prop *prop) } else if ((obj->hidden & OBJHFLAG_AIRBORNE) && (obj->projectile->flags & PROJECTILEFLAG_00000800) == 0) { prop->flags &= ~PROPFLAG_02; obj->hidden |= OBJHFLAG_00000008; - return 3; + return TICKOP_RETICK; } if (obj->hidden & OBJHFLAG_REAPABLE) { @@ -46353,8 +46353,8 @@ s32 objTick(struct prop *prop) if (!pass) { func0f070698(prop, true); - objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_04); - return 1; + objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_CANREGEN); + return TICKOP_FREE; } } @@ -46567,7 +46567,7 @@ s32 objTick(struct prop *prop) sp592 = func0f073c6c(obj, &sp560); if (sp560) { - result = 5; + result = TICKOP_5; } } @@ -62913,7 +62913,7 @@ glabel var7f1aae70 // // // fa4 // if (v0 == 1 && (obj->hidden & OBJHFLAG_TAGGED) == 0) { -// objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_04); +// objRemove2(obj, false, obj->hidden2 & OBJH2FLAG_CANREGEN); // return 1; // } // @@ -69596,7 +69596,7 @@ bool propdoorInteract(struct prop *doorprop) door->base.flags2 |= OBJFLAG2_00000008; } - return false; + return TICKOP_NONE; } void alarmActivate(void) diff --git a/src/game/smoke/smoke.c b/src/game/smoke/smoke.c index 078dda3cc..866ce964e 100644 --- a/src/game/smoke/smoke.c +++ b/src/game/smoke/smoke.c @@ -2033,7 +2033,7 @@ glabel func0f12e848 /* f12f180: 27bd00d0 */ addiu $sp,$sp,0xd0 ); -u32 smokeUpdateZ(struct prop *prop) +u32 smokeTick(struct prop *prop) { Mtxf *matrix = currentPlayerGetMatrix1740(); @@ -2047,7 +2047,7 @@ u32 smokeUpdateZ(struct prop *prop) prop->flags |= PROPFLAG_40 | PROPFLAG_02; - return 0; + return TICKOP_NONE; } Gfx *smokeRender(struct prop *prop, Gfx *gdl, bool withalpha) diff --git a/src/include/constants.h b/src/include/constants.h index 0f971b6a1..f74a7ac30 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -2987,7 +2987,7 @@ // obj->hidden2 #define OBJH2FLAG_RENDEROPAQUE 0x01 #define OBJH2FLAG_RENDERALPHA 0x02 // must be immediately after OBJH2FLAG_RENDEROPAQUE -#define OBJH2FLAG_04 0x04 +#define OBJH2FLAG_CANREGEN 0x04 #define OBJH2FLAG_08 0x08 #define OBJH2FLAG_10 0x10 #define OBJH2FLAG_40 0x40 @@ -3714,6 +3714,13 @@ #define TICKMODE_CUTSCENE 6 #define TICKMODE_AUTOWALK 7 +#define TICKOP_NONE 0 +#define TICKOP_FREE 1 +#define TICKOP_DISABLE 2 +#define TICKOP_RETICK 3 +#define TICKOP_GIVETOPLAYER 4 +#define TICKOP_5 5 + #define TILEFLAG_0001 0x0001 // Editor: Traversable #define TILEFLAG_0002 0x0002 #define TILEFLAG_0004 0x0004 // Editor: Collisions diff --git a/src/include/data.h b/src/include/data.h index 7a03636cb..5052812c1 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -37,7 +37,7 @@ extern u32 _osShutdown; extern u32 __osGlobalIntMask; extern u32 var8005cf84; extern u8 g_LoadType; -extern s32 var8005d9d0; +extern s32 g_MainIsEndscreen; extern s32 var8005dd18; extern u32 var8005dd58; extern bool g_SndDisabled; diff --git a/src/include/game/chr/chr.h b/src/include/game/chr/chr.h index 0ee8d3c7c..1f00a053e 100644 --- a/src/include/game/chr/chr.h +++ b/src/include/game/chr/chr.h @@ -4,7 +4,7 @@ #include "data.h" #include "types.h" -void func0f01e250(void); +void propsTick2(void); void chrSetChrnum(struct chrdata *chr, s16 chrnum); void chrDeregister(s32 chrnum); void chrCalculatePushPos(struct chrdata *chr, struct coord *pos, s16 *rooms, bool arg3); @@ -25,8 +25,8 @@ void chrUpdateCloak(struct chrdata *chr); s32 func0f022be4(struct chrdata *chr); void chrSetPoisoned(struct chrdata *chr, struct prop *poisonprop); void chrTickPoisoned(struct chrdata *chr); -bool propchrDoFireslotThing(struct prop *prop); -bool func0f023098(struct prop *prop); +bool chrTickBeams(struct prop *prop); +s32 func0f023098(struct prop *prop); void chrDropItems(struct chrdata *chr); void chrSetHudpieceVisible(struct chrdata *chr, bool visible); void chrDropWeapons(struct chrdata *chr); diff --git a/src/include/game/explosions/explosions.h b/src/include/game/explosions/explosions.h index 660ad5f57..b68009529 100644 --- a/src/include/game/explosions/explosions.h +++ b/src/include/game/explosions/explosions.h @@ -15,7 +15,7 @@ void func0f12acec(struct coord *arg0, struct coord *arg1, struct coord *arg2); bool func0f12af5c(struct explosion *exp, struct prop *prop, struct coord *pos1, struct coord *pos2); u32 func0f12b0e0(void); u32 func0f12bbdc(struct prop *prop); -u32 explosionUpdateZ(struct prop *prop); +u32 explosionTick(struct prop *prop); Gfx *explosionRender(struct prop *prop, Gfx *gdl, bool withalpha); Gfx *explosionRenderPart(struct explosion *exp, struct explosionpart *part, Gfx *gdl, struct coord *coord, s32 arg4); diff --git a/src/include/game/game_0b69d0.h b/src/include/game/game_0b69d0.h index 5cf434845..54b2e33dd 100644 --- a/src/include/game/game_0b69d0.h +++ b/src/include/game/game_0b69d0.h @@ -75,8 +75,8 @@ f32 currentPlayerGetHealthFrac(void); f32 currentPlayerGetShieldFrac(void); void currentPlayerSetShieldFrac(f32 frac); s32 getMissionTime(void); -s32 func0f0c228c(struct prop *prop); -u32 func0f0c2364(void); +s32 playerTickBeams(struct prop *prop); +s32 playerTick(struct prop *prop); void func0f0c2a58(struct chrdata *chr, s32 crouchpos, f32 arg2, f32 arg3, f32 arg4, f32 *arg5, struct attackanimconfig **arg6); Gfx *playerRender(struct prop *prop, Gfx *gdl, bool withalpha); Gfx *currentPlayerLoadMatrix(Gfx *gdl); diff --git a/src/include/game/game_190260.h b/src/include/game/game_190260.h index 0cacbcd3d..55f7fb74d 100644 --- a/src/include/game/game_190260.h +++ b/src/include/game/game_190260.h @@ -15,7 +15,7 @@ void func0f19124c(struct chrdata *chr); s32 chrGuessCrouchPos(struct chrdata *chr); bool func0f191448(struct chrdata *chr); bool func0f191638(struct chrdata *chr, bool arg1); -bool aibotTick(struct prop *prop); +s32 aibotTick(struct prop *prop); f32 aibotCalculateMaxSpeed(struct chrdata *chr); void func0f1921f8(struct chrdata *chr, f32 *arg1, s32 arg2, f32 arg3); void aibotLoseGun(struct chrdata *chr, struct prop *attacker); diff --git a/src/include/game/prop.h b/src/include/game/prop.h index f8c490a98..d2aa73860 100644 --- a/src/include/game/prop.h +++ b/src/include/game/prop.h @@ -27,13 +27,13 @@ u32 func0f061fa8(void); void handInflictCloseRangeDamage(s32 handnum, struct gset *gset, bool arg2); void handTickAttack(s32 handnum); void handsTickAttack(void); -void func0f062b64(struct prop *prop, s32 arg1); +void propExecuteTickOperation(struct prop *prop, s32 op); struct prop *currentPlayerFindPropForInteract(bool eyespy); void func0f062dd0(void); bool currentPlayerInteract(bool eyespy); void propPrependToList2(struct prop *prop); void propMoveFromList2To1(struct prop *prop); -void func0f06302c(ubool arg0); +void propsTick(u32 islastplayer); void func0f063dcc(void); void propSetCollisionsEnabled(struct prop *prop, bool enable); void func0f0641f4(void); diff --git a/src/include/game/propobj.h b/src/include/game/propobj.h index d78cb2f60..c03ce062e 100644 --- a/src/include/game/propobj.h +++ b/src/include/game/propobj.h @@ -106,7 +106,7 @@ void func0f06a730(struct defaultobj *obj, struct pad *newpad, Mtxf *matrix, s16 u32 func0f06ab60(void); void objEndFlight(struct defaultobj *obj); void func0f06ac90(struct prop *prop); -void objRemove2(struct defaultobj *obj, bool freeprop, bool onlyunref); +void objRemove2(struct defaultobj *obj, bool freeprop, bool regen); void objRemove(struct defaultobj *obj, bool freeprop); u32 func0f06b36c(void); bool func0f06b39c(struct coord *arg0, struct coord *arg1, struct coord *arg2, f32 arg3); diff --git a/src/include/game/smoke/smoke.h b/src/include/game/smoke/smoke.h index 7b50b2fd1..c48c4fe56 100644 --- a/src/include/game/smoke/smoke.h +++ b/src/include/game/smoke/smoke.h @@ -13,7 +13,7 @@ void func0f12e74c(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, u3 void smokeClearForProp(struct prop *prop); struct smoke *smokeCreateSimple(struct coord *pos, s16 *rooms, s16 type); u32 func0f12e848(struct prop *prop); -u32 smokeUpdateZ(struct prop *prop); +u32 smokeTick(struct prop *prop); Gfx *smokeRender(struct prop *prop, Gfx *gdl, bool withalpha); void smokeClearSomeTypes(void); diff --git a/src/include/types.h b/src/include/types.h index ef60b1f5d..c6d9995d6 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -46,11 +46,11 @@ struct propstate { /*0x02*/ u16 chrpropcount; /*0x04*/ u16 foregroundpropcount; /*0x06*/ u16 foregroundchrpropcount; - /*0x08*/ u32 updatetime; - /*0x0c*/ u32 chrupdatetime; - /*0x10*/ u32 slotupdate240; - /*0x14*/ u32 slotupdate60error; - /*0x18*/ u32 lastupdateframe; + /*0x08*/ s32 updatetime; + /*0x0c*/ s32 chrupdatetime; + /*0x10*/ s32 slotupdate240; + /*0x14*/ s32 slotupdate60error; + /*0x18*/ u16 lastupdateframe; }; struct playerstats { @@ -167,12 +167,12 @@ struct g_vars { /*00034c*/ struct prop **unk00034c; /*000350*/ struct prop *unk000350; /*000354*/ struct prop *list2head; // prev pointer points to list1tail - /*000358*/ u8 numpropstateindexes; - /*000359*/ u8 nextpropstateindex; - /*00035a*/ u8 unk00035a; - /*00035b*/ u8 unk00035b; - /*00035c*/ u16 unk00035c; - /*00035e*/ u16 unk00035e; + /*000358*/ u8 numpropstates; + /*000359*/ u8 allocstateindex; + /*00035a*/ u8 runstateindex; + /*00035b*/ u8 alwaystick; + /*00035c*/ u16 updateframe; + /*00035e*/ u16 prevupdateframe; /*000360*/ struct propstate propstates[7]; /*000424*/ struct chrdata *chrdata; /*000428*/ struct truckobj *truck; @@ -409,13 +409,13 @@ struct prop { /*0x20*/ struct prop *next; /*0x24*/ struct prop *prev; /*0x28*/ s16 rooms[8]; - /*0x38*/ u16 unk38; - /*0x3a*/ s16 unk3a; - /*0x3c*/ u8 unk3c; + /*0x38*/ u16 lastupdateframe; + /*0x3a*/ u16 propupdate240; + /*0x3c*/ u8 propupdate60err; /*0x3d*/ u8 propstateindex; /*0x3e*/ u8 unk3e; - /*0x3f*/ u8 unk3f_00 : 1; - /*0x3f*/ u8 unk3f_01 : 1; + /*0x3f*/ u8 forcetick : 1; + /*0x3f*/ u8 backgrounded : 1; /*0x3f*/ u8 unk3f_02 : 1; /*0x3f*/ u8 inlist1 : 1; /*0x3f*/ u8 unk3f_04 : 1; diff --git a/src/lib/main.c b/src/lib/main.c index 738b30132..fcd037cd4 100644 --- a/src/lib/main.c +++ b/src/lib/main.c @@ -69,7 +69,7 @@ s32 var8005d9c0 = 0; s32 var8005d9c4 = 0; s32 var8005d9c8 = 1; u32 var8005d9cc = 0; -s32 var8005d9d0 = 0; +bool g_MainIsEndscreen = false; s32 g_DoBootPakMenu = 0; struct stageallocation g_StageAllocations8Mb[] = { @@ -1782,7 +1782,7 @@ void mainLoop(void) var8005d9cc = 0; var8005d9c8 = 1; msg = NULL; - var8005d9d0 = 0; + g_MainIsEndscreen = false; if (var8005d9b0 && var8005d9c4 == 0) { index = -1; @@ -3045,7 +3045,7 @@ void mainEndStage(void) { sndStopNosedive(); - if (var8005d9d0 == 0) { + if (!g_MainIsEndscreen) { #if VERSION >= VERSION_NTSC_1_0 func0f11c6d0(); #endif @@ -3081,7 +3081,7 @@ void mainEndStage(void) } } - var8005d9d0 = 1; + g_MainIsEndscreen = true; } void mainSetStageNum(s32 stagenum)