Add logging to Wii
This commit is contained in:
@@ -144,7 +144,7 @@ jobs:
|
|||||||
- name: Copy output files.
|
- name: Copy output files.
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./git-artifcats/Dusk/apps/Dusk
|
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/dusk.dsk ./git-artifcats/Dusk/apps/Dusk/dusk.dsk
|
||||||
cp build-wii/meta.xml ./git-artifcats/Dusk/apps/Dusk/meta.xml
|
cp build-wii/meta.xml ./git-artifcats/Dusk/apps/Dusk/meta.xml
|
||||||
- name: Upload Wii binary
|
- name: Upload Wii binary
|
||||||
|
|||||||
+2
-1
@@ -105,4 +105,5 @@ yarn.lock
|
|||||||
/build2
|
/build2
|
||||||
/build*
|
/build*
|
||||||
/assets/test
|
/assets/test
|
||||||
/tools_old
|
/tools_old
|
||||||
|
/assets/test.png
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// Load rosa.
|
// Load rosa.
|
||||||
Console.print('Asset time');
|
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);
|
Asset.requireLoaded(entry);
|
||||||
Console.print('Asset loaded');
|
Console.print('Asset loaded');
|
||||||
|
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ fi
|
|||||||
mkdir -p build-wii
|
mkdir -p build-wii
|
||||||
cmake -S. -Bbuild-wii -DDUSK_TARGET_SYSTEM=wii -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/Wii.cmake"
|
cmake -S. -Bbuild-wii -DDUSK_TARGET_SYSTEM=wii -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/Wii.cmake"
|
||||||
cd build-wii
|
cd build-wii
|
||||||
make -j$(nproc) VERBOSE=1
|
make -j$(nproc) VERBOSE=1
|
||||||
|
mv Dusk.dol boot.dol
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2026 Dominic Masters
|
* Copyright (c) 2026 Dominic Masters
|
||||||
*
|
*
|
||||||
* This software is released under the MIT License.
|
* This software is released under the MIT License.
|
||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
@@ -8,19 +8,66 @@
|
|||||||
#include "log/log.h"
|
#include "log/log.h"
|
||||||
#include "display/display.h"
|
#include "display/display.h"
|
||||||
#include <debug.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, ...) {
|
void logDebug(const char_t *message, ...) {
|
||||||
// Print to stdout
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, message);
|
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);
|
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, ...) {
|
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.
|
// Either create graphics, or hijack the displays' graphics.
|
||||||
void *xfb = NULL;
|
|
||||||
GXRModeObj *rmode = NULL;
|
GXRModeObj *rmode = NULL;
|
||||||
void *framebuffer;
|
void *framebuffer;
|
||||||
|
|
||||||
@@ -54,12 +101,24 @@ void logError(const char_t *message, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Printf
|
// Printf
|
||||||
va_list args;
|
va_list copy;
|
||||||
va_start(args, message);
|
va_copy(copy, args);
|
||||||
vprintf(message, args);
|
vprintf(message, copy);
|
||||||
|
va_end(copy);
|
||||||
va_end(args);
|
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()) {
|
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();
|
VIDEO_WaitVSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exit cleanly to HBC regardless of engine state. engineDispose() is not
|
||||||
|
// called here because the engine may be partially initialized.
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user