From 7b5713f0f55d5081c531d873490f4252a6b88dec Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 30 Oct 2021 14:54:33 +1000 Subject: [PATCH] Decompile crashSetMessage --- src/game/bg.c | 8 ++++---- src/game/file.c | 4 ++-- src/game/lv.c | 2 +- src/game/pak/pak.c | 2 +- src/game/texdecompress.c | 2 +- src/include/lib/crash.h | 1 + src/lib/boot.c | 4 ++-- src/lib/crash.c | 25 +++++++------------------ src/lib/dma.c | 2 +- src/lib/main.c | 4 ++-- src/lib/memp.c | 2 +- src/lib/sched.c | 1 - src/lib/snd.c | 4 ++-- src/lib/vm.c | 2 +- 14 files changed, 26 insertions(+), 37 deletions(-) diff --git a/src/game/bg.c b/src/game/bg.c index ae8713bdf..fefead7ac 100644 --- a/src/game/bg.c +++ b/src/game/bg.c @@ -4538,7 +4538,7 @@ glabel func7f155c10nb /* f155c80: afa300ac */ sw $v1,0xac($sp) /* f155c84: 0c004fc1 */ jal sprintf /* f155c88: afa000a8 */ sw $zero,0xa8($sp) -/* f155c8c: 0c003074 */ jal func0000c1d0nb +/* f155c8c: 0c003074 */ jal crashSetMessage /* f155c90: 27a40028 */ addiu $a0,$sp,0x28 /* f155c94: 24180045 */ addiu $t8,$zero,0x45 /* f155c98: a0180000 */ sb $t8,0x0($zero) @@ -4567,7 +4567,7 @@ glabel func7f155c10nb /* f155ce8: 8fa600b0 */ lw $a2,0xb0($sp) /* f155cec: 0c004fc1 */ jal sprintf /* f155cf0: 8fa700b4 */ lw $a3,0xb4($sp) -/* f155cf4: 0c003074 */ jal func0000c1d0nb +/* f155cf4: 0c003074 */ jal crashSetMessage /* f155cf8: 27a40028 */ addiu $a0,$sp,0x28 /* f155cfc: 240a0045 */ addiu $t2,$zero,0x45 /* f155d00: a00a0000 */ sb $t2,0x0($zero) @@ -9446,7 +9446,7 @@ glabel bgInflate /* f158158: 9209000f */ lbu $t1,0xf($s0) /* f15815c: 0c004fc1 */ jal sprintf /* f158160: afa9004c */ sw $t1,0x4c($sp) -/* f158164: 0c003074 */ jal func0000c1d0nb +/* f158164: 0c003074 */ jal crashSetMessage /* f158168: 27a40064 */ addiu $a0,$sp,0x64 /* f15816c: 240a0045 */ addiu $t2,$zero,0x45 /* f158170: 10000004 */ beqz $zero,.NB0f158184 @@ -10637,7 +10637,7 @@ glabel func0f15dc58 /* f158a24: 004e082a */ slt $at,$v0,$t6 /* f158a28: 5020000a */ beqzl $at,.NB0f158a54 /* f158a2c: 240a0001 */ addiu $t2,$zero,0x1 -/* f158a30: 0c003074 */ jal func0000c1d0nb +/* f158a30: 0c003074 */ jal crashSetMessage /* f158a34: 24841a34 */ addiu $a0,$a0,0x1a34 /* f158a38: 24180045 */ addiu $t8,$zero,0x45 /* f158a3c: a0180000 */ sb $t8,0x0($zero) diff --git a/src/game/file.c b/src/game/file.c index 2d8c41ff4..76c9e3c21 100644 --- a/src/game/file.c +++ b/src/game/file.c @@ -4180,7 +4180,7 @@ glabel func0f166eb4 /* f1617ac: afa200d4 */ sw $v0,0xd4($sp) /* f1617b0: 0c004fc1 */ jal sprintf /* f1617b4: afac002c */ sw $t4,0x2c($sp) -/* f1617b8: 0c003074 */ jal func0000c1d0nb +/* f1617b8: 0c003074 */ jal crashSetMessage /* f1617bc: 27a40054 */ addiu $a0,$sp,0x54 /* f1617c0: 240d0045 */ addiu $t5,$zero,0x45 /* f1617c4: 8fa300d4 */ lw $v1,0xd4($sp) @@ -4429,7 +4429,7 @@ glabel fileGetInflatedLength /* f1619fc: 9208000f */ lbu $t0,0xf($s0) /* f161a00: 0c004fc1 */ jal sprintf /* f161a04: afa8004c */ sw $t0,0x4c($sp) -/* f161a08: 0c003074 */ jal func0000c1d0nb +/* f161a08: 0c003074 */ jal crashSetMessage /* f161a0c: 27a40070 */ addiu $a0,$sp,0x70 /* f161a10: 240a0045 */ addiu $t2,$zero,0x45 /* f161a14: a00a0000 */ sb $t2,0x0($zero) diff --git a/src/game/lv.c b/src/game/lv.c index be7cdf267..b51f29f49 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -6243,7 +6243,7 @@ glabel var7f1b1fd4nb /* f165eb4: 50200006 */ beqzl $at,.NB0f165ed0 /* f165eb8: 8fbf0054 */ lw $ra,0x54($sp) .NB0f165ebc: -/* f165ebc: 0c003074 */ jal func0000c1d0nb +/* f165ebc: 0c003074 */ jal crashSetMessage /* f165ec0: 24841e78 */ addiu $a0,$a0,0x1e78 /* f165ec4: 240e0045 */ addiu $t6,$zero,0x45 /* f165ec8: a00e0000 */ sb $t6,0x0($zero) diff --git a/src/game/pak/pak.c b/src/game/pak/pak.c index 3be8b5183..e2f402a5c 100644 --- a/src/game/pak/pak.c +++ b/src/game/pak/pak.c @@ -1103,7 +1103,7 @@ PakErr1 _pakReadWriteBlock(OSPfs *pfs, s32 file_no, u8 flag, u32 address, u32 le if (newaddress >= 256) { #if VERSION < VERSION_NTSC_1_0 u32 stack; - func0000c1d0nb("ILLEGAL EEPROM ADDRESS (>=256)"); + crashSetMessage("ILLEGAL EEPROM ADDRESS (>=256)"); CRASH(); #endif } diff --git a/src/game/texdecompress.c b/src/game/texdecompress.c index 8dc3c05b4..3c710c5a9 100644 --- a/src/game/texdecompress.c +++ b/src/game/texdecompress.c @@ -765,7 +765,7 @@ glabel func0f16e818 /* f1696f8: 904c000f */ lbu $t4,0xf($v0) /* f1696fc: 0c004fc1 */ jal sprintf /* f169700: afac004c */ sw $t4,0x4c($sp) -/* f169704: 0c003074 */ jal func0000c1d0nb +/* f169704: 0c003074 */ jal crashSetMessage /* f169708: 27a400a4 */ addiu $a0,$sp,0xa4 /* f16970c: 240b0045 */ addiu $t3,$zero,0x45 /* f169710: a00b0000 */ sb $t3,0x0($zero) diff --git a/src/include/lib/crash.h b/src/include/lib/crash.h index cd0562515..7d0845036 100644 --- a/src/include/lib/crash.h +++ b/src/include/lib/crash.h @@ -87,6 +87,7 @@ extern const char var700529a4[]; extern const char var700529a8[]; extern const char var700529ac[]; +void crashSetMessage(char *string); void crashCreateThread(void); u32 crashGetParentStackFrame(u32 *ptr, u32 *start, u32 sp, u32 *regs); bool crashIsReturnAddress(u32 *instruction); diff --git a/src/lib/boot.c b/src/lib/boot.c index af69de51c..b8ab5bb2c 100644 --- a/src/lib/boot.c +++ b/src/lib/boot.c @@ -12,7 +12,7 @@ #include "lib/main.h" #include "lib/snd.h" #include "lib/pimgr.h" -#include "lib/lib_13750.h" +#include "lib/videbug.h" #include "lib/rmon.h" #include "lib/lib_48150.h" #include "data.h" @@ -693,7 +693,7 @@ glabel func00001bf4nb /* 1c70: 02a02825 */ move $a1,$s5 /* 1c74: 0c004fc1 */ jal sprintf /* 1c78: 02603025 */ move $a2,$s3 -/* 1c7c: 0c003074 */ jal func0000c1d0nb +/* 1c7c: 0c003074 */ jal crashSetMessage /* 1c80: 02402025 */ move $a0,$s2 /* 1c84: a0160000 */ sb $s6,0x0($zero) /* 1c88: 26310001 */ addiu $s1,$s1,0x1 diff --git a/src/lib/crash.c b/src/lib/crash.c index 20641c922..65d98dff8 100644 --- a/src/lib/crash.c +++ b/src/lib/crash.c @@ -17,7 +17,7 @@ #endif #if VERSION < VERSION_NTSC_1_0 -u32 padding[18]; +char g_CrashMessage[70]; #endif OSThread g_FaultThread; @@ -25,7 +25,7 @@ u8 g_FaultStack[STACKSIZE_FAULT]; OSMesgQueue g_FaultMesgQueue; OSMesg g_FaultMesg; -u32 var8005d5b0 = 0; +u8 g_CrashHasMessage = false; s16 g_CrashCurX = 0; s16 g_CrashCurY = 0; @@ -169,22 +169,11 @@ u32 crashGenerate(OSThread *thread, u32 *callstack, s32 *tracelen); void crashPrintDescription(u32 mask, char *label, struct crashdescription *descriptions); #if VERSION < VERSION_NTSC_1_0 -GLOBAL_ASM( -glabel func0000c1d0nb -/* c1d0: 27bdffe8 */ addiu $sp,$sp,-24 -/* c1d4: 00802825 */ or $a1,$a0,$zero -/* c1d8: afbf0014 */ sw $ra,0x14($sp) -/* c1dc: 3c048009 */ lui $a0,0x8009 -/* c1e0: 24844e70 */ addiu $a0,$a0,0x4e70 -/* c1e4: 0c004e86 */ jal strncpy -/* c1e8: 24060046 */ addiu $a2,$zero,0x46 -/* c1ec: 8fbf0014 */ lw $ra,0x14($sp) -/* c1f0: 240e0001 */ addiu $t6,$zero,0x1 -/* c1f4: 3c018006 */ lui $at,0x8006 -/* c1f8: a02eed50 */ sb $t6,-0x12b0($at) -/* c1fc: 03e00008 */ jr $ra -/* c200: 27bd0018 */ addiu $sp,$sp,0x18 -); +void crashSetMessage(char *string) +{ + strncpy(g_CrashMessage, string, sizeof(g_CrashMessage)); + g_CrashHasMessage = true; +} #endif void crashCreateThread(void) diff --git a/src/lib/dma.c b/src/lib/dma.c index cddce40cf..fefd40496 100644 --- a/src/lib/dma.c +++ b/src/lib/dma.c @@ -39,7 +39,7 @@ void dmaStart(void *memaddr, u32 romaddr, u32 len, bool priority) #if VERSION < VERSION_NTSC_1_0 if (romaddr >= 1024 * 1024 * 32) { - func0000c1d0nb("DMA : Off the end of the rom"); + crashSetMessage("DMA : Off the end of the rom"); CRASH(); } #endif diff --git a/src/lib/main.c b/src/lib/main.c index 6651b8e0c..ff10187cf 100644 --- a/src/lib/main.c +++ b/src/lib/main.c @@ -52,7 +52,7 @@ #include "lib/snd.h" #include "lib/memp.h" #include "lib/mema.h" -#include "lib/lib_13750.h" +#include "lib/videbug.h" #include "lib/debughud.h" #include "lib/anim.h" #include "lib/rdp.h" @@ -2560,7 +2560,7 @@ glabel mainLoop /* e840: 24a5516c */ addiu $a1,$a1,0x516c /* e844: 0c004fc1 */ jal sprintf /* e848: 8fa600b8 */ lw $a2,0xb8($sp) -/* e84c: 0c003074 */ jal func0000c1d0nb +/* e84c: 0c003074 */ jal crashSetMessage /* e850: 02a02025 */ or $a0,$s5,$zero /* e854: 24190045 */ addiu $t9,$zero,0x45 /* e858: a0190000 */ sb $t9,0x0($zero) diff --git a/src/lib/memp.c b/src/lib/memp.c index 7b5a6e7bf..113263f1f 100644 --- a/src/lib/memp.c +++ b/src/lib/memp.c @@ -201,7 +201,7 @@ void *mempAlloc(u32 len, u8 pool) sprintf(buffer, "Out of mem - ETR: %d f %d s %d", len, free, size); } - func0000c1d0nb(buffer); + crashSetMessage(buffer); CRASH(); } #endif diff --git a/src/lib/sched.c b/src/lib/sched.c index 38ea1e9e0..870ecc5d7 100644 --- a/src/lib/sched.c +++ b/src/lib/sched.c @@ -11,7 +11,6 @@ #include "lib/main.h" #include "lib/snd.h" #include "lib/pimgr.h" -#include "lib/lib_13750.h" #include "lib/rmon.h" #include "lib/lib_48150.h" #include "data.h" diff --git a/src/lib/snd.c b/src/lib/snd.c index 596f775b2..c5eaed0d1 100644 --- a/src/lib/snd.c +++ b/src/lib/snd.c @@ -2641,7 +2641,7 @@ glabel snd0000fc48 /* 1025c: 906b000f */ lbu $t3,0xf($v1) /* 10260: 0c004fc1 */ jal sprintf /* 10264: afab004c */ sw $t3,0x4c($sp) -/* 10268: 0c003074 */ jal func0000c1d0nb +/* 10268: 0c003074 */ jal crashSetMessage /* 1026c: 27a40070 */ addiu $a0,$sp,0x70 /* 10270: 240c0045 */ addiu $t4,$zero,0x45 /* 10274: a00c0000 */ sb $t4,0x0($zero) @@ -3493,7 +3493,7 @@ glabel sndTick /* 104d0: 24a55190 */ addiu $a1,$a1,0x5190 /* 104d4: 10400005 */ beqz $v0,.NB000104ec /* 104d8: 3c047005 */ lui $a0,0x7005 -/* 104dc: 0c003074 */ jal func0000c1d0nb +/* 104dc: 0c003074 */ jal crashSetMessage /* 104e0: 248452b0 */ addiu $a0,$a0,0x52b0 /* 104e4: 24190045 */ addiu $t9,$zero,0x45 /* 104e8: a0190000 */ sb $t9,0x0($zero) diff --git a/src/lib/vm.c b/src/lib/vm.c index bfbeceba1..06181f7e8 100644 --- a/src/lib/vm.c +++ b/src/lib/vm.c @@ -573,7 +573,7 @@ glabel vmInit /* 758c: 920d000f */ lbu $t5,0xf($s0) /* 7590: 0c004fc1 */ jal sprintf /* 7594: afad004c */ sw $t5,0x4c($sp) -/* 7598: 0c003074 */ jal func0000c1d0nb +/* 7598: 0c003074 */ jal crashSetMessage /* 759c: 02c02025 */ or $a0,$s6,$zero /* 75a0: 240e0045 */ addiu $t6,$zero,0x45 /* 75a4: a00e0000 */ sb $t6,0x0($zero)