Add support for crash screen asserts

This commit is contained in:
a
2025-07-04 17:06:21 -04:00
parent 9f47426ba8
commit e4dcef00df
4 changed files with 20 additions and 11 deletions

View File

@@ -1,9 +0,0 @@
#include "n64-assert.h"
#include "n64-stdlib.h"
#include "n64-stdio.h"
void __n64_assert_fail( const char *assertion, const char *file, unsigned int line, const char *fcn ) {
n64_printf( "%s:%u: %s: Assertion `%s' failed.\n", file, line, fcn, assertion );
n64_abort();
}

View File

@@ -3,7 +3,12 @@
#include "n64-stdlib.h"
#include "n64-stdio.h"
extern char *assertMsg;
char assertBuf[256];
void __n64_assert_fail( const char *assertion, const char *file, unsigned int line, const char *fcn ) {
n64_snprintf( assertBuf, 256, "%s:%u:%s: Assertion `%s' failed.", file, line, fcn, assertion );
assertMsg = &assertBuf[0];
n64_printf( "%s:%u: %s: Assertion `%s' failed.\n", file, line, fcn, assertion );
n64_abort();
}

View File

@@ -9,6 +9,8 @@ OUTPUT_ARCH (mips)
#include "config.h"
#include "ld.h"
EXTERN(assertMsg);
SECTIONS
{
__romPos = 0;
@@ -52,7 +54,7 @@ SECTIONS
AUDIO_DIR*.o(.text);
ULTRA_BUILD_DIR/libgultra_rom.a:*.o(.text);
BUILD_DIR/src/audio/external.o(.text);
BUILD_DIR/n64-libc.a:*.o(.text);
BUILD_DIR/n64-libc.a:*.o(.text*);
BUILD_DIR/libpl2.a:*.o(.text);
BUILD_DIR/lib/rsp.o(.text);

View File

@@ -6,7 +6,7 @@
#include "PR/os_internal.h"
#include "lib/hackerlibultra/src/libc/xstdio.h"
#include "n64-stdio.h"
#include "n64-libc.h"
#include "audio/external.h"
#include "sounds.h"
@@ -14,6 +14,8 @@
extern u32 gGlobalTimer;
char *assertMsg = NULL;
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,
@@ -149,6 +151,11 @@ void crash_screen_print(s32 x, s32 y, const char *fmt, ...) {
ptr++;
x += 6;
if (x >= 285) {
x = 30;
y += 10;
}
}
}
@@ -292,6 +299,10 @@ void draw_crash_screen(OSThread *thread) {
n64_printf("==============================================\n");
osViBlack(FALSE);
crash_screen_sleep(2500);
if (assertMsg != NULL) {
crash_screen_draw_rect(25, 45, 270, 185);
crash_screen_print(30, 50, assertMsg);
}
play_music(SEQ_PLAYER_LEVEL, SEQ_LEVEL_BOSS_KOOPA, 0);
}