mirror of
https://github.com/notwa/mm
synced 2025-02-05 13:23:23 -08:00
use new features again
This commit is contained in:
parent
2edbe2135a
commit
f1ebc3f9ff
11 changed files with 71 additions and 122 deletions
|
@ -206,7 +206,7 @@ load_hook:
|
||||||
sw v0, rng_seed
|
sw v0, rng_seed
|
||||||
jal shuffle_all
|
jal shuffle_all
|
||||||
nop
|
nop
|
||||||
jpop 4, s0, s1, ra, 1
|
ret 4, s0, s1, ra, 1
|
||||||
|
|
||||||
prng:
|
prng:
|
||||||
// just a reimplementation of the PRNG the game uses.
|
// just a reimplementation of the PRNG the game uses.
|
||||||
|
@ -232,7 +232,7 @@ randint:
|
||||||
addi s0, a0, 1
|
addi s0, a0, 1
|
||||||
divu v0, s0
|
divu v0, s0
|
||||||
mfhi v0
|
mfhi v0
|
||||||
jpop 4, s0, ra
|
ret 4, s0, ra
|
||||||
|
|
||||||
shuffle_all:
|
shuffle_all:
|
||||||
push 4, s0, s1, s2, ra
|
push 4, s0, s1, s2, ra
|
||||||
|
@ -259,7 +259,7 @@ shuffle_all:
|
||||||
bne s0, s1, -
|
bne s0, s1, -
|
||||||
nop
|
nop
|
||||||
+:
|
+:
|
||||||
jpop 4, s0, s1, s2, ra
|
ret 4, s0, s1, s2, ra
|
||||||
|
|
||||||
shuffle_get:
|
shuffle_get:
|
||||||
// a0: exit value
|
// a0: exit value
|
||||||
|
@ -282,7 +282,7 @@ shuffle_get:
|
||||||
+:
|
+:
|
||||||
lhu v0, 2(t4)
|
lhu v0, 2(t4)
|
||||||
shuffle_get_return:
|
shuffle_get_return:
|
||||||
jpop 4, ra, 1
|
ret 4, ra, 1
|
||||||
|
|
||||||
unset_alt_scene:
|
unset_alt_scene:
|
||||||
andi t9, a0, 0x01FF
|
andi t9, a0, 0x01FF
|
||||||
|
@ -356,7 +356,7 @@ set_alt_scene:
|
||||||
+:
|
+:
|
||||||
set_alt_scene_return:
|
set_alt_scene_return:
|
||||||
mov v0, s0
|
mov v0, s0
|
||||||
jpop 4, s0, ra
|
ret 4, s0, ra
|
||||||
|
|
||||||
shuffle_exit:
|
shuffle_exit:
|
||||||
push 4, s0, ra
|
push 4, s0, ra
|
||||||
|
@ -403,7 +403,7 @@ shuffle_exit:
|
||||||
li a2, 0
|
li a2, 0
|
||||||
+:
|
+:
|
||||||
mov v0, s0
|
mov v0, s0
|
||||||
jpop 4, s0, ra
|
ret 4, s0, ra
|
||||||
|
|
||||||
setup_hook:
|
setup_hook:
|
||||||
push 4, a0, ra
|
push 4, a0, ra
|
||||||
|
|
|
@ -70,7 +70,7 @@ continue:
|
||||||
bne s4, t0, typeloop
|
bne s4, t0, typeloop
|
||||||
addi s3, s3, @actorlist_dead_space
|
addi s3, s3, @actorlist_dead_space
|
||||||
|
|
||||||
jpop 4, s1, s3, s4, ra
|
ret 4, s1, s3, s4, ra
|
||||||
|
|
||||||
process_actor: // args: a0. returns nothing.
|
process_actor: // args: a0. returns nothing.
|
||||||
// TODO: ignore bomb explosions, they share the same type
|
// TODO: ignore bomb explosions, they share the same type
|
||||||
|
@ -127,7 +127,7 @@ process_actor: // args: a0. returns nothing.
|
||||||
sw t5, current_rotation
|
sw t5, current_rotation
|
||||||
|
|
||||||
+:
|
+:
|
||||||
jpop 4, s0, s1, ra
|
ret 4, s0, s1, ra
|
||||||
|
|
||||||
rotations:
|
rotations:
|
||||||
.word 0x00000000 // pi*0/6
|
.word 0x00000000 // pi*0/6
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
sw t0, buffer_pos
|
sw t0, buffer_pos
|
||||||
// and set the string to null
|
// and set the string to null
|
||||||
sb r0, 0(t0)
|
sb r0, 0(t0)
|
||||||
jpop 4, 1, ra
|
ret 4, 1, ra
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
.asciiz "%s"
|
.asciiz "%s"
|
||||||
|
|
|
@ -31,4 +31,4 @@ simple_spawn:
|
||||||
sw t9, 0x30(sp) // unknown
|
sw t9, 0x30(sp) // unknown
|
||||||
jal @actor_spawn
|
jal @actor_spawn
|
||||||
nop
|
nop
|
||||||
jpop 4, 9, ra
|
ret 4, 9, ra
|
||||||
|
|
|
@ -28,33 +28,24 @@ simple_text:
|
||||||
lw s1, 0(t0)
|
lw s1, 0(t0)
|
||||||
lw t2, @dlist_offset(s1)
|
lw t2, @dlist_offset(s1)
|
||||||
|
|
||||||
mov a0, s0
|
call @DoTxtStruct, s0, t2
|
||||||
mov a1, t2
|
|
||||||
jal @DoTxtStruct
|
|
||||||
nop
|
|
||||||
|
|
||||||
lbu a1, 36(sp)
|
lbu a1, 36(sp)
|
||||||
lbu a2, 37(sp)
|
lbu a2, 37(sp)
|
||||||
lbu a3, 38(sp)
|
lbu a3, 38(sp)
|
||||||
lbu t1, 39(sp)
|
lbu t1, 39(sp)
|
||||||
sw t1, 0x10(sp)
|
call @SetTextRGBA, s0, a1, a2, a3, t1
|
||||||
jal @SetTextRGBA
|
|
||||||
mov a0, s0
|
|
||||||
|
|
||||||
lh a1, 32(sp)
|
lh a1, 32(sp)
|
||||||
lh a2, 34(sp)
|
lh a2, 34(sp)
|
||||||
jal @SetTextXY
|
call @SetTextXY, s0, a1, a2
|
||||||
mov a0, s0
|
|
||||||
|
|
||||||
lw a1, 40(sp)
|
lw a1, 40(sp)
|
||||||
lw a2, 44(sp)
|
lw a2, 44(sp)
|
||||||
jal @SetTextString
|
call @SetTextString, s0, a1, a2
|
||||||
mov a0, s0
|
|
||||||
|
|
||||||
mov a0, s0
|
call @UpdateTxtStruct, s0
|
||||||
jal @UpdateTxtStruct
|
|
||||||
nop
|
|
||||||
|
|
||||||
sw v0, @dlist_offset(s1)
|
sw v0, @dlist_offset(s1)
|
||||||
|
|
||||||
jpop 4, 1, s0, s1, ra
|
ret 4, 1, s0, s1, ra
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
jal 0x800BB2D0 // original code
|
jal 0x800BB2D0 // original code
|
||||||
nop
|
nop
|
||||||
+:
|
+:
|
||||||
jpop 5, ra
|
ret 5, ra
|
||||||
|
|
||||||
.org 0x800B9430 // part of scene actor loading routine
|
.org 0x800B9430 // part of scene actor loading routine
|
||||||
jal @whatever
|
jal @whatever
|
||||||
|
|
|
@ -32,14 +32,12 @@ spawn:
|
||||||
+: // handle dpad
|
+: // handle dpad
|
||||||
bnez s4, +
|
bnez s4, +
|
||||||
mov a1, s2
|
mov a1, s2
|
||||||
jal dpad_control
|
call dpad_control, s0, a1
|
||||||
mov a0, s0
|
|
||||||
mov s0, v0
|
mov s0, v0
|
||||||
b ++
|
b ++
|
||||||
nop
|
nop
|
||||||
+:
|
+:
|
||||||
jal dpad_control
|
call dpad_control, s3, a1
|
||||||
mov a0, s3
|
|
||||||
andi s3, v0, 0xFFFF
|
andi s3, v0, 0xFFFF
|
||||||
+: // set min/max on actor number
|
+: // set min/max on actor number
|
||||||
subi t4, s0, @min_actor_no
|
subi t4, s0, @min_actor_no
|
||||||
|
@ -61,25 +59,15 @@ spawn:
|
||||||
nop
|
nop
|
||||||
return:
|
return:
|
||||||
// render actor number
|
// render actor number
|
||||||
li a0, 0x0001001C // xy
|
call simple_text, 0x0001001C, 0x88CCFFFF, fmt, s0
|
||||||
li a1, 0x88CCFFFF // rgba
|
|
||||||
la a2, fmt
|
|
||||||
mov a3, s0
|
|
||||||
jal simple_text
|
|
||||||
nop
|
|
||||||
// render actor variable
|
// render actor variable
|
||||||
li a0, 0x0006001C // xy
|
call simple_text, 0x0006001C, 0xFFCC88FF, fmt, s3
|
||||||
li a1, 0xFFCC88FF // rgba
|
|
||||||
la a2, fmt
|
|
||||||
mov a3, s3
|
|
||||||
jal simple_text
|
|
||||||
nop
|
|
||||||
// done
|
// done
|
||||||
sh s0, anum
|
sh s0, anum
|
||||||
sw s1, hold_delay
|
sw s1, hold_delay
|
||||||
sh s3, avar
|
sh s3, avar
|
||||||
sw s4, selected
|
sw s4, selected
|
||||||
jpop 4, s0, s1, s2, s3, s4, ra,
|
ret 4, s0, s1, s2, s3, s4, ra,
|
||||||
|
|
||||||
anum:
|
anum:
|
||||||
.word 0
|
.word 0
|
||||||
|
@ -108,8 +96,7 @@ object_spawn_wrap:
|
||||||
nop
|
nop
|
||||||
beqi a0, 2, +
|
beqi a0, 2, +
|
||||||
nop
|
nop
|
||||||
jal @object_spawn
|
call @object_spawn, a0, a1
|
||||||
nop
|
|
||||||
+:
|
+:
|
||||||
jr
|
jr
|
||||||
nop
|
nop
|
||||||
|
@ -135,8 +122,7 @@ object_spawn_wrap:
|
||||||
addi t0, t0, 68
|
addi t0, t0, 68
|
||||||
bnez t1, -
|
bnez t1, -
|
||||||
nop
|
nop
|
||||||
jal @object_spawn
|
call @object_spawn, a0, a1
|
||||||
nop
|
|
||||||
//subiu v0, r0, -1 // original code
|
//subiu v0, r0, -1 // original code
|
||||||
+:
|
+:
|
||||||
jpop 4, ra, 1
|
ret 4, ra, 1
|
||||||
|
|
|
@ -7,7 +7,7 @@ start:
|
||||||
jal adjust_dlist
|
jal adjust_dlist
|
||||||
lw a0, 4(t0) ; HUD display list start
|
lw a0, 4(t0) ; HUD display list start
|
||||||
|
|
||||||
jpop 4, 1, ra
|
ret 4, 1, ra
|
||||||
|
|
||||||
adjust_dlist:
|
adjust_dlist:
|
||||||
; args: pointer to start of dlist
|
; args: pointer to start of dlist
|
||||||
|
@ -50,8 +50,7 @@ recurse:
|
||||||
bne t3, t9, next
|
bne t3, t9, next
|
||||||
nop
|
nop
|
||||||
sw a0, debug
|
sw a0, debug
|
||||||
jal adjust_dlist
|
call adjust_dlist, a0
|
||||||
nop
|
|
||||||
b next
|
b next
|
||||||
nop
|
nop
|
||||||
|
|
||||||
|
@ -72,16 +71,13 @@ texscale:
|
||||||
andi s4, t3, 0xFFFF ; get x scale
|
andi s4, t3, 0xFFFF ; get x scale
|
||||||
|
|
||||||
; scale coordinates
|
; scale coordinates
|
||||||
jal scale_xy
|
call scale_xy, s0
|
||||||
mov a0, s0
|
|
||||||
mov s0, v0
|
mov s0, v0
|
||||||
jal scale_xy
|
call scale_xy, s2
|
||||||
mov a0, s2
|
|
||||||
mov s2, v0
|
mov s2, v0
|
||||||
|
|
||||||
; scale pixel steps
|
; scale pixel steps
|
||||||
jal scale_step
|
call scale_step, s4
|
||||||
mov a0, s4
|
|
||||||
mov s4, v0
|
mov s4, v0
|
||||||
|
|
||||||
; reconstruct commands
|
; reconstruct commands
|
||||||
|
@ -152,7 +148,7 @@ setscissor:
|
||||||
;80167FB0
|
;80167FB0
|
||||||
|
|
||||||
+return:
|
+return:
|
||||||
jpop 4, s0, s1, s2, s3, s4, s5, s6, s7, s8, ra
|
ret 4, s0, s1, s2, s3, s4, s5, s6, s7, s8, ra
|
||||||
|
|
||||||
.align 4
|
.align 4
|
||||||
.word 0xDEADBEEF
|
.word 0xDEADBEEF
|
||||||
|
|
|
@ -22,10 +22,7 @@
|
||||||
li s0, 0x801BD910 ; original code
|
li s0, 0x801BD910 ; original code
|
||||||
; pushes removed here
|
; pushes removed here
|
||||||
; 6 instructions to work with
|
; 6 instructions to work with
|
||||||
li a1, @vstart ; 2
|
call @DMARomToRam, @start, @vstart, @size
|
||||||
li a2, @size ; 2
|
|
||||||
jal @DMARomToRam ; 1
|
|
||||||
li a0, @start ; 1 (just ensure @start can be a LUI!)
|
|
||||||
|
|
||||||
.org @dma_overwrite
|
.org @dma_overwrite
|
||||||
j dma_hook ; 1
|
j dma_hook ; 1
|
||||||
|
|
|
@ -30,11 +30,8 @@
|
||||||
li s0, 0x8011F830 ; original code
|
li s0, 0x8011F830 ; original code
|
||||||
; pushes removed here
|
; pushes removed here
|
||||||
; 9 instructions to work with?
|
; 9 instructions to work with?
|
||||||
; dma args are backwards compared to MM?
|
; a0 and a1 are backwards compared to MM?
|
||||||
li a1, @start
|
call @DMARomToRam, @vstart, @start, @size
|
||||||
li a2, @size
|
|
||||||
jal @DMARomToRam
|
|
||||||
li a0, @vstart
|
|
||||||
lui a0 0x8014 ; original code
|
lui a0 0x8014 ; original code
|
||||||
cl a1
|
cl a1
|
||||||
cl a2
|
cl a2
|
||||||
|
|
|
@ -22,8 +22,7 @@ rng_seed:
|
||||||
|
|
||||||
dma_hook:
|
dma_hook:
|
||||||
push 4, 1, ra
|
push 4, 1, ra
|
||||||
jal setup_hook
|
call setup_hook
|
||||||
nop
|
|
||||||
pop 4, 1, ra
|
pop 4, 1, ra
|
||||||
addiu sp, 0xFF58 ; original code
|
addiu sp, 0xFF58 ; original code
|
||||||
j 0x8016A2D0 ; return to scene setup function
|
j 0x8016A2D0 ; return to scene setup function
|
||||||
|
@ -113,37 +112,34 @@ load_hook:
|
||||||
; first time setup
|
; first time setup
|
||||||
sb t0, @has_completed_intro(s0)
|
sb t0, @has_completed_intro(s0)
|
||||||
sb t0, @have_tatl(s0)
|
sb t0, @have_tatl(s0)
|
||||||
li a0, 0x001A ; deku intro area
|
|
||||||
li a1, 2
|
; deku intro area
|
||||||
jal set_scene_flag
|
; "Hey, you! C'mon! Press Z and talk to me!"
|
||||||
li a2, 2 ; "Hey, you! C'mon! Press Z and talk to me!"
|
call set_scene_flag, 0x001A, 2, 2
|
||||||
li a0, 0x0063 ; inside clock tower
|
|
||||||
li a1, 1 ; second word
|
; inside clock tower
|
||||||
jal set_scene_flag
|
; second word
|
||||||
li a2, 0 ; first bit ("You've met with a terrible fate")
|
; first bit ("You've met with a terrible fate")
|
||||||
li a0, @week_event_reg
|
call set_scene_flag, 0x0063, 1, 0
|
||||||
li a1, 31
|
|
||||||
jal set_event_flag
|
; Tatl reminding you about the four directions
|
||||||
li a2, 2 ; Tatl reminding you about the four directions
|
call set_event_flag, @week_event_reg, 31, 2
|
||||||
li a0, @week_event_reg
|
|
||||||
li a1, 93
|
; woken turtle once (shortens cutscene)
|
||||||
jal set_event_flag
|
call set_event_flag, @week_event_reg, 93, 3
|
||||||
li a2, 3 ; woken turtle once (shortens cutscene)
|
|
||||||
li a0, @week_event_reg
|
; taken turtle once (skips pirates getting wrekt)
|
||||||
li a1, 53
|
call set_event_flag, @week_event_reg, 53, 6
|
||||||
jal set_event_flag
|
|
||||||
li a2, 6 ; taken turtle once (skips pirates getting wrekt)
|
|
||||||
+:
|
+:
|
||||||
addi a0, s0, @player_name
|
addi a0, s0, @player_name
|
||||||
li a2, 0xFFFFFFFF
|
call crc32, a0, 8, 0xFFFFFFFF
|
||||||
jal crc32
|
|
||||||
li a1, 8
|
|
||||||
not v0, v0
|
not v0, v0
|
||||||
sw v0, hash
|
sw v0, hash
|
||||||
sw v0, rng_seed
|
sw v0, rng_seed
|
||||||
jal shuffle_all
|
call shuffle_all
|
||||||
nop
|
ret 4, s0, s1, ra, 1
|
||||||
jpop 4, s0, s1, ra, 1
|
|
||||||
|
|
||||||
prng:
|
prng:
|
||||||
; just a reimplementation of the PRNG the game uses.
|
; just a reimplementation of the PRNG the game uses.
|
||||||
|
@ -166,7 +162,7 @@ randint:
|
||||||
addi s0, a0, 1
|
addi s0, a0, 1
|
||||||
divu v0, s0
|
divu v0, s0
|
||||||
mfhi v0
|
mfhi v0
|
||||||
jpop 4, s0, ra
|
ret 4, s0, ra
|
||||||
|
|
||||||
shuffle_all:
|
shuffle_all:
|
||||||
push 4, s0, s1, s2, ra
|
push 4, s0, s1, s2, ra
|
||||||
|
@ -175,8 +171,7 @@ shuffle_all:
|
||||||
li s1, @entries
|
li s1, @entries
|
||||||
la s2, shuffles
|
la s2, shuffles
|
||||||
-:
|
-:
|
||||||
jal randint
|
call randint, s0
|
||||||
mov a0, s0
|
|
||||||
; s0 is i, v0 is j
|
; s0 is i, v0 is j
|
||||||
sll t0, s0, 2 ; 1<<2 == 2*sizeof(half)
|
sll t0, s0, 2 ; 1<<2 == 2*sizeof(half)
|
||||||
sll t1, v0, 2 ; likewise
|
sll t1, v0, 2 ; likewise
|
||||||
|
@ -193,7 +188,7 @@ shuffle_all:
|
||||||
bne s0, s1, -
|
bne s0, s1, -
|
||||||
nop
|
nop
|
||||||
+:
|
+:
|
||||||
jpop 4, s0, s1, s2, ra
|
ret 4, s0, s1, s2, ra
|
||||||
|
|
||||||
shuffle_get:
|
shuffle_get:
|
||||||
; a0: exit value
|
; a0: exit value
|
||||||
|
@ -216,7 +211,7 @@ shuffle_get:
|
||||||
+:
|
+:
|
||||||
lhu v0, 2(t4)
|
lhu v0, 2(t4)
|
||||||
+return:
|
+return:
|
||||||
jpop 4, ra, 1
|
ret 4, ra, 1
|
||||||
|
|
||||||
unset_alt_scene:
|
unset_alt_scene:
|
||||||
andi t9, a0, 0x01FF
|
andi t9, a0, 0x01FF
|
||||||
|
@ -250,10 +245,7 @@ set_alt_scene:
|
||||||
push 4, s0, ra
|
push 4, s0, ra
|
||||||
mov s0, a0
|
mov s0, a0
|
||||||
; use clean swamp when odolwa is beaten
|
; use clean swamp when odolwa is beaten
|
||||||
li a0, @week_event_reg
|
call get_event_flag, @week_event_reg, 20, 1
|
||||||
li a1, 20
|
|
||||||
jal get_event_flag
|
|
||||||
li a2, 1
|
|
||||||
beqz v0, +
|
beqz v0, +
|
||||||
nop
|
nop
|
||||||
andi t9, s0, 0x01FF
|
andi t9, s0, 0x01FF
|
||||||
|
@ -265,10 +257,7 @@ set_alt_scene:
|
||||||
addu s0, t9, at
|
addu s0, t9, at
|
||||||
+:
|
+:
|
||||||
; use unfrozen mountain when goht is beaten
|
; use unfrozen mountain when goht is beaten
|
||||||
li a0, @week_event_reg
|
call get_event_flag, @week_event_reg, 33, 7
|
||||||
li a1, 33
|
|
||||||
jal get_event_flag
|
|
||||||
li a2, 7
|
|
||||||
beqz v0, +return
|
beqz v0, +return
|
||||||
nop
|
nop
|
||||||
andi t9, s0, 0x01FF
|
andi t9, s0, 0x01FF
|
||||||
|
@ -290,7 +279,7 @@ set_alt_scene:
|
||||||
+:
|
+:
|
||||||
+return:
|
+return:
|
||||||
mov v0, s0
|
mov v0, s0
|
||||||
jpop 4, s0, ra
|
ret 4, s0, ra
|
||||||
|
|
||||||
shuffle_exit:
|
shuffle_exit:
|
||||||
push 4, s0, ra
|
push 4, s0, ra
|
||||||
|
@ -318,26 +307,19 @@ shuffle_exit:
|
||||||
lh t2, @exit_mod_setter(t0)
|
lh t2, @exit_mod_setter(t0)
|
||||||
bnei t2, 0xFFEF, +
|
bnei t2, 0xFFEF, +
|
||||||
nop
|
nop
|
||||||
; implicitly passes a0
|
call unset_alt_scene, a0
|
||||||
jal unset_alt_scene
|
call shuffle_get, v0
|
||||||
nop
|
call set_alt_scene, v0
|
||||||
jal shuffle_get
|
|
||||||
mov a0, v0
|
|
||||||
jal set_alt_scene
|
|
||||||
mov a0, v0
|
|
||||||
mov s0, v0
|
mov s0, v0
|
||||||
sh v0, new_exit
|
sh v0, new_exit
|
||||||
; set woodfall temple as raised after beating odolwa
|
; set woodfall temple as raised after beating odolwa
|
||||||
; otherwise the swamp won't be cleansed
|
; otherwise the swamp won't be cleansed
|
||||||
li at, 0x8601
|
li at, 0x8601
|
||||||
bne s0, at, +
|
bne s0, at, +
|
||||||
li a1, 20
|
call set_event_flag, @week_event_reg, 20, 0
|
||||||
li a0, @week_event_reg
|
|
||||||
jal set_event_flag
|
|
||||||
li a2, 0
|
|
||||||
+:
|
+:
|
||||||
mov v0, s0
|
mov v0, s0
|
||||||
jpop 4, s0, ra
|
ret 4, s0, ra
|
||||||
|
|
||||||
setup_hook:
|
setup_hook:
|
||||||
push 4, a0, ra
|
push 4, a0, ra
|
||||||
|
@ -345,6 +327,6 @@ setup_hook:
|
||||||
jal shuffle_exit
|
jal shuffle_exit
|
||||||
andi a0, 0xFFFF
|
andi a0, 0xFFFF
|
||||||
sw v0, @link_save
|
sw v0, @link_save
|
||||||
jpop 4, a0, ra
|
ret 4, a0, ra
|
||||||
|
|
||||||
.word 0xDEADBEEF
|
.word 0xDEADBEEF
|
||||||
|
|
Loading…
Add table
Reference in a new issue