You've already forked ultrasm64-2
mirror of
https://github.com/HackerN64/ultrasm64-2.git
synced 2026-01-21 10:38:08 -08:00
Refresh 10
This commit is contained in:
@@ -1,42 +1,36 @@
|
||||
diff --git a/asm/crash.s b/asm/crash.s
|
||||
new file mode 100644
|
||||
index 00000000..870b7e2c
|
||||
index 00000000..7c272050
|
||||
--- /dev/null
|
||||
+++ b/asm/crash.s
|
||||
@@ -0,0 +1,160 @@
|
||||
@@ -0,0 +1,153 @@
|
||||
+# SM64 Crash Handler
|
||||
+# See Readme below.
|
||||
+
|
||||
+.include "macros.inc"
|
||||
+
|
||||
+.set COP0_CAUSE, 13
|
||||
+.set COP0_EPC, 14
|
||||
+.set COP0_BADVADDR, 8
|
||||
+
|
||||
+/* ---------------------------------------------------------------
|
||||
+ * IMPORTANT README:
|
||||
+ * ---------------------------------------------------------------
|
||||
+ * To use this crash screen, in lib/__osExceptionPreamble.s, change
|
||||
+ * the function to use the following assembly:
|
||||
+ * Frame buffer emulation is required. To enable it in GlideN64,
|
||||
+ * check "Emulate frame buffer" and "Render frame buffer to output"
|
||||
+ * in the "Frame buffer" tab.
|
||||
+ *
|
||||
+ * lui $k0, %hi(__crash_handler_entry)
|
||||
+ * addiu $k0, $k0, %lo(__crash_handler_entry)
|
||||
+ * jr $k0
|
||||
+ * nop
|
||||
+ *
|
||||
+ * Doing just a jal __crash_handler_entry will cause mupen recompiler
|
||||
+ * errors, so be sure to use the original exception style assembly
|
||||
+ * above!
|
||||
+ *
|
||||
+ * Be sure to add #include "../../enhancements/crash.inc.c" to
|
||||
+ * the top of game.c. Add .include "../enhancements/crash.inc.s" to
|
||||
+ * the bottom of asm/decompress.s. Add "../enhancements/crash.h" to
|
||||
+ * the top of sm64.h, above the CRASH_SCREEN_INCLUDED condition.
|
||||
+ * Your emulator's CPU core style should be set to interpreter for best results.
|
||||
+ *
|
||||
+ * See the DEBUG_ASSERT macro on how to call the crash screen for
|
||||
+ * detected exceptions.
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+.set noat
|
||||
+.set noreorder
|
||||
+.set gp=64
|
||||
+
|
||||
+.set COP0_CAUSE, $13
|
||||
+.set COP0_EPC, $14
|
||||
+.set COP0_BADVADDR, $8
|
||||
+
|
||||
+glabel crashFont
|
||||
+ .incbin "enhancements/crash_font.bin"
|
||||
+ .align 4
|
||||
@@ -63,23 +57,23 @@ index 00000000..870b7e2c
|
||||
+ lui $at, %hi(nAssertStopProgram)
|
||||
+ sw $a3, %lo(nAssertStopProgram)($at)
|
||||
+ beqz $a3, .end_2
|
||||
+ nop
|
||||
+ nop
|
||||
+ syscall # trigger crash screen
|
||||
+.end_2:
|
||||
+ jr $ra
|
||||
+ nop
|
||||
+ nop
|
||||
+
|
||||
+glabel cop0_get_cause
|
||||
+ jr $ra
|
||||
+ mfc0 $v0, $13 # COP0_CAUSE
|
||||
+ mfc0 $v0, COP0_CAUSE
|
||||
+
|
||||
+glabel cop0_get_epc
|
||||
+ jr $ra
|
||||
+ mfc0 $v0, $14 # COP0_EPC
|
||||
+ mfc0 $v0, COP0_EPC
|
||||
+
|
||||
+glabel cop0_get_badvaddr
|
||||
+ jr $ra
|
||||
+ mfc0 $v0, $8 # COP0_BADVADDR
|
||||
+ mfc0 $v0, COP0_BADVADDR
|
||||
+
|
||||
+# If the error code field of cop0's cause register is non-zero,
|
||||
+# draw crash details to the screen and hang
|
||||
@@ -87,6 +81,10 @@ index 00000000..870b7e2c
|
||||
+# If there wasn't an error, continue to the original handler
|
||||
+
|
||||
+glabel __crash_handler_entry
|
||||
+ mfc0 $k1, COP0_CAUSE
|
||||
+ andi $k1, $k1, (0x1F << 2)
|
||||
+ beqzl $k1, .end2 # exit if ExCode is 0
|
||||
+ lui $k0, %hi(__osException)
|
||||
+ la $k0, exceptionRegContext
|
||||
+ sd $zero, 0x018 ($k0)
|
||||
+ sd $at, 0x020 ($k0)
|
||||
@@ -116,21 +114,15 @@ index 00000000..870b7e2c
|
||||
+ sd $t9, 0x0E0 ($k0)
|
||||
+ sd $gp, 0x0E8 ($k0)
|
||||
+ sd $sp, 0x0F0 ($k0)
|
||||
+ sd $s8, 0x0F8 ($k0)
|
||||
+ sd $fp, 0x0F8 ($k0)
|
||||
+ sd $ra, 0x100 ($k0)
|
||||
+ mfc0 $t0, $13 # COP0_CAUSE
|
||||
+ srl $t0, $t0, 2
|
||||
+ andi $t0, $t0, 0x1F
|
||||
+ beqz $t0, .end
|
||||
+ nop
|
||||
+ # cop unusable exception fired twice on startup so we'll ignore it for now
|
||||
+ li $at, 0x0B
|
||||
+ beq $t0, $at, .end
|
||||
+ nop
|
||||
+ li $t0, (0x0B << 2)
|
||||
+ beq $k1, $t0, .end
|
||||
+ nop
|
||||
+ jal show_crash_screen_and_hang
|
||||
+ nop
|
||||
+ nop
|
||||
+ .end:
|
||||
+ ld $zero, 0x018 ($k0)
|
||||
+ ld $at, 0x020 ($k0)
|
||||
+ ld $v0, 0x028 ($k0)
|
||||
+ ld $v1, 0x030 ($k0)
|
||||
@@ -158,36 +150,33 @@ index 00000000..870b7e2c
|
||||
+ ld $t9, 0x0E0 ($k0)
|
||||
+ ld $gp, 0x0E8 ($k0)
|
||||
+ ld $sp, 0x0F0 ($k0)
|
||||
+ ld $s8, 0x0F8 ($k0)
|
||||
+ ld $fp, 0x0F8 ($k0)
|
||||
+ ld $ra, 0x100 ($k0)
|
||||
+ lui $k0, %hi(__osException)
|
||||
+ .end2:
|
||||
+ addiu $k0, $k0, %lo(__osException)
|
||||
+ jr $k0 # run the original handler
|
||||
+ nop
|
||||
+ nop
|
||||
diff --git a/lib/asm/__osExceptionPreamble.s b/lib/asm/__osExceptionPreamble.s
|
||||
index fdc36c8b..ccbf4ecc 100644
|
||||
index 865273d9..f9ce7596 100644
|
||||
--- a/lib/asm/__osExceptionPreamble.s
|
||||
+++ b/lib/asm/__osExceptionPreamble.s
|
||||
@@ -8,12 +8,11 @@
|
||||
.section .text, "ax"
|
||||
@@ -15,8 +15,8 @@
|
||||
.endif
|
||||
|
||||
glabel __osExceptionPreamble
|
||||
- lui $k0, %hi(__osException) # $k0, 0x8032
|
||||
- addiu $k0, %lo(__osException) # addiu $k0, $k0, 0x66d0
|
||||
+ lui $k0, %hi(__crash_handler_entry) # $k0, 0x8032
|
||||
+ addiu $k0, %lo(__crash_handler_entry) # addiu $k0, $k0, 0x66d0
|
||||
- lui $k0, %hi(__osException)
|
||||
- addiu $k0, %lo(__osException)
|
||||
+ lui $k0, %hi(__crash_handler_entry)
|
||||
+ addiu $k0, %lo(__crash_handler_entry)
|
||||
jr $k0
|
||||
nop
|
||||
|
||||
-
|
||||
glabel __osException
|
||||
lui $k0, %hi(gInterruptedThread) # $k0, 0x8036
|
||||
addiu $k0, %lo(gInterruptedThread) # addiu $k0, $k0, 0x5f40
|
||||
diff --git a/sm64.ld b/sm64.ld
|
||||
index dea5c8bd..22fff2d8 100755
|
||||
index e6f5c942..c0feb343
|
||||
--- a/sm64.ld
|
||||
+++ b/sm64.ld
|
||||
@@ -112,6 +112,7 @@ SECTIONS
|
||||
@@ -116,6 +116,7 @@ SECTIONS
|
||||
BUILD_DIR/src/game/rendering_graph_node.o(.text);
|
||||
BUILD_DIR/src/game/profiler.o(.text);
|
||||
BUILD_DIR/asm/decompress.o(.text);
|
||||
@@ -197,10 +186,10 @@ index dea5c8bd..22fff2d8 100755
|
||||
BUILD_DIR/src/game/object_list_processor.o(.text);
|
||||
diff --git a/src/game/crash.c b/src/game/crash.c
|
||||
new file mode 100644
|
||||
index 00000000..587ac86d
|
||||
index 00000000..716adfbd
|
||||
--- /dev/null
|
||||
+++ b/src/game/crash.c
|
||||
@@ -0,0 +1,291 @@
|
||||
@@ -0,0 +1,260 @@
|
||||
+/* SM64 Crash Handler */
|
||||
+
|
||||
+#include <sm64.h>
|
||||
@@ -246,37 +235,6 @@ index 00000000..587ac86d
|
||||
+ "S5", "S6", "S7", "T8", "T9", /*"K0", "K1",*/
|
||||
+ "GP", "SP", "FP", "RA", NULL };
|
||||
+
|
||||
+/*
|
||||
+ Generates new preamble code at the exception vectors (0x000, 0x180)
|
||||
+
|
||||
+ eg: generate_exception_preambles(crash_handler_entry);
|
||||
+
|
||||
+ 000: lui k0, hi(crash_handler_entry)
|
||||
+ 004: addiu k0, k0, lo(crash_handler_entry)
|
||||
+ 008: jr k0
|
||||
+ 00C: nop
|
||||
+*/
|
||||
+void generate_exception_preambles(void *entryPoint) {
|
||||
+ u8 *mem = (u8 *) 0xA0000000;
|
||||
+ int offs = 0;
|
||||
+ int i;
|
||||
+
|
||||
+ u16 hi = (u32) entryPoint >> 16;
|
||||
+ u16 lo = (u32) entryPoint & 0xFFFF;
|
||||
+
|
||||
+ if (lo & 0x8000) {
|
||||
+ hi++;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < 2; i++) {
|
||||
+ *(u32 *) &mem[offs + 0x00] = 0x3C1A0000 | hi;
|
||||
+ *(u32 *) &mem[offs + 0x04] = 0x275A0000 | lo;
|
||||
+ *(u32 *) &mem[offs + 0x08] = 0x03400008;
|
||||
+ *(u32 *) &mem[offs + 0x0C] = 0x00000000;
|
||||
+ offs += 0x180;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int crash_strlen(char *str) {
|
||||
+ int len = 0;
|
||||
+ while (*str++) {
|
||||
@@ -303,7 +261,7 @@ index 00000000..587ac86d
|
||||
+
|
||||
+ fb_print_str(80, 20, "AN ERROR HAS OCCURRED!");
|
||||
+ fb_print_int_hex(80, 30, errno, 8);
|
||||
+ fb_print_str(107, 30, szErrCodes[errno]);
|
||||
+ fb_print_str(95, 30, szErrCodes[errno]);
|
||||
+
|
||||
+ if (errno >= 2 && errno <= 5) {
|
||||
+ /*
|
||||
@@ -314,8 +272,8 @@ index 00000000..587ac86d
|
||||
+ */
|
||||
+ u32 badvaddr = cop0_get_badvaddr();
|
||||
+
|
||||
+ fb_print_str(188, 50, "VA");
|
||||
+ fb_print_int_hex(215, 50, badvaddr, 32);
|
||||
+ fb_print_str(145, 50, "VA");
|
||||
+ fb_print_int_hex(160, 50, badvaddr, 32);
|
||||
+ }
|
||||
+ } else {
|
||||
+ int afterFileX;
|
||||
@@ -385,7 +343,7 @@ index 00000000..587ac86d
|
||||
+ u8 curbyte = in[nbyte];
|
||||
+ for (nrow = 0; nrow < 2; nrow++) {
|
||||
+ for (ncol = 0; ncol < 4; ncol++) {
|
||||
+ u8 px = curbyte & (1 << 7 - (nrow * 4 + ncol));
|
||||
+ u8 px = curbyte & (1 << (7 - (nrow * 4 + ncol)));
|
||||
+ if (px != 0) {
|
||||
+ out[ncol] = fbFillColor;
|
||||
+ }
|
||||
@@ -494,10 +452,10 @@ index 00000000..587ac86d
|
||||
+}
|
||||
diff --git a/src/game/crash.h b/src/game/crash.h
|
||||
new file mode 100644
|
||||
index 00000000..da4e011e
|
||||
index 00000000..1386930d
|
||||
--- /dev/null
|
||||
+++ b/src/game/crash.h
|
||||
@@ -0,0 +1,29 @@
|
||||
@@ -0,0 +1,28 @@
|
||||
+#ifndef _CRASH_H_
|
||||
+#define _CRASH_H_
|
||||
+
|
||||
@@ -513,7 +471,6 @@ index 00000000..da4e011e
|
||||
+
|
||||
+extern u8 __crash_handler_entry[];
|
||||
+
|
||||
+void generate_exception_preambles(void *entryPoint);
|
||||
+void show_crash_screen_and_hang(void);
|
||||
+u8 ascii_to_idx(char c);
|
||||
+void fb_set_address(void *address);
|
||||
|
||||
@@ -108,16 +108,16 @@ index d550b846..bbaf2bcc 100644
|
||||
__osSiRelAccess();
|
||||
return status;
|
||||
diff --git a/lib/src/osEepromRead.c b/lib/src/osEepromRead.c
|
||||
index 905eff74..23f34dd5 100644
|
||||
index ea784b2c..116dae2d 100644
|
||||
--- a/lib/src/osEepromRead.c
|
||||
+++ b/lib/src/osEepromRead.c
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "libultra_internal.h"
|
||||
+#include <PR/console_type.h>
|
||||
|
||||
extern u32 D_80365E00[15];
|
||||
extern u32 D_80365E3C;
|
||||
@@ -44,33 +45,44 @@ s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer) {
|
||||
extern u8 _osLastSentSiCmd;
|
||||
|
||||
@@ -42,33 +43,44 @@ s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer) {
|
||||
return -1;
|
||||
}
|
||||
__osSiGetAccess();
|
||||
@@ -140,7 +140,7 @@ index 905eff74..23f34dd5 100644
|
||||
- }
|
||||
- D_80365E3C = 0;
|
||||
- sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
- D_80365D20 = 4;
|
||||
- _osLastSentSiCmd = 4;
|
||||
- osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
- for (sp30 = 0; sp30 < 4; sp30++) {
|
||||
- sp2c++;
|
||||
@@ -163,7 +163,7 @@ index 905eff74..23f34dd5 100644
|
||||
}
|
||||
+ D_80365E3C = 0;
|
||||
+ sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
+ D_80365D20 = 4;
|
||||
+ _osLastSentSiCmd = 4;
|
||||
+ osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
+ for (sp30 = 0; sp30 < 4; sp30++) {
|
||||
+ sp2c++;
|
||||
@@ -188,7 +188,7 @@ index 905eff74..23f34dd5 100644
|
||||
__osSiRelAccess();
|
||||
return sp34;
|
||||
diff --git a/lib/src/osEepromWrite.c b/lib/src/osEepromWrite.c
|
||||
index 71d0b7d6..c855cc20 100644
|
||||
index 1a86477b..52a23e5e 100644
|
||||
--- a/lib/src/osEepromWrite.c
|
||||
+++ b/lib/src/osEepromWrite.c
|
||||
@@ -1,5 +1,6 @@
|
||||
@@ -196,9 +196,9 @@ index 71d0b7d6..c855cc20 100644
|
||||
#include "osContInternal.h"
|
||||
+#include <PR/console_type.h>
|
||||
|
||||
u32 D_80365E00[0x3c >> 2];
|
||||
u32 D_80365E3C;
|
||||
@@ -46,36 +47,47 @@ s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) {
|
||||
#ifndef AVOID_UB
|
||||
ALIGNED8 u32 D_80365E00[15];
|
||||
@@ -52,36 +53,47 @@ s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) {
|
||||
}
|
||||
|
||||
__osSiGetAccess();
|
||||
@@ -237,11 +237,11 @@ index 71d0b7d6..c855cc20 100644
|
||||
|
||||
- D_80365E3C = 0;
|
||||
- sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
- D_80365D20 = 5;
|
||||
- _osLastSentSiCmd = 5;
|
||||
- osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
+ D_80365E3C = 0;
|
||||
+ sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
|
||||
+ D_80365D20 = 5;
|
||||
+ _osLastSentSiCmd = 5;
|
||||
+ osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
||||
- for (sp30 = 0; sp30 < 4; sp30++) {
|
||||
@@ -269,7 +269,7 @@ index 71d0b7d6..c855cc20 100644
|
||||
return sp34;
|
||||
}
|
||||
diff --git a/lib/src/osInitialize.c b/lib/src/osInitialize.c
|
||||
index 0b9f7128..660d1991 100644
|
||||
index 3cbca8ea..20723b2f 100644
|
||||
--- a/lib/src/osInitialize.c
|
||||
+++ b/lib/src/osInitialize.c
|
||||
@@ -1,6 +1,7 @@
|
||||
@@ -289,19 +289,19 @@ index 0b9f7128..660d1991 100644
|
||||
__osSetSR(__osGetSR() | 0x20000000);
|
||||
__osSetFpcCsr(0x01000800);
|
||||
diff --git a/sm64.ld b/sm64.ld
|
||||
index 59a5a2a6..c8976649 100755
|
||||
index 3275819f..6f97698f 100755
|
||||
--- a/sm64.ld
|
||||
+++ b/sm64.ld
|
||||
@@ -256,6 +256,8 @@ SECTIONS
|
||||
@@ -261,6 +261,8 @@ SECTIONS
|
||||
BUILD_DIR/libultra.a:func_802F7140.o(.text)
|
||||
BUILD_DIR/libultra.a:func_802F71A0.o(.text)
|
||||
BUILD_DIR/libultra.a:func_802F71F0.o(.text)
|
||||
+ BUILD_DIR/libultra.a:consoleType.o(.text)
|
||||
+ BUILD_DIR/libultra.a:skGetId.o(.text)
|
||||
|
||||
BUILD_DIR/lib/rsp.o(.text);
|
||||
|
||||
@@ -369,6 +371,8 @@ SECTIONS
|
||||
#else
|
||||
BUILD_DIR/src/game*.o(.text);
|
||||
@@ -371,6 +373,8 @@ SECTIONS
|
||||
BUILD_DIR/libultra.a:__osGetCause.o(.text);
|
||||
BUILD_DIR/libultra.a:__osAtomicDec.o(.text);
|
||||
BUILD_DIR/libultra.a:guLookAtRef.o(.text); /* Fast3DEX2 only */
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
diff --git a/src/game/game_init.c b/src/game/game_init.c
|
||||
index 0852a141..004941d8 100644
|
||||
index a4302124..5ffbf3ed 100644
|
||||
--- a/src/game/game_init.c
|
||||
+++ b/src/game/game_init.c
|
||||
@@ -332,6 +332,45 @@ void display_and_vsync(void) {
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "game_init.h"
|
||||
#include "main.h"
|
||||
#include "memory.h"
|
||||
+#include "object_list_processor.h"
|
||||
#include "profiler.h"
|
||||
#include "save_file.h"
|
||||
#include "seq_ids.h"
|
||||
@@ -335,6 +336,45 @@ void display_and_vsync(void) {
|
||||
gGlobalTimer++;
|
||||
}
|
||||
|
||||
@@ -48,7 +56,7 @@ index 0852a141..004941d8 100644
|
||||
// this function records distinct inputs over a 255-frame interval to RAM locations and was likely
|
||||
// used to record the demo sequences seen in the final game. This function is unused.
|
||||
static void record_demo(void) {
|
||||
@@ -365,6 +404,118 @@ static void record_demo(void) {
|
||||
@@ -368,6 +408,118 @@ static void record_demo(void) {
|
||||
gRecordedDemoInput.timer++;
|
||||
}
|
||||
|
||||
@@ -167,7 +175,7 @@ index 0852a141..004941d8 100644
|
||||
// take the updated controller struct and calculate
|
||||
// the new x, y, and distance floats.
|
||||
void adjust_analog_stick(struct Controller *controller) {
|
||||
@@ -605,6 +756,7 @@ void thread5_game_loop(UNUSED void *arg) {
|
||||
@@ -623,6 +775,7 @@ void thread5_game_loop(UNUSED void *arg) {
|
||||
audio_game_loop_tick();
|
||||
config_gfx_pool();
|
||||
read_controller_inputs();
|
||||
|
||||
Reference in New Issue
Block a user