From 1fc77b93ada5b5d1067d649a44b3c6713ea3a24e Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Mon, 4 Apr 2016 07:35:17 -0700 Subject: [PATCH] use a cleaner method of loading extra file --- patch/code.asm | 23 +++++++++++++++++++++-- patch/extra.asm | 6 +++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/patch/code.asm b/patch/code.asm index 049434a..25ac5b2 100644 --- a/patch/code.asm +++ b/patch/code.asm @@ -5,10 +5,26 @@ ; 0x8016A2C8 -> 0xC4808 ; 0x8016A2C8 - 0xC4808 = 0x800A5AC0 - ; 0x8016AC0C - 0x8016A2C8 = 0x944 -.org 0xC4808 +.org 0xCEDE0 ; 0x801748A0 + ; 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 doing this in OoT first. + addiu sp, sp, 0xFCC0 ; original code + ; push removed here + li s0, 0x801BD910 ; original code + ; pushes removed here + ; 6 instructions to work with + li a1, @vstart ; 2 + li a2, @size ; 2 + jal @DMARomToRam ; 1 + li a0, @start ; 1 (just make sure @start can be a LUI!) + +.org 0xC4808 ; 0x8016A2C8 +/* ; if we've already loaded once, don't load again lbu t0, @start ; 2 bnez t0, + ; 1 @@ -28,6 +44,9 @@ ; and is moved into our extra file. ; we have (0x944 / 4 - 23) = 570 words of space here, should we need it. .word 0xDEADBEEF +*/ + j @dma_hook ; 1 + nop ; 1 .org 0x9F9A4 ; JR of starting_exit's function j @load_hook ; tail call diff --git a/patch/extra.asm b/patch/extra.asm index fa54905..bcaa8e3 100644 --- a/patch/extra.asm +++ b/patch/extra.asm @@ -26,9 +26,9 @@ dma_hook: jal setup_hook nop pop 4, 1, ra - -; original code (includes jr) -.include "setup.asm" + addiu sp, sp, 0xFF58 ; original code + j 0x8016A2D0 ; return to scene setup function + sw s1, 0x30(sp) ; original code set_scene_flag: ; a0: scene number