2015-12-18 11:57:48 -08:00
|
|
|
[button_L]: 0x0020
|
2016-01-12 07:44:41 -08:00
|
|
|
[button_R]: 0x0010
|
2015-12-18 14:04:44 -08:00
|
|
|
[button_any]: 0x0F20
|
2015-12-18 10:00:15 -08:00
|
|
|
|
2016-01-13 11:20:28 -08:00
|
|
|
[min_actor_no]: 0
|
|
|
|
|
2015-12-18 14:04:44 -08:00
|
|
|
[hold_delay_amount]: 3
|
|
|
|
|
2016-04-15 12:17:46 -07:00
|
|
|
spawn:
|
2016-01-12 07:44:41 -08:00
|
|
|
push 4, s0, s1, s2, s3, s4, ra,
|
2015-12-22 17:33:38 -08:00
|
|
|
li t1, @global_context
|
2016-01-12 06:59:29 -08:00
|
|
|
lhu s0, anum
|
2015-12-22 17:33:38 -08:00
|
|
|
lw s1, hold_delay
|
2016-01-12 07:44:41 -08:00
|
|
|
lhu s2, @buttons_offset(t1)
|
|
|
|
lhu s3, avar
|
|
|
|
lw s4, selected
|
|
|
|
// set selected
|
|
|
|
// andi t2, s2, @button_R
|
|
|
|
srl s4, s2, 4
|
|
|
|
andi s4, s4, 1
|
|
|
|
// handle hold delay
|
2016-01-12 06:59:29 -08:00
|
|
|
andi t4, s2, @button_any
|
2016-01-02 06:00:05 -08:00
|
|
|
bnez t4, +
|
2015-12-22 17:33:38 -08:00
|
|
|
addi s1, s1, 1
|
|
|
|
li s1, 0
|
2016-01-02 04:07:18 -08:00
|
|
|
+:
|
2016-01-02 06:00:05 -08:00
|
|
|
beqi s1, 1, +
|
2015-12-22 17:33:38 -08:00
|
|
|
nop
|
|
|
|
subi t4, s1, @hold_delay_amount
|
|
|
|
bltz t4, return
|
|
|
|
nop
|
2016-01-12 07:44:41 -08:00
|
|
|
+: // handle dpad
|
|
|
|
bnez s4, +
|
2016-01-12 06:59:29 -08:00
|
|
|
mov a1, s2
|
2016-05-18 03:24:20 -07:00
|
|
|
call dpad_control, s0, a1
|
2016-01-12 06:59:29 -08:00
|
|
|
mov s0, v0
|
2016-01-12 07:44:41 -08:00
|
|
|
b ++
|
|
|
|
nop
|
|
|
|
+:
|
2016-05-18 03:24:20 -07:00
|
|
|
call dpad_control, s3, a1
|
2016-01-12 08:13:26 -08:00
|
|
|
andi s3, v0, 0xFFFF
|
2016-01-12 07:44:41 -08:00
|
|
|
+: // set min/max on actor number
|
2016-01-13 11:20:28 -08:00
|
|
|
subi t4, s0, @min_actor_no
|
2016-01-02 04:07:18 -08:00
|
|
|
bgez t4, +
|
2015-12-22 17:33:38 -08:00
|
|
|
nop
|
2016-01-12 06:59:29 -08:00
|
|
|
li s0, @max_actor_no
|
2016-01-02 04:07:18 -08:00
|
|
|
+:
|
2016-01-12 06:59:29 -08:00
|
|
|
subi t4, s0, @max_actor_no
|
2016-01-02 04:07:18 -08:00
|
|
|
blez t4, +
|
2015-12-22 17:33:38 -08:00
|
|
|
nop
|
2016-01-13 11:20:28 -08:00
|
|
|
li s0, @min_actor_no
|
2016-01-12 07:44:41 -08:00
|
|
|
+: // spawn
|
2016-01-12 06:59:29 -08:00
|
|
|
andi t3, s2, @button_L
|
2016-01-02 06:00:05 -08:00
|
|
|
beqz t3, return
|
2015-12-22 17:33:38 -08:00
|
|
|
nop
|
2016-01-12 06:59:29 -08:00
|
|
|
mov a0, s0
|
2016-01-12 08:13:26 -08:00
|
|
|
mov a1, s3
|
2015-12-22 17:33:38 -08:00
|
|
|
bal simple_spawn
|
|
|
|
nop
|
2015-12-18 10:00:15 -08:00
|
|
|
return:
|
2016-01-12 06:59:29 -08:00
|
|
|
// render actor number
|
2016-05-18 03:24:20 -07:00
|
|
|
call simple_text, 0x0001001C, 0x88CCFFFF, fmt, s0
|
2016-01-12 06:59:29 -08:00
|
|
|
// render actor variable
|
2016-05-18 03:24:20 -07:00
|
|
|
call simple_text, 0x0006001C, 0xFFCC88FF, fmt, s3
|
2016-01-12 07:44:41 -08:00
|
|
|
// done
|
|
|
|
sh s0, anum
|
|
|
|
sw s1, hold_delay
|
|
|
|
sh s3, avar
|
|
|
|
sw s4, selected
|
2016-05-18 03:24:20 -07:00
|
|
|
ret 4, s0, s1, s2, s3, s4, ra,
|
2015-12-18 14:04:44 -08:00
|
|
|
|
2016-01-12 06:59:29 -08:00
|
|
|
anum:
|
|
|
|
.word 0
|
|
|
|
avar:
|
|
|
|
.word 0
|
2016-01-12 07:44:41 -08:00
|
|
|
selected:
|
|
|
|
.word 0
|
2015-12-18 14:04:44 -08:00
|
|
|
|
2016-01-12 06:59:29 -08:00
|
|
|
fmt:
|
2016-01-13 11:20:28 -08:00
|
|
|
.asciiz "%04X"
|
2016-01-12 06:59:29 -08:00
|
|
|
.align
|
2015-12-18 14:04:44 -08:00
|
|
|
|
2016-01-12 06:59:29 -08:00
|
|
|
.include "dpad control.asm"
|
|
|
|
.include "simple spawn.asm"
|
|
|
|
.include "simple text.asm"
|
2015-12-18 14:04:44 -08:00
|
|
|
|
|
|
|
hold_delay:
|
2015-12-22 17:33:38 -08:00
|
|
|
.word 0
|
2015-12-22 14:12:20 -08:00
|
|
|
|
2016-01-13 11:20:28 -08:00
|
|
|
object_spawn_wrap:
|
|
|
|
// a0: object table
|
|
|
|
// a1: object number
|
|
|
|
beqz a0, +
|
|
|
|
nop
|
|
|
|
beqi a0, 1, +
|
|
|
|
nop
|
|
|
|
beqi a0, 2, +
|
|
|
|
nop
|
2016-05-18 03:24:20 -07:00
|
|
|
call @object_spawn, a0, a1
|
2016-01-13 11:20:28 -08:00
|
|
|
+:
|
|
|
|
jr
|
|
|
|
nop
|
|
|
|
|
2016-01-03 04:11:51 -08:00
|
|
|
.org @object_index
|
2016-01-13 11:20:28 -08:00
|
|
|
// a0: object table
|
|
|
|
// a1: object number
|
2016-01-03 04:11:51 -08:00
|
|
|
// we have space for 22 instructions (on debug, 23 on 1.0?)
|
|
|
|
push 4, ra, 1
|
|
|
|
mov t0, a0
|
|
|
|
lbu t1, 8(a0) // remaining items
|
2015-12-22 17:33:38 -08:00
|
|
|
cl v0
|
2016-01-02 04:07:18 -08:00
|
|
|
-:
|
2015-12-22 17:33:38 -08:00
|
|
|
lh t2, 12(t0) // item's object number
|
2016-01-03 04:11:51 -08:00
|
|
|
// t2 = abs(t2)
|
|
|
|
bgez t2, +
|
|
|
|
nop
|
|
|
|
subu t2, r0, t2
|
|
|
|
+:
|
|
|
|
beq a1, t2, +
|
|
|
|
subi t1, t1, 1
|
|
|
|
addiu v0, v0, 1
|
2015-12-22 17:33:38 -08:00
|
|
|
addi t0, t0, 68
|
2016-01-02 06:00:05 -08:00
|
|
|
bnez t1, -
|
2015-12-22 17:33:38 -08:00
|
|
|
nop
|
2016-05-18 03:24:20 -07:00
|
|
|
call @object_spawn, a0, a1
|
2016-01-03 04:11:51 -08:00
|
|
|
//subiu v0, r0, -1 // original code
|
2016-01-02 04:26:18 -08:00
|
|
|
+:
|
2016-05-18 03:24:20 -07:00
|
|
|
ret 4, ra, 1
|