From ad9381adf725b72dc0843f2717e22bb93df4c755 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Tue, 19 Jan 2016 16:31:21 -0800 Subject: [PATCH] finish beta quest basics, ready to shuffle --- Lua/inject/beta.asm | 69 ++++++++++++ Lua/inject/entrances.asm | 233 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 302 insertions(+) create mode 100644 Lua/inject/entrances.asm diff --git a/Lua/inject/beta.asm b/Lua/inject/beta.asm index 0efcba5..3cd8887 100644 --- a/Lua/inject/beta.asm +++ b/Lua/inject/beta.asm @@ -33,9 +33,20 @@ short term: actually begin shuffling entrances/exits long term: + fix grottos + make bombers' code etc. a function of the filename (if it isn't already) skip giants cutscenes; give oath when any mask is acquired */ +/* notes: +8016A708 breakpoint hit for reading entrance mod (gets summed immediately after) +then calls 80132338 -> 801322C0 +same thing for calling 80132374 + +80132338 calls 801322C0 and returns the scene number +801322C0 returns the entrance value in V0 (and the pointer to it in V1) +*/ + .word 0xDEADBEEF // debugging stuff whatever: @@ -133,6 +144,64 @@ load_hook: sw v0, hash jpop 4, s0, s1, ra +prng: + // just a reimplementation of the PRNG the game uses. + // it's from Numerical Recipes in C, by the way. + // random = random*0x19660D + 0x3C6EF35F; + lw t0, rng_last + li t1, 0x19660D + multu t0, t1 + li t2, 0x3C6EF35F + mflo t3 + addu v0, t3, t2 + sw v0, rng_last + jr + nop + +rng_last: + .word 0 + +.include "entrances.asm" + +shuffle_exit: + // a0: exit value + // v0: shuffled exit value + push 4, ra + mov v0, a0 + li t0, @entries + li t1, 0 + lw t2, crc32 + sw t2, rng_last + la t3, shuffles + mov t4, t3 +-: + lhu t5, (t4) + beq a0, t5, + + nop + addi t1, t1, 1 + beq t1, t0, shuffle_exit_return + nop + b - + addi t4, t4, 4 // 2*sizeof(halfword) ++: + lhu v0, 2(t4) +shuffle_exit_return: + jpop 4, ra + +shuffle_hook: + push 4, ra + jal shuffle_exit + nop + mov a0, v0 + pop 4, ra + j shuffle_hook_return + sw a0, 0(sp) // original code + +.org 0x801322C0 + j shuffle_hook + andi a0, a0, 0xFFFF // original code +shuffle_hook_return: + .org @starting_exit li t8, 0xD800 li t4, 0xD800 diff --git a/Lua/inject/entrances.asm b/Lua/inject/entrances.asm new file mode 100644 index 0000000..77d6373 --- /dev/null +++ b/Lua/inject/entrances.asm @@ -0,0 +1,233 @@ +[entries]: 228 +shuffles: +// format: from, to +// "to" gets filled in when the file is loaded +.half 0x0400, 0 +.half 0x0800, 0 +.half 0x0E00, 0 +.half 0x0E10, 0 +.half 0x1500, 0 +.half 0x1C00, 0 +.half 0x2000, 0 +.half 0x2010, 0 +.half 0x2020, 0 +.half 0x2030, 0 +.half 0x2050, 0 +.half 0x2060, 0 +.half 0x20B0, 0 +.half 0x20C0, 0 +.half 0x20D0, 0 +.half 0x20E0, 0 +.half 0x2200, 0 +.half 0x2210, 0 +.half 0x2220, 0 +.half 0x2230, 0 +.half 0x2240, 0 +.half 0x2260, 0 +.half 0x2270, 0 +.half 0x22A0, 0 +.half 0x22C0, 0 +.half 0x2400, 0 +.half 0x2600, 0 +.half 0x2800, 0 +.half 0x2A00, 0 +.half 0x2E10, 0 +.half 0x3200, 0 +.half 0x3210, 0 +.half 0x3400, 0 +.half 0x3410, 0 +.half 0x3420, 0 +.half 0x3430, 0 +.half 0x3440, 0 +.half 0x3450, 0 +.half 0x3460, 0 +.half 0x3600, 0 +.half 0x3A00, 0 +.half 0x3C00, 0 +.half 0x3E00, 0 +.half 0x3E20, 0 +.half 0x3E30, 0 +.half 0x4000, 0 +.half 0x4010, 0 +.half 0x4020, 0 +.half 0x4030, 0 +.half 0x4050, 0 +.half 0x4060, 0 +.half 0x4080, 0 +.half 0x4090, 0 +.half 0x40A0, 0 +.half 0x4200, 0 +.half 0x4400, 0 +.half 0x4410, 0 +.half 0x4600, 0 +.half 0x4610, 0 +.half 0x4620, 0 +.half 0x4630, 0 +.half 0x4640, 0 +.half 0x4800, 0 +.half 0x4A00, 0 +.half 0x4C00, 0 +.half 0x4C10, 0 +.half 0x4C20, 0 +.half 0x5000, 0 +.half 0x5010, 0 +.half 0x5020, 0 +.half 0x5030, 0 +.half 0x5040, 0 +.half 0x5050, 0 +.half 0x5200, 0 +.half 0x5400, 0 +.half 0x5410, 0 +.half 0x5420, 0 +.half 0x5430, 0 +.half 0x5440, 0 +.half 0x5450, 0 +.half 0x5460, 0 +.half 0x5470, 0 +.half 0x5480, 0 +.half 0x5490, 0 +.half 0x54A0, 0 +.half 0x5600, 0 +.half 0x5800, 0 +.half 0x5E00, 0 +.half 0x5E10, 0 +.half 0x6000, 0 +.half 0x6010, 0 +.half 0x6020, 0 +.half 0x6030, 0 +.half 0x6040, 0 +.half 0x6050, 0 +.half 0x6060, 0 +.half 0x6200, 0 +.half 0x6400, 0 +.half 0x6800, 0 +.half 0x6810, 0 +.half 0x6820, 0 +.half 0x6830, 0 +.half 0x6840, 0 +.half 0x6850, 0 +.half 0x6860, 0 +.half 0x6870, 0 +.half 0x6880, 0 +.half 0x68C0, 0 +.half 0x6A00, 0 +.half 0x6A10, 0 +.half 0x6A20, 0 +.half 0x6A30, 0 +.half 0x6A40, 0 +.half 0x6A50, 0 +.half 0x6C00, 0 +.half 0x7000, 0 +.half 0x7010, 0 +.half 0x7020, 0 +.half 0x7030, 0 +.half 0x7040, 0 +.half 0x7050, 0 +.half 0x7060, 0 +.half 0x7200, 0 +.half 0x7400, 0 +.half 0x7600, 0 +.half 0x7610, 0 +.half 0x7A00, 0 +.half 0x7A10, 0 +.half 0x7A20, 0 +.half 0x8000, 0 +.half 0x8400, 0 +.half 0x8410, 0 +.half 0x8420, 0 +.half 0x8430, 0 +.half 0x8440, 0 +.half 0x8450, 0 +.half 0x8460, 0 +.half 0x8470, 0 +.half 0x8480, 0 +.half 0x8490, 0 +.half 0x8600, 0 +.half 0x8620, 0 +.half 0x8E00, 0 +.half 0x9000, 0 +.half 0x9010, 0 +.half 0x9200, 0 +.half 0x9210, 0 +.half 0x9220, 0 +.half 0x9230, 0 +.half 0x9250, 0 +.half 0x9400, 0 +.half 0x9420, 0 +.half 0x9430, 0 +.half 0x9600, 0 +.half 0x9800, 0 +.half 0x9A10, 0 +.half 0x9A20, 0 +.half 0x9A30, 0 +.half 0x9A40, 0 +.half 0x9A60, 0 +.half 0x9C00, 0 +.half 0x9E00, 0 +.half 0xA000, 0 +.half 0xA010, 0 +.half 0xA020, 0 +.half 0xA200, 0 +.half 0xA400, 0 +.half 0xA600, 0 +.half 0xA800, 0 +.half 0xA810, 0 +.half 0xAA00, 0 +.half 0xAA10, 0 +.half 0xAA20, 0 +.half 0xAC00, 0 +.half 0xAC10, 0 +.half 0xB000, 0 +.half 0xB010, 0 +.half 0xB200, 0 +.half 0xB210, 0 +.half 0xB220, 0 +.half 0xB400, 0 +.half 0xB410, 0 +.half 0xB420, 0 +.half 0xBA00, 0 +.half 0xBC00, 0 +.half 0xBC10, 0 +.half 0xC000, 0 +.half 0xC010, 0 +.half 0xC200, 0 +.half 0xCA00, 0 +.half 0xCE00, 0 +.half 0xCE30, 0 +.half 0xD000, 0 +.half 0xD200, 0 +.half 0xD210, 0 +.half 0xD220, 0 +.half 0xD230, 0 +.half 0xD240, 0 +.half 0xD250, 0 +.half 0xD260, 0 +.half 0xD270, 0 +.half 0xD280, 0 +.half 0xD290, 0 +.half 0xD2A0, 0 +.half 0xD2B0, 0 +.half 0xD400, 0 +.half 0xD410, 0 +.half 0xD420, 0 +.half 0xD430, 0 +.half 0xD440, 0 +.half 0xD450, 0 +.half 0xD460, 0 +.half 0xD470, 0 +.half 0xD480, 0 +.half 0xD600, 0 +.half 0xD610, 0 +.half 0xD620, 0 +.half 0xD630, 0 +.half 0xD640, 0 +.half 0xD800, 0 +.half 0xD810, 0 +.half 0xD820, 0 +.half 0xD840, 0 +.half 0xD850, 0 +.half 0xD860, 0 +.half 0xD870, 0 +.half 0xDA00, 0 +.half 0xDA10, 0 +.align