Add logging to Wii

This commit is contained in:
2026-06-02 11:01:54 -05:00
parent 36f6ac65f2
commit 0f8b629e20
5 changed files with 74 additions and 13 deletions
+1 -1
View File
@@ -144,7 +144,7 @@ jobs:
- name: Copy output files.
run: |
mkdir -p ./git-artifcats/Dusk/apps/Dusk
cp build-wii/Dusk.dol ./git-artifcats/Dusk/apps/Dusk/boot.dol
cp build-wii/boot.dol ./git-artifcats/Dusk/apps/Dusk/boot.dol
cp build-wii/dusk.dsk ./git-artifcats/Dusk/apps/Dusk/dusk.dsk
cp build-wii/meta.xml ./git-artifcats/Dusk/apps/Dusk/meta.xml
- name: Upload Wii binary
+2 -1
View File
@@ -105,4 +105,5 @@ yarn.lock
/build2
/build*
/assets/test
/tools_old
/tools_old
/assets/test.png
+1 -1
View File
@@ -1,6 +1,6 @@
// Load rosa.
Console.print('Asset time');
const entry = Asset.lock('rosa.png', Asset.TYPE_TEXTURE, Texture.FORMAT_RGBA);
const entry = Asset.lock('test.png', Asset.TYPE_TEXTURE, Texture.FORMAT_RGBA);
Asset.requireLoaded(entry);
Console.print('Asset loaded');
+2 -1
View File
@@ -7,4 +7,5 @@ fi
mkdir -p build-wii
cmake -S. -Bbuild-wii -DDUSK_TARGET_SYSTEM=wii -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/Wii.cmake"
cd build-wii
make -j$(nproc) VERBOSE=1
make -j$(nproc) VERBOSE=1
mv Dusk.dol boot.dol
+68 -9
View File
@@ -1,6 +1,6 @@
/**
* Copyright (c) 2026 Dominic Masters
*
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
@@ -8,19 +8,66 @@
#include "log/log.h"
#include "display/display.h"
#include <debug.h>
#include <fat.h>
#include <stdio.h>
#include <stdlib.h>
#define LOG_DEBUG_PATH "/apps/Dusk/debug.log"
#define LOG_ERROR_PATH "/apps/Dusk/error.log"
static bool_t fatTried = false;
static bool_t fatReady = false;
static void logInitFAT(void) {
if(fatTried) return;
fatTried = true;
fatReady = fatInitDefault();
}
void logDebug(const char_t *message, ...) {
// Print to stdout
va_list args;
va_start(args, message);
vfprintf(stdout, message, args);
va_end(args);
// Print to stdout
va_list copy;
va_copy(copy, args);
vfprintf(stdout, message, copy);
va_end(copy);
fflush(stdout);
// Print to file
logInitFAT();
if(fatReady) {
FILE *file = fopen(LOG_DEBUG_PATH, "a");
if(file) {
va_copy(copy, args);
vfprintf(file, message, copy);
va_end(copy);
fclose(file);
}
}
va_end(args);
}
void logError(const char_t *message, ...) {
va_list args;
va_start(args, message);
// Write to file before displaying on screen
logInitFAT();
if(fatReady) {
FILE *file = fopen(LOG_ERROR_PATH, "a");
if(file) {
va_list copy;
va_copy(copy, args);
vfprintf(file, message, copy);
va_end(copy);
fclose(file);
}
}
// Either create graphics, or hijack the displays' graphics.
void *xfb = NULL;
GXRModeObj *rmode = NULL;
void *framebuffer;
@@ -54,12 +101,24 @@ void logError(const char_t *message, ...) {
}
// Printf
va_list args;
va_start(args, message);
vprintf(message, args);
va_list copy;
va_copy(copy, args);
vprintf(message, copy);
va_end(copy);
va_end(args);
// PAD_Init is idempotent — safe to call even if inputInit already called it,
// and handles the case where the error occurred before inputInit ran.
PAD_Init();
while(SYS_MainLoop()) {
PAD_ScanPads();
// START button matches the RAGEQUIT bind — allows exit on GC controller
// when there is no Wiimote HOME button available.
if(PAD_ButtonsDown(0) & PAD_BUTTON_START) break;
VIDEO_WaitVSync();
}
// Exit cleanly to HBC regardless of engine state. engineDispose() is not
// called here because the engine may be partially initialized.
exit(0);
}