Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate behavior files into standalone C files #721

Open
wants to merge 36 commits into
base: develop/3.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0a1f1b9
add global object fields file for later
Oct 2, 2023
825483b
isolate all files that could be done automatically
Oct 2, 2023
e693e89
prelim: rename all files that werent changed
Oct 2, 2023
696bf7c
make all behavior files (even unfinished ones) use global includes
Oct 2, 2023
3321073
start getting the game to compile
Oct 2, 2023
2f47c36
make all obj_behaviors_2 files nonstatic
Oct 3, 2023
c909b5c
add is_mario_attacking to interaction.c
Oct 3, 2023
a459348
All behaviors are in .c files, game compiles
Oct 3, 2023
af5df13
merge obj_behaviors into one file
Oct 4, 2023
8457316
more consolidation in obj_behaviors headers
Oct 4, 2023
ed93dbf
forward-declare struct Camrea
Oct 4, 2023
839290d
start deleting useless prototypes in obj_behaviors.h
Oct 4, 2023
cb00372
purge obj_behaviors_2.h
Oct 4, 2023
1fb4ce3
purge obj_behaviors_2, remove all duplicate init/loop funcs from obj_…
Oct 4, 2023
8628100
address all warnings
Oct 4, 2023
decdada
remove old object_fields.h
Oct 4, 2023
d5b990e
debug
Oct 4, 2023
b4259be
Merge 2.2
Dec 27, 2023
09973cc
a
Jan 20, 2024
ca2494e
git subrepo clone https://github.com/devwizard64/libcart src/libcart
Jan 20, 2024
62ad214
merge upstream
Jul 19, 2024
631e50e
merge upstream again
Jul 19, 2024
c0378be
libcart is not here yet
Jul 19, 2024
1afcff4
debugprint
Jul 19, 2024
a3852f6
include math_util.h
Jul 20, 2024
ce1e971
add math_util to every file that was missing it...
Jul 20, 2024
62ac63b
this tool is out of scope
Jul 20, 2024
86d3822
clean out behavior_actions.c; move toad and spinning star to their ow…
Jul 20, 2024
439c516
rename mario_misc and behavior_actions
Jul 20, 2024
f060886
cleanup
Jul 21, 2024
0b42d7b
remove the TODO's too as they seem to be addressed or duplicates
Jul 21, 2024
4182140
i thought i set this back to 0
Jul 21, 2024
fe31a53
fix build issue
Aug 30, 2024
1cb2241
merge upstream
Dec 29, 2024
483f524
address last two TODO's
Dec 29, 2024
9e6f29f
address feedback (camera.h obj fields moved to global_object_fields)
Dec 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ ACTOR_DIR := actors
LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h)))

# Directories containing source files
SRC_DIRS += src src/boot src/game src/engine src/audio src/menu src/buffers actors levels bin data assets asm lib sound
SRC_DIRS += src src/boot src/game src/game/behaviors src/engine src/audio src/menu src/buffers actors levels bin data assets asm lib sound
LIBZ_SRC_DIRS := src/libz
GODDARD_SRC_DIRS := src/goddard src/goddard/dynlists
BIN_DIRS := bin bin/$(VERSION)
Expand Down
2 changes: 1 addition & 1 deletion data/behavior_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "game/interaction.h"
#include "game/behavior_actions.h"
#include "game/mario_actions_cutscene.h"
#include "game/mario_misc.h"
#include "game/mario_geo.h"
#include "game/object_helpers.h"
#include "game/debug.h"
#include "menu/file_select.h"
Expand Down
2 changes: 1 addition & 1 deletion include/geo_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "game/object_helpers.h"
#include "game/behavior_actions.h"
#include "game/segment2.h"
#include "game/mario_misc.h"
#include "game/mario_geo.h"
#include "game/mario_actions_cutscene.h"

// sky background params
Expand Down
429 changes: 429 additions & 0 deletions include/global_object_fields.h

Large diffs are not rendered by default.

1,335 changes: 0 additions & 1,335 deletions include/object_fields.h

This file was deleted.

2 changes: 1 addition & 1 deletion include/sm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "types.h"
#include "config.h"
#include "object_fields.h"
#include "global_object_fields.h"
#include "object_constants.h"
#include "sounds.h"
#include "model_ids.h"
Expand Down
3 changes: 1 addition & 2 deletions sm64.ld
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ SECTIONS
BEGIN_SEG(engine, .)
{
BUILD_DIR/src/game*.o(.text*);
BUILD_DIR/src/game/behavior_actions.o(.text*);
BUILD_DIR/src/game/obj_behaviors_2.o(.text*);
BUILD_DIR/src/game/behaviors*.o(.text*);
BUILD_DIR/src/game/obj_behaviors.o(.text*);
BUILD_DIR/src/game/object_helpers.o(.text*);
BUILD_DIR/src/game/rendering_graph_node.o(.text*);
Expand Down
1 change: 0 additions & 1 deletion src/engine/behavior_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "game/game_init.h"
#include "game/mario.h"
#include "game/memory.h"
#include "game/obj_behaviors_2.h"
#include "game/object_helpers.h"
#include "game/object_list_processor.h"
#include "math_util.h"
Expand Down
232 changes: 0 additions & 232 deletions src/game/behavior_actions.c

This file was deleted.

6 changes: 6 additions & 0 deletions src/game/behavior_actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ void tox_box_move(f32 forwardVel, f32 a1, s16 deltaPitch, s16 deltaRoll);
void play_penguin_walking_sound(s32 walk);
s32 update_angle_from_move_flags(s32 *angle);
void cur_obj_spawn_strong_wind_particles(s32 windSpread, f32 scale, f32 relPosX, f32 relPosY, f32 relPosZ);
void spawn_sparkle_particles(s32 n, s32 radius, s32 height, s32 r);
void set_obj_anim_with_accel_and_sound(s16 frame1, s16 frame2, s32 sound);

//! Lots of these are duplicates
void bhv_cap_switch_loop(void);
Expand Down Expand Up @@ -550,6 +552,10 @@ void bhv_intro_scene_loop(void);
void bhv_dust_smoke_loop(void);
void bhv_yoshi_loop(void);
void bhv_volcano_trap_loop(void);
void bhv_toad_message_loop(void);
void bhv_toad_message_init(void);
void bhv_unlock_door_star_init(void);
void bhv_unlock_door_star_loop(void);

Gfx *geo_move_mario_part_from_parent(s32 callContext, UNUSED struct GraphNode *node, Mat4 mtx);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#include <ultra64.h>
#include "global_object_fields.h"
#include "game/object_helpers.h"
#include "levels/bitfs/header.h"
#include "levels/bits/header.h"

/**
* Behavior for bhvActivatedBackAndForthPlatform.
Expand All @@ -6,6 +11,15 @@
* Note: The filename is abbreviated to avoid compiler seg fault on long paths
*/

/* Activated Back and Forth Platform */
#define /*0x0F4*/ oActivatedBackAndForthPlatformMaxOffset OBJECT_FIELD_F32(0x1B)
#define /*0x0F8*/ oActivatedBackAndForthPlatformOffset OBJECT_FIELD_F32(0x1C)
#define /*0x0FC*/ oActivatedBackAndForthPlatformVel OBJECT_FIELD_F32(0x1D)
#define /*0x100*/ oActivatedBackAndForthPlatformCountdown OBJECT_FIELD_S32(0x1E)
#define /*0x104*/ oActivatedBackAndForthPlatformStartYaw OBJECT_FIELD_S32(0x1F)
#define /*0x108*/ oActivatedBackAndForthPlatformVertical OBJECT_FIELD_S32(0x20)
#define /*0x10C*/ oActivatedBackAndForthPlatformFlipRotation OBJECT_FIELD_S32(0x21)

/**
* Table of activated back-and-forth platform collision models.
* The second entry is unused. It corresponds to the mesh platform
Expand Down
14 changes: 14 additions & 0 deletions src/game/behaviors/amp.inc.c → src/game/behaviors/amp.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#include <ultra64.h>
#include "global_object_fields.h"
#include "game/interaction.h"
#include "engine/math_util.h"
#include "game/object_helpers.h"
#include "game/spawn_sound.h"

/**
* Behavior for bhvHomingAmp and bhvCirclingAmp.
Expand All @@ -6,6 +12,14 @@
* of 200, 300, 400, or 0 (stationary).
*/

/* Amp */
#define /*0x0F4*/ oAmpRadiusOfRotation OBJECT_FIELD_F32(0x1B)
#define /*0x0F8*/ oAmpYPhase OBJECT_FIELD_S32(0x1C)

/* Homing Amp */
#define /*0x0F4*/ oHomingAmpLockedOn OBJECT_FIELD_S32(0x1B)
#define /*0x0FC*/ oHomingAmpAvgY OBJECT_FIELD_F32(0x1D)

static struct ObjectHitbox sAmpHitbox = {
/* interactType: */ INTERACT_SHOCK,
/* downOffset: */ 40,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
// animated_floor_switch.inc.c
#include <ultra64.h>
#include "behavior_data.h"
#include "global_object_fields.h"
#include "game/object_helpers.h"
#include "game/spawn_sound.h"
#include "levels/bitdw/header.h"
#include "levels/bits/header.h"
#include "levels/rr/header.h"

/* Floor Switch Press Animation */
#define /*0x0F4*/ oFloorSwitchPressAnimationTickTimer OBJECT_FIELD_S32(0x1B)
#define /*0x0F8*/ oFloorSwitchPressAnimationDoubleFrame OBJECT_FIELD_S32(0x1C)
#define /*0x0FC*/ oFloorSwitchPressAnimationDoResetTime OBJECT_FIELD_S32(0x1D)
#define /*0x100*/ oFloorSwitchPressAnimationSwitchNotTicking OBJECT_FIELD_S32(0x1E)

struct FloorSwitchTriggeredAnimationFrame {
const Collision *collision;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#include <ultra64.h>
#include "global_object_fields.h"
#include "game/object_helpers.h"

#define /*0x0F4*/ oArrowLiftDisplacement OBJECT_FIELD_F32(0x1B)

/**
* Behavior for WDW arrow lifts.
Expand Down
Loading