Document lll_octagonal_rotating_mesh.inc.c

This commit is contained in:
iProgramMC 2021-07-19 11:26:18 +03:00
parent f9982e0ef5
commit d9fefad35f
2 changed files with 85 additions and 40 deletions

View File

@ -582,6 +582,13 @@
#define /*0x104*/ oHorizontalMovementUnk104 OBJECT_FIELD_S32(0x1F)
#define /*0x108*/ oHorizontalMovementUnk108 OBJECT_FIELD_F32(0x20)
/* LLL Octagonal Rotating Mesh */
#define /*0x0F4*/ oLllOctmeshWaveTimer OBJECT_FIELD_S32(0x1B)
#define /*0x0F8*/ oLllOctmeshActionOffset OBJECT_FIELD_S32(0x1C)
#define /*0x100*/ oLllOctmeshWaveOffset1 OBJECT_FIELD_F32(0x1E)
#define /*0x104*/ oLllOctmeshStandTimer OBJECT_FIELD_S32(0x1F)
#define /*0x108*/ oLllOctmeshWaveOffset2 OBJECT_FIELD_F32(0x20)
/* Kickable Board */
#define /*0x0F4*/ oKickableBoardF4 OBJECT_FIELD_S32(0x1B)
#define /*0x0F8*/ oKickableBoardF8 OBJECT_FIELD_S32(0x1C)

View File

@ -1,59 +1,89 @@
// lll_octagonal_rotating_mesh.c.inc
s16 D_8032F860[] = { 2, 30, 0x4000, 0, 1, 220, 900, 30, 1, 30, 0, -30, 2,
30, -0x4000, 0, 1, 220, 900, 30, 1, 30, 0, -30, 3, 0 };
s16 D_8032F894[] = { 4, 0, 0, 0, 1, 475, 900, 30, 1, 30, 0, -30, 2,
30, 0x8000, 0, 1, 475, 900, 30, 1, 30, 0, -30, 3, 0 };
s16 *D_8032F8C8[] = { D_8032F860, D_8032F894 };
enum {
LLL_OCTMESH_CHANGE_DIR = 1, // 1
LLL_OCTMESH_LINEAR_MOVE, // 2
LLL_OCTMESH_RESET, // 3
LLL_OCTMESH_WAIT_FOR_MARIO // 4
};
//! Note: useless zero at the reset instruction, there's no accesses beyond that anyway
s16 gLllOctagonalMeshAction0[] = {
// instruction time moveAngle forwardVel
LLL_OCTMESH_LINEAR_MOVE, 30, 0x4000, 0,
LLL_OCTMESH_CHANGE_DIR, 220, 900, 30,
LLL_OCTMESH_CHANGE_DIR, 30, 0, -30,
LLL_OCTMESH_LINEAR_MOVE, 30, -0x4000, 0,
LLL_OCTMESH_CHANGE_DIR, 220, 900, 30,
LLL_OCTMESH_CHANGE_DIR, 30, 0, -30,
LLL_OCTMESH_RESET, 0
};
s16 gLllOctagonalMeshAction1[] = {
// instruction time moveAngle forwardVel
LLL_OCTMESH_WAIT_FOR_MARIO, 0, 0, 0,
LLL_OCTMESH_CHANGE_DIR, 475, 900, 30,
LLL_OCTMESH_CHANGE_DIR, 30, 0, -30,
LLL_OCTMESH_LINEAR_MOVE, 30, 0x8000, 0,
LLL_OCTMESH_CHANGE_DIR, 475, 900, 30,
LLL_OCTMESH_CHANGE_DIR, 30, 0, -30,
LLL_OCTMESH_RESET, 0
};
// picked by oBehParams2ndByte
s16 *gLllOctagonalMeshActionList[] = { gLllOctagonalMeshAction0, gLllOctagonalMeshAction1 };
s32 lll_octagonal_mesh_move(s16 *a0, s32 a1) {
switch (a0[a1]) {
case 4:
o->oMoveAngleYaw = a0[a1 + 2];
o->oForwardVel = a0[a1 + 3] / 100.0f;
s32 lll_octagonal_mesh_move(s16 *actionTable, s32 actionOffset) {
switch (actionTable[actionOffset]) {
case LLL_OCTMESH_WAIT_FOR_MARIO:
o->oMoveAngleYaw = actionTable[actionOffset + 2];
o->oForwardVel = actionTable[actionOffset + 3] / 100.0f;
if (cur_obj_is_mario_on_platform()) {
a1 += 4;
actionOffset += 4;
o->oTimer = 0;
}
break;
case 2:
o->oMoveAngleYaw = a0[a1 + 2];
o->oForwardVel = a0[a1 + 3] / 100.0f;
if (o->oTimer > a0[a1 + 1]) {
a1 += 4;
case LLL_OCTMESH_LINEAR_MOVE:
o->oMoveAngleYaw = actionTable[actionOffset + 2];
o->oForwardVel = actionTable[actionOffset + 3] / 100.0f;
if (o->oTimer > actionTable[actionOffset + 1]) {
actionOffset += 4;
o->oTimer = 0;
}
break;
case 1:
approach_f32_signed(&o->oForwardVel, a0[a1 + 2] / 100.0f, a0[a1 + 3] / 100.0f);
if (o->oTimer > a0[a1 + 1]) {
a1 += 4;
case LLL_OCTMESH_CHANGE_DIR:
approach_f32_signed(&o->oForwardVel, actionTable[actionOffset + 2] / 100.0f, actionTable[actionOffset + 3] / 100.0f);
if (o->oTimer > actionTable[actionOffset + 1]) {
actionOffset += 4;
o->oTimer = 0;
}
break;
case 3:
case LLL_OCTMESH_RESET:
o->oForwardVel = 0.0f;
a1 = 0;
actionOffset = 0;
break;
}
return a1;
return actionOffset;
}
s32 lll_octagonal_mesh_find_y_offset(s32 *a0, f32 *a1, s32 a2, s32 a3) {
s32 lll_octagonal_mesh_find_y_offset(s32 *standTimer, f32 *posOffset, s32 standTimerInc, s32 moveDownAmount) {
// if Mario is on the platform...
if (cur_obj_is_mario_on_platform()) {
if (a0[0] < 0x4000)
a0[0] += a2;
// move standTimer up by 'standTimerInc' until it hits 0x4000
// since standTimerInc is 0x400, this takes 10 frames, or 1/3 seconds
if (standTimer[0] < 0x4000)
standTimer[0] += standTimerInc;
else
a0[0] = 0x4000;
standTimer[0] = 0x4000;
} else {
if (a0[0] > 0)
a0[0] -= a2;
// move standTimer back down to zero
if (standTimer[0] > 0)
standTimer[0] -= standTimerInc;
else
a0[0] = 0;
standTimer[0] = 0;
}
a1[0] = sins(a0[0]) * a3;
if (a0[0] == 0 || a0[0] == 0x4000)
posOffset[0] = sins(standTimer[0]) * moveDownAmount;
if (standTimer[0] == 0 || standTimer[0] == 0x4000)
return 1;
else
return 0;
@ -61,16 +91,24 @@ s32 lll_octagonal_mesh_find_y_offset(s32 *a0, f32 *a1, s32 a2, s32 a3) {
void bhv_lll_moving_octagonal_mesh_platform_loop(void) {
if (o->oAction == 0) {
o->oHorizontalMovementUnkF8 = 0;
// reset the platform (when initting?)
o->oLllOctmeshActionOffset = 0;
o->oAction++;
} else
o->oHorizontalMovementUnkF8 =
lll_octagonal_mesh_move(D_8032F8C8[o->oBehParams2ndByte], o->oHorizontalMovementUnkF8);
print_debug_top_down_objectinfo("number %d\n", o->oHorizontalMovementUnkF8);
o->oLllOctmeshActionOffset =
lll_octagonal_mesh_move(gLllOctagonalMeshActionList[o->oBehParams2ndByte], o->oLllOctmeshActionOffset);
// prints the current actionOffset to the screen
print_debug_top_down_objectinfo("number %d\n", o->oLllOctmeshActionOffset);
cur_obj_move_using_fvel_and_gravity();
if (lll_octagonal_mesh_find_y_offset(&o->oHorizontalMovementUnk104, &o->oHorizontalMovementUnk108, 0x400, -80)) {
o->oHorizontalMovementUnkF4 += 0x800;
o->oHorizontalMovementUnk100 -= sins(o->oHorizontalMovementUnkF4) * 2;
// are we transitioning between Mario standing and not standing?
if (lll_octagonal_mesh_find_y_offset(&o->oLllOctmeshStandTimer, &o->oLllOctmeshWaveOffset2, 0x400, -80)) {
// nope, wave as usual
o->oLllOctmeshWaveTimer += 0x800;
o->oLllOctmeshWaveOffset1 -= sins(o->oLllOctmeshWaveTimer) * 2;
}
o->oPosY = o->oHorizontalMovementUnk100 + o->oHomeY + o->oHorizontalMovementUnk108;
//! oHomeY is not initialized, it's always 0. Moving the object upwards in the script has no effect.
o->oPosY = o->oLllOctmeshWaveOffset1 + o->oHomeY + o->oLllOctmeshWaveOffset2;
}