-
Notifications
You must be signed in to change notification settings - Fork 0
/
tvout.asm
824 lines (821 loc) · 12.8 KB
/
tvout.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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
.cpu cortex-m3
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 1
.eabi_attribute 30, 6
.eabi_attribute 34, 1
.eabi_attribute 18, 4
.file "tvout.c"
.comm month_name,52,4
.comm day_name,32,4
.section .rodata
.align 2
.type palette, %object
.size palette, 8
palette:
.short 0
.short 256
.short 4096
.short 4352
.bss
video_mode:
.space 1
.size video_mode, 1
.align 1
task:
.space 2
.size task, 2
.align 1
flags:
.space 2
.size flags, 2
.align 1
slice:
.space 2
.size slice, 2
.align 1
scan_line:
.space 2
.size scan_line, 2
.comm pad,2,2
.section .rodata
.align 2
.type video_params, %object
.size video_params, 72
video_params:
.byte 0
.space 1
.short 22
.short 246
.short 840
.byte 90
.byte 2
.byte 20
.space 1
.short 180
.short 112
.short 4352
.byte 1
.space 1
.short 38
.short 230
.short 840
.byte 64
.byte 3
.byte 20
.space 1
.short 128
.short 64
.short 4352
.byte 2
.space 1
.short 38
.short 230
.short 840
.byte 64
.byte 3
.byte 20
.space 1
.short 128
.short 64
.short 0
.byte 3
.space 1
.short 22
.short 246
.short 840
.byte 32
.byte 7
.byte 0
.space 1
.short 64
.short 32
.short 0
.comm video_buffer,10080,4
.text
.align 1
.global tvout_init
.syntax unified
.thumb
.thumb_func
.fpu softvfp
.type tvout_init, %function
tvout_init:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 1, uses_anonymous_args = 0
push {r7, lr}
add r7, sp, #0
ldr r3, .L2
ldr r2, .L2+4
str r2, [r3]
ldr r3, .L2+8
ldr r2, .L2+12
str r2, [r3]
movs r2, #10
movs r1, #8
ldr r0, .L2
bl config_pin
ldr r3, .L2
movs r2, #0
str r2, [r3, #12]
ldr r2, .L2+16
ldr r3, .L2+16
ldr r3, [r3, #24]
orr r3, r3, #2048
str r3, [r2, #24]
ldr r3, .L2+20
movs r2, #120
str r2, [r3, #24]
ldr r3, .L2+20
movs r2, #1
str r2, [r3, #32]
ldr r3, .L2+20
movs r2, #132
str r2, [r3]
ldr r3, .L2+20
movw r2, #4549
str r2, [r3, #44]
ldr r3, .L2+20
mov r2, #336
str r2, [r3, #52]
ldr r3, .L2+20
movw r2, #365
str r2, [r3, #56]
ldr r2, .L2+20
ldr r3, .L2+20
ldr r3, [r3, #20]
orr r3, r3, #1
str r3, [r2, #20]
ldr r3, .L2+20
mov r2, #32768
str r2, [r3, #68]
ldr r3, .L2+20
movs r2, #0
str r2, [r3, #16]
ldr r2, .L2+20
ldr r3, .L2+20
ldr r3, [r3, #12]
orr r3, r3, #1
str r3, [r2, #12]
movs r1, #0
movs r0, #25
bl set_int_priority
movs r1, #0
movs r0, #27
bl set_int_priority
movs r0, #27
bl enable_interrupt
movs r0, #25
bl enable_interrupt
ldr r2, .L2+20
ldr r3, .L2+20
ldr r3, [r3]
orr r3, r3, #1
str r3, [r2]
movs r2, #10
movs r1, #0
ldr r0, .L2+24
bl config_pin
movs r2, #10
movs r1, #1
ldr r0, .L2+24
bl config_pin
ldr r2, .L2+16
ldr r3, .L2+16
ldr r3, [r3, #28]
orr r3, r3, #2
str r3, [r2, #28]
ldr r3, .L2+28
movw r2, #24696
str r2, [r3, #28]
ldr r3, .L2+28
mov r2, #8448
str r2, [r3, #32]
ldr r3, .L2+28
movs r2, #132
str r2, [r3]
ldr r3, .L2+28
movs r2, #19
str r2, [r3, #44]
ldr r3, .L2+28
movs r2, #10
str r2, [r3, #60]
ldr r3, .L2+28
movs r2, #10
str r2, [r3, #64]
ldr r2, .L2+28
ldr r3, .L2+28
ldr r3, [r3, #68]
orr r3, r3, #32768
str r3, [r2, #68]
ldr r2, .L2+28
ldr r3, .L2+28
ldr r3, [r3, #20]
orr r3, r3, #1
str r3, [r2, #20]
ldr r3, .L2+28
movs r2, #0
str r2, [r3, #16]
ldr r2, .L2+28
ldr r3, .L2+28
ldr r3, [r3]
orr r3, r3, #1
str r3, [r2]
nop
pop {r7, pc}
.L3:
.align 2
.L2:
.word 1073809408
.word -2004339917
.word 1073809412
.word -2008791996
.word 1073876992
.word 1073818624
.word 1073810432
.word 1073742848
.size tvout_init, .-tvout_init
.align 1
.global TV_OUT_handler
.syntax unified
.thumb
.thumb_func
.fpu softvfp
.type TV_OUT_handler, %function
TV_OUT_handler:
@ Stack Align: May be called with mis-aligned SP.
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
mov r0, sp
bic r1, r0, #7
mov sp, r1
push {r0, r4, r5, r6, lr}
ldr r3, .L15
ldrb r0, [r3] @ zero_extendqisi2
cmp r0, #1
bls .L14
.L5:
ldr r3, .L15+4
ldrh r3, [r3]
tst r3, #4
beq .L7
add r3, r0, r0, lsl #3
ldr r2, .L15+8
add r3, r2, r3, lsl #1
ldrh r2, [r3, #6]
ldr r1, .L15+12
.L8:
ldr r3, [r1, #36]
cmp r3, r2
bcc .L8
ldr r3, .L15+16
.syntax unified
@ 213 "tvout.c" 1
mov r2,r3
ldr r2,[r2,#0]
and r2,#15
lsl r2,#1
add pc,pc,r2
.rept 16
nop
.endr
@ 0 "" 2
.thumb
.syntax unified
ldr r5, .L15+20
ldr r6, [r5, #32]
ldr r2, .L15+8
lsls r1, r0, #3
adds r3, r1, r0
add r3, r2, r3, lsl #1
ldrh r4, [r3, #16]
orrs r4, r4, r6
str r4, [r5, #32]
ldr r4, .L15+24
ldrh r5, [r4]
uxth r5, r5
ldrb r4, [r3, #8] @ zero_extendqisi2
ldrb r3, [r3, #9] @ zero_extendqisi2
sdiv r5, r5, r3
ldr r3, .L15+28
mla r5, r4, r5, r3
add r0, r0, r1
add r2, r2, r0, lsl #1
ldrb r0, [r2, #10] @ zero_extendqisi2
cbz r4, .L9
mov r1, r5
ldr r4, .L15+32
ldr r6, .L15+8
ldr lr, .L15
.L10:
ldrb r3, [r1] @ zero_extendqisi2
lsrs r3, r3, #4
strh r3, [r4] @ movhi
.syntax unified
@ 219 "tvout.c" 1
mov r2,r0
lsl r2,#1
add pc,pc,r2
.rept 21
nop
.endr
@ 0 "" 2
.thumb
.syntax unified
ldrb r3, [r1], #1 @ zero_extendqisi2
and r3, r3, #15
strh r3, [r4] @ movhi
.syntax unified
@ 221 "tvout.c" 1
mov r2,r0
lsl r2,#1
add pc,pc,r2
.rept 21
nop
.endr
@ 0 "" 2
.thumb
.syntax unified
subs r2, r1, r5
ldrb r3, [lr] @ zero_extendqisi2
add r3, r3, r3, lsl #3
add r3, r6, r3, lsl #1
ldrb r3, [r3, #8] @ zero_extendqisi2
cmp r2, r3
bcc .L10
.L9:
movs r2, #0
ldr r3, .L15+36
str r2, [r3, #12]
ldr r2, .L15+20
ldr r3, [r2, #32]
bic r3, r3, #4352
str r3, [r2, #32]
.L7:
ldr r2, .L15+12
ldr r3, [r2, #16]
bic r3, r3, #4
str r3, [r2, #16]
pop {r0, r4, r5, r6, lr}
mov sp, r0
bx lr
.L14:
ldr r2, .L15+20
ldr r3, [r2, #32]
orr r3, r3, #256
str r3, [r2, #32]
add r2, r2, #75776
.L6:
ldr r3, [r2, #36]
cmp r3, #572
bls .L6
ldr r2, .L15+20
ldr r3, [r2, #32]
bic r3, r3, #256
str r3, [r2, #32]
b .L5
.L16:
.align 2
.L15:
.word video_mode
.word flags
.word video_params
.word 1073818624
.word 1073818660
.word 1073742848
.word slice
.word video_buffer
.word 1073809420
.word 1073809408
.size TV_OUT_handler, .-TV_OUT_handler
.align 1
.global TV_SYNC_handler
.syntax unified
.thumb
.thumb_func
.fpu softvfp
.type TV_SYNC_handler, %function
TV_SYNC_handler:
@ Stack Align: May be called with mis-aligned SP.
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
mov r0, sp
bic r1, r0, #7
mov sp, r1
push {r0}
ldr r2, .L37
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
ldr r3, .L37+4
ldrh r3, [r3]
uxth r3, r3
cmp r3, #7
bhi .L18
tbh [pc, r3, lsl #1]
.L20:
.2byte (.L19-.L20)/2
.2byte (.L21-.L20)/2
.2byte (.L22-.L20)/2
.2byte (.L23-.L20)/2
.2byte (.L24-.L20)/2
.2byte (.L25-.L20)/2
.2byte (.L26-.L20)/2
.2byte (.L27-.L20)/2
.p2align 1
.L19:
ldr r3, .L37+8
ldrh r3, [r3]
uxth r3, r3
cbz r3, .L33
ldr r2, .L37+8
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
ldrh r3, [r2]
uxth r3, r3
cmp r3, #6
bne .L18
movs r2, #0
ldr r3, .L37+8
strh r2, [r3] @ movhi
ldr r2, .L37+4
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
b .L18
.L33:
ldr r3, .L37+12
movw r2, #2274
str r2, [r3, #44]
movs r2, #164
str r2, [r3, #52]
ldr r2, .L37+8
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
b .L18
.L21:
ldr r3, .L37+8
ldrh r3, [r3]
uxth r3, r3
cbz r3, .L34
ldr r2, .L37+8
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
ldrh r3, [r2]
uxth r3, r3
cmp r3, #6
bne .L18
movs r2, #0
ldr r3, .L37+8
strh r2, [r3] @ movhi
ldr r2, .L37+4
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
b .L18
.L34:
movw r2, #1940
ldr r3, .L37+12
str r2, [r3, #52]
ldr r2, .L37+8
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
b .L18
.L22:
ldr r3, .L37+8
ldrh r3, [r3]
uxth r3, r3
cbz r3, .L35
ldr r3, .L37+8
ldrh r3, [r3]
uxth r3, r3
cmp r3, #6
beq .L36
ldr r2, .L37+8
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
b .L18
.L35:
movs r2, #164
ldr r3, .L37+12
str r2, [r3, #52]
ldr r2, .L37+8
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
b .L18
.L36:
ldr r2, .L37+4
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
ldr r3, .L37+16
ldrh r3, [r3]
tst r3, #1
beq .L18
.L23:
ldr r2, .L37+12
movw r3, #4549
str r3, [r2, #44]
mov r3, #336
str r3, [r2, #52]
ldr r1, .L37+16
ldrh r3, [r1]
bic r3, r3, #2
lsls r3, r3, #16
lsrs r3, r3, #16
strh r3, [r1] @ movhi
ldr r1, .L37
ldrh r3, [r1]
ubfx r3, r3, #2, #14
strh r3, [r1] @ movhi
ldr r1, .L37+4
ldrh r3, [r1]
adds r3, r3, #1
uxth r3, r3
strh r3, [r1] @ movhi
ldr r3, [r2, #16]
bic r3, r3, #4
str r3, [r2, #16]
ldr r3, [r2, #12]
orr r3, r3, #4
str r3, [r2, #12]
.L18:
ldr r2, .L37+12
ldr r3, [r2, #16]
bic r3, r3, #1
str r3, [r2, #16]
pop {r0}
mov sp, r0
bx lr
.L24:
ldr r3, .L37+20
ldr r3, [r3, #8]
bic r3, r3, #16128
bic r3, r3, #15
uxth r3, r3
ldr r2, .L37+24
strh r3, [r2] @ movhi
ldr r2, .L37+4
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
b .L18
.L25:
ldr r3, .L37
ldrh r2, [r3]
uxth r2, r2
ldr r3, .L37+28
ldrb r3, [r3] @ zero_extendqisi2
add r3, r3, r3, lsl #3
ldr r1, .L37+32
add r3, r1, r3, lsl #1
ldrh r3, [r3, #2]
cmp r3, r2
bne .L18
ldr r2, .L37+4
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
movs r2, #0
ldr r3, .L37+8
strh r2, [r3] @ movhi
ldr r2, .L37+16
ldrh r3, [r2]
uxth r3, r3
orr r3, r3, #4
strh r3, [r2] @ movhi
b .L18
.L26:
ldr r2, .L37+8
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
ldr r3, .L37
ldrh r2, [r3]
uxth r2, r2
ldr r3, .L37+28
ldrb r3, [r3] @ zero_extendqisi2
add r3, r3, r3, lsl #3
ldr r1, .L37+32
add r3, r1, r3, lsl #1
ldrh r3, [r3, #4]
cmp r3, r2
bne .L18
ldr r2, .L37+4
ldrh r3, [r2]
adds r3, r3, #1
uxth r3, r3
strh r3, [r2] @ movhi
ldr r2, .L37+16
ldrh r3, [r2]
bic r3, r3, #4
lsls r3, r3, #16
lsrs r3, r3, #16
strh r3, [r2] @ movhi
b .L18
.L27:
ldr r3, .L37
ldrh r3, [r3]
uxth r3, r3
movw r2, #263
cmp r3, r2
bne .L18
ldr r3, .L37+16
ldrh r3, [r3]
tst r3, #1
beq .L32
movw r2, #2274
ldr r3, .L37+12
str r2, [r3, #44]
.L32:
ldr r2, .L37+16
ldrh r3, [r2]
uxth r3, r3
eor r3, r3, #1
strh r3, [r2] @ movhi
ldrh r3, [r2]
uxth r3, r3
orr r3, r3, #2
strh r3, [r2] @ movhi
movs r3, #0
ldr r2, .L37
strh r3, [r2] @ movhi
ldr r2, .L37+8
strh r3, [r2] @ movhi
ldr r2, .L37+4
strh r3, [r2] @ movhi
ldr r2, .L37+12
ldr r3, [r2, #12]
bic r3, r3, #4
str r3, [r2, #12]
b .L18
.L38:
.align 2
.L37:
.word scan_line
.word task
.word slice
.word 1073818624
.word flags
.word 1073809408
.word pad
.word video_mode
.word video_params
.size TV_SYNC_handler, .-TV_SYNC_handler
.align 1
.global frame_sync
.syntax unified
.thumb
.thumb_func
.fpu softvfp
.type frame_sync, %function
frame_sync:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 1, uses_anonymous_args = 0
@ link register save eliminated.
push {r7}
add r7, sp, #0
nop
.L40:
ldr r3, .L41
ldrh r3, [r3] @ movhi
uxth r3, r3
and r3, r3, #2
cmp r3, #0
beq .L40
nop
mov sp, r7
@ sp needed
pop {r7}
bx lr
.L42:
.align 2
.L41:
.word flags
.size frame_sync, .-frame_sync
.align 1
.global btn_wait_any
.syntax unified
.thumb
.thumb_func
.fpu softvfp
.type btn_wait_any, %function
btn_wait_any:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 1, uses_anonymous_args = 0
@ link register save eliminated.
push {r7}
add r7, sp, #0
nop
.L44:
ldr r3, .L46
ldrh r3, [r3] @ movhi
uxth r3, r3
mov r2, r3
movw r3, #49392
ands r3, r3, r2
movw r2, #49392
cmp r3, r2
beq .L44
ldr r3, .L46
ldrh r3, [r3] @ movhi
uxth r3, r3
mvns r3, r3
uxth r3, r3
mov r0, r3
mov sp, r7
@ sp needed
pop {r7}
bx lr
.L47:
.align 2
.L46:
.word pad
.size btn_wait_any, .-btn_wait_any
.align 1
.global set_video_mode
.syntax unified
.thumb
.thumb_func
.fpu softvfp
.type set_video_mode, %function
set_video_mode:
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 1, uses_anonymous_args = 0
push {r7, lr}
sub sp, sp, #8
add r7, sp, #0
mov r3, r0
strb r3, [r7, #7]
bl gfx_cls
bl frame_sync
ldr r2, .L49
ldrb r3, [r7, #7]
strb r3, [r2]
nop
adds r7, r7, #8
mov sp, r7
@ sp needed
pop {r7, pc}
.L50:
.align 2
.L49:
.word video_mode
.size set_video_mode, .-set_video_mode
.align 1
.global get_video_params
.syntax unified
.thumb
.thumb_func
.fpu softvfp
.type get_video_params, %function
get_video_params:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 1, uses_anonymous_args = 0
@ link register save eliminated.
push {r7}
add r7, sp, #0
ldr r3, .L53
ldrb r3, [r3] @ zero_extendqisi2
mov r2, r3
mov r3, r2
lsls r3, r3, #3
add r3, r3, r2
lsls r3, r3, #1
ldr r2, .L53+4
add r3, r3, r2
mov r0, r3
mov sp, r7
@ sp needed
pop {r7}
bx lr
.L54:
.align 2
.L53:
.word video_mode
.word video_params
.size get_video_params, .-get_video_params
.ident "GCC: (15:6.3.1+svn253039-1build1) 6.3.1 20170620"