First texture rendering (if broken)

This commit is contained in:
2026-02-06 12:48:49 -06:00
parent 0d56859d94
commit aa5b41fe31
23 changed files with 226 additions and 179 deletions

View File

@@ -8,6 +8,8 @@
#include "debug.h"
#if DOLPHIN
#include "display/display.h"
static char_t DEBUG_ERROR_BUFFER[16*1024] = {0};
#endif
void debugPrint(const char_t *message, ...) {
@@ -15,7 +17,6 @@ void debugPrint(const char_t *message, ...) {
va_start(args, message);
vprintf(message, args);
va_end(args);
fflush(stdout);
#if PSP
FILE *file = fopen("ms0:/PSP/GAME/Dusk/debug.log", "a");
@@ -27,36 +28,68 @@ void debugPrint(const char_t *message, ...) {
}
#elif DOLPHIN
if(!DISPLAY.frameBuffer) {
errorret_t ret = displayInit();
if(ret.code != ERROR_OK) {
abort();
}
// append to error buffer
size_t start = strlen(DEBUG_ERROR_BUFFER);
va_start(args, message);
vsnprintf(
DEBUG_ERROR_BUFFER + start,
sizeof(DEBUG_ERROR_BUFFER) - start,
message,
args
);
va_end(args);
#endif
}
void debugFlush() {
#if PSP
// No buffering, so nothing to flush
#elif DOLPHIN
// Either create graphics, or hijack the displays' graphics.
void *xfb = NULL;
GXRModeObj *rmode = NULL;
void *framebuffer;
if(DISPLAY.frameBuffer) {
console_init(
DISPLAY.frameBuffer,
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();
}
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...");
printf("SOB\n");
printf(DEBUG_ERROR_BUFFER);
printf("\nEOB.");
while(SYS_MainLoop()) {
VIDEO_WaitVSync();
PAD_ScanPads();
int buttonsDown = PAD_ButtonsDown(0);
if (buttonsDown & PAD_BUTTON_START) {
exit(0);
}
}
#else
fflush(stdout);
#endif
}