-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup.asm
343 lines (317 loc) · 6.2 KB
/
startup.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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
type(ML620909)
model large
romwindow 0, 08fffH
extrn code: _main
extrn code: _custom_break
public $$start_up
_$$SP EQU 0F000h
dw _$$SP
dw $$start_up
dw _BRK
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
dw _INT
_BRK:
b _custom_break
mov psw, #3
brk
_INT:
rti
_060EC:
PUSH LR
MOV ER2, ER0
TB 0F00AH.1
BNE _$L074
_$L00A:
DI
MOV ER0, #01H
ST ER0, 0F024H
MOV ER0, #00H
ST ER0, 0F022H
ST ER2, 0F020H
MOV R0, #01H
ST R0, 0F025H
MOV R0, #00H
ST R0, 0F014H
ST R0, 0F015H
MOV R2, #50H
MOV R3, #0A0H
ST R2, 0F008H
ST R3, 0F008H
MOV R0, #02H
ST R0, 0F009H
NOP
NOP
_$L044:
L R0, 0F042H
BNE _$L072
_$L04A:
MOV ER0, #0FH
ST ER0, 0F024H
MOV ER0, #00H
ST ER0, 0F022H
MOV R0, #9EH
MOV R1, #07H
ST ER0, 0F020H
MOV R0, #01H
ST R0, 0F025H
MOV R0, #00H
ST R0, 0F014H
ST R0, 0F015H
EI
_$L072:
POP PC
_$L074:
RB 0F00AH.1
BAL _$L00A
$$start_up:
MOV R0, #00H
ST R0, 0F000H
B _2F060
_2F060:
L R0, 0F058H
MOV R4, R0
BL _3DEDE
MOV R0, #40H
MOV R1, #06H
BL _060EC
MOV R0, #81H
ST R0, 0F00AH
MOV R0, #04H
ST R0, 0F030H
MOV R0, #03H
ST R0, 0F033H
MOV R0, #06H
ST R0, 0F034H
MOV R0, #17H
ST R0, 0F035H
MOV R0, #08H
ST R0, 0F036H
MOV R0, #00H
ST R0, 0F039H
MOV R0, #55H
ST R0, 0F031H
BL _entry
_3DEDE:
PUSH LR
MOV R0, #31H
ST R0, 0F00AH
MOV R0, #0F7H
ST R0, 0F028H
MOV R0, #32H
_$L010:
ADD R0, #-1H
CMP R0, #00H
BNE _$L010
MOV R0, #22H
ST R0, 0F010H
MOV R0, #00H
ST R0, 0F011H
ST R0, 0F012H
MOV R0, #01H
ST R0, 0F018H
MOV R0, #00H
ST R0, 0F058H
MOV R0, #00H
ST R0, 0F042H
MOV R0, #07H
ST R0, 0F03DH
MOV R0, #0C8H
MOV R1, #00H
_$L02E:
BL _060EC
MOV R0, #04H
ST R0, 0F030H
MOV R0, #07H
ST R0, 0F033H
MOV R0, #06H
ST R0, 0F034H
MOV R0, #17H
ST R0, 0F035H
MOV R0, #08H
ST R0, 0F036H
MOV R0, #00H
ST R0, 0F039H
MOV R0, #57H
ST R0, 0F031H
MOV R0, #12H
ST R0, 0F032H
MOV R0, #00H
ST R0, 0F220H
MOV R0, #7FH
ST R0, 0F221H
MOV R0, #00H
ST R0, 0F222H
MOV R0, #7FH
ST R0, 0F223H
MOV R0, #00H
ST R0, 0F224H
ST R0, 0F225H
MOV R0, #00H
ST R0, 0F048H
ST R0, 0F049H
MOV R0, #07H
ST R0, 0F04AH
MOV R0, #00H
ST R0, 0F04BH
MOV R0, #07H
ST R0, 0F04CH
MOV R0, #00H
ST R0, 0F04EH
MOV R0, #00H
ST R0, 0F041H
MOV R0, #80H
ST R0, 0F044H
MOV R0, #0FFH
ST R0, 0F045H
MOV R2, #00H
ST R2, 0F046H
POP PC
delay:
tb 00h:0f00ah.1
beq _$L27
rb 00h:0f00ah.1
_$L27 :
di
st er0, 00h:0f020h
mov er0, #0
st er0, 00h:0f022h
mov r0, #01h
mov r1, #01h
st er0, 00h:0f024h
mov er0, #0
st er0, 00h:0f014h
mov r0, #050h
st r0, 00h:0f008h
mov r0, #0a0h
st r0, 00h:0f008h
mov r0, #02h
st r0, 00h:0f009h
nop
nop
ei
rt
_entry:
mov r0, #01h
st r0, 0F018h
b _main
mov r0, #06h
st r0, 00h:0f034h
mov r0, #08h
st r0, 00h:0f036h
main_loop:
mov r13, #01h ;starting segment to read from
mov r10, #00h ;starting address to read from ill have to change this to the address right after the code
mov r11, #00h ;
loop_n:
bl decomp ;decompress the image to image buffer
push er10 ;save address after decomp (next frame data)
push r13 ;save segment after decomp (segment to read data from)
l r0, 0F037h ;load state of f037 (lcd buffer select)
xor r0, #04h ;toggle f037 buffer select
st r0, 0F037h ;store back into f037
mov r2, #00h ;buff 1
mov r3, #90h ;
mov r0, #00h ;not invert
bl FastRender_LCD;render the frame buffer to the screen (light gray)
l r0, 0F037h ;load state of f037 (lcd buffer select)
xor r0, #04h ;toggle f037 buffer select
st r0, 0F037h ;store back into f037
mov r2, #00h ;buff 2
mov r3, #96h ;
bl FastRender_LCD;render the frame buffer to the screen (dark gray)
mov r0, #35h ;delay 055A ticks
mov r1, #0Ch ;
bl delay ;
;brk
pop r13 ;restore segment to read from
pop er10 ;restore address to read from
bal loop_n ;loop
decomp:
mov r3, #90h
mov r2, #00h
push er10
mov er6, #00h
main_d:
l er0, r13:[er10]
add er10, #02h
addc r13, #00h
cmp r13, #09h
beq skib
bal cont
skib:
mov r13, #01h
cont:
mov r4, #00h
loop_d:
st r1, [er2]
add er2, #01h
add er6, #01h
cmp r7, #0Ch
beq return
add r4, #01h
cmp r0, r4
bne loop_d
bal main_d
return:
rt
FastRender_LCD:
push qr8 ; 4
push xr4 ; 2
mov r4, #00h ; 1
mov r5, #0F8h ; 1 ; ER4 = VRAM
lea [er2] ; 1 ; destination goes to EA
mov r3, #0FFh ; 1 ; 64 rows * 4 * 8 bytes in VRAM
mov r6, #37h
mov r7, #0F0h
loop:
mov r8, #03h ; 1
and r8, r3 ; 1 ; test lower 2 bits of counter
bc zf, skip ; 3/1 ; skip last 8 bytes for each row of VRAM
l qr8, [ea+] ; 5
; cmp r0, #01h
; beq is_one
; bal is_not_one
;is_one:
; xor r8, #0FFh
; xor r9, #0FFh
; xor r10, #0FFh
; xor r11, #0FFh
; xor r12, #0FFh
; xor r13, #0FFh
; xor r14, #0FFh
; xor r15, #0FFh
;is_not_one:
st er8, [er4] ; 1
add er4, #02h ; 1
st er10, [er4] ; 1
add er4, #02h ; 1
st er12, [er4] ; 1
add er4, #02h ; 1
st er14, [er4] ; 1
add er4, #02h ; 1
add r3, #0FFh ; 1
bc nz, loop ; 3
pop xr4 ; 2
pop qr8 ; 4
rt ; 2
skip:
add er4, #08h ; 1
add r3, #0FFh ; 1
bc al, loop ; 3