Add a free camera to the debug menu.

With it on, the game draws from a camera of the menu's instead of its own, in play and in cutscenes. The left stick moves it along its view and sideways, the right stick turns it, ZR and ZL raise and lower it, R makes it faster and L slower, and Link stands meanwhile; or the camera stays where it is and the pad plays the game.

It works inside the game's own camera update: a new patch site sends the instruction at which the frame's position, target and up vector are final to a host function, which replaces them for the camera that follows Link and the one the events direct, so the game draws, culls and loads detail for what the free camera sees. The camera of the interface's 3D models and the one the sound follows stay the game's. The set is off unless the menu switches it on. A teleport's arrival starts the free camera again from the game's view.

Tested in Hyrule Field with scripted stick input (turn, rise, strafe, with Link's position unchanged), with the pad playing while the camera stays, across a teleport to Kakariko Village, during the Kakariko arrival cutscene, and switched on by a click in the menu.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
epicmeme546
2026-11-11 08:04:19 -05:00
parent fe3126e9a7
commit b59c0d40a8
11 changed files with 207 additions and 15 deletions

View File

@@ -5,6 +5,9 @@
#ifndef __cplusplus
#include "cpu.h"
void dbg_tick(Cpu *c); // the game's thread, at its pad read (ov_input.c): does what the menu asked for
// ... and the pad's state before the game gets it: the free camera takes the sticks and four buttons while it flies
void dbg_pad(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry);
void dbg_freecam_host(Cpu *c); // the free camera's patch site (recomp/patches-v111.txt, set freecam)
#endif
#ifdef __cplusplus
@@ -39,6 +42,13 @@ void dbg_event_start(const char *name);
int dbg_busy(void);
void dbg_status(char out[160]);
// The free camera: the game draws from a camera of the menu's instead of its own. With sticks on, the pad flies it and
// Link stands; with sticks off it stays where it is and the pad plays the game. speed in metres a second.
int dbg_freecam_available(void); // the build has the camera's patch set
void dbg_freecam_set(int on, int sticks, float speed);
void dbg_freecam_reset(void); // back to the game's view, free again from there
int dbg_freecam(int *sticks, float *speed, double pos[3]); // on or off
// Memory: values of 1, 2 or 4 bytes in the game's heap.
int dbg_search_new(uint32_t value, int size); // returns the number of places
int dbg_search_next(int mode, uint32_t value); // 0 equals value, 1 changed, 2 unchanged, 3 greater, 4 less