1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-05-17 21:23:22 -07:00

use new features again

This commit is contained in:
Connor Olding 2016-05-18 03:24:20 -07:00
parent 2edbe2135a
commit f1ebc3f9ff
11 changed files with 71 additions and 122 deletions

View File

@ -206,7 +206,7 @@ load_hook:
sw v0, rng_seed
jal shuffle_all
nop
jpop 4, s0, s1, ra, 1
ret 4, s0, s1, ra, 1
prng:
// just a reimplementation of the PRNG the game uses.
@ -232,7 +232,7 @@ randint:
addi s0, a0, 1
divu v0, s0
mfhi v0
jpop 4, s0, ra
ret 4, s0, ra
shuffle_all:
push 4, s0, s1, s2, ra
@ -259,7 +259,7 @@ shuffle_all:
bne s0, s1, -
nop
+:
jpop 4, s0, s1, s2, ra
ret 4, s0, s1, s2, ra
shuffle_get:
// a0: exit value
@ -282,7 +282,7 @@ shuffle_get:
+:
lhu v0, 2(t4)
shuffle_get_return:
jpop 4, ra, 1
ret 4, ra, 1
unset_alt_scene:
andi t9, a0, 0x01FF
@ -356,7 +356,7 @@ set_alt_scene:
+:
set_alt_scene_return:
mov v0, s0
jpop 4, s0, ra
ret 4, s0, ra
shuffle_exit:
push 4, s0, ra
@ -403,7 +403,7 @@ shuffle_exit:
li a2, 0
+:
mov v0, s0
jpop 4, s0, ra
ret 4, s0, ra
setup_hook:
push 4, a0, ra

View File

@ -70,7 +70,7 @@ continue:
bne s4, t0, typeloop
addi s3, s3, @actorlist_dead_space
jpop 4, s1, s3, s4, ra
ret 4, s1, s3, s4, ra
process_actor: // args: a0. returns nothing.
// TODO: ignore bomb explosions, they share the same type
@ -127,7 +127,7 @@ process_actor: // args: a0. returns nothing.
sw t5, current_rotation
+:
jpop 4, s0, s1, ra
ret 4, s0, s1, ra
rotations:
.word 0x00000000 // pi*0/6

View File

@ -31,7 +31,7 @@
sw t0, buffer_pos
// and set the string to null
sb r0, 0(t0)
jpop 4, 1, ra
ret 4, 1, ra
fmt:
.asciiz "%s"

View File

@ -31,4 +31,4 @@ simple_spawn:
sw t9, 0x30(sp) // unknown
jal @actor_spawn
nop
jpop 4, 9, ra
ret 4, 9, ra

View File

@ -28,33 +28,24 @@ simple_text:
lw s1, 0(t0)
lw t2, @dlist_offset(s1)
mov a0, s0
mov a1, t2
jal @DoTxtStruct
nop
call @DoTxtStruct, s0, t2
lbu a1, 36(sp)
lbu a2, 37(sp)
lbu a3, 38(sp)
lbu t1, 39(sp)
sw t1, 0x10(sp)
jal @SetTextRGBA
mov a0, s0
call @SetTextRGBA, s0, a1, a2, a3, t1
lh a1, 32(sp)
lh a2, 34(sp)
jal @SetTextXY
mov a0, s0
call @SetTextXY, s0, a1, a2
lw a1, 40(sp)
lw a2, 44(sp)
jal @SetTextString
mov a0, s0
call @SetTextString, s0, a1, a2
mov a0, s0
jal @UpdateTxtStruct
nop
call @UpdateTxtStruct, s0
sw v0, @dlist_offset(s1)
jpop 4, 1, s0, s1, ra
ret 4, 1, s0, s1, ra

View File

@ -41,7 +41,7 @@
jal 0x800BB2D0 // original code
nop
+:
jpop 5, ra
ret 5, ra
.org 0x800B9430 // part of scene actor loading routine
jal @whatever

View File

@ -32,14 +32,12 @@ spawn:
+: // handle dpad
bnez s4, +
mov a1, s2
jal dpad_control
mov a0, s0
call dpad_control, s0, a1
mov s0, v0
b ++
nop
+:
jal dpad_control
mov a0, s3
call dpad_control, s3, a1
andi s3, v0, 0xFFFF
+: // set min/max on actor number
subi t4, s0, @min_actor_no
@ -61,25 +59,15 @@ spawn:
nop
return:
// render actor number
li a0, 0x0001001C // xy
li a1, 0x88CCFFFF // rgba
la a2, fmt
mov a3, s0
jal simple_text
nop
call simple_text, 0x0001001C, 0x88CCFFFF, fmt, s0
// render actor variable
li a0, 0x0006001C // xy
li a1, 0xFFCC88FF // rgba
la a2, fmt
mov a3, s3
jal simple_text
nop
call simple_text, 0x0006001C, 0xFFCC88FF, fmt, s3
// done
sh s0, anum
sw s1, hold_delay
sh s3, avar
sw s4, selected
jpop 4, s0, s1, s2, s3, s4, ra,
ret 4, s0, s1, s2, s3, s4, ra,
anum:
.word 0
@ -108,8 +96,7 @@ object_spawn_wrap:
nop
beqi a0, 2, +
nop
jal @object_spawn
nop
call @object_spawn, a0, a1
+:
jr
nop
@ -135,8 +122,7 @@ object_spawn_wrap:
addi t0, t0, 68
bnez t1, -
nop
jal @object_spawn
nop
call @object_spawn, a0, a1
//subiu v0, r0, -1 // original code
+:
jpop 4, ra, 1
ret 4, ra, 1

View File

@ -7,7 +7,7 @@ start:
jal adjust_dlist
lw a0, 4(t0) ; HUD display list start
jpop 4, 1, ra
ret 4, 1, ra
adjust_dlist:
; args: pointer to start of dlist
@ -50,8 +50,7 @@ recurse:
bne t3, t9, next
nop
sw a0, debug
jal adjust_dlist
nop
call adjust_dlist, a0
b next
nop
@ -72,16 +71,13 @@ texscale:
andi s4, t3, 0xFFFF ; get x scale
; scale coordinates
jal scale_xy
mov a0, s0
call scale_xy, s0
mov s0, v0
jal scale_xy
mov a0, s2
call scale_xy, s2
mov s2, v0
; scale pixel steps
jal scale_step
mov a0, s4
call scale_step, s4
mov s4, v0
; reconstruct commands
@ -152,7 +148,7 @@ setscissor:
;80167FB0
+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
.word 0xDEADBEEF

View File

@ -22,10 +22,7 @@
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 ensure @start can be a LUI!)
call @DMARomToRam, @start, @vstart, @size
.org @dma_overwrite
j dma_hook ; 1

View File

@ -30,11 +30,8 @@
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
; a0 and a1 are backwards compared to MM?
call @DMARomToRam, @vstart, @start, @size
lui a0 0x8014 ; original code
cl a1
cl a2

View File

@ -22,8 +22,7 @@ rng_seed:
dma_hook:
push 4, 1, ra
jal setup_hook
nop
call setup_hook
pop 4, 1, ra
addiu sp, 0xFF58 ; original code
j 0x8016A2D0 ; return to scene setup function
@ -113,37 +112,34 @@ load_hook:
; first time setup
sb t0, @has_completed_intro(s0)
sb t0, @have_tatl(s0)
li a0, 0x001A ; deku intro area
li a1, 2
jal set_scene_flag
li a2, 2 ; "Hey, you! C'mon! Press Z and talk to me!"
li a0, 0x0063 ; inside clock tower
li a1, 1 ; second word
jal set_scene_flag
li a2, 0 ; first bit ("You've met with a terrible fate")
li a0, @week_event_reg
li a1, 31
jal set_event_flag
li a2, 2 ; Tatl reminding you about the four directions
li a0, @week_event_reg
li a1, 93
jal set_event_flag
li a2, 3 ; woken turtle once (shortens cutscene)
li a0, @week_event_reg
li a1, 53
jal set_event_flag
li a2, 6 ; taken turtle once (skips pirates getting wrekt)
; deku intro area
; "Hey, you! C'mon! Press Z and talk to me!"
call set_scene_flag, 0x001A, 2, 2
; inside clock tower
; second word
; first bit ("You've met with a terrible fate")
call set_scene_flag, 0x0063, 1, 0
; Tatl reminding you about the four directions
call set_event_flag, @week_event_reg, 31, 2
; woken turtle once (shortens cutscene)
call set_event_flag, @week_event_reg, 93, 3
; taken turtle once (skips pirates getting wrekt)
call set_event_flag, @week_event_reg, 53, 6
+:
addi a0, s0, @player_name
li a2, 0xFFFFFFFF
jal crc32
li a1, 8
call crc32, a0, 8, 0xFFFFFFFF
not v0, v0
sw v0, hash
sw v0, rng_seed
jal shuffle_all
nop
jpop 4, s0, s1, ra, 1
call shuffle_all
ret 4, s0, s1, ra, 1
prng:
; just a reimplementation of the PRNG the game uses.
@ -166,7 +162,7 @@ randint:
addi s0, a0, 1
divu v0, s0
mfhi v0
jpop 4, s0, ra
ret 4, s0, ra
shuffle_all:
push 4, s0, s1, s2, ra
@ -175,8 +171,7 @@ shuffle_all:
li s1, @entries
la s2, shuffles
-:
jal randint
mov a0, s0
call randint, s0
; s0 is i, v0 is j
sll t0, s0, 2 ; 1<<2 == 2*sizeof(half)
sll t1, v0, 2 ; likewise
@ -193,7 +188,7 @@ shuffle_all:
bne s0, s1, -
nop
+:
jpop 4, s0, s1, s2, ra
ret 4, s0, s1, s2, ra
shuffle_get:
; a0: exit value
@ -216,7 +211,7 @@ shuffle_get:
+:
lhu v0, 2(t4)
+return:
jpop 4, ra, 1
ret 4, ra, 1
unset_alt_scene:
andi t9, a0, 0x01FF
@ -250,10 +245,7 @@ set_alt_scene:
push 4, s0, ra
mov s0, a0
; use clean swamp when odolwa is beaten
li a0, @week_event_reg
li a1, 20
jal get_event_flag
li a2, 1
call get_event_flag, @week_event_reg, 20, 1
beqz v0, +
nop
andi t9, s0, 0x01FF
@ -265,10 +257,7 @@ set_alt_scene:
addu s0, t9, at
+:
; use unfrozen mountain when goht is beaten
li a0, @week_event_reg
li a1, 33
jal get_event_flag
li a2, 7
call get_event_flag, @week_event_reg, 33, 7
beqz v0, +return
nop
andi t9, s0, 0x01FF
@ -290,7 +279,7 @@ set_alt_scene:
+:
+return:
mov v0, s0
jpop 4, s0, ra
ret 4, s0, ra
shuffle_exit:
push 4, s0, ra
@ -318,26 +307,19 @@ shuffle_exit:
lh t2, @exit_mod_setter(t0)
bnei t2, 0xFFEF, +
nop
; implicitly passes a0
jal unset_alt_scene
nop
jal shuffle_get
mov a0, v0
jal set_alt_scene
mov a0, v0
call unset_alt_scene, a0
call shuffle_get, v0
call set_alt_scene, v0
mov s0, v0
sh v0, new_exit
; set woodfall temple as raised after beating odolwa
; otherwise the swamp won't be cleansed
li at, 0x8601
bne s0, at, +
li a1, 20
li a0, @week_event_reg
jal set_event_flag
li a2, 0
call set_event_flag, @week_event_reg, 20, 0
+:
mov v0, s0
jpop 4, s0, ra
ret 4, s0, ra
setup_hook:
push 4, a0, ra
@ -345,6 +327,6 @@ setup_hook:
jal shuffle_exit
andi a0, 0xFFFF
sw v0, @link_save
jpop 4, a0, ra
ret 4, a0, ra
.word 0xDEADBEEF