From f2a291c6cdc5fbad25e4067a94d030add8dba357 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 15 Apr 2016 12:17:46 -0700 Subject: [PATCH] add ROM version of spawner for OoT debug --- Lua/inject/spawn.asm | 2 +- patch/dma O EUDB MQ.asm | 41 ++++++++++++++++++++++++++++ patch/mm-bq | 6 ++--- patch/oot-widescreen | 4 +-- patch/spawn O EUDB MQ.asm | 54 +++++++++++++++++++++++++++++++++++++ patch/widescreen-inline.asm | 42 +---------------------------- 6 files changed, 101 insertions(+), 48 deletions(-) create mode 100644 patch/dma O EUDB MQ.asm create mode 100644 patch/spawn O EUDB MQ.asm diff --git a/Lua/inject/spawn.asm b/Lua/inject/spawn.asm index f59e580..6c9c009 100644 --- a/Lua/inject/spawn.asm +++ b/Lua/inject/spawn.asm @@ -6,8 +6,8 @@ [hold_delay_amount]: 3 +spawn: push 4, s0, s1, s2, s3, s4, ra, - li t0, @link_save li t1, @global_context lhu s0, anum lw s1, hold_delay diff --git a/patch/dma O EUDB MQ.asm b/patch/dma O EUDB MQ.asm new file mode 100644 index 0000000..3bb6518 --- /dev/null +++ b/patch/dma O EUDB MQ.asm @@ -0,0 +1,41 @@ +[DMARomToRam]: 0x80000BFC + +[vstart]: 0x035D0000 +[start]: 0x80700000 +[size]: 0x10000 + +/* +.org 0x18F30 +; add an entry to the end of dmatable to hold our extra code +; this actually just crashes the game so don't bother +; (no debug filename associated with it = bad pointer dereference? maybe?) + .word @vstart ; virtual start + .word 0x035E0000 ; virtual end (@vstart + @size) + .word @vstart ; physical start (should be same as virtual start) + .word 0 ; physical end (should be 0 for uncompressed) +*/ + +.org 0xB3D9E4 ; 0x800C6844 + ; this appears to be the main game loop function + ; we can "make room" for some injected code + ; by taking advantage of it never returning under normal circumstances. + ; we'll cut out pushing RA, S1-S8 stuff on stack. + ; props to CloudMax for coming up with this. + addiu sp, sp, 0xFC60 ; original code + ; push removed here + li s0, 0x8011F830 ; original code + ; pushes removed here + ; 9 instructions to work with? + ; dma args are backwards compared to MM? + li a1, @start + li a2, @size + jal @DMARomToRam + li a0, @vstart + lui a0 0x8014 ; original code + cl a1 + cl a2 + nop + nop + nop + nop + nop diff --git a/patch/mm-bq b/patch/mm-bq index 551725f..bcd966d 100755 --- a/patch/mm-bq +++ b/patch/mm-bq @@ -56,10 +56,8 @@ unc "$code" mkdir -p lips cp ../"$lips"/* lips -cp ../"$inject/"{crc32,entrances}.asm . -cp ../extra.asm . -cp ../common.asm . -cp ../code.asm . +cp ../"$inject"/*.asm . +cp ../*.asm . dd if=/dev/zero of=extra bs=370688 count=1 2>/dev/null diff --git a/patch/oot-widescreen b/patch/oot-widescreen index 48684fb..356deb2 100755 --- a/patch/oot-widescreen +++ b/patch/oot-widescreen @@ -16,8 +16,8 @@ cp ../../"$rom" "$out" mkdir -p lips cp ../"$lips"/* lips -cp ../"$inject/"widescreen-either.asm . -cp ../widescreen-inline.asm . +cp ../"$inject/"*.asm . +cp ../*.asm . luajit patch.lua -o 0 \ --extra-rom 0x035D0000 --extra-ram 0x80700000 \ diff --git a/patch/spawn O EUDB MQ.asm b/patch/spawn O EUDB MQ.asm new file mode 100644 index 0000000..e3dd766 --- /dev/null +++ b/patch/spawn O EUDB MQ.asm @@ -0,0 +1,54 @@ +.include "dma O EUDB MQ.asm" + +[original]: 0x800C6AC4 +[inject_from]: 0xB3D458 ; 0x800C62B8 +[inject_to]: 0x80700000 + +.org @inject_from + jal @inject_to + +.org @inject_to + sw ra, -4(sp) + sw a0, 0(sp) + sw a1, 4(sp) + sw a2, 8(sp) + sw a3, 12(sp) + bal spawn + subi sp, sp, 24 + lw ra, 20(sp) + lw a0, 24(sp) + lw a1, 28(sp) + lw a2, 32(sp) + lw a3, 36(sp) + j @original + addi sp, sp, 24 + +[actor_spawn]: 0x80031F50 +[object_spawn]: 0x80097C00 +[object_index]: 0xAF246C ; 0x8009812C + +[max_actor_no]: 0x1D6 + +[global_context]: 0x80212020 + [buttons_offset]: 0x14 + [actor_spawn_offset]: 0x1C24 + [object_spawn_offset]: 0x117A4 + +[link_actor]: 0x802245B0 + [actor_x]: 0x24 + [actor_y]: 0x28 + [actor_z]: 0x2C + [actor_horiz_angle]: 0x46 + +// offset from first pointer in global context +[dlist_offset]: 0x2B0 + +[SetTextRGBA]: 0x800FB3AC +[SetTextXY]: 0x800FB41C +[SetTextString]: 0x800FBCB4 +[TxtPrinter]: 0x800FBB60 +[InitTxtStruct]: 0x800FBB8C // unused here; we set it up inline +[DoTxtStruct]: 0x800FBC1C +[UpdateTxtStruct]: 0x800FBC64 + +.include "spawn.asm" diff --git a/patch/widescreen-inline.asm b/patch/widescreen-inline.asm index 7c6659f..1298151 100644 --- a/patch/widescreen-inline.asm +++ b/patch/widescreen-inline.asm @@ -6,47 +6,7 @@ [ctxt]: 0x80212020 [dlists]: 0x80168930 -[DMARomToRam]: 0x80000BFC - -[vstart]: 0x035D0000 -[start]: 0x80700000 -[size]: 0x10000 - -/* -.org 0x18F30 -; add an entry to the end of dmatable to hold our extra code -; this actually just crashes the game so don't bother -; (no debug filename associated with it = bad pointer dereference? maybe?) - .word @vstart ; virtual start - .word 0x035E0000 ; virtual end (@vstart + @size) - .word @vstart ; physical start (should be same as virtual start) - .word 0 ; physical end (should be 0 for uncompressed) -*/ - -.org 0xB3D9E4 ; 0x800C6844 - ; this appears to be the main game loop function - ; we can "make room" for some injected code - ; by taking advantage of it never returning under normal circumstances. - ; we'll cut out pushing RA, S1-S8 stuff on stack. - ; props to CloudMax for coming up with this. - addiu sp, sp, 0xFC60 ; original code - ; push removed here - li s0, 0x8011F830 ; original code - ; pushes removed here - ; 9 instructions to work with? - ; dma args are backwards compared to MM? - li a1, @start - li a2, @size - jal @DMARomToRam - li a0, @vstart - lui a0 0x8014 ; original code - cl a1 - cl a2 - nop - nop - nop - nop - nop +.include "dma O EUDB MQ.asm" [original]: 0x800C6AC4 [inject_from]: 0xB3D458 ; 0x800C62B8