-
Notifications
You must be signed in to change notification settings - Fork 3
/
american_v1.05.s
10019 lines (9905 loc) · 301 KB
/
american_v1.05.s
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
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;; ========== INTERRUPT VECTOR TABLE ==========
;; Reset ISR
.org 0
jmp label_0200
.byte $FF
;; INT0 (external) ISR
.org $0003
jmp label_004F
.byte $FF, $FF, $FF, $FF, $FF, $FF
;; INT1 (external) ISR
.org $000B
jmp label_0052
.byte $FF, $FF, $FF, $FF, $FF, $FF
;; INT2 (external) OR Timer 0 T0L overflow ISR
.org $0013
jmp label_0055
.byte $FF, $FF, $FF, $FF, $FF, $FF
;; INT3 (external) OR Base Timer overflow ISR
.org $001B
callf label_3DC9
reti
.byte $FF, $FF, $FF, $FF
;; Timer 0 T0H or T0H overflow ISR
.org $0023
jmp label_005A
.byte $FF, $FF, $FF, $FF, $FF, $FF
;; Timer 1 T1H or T1L overflow ISR
.org $002B
jmp label_005D
.byte $FF, $FF, $FF, $FF, $FF, $FF
;; SIO0 (Serial Port 0) ISR
.org $0033
callf label_25E4
reti
.byte $FF, $FF, $FF, $FF
;; SIO1 (Serial Port 1) ISR
.org $003B
callf label_260E
reti
.byte $FF, $FF, $FF, $FF
;; RFB (VMU-to-VMU receive/detect) ISR
.org $0043
callf label_05E8
reti
.byte $FF, $FF, $FF, $FF
;; P3 ISR
.org $004B
callf P3_IRQ_Vector
reti
;; ========== END INTERRUPT VECTOR TABLE ==========
label_004F:
clr1 i01cr, $01
reti
label_0052:
clr1 i01cr, $05
reti
label_0055:
clr1 t0con, $01
clr1 i23cr, $05
reti
label_005A:
clr1 t0con, $03
reti
label_005D:
clr1 t1cnt, $01
clr1 t1cnt, $03
reti
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
;; ========== PUBLIC FIRMWARE SUBROUTINES ==========
;; FM_WRT_EX (Write to Flash Memory)
.org $0100
callf label_3CB7
not1 ext, $00
jmpf $0105
;; FM_WRTA_EX (Write to Flash Memory)
.org $0108
callf label_3CB7
not1 ext, $00
jmpf $010B
;; FM_VRF_EX (Flash Memory Verify)
.org $0110
callf label_E01B
not1 ext, $00
jmpf $0115
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
;; FM_PRD_EX (Flash Memory Page Data Readout)
.org $0120
callf label_E027
not1 ext, $00
jmpf $0125
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
;; TIMER_EX (Base Timer/Clock 1/2 Second Clock Update)
.org $0130
callf label_3DC9
not1 ext, $00
jmpf $0139
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
;; SLEEP_EX (Sleep/CPU Halt)
.org $0140
callf label_0421
not1 ext, $00
jmpf $0145
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
;; EXIT_EX (Mode Button)
.org $01F0
brf label_3C5C
.byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
;; ========== END PUBLIC FIRMWARE SUBROUTINES ==========
label_0200:
mov #$A3, ocr
mov #$7F, sp ; initialize stack pointer
clr1 psw, rambk0 ; change to system RAM
clr1 p3int, $00
mov #$FF, $6E
mov #$FF, $67
callf label_3BA9
callf label_338F
callf label_33E6
ld $70
be #$F0, label_0220
br label_024C
label_0220:
mov #$04, b
mov #$00, acc
mov #$2C, $00
label_0229:
push b
push acc
ld @R0
inc $00
st b
pop acc
push acc
mov #$C3, trl
mov #$05, trh
ldc
sub b
bnz label_024C
pop acc
inc acc
pop b
dbnz b, label_0229
br label_0294
label_024C:
mov #$7F, sp
mov #$02, c
clr1 psw, rambk0
mov #$00, acc
label_0257:
mov #$00, $00
mov #$40, b
label_025D:
st @R0
inc $00
st @R0
inc $00
st @R0
inc $00
st @R0
inc $00
dbnz b, label_025D
mov #$00, $00
set1 psw, rambk0
dbnz c, label_0257
clr1 psw, rambk0
mov #$2C, $00
mov #$00, acc
mov #$04, b
label_027F:
push acc
mov #$C3, trl
mov #$05, trh
ldc
st @R0
pop acc
inc $00
inc acc
dbnz b, label_027F
clr1 psw, rambk0
label_0294:
mov #$00, $70
mov #$00, $67
callf label_1007
callf label_1017
clr1 vsel, $00
clr1 vsel, $01
clr1 mapletxrxctl, $02
mov #$00, $6E
mov #$00, $30
mov #$00, $35
label_02AF:
ld $31
bnz label_02EF
mov #$00, $6C
callf label_1253
ld p7
and #$01
bz label_02C2
jmpf label_3EA7
label_02C2:
push ocr
mov #$81, ocr
mov #$02, xbnk
mov #$00, xram_0181
mov #$00, xram_0182
mov #$04, xram_0183
mov #$00, xram_0184
mov #$00, xbnk
pop ocr
mov #$40, $35
callf label_129D
bnz label_02EF
mov #$FF, $31
mov #$00, $6E
mov #$00, $30
mov #$00, $35
label_02EF: ; lots of locations calls here, looks like a big deal
clr1 psw, rambk0 ; BIOS RAM
clr1 p3int, $00 ; P3 interrupts off
ld p7 ; get port 7 and isolate the 5V detect pin
and #$01
bnz label_0337
ld $31
bz label_02AF
callf label_3BA9
mov #$C7, trl
mov #$05, trh
mov #$00, $60
mov #$00, $61
callf label_3A05
set1 p3int, $00
mov #$01, $33
mov #$00, $34
label_0317: ;
set1 pcon, $00
ld p7
and #$01
bnz label_0337
ld $33
bz label_0333
ld $35
bnz label_0333
ld $30
bz label_033A
be #$01, label_0360
be #$02, label_0387
br label_0317
label_0333:
call label_0421
br label_0317
label_0337:
jmpf label_3EA7
label_033A:
ld $70
and #$10
bnz label_035E
ld $34
bz label_0317
mov #$00, $34
push ocr
mov #$81, ocr
mov #$02, xbnk
not1 xram_0181, $06
mov #$00, xram_0182
mov #$00, xram_0183
mov #$00, xbnk
pop ocr
br label_0317
label_035E:
jmp label_03AE
label_0360:
ld $70
and #$10
bnz label_0384
ld $34
bz label_0317
mov #$00, $34
push ocr
mov #$81, ocr
mov #$02, xbnk
not1 xram_0182, $04
mov #$00, xram_0181
mov #$00, xram_0183
mov #$00, xbnk
pop ocr
br label_0317
label_0384:
jmpf label_3C12
label_0387:
ld $70
and #$10
bnz label_03AB
ld $34
bz label_0317
mov #$00, $34
push ocr
mov #$81, ocr
mov #$02, xbnk
not1 xram_0183, $02
mov #$00, xram_0181
mov #$00, xram_0182
mov #$02, xbnk
pop ocr
jmp label_0317
label_03AB:
jmpf label_1034
label_03AE:
push ocr
mov #$81, ocr
mov #$02, xbnk
mov #$40, xram_0181
mov #$00, xram_0182
mov #$00, xram_0183
mov #$00, xbnk
pop ocr
mov #$01, fpr
mov #$01, $6F
mov #$FE, trh
mov #$00, trl
mov #$10, b
label_03D3:
ldf
xor #$55
bnz label_03E1
dbnz b, label_03D3
mov #$00, $2B
jmpf label_196F
label_03E1:
clr1 p3int, $00
callf label_3C07
mov #$0E, trl
mov #$04, trh
mov #$00, $60
mov #$00, $61
callf label_3A05
set1 p3int, $00
mov #$01, $33
label_03FA:
callf label_3696
be #$FF, label_0408
be #$FD, label_0408
be #$FE, label_040A
br label_03FA
label_0408:
jmp label_02EF
label_040A:
call label_0421
br label_03FA
.byte $46, $6F, $72, $6D, $61, $74, $20, $20, $0D, $0A, $20, $20, $6D, $65, $6D, $6F
.byte $72, $79, $00
label_0421:
push acc
push psw
clr1 psw, rambk0
push $30
push $6E
mov #$FF, $6E
mov #$00, vccr
mov #$00, mcr
callf label_3675
set1 p3int, $00
label_0439:
set1 pcon, $00
ld p7
and #$01
bnz label_045C
ld $70
and #$80
bz label_0439
mov #$09, mcr
mov #$80, vccr
mov #$00, $35
mov #$01, $33
pop $6E
pop $30
pop psw
pop acc
ret
label_045C:
mov #$09, mcr
mov #$80, vccr
mov #$00, $35
mov #$00, $30
mov #$FF, $6E
clr1 psw, rambk0
mov #$7F, sp
jmpf label_3EA7
.byte $7C, $C6, $C6, $C6, $C6, $C6, $7C, $00, $18, $38, $18, $18, $18, $18, $3C, $00
.byte $7C, $C6, $C6, $1C, $70, $C0, $FE, $00, $7C, $C6, $C6, $1C, $C6, $C6, $7C, $00
.byte $C0, $D8, $D8, $D8, $FE, $18, $3C, $00, $FE, $C0, $FC, $06, $C6, $C6, $7C, $00
.byte $7C, $C6, $C0, $FC, $C6, $C6, $7C, $00, $7E, $C6, $C6, $06, $06, $06, $06, $00
.byte $7C, $C6, $C6, $7C, $C6, $C6, $7C, $00, $7C, $C6, $C6, $7E, $06, $C6, $7C, $00
.byte $00, $30, $30, $00, $30, $30, $00, $00, $00, $FE, $7C, $38, $10, $00, $00, $00
.byte $00, $00, $10, $38, $7C, $FE, $00, $00, $02, $04, $08, $10, $20, $40, $80, $00
.byte $02, $04, $08, $10, $20, $40, $80, $00, $02, $04, $08, $10, $20, $40, $80, $00
.byte $38, $6C, $C6, $C6, $FE, $C6, $C6, $00, $FC, $C6, $C6, $FC, $C6, $C6, $FC, $00
.byte $7C, $C6, $C6, $C0, $C6, $C6, $7C, $00, $FC, $C6, $C6, $C6, $C6, $C6, $FC, $00
.byte $FC, $C0, $C0, $F8, $C0, $C0, $FC, $00, $FC, $C0, $C0, $F8, $C0, $C0, $C0, $00
.byte $7C, $C6, $C6, $C0, $DE, $C6, $7E, $00, $C6, $C6, $C6, $FE, $C6, $C6, $C6, $00
.byte $78, $30, $30, $30, $30, $30, $78, $00, $06, $06, $06, $06, $66, $66, $3C, $00
.byte $CC, $CC, $D8, $F0, $D8, $CC, $CC, $00, $C0, $C0, $C0, $C0, $C0, $C0, $FC, $00
.byte $C6, $EE, $FE, $D6, $C6, $C6, $C6, $00, $C6, $E6, $F6, $DE, $CE, $C6, $C6, $00
.byte $38, $6C, $C6, $C6, $C6, $6C, $38, $00, $FC, $C6, $C6, $FC, $C0, $C0, $C0, $00
.byte $38, $6C, $C6, $C6, $D6, $6C, $36, $00, $FC, $C6, $C6, $FC, $C6, $C6, $C6, $00
.byte $7C, $C6, $C0, $7C, $06, $C6, $7C, $00, $7E, $18, $18, $18, $18, $18, $18, $00
.byte $C6, $C6, $C6, $C6, $C6, $C6, $7C, $00, $C6, $C6, $C6, $6C, $6C, $38, $10, $00
.byte $C6, $C6, $D6, $D6, $FE, $EE, $C6, $00, $C6, $C6, $6C, $38, $6C, $C6, $C6, $00
.byte $CC, $CC, $CC, $78, $30, $30, $30, $00, $FE, $06, $0C, $38, $60, $C0, $FE, $00
.byte $52, $45, $53, $54, $20, $20, $17, $18, $19, $1A, $0D, $0A, $20, $56, $69, $73
.byte $75, $61, $6C, $0D, $0A, $20, $4D, $65, $6D, $6F, $72, $79, $0D, $0A, $20, $20
.byte $55, $6E, $69, $74, $00
; ===== MAPLE FRAME RX ENTRY POINT ======
label_05E8:
clr1 vsel, $00
push acc
push b
push c
push $00
push $01
push $02
push $03
ld maplesta
and #$76
st b
bp acc, $05, label_062F
bp acc, $04, label_062F
bp acc, $01, label_062F
ld $22
bnz label_063F
mov #$03, vrmad1
clr1 vrmad2, $00
ld vtrbf
be #$01, label_0617
jmp label_07D8
label_0617:
mov #$02, vrmad1
ld vtrbf
st c
and #$3F
sub $20
bz label_0626
jmp label_07D8
label_0626:
ld c
st $20
mov #$FF, $22
jmp label_0646
label_062F:
ld $22
bnz label_0635
jmp label_07D8
label_0635:
call label_07EB
bz label_063B
jmp label_07D8
label_063B:
call label_0800
jmp label_07D8
label_063F:
ld $22
bne #$55, label_0646
jmp label_07D8
label_0646:
call label_07EB
bz label_064C
jmp label_07D8
label_064C:
mov #$03, vrmad1
clr1 vrmad2, $00
ld vtrbf
bne #$01, label_066A
mov #$00, vrmad1
clr1 vrmad2, $00
ld vtrbf
bnz label_0666
mov #$01, $24
call label_08B9
jmp label_07D8
label_0666:
call label_0800
jmp label_07D8
label_066A:
bne #$02, label_0681
mov #$00, vrmad1
clr1 vrmad2, $00
ld vtrbf
bnz label_067D
mov #$02, $24
call label_090F
jmp label_07D8
label_067D:
call label_0800
jmp label_07D8
label_0681:
bne #$03, label_0698
mov #$00, vrmad1
clr1 vrmad2, $00
ld vtrbf
bnz label_0694
mov #$FF, $24
call label_0962
jmp label_07D8
label_0694:
call label_0800
jmp label_07D8
label_0698:
bne #$04, label_06AF
mov #$00, vrmad1
clr1 vrmad2, $00
ld vtrbf
bnz label_06AB
mov #$FF, $24
call label_0970
jmp label_07D8
label_06AB:
call label_0800
jmp label_07D8
label_06AF:
bne #$0A, label_06D7
mov #$00, vrmad1
clr1 vrmad2, $00
ld vtrbf
bne #$02, label_06D3
mov #$0A, $24
call label_0827
ld $29
be #$02, label_06CB
be #$04, label_06CF
jmp label_07D4
label_06CB:
call label_09BB
jmp label_07D8
label_06CF:
call label_0A6A
jmp label_07D8
label_06D3:
call label_0800
jmp label_07D8
label_06D7:
bne #$0B, label_0735
mov #$00, vrmad1
clr1 vrmad2, $00
ld vtrbf
bne #$02, label_0731
mov #$0B, $24
call label_0827
ld $29
be #$02, label_06F7
be #$08, label_06F3
jmp label_07D4
label_06F3:
call label_0BFE
jmp label_07D8
label_06F7:
mov #$00, vrmad1
clr1 vrmad2, $00
set1 psw, rambk0
mov #$70, $00
ld vtrbf
st @R0
inc $00
mov #$04, vrmad1
mov #$02, b
label_070C:
ld vtrbf
st @R0
inc $00
ld vtrbf
st @R0
inc $00
ld vtrbf
st @R0
inc $00
ld vtrbf
st @R0
inc $00
dbnz b, label_070C
clr1 psw, rambk0
mov #$00, $25
mov #$00, $27
call label_0858
call label_0B7D
jmp label_07D8
label_0731:
call label_0800
jmp label_07D8
label_0735:
bne #$0C, label_0756
mov #$0C, $24
call label_0827
ld $29
be #$04, label_074C
be #$08, label_0750
bne #$02, label_0754
call label_0C5B
jmp label_07D8
label_074C:
call label_0D02
jmp label_07D8
label_0750:
call label_0DBD
jmp label_07D8
label_0754:
jmp label_07D4
label_0756:
bne #$0D, label_0787
mov #$00, vrmad1
clr1 vrmad2, $00
ld vtrbf
be #$02, label_0767
call label_0800
jmp label_07D8
label_0767:
mov #$0D, $24
call label_0827
ld $29
bne #$02, label_0785
mov #$0A, vrmad1
clr1 vrmad2, $00
ld vtrbf
sub $25
bz label_077E
set1 $27, $01
label_077E:
mov #$00, $25
call label_0E5D
jmp label_07D8
label_0785:
jmp label_07D4
label_0787:
bne #$FC, label_078E
call label_0E6F
jmp label_07D8
label_078E:
bne #$09, label_07AF
mov #$09, $24
mov #$00, vrmad1
clr1 vrmad2, $00
ld vtrbf
bne #$01, label_07A9
call label_0827
ld $29
bne #$08, label_07AD
call label_0E08
jmp label_07D8
label_07A9:
call label_0800
jmp label_07D8
label_07AD:
jmp label_07D4
label_07AF:
bne #$0E, label_07D0
mov #$0E, $24
mov #$00, vrmad1
clr1 vrmad2, $00
ld vtrbf
bne #$02, label_07CA
call label_0827
ld $29
bne #$08, label_07CE
call label_0E3A ; Play maple buzzer
jmp label_07D8
label_07CA:
call label_0800
jmp label_07D8
label_07CE:
jmp label_07D4
label_07D0:
call label_097B
jmp label_07D8
label_07D4:
call label_099B
jmp label_07D8
label_07D8:
clr1 maplesta, $02
pop $03
pop $02
pop $01
pop $00
pop c
pop b
pop acc
set1 vsel, $00
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
label_07EB:
mov #$02, vrmad1
clr1 vrmad2, $00
ld vtrbf
st b
mov #$01, vrmad1
ld vtrbf
st $21
ld $20
sub b
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
label_0800:
call label_081D
mov #$00, vtrbf
ld $20
st vtrbf
ld $21
st vtrbf
mov #$FC, vtrbf
mov #$FC, $24
mov #$00, vlreg
set1 vsel, $00
set1 mapletxrxctl, $04
set1 mapletxrxctl, $00
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
label_081D: ; set WRAM to reply a MAPLE packet, called from around 20 locals
clr1 vsel, $00 ; WRAM is set to be accessed by CPU
clr1 mapletxrxctl, $04 ; no idea
mov #$00, vrmad1 ; set address to $100
set1 vrmad2, $00
ret
label_0827:
mov #$05, vrmad1
clr1 vrmad2, $00
ld vtrbf
bnz label_0854
ld vtrbf
bnz label_0854
ld vtrbf
bnz label_0854
mov #$04, vrmad1
ld vtrbf
be #$04, label_084B
be #$08, label_0850
bne #$02, label_0854
mov #$02, $29
br label_0853
label_084B:
mov #$04, $29
br label_0853
label_0850:
mov #$08, $29
label_0853:
ret
label_0854:
mov #$FF, $29
ret
label_0858:
set1 psw, rambk0
mov #$78, $00
ld @R0
bz label_0864
clr1 psw, rambk0
set1 $27, $00
label_0864:
clr1 psw, rambk0
ld $25
set1 psw, rambk0
dec $00
sub @R0
bz label_0876
clr1 psw, rambk0
set1 $27, $01
mov #$FE, $25
label_0876:
clr1 psw, rambk0
inc $25
set1 psw, rambk0
dec $00
ld @R0
bz label_0887
clr1 psw, rambk0
set1 $27, $02
set1 psw, rambk0
label_0887:
clr1 psw, rambk0
ld $27
bnz label_08B8
set1 psw, rambk0
dec $00
ld @R0
clr1 psw, cy
rolc
rolc
st b
and #$01
st $7D
ld b
and #$FC
mov #$77, $00
or @R0
st c
and #$00
rolc
mov #$80, b
mul
st $7E
ld c
st $7F
mov #$01, $7C
clr1 psw, rambk0
label_08B8:
ret
label_08B9:
call label_081D
mov #$00, $25
mov #$1C, vtrbf
ld $20
st vtrbf
ld $21
st vtrbf
mov #$05, vtrbf
mov #$95, trl
mov #$0A, trh
mov #$00, acc
mov #$03, vlreg
mov #$03, b
call label_0F4A
set1 vsel, $00
set1 mapletxrxctl, $00
call label_0FBF
mov #$06, c
label_08E6:
clr1 vsel, $00
mov #$00, vrmad1
mov #$04, b
call label_0F4A
set1 vsel, $00
set1 mapletxrxctl, $01
call label_0FBF
dbnz c, label_08E6
clr1 vsel, $00
mov #$00, vrmad1
mov #$00, vlreg
mov #$01, b
call label_0F4A
set1 vsel, $00
set1 mapletxrxctl, $04
set1 mapletxrxctl, $01
call label_0FBF
ret
label_090F:
call label_081D
mov #$00, $25
mov #$30, vtrbf
ld $20
st vtrbf
ld $21
st vtrbf
mov #$06, vtrbf
mov #$95, trl
mov #$0A, trh
mov #$00, acc
mov #$03, vlreg
mov #$03, b
call label_0F4A
set1 vsel, $00
set1 mapletxrxctl, $00
call label_0FBF
mov #$0B, c
label_093C:
clr1 vsel, $00
mov #$00, vrmad1
mov #$04, b
call label_0F4A
set1 vsel, $00
set1 mapletxrxctl, $01
call label_0FBF
dbnz c, label_093C
clr1 vsel, $00
mov #$00, vrmad1
mov #$01, b
call label_0F4A
set1 vsel, $00
set1 mapletxrxctl, $04
set1 mapletxrxctl, $01
call label_0FBF
ret
label_0962:
call label_081D
mov #$00, $25
call label_0F32
callf label_1017
callf label_3C07
ret
label_0970:
call label_081D
mov #$00, $25
call label_0F32
mov #$55, $22
ret
label_097B:
call label_081D
mov #$00, $25
mov #$00, vtrbf
ld $20
st vtrbf
ld $21
st vtrbf
mov #$FD, vtrbf
mov #$FD, $24
mov #$00, vlreg
set1 vsel, $00
set1 mapletxrxctl, $04
set1 mapletxrxctl, $00
ret
label_099B:
call label_081D
mov #$00, $25
mov #$00, vtrbf
ld $20
st vtrbf
ld $21
st vtrbf
mov #$FE, vtrbf
mov #$FE, $24
mov #$00, vlreg
set1 vsel, $00
set1 mapletxrxctl, $04
set1 mapletxrxctl, $00
ret
label_09BB:
call label_081D
mov #$00, $25
mov #$07, vtrbf
ld $20
st vtrbf
ld $21
st vtrbf
mov #$08, vtrbf
mov #$07, vlreg
mov #$00, acc
mov #$01, fpr
mov #$01, $6F
mov #$FE, trh
mov #$00, trl