From aeda407a17984b6a99af4595f284c7650ae1b362 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Fri, 18 Sep 2009 21:25:32 +0000 Subject: Show the console when exiting abnormally. svn-id: r44190 --- backends/platform/wii/main.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'backends') diff --git a/backends/platform/wii/main.cpp b/backends/platform/wii/main.cpp index 85ce7b02de..644726ac44 100644 --- a/backends/platform/wii/main.cpp +++ b/backends/platform/wii/main.cpp @@ -28,6 +28,9 @@ #include #include +#ifndef GAMECUBE +#include +#endif #ifdef USE_WII_DI #include #endif @@ -58,6 +61,53 @@ void power_cb(void) { power_btn_pressed = true; } +static void show_console(int code) { + u32 b; + + printf("ScummVM exited abnormally (%d).\n", code); + + if (!gfx_frame_start()) + return; + + gfx_con_draw(); + gfx_frame_end(); + + while (true) { + b = 0; + + if (PAD_ScanPads() & 1) + b = PAD_ButtonsDown(0); + +#ifndef GAMECUBE + WPAD_ScanPads(); + if (WPAD_Probe(0, NULL) == WPAD_ERR_NONE) + b |= WPAD_ButtonsDown(0); +#endif + + if (b) + break; + + VIDEO_WaitVSync(); + } +} + +s32 reset_func(s32 final) { + static bool done = false; + + if (!done) { + show_console(-127); + done = true; + } + + return 1; +} + +static sys_resetinfo resetinfo = { + { NULL, NULL }, + reset_func, + 1 +}; + #ifdef DEBUG_WII_MEMSTATS void wii_memstats(void) { static u32 min_free = UINT_MAX; @@ -105,6 +155,8 @@ int main(int argc, char *argv[]) { else printf("\n"); + SYS_RegisterResetFunc(&resetinfo); + SYS_SetResetCallback(reset_cb); #ifndef GAMECUBE SYS_SetPowerCallback(power_cb); @@ -135,8 +187,12 @@ int main(int argc, char *argv[]) { printf("shutdown\n"); + SYS_UnregisterResetFunc(&resetinfo); fatUnmountDefault(); + if (res) + show_console(res); + if (power_btn_pressed) { printf("shutting down\n"); SYS_ResetSystem(SYS_POWEROFF, 0, 0); -- cgit v1.2.3