Implement FakeObjects (Just poles for now)
Build libsm64 / Build libsm64 for linux (push) Successful in 33s
Build libsm64 / Build libsm64 for web (push) Successful in 30s
Build libsm64 / Build libsm64 for windows (push) Successful in 23s

This commit is contained in:
2026-05-31 16:44:11 -05:00
parent b096207a10
commit ede2099ff5
12 changed files with 418 additions and 25 deletions
+57 -1
View File
@@ -71,6 +71,62 @@ static u32 interact_noop(struct MarioState *m, u32 interactType, struct Object *
return FALSE;
}
void push_mario_out_of_object(struct MarioState *m, struct Object *o, f32 padding);
void reset_mario_pitch(struct MarioState *m);
static u32 interact_pole(struct MarioState *m, u32 interactType, struct Object *o)
{
s32 actionId = m->action & ACT_ID_MASK;
if (actionId >= 0x080 && actionId < 0x0A0)
{
#if defined(VERSION_SH) || defined(VERSION_CN)
f32 velConv = m->forwardVel; // conserve the velocity.
struct Object *marioObj = m->marioObj;
u32 lowSpeed;
#else
u32 lowSpeed = (m->forwardVel <= 10.0f);
struct Object *marioObj = m->marioObj;
#endif
if (!(m->prevAction & ACT_FLAG_ON_POLE) || m->usedObj != o)
{
#if defined(VERSION_SH) || defined(VERSION_CN)
lowSpeed = (velConv <= 10.0f);
#endif
mario_stop_riding_and_holding(m);
m->interactObj = o;
m->usedObj = o;
m->vel[1] = 0.0f;
m->forwardVel = 0.0f;
marioObj->oMarioPoleUnk108 = 0;
marioObj->oMarioPoleYawVel = 0;
marioObj->oMarioPolePos = m->pos[1] - o->oPosY;
if (lowSpeed)
{
return set_mario_action(m, ACT_GRAB_POLE_SLOW, 0);
}
#if defined(VERSION_SH) || defined(VERSION_CN)
marioObj->oMarioPoleYawVel = (s32)(velConv * 0x100 + 0x1000);
#else
marioObj->oMarioPoleYawVel = (s32)(m->forwardVel * 0x100 + 0x1000);
#endif
reset_mario_pitch(m);
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
return set_mario_action(m, ACT_GRAB_POLE_FAST, 0);
}
}
return FALSE;
}
static struct InteractionHandler sInteractionHandlers[] = {
{INTERACT_COIN, interact_noop},
{INTERACT_WATER_RING, interact_noop},
@@ -94,7 +150,7 @@ static struct InteractionHandler sInteractionHandlers[] = {
{INTERACT_HIT_FROM_BELOW, interact_noop},
{INTERACT_BOUNCE_TOP, interact_noop},
{INTERACT_DAMAGE, interact_noop},
{INTERACT_POLE, interact_noop},
{INTERACT_POLE, interact_pole},
{INTERACT_HOOT, interact_noop},
{INTERACT_BREAKABLE, interact_noop},
{INTERACT_KOOPA, interact_noop},
+12 -10
View File
@@ -123,8 +123,7 @@ s32 set_pole_position(struct MarioState *m, f32 offsetY)
}
vec3f_copy(m->marioObj->header.gfx.pos, m->pos);
vec3s_set(m->marioObj->header.gfx.angle, m->usedObj->oMoveAnglePitch, m->faceAngle[1],
m->usedObj->oMoveAngleRoll);
vec3s_set(m->marioObj->header.gfx.angle, m->usedObj->oMoveAnglePitch, m->faceAngle[1], m->usedObj->oMoveAngleRoll);
return result;
}
@@ -132,6 +131,7 @@ s32 set_pole_position(struct MarioState *m, f32 offsetY)
s32 act_holding_pole(struct MarioState *m)
{
struct Object *marioObj = m->marioObj;
f32 poleStickY = -m->controller->stickY;
#ifdef VERSION_JP
if (m->input & INPUT_A_PRESSED)
@@ -163,7 +163,7 @@ s32 act_holding_pole(struct MarioState *m)
}
#endif
if (m->controller->stickY > 16.0f)
if (poleStickY > 16.0f)
{
f32 poleTop = m->usedObj->hitboxHeight - 100.0f;
// const BehaviorScript *poleBehavior = virtual_to_segmented(0x13, m->usedObj->behavior);
@@ -174,15 +174,15 @@ s32 act_holding_pole(struct MarioState *m)
}
// if (poleBehavior != bhvGiantPole && m->controller->stickY > 50.0f) {
if (m->controller->stickY > 50.0f)
if (poleStickY > 50.0f)
{
return set_mario_action(m, ACT_TOP_OF_POLE_TRANSITION, 0);
}
}
if (m->controller->stickY < -16.0f)
if (poleStickY < -16.0f)
{
marioObj->oMarioPoleYawVel -= m->controller->stickY * 2;
marioObj->oMarioPoleYawVel -= poleStickY * 2;
if (marioObj->oMarioPoleYawVel > 0x1000)
{
marioObj->oMarioPoleYawVel = 0x1000;
@@ -223,6 +223,7 @@ s32 act_climbing_pole(struct MarioState *m)
s32 sp24;
struct Object *marioObj = m->marioObj;
s16 cameraAngle = m->area->camera->yaw;
f32 poleStickY = -m->controller->stickY;
#ifndef VERSION_JP
if (m->health < 0x100)
@@ -240,18 +241,18 @@ s32 act_climbing_pole(struct MarioState *m)
return set_mario_action(m, ACT_WALL_KICK_AIR, 0);
}
if (m->controller->stickY < 8.0f)
if (poleStickY < 8.0f)
{
return set_mario_action(m, ACT_HOLDING_POLE, 0);
}
marioObj->oMarioPolePos += m->controller->stickY / 8.0f;
marioObj->oMarioPolePos += poleStickY / 8.0f;
marioObj->oMarioPoleYawVel = 0;
m->faceAngle[1] = cameraAngle - approach_s32((s16)(cameraAngle - m->faceAngle[1]), 0, 0x400, 0x400);
if (set_pole_position(m, 0.0f) == POLE_NONE)
{
sp24 = m->controller->stickY / 4.0f * 0x10000;
sp24 = poleStickY / 4.0f * 0x10000;
set_mario_anim_with_accel(m, MARIO_ANIM_CLIMB_UP_POLE, sp24);
add_tree_leaf_particles(m);
play_climbing_sounds(m, 1);
@@ -336,12 +337,13 @@ s32 act_top_of_pole(struct MarioState *m)
{
UNUSED
struct Object *marioObj = m->marioObj;
f32 poleStickY = -m->controller->stickY;
if (m->input & INPUT_A_PRESSED)
{
return set_mario_action(m, ACT_TOP_OF_POLE_JUMP, 0);
}
if (m->controller->stickY < -16.0f)
if (poleStickY < -16.0f)
{
return set_mario_action(m, ACT_TOP_OF_POLE_TRANSITION, 1);
}
+3
View File
@@ -3,6 +3,8 @@
#include <stdlib.h>
#include <string.h>
#include "../obj_pool.h"
struct GlobalState *g_state = 0;
struct GlobalState *global_state_create(void)
@@ -21,5 +23,6 @@ void global_state_bind(struct GlobalState *state)
void global_state_delete(struct GlobalState *state)
{
obj_pool_free_all(&state->mgFakeObjects);
free(state);
}
+3 -1
View File
@@ -2,6 +2,7 @@
#include "include/types.h"
#include "game/area.h"
#include "../obj_pool.h"
struct GlobalState
{
@@ -41,6 +42,7 @@ struct GlobalState
struct Area *mgCurrentArea;
struct Object *mgCurrentObject;
struct Object *mgMarioObject;
struct ObjPool mgFakeObjects;
struct MarioAnimation mD_80339D10;
struct MarioState mgMarioStateVal;
};
@@ -54,4 +56,4 @@ extern struct GlobalState *global_state_create(void);
extern void global_state_bind(struct GlobalState *state);
extern void global_state_delete(struct GlobalState *state);
extern void global_state_delete(struct GlobalState *state);