decomp progress

This commit is contained in:
Niko 2022-12-29 14:45:45 -05:00
parent 24956c3176
commit 4771a570f4
6 changed files with 302 additions and 36 deletions

View File

@ -0,0 +1,244 @@
#include <common.h>
void DECOMP_RB_Turtle_ThTick(struct Thread* t)
{
struct Turtle* turtleObj;
struct Instance* turtleInst;
int currTimer;
int newTimer;
turtleObj = t->object;
turtleInst = t->inst;
// 0 from moment it hits bottom to moment it hits top
if(turtleObj->direction == 0)
{
// use timer variables for milliseconds
currTimer = turtleObj->timer;
// if less than 1.0 seconds
// wait for rise
if(currTimer < 0x3c0)
{
// increment
currTimer += sdata->gGT->elapsedTimeMS;
// set
turtleObj->timer = currTimer;
// == fixed Naughty Dog bug ==
#if 0
// Naughty Dog "intended" this
if(currTimer >= 0x3c0)
{
turtleObj->timer = 0x3c0;
PlaySound3D(0x7d, turtleInst);
}
#else
// but for the sake of a functionally
// identical decomp that represents
// the "shipped" game
if(currTimer > 0x3c0)
{
turtleObj->timer = 0x3c0;
}
#endif
}
// if more than one second has passed
// time to rise
else
{
// turtle not fully down,
// impacts jumping
turtleObj->state = 1;
// use timer variables for frame counting
// decrement frame (make turtle rise)
currTimer = turtleInst->animFrame - 1;
// end of animation
if(currTimer < 1)
{
// reset direction
turtleObj->direction = 1;
// reset timer
turtleObj->timer = 0;
}
// playing animation
else
{
// decrement frame (make turtle rise)
turtleInst->animFrame = currTimer;
}
}
}
// 1 from moment it hits top to moment it hits bottom
else
{
// use timer variables for milliseconds
currTimer = turtleObj->timer;
// if less than 1.0 seconds
// wait for fall
if(currTimer < 0x3c0)
{
// increment
currTimer += sdata->gGT->elapsedTimeMS;
// set
turtleObj->timer = currTimer;
// == fixed Naughty Dog bug ==
if(currTimer > 0x3c0)
{
turtleObj->timer = 0x3c0;
}
}
// if more than one second has passed
// time to fall
else
{
// use timer variables for frame counting
// increment frame (make turtle fall)
currTimer = turtleInst->animFrame + 1;
// playing animation
if(currTimer < INSTANCE_GetNumAnimFrames(turtleInst, 0))
{
// increment frame (make turtle fall)
turtleInst->animFrame = currTimer;
}
// finished animation
else
{
// reset direction
turtleObj->direction = 0;
// reset timer
turtleObj->timer = 0;
// turtle is "fully" down
turtleObj->state = 0;
}
}
}
}
int DECOMP_RB_Turtle_LInC(struct Instance* inst, struct Thread* driverTh)
{
int speed;
int jumpType;
struct Driver* driver;
driver = driverTh->object;
// absolute value
speed = driver->speedApprox;
if(speed < 0) speed = -speed;
if(speed > 0x1400)
{
// small jump
jumpType = 1;
if(
// turtleObj->state != FULLY_DOWN
((struct Turtle*)inst->thread->object)
->state != 0
)
{
// big jump
jumpType = 2;
}
// make the player jump
driver->forcedJump_trampoline = jumpType;
return 2;
}
return 1;
}
void DECOMP_RB_Turtle_LInB(struct Instance* inst)
{
int turtleID;
struct Thread* t;
struct Turtle* turtleObj;
inst->flags |= 0x2000;
t =
THREAD_BirthWithObject
(
// creation flags
SIZE_RELATIVE_POOL_BUCKET
(
sizeof(struct Turtle),
NONE,
SMALL,
STATIC
),
DECOMP_RB_Turtle_ThTick, // behavior
0, // debug name
0 // thread relative
);
if(t == 0) return;
inst->thread = t;
t->inst = inst;
inst->scale[0] = 0x1000;
inst->scale[1] = 0x1000;
inst->scale[2] = 0x1000;
// double-digit number,
turtleID = inst->name[8];
// take [8] and check for null character (0x00)
// switch to [7] if [8] is invalid
if(turtleID == 0) turtleID = inst->name[7];
// one turtle is just "turtle" with no number
if(turtleID == 0) turtleID = 1;
// dont subtract '0', just do & 1,
// that'll work fine
turtleObj = ((struct Turtle*)t->object);
turtleObj->timer = 0;
// put turtles on different cycles, based on turtleID
if((turtleID & 1) == 0)
{
// fully up
turtleObj->direction = 1;
turtleObj->state = 1; // "not fully down"
inst->animFrame = 0;
return;
}
// fully down
turtleObj->direction = 0;
turtleObj->state = 0;
inst->animFrame = INSTANCE_GetNumAnimFrames(inst, 0);
}

View File

@ -274,7 +274,7 @@ u_int main()
// Process all gamepad input
GAMEPAD_UpdateAll(sdata->gGamepads);
// Niko testing armadillo,
// Niko testing turtles,
// dont erase, will be used for many future tests
#if 0
// disable spawn
@ -286,20 +286,11 @@ u_int main()
if(sdata->gGamepads->gamepad[0].buttonsTapped & BTN_L2)
{
gGT->drivers[0]->posCurr[0] = 0x13F5BF;
gGT->drivers[0]->posCurr[1] = 0x8FFB3;
gGT->drivers[0]->posCurr[2] = 0xFFECB546;
gGT->drivers[0]->angle = 0x1E8;
gGT->drivers[0]->posCurr[0] = 0xfc394;
gGT->drivers[0]->posCurr[1] = 0x188;
gGT->drivers[0]->posCurr[2] = 0xFFFD93BC;
gGT->drivers[0]->angle = 0xAA4;
}
if(sdata->gGamepads->gamepad[0].buttonsTapped & BTN_R2)
{
gGT->drivers[0]->posCurr[0] = 0x52430e;
gGT->drivers[0]->posCurr[1] = 0x2ff58;
gGT->drivers[0]->posCurr[2] = 0x255f7a;
gGT->drivers[0]->angle = 0xbb4;
}
#endif
// Start new frame (ClearOTagR)
@ -543,7 +534,7 @@ void StateZero()
// Niko testing, override level
// for instant-boot, dont erase
#if 0
gGT->levelID = 0;
gGT->levelID = 9;
//gGT->numPlayers = 4;
//gGT->numScreens = 4;
#endif

View File

@ -18,8 +18,8 @@ void DECOMP_RB_Blade_LInB();
void DECOMP_RB_Seal_LInB();
void RB_Orca_LInB();
void RB_Baron_LInB();
void RB_Turtle_LInB();
void RB_Turtle_LInC();
void DECOMP_RB_Turtle_LInB();
void DECOMP_RB_Turtle_LInC();
void RB_Spider_LInB();
void RB_Fireball_LInB();
void RB_StartText_LInB();
@ -322,7 +322,7 @@ struct MetaDataModel mdm[0xe2] =
SET_MDM(0,RB_Minecart_LInB,0),
// 0x51 - DYNAMIC_TURTLE (mystery caves)
SET_MDM(0,RB_Turtle_LInB,RB_Turtle_LInC),
SET_MDM(0,DECOMP_RB_Turtle_LInB,DECOMP_RB_Turtle_LInC),
// 0x52 - DYNAMIC_SPIDER (cortex castle)
SET_MDM(0,RB_Spider_LInB,0),

View File

@ -35,6 +35,8 @@ common, 231, RB_Armadillo_ThTick_TurnAround, 0x0, General/231/231_080_083_RB_Arm
common, 231, RB_Fruit_ThTick, 0x0, General/231/231_093_096_RB_Fruit.c
// skip a bunch
common, 231, RB_Seal_ThTick_TurnAround, 0x0, General/231/231_108_111_RB_Seal.c
// skip a bunch
common, 231, RB_Turtle_ThTick, 0x0, General/231/231_125_127_RB_Turtle.c
// 232 (incomplete)
common, 232, AH_WarpPad_GetSpawnPosRot, 0x0, General/232/232_01_AH_WarpPad_GetSpawnPosRot.c

View File

@ -13144,10 +13144,12 @@ void FUN_800ba2c0(int param_1)
// thread -> instance
iVar5 = *(int *)(param_1 + 0x34);
// 0 from moment it hits bottom to moment it hits top
if (psVar4[1] == 0) {
sVar1 = *psVar4;
// if less than 1.0 seconds
// wait for rise
if (*psVar4 < 0x3c0)
{
// get elapsed ms per frame ~32
@ -13156,6 +13158,14 @@ void FUN_800ba2c0(int param_1)
// add milliseconds
*psVar4 = sVar1 + sVar2;
// Naughty Dog bug, should have just been:
// if (0x3c0 < sVar1+sVar2)
// *psVar4 = 0x3c0
// play sound
// Then the original "if < 0x3c0"
// goes to "else" next frame
// if more than 1.5 seconds passed
if (0x5a0 < (short)(sVar1 + sVar2))
{
@ -13165,45 +13175,47 @@ void FUN_800ba2c0(int param_1)
// if 1.5s passed
if (*psVar4 == 0x5a0)
{
// NOP 800ba3c4 to make this work
// bug?
{
// play water sound
FUN_8002f0dc(0x7d,iVar5);
}
}
// if more than one second has passed
// time to rise
else
{
// turtle is now up
// turtle not fully down,
// impacts jumping
psVar4[4] = 1;
// instance -> animFrame is at beginning
// end of animation
if ((int)*(short *)(iVar5 + 0x54) + -1 < 1)
{
// reset direction
psVar4[1] = 1;
// reset timer to zero
*psVar4 = 0;
}
// if you are not on first animation frame
// playing animation
else
{
// play animation backwards
// decrement frame (make turtle rise)
*(short *)(iVar5 + 0x54) = *(short *)(iVar5 + 0x54) + -1;
}
}
}
// 1 from moment it hits top to moment it hits bottom
else
{
// get timer
sVar1 = *psVar4;
// if less than 1.0 seconds
// wait for time to fall
if (*psVar4 < 0x3c0)
{
// get elaped time
@ -13211,6 +13223,8 @@ void FUN_800ba2c0(int param_1)
// add milliseconds
*psVar4 = sVar1 + sVar2;
// Naughty Dog bug, should be 0x3c0
// if more than 1.5s
if (0x5a0 < (short)(sVar1 + sVar2))
@ -13221,6 +13235,7 @@ void FUN_800ba2c0(int param_1)
}
// if more than 1.0s
// time to fall
else
{
// get animation frame
@ -13232,16 +13247,20 @@ void FUN_800ba2c0(int param_1)
// if animation is not done
if ((int)sVar1 + 1 < iVar3)
{
// increment animation frame
// increment frame (make turtle fall)
*(short *)(iVar5 + 0x54) = *(short *)(iVar5 + 0x54) + 1;
}
// if animation is done
else {
else
{
// reset direction
psVar4[1] = 0;
// reset timer
*psVar4 = 0;
// turtle is down
// turtle is fully down
psVar4[4] = 0;
}
}
@ -13269,7 +13288,7 @@ undefined4 FUN_800ba420(int param_1,int param_2)
// small jump
uVar2 = 1;
// if turtleInst->thread->object->state != STATE_DOWN (== STATE_UP)
// if turtleInst->thread->object->state != FullyDown
if (*(short *)(*(int *)(*(int *)(param_1 + 0x6c) + 0x30) + 8) != 0) {
// big jump
@ -13326,7 +13345,10 @@ void FUN_800ba470(int param_1)
// turtleID
puVar3[2] = (ushort)*(byte *)(iVar2 + param_1 + 7) - 0x30;
// default direction (waste)
puVar3[1] = 1;
// reset timer
*puVar3 = 0;
// restart animation, set frame to zero
@ -13335,23 +13357,20 @@ void FUN_800ba470(int param_1)
// put turtles on different cycles, based on turtleID
if ((puVar3[2] & 1) == 0)
{
// turtle is fully up
puVar3[1] = 1;
// turtle is up
puVar3[4] = 1;
}
else
{
// turtle is fully down
puVar3[1] = 0;
// turtle is down
puVar3[4] = 0;
// INSTANCE_GetNumAnimFrames
// last frame of fall animation
uVar1 = FUN_80030f58(param_1,0);
// set animation frame to last frame
*(undefined2 *)(param_1 + 0x54) = uVar1;
}
}

View File

@ -3322,11 +3322,21 @@ struct Turtle
{
// 0x0
short timer;
// 0x2
// 0 from moment it hits top to moment it hits bottom
// 1 from moment it hits bottom to moment it hits top
short direction;
// 0x4
short unk4;
// 0x6
short turtleID;
// 0x8
// 0 - fully up (big jump)
// 1 - not fully up (small jump)
short state;
// 0xC bytes large