:(
Build libsm64 / Build libsm64 for linux (push) Successful in 34s
Build libsm64 / Build libsm64 for web (push) Successful in 32s
Build libsm64 / Build libsm64 for windows (push) Successful in 24s

This commit is contained in:
2026-05-31 21:57:50 -05:00
parent ede2099ff5
commit 40bee0f224
9 changed files with 68 additions and 42 deletions
+5
View File
@@ -51,9 +51,14 @@ jobs:
uses: mymindstorm/setup-emsdk@v14
- name: Build shared library
shell: bash
run: |
if [[ "${{ matrix.identifier }}" == "web" ]]; then
emmake make lib -j $(nproc) CC=emcc
elif [[ "${{ matrix.identifier }}" == "windows" ]]; then
make lib -j $(nproc 2>/dev/null || sysctl -n hw.ncpu) \
CC=x86_64-w64-mingw32-gcc \
CXX=x86_64-w64-mingw32-g++
else
make lib -j $(nproc 2>/dev/null || sysctl -n hw.ncpu)
fi
+3 -2
View File
@@ -95,7 +95,8 @@ test/level.c: ./import-test-collision.py
test/main.cpp test/gl20/gl20_renderer.c test/gl33core/gl33core_renderer.c: test/level.c
SDL2_CFLAGS := $(shell sdl2-config --cflags)
SDL2_RAW_CFLAGS := $(shell sdl2-config --cflags)
SDL2_CFLAGS := $(filter-out -Dmain=SDL_main,$(SDL2_RAW_CFLAGS))
$(BUILD_DIR)/test/%.o: test/%.c
$(CC) -c $(CFLAGS) $(SDL2_CFLAGS) -I src/decomp/include -o $@ $<
@@ -105,7 +106,7 @@ $(BUILD_DIR)/test/%.o: test/%.cpp
$(TEST_FILE): $(LIB_FILE) $(TEST_OBJS)
ifdef WINDOWS_BUILD
$(CXX) -o $@ $(TEST_OBJS) $(LIB_FILE) -lglew32 -lopengl32 -lSDL2 -lSDL2main -lm
$(CXX) -o $@ $(TEST_OBJS) $(LIB_FILE) -lglew32 -lopengl32 -lSDL2 -lm
else ifdef MACOS_BUILD
$(CXX) -o $@ $(TEST_OBJS) $(LIB_FILE) -framework OpenGL -lGLEW -lSDL2 -lSDL2main -lm -lpthread
else
+2 -1
View File
@@ -2093,10 +2093,11 @@ s32 execute_mario_action(UNUSED struct Object * o)
* INITIALIZATION *
**************************************************/
int init_mario(void)
int init_mario(uint8_t isLocal)
{
//Vec3s capPos;
//struct Object *capObject;
gMarioState->isLocal = isLocal;
gMarioState->actionTimer = 0;
gMarioState->framesSinceA = 0xFF;
+1 -1
View File
@@ -90,7 +90,7 @@ s32 set_water_plunge_action(struct MarioState *m);
s32 execute_mario_action(UNUSED struct Object *o);
int init_mario(void);
int init_mario(uint8_t isLocal);
void init_mario_from_save_file(void);
+44 -23
View File
@@ -34,38 +34,44 @@ static Vec3f gVec3fZero = {0.0f, 0.0f, 0.0f};
void add_tree_leaf_particles(struct MarioState *m)
{
// f32 leafHeight;
f32 leafHeight;
s32 isOnTree = false;//(m->usedObj->behavior == segmented_to_virtual(bhvTree));
// if (m->usedObj->behavior == segmented_to_virtual(bhvTree)) {
// // make leaf effect spawn higher on the Shifting Sand Land palm tree
// if (gCurrLevelNum == LEVEL_SSL) {
// leafHeight = 250.0f;
// } else {
// leafHeight = 100.0f;
// }
// if (m->pos[1] - m->floorHeight > leafHeight) {
// m->particleFlags |= PARTICLE_LEAF;
// }
// }
if (isOnTree) {
// make leaf effect spawn higher on the Shifting Sand Land palm tree
if (gCurrLevelNum == LEVEL_SSL) {
leafHeight = 250.0f;
} else {
leafHeight = 100.0f;
}
if (m->pos[1] - m->floorHeight > leafHeight) {
m->particleFlags |= PARTICLE_LEAF;
}
}
}
void play_climbing_sounds(struct MarioState *m, s32 b)
{
// s32 isOnTree = (m->usedObj->behavior == segmented_to_virtual(bhvTree));
s32 isOnTree = false;//(m->usedObj->behavior == segmented_to_virtual(bhvTree));
// if (b == 1) {
// if (is_anim_past_frame(m, 1)) {
// play_sound(isOnTree ? SOUND_ACTION_CLIMB_UP_TREE : SOUND_ACTION_CLIMB_UP_POLE,
// m->marioObj->header.gfx.cameraToObject);
// }
// } else {
// play_sound(isOnTree ? SOUND_MOVING_SLIDE_DOWN_TREE : SOUND_MOVING_SLIDE_DOWN_POLE,
// m->marioObj->header.gfx.cameraToObject);
// }
if (b == 1) {
if (is_anim_past_frame(m, 1)) {
play_sound(isOnTree ? SOUND_ACTION_CLIMB_UP_TREE : SOUND_ACTION_CLIMB_UP_POLE,
m->marioObj->header.gfx.cameraToObject);
}
} else {
play_sound(isOnTree ? SOUND_MOVING_SLIDE_DOWN_TREE : SOUND_MOVING_SLIDE_DOWN_POLE,
m->marioObj->header.gfx.cameraToObject);
}
}
s32 set_pole_position(struct MarioState *m, f32 offsetY)
{
if (!m->isLocal && m->usedObj == NULL)
{
return POLE_NONE;
}
UNUSED s32 unused1;
UNUSED s32 unused2;
UNUSED s32 unused3;
@@ -95,6 +101,7 @@ s32 set_pole_position(struct MarioState *m, f32 offsetY)
}
f32 floorHeight = find_floor(m->pos[0], m->pos[1], m->pos[2], &floor);
f32 floorHeight2 = find_floor(m->pos[0], m->pos[1] + 100, m->pos[2], &floor);
if (m->pos[1] < floorHeight)
{
m->pos[1] = floorHeight;
@@ -104,9 +111,18 @@ s32 set_pole_position(struct MarioState *m, f32 offsetY)
else if (marioObj->oMarioPolePos < -m->usedObj->hitboxDownOffset)
{
m->pos[1] = m->usedObj->oPosY - m->usedObj->hitboxDownOffset;
if (m->pos[1] < floorHeight2)
{
m->pos[1] = floorHeight2;
set_mario_action(m, ACT_IDLE, 0);
result = POLE_TOUCHED_FLOOR;
}
else
{
set_mario_action(m, ACT_FREEFALL, 0);
result = POLE_FELL_OFF;
}
}
else if (collided)
{
if (m->pos[1] > floorHeight + 20.0f)
@@ -165,7 +181,12 @@ s32 act_holding_pole(struct MarioState *m)
if (poleStickY > 16.0f)
{
f32 poleTop = m->usedObj->hitboxHeight - 100.0f;
f32 poleTop = m->pos[1] + 1000;
if (m->usedObj != NULL)
{
poleTop = m->usedObj->hitboxHeight - 100.0f;
}
// const BehaviorScript *poleBehavior = virtual_to_segmented(0x13, m->usedObj->behavior);
if (marioObj->oMarioPolePos < poleTop - 0.4f)
+1
View File
@@ -477,6 +477,7 @@ struct MarioState
u16 curTerrain; // libsm64: added field
s32 gasLevel; // libsm64: added field
uint8_t isLocal;
};
#endif // TYPES_H
+2 -2
View File
@@ -182,7 +182,7 @@ SM64_LIB_FN void sm64_static_surfaces_load(const struct SM64Surface *surfaceArra
surfaces_load_static(surfaceArray, numSurfaces);
}
SM64_LIB_FN int32_t sm64_mario_create(float x, float y, float z)
SM64_LIB_FN int32_t sm64_mario_create(float x, float y, float z, uint8_t isLocal)
{
int32_t marioIndex = obj_pool_alloc_index(&s_mario_instance_pool, sizeof(struct MarioInstance));
struct MarioInstance *newInstance = s_mario_instance_pool.objects[marioIndex];
@@ -220,7 +220,7 @@ SM64_LIB_FN int32_t sm64_mario_create(float x, float y, float z)
init_mario_from_save_file();
if (init_mario() < 0)
if (init_mario(isLocal) < 0)
{
sm64_mario_delete(marioIndex);
return -1;
+1 -1
View File
@@ -176,7 +176,7 @@ extern SM64_LIB_FN uint32_t sm64_audio_tick(uint32_t numQueuedSamples, uint32_t
extern SM64_LIB_FN void sm64_static_surfaces_load(const struct SM64Surface *surfaceArray, uint32_t numSurfaces);
extern SM64_LIB_FN int32_t sm64_mario_create(float x, float y, float z);
extern SM64_LIB_FN int32_t sm64_mario_create(float x, float y, float z, uint8_t isLocal);
extern SM64_LIB_FN void sm64_mario_tick(int32_t marioId, const struct SM64MarioInputs *inputs, struct SM64MarioState *outState, struct SM64MarioGeometryBuffers *outBuffers);
+7 -10
View File
@@ -28,13 +28,8 @@ extern "C"
#include "audio.h"
#include "sm64.h"
#include "../src/decomp/include/types.h"
// Add this include near the top, after libsm64.h
// AnimInfo is defined in the decomp headers, not the public API
#include "../src/decomp/include/types.h" // or wherever AnimInfo is fully defined in your tree
// -------------------------------------------------------
// Named struct so it can be used as a parameter type
struct FlagEntry
{
uint32_t bit;
@@ -568,9 +563,6 @@ static const char *GetActionName(uint32_t action)
}
}
// -------------------------------------------------------
// All helpers defined BEFORE DrawMarioState
static void DrawBitFlags(
const char *label, uint32_t value,
const FlagEntry *table, int count)
@@ -776,8 +768,13 @@ static void Rumble(int32_t marioId, int16_t level, int16_t time)
SDL_HapticRumblePlay(gHaptic, strength, duration);
}
#ifdef WINDOWS_BUILD
constexpr float M_PI = 3.14159265358979323846f;
#endif
int main(void)
{
SDL_SetMainReady();
size_t romSize;
uint8_t *rom = utils_read_file_alloc("baserom.us.z64", &romSize);
@@ -798,7 +795,7 @@ int main(void)
sm64_register_rumble_callback_function(Rumble);
sm64_static_surfaces_load(surfaces, surfaces_count);
int32_t marioId = sm64_mario_create(-6558, 0, 6464);
int32_t marioId = sm64_mario_create(-6558, 0, 6464, true);
int thing = sm64_fake_object_create(-6558.0f, 0.0f, 6200.0f, 1);
sm64_fake_object_set_hitbox(thing, 32.0f, 800.0f * 2, 800);