1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-05-18 05:23:22 -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 = [[
[overwritten]: 0x%08X
// TODO: optimize for size
// TODO: fix case where overwritten function takes 5+ args
push ra
push a0, a1, a2, a3
bal start
nop
pop a0, a1, a2, a3
jal @overwritten
nop
jpop ra
// TODO: optimize for size
// TODO: fix case where overwritten function takes 5+ args
push ra
push a0, a1, a2, a3
bal start
nop
pop a0, a1, a2, a3
jal @overwritten
nop
jpop ra
start:
]]

View File

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

View File

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