1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-06-17 17:03:06 -07:00

style change: four space indentation for instructions

This commit is contained in:
Connor Olding 2015-12-22 17:33:38 -08:00
parent 14ab1ee731
commit 2cbb2edf70
3 changed files with 218 additions and 218 deletions

View File

@ -27,16 +27,16 @@ local injection_points = {
local header = [[ local header = [[
[overwritten]: 0x%08X [overwritten]: 0x%08X
// TODO: optimize for size // TODO: optimize for size
// TODO: fix case where overwritten function takes 5+ args // TODO: fix case where overwritten function takes 5+ args
push ra push ra
push a0, a1, a2, a3 push a0, a1, a2, a3
bal start bal start
nop nop
pop a0, a1, a2, a3 pop a0, a1, a2, a3
jal @overwritten jal @overwritten
nop nop
jpop ra jpop ra
start: start:
]] ]]

View File

@ -24,118 +24,118 @@
[cosf]: 0x80091F40 [cosf]: 0x80091F40
main: main:
push 4, s1, s3, s4, ra push 4, s1, s3, s4, ra
// s1: current actor ptr // s1: current actor ptr
// s3: current actor type ptr // s3: current actor type ptr
// s4: current actor type index // s4: current actor type index
li t0, @global_context li t0, @global_context
addi s3, t0, @actorlist_offset addi s3, t0, @actorlist_offset
li s4, 0 li s4, 0
// update rotations // update rotations
la t0, rotations la t0, rotations
li t2, @rotate_amount li t2, @rotate_amount
li t9, 0 li t9, 0
rotate_loop: rotate_loop:
lw t1, 0(t0) lw t1, 0(t0)
mtc1 t1, F0 mtc1 t1, F0
mtc1 t2, F1 mtc1 t2, F1
add.s F0, F0, F1 add.s F0, F0, F1
mfc1 t1, F0 mfc1 t1, F0
sw t1, 0(t0) sw t1, 0(t0)
addi t0, t0, 4 addi t0, t0, 4
addi t9, t9, 1 addi t9, t9, 1
li at, 6 li at, 6
bne t9, at, rotate_loop bne t9, at, rotate_loop
nop nop
la t0, rotations la t0, rotations
sw t0, current_rotation sw t0, current_rotation
typeloop: typeloop:
addi s3, s3, 4 // skip over count addi s3, s3, 4 // skip over count
lw s1, 0(s3) lw s1, 0(s3)
beq s1, r0, continue beq s1, r0, continue
listloop: listloop:
mov a0, s1 mov a0, s1
bal process_actor bal process_actor
lw s1, @actor_next(s1) lw s1, @actor_next(s1)
bne s1, r0, listloop bne s1, r0, listloop
nop nop
continue: continue:
addi s3, s3, 4 addi s3, s3, 4
addi s4, s4, 1 addi s4, s4, 1
li t0, 12 li t0, 12
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 jpop 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
push 4, s0, s1, ra push 4, s0, s1, ra
// s0: result of sin // s0: result of sin
// s1: result of cos // s1: result of cos
lh t0, 0(a0) lh t0, 0(a0)
subiu t0, t0, @at_bomb subiu t0, t0, @at_bomb
bne t0, r0, process_actor_return bne t0, r0, process_actor_return
nop nop
li t0, 0x45 li t0, 0x45
sb t0, @actor_bomb_timer(a0) sb t0, @actor_bomb_timer(a0)
lw t5, current_rotation lw t5, current_rotation
lw t5, 0(t5) lw t5, 0(t5)
jal @sinf jal @sinf
mtc1 t5, F12 mtc1 t5, F12
mfc1 s0, F0 mfc1 s0, F0
lw t5, current_rotation lw t5, current_rotation
lw t5, 0(t5) lw t5, 0(t5)
jal @cosf jal @cosf
mtc1 t5, F12 mtc1 t5, F12
mfc1 s1, F0 mfc1 s1, F0
li t1, @link_actor li t1, @link_actor
lw t2, @actor_x(t1) lw t2, @actor_x(t1)
lw t3, @actor_y(t1) lw t3, @actor_y(t1)
lw t4, @actor_z(t1) lw t4, @actor_z(t1)
li t0, 0x42960000 // 75 li t0, 0x42960000 // 75
mtc1 t0, F2 mtc1 t0, F2
// process X // process X
mtc1 s0, F0 mtc1 s0, F0
mtc1 t2, F1 mtc1 t2, F1
mul.s F0, F0, F2 mul.s F0, F0, F2
add.s F0, F0, F1 add.s F0, F0, F1
mfc1 t2, F0 mfc1 t2, F0
// process Z // process Z
mtc1 s1, F0 mtc1 s1, F0
mtc1 t4, F1 mtc1 t4, F1
mul.s F0, F0, F2 mul.s F0, F0, F2
add.s F0, F0, F1 add.s F0, F0, F1
mfc1 t4, F0 mfc1 t4, F0
sw t2, @actor_x(a0) sw t2, @actor_x(a0)
sw t3, @actor_y(a0) sw t3, @actor_y(a0)
sw t4, @actor_z(a0) sw t4, @actor_z(a0)
lw t5, current_rotation lw t5, current_rotation
addi t5, t5, 4 addi t5, t5, 4
sw t5, current_rotation sw t5, current_rotation
process_actor_return: process_actor_return:
jpop 4, s0, s1, ra jpop 4, s0, s1, ra
rotations: rotations:
.word 0x00000000 // pi*0/6 .word 0x00000000 // pi*0/6
.word 0x40060a92 // pi*4/6 .word 0x40060a92 // pi*4/6
.word 0x40860a92 // pi*8/6 .word 0x40860a92 // pi*8/6
.word 0x40c90fdb // pi*12/6 .word 0x40c90fdb // pi*12/6
.word 0x41060a92 // pi*16/6 .word 0x41060a92 // pi*16/6
.word 0x41278d36 // pi*20/6 .word 0x41278d36 // pi*20/6
current_rotation: current_rotation:
.word 0 .word 0

View File

@ -7,135 +7,135 @@
[hold_delay_amount]: 3 [hold_delay_amount]: 3
push 4, s1, ra push 4, s1, ra
li t0, @link_save li t0, @link_save
li t1, @global_context li t1, @global_context
// give max rupee upgrade (set bit 13, clear bit 12 of lower halfword) // give max rupee upgrade (set bit 13, clear bit 12 of lower halfword)
lhu t2, @upgrades_2_offset(t0) lhu t2, @upgrades_2_offset(t0)
ori t2, t2, 0x2000 ori t2, t2, 0x2000
andi t2, t2, 0xEFFF andi t2, t2, 0xEFFF
sh t2, @upgrades_2_offset(t0) sh t2, @upgrades_2_offset(t0)
// //
lhu t2, @buttons_offset(t1) lhu t2, @buttons_offset(t1)
lhu t9, @rupees_offset(t0) lhu t9, @rupees_offset(t0)
lw s1, hold_delay lw s1, hold_delay
andi t4, t2, @button_any andi t4, t2, @button_any
bne t4, r0, no_reset bne t4, r0, no_reset
addi s1, s1, 1 addi s1, s1, 1
li s1, 0 li s1, 0
no_reset: no_reset:
subi t4, s1, 1 subi t4, s1, 1
beq t4, r0, first_time beq t4, r0, first_time
nop nop
subi t4, s1, @hold_delay_amount subi t4, s1, @hold_delay_amount
bltz t4, return bltz t4, return
nop nop
first_time: first_time:
andi t3, t2, @button_D_up andi t3, t2, @button_D_up
beq t3, r0, no_D_up beq t3, r0, no_D_up
nop nop
addi t9, t9, 1 addi t9, t9, 1
no_D_up: no_D_up:
andi t3, t2, @button_D_down andi t3, t2, @button_D_down
beq t3, r0, no_D_down beq t3, r0, no_D_down
nop nop
subi t9, t9, 1 subi t9, t9, 1
no_D_down: no_D_down:
andi t3, t2, @button_D_right andi t3, t2, @button_D_right
beq t3, r0, no_D_right beq t3, r0, no_D_right
nop nop
addi t9, t9, 10 addi t9, t9, 10
no_D_right: no_D_right:
andi t3, t2, @button_D_left andi t3, t2, @button_D_left
beq t3, r0, no_D_left beq t3, r0, no_D_left
nop nop
subi t9, t9, 10 subi t9, t9, 10
no_D_left: no_D_left:
subi t4, t9, 1 subi t4, t9, 1
bgez t4, no_min bgez t4, no_min
nop nop
li t9, @max_actor_no li t9, @max_actor_no
no_min: no_min:
subi t4, t9, @max_actor_no subi t4, t9, @max_actor_no
blez t4, no_max blez t4, no_max
nop nop
li t9, 1 li t9, 1
no_max: no_max:
sh t9, @rupees_offset(t0) sh t9, @rupees_offset(t0)
andi t3, t2, @button_L andi t3, t2, @button_L
beq t3, r0, return beq t3, r0, return
nop nop
mov a0, t9 mov a0, t9
bal simple_spawn bal simple_spawn
nop nop
return: return:
sw s1, hold_delay sw s1, hold_delay
jpop 4, s1, ra jpop 4, s1, ra
simple_spawn: // args: a0 (actor to spawn) simple_spawn: // args: a0 (actor to spawn)
push 4, 9, ra push 4, 9, ra
jal load_object jal load_object
sw a0, 56(sp) // keep me updated! sw a0, 56(sp) // keep me updated!
bne v0, r0, simple_spawn_return bne v0, r0, simple_spawn_return
lw a2, 56(sp) // keep me updated! lw a2, 56(sp) // keep me updated!
li a1, @global_context li a1, @global_context
addi a0, a1, @actor_spawn_offset addi a0, a1, @actor_spawn_offset
li t0, @link_actor li t0, @link_actor
lw t1, @actor_x(t0) lw t1, @actor_x(t0)
lw t2, @actor_y(t0) lw t2, @actor_y(t0)
lw t3, @actor_z(t0) lw t3, @actor_z(t0)
mov a3, t1 // X position mov a3, t1 // X position
sw t2, 0x10(sp) // Y position sw t2, 0x10(sp) // Y position
sw t3, 0x14(sp) // Z position sw t3, 0x14(sp) // Z position
li t9, 0x0 li t9, 0x0
sw t9, 0x18(sp) // rotation? sw t9, 0x18(sp) // rotation?
lhu t7, @actor_horiz_angle(t0) lhu t7, @actor_horiz_angle(t0)
sw t7, 0x1C(sp) // horizontal rotation sw t7, 0x1C(sp) // horizontal rotation
li t9, 0x0 li t9, 0x0
sw t9, 0x20(sp) // rotation? sw t9, 0x20(sp) // rotation?
//lhu t7, @actor_horiz_angle(t0) // lhu t7, @actor_horiz_angle(t0)
li t7, 0 li t7, 0
sw t7, 0x24(sp) // actor variable sw t7, 0x24(sp) // actor variable
li t9, 0x0000007F li t9, 0x0000007F
sw t9, 0x28(sp) // unknown sw t9, 0x28(sp) // unknown
li t9, 0x000003FF li t9, 0x000003FF
sw t9, 0x2C(sp) // unknown sw t9, 0x2C(sp) // unknown
li t9, 0x00000000 li t9, 0x00000000
sw t9, 0x30(sp) // unknown sw t9, 0x30(sp) // unknown
jal @actor_spawn jal @actor_spawn
nop nop
simple_spawn_return: simple_spawn_return:
jpop 4, 9, ra jpop 4, 9, ra
hold_delay: hold_delay:
.word 0 .word 0
load_object: load_object:
// args: a0 (actor number) // args: a0 (actor number)
// returns v0 (0 if ok, 1 on error) // returns v0 (0 if ok, 1 on error)
push 4, s0, ra push 4, s0, ra
li v0, 1 li v0, 1
la t0, actor_object_table la t0, actor_object_table
sll t1, a0, 1 sll t1, a0, 1
addu t0, t0, t1 addu t0, t0, t1
lhu s0, 0(t0) // object number lhu s0, 0(t0) // object number
beq s0, r0, load_object_return beq s0, r0, load_object_return
nop nop
bal is_object_loaded bal is_object_loaded
mov a0, s0 mov a0, s0
bne v0, r0, load_object_return bne v0, r0, load_object_return
cl v0 cl v0
li t8, @global_context li t8, @global_context
li t9, @object_spawn_offset li t9, @object_spawn_offset
add a0, t8, t9 add a0, t8, t9
mov a1, s0 mov a1, s0
jal @object_spawn jal @object_spawn
nop nop
load_object_return: load_object_return:
jpop 4, s0, ra jpop 4, s0, ra
/* /*
we'll be dealing with structs like we'll be dealing with structs like
@ -156,19 +156,19 @@ typedef struct {
is_object_loaded: is_object_loaded:
// args: a0 (object number) // args: a0 (object number)
// returns v0 (1 if loaded, 0 if not) // returns v0 (1 if loaded, 0 if not)
push 4 push 4
li t8, @global_context li t8, @global_context
li t9, @object_spawn_offset li t9, @object_spawn_offset
add t0, t8, t9 // current item add t0, t8, t9 // current item
lb t1, 8(t0) // remaining items lb t1, 8(t0) // remaining items
li v0, 1 li v0, 1
is_object_loaded_loop: is_object_loaded_loop:
lh t2, 12(t0) // item's object number lh t2, 12(t0) // item's object number
beq a0, t2, is_object_loaded_return beq a0, t2, is_object_loaded_return
subi t1, t1, 1 // TODO: double check there's no off-by-one error subi t1, t1, 1 // TODO: double check there's no off-by-one error
addi t0, t0, 68 addi t0, t0, 68
bne t1, r0, is_object_loaded_loop bne t1, r0, is_object_loaded_loop
nop nop
cl v0 cl v0
is_object_loaded_return: is_object_loaded_return:
jpop 4 jpop 4