diff --git a/ld/libfiles.ntsc-final.inc b/ld/libfiles.ntsc-final.inc index 0d14cee3a..a114b3793 100644 --- a/ld/libfiles.ntsc-final.inc +++ b/ld/libfiles.ntsc-final.inc @@ -32,8 +32,6 @@ build/ROMID/lib/audiodma.o (section); \ build/ROMID/lib/profile.o (section); \ build/ROMID/lib/vi.o (section); \ - build/ROMID/lib/fault.o (section); \ - build/ROMID/lib/crash.o (section); \ build/ROMID/lib/dma.o (section); \ build/ROMID/lib/main.o (section); \ build/ROMID/lib/snd.o (section); \ @@ -45,8 +43,6 @@ build/ROMID/lib/str.o (section); \ build/ROMID/lib/ultra/libc/sprintf.o (section); \ build/ROMID/lib/pimgr.o (section); \ - build/ROMID/lib/videbug.o (section); \ - build/ROMID/lib/debughud.o (section); \ build/ROMID/lib/base.o (section); \ build/ROMID/lib/joy.o (section); \ build/ROMID/lib/lib_15850.o (section); \ @@ -62,7 +58,6 @@ build/ROMID/lib/collision.o (section); \ build/ROMID/lib/lib_2f490.o (section); \ build/ROMID/lib/rdp.o (section); \ - build/ROMID/lib/rmon.o (section); \ build/ROMID/lib/ultra/audio/heap.o (section); \ build/ROMID/lib/naudio/n_sl.o (section); \ build/ROMID/lib/lib_2fc60.o (section); \ diff --git a/src/game/bossfile.c b/src/game/bossfile.c index bbcad42e1..942b87db2 100644 --- a/src/game/bossfile.c +++ b/src/game/bossfile.c @@ -15,7 +15,6 @@ #include "game/options.h" #include "game/utils.h" #include "bss.h" -#include "lib/fault.h" #include "lib/snd.h" #include "data.h" #include "types.h" diff --git a/src/game/filelist.c b/src/game/filelist.c index 0aeed3008..73e79a401 100644 --- a/src/game/filelist.c +++ b/src/game/filelist.c @@ -15,7 +15,6 @@ #include "game/options.h" #include "game/utils.h" #include "bss.h" -#include "lib/fault.h" #include "lib/joy.h" #include "lib/snd.h" #include "lib/mema.h" diff --git a/src/game/gamefile.c b/src/game/gamefile.c index d54af43db..b29a38035 100644 --- a/src/game/gamefile.c +++ b/src/game/gamefile.c @@ -14,7 +14,6 @@ #include "game/options.h" #include "game/utils.h" #include "bss.h" -#include "lib/fault.h" #include "lib/snd.h" #include "lib/str.h" #include "data.h" diff --git a/src/game/title.c b/src/game/title.c index 71743d574..19f4256d3 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -19,7 +19,6 @@ #include "game/propobj.h" #include "game/savebuffer.h" #include "bss.h" -#include "lib/crash.h" #include "lib/joy.h" #include "lib/vi.h" #include "lib/main.h" diff --git a/src/game/vmstats.c b/src/game/vmstats.c index 5ba6a9235..067dfe4df 100644 --- a/src/game/vmstats.c +++ b/src/game/vmstats.c @@ -1,7 +1,6 @@ #include #include "constants.h" #include "bss.h" -#include "lib/debughud.h" #include "lib/vm.h" #include "data.h" #include "types.h" diff --git a/src/include/constants.h b/src/include/constants.h index e157402d6..47e8f1391 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -3906,12 +3906,12 @@ enum rspevent { #define SQUADRON_0E 0x0e #define SQUADRON_0F 0x0f -#define STACKSIZE_RMON 0x40 +#define STACKSIZE_RMON 0 #define STACKSIZE_IDLE 0x40 #define STACKSIZE_SCHED 0x400 #define STACKSIZE_MAIN 0x9800 #define STACKSIZE_AUDIO 0x1000 -#define STACKSIZE_FAULT 0x40 +#define STACKSIZE_FAULT 0 #define STACKSIZE_RESET 0x100 #define STACK_START (0x80400000 \ diff --git a/src/include/lib/crash.h b/src/include/lib/crash.h deleted file mode 100644 index a5d22d358..000000000 --- a/src/include/lib/crash.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef _IN_LIB_CRASH_H -#define _IN_LIB_CRASH_H -#include -#include "data.h" -#include "types.h" - -extern const char var70052700[]; -extern const char var70052704[]; -extern const char var70052708[]; -extern const char var7005270c[]; -extern const char var70052710[]; -extern const char var70052714[]; -extern const char var70052718[]; -extern const char var7005271c[]; -extern const char var70052720[]; -extern const char var70052724[]; -extern const char var70052728[]; -extern const char var70052730[]; -extern const char var70052738[]; -extern const char var70052744[]; -extern const char var70052770[]; -extern const char var70052788[]; -extern const char var700527b4[]; -extern const char var700527dc[]; -extern const char var700527e4[]; -extern const char var700527e8[]; -extern const char var70052800[]; -extern const char var70052810[]; -extern const char var7005281c[]; -extern const char var70052824[]; -extern const char var70052854[]; -extern const char var70052864[]; -extern const char var70052870[]; -extern const char var700528a0[]; -extern const char var700528a4[]; -extern const char var700528a8[]; -extern const char var700528ac[]; -extern const char var700528b0[]; -extern const char var700528b4[]; -extern const char var700528b8[]; -extern const char var700528bc[]; -extern const char var700528c0[]; -extern const char var700528c4[]; -extern const char var700528c8[]; -extern const char var700528cc[]; -extern const char var700528d0[]; -extern const char var700528d4[]; -extern const char var700528d8[]; -extern const char var700528dc[]; -extern const char var700528e0[]; -extern const char var700528e4[]; -extern const char var700528e8[]; -extern const char var700528ec[]; -extern const char var700528f0[]; -extern const char var700528f4[]; -extern const char var700528f8[]; -extern const char var700528fc[]; -extern const char var70052900[]; -extern const char var70052904[]; -extern const char var70052908[]; -extern const char var7005290c[]; -extern const char var70052910[]; -extern const char var70052914[]; -extern const char var70052918[]; -extern const char var7005291c[]; -extern const char var70052920[]; -extern const char var70052924[]; -extern const char var70052928[]; -extern const char var70052938[]; -extern const char var70052944[]; -extern const char var70052950[]; -extern const char var7005295c[]; -extern const char var70052968[]; -extern const char var70052974[]; -extern const char var70052978[]; -extern const char var7005297c[]; -extern const char var70052980[]; -extern const char var70052984[]; -extern const char var70052988[]; -extern const char var7005298c[]; -extern const char var70052990[]; -extern const char var70052994[]; -extern const char var70052998[]; -extern const char var7005299c[]; -extern const char var700529a0[]; -extern const char var700529a4[]; -extern const char var700529a8[]; -extern const char var700529ac[]; - -#if VERSION == VERSION_NTSC_BETA -extern u8 g_CrashHasMessage; -#else -extern bool g_CrashHasMessage; -#endif - -void crashSetMessage(char *string); -void crashCreateThread(void); -u32 crashGetParentStackFrame(u32 *ptr, u32 *start, u32 sp, u32 *regs); -bool crashIsReturnAddress(u32 *instruction); -u32 crashGetStackEnd(u32 sp, s32 tid); -u32 crashGetStackStart(u32 arg0, s32 tid); -bool crashIsDouble(f32 value); -void crashPrintFloat(s32 index, f32 arg1); -void crashPrint2Floats(s32 index, f32 value1, f32 value2); -void crashPrint3Floats(s32 index, f32 value1, f32 value2, f32 value3); -void crashPutChar(s32 x, s32 y, char c); -void crashAppendChar(char c); -void crashScroll(s32 numlines); -void crashRenderChar(s32 x, s32 y, char c); -void crashReset(void); -void crashRenderFrame(u16 *fb); - -#endif diff --git a/src/include/lib/debughud.h b/src/include/lib/debughud.h deleted file mode 100644 index ac2a34b8f..000000000 --- a/src/include/lib/debughud.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _IN_LIB_DEBUGHUD_H -#define _IN_LIB_DEBUGHUD_H -#include -#include "data.h" -#include "types.h" - -void dhudPutCharAt(s32 x, s32 y, char c); -void dhudInit(void); -void dhudReset(void); -void dhudClear(void); -void dhudSetPos(s32 x, s32 y); -void dhudSetFgColour(s32 r, s32 g, s32 b, s32 a); -void dhudSetBgColour(s32 r, s32 g, s32 b, s32 a); -void dhudPrintChar(u8 c); -void dhudPrintString(char *text); -Gfx *dhudRender(Gfx *gdl); - -#endif diff --git a/src/include/lib/fault.h b/src/include/lib/fault.h deleted file mode 100644 index 1f1c51cfc..000000000 --- a/src/include/lib/fault.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _IN_LIB_FAULT_H -#define _IN_LIB_FAULT_H -#include -#include "data.h" -#include "types.h" - -void faultInit(void); -void faultAssert(char *msg, char *file, s32 line); - -#endif diff --git a/src/include/lib/rmon.h b/src/include/lib/rmon.h deleted file mode 100644 index 8891d9598..000000000 --- a/src/include/lib/rmon.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _IN_LIB_RMON_H -#define _IN_LIB_RMON_H -#include -#include "data.h" -#include "types.h" - -void rmonproc(); -void rmon0002fa30(u32 *arg0, s32 arg1); -void rmon0002fa38(s32 arg0); -void rmon0002fa40(void); -bool rmonIsDisabled(void); -void rmonPrintf(const char *format, ...); - -#endif diff --git a/src/include/lib/videbug.h b/src/include/lib/videbug.h deleted file mode 100644 index 3981f8cc3..000000000 --- a/src/include/lib/videbug.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _IN_LIB_VIDEBUG_H -#define _IN_LIB_VIDEBUG_H -#include -#include "data.h" -#include "types.h" - -void videbugCreate(void); -void videbugInit(void); - -#endif diff --git a/src/lib/args.c b/src/lib/args.c index fb758f8b5..48d67dfc9 100644 --- a/src/lib/args.c +++ b/src/lib/args.c @@ -3,7 +3,6 @@ #include "bss.h" #include "lib/args.h" #include "lib/str.h" -#include "lib/rmon.h" #include "string.h" #include "data.h" #include "types.h" @@ -71,14 +70,7 @@ bool argsParseDebugArgs(void) devaddr = 0x1ffff00; - if (rmonIsDisabled()) { - g_ArgBuffer[0] = 0; - } else { - for (i = 0; i < 30; i++) { - osPiReadIo(devaddr, &g_ArgBuffer[i]); - devaddr += 4; - } - } + g_ArgBuffer[0] = 0; argParseString((char *) g_ArgBuffer); diff --git a/src/lib/boot.c b/src/lib/boot.c index a60dcfc70..d6f74f835 100644 --- a/src/lib/boot.c +++ b/src/lib/boot.c @@ -8,17 +8,13 @@ #include "bss.h" #include "lib/args.h" #include "lib/rzip.h" -#include "lib/crash.h" #include "lib/main.h" #include "lib/snd.h" #include "lib/pimgr.h" -#include "lib/videbug.h" -#include "lib/rmon.h" #include "lib/lib_48150.h" #include "data.h" #include "types.h" -OSThread g_RmonThread; OSThread g_IdleThread; OSThread g_MainThread; OSThread g_SchedThread; @@ -214,7 +210,6 @@ void bootCreateSchedThread(void) void bootPhase2(void *arg) { bootCreateIdleThread(); - videbugCreate(); pimgrCreate(); if (argsParseDebugArgs()) { diff --git a/src/lib/crash.c b/src/lib/crash.c deleted file mode 100644 index 8ca79a17b..000000000 --- a/src/lib/crash.c +++ /dev/null @@ -1,1054 +0,0 @@ -#include -#include "os_internal.h" -#include "constants.h" -#include "bss.h" -#include "lib/tlb.h" -#include "lib/crash.h" -#include "lib/dma.h" -#include "lib/rmon.h" -#include "lib/vi.h" -#include "data.h" -#include "types.h" - -#define MSG_FAULT 0x10 - -#if VERSION >= VERSION_NTSC_1_0 -#define MAX_LINES 29 -#else -#define MAX_LINES 31 -#endif - -#if VERSION < VERSION_NTSC_1_0 -char g_CrashMessage[70]; -#endif - -OSThread g_FaultThread; -u8 g_FaultStack[STACKSIZE_FAULT]; -OSMesgQueue g_FaultMesgQueue; -OSMesg g_FaultMesg; - -#if VERSION == VERSION_NTSC_BETA -s32 var80097104nb; -s32 var80097108nb; -u32 var8009710cnb; -u8 g_CrashHasMessage = false; -#else -bool g_CrashHasMessage = false; -#endif - -s16 g_CrashCurX = 0; -s16 g_CrashCurY = 0; - -struct crashdescription { - u32 mask; - u32 value; - const char *text; -}; - -struct crashdescription g_CrashCauseDescriptions[] = { - { CAUSE_BD, CAUSE_BD, "BD" }, - { CAUSE_IP8, CAUSE_IP8, "IP8" }, - { CAUSE_IP7, CAUSE_IP7, "IP7" }, - { CAUSE_IP6, CAUSE_IP6, "IP6" }, - { CAUSE_IP5, CAUSE_IP5, "IP5" }, - { CAUSE_IP4, CAUSE_IP4, "IP4" }, - { CAUSE_IP3, CAUSE_IP3, "IP3" }, - { CAUSE_SW2, CAUSE_SW2, "IP2" }, - { CAUSE_SW1, CAUSE_SW1, "IP1" }, - { CAUSE_EXCMASK, EXC_INT, "Int" }, - { CAUSE_EXCMASK, EXC_MOD, "TLBmod" }, - { CAUSE_EXCMASK, EXC_RMISS, "TLBload" }, - { CAUSE_EXCMASK, EXC_WMISS, "TLBstore" }, - { CAUSE_EXCMASK, EXC_RADE, "Address error on load or instruction fetch" }, - { CAUSE_EXCMASK, EXC_WADE, "Address error on store" }, - { CAUSE_EXCMASK, EXC_IBE, "Bus error exception on instruction fetch" }, - { CAUSE_EXCMASK, EXC_DBE, "Bus error exception on data reference" }, - { CAUSE_EXCMASK, EXC_SYSCALL, "Syscall" }, - { CAUSE_EXCMASK, EXC_BREAK, "Brk" }, - { CAUSE_EXCMASK, EXC_II, "Reserved instruction" }, - { CAUSE_EXCMASK, EXC_CPU, "Cop unusable" }, - { CAUSE_EXCMASK, EXC_OV, "Overflow" }, - { CAUSE_EXCMASK, EXC_TRAP, "Trap" }, - { CAUSE_EXCMASK, EXC_VCEI, "Virtual coherency exception on intruction fetch" }, - { CAUSE_EXCMASK, EXC_FPE, "Fp exception" }, - { CAUSE_EXCMASK, EXC_WATCH, "Watchpoint" }, - { CAUSE_EXCMASK, EXC_VCED, "Virtual coherency exception on data reference" }, - { 0, 0, "" }, -}; - -struct crashdescription g_CrashSrDescriptions[] = { - { SR_CU3, SR_CU3, "CU3" }, - { SR_CU2, SR_CU2, "CU2" }, - { SR_CU1, SR_CU1, "CU1" }, - { SR_CU0, SR_CU0, "CU0" }, - { SR_RP, SR_RP, "RP" }, - { SR_FR, SR_FR, "FR" }, - { SR_RE, SR_RE, "RE" }, - { SR_BEV, SR_BEV, "BEV" }, - { SR_TS, SR_TS, "TS" }, - { SR_SR, SR_SR, "SR" }, - { SR_CH, SR_CH, "CH" }, - { SR_CE, SR_CE, "CE" }, - { SR_DE, SR_DE, "DE" }, - { SR_IBIT8, SR_IBIT8, "IM8" }, - { SR_IBIT7, SR_IBIT7, "IM7" }, - { SR_IBIT6, SR_IBIT6, "IM6" }, - { SR_IBIT5, SR_IBIT5, "IM5" }, - { SR_IBIT4, SR_IBIT4, "IM4" }, - { SR_IBIT3, SR_IBIT3, "IM3" }, - { SR_IBIT2, SR_IBIT2, "IM2" }, - { SR_IBIT1, SR_IBIT1, "IM1" }, - { SR_KX, SR_KX, "KX" }, - { SR_SX, SR_SX, "SX" }, - { SR_UX, SR_UX, "UX" }, - { SR_KSU_MASK, SR_KSU_USR, "USR" }, - { SR_KSU_MASK, SR_KSU_SUP, "SUP" }, - { SR_KSU_MASK, SR_KSU_KER, "KER" }, - { SR_ERL, SR_ERL, "ERL" }, - { SR_EXL, SR_EXL, "EXL" }, - { SR_IE, SR_IE, "IE" }, - { 0, 0, "" }, -}; - -struct crashdescription g_CrashFpcsrDescriptions[] = { - { FPCSR_FS, FPCSR_FS, "FS" }, - { FPCSR_C, FPCSR_C, "C" }, - { FPCSR_CE, FPCSR_CE, "Unimplemented" }, - { FPCSR_CV, FPCSR_CV, "Invalid op" }, - { FPCSR_CZ, FPCSR_CZ, "/ by 0.0" }, - { FPCSR_CO, FPCSR_CO, "Overflow" }, - { FPCSR_CU, FPCSR_CU, "Underflow" }, - { FPCSR_CI, FPCSR_CI, "Inexact op" }, - { FPCSR_EV, FPCSR_EV, "EV" }, - { FPCSR_EZ, FPCSR_EZ, "EZ" }, - { FPCSR_EO, FPCSR_EO, "EO" }, - { FPCSR_EU, FPCSR_EU, "EU" }, - { FPCSR_EI, FPCSR_EI, "EI" }, - { FPCSR_FV, FPCSR_FV, "FV" }, - { FPCSR_FZ, FPCSR_FZ, "FZ" }, - { FPCSR_FO, FPCSR_FO, "FO" }, - { FPCSR_FU, FPCSR_FU, "FU" }, - { FPCSR_FI, FPCSR_FI, "FI" }, - { FPCSR_RM_MASK, FPCSR_RM_RN, "RN" }, - { FPCSR_RM_MASK, FPCSR_RM_RZ, "RZ" }, - { FPCSR_RM_MASK, FPCSR_RM_RP, "RP" }, - { FPCSR_RM_MASK, FPCSR_RM_RM, "RM" }, - { 0, 0, "" }, -}; - -char (*g_CrashCharBuffer)[71] = NULL; - -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA -u32 var8005f138nb[] = { - 0x00000000, 0x22220200, 0x55000000, 0x05f5f500, - 0x27427200, 0x05124500, 0x34255300, 0x22000000, - 0x24444420, 0x42222240, 0x06f6f600, 0x00272000, - 0x00000240, 0x00070000, 0x00000200, 0x11224480, - 0x25555200, 0x26222700, 0x25125700, 0x61211600, - 0x33557300, 0x64611600, 0x24655200, 0x71112200, - 0x25755200, 0x25531600, 0x00200200, 0x00200640, - 0x01242100, 0x00707000, 0x04212400, 0x07120200, - 0x25ff5700, 0x02557d00, 0x06575e00, 0x07445300, - 0x07555600, 0x07565700, 0x07564400, 0x07c95700, - 0x05575500, 0x07222700, 0x03111600, 0x05665500, - 0x04445f00, 0x0dff9d00, 0x0f777d00, 0x07dd5700, - 0x07564600, 0x07995770, 0x07565500, 0x07461e00, - 0x07222200, 0x0d999600, 0x0d552200, 0x0df77500, - 0x0d625500, 0x05622600, 0x07125700, 0x32222230, - 0x44222110, 0x62222260, 0x25000000, 0x00000700, - 0x42200000, 0x0067d700, 0x44755700, 0x00788600, - 0x117dd700, 0x006fc700, 0x32722700, 0x007dd730, - 0x44755500, 0x02622700, 0x02711130, 0x44766500, - 0x62222700, 0x00ffff00, 0x00755d00, 0x006dd600, - 0x00755740, 0x00799710, 0x00744600, 0x00775700, - 0x02722300, 0x00555700, 0x00552200, 0x00577500, - 0x00562500, 0x00552220, 0x00703700, 0x12242210, - 0x02222220, 0x42212240, 0x005a0000, -}; -#endif - -u16 *g_CrashFrameBuffer = NULL; - -extern u32 _libSegmentStart; -extern u32 _libSegmentEnd; - -void faultproc(void *arg0); -u32 crashGenerate(OSThread *thread, u32 *callstack, s32 *tracelen); -void crashPrintDescription(u32 mask, char *label, struct crashdescription *descriptions); - -#if VERSION < VERSION_NTSC_1_0 -void crashSetMessage(char *string) -{ - strncpy(g_CrashMessage, string, sizeof(g_CrashMessage)); - g_CrashHasMessage = true; -} -#endif - -void crashCreateThread(void) -{ - osCreateMesgQueue(&g_FaultMesgQueue, &g_FaultMesg, 1); - osCreateThread(&g_FaultThread, THREAD_FAULT, faultproc, NULL, &g_FaultStack[1024], THREADPRI_FAULT); - osStartThread(&g_FaultThread); -} - -#if VERSION == VERSION_NTSC_BETA -GLOBAL_ASM( -glabel faultproc -/* c270: 27bdff98 */ addiu $sp,$sp,-104 -/* c274: afb40028 */ sw $s4,0x28($sp) -/* c278: 3c148009 */ lui $s4,0x8009 -/* c27c: 269470e8 */ addiu $s4,$s4,0x70e8 -/* c280: afbf002c */ sw $ra,0x2c($sp) -/* c284: afa40068 */ sw $a0,0x68($sp) -/* c288: afb30024 */ sw $s3,0x24($sp) -/* c28c: afb20020 */ sw $s2,0x20($sp) -/* c290: afb1001c */ sw $s1,0x1c($sp) -/* c294: afb00018 */ sw $s0,0x18($sp) -/* c298: afa00064 */ sw $zero,0x64($sp) -/* c29c: 2404000c */ addiu $a0,$zero,0xc -/* c2a0: 02802825 */ or $a1,$s4,$zero -/* c2a4: 0c01263c */ jal osSetEventMesg -/* c2a8: 24060010 */ addiu $a2,$zero,0x10 -/* c2ac: 3c018009 */ lui $at,0x8009 -/* c2b0: ac207108 */ sw $zero,0x7108($at) -/* c2b4: 27b30034 */ addiu $s3,$sp,0x34 -/* c2b8: 27b20038 */ addiu $s2,$sp,0x38 -/* c2bc: 27b10064 */ addiu $s1,$sp,0x64 -.NB0000c2c0: -/* c2c0: 02802025 */ or $a0,$s4,$zero -.NB0000c2c4: -/* c2c4: 02202825 */ or $a1,$s1,$zero -/* c2c8: 0c0126b0 */ jal osRecvMesg -/* c2cc: 24060001 */ addiu $a2,$zero,0x1 -/* c2d0: 0c012688 */ jal osSetIntMask -/* c2d4: 24040001 */ addiu $a0,$zero,0x1 -/* c2d8: 0c013eb8 */ jal __osGetCurrFaultedThread -/* c2dc: 00408025 */ or $s0,$v0,$zero -/* c2e0: 3c018009 */ lui $at,0x8009 -/* c2e4: 1040fff6 */ beqz $v0,.NB0000c2c0 -/* c2e8: ac227104 */ sw $v0,0x7104($at) -/* c2ec: 0c012688 */ jal osSetIntMask -/* c2f0: 02002025 */ or $a0,$s0,$zero -/* c2f4: 3c048009 */ lui $a0,0x8009 -/* c2f8: 8c847104 */ lw $a0,0x7104($a0) -/* c2fc: 02402825 */ or $a1,$s2,$zero -/* c300: 0c003297 */ jal crashGenerate -/* c304: 02603025 */ or $a2,$s3,$zero -/* c308: 0c00073b */ jal schedSetCrashedUnexpectedly -/* c30c: 24040001 */ addiu $a0,$zero,0x1 -/* c310: 1000ffec */ beqz $zero,.NB0000c2c4 -/* c314: 02802025 */ or $a0,$s4,$zero -/* c318: 00000000 */ sll $zero,$zero,0x0 -/* c31c: 00000000 */ sll $zero,$zero,0x0 -/* c320: 00000000 */ sll $zero,$zero,0x0 -/* c324: 00000000 */ sll $zero,$zero,0x0 -/* c328: 00000000 */ sll $zero,$zero,0x0 -/* c32c: 00000000 */ sll $zero,$zero,0x0 -/* c330: 8fbf002c */ lw $ra,0x2c($sp) -/* c334: 8fb00018 */ lw $s0,0x18($sp) -/* c338: 8fb1001c */ lw $s1,0x1c($sp) -/* c33c: 8fb20020 */ lw $s2,0x20($sp) -/* c340: 8fb30024 */ lw $s3,0x24($sp) -/* c344: 8fb40028 */ lw $s4,0x28($sp) -/* c348: 03e00008 */ jr $ra -/* c34c: 27bd0068 */ addiu $sp,$sp,0x68 -); -#else -void faultproc(void *arg0) -{ - OSMesg msg = 0; - OSIntMask mask; - u32 callstack[10]; - s32 tracelen; - static OSThread *curr; - static OSThread *last; - - osSetEventMesg(OS_EVENT_FAULT, &g_FaultMesgQueue, (OSMesg) MSG_FAULT); - last = NULL; - -#if VERSION == VERSION_PAL_BETA - while (true) { - do { - do { - osRecvMesg(&g_FaultMesgQueue, &msg, OS_MESG_BLOCK); - mask = osSetIntMask(1); - curr = __osGetCurrFaultedThread(); - } while (!curr); - - osSetIntMask(mask); - } while (!g_CrashHasMessage); - - crashGenerate(curr, callstack, &tracelen); - schedSetCrashedUnexpectedly(true); - } -#elif VERSION == VERSION_NTSC_BETA - while (true) { - do { - osRecvMesg(&g_FaultMesgQueue, &msg, OS_MESG_BLOCK); - mask = osSetIntMask(1); - curr = __osGetCurrFaultedThread(); - } while (!curr); - - osSetIntMask(mask); - - crashGenerate(curr, callstack, &tracelen); - schedSetCrashedUnexpectedly(true); - } -#else - while (true) { - do { - osRecvMesg(&g_FaultMesgQueue, &msg, OS_MESG_BLOCK); - mask = osSetIntMask(1); - curr = __osGetCurrFaultedThread(); - } while (!curr); - - osSetIntMask(mask); - } -#endif -} -#endif - -#if VERSION == VERSION_NTSC_BETA -char *var80097110nb; -char *var80097114nb; -u32 var80097118nb[24]; -u8 var80097178nb[MAX_LINES + 1][71]; -#elif VERSION == VERSION_PAL_BETA -u8 var80097178nb[MAX_LINES + 1][71]; -#endif - -/** - * Given a pointer to an instruction and a stack frame pointer, attempt to find - * the calling function. Return the address of the caller's stack frame and - * populate regs with stack addresses where that register was saved. This can be - * used to retrieve the RA value and invoke crashGetParentStackFrame again to - * build a backtrace. - * - * origptr is a pointer to an instruction. This should be either the value of - * the PC register of the faulted thread, or an RA register if searching a - * parent. - * minaddr is the memory address of the start of the code segment, - * ie. 0x70001050. This is used to prevent the function from walking out of - * the code segment. - * origsp is the address of the stack frame for the given origptr. - * regs is a pointer to an array of 32 words. - * - * The function works by walking backwards one instruction at a time, looking - * for stack frame adjustments and stores of $ra to the stack. Once both of - * these are are found, the function returns with this information. - * - * The function will return 0 if it can't reliably find the caller. This will - * happen if the function being analysed didn't adjust the stack pointer or - * store $ra in the stack. It can also fail if the function being analysed uses - * returns within branches. - */ -u32 crashGetParentStackFrame(u32 *origptr, u32 *minaddr, u32 origsp, u32 *regs) -{ - u32 sp = origsp; - u32 *ptr; - bool foundaddsp = false; - bool foundra = false; - s32 regid; - u32 instruction; - s16 value; - - // Clear the regs array (note: reusing the instruction variable here) - for (instruction = 0; instruction < 32; instruction++) regs[instruction] = 0; - - // Walk backwards through the instructions - for (ptr = origptr; ptr >= minaddr; ptr--) { - instruction = *ptr; - value = instruction & 0xffff; - - if ((instruction & 0xffff0000) == 0x27bd0000) { - // Found an addiu $sp, $sp, instruction, which adjusts the - // stack pointer. These can exist near the start and end of any - // function. The "add" at the start is done with a negative value - // which increases the size of the stack, as the stack expands to - // the left. This function is interested in these negative adds, - // because it needs to reverse it and move the sp variable forward - // to the next stack frame (the frame of the caller). - - foundaddsp = true; - - if (value > 0) { - // Found the addiu sp at the end of the function. It's pretty - // rare to crash (or jump elsewhere) after restoring the sp, - // so this situation is not supported by this function. - break; - } - - // Change sp to point to the caller's stack frame - sp -= (value >> 2) * 4; - - if (foundra) { - break; - } - } else if ((instruction & 0xffe00000) == 0xafa00000) { - // Found a store word instruction that stores to the stack. - // The encoding of this instruction is: - // - // oooooodd dddsssss iiiiiiii iiiiiiii - // - // Where: - // o is the opcode (already known to be sw). - // d is the destination register (already known to be $sp) - // s is the source register - // i is the offset to store to - // - // This looks for a store from $ra to the stack, so the value can - // be read from the stack and used to find the caller's address. - - regid = (instruction >> 16) & 0x1f; - regs[regid] = sp + (value >> 2) * 4; - - if (regid == 31) { - foundra = true; - } - - if (foundaddsp && foundra) { - break; - } - } else if (instruction == 0x03e00008) { - // Found a jr $ra statement, which is a return. This will happen if - // this loop has walked out of the current function and into the one - // prior to it, so bail. - - // It can also happen if the function has return statements within - // branches, but handling these correctly would involve a lot of - // complexity so that's unsupported. Because of this, this function - // can end the backtrace prematurely if it encounters a function - // that does this. - break; - } - } - - if (foundaddsp && foundra) { - return sp; - } - - return 0; -} - -bool crashIsReturnAddress(u32 *instruction) -{ - if (((u32)instruction % 4) == 0 - && (u32)instruction >= (u32)tlbInit - && (u32)instruction <= (u32)&_libSegmentEnd) { - // This condition can never pass because 9 is masked out - if ((instruction[-2] & 0xfc00003c) == 9) { - return true; - } - - // If 2 instructions earlier was a jal - if ((instruction[-2] & 0xfc000000) == 0x0c000000) { - return true; - } - } - - return false; -} - -#if VERSION < VERSION_NTSC_1_0 -s32 crashGetStrLen(char *str) -{ - s32 i = 0; - char c = *str++; - - while (c != '\0') { - i++; - - if (i >= 256) { - break; - } - - c = *str++; - } - - return i; -} -#endif - -#if VERSION < VERSION_NTSC_1_0 -u32 crash0000c52cnb(u32 romaddr) -{ - u32 addr; - - dmaExec(var80097118nb, romaddr, 0x60); - - var8009710cnb = var80097118nb[0]; - var80097110nb = (char *)&var80097118nb[1]; - var80097114nb = (char *)(crashGetStrLen(var80097110nb) + (u32)var80097110nb + 1); - - addr = romaddr + crashGetStrLen(var80097110nb) + crashGetStrLen(var80097114nb) + 6; - - if (addr % 4) { - addr = (addr | 3) + 1; - } - - return addr; -} -#endif - -#if VERSION < VERSION_NTSC_1_0 -bool crash0000c5d8nb(u32 arg0) -{ - u32 this = 0x00e00004; - u32 prev = 0x00e00004; - - while (true) { - u32 next = crash0000c52cnb(this); - - if (arg0 >= var8009710cnb) { - prev = this; - - if (var8009710cnb == 0) { - return false; - } - - this = next; - } else { - break; - } - } - - crash0000c52cnb(prev); - - return true; -} -#endif - -#if VERSION < VERSION_NTSC_1_0 -bool crash0000c660nb(void) -{ - crash0000c52cnb(0xe00000); - - return var8009710cnb == 0x826475be; -} -#endif - -#if VERSION < VERSION_NTSC_1_0 -void crash0000c694nb(void) -{ - s32 numvalid = 0; - s32 i; - - for (i = 0; i < 4; i++) { - if (var80097110nb[i] >= '!' && var80097110nb[i] <= 0x7f) { - numvalid++; - } - } - - if (numvalid == 4) { - rmonPrintf("%.49s", var80097110nb); - } else { - rmonPrintf("???"); - } -} -#endif - -#if VERSION < VERSION_NTSC_1_0 -void crash0000c714nb(void) -{ - s32 numvalid = 0; - s32 i; - - for (i = 0; i < 4; i++) { - if (var80097114nb[i] >= '!' && var80097114nb[i] <= 0x7f) { - numvalid++; - } - } - - if (numvalid == 4) { - rmonPrintf("%.41s", var80097114nb); - } else { - rmonPrintf("???"); - } -} -#endif - -#if VERSION < VERSION_NTSC_1_0 -void crash0000c794nb(void) -{ - rmonPrintf("%08x", var8009710cnb); -} -#endif - -#if VERSION < VERSION_NTSC_1_0 -u32 crash0000c7c0nb(void) -{ - return var8009710cnb; -} -#endif - -u32 crashGetStackEnd(u32 sp, s32 tid) -{ - u32 start; - u32 end; - - if (tid <= 0 || tid > 6U) { - rmonPrintf("Bad tid\n"); - return 0; - } - - start = (u32)g_StackLeftAddrs[tid]; - end = (u32)g_StackRightAddrs[tid]; - - if (sp >= K0BASE) { - return end; - } - - return (sp & 0xf0000000) | (end - start); -} - -u32 crashGetStackStart(u32 sp, s32 tid) -{ - u32 start; - - if (tid <= 0 || tid > 6U) { - rmonPrintf("Bad tid\n"); - return 0; - } - - start = (u32)g_StackLeftAddrs[tid]; - - if (sp >= K0BASE) { - return start; - } - - return sp & 0xf0000000; -} - -bool crashIsDouble(f32 value) -{ - u32 bits = *(u32*)&value; - u32 fraction = bits & 0x7fffff; - u8 exponent = (u8)(bits >> 23); - - return fraction == 0 || (exponent != 0 && exponent != 0xff); -} - -void crashPrintFloat(s32 index, f32 value) -{ - if (crashIsDouble(value)) { - rmonPrintf("%s%s%02d: % .7e ", "", "", index, (f64)value); - } else { - u32 bits = *(u32 *)&value; - rmonPrintf("%02d: I%d.%03d.%07d ", index, (bits & 0x80000000) >> 31, (bits & 0x7f800000) >> 23, bits & 0x7fffff); - } -} - -void crashPrint2Floats(s32 index, f32 value1, f32 value2) -{ - crashPrintFloat(index, value1); - rmonPrintf(" "); - - crashPrintFloat(index + 1, value2); - rmonPrintf("\n"); -} - -void crashPrint3Floats(s32 index, f32 value1, f32 value2, f32 value3) -{ - crashPrintFloat(index, value1); - rmonPrintf(" "); - - crashPrintFloat(index + 1, value2); - rmonPrintf(" "); - - crashPrintFloat(index + 2, value3); - rmonPrintf("\n"); -} - -u32 crashGenerate(OSThread *thread, u32 *callstack, s32 *tracelen) -{ - s32 i; - u32 ptr; - u32 *sp; - u32 regs[32]; -#if VERSION == VERSION_NTSC_BETA - s32 j; - u32 *stackstart; - u32 *stackend; -#else - u32 *stackend; - u32 *stackstart; -#endif - __OSThreadContext *ctx = &thread->context; - bool done; - u32 *tmpsp; -#if VERSION == VERSION_NTSC_BETA - s32 len; -#endif - - rmonPrintf("\n\nFAULT-\n"); - -#if VERSION >= VERSION_NTSC_1_0 - if (!g_Vars.fourmeg2player) -#endif - { - // Print a stack trace in a dodgy way. - // It works by iterating through the stack allocation, looking for any - // values which could potentially be a return address, and prints them. - u32 *stackend = (u32 *) crashGetStackEnd(ctx->sp, thread->id); - rmonPrintf("DodgyStackTrace: %08llx ", ctx->ra & 0xffffffff); - tmpsp = (u32 *) ctx->sp; - - while (tmpsp < stackend) { - if (crashIsReturnAddress((u32 *)*tmpsp)) { - rmonPrintf("%08x ", *tmpsp); - } - - tmpsp++; - } - - rmonPrintf(".\n"); - } - -#if VERSION >= VERSION_NTSC_1_0 - rmonPrintf("%H#@! Another Perfect Crash (tm)\n"); -#else - rmonPrintf("\nPerfect Crash (tm)\n\n"); -#endif - -#if VERSION >= VERSION_NTSC_1_0 - if (!g_Vars.fourmeg2player) -#endif - { - // Print floating point registers - crashPrint2Floats(0, ctx->fp0.f.f_odd, ctx->fp0.f.f_even); - crashPrint3Floats(2, ctx->fp2.f.f_odd, ctx->fp2.f.f_even, ctx->fp4.f.f_odd); - crashPrint3Floats(5, ctx->fp4.f.f_even, ctx->fp6.f.f_odd, ctx->fp6.f.f_even); - crashPrint3Floats(8, ctx->fp8.f.f_odd, ctx->fp8.f.f_even, ctx->fp10.f.f_odd); - crashPrint3Floats(11, ctx->fp10.f.f_even, ctx->fp12.f.f_odd, ctx->fp12.f.f_even); - crashPrint3Floats(14, ctx->fp14.f.f_odd, ctx->fp14.f.f_even, ctx->fp16.f.f_odd); - crashPrint3Floats(17, ctx->fp16.f.f_even, ctx->fp18.f.f_odd, ctx->fp18.f.f_even); - crashPrint3Floats(20, ctx->fp20.f.f_odd, ctx->fp20.f.f_even, ctx->fp22.f.f_odd); - crashPrint3Floats(23, ctx->fp22.f.f_even, ctx->fp24.f.f_odd, ctx->fp24.f.f_even); - crashPrint3Floats(26, ctx->fp26.f.f_odd, ctx->fp26.f.f_even, ctx->fp28.f.f_odd); - crashPrint3Floats(29, ctx->fp28.f.f_even, ctx->fp30.f.f_odd, ctx->fp30.f.f_even); - } - - // Print integer registers - rmonPrintf("at 0x%016llx v0 0x%016llx v1 0x%016llx\n", ctx->at, ctx->v0, ctx->v1); - rmonPrintf("a0 0x%016llx a1 0x%016llx a2 0x%016llx\n", ctx->a0, ctx->a1, ctx->a2); - rmonPrintf("a3 0x%016llx t0 0x%016llx t1 0x%016llx\n", ctx->a3, ctx->t0, ctx->t1); - rmonPrintf("t2 0x%016llx t3 0x%016llx t4 0x%016llx\n", ctx->t2, ctx->t3, ctx->t4); - rmonPrintf("t5 0x%016llx t6 0x%016llx t7 0x%016llx\n", ctx->t5, ctx->t6, ctx->t7); - rmonPrintf("s0 0x%016llx s1 0x%016llx s2 0x%016llx\n", ctx->s0, ctx->s1, ctx->s2); - rmonPrintf("s3 0x%016llx s4 0x%016llx s5 0x%016llx\n", ctx->s3, ctx->s4, ctx->s5); - rmonPrintf("s6 0x%016llx s7 0x%016llx t8 0x%016llx\n", ctx->s6, ctx->s7, ctx->t8); - rmonPrintf("t9 0x%016llx gp 0x%016llx sp 0x%016llx\n", ctx->t9, ctx->gp, ctx->sp); - rmonPrintf("s8 0x%016llx ra 0x%016llx\n", ctx->s8, ctx->ra); - -#if VERSION >= VERSION_NTSC_1_0 - rmonPrintf("TID %d epc %08x caus %08x fp %08x badv %08x sr %08x\n", - thread->id, ctx->pc, ctx->cause, ctx->fpcsr, ctx->badvaddr, ctx->sr); -#else - rmonPrintf("TID %d epc %08x cause %08x fp %08x badv %08x sr %08x\n", - thread->id, ctx->pc, ctx->cause, ctx->fpcsr, ctx->badvaddr, ctx->sr); -#endif - - // Print the address of the faulted instruction, along with the instruction - // itself and the next three - presumably to help the developer locate it. - rmonPrintf("dshex -a %08x %08x %08x %08x %08x\n", ctx->pc, - ((u32 *)ctx->pc)[0], - ((u32 *)ctx->pc)[1], - ((u32 *)ctx->pc)[2], - ((u32 *)ctx->pc)[3]); - - crashPrintDescription(ctx->cause, "cause", g_CrashCauseDescriptions); - rmonPrintf(" : "); - crashPrintDescription(ctx->fpcsr, "fpcsr", g_CrashFpcsrDescriptions); - rmonPrintf("\n"); - - // Print a proper stack trace - i = 0; - done = false; - sp = (u32 *)ctx->sp; - stackend = (u32 *) crashGetStackEnd((u32)sp, thread->id); - stackstart = (u32 *) crashGetStackStart((u32)sp, thread->id); - ptr = ctx->pc; - *tracelen = 0; - rmonPrintf("nearl: "); - - while (!done) { - sp = (u32 *) crashGetParentStackFrame((u32 *) ptr, &_libSegmentStart, (u32)sp, regs); - rmonPrintf(" %08x ", ptr); - - callstack[*tracelen] = ptr; - *tracelen = *tracelen + 1; - - if (i == 4) { - rmonPrintf("\n "); - } - - if (sp == NULL) { - sp = (u32 *)ctx->sp; - } - - if (regs[31] == 0) { - ptr = ctx->ra; - } else { - ptr = *(u32 *)(regs[31]); - } - - if (sp < stackstart || sp >= stackend || stackend == &sp[4] || ptr == 0) { - break; - } - - done = i >= 9; - i++; - } - -#if VERSION == VERSION_NTSC_BETA - g_CrashCurY = 31; - - if (g_CrashHasMessage) { - g_CrashCurX = 0; - - for (len = 0; len < 71U; len++) { - if (g_CrashMessage[len] == '\0') { - break; - } - } - - g_CrashCurX = (71 - len) / 2; - - for (j = 0; j < len; j++) { - crashAppendChar(g_CrashMessage[j]); - } - } else { - g_CrashCurX = 32; - - crashAppendChar('C'); - crashAppendChar('R'); - crashAppendChar('A'); - crashAppendChar('S'); - crashAppendChar('H'); - crashAppendChar('E'); - crashAppendChar('D'); - } -#endif - - rmonPrintf("\n"); - rmonPrintf("\n"); - - return 0; -} - -void crashPrintDescription(u32 mask, char *label, struct crashdescription *description) -{ - bool first = true; - s32 i; - - rmonPrintf("%s <", label); - - while (description->mask != 0) { - if ((description->mask & mask) == description->value) { - if (first) { - first = false; - } else { - rmonPrintf(","); - } - - rmonPrintf("%s", description->text); - } - - description++; - } - - rmonPrintf(">"); -} - -void crashPutChar(s32 x, s32 y, char c) -{ - if (c == '\t' || c == '\n') { - c = '\0'; - } - - if ((c > '\0' && c < ' ') || c > '~') { - c = '?'; - } - - if (x >= 0 && x < 72 && y >= 0 && y <= MAX_LINES && g_CrashCharBuffer != NULL) { - g_CrashCharBuffer[y][x] = c; - } -} - -void crashAppendChar(char c) -{ - if (c == '\0') { - return; - } - - if (c == '\t') { - do { - crashAppendChar(' '); - } while (g_CrashCurX & 7); - - return; - } - - if (c == '\n') { - g_CrashCurY++; - g_CrashCurX = 0; - } - - if (g_CrashCurY >= MAX_LINES) { - crashScroll(g_CrashCurY - MAX_LINES + 1); - g_CrashCurY = MAX_LINES - 1; - } - - if (c != '\n') { - crashPutChar(g_CrashCurX, g_CrashCurY, c); - g_CrashCurX++; - - if (g_CrashCurX >= 71) { - g_CrashCurX = 0; - g_CrashCurY++; - } - } -} - -void crashScroll(s32 numlines) -{ - s32 i; - s32 y; - s32 x; - - if (g_CrashCharBuffer == NULL) { - return; - } - - while (numlines-- > 0) { - for (y = 0; y < MAX_LINES; y++) { - for (x = 0; x < 71; x++) { - g_CrashCharBuffer[y][x] = g_CrashCharBuffer[y + 1][x]; - } - } - } -} - -/** - * Render a character to the crash buffer. - */ -void crashRenderChar(s32 x, s32 y, char c) -{ - s32 i; - s32 j; - s32 width; - u16 *fbpos; - bool hires; - s32 tmp; - u32 a2; - - width = viGetWidth(); - - if (c == '\0') { - c = ' '; - } - - if (c < ' ' || c > '~') { - return; - } - - hires = (width == 640); - - if (hires) { - fbpos = g_CrashFrameBuffer + x * 2 + y * width; - } else { - fbpos = g_CrashFrameBuffer + x + y * width; - } - -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA - a2 = var8005f138nb[c - ' ']; -#else - a2 = 0; -#endif - - for (i = 0; i < 7; i++) { - for (j = 0; j < 4; j++) { - u32 gray = a2 & 0x80000000; - - if (gray) { -#if VERSION == VERSION_NTSC_BETA - fbpos[0] = GPACK_RGBA5551(0xff, 0xff, 0xff, 1); -#else - fbpos[0] = GPACK_RGBA5551(0x78, 0x78, 0x78, 1); -#endif - } else { - fbpos[0] = GPACK_RGBA5551(0, 0, 0, 1); - } - - if (hires) { - if (gray) { -#if VERSION == VERSION_NTSC_BETA - fbpos[1] = GPACK_RGBA5551(0xff, 0xff, 0xff, 1); -#else - fbpos[1] = GPACK_RGBA5551(0x78, 0x78, 0x78, 1); -#endif - } else { - fbpos[1] = GPACK_RGBA5551(0, 0, 0, 1); - } - } - - fbpos++; - - if (hires) { - fbpos++; - } - - a2 *= 2; - } - - if (hires) { - fbpos += width; - fbpos -= 8; - } else { - fbpos += width; - fbpos -= 4; - } - } -} - -void crashReset(void) -{ -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA - g_CrashCharBuffer = var80097178nb; -#else - g_CrashCharBuffer = NULL; -#endif - - if (g_CrashCharBuffer) { - // Unreachable - s32 x; - s32 y; - - for (y = 0; y < MAX_LINES + 1; y++) { - for (x = 0; x < 71; x++) { - g_CrashCharBuffer[y][x] = '\0'; - } - } - } -} - -void crashRenderFrame(u16 *fb) -{ - s32 width; - s32 height; - s32 x; - s32 y; - - g_CrashFrameBuffer = (u16 *) PHYS_TO_K1(fb); - - width = (viGetWidth() - 13) / 4; - height = (viGetHeight() - 10) / 7 - 1; - - if (g_CrashCharBuffer != NULL) { - for (y = 0; y < height && y < MAX_LINES; y++) { - for (x = 0; x < width - 5 && x < 71; x++) { - crashRenderChar(20 + x * 4, 7 + y * 7, g_CrashCharBuffer[y][x]); - } - } - } -} diff --git a/src/lib/debughud.c b/src/lib/debughud.c deleted file mode 100644 index 3bf38968a..000000000 --- a/src/lib/debughud.c +++ /dev/null @@ -1,425 +0,0 @@ -#include -#include "constants.h" -#include "bss.h" -#include "lib/debughud.h" -#include "game/gfxmemory.h" -#include "data.h" -#include "types.h" - -// The number of columns and rows in the screen buffer, in characters. -#define NUM_COLS 80 -#define NUM_ROWS 35 - -// The dimensions of each character's texture, in pixels. -// These are shown at 4x the texture size when rendering. -#define CHAR_W 4 -#define CHAR_H 7 - -#define MAX_COLOURS 32 - -struct dhudchar { - char c; - u8 paletteindex; -}; - -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA -struct dhudchar g_DHudCharBuffer[NUM_COLS][NUM_ROWS]; -Gfx g_DHudFgGbi[MAX_COLOURS]; -Gfx g_DHudBgGbi[MAX_COLOURS]; -Gfx var800606e0nb = gsSPEndDisplayList(); - -// This is a 128 x 21 sprite of characers in greyscale at one byte per pixel. -// Each character is 4 x 7 pixels. There's 3 rows with 32 characters per row. -u32 g_DHudSprite[] = { - // space ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? - 0x00000000, 0x00227a00, 0x007a348b, 0x00223434, 0x00115811, 0x00696900, 0x00000000, 0x00009c00, 0x00004600, 0x00460000, 0x00004600, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000046, 0x00229c11, 0x00346900, 0x00229c11, 0x00699c11, 0x00005834, 0x00adad34, 0x00118b34, 0x009cad7a, 0x00229c11, 0x00229c11, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00113411, - 0x00000000, 0x0046ce00, 0x00ad58de, 0x00466969, 0x009c9c69, 0x008b8b00, 0x00469c00, 0x0022ce00, 0x00583400, 0x00345800, 0x007ace69, 0x00005800, 0x00000000, 0x00000000, 0x00000000, 0x00003446, 0x008b007a, 0x00588b00, 0x008b008b, 0x0022007a, 0x00119c69, 0x008b0000, 0x009c1100, 0x0022008b, 0x008b007a, 0x008b007a, 0x00000000, 0x00000000, 0x00225869, 0x00000000, 0x69582200, 0x009c698b, - 0x00000000, 0x0046ce00, 0x00222258, 0x00deef7a, 0x00ad1111, 0x0069ef9c, 0x008b0000, 0x00460000, 0x008b0000, 0x00008b00, 0x0058ce34, 0x00008b00, 0x00000000, 0x00000000, 0x00000000, 0x00008b00, 0x008b008b, 0x00008b00, 0x0011007a, 0x00118b46, 0x0058467a, 0x00cead22, 0x009c8b00, 0x0000117a, 0x00698b46, 0x008b00ad, 0x0034ad00, 0x0034ad00, 0x228b4600, 0x8b8b8b8b, 0x00468b22, 0x0011008b, - 0x00000000, 0x00007a00, 0x00000000, 0x009c9c00, 0x00118b34, 0x22adbd46, 0x008b8b34, 0x00000000, 0x008b0000, 0x00008b00, 0x007a2269, 0x22adef9c, 0x00000000, 0x22adadad, 0x00000000, 0x00226900, 0x008b008b, 0x00008b00, 0x00007a00, 0x0000117a, 0x009c347a, 0x0000008b, 0x00ce117a, 0x00002269, 0x008b227a, 0x00229c8b, 0x00001100, 0x00001100, 0xad580000, 0x34343434, 0x000058ad, 0x0000bd34, - 0x00000000, 0x00112200, 0x00000000, 0x22dede22, 0x00ce5858, 0x0046468b, 0x008bad00, 0x00000000, 0x008b0000, 0x00008b00, 0x00000000, 0x00008b00, 0x00003400, 0x00000000, 0x00002200, 0x00691100, 0x008b008b, 0x00008b00, 0x00691158, 0x0011008b, 0x007a9cad, 0x1122008b, 0x008b008b, 0x00008b00, 0x008b008b, 0x0000227a, 0x00002200, 0x00002200, 0x228b4600, 0x8b8b8b8b, 0x00468b22, 0x00006900, - 0x00000000, 0x00228b00, 0x00000000, 0x008b8b00, 0x0034bd00, 0x00119c46, 0x007a6969, 0x00000000, 0x00583400, 0x00345800, 0x00000000, 0x00005800, 0x0011ff00, 0x00000000, 0x00228b00, 0x008b0000, 0x00349c22, 0x008bce69, 0x22bdad8b, 0x007a9c11, 0x00008b8b, 0x118b9c11, 0x00349c22, 0x00005800, 0x00349c11, 0x00588b11, 0x00228b00, 0x0069ad00, 0x00225869, 0x00000000, 0x69582200, 0x0000bd00, - 0x00000000, 0x00000000, 0x00000000, 0x00464600, 0x00004600, 0x00000000, 0x00000000, 0x00000000, 0x00004600, 0x00460000, 0x00000000, 0x00000000, 0x00583400, 0x00000000, 0x00000000, 0x58340000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x008b0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - - // @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ - 0x00229c11, 0x00221100, 0x11223400, 0x00003411, 0x11342200, 0x00343422, 0x00343422, 0x00002222, 0x00220022, 0x00342222, 0x00003434, 0x00341122, 0x22341100, 0x11110022, 0x22221134, 0x00002200, 0x00343411, 0x00003400, 0x00343411, 0x00113411, 0x00343434, 0x11341134, 0x11220034, 0x34220034, 0x11340022, 0x11220034, 0x00223422, 0x00008b34, 0x00460000, 0x00587a00, 0x00005800, 0x00000000, - 0x348b008b, 0x0069bd00, 0x11de7a58, 0x00ad69de, 0x22ce7a9c, 0x11ce7aad, 0x11ce7aad, 0x00ad7ade, 0x22ce00ce, 0x0069ce58, 0x00008bce, 0x22ce22ce, 0x46ce4600, 0x7abd00ff, 0x58ff46ce, 0x00ad7a9c, 0x11ce7a7a, 0x00ad7a8b, 0x22ce7a7a, 0x118b7abd, 0x469ccece, 0x8b8b34ce, 0x8b8b00bd, 0xbd8b22bd, 0x58ce00ce, 0x22bd00ce, 0x00bd7aad, 0x00008b00, 0x007a1100, 0x00008b00, 0x00694658, 0x00000000, - 0x468b7abd, 0x00588b22, 0x008b008b, 0x46460011, 0x008b007a, 0x118b3458, 0x008b3458, 0x46460011, 0x008b008b, 0x00008b00, 0x0000117a, 0x008b7a11, 0x008b0000, 0x589c58bd, 0x11ad698b, 0x4646007a, 0x118b007a, 0x5846007a, 0x118b007a, 0x46580011, 0x34228b46, 0x6934008b, 0x007a008b, 0x58348b7a, 0x11696946, 0x00695846, 0x00113458, 0x00008b00, 0x00116900, 0x00008b00, 0x00110011, 0x00000000, - 0x468b8b9c, 0x009c228b, 0x00dead7a, 0x58340000, 0x008b007a, 0x11dead00, 0x00dead00, 0x583400ad, 0x46deadbd, 0x00008b00, 0x3411117a, 0x00dead00, 0x008b0000, 0x5846ad7a, 0x118b8b8b, 0x5834007a, 0x11dead34, 0x5834007a, 0x11dede46, 0x0058ad34, 0x00008b00, 0x5834008b, 0x008b117a, 0x00bdde8b, 0x0022ad00, 0x0011bd00, 0x00226900, 0x00008b00, 0x00008b00, 0x00008b00, 0x00000000, 0x00000000, - 0x348b348b, 0x469c8bad, 0x008b007a, 0x347a0058, 0x008b009c, 0x008b008b, 0x008b0000, 0x228b007a, 0x008b008b, 0x00008b00, 0x46462269, 0x008b117a, 0x008b007a, 0x6934347a, 0x118b34de, 0x118b009c, 0x008b0000, 0x228b009c, 0x008b117a, 0x3434008b, 0x00008b00, 0x4646008b, 0x0022ce00, 0x00adbd8b, 0x008b007a, 0x00008b00, 0x008b0058, 0x00008b00, 0x00003446, 0x00008b00, 0x00000000, 0x00000000, - 0x00697a9c, 0x7a9c00bd, 0x69cead58, 0x0058ad58, 0x22bdad34, 0x22cead8b, 0x22bd2200, 0x0058ad58, 0x22ad00ce, 0x008bbd7a, 0x007a7a00, 0x22bd228b, 0x69bdadbd, 0x8b9c00bd, 0x69ce227a, 0x0058ad34, 0x22ce6900, 0x009cef69, 0x22bd2258, 0x7a9c9c22, 0x0046ce34, 0x007aad11, 0x00005800, 0x00580058, 0x22ad00ce, 0x0058bd34, 0x00ad9c9c, 0x00008b00, 0x0000008b, 0x00008b00, 0x00000000, 0x22222222, - 0x00002211, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0058588b, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000ce34, 0x0000007a, 0x1158ad00, 0x00000000, 0x7a7a7a7a, - - // ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ blank/unused - 0x00693400, 0x00000000, 0x22690000, 0x00000000, 0x0000008b, 0x00000000, 0x0000589c, 0x11000000, 0x22690000, 0x00001100, 0x00001100, 0x22690000, 0x008b7a00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00004646, 0x00004600, 0x00464600, 0x00000000, 0x00000000, - 0x0046ad00, 0x00000000, 0x008b0000, 0x00000000, 0x0000008b, 0x00000000, 0x00116900, 0x00000000, 0x008b0000, 0x00006900, 0x00006900, 0x008b0000, 0x00008b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00226900, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00008b00, 0x00008b00, 0x00008b00, 0x00000000, 0x00000000, - 0x00005800, 0x008b9c34, 0x00cead69, 0x007aad9c, 0x008badbd, 0x007aad34, 0x009cde7a, 0x008b9cce, 0x11cead69, 0x00589c00, 0x008bad69, 0x008bad69, 0x00008b00, 0x7aad9c9c, 0x22cead69, 0x007aad34, 0x22cead69, 0x008b9cde, 0x22de9c69, 0x007aad9c, 0x009cde7a, 0x118b00ad, 0x11ce00de, 0x34ce00de, 0x22ce34ad, 0x22ce00de, 0x00bd9cad, 0x00008b00, 0x00008b00, 0x00008b00, 0x229c347a, 0x00000000, - 0x00000000, 0x009cad7a, 0x008b007a, 0x69340034, 0x4634009c, 0x46ce9cbd, 0x00226900, 0x4646008b, 0x008b008b, 0x00008b00, 0x0000007a, 0x00de7a00, 0x00008b00, 0x46468b69, 0x119c008b, 0x4646008b, 0x008b0069, 0x5846008b, 0x008b0000, 0x008b7a58, 0x00226900, 0x008b008b, 0x007a117a, 0x008b8b8b, 0x0058bd00, 0x008b008b, 0x00464646, 0x00467a00, 0x00008b00, 0x00008b46, 0x7a349c22, 0x00000000, - 0x00000000, 0x4634227a, 0x009c007a, 0x58460022, 0x4646009c, 0x34460034, 0x00226900, 0x3446009c, 0x008b008b, 0x00008b00, 0x0000007a, 0x008b6911, 0x00008b00, 0x46468b69, 0x118b008b, 0x3458008b, 0x00ad0069, 0x584600ad, 0x008b0000, 0x0069348b, 0x00226911, 0x008b009c, 0x0011de00, 0x00adbd8b, 0x00699c11, 0x00469c34, 0x00225858, 0x00008b00, 0x00008b00, 0x00008b00, 0x00000000, 0x00000000, - 0x00000000, 0x119c8bce, 0x22adad58, 0x007a9c46, 0x0069adad, 0x1169ad46, 0x008bbd7a, 0x0069adad, 0x22ad00bd, 0x118bce69, 0x0000007a, 0x227a34ce, 0x008bbd7a, 0x7a699c46, 0x69bd00ce, 0x007a9c22, 0x00bd9c58, 0x0069adad, 0x22ce9c34, 0x008bad58, 0x00009c8b, 0x00699cad, 0x11005800, 0x00580069, 0x11bd349c, 0x00009c00, 0x00adad9c, 0x00008b00, 0x00008b00, 0x00008b00, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000008b, 0x00000000, 0x00000000, 0x00004646, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x008b0000, 0x0000008b, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00226900, 0x00000000, 0x00008b46, 0x00008b00, 0x00467a00, 0x00000000, 0x00000000, -}; - -s32 g_DHudBaseX = 5; -s32 g_DHudBaseY = 1; -s32 g_DHudPosX = 24; -s32 g_DHudPosY = 16; -bool g_DHudIsEmpty = true; -bool g_DHudInitialised = false; - -Gfx var80061180nb[] = { - gsDPPipeSync(), - gsDPSetCycleType(G_CYC_1CYCLE), - gsDPSetColorDither(G_CD_DISABLE), - gsDPSetRenderMode(IM_RD | CVG_DST_FULL | ZMODE_OPA | FORCE_BL | GBL_c1(G_BL_CLR_MEM, G_BL_A_IN, G_BL_CLR_IN, G_BL_1), IM_RD | CVG_DST_FULL | ZMODE_OPA | FORCE_BL | GBL_c2(G_BL_CLR_MEM, G_BL_A_IN, G_BL_CLR_IN, G_BL_1)), - gsDPSetCombineLERP(PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT), - gsDPSetTexturePersp(G_TP_NONE), - gsDPSetTextureLUT(G_TT_NONE), - gsDPSetAlphaCompare(G_AC_NONE), - gsDPLoadTextureBlock(g_DHudSprite, G_IM_FMT_IA, G_IM_SIZ_8b, 128, 21, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD), - gsDPLoadSync(), - gsSPEndDisplayList(), -}; - -struct dhudchar (*g_DHudCharBufferPtr)[NUM_ROWS] = NULL; -Gfx *g_DHudFgGbiPtrs = NULL; -Gfx *g_DHudBgGbiPtrs = NULL; -s32 g_DHudNextPaletteIndex = 0; -Gfx var80061218nb = gsSPEndDisplayList(); -Gfx var80061220nb = gsDPNoOp(); -Gfx g_DHudFgColour = gsDPSetPrimColor(0, 0, 0xff, 0xff, 0xff, 0); -Gfx g_DHudBgColour = gsDPSetEnvColor(0, 0, 0, 0); -#endif - -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA -s32 dhud00013fe0nb(s32 arg0, s32 arg1) -{ - return 0; -} -#endif - -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA -s32 dhud00013ff0nb(s32 arg0, s32 arg1) -{ - return 0; -} -#endif - -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA -void dhud00014000nb(void) -{ - // empty -} -#endif - -void dhudInit(void) -{ -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA - s32 i; - s32 x; - s32 y; - u32 stack; - - Gfx cmd = {0, 0}; - - g_DHudCharBufferPtr = g_DHudCharBuffer; - g_DHudFgGbiPtrs = g_DHudFgGbi; - g_DHudBgGbiPtrs = g_DHudBgGbi; - - g_DHudInitialised = true; - - for (x = 0; x < NUM_COLS; x++) { - for (y = 0; y < NUM_ROWS; y++) { - g_DHudCharBufferPtr[x][y].c = '\0'; - g_DHudCharBufferPtr[x][y].paletteindex = 0; - } - } - - for (i = 0; i < MAX_COLOURS; i++) { - g_DHudFgGbiPtrs[i] = cmd; - g_DHudBgGbiPtrs[i] = cmd; - } -#endif -} - -void dhudReset(void) -{ -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA - if (g_DHudInitialised) { - dhudClear(); - } -#endif -} - -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA -void dhudPutCharAt(s32 x, s32 y, char c) -{ - s32 i; - - // Check if the current colour pair exists in the palette - for (i = 0; i < MAX_COLOURS; i++) { - if (g_DHudFgColour.words.w1 == g_DHudFgGbiPtrs[i].words.w1 - && g_DHudBgColour.words.w1 == g_DHudBgGbiPtrs[i].words.w1) { - goto havepalette; - } - } - - // Add colours to pallete - g_DHudFgGbiPtrs[g_DHudNextPaletteIndex] = g_DHudFgColour; - g_DHudBgGbiPtrs[g_DHudNextPaletteIndex] = g_DHudBgColour; - - i = g_DHudNextPaletteIndex = (g_DHudNextPaletteIndex + 1) % MAX_COLOURS; - -havepalette: - g_DHudCharBufferPtr[x][y].c = c; - g_DHudCharBufferPtr[x][y].paletteindex = i; - - if (c != '\0') { - g_DHudIsEmpty = false; - } -} -#endif - -void dhudResetPos(void) -{ -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA - if (g_DHudInitialised) { - g_DHudPosX = g_DHudBaseX; - g_DHudPosY = g_DHudBaseY; - } -#endif -} - -void dhudClear(void) -{ -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA - s32 x; - s32 y; - - if (g_DHudInitialised && g_DHudIsEmpty != true) { - for (y = 0; y < NUM_ROWS; y++) { - for (x = 0; x < NUM_COLS; x++) { - dhudPutCharAt(x, y, '\0'); - } - } - - g_DHudIsEmpty = true; - - dhudResetPos(); - dhud00014000nb(); - - g_DHudNextPaletteIndex = 0; - } -#endif -} - -void dhudSetPos(s32 x, s32 y) -{ -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA - if (g_DHudInitialised) { - x += g_DHudBaseX; - y += g_DHudBaseY; - - if (y >= (viGetHeight() - 10) / CHAR_H) { - y = (viGetHeight() - 10) / CHAR_H - 1; - } - - g_DHudPosX = x; - g_DHudPosY = y; - } -#endif -} - -void dhudSetFgColour(s32 r, s32 g, s32 b, s32 a) -{ -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA - if (g_DHudInitialised) { - g_DHudFgColour.words.w1 = r << 24 | g << 16 | b << 8 | (255 - a); - } -#endif -} - -void dhudSetBgColour(s32 r, s32 g, s32 b, s32 a) -{ -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA - if (g_DHudInitialised) { - g_DHudBgColour.words.w1 = r << 24 | g << 16 | b << 8 | (255 - a); - } -#endif -} - -void dhudPrintChar(u8 c) -{ -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA - s32 maxwidth = (viGetWidth() - 13) / CHAR_W; - s32 maxheight = (viGetHeight() - 10) / CHAR_H; - - if (g_DHudInitialised) { - if (c == '\0' || (c >= ' ' && c <= '~')) { - dhudPutCharAt(g_DHudPosX, g_DHudPosY, c); - } - - g_DHudPosX++; - - if (c == '\r' || c == '\n' || g_DHudPosX >= maxwidth) { - g_DHudPosX = g_DHudBaseX; - g_DHudPosY++; - - if (g_DHudPosY >= maxheight) { - g_DHudPosY = g_DHudBaseY; - } - } - } -#endif -} - -#if VERSION != VERSION_PAL_BETA -void dhudPrintCharAt(s32 x, s32 y, char c) -{ -#if VERSION == VERSION_NTSC_BETA - if (g_DHudInitialised) { - dhudSetPos(x, y); - dhudPrintChar(c); - } -#endif -} -#endif - -void dhudPrintString(char *str) -{ -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA - if (g_DHudInitialised) { - while (*str != '\0') { - dhudPrintChar(*str++); - } - } -#endif -} - -#if VERSION != VERSION_PAL_BETA -void dhudPrintStringAt(s32 x, s32 y, char *str) -{ -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA - if (g_DHudInitialised) { - dhudSetPos(x, y); - - while (*str != '\0') { - dhudPrintChar(*str++); - } - } -#endif -} -#endif - -Gfx *dhudRender(Gfx *gdl) -{ -#if VERSION == VERSION_NTSC_BETA || VERSION == VERSION_PAL_BETA - if (!g_DHudInitialised) { - return gdl; - } - - if (!g_DHudIsEmpty) { - s32 x; - s32 y; - s32 appliedpaletteindex; - s32 available; - s32 needed; - Gfx *gdl2; - - static u32 percentage = 255; - - // Calculate how much space is needed in the display list - // based on the number of characters to draw and the number - // of times the colours will be changed. - gdl2 = gdl; - appliedpaletteindex = -1; - - for (y = 0; y < NUM_ROWS; y++) { - for (x = 0; x < NUM_COLS; x++) { - u32 c = g_DHudCharBufferPtr[x][y].c; - s32 paletteindex = g_DHudCharBufferPtr[x][y].paletteindex; - - if (c != '\0') { - if (paletteindex != appliedpaletteindex) { - gdl2 += 2; - appliedpaletteindex = paletteindex; - } - - if (1); - - gdl2 += 3; - } - } - } - - // Make sure there'll be a least 256 GBI commands free (2KB) - available = gfxGetFreeGfx(gdl) - 256 * sizeof(Gfx); - needed = (u32)gdl2 - (u32)gdl; - - if (needed <= 0) { // shouldn't be possible - return gdl; - } - - { - s32 x; - s32 appliedpaletteindex = -1; - - // Write a "percentage" (out of 255) into a global variable - // which shows how much of the displaylist will be committed, - // provided 2KB is kept free. - if (available <= 0) { - // There's already less than 2KB free in the display list - percentage = 0; - } else if (needed > available) { - // The display list would end with less than 2KB free, - // so calculate the percentage - percentage = available * 255 / needed; - } else { - // The display list would end with at least 2KB free, - // so the displaylist can be committed in full - percentage = 256; - } - - gSPDisplayList(gdl++, var80061180nb); - - // Build the display list for real this time. - // Regardless of the availability checks above, just stop when - // there's less than 1KB of free space... sort of. It still writes - // the colour change commands, but the debug HUD doesn't exactly - // draw rainbows so it's no big deal. - for (y = 0; y < NUM_ROWS; y++) { - for (x = 0; x < NUM_COLS; x++) { - u32 c = g_DHudCharBufferPtr[x][y].c; - s32 paletteindex = g_DHudCharBufferPtr[x][y].paletteindex; - - if (c != '\0') { - if (paletteindex != appliedpaletteindex) { - *gdl = g_DHudFgGbiPtrs[paletteindex]; gdl++; - *gdl = g_DHudBgGbiPtrs[paletteindex]; gdl++; - - appliedpaletteindex = paletteindex; - } - - if (1); - - if (gfxGetFreeGfx(gdl) >= 1024) { - gSPTextureRectangle(gdl++, - // Screen coords to draw at - x * CHAR_W * 4, - y * CHAR_H * 4, - x * CHAR_W * 4 + CHAR_W * 4, - y * CHAR_H * 4 + CHAR_H * 4, - 0, - // Sprite X and Y positions - ((c - ' ') % 32) * CHAR_W * 32, - ((s32)(c - ' ') >> 5) * CHAR_H * 32, - 1024, 1024); - } - } - } - } - } - } -#endif - - return gdl; -} diff --git a/src/lib/fault.c b/src/lib/fault.c deleted file mode 100644 index d453aa72c..000000000 --- a/src/lib/fault.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include "constants.h" -#include "bss.h" -#include "lib/crash.h" -#include "lib/rmon.h" -#include "data.h" -#include "types.h" - -void faultInit(void) -{ -} - -void faultAssert(char *message, char *file, s32 line) -{ - rmonPrintf("ASSERTION : %s, %d: (\"%s\")\n", file, line, message); -} diff --git a/src/lib/main.c b/src/lib/main.c index c032ce4d3..a3d25cb52 100644 --- a/src/lib/main.c +++ b/src/lib/main.c @@ -49,8 +49,6 @@ #include "lib/vm.h" #include "lib/rzip.h" #include "lib/vi.h" -#include "lib/fault.h" -#include "lib/crash.h" #include "lib/dma.h" #include "lib/joy.h" #include "lib/main.h" @@ -58,13 +56,10 @@ #include "lib/memp.h" #include "lib/mema.h" #include "lib/profile.h" -#include "lib/videbug.h" -#include "lib/debughud.h" #include "lib/anim.h" #include "lib/rdp.h" #include "lib/lib_34d0.h" #include "lib/lib_2f490.h" -#include "lib/rmon.h" #include "lib/rng.h" #include "lib/str.h" #include "data.h" @@ -198,9 +193,8 @@ void mainInit(void) varsInit(); mempInit(); memaInit(); - videbugInit(); viConfigureForLogos(); - var8005d9b0 = rmonIsDisabled(); + var8005d9b0 = 1; joyInit(); osCreateMesgQueue(&queue, &msg, 1); @@ -366,7 +360,6 @@ void mainInit(void) mempResetPool(MEMPOOL_8); mempResetPool(MEMPOOL_PERMANENT); - crashReset(); challengesInit(); utilsInit(); func000034d0(); @@ -375,7 +368,6 @@ void mainInit(void) cheatsInit(); func0000e9c0(); textInit(); - dhudInit(); playermgrInit(); frametimeInit(); stub0f00b200(); @@ -575,7 +567,6 @@ void mainLoop(void) gfxReset(); joyReset(); - dhudReset(); mblurReset(g_StageNum); lvReset(g_StageNum); viReset(g_StageNum); @@ -638,7 +629,6 @@ void mainTick(void) profileReset(); func000034d8(); joyDebugJoy(); - schedSetCrashEnable2(false); if (g_MainGameLogicEnabled) { profileStart(PROFILEMARKER_CPU); diff --git a/src/lib/mema.c b/src/lib/mema.c index 1aa429e43..31ea21429 100644 --- a/src/lib/mema.c +++ b/src/lib/mema.c @@ -1,7 +1,6 @@ #include #include "constants.h" #include "bss.h" -#include "lib/debughud.h" #include "lib/mema.h" #include "lib/memp.h" #include "data.h" diff --git a/src/lib/rmon.c b/src/lib/rmon.c deleted file mode 100644 index 0d149bd24..000000000 --- a/src/lib/rmon.c +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include -#include "constants.h" -#include "bss.h" -#include "lib/crash.h" -#include "lib/libc/xprintf.h" -#include "data.h" -#include "types.h" - -void rmonproc() -{ - // empty -} - -bool rmonIsDisabled(void) -{ - return true; -} - -s32 rmon0002fa10(void) -{ - return -1; -} - -void rmon0002fa18(void) -{ - // empty -} - -void rmon0002fa20(void) -{ - // empty -} - -void rmon0002fa28(void) -{ - // empty -} - -void rmon0002fa30(s32 *arg0, s32 arg1) -{ - if (arg0); - if (arg1); -} - -void rmon0002fa38(u32 arg0) -{ - if (arg0); -} - -void rmon0002fa40(void) -{ - // empty -} - -char *rmonProut(char *dst, const char *src, size_t count) -{ - s32 i = 0; - - while (i != count) { - crashAppendChar(src[i++]); - } - - return (char *) 1; -} - -void rmonPrintf(const char *format, ...) -{ - va_list ap; - va_start(ap, format); - - _Printf(rmonProut, NULL, format, ap); -} diff --git a/src/lib/rzip.s b/src/lib/rzip.s index 5e7dd4c07..091859490 100644 --- a/src/lib/rzip.s +++ b/src/lib/rzip.s @@ -279,7 +279,6 @@ glabel rzipInflate sw $sp, 0x74($sp) sw $s8, 0x78($sp) addiu $sp, $sp, -0x18 - jal rmonPrintf addiu $a0, $a0, %lo(errstr_unrecognised) addiu $sp, $sp, 0x18 lw $ra, 0x0($sp) @@ -352,7 +351,6 @@ glabel rzipInflate sw $sp, 0x74($sp) sw $s8, 0x78($sp) addiu $sp, $sp, -0x18 - jal rmonPrintf addiu $a0, $a0, %lo(errstr_unrecognised) addiu $sp, $sp, 0x18 lw $ra, 0x0($sp) @@ -466,7 +464,6 @@ glabel rzipInflate sw $v0, 0x4($sp) lui $a0, %hi(errstr_inflatefailed) addiu $a0, $a0, %lo(errstr_inflatefailed) - jal rmonPrintf lw $a1, 0x4($sp) addiu $sp, $sp, 0x18 lw $ra, 0x0($sp) @@ -898,7 +895,6 @@ glabel rzipInflateDynamic sw $sp, 0x74($sp) sw $s8, 0x78($sp) addiu $sp, $sp, -24 - jal rmonPrintf addiu $a0, $a0, %lo(errstr_badlen) addiu $sp, $sp, 0x18 lw $ra, 0x0($sp) @@ -1402,7 +1398,6 @@ glabel rzipBuildHufts sw $s3, 0x4($sp) lui $a0, %hi(errstr_huftsoverflow) addiu $a0, $a0, %lo(errstr_huftsoverflow) - jal rmonPrintf lw $a1, 0x4($sp) addiu $sp, $sp, 0x18 lw $ra, 0x0($sp) diff --git a/src/lib/sched.c b/src/lib/sched.c index 305dc6011..9741a281f 100644 --- a/src/lib/sched.c +++ b/src/lib/sched.c @@ -8,12 +8,10 @@ #include "lib/audiomgr.h" #include "lib/reset.h" #include "lib/rzip.h" -#include "lib/crash.h" #include "lib/main.h" #include "lib/snd.h" #include "lib/pimgr.h" #include "lib/profile.h" -#include "lib/rmon.h" #include "lib/lib_48150.h" #include "lib/vi.h" #include "lib/joy.h" @@ -75,12 +73,6 @@ s32 g_SchedWriteArtifactsIndex; s32 g_SchedFrontArtifactsIndex; s32 g_SchedPendingArtifactsIndex; -bool g_SchedCrashedUnexpectedly = false; -bool g_SchedCrashEnable1 = false; -bool g_SchedCrashEnable2 = false; -u32 g_SchedCrashRenderInterval = 45000000; -u32 g_SchedCrashLastRendered = 0; - s32 var8005ce74 = 0; f32 g_ViXScalesBySlot[2] = {1, 1}; f32 g_ViYScalesBySlot[2] = {1, 1}; @@ -94,49 +86,6 @@ u32 var8005cea4 = 0; OSScMsg g_SchedRspMsg = {OS_SC_RSP_MSG}; bool g_SchedIsFirstTask = true; -void schedSetCrashEnable1(bool enable) -{ - g_SchedCrashEnable1 = enable; -} - -void schedSetCrashedUnexpectedly(bool enable) -{ - g_SchedCrashedUnexpectedly = enable; -} - -void schedSetCrashEnable2(bool enable) -{ - g_SchedCrashEnable2 = enable; -} - -void schedSetCrashRenderInterval(u32 cycles) -{ - g_SchedCrashRenderInterval = cycles; -} - -void schedRenderCrashOnBuffer(void *framebuffer) -{ - if ((g_SchedCrashEnable2 && g_SchedCrashEnable1) || g_SchedCrashedUnexpectedly) { - crashRenderFrame(framebuffer); - g_SchedCrashLastRendered = osGetCount(); - } -} - -void schedRenderCrashPeriodically(u32 framecount) -{ - if ((framecount & 0xf) == 0 && ((g_SchedCrashEnable2 && g_SchedCrashEnable1) || g_SchedCrashedUnexpectedly)) { - if (osGetCount() - g_SchedCrashLastRendered > g_SchedCrashRenderInterval) { - crashRenderFrame(g_FrameBuffers[0]); - crashRenderFrame(g_FrameBuffers[1]); - } - } -} - -void schedInitCrashLastRendered(void) -{ - g_SchedCrashLastRendered = osGetCount(); -} - void osCreateScheduler(OSSched *sc, OSThread *thread, u8 mode, u32 numFields) { sc->curRSPTask = 0; @@ -172,7 +121,6 @@ void osCreateScheduler(OSSched *sc, OSThread *thread, u8 mode, u32 numFields) osSetEventMesg(OS_EVENT_DP, &sc->interruptQ, (OSMesg)RDP_DONE_MSG); osViSetEvent(&sc->interruptQ, (OSMesg)VIDEO_MSG, numFields); - schedInitCrashLastRendered(); osCreateThread(sc->thread, THREAD_SCHED, &__scMain, sc, bootAllocateStack(THREAD_SCHED, STACKSIZE_SCHED), THREADPRI_SCHED); osStartThread(sc->thread); } @@ -294,7 +242,6 @@ void __scHandleRetrace(OSSched *sc) joysTick(); snd0000fe18(); - schedRenderCrashPeriodically(sc->frameCount); } extern struct sndcache g_SndCache; @@ -599,7 +546,6 @@ s32 __scTaskComplete(OSSched *sc, OSScTask *t) g_ViUnblackTimer--; } - schedRenderCrashOnBuffer(t->framebuffer); osViSwapBuffer(t->framebuffer); } diff --git a/src/lib/str.c b/src/lib/str.c index 3491ba41f..143587679 100644 --- a/src/lib/str.c +++ b/src/lib/str.c @@ -1,19 +1,11 @@ #include -#include "lib/fault.h" +#include "types.h" char *strcpy(char *dst, const char *src) { char *ptr = dst; char c; - if (dst == NULL) { - faultAssert("s1", "str.c", 44); - } - - if (src == NULL) { - faultAssert("s2", "str.c", 45); - } - *ptr = c = *src; ptr++; src++; diff --git a/src/lib/videbug.c b/src/lib/videbug.c deleted file mode 100644 index 4e9e42634..000000000 --- a/src/lib/videbug.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" -#include "lib/videbug.h" - -OSMesg g_ViDebugMesgs[8]; -OSMesgQueue g_ViDebugMesgQueue; - -void videbugCreate(void) -{ - // empty -} - -void videbugInit(void) -{ - osCreateMesgQueue(&g_ViDebugMesgQueue, g_ViDebugMesgs, ARRAYCOUNT(g_ViDebugMesgs)); -}