Ifdefs and config

This commit is contained in:
Fazana
2021-08-15 15:15:16 +01:00
parent 280baf58ad
commit 5dc75cf792
13 changed files with 60 additions and 9 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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) {

View File

@@ -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
}
/**

View File

@@ -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);

View File

@@ -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();
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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");