@@ -61,11 +61,14 @@ typedef struct _framerec {
6161} frame_rec , * frame_rec_t ;
6262
6363static void * exception_xfb = (void * )0xC1700000 ; //we use a static address above ArenaHi.
64+ static void * lookup_xfb = NULL ;
6465static int reload_timer = -1 ;
6566
6667void __exception_sethandler (u32 nExcept , void (* pHndl )(frame_context * ));
6768
6869extern void udelay (int us );
70+ extern s32 CONF_GetEuRGB60 (void );
71+ extern s32 CONF_GetProgressiveScan (void );
6972extern void fpu_exceptionhandler (frame_context * );
7073extern void irq_exceptionhandler (frame_context * );
7174extern void dec_exceptionhandler (frame_context * );
@@ -198,40 +201,76 @@ void __exception_setreload(int t)
198201 reload_timer = t * 50 ;
199202}
200203
204+ void __exception_setlookupxfb (void * xfb ) {
205+ lookup_xfb = (u32 * )xfb ;
206+ }
207+
208+ static void __toggleframebuffer () {
209+ static bool currfb = false;
210+ if (currfb ) {
211+ currfb = false;
212+ VIDEO_SetFramebuffer (exception_xfb );
213+ } else {
214+ currfb = true;
215+ VIDEO_SetFramebuffer (lookup_xfb );
216+ }
217+ }
218+
201219static void waitForReload (void )
202220{
203221 u32 level ;
204-
222+
205223 PAD_Init ();
206224
207- kprintf ("\n\n\tPress RESET, or Z on a GameCube Controller, to reload\n\n" );
225+ VIDEO_WaitVSync (); // For VI/PAD_Interface Timing
226+
227+ kprintf ("\n\tRESET / A: Reset, B: Reload" );
228+ if (lookup_xfb ) {
229+ kprintf (", START: Show the previous XFB\n" );
230+ } else {
231+ kprintf ("\n" );
232+ }
208233
209234 while ( 1 )
210235 {
211236 if (reload_timer > 0 ) {
212237 kprintf ("\x1b[2K\r\tReloading in %d seconds" , reload_timer /50 );
213238 }
239+
214240 PAD_ScanPads ();
241+
242+ // Checks all controller ports because why not
243+ int buttonsDown = PAD_ButtonsDown (0 ) | PAD_ButtonsDown (1 ) | PAD_ButtonsDown (2 ) | PAD_ButtonsDown (3 );
215244
216- int buttonsDown = PAD_ButtonsDown (0 );
217-
218- if ( (buttonsDown & PAD_TRIGGER_Z ) || SYS_ResetButtonDown () || reload_timer == 0 )
245+ if ( (buttonsDown & PAD_BUTTON_B ) || reload_timer == 0 )
219246 {
220- kprintf ("\n\tReload\n\n\n" );
247+ // Clears the screen because the added text
248+ // could interfere with the ability of showing the full stack
249+ consoleClear ();
250+ kprintf ("\tReloading..." );
221251 _CPU_ISR_Disable (level );
222252 __reload ();
223253 }
224254
225- if ( buttonsDown & PAD_BUTTON_A )
255+ if ( (buttonsDown & PAD_BUTTON_START ) && lookup_xfb ) {
256+ reload_timer -- ;
257+ __toggleframebuffer ();
258+ VIDEO_WaitVSync ();
259+ }
260+
261+ if ( buttonsDown & PAD_BUTTON_A || SYS_ResetButtonDown () )
226262 {
227- kprintf ("\n\tReset\n\n\n" );
263+ // Clears the screen because the added text
264+ // could interfere with the ability of showing the full stack
265+ consoleClear ();
266+ kprintf ("\tResetting..." );
228267#if defined(HW_DOL )
229- SYS_ResetSystem (SYS_HOTRESET , 0 ,FALSE );
268+ SYS_ResetSystem (SYS_RETURNTOMENU , 0 , 0 );
230269#else
231270 __reload ();
232271#endif
233272 }
234-
273+ VIDEO_WaitVSync ();
235274 udelay (20000 );
236275 if (reload_timer > 0 )
237276 reload_timer -- ;
@@ -240,17 +279,26 @@ static void waitForReload(void)
240279
241280//just implement core for unrecoverable exceptions.
242281void c_default_exceptionhandler (frame_context * pCtx )
243- {
244- const u16 console_height = 680 ;
245- const u16 console_width = 574 ;
282+ {
283+ // Default values are for 576i
284+ u16 console_height = 680 ;
285+ u16 console_width = 574 ;
286+ u8 Yoffset = 48 ;
287+
288+ if (CONF_GetEuRGB60 () > 0 || ((CONF_GetProgressiveScan () > 0 ) && VIDEO_HaveComponentCable ())) {
289+ // Changes to 480i/p values
290+ console_height = 640 ;
291+ console_width = 480 ;
292+ Yoffset = 32 ;
293+ }
246294
247295 GX_AbortFrame ();
248296 VIDEO_SetFramebuffer (exception_xfb );
249297 __VIClearFramebuffer (exception_xfb , console_height * console_width * VI_DISPLAY_PIX_SZ , COLOR_BLACK );
250- __console_init (exception_xfb , 20 , 20 , console_height - 40 , console_width - 40 , 1280 );
298+ __console_init (exception_xfb , 16 , Yoffset , console_height - 16 , console_width - Yoffset , 1280 );
251299 CON_EnableGecko (1 , true);
252300
253- kprintf ("\n\n\n\ tException (%s) occurred!\n" , exception_name [pCtx -> EXCPT_Number ]);
301+ kprintf ("\tException (%s) occurred!\n" , exception_name [pCtx -> EXCPT_Number ]);
254302
255303 kprintf ("\tGPR00 %08X GPR08 %08X GPR16 %08X GPR24 %08X\n" ,pCtx -> GPR [0 ], pCtx -> GPR [8 ], pCtx -> GPR [16 ], pCtx -> GPR [24 ]);
256304 kprintf ("\tGPR01 %08X GPR09 %08X GPR17 %08X GPR25 %08X\n" ,pCtx -> GPR [1 ], pCtx -> GPR [9 ], pCtx -> GPR [17 ], pCtx -> GPR [25 ]);
@@ -275,5 +323,4 @@ void c_default_exceptionhandler(frame_context *pCtx)
275323 }
276324
277325 waitForReload ();
278- }
279-
326+ }
0 commit comments