From 04b31d912636eaea12a0b6f3d5e822605da68504 Mon Sep 17 00:00:00 2001 From: Prakxo <87568477+Prakxo@users.noreply.github.com> Date: Thu, 10 Aug 2023 16:36:44 +0100 Subject: m_debug OK (#39) * m_debug OK * forgor to format * replace macros for zelda64 ones * refactor * refactor 3 * refactor 4 --- src/code/game.c | 11 ++++++----- src/code/m_debug.c | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 src/code/m_debug.c (limited to 'src/code') diff --git a/src/code/game.c b/src/code/game.c index 480dba1..ac01008 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -1,6 +1,7 @@ #include "game.h" #include "gfx.h" #include "m_controller.h" +#include "m_debug.h" #include "67E840.h" #include "speed_meter.h" #include "graph.h" @@ -31,7 +32,7 @@ void func_800D2E00_jp(GameState* gameState) { Debug_mode_input(CONTROLLER2(gameState)); } - if (debug_mode->unk_0D4 != 0) { + if (SREG(0) != 0) { func_800D88E0_jp(&B_80145020_jp); } } @@ -113,7 +114,7 @@ void game_debug_draw_last(GameState* gameState, GraphicsContext* gfxCtx) { Debug_mode_output(gfxCtx); } - if (debug_mode->unk_0D4 != 0) { + if (SREG(0) != 0) { func_800D8A54_jp(&B_80145020_jp, gfxCtx); func_800D9018_jp(&B_80145020_jp, gfxCtx, gameState); } @@ -182,7 +183,7 @@ void SetGameFrame(s32 divisor) { game_GameFrameF = (divisor & 0xFF); game_GameFrame_2F = game_GameFrameF / 2.0f; game_GameFrame__1F = 1.0f / game_GameFrameF; - debug_mode->gameframe = divisor; + SREG(30) = divisor; } } @@ -190,8 +191,8 @@ void game_main(GameState* gameState) { GraphicsContext* gfxCtx = gameState->gfxCtx; u8 gameframe = game_GameFrame; - if (debug_mode->gameframe != gameframe) { - SetGameFrame(debug_mode->gameframe); + if (SREG(30) != gameframe) { + SetGameFrame(SREG(30)); } game_draw_first(gfxCtx); diff --git a/src/code/m_debug.c b/src/code/m_debug.c new file mode 100644 index 0000000..7d22f2c --- /dev/null +++ b/src/code/m_debug.c @@ -0,0 +1,20 @@ +#include "m_debug.h" +#include "libc64/malloc.h" + +Debug_mode* debug_mode; + +void new_Debug_mode() { + s32 i; + + debug_mode = malloc(sizeof(Debug_mode)); + + debug_mode->mode = 0; + debug_mode->type = 0; + debug_mode->inputR = 0; + debug_mode->oldKey = 0; + debug_mode->keyWait = 0; + + for (i = 0; i < DEBUG_REG_COUNT; i++) { + debug_mode->r[i] = 0; + } +} -- cgit v1.2.3