summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorcadmic <cadmic24@gmail.com>2024-09-03 20:00:37 -0700
committerGitHub <noreply@github.com>2024-09-03 23:00:37 -0400
commit7a9209c88561ed1d1c8025e4001f0f29e5921cd2 (patch)
tree8ce355d56d0bfe4513b7a6c74797688e597524d7 /src/code
parent808fe81deb9139207b351735d158cfab41afbfc4 (diff)
[ntsc-1.2] Match z_camera.c (#2112)
* Add CAMERA_CHECK_BTN * Match Camera_Demo3
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_camera.c145
1 files changed, 74 insertions, 71 deletions
diff --git a/src/code/z_camera.c b/src/code/z_camera.c
index 026cf91b1..f368e964d 100644
--- a/src/code/z_camera.c
+++ b/src/code/z_camera.c
@@ -10,6 +10,12 @@ s16 Camera_RequestSettingImpl(Camera* camera, s16 requestedSetting, s16 flags);
s32 Camera_RequestModeImpl(Camera* camera, s16 requestedMode, u8 forceModeChange);
s32 Camera_UpdateWater(Camera* camera);
+#if PLATFORM_N64
+#define CAMERA_CHECK_BTN(input, btn) PadUtils_CheckPressed((input), (btn))
+#else
+#define CAMERA_CHECK_BTN(input, btn) CHECK_BTN_ALL((input)->press.button, (btn))
+#endif
+
#if OOT_DEBUG
s32 Camera_QRegInit(void);
#endif
@@ -3615,14 +3621,14 @@ s32 Camera_KeepOn3(Camera* camera) {
func_80043B60(camera);
camera->atLERPStepScale = 0.0f;
- if (camera->xzSpeed > 0.001f || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z)) {
+ if (camera->xzSpeed > 0.001f || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_A) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_B) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CLEFT) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CDOWN) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CUP) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CRIGHT) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_R) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_Z)) {
camera->stateFlags |= CAM_STATE_CHECK_BG;
camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED;
}
@@ -4971,14 +4977,14 @@ s32 Camera_Unique3(Camera* camera) {
break;
}
doorParams->timer3 = 5;
- if (camera->xzSpeed > 0.001f || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z)) {
+ if (camera->xzSpeed > 0.001f || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_A) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_B) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CLEFT) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CDOWN) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CUP) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CRIGHT) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_R) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_Z)) {
camera->animState++;
} else {
break;
@@ -5080,14 +5086,14 @@ s32 Camera_Unique0(Camera* camera) {
rwData->initalPos = playerPosRot->pos;
} else if (!(player->stateFlags1 & PLAYER_STATE1_29) &&
((OLib_Vec3fDistXZ(&playerPosRot->pos, &rwData->initalPos) >= 10.0f) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z))) {
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_A) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_B) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CLEFT) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CDOWN) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CUP) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CRIGHT) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_R) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_Z))) {
camera->dist = OLib_Vec3fDist(&camera->at, eye);
camera->playerToAtOffset.x = camera->at.x - playerPosRot->pos.x;
camera->playerToAtOffset.y = camera->at.y - playerPosRot->pos.y;
@@ -5107,14 +5113,14 @@ s32 Camera_Unique0(Camera* camera) {
}
if (!(player->stateFlags1 & PLAYER_STATE1_29) &&
- ((0.001f < camera->xzSpeed) || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z))) {
+ ((0.001f < camera->xzSpeed) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_A) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_B) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CLEFT) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CDOWN) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CUP) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CRIGHT) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_R) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_Z))) {
camera->dist = OLib_Vec3fDist(&camera->at, &camera->eye);
camera->playerToAtOffset.x = camera->at.x - playerPosRot->pos.x;
camera->playerToAtOffset.y = camera->at.y - playerPosRot->pos.y;
@@ -6015,30 +6021,30 @@ s32 Camera_Demo3(Camera* camera) {
rwData->unk_0C = 0.1f;
sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_A, 0);
- if (!((rwData->animFrame < 0 || camera->xzSpeed > 0.001f ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z)) &&
- (camera->stateFlags & CAM_STATE_EXTERNAL_FINISHED))) {
- goto skipeyeUpdate;
- }
- FALLTHROUGH;
+ if ((rwData->animFrame < 0 || camera->xzSpeed > 0.001f ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_A) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_B) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CLEFT) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CDOWN) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CUP) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CRIGHT) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_R) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_Z)) &&
+ (camera->stateFlags & CAM_STATE_EXTERNAL_FINISHED)) {
+ // clang-format off
+ // Note: default for switch inside if statement
default:
- camera->stateFlags |= (CAM_STATE_CHECK_BG | CAM_STATE_CAM_FUNC_FINISH);
- camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED;
- if (camera->prevBgCamIndex < 0) {
- Camera_RequestSettingImpl(camera, camera->prevSetting, CAM_REQUEST_SETTING_IGNORE_PRIORITY);
- } else {
- Camera_RequestBgCam(camera, camera->prevBgCamIndex);
- camera->prevBgCamIndex = -1;
+ // clang-format on
+ camera->stateFlags |= (CAM_STATE_CHECK_BG | CAM_STATE_CAM_FUNC_FINISH);
+ camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED;
+ if (camera->prevBgCamIndex < 0) {
+ Camera_RequestSettingImpl(camera, camera->prevSetting, CAM_REQUEST_SETTING_IGNORE_PRIORITY);
+ } else {
+ Camera_RequestBgCam(camera, camera->prevBgCamIndex);
+ camera->prevBgCamIndex = -1;
+ }
+ sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0);
}
- sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0);
- skipeyeUpdate:
skipUpdateEye = true;
break;
}
@@ -6061,8 +6067,6 @@ s32 Camera_Demo3(Camera* camera) {
camera->animState = 4;
}
- if (1) {}
-
if (!skipUpdateEye) {
eyeOffset.r = Camera_LERPCeilF(eyeOffset.r, eyeAtOffset.r, rwData->unk_0C, 2.0f);
eyeOffset.pitch = Camera_LERPCeilS(eyeOffset.pitch, eyeAtOffset.pitch, rwData->unk_0C, 0xA);
@@ -7397,15 +7401,14 @@ s32 Camera_Special9(Camera* camera) {
camera->stateFlags |= (CAM_STATE_CAM_FUNC_FINISH | CAM_STATE_BLOCK_BG);
sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0);
- if (camera->xzSpeed > 0.001f || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) ||
- CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z) ||
- (roData->interfaceField & SPECIAL9_FLAG_3)) {
+ if (camera->xzSpeed > 0.001f || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_A) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_B) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CLEFT) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CDOWN) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CUP) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CRIGHT) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_R) ||
+ CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_Z) || (roData->interfaceField & SPECIAL9_FLAG_3)) {
Camera_RequestSettingImpl(camera, camera->prevSetting, CAM_REQUEST_SETTING_IGNORE_PRIORITY);
camera->stateFlags |= (CAM_STATE_CHECK_WATER | CAM_STATE_CHECK_BG);
@@ -7890,19 +7893,19 @@ s32 Camera_DbgChangeMode(Camera* camera) {
s32 changeDir = 0;
if (!gDebugCamEnabled && camera->play->activeCamId == CAM_ID_MAIN) {
- if (CHECK_BTN_ALL(D_8015BD7C->state.input[2].press.button, BTN_CUP)) {
+ if (CAMERA_CHECK_BTN(&D_8015BD7C->state.input[2], BTN_CUP)) {
PRINTF("attention sound URGENCY\n");
Sfx_PlaySfxCentered(NA_SE_SY_ATTENTION_URGENCY);
}
- if (CHECK_BTN_ALL(D_8015BD7C->state.input[2].press.button, BTN_CDOWN)) {
+ if (CAMERA_CHECK_BTN(&D_8015BD7C->state.input[2], BTN_CDOWN)) {
PRINTF("attention sound NORMAL\n");
Sfx_PlaySfxCentered(NA_SE_SY_ATTENTION_ON);
}
- if (CHECK_BTN_ALL(D_8015BD7C->state.input[2].press.button, BTN_CRIGHT)) {
+ if (CAMERA_CHECK_BTN(&D_8015BD7C->state.input[2], BTN_CRIGHT)) {
changeDir = 1;
}
- if (CHECK_BTN_ALL(D_8015BD7C->state.input[2].press.button, BTN_CLEFT)) {
+ if (CAMERA_CHECK_BTN(&D_8015BD7C->state.input[2], BTN_CLEFT)) {
changeDir = -1;
}
if (changeDir != 0) {
@@ -8164,7 +8167,7 @@ Vec3s Camera_Update(Camera* camera) {
#if OOT_DEBUG
// enable/disable debug cam
- if (CHECK_BTN_ALL(D_8015BD7C->state.input[2].press.button, BTN_START)) {
+ if (CAMERA_CHECK_BTN(&D_8015BD7C->state.input[2], BTN_START)) {
gDebugCamEnabled ^= 1;
if (gDebugCamEnabled) {
DebugCamera_Enable(&D_8015BD80, camera);
@@ -8252,7 +8255,7 @@ Vec3s Camera_Update(Camera* camera) {
}
#if OOT_DEBUG
- if (camera->timer != -1 && CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_DRIGHT)) {
+ if (camera->timer != -1 && CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_DRIGHT)) {
camera->timer = 0;
}
#endif