Debugging functions.

This commit is contained in:
2026-02-04 18:32:20 -06:00
parent dd910a31aa
commit d955fb6430
8 changed files with 107 additions and 3 deletions

View File

@@ -15,6 +15,10 @@
errorret_t assetInit(void) {
memoryZero(&ASSET, sizeof(asset_t));
#if DOLPHIN
errorOk();
#endif
// Engine may have been provided the launch path
if(ENGINE.argc > 0) {
@@ -174,6 +178,10 @@ bool_t assetFileExists(const char_t *filename) {
}
errorret_t assetLoad(const char_t *filename, void *output) {
#if DOLPHIN
errorOk();
#endif
assertStrLenMax(filename, FILENAME_MAX, "Filename too long.");
assertNotNull(output, "Output pointer cannot be NULL.");

View File

@@ -6,6 +6,9 @@
*/
#include "debug.h"
#if DOLPHIN
#include "display/display.h"
#endif
void debugPrint(const char_t *message, ...) {
va_list args;
@@ -22,5 +25,32 @@ void debugPrint(const char_t *message, ...) {
va_end(args);
fclose(file);
}
#elif DOLPHIN
if(!DISPLAY.frameBuffer) return;
console_init(
DISPLAY.frameBuffer,
20,
20,
DISPLAY.screenMode->fbWidth,
DISPLAY.screenMode->xfbHeight,
DISPLAY.screenMode->fbWidth * VI_DISPLAY_PIX_SZ
);
// Printf
va_start(args, message);
vprintf(message, args);
va_end(args);
printf("\nPress START to exit...");
while(SYS_MainLoop()) {
VIDEO_WaitVSync();
PAD_ScanPads();
int buttonsDown = PAD_ButtonsDown(0);
if (buttonsDown & PAD_BUTTON_START) {
exit(0);
}
}
#endif
}

View File

@@ -15,8 +15,9 @@
#include "ui/ui.h"
#include "debug/debug.h"
#include "display/text.h"
#include "assert/assert.h"
display_t DISPLAY;
display_t DISPLAY = { 0 };
errorret_t displayInit(void) {
#if DISPLAY_SDL2
@@ -69,6 +70,42 @@ errorret_t displayInit(void) {
glEnableClientState(GL_COLOR_ARRAY);// To confirm: every frame on PSP?
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
#elif DOLPHIN
VIDEO_Init();
DISPLAY.screenMode = VIDEO_GetPreferredMode(NULL);
DISPLAY.frameBuffer = MEM_K0_TO_K1(
SYS_AllocateFramebuffer(DISPLAY.screenMode)
);
VIDEO_Configure(DISPLAY.screenMode);
VIDEO_SetNextFramebuffer(DISPLAY.frameBuffer);
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
VIDEO_WaitVSync();
if(DISPLAY.screenMode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
// DISPLAY.fifoBuffer = MEM_K0_TO_K1(memalign(32,FIFO_SIZE));
// memset(DISPLAY.fifoBuffer, 0, FIFO_SIZE);
// GX_Init(DISPLAY.fifoBuffer, FIFO_SIZE);
// GXColor backgroundColor = {0, 0, 0, 255};
// GX_SetCopyClear(backgroundColor, 0x00ffffff);
// GX_SetViewport(0,0,DISPLAY.screenMode->fbWidth,DISPLAY.screenMode->efbHeight,0,1);
// GX_SetDispCopyYScale((f32)DISPLAY.screenMode->xfbHeight/(f32)DISPLAY.screenMode->efbHeight);
// GX_SetScissor(0,0,DISPLAY.screenMode->fbWidth,DISPLAY.screenMode->efbHeight);
// GX_SetDispCopySrc(0,0,DISPLAY.screenMode->fbWidth,DISPLAY.screenMode->efbHeight);
// GX_SetDispCopyDst(DISPLAY.screenMode->fbWidth,DISPLAY.screenMode->xfbHeight);
// GX_SetCopyFilter(DISPLAY.screenMode->aa,DISPLAY.screenMode->sample_pattern,
// GX_TRUE,DISPLAY.screenMode->vfilter);
// GX_SetFieldMode(DISPLAY.screenMode->field_rendering,
// ((DISPLAY.screenMode->viHeight==2*DISPLAY.screenMode->xfbHeight)?GX_ENABLE:GX_DISABLE));
// GX_SetCullMode(GX_CULL_NONE);
// GX_CopyDisp(DISPLAY.frameBuffer,GX_TRUE);
// GX_SetDispCopyGamma(GX_GM_1_0);
#endif
quadInit();
@@ -110,6 +147,9 @@ errorret_t displayUpdate(void) {
}
SDL_GL_MakeCurrent(DISPLAY.window, DISPLAY.glContext);
#elif DOLPHIN
#endif
// Reset state
@@ -138,6 +178,9 @@ errorret_t displayUpdate(void) {
while((err = glGetError()) != GL_NO_ERROR) {
debugPrint("GL Error: %d\n", err);
}
#elif DOLPHIN
VIDEO_WaitVSync();
if(DISPLAY.screenMode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
#endif

View File

@@ -15,6 +15,12 @@ typedef struct {
#if DISPLAY_SDL2
SDL_Window *window;
SDL_GLContext glContext;
#elif DOLPHIN
void *frameBuffer;
GXRModeObj *screenMode;
void *fifoBuffer;
#endif
} display_t;

View File

@@ -30,6 +30,7 @@
#endif
#if DOLPHIN
#include <ogcsys.h>
#include <gccore.h>
#endif

View File

@@ -37,7 +37,6 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
errorChain(uiInit());
errorChain(mapInit());
errorChain(sceneInit());
backpackInit();
// Run the initial script.
@@ -50,6 +49,10 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
}
errorret_t engineUpdate(void) {
#if DOLPHIN
ENGINE.running = SYS_MainLoop();
#endif
timeUpdate();
inputUpdate();

View File

@@ -23,7 +23,13 @@ void inputInit(void) {
INPUT.actions[i].currentValue = 0.0f;
}
INPUT.deadzone = 0.2f;
#if INPUT_GAMEPAD == 1
INPUT.deadzone = 0.2f;
#endif
#if DOLPHIN
PAD_Init();
#endif
eventInit(
&INPUT.eventPressed, INPUT.pressedListeners, INPUT_LISTENER_PRESSED_MAX
@@ -47,6 +53,9 @@ void inputUpdate(void) {
#if INPUT_KEYBOARD == 1
INPUT.keyboardState = SDL_GetKeyboardState(NULL);
#endif
#elif DOLPHIN
PAD_Read(INPUT.pads);
#endif
// Reset all actions

View File

@@ -37,6 +37,10 @@ typedef struct {
#if INPUT_KEYBOARD == 1
const uint8_t *keyboardState;
#endif
#elif DOLPHIN
PADStatus pads[4];
#endif
} input_t;