1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-16 12:54:40 +00:00

[ntsc-1.2] Match z_camera.c (#2112)

* Add CAMERA_CHECK_BTN

* Match Camera_Demo3
This commit is contained in:
cadmic 2024-09-03 20:00:37 -07:00 committed by GitHub
parent 808fe81deb
commit 7a9209c885
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,6 +10,12 @@ s16 Camera_RequestSettingImpl(Camera* camera, s16 requestedSetting, s16 flags);
s32 Camera_RequestModeImpl(Camera* camera, s16 requestedMode, u8 forceModeChange); s32 Camera_RequestModeImpl(Camera* camera, s16 requestedMode, u8 forceModeChange);
s32 Camera_UpdateWater(Camera* camera); 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 #if OOT_DEBUG
s32 Camera_QRegInit(void); s32 Camera_QRegInit(void);
#endif #endif
@ -3615,14 +3621,14 @@ s32 Camera_KeepOn3(Camera* camera) {
func_80043B60(camera); func_80043B60(camera);
camera->atLERPStepScale = 0.0f; camera->atLERPStepScale = 0.0f;
if (camera->xzSpeed > 0.001f || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) || if (camera->xzSpeed > 0.001f || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_A) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_B) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CLEFT) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CDOWN) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CUP) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CRIGHT) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_R) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z)) { CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_Z)) {
camera->stateFlags |= CAM_STATE_CHECK_BG; camera->stateFlags |= CAM_STATE_CHECK_BG;
camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED; camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED;
} }
@ -4971,14 +4977,14 @@ s32 Camera_Unique3(Camera* camera) {
break; break;
} }
doorParams->timer3 = 5; doorParams->timer3 = 5;
if (camera->xzSpeed > 0.001f || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) || if (camera->xzSpeed > 0.001f || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_A) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_B) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CLEFT) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CDOWN) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CUP) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CRIGHT) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_R) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z)) { CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_Z)) {
camera->animState++; camera->animState++;
} else { } else {
break; break;
@ -5080,14 +5086,14 @@ s32 Camera_Unique0(Camera* camera) {
rwData->initalPos = playerPosRot->pos; rwData->initalPos = playerPosRot->pos;
} else if (!(player->stateFlags1 & PLAYER_STATE1_29) && } else if (!(player->stateFlags1 & PLAYER_STATE1_29) &&
((OLib_Vec3fDistXZ(&playerPosRot->pos, &rwData->initalPos) >= 10.0f) || ((OLib_Vec3fDistXZ(&playerPosRot->pos, &rwData->initalPos) >= 10.0f) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_A) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_B) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CLEFT) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CDOWN) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CUP) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CRIGHT) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_R) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z))) { CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_Z))) {
camera->dist = OLib_Vec3fDist(&camera->at, eye); camera->dist = OLib_Vec3fDist(&camera->at, eye);
camera->playerToAtOffset.x = camera->at.x - playerPosRot->pos.x; camera->playerToAtOffset.x = camera->at.x - playerPosRot->pos.x;
camera->playerToAtOffset.y = camera->at.y - playerPosRot->pos.y; camera->playerToAtOffset.y = camera->at.y - playerPosRot->pos.y;
@ -5107,14 +5113,14 @@ s32 Camera_Unique0(Camera* camera) {
} }
if (!(player->stateFlags1 & PLAYER_STATE1_29) && if (!(player->stateFlags1 & PLAYER_STATE1_29) &&
((0.001f < camera->xzSpeed) || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) || ((0.001f < camera->xzSpeed) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_A) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_B) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CLEFT) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CDOWN) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CUP) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CRIGHT) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_R) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z))) { CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_Z))) {
camera->dist = OLib_Vec3fDist(&camera->at, &camera->eye); camera->dist = OLib_Vec3fDist(&camera->at, &camera->eye);
camera->playerToAtOffset.x = camera->at.x - playerPosRot->pos.x; camera->playerToAtOffset.x = camera->at.x - playerPosRot->pos.x;
camera->playerToAtOffset.y = camera->at.y - playerPosRot->pos.y; camera->playerToAtOffset.y = camera->at.y - playerPosRot->pos.y;
@ -6015,20 +6021,20 @@ s32 Camera_Demo3(Camera* camera) {
rwData->unk_0C = 0.1f; rwData->unk_0C = 0.1f;
sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_A, 0); sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_A, 0);
if (!((rwData->animFrame < 0 || camera->xzSpeed > 0.001f || if ((rwData->animFrame < 0 || camera->xzSpeed > 0.001f ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_A) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_B) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CLEFT) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CDOWN) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CUP) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CRIGHT) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_R) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z)) && CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_Z)) &&
(camera->stateFlags & CAM_STATE_EXTERNAL_FINISHED))) { (camera->stateFlags & CAM_STATE_EXTERNAL_FINISHED)) {
goto skipeyeUpdate; // clang-format off
} // Note: default for switch inside if statement
FALLTHROUGH;
default: default:
// clang-format on
camera->stateFlags |= (CAM_STATE_CHECK_BG | CAM_STATE_CAM_FUNC_FINISH); camera->stateFlags |= (CAM_STATE_CHECK_BG | CAM_STATE_CAM_FUNC_FINISH);
camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED; camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED;
if (camera->prevBgCamIndex < 0) { if (camera->prevBgCamIndex < 0) {
@ -6038,7 +6044,7 @@ s32 Camera_Demo3(Camera* camera) {
camera->prevBgCamIndex = -1; 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; skipUpdateEye = true;
break; break;
} }
@ -6061,8 +6067,6 @@ s32 Camera_Demo3(Camera* camera) {
camera->animState = 4; camera->animState = 4;
} }
if (1) {}
if (!skipUpdateEye) { if (!skipUpdateEye) {
eyeOffset.r = Camera_LERPCeilF(eyeOffset.r, eyeAtOffset.r, rwData->unk_0C, 2.0f); 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); 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); camera->stateFlags |= (CAM_STATE_CAM_FUNC_FINISH | CAM_STATE_BLOCK_BG);
sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0); 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) || if (camera->xzSpeed > 0.001f || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_A) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_B) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CLEFT) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CDOWN) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CDOWN) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CUP) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CUP) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_CRIGHT) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_R) ||
CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z) || CAMERA_CHECK_BTN(&D_8015BD7C->state.input[0], BTN_Z) || (roData->interfaceField & SPECIAL9_FLAG_3)) {
(roData->interfaceField & SPECIAL9_FLAG_3)) {
Camera_RequestSettingImpl(camera, camera->prevSetting, CAM_REQUEST_SETTING_IGNORE_PRIORITY); Camera_RequestSettingImpl(camera, camera->prevSetting, CAM_REQUEST_SETTING_IGNORE_PRIORITY);
camera->stateFlags |= (CAM_STATE_CHECK_WATER | CAM_STATE_CHECK_BG); camera->stateFlags |= (CAM_STATE_CHECK_WATER | CAM_STATE_CHECK_BG);
@ -7890,19 +7893,19 @@ s32 Camera_DbgChangeMode(Camera* camera) {
s32 changeDir = 0; s32 changeDir = 0;
if (!gDebugCamEnabled && camera->play->activeCamId == CAM_ID_MAIN) { 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"); PRINTF("attention sound URGENCY\n");
Sfx_PlaySfxCentered(NA_SE_SY_ATTENTION_URGENCY); 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"); PRINTF("attention sound NORMAL\n");
Sfx_PlaySfxCentered(NA_SE_SY_ATTENTION_ON); 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; 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; changeDir = -1;
} }
if (changeDir != 0) { if (changeDir != 0) {
@ -8164,7 +8167,7 @@ Vec3s Camera_Update(Camera* camera) {
#if OOT_DEBUG #if OOT_DEBUG
// enable/disable debug cam // 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; gDebugCamEnabled ^= 1;
if (gDebugCamEnabled) { if (gDebugCamEnabled) {
DebugCamera_Enable(&D_8015BD80, camera); DebugCamera_Enable(&D_8015BD80, camera);
@ -8252,7 +8255,7 @@ Vec3s Camera_Update(Camera* camera) {
} }
#if OOT_DEBUG #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; camera->timer = 0;
} }
#endif #endif