Skip to content
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
f880be6
reonucam initial commit
Reonu Jan 11, 2022
69606ac
delete text_srings.h.in file
Reonu Apr 2, 2024
fc86b11
removed oudated config info
Reonu Apr 17, 2024
111a5a7
cleaner printing code + multilang
Reonu Apr 17, 2024
8b54cf6
add camera collision
Reonu Apr 17, 2024
3c49d2f
add comment
Reonu Apr 17, 2024
ba9fb41
cast the ray from 300 units above mario
Reonu Apr 17, 2024
54727ce
set default camera speed to medium
Reonu Apr 17, 2024
b91fb42
add comment
Reonu Apr 17, 2024
54bd5bc
clarify config_camera stuff
Reonu Apr 17, 2024
8875cc3
put safewuards in the right place
Reonu Apr 17, 2024
d794f3a
update french reonucam text
Reonu Apr 17, 2024
835f877
remove unnecesary define and fix flying
Reonu Apr 17, 2024
1555667
fix spacing
Reonu Apr 17, 2024
b8b86cc
add japanese text
Reonu Apr 17, 2024
ccb9a8e
remove formatting change
Reonu Apr 18, 2024
af17caf
update readme
Reonu Apr 18, 2024
2a40167
update readme again
Reonu Apr 18, 2024
5db1d1d
Fix capitalization
Reonu Apr 20, 2024
5ce4797
fix space
Reonu Apr 20, 2024
f4ec430
remove unnecessary ifdefs
Reonu Apr 20, 2024
56f4b9c
address requested changes
Reonu Apr 20, 2024
725596d
Reduce ifdefs in mode_8_directions_camera
Reonu Feb 13, 2025
32e904c
Minor formatting changes
Reonu Feb 13, 2025
1b7df11
remove unnecessary line
Reonu Feb 13, 2025
32ad8ee
cleaned up camera sound stuff
Reonu Feb 13, 2025
d440b12
fix spaces
Reonu Feb 13, 2025
e3ec7e5
nitpics
Reonu Feb 13, 2025
b284156
fix spaces properly
Reonu Feb 13, 2025
e15a57e
use ARRAY_COUNT for camera speeds
Reonu Feb 13, 2025
24743f6
use block comment
Reonu Feb 13, 2025
86134d2
make the game build without reonucam
Reonu Feb 16, 2025
eb78b1c
newline
Reonu Feb 16, 2025
bedd59a
reorder savefile settigns
Reonu Feb 16, 2025
e99a038
rename cameraSpeeds to reonucamSpeeds
Reonu Feb 16, 2025
2dc732e
mute camera sound properly
Reonu Feb 16, 2025
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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ Thanks to Frame#5375 and AloXado320 for also helping with silhouette stuff
- Removed course-specific camera processing *
- Ability to set Mario's movement speed when hanging from a ceiling *
- Tighter hanging controls (Mario will face the direction of the analog stick directly while hanging from a ceiling) *
- reonucam3: custom camera by Reonu. This is included as a .patch file in the enhancements folder, you need to apply it if you want this camera.
This video shows a rundown of the features: https://youtu.be/TQNkznX9Z3k
- Reonucam: Custom camera by Reonu. Now included as a define in config_camera.h.
- Ability to disable Mario getting suck in snow or sand

**Hacker QOL:**
Expand Down
21 changes: 13 additions & 8 deletions include/config/config_camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,26 @@
#define FAST_VERTICAL_CAMERA_MOVEMENT

/**
* Enables "parallel lakitu camera" or "aglab cam" which lets you move the camera smoothly with the D-pad.
* Enables camera collision for 8 direction camera and, by extension, to Parallel Lakitu cam or Reonucam if enabled.
* If you enable it, please consider using surface types with the SURFACE_FLAG_NO_CAM_COLLISION flag for small obstacles,
* such as fences, pillars, signs, etc, in order to make your game more enjoyable and not let the camera get in the way of gameplay.
*/
#define PARALLEL_LAKITU_CAM
#define EIGHT_DIR_CAMERA_COLLISION

/**
* Enables Puppy Camera 2, a rewritten camera that can be freely configured and modified.
* Enables "parallel lakitu camera" or "aglab cam" which lets you move the camera smoothly with the D-pad. Will be disabled if Reonucam is enabled.
*/
// #define PUPPYCAM
#define PARALLEL_LAKITU_CAM
/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wants a newline.

* Enables Reonucam, a custom camera that aims to be a more feature-rich "aglabcam" that doesn't use a single button more than the vanilla camera.
* An explanation the features can be seen here: https://www.youtube.com/watch?v=TQNkznX9Z3k (please note that the analog feature shown at the end is no longer present)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"An explanation OF the features..."

*/
#define REONUCAM

/**
* Note: Reonucam is available, but because we had no time to test it properly, it's included as a patch rather than being in the code by default.
* Run this command to apply the patch if you want to use it:
* tools/apply_patch.sh enhancements/reonucam.patch
* Consider it a beta, but it should work fine. Please report any bugs with it. Applying the patch will simply add a define here, so you can still turn it off even after patching.
* Enables Puppy Camera 2, a rewritten camera that can be freely configured and modified.
*/
// #define PUPPYCAM

/**********************************/
/***** Vanilla config options *****/
Expand Down
28 changes: 28 additions & 0 deletions include/config/config_safeguards.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,34 @@
#define FLYING_CAMERA_MODE CAMERA_MODE_BEHIND_MARIO
#endif // !FLYING_CAMERA_MODE

// Reonucam overrides
#ifdef REONUCAM
// Use course default mode
#ifdef USE_COURSE_DEFAULT_MODE
#undef USE_COURSE_DEFAULT_MODE
#define USE_COURSE_DEFAULT_MODE
#endif
Comment on lines +145 to +148
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this doing what you think it's doing? This code seems completely useless lol.

I assume what you meant to do was force camera default mode to always be on, in which case just get rid of the ifdef/endif lines completely. Same goes for the 4 lines after this, only that ifdef is actually not broken this time so it matters a bit less lol.


// Force camera mode to 8 Dir
#ifdef FORCED_CAMERA_MODE
#undef FORCED_CAMERA_MODE
#endif
#define FORCED_CAMERA_MODE CAMERA_MODE_8_DIRECTIONS

// Disable vanilla cam processing
#undef ENABLE_VANILLA_CAM_PROCESSING

// Disable aglab cam
#undef PARALLEL_LAKITU_CAM

// Disable camera sounds
#define play_sound_cbutton_up()
#define play_sound_cbutton_down()
#define play_sound_cbutton_side()
#define play_sound_if_cam_switched_to_lakitu_or_mario()
#endif



/*****************
* config_game.h
Expand Down
178 changes: 168 additions & 10 deletions src/game/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
*
*/

#ifdef REONUCAM
struct ReonucamState gReonucamState = { 2, FALSE, FALSE, FALSE, 0, 0, };
#endif

// BSS
/**
* Stores Lakitu's position from the last frame, used for transitioning in next_lakitu_state()
Expand Down Expand Up @@ -875,6 +879,25 @@ s32 update_8_directions_camera(struct Camera *c, Vec3f focus, Vec3f pos) {
f32 yOff = 125.f;
f32 baseDist = 1000.f;

#ifdef REONUCAM
if (gMarioState->action & ACT_FLAG_SWIMMING) {
yOff = -125.f;
} else if (gMarioState->action & ACT_FLAG_SWIMMING_OR_FLYING) {
yOff = 325.f;
} else {
yOff = 125.f;
}

if ((gPlayer1Controller->buttonDown & R_TRIG) && (gPlayer1Controller->buttonDown & U_CBUTTONS)) {
gReonucamState.keepCliffCam = 1;
pitch = DEGREES(60);
} else if (((gPlayer1Controller->buttonDown & U_CBUTTONS) || (gPlayer1Controller->buttonDown & R_TRIG)) && gReonucamState.keepCliffCam) {
pitch = DEGREES(60);
} else {
gReonucamState.keepCliffCam = 0;
}
#endif

sAreaYaw = camYaw;
calc_y_to_curr_floor(&posY, 1.f, 200.f, &focusY, 0.9f, 200.f);
focus_on_mario(focus, pos, posY + yOff, focusY + yOff, sLakituDist + baseDist, pitch, camYaw);
Expand Down Expand Up @@ -1116,13 +1139,128 @@ s32 snap_to_45_degrees(s16 angle) {
return angle;
}

#ifdef EIGHT_DIR_CAMERA_COLLISION

#define MIN_CAMERA_DISTANCE 300.0f // Minimum distance between Mario and the camera.
#define VERTICAL_RAY_OFFSET 300.0f // The ray is cast from 300 units above Mario in order to prevent small obstacles from constantly snapping the camera

void eight_dir_collision_handler(struct Camera *c) {
struct Surface *surf;

Vec3f camdir;
Vec3f origin;
Vec3f thick;
Vec3f hitpos;

vec3f_copy(origin,gMarioState->pos);

origin[1] += VERTICAL_RAY_OFFSET;
camdir[0] = c->pos[0] - origin[0];
camdir[1] = c->pos[1] - origin[1];
camdir[2] = c->pos[2] - origin[2];

find_surface_on_ray(origin, camdir, &surf, hitpos, (RAYCAST_FIND_FLOOR | RAYCAST_FIND_WALL | RAYCAST_FIND_CEIL));

if (surf) {
f32 distFromSurf = 100.0f;
f32 dist;
f32 yDist = 0;
Vec3f camToMario;
vec3f_diff(camToMario, gMarioState->pos, hitpos);
s16 yaw = atan2s(camToMario[2], camToMario[0]);
vec3f_get_lateral_dist(hitpos,gMarioState->pos, &dist);
if (dist < MIN_CAMERA_DISTANCE) {
distFromSurf += (dist - MIN_CAMERA_DISTANCE); // If Mario runs right up to the screen, the camera pull back slightly...
yDist = MIN_CAMERA_DISTANCE - CLAMP(dist, 0, MIN_CAMERA_DISTANCE); // ...and also up slightly.
}
thick[0] = sins(yaw) * distFromSurf;
thick[1] = yDist;
thick[2] = coss(yaw) * distFromSurf;
vec3f_add(hitpos,thick);
vec3f_copy(c->pos,hitpos);
c->yaw = yaw;
}
else {
c->yaw = atan2s(c->pos[2] - gMarioState->pos[2], c->pos[0] - gMarioState->pos[0]);
}

}
#endif

#ifdef REONUCAM
f32 reonucamSpeeds[5] = {0.5f, 1.f, 1.5f, 2.f, 3.5f}; // The camera speed settings, from slowest to fastest.
#define R_DOUBLE_TAP_WINDOW 5 // How many frames the player has to double tap R in order to ender Mario cam mode.

void reonucam_handler(struct Camera *c) {
Vec3f pos;
s16 oldAreaYaw = sAreaYaw;
// Get the camera speed based on the user's setting
f32 cameraSpeed = reonucamSpeeds[gReonucamState.speed];

//45º rotations
if ((gPlayer1Controller->buttonPressed & L_CBUTTONS) && !(gPlayer1Controller->buttonDown & R_TRIG)) {
s8DirModeBaseYaw = snap_to_45_degrees(s8DirModeBaseYaw - DEGREES(45));
} else if ((gPlayer1Controller->buttonPressed & R_CBUTTONS) && !(gPlayer1Controller->buttonDown & R_TRIG)) {
s8DirModeBaseYaw = snap_to_45_degrees(s8DirModeBaseYaw + DEGREES(45));
}

//Smooth rotation
if (gPlayer1Controller->buttonDown & R_TRIG) {
if (gPlayer1Controller->buttonDown & L_CBUTTONS) {
s8DirModeBaseYaw -= DEGREES(cameraSpeed);
} else if (gPlayer1Controller->buttonDown & R_CBUTTONS) {
s8DirModeBaseYaw += DEGREES(cameraSpeed);
}
if (gReonucamState.rButtonCounter++ > 100) { // This increses whenever R is held.
gReonucamState.rButtonCounter = 100;
}
} else {
if (gReonucamState.rButtonCounter > 0 && gReonucamState.rButtonCounter <= R_DOUBLE_TAP_WINDOW && !((gPlayer1Controller->buttonDown & L_CBUTTONS) || (gPlayer1Controller->buttonDown & R_CBUTTONS) || (gMarioState->action & ACT_FLAG_SWIMMING_OR_FLYING))) {
// This centers the camera behind mario. It triggers when you let go of R in less than 5 frames.
s8DirModeYawOffset = 0;
s8DirModeBaseYaw = gMarioState->faceAngle[1]-0x8000;
gMarioState->area->camera->yaw = s8DirModeBaseYaw;
play_sound_rbutton_changed();
}
gReonucamState.rButtonCounter = 0;
}

if (gPlayer1Controller->buttonPressed & R_TRIG) {
if (gReonucamState.rButtonCounter2 <= R_DOUBLE_TAP_WINDOW) {
set_cam_angle(CAM_ANGLE_MARIO); // Enter mario cam if R is pressed 2 times in less than 5 frames
gReonucamState.rButtonCounter2 = R_DOUBLE_TAP_WINDOW + 1;
} else {
gReonucamState.rButtonCounter2 = 0;
}
} else {
if (gReonucamState.rButtonCounter2++ > 100) {
gReonucamState.rButtonCounter2 = 100;
}
}

radial_camera_input(c);

lakitu_zoom(400.f, 0x900);
c->nextYaw = update_8_directions_camera(c, c->focus, pos);

set_camera_height(c, pos[1]);

c->pos[0] = pos[0];
c->pos[2] = pos[2];
sAreaYawChange = sAreaYaw - oldAreaYaw;
eight_dir_collision_handler(c);
}
#endif

/**
* A mode that only has 8 camera angles, 45 degrees apart
*/
void mode_8_directions_camera(struct Camera *c) {
Vec3f pos;
s16 oldAreaYaw = sAreaYaw;

#ifdef REONUCAM
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this function i think it might be better if reonucam_handler was expanded to include the other parts of this function and then it would be a replacement for this function rather than being full of ifdefs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, will look into it tomorrow

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still havent done this smh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this ok now @arthurtilly

reonucam_handler(c);
#else
radial_camera_input(c);

if (gPlayer1Controller->buttonPressed & R_CBUTTONS) {
Expand All @@ -1149,13 +1287,16 @@ void mode_8_directions_camera(struct Camera *c) {
s8DirModeYawOffset = snap_to_45_degrees(s8DirModeYawOffset);
}
#endif

lakitu_zoom(400.f, 0x900);
c->nextYaw = update_8_directions_camera(c, c->focus, pos);
c->pos[0] = pos[0];
c->pos[2] = pos[2];
sAreaYawChange = sAreaYaw - oldAreaYaw;
#ifdef EIGHT_DIR_CAMERA_COLLISION
eight_dir_collision_handler(c);
#endif
set_camera_height(c, pos[1]);
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: inconsistent indentation (also add a comment clarifying it's a REONUCAM endif)

}

/**
Expand Down Expand Up @@ -2751,6 +2892,9 @@ void set_camera_mode(struct Camera *c, s16 mode, s16 frames) {
#ifndef ENABLE_VANILLA_CAM_PROCESSING
if (mode == CAMERA_MODE_8_DIRECTIONS) {
// Helps transition from any camera mode to 8dir
#ifdef REONUCAM
s8DirModeBaseYaw = 0;
#endif
s8DirModeYawOffset = snap_to_45_degrees(c->yaw);
}
#endif
Expand Down Expand Up @@ -2882,11 +3026,18 @@ void update_camera(struct Camera *c) {
// Only process R_TRIG if 'fixed' is not selected in the menu
if (cam_select_alt_mode(CAM_SELECTION_NONE) == CAM_SELECTION_MARIO) {
if (gPlayer1Controller->buttonPressed & R_TRIG) {
#ifdef REONUCAM
if (set_cam_angle(0) == CAM_ANGLE_MARIO) {
s8DirModeBaseYaw = snap_to_45_degrees(s8DirModeBaseYaw);
set_cam_angle(CAM_ANGLE_LAKITU);
}
#else
if (set_cam_angle(0) == CAM_ANGLE_LAKITU) {
set_cam_angle(CAM_ANGLE_MARIO);
} else {
set_cam_angle(CAM_ANGLE_LAKITU);
}
#endif
}
}
play_sound_if_cam_switched_to_lakitu_or_mario();
Expand Down Expand Up @@ -4544,6 +4695,7 @@ void play_camera_buzz_if_c_sideways(void) {
}
}

#ifndef REONUCAM
void play_sound_cbutton_up(void) {
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
}
Expand All @@ -4556,14 +4708,6 @@ void play_sound_cbutton_side(void) {
play_sound(SOUND_MENU_CAMERA_TURN, gGlobalSoundSource);
}

void play_sound_button_change_blocked(void) {
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource);
}

void play_sound_rbutton_changed(void) {
play_sound(SOUND_MENU_CLICK_CHANGE_VIEW, gGlobalSoundSource);
}

void play_sound_if_cam_switched_to_lakitu_or_mario(void) {
if (sCameraSoundFlags & CAM_SOUND_MARIO_ACTIVE) {
play_sound_rbutton_changed();
Expand All @@ -4574,6 +4718,16 @@ void play_sound_if_cam_switched_to_lakitu_or_mario(void) {
sCameraSoundFlags &= ~(CAM_SOUND_MARIO_ACTIVE | CAM_SOUND_NORMAL_ACTIVE);
}

#endif

void play_sound_button_change_blocked(void) {
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource);
}

void play_sound_rbutton_changed(void) {
play_sound(SOUND_MENU_CLICK_CHANGE_VIEW, gGlobalSoundSource);
}

/**
* Handles input for radial, outwards radial, parallel tracking, and 8 direction mode.
*/
Expand Down Expand Up @@ -4652,7 +4806,11 @@ void radial_camera_input(struct Camera *c) {
}

// Zoom in / enter C-Up
#ifdef REONUCAM
if ((gPlayer1Controller->buttonPressed & U_CBUTTONS) && !(gPlayer1Controller->buttonDown & R_TRIG)) {
#else
if (gPlayer1Controller->buttonPressed & U_CBUTTONS) {
#endif
if (gCameraMovementFlags & CAM_MOVE_ZOOMED_OUT) {
gCameraMovementFlags &= ~CAM_MOVE_ZOOMED_OUT;
play_sound_cbutton_up();
Expand Down
18 changes: 17 additions & 1 deletion src/game/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@
#define CAM_MODE_LAKITU_WAS_ZOOMED_OUT 0x02
#define CAM_MODE_MARIO_SELECTED 0x04

#ifdef REONUCAM
struct ReonucamState {
s8 speed;
u8 waterCamOverride;
u8 flyingCamOverride;
u8 keepCliffCam;
u16 rButtonCounter;
u16 rButtonCounter2;
};
extern struct ReonucamState gReonucamState;
#endif

enum CameraSelection {
CAM_SELECTION_NONE,
CAM_SELECTION_MARIO,
Expand Down Expand Up @@ -769,12 +781,16 @@ s32 offset_yaw_outward_radial(struct Camera *c, s16 areaYaw);
void play_camera_buzz_if_cdown(void);
void play_camera_buzz_if_cbutton(void);
void play_camera_buzz_if_c_sideways(void);
#ifndef REONUCAM
void play_sound_cbutton_up(void);
void play_sound_cbutton_down(void);
void play_sound_cbutton_side(void);
void play_sound_if_cam_switched_to_lakitu_or_mario(void);
#else
extern f32 reonucamSpeeds[5];
#endif
void play_sound_button_change_blocked(void);
void play_sound_rbutton_changed(void);
void play_sound_if_cam_switched_to_lakitu_or_mario(void);
void radial_camera_input(struct Camera *c);
void trigger_cutscene_dialog(s32 trigger);
void handle_c_button_movement(struct Camera *c);
Expand Down
Loading