From b5ab50084b4e1b4521da8cdebd8c4d3e31791c46 Mon Sep 17 00:00:00 2001 From: Cuyler36 Date: Wed, 16 Jul 2025 04:38:28 -0400 Subject: [PATCH] libultra: add expected size for osAppNMIBuffer in declaration & improve shutdown.c --- include/libultra/libultra.h | 2 +- src/static/libultra/shutdown.c | 78 +++++++++++++++++----------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/include/libultra/libultra.h b/include/libultra/libultra.h index 40debccb..20df57f7 100644 --- a/include/libultra/libultra.h +++ b/include/libultra/libultra.h @@ -30,7 +30,7 @@ void osWritebackDCache(void* vaddr, u32 nbytes); u32 osGetCount(void); OSTime osGetTime(void); -extern s32 osAppNMIBuffer[]; +extern s32 osAppNMIBuffer[16]; extern int osShutdown; extern u8 __osResetSwitchPressed; diff --git a/src/static/libultra/shutdown.c b/src/static/libultra/shutdown.c index 219cf598..99bb11d3 100644 --- a/src/static/libultra/shutdown.c +++ b/src/static/libultra/shutdown.c @@ -19,54 +19,54 @@ void osShutdownStart(int val) { OSReport("***osShutdownStart***\n"); dstat = DVDGetDriveStatus(); - if (dstat == -1) { + if (dstat == -1) { while (TRUE) {} } - osIsEnableShutdown(); - PADRecalibrate(0xF0000000); - Na_Reset(); + osIsEnableShutdown(); + PADRecalibrate(0xF0000000); + Na_Reset(); - gthread = GXGetCurrentGXThread(); - enable = OSDisableInterrupts(); - cthread = OSGetCurrentThread(); + gthread = GXGetCurrentGXThread(); + enable = OSDisableInterrupts(); + cthread = OSGetCurrentThread(); - if(gthread != cthread){ - OSCancelThread(gthread); - GXSetCurrentGXThread(); - } - GXFlush(); - GXAbortFrame(); - GXDrawDone(); + if (gthread != cthread) { + OSCancelThread(gthread); + GXSetCurrentGXThread(); + } + GXFlush(); + GXAbortFrame(); + GXDrawDone(); - OSRestoreInterrupts(enable); - JW_JUTXfb_clearIndex(); - VIWaitForRetrace(); - VISetBlack(TRUE); - VIFlush(); - VIWaitForRetrace(); - osStopTimerAll(); - LCDisable(); - OSReport("リセットしてもこれだけは忘れない。 osAppNMIBuffer[15] = %08x\n", osAppNMIBuffer[15]); + OSRestoreInterrupts(enable); + JW_JUTXfb_clearIndex(); + VIWaitForRetrace(); + VISetBlack(TRUE); + VIFlush(); + VIWaitForRetrace(); + osStopTimerAll(); + LCDisable(); + OSReport("リセットしてもこれだけは忘れない。 osAppNMIBuffer[15] = %08x\n", osAppNMIBuffer[15]); - if((val == 2) && (DVDCheckDisk() == 0)){ - OSReport("蓋空き。ホットリセットします。\n"); - val = 0; - } + if ((val == 2) && (DVDCheckDisk() == 0)) { + OSReport("蓋空き。ホットリセットします。\n"); + val = 0; + } if (APPNMI_HOTRESET_GET()) { - OSResetSystem(FALSE, 0, FALSE); + OSResetSystem(OS_RESET_RESTART, 0, FALSE); return; } - switch (val) { - case 0: - OSResetSystem(TRUE,osAppNMIBuffer[15], FALSE); - break; - case 1: - HotResetIplMenu(); - break; - case 2: - bcopy(osAppNMIBuffer, (void*)0x811FFFC0, 0x40U); - OSResetSystem(0, 0x80000000, FALSE); - break;; + switch (val) { + case OS_RESET_RESTART: + OSResetSystem(OS_RESET_HOTRESET, osAppNMIBuffer[15], FALSE); + break; + case OS_RESET_HOTRESET: + HotResetIplMenu(); + break; + case OS_RESET_SHUTDOWN: + bcopy(osAppNMIBuffer, NMISaveArea, sizeof(osAppNMIBuffer)); + OSResetSystem(OS_RESET_RESTART, 0x80000000, FALSE); + break; } }