Skip to content

Commit

Permalink
Simplify Wii logging
Browse files Browse the repository at this point in the history
  • Loading branch information
carstene1ns committed Feb 20, 2024
1 parent 2548eab commit c7b30f9
Showing 1 changed file with 10 additions and 42 deletions.
52 changes: 10 additions & 42 deletions src/platforms/wii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,59 +18,27 @@
#ifdef __wii__

#include <gccore.h>
#include <ogc/usbgecko.h>
#include <sys/iosupport.h>
#include <unistd.h>
#include <fat.h>

#include "util.h"
#include "io/file.h"

/* USBGecko Debugging */

#define SLOT 1 // A: 0, B: 1
bool usbgecko = false;
mutex_t usbgecko_mutex = 0;

static ssize_t __usbgecko_write(struct _reent * /* r */, void* /* fd */, const char *ptr, size_t len) {
uint32_t level;

if (!ptr || !len || !usbgecko)
return 0;

LWP_MutexLock(usbgecko_mutex);
level = IRQ_Disable();
usb_sendbuffer(SLOT, ptr, len);
IRQ_Restore(level);
LWP_MutexUnlock(usbgecko_mutex);

return len;
}

extern const devoptab_t dotab_stdnull;
const devoptab_t dotab_geckoout = {
"geckoout", 0, NULL, NULL, __usbgecko_write, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL
};

void WII_Init() {
// enable file system
fatInitDefault();

// set console
LWP_MutexInit(&usbgecko_mutex, false);
usbgecko = usb_isgeckoalive(SLOT);

if (usbgecko) {
// USBGecko Debugging
constexpr int SLOT = CARD_SLOTB;
if (usb_isgeckoalive(SLOT)) {
usb_flush(SLOT);

devoptab_list[STD_OUT] = &dotab_geckoout;
devoptab_list[STD_ERR] = &dotab_geckoout;
} else {
devoptab_list[STD_OUT] = &dotab_stdnull;
devoptab_list[STD_ERR] = &dotab_stdnull;
CON_EnableGecko(SLOT, false);
}
#ifndef NDEBUG
// Dolphin UART Debugging
else if(!__system_argv->argc) {
SYS_STDIO_Report(true);
}
#endif
}

void WII_AddGamePaths() {
Expand Down

0 comments on commit c7b30f9

Please sign in to comment.