1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-04 06:54:33 +00:00

DbCamera to DebugCamera (#1482)

* better dbCam prefix

* missed some

* PR Suggestions

* alignment

* more debug

* cleanup
This commit is contained in:
engineer124 2023-01-12 16:06:31 -05:00 committed by GitHub
parent 542012efa6
commit 1149530c92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 1050 additions and 1076 deletions

File diff suppressed because it is too large Load diff

View file

@ -4062,7 +4062,7 @@ s16 func_80034DD4(Actor* actor, PlayState* play, s16 arg2, f32 arg3) {
Player* player = GET_PLAYER(play);
f32 var;
if ((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) {
if ((play->csCtx.state != CS_STATE_IDLE) || gDebugCamEnabled) {
var = Math_Vec3f_DistXYZ(&actor->world.pos, &play->view.eye) * 0.25f;
} else {
var = Math_Vec3f_DistXYZ(&actor->world.pos, &player->actor.world.pos);
@ -5736,7 +5736,7 @@ s32 Actor_TrackPlayerSetFocusHeight(PlayState* play, Actor* actor, Vec3s* headRo
actor->focus.pos = actor->world.pos;
actor->focus.pos.y += focusHeight;
if (!(((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) &&
if (!(((play->csCtx.state != CS_STATE_IDLE) || gDebugCamEnabled) &&
(gSaveContext.entranceIndex == ENTR_KOKIRI_FOREST_0))) {
yaw = ABS((s16)(actor->yawTowardsPlayer - actor->shape.rot.y));
if (yaw >= 0x4300) {
@ -5745,7 +5745,7 @@ s32 Actor_TrackPlayerSetFocusHeight(PlayState* play, Actor* actor, Vec3s* headRo
}
}
if (((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) &&
if (((play->csCtx.state != CS_STATE_IDLE) || gDebugCamEnabled) &&
(gSaveContext.entranceIndex == ENTR_KOKIRI_FOREST_0)) {
target = play->view.eye;
} else {
@ -5780,7 +5780,7 @@ s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* tors
actor->focus.pos = focusPos;
if (!(((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) &&
if (!(((play->csCtx.state != CS_STATE_IDLE) || gDebugCamEnabled) &&
(gSaveContext.entranceIndex == ENTR_KOKIRI_FOREST_0))) {
yaw = ABS((s16)(actor->yawTowardsPlayer - actor->shape.rot.y));
if (yaw >= 0x4300) {
@ -5789,7 +5789,7 @@ s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* tors
}
}
if (((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) &&
if (((play->csCtx.state != CS_STATE_IDLE) || gDebugCamEnabled) &&
(gSaveContext.entranceIndex == ENTR_KOKIRI_FOREST_0)) {
target = play->view.eye;
} else {

View file

@ -7049,12 +7049,12 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState
R_CAM_DATA(i) = sCamDataRegsInit[i];
}
DbCamera_Reset(camera, &D_8015BD80);
DebugCamera_Reset(camera, &D_8015BD80);
sInitRegs = false;
PREG(88) = -1;
}
camera->play = D_8015BD7C = play;
DbCamera_Init(&D_8015BD80, camera);
DebugCamera_Init(&D_8015BD80, camera);
curUID = sNextUID;
sNextUID++;
while (curUID != 0) {
@ -7245,7 +7245,7 @@ void Camera_PrintSettings(Camera* camera) {
char sp48[8];
s32 i;
if ((OREG(0) & 1) && (camera->play->activeCamId == camera->camId) && !gDbgCamEnabled) {
if ((OREG(0) & 1) && (camera->play->activeCamId == camera->camId) && !gDebugCamEnabled) {
for (i = 0; i < NUM_CAMS; i++) {
if (camera->play->cameraPtrs[i] == NULL) {
sp58[i] = '-';
@ -7278,15 +7278,15 @@ void Camera_PrintSettings(Camera* camera) {
sp48[i] = '\0';
sp48[camera->play->activeCamId] = 'a';
DbCamera_ScreenTextColored(3, 22, DBCAMERA_TEXT_WHITE, sp58);
DbCamera_ScreenTextColored(3, 22, DBCAMERA_TEXT_PEACH, sp48);
DbCamera_ScreenTextColored(3, 23, DBCAMERA_TEXT_WHITE, "S:");
DbCamera_ScreenTextColored(5, 23, DBCAMERA_TEXT_GOLD, sCameraSettingNames[camera->setting]);
DbCamera_ScreenTextColored(3, 24, DBCAMERA_TEXT_WHITE, "M:");
DbCamera_ScreenTextColored(5, 24, DBCAMERA_TEXT_GOLD, sCameraModeNames[camera->mode]);
DbCamera_ScreenTextColored(3, 25, DBCAMERA_TEXT_WHITE, "F:");
DbCamera_ScreenTextColored(
5, 25, DBCAMERA_TEXT_GOLD,
DebugCamera_ScreenTextColored(3, 22, DEBUG_CAM_TEXT_WHITE, sp58);
DebugCamera_ScreenTextColored(3, 22, DEBUG_CAM_TEXT_PEACH, sp48);
DebugCamera_ScreenTextColored(3, 23, DEBUG_CAM_TEXT_WHITE, "S:");
DebugCamera_ScreenTextColored(5, 23, DEBUG_CAM_TEXT_GOLD, sCameraSettingNames[camera->setting]);
DebugCamera_ScreenTextColored(3, 24, DEBUG_CAM_TEXT_WHITE, "M:");
DebugCamera_ScreenTextColored(5, 24, DEBUG_CAM_TEXT_GOLD, sCameraModeNames[camera->mode]);
DebugCamera_ScreenTextColored(3, 25, DEBUG_CAM_TEXT_WHITE, "F:");
DebugCamera_ScreenTextColored(
5, 25, DEBUG_CAM_TEXT_GOLD,
sCameraFunctionNames[sCameraSettings[camera->setting].cameraModes[camera->mode].funcIdx]);
i = 0;
@ -7311,8 +7311,8 @@ void Camera_PrintSettings(Camera* camera) {
sp50[i++] = ' ';
sp50[i++] = ' ';
sp50[i] = '\0';
DbCamera_ScreenTextColored(3, 26, DBCAMERA_TEXT_WHITE, "I:");
DbCamera_ScreenTextColored(5, 26, DBCAMERA_TEXT_GOLD, sp50);
DebugCamera_ScreenTextColored(3, 26, DEBUG_CAM_TEXT_WHITE, "I:");
DebugCamera_ScreenTextColored(5, 26, DEBUG_CAM_TEXT_GOLD, sp50);
}
}
@ -7451,7 +7451,7 @@ s32 Camera_UpdateHotRoom(Camera* camera) {
s32 Camera_DbgChangeMode(Camera* camera) {
s32 changeDir = 0;
if (!gDbgCamEnabled && 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)) {
osSyncPrintf("attention sound URGENCY\n");
func_80078884(NA_SE_SY_ATTENTION_URGENCY);
@ -7581,12 +7581,12 @@ Vec3s Camera_Update(Camera* camera) {
player = camera->play->cameraPtrs[CAM_ID_MAIN]->player;
if (R_DBG_CAM_UPDATE) {
if (R_DEBUG_CAM_UPDATE) {
osSyncPrintf("camera: in %x\n", camera);
}
if (camera->status == CAM_STAT_CUT) {
if (R_DBG_CAM_UPDATE) {
if (R_DEBUG_CAM_UPDATE) {
osSyncPrintf("camera: cut out %x\n", camera);
}
return camera->inputDir;
@ -7661,7 +7661,7 @@ Vec3s Camera_Update(Camera* camera) {
Camera_DbgChangeMode(camera);
if (camera->status == CAM_STAT_WAIT) {
if (R_DBG_CAM_UPDATE) {
if (R_DEBUG_CAM_UPDATE) {
osSyncPrintf("camera: wait out %x\n", camera);
}
return camera->inputDir;
@ -7671,7 +7671,7 @@ Vec3s Camera_Update(Camera* camera) {
camera->stateFlags &= ~(CAM_STATE_10 | CAM_STATE_5);
camera->stateFlags |= CAM_STATE_4;
if (R_DBG_CAM_UPDATE) {
if (R_DEBUG_CAM_UPDATE) {
osSyncPrintf("camera: engine (%d %d %d) %04x \n", camera->setting, camera->mode,
sCameraSettings[camera->setting].cameraModes[camera->mode].funcIdx, camera->stateFlags);
}
@ -7702,11 +7702,11 @@ Vec3s Camera_Update(Camera* camera) {
}
}
if (R_DBG_CAM_UPDATE) {
if (R_DEBUG_CAM_UPDATE) {
osSyncPrintf("camera: shrink_and_bitem %x(%d)\n", sCameraInterfaceField, camera->play->transitionMode);
}
if (R_DBG_CAM_UPDATE) {
if (R_DEBUG_CAM_UPDATE) {
osSyncPrintf("camera: engine (%s(%d) %s(%d) %s(%d)) ok!\n", &sCameraSettingNames[camera->setting],
camera->setting, &sCameraModeNames[camera->mode], camera->mode,
&sCameraFunctionNames[sCameraSettings[camera->setting].cameraModes[camera->mode].funcIdx],
@ -7715,20 +7715,20 @@ Vec3s Camera_Update(Camera* camera) {
// enable/disable debug cam
if (CHECK_BTN_ALL(D_8015BD7C->state.input[2].press.button, BTN_START)) {
gDbgCamEnabled ^= 1;
if (gDbgCamEnabled) {
DbgCamera_Enable(&D_8015BD80, camera);
gDebugCamEnabled ^= 1;
if (gDebugCamEnabled) {
DebugCamera_Enable(&D_8015BD80, camera);
} else if (camera->play->csCtx.state != CS_STATE_IDLE) {
Cutscene_StopManual(camera->play, &camera->play->csCtx);
}
}
// Debug cam update
if (gDbgCamEnabled) {
if (gDebugCamEnabled) {
camera->play->view.fovy = D_8015BD80.fov;
DbCamera_Update(&D_8015BD80, camera);
DebugCamera_Update(&D_8015BD80, camera);
View_LookAt(&camera->play->view, &D_8015BD80.eye, &D_8015BD80.at, &D_8015BD80.unk_1C);
if (R_DBG_CAM_UPDATE) {
if (R_DEBUG_CAM_UPDATE) {
osSyncPrintf("camera: debug out\n");
}
return D_8015BD80.sub.unk_104A;
@ -7804,7 +7804,7 @@ Vec3s Camera_Update(Camera* camera) {
camera->timer = 0;
}
if (R_DBG_CAM_UPDATE) {
if (R_DEBUG_CAM_UPDATE) {
osSyncPrintf("camera: out (%f %f %f) (%f %f %f)\n", camera->at.x, camera->at.y, camera->at.z, camera->eye.x,
camera->eye.y, camera->eye.z);
osSyncPrintf("camera: dir (%f %d(%f) %d(%f)) (%f)\n", eyeAtAngle.r, eyeAtAngle.pitch,
@ -8105,7 +8105,7 @@ s32 Camera_ChangeBgCamIndex(Camera* camera, s32 bgCamIndex) {
}
Vec3s* Camera_GetInputDir(Vec3s* dst, Camera* camera) {
if (gDbgCamEnabled) {
if (gDebugCamEnabled) {
*dst = D_8015BD80.sub.unk_104A;
return dst;
} else {
@ -8129,7 +8129,7 @@ s16 Camera_GetInputDirYaw(Camera* camera) {
}
Vec3s* Camera_GetCamDir(Vec3s* dst, Camera* camera) {
if (gDbgCamEnabled) {
if (gDebugCamEnabled) {
*dst = D_8015BD80.sub.unk_104A;
return dst;
} else {
@ -8331,8 +8331,8 @@ s32 Camera_Copy(Camera* dstCamera, Camera* srcCamera) {
return true;
}
s32 Camera_GetDbgCamEnabled(void) {
return gDbgCamEnabled;
s32 Camera_IsDebugCamEnabled(void) {
return gDebugCamEnabled;
}
Vec3f* Camera_GetQuakeOffset(Vec3f* quakeOffset, Camera* camera) {

View file

@ -2555,7 +2555,7 @@ s32 (*sCameraFunctions[])(Camera*) = {
s32 sInitRegs = 1;
s32 gDbgCamEnabled = 0;
s32 gDebugCamEnabled = false;
s32 sDbgModeIdx = -1;
s16 sNextUID = 0;
@ -3034,5 +3034,5 @@ s16 D_8011DAFC[] = {
};
PlayState* D_8015BD7C;
DbCamera D_8015BD80;
DebugCam D_8015BD80;
CollisionPoly* playerFloorPoly;

View file

@ -1,32 +1,32 @@
#include "global.h"
typedef struct {
u8 x;
u8 y;
u8 colorIndex;
char text[21];
} DbCameraTextBufferEntry; // size = 0x18
/* 0x0 */ u8 x;
/* 0x1 */ u8 y;
/* 0x2 */ u8 colorIndex;
/* 0x3 */ char text[21];
} DebugCamTextBufferEntry; // size = 0x18
typedef struct {
u16 hold;
u16 press;
/* 0x0 */ u16 hold;
/* 0x2 */ u16 press;
} InputCombo; // size = 0x4
RegEditor* gRegEditor;
DbCameraTextBufferEntry sDbCameraTextBuffer[22];
DebugCamTextBufferEntry sDebugCamTextBuffer[22];
s16 sDbCameraTextEntryCount = 0;
s16 sDebugCamTextEntryCount = 0;
Color_RGBA8 sDbCameraTextColors[] = {
{ 255, 255, 32, 192 }, // DBCAMERA_TEXT_YELLOW
{ 255, 150, 128, 192 }, // DBCAMERA_TEXT_PEACH
{ 128, 96, 0, 64 }, // DBCAMERA_TEXT_BROWN
{ 192, 128, 16, 128 }, // DBCAMERA_TEXT_ORANGE
{ 255, 192, 32, 128 }, // DBCAMERA_TEXT_GOLD
{ 230, 230, 220, 64 }, // DBCAMERA_TEXT_WHITE
{ 128, 150, 255, 128 }, // DBCAMERA_TEXT_BLUE
{ 128, 255, 32, 128 }, // DBCAMERA_TEXT_GREEN
Color_RGBA8 sDebugCamTextColors[] = {
{ 255, 255, 32, 192 }, // DEBUG_CAM_TEXT_YELLOW
{ 255, 150, 128, 192 }, // DEBUG_CAM_TEXT_PEACH
{ 128, 96, 0, 64 }, // DEBUG_CAM_TEXT_BROWN
{ 192, 128, 16, 128 }, // DEBUG_CAM_TEXT_ORANGE
{ 255, 192, 32, 128 }, // DEBUG_CAM_TEXT_GOLD
{ 230, 230, 220, 64 }, // DEBUG_CAM_TEXT_WHITE
{ 128, 150, 255, 128 }, // DEBUG_CAM_TEXT_BLUE
{ 128, 255, 32, 128 }, // DEBUG_CAM_TEXT_GREEN
};
InputCombo sRegGroupInputCombos[REG_GROUPS] = {
@ -108,16 +108,16 @@ void Regs_Init(void) {
}
}
// Function is stubbed. Name is assumed by similarities in signature to `DbCamera_ScreenTextColored` and usage.
void DbCamera_ScreenText(u8 x, u8 y, const char* text) {
// Function is stubbed. Name is assumed by similarities in signature to `DebugCamera_ScreenTextColored` and usage.
void DebugCamera_ScreenText(u8 x, u8 y, const char* text) {
}
void DbCamera_ScreenTextColored(u8 x, u8 y, u8 colorIndex, const char* text) {
DbCameraTextBufferEntry* entry = &sDbCameraTextBuffer[sDbCameraTextEntryCount];
void DebugCamera_ScreenTextColored(u8 x, u8 y, u8 colorIndex, const char* text) {
DebugCamTextBufferEntry* entry = &sDebugCamTextBuffer[sDebugCamTextEntryCount];
char* textDest;
s16 charCount;
if (sDbCameraTextEntryCount < ARRAY_COUNT(sDbCameraTextBuffer)) {
if (sDebugCamTextEntryCount < ARRAY_COUNT(sDebugCamTextBuffer)) {
entry->x = x;
entry->y = y;
entry->colorIndex = colorIndex;
@ -134,18 +134,18 @@ void DbCamera_ScreenTextColored(u8 x, u8 y, u8 colorIndex, const char* text) {
*textDest = '\0';
sDbCameraTextEntryCount++;
sDebugCamTextEntryCount++;
}
}
void DbCamera_DrawScreenText(GfxPrint* printer) {
void DebugCamera_DrawScreenText(GfxPrint* printer) {
s32 i;
Color_RGBA8* color;
DbCameraTextBufferEntry* entry;
DebugCamTextBufferEntry* entry;
for (i = 0; i < sDbCameraTextEntryCount; i++) {
entry = &sDbCameraTextBuffer[i];
color = &sDbCameraTextColors[entry->colorIndex];
for (i = 0; i < sDebugCamTextEntryCount; i++) {
entry = &sDebugCamTextBuffer[i];
color = &sDebugCamTextColors[entry->colorIndex];
GfxPrint_SetColor(printer, color->r, color->g, color->b, color->a);
GfxPrint_SetPos(printer, entry->x, entry->y);
@ -288,14 +288,14 @@ void Debug_DrawText(GraphicsContext* gfxCtx) {
GfxPrint_Open(&printer, gfx);
if ((OREG(0) == 1) || (OREG(0) == 8)) {
DbCamera_DrawScreenText(&printer);
DebugCamera_DrawScreenText(&printer);
}
if (gRegEditor->regPage != 0) {
Regs_DrawEditor(&printer);
}
sDbCameraTextEntryCount = 0;
sDebugCamTextEntryCount = 0;
gfx = GfxPrint_Close(&printer);
gSPEndDisplayList(gfx++);

View file

@ -182,7 +182,7 @@ void Cutscene_UpdateScripted(PlayState* play, CutsceneContext* csCtx) {
}
if (CHECK_BTN_ALL(input->press.button, BTN_DUP) && (csCtx->state == CS_STATE_IDLE) && IS_CUTSCENE_LAYER &&
!gDbgCamEnabled) {
!gDebugCamEnabled) {
gUseCutsceneCam = true;
gSaveContext.cutsceneIndex = 0xFFFD;
gSaveContext.cutsceneTrigger = 1;

View file

@ -988,7 +988,7 @@ void Play_Update(PlayState* this) {
skip:
PLAY_LOG(3801);
if ((sp80 == 0) || gDbgCamEnabled) {
if ((sp80 == 0) || gDebugCamEnabled) {
s32 pad3[5];
s32 i;