You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
Crash screen now has multiple pages
Can be moved with L and R
This commit is contained in:
@@ -6,11 +6,19 @@
|
||||
#include "types.h"
|
||||
#include "puppyprint.h"
|
||||
#include "audio/external.h"
|
||||
#include "game_init.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "sm64.h"
|
||||
|
||||
#include "printf.h"
|
||||
|
||||
enum crashPages {
|
||||
PAGE_STACK,
|
||||
PAGE_LOG,
|
||||
PAGE_COUNT
|
||||
};
|
||||
|
||||
u8 gCrashScreenCharToGlyph[128] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, -1, -1, -1, 43, -1, -1, 37, 38, -1, 42,
|
||||
@@ -24,6 +32,9 @@ u32 gCrashScreenFont[7 * 9 + 1] = {
|
||||
#include "textures/crash_custom/crash_screen_font.ia1.inc.c"
|
||||
};
|
||||
|
||||
u8 crashPage = 0;
|
||||
u8 updateBuffer = TRUE;
|
||||
|
||||
|
||||
char *gCauseDesc[18] = {
|
||||
"Interrupt",
|
||||
@@ -73,7 +84,7 @@ void crash_screen_draw_rect(s32 x, s32 y, s32 w, s32 h) {
|
||||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w; j++) {
|
||||
// 0xe738 = 0b1110011100111000
|
||||
*ptr = ((*ptr & 0xe738) >> 2) | 1;
|
||||
*ptr = ((*ptr & 0xE738) >> 2) | 1;
|
||||
ptr++;
|
||||
}
|
||||
ptr += gCrashScreen.width - w;
|
||||
@@ -95,7 +106,7 @@ void crash_screen_draw_glyph(s32 x, s32 y, s32 glyph) {
|
||||
rowMask = *data++;
|
||||
|
||||
for (j = 0; j < 6; j++) {
|
||||
*ptr++ = (bit & rowMask) ? 0xffff : 1;
|
||||
*ptr++ = (bit & rowMask) ? 0xFFFF : 1;
|
||||
bit >>= 1;
|
||||
}
|
||||
ptr += gCrashScreen.width - 6;
|
||||
@@ -150,8 +161,8 @@ void crash_screen_print_float_reg(s32 x, s32 y, s32 regNum, void *addr) {
|
||||
s32 exponent;
|
||||
|
||||
bits = *(u32 *) addr;
|
||||
exponent = ((bits & 0x7f800000U) >> 0x17) - 0x7f;
|
||||
if ((exponent >= -0x7e && exponent <= 0x7f) || bits == 0) {
|
||||
exponent = ((bits & 0x7f800000U) >> 0x17) - 0x7F;
|
||||
if ((exponent >= -0x7E && exponent <= 0x7F) || bits == 0) {
|
||||
crash_screen_print(x, y, "F%02d:%.3e", regNum, *(f32 *) addr);
|
||||
} else {
|
||||
crash_screen_print(x, y, "F%02d:---------", regNum);
|
||||
@@ -173,49 +184,24 @@ void crash_screen_print_fpcsr(u32 fpcsr) {
|
||||
}
|
||||
}
|
||||
|
||||
void draw_crash_screen(OSThread *thread) {
|
||||
s16 cause;
|
||||
void draw_crash_stack(OSThread *thread, s32 cause)
|
||||
{
|
||||
__OSThreadContext *tc = &thread->context;
|
||||
|
||||
cause = (tc->cause >> 2) & 0x1f;
|
||||
if (cause == 23) // EXC_WATCH
|
||||
{
|
||||
cause = 16;
|
||||
}
|
||||
if (cause == 31) // EXC_VCED
|
||||
{
|
||||
cause = 17;
|
||||
}
|
||||
|
||||
osWritebackDCacheAll();
|
||||
crash_screen_sleep(500);
|
||||
crash_screen_draw_rect(25, 20, 270, 25);
|
||||
crash_screen_print(30, 25, "THREAD:%d (%s)", thread->id, gCauseDesc[cause]);
|
||||
#if !PUPPYPRINT_DEBUG
|
||||
crash_screen_print(30, 35, "PC:%08XH SR:%08XH VA:%08XH", tc->pc, tc->sr, tc->badvaddr);
|
||||
#else
|
||||
crash_screen_print(30, 35, "PC:%08XH SR:%08XH RA:%08XH", tc->pc, tc->sr, (u32) tc->ra);
|
||||
#endif
|
||||
osWritebackDCacheAll();
|
||||
crash_screen_draw_rect(25, 45, 270, 185);
|
||||
#if !PUPPYPRINT_DEBUG
|
||||
crash_screen_print(30, 50, "AT:%08XH V0:%08XH V1:%08XH", (u32) tc->at, (u32) tc->v0,
|
||||
(u32) tc->v1);
|
||||
crash_screen_print(30, 60, "A0:%08XH A1:%08XH A2:%08XH", (u32) tc->a0, (u32) tc->a1,
|
||||
(u32) tc->a2);
|
||||
crash_screen_print(30, 70, "A3:%08XH T0:%08XH T1:%08XH", (u32) tc->a3, (u32) tc->t0,
|
||||
(u32) tc->t1);
|
||||
crash_screen_print(30, 80, "T2:%08XH T3:%08XH T4:%08XH", (u32) tc->t2, (u32) tc->t3,
|
||||
(u32) tc->t4);
|
||||
crash_screen_print(30, 90, "T5:%08XH T6:%08XH T7:%08XH", (u32) tc->t5, (u32) tc->t6,
|
||||
(u32) tc->t7);
|
||||
crash_screen_print(30, 100, "S0:%08XH S1:%08XH S2:%08XH", (u32) tc->s0, (u32) tc->s1,
|
||||
(u32) tc->s2);
|
||||
crash_screen_print(30, 110, "S3:%08XH S4:%08XH S5:%08XH", (u32) tc->s3, (u32) tc->s4,
|
||||
(u32) tc->s5);
|
||||
crash_screen_print(30, 120, "S6:%08XH S7:%08XH T8:%08XH", (u32) tc->s6, (u32) tc->s7,
|
||||
(u32) tc->t8);
|
||||
crash_screen_print(30, 130, "T9:%08XH GP:%08XH SP:%08XH", (u32) tc->t9, (u32) tc->gp,
|
||||
(u32) tc->sp);
|
||||
crash_screen_print(30, 50, "AT:%08XH V0:%08XH V1:%08XH", (u32) tc->at, (u32) tc->v0, (u32) tc->v1);
|
||||
crash_screen_print(30, 60, "A0:%08XH A1:%08XH A2:%08XH", (u32) tc->a0, (u32) tc->a1, (u32) tc->a2);
|
||||
crash_screen_print(30, 70, "A3:%08XH T0:%08XH T1:%08XH", (u32) tc->a3, (u32) tc->t0, (u32) tc->t1);
|
||||
crash_screen_print(30, 80, "T2:%08XH T3:%08XH T4:%08XH", (u32) tc->t2, (u32) tc->t3, (u32) tc->t4);
|
||||
crash_screen_print(30, 90, "T5:%08XH T6:%08XH T7:%08XH", (u32) tc->t5, (u32) tc->t6, (u32) tc->t7);
|
||||
crash_screen_print(30, 100, "S0:%08XH S1:%08XH S2:%08XH", (u32) tc->s0, (u32) tc->s1, (u32) tc->s2);
|
||||
crash_screen_print(30, 110, "S3:%08XH S4:%08XH S5:%08XH", (u32) tc->s3, (u32) tc->s4, (u32) tc->s5);
|
||||
crash_screen_print(30, 120, "S6:%08XH S7:%08XH T8:%08XH", (u32) tc->s6, (u32) tc->s7, (u32) tc->t8);
|
||||
crash_screen_print(30, 130, "T9:%08XH GP:%08XH SP:%08XH", (u32) tc->t9, (u32) tc->gp, (u32) tc->sp);
|
||||
crash_screen_print(30, 140, "S8:%08XH RA:%08XH", (u32) tc->s8, (u32) tc->ra);
|
||||
crash_screen_print_fpcsr(tc->fpcsr);
|
||||
|
||||
@@ -236,18 +222,75 @@ void draw_crash_screen(OSThread *thread) {
|
||||
crash_screen_print_float_reg(120, 210, 26, &tc->fp26.f.f_even);
|
||||
crash_screen_print_float_reg(210, 210, 28, &tc->fp28.f.f_even);
|
||||
crash_screen_print_float_reg(30, 220, 30, &tc->fp30.f.f_even);
|
||||
#else
|
||||
}
|
||||
|
||||
void draw_crash_log(OSThread *thread, s32 cause)
|
||||
{
|
||||
#if PUPPYPRINT_DEBUG
|
||||
s32 i;
|
||||
#define LINE_HEIGHT 60 + ((LOG_BUFFER_SIZE-1)*10)
|
||||
|
||||
crash_screen_draw_rect(25, 20, 270, 210);
|
||||
osWritebackDCacheAll();
|
||||
#define LINE_HEIGHT 25 + ((LOG_BUFFER_SIZE-1)*10)
|
||||
for (i = 0; i < LOG_BUFFER_SIZE; i++)
|
||||
{
|
||||
crash_screen_print(30, (LINE_HEIGHT)-(i*10), consoleLogTable[i]);
|
||||
}
|
||||
#undef LINE_HEIGHT
|
||||
#endif
|
||||
osWritebackDCacheAll();
|
||||
osViBlack(FALSE);
|
||||
osViSwapBuffer(gCrashScreen.framebuffer);
|
||||
}
|
||||
|
||||
|
||||
void draw_crash_screen(OSThread *thread)
|
||||
{
|
||||
s32 cause;
|
||||
__OSThreadContext *tc = &thread->context;
|
||||
|
||||
cause = (tc->cause >> 2) & 0x1F;
|
||||
if (cause == 23) // EXC_WATCH
|
||||
{
|
||||
cause = 16;
|
||||
}
|
||||
if (cause == 31) // EXC_VCED
|
||||
{
|
||||
cause = 17;
|
||||
}
|
||||
|
||||
if (gPlayer1Controller->buttonPressed & R_TRIG)
|
||||
{
|
||||
crashPage++;
|
||||
updateBuffer = TRUE;
|
||||
}
|
||||
if (gPlayer1Controller->buttonPressed & L_TRIG || gPlayer1Controller->buttonPressed & Z_TRIG)
|
||||
{
|
||||
crashPage--;
|
||||
updateBuffer = TRUE;
|
||||
}
|
||||
|
||||
#if !PUPPYPRINT_DEBUG
|
||||
if (crashPage == PAGE_LOG)
|
||||
crashPage++;
|
||||
#endif
|
||||
|
||||
if (crashPage >= PAGE_COUNT)
|
||||
crashPage = 0;
|
||||
if (crashPage == 255)
|
||||
crashPage = PAGE_COUNT-1;
|
||||
|
||||
if (updateBuffer)
|
||||
{
|
||||
crash_screen_print(15, 10, "Page:%d L/Z: Left R: Right", crashPage);
|
||||
switch (crashPage)
|
||||
{
|
||||
case PAGE_STACK: draw_crash_stack(thread, cause); break;
|
||||
case PAGE_LOG: draw_crash_log(thread, cause); break;
|
||||
}
|
||||
|
||||
osWritebackDCacheAll();
|
||||
osViBlack(FALSE);
|
||||
osViSwapBuffer(gCrashScreen.framebuffer);
|
||||
updateBuffer = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
OSThread *get_crashed_thread(void) {
|
||||
@@ -267,6 +310,7 @@ OSThread *get_crashed_thread(void) {
|
||||
extern u16 sRenderedFramebuffer;
|
||||
extern void audio_signal_game_loop_tick(void);
|
||||
extern void stop_sounds_in_continuous_banks(void);
|
||||
extern void read_controller_inputs(s32 threadID);
|
||||
extern struct SequenceQueueItem sBackgroundMusicQueue[6];
|
||||
|
||||
void thread2_crash_screen(UNUSED void *arg) {
|
||||
@@ -275,34 +319,47 @@ void thread2_crash_screen(UNUSED void *arg) {
|
||||
|
||||
osSetEventMesg(OS_EVENT_CPU_BREAK, &gCrashScreen.mesgQueue, (OSMesg) 1);
|
||||
osSetEventMesg(OS_EVENT_FAULT, &gCrashScreen.mesgQueue, (OSMesg) 2);
|
||||
do {
|
||||
#if PUPPYPRINT_DEBUG
|
||||
OSTime first = osGetTime();
|
||||
#endif
|
||||
osRecvMesg(&gCrashScreen.mesgQueue, &mesg, 1);
|
||||
thread = get_crashed_thread();
|
||||
gCrashScreen.framebuffer = (u16 *) gFrameBuffers[sRenderedFramebuffer];
|
||||
#if PUPPYPRINT_DEBUG
|
||||
profiler_update(faultTime, first);
|
||||
#endif
|
||||
} while (thread == NULL);
|
||||
goto finished;
|
||||
reset:
|
||||
gCrashScreen.thread.priority = 15;
|
||||
stop_sounds_in_continuous_banks();
|
||||
stop_background_music(sBackgroundMusicQueue[0].seqId);
|
||||
audio_signal_game_loop_tick();
|
||||
draw_crash_screen(thread);
|
||||
crash_screen_sleep(200);
|
||||
play_sound(SOUND_MARIO_WAAAOOOW, gGlobalSoundSource);
|
||||
audio_signal_game_loop_tick();
|
||||
for (;;) {
|
||||
crash_screen_sleep(200);
|
||||
finished:
|
||||
while (TRUE)
|
||||
{
|
||||
#if PUPPYPRINT_DEBUG
|
||||
OSTime first = osGetTime();
|
||||
#endif
|
||||
if (thread == NULL)
|
||||
{
|
||||
osRecvMesg(&gCrashScreen.mesgQueue, &mesg, 1);
|
||||
thread = get_crashed_thread();
|
||||
gCrashScreen.framebuffer = (u16 *) gFrameBuffers[sRenderedFramebuffer];
|
||||
if (thread)
|
||||
goto reset;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gControllerBits) {
|
||||
#if ENABLE_RUMBLE
|
||||
block_until_rumble_pak_free();
|
||||
#endif
|
||||
osContStartReadData(&gSIEventMesgQueue);
|
||||
}
|
||||
read_controller_inputs(2);
|
||||
draw_crash_screen(thread);
|
||||
}
|
||||
#if PUPPYPRINT_DEBUG
|
||||
profiler_update(faultTime, first);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void crash_screen_set_framebuffer(u16 *framebuffer, u16 width, u16 height) {
|
||||
gCrashScreen.framebuffer = framebuffer;
|
||||
gCrashScreen.width = width;
|
||||
gCrashScreen.height = height;
|
||||
}
|
||||
|
||||
void crash_screen_init(void) {
|
||||
gCrashScreen.framebuffer = (u16 *) gFrameBuffers[sRenderedFramebuffer];
|
||||
gCrashScreen.width = SCREEN_WIDTH;
|
||||
|
||||
@@ -577,12 +577,13 @@ void run_demo_inputs(void) {
|
||||
/**
|
||||
* Update the controller struct with available inputs if present.
|
||||
*/
|
||||
void read_controller_inputs(void) {
|
||||
void read_controller_inputs(s32 threadID) {
|
||||
s32 i;
|
||||
|
||||
// If any controllers are plugged in, update the controller information.
|
||||
if (gControllerBits) {
|
||||
osRecvMesg(&gSIEventMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
|
||||
if (threadID == 5)
|
||||
osRecvMesg(&gSIEventMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
|
||||
osContGetReadData(&gControllerPads[0]);
|
||||
#if ENABLE_RUMBLE
|
||||
release_rumble_pak_control();
|
||||
@@ -765,7 +766,7 @@ void thread5_game_loop(UNUSED void *arg) {
|
||||
|
||||
audio_game_loop_tick();
|
||||
select_gfx_pool();
|
||||
read_controller_inputs();
|
||||
read_controller_inputs(5);
|
||||
addr = level_script_execute(addr);
|
||||
#if PUPPYPRINT_DEBUG == 0 && defined(VISUAL_DEBUG)
|
||||
debug_box_input();
|
||||
|
||||
Reference in New Issue
Block a user