From 5dc75cf792b1809b82d73237540ca0c7920b2ae6 Mon Sep 17 00:00:00 2001 From: Fazana <52551480+FazanaJ@users.noreply.github.com> Date: Sun, 15 Aug 2021 15:15:16 +0100 Subject: [PATCH] Ifdefs and config --- include/config.h | 2 ++ include/text_strings.h.in | 2 ++ src/engine/level_script.c | 4 ++++ src/game/camera.c | 25 ++++++++++++++++++++++--- src/game/game_init.c | 2 ++ src/game/hud.c | 2 ++ src/game/ingame_menu.c | 15 +++++++++------ src/game/mario.c | 2 ++ src/game/mario_misc.c | 2 ++ src/game/puppycam2.c | 3 +++ src/game/puppycam2.h | 4 ++++ src/game/save_file.c | 2 ++ src/game/save_file.h | 4 ++++ 13 files changed, 60 insertions(+), 9 deletions(-) diff --git a/include/config.h b/include/config.h index f38082b4..ca21728b 100644 --- a/include/config.h +++ b/include/config.h @@ -98,6 +98,8 @@ #define PARALLEL_LAKITU_CAM // Allows Mario to ledgegrab sloped floors #define NO_FALSE_LEDGEGRABS +//Enables Puppy Camera 2, a rewritten camera that can be freely configured and modified. +//#define PUPPYCAM // HACKER QOL diff --git a/include/text_strings.h.in b/include/text_strings.h.in index 8c264389..30d01fa6 100644 --- a/include/text_strings.h.in +++ b/include/text_strings.h.in @@ -3,6 +3,7 @@ #include "text_menu_strings.h" +#ifdef PUPPYCAM #define NC_CAMX_EN _("Camera X Sensitivity") #define NC_CAMY_EN _("Camera Y Sensitivity") #define NC_INVERTX_EN _("Invert X Axis") @@ -71,6 +72,7 @@ #define NC_OPTION_FR _("OPTIONS PUPPYCAM") #define NC_OPTION_DE _("PUPPYCAM OPTIONS") #endif +#endif /** * Global Symbols diff --git a/src/engine/level_script.c b/src/engine/level_script.c index ae9bd5cb..06ab70d1 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -758,6 +758,7 @@ static void level_cmd_get_or_set_var(void) { sCurrentCmd = CMD_NEXT; } +#ifdef PUPPYCAM static void level_cmd_puppyvolume(void) { if ((sPuppyVolumeStack[gPuppyVolumeCount] = mem_pool_alloc(gPuppyMemoryPool,sizeof(struct sPuppyVolume))) == NULL) @@ -791,6 +792,7 @@ static void level_cmd_puppyvolume(void) gPuppyVolumeCount++; sCurrentCmd = CMD_NEXT; } +#endif static void (*LevelScriptJumpTable[])(void) = { /*00*/ level_cmd_load_and_execute, @@ -854,7 +856,9 @@ static void (*LevelScriptJumpTable[])(void) = { /*3A*/ level_cmd_3A, /*3B*/ level_cmd_create_whirlpool, /*3C*/ level_cmd_get_or_set_var, + #ifdef PUPPYCAM /*3E*/ level_cmd_puppyvolume, + #endif }; struct LevelCommand *level_script_execute(struct LevelCommand *cmd) { diff --git a/src/game/camera.c b/src/game/camera.c index 0435d3be..919bff93 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -3038,7 +3038,11 @@ void update_camera(struct Camera *c) { gCamera = c; update_camera_hud_status(c); - if (c->cutscene == 0 && !gPuppyCam.enabled && !(gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON)) { + if (c->cutscene == 0 && + #ifdef PUPPYCAM + !gPuppyCam.enabled && + #endif + !(gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON)) { // Only process R_TRIG if 'fixed' is not selected in the menu if (cam_select_alt_mode(0) == CAM_SELECTION_MARIO) { if (gPlayer1Controller->buttonPressed & R_TRIG) { @@ -3060,7 +3064,9 @@ void update_camera(struct Camera *c) { sStatusFlags |= CAM_FLAG_FRAME_AFTER_CAM_INIT; } + #ifdef PUPPYCAM if (!gPuppyCam.enabled || c->cutscene != 0 || gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON) { + #endif // Store previous geometry information sMarioGeometry.prevFloorHeight = sMarioGeometry.currFloorHeight; sMarioGeometry.prevCeilHeight = sMarioGeometry.currCeilHeight; @@ -3183,12 +3189,16 @@ void update_camera(struct Camera *c) { } } } + #ifdef PUPPYCAM } + #endif // Start any Mario-related cutscenes start_cutscene(c, get_cutscene_from_mario_status(c)); stub_camera_2(c); gCheckingSurfaceCollisionsForCamera = FALSE; + #ifdef PUPPYCAM if (!gPuppyCam.enabled || c->cutscene != 0 || gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON) { + #endif if (gCurrLevelNum != LEVEL_CASTLE) { // If fixed camera is selected as the alternate mode, then fix the camera as long as the right // trigger is held @@ -3226,6 +3236,7 @@ void update_camera(struct Camera *c) { } update_lakitu(c); + #ifdef PUPPYCAM } //Just a cute little bit that syncs puppycamera up to vanilla when playing a vanilla cutscene :3 if (c->cutscene != 0) @@ -3238,8 +3249,12 @@ void update_camera(struct Camera *c) { gPuppyCam.yaw = gMarioState->faceAngle[1]+0x8000; } } - - if (c->cutscene == 0 && gPuppyCam.enabled && !(gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON)) + #endif + if (c->cutscene == 0 && + #ifdef PUPPYCAM + gPuppyCam.enabled && + #endif + !(gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON)) { // Clear the recent cutscene after 8 frames if (gRecentCutscene != 0 && sFramesSinceCutsceneEnded < 8) { @@ -3249,7 +3264,9 @@ void update_camera(struct Camera *c) { sFramesSinceCutsceneEnded = 0; } } + #ifdef PUPPYCAM puppycam_loop(); + #endif // Apply camera shakes shake_camera_pitch(gLakituState.pos, gLakituState.focus); shake_camera_yaw(gLakituState.pos, gLakituState.focus); @@ -3498,7 +3515,9 @@ void init_camera(struct Camera *c) { gLakituState.nextYaw = gLakituState.yaw; c->yaw = gLakituState.yaw; c->nextYaw = gLakituState.yaw; + #ifdef PUPPYCAM puppycam_init(); + #endif } /** diff --git a/src/game/game_init.c b/src/game/game_init.c index d15b405e..317e33bf 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -728,7 +728,9 @@ void thread5_game_loop(UNUSED void *arg) { createHvqmThread(); #endif save_file_load_all(); + #ifdef PUPPYCAM puppycam_boot(); + #endif set_vblank_handler(2, &gGameVblankHandler, &gGameVblankQueue, (OSMesg) 1); diff --git a/src/game/hud.c b/src/game/hud.c index 7d73ce81..5106d7dd 100644 --- a/src/game/hud.c +++ b/src/game/hud.c @@ -526,7 +526,9 @@ void render_hud(void) { if (hudDisplayFlags & HUD_DISPLAY_FLAG_CAMERA_AND_POWER) { render_hud_power_meter(); + #ifdef PUPPYCAM if (!gPuppyCam.enabled) + #endif render_hud_camera_status(); } diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index ac93f3dd..c5736037 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -1494,8 +1494,8 @@ void render_pause_red_coins(void) { } } ///By default, not needed as puppycamera has an option, but should you wish to revert that, you are legally allowed. -/* -#ifdef WIDE + +#if defined(WIDE) && !defined(PUPPYCAM) void render_widescreen_setting(void) { gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); @@ -1514,7 +1514,7 @@ void render_widescreen_setting(void) { save_file_set_widescreen_mode(gWidescreen); } } -#endif*/ +#endif #define CRS_NUM_X1 100 #define TXT_STAR_X 98 @@ -1802,10 +1802,11 @@ s8 gHudFlash = 0; s16 render_pause_courses_and_castle(void) { s16 index; - + #ifdef PUPPYCAM puppycam_check_pause_buttons(); if (!gPCOptionOpen) { + #endif switch (gDialogBoxState) { case DIALOG_STATE_OPENING: gDialogLineNum = MENU_OPT_DEFAULT; @@ -1870,12 +1871,13 @@ s16 render_pause_courses_and_castle(void) { } break; } - #ifdef WIDE - //render_widescreen_setting(); + #if defined(WIDE) && !defined(PUPPYCAM) + render_widescreen_setting(); #endif if (gDialogTextAlpha < 250) { gDialogTextAlpha += 25; } + #ifdef PUPPYCAM } else { @@ -1884,6 +1886,7 @@ s16 render_pause_courses_and_castle(void) { } puppycam_render_option_text(); + #endif return MENU_OPT_NONE; } diff --git a/src/game/mario.c b/src/game/mario.c index 1ea37156..31e97bce 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1417,11 +1417,13 @@ void update_mario_inputs(struct MarioState *m) { m->collidedObjInteractTypes = m->marioObj->collidedObjInteractTypes; m->flags &= 0xFFFFFF; + #ifdef PUPPYCAM if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ENTER_FIRST_PERSON) { m->input = INPUT_FIRST_PERSON; return; } + #endif update_mario_button_inputs(m); update_mario_joystick_inputs(m); diff --git a/src/game/mario_misc.c b/src/game/mario_misc.c index 68af9f7a..6eab1b69 100644 --- a/src/game/mario_misc.c +++ b/src/game/mario_misc.c @@ -342,11 +342,13 @@ Gfx *geo_mirror_mario_set_alpha(s32 callContext, struct GraphNode *node, UNUSED if (callContext == GEO_CONTEXT_RENDER) { alpha = (bodyState->modelState & 0x100) ? (bodyState->modelState & 0xFF) : 255; + #ifdef PUPPYCAM if (alpha > gPuppyCam.opacity) { alpha = gPuppyCam.opacity; bodyState->modelState |= MODEL_STATE_NOISE_ALPHA; } + #endif gfx = make_gfx_mario_alpha(asGenerated, alpha); } return gfx; diff --git a/src/game/puppycam2.c b/src/game/puppycam2.c index 1963f215..d69c5bb5 100644 --- a/src/game/puppycam2.c +++ b/src/game/puppycam2.c @@ -23,6 +23,8 @@ #include "save_file.h" #include "mario.h" +#ifdef PUPPYCAM + #define OFFSET 30.0f #define STEPS 1 #define DECELERATION 0.66f @@ -1590,3 +1592,4 @@ void puppycam_loop(void) puppycam_apply(); } +#endif diff --git a/src/game/puppycam2.h b/src/game/puppycam2.h index da825d5e..69819243 100644 --- a/src/game/puppycam2.h +++ b/src/game/puppycam2.h @@ -1,6 +1,8 @@ #ifndef PUPPYCAM2_H #define PUPPYCAM2_H +#ifdef PUPPYCAM + #define PUPPYCAM_FLAGS_CUTSCENE 0x0001 #define PUPPYCAM_FLAGS_SMOOTH 0x0002 @@ -172,4 +174,6 @@ extern void puppycam_activate_cutscene(s32 *scene, s32 lockinput); extern void puppycam_render_option_text(); void puppycam_warp(f32 displacementX, f32 displacementY, f32 displacementZ); +#endif + #endif // PUPPYCAM2_H diff --git a/src/game/save_file.c b/src/game/save_file.c index cf801dcb..1dd1606a 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -391,6 +391,7 @@ void save_file_load_all(void) { } } +#ifdef PUPPYCAM void puppycam_check_save(void) { if (gSaveBuffer.menuData[0].firstBoot != 4 || gSaveBuffer.menuData[0].saveOptions.sensitivityX < 5 || gSaveBuffer.menuData[0].saveOptions.sensitivityY < 5) @@ -419,6 +420,7 @@ void puppycam_set_save(void) gMainMenuDataModified = TRUE; save_main_menu_data(); } +#endif /** * Reload the current save file from its backup copy, which is effectively a diff --git a/src/game/save_file.h b/src/game/save_file.h index d255f2d1..64cf0c63 100644 --- a/src/game/save_file.h +++ b/src/game/save_file.h @@ -75,7 +75,9 @@ struct MainMenuSaveData // Pad to match the EEPROM size of 0x200 (10 bytes on JP/US, 8 bytes on EU) //u8 filler[EEPROM_SIZE / 2 - SUBTRAHEND - NUM_SAVE_FILES * (4 + sizeof(struct SaveFile))]; + #ifdef PUPPYCAM struct gPuppyOptions saveOptions; + #endif struct SaveBlockSignature signature; }; @@ -87,9 +89,11 @@ struct SaveBuffer struct MainMenuSaveData menuData[1]; }; +#ifdef PUPPYCAM extern void puppycam_set_save(void); extern void puppycam_get_save(void); extern void puppycam_check_save(void); +#endif STATIC_ASSERT(sizeof(struct SaveBuffer) <= EEPROM_SIZE, "ERROR: Save struct too big for specified save type");