summaryrefslogtreecommitdiff
path: root/soh/src/code/graph.c
diff options
context:
space:
mode:
authorArchez <Archez@users.noreply.github.com>2024-10-18 11:05:31 +0900
committerGitHub <noreply@github.com>2024-10-17 19:05:31 -0700
commitf1841a20f39d3ac3b60a61ecb0f54b536e416fff (patch)
tree3662331422852da26e8fc4f72b402515161423b4 /soh/src/code/graph.c
parented32a2820c0316a658ab75cfd9edfa199bf37a54 (diff)
add gfx debugger support (#4345)
Co-authored-by: Malkierian <malkierian@gmail.com>
Diffstat (limited to 'soh/src/code/graph.c')
-rw-r--r--soh/src/code/graph.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/soh/src/code/graph.c b/soh/src/code/graph.c
index 3b9487f55..6a49117dd 100644
--- a/soh/src/code/graph.c
+++ b/soh/src/code/graph.c
@@ -15,6 +15,15 @@
#define GFXPOOL_HEAD_MAGIC 0x1234
#define GFXPOOL_TAIL_MAGIC 0x5678
+// SOH [Port] Game State management for our render loop
+static struct RunFrameContext {
+ GraphicsContext gfxCtx;
+ GameState* gameState;
+ GameStateOverlay* nextOvl;
+ GameStateOverlay* ovl;
+ int state;
+} runFrameContext;
+
OSTime sGraphUpdateTime;
OSTime sGraphSetTaskTime;
FaultClient sGraphFaultClient;
@@ -271,6 +280,12 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) {
void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
u32 problem;
+ // Skip game frame updates while gfx debugger is active, and execute with the last frame's DL buffer
+ if (GfxDebuggerIsDebugging()) {
+ Graph_ProcessGfxCommands(runFrameContext.gfxCtx.workBuffer);
+ return;
+ }
+
gameState->unk_A0 = 0;
Graph_InitTHGA(gfxCtx);
@@ -443,15 +458,6 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
uint64_t GetFrequency();
uint64_t GetPerfCounter();
-static struct RunFrameContext {
- GraphicsContext gfxCtx;
- GameState* gameState;
- GameStateOverlay* nextOvl;
- GameStateOverlay* ovl;
- int state;
-} runFrameContext;
-
-
extern AudioMgr gAudioMgr;
extern void ProcessSaveStateRequests(void);
@@ -515,6 +521,10 @@ static void RunFrame()
Graph_Update(&runFrameContext.gfxCtx, runFrameContext.gameState);
//ticksB = GetPerfCounter();
+ if (GfxDebuggerIsDebuggingRequested()) {
+ GfxDebuggerDebugDisplayList(runFrameContext.gfxCtx.workBuffer);
+ }
+
Graph_ProcessGfxCommands(runFrameContext.gfxCtx.workBuffer);
@@ -565,7 +575,8 @@ void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size) {
}
void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, s32 line) {
- if (HREG(80) == 7 && HREG(82) != 4) {
+ // SOH [Debugging] Force open/close disp string handling on so that the graphics debugger can leverage it
+ if (true || HREG(80) == 7 && HREG(82) != 4) {
dispRefs[0] = gfxCtx->polyOpa.p;
dispRefs[1] = gfxCtx->polyXlu.p;
dispRefs[2] = gfxCtx->overlay.p;
@@ -577,7 +588,8 @@ void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file,
}
void Graph_CloseDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, s32 line) {
- if (HREG(80) == 7 && HREG(82) != 4) {
+ // SOH [Debugging] Force open/close disp string handling on so that the graphics debugger can leverage it
+ if (true || HREG(80) == 7 && HREG(82) != 4) {
if (dispRefs[0] + 1 == gfxCtx->polyOpa.p) {
gfxCtx->polyOpa.p = dispRefs[0];
} else {