mirror of
https://github.com/notwa/mm
synced 2025-02-05 13:23:23 -08:00
add basic exit shuffling
This commit is contained in:
parent
4faf79f891
commit
c6eba55171
1 changed files with 52 additions and 16 deletions
|
@ -16,24 +16,22 @@
|
||||||
|
|
||||||
[link_object_ptr]: 0x803FFFF4
|
[link_object_ptr]: 0x803FFFF4
|
||||||
|
|
||||||
/*
|
|
||||||
push 4, ra
|
|
||||||
li a0, 0x0063 // inside clock tower
|
|
||||||
li a1, 1 // second word
|
|
||||||
li a2, 0 // first bit ("You've met with a terrible fate")
|
|
||||||
jal set_scene_flag
|
|
||||||
nop
|
|
||||||
jpop 4, ra
|
|
||||||
*/
|
|
||||||
jr
|
jr
|
||||||
nop
|
nop
|
||||||
|
|
||||||
/* TODO:
|
/* TODO:
|
||||||
short term:
|
short term:
|
||||||
actually begin shuffling entrances/exits
|
set first SoT cutscene as watched already
|
||||||
|
shuffle owl loads
|
||||||
|
shuffle owl warps
|
||||||
|
go to poisoned or clean swamp depending on boss defeated status
|
||||||
|
go to frozen or spring mountain depending on boss defeated status
|
||||||
|
don't shuffle if cutscene mod is set
|
||||||
|
fix death warps so they won't spawn you out of bounds
|
||||||
|
|
||||||
long term:
|
long term:
|
||||||
fix grottos
|
add/fix generic grottos
|
||||||
|
make death warps work like in mzx's hack
|
||||||
make bombers' code etc. a function of the filename (if it isn't already)
|
make bombers' code etc. a function of the filename (if it isn't already)
|
||||||
skip giants cutscenes; give oath when any mask is acquired
|
skip giants cutscenes; give oath when any mask is acquired
|
||||||
*/
|
*/
|
||||||
|
@ -59,6 +57,7 @@ tunic_color:
|
||||||
.word 0xFFFFFFFF
|
.word 0xFFFFFFFF
|
||||||
|
|
||||||
.include "crc32.asm"
|
.include "crc32.asm"
|
||||||
|
.include "entrances.asm"
|
||||||
|
|
||||||
set_scene_flag:
|
set_scene_flag:
|
||||||
// a0: scene number
|
// a0: scene number
|
||||||
|
@ -142,26 +141,63 @@ load_hook:
|
||||||
li a1, 8
|
li a1, 8
|
||||||
not v0, v0
|
not v0, v0
|
||||||
sw v0, hash
|
sw v0, hash
|
||||||
|
sw v0, rng_seed
|
||||||
|
jal shuffle_all
|
||||||
|
nop
|
||||||
jpop 4, s0, s1, ra
|
jpop 4, s0, s1, ra
|
||||||
|
|
||||||
prng:
|
prng:
|
||||||
// just a reimplementation of the PRNG the game uses.
|
// just a reimplementation of the PRNG the game uses.
|
||||||
// it's from Numerical Recipes in C, by the way.
|
// it's from Numerical Recipes in C, by the way.
|
||||||
// random = random*0x19660D + 0x3C6EF35F;
|
// random = random*0x19660D + 0x3C6EF35F;
|
||||||
lw t0, rng_last
|
lw t0, rng_seed
|
||||||
li t1, 0x19660D
|
li t1, 0x19660D
|
||||||
multu t0, t1
|
multu t0, t1
|
||||||
li t2, 0x3C6EF35F
|
li t2, 0x3C6EF35F
|
||||||
mflo t3
|
mflo t3
|
||||||
addu v0, t3, t2
|
addu v0, t3, t2
|
||||||
sw v0, rng_last
|
sw v0, rng_seed
|
||||||
jr
|
jr
|
||||||
nop
|
nop
|
||||||
|
|
||||||
rng_last:
|
rng_seed:
|
||||||
.word 0
|
.word 0
|
||||||
|
|
||||||
.include "entrances.asm"
|
randint:
|
||||||
|
// v0 = random integer from 0 to a0; a0 >= 0
|
||||||
|
push 4, s0, ra, 1
|
||||||
|
jal prng
|
||||||
|
addi s0, a0, 1
|
||||||
|
divu v0, s0
|
||||||
|
mfhi v0
|
||||||
|
jpop 4, s0, ra, 1
|
||||||
|
|
||||||
|
shuffle_all:
|
||||||
|
push 4, s0, s1, s2, ra
|
||||||
|
// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_.22inside-out.22_algorithm
|
||||||
|
li s0, 0
|
||||||
|
li s1, @entries
|
||||||
|
la s2, shuffles
|
||||||
|
-:
|
||||||
|
jal randint
|
||||||
|
mov a0, s0
|
||||||
|
// s0 is i, v0 is j
|
||||||
|
sll t0, s0, 2 // 1<<2 == 2*sizeof(half)
|
||||||
|
sll t1, v0, 2 // likewise
|
||||||
|
addu t0, s2, t0 // [i]
|
||||||
|
addu t1, s2, t1 // [j]
|
||||||
|
// a[i] = a[j]
|
||||||
|
lhu t3, 2(t1)
|
||||||
|
sh t3, 2(t0)
|
||||||
|
// a[j] = source[i]
|
||||||
|
lhu t4, 0(t0)
|
||||||
|
sh t4, 2(t1)
|
||||||
|
// iterate
|
||||||
|
addi s0, s0, 1
|
||||||
|
bne s0, s1, -
|
||||||
|
nop
|
||||||
|
+:
|
||||||
|
jpop 4, s0, s1, s2, ra
|
||||||
|
|
||||||
shuffle_exit:
|
shuffle_exit:
|
||||||
// a0: exit value
|
// a0: exit value
|
||||||
|
@ -171,7 +207,7 @@ shuffle_exit:
|
||||||
li t0, @entries
|
li t0, @entries
|
||||||
li t1, 0
|
li t1, 0
|
||||||
lw t2, crc32
|
lw t2, crc32
|
||||||
sw t2, rng_last
|
sw t2, rng_seed
|
||||||
la t3, shuffles
|
la t3, shuffles
|
||||||
mov t4, t3
|
mov t4, t3
|
||||||
-:
|
-:
|
||||||
|
|
Loading…
Add table
Reference in a new issue