-
Notifications
You must be signed in to change notification settings - Fork 1
/
softrom.lst
2150 lines (1957 loc) · 82.1 KB
/
softrom.lst
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
; **********************************************
; ************* SoftROM EEPROM tool ************
; **********************************************
;
; Assemble with "The Black Smurf Assembler"
; freely available from https://github.com/Edilbert/BSA
;
; Copyright (c) 2014 Nils Eilers <[email protected]>
; This work is free. You can redistribute it and/or modify it under the
; terms of the Do What The Fuck You Want to Public License, Version 2,
; as published by Sam Hocevar. See the COPYING file for more details.
; ************
; * Keycodes *
; ************
0009 TAB = 9 ; Tab
000d CR = 13 ; Carriage Return
0013 HOME = 19 ; Home
0014 DEL = 20 ; Delete
0093 CLR = 147 ; Clear
0011 CDOWN = 17 ; Cursor Down
001d CRIGHT = 29 ; Cursor Right
0091 CUP = 145 ; Cursor Up
009d CLEFT = 157 ; Cursor Left
; ****************
; * Screen codes *
; ****************
0000 C8296 = 0
0001 FALSE #if C8296
SKIP HOR_BAR = 102 ; -
SKIP VER_BAR = 97 ; |
SKIP UL = 104 ; upper left
SKIP UR = 106 ; upper right
SKIP LL = 98 ; lower left
SKIP LR = 100 ; lower right
SKIP TL = 101 ; T left
SKIP TR = 103 ; T right
SKIP TU = 105 ; T upper
SKIP TB = 99 ; T bottom
SKIP
#else
0040 HOR_BAR = 64 ; -
005d VER_BAR = 93 ; |
0070 UL = 112 ; upper left
006e UR = 110 ; upper right
006d LL = 109 ; lower left
007d LR = 125 ; lower right
006b TL = 107 ; T left
0073 TR = 115 ; T right
#endif
0019 ROWS = 25
; ****************************
; * Some Zero Page Variables *
; ****************************
005e BP = $5e ; Buffer Pointer
0060 STRPTR = $60 ; String Pointer
0062 SP = $62 ; SCREEN Pointer
0064 TP = $64 ; Temporary Pointer
0066 SelPtr = $66 ; Selection pointer
; ************************
; * CBM Kernal Variables *
; ************************
0096 STATUS = $96 ; Status byte
009b STKEY = $9b ; Stop key pressed?
00a7 BLNSW = $a7 ; Blink switch
00a8 BLNCT = $a8 ; Blink count
00aa BLNON = $aa ; Blink On
00c9 EAL = $c9 ; used for LOAD, SAVE and TIM
00d1 FNLEN = $d1 ; Filename length
00d3 SA = $d3 ; Secondary address
00d4 FA = $d4 ; First sddress
00da FNADR = $da ; Filename address
0342 DOS_Filename = $0342
; *************
; * Constants *
; *************
8000 Screen = $8000
0014 EntriesPerPage = 20
; *****************************************
; * Put the buffer after the program code *
; *****************************************
0f00 Buffer = [EOP & $ff00] + $100
0008 PosDiskName = 8
001a PosDiskID = 26
; ***************************************************
; * The CBM 8000 Kernal has no jump table for these *
; ***************************************************
b403 READY = $b403 ; $b3ff ; $b406 omitting prompt
f0d2 TALK = $f0d2
f0d5 LISTEN = $f0d5
f143 SECOND = $f143
f193 TKSA = $f193
f19e CIOUT = $f19e
f1ae UNTLK = $f1ae
f1b9 UNLSN = $f1b9
f1c0 ACPTR = $f1c0
ffd2 BSOUT = $ffd2
ffd2 CHROUT = $ffd2
ffe4 GETIN = $ffe4
f343 Kernal_STOP = $f343
; ***************
; * Print Macro *
; ***************
MACRO MAC_Print(lab)
LDY #<lab
LDA #>lab
LDX #?lab
JSR PrintText
ENDMAC
MACRO MAC_Plot(Row,Col,Char)
LDA #Char
LDX #Row
LDY #Col
JSR PlotAt
ENDMAC
MACRO MAC_PutString(Row,Col,Text)
LDX #Row
LDY #Col
JSR GotoXY
LDX #<Text
LDY #>Text
JSR PutString
ENDMAC
; ***************************************************
; The directory is loaded into RAM beyond the program
; SOD = Start of directory
; EOD = End of directory
; ***************************************************
; **********************************
; * BASIC header for program start *
; **********************************
0401 START = $0401
0401 * = START ; *** BASIC *** CBM / PET series
.STORE START,EOP-START,"softrom.prg"
0401 27 04 Link .WORD EndLink
; **********
0403 Linenumber
; **********
0403 df 07 .WORD 2015
; **********
0405 SysCommand
; **********
0405 9e .BYTE $9e ; SYS token
0406 28 31 30 StartML .BYTE "(1065)"
040c 3a 8f .BYTE ':',$8f ; REM token
040e 20 53 4f .BYTE " SOFTROM EEPROM TOOL 0.2"
0426 00 LineEnd .BYTE 0
0427 00 00 EndLink .WORD 0
0429 4c 3d 0a JMP Main
042c 30 30 30 NUMBER .BYTE "00000 "
0432 55 4e 49 UnitText .PET 'unit:',0
0438 44 52 49 DriveText .PET 'drive:',0
043f 3c 48 3e HelpText .BYTE "<H> = HELP",0
044a 20 53 4f ProgramText .BYTE " SOFTROM EEPROM TOOL (C) NILS EILERS & BS ",0
0475 52 45 41 Msg_READY .BYTE "READY.",0
047c 50 Cols .BYTE 80
047d 00 Count .BYTE 0
047e 00 CursorRow .BYTE 0
047f 00 CursorCol .BYTE 0
0480 00 Entries .BYTE 0
0481 00 FirstLine .BYTE 0
0482 14 LastLine .BYTE 20
0483 00 HelpScreen .BYTE 0
0484 02 Pages .BYTE 2
0485 00 00 00 ScreenLo .FILL 25 (0) ; 25 bytes
049e 00 00 00 ScreenHi .FILL 25 (0) ; 25 bytes
04b7 00 00 00 EntryLo .FILL 40 (0) ; 40 bytes
04df 00 00 00 EntryHi .FILL 40 (0) ; 40 bytes
0507 00 Page .BYTE 0
0508 00 Offset .BYTE 0
0509 08 Unit .BYTE 8
050a 30 Drive .BYTE '0'
050b 00 LV0 .BYTE 0
050c 00 LV1 .BYTE 0
050d 00 Reverse .BYTE 0
050e 02 Select .BYTE 2
050f 00 FirstFile .BYTE 0 ; First file on display
0510 00 00 SOD .WORD 0 ; Start Of Directory
0512 00 00 EOD .WORD 0 ; End Of Directory
0514 00 TargetLo .BYTE $00
0515 90 TargetHi .BYTE $90
0516 00 SelectionLo .BYTE 0
0517 00 SelectionHi .BYTE 0
0518 10 SelFilename .BYTE 16
80c9 DiskStatus = $8000 + 201
001e HelpLen = 30
0007 HelpLines = 7
0519 55 50 2f HelpWin .BYTE "UP/DN MOVE SELECTION BAR ",0
0537 2b 20 2f .BYTE "+ / - CHANGE UNIT OR DRIVE #",0
0555 48 4f 4d .BYTE "HOME RESET THE SCREEN ",0
0573 52 45 54 .BYTE "RETURN FLASH EEPROM FROM FILE",0
0591 53 54 4f .BYTE "STOP QUIT THE PROGRAM ",0
05af 48 20 20 .BYTE "H SHOW THIS HELP WINDOW ",0
05cd 45 53 43 .BYTE "ESC CLOSE HELP WINDOW ",0
; ********
05eb ShowHelp
; ********
05eb a9 00 LDA #0
05ed 8d 08 05 STA Offset
05f0 a2 35 LDX #53
05f2 8e 7d 04 STX Count
05f5 a2 08 LDX #8
05f7 a0 18 LDY #24
05f9 20 bd 0a JSR HorLine
05fc a2 10 LDX #16
05fe a0 18 LDY #24
0600 20 bd 0a JSR HorLine
0603 a2 10 LDX #16
0605 8e 7d 04 STX Count
0608 a2 08 LDX #8
060a a0 17 LDY #23
060c 20 d8 0a JSR VerLine
060f a2 08 LDX #8
0611 a0 35 LDY #53
0613 20 d8 0a JSR VerLine
MAC_Plot( 8,23,UL)
0616 a9 70 LDA #UL
0618 a2 08 LDX #8
061a a0 17 LDY #23
061c 20 61 0b JSR PlotAt
MAC_Plot( 8,53,UR)
061f a9 6e LDA #UR
0621 a2 08 LDX #8
0623 a0 35 LDY #53
0625 20 61 0b JSR PlotAt
MAC_Plot(16,23,LL)
0628 a9 6d LDA #LL
062a a2 10 LDX #16
062c a0 17 LDY #23
062e 20 61 0b JSR PlotAt
MAC_Plot(16,53,LR)
0631 a9 7d LDA #LR
0633 a2 10 LDX #16
0635 a0 35 LDY #53
0637 20 61 0b JSR PlotAt
063a a9 07 LDA #HelpLines
063c 8d 7d 04 STA Count
063f a2 09 LDX #9
0641 a0 18 LDY #24
0643 20 f3 0a JSR GotoXY
0646 a2 19 LDX #<HelpWin
0648 a0 05 LDY #>HelpWin
064a 20 3a 0b ShHe10 JSR PutString
064d ae 7e 04 LDX CursorRow
0650 e8 INX
0651 a0 18 LDY #24
0653 20 f3 0a JSR GotoXY
0656 18 CLC
0657 a5 60 LDA STRPTR
0659 69 1e ADC #HelpLen
065b aa TAX
065c a5 61 LDA STRPTR+1
065e 69 00 ADC #0
0660 a8 TAY
0661 ce 7d 04 DEC Count
0664 d0 e4 BNE ShHe10
0666 a9 ff LDA #$ff
0668 8d 83 04 STA HelpScreen
066b 60 RTS ;Size 129 [ShowHelp]
; ****
066c STOP
; ****
066c a5 9b LDA STKEY
066e c9 ef CMP #$ef
0670 60 RTS ;Size 5 [STOP]
; **********
0671 Error_Beep
; **********
0671 a9 07 LDA #7
0673 4c d2 ff JMP BSOUT
; *********
0676 PrintText
; *********
0676 84 62 STY SP
0678 85 63 STA SP+1
067a a0 00 LDY #0
067c b1 62 PrTe_10 LDA (SP),Y
067e 20 d2 ff JSR BSOUT
0681 c8 INY
0682 ca DEX
0683 d0 f7 BNE PrTe_10
0685 60 RTS ;Size 16 [PrintText]
; ********************
0686 Flush_Keyboard_Queue
; ********************
0686 20 e4 ff JSR GETIN
0689 d0 fb BNE Flush_Keyboard_Queue
068b 60 RTS ;Size 6 [Flush_Keyboard_Queue]
; ***********
068c FormatByte
; ***********
; Convert binary number in (A) to
; three decimal digits in (Y),(X) and (A)
068c a0 30 LDY #'0' ; 100
068e a2 2f LDX #'0'-1 ; 10
0690 38 SEC
0691 e8 asts_01 INX
0692 e9 0a SBC #10
0694 b0 fb BCS asts_01
0696 69 3a ADC #$3a
0698 e0 3a CPX #$3a
069a 90 07 BCC asts_rt ; X < 10
069c 48 PHA
069d 8a TXA
069e e9 0a SBC #10 ; X -= 10
06a0 aa TAX
06a1 68 PLA
06a2 c8 INY ; Y = 1
06a3 60 asts_rt RTS ;Size 24 [FormatByte]
; **************
06a4 FormatInteger
; **************
06a4 a0 2f LDY #$2f ; X = low byte
06a6 38 SEC ; A = high byte
06a7 c8 FORINT_01 INY
06a8 8e 0b 05 STX LV0
06ab 8d 0c 05 STA LV1
06ae 8a TXA
06af e9 10 SBC #<10000
06b1 aa TAX
06b2 ad 0c 05 LDA LV1
06b5 e9 27 SBC #>10000
06b7 b0 ee BCS FORINT_01
06b9 8c 2c 04 STY NUMBER
06bc ae 0b 05 LDX LV0
06bf ad 0c 05 LDA LV1
06c2 a0 2f LDY #$2f
06c4 38 SEC
06c5 c8 FORINT_02 INY
06c6 8e 0b 05 STX LV0
06c9 8d 0c 05 STA LV1
06cc 8a TXA
06cd e9 e8 SBC #<1000
06cf aa TAX
06d0 ad 0c 05 LDA LV1
06d3 e9 03 SBC #>1000
06d5 b0 ee BCS FORINT_02
06d7 8c 2d 04 STY NUMBER+1
06da ae 0b 05 LDX LV0
06dd ad 0c 05 LDA LV1
06e0 a0 2f LDY #$2f
06e2 38 SEC
06e3 c8 FORINT_03 INY
06e4 8e 0b 05 STX LV0
06e7 8d 0c 05 STA LV1
06ea 8a TXA
06eb e9 64 SBC #100
06ed aa TAX
06ee ad 0c 05 LDA LV1
06f1 e9 00 SBC #0
06f3 b0 ee BCS FORINT_03
06f5 8c 2e 04 STY NUMBER+2
06f8 ad 0b 05 LDA LV0
06fb a0 2f LDY #$2f
06fd 38 SEC
06fe c8 FORINT_04 INY
06ff e9 0a SBC #10
0701 b0 fb BCS FORINT_04
0703 8c 2f 04 STY NUMBER+3
0706 69 3a ADC #$3a
0708 8d 30 04 STA NUMBER+4
070b a2 00 LDX #0
070d a9 20 LDA #' '
070f bc 2c 04 FORINT_05 LDY NUMBER,X
0712 c0 30 CPY #'0'
0714 d0 08 BNE FORINT_06
0716 9d 2c 04 STA NUMBER,X
0719 e8 INX
071a e0 04 CPX #4
071c 90 f1 BCC FORINT_05
071e 60 FORINT_06 RTS ;Size 123 [FormatInteger]
; ********
071f ShowUnit
; ********
071f a2 00 LDX #0
0721 ac 0e 05 LDY Select
0724 d0 02 BNE ShUn10
0726 a2 80 LDX #$80
0728 8e 0d 05 ShUn10 STX Reverse
072b a2 02 LDX #2
072d a0 06 LDY #6
072f 20 f3 0a JSR GotoXY
0732 ad 09 05 LDA Unit
0735 20 8c 06 JSR FormatByte
0738 e0 30 CPX #'0'
073a f0 06 BEQ ShUn20
073c 48 PHA
073d 8a TXA
073e 20 17 0b JSR PutCharR
0741 68 PLA
0742 20 17 0b ShUn20 JSR PutCharR
0745 a9 20 LDA #' '
0747 4c fa 0a JMP PutChar
; *********
074a ShowDrive
; *********
074a a2 00 LDX #0
074c ac 0e 05 LDY Select
074f 88 DEY
0750 d0 02 BNE ShDr10
0752 a2 80 LDX #$80
0754 8e 0d 05 ShDr10 STX Reverse
0757 ad 0a 05 LDA Drive
075a a2 02 LDX #2
075c a0 0f LDY #15
075e 4c 76 0b JMP PlotAtR
; ************
0761 ShowDiskName
; ************
0761 a2 02 LDX #2
0763 a0 12 LDY #18
0765 20 f3 0a JSR GotoXY
0768 a9 20 LDA #' '
076a 8d 18 0f STA Buffer + PosDiskName + 16 ; delete quote
076d a9 00 LDA #0
076f 8d 1c 0f STA Buffer + PosDiskName + 20 ; mark string end
0772 a2 08 LDX #<[Buffer + PosDiskName]
0774 a0 0f LDY #>[Buffer + PosDiskName]
0776 4c 3a 0b JMP PutString
; **************
0779 FormatFilename
; **************
0779 a5 5e LDA BP
077b 85 60 STA STRPTR
077d a5 5f LDA BP+1
077f 85 61 STA STRPTR+1
0781 a0 02 LDY #2
0783 b1 5e LDA (BP),Y ; Blocks low
0785 aa TAX
0786 c8 INY
0787 b1 5e LDA (BP),Y ; Blocks high
0789 20 a4 06 JSR FormatInteger
078c a0 00 LDY #0
078e b9 2e 04 FoFi10 LDA NUMBER+2,Y
0791 91 5e STA (BP),Y
0793 c8 INY
0794 c0 04 CPY #4
0796 90 f6 BCC FoFi10
0798 b1 5e LDA (BP),Y
079a c9 20 CMP #' '
079c d0 1c BNE FoFi99
079e e6 60 FoFi20 INC STRPTR
07a0 b1 60 LDA (STRPTR),Y
07a2 c9 20 CMP #' '
07a4 f0 f8 BEQ FoFi20
07a6 c9 22 CMP #$22
07a8 f0 f4 BEQ FoFi20
07aa 91 5e STA (BP),Y
07ac c8 FoFi40 INY
07ad c0 20 CPY #$20
07af b0 09 BCS FoFi99
07b1 b1 60 FoFi50 LDA (STRPTR),Y
07b3 91 5e STA (BP),Y
07b5 d0 f5 BNE FoFi40
07b7 ee 80 04 INC Entries
07ba 60 FoFi99 RTS ;Size 66 [FormatFilename]
; *************
07bb FormatEntries
; *************
07bb a9 00 LDA #0
07bd 8d 80 04 STA Entries
07c0 a9 20 LDA #$20 ; 1st. file
07c2 85 5e STA BP
07c4 a9 0f LDA #>Buffer
07c6 85 5f STA BP+1
07c8 a0 04 FoEn10 LDY #4 ; after link and #
07ca b1 5e LDA (BP),Y
07cc c9 20 CMP #' ' ; for filename must be blank
07ce d0 24 BNE FoEn99
07d0 20 79 07 JSR FormatFilename
07d3 20 ff 0c JSR GetLoadAddress
07d6 ae 80 04 LDX Entries
07d9 ca DEX
07da 20 0b 08 JSR ShowEntry
07dd 18 CLC
07de a5 5e LDA BP
07e0 69 20 ADC #$20
07e2 85 5e STA BP
07e4 90 02 BCC FoEn20
07e6 e6 5f INC BP+1
07e8 ad 12 05 FoEn20 LDA EOD ; check for End Of Directory
07eb c5 5e CMP BP
07ed ad 13 05 LDA EOD+1
07f0 e5 5f SBC BP+1
07f2 b0 d4 BCS FoEn10
07f4 60 FoEn99 RTS ;Size 58 [FormatEntries]
; *******
07f5 PET2SCR
; *******
07f5 c9 41 CMP #$41
07f7 90 11 BCC P2C99
07f9 c9 5b CMP #$5b
07fb b0 03 BCS P2C10
07fd 29 1f AND #$1f ; a - z
07ff 60 RTS ;Size 11 [PET2SCR]
0800 c9 c1 P2C10 CMP #$c1
0802 90 06 BCC P2C99
0804 c9 ca CMP #$ca
0806 b0 02 BCS P2C99
0808 29 7f AND #$7f ; A - Z
080a 60 P2C99 RTS ;Size 22 [PET2SCR]
; *********
080b ShowEntry
; *********
; Input: (X) = entry # (unchanged)
; (BP) = buffer pointer
; Used: (A),(Y)
080b ec 82 04 CPX LastLine
080e b0 47 BCS ShEn99
0810 a0 00 LDY #0 ; no reverse
0812 8a TXA ; entry # in (X)
0813 18 CLC
0814 69 02 ADC #2
0816 cd 0e 05 CMP Select
0819 d0 16 BNE ShEn10
081b bd b7 04 LDA EntryLo,X
081e 8d 16 05 STA SelectionLo
0821 bd df 04 LDA EntryHi,X
0824 8d 17 05 STA SelectionHi
0827 a5 5e LDA BP
0829 85 66 STA SelPtr
082b a5 5f LDA BP+1
082d 85 67 STA SelPtr+1
082f a0 80 LDY #$80 ; selected
0831 8c 0d 05 ShEn10 STY Reverse
0834 bd b7 04 LDA EntryLo,X
0837 85 62 STA SP
0839 bd df 04 LDA EntryHi,X
083c 85 63 STA SP+1
083e a0 00 LDY #0
0840 b1 5e ShEn20 LDA (BP),Y
0842 f0 13 BEQ ShEn99
0844 c9 22 CMP #$22 ; hide quote
0846 d0 02 BNE ShEn30
0848 a9 20 LDA #' '
084a 20 f5 07 ShEn30 JSR PET2SCR
084d 0d 0d 05 ORA Reverse
0850 91 62 STA (SP),Y
0852 c8 INY
0853 c0 20 CPY #32
0855 90 e9 BCC ShEn20
0857 60 ShEn99 RTS ;Size 77 [ShowEntry]
; ***********
0858 ShowEntries
; ***********
0858 ad 10 05 LDA SOD
085b 85 5e STA BP
085d ad 11 05 LDA SOD+1
0860 85 5f STA BP+1
0862 a2 00 LDX #0
0864 20 0b 08 ShoE10 JSR ShowEntry
0867 18 CLC
0868 a5 5e LDA BP
086a 69 20 ADC #$20
086c 85 5e STA BP
086e 90 02 BCC ShoE20
0870 e6 5f INC BP+1
0872 e8 ShoE20 INX
0873 ec 82 04 CPX LastLine
0876 b0 09 BCS ShoE99
0878 8a TXA
0879 6d 81 04 ADC FirstLine ; Carry is clear
087c cd 80 04 CMP Entries
087f 90 e3 BCC ShoE10
0881 60 ShoE99 RTS ;Size 42 [ShowEntries]
; ***********
0882 RightSelect
; ***********
0882 ad 0e 05 LDA Select
0885 f0 23 BEQ IncSelect ; Unit -> Drive
0887 c9 02 CMP #2
0889 90 0d BCC RiSe99 ; Drive
088b 18 CLC
088c 69 12 ADC #18
088e cd 80 04 CMP Entries
0891 b0 05 BCS RiSe99
0893 69 02 ADC #2
0895 8d 0e 05 STA Select
0898 60 RiSe99 RTS ;Size 23 [RightSelect]
; **********
0899 LeftSelect
; **********
0899 ad 0e 05 LDA Select
089c c9 01 CMP #1
089e f0 42 BEQ DecSelect ; Unit <- Drive
08a0 c9 17 CMP #23
08a2 90 05 BCC LeSe99
08a4 e9 14 SBC #20
08a6 8d 0e 05 STA Select
08a9 60 LeSe99 RTS ;Size 17 [LeftSelect]
; *********
08aa IncSelect
; *********
; Increment selection
; 0 : unit
; 1 : drive
; > 1 : filename
08aa ae 0e 05 LDX Select
08ad f0 2f BEQ InSe40 ; Unit
08af ca DEX
08b0 f0 2c BEQ InSe40 ; Drive
08b2 ec 82 04 CPX LastLine
08b5 90 1d BCC InSe20
08b7 18 CLC ; Scroll display
08b8 ad 81 04 LDA FirstLine
08bb 6d 82 04 ADC LastLine
08be cd 80 04 CMP Entries
08c1 b0 16 BCS InSe30 ; At end alreay
08c3 ee 81 04 INC FirstLine
08c6 ad 10 05 LDA SOD ; Advance SOD
08c9 69 20 ADC #$20
08cb 8d 10 05 STA SOD
08ce 90 03 BCC InSe10
08d0 ee 11 05 INC SOD+1
08d3 60 InSe10 RTS ;Size 42 [IncSelect]
08d4 ec 80 04 InSe20 CPX Entries
08d7 90 05 BCC InSe40 ; in range
08d9 a2 01 InSe30 LDX #1
08db 8e 0e 05 STX Select ; wrap around
08de ee 0e 05 InSe40 INC Select
08e1 60 InSe99 RTS ;Size 56 [IncSelect]
; *********
08e2 DecSelect
; *********
; Decrement selection
; 0 : unit
; 1 : drive
; > 1 : filename
08e2 ae 0e 05 LDX Select
08e5 e0 02 CPX #2 ; First file
08e7 d0 17 BNE DeSe20
08e9 ad 81 04 LDA FirstLine ; Scroll display
08ec f0 12 BEQ DeSe20
08ee ce 81 04 DEC FirstLine
08f1 38 SEC
08f2 ad 10 05 LDA SOD
08f5 e9 20 SBC #$20
08f7 8d 10 05 STA SOD
08fa b0 03 BCS DeSe10
08fc ce 11 05 DEC SOD+1
08ff 60 DeSe10 RTS ;Size 30 [DecSelect]
0900 ce 0e 05 DeSe20 DEC Select
0903 10 0f BPL DeSe99
0905 ae 80 04 LDX Entries
0908 ec 82 04 CPX LastLine
090b 90 03 BCC DeSe30
090d ae 82 04 LDX LastLine
0910 e8 DeSe30 INX
0911 8e 0e 05 STX Select ; wrap around
0914 60 DeSe99 RTS ;Size 51 [DecSelect]
; *************
0915 ShowSelection
; *************
0915 20 1f 07 JSR ShowUnit
0918 20 4a 07 JSR ShowDrive
091b 4c 58 08 JMP ShowEntries
; ********
091e IncValue
; ********
091e ae 0e 05 LDX Select
0921 d0 0c BNE InVa10
0923 ad 09 05 LDA Unit
0926 c9 0b CMP #11
0928 b0 15 BCS InVa99
092a ee 09 05 INC Unit
092d d0 0d BNE InVa20
092f ca InVa10 DEX
0930 d0 0d BNE InVa99
0932 ad 0a 05 LDA Drive
0935 c9 39 CMP #'9'
0937 b0 06 BCS InVa99
0939 ee 0a 05 INC Drive
093c 20 0c 0a InVa20 JSR Reload
093f 60 InVa99 RTS ;Size 34 [IncValue]
; ********
0940 DecValue
; ********
0940 ae 0e 05 LDX Select
0943 d0 0c BNE DeVa10
0945 ad 09 05 LDA Unit
0948 c9 09 CMP #9
094a 90 15 BCC DeVa99
094c ce 09 05 DEC Unit
094f d0 0d BNE DeVa20
0951 ca DeVa10 DEX
0952 d0 0d BNE DeVa99
0954 ad 0a 05 LDA Drive
0957 c9 31 CMP #'1'
0959 90 06 BCC DeVa99
095b ce 0a 05 DEC Drive
095e 20 0c 0a DeVa20 JSR Reload
0961 60 DeVa99 RTS ;Size 34 [DecValue]
; **********
0962 HomeSelect
; **********
0962 a9 00 LDA #0
0964 8d 0e 05 STA Select
0967 8d 81 04 STA FirstLine
096a a9 20 LDA #$20
096c 8d 10 05 STA SOD
096f a9 0f LDA #>Buffer
0971 8d 11 05 STA SOD+1
0974 60 RTS ;Size 19 [HomeSelect]
; ********
0975 MainLoop
; ********
0975 20 e4 ff JSR GETIN
0978 f0 fb BEQ MainLoop
097a 2c 83 04 BIT HelpScreen
097d 10 05 BPL MaLo02
097f 48 PHA
0980 20 ea 09 JSR Repaint
0983 68 PLA
0984 c9 03 MaLo02 CMP #3 ; STOP key
0986 f0 61 BEQ MaLo99
0988 c9 09 CMP #TAB
098a f0 54 BEQ MaLo85
098c c9 11 CMP #CDOWN
098e f0 50 BEQ MaLo85
0990 c9 91 MaLo05 CMP #CUP
0992 d0 06 BNE MaLo10
0994 20 e2 08 JSR DecSelect
0997 4c e3 09 JMP MaLo90
099a c9 1d MaLo10 CMP #CRIGHT
099c d0 06 BNE MaLo15
099e 20 82 08 JSR RightSelect
09a1 4c e3 09 JMP MaLo90
09a4 c9 9d MaLo15 CMP #CLEFT
09a6 d0 06 BNE MaLo20
09a8 20 99 08 JSR LeftSelect
09ab 4c e3 09 JMP MaLo90
09ae c9 2b MaLo20 CMP #'+'
09b0 d0 06 BNE MaLo25
09b2 20 1e 09 JSR IncValue
09b5 4c e3 09 JMP MaLo90
09b8 c9 2d MaLo25 CMP #'-'
09ba d0 06 BNE MaLo30
09bc 20 40 09 JSR DecValue
09bf 4c e3 09 JMP MaLo90
09c2 c9 13 MaLo30 CMP #HOME
09c4 d0 06 BNE MaLo35
09c6 20 62 09 JSR HomeSelect
09c9 4c e3 09 JMP MaLo90
09cc c9 48 MaLo35 CMP #'H'
09ce d0 06 BNE MaLo40
09d0 20 eb 05 JSR ShowHelp
09d3 4c 75 09 JMP MainLoop
09d6 c9 0d MaLo40 CMP #13
09d8 d0 03 BNE MaLo45
09da 4c fb 0d JMP Flash
09dd 4c 75 09 MaLo45 JMP MainLoop
09e0 20 aa 08 MaLo85 JSR IncSelect
09e3 20 15 09 MaLo90 JSR ShowSelection
09e6 4c 75 09 JMP MainLoop
09e9 60 MaLo99 RTS ;Size 117 [MainLoop]
; *******
09ea Repaint
; *******
09ea a9 00 LDA #0
09ec 8d 83 04 STA HelpScreen
09ef 20 f2 0b JSR PaintMask
09f2 20 1f 07 JSR ShowUnit
09f5 20 4a 07 JSR ShowDrive
09f8 20 61 07 JSR ShowDiskName
09fb ad 80 04 LDA Entries
09fe f0 0b BEQ Repa10
0a00 a9 02 LDA #2
0a02 8d 0e 05 STA Select
0a05 20 58 08 JSR ShowEntries
0a08 20 1f 07 JSR ShowUnit
0a0b 60 Repa10 RTS ;Size 34 [Repaint]
; ******
0a0c Reload
; ******
0a0c a9 00 LDA #0
0a0e 8d 80 04 STA Entries
0a11 20 8d 0c JSR LoadDirectory
0a14 20 bb 07 JSR FormatEntries
0a17 20 ea 09 JSR Repaint
0a1a 60 RTS ;Size 15 [Reload]
; ****
0a1b Init
; ****
0a1b a9 08 LDA #8
0a1d 8d 09 05 STA Unit
0a20 a9 30 LDA #'0'
0a22 8d 0a 05 STA Drive
0a25 a9 00 LDA #0
0a27 8d 7e 04 STA CursorRow
0a2a 8d 7f 04 STA CursorCol
0a2d 8d 80 04 STA Entries
0a30 8d 08 05 STA Offset
0a33 8d 0d 05 STA Reverse
0a36 8d 0e 05 STA Select
0a39 8d 81 04 STA FirstLine
0a3c 60 RTS ;Size 34 [Init]
; ****
0a3d Main
; ****
0a3d 20 5f 0a JSR Detect_BASIC_version
0a40 20 60 0a JSR Detect_Screen_Width
0a43 20 70 0a JSR SetupScreen
0a46 20 ea 09 JSR Repaint
0a49 20 97 0a JSR SetupEntries
0a4c 20 1b 0a JSR Init
0a4f 20 0c 0a JSR Reload
0a52 20 75 09 JSR MainLoop
0a55 20 86 06 JSR Flush_Keyboard_Queue
0a58 a9 75 LDA #<Msg_READY
0a5a a0 04 LDY #>Msg_READY
0a5c 4c 03 b4 JMP READY
; ********************
0a5f Detect_BASIC_version
; ********************
; TODO: detect BASIC version and patch vectors
0a5f 60 RTS ;Size 1 [Detect_BASIC_version]
; *******************
0a60 Detect_Screen_Width
; *******************
; TODO: detect Screen Width
0a60 a9 50 LDA #80
0a62 8d 7c 04 STA Cols
0a65 a9 02 LDA #2
0a67 8d 84 04 STA Pages
0a6a a9 28 LDA #40
0a6c 8d 82 04 STA LastLine
0a6f 60 RTS ;Size 16 [Detect_Screen_Width]
; ***********
0a70 SetupScreen
; ***********
0a70 a9 93 LDA #CLR
0a72 20 d2 ff JSR CHROUT ; clear screen
0a75 a9 82 LDA #130
0a77 20 d2 ff JSR CHROUT ; legacy character set
0a7a a9 00 LDA #<Screen
0a7c a2 80 LDX #>Screen
0a7e a0 00 LDY #0
0a80 99 85 04 SeSe10 STA ScreenLo,Y
0a83 8a TXA
0a84 99 9e 04 STA ScreenHi,Y
0a87 18 CLC
0a88 b9 85 04 LDA ScreenLo,Y
0a8b 6d 7c 04 ADC Cols
0a8e 90 01 BCC SeSe20
0a90 e8 INX
0a91 c8 SeSe20 INY
0a92 c0 19 CPY #ROWS
0a94 90 ea BCC SeSe10
0a96 60 RTS ;Size 39 [SetupScreen]
; ************
0a97 SetupEntries
; ************
0a97 a0 00 LDY #0
0a99 b9 89 04 SeEn10 LDA ScreenLo+4,Y
0a9c be a2 04 LDX ScreenHi+4,Y
0a9f 09 01 ORA #1
0aa1 99 b7 04 STA EntryLo,Y
0aa4 48 PHA
0aa5 8a TXA
0aa6 99 df 04 STA EntryHi,Y
0aa9 68 PLA
0aaa 18 CLC
0aab 69 28 ADC #40
0aad 99 cb 04 STA EntryLo+EntriesPerPage,Y
0ab0 90 01 BCC SeEn20
0ab2 e8 INX
0ab3 8a SeEn20 TXA
0ab4 99 f3 04 STA EntryHi+EntriesPerPage,Y
0ab7 c8 INY
0ab8 c0 14 CPY #EntriesPerPage