Puppy Camera 2

Now supported with the HackerSM64 repo
This commit is contained in:
Fazana committed 2021-07-24 16:14:03 +01:00
1 parent 11af76e1a5
commit 305518ce3c
11 files changed
+1944 -8

No files matched your search

+1
View File
@@ -566,6 +566,7 @@ $(BUILD_DIR)/include/text_strings.h: $(BUILD_DIR)/include/text_menu_strings.h
$(BUILD_DIR)/src/menu/file_select.o: $(BUILD_DIR)/include/text_strings.h
$(BUILD_DIR)/src/menu/star_select.o: $(BUILD_DIR)/include/text_strings.h
$(BUILD_DIR)/src/game/ingame_menu.o: $(BUILD_DIR)/include/text_strings.h
$(BUILD_DIR)/src/game/puppycam2.o: $(BUILD_DIR)/include/text_strings.h
#==============================================================================#
+65
View File
@@ -3,6 +3,71 @@
#include "text_menu_strings.h"
#define NC_CAMX_EN _("Camera X Sensitivity")
#define NC_CAMY_EN _("Camera Y Sensitivity")
#define NC_INVERTX_EN _("Invert X Axis")
#define NC_INVERTX_FR _("Invertir Axe X")
#define NC_INVERTX_DE _("Invert X Axis")
#define NC_INVERTY_EN _("Invert Y Axis")
#define NC_CAMC_EN _("Camera Centre Speed")
#define NC_ANALOGUE_EN _("Analogue Camera")
#define NC_SCHEME_EN _("Control Scheme")
#define OPTION_ENABLED_EN _("Enabled")
#define OPTION_DISABLED_EN _("Disabled")
#define OPTION_SCHEME1_EN _("Double Tap")
#define OPTION_SCHEME2_EN _("Single Press")
#define OPTION_SCHEME3_EN _("Classic")
#define NC_HIGHLIGHT_L _(">")
#define NC_HIGHLIGHT_R _("<")
#define NC_BUTTON_EN _("[R]: Options")
#define NC_BUTTON2_EN _("[R]: Return")
#define NC_OPTION_EN _("PUPPYCAM OPTIONS")
#if defined(VERSION_EU)
#define NC_CAMX_FR _("Sensibilite sur l'axe X")
#define NC_CAMX_DE _("Camera X Sensitivity")
#define NC_CAMY_FR _("Sensibilite sur l'axe Y")
#define NC_CAMY_DE _("Camera Y Sensitivity")
#define NC_INVERTY_FR _("Invertir Axe Y")
#define NC_INVERTY_DE _("Invert Y Axis")
#define NC_CAMC_FR _("Vitesse de Centrage")
#define NC_CAMC_DE _("Camera Centre Speed")
#define NC_ANALOGUE_FR _("Camera Analogue")
#define NC_ANALOGUE_DE _("Analogue Camera")
#define NC_SCHEME_FR _("Control Scheme")
#define NC_SCHEME_DE _("Control Scheme")
#define OPTION_ENABLED_FR _("Active")
#define OPTION_ENABLED_DE _("Enabled")
#define OPTION_DISABLED_FR _("Desactive")
#define OPTION_DISABLED_DE _("Disabled")
#define OPTION_SCHEME1_FR _("Double Tap")
#define OPTION_SCHEME1_DE _("Double Tap")
#define OPTION_SCHEME2_FR _("Single Press")
#define OPTION_SCHEME2_DE _("Single Press")
#define OPTION_SCHEME3_FR _("Classic")
#define OPTION_SCHEME3_DE _("Classic")
#define NC_BUTTON_FR _("[R]: Options")
#define NC_BUTTON_DE _("[R]: Options")
#define NC_BUTTON2_FR _("[R]: Retournez")
#define NC_BUTTON2_DE _("[R]: Return")
#define NC_OPTION_FR _("OPTIONS PUPPYCAM")
#define NC_OPTION_DE _("PUPPYCAM OPTIONS")
#endif
/**
* Global Symbols
*/
+41 -2
View File
@@ -1202,7 +1202,7 @@ void mode_8_directions_camera(struct Camera *c) {
}
else if (gPlayer1Controller->buttonPressed & D_JPAD) {
s8DirModeYawOffset = s8DirModeYawOffset&0xE000;
}
}
#endif
lakitu_zoom(400.f, 0x900);
@@ -3038,7 +3038,7 @@ void update_camera(struct Camera *c) {
gCamera = c;
update_camera_hud_status(c);
if (c->cutscene == 0) {
if (c->cutscene == 0 && !gPuppyCam.enabled && !(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,6 +3060,7 @@ void update_camera(struct Camera *c) {
sStatusFlags |= CAM_FLAG_FRAME_AFTER_CAM_INIT;
}
if (!gPuppyCam.enabled || c->cutscene != 0 || gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON) {
// Store previous geometry information
sMarioGeometry.prevFloorHeight = sMarioGeometry.currFloorHeight;
sMarioGeometry.prevCeilHeight = sMarioGeometry.currCeilHeight;
@@ -3182,10 +3183,12 @@ void update_camera(struct Camera *c) {
}
}
}
}
// Start any Mario-related cutscenes
start_cutscene(c, get_cutscene_from_mario_status(c));
stub_camera_2(c);
gCheckingSurfaceCollisionsForCamera = FALSE;
if (!gPuppyCam.enabled || c->cutscene != 0 || gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON) {
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
@@ -3223,7 +3226,42 @@ void update_camera(struct Camera *c) {
}
update_lakitu(c);
}
//Just a cute little bit that syncs puppycamera up to vanilla when playing a vanilla cutscene :3
if (c->cutscene != 0)
{
gPuppyCam.yawTarget = gCamera->yaw;
gPuppyCam.yaw = gCamera->yaw;
if (gMarioState->action == ACT_ENTERING_STAR_DOOR)
{ //god this is stupid and the fact I have to continue doing this is testament to the idiocy of the star door cutscene >:(
gPuppyCam.yawTarget = gMarioState->faceAngle[1]+0x8000;
gPuppyCam.yaw = gMarioState->faceAngle[1]+0x8000;
}
}
if (c->cutscene == 0 && gPuppyCam.enabled && !(gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON))
{
// Clear the recent cutscene after 8 frames
if (gRecentCutscene != 0 && sFramesSinceCutsceneEnded < 8) {
sFramesSinceCutsceneEnded++;
if (sFramesSinceCutsceneEnded >= 8) {
gRecentCutscene = 0;
sFramesSinceCutsceneEnded = 0;
}
}
puppycam_loop();
// Apply camera shakes
shake_camera_pitch(gLakituState.pos, gLakituState.focus);
shake_camera_yaw(gLakituState.pos, gLakituState.focus);
shake_camera_roll(&gLakituState.roll);
shake_camera_handheld(gLakituState.pos, gLakituState.focus);
if (sMarioCamState->action == ACT_DIVE && gLakituState.lastFrameAction != ACT_DIVE) {
set_camera_shake_from_hit(SHAKE_HIT_FROM_BELOW);
}
gLakituState.roll += sHandheldShakeRoll;
gLakituState.roll += gLakituState.keyDanceRoll;
}
gLakituState.lastFrameAction = sMarioCamState->action;
}
@@ -3460,6 +3498,7 @@ void init_camera(struct Camera *c) {
gLakituState.nextYaw = gLakituState.yaw;
c->yaw = gLakituState.yaw;
c->nextYaw = gLakituState.yaw;
puppycam_init();
}
/**
+3 -1
View File
@@ -30,6 +30,7 @@
#include "sram.h"
#endif
#include <prevent_bss_reordering.h>
#include "puppycam2.h"
// First 3 controller slots
struct Controller gControllers[3];
@@ -288,7 +289,7 @@ void create_gfx_task_structure(void) {
gGfxSPTask->task.t.ucode_data = gspF3DEX_fifoDataStart;
#elif SUPER3D_GBI
gGfxSPTask->task.t.ucode = gspSuper3D_fifoTextStart;
gGfxSPTask->task.t.ucode_data = gspSuper3D_fifoDataStart;
gGfxSPTask->task.t.ucode_data = gspSuper3D_fifoDataStart;
#else
gGfxSPTask->task.t.ucode = gspFast3D_fifoTextStart;
gGfxSPTask->task.t.ucode_data = gspFast3D_fifoDataStart;
@@ -707,6 +708,7 @@ void thread5_game_loop(UNUSED void *arg) {
createHvqmThread();
#endif
save_file_load_all();
puppycam_boot();
set_vblank_handler(2, &gGameVblankHandler, &gGameVblankQueue, (OSMesg) 1);
+3 -1
View File
@@ -14,6 +14,7 @@
#include "save_file.h"
#include "print.h"
#include "engine/surface_load.h"
#include "puppycam2.h"
/* @file hud.c
* This file implements HUD rendering and power meter animations.
@@ -506,7 +507,8 @@ void render_hud(void) {
if (hudDisplayFlags & HUD_DISPLAY_FLAG_CAMERA_AND_POWER) {
render_hud_power_meter();
render_hud_camera_status();
if (!gPuppyCam.enabled)
render_hud_camera_status();
}
if (hudDisplayFlags & HUD_DISPLAY_FLAG_TIMER) {
+12 -1
View File
@@ -23,6 +23,7 @@
#include "text_strings.h"
#include "types.h"
#include "config.h"
#include "puppycam2.h"
u16 gDialogColorFadeTimer;
s8 gLastDialogLineNum;
@@ -1414,7 +1415,7 @@ void render_widescreen_setting(void) {
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha);
if (!gWidescreen) {
print_generic_string(10, 20, textCurrRatio43);
print_generic_string(10, 7, textPressL);
print_generic_string(10, 7, textPressL);
}
else {
print_generic_string(10, 20, textCurrRatio169);
@@ -1713,6 +1714,9 @@ s16 render_pause_courses_and_castle(void) {
s16 index;
puppycam_check_pause_buttons();
if (!gPCOptionOpen)
{
switch (gDialogBoxState) {
case DIALOG_STATE_OPENING:
gDialogLineNum = MENU_OPT_DEFAULT;
@@ -1787,7 +1791,14 @@ s16 render_pause_courses_and_castle(void) {
if (gDialogTextAlpha < 250) {
gDialogTextAlpha += 25;
}
}
else
{
shade_screen();
puppycam_display_options();
}
puppycam_render_option_text();
return MENU_OPT_NONE;
}
+15 -2
View File
@@ -24,6 +24,7 @@
#include "save_file.h"
#include "skybox.h"
#include "sound_init.h"
#include "puppycam2.h"
#include "config.h"
@@ -127,7 +128,7 @@ static void toad_message_opaque(void) {
}
static void toad_message_talking(void) {
if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_DOWN,
if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_DOWN,
DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, gCurrentObject->oToadMessageDialogId)) {
gCurrentObject->oToadMessageRecentlyTalked = TRUE;
gCurrentObject->oToadMessageState = TOAD_MESSAGE_FADING;
@@ -314,7 +315,14 @@ static Gfx *make_gfx_mario_alpha(struct GraphNodeGenerated *node, s16 alpha) {
node->fnNode.node.flags = (node->fnNode.node.flags & 0xFF) | (LAYER_TRANSPARENT << 8);
gfxHead = alloc_display_list(3 * sizeof(*gfxHead));
gfx = gfxHead;
gDPSetAlphaCompare(gfx++, G_AC_DITHER);
if (gMarioState->flags & MARIO_VANISH_CAP)
{
gDPSetAlphaCompare(gfx++, G_AC_DITHER);
}
else
{
gDPSetAlphaCompare(gfx++, G_AC_NONE);
}
}
gDPSetEnvColor(gfx++, 255, 255, 255, alpha);
gSPEndDisplayList(gfx);
@@ -334,6 +342,11 @@ 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;
if (alpha > gPuppyCam.opacity)
{
alpha = gPuppyCam.opacity;
bodyState->modelState |= MODEL_STATE_NOISE_ALPHA;
}
gfx = make_gfx_mario_alpha(asGenerated, alpha);
}
return gfx;
+1595
View File
File diff suppressed because it is too large. Load diff
+171
View File
@@ -0,0 +1,171 @@
#ifndef PUPPYCAM2_H
#define PUPPYCAM2_H
#define PUPPYCAM_FLAGS_CUTSCENE 0x0001
#define PUPPYCAM_FLAGS_SMOOTH 0x0002
#define PUPPY_ERROR_POOL_FULL 0x1
#define PUPPY_NULL 15151
#define MAX_PUPPYCAM_VOLUMES 128
#define PUPPYCAM_BEHAVIOUR_TEMPORARY 0x0
#define PUPPYCAM_BEHAVIOUR_PERMANENT 0x1
#define PUPPYVOLUME_SHAPE_BOX 0x0
#define PUPPYVOLUME_SHAPE_CYLINDER 0x1
#define PUPPYCAM_MODE3_ZOOMED_IN 0x1
#define PUPPYCAM_MODE3_ZOOMED_MED 0x2
#define PUPPYCAM_MODE3_ZOOMED_OUT 0x4
#define PUPPYCAM_MODE3_ENTER_FIRST_PERSON 0x8
#include "include/command_macros_base.h"
#define PUPPYVOLUME(x, y, z, length, height, width, yaw, functionptr, anglesptr, addflags, removeflags, flagpersistance, room, shape) \
CMD_BBH(0x3D, 0x24, x), \
CMD_HHHHHH(y, z, length, height, width, yaw), \
CMD_PTR(functionptr), \
CMD_PTR(anglesptr), \
CMD_W(addflags), \
CMD_W(removeflags), \
CMD_BBH(flagpersistance, shape, room)
struct gPuppyOptions
{
s16 analogue;
s16 sensitivityX;
s16 sensitivityY;
s16 invertX;
s16 invertY;
s16 turnAggression;
s16 inputType;
};
struct gPuppyStruct
{
s16 yaw; //Horizontal Direction the game reads as the active value.
s16 yawTarget; //Horizontal Direction that yaw tries to be.
f32 yawAcceleration; //Horizontal Direction that sets yawTarget.
s16 pitch; //Vertical Direction the game reads as the active value.
s16 pitchTarget; //Vertical Direction that pitch tries to be.
f32 pitchAcceleration; //Vertical Direction that sets pitchTarget.
s16 posHeight[2]; //The first index is the ground offset of pos[1], the second index is the ground offset of focus[1].
s16 zoom; //How far the camera is currently zoomed out
u8 zoomSet; //The current setting of which zoompoint to set the target to.
s16 zoomTarget; //The value that zoom tries to be.
s16 zoomPoints[3]; //An array containing distances.
s16 targetFloorHeight; //Mario's current floor height
s16 lastTargetFloorHeight; //Mirror's mario's floor height when his velocity is not above 0.
Vec3s pos; //Where the camera is
Vec3s focus; //Where the camera's looking
Vec3s pan; //An offset of the camera's focus
s32 intendedFlags; //The flagset the camera tries to be when it's not held hostage.
s32 flags; //Behaviour flags that affect different properties of the camera's behaviour
Vec3s shake; //How much the camera's shaking
u8 shakeFrames; //How long the camera's shaking for
f32 shakeForce; //How violently the camera's shaking
s32 framesSinceC[2]; //Counts the number of frames since the last C left or right press, to track double presses.
s16 collisionDistance; //Tries to be zoom, but will be overwritten by collision detection
struct Object *targetObj; //The object that the focus will base its positioning off. Usually Mario.
struct Object *targetObj2; //This is the second focus point that the camera will focus on. It'll focus between them.
s16 povHeight; //An offset of the focus object's Y value.
s16 floorY[2]; //Floor offsets, to allow a grace period before following Mario into the air.
u8 opacity; //A value set by collision distance, to fade Mario out if you're too close.
s8 stick2[2];//The value that's set and read for analogue stick.
u8 stickN[2]; //This is set when the stick is neutral. It's to prevent rapidfire input.
u8 enabled; //A boolean that decides whether to use vanilla camera or puppy camera. Of course, anybody with this enabled is obligated to a death sentence :)
s16 swimPitch; //Pitch adjustment that's applied when swimming. All pitch adjustment is clamped.
s16 edgePitch; //Pitch adjustment that's applied when stood near an edge. All pitch adjustment is clamped.
s16 moveZoom; //A small zoom value that's added on top of the regular zoom when moving. It's pretty subtle, but gives the feeling of a bit of speed.
u8 mode3Flags; //A flagset for classic mode.
u8 moveFlagAdd; //A bit that multiplies movement rate of axes when moving, to centre them faster.
s16 targetDist[2];
u8 cutscene; //A boolean that decides whether a cutscene is active
s32 (*sceneFunc)();
u8 sceneInput; //A boolean that decides whether the controller updates during the scene.
s32 sceneTimer; //The cutscene timer that goes up during a cutscene.
Vec3s scenePos; //Where the camera is during a cutscene
Vec3s sceneFocus; //Where the camera looks during a cutscene
struct gPuppyOptions options;
};
//A second container for bounds that have 2 pairs of coordinates. Optional.
struct sPuppyAngles
{
Vec3s pos;
Vec3s focus;
s16 yaw;
s16 pitch;
s16 zoom;
};
//A bounding volume for activating puppycamera scripts and angles.
struct sPuppyVolume
{
Vec3s pos; //The set position of the volume
Vec3s radius; //Where it extends.
s16 rot; //The rotational angle of the volume.
s32 *func; //a pointer to a function. Optional.
struct sPuppyAngles *angles; //A pointer to a gPuppyAngles struct. Optional
s32 flagsAdd; //Adds behaviour flags.
s32 flagsRemove; //Removes behaviour flags.
u8 flagPersistance; //Decides if adding or removing the flags is temporary or permanent.
u8 shape;
s16 room;
};
enum gPuppyCamBeh
{
PUPPYCAM_BEHAVIOUR_X_MOVEMENT = 0x0001,
PUPPYCAM_BEHAVIOUR_Y_MOVEMENT = 0x0002,
PUPPYCAM_BEHAVIOUR_Z_MOVEMENT = 0x0004,
PUPPYCAM_BEHAVIOUR_YAW_ROTATION = 0x0008,
PUPPYCAM_BEHAVIOUR_PITCH_ROTATION = 0x0010,
PUPPYCAM_BEHAVIOUR_ZOOM_CHANGE = 0x0020,
PUPPYCAM_BEHAVIOUR_INPUT_NORMAL = 0x0040,
PUPPYCAM_BEHAVIOUR_INPUT_8DIR = 0x0080,
PUPPYCAM_BEHAVIOUR_INPUT_4DIR = 0x0100,
PUPPYCAM_BEHAVIOUR_INPUT_2D = 0x0200,
PUPPYCAM_BEHAVIOUR_SLIDE_CORRECTION = 0x0400,
PUPPYCAM_BEHAVIOUR_TURN_HELPER = 0x0800,
PUPPYCAM_BEHAVIOUR_HEIGHT_HELPER = 0x1000,
PUPPYCAM_BEHAVIOUR_PANSHIFT = 0x2000,
PUPPYCAM_BEHAVIOUR_COLLISION = 0x4000,
PUPPYCAM_BEHAVIOUR_DEFAULT = PUPPYCAM_BEHAVIOUR_X_MOVEMENT | PUPPYCAM_BEHAVIOUR_Y_MOVEMENT | PUPPYCAM_BEHAVIOUR_Z_MOVEMENT |
PUPPYCAM_BEHAVIOUR_YAW_ROTATION | PUPPYCAM_BEHAVIOUR_PITCH_ROTATION | PUPPYCAM_BEHAVIOUR_ZOOM_CHANGE |
PUPPYCAM_BEHAVIOUR_HEIGHT_HELPER | PUPPYCAM_BEHAVIOUR_TURN_HELPER | PUPPYCAM_BEHAVIOUR_INPUT_NORMAL | PUPPYCAM_BEHAVIOUR_PANSHIFT | PUPPYCAM_BEHAVIOUR_COLLISION
};
extern u8 gPCOptionOpen;
extern s32 gPuppyError;
extern struct gPuppyStruct gPuppyCam;
extern struct sPuppyVolume *sPuppyVolumeStack[MAX_PUPPYCAM_VOLUMES];
extern u16 gPuppyVolumeCount;
extern struct MemoryPool *gPuppyMemoryPool;
extern void puppycam_boot(void);
extern void puppycam_init(void);
extern void puppycam_loop(void);
extern void puppycam_shake(s16 x, s16 y, s16 z);
extern void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos);
extern f32 approach_f32_asymptotic(f32 current, f32 target, f32 multiplier);
extern void puppycam_default_config(void);
extern s16 LENCOS(s16 length, s16 direction);
extern s16 LENSIN(s16 length, s16 direction);
extern void puppycam_display_options(void);
extern void puppycam_set_save(void);
extern void puppycam_check_pause_buttons(void);
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 // PUPPYCAM2_H
+30
View File
@@ -15,6 +15,7 @@
#ifdef SRAM
#include "sram.h"
#endif
#include "puppycam2.h"
#define ALIGN4(val) (((val) + 0x3) & ~0x3)
@@ -390,6 +391,35 @@ void save_file_load_all(void) {
}
}
void puppycam_check_save(void)
{
if (gSaveBuffer.menuData[0].firstBoot != 4 || gSaveBuffer.menuData[0].saveOptions.sensitivityX < 5 || gSaveBuffer.menuData[0].saveOptions.sensitivityY < 5)
{
wipe_main_menu_data();
gSaveBuffer.menuData[0].firstBoot = 4;
puppycam_default_config();
}
}
void puppycam_get_save(void)
{
gPuppyCam.options = gSaveBuffer.menuData[0].saveOptions;
gSaveBuffer.menuData[0].firstBoot = gSaveBuffer.menuData[0].firstBoot;
puppycam_check_save();
}
void puppycam_set_save(void)
{
gSaveBuffer.menuData[0].saveOptions = gPuppyCam.options;
gSaveBuffer.menuData[0].firstBoot = 4;
gMainMenuDataModified = TRUE;
save_main_menu_data();
}
/**
* Reload the current save file from its backup copy, which is effectively a
* a cached copy of what has been written to EEPROM.
+8 -1
View File
@@ -5,6 +5,7 @@
#include "types.h"
#include "area.h"
#include "puppycam2.h"
#include "course_table.h"
@@ -69,10 +70,12 @@ struct MainMenuSaveData
#else
#define SUBTRAHEND 6
#endif
u8 firstBoot;
// 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))];
struct gPuppyOptions saveOptions;
struct SaveBlockSignature signature;
};
@@ -81,9 +84,13 @@ struct SaveBuffer
// Each of the four save files has two copies. If one is bad, the other is used as a backup.
struct SaveFile files[NUM_SAVE_FILES][2];
// The main menu data has two copies. If one is bad, the other is used as a backup.
struct MainMenuSaveData menuData[2];
struct MainMenuSaveData menuData[1];
};
extern void puppycam_set_save(void);
extern void puppycam_get_save(void);
extern void puppycam_check_save(void);
STATIC_ASSERT(sizeof(struct SaveBuffer) <= EEPROM_SIZE, "ERROR: Save struct too big for specified save type");
extern u8 gLastCompletedCourseNum;