-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmypdos.src
2443 lines (2035 loc) · 29.9 KB
/
mypdos.src
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
; MyPicoDos - main menu and loader routine
;
; Copyright (C) 1992-2017 Matthias Reichl <[email protected]>
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
.include "common.inc"
.include "cio.inc"
.include "version.inc"
.if .def HWDEBUG
.include "hwdebug.src"
.endif
.IF .NOT .DEF DEFDRIVE
DEFDRIVE=1
.ENDIF
; default highspeed mode
; $00 = off
; $01 = auto (enable after booting)
; $81 = enable during booting
.if .not .def HIDEF
HIDEF=$81
.endif
; default pokey divisor for SDrive
.if .not .def SDDEF
SDDEF=0
.endif
PICOSTART = $1000
.OPT NO OBJ
.include "rreadcode.src"
.include "comloadcode.src"
.include "basloadcode.src"
.IF .DEF HIGHSPEED
.include "hisio.inc"
SIOADR = COMLEND
.include "highspeedcode.src"
.ENDIF
.OPT OBJ
; sector number of root directory
ORIGDIR = $169
; start of data area
BASE = $3000
FFLAG = BASE
STSECLO = BASE+$80
STSECHI = BASE+$100
SECBUF = BASE+$200
STACK = BASE+$300
DIRBUF = BASE+$400 ; - $C00 / $800 bytes
; misc storage buffer
STORAGE = BASE+$C00
; format of dirbuf:
; byte 0 ; 1 = regular file, 0 = dir
; bytes 1..11 : filenameext
; bytes 12-13 : start sector low / high
SCREEN = BASE+$1000
NAMEBUF = BASE+$2000
NAMEBUFE = BASE+$3400
CLREND = BASE+$3500
; line separator for PICONAME.TXT
LINESEP = 155
STACKPTR = $E0
SADR = $E2 ; ,$E3
TEMPV = $E4 ; ,E5
NAMV = $E6 ; ,E7
TEMP = $E8
; states for joystick input
JOYSTATE_IDLE = 0 ; idle position
JOYSTATE_MOVE = 1 ; stick just moved
JOYSTATE_TRIGGER = 2 ; trigger pressed, wait for release
JOYSTATE_WAIT_IDLE = 3 ; trigger just released, wait for idle
JOY_DELAY_INITIAL = 25 ; delay before starting key repeat
JOY_DELAY_REPEAT = 4 ; delay in repeating mode
.MACRO PUSH
LDX STACKPTR
STA STACK,X
INC STACKPTR
.ENDM
.MACRO POP
DEC STACKPTR
LDX STACKPTR
LDA STACK,X
.ENDM
.IF .DEF MYPDOSATR
* = PICOSTART-16
;************************************
; ATR file header
.WORD $0296 ; magic
.WORD (PICOEND-PICOSTART+15)/16
.WORD 128
.WORD 0,0,0,0,0
.ENDIF ; MYPDOSATR
* = PICOSTART
.IF .DEF MYPDOSBIN
;************************************
; boot header complete file
.BYTE 0
.if .def MYPDOSATR
; two-stage load
.BYTE 3
.else
; single-stage load
.BYTE (PICOEND-PICOSTART+127)/128
.endif
.WORD PICOSTART
.WORD XRTS
.if .def MYPDOSATR
; two-stage ATR loader
LDA #$31
STA $300
LDA #128
STA $308
ASL
STA $309 ; A=0
STA DSEC+1
ROL
STA $301 ; A=1
LDA #4
STA DSEC
LDA #$52
STA $302
LDA #7
STA $306
LDA #<(PICOSTART+384)
STA DBUF
LDA #>(PICOSTART+384)
STA DBUF+1
LDRERR
.if .def HIGHSPEED
LDA #$59
STA LDSIO+1
LDA #$E4
STA LDSIO+2
.endif
LDREST LDA #$40
STA $303
LDSIO JSR $E459
BMI LDRERR ; switch back to OS SIO and retry on errors
.if .def HIGHSPEED
; if SELECT is pressed, disable highspeed SIO
LDA $D01F
AND #2
BNE KEEPHF
STA HIFLG
KEEPHF BIT HIFLG ; enable highspeed SIO during load?
BPL LDNOHI ; bit7=0: no -> out of here
LDA HIAVAIL ; highspeed code completely loaded?
CMP #$60 ; #$60 is RTS
BNE LDNOHI ; no, still loading
ASL HIFLG ; mask out enable-during-load bit so we only install
LSR HIFLG ; the SIO code once
JSR INSTHI ; copy highspeed code to right location
LDA #<HISIO ; change SIO vector to highspeed code
STA LDSIO+1
LDA #>HISIO
STA LDSIO+2
LDNOHI
.endif
INC DSEC
BNE NLR1
INC DSEC+1
NLR1 CLC
LDA DBUF
ADC #$80
STA DBUF
BCC NLR2
INC DBUF+1
NLR2 DEC BREMAIN
BNE LDREST
JMP MENU
BREMAIN .BYTE ((PICOEND-PICOSTART+127)/128)-3
.else
JMP MENU
.endif
.if .def HIGHSPEED
HIFLG .BYTE HIDEF
.endif
CAUTORUN .BYTE 0
.if .def SDRIVE
SDDIV .BYTE SDDEF
.endif
.ELSE ; no MYPDOSBIN
.IF .DEF MYPDOSROM
JMP MENU
.if .def HIGHSPEED
HIFLG .BYTE HIDEF
.endif
CAUTORUN .BYTE 0
.if .def SDRIVE
SDDIV .BYTE SDDEF
.endif
.ELSE ; no MYPDOSROM
;************************************
; boot header 2-stage boot
.BYTE 0 ; Boot-Block Header
.BYTE 3 ; 3 sectors
.WORD PICOSTART
.WORD XRTS ; Dummy=RTS
JMP REST
RESTSEC .WORD 4
RESTBYT .BYTE 125
RESTMSK .BYTE 3
RESTLEN .WORD 128
.if .def HIGHSPEED
HIFLG .BYTE HIDEF
.endif
CAUTORUN .BYTE 0
.if .def SDRIVE
SDDIV .BYTE SDDEF
.endif
REST
LDA #$31
STA $300
LDA #1
STA $301
LDA #$52
STA $302
LDA #7
STA $306
LDA #<(PICOSTART+384)
STA DBUF
LDA #>(PICOSTART+384)
STA DBUF+1
LDA RESTLEN
STA $308
LDA RESTLEN+1
STA $309
; read sector 4 so that the XF551 recognizes the disk density
LDA #4
STA DSEC
LDA #0
STA DSEC+1
LDA #$40
STA $303
JSR $E459
LDA RESTSEC
STA DSEC
LDA RESTSEC+1
STA DSEC+1
LDRERR
.if .def HIGHSPEED
LDA #$59
STA LDSIO+1
LDA #$E4
STA LDSIO+2
.endif
LDREST LDA #$40
STA $303
LDSIO JSR $E459
BMI LDRERR ; switch back to OS SIO and retry on errors
.if .def HIGHSPEED
; if SELECT is pressed, disable highspeed SIO
LDA $D01F
AND #2
BNE KEEPHF
STA HIFLG
KEEPHF BIT HIFLG ; enable highspeed SIO during load?
BPL LDNOHI ; bit7=0: no -> out of here
LDA HIAVAIL ; highspeed code completely loaded?
CMP #$60 ; #$60 is RTS
BNE LDNOHI ; no, still loading
ASL HIFLG ; mask out enable-during-load bit so we only install
LSR HIFLG ; the SIO code once
JSR INSTHI ; copy highspeed code to right location
LDA #<HISIO ; change SIO vector to highspeed code
STA LDSIO+1
LDA #>HISIO
STA LDSIO+2
LDNOHI
.endif
LDA DBUF
STA ADR
LDA DBUF+1
STA ADR+1
LDY RESTBYT
INY
INY
CLC
LDA DBUF
ADC (ADR),Y
STA DBUF
BCC NLR1
INC DBUF+1
NLR1 DEY
LDA (ADR),Y
STA DSEC
DEY
LDA (ADR),Y
AND RESTMSK
STA DSEC+1
ORA DSEC
BNE LDREST
.ENDIF ; MYPDOSROM
JMP MENU
.ENDIF ; MYPDOSBIN
XRTS RTS
; highspeed SIO code moved to beginning so that fast 2-stage loading is possible
.IF .DEF HIGHSPEED
.include "hisiodet.src"
USSIO .incbin "highspeed.bin"
USLEN = * - USSIO
SPEEDTB .DC 8 0
HIBUF .DC 4 0
; copy highspeed code to right location
INSTHI COP768 SIOADR, USSIO, USLEN
; this location is checked by the 2-stage loader.
; If it contains the "RTS" the highspeed code is in memory
; and can be used to speed up further loading
HIAVAIL RTS
.ENDIF
; MyPicoDos display list
; number of screen lines
LINES = 15
DLIST .BYTE 112
.IF .NOT .DEF HIGHSPEED
.BYTE 48
.ENDIF
.IF .NOT .DEF REMOTE
.BYTE 48
.ENDIF
.BYTE $42
.WORD TITLE
.BYTE 112,$42
.WORD DRVLIN
.BYTE 16,$42
.WORD TLINE1
.BYTE 16
.BYTE $42
SLMS .WORD SCREEN
.DC (LINES-1) 2
.BYTE 16
.BYTE $42
.WORD TLINE2
.BYTE 0,$42
.WORD TSELECT
.BYTE 0,2,0,2,0,2
.IF .DEF HIGHSPEED
.BYTE 0,2
.ENDIF
.IF .DEF REMOTE
.BYTE 0,2
.ENDIF
.BYTE $41
.WORD DLIST
; MyPicoDos screen
TITLE = *
.SBYTE " MyPicoDos "
SVERSION
.IF .DEF BAREBONE
.SBYTE "B"
.ELSE
.IF .DEF THECART
.SBYTE "T"
.ELSE
.IF .DEF FREEZER
.SBYTE "F"
.ELSE
.IF .DEF REMOTE
.SBYTE "R"
.ELSE
.IF .DEF SDRIVE
.SBYTE "S"
.ELSE
.SBYTE " "
.ENDIF
.ENDIF
.ENDIF
.ENDIF
.ENDIF
.SBYTE " (c)"
.SBYTE " HiassofT 1992-"
SCOPYYEAR
.SBYTE " "
; 12345678901234567890
TSELECT .SBYTE " "
.SBYTE "use"
.BYTE 66,222,86
.BYTE 66,223,86
.BYTE 66,220,86
.BYTE 66,221,86
.BYTE 66
.SBYTE +$80,"RETURN"
.BYTE 86
.SBYTE "to select"
.SBYTE " "
.BYTE 66
.SBYTE +$80,"ESC"
.BYTE 86
.SBYTE " = parent DIR"
.SBYTE " "
.BYTE 66
.SBYTE +$80,"1"
.BYTE 86
.SBYTE "-"
.BYTE 66
.SBYTE +$80,"8"
.BYTE 86
.SBYTE " = D1: - D8: "
.SBYTE " "
.BYTE 66
.SBYTE +$80,"F"
.BYTE 86
.SBYTE " = disk format :"
FORLEN = 11
DFORMAT .DC FORLEN 0
.SBYTE " "
.SBYTE " "
.BYTE 66
.SBYTE +$80,"L"
.BYTE 86
.SBYTE " = long names :"
LNSTAT .BYTE 66
.SBYTE +$80,"AUTO"
.BYTE 86
.SBYTE " "
.IF .DEF HIGHSPEED
.SBYTE " "
.BYTE 66
.SBYTE +$80,"H"
.BYTE 86
.SBYTE " = high speed"
.SBYTE " SIO :"
SIOSTAT .BYTE 66
.SBYTE +$80,"AUTO"
.BYTE 86
.SBYTE " "
.ENDIF
.IF .DEF REMOTE
.SBYTE " "
.BYTE 66
.SBYTE +$80,"A"
.BYTE 86
.SBYTE " = atariserver remote console"
.SBYTE " "
.ENDIF
FORASD .BYTE 66
.SBYTE +$80,"AUTO"
.BYTE 86
.SBYTE "(SD) "
FORADD .BYTE 66
.SBYTE +$80,"AUTO"
.BYTE 86
.SBYTE "(DD) "
FORSD .BYTE 66
.SBYTE +$80,"SD/DOS2.x"
.BYTE 86
FORSM .BYTE 66
.SBYTE +$80,"SD/MyDOS"
.BYTE 86
.SBYTE " "
FORDD .BYTE 66
.SBYTE +$80,"DD/DOS2.x"
.BYTE 86
FORDM .BYTE 66
.SBYTE +$80,"DD/MyDOS"
.BYTE 86
.SBYTE " "
TAUTO .BYTE 66
.SBYTE +$80,"AUTO"
.BYTE 86
TOFF .BYTE 66
.SBYTE +$80,"OFF"
.BYTE 86,0
;************************************
; file loader code
RREADB .incbin "rread.bin"
RREADL = * - RREADB
BASLOAD .incbin "basload.bin"
BASLEN = * - BASLOAD
COMLOAD .incbin "comload.bin"
COMLEN = * - COMLOAD
;************************************
; start of main selection code
MENU = *
LDX #$FF
TXS
; LDX #0
; LDA #$FF
;CLRSTOR LDA STORAGE,X
; INX
; BNE CLRSTOR
.if .def HWDEBUG
TSX
TXA
LDX #0
DBGA
.endif
LDA #1
STA 580
ORA 9
STA 9
LDA #$77
STA 10
LDA #$E4
STA 11
LDA #JOYSTATE_WAIT_IDLE
STA JOYSTAT
COP768 $0800, RREADB, RREADL
.IF .DEF HIGHSPEED
JSR INSTHI ; copy SIO code to right location
LDA HIFLG
AND #1
BEQ NODHI
JSR SPDHI
NODHI
.ENDIF
.IF .DEF SDRIVE
LDA #$71
STA $300
LDA #1
STA $301
LDA #$C1
STA $302
LDA #0
STA $303
LDA SDDIV
STA $30A
JSR $E459 ; set SDrive pokey divisor
.IF .DEF HIGHSPEED
LDA #0
STA $301
JSR HISIO ; clear SIO speed table
.ENDIF
.ENDIF
LDA CAUTORUN
STA AUTORUN
MENU2 LDA 560
STA OLD560
LDA 561
STA OLD560+1
LDA 710
STA OLD710
.IF .DEF HIGHSPEED
JSR HISTAT
.ENDIF
STW 560,DLIST
LDA #DEFDRIVE
STA DRIVENO
STA $301
LDA #$31
STA $300
NEWDISK STW DIRSEC,ORIGDIR
LDA #0
STA 710
STA STACKPTR
; LDA #$04
; STA 710
; STA 712
JSR CLS
JSR GETDENS
LDA SECBYTE
STA DSKBYT
LDA $308
STA DSKLEN
LDA $309
STA DSKLEN+1
LDX DSKFOR
JSR SETFMT
JSR PRTFOR
LOOP JSR SELECT
LDA FFLAG,X
BPL STDFIL1
; APE PC-mirror subdirectories are listed with a size of 0 and
; are flagged with a status of $80
; entering them is done by just accessing the first sector of the file
LDA STSECLO,X
STA DSEC
LDA STSECHI,X
STA DSEC+1
JSR READSEC
LDA 20
CLC
ADC #20
WCD CMP 20
BNE WCD
JMP LOOP
STDFIL1 AND #$10
BNE SUBDIR
LDY SECBYTE
LDA STSECHI,X
STA BUF,Y
LDA STSECLO,X
INY
STA BUF,Y
LDA FFLAG,X
JSR CHK16
LDA OLD560
STA 560
; STA $D402
LDA OLD560+1
STA 561
; STA $D403
LDA OLD710
STA 710
; STA $D018
LDA 20
?WT20 CMP 20
BEQ ?WT20
JMP LOAD
SUBDIR STX TEMP
LDA DIRSEC
PUSH
LDA DIRSEC+1
PUSH
LDX TEMP
LDA STSECLO,X
STA DIRSEC
LDA STSECHI,X
STA DIRSEC+1
JMP LOOP
SELECT JSR READDIR
LDA INDUP
STA TLUP
.if .def HWDEBUG
TSX
TXA
LDX #2
DBGA
.endif
LDA AUTORUN
PHA
LDA #0
STA XPOS
STA YPOS
STA AUTORUN
PLA
BEQ NOAUTO
LDA FILES
CMP #1
BNE NOAUTO
LDX #0
RTS
NOAUTO LDA #0
STA AUTORUN
; directory selection
SELLP JSR INVERS
GKLP1 JSR GETKEY
TAX
TYA
BMI GKLP1
TXA
PHA
JSR INVERS
PLA
CMP #'+
BNE NCLEFT
YCLEFT JMP CLEFT
NCLEFT CMP #30
BEQ YCLEFT
CMP #'*
BNE NCRIGHT
YCRIGHT JMP CRIGHT
NCRIGHT CMP #31
BEQ YCRIGHT
CMP #'-
BNE NCUP
YCUP JMP CUP
NCUP CMP #28
BEQ YCUP
CMP #'=
BNE NCDOWN
YCDOWN JMP CDOWN
NCDOWN CMP #29
BEQ YCDOWN
CMP #155
BNE NCR
LDA FILES
BEQ NCR
JMP RETURN
NCR CMP #27
BNE NESC
LDA STACKPTR
BEQ SELLP
POP
STA DIRSEC+1
POP
STA DIRSEC
JMP SELECT
NESC = *
.IF .DEF REMOTE
CMP #'A
BNE NKEYA
PLA
PLA
JSR CONSOLE
JMP NEWDISK
NKEYA = *
.ENDIF
.IF .DEF HIGHSPEED
CMP #'H
BNE NKEYH
JMP KEYH
NKEYH = *
.ENDIF
CMP #'1
BCC NKEY18
CMP #'9
BCS NKEY18
JMP KEY18
NKEY18 CMP #'F
BNE NKEYF
JMP KEYF
NKEYF CMP #'L
BNE NKEYL
JMP KEYL
NKEYL JMP SELLP
CLEFT LDA LONGFLG
BNE CLEFTL
DEC XPOS
BPL CLOK
LDA #2
STA XPOS
DEC YPOS
BPL CLOK
GOSTRT LDA #0
STA XPOS
STA YPOS
CLOK JMP SELLP
CLEFTL LDA YPOS
CMP #LINES-1
BCC GOSTRT
SBC #LINES-1
STA YPOS
JMP SELLP
CRIGHT LDA LONGFLG
BNE CRIGHTL
LDA YPOS
CMP MAXY
BEQ CRMY
INC XPOS
LDA XPOS
CMP #3
BNE CROK
LDA #0
STA XPOS
INC YPOS
JMP CROK
CRMY LDA XPOS
CMP MAXX
BEQ CROK
INC XPOS
CROK JMP SELLP
CRIGHTL LDA FILES
BEQ CROK
CLC
LDA YPOS
ADC #LINES-1
CMP FILES
BCC NOTEND
LDA FILES
SBC #1
NOTEND STA YPOS
JMP SELLP
CUP LDA YPOS
BEQ CUOK
DEC YPOS
CUOK JMP SELLP
CDOWN LDA LONGFLG
BNE CDOWNL
LDA YPOS
CMP MAXY
BEQ CDOK
INC YPOS
LDA YPOS
CMP MAXY
BNE CDOK
LDA XPOS
CMP MAXX
BCC CDOK
BEQ CDOK
LDX MAXY
DEX
STX YPOS
CDOK JMP SELLP
CDOWNL LDA FILES
BEQ CDOK2
CLC
LDA YPOS
ADC #1
CMP FILES
BEQ CDOK2
STA YPOS
CDOK2 JMP SELLP
CALCIDX LDA YPOS
ASL
CLC
ADC YPOS
CLC
ADC XPOS
TAX
RTS
RETURN JSR INVERS
LDA LONGFLG
BNE RETURNL
JSR CALCIDX
CLC
RTS
RETURNL LDX YPOS
CLC
RTS
KEY18 SEC
SBC #'0
STA DRIVENO
STA $301
PLA