This commit is contained in:
2026-03-06 16:34:45 -06:00
parent 9139c4350a
commit 93074d653e
27 changed files with 122 additions and 61 deletions

View File

@@ -2,3 +2,12 @@
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Includes
target_include_directories(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
# Subdirs
add_subdirectory(debug)

View File

@@ -0,0 +1,11 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
debug.c
)

View File

@@ -0,0 +1,70 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "dolphin.h"
#include "display/display.h"
static char_t DEBUG_ERROR_BUFFER[16*1024] = {0};
void debugPrint(const char_t *message, ...) {
// append to error buffer
size_t start = strlen(DEBUG_ERROR_BUFFER);
va_list args;
va_start(args, message);
vsnprintf(
DEBUG_ERROR_BUFFER + start,
sizeof(DEBUG_ERROR_BUFFER) - start,
message,
args
);
va_end(args);
}
void debugFlush() {
// Either create graphics, or hijack the displays' graphics.
void *xfb = NULL;
GXRModeObj *rmode = NULL;
void *framebuffer;
if(DISPLAY.frameBuffer[0]) {
console_init(
DISPLAY.frameBuffer[0],
20,
20,
DISPLAY.screenMode->fbWidth,
DISPLAY.screenMode->xfbHeight,
DISPLAY.screenMode->fbWidth * VI_DISPLAY_PIX_SZ
);
} else {
VIDEO_Init();
rmode = VIDEO_GetPreferredMode(NULL);
framebuffer = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
console_init(
framebuffer,
20,
20,
rmode->fbWidth,
rmode->xfbHeight,
rmode->fbWidth*VI_DISPLAY_PIX_SZ
);
VIDEO_Configure(rmode);
VIDEO_SetNextFramebuffer(framebuffer);
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
}
// Printf
printf("SOB\n");
printf(DEBUG_ERROR_BUFFER);
printf("\nEOB.");
while(SYS_MainLoop()) {
VIDEO_WaitVSync();
}
}

View File

@@ -0,0 +1,9 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "display/displaysdl2.h"