-
Notifications
You must be signed in to change notification settings - Fork 1
/
z3-customrouteslvx.asm
312 lines (305 loc) · 7.53 KB
/
z3-customrouteslvx.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
.gba
MENU_OFFSET_LVX equ 0x5
LVX_ENTRY_MAX equ 32
LVX_ENTRY_COUNT equ 6
.org REG_CUSTOM_ROUTE_MENU_LVX
.area REG_CUSTOM_ROUTE_MENU_LVX_AREA
push {r3-r7,r14}
ldr r0,=#REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES
mov r1,#0x0
mov r2,#0x2
bl draw_textline ; Draw explanation line 1
ldr r0,=#REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES+LVX_ENTRY_MAX*1
mov r1,#0x0
mov r2,#0x3
bl draw_textline ; Draw explanation line 2
ldr r5,=#ADDR_CURSOR_POSITION_LVX
ldrb r4,[r5]
ldr r7,=#ADDR_LVX_STATE
ldrb r7,[r7]
cmp r7,#0x1
bne @@after_moving_cursor
ldr r7,=#0x02001EB0 ; Fixed (input checking)
ldrh r1,[r7,#0x6]
@@check_for_down:
mov r0,#VAL_KEY_DOWN
and r0,r1
cmp r0,#0x0
beq @@check_for_up
add r0,r4,#0x1
lsl r0,r0,#0x18
lsr r4,r0,#0x18
@@check_for_up:
mov r0,#VAL_KEY_UP
and r0,r1
cmp r0,#0x0
beq @@no_up
mov r0,r4
sub r0,#0x1
lsl r0,r0,#0x18
lsr r4,r0,#0x18
@@no_up:
mov r0,r4
cmp r0,#0xFF
bne @@no_upwrap
mov r0,#LVX_ENTRY_COUNT-1
@@no_upwrap:
cmp r0,#LVX_ENTRY_COUNT
bne @@no_downwrap
mov r0,#0x0
@@no_downwrap:
lsl r0,r0,#0x18
lsr r4,r0,#0x18
@@after_moving_cursor:
ldr r0,=#REG_CUSTOM_ROUTE_MENU_ENTRIES+0x16*1
mov r1,CURSOR_OFFSET
add r2,r4,#MENU_OFFSET_LVX
bl draw_textline
strb r4,[r5]
mov r3,#0x0 ; y offset
ldr r4,=#REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES+LVX_ENTRY_MAX*2 ; First address of menu entry
mov r6,#LVX_ENTRY_MAX
@@print_menu_loop:
mov r1,#MENU_OFFSET ; x offset
mov r2,r3
add r2,#MENU_OFFSET_LVX
sub r7,r2,#MENU_OFFSET_LVX ; 0-indexed stage number
mul r7,r6 ; Stage select entry offset
add r0,r4,r7 ; Stage select entry address
bl draw_textline
add r3,#0x1
cmp r3,#LVX_ENTRY_COUNT
blt @@print_menu_loop
ldr r4,=#ADDR_LVX_STATE
ldrb r4,[r4]
cmp r4,#0x1
ble @@check_for_a
ldr r0,=#REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES+LVX_ENTRY_MAX*8
mov r1,#MENU_OFFSET
mov r2,#13
bl draw_textline
ldr r0,=#REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES+LVX_ENTRY_MAX*9
mov r1,#MENU_OFFSET
mov r2,#14
bl draw_textline
@@check_for_a:
ldr r7,=#ADDR_KEY
ldrh r1,[r7,#0x4] ; Check for A input
mov r0,#VAL_KEY_A
and r0,r1
cmp r0,#0x0
beq @@check_for_b
ldr r0,=#ADDR_LVX_STATE
ldrb r1,[r0]
cmp r1,#0x1
bgt @@confirm
mov r1,#0x2
strb r1,[r0]
b @@subr_end
@@confirm:
mov r1,#0x1
strb r1,[r0]
ldr r0,=#ADDR_CURSOR_POSITION_LVX
ldrb r2,[r0]
ldr r0,=#ADDR_STORED_CUSTOM_ROUTE_CFG
cmp r2,#0x0
beq @@goto_999_crystals
cmp r2,#0x1
beq @@goto_4_subtanks
cmp r2,#0x2
beq @@goto_swap_elves
cmp r2,#0x3
beq @@goto_swap_weapons
cmp r2,#0x4
beq @@goto_copy_route1
cmp r2,#0x5
beq @@goto_copy_route2
b @@subr_end
@@goto_999_crystals:
bl @set_999_crystals
b @@subr_end
@@goto_4_subtanks:
bl @set_4_subtanks
b @@subr_end
@@goto_swap_elves:
bl @swap_elves
b @@subr_end
@@goto_swap_weapons:
bl @swap_weapons
b @@subr_end
@@goto_copy_route1:
mov r1,#0x0
bl @copy_route
b @@subr_end
@@goto_copy_route2:
mov r1,#0x1
bl @copy_route
@@subr_end:
pop {r3-r7}
pop r0
bx r0
@@check_for_b:
mov r0,#VAL_KEY_B
and r0,r1
cmp r0,#0x0
beq @@subr_end
ldr r0,=#ADDR_LVX_STATE
ldrb r1,[r0]
cmp r1,#0x1
bgt @@cancel
mov r1,#0x0
strb r1,[r0]
b @@subr_end
@@cancel:
mov r1,#0x1
strb r1,[r0]
b @@subr_end
.pool
@set_999_crystals:
push {r3-r7,r14}
mov r3,#0x8
add r0,r0,r3
mov r3,#28
mov r4,#0x1
ldr r7,=#999
@@loop:
mov r5,r4
mul r5,r3
add r6,r0,r5
strh r7,[r6]
add r4,#0x1
cmp r4,#0x10
blt @@loop
@@subr_end:
pop {r3-r7}
pop r15
@set_4_subtanks:
push {r3-r7,r14}
mov r3,#0xA
add r0,r0,r3
mov r3,#28
mov r4,#0x1
ldr r7,=#0x20202020
@@loop:
mov r5,r4
mul r5,r3
add r6,r0,r5
str r7,[r6]
add r4,#0x1
cmp r4,#0x10
blt @@loop
@@subr_end:
pop {r3-r7}
pop r15
@swap_elves:
push {r3-r7,r14}
add r0,#2
mov r3,#28
mov r4,#0x1
@@loop:
mov r5,r4
mul r5,r3
add r6,r0,r5
ldrb r1,[r6]
ldrb r7,[r6,#0x1]
strb r1,[r6,#0x1]
strb r7,[r6]
add r4,#0x1
cmp r4,#0x10
blt @@loop
@@subr_end:
pop {r3-r7}
pop r15
@swap_weapons:
push {r3-r7,r14}
add r0,#14
mov r3,#28
mov r4,#0x1
@@loop:
mov r5,r4
mul r5,r3
add r6,r0,r5
ldrb r1,[r6]
ldrb r7,[r6,#0x1]
strb r1,[r6,#0x1]
strb r7,[r6]
add r4,#0x1
cmp r4,#0x10
blt @@loop
@@subr_end:
pop {r3-r7}
pop r15
@copy_route:
push {r3-r7,r14}
mov r7,r1
mov r3,#0x14
mul r3,r7
ldr r0,=#REG_STAGE_SELECT_DISPLAY
add r0,r3
ldr r1,=#ADDR_STAGE_SELECT_DISPLAY_CUSTOM
ldmia r0!,{r3-r6}
stmia r1!,{r3-r6}
ldrb r3,[r0]
strb r3,[r1]
mov r3,#0x14
mul r3,r7
ldr r0,=#REG_STAGE_SELECT_ROUTES
add r0,r3
ldr r1,=#ADDR_STAGE_SELECT_ROUTES_CUSTOM
ldmia r0!,{r3-r6}
stmia r1!,{r3-r6}
ldrb r3,[r0]
strb r3,[r1]
ldr r0,=#REG_STAGE_SETTING_POINTERS
mov r3,#0x40
mul r3,r7
add r0,r3
ldr r1,=#ADDR_STORED_CUSTOM_ROUTE_CFG
mov r2,#0x0
@@load_store_loop:
mov r4,#0x4
mul r4,r2
add r3,r0,r4
ldr r3,[r3]
ldrh r4,[r3]
strh r4,[r1]
add r3,#0x2
add r1,#0x2
ldmia r3!,{r4-r6}
stmia r1!,{r4-r6}
ldmia r3!,{r4-r6}
stmia r1!,{r4-r6}
ldrh r4,[r3]
strh r4,[r1]
add r3,#0x2
add r1,#0x2
add r2,#0x1
cmp r2,#0x10
blt @@load_store_loop
@@subr_end:
pop {r3-r7}
pop r15
.pool
.endarea
.org REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES
.area REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES_AREA
.asciiz "THE FOLLOWING OPTIONS AFFECT"
.org REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES+LVX_ENTRY_MAX*1
.asciiz "EVERY STAGE EXCEPT FOR INTRO"
.org REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES+LVX_ENTRY_MAX*2
.asciiz "999 E-CRYSTALS"
.org REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES+LVX_ENTRY_MAX*3
.asciiz "4 SUBTANKS"
.org REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES+LVX_ENTRY_MAX*4
.asciiz "SWAP ELF 1/ELF2"
.org REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES+LVX_ENTRY_MAX*5
.asciiz "SWAP MAIN/SUB WEAPON"
.org REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES+LVX_ENTRY_MAX*6
.asciiz "COPY ROUTE 1"
.org REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES+LVX_ENTRY_MAX*7
.asciiz "COPY ROUTE 2"
.org REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES+LVX_ENTRY_MAX*8
.asciiz "A: CONFIRM"
.org REG_CUSTOM_ROUTE_MENU_LVX_ENTRIES+LVX_ENTRY_MAX*9
.asciiz "B: CANCEL"
.endarea