From 9f538f8e7de16e61ea166d61c670ba043f601097 Mon Sep 17 00:00:00 2001 From: Fazana <52551480+FazanaJ@users.noreply.github.com> Date: Sun, 12 Dec 2021 16:25:53 +0000 Subject: [PATCH 1/2] Some puppytech fixes --- src/engine/level_script.c | 1 + src/game/puppycam2.c | 26 +++++++++++++++++--------- src/game/puppycam2.h | 16 +++++++++------- src/game/puppyprint.c | 2 ++ 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/engine/level_script.c b/src/engine/level_script.c index b6274eb64..7e3fa0b9d 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -823,6 +823,7 @@ static void level_cmd_puppyvolume(void) { sPuppyVolumeStack[gPuppyVolumeCount]->shape = CMD_GET(u8, 33); sPuppyVolumeStack[gPuppyVolumeCount]->room = CMD_GET(s16, 34); + sPuppyVolumeStack[gPuppyVolumeCount]->fov = CMD_GET(u8, 36); sPuppyVolumeStack[gPuppyVolumeCount]->area = sCurrAreaIndex; gPuppyVolumeCount++; diff --git a/src/game/puppycam2.c b/src/game/puppycam2.c index a5d00272c..09ed62d75 100644 --- a/src/game/puppycam2.c +++ b/src/game/puppycam2.c @@ -879,7 +879,7 @@ void puppycam_terrain_angle(void) { adjustSpeed = 0.25f; farFromSurface = TRUE; } else { - adjustSpeed = CLAMP(MAX(gMarioState->forwardVel/480.0f, gPuppyCam.yawAcceleration/100.0f), 0.05f, 1.0f); + adjustSpeed = CLAMP(MAX(gMarioState->forwardVel/400.0f, gPuppyCam.yawAcceleration/100.0f), 0.05f, 1.0f); f32 x = gPuppyCam.targetObj->oPosX - (10 * sins(gPuppyCam.yaw)); f32 z = gPuppyCam.targetObj->oPosZ - (10 * coss(gPuppyCam.yaw)); @@ -1000,10 +1000,10 @@ void puppycam_projection_behaviours(void) { // This will only be executed if Mario's the target. If it's not, it'll reset the if (gPuppyCam.targetObj == gMarioState->marioObj) { - if (gPuppyCam.options.turnAggression > 0 && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_TURN_HELPER && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) && - gMarioState->vel[1] == 0.0f && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) && gPuppyCam.options.inputType != 2) { // Holy hell this is getting spicy. + if ((gPuppyCam.options.turnAggression > 0 && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_TURN_HELPER && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) && + gMarioState->vel[1] == 0.0f && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) && gPuppyCam.options.inputType != 2) || (gMarioState->action == ACT_SHOT_FROM_CANNON || gMarioState->action == ACT_FLYING)) { // Holy hell this is getting spicy. // With turn aggression enabled, or if Mario's sliding, adjust the camera view behind mario. - if (gPuppyCam.options.turnAggression > 0 || gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE) { + if (gPuppyCam.options.turnAggression > 0 || gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE || gMarioState->action == ACT_SHOT_FROM_CANNON || gMarioState->action == ACT_FLYING) { if (gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE) { turnRate = 4; // If he's sliding, do it 4x as fast. } @@ -1036,11 +1036,11 @@ void puppycam_projection_behaviours(void) { if (gMarioState->action == ACT_SLEEPING || gMarioState->action == ACT_START_SLEEPING) { gPuppyCam.zoom = approach_f32_asymptotic(gPuppyCam.zoom,gPuppyCam.zoomPoints[0],0.01f); - } else if (gMarioState->action & ACT_FLAG_SWIMMING && gMarioState->waterLevel-100 - gMarioState->pos[1] > 5) { - // When moving underwater, the camera will zoom in on Mayro. + } else if ((gMarioState->action & ACT_FLAG_SWIMMING_OR_FLYING && gMarioState->waterLevel-100 - gMarioState->pos[1] > 5) || gMarioState->action == ACT_FLYING) { + // When moving underwater or flying, the camera will zoom in on Mayro. gPuppyCam.zoom = approach_f32_asymptotic(gPuppyCam.zoom, MAX(gPuppyCam.zoomTarget/1.5f, gPuppyCam.zoomPoints[0]), 0.2f); } else { - gPuppyCam.zoom = approach_f32_asymptotic(gPuppyCam.zoom,gPuppyCam.zoomTarget,0.2f); + gPuppyCam.zoom = approach_f32_asymptotic(gPuppyCam.zoom,gPuppyCam.zoomTarget, 0.2f); } // Attempts at automatic adjustment that only apply when moving or jumping. if (gMarioState->action & ACT_FLAG_MOVING || gMarioState->action & ACT_FLAG_AIR || (gMarioState->action & ACT_FLAG_SWIMMING && !gMarioState->waterLevel-100 - gMarioState->pos[1] > 5 && gMarioState->forwardVel != 0.0f)) { @@ -1061,7 +1061,7 @@ void puppycam_projection_behaviours(void) { gPuppyCam.zoom = approach_f32_asymptotic((f32)gPuppyCam.zoom, 250.0f, CLAMP((f32)((gPuppyCam.pitch - 0x38C0) / 3072.0f), 0.0f, 1.0f)); } - if (!(gMarioState->action & ACT_FLAG_SWIMMING)) { + if (!(gMarioState->action & ACT_FLAG_SWIMMING_OR_FLYING)) { gPuppyCam.floorY[0] = softClamp(gPuppyCam.targetObj->oPosY - gPuppyCam.lastTargetFloorHeight, -180, 300); gPuppyCam.floorY[1] = softClamp(gPuppyCam.targetObj->oPosY - gPuppyCam.lastTargetFloorHeight, -180, 350); gPuppyCam.swimPitch = approach_f32_asymptotic(gPuppyCam.swimPitch,0,0.2f); @@ -1072,7 +1072,7 @@ void puppycam_projection_behaviours(void) { gPuppyCam.lastTargetFloorHeight = gPuppyCam.targetObj->oPosY; gPuppyCam.yawTarget = approach_angle(gPuppyCam.yawTarget, (gMarioState->faceAngle[1] + 0x8000), (1000 * (gMarioState->forwardVel / 32))); - if (gMarioState->waterLevel - 100 - gMarioState->pos[1] > 5 && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PITCH_ROTATION) { + if ((gMarioState->waterLevel - 100 - gMarioState->pos[1] > 5 && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PITCH_ROTATION) || gMarioState->action == ACT_FLYING || gMarioState->action == ACT_SHOT_FROM_CANNON) { gPuppyCam.swimPitch = approach_f32_asymptotic(gPuppyCam.swimPitch,gMarioState->faceAngle[0] / 10, 0.05f); } else { gPuppyCam.swimPitch = approach_f32_asymptotic(gPuppyCam.swimPitch, 0, 0.2f); @@ -1087,6 +1087,14 @@ void puppycam_projection_behaviours(void) { // This will shift the intended yaw when wall kicking, to align with the wall being kicked. // puppycam_wall_angle(); + +#ifdef ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS +if (gMarioState->floor != NULL && gMarioState->floor->type == SURFACE_LOOK_UP_WARP && save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1) >= 10) { + if (gPuppyCam.pitchTarget >= 0x7000) { + level_trigger_warp(gMarioState, WARP_OP_LOOK_UP); + } + } +#endif } else { puppycam_reset_values(); } diff --git a/src/game/puppycam2.h b/src/game/puppycam2.h index f81b72f0f..66dca9f03 100644 --- a/src/game/puppycam2.h +++ b/src/game/puppycam2.h @@ -33,14 +33,15 @@ #include "include/command_macros_base.h" -#define PUPPYVOLUME(x, y, z, length, height, width, yaw, functionptr, anglesptr, addflags, removeflags, flagpersistance, room, shape) \ +#define PUPPYVOLUME(x, y, z, length, height, width, yaw, functionptr, anglesptr, addflags, removeflags, flagpersistance, room, shape, fov) \ 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) + CMD_BBH(flagpersistance, shape, room) \ + CMD_BBH(fov, 0x0, 0x0) struct gPuppyOptions { @@ -121,25 +122,26 @@ struct sPuppyAngles //Structurally, it's exactly the same as CutsceneSplinePoint struct sPuppySpline { + Vec3s pos; // The vector pos of the spline index itself. s8 index; // The index of the spline. Ends with -1 u8 speed; // The amount of frames it takes to get through this index. - Vec3s pos; // The vector pos of the spline index itself. }; //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. + Vec3s pos; // The set position of the volume + Vec3s radius; // Where it extends. + s16 rot; // The rotational angle of the volume. + s16 room; u8 flagPersistance; // Decides if adding or removing the flags is temporary or permanent. u8 shape; - s16 room; u8 area; + u8 fov; }; enum gPuppyCamBeh diff --git a/src/game/puppyprint.c b/src/game/puppyprint.c index 024efe54a..745359d3d 100644 --- a/src/game/puppyprint.c +++ b/src/game/puppyprint.c @@ -686,6 +686,8 @@ void render_page_menu(void) { void puppyprint_render_profiler(void) { OSTime first = osGetTime(); + print_set_envcolour(255, 255, 255, 255); + if (!fDebug) { profiler_update(profilerTime, first); return; From a5a826052eda8b094edf66df2b5dae91cb595a1d Mon Sep 17 00:00:00 2001 From: Fazana <52551480+FazanaJ@users.noreply.github.com> Date: Sun, 12 Dec 2021 19:38:19 +0000 Subject: [PATCH 2/2] Further Puppycamera fixes --- asm/rom_header.s | 6 ++++++ src/game/puppycam2.c | 12 +++++++----- src/game/save_file.h | 10 ++++++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/asm/rom_header.s b/asm/rom_header.s index 1ed6540d1..da2041f21 100644 --- a/asm/rom_header.s +++ b/asm/rom_header.s @@ -25,6 +25,12 @@ #else .ascii "E" /* NTSC-U (North America) */ #endif + +#if defined(PUPPYCAM) && defined(EEP4K) + #undef EEP4K + #define EEP16K +#endif + #if defined(SRAM) .byte 0x32 /* Version */ #elif defined(EEP16K) diff --git a/src/game/puppycam2.c b/src/game/puppycam2.c index 09ed62d75..5f08b30a6 100644 --- a/src/game/puppycam2.c +++ b/src/game/puppycam2.c @@ -997,22 +997,24 @@ void puppycam_wall_angle(void) { void puppycam_projection_behaviours(void) { f32 turnRate = 1; + f32 turnMag = ABS(gPlayer1Controller->rawStickX / 80.0f); // This will only be executed if Mario's the target. If it's not, it'll reset the if (gPuppyCam.targetObj == gMarioState->marioObj) { if ((gPuppyCam.options.turnAggression > 0 && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_TURN_HELPER && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) && - gMarioState->vel[1] == 0.0f && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) && gPuppyCam.options.inputType != 2) || (gMarioState->action == ACT_SHOT_FROM_CANNON || gMarioState->action == ACT_FLYING)) { // Holy hell this is getting spicy. + gMarioState->vel[1] == 0.0f && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) && gPuppyCam.options.inputType != 2) || gMarioState->action == ACT_SHOT_FROM_CANNON || gMarioState->action == ACT_FLYING) { // Holy hell this is getting spicy. // With turn aggression enabled, or if Mario's sliding, adjust the camera view behind mario. if (gPuppyCam.options.turnAggression > 0 || gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE || gMarioState->action == ACT_SHOT_FROM_CANNON || gMarioState->action == ACT_FLYING) { if (gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE) { turnRate = 4; // If he's sliding, do it 4x as fast. } + if (gMarioState->action == ACT_SHOT_FROM_CANNON || gMarioState->action == ACT_FLYING) + turnMag = 1; // The deal here, is if Mario's moving, or he's sliding and the camera's within 90 degrees behind him, it'll auto focus behind him, with an intensity based on the camera's centre speed. // It also scales with forward velocity, so it's a gradual effect as he speeds up. - if ((ABS(gPlayer1Controller->rawStickX) > 20 && !(gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE)) || - (gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE && - (s16)ABS(((gPuppyCam.yaw + 0x8000) % 0xFFFF - 0x8000) - ((gMarioState->faceAngle[1]) % 0xFFFF - 0x8000)) < 0x3000 )) - gPuppyCam.yawTarget = approach_angle(gPuppyCam.yawTarget, (gMarioState->faceAngle[1] + 0x8000), ((gPuppyCam.options.turnAggression * 10) * ABS(gMarioState->forwardVel / 32) * ABS(gPlayer1Controller->rawStickX / 80.0f) * turnRate)); + if ((ABS(gPlayer1Controller->rawStickX) > 20 && !(gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE)) || (gMarioState->action == ACT_SHOT_FROM_CANNON) || + (gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE && (s16)ABS(((gPuppyCam.yaw + 0x8000) % 0xFFFF - 0x8000) - ((gMarioState->faceAngle[1]) % 0xFFFF - 0x8000)) < 0x3000 )) + gPuppyCam.yawTarget = approach_angle(gPuppyCam.yawTarget, (gMarioState->faceAngle[1] + 0x8000), ((gPuppyCam.options.turnAggression * 10) * ABS(gMarioState->forwardVel / 32) * turnMag * turnRate)); } } else { //If none of the above is true, it'll attempt to do this instead. // If the camera's in these modes, snap the yaw to prevent desync. diff --git a/src/game/save_file.h b/src/game/save_file.h index 9fe3b9752..199970193 100644 --- a/src/game/save_file.h +++ b/src/game/save_file.h @@ -9,6 +9,11 @@ #include "course_table.h" +#if defined(PUPPYCAM) && defined(EEP4K) + #undef EEP4K + #define EEP16K +#endif + #if defined(SRAM) #define EEPROM_SIZE 0x8000 #elif defined(EEP16K) @@ -77,9 +82,6 @@ struct MainMenuSaveData { u8 firstBoot; #ifdef PUPPYCAM - // 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; #endif struct SaveBlockSignature signature; @@ -89,7 +91,7 @@ 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[1]; + struct MainMenuSaveData menuData[2]; }; #ifdef PUPPYCAM