Skip to content

Commit

Permalink
move certain includes into standard cam API
Browse files Browse the repository at this point in the history
  • Loading branch information
z64a committed Jun 14, 2024
1 parent 30aa71a commit c66aa15
Show file tree
Hide file tree
Showing 44 changed files with 107 additions and 179 deletions.
10 changes: 6 additions & 4 deletions include/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
extern f32 CamLengthScale;

void update_camera_minimal(Camera*);
void update_camera_unused_radial(Camera*);
void update_camera_no_interp(Camera*);
void update_camera_interp_pos(Camera*);
void update_camera_zone_interp(Camera* camera);

void update_camera_unused_confined(Camera*);
void update_camera_unused_leading(Camera*);
void update_camera_no_interp(Camera*);
void create_camera_leadplayer_matrix(Camera*);
void update_camera_unused_radial(Camera*);
void update_camera_unused_ahead(Camera*);

void update_camera_zone_interp(Camera* camera);
void create_camera_leadplayer_matrix(Camera*);
Camera* initialize_next_camera(CameraInitData* data);

#endif
12 changes: 12 additions & 0 deletions include/script_api/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ API_CALLABLE(ShakeCam);
/// @evtapi
API_CALLABLE(SetCamLeadPlayer);

/// @evtapi
API_CALLABLE(EnableCameraFollowPlayerY);

/// @evtapi
API_CALLABLE(DisableCameraFollowPlayerY);

/// @evtapi
API_CALLABLE(EnableCameraLeadingPlayer);

/// @evtapi
API_CALLABLE(DisableCameraLeadingPlayer);

/// @evtapi
API_CALLABLE(SetCamLeadScale);

Expand Down
1 change: 0 additions & 1 deletion src/battle/move/item/dizzy_dial.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "common.h"
#include "script_api/battle.h"
#include "camera.h"

#define NAMESPACE battle_item_dizzy_dial

Expand Down
2 changes: 0 additions & 2 deletions src/cam_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
#include "camera.h"
#include "nu/nusys.h"
#include "hud_element.h"
#include "camera.h"
#include "dx/profiling.h"
#include "dx/debug_menu.h"

void render_models(void);
void execute_render_tasks(void);
Expand Down
29 changes: 28 additions & 1 deletion src/evt/cam_api.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "common.h"
#include "camera.h"

EvtScript ShakeCam1 = {
SetGroup(EVT_GROUP_00)
Expand Down Expand Up @@ -360,6 +359,34 @@ API_CALLABLE(SetCamLeadPlayer) {
return ApiStatus_DONE2;
}

API_CALLABLE(EnableCameraFollowPlayerY) {
Camera* camera = &gCameras[CAM_DEFAULT];

camera->moveFlags &= ~CAMERA_MOVE_IGNORE_PLAYER_Y;
return ApiStatus_DONE2;
}

API_CALLABLE(DisableCameraFollowPlayerY) {
Camera* camera = &gCameras[CAM_DEFAULT];

camera->moveFlags |= CAMERA_MOVE_IGNORE_PLAYER_Y;
return ApiStatus_DONE2;
}

API_CALLABLE(EnableCameraLeadingPlayer) {
Camera* camera = &gCameras[CAM_DEFAULT];

camera->flags &= ~CAMERA_FLAG_SUPRESS_LEADING;
return ApiStatus_DONE2;
}

API_CALLABLE(DisableCameraLeadingPlayer) {
Camera* camera = &gCameras[CAM_DEFAULT];

camera->flags |= CAMERA_FLAG_SUPRESS_LEADING;
return ApiStatus_DONE2;
}

API_CALLABLE(SetCamLeadScale) {
Bytecode* args = script->ptrReadPos;
s32 id = evt_get_variable(script, *args++);
Expand Down
1 change: 0 additions & 1 deletion src/state_file_select.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "common.h"
#include "ld_addrs.h"
#include "nu/nusys.h"
#include "camera.h"
#include "hud_element.h"
#include "sprite.h"
#include "model.h"
Expand Down
1 change: 0 additions & 1 deletion src/state_logos.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "common.h"
#include "ld_addrs.h"
#include "camera.h"
#include "hud_element.h"
#include "sprite.h"
#include "nu/nusys.h"
Expand Down
2 changes: 0 additions & 2 deletions src/world/area_flo/flo_21/flo_21_4_npc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include "world/common/enemy/HuffNPuff.h"
#include "world/common/enemy/RuffPuff.h"

#include "world/common/EnableCameraFollowPlayerY.inc.c"

NpcSettings N(NpcSettings_RuffPuff) = {
.height = 24,
.radius = 28,
Expand Down
4 changes: 1 addition & 3 deletions src/world/area_hos/hos_00/hos_00_6_scenes.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ API_CALLABLE(N(UpdateMagikoopaAngles)) {
return ApiStatus_DONE2;
}

#include "world/common/DisableCameraLeadingPlayer.inc.c"

API_CALLABLE(N(AddOffsetForCamPos)) {
s32 baseX = script->varTable[0];
s32 baseZ = script->varTable[2];
Expand Down Expand Up @@ -232,7 +230,7 @@ EvtScript N(EVS_Scene_MeetingTwink) = {
Call(SetNpcAnimation, NPC_Twink, ANIM_Twink_Idle)
Call(NpcFacePlayer, NPC_Twink, 0)
Call(SpeakToPlayer, NPC_Twink, ANIM_Twink_Shout, ANIM_Twink_Idle, 0, MSG_HOS_000E)
Call(N(DisableCameraLeadingPlayer))
Call(DisableCameraLeadingPlayer)
Call(GetPlayerPos, LVar0, LVar1, LVar2)
Add(LVar0, -20)
Call(UseSettingsFrom, CAM_DEFAULT, LVar0, LVar1, LVar2)
Expand Down
4 changes: 1 addition & 3 deletions src/world/area_hos/hos_01/hos_01_6_star_way.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "hos_01.h"
#include "effects.h"

#include "world/common/EnableCameraFollowPlayerY.inc.c"

#define NAME_SUFFIX _StarWay
#include "world/common/todo/GetFloorCollider.inc.c"
#define NAME_SUFFIX
Expand Down Expand Up @@ -120,7 +118,7 @@ EvtScript N(EVS_AscendStarBeam) = {
EndLoop
EndThread
Wait(30)
Call(N(EnableCameraFollowPlayerY))
Call(EnableCameraFollowPlayerY)
Thread
Label(10)
Call(SetCamSpeed, CAM_DEFAULT, Float(90.0))
Expand Down
8 changes: 3 additions & 5 deletions src/world/area_jan/jan_01/jan_01_3_npc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include "world/common/enemy/JungleFuzzy_Wander.inc.c"
#include "world/common/enemy/JungleFuzzy.inc.c"
#include "world/common/npc/Kolorado.inc.c"
#include "world/common/DisableCameraLeadingPlayer.inc.c"
#include "world/common/EnableCameraLeadingPlayer.inc.c"

EvtScript N(EVS_PlayerWatchKolorado) = {
Loop(0)
Expand All @@ -27,7 +25,7 @@ EvtScript N(EVS_Kolorado_RunToVillage) = {
Call(SetNpcPos, NPC_SELF, NPC_DISPOSE_LOCATION)
Call(SetNpcFlagBits, NPC_SELF, NPC_FLAG_GRAVITY, FALSE)
KillThread(LVar9)
Call(N(EnableCameraLeadingPlayer))
Call(EnableCameraLeadingPlayer)
Call(ResetCam, CAM_DEFAULT, Float(5.0 / DT))
Call(SetSelfVar, 0, 3)
Return
Expand Down Expand Up @@ -82,7 +80,7 @@ EvtScript N(EVS_NpcIdle_Kolorado) = {
Call(SetCamPitch, CAM_DEFAULT, Float(17.0), Float(-7.0))
Call(SetCamSpeed, CAM_DEFAULT, Float(5.0 / DT))
Call(PanToTarget, CAM_DEFAULT, 0, TRUE)
Call(N(DisableCameraLeadingPlayer))
Call(DisableCameraLeadingPlayer)
Call(WaitForCam, CAM_DEFAULT, Float(1.0))
Wait(10 * DT)
Call(SpeakToPlayer, NPC_SELF, ANIM_Kolorado_Talk, ANIM_Kolorado_Idle, 0, MSG_CH5_0011)
Expand Down Expand Up @@ -235,7 +233,7 @@ EvtScript N(EVS_NpcDefeat_JungleFuzzyBoss) = {
Call(SetPanTarget, CAM_DEFAULT, LVar0, LVar1, LVar2)
Call(SetCamDistance, CAM_DEFAULT, 300)
Call(SetCamSpeed, CAM_DEFAULT, Float(3.0))
Call(N(DisableCameraLeadingPlayer))
Call(DisableCameraLeadingPlayer)
Call(PanToTarget, CAM_DEFAULT, 0, TRUE)
Call(SetNpcFlagBits, NPC_Kolorado, NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_IGNORE_PLAYER_COLLISION, TRUE)
Call(SetNpcAnimation, NPC_Kolorado, ANIM_Kolorado_Run)
Expand Down
13 changes: 5 additions & 8 deletions src/world/area_jan/jan_22/jan_22_3_npc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

#include "world/common/complete/GiveReward.inc.c"

#include "world/common/DisableCameraLeadingPlayer.inc.c"
#include "world/common/EnableCameraLeadingPlayer.inc.c"

enum {
RAVEN_SCENE_AWAITING_COMMAND = 0,
RAVEN_SCENE_LEAP_INTO_ACTION = 10,
Expand Down Expand Up @@ -218,7 +215,7 @@ EvtScript N(EVS_NpcInteract_RaphaelRaven) = {
Call(SetCamPitch, CAM_DEFAULT, Float(15.0), Float(-8.5))
Call(SetCamSpeed, CAM_DEFAULT, Float(1.5 / DT))
Call(PanToTarget, CAM_DEFAULT, 0, TRUE)
Call(N(DisableCameraLeadingPlayer))
Call(DisableCameraLeadingPlayer)
Call(WaitForCam, CAM_DEFAULT, Float(1.0))
Wait(10 * DT)
Call(SetNpcFlagBits, NPC_RaphaelRaven, NPC_FLAG_IGNORE_PLAYER_COLLISION, TRUE)
Expand Down Expand Up @@ -556,7 +553,7 @@ EvtScript N(EVS_ManageRavens) = {
Wait(40 * DT)
Call(BindNpcInteract, NPC_Raven_01, Ref(N(EVS_NpcInteract_Raven)))
Call(SetNpcFlagBits, NPC_Raven_01, NPC_FLAG_IGNORE_PLAYER_COLLISION, FALSE)
Call(N(EnableCameraLeadingPlayer))
Call(EnableCameraLeadingPlayer)
Call(ResetCam, CAM_DEFAULT, Float(1.5 / DT))
Set(GB_StoryProgress, STORY_CH5_ZIP_LINE_READY)
Call(DisablePlayerInput, FALSE)
Expand Down Expand Up @@ -740,7 +737,7 @@ EvtScript N(EVS_NpcIdle_Kolorado_HeldCaptive) = {
Call(SetCamPitch, CAM_DEFAULT, Float(17.0), Float(-7.5))
Call(SetCamSpeed, CAM_DEFAULT, Float(5.0 / DT))
Call(PanToTarget, CAM_DEFAULT, 0, TRUE)
Call(N(DisableCameraLeadingPlayer))
Call(DisableCameraLeadingPlayer)
Call(WaitForCam, CAM_DEFAULT, Float(1.0))
Wait(10 * DT)
Call(SpeakToPlayer, NPC_SELF, ANIM_Kolorado_Talk, ANIM_Kolorado_Idle, 0, MSG_CH5_00C1)
Expand Down Expand Up @@ -780,7 +777,7 @@ EvtScript N(EVS_NpcIdle_Kolorado_HeldCaptive) = {
EndThread
ExecGetTID(N(D_8024511C_B8929C), LVar9)
Wait(35)
Call(N(EnableCameraLeadingPlayer))
Call(EnableCameraLeadingPlayer)
Call(ResetCam, CAM_DEFAULT, Float(5.0))
KillThread(LVar9)
Call(SetSelfVar, 0, 3)
Expand Down Expand Up @@ -1133,7 +1130,7 @@ EvtScript N(EVS_NpcDefeat_SpearGuy) = {
Call(SetCamDistance, CAM_DEFAULT, 300)
Call(SetCamPitch, CAM_DEFAULT, Float(17.0), Float(-7.5))
Call(SetCamSpeed, CAM_DEFAULT, Float(3.0 / DT))
Call(N(DisableCameraLeadingPlayer))
Call(DisableCameraLeadingPlayer)
Call(PanToTarget, CAM_DEFAULT, 0, TRUE)
Call(SetNpcFlagBits, NPC_Kolorado_01, NPC_FLAG_IGNORE_WORLD_COLLISION | NPC_FLAG_IGNORE_PLAYER_COLLISION, TRUE)
Call(SetNpcAnimation, NPC_Kolorado_01, ANIM_Kolorado_Run)
Expand Down
4 changes: 0 additions & 4 deletions src/world/area_kmr/kmr_03/kmr_03_4_entity.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ EvtScript N(EVS_OnSmashBlock2) = {
End
};

#include "world/common/EnableCameraFollowPlayerY.inc.c"

#include "world/common/DisableCameraFollowPlayerY.inc.c"

API_CALLABLE(func_80240358_8C82E8) {
PlayerStatus* playerStatus = &gPlayerStatus;

Expand Down
4 changes: 1 addition & 3 deletions src/world/area_kmr/kmr_20/kmr_20_5_entity.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ API_CALLABLE(N(SetAmbienceVolumeHalf_Entity)){
return ApiStatus_DONE2;
}

#include "world/common/EnableCameraFollowPlayerY.inc.c"

EvtScript N(EVS_SecretPanel_FlipBack) = {
Call(ModifyColliderFlags, MODIFY_COLLIDER_FLAGS_SET_BITS, COLLIDER_o252, COLLIDER_FLAGS_UPPER_MASK)
Call(PlaySoundAtCollider, COLLIDER_o252, SOUND_FLIP_PANEL, SOUND_SPACE_DEFAULT)
Expand Down Expand Up @@ -48,7 +46,7 @@ EvtScript N(EVS_UseSpring_Basement) = {
Call(PlayerJump, -110, -80, -35, 20)
Set(AF_KMR_0B, TRUE)
Else
Call(N(EnableCameraFollowPlayerY))
Call(EnableCameraFollowPlayerY)
Exec(N(EVS_SecretPanel_FlipBack))
Call(PlayerJump, -150, 30, -90, 30)
Call(InterpPlayerYaw, 180, 0)
Expand Down
4 changes: 1 addition & 3 deletions src/world/area_kpa/kpa_08/kpa_08_3_entity.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "kpa_08.h"
#include "entity.h"

#include "world/common/EnableCameraFollowPlayerY.inc.c"

API_CALLABLE(N(ElevatePlayer)) {
Bytecode* args = script->ptrReadPos;
s32 floor = evt_get_variable(script, *args++);
Expand All @@ -20,7 +18,7 @@ EvtScript N(EVS_ActivateSwitch) = {
Return
EndIf
Set(AF_KPA08_PlatformRaised, TRUE)
Call(N(EnableCameraFollowPlayerY))
Call(EnableCameraFollowPlayerY)
Thread
SetGroup(EVT_GROUP_EF)
Call(PlaySoundAtCollider, COLLIDER_o19, SOUND_KPA_RAISE_STONE_PLATFORM, SOUND_SPACE_DEFAULT)
Expand Down
4 changes: 1 addition & 3 deletions src/world/area_kpa/kpa_09/kpa_09_3_entity.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "kpa_09.h"
#include "entity.h"

#include "world/common/EnableCameraFollowPlayerY.inc.c"

API_CALLABLE(N(ElevatePlayer)) {
Bytecode* args = script->ptrReadPos;
s32 floor = evt_get_variable(script, *args++);
Expand All @@ -20,7 +18,7 @@ EvtScript N(EVS_ActivateSwitch) = {
Return
EndIf
Set(AF_KPA09_PlatformRaised, TRUE)
Call(N(EnableCameraFollowPlayerY))
Call(EnableCameraFollowPlayerY)
Thread
SetGroup(EVT_GROUP_EF)
Call(PlaySoundAtCollider, COLLIDER_o19, SOUND_KPA_RAISE_STONE_PLATFORM, SOUND_SPACE_DEFAULT)
Expand Down
15 changes: 6 additions & 9 deletions src/world/area_kzn/kzn_03/kzn_03_3_entity.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#include "kzn_03.h"
#include "entity.h"

#include "world/common/EnableCameraFollowPlayerY.inc.c"
#include "world/common/DisableCameraFollowPlayerY.inc.c"

API_CALLABLE(N(IsPlayerOnFirstCliff)) {
s32 result = -1;

Expand Down Expand Up @@ -37,15 +34,15 @@ EvtScript N(EVS_UseSpringA) = {
Wait(1)
Call(SetPlayerActionState, ACTION_STATE_LAUNCH)
Wait(1)
Call(N(EnableCameraFollowPlayerY))
Call(EnableCameraFollowPlayerY)
ExecGetTID(N(EVS_TetherCameraToPlayer), LVarA)
Call(SetPlayerJumpscale, Float(0.7))
Call(PlayerJump, 335, 290, 360, 40)
Call(SetPlayerFlagBits, PS_FLAG_FLYING, TRUE)
Call(SetPlayerActionState, ACTION_STATE_FALLING)
Call(DisablePlayerPhysics, FALSE)
KillThread(LVarA)
Call(N(DisableCameraFollowPlayerY))
Call(DisableCameraFollowPlayerY)
Return
End
};
Expand All @@ -56,15 +53,15 @@ EvtScript N(EVS_UseSpringB) = {
Wait(1)
Call(SetPlayerActionState, ACTION_STATE_JUMP)
Wait(1)
Call(N(EnableCameraFollowPlayerY))
Call(EnableCameraFollowPlayerY)
ExecGetTID(N(EVS_TetherCameraToPlayer), LVarA)
Call(SetPlayerJumpscale, Float(0.7))
Call(PlayerJump, 350, 470, 210, 40)
Call(SetPlayerActionState, ACTION_STATE_LAND)
Call(DisablePlayerPhysics, FALSE)
Call(DisablePlayerInput, FALSE)
KillThread(LVarA)
Call(N(DisableCameraFollowPlayerY))
Call(DisableCameraFollowPlayerY)
Return
End
};
Expand All @@ -76,7 +73,7 @@ EvtScript N(EVS_UseSpringC) = {
Wait(1)
Call(SetPlayerActionState, ACTION_STATE_JUMP)
Wait(1)
Call(N(EnableCameraFollowPlayerY))
Call(EnableCameraFollowPlayerY)
ExecGetTID(N(EVS_TetherCameraToPlayer), LVarA)
IfEq(MV_PlayerCliffState, 0)
Call(SetPlayerJumpscale, Float(1.4))
Expand All @@ -89,7 +86,7 @@ EvtScript N(EVS_UseSpringC) = {
Call(DisablePlayerPhysics, FALSE)
Call(DisablePlayerInput, FALSE)
KillThread(LVarA)
Call(N(DisableCameraFollowPlayerY))
Call(DisableCameraFollowPlayerY)
Return
End
};
Expand Down
Loading

0 comments on commit c66aa15

Please sign in to comment.