diff --git a/.gitignore b/.gitignore index 6664642..5f31c8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/src/mario +/src/decomp/mario /build/ /dist/ /test/level.c diff --git a/Makefile b/Makefile index 7a435e2..ae0d729 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ CC := cc CFLAGS := -g -Wall -fPIC LDFLAGS := -lm -shared -SRC_DIRS := src src/engine src/game src/mario src/tools +SRC_DIRS := src src/decomp src/decomp/engine src/decomp/game src/decomp/mario src/decomp/tools BUILD_DIR := build DIST_DIR := dist ALL_DIRS := $(addprefix $(BUILD_DIR)/,$(SRC_DIRS)) @@ -13,7 +13,7 @@ LIB_FILE := $(DIST_DIR)/libsm64.so LIB_H_FILE := $(DIST_DIR)/include/libsm64.h TEST_FILE := run-test -C_IMPORTED := src/mario/geo.inc.c src/mario/model.inc.c +C_IMPORTED := src/decomp/mario/geo.inc.c src/decomp/mario/model.inc.c H_IMPORTED := $(C_IMPORTED:.c=.h) IMPORTED := $(C_IMPORTED) $(H_IMPORTED) @@ -29,11 +29,11 @@ ifeq ($(OS),Windows_NT) CFLAGS := $(CFLAGS) -DBUILDING_SM64_DLL endif -DUMMY != mkdir -p $(ALL_DIRS) build/test src/mario $(DIST_DIR)/include +DUMMY != mkdir -p $(ALL_DIRS) build/test src/decomp/mario $(DIST_DIR)/include -$(filter-out src/mario/geo.inc.c,$(IMPORTED)): src/mario/geo.inc.c -src/mario/geo.inc.c: ./import-mario-geo.py +$(filter-out src/decomp/mario/geo.inc.c,$(IMPORTED)): src/decomp/mario/geo.inc.c +src/decomp/mario/geo.inc.c: ./import-mario-geo.py ./import-mario-geo.py $(BUILD_DIR)/%.o: %.c $(IMPORTED) @@ -68,6 +68,6 @@ run: test ./$(TEST_FILE) clean: - rm -rf $(BUILD_DIR) $(DIST_DIR) src/mario test/level.? $(TEST_FILE) + rm -rf $(BUILD_DIR) $(DIST_DIR) src/decomp/mario test/level.? $(TEST_FILE) -include $(DEP_FILES) \ No newline at end of file diff --git a/import-mario-geo.py b/import-mario-geo.py index cf8dfd0..0aa1397 100755 --- a/import-mario-geo.py +++ b/import-mario-geo.py @@ -57,8 +57,8 @@ model_inc_h = """ def main(): global model_inc_h - shutil.rmtree("src/mario", ignore_errors=True) - os.makedirs("src/mario", exist_ok=True) + shutil.rmtree("src/decomp/mario", ignore_errors=True) + os.makedirs("src/decomp/mario", exist_ok=True) print("Downloading " + GEO_URL) geo_inc_c = urllib.request.urlopen(GEO_URL).read().decode('utf8') @@ -78,21 +78,21 @@ def main(): elif lines[i].startswith("const "): model_inc_h += "\nextern " + lines[i].replace(" = {", ";") - lines.insert(0, "#include \"../gfx_macros.h\"") - lines.insert(0, "#include \"../load_tex_data.h\"") + lines.insert(0, "#include \"../../gfx_macros.h\"") + lines.insert(0, "#include \"../../load_tex_data.h\"") model_inc_c = "\n".join(lines) - with open("src/mario/geo.inc.c", "w") as file: + with open("src/decomp/mario/geo.inc.c", "w") as file: file.write(geo_inc_c_header + geo_inc_c + geo_inc_c_footer) - with open("src/mario/model.inc.c", "w") as file: + with open("src/decomp/mario/model.inc.c", "w") as file: file.write(model_inc_c) - with open("src/mario/model.inc.h", "w") as file: + with open("src/decomp/mario/model.inc.h", "w") as file: file.write(model_inc_h) - with open("src/mario/geo.inc.h", "w") as file: + with open("src/decomp/mario/geo.inc.h", "w") as file: file.write(geo_inc_h) if __name__ == "__main__": diff --git a/src/engine/geo_layout.c b/src/decomp/engine/geo_layout.c similarity index 100% rename from src/engine/geo_layout.c rename to src/decomp/engine/geo_layout.c diff --git a/src/engine/geo_layout.h b/src/decomp/engine/geo_layout.h similarity index 100% rename from src/engine/geo_layout.h rename to src/decomp/engine/geo_layout.h diff --git a/src/engine/graph_node.c b/src/decomp/engine/graph_node.c similarity index 98% rename from src/engine/graph_node.c rename to src/decomp/engine/graph_node.c index 6424bdd..8f83638 100644 --- a/src/engine/graph_node.c +++ b/src/decomp/engine/graph_node.c @@ -10,13 +10,9 @@ #include "../shim.h" // unused Mtx(s) -s16 identityMtx[4][4] = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }; -s16 zeroMtx[4][4] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }; - -Vec3f gVec3fZero = { 0.0f, 0.0f, 0.0f }; -Vec3s gVec3sZero = { 0, 0, 0 }; -Vec3f gVec3fOne = { 1.0f, 1.0f, 1.0f }; -UNUSED Vec3s gVec3sOne = { 1, 1, 1 }; +static Vec3f gVec3fZero = { 0.0f, 0.0f, 0.0f }; +static Vec3s gVec3sZero = { 0, 0, 0 }; +static Vec3f gVec3fOne = { 1.0f, 1.0f, 1.0f }; /** * Initialize a geo node with a given type. Sets all links such that there diff --git a/src/engine/graph_node.h b/src/decomp/engine/graph_node.h similarity index 99% rename from src/engine/graph_node.h rename to src/decomp/engine/graph_node.h index 925bbcc..c9f7fb1 100644 --- a/src/engine/graph_node.h +++ b/src/decomp/engine/graph_node.h @@ -5,7 +5,7 @@ #include "../include/PR/gbi.h" #include "../include/types.h" -#include "../memory.h" +#include "../../memory.h" #define GRAPH_RENDER_ACTIVE (1 << 0) #define GRAPH_RENDER_CHILDREN_FIRST (1 << 1) diff --git a/src/engine/graph_node_manager.c b/src/decomp/engine/graph_node_manager.c similarity index 100% rename from src/engine/graph_node_manager.c rename to src/decomp/engine/graph_node_manager.c diff --git a/src/engine/math_util.c b/src/decomp/engine/math_util.c similarity index 99% rename from src/engine/math_util.c rename to src/decomp/engine/math_util.c index 1f56801..05dc3f7 100644 --- a/src/engine/math_util.c +++ b/src/decomp/engine/math_util.c @@ -3,12 +3,11 @@ #include #include "../shim.h" -#include "../guMtxF2L.h" +#include "../../guMtxF2L.h" #include "../include/sm64.h" #include "graph_node.h" #include "surface_collision.h" -// PATCH static Vec3f gVec3fZero = { 0.0f, 0.0f, 0.0f }; // Inlined tables diff --git a/src/engine/math_util.h b/src/decomp/engine/math_util.h similarity index 100% rename from src/engine/math_util.h rename to src/decomp/engine/math_util.h diff --git a/src/engine/surface_collision.c b/src/decomp/engine/surface_collision.c similarity index 99% rename from src/engine/surface_collision.c rename to src/decomp/engine/surface_collision.c index 55ff6a0..dca89ae 100644 --- a/src/engine/surface_collision.c +++ b/src/decomp/engine/surface_collision.c @@ -3,7 +3,7 @@ #include "../shim.h" #include "surface_collision.h" #include "../include/surface_terrains.h" -#include "../load_surfaces.h" +#include "../../load_surfaces.h" /** * Iterate through the list of ceilings and find the first ceiling over a given point. diff --git a/src/engine/surface_collision.h b/src/decomp/engine/surface_collision.h similarity index 100% rename from src/engine/surface_collision.h rename to src/decomp/engine/surface_collision.h diff --git a/src/game/area.h b/src/decomp/game/area.h similarity index 100% rename from src/game/area.h rename to src/decomp/game/area.h diff --git a/src/game/behavior_actions.c b/src/decomp/game/behavior_actions.c similarity index 100% rename from src/game/behavior_actions.c rename to src/decomp/game/behavior_actions.c diff --git a/src/game/behavior_actions.h b/src/decomp/game/behavior_actions.h similarity index 100% rename from src/game/behavior_actions.h rename to src/decomp/game/behavior_actions.h diff --git a/src/game/camera.h b/src/decomp/game/camera.h similarity index 100% rename from src/game/camera.h rename to src/decomp/game/camera.h diff --git a/src/game/interaction.c b/src/decomp/game/interaction.c similarity index 99% rename from src/game/interaction.c rename to src/decomp/game/interaction.c index ffa5f38..2d5cc79 100644 --- a/src/game/interaction.c +++ b/src/decomp/game/interaction.c @@ -871,11 +871,11 @@ void check_lava_boost(struct MarioState *m) { } void pss_begin_slide(UNUSED struct MarioState *m) { - if (!(gHudDisplay.flags & HUD_DISPLAY_FLAG_TIMER)) { - level_control_timer(TIMER_CONTROL_SHOW); - level_control_timer(TIMER_CONTROL_START); - sPssSlideStarted = TRUE; - } +// if (!(gHudDisplay.flags & HUD_DISPLAY_FLAG_TIMER)) { +// level_control_timer(TIMER_CONTROL_SHOW); +// level_control_timer(TIMER_CONTROL_START); +// sPssSlideStarted = TRUE; +// } } void pss_end_slide(struct MarioState *m) { diff --git a/src/game/interaction.h b/src/decomp/game/interaction.h similarity index 100% rename from src/game/interaction.h rename to src/decomp/game/interaction.h diff --git a/src/game/level_update.h b/src/decomp/game/level_update.h similarity index 100% rename from src/game/level_update.h rename to src/decomp/game/level_update.h diff --git a/src/game/mario.c b/src/decomp/game/mario.c similarity index 99% rename from src/game/mario.c rename to src/decomp/game/mario.c index e857623..4408004 100644 --- a/src/game/mario.c +++ b/src/decomp/game/mario.c @@ -39,9 +39,6 @@ // #include "thread6.h" -u32 unused80339F10; -s8 filler80339F1C[20]; - /************************************************** * ANIMATIONS * **************************************************/ @@ -1521,14 +1518,14 @@ void update_mario_health(struct MarioState *m) { * Updates some basic info for camera usage. */ void update_mario_info_for_cam(struct MarioState *m) { - m->marioBodyState->action = m->action; - m->statusForCamera->action = m->action; +// m->marioBodyState->action = m->action; +// m->statusForCamera->action = m->action; - vec3s_copy(m->statusForCamera->faceAngle, m->faceAngle); +// vec3s_copy(m->statusForCamera->faceAngle, m->faceAngle); - if (!(m->flags & MARIO_UNKNOWN_25)) { - vec3f_copy(m->statusForCamera->pos, m->pos); - } +// if (!(m->flags & MARIO_UNKNOWN_25)) { +// vec3f_copy(m->statusForCamera->pos, m->pos); +// } } /** @@ -1796,8 +1793,6 @@ void init_mario(void) { //Vec3s capPos; //struct Object *capObject; - unused80339F10 = 0; - gMarioState->actionTimer = 0; gMarioState->framesSinceA = 0xFF; gMarioState->framesSinceB = 0xFF; @@ -1882,7 +1877,7 @@ void init_mario_from_save_file(void) { gMarioState->flags = 0; gMarioState->action = 0; gMarioState->spawnInfo = gMarioSpawnInfo; - gMarioState->statusForCamera = &gPlayerCameraState; // PATCH +// gMarioState->statusForCamera = &gPlayerCameraState; gMarioState->marioBodyState = &gBodyStates[0]; gMarioState->controller = &gController; gMarioState->animation = &D_80339D10; @@ -1898,6 +1893,6 @@ void init_mario_from_save_file(void) { gMarioState->prevNumStarsForDialog = gMarioState->numStars; gMarioState->unkB0 = 0xBD; - gHudDisplay.coins = 0; - gHudDisplay.wedges = 8; +// gHudDisplay.coins = 0; +// gHudDisplay.wedges = 8; } diff --git a/src/game/mario.h b/src/decomp/game/mario.h similarity index 100% rename from src/game/mario.h rename to src/decomp/game/mario.h diff --git a/src/game/mario_actions_airborne.c b/src/decomp/game/mario_actions_airborne.c similarity index 99% rename from src/game/mario_actions_airborne.c rename to src/decomp/game/mario_actions_airborne.c index 2ed3d2c..ed82f2d 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/decomp/game/mario_actions_airborne.c @@ -1663,9 +1663,9 @@ s32 act_jump_kick(struct MarioState *m) { } s32 act_shot_from_cannon(struct MarioState *m) { - if (m->area->camera->mode != CAMERA_MODE_BEHIND_MARIO) { - m->statusForCamera->cameraEvent = CAM_EVENT_SHOT_FROM_CANNON; - } +// if (m->area->camera->mode != CAMERA_MODE_BEHIND_MARIO) { +// m->statusForCamera->cameraEvent = CAM_EVENT_SHOT_FROM_CANNON; +// } mario_set_forward_vel(m, m->forwardVel); diff --git a/src/game/mario_actions_airborne.h b/src/decomp/game/mario_actions_airborne.h similarity index 100% rename from src/game/mario_actions_airborne.h rename to src/decomp/game/mario_actions_airborne.h diff --git a/src/game/mario_actions_automatic.c b/src/decomp/game/mario_actions_automatic.c similarity index 98% rename from src/game/mario_actions_automatic.c rename to src/decomp/game/mario_actions_automatic.c index 4581267..c23692c 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/decomp/game/mario_actions_automatic.c @@ -524,18 +524,18 @@ void climb_up_ledge(struct MarioState *m) { } void update_ledge_climb_camera(struct MarioState *m) { - f32 sp4; +// f32 sp4; - if (m->actionTimer < 14) { - sp4 = m->actionTimer; - } else { - sp4 = 14.0f; - } - m->statusForCamera->pos[0] = m->pos[0] + sp4 * sins(m->faceAngle[1]); - m->statusForCamera->pos[2] = m->pos[2] + sp4 * coss(m->faceAngle[1]); - m->statusForCamera->pos[1] = m->pos[1]; - m->actionTimer++; - m->flags |= MARIO_UNKNOWN_25; +// if (m->actionTimer < 14) { +// sp4 = m->actionTimer; +// } else { +// sp4 = 14.0f; +// } +// m->statusForCamera->pos[0] = m->pos[0] + sp4 * sins(m->faceAngle[1]); +// m->statusForCamera->pos[2] = m->pos[2] + sp4 * coss(m->faceAngle[1]); +// m->statusForCamera->pos[1] = m->pos[1]; +// m->actionTimer++; +// m->flags |= MARIO_UNKNOWN_25; } void update_ledge_climb(struct MarioState *m, s32 animation, u32 endAction) { @@ -692,8 +692,8 @@ s32 act_in_cannon(struct MarioState *m) { m->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; m->usedObj->oInteractStatus = INT_STATUS_INTERACTED; - m->statusForCamera->cameraEvent = CAM_EVENT_CANNON; - m->statusForCamera->usedObj = m->usedObj; +// m->statusForCamera->cameraEvent = CAM_EVENT_CANNON; +// m->statusForCamera->usedObj = m->usedObj; vec3f_set(m->vel, 0.0f, 0.0f, 0.0f); diff --git a/src/game/mario_actions_automatic.h b/src/decomp/game/mario_actions_automatic.h similarity index 100% rename from src/game/mario_actions_automatic.h rename to src/decomp/game/mario_actions_automatic.h diff --git a/src/game/mario_actions_cutscene.c b/src/decomp/game/mario_actions_cutscene.c similarity index 98% rename from src/game/mario_actions_cutscene.c rename to src/decomp/game/mario_actions_cutscene.c index 7ba9b03..45aa681 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/decomp/game/mario_actions_cutscene.c @@ -1693,10 +1693,10 @@ static void advance_cutscene_step(struct MarioState *m) { } static void intro_cutscene_hide_hud_and_mario(struct MarioState *m) { - gHudDisplay.flags = HUD_DISPLAY_NONE; - m->statusForCamera->cameraEvent = CAM_EVENT_START_INTRO; - m->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; - advance_cutscene_step(m); +// gHudDisplay.flags = HUD_DISPLAY_NONE; +// m->statusForCamera->cameraEvent = CAM_EVENT_START_INTRO; +// m->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; +// advance_cutscene_step(m); } #ifdef VERSION_EU @@ -1842,29 +1842,29 @@ static s32 act_intro_cutscene(struct MarioState *m) { // jumbo star cutscene: Mario lands after grabbing the jumbo star static void jumbo_star_cutscene_falling(struct MarioState *m) { - if (m->actionState == 0) { - m->input |= INPUT_A_DOWN; - m->flags |= (MARIO_WING_CAP | MARIO_CAP_ON_HEAD); +// if (m->actionState == 0) { +// m->input |= INPUT_A_DOWN; +// m->flags |= (MARIO_WING_CAP | MARIO_CAP_ON_HEAD); - m->faceAngle[1] = -0x8000; - m->pos[0] = 0.0f; - m->pos[2] = 0.0f; +// m->faceAngle[1] = -0x8000; +// m->pos[0] = 0.0f; +// m->pos[2] = 0.0f; - mario_set_forward_vel(m, 0.0f); - set_mario_animation(m, MARIO_ANIM_GENERAL_FALL); +// mario_set_forward_vel(m, 0.0f); +// set_mario_animation(m, MARIO_ANIM_GENERAL_FALL); - if (perform_air_step(m, 1) == AIR_STEP_LANDED) { - play_cutscene_music(SEQUENCE_ARGS(15, SEQ_EVENT_CUTSCENE_VICTORY)); - play_mario_landing_sound(m, SOUND_ACTION_TERRAIN_LANDING); - m->actionState++; - } - } else { - set_mario_animation(m, MARIO_ANIM_GENERAL_LAND); - if (is_anim_at_end(m)) { - m->statusForCamera->cameraEvent = CAM_EVENT_START_GRAND_STAR; - advance_cutscene_step(m); - } - } +// if (perform_air_step(m, 1) == AIR_STEP_LANDED) { +// play_cutscene_music(SEQUENCE_ARGS(15, SEQ_EVENT_CUTSCENE_VICTORY)); +// play_mario_landing_sound(m, SOUND_ACTION_TERRAIN_LANDING); +// m->actionState++; +// } +// } else { +// set_mario_animation(m, MARIO_ANIM_GENERAL_LAND); +// if (is_anim_at_end(m)) { +// m->statusForCamera->cameraEvent = CAM_EVENT_START_GRAND_STAR; +// advance_cutscene_step(m); +// } +// } } // jumbo star cutscene: Mario takes off @@ -2031,20 +2031,20 @@ void generate_yellow_sparkles(s16 x, s16 y, s16 z, f32 radius) { // make Mario fall and soften wing cap gravity static void end_peach_cutscene_mario_falling(struct MarioState *m) { - if (m->actionTimer == 1) { - m->statusForCamera->cameraEvent = CAM_EVENT_START_ENDING; - } +// if (m->actionTimer == 1) { +// m->statusForCamera->cameraEvent = CAM_EVENT_START_ENDING; +// } - m->input |= INPUT_A_DOWN; - m->flags |= (MARIO_WING_CAP | MARIO_CAP_ON_HEAD); +// m->input |= INPUT_A_DOWN; +// m->flags |= (MARIO_WING_CAP | MARIO_CAP_ON_HEAD); - set_mario_animation(m, MARIO_ANIM_GENERAL_FALL); - mario_set_forward_vel(m, 0.0f); +// set_mario_animation(m, MARIO_ANIM_GENERAL_FALL); +// mario_set_forward_vel(m, 0.0f); - if (perform_air_step(m, 0) == AIR_STEP_LANDED) { - play_mario_landing_sound(m, SOUND_ACTION_TERRAIN_LANDING); - advance_cutscene_step(m); - } +// if (perform_air_step(m, 0) == AIR_STEP_LANDED) { +// play_mario_landing_sound(m, SOUND_ACTION_TERRAIN_LANDING); +// advance_cutscene_step(m); +// } } // set Mario on the ground, wait and spawn the jumbo star outside the castle. diff --git a/src/game/mario_actions_cutscene.h b/src/decomp/game/mario_actions_cutscene.h similarity index 100% rename from src/game/mario_actions_cutscene.h rename to src/decomp/game/mario_actions_cutscene.h diff --git a/src/game/mario_actions_moving.c b/src/decomp/game/mario_actions_moving.c similarity index 100% rename from src/game/mario_actions_moving.c rename to src/decomp/game/mario_actions_moving.c diff --git a/src/game/mario_actions_moving.h b/src/decomp/game/mario_actions_moving.h similarity index 100% rename from src/game/mario_actions_moving.h rename to src/decomp/game/mario_actions_moving.h diff --git a/src/game/mario_actions_object.c b/src/decomp/game/mario_actions_object.c similarity index 100% rename from src/game/mario_actions_object.c rename to src/decomp/game/mario_actions_object.c diff --git a/src/game/mario_actions_object.h b/src/decomp/game/mario_actions_object.h similarity index 100% rename from src/game/mario_actions_object.h rename to src/decomp/game/mario_actions_object.h diff --git a/src/game/mario_actions_stationary.c b/src/decomp/game/mario_actions_stationary.c similarity index 98% rename from src/game/mario_actions_stationary.c rename to src/decomp/game/mario_actions_stationary.c index ee59ae5..499988d 100644 --- a/src/game/mario_actions_stationary.c +++ b/src/decomp/game/mario_actions_stationary.c @@ -1073,14 +1073,14 @@ s32 act_first_person(struct MarioState *m) { return set_mario_action(m, ACT_IDLE, 0); } - if (m->floor->type == SURFACE_LOOK_UP_WARP - && save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1) >= 10) { - s16 sp1A = m->statusForCamera->headRotation[0]; - s16 sp18 = ((m->statusForCamera->headRotation[1] * 4) / 3) + m->faceAngle[1]; - if (sp1A == -0x1800 && (sp18 < -0x6FFF || sp18 >= 0x7000)) { - level_trigger_warp(m, WARP_OP_UNKNOWN_01); - } - } +// if (m->floor->type == SURFACE_LOOK_UP_WARP +// && save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1) >= 10) { +// s16 sp1A = m->statusForCamera->headRotation[0]; +// s16 sp18 = ((m->statusForCamera->headRotation[1] * 4) / 3) + m->faceAngle[1]; +// if (sp1A == -0x1800 && (sp18 < -0x6FFF || sp18 >= 0x7000)) { +// level_trigger_warp(m, WARP_OP_UNKNOWN_01); +// } +// } stationary_ground_step(m); set_mario_animation(m, MARIO_ANIM_FIRST_PERSON); diff --git a/src/game/mario_actions_stationary.h b/src/decomp/game/mario_actions_stationary.h similarity index 100% rename from src/game/mario_actions_stationary.h rename to src/decomp/game/mario_actions_stationary.h diff --git a/src/game/mario_actions_submerged.c b/src/decomp/game/mario_actions_submerged.c similarity index 100% rename from src/game/mario_actions_submerged.c rename to src/decomp/game/mario_actions_submerged.c diff --git a/src/game/mario_actions_submerged.h b/src/decomp/game/mario_actions_submerged.h similarity index 100% rename from src/game/mario_actions_submerged.h rename to src/decomp/game/mario_actions_submerged.h diff --git a/src/game/mario_misc.c b/src/decomp/game/mario_misc.c similarity index 94% rename from src/game/mario_misc.c rename to src/decomp/game/mario_misc.c index 131d9fa..b765066 100644 --- a/src/game/mario_misc.c +++ b/src/decomp/game/mario_misc.c @@ -79,7 +79,7 @@ static s8 gMarioAttackScaleAnimation[3 * 6] = { }; struct MarioBodyState gBodyStates[2]; // 2nd is never accessed in practice, most likely Luigi related -struct GraphNodeObject gMirrorMario; // copy of Mario's geo node for drawing mirror Mario +//struct GraphNodeObject gMirrorMario; // copy of Mario's geo node for drawing mirror Mario // This whole file is weirdly organized. It has to be the same file due // to rodata boundaries and function aligns, which means the programmer @@ -594,40 +594,40 @@ Gfx *geo_switch_mario_hand_grab_pos(s32 callContext, struct GraphNode *b, Mat4 * * a mirror image of the player. */ Gfx *geo_render_mirror_mario(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) { - f32 mirroredX; - struct Object *mario = gMarioState->marioObj; // PATCH gMarioStates[0].marioObj; +// f32 mirroredX; +// struct Object *mario = gMarioState->marioObj; // PATCH gMarioStates[0].marioObj; - switch (callContext) { - case GEO_CONTEXT_CREATE: - init_graph_node_object(NULL, &gMirrorMario, NULL, gVec3fZero, gVec3sZero, gVec3fOne); - break; - case GEO_CONTEXT_AREA_LOAD: - geo_add_child(node, &gMirrorMario.node); - break; - case GEO_CONTEXT_AREA_UNLOAD: - geo_remove_child(&gMirrorMario.node); - break; - case GEO_CONTEXT_RENDER: - if (mario->header.gfx.pos[0] > 1700.0f) { - // TODO: Is this a geo layout copy or a graph node copy? - gMirrorMario.sharedChild = mario->header.gfx.sharedChild; - gMirrorMario.areaIndex = mario->header.gfx.areaIndex; - vec3s_copy(gMirrorMario.angle, mario->header.gfx.angle); - vec3f_copy(gMirrorMario.pos, mario->header.gfx.pos); - vec3f_copy(gMirrorMario.scale, mario->header.gfx.scale); +// switch (callContext) { +// case GEO_CONTEXT_CREATE: +// init_graph_node_object(NULL, &gMirrorMario, NULL, gVec3fZero, gVec3sZero, gVec3fOne); +// break; +// case GEO_CONTEXT_AREA_LOAD: +// geo_add_child(node, &gMirrorMario.node); +// break; +// case GEO_CONTEXT_AREA_UNLOAD: +// geo_remove_child(&gMirrorMario.node); +// break; +// case GEO_CONTEXT_RENDER: +// if (mario->header.gfx.pos[0] > 1700.0f) { +// // TODO: Is this a geo layout copy or a graph node copy? +// gMirrorMario.sharedChild = mario->header.gfx.sharedChild; +// gMirrorMario.areaIndex = mario->header.gfx.areaIndex; +// vec3s_copy(gMirrorMario.angle, mario->header.gfx.angle); +// vec3f_copy(gMirrorMario.pos, mario->header.gfx.pos); +// vec3f_copy(gMirrorMario.scale, mario->header.gfx.scale); - gMirrorMario.animInfo = mario->header.gfx.animInfo; - mirroredX = MIRROR_X - gMirrorMario.pos[0]; - gMirrorMario.pos[0] = mirroredX + MIRROR_X; - gMirrorMario.angle[1] = -gMirrorMario.angle[1]; - gMirrorMario.scale[0] *= -1.0f; - ((struct GraphNode *) &gMirrorMario)->flags |= 1; - } else { - ((struct GraphNode *) &gMirrorMario)->flags &= ~1; - } - break; - } - return NULL; +// gMirrorMario.animInfo = mario->header.gfx.animInfo; +// mirroredX = MIRROR_X - gMirrorMario.pos[0]; +// gMirrorMario.pos[0] = mirroredX + MIRROR_X; +// gMirrorMario.angle[1] = -gMirrorMario.angle[1]; +// gMirrorMario.scale[0] *= -1.0f; +// ((struct GraphNode *) &gMirrorMario)->flags |= 1; +// } else { +// ((struct GraphNode *) &gMirrorMario)->flags &= ~1; +// } +// break; +// } +// return NULL; } /** diff --git a/src/game/mario_misc.h b/src/decomp/game/mario_misc.h similarity index 100% rename from src/game/mario_misc.h rename to src/decomp/game/mario_misc.h diff --git a/src/game/mario_step.c b/src/decomp/game/mario_step.c similarity index 100% rename from src/game/mario_step.c rename to src/decomp/game/mario_step.c diff --git a/src/game/mario_step.h b/src/decomp/game/mario_step.h similarity index 100% rename from src/game/mario_step.h rename to src/decomp/game/mario_step.h diff --git a/src/game/object_stuff.c b/src/decomp/game/object_stuff.c similarity index 100% rename from src/game/object_stuff.c rename to src/decomp/game/object_stuff.c diff --git a/src/game/object_stuff.h b/src/decomp/game/object_stuff.h similarity index 100% rename from src/game/object_stuff.h rename to src/decomp/game/object_stuff.h diff --git a/src/game/platform_displacement.c b/src/decomp/game/platform_displacement.c similarity index 100% rename from src/game/platform_displacement.c rename to src/decomp/game/platform_displacement.c diff --git a/src/game/platform_displacement.h b/src/decomp/game/platform_displacement.h similarity index 100% rename from src/game/platform_displacement.h rename to src/decomp/game/platform_displacement.h diff --git a/src/game/rendering_graph_node.c b/src/decomp/game/rendering_graph_node.c similarity index 99% rename from src/game/rendering_graph_node.c rename to src/decomp/game/rendering_graph_node.c index 9853556..09fd73d 100644 --- a/src/game/rendering_graph_node.c +++ b/src/decomp/game/rendering_graph_node.c @@ -14,7 +14,7 @@ //#include "shadow.h" #include "../include/sm64.h" #include "../shim.h" -#include "../gfx_adapter.h" +#include "../../gfx_adapter.h" diff --git a/src/game/rendering_graph_node.h b/src/decomp/game/rendering_graph_node.h similarity index 100% rename from src/game/rendering_graph_node.h rename to src/decomp/game/rendering_graph_node.h diff --git a/src/game/save_file.h b/src/decomp/game/save_file.h similarity index 100% rename from src/game/save_file.h rename to src/decomp/game/save_file.h diff --git a/src/decomp/global_state.c b/src/decomp/global_state.c new file mode 100644 index 0000000..e25b988 --- /dev/null +++ b/src/decomp/global_state.c @@ -0,0 +1,3 @@ +#include "global_state.h" + +struct GlobalState *gState = 0; \ No newline at end of file diff --git a/src/decomp/global_state.h b/src/decomp/global_state.h new file mode 100644 index 0000000..a5ed474 --- /dev/null +++ b/src/decomp/global_state.h @@ -0,0 +1,48 @@ +#pragma once + +#include "include/types.h" +#include "game/area.h" + +struct GlobalState +{ + // interaction.c + u8 sDelayInvincTimer; + s16 sInvulnerable; + + // mario_actions_moving.c + Mat4 sFloorAlignMatrix; + + // mario_actions_submerged.c + s16 sWasAtSurface; + s16 sSwimStrength; + s16 D_80339FD0; + s16 D_80339FD2; + f32 D_80339FD4; + + // mario_misc.c + struct MarioBodyState gBodyStates[2]; + + // platform_displacement.c + void *gMarioPlatform; + + // misc + u32 gGlobalTimer; + u8 gSpecialTripleJump; + s16 gCurrLevelNum; + s16 gCameraMovementFlags; + u32 gAudioRandom; + s8 gShowDebugText; + s8 gDebugLevelSelect; + s16 gCurrSaveFileNum; + struct Controller gController; + struct SpawnInfo gMarioSpawnInfoVal; + struct SpawnInfo *gMarioSpawnInfo; + struct Area *gCurrentArea; + struct Object *gCurrentObject; + struct Object *gMarioObject; + struct MarioAnimation D_80339D10; + struct MarioState gMarioStateVal; + struct MarioState *gMarioState; +}; + +extern struct GlobalState *gState; \ No newline at end of file diff --git a/src/include/PR/gbi.h b/src/decomp/include/PR/gbi.h similarity index 100% rename from src/include/PR/gbi.h rename to src/decomp/include/PR/gbi.h diff --git a/src/include/PR/os_cont.h b/src/decomp/include/PR/os_cont.h similarity index 100% rename from src/include/PR/os_cont.h rename to src/decomp/include/PR/os_cont.h diff --git a/src/include/PR/ultratypes.h b/src/decomp/include/PR/ultratypes.h similarity index 100% rename from src/include/PR/ultratypes.h rename to src/decomp/include/PR/ultratypes.h diff --git a/src/include/audio_defines.h b/src/decomp/include/audio_defines.h similarity index 100% rename from src/include/audio_defines.h rename to src/decomp/include/audio_defines.h diff --git a/src/include/command_macros_base.h b/src/decomp/include/command_macros_base.h similarity index 100% rename from src/include/command_macros_base.h rename to src/decomp/include/command_macros_base.h diff --git a/src/include/geo_commands.h b/src/decomp/include/geo_commands.h similarity index 100% rename from src/include/geo_commands.h rename to src/decomp/include/geo_commands.h diff --git a/src/include/level_misc_macros.h b/src/decomp/include/level_misc_macros.h similarity index 100% rename from src/include/level_misc_macros.h rename to src/decomp/include/level_misc_macros.h diff --git a/src/include/macros.h b/src/decomp/include/macros.h similarity index 100% rename from src/include/macros.h rename to src/decomp/include/macros.h diff --git a/src/include/mario_animation_ids.h b/src/decomp/include/mario_animation_ids.h similarity index 100% rename from src/include/mario_animation_ids.h rename to src/decomp/include/mario_animation_ids.h diff --git a/src/include/mario_geo_switch_case_ids.h b/src/decomp/include/mario_geo_switch_case_ids.h similarity index 100% rename from src/include/mario_geo_switch_case_ids.h rename to src/decomp/include/mario_geo_switch_case_ids.h diff --git a/src/include/object_fields.h b/src/decomp/include/object_fields.h similarity index 100% rename from src/include/object_fields.h rename to src/decomp/include/object_fields.h diff --git a/src/include/platform_info.h b/src/decomp/include/platform_info.h similarity index 100% rename from src/include/platform_info.h rename to src/decomp/include/platform_info.h diff --git a/src/include/seq_ids.h b/src/decomp/include/seq_ids.h similarity index 100% rename from src/include/seq_ids.h rename to src/decomp/include/seq_ids.h diff --git a/src/include/sm64.h b/src/decomp/include/sm64.h similarity index 100% rename from src/include/sm64.h rename to src/decomp/include/sm64.h diff --git a/src/include/special_preset_names.h b/src/decomp/include/special_preset_names.h similarity index 100% rename from src/include/special_preset_names.h rename to src/decomp/include/special_preset_names.h diff --git a/src/include/surface_terrains.h b/src/decomp/include/surface_terrains.h similarity index 100% rename from src/include/surface_terrains.h rename to src/decomp/include/surface_terrains.h diff --git a/src/include/types.h b/src/decomp/include/types.h similarity index 99% rename from src/include/types.h rename to src/decomp/include/types.h index 35e233c..8a0791a 100644 --- a/src/include/types.h +++ b/src/decomp/include/types.h @@ -323,7 +323,7 @@ struct MarioState /*0x88*/ struct Object *marioObj; /*0x8C*/ struct SpawnInfo *spawnInfo; /*0x90*/ struct Area *area; - /*0x94*/ struct PlayerCameraState *statusForCamera; +// /*0x94*/ struct PlayerCameraState *statusForCamera; /*0x98*/ struct MarioBodyState *marioBodyState; /*0x9C*/ struct Controller *controller; /*0xA0*/ struct MarioAnimation *animation; diff --git a/src/shim.c b/src/decomp/shim.c similarity index 98% rename from src/shim.c rename to src/decomp/shim.c index 2fbbb8b..6810309 100644 --- a/src/shim.c +++ b/src/decomp/shim.c @@ -1,10 +1,9 @@ #include #include "shim.h" -#include "load_anim_data.h" +#include "../load_anim_data.h" u32 gGlobalTimer = 0; u8 gSpecialTripleJump = FALSE; -struct HudDisplay gHudDisplay; s16 gCurrLevelNum = 0; s16 gCameraMovementFlags = 0; u32 gAudioRandom = 0; diff --git a/src/shim.h b/src/decomp/shim.h similarity index 98% rename from src/shim.h rename to src/decomp/shim.h index cc3178b..194da18 100644 --- a/src/shim.h +++ b/src/decomp/shim.h @@ -3,7 +3,7 @@ #include "include/types.h" #include "game/area.h" #include "game/level_update.h" -#include "libsm64.h" +#include "../libsm64.h" #define COURSE_MIN 0 #define COURSE_MAX 14 @@ -44,7 +44,6 @@ struct SurfaceNode extern u32 gGlobalTimer; extern u8 gSpecialTripleJump; -extern struct HudDisplay gHudDisplay; extern s16 gCurrLevelNum; extern s16 gCameraMovementFlags; extern u32 gAudioRandom; diff --git a/src/tools/libmio0.c b/src/decomp/tools/libmio0.c similarity index 100% rename from src/tools/libmio0.c rename to src/decomp/tools/libmio0.c diff --git a/src/tools/libmio0.h b/src/decomp/tools/libmio0.h similarity index 100% rename from src/tools/libmio0.h rename to src/decomp/tools/libmio0.h diff --git a/src/tools/n64graphics.c b/src/decomp/tools/n64graphics.c similarity index 100% rename from src/tools/n64graphics.c rename to src/decomp/tools/n64graphics.c diff --git a/src/tools/n64graphics.h b/src/decomp/tools/n64graphics.h similarity index 100% rename from src/tools/n64graphics.h rename to src/decomp/tools/n64graphics.h diff --git a/src/tools/stb/stb_image.h b/src/decomp/tools/stb/stb_image.h similarity index 100% rename from src/tools/stb/stb_image.h rename to src/decomp/tools/stb/stb_image.h diff --git a/src/tools/stb/stb_image_write.h b/src/decomp/tools/stb/stb_image_write.h similarity index 100% rename from src/tools/stb/stb_image_write.h rename to src/decomp/tools/stb/stb_image_write.h diff --git a/src/tools/utils.c b/src/decomp/tools/utils.c similarity index 100% rename from src/tools/utils.c rename to src/decomp/tools/utils.c diff --git a/src/tools/utils.h b/src/decomp/tools/utils.h similarity index 100% rename from src/tools/utils.h rename to src/decomp/tools/utils.h diff --git a/src/gfx_adapter.c b/src/gfx_adapter.c index 44e03c5..c28c65b 100644 --- a/src/gfx_adapter.c +++ b/src/gfx_adapter.c @@ -2,7 +2,7 @@ #include #include "libsm64.h" -#include "engine/math_util.h" +#include "decomp/engine/math_util.h" #include "guMtxF2L.h" #include "gfx_adapter.h" #include "gfx_adapter_commands.h" diff --git a/src/gfx_adapter.h b/src/gfx_adapter.h index c758c65..4b97be3 100644 --- a/src/gfx_adapter.h +++ b/src/gfx_adapter.h @@ -1,6 +1,6 @@ #pragma once -#include "engine/graph_node.h" +#include "decomp/engine/graph_node.h" #include "libsm64.h" // Commented out in gbi.h - Replaced here diff --git a/src/gfx_macros.h b/src/gfx_macros.h index 09cd4f1..35b2988 100644 --- a/src/gfx_macros.h +++ b/src/gfx_macros.h @@ -1,6 +1,6 @@ #pragma once -#include "include/types.h" +#include "decomp/include/types.h" #include "gfx_adapter_commands.h" /* diff --git a/src/guMtxF2L.h b/src/guMtxF2L.h index 751cc07..107f505 100644 --- a/src/guMtxF2L.h +++ b/src/guMtxF2L.h @@ -1,6 +1,6 @@ #pragma once -#include "include/PR/gbi.h" +#include "decomp/include/PR/gbi.h" extern void guMtxF2L(float mf[4][4], Mtx *m); extern void guMtxL2F(float mf[4][4], Mtx *m); \ No newline at end of file diff --git a/src/libsm64.c b/src/libsm64.c index 082c9b9..53a812d 100644 --- a/src/libsm64.c +++ b/src/libsm64.c @@ -6,22 +6,23 @@ #include #include -#include "include/PR/os_cont.h" -#include "engine/math_util.h" -#include "include/sm64.h" -#include "shim.h" -#include "game/mario.h" -#include "game/object_stuff.h" -#include "engine/surface_collision.h" -#include "engine/graph_node.h" -#include "engine/geo_layout.h" -#include "game/rendering_graph_node.h" -#include "mario/geo.inc.h" +#include "decomp/include/PR/os_cont.h" +#include "decomp/engine/math_util.h" +#include "decomp/include/sm64.h" +#include "decomp/shim.h" +#include "decomp/game/mario.h" +#include "decomp/game/object_stuff.h" +#include "decomp/engine/surface_collision.h" +#include "decomp/engine/graph_node.h" +#include "decomp/engine/geo_layout.h" +#include "decomp/game/rendering_graph_node.h" +#include "decomp/mario/geo.inc.h" +#include "decomp/game/platform_displacement.h" + #include "load_surfaces.h" #include "gfx_adapter.h" #include "load_anim_data.h" #include "load_tex_data.h" -#include "game/platform_displacement.h" static struct AllocOnlyPool *s_mario_geo_pool; static struct GraphNode *s_mario_graph_node; diff --git a/src/load_anim_data.c b/src/load_anim_data.c index 87c29c3..9db93a9 100644 --- a/src/load_anim_data.c +++ b/src/load_anim_data.c @@ -1,5 +1,4 @@ #include "load_anim_data.h" -#include "include/types.h" #include diff --git a/src/load_anim_data.h b/src/load_anim_data.h index 5f5c6bd..d0d58a6 100644 --- a/src/load_anim_data.h +++ b/src/load_anim_data.h @@ -3,7 +3,7 @@ #include #include -#include "include/types.h" +#include "decomp/include/types.h" extern struct Animation *gLibSm64MarioAnimations; diff --git a/src/load_surfaces.c b/src/load_surfaces.c index 038d065..141c7ba 100644 --- a/src/load_surfaces.c +++ b/src/load_surfaces.c @@ -3,10 +3,10 @@ #include #include -#include "include/types.h" -#include "include/surface_terrains.h" -#include "engine/math_util.h" -#include "shim.h" +#include "decomp/include/types.h" +#include "decomp/include/surface_terrains.h" +#include "decomp/engine/math_util.h" +#include "decomp/shim.h" struct LoadedSurfaceObject { diff --git a/src/load_tex_data.c b/src/load_tex_data.c index 069fe7c..37f8c95 100644 --- a/src/load_tex_data.c +++ b/src/load_tex_data.c @@ -4,8 +4,8 @@ #include #include "libsm64.h" -#include "tools/libmio0.h" -#include "tools/n64graphics.h" +#include "decomp/tools/libmio0.h" +#include "decomp/tools/n64graphics.h" #define MARIO_TEX_ROM_OFFSET 1132368 #define ATLAS_WIDTH (NUM_USED_TEXTURES * 64) diff --git a/src/memory.h b/src/memory.h index 78d35b5..3ed8b0f 100644 --- a/src/memory.h +++ b/src/memory.h @@ -1,6 +1,6 @@ #pragma once -#include "include/types.h" +#include "decomp/include/types.h" struct AllocOnlyPool;