-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1541.MEM.asm
More file actions
1437 lines (1395 loc) · 120 KB
/
1541.MEM.asm
File metadata and controls
1437 lines (1395 loc) · 120 KB
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
; --------------------------------------------------------------------------------------------------------------------- ;
; VIC 1541 - Zeropage / Extended Zeropage / Stack / Vectors / Buffers
; --------------------------------------------------------------------------------------------------------------------- ;
SystemConstants .include "1541.DOS.const.asm" ; system constant definitions
; --------------------------------------------------------------------------------------------------------------------- ;
ZP_DOS = $00 ; Zeropage - JOB queue / Constants / Pointers / Work Area
; --------------------------------------------------------------------------------------------------------------------- ;
; JOBSTCC0 - JOBSTCC5 ; Interface Main Program - Disc Controller
; ; main program writes
; ; - job command codes
; ; - TRACK/sector numbers of the block to be processed (if necessary)
; ; into the appropriate job cmd memory area
; ; - bit7 set - job will be executed with the next interrupt
; ; - bit7 clear - bit0-bit6 contain the jobs status code
; ;
; ; Addresses and the assigned buffers
; ; +-----+-------+--------+-------------+
; ; ! JOB ! TRACK ! SECTOR ! BUFFER !
; ; +-----+-------+--------+-------------+
; ; ! $00 ! $06 ! $07 ! $0300-$03ff !
; ; ! $01 ! $08 ! $09 ! $0400-$04ff !
; ; ! $02 ! $0a ! $0b ! $0500-$05ff !
; ; ! $03 ! $0c ! $0d ! $0600-$06ff !
; ; ! $04 ! $0e ! $0f ! $0700-$07ff !
; ; ! $05 ! $10 ! $11 ! -<no ram>-- !
; --------------------------------------------------------------------------------------------------------------------- ;
; Job Queue
; --------------------------------------------------------------------------------------------------------------------- ;
JOBS = $00 ; command code
JOBS_0 = $00 ; Command code for BUFF0 - command and status registers: HDRS_0_TRA/HDRS_0_SEC
JOBS_1 = $01 ; Command code for BUFF1 - command and status registers: HDRS_1_TRA/HDRS_1_SEC
JOBS_2 = $02 ; Command code for BUFF2 - command and status registers: HDRS_2_TRA/HDRS_2_SEC
JOBS_3 = $03 ; Command code for BUFF3 - command and status registers: HDRS_3_TRA/HDRS_3_SEC
JOBS_4 = $04 ; Command code for BUFF4 - command and status registers: HDRS_4_TRA/HDRS_4_SEC
JOBS_5 = $05 ; Command code for BUFF5 - command and status registers: HDRS_5_TRA/HDRS_5_SEC - unused: no RAM
JOBS_FLAG_CODE = %10000000 ; Flag: bit7=1 - job code
JOBS_FLAG_ERROR = %01111111 ; Flag: bit7=0 - error code
JOBS_DRIVE_NUM = %00000001 ; bit0 - drive number
; --------------------------------------------------------------------------------------------------------------------- ;
JOBS_CODE_MASK = %11110000 ; bits 4-7: command code
JOBS_CODE_READ = %10000000 ; $80 - Read a sector
JOBS_CODE_WRITE = %10010000 ; $90 - Write a sector
JOBS_CODE_VERIFY = %10100000 ; $a0 - Verify a sector
JOBS_CODE_SEEK = %10110000 ; $b0 - Seek a sector - read in SECTOR header - fetch HEADER ID
JOBS_CODE_BUMP = %11000000 ; $c0 - Bump head - find TRACK 01
JOBS_CODE_JUMP = %11010000 ; $d0 - Exec program in buffer
JOBS_CODE_EXECUTE = %11100000 ; $e0 - Read in SECTOR and exec program in buffer
JOBS_CODE_HEADER = %11110000 ; $f0 - Read in SECTOR header
; --------------------------------------------------------------------------------------------------------------------- ;
JOBS_ERR_MASK = %00001111 ; bits 0-3: error code
JOBS_ERR_DECODE = %00000000 ; $00 - Error during disk format 24, READ ERROR
JOBS_ERR_NONE = %00000001 ; $01 - JOB completed successfully 00, OK
JOBS_ERR_NOHDR = %00000010 ; $02 - Header block not found 20, READ ERROR
JOBS_ERR_NOSYNC = %00000011 ; $03 - SYNC not found 21, READ ERROR
JOBS_ERR_NODATA = %00000100 ; $04 - Data block not found 22, READ ERROR
JOBS_ERR_CHECKSUM_DATA = %00000101 ; $05 - Data block checksum error 23, READ ERROR
JOBS_ERR_FORMAT = %00000110 ; $06 - Format error 24, READ ERROR (unused)
JOBS_ERR_VERIFY = %00000111 ; $07 - Verify error 25, WRITE ERROR
JOBS_ERR_PROTECTED = %00001000 ; $08 - Disk write protected 26, WRITE PROTECT ON
JOBS_ERR_CHECKSUM_HDR = %00001001 ; $09 - Header block checksum error 27, READ ERROR
JOBS_ERR_LONGDATA = %00001100 ; $0a - Data block too long 28, READ ERROR (unused)
JOBS_ERR_MISMATCH = %00001011 ; $0b - Id mismatch 29, DISK ID MISMATCH
JOBS_ERR_NODISC = %00001111 ; $0f - Disk not inserted 74, DRIVE NOT READY
; --------------------------------------------------------------------------------------------------------------------- ;
; Header Table
; TRACKs and SECTORs to be used for the JOBS in the JOB queue
; TRACKs and SECTORs are not needed for BUMP or JUMP jobs
; --------------------------------------------------------------------------------------------------------------------- ;
HDRS = $06 ; Tab : TRACK/sector area for JOBS
HDRS_TRA = $06 ;
HDRS_SEC = $07 ;
HDRS_0_TRA = $06 ; BUFF0 TRACK
HDRS_0_SEC = $07 ; BUFF0 sector
HDRS_1_TRA = $08 ; BUFF1 TRACK
HDRS_1_SEC = $09 ; BUFF1 sector
HDRS_2_TRA = $0a ; BUFF2 TRACK
HDRS_2_SEC = $0b ; BUFF2 sector
HDRS_3_TRA = $0c ; BUFF3 TRACK
HDRS_3_SEC = $0d ; BUFF3 sector
HDRS_4_TRA = $0e ; BUFF4 TRACK
HDRS_4_SEC = $0f ; BUFF4 sector
HDRS_5_TRA = $10 ; BUFF5 TRACK - unused: no RAM
HDRS_5_SEC = $11 ; BUFF5 sector - unused: no RAM
; --------------------------------------------------------------------------------------------------------------------- ;
; Master copy of disk ID (specified when disk was formatted) - updated with any JOBS_CODE_SEEK
; --------------------------------------------------------------------------------------------------------------------- ;
DSKID = $12 ; drive #0 - expected sector header ID
DSKID_CHR1 = $12 ;
DSKID_CHR2 = $13 ;
DSKID1 = $14 ; drive #1 - expected sector header ID (unused)
DSKID1_CHR1 = $14 ;
DSKID1_CHR2 = $15 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Image of current HEADER - stored on disk in the opposite sequence
; --------------------------------------------------------------------------------------------------------------------- ;
HEADER = $16 ; header block - contains the header of the sector last read from disk
HEADER_CHR1 = $16 ; header block ID - 1st ID char
HEADER_CHR2 = $17 ; header block ID - 2nd ID char
HEADER_TRK = $18 ; header block TRACK - TRACK number from header of sector last read from disk
HEADER_SEC = $19 ; header block sector - sector number from header of sector last read from disk
HEADER_CRC = $1a ; header block parity - checksum from header of sector last read from disk
; --------------------------------------------------------------------------------------------------------------------- ;
ACTJOB = $1b ; controllers active job (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
; Flag for disk change
; --------------------------------------------------------------------------------------------------------------------- ;
WPSW = $1c ; Flag: drive #0 - disk change indicator
WPSW_FLAG = %00000001 ;
WPSW_SAME = %00000000 ; disk not changed
WPSW_CHANGED = $00000001 ; disk changed (statuts write protect photocell has changed)
WPSW1 = $1d ; Flag: drive #1 - disk change indicator (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
; Flag for write protect sense
; --------------------------------------------------------------------------------------------------------------------- ;
LWPT = $1e ; Flag: drive #0 - previous state of write protect photocell (write protect sense)
LWPT_ON = %00010000 ;
LWPT_OFF = %11101111 ;
LWPT1 = $1f ; Flag: drive #1 - previous state of write protect photocell (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
; Current drive status
; --------------------------------------------------------------------------------------------------------------------- ;
DRVST = $20 ; Tab : drives current status (disk and step motor)
DRVST_0 = $20 ; drive #0 - disk drive status
DRVST_CLEAR = %00000000 ; reset status
DRVST_MASK = %11110000 ;
DRVST_MOTOR_STOPS = %00010000 ; shut down drive motor (0 = yes, 1 = no)
DRVST_MOTOR_STOPS_NO = %00010000 ;
DRVST_MOTOR_STOPS_YES = %11101111 ;
DRVST_MOTOR_RUNS = %00100000 ; drive motor is on (1 = yes, 0 = no)
DRVST_MOTOR_RUNS_YES = %00100000 ;
DRVST_MOTOR_RUNS_NO = %11011111 ;
DRVST_HEAD_STEPS = %01000000 ; read/write head stepping (1 = yes, 0 = no)
DRVST_HEAD_STEPS_YES = %01000000 ;
DRVST_HEAD_STEPS_NO = %10111111 ;
DRVST_MOTOR_ACCELERATE = %10000000 ; drive motor accelerating (1 = yes, 0 = no)
DRVST_MOTOR_ACCELERATE_YES = %10000000 ;
DRVST_MOTOR_ACCELERATE_DONE = %01111111 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; bits 7 6 5 4 3 2 1 0
; ! ! ! !
; ! ! ! '-- timeout
; ! ! '---- running
; ! '------ stepping
; '-------- accelerating
;
; $00 - ........ no drive active
; $10 - ...#.... stopping
; $20 - ..#..... running
; $30 - ..##.... running and timeout
; $50 - .#.#.... stepping and stopping
; $60 - .##..... stepping and running
; $80 - #....... accelerating
; $a0 - #.#..... accelerating and running
; --------------------------------------------------------------------- ;
DRVST_1 = $21 ; drive #1 - disk drive status (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
; TRACK currently under R/W head
; --------------------------------------------------------------------------------------------------------------------- ;
DRVTRK = $22 ; drive #0 - current TRACK under head
DRVTRK1 = $23 ; drive #1 - current TRACK under head (unused) but: see next line
; --------------------------------------------------------------------------------------------------------------------- ;
SLFLAG = $23 ; Flag: serial bus communication speed (0=1541 /<>0=1540)
SLFLAG_C64 = $00 ; C64 mode - lower speed (extra waits are needed as compensation for the delays caused by sprite DMA in the host)
SLFLAG_VC20 = $01 ; - $ff ; VIC-20 mode - higher speed ($01-$ff)
; --------------------------------------------------------------------------------------------------------------------- ;
; Scratch Pad Area of GCR conversion / storage for BIN -> GCR conversions
; --------------------------------------------------------------------------------------------------------------------- ;
STAB = $24 ; storage table for BIN --> GCR conversion
STAB_X = $2d ;
STAB_LEN = STAB_X - STAB - $01 ; $09 ($00 - $08)
; --------------------------------------------------------------------------------------------------------------------- ;
; Temporary storage of pointers
; --------------------------------------------------------------------------------------------------------------------- ;
SAVPNT = $2e ; Ptr : current byte in buffer during GCR-encoding/decoding
SAVPNT_LO = $2e ;
SAVPNT_HI = $2f ;
; --------------------------------------------------------------------------------------------------------------------- ;
BUFPNT = $30 ; Ptr : start of currently active buffer
BUFPNT_LO = $30 ;
BUFPNT_HI = $31 ;
; --------------------------------------------------------------------------------------------------------------------- ;
HDRPNT = $32 ; Ptr : TRACK and sector registers of current buffer
HDRPNT_TT = $32 ; Ptr : active TRACK
HDRPNT_SS = $33 ; Ptr : active sector
; --------------------------------------------------------------------------------------------------------------------- ;
GCRPNT = $34 ; Ptr : last converted byte during GCR-encoding/decoding
; --------------------------------------------------------------------------------------------------------------------- ;
GCRERR = $35 ; indicate GCR error code (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
BYTCNT = $36 ; byte counter during GCR-encoding/decoding
; --------------------------------------------------------------------------------------------------------------------- ;
BITCNT = $37 ; bit counter (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
; Data block ID
; --------------------------------------------------------------------------------------------------------------------- ;
BID = $38 ; ID byte of data block
BID_DFLT = $07 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Header block ID
; --------------------------------------------------------------------------------------------------------------------- ;
HBID = $39 ; ID byte of block header
HBID_DFLT = $08 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Data/header checksum
; --------------------------------------------------------------------------------------------------------------------- ;
CHKSUM = $3a ; computed data or header checksum
; --------------------------------------------------------------------------------------------------------------------- ;
HINIB = $3b ; (unused)
BYTE = $3c ; (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
DRIVE = $3d ; drive number - always $00 on 1541
DRIVE_0 = $00 ;
DRIVE_1 = $01 ; (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
CDRIVE = $3e ; current (active) drive number
CDRIVE_0 = $00 ;
CDRIVE_1 = $01 ; (unused)
CDRIVE_NONE = $ff ; no active drive: motor is off - must spin up before seeking
; --------------------------------------------------------------------------------------------------------------------- ;
; Position of last JOB in JOB queue (0-5)
; --------------------------------------------------------------------------------------------------------------------- ;
JOBN = $3f ; current JOB number (buffer num for disk controller)
JOBN_0 = $00 ;
JOBN_1 = $01 ;
JOBN_2 = $02 ;
JOBN_3 = $03 ;
JOBN_4 = $04 ;
JOBN_5 = $05 ; buffer #5 does not exist (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
TRACC = $40 ; Work: TRACK number
; --------------------------------------------------------------------------------------------------------------------- ;
; Position of next job in job queue (0-5)
; --------------------------------------------------------------------------------------------------------------------- ;
NXTJOB = $41 ; position of next job in queue
NXTJOB_0 = $00 ;
NXTJOB_1 = $01 ;
NXTJOB_2 = $02 ;
NXTJOB_3 = $03 ;
NXTJOB_4 = $04 ;
NXTJOB_5 = $05 ; buffer #5 does not exist (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
; Next TRACK to move head to
; --------------------------------------------------------------------------------------------------------------------- ;
NXTRK = $42 ; destination (next) TRACK to move head to
; --------------------------------------------------------------------------------------------------------------------- ;
; SECTOR counter of format routine
; --------------------------------------------------------------------------------------------------------------------- ;
SECTR = $43 ; max number of SECTORs current TRACK for formatting
; --------------------------------------------------------------------------------------------------------------------- ;
; Temp workspace
; --------------------------------------------------------------------------------------------------------------------- ;
WORK = $44 ; scratch pad
; --------------------------------------------------------------------------------------------------------------------- ;
; Temporary storage of job code
; --------------------------------------------------------------------------------------------------------------------- ;
JOB = $45 ; temp storage of JOB code
JOB_READ = %00000000 ; JOB code read
JOB_WRITE = %00010000 ; JOB code write
JOB_VERIFY = %00100000 ; JOB code verify
JOB_SEEK_SECTOR = %00110000 ; JOB code seek a SECTOR
JOB_BUMP = %01000000 ; JOB code bump
JOB_NON_EXISTENT = %01010000 ; JOB code ???
JOB_EXEC_PGM = %01100000 ; JOB code exec program in buffer
JOB_FORMAT = %01110000 ; JOB code format
; --------------------------------------------------------------------------------------------------------------------- ;
CTRACK = $46 ; (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
; Data block ID ($07)
; --------------------------------------------------------------------------------------------------------------------- ;
DBID = $47 ; data block ID code
; - init to DBID_DFLT ($07) on reset drive
; - may be changed
; - write/read data blocks with different data block ID codes
; - 1st nibble of the data block ID code should always be a zero ($0-)
; otherwise the controller will have difficulty detecting the
; end of the SYNC mark and the start of the DBID
; if a sector is read whose DBID is different from the value stored here
; the disk controller puts JOBS_ERR_NODATA ($04) in the job queue and
; the drive will report a #22 error (DATA BLOCK NOT FOUND)
DBID_DFLT = $07 ; default
DBID_MIN = $00 ; allowed values: $00-$0f
DBID_MAX = $0f ; allowed values: $00-$0f
; --------------------------------------------------------------------------------------------------------------------- ;
; Timer for head acceleration
; --------------------------------------------------------------------------------------------------------------------- ;
ACLTIM = $48 ; acceleration time delay (counter head R/W movement)
; - timer for acceleration of head movement
; --------------------------------------------------------------------------------------------------------------------- ;
; Temporary storage of stack pointer
; --------------------------------------------------------------------------------------------------------------------- ;
SAVSP = $49 ; temp save of stack pointer
; --------------------------------------------------------------------------------------------------------------------- ;
; Number of steps to move the head to get to the desired TRACK
; --------------------------------------------------------------------------------------------------------------------- ;
STEPS = $4a ; number of steps to move head to desired TRACK
; $00-$7f - move head out (from disk centre)
; $80-$ff - move head in (to disk centre)
STEPS_BUMP = $a4 ; step 45 TRACKs inwards ($ff - (2 * 46))
; --------------------------------------------------------------------------------------------------------------------- ;
; temporary storage
; --------------------------------------------------------------------------------------------------------------------- ;
TMP = $4b ; retry counter for reading sector header / temporary storage during seeking
; --------------------------------------------------------------------------------------------------------------------- ;
; Last sector read
; --------------------------------------------------------------------------------------------------------------------- ;
CSECT = $4c ; current sector
; --------------------------------------------------------------------------------------------------------------------- ;
; Next sector to service
; --------------------------------------------------------------------------------------------------------------------- ;
NEXTS = $4d ; next sector to read
; --------------------------------------------------------------------------------------------------------------------- ;
; Pointer to GCR source buffer to be converted to BIN .hbu
; --------------------------------------------------------------------------------------------------------------------- ;
NXTBF = $4e ; Ptr : HI byte - GCR source buffer to be converted to BIN
; GCR bytes in the overflow buffer are translated 1st
; points to the buffer that holds the rest of them
NXTPNT = $4f ; Off : LO byte - offset next GCR source byte location in buffer
; --------------------------------------------------------------------------------------------------------------------- ;
; Indicate data in the currently active buffer still in GCR form
; --------------------------------------------------------------------------------------------------------------------- ;
GCRFLG = $50 ; Flag: some buffer data still in GCR-encoded form
GCRFLG_OFF = $00 ; Data in normal form
GCRFLG_GCR = $01 ; - $ff ; Data in GCR-encoded form - must be decoded
; --------------------------------------------------------------------------------------------------------------------- ;
; Number of the TRACK currently being formatted
; --------------------------------------------------------------------------------------------------------------------- ;
FTNUM = $51 ; current TRACK number for FORMAT
FTNUM_MIN = $01 ;
FTNUM_MAX = $24 ; 36
FTNUM_END = $ff ; Flag: End of Format
; --------------------------------------------------------------------------------------------------------------------- ;
; Staging area for the 4 BIN bytes being converted to GCR (PUT4BG) or from GCR (GET4BG)
; --------------------------------------------------------------------------------------------------------------------- ;
BTAB = $52 ; Tab : BIN temp area for 4 data bytes during GCR-BIN encoding/decoding
BTAB_0 = $52 ;
BTAB_1 = $53 ;
BTAB_2 = $54 ;
BTAB_3 = $55 ;
BTAB_X = BTAB_3 ;
BTAB_LEN = BTAB_X - BTAB ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Staging area for the 5 GCR bytes being converted from BIN (PUT4BG) or to BIN (GET4BG)
; --------------------------------------------------------------------------------------------------------------------- ;
GTAB = $56 ; Tab : GCR temp area for data nybbles/5 GCR bytes during GCR-BIN encoding/decoding
GTAB_0 = $56 ;
GTAB_1 = $57 ;
GTAB_2 = $58 ;
GTAB_3 = $59 ;
GTAB_4 = $5a ;
GTAB_5 = $5b ;
GTAB_6 = $5c ;
GTAB_7 = $5d ;
GTAB_X = GTAB_7 ;
GTAB_LEN = GTAB_X - GTAB ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Number of steps to accelerate or decelerate when stepping the head
; --------------------------------------------------------------------------------------------------------------------- ;
AS = $5e ; acceleration/deceleration number of steps (half TRACKs)
AS_DFLT = $04 ; twice this value must be less than value of MINSTP
; --------------------------------------------------------------------------------------------------------------------- ;
; Acceleration/deceleration factor
; --------------------------------------------------------------------------------------------------------------------- ;
AF = $5f ; acceleration/deceleration factor
AF_DFLT = $04 ; value of DSKCNT(T1LH2) plus/minus value of AS times
; must not be: too low – below ~12-20 (depends on drive mechanics)
; too high – above 255
; --------------------------------------------------------------------------------------------------------------------- ;
; Number of steps left to accelerate/decelerate when stepping the head
; --------------------------------------------------------------------------------------------------------------------- ;
ACLSTP = $60 ; number of steps left to accelerate/decelerate
; --------------------------------------------------------------------------------------------------------------------- ;
; Number of steps left to step the head in fast stepping (RUN) mode
; --------------------------------------------------------------------------------------------------------------------- ;
RSTEPS = $61 ; number of steps left in RUN mode
; --------------------------------------------------------------------------------------------------------------------- ;
; pointer to call the proper stepper motor routine
; --------------------------------------------------------------------------------------------------------------------- ;
NXTST = $62 ; Ptr : head stepping routine
NXTST_LO = $62 ; normally point to INACT - head stepping control
NXTST_HI = $63 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Minimum steps for the head to move to make the use of the fast stepping mode useful
; If fewer steps needed use the slow stepping mode
; --------------------------------------------------------------------------------------------------------------------- ;
MINSTP = $64 ; minimum number of steps required for fast stepping (RUN) mode
MINSTP_DFLT = $c8 ; 200
; --------------------------------------------------------------------------------------------------------------------- ;
;UIPNT = $65 ; Ptr : warm start ('UI' command) routine [$EB22]
;UIPNT_LO = $65 ;
;UIPNT_HI = $66 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Pointer to start of NMI routine (DIAGOK)
; --------------------------------------------------------------------------------------------------------------------- ;
VNMI = $65 ; Ptr : warm start ('UI' command) routine [$EB22]
VNMI_LO = $65 ; --< all same name as in C64 mapping >-- use UIPNT instead to avoid conflicts
VNMI_HI = $66 ;
; --------------------------------------------------------------------------------------------------------------------- ;
NMIFLG = $67 ; Flag: NMI in progress
; --------------------------------------------------------------------------------------------------------------------- ;
AUTOFG = $68 ; Flag: enable/disable automatic disk init on ID MISMATCH (read BAM)
AUTOFG_YES = $00 ;
AUTOFG_NO = $01 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Sector increment for use by FNDNXT routine
; --------------------------------------------------------------------------------------------------------------------- ;
SECINC = $69 ; soft interleave - distance (in sectors) for allocating the next sector for files
SECINC_DIR = $03 ; DIRECORY interleave
SECINC_FILE = $0a ; FILE interleave
; --------------------------------------------------------------------------------------------------------------------- ;
; Counter for error recovery (number of attempts so far)
; --------------------------------------------------------------------------------------------------------------------- ;
REVCNT = $6a ; number of retries on DOS commands in case of an error
REVCNT_DFLT = $05 ; default
REVCNT_MASK = %00111111 ;
REVCNT_AHT = %01000000 ; Flag: head is on full TRACK
REVCNT_AHT_NO = %10111111 ; head is on adjacent half TRACK
REVCNT_BUMP = %10000000 ; Flag: bump head is on
REVCNT_BUMP_NO = %01111111 ; bump head is off
; --------------------------------------------------------------------------------------------------------------------- ;
; Pointer table adresses user commands (UBLOCK)
; --------------------------------------------------------------------------------------------------------------------- ;
USRJMP = $6b ; Ptr : start of user jump table for 'Ux' commands
USRJMP_LO = $6b ;
USRJMP_HI = $6c ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Pointer start of BAM bitmap
; --------------------------------------------------------------------------------------------------------------------- ;
BMPNT = $6d ; Ptr : start of BAM bitmap BUFF1 - set when a disk is initialized
BMPNT_LO = $6d ;
BMPNT_HI = $6e ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Temporary Work Area
; --------------------------------------------------------------------------------------------------------------------- ;
TEMP = $6f ;
T0 = $6f ; Ptr : address m & B commands HI
T1 = $70 ; Ptr : address m & B commands LO
T2 = $71 ;
T3 = $72 ;
T4 = $73 ;
T5 = $74 ;
TEMP_X = T5 ;
TEMP_LEN = TEMP_X - TEMP ;
; --------------------------------------------------------------------------------------------------------------------- ;
IP = $75 ; Ptr : indirect current byte during memory test
; exec address current 'Ux' user command
IP_LO = $75 ;
IP_HI = $76 ;
; --------------------------------------------------------------------------------------------------------------------- ;
LSNADR = $77 ; LISTENer address (device number + $20) - $28 on reset = unit #8
LSNADR_DFLT = $28 ;
; --------------------------------------------------------------------------------------------------------------------- ;
TLKADR = $78 ; TALKer address (device number + $40) - $48 on reset = unit #8
TLKADR_DFLT = $48 ;
; --------------------------------------------------------------------------------------------------------------------- ;
LSNACT = $79 ; Flag: active LISTENer
LSNACT_YES = $01 ; - $ff ; a LISTEN command currently active
LSNACT_NO = $00 ; no LISTEN command active
; --------------------------------------------------------------------------------------------------------------------- ;
TLKACT = $7a ; Flag: active TALKer
TLKACT_YES = $01 ; - $ff ; a TALK command currently active
TLKACT_NO = $00 ; no TALK command active
; --------------------------------------------------------------------------------------------------------------------- ;
ADRSED = $7b ; Flag: addressing mode (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
; Attention pending flag
; --------------------------------------------------------------------------------------------------------------------- ;
ATNPND = $7c ; Flag: ATN pending - still receiving from serial bus
ATNPND_YES = $01 ; - $ff ; ATN signal arrived
ATNPND_NO = $00 ; ATN inactive
ATNACT = $7d ; Flag: end of command (6502 in attention mode)
ATNACT_YES = $00 ; Command fully arrived - ATN became inactive
ATNACT_NO = $01 ; - $ff ; Command still transferring
; --------------------------------------------------------------------------------------------------------------------- ;
; Flag a program was already accessed - used when opening '*'
; --------------------------------------------------------------------------------------------------------------------- ;
PRGTRK = $7e ; Flag: TRACK number of previously opened file
PRGTRK_NONE = $00 ; no file has been opened yet
PRGTRK_YES = $01 ; - $ff ; a file has been opened before
; --------------------------------------------------------------------------------------------------------------------- ;
DRVNUM = $7f ; current drive number (always 0 for 1541)
DRVNUM_MASK = %00000001 ;
DRVNUM_BAD = %10000000 ;
; --------------------------------------------------------------------------------------------------------------------- ;
TRACK = $80 ; current TRACK number ($00 after use)
; --------------------------------------------------------------------------------------------------------------------- ;
SECTOR = $81 ; current sector number ($00 after use)
; --------------------------------------------------------------------------------------------------------------------- ;
; Logical index
; --------------------------------------------------------------------------------------------------------------------- ;
LINDX = $82 ; Idx : current channel number
LINDX_MASK = %00111111 ; all buffers
LINDX_0 = $00 ; buffer #00
LINDX_1 = $01 ; buffer #01
LINDX_2 = $02 ; buffer #02
LINDX_3 = $03 ; buffer #03
LINDX_4 = $04 ; buffer #04
LINDX_5 = $05 ; buffer #05 - error message
; --------------------------------------------------------------------------------------------------------------------- ;
; Current secondary address
; --------------------------------------------------------------------------------------------------------------------- ;
SA = $83 ; current secondary address
SA_MASK = %00001111 ;
SA_MAX = LINTAB_LEN ;
SA_LOAD = %00000000 ;
SA_SAVE = %00000001 ;
SA_CMD = LINTAB_NUM_CMD ; 15 - command channel
SA_ERR = LINTAB_NUM_ERROR; 16 - error channel
SA_READ = LINTAB_NUM_READ ; 17 - internal read
SA_WRITE = LINTAB_NUM_WRITE; 18 - internal write
; --------------------------------------------------------------------------------------------------------------------- ;
; Original secondary address
; --------------------------------------------------------------------------------------------------------------------- ;
ORGSA = $84 ; original secondary address
ORGSA_ID = %01100000 ; id: valid secondary address = $60 + num($01-$0f)
ORGSA_DFLT = ORGSA_ID | ORGSA_CMD ; $6f - command channel
ORGSA_MASK = %00001111 ;
ORGSA_LOAD_BASIC = %00000000 ; read data to BASIC start
ORGSA_LOAD_ABS = %00000001 ; read data to address stored in PRG_LOAD_ADR of the PRG file
ORGSA_CMD = %00001111 ; $0f (15) - command channel
ORGSA_FLAG_OC = %10000000 ; flag OPEN/CLOSE
ORGSA_MASK_OC = %11110000 ; mask OPEN/CLOSE commands
ORGSA_OPEN = %11110000 ;
ORGSA_CLOSE = %11100000 ;
; --------------------------------------------------------------------------------------------------------------------- ;
DATA = $85 ; temporary (current) data byte
R0 = $86 ; temporary result
R1 = $87 ; temporary result
R2 = $88 ; temporary result
R3 = $89 ; temporary result
R4 = $8a ; temporary result
; --------------------------------------------------------------------------------------------------------------------- ;
; Result Area
; --------------------------------------------------------------------------------------------------------------------- ;
RESULT = $8b ;
RESULT_0 = $8b ;
RESULT_1 = $8c ;
RESULT_2 = $8d ;
RESULT_3 = $8e ;
RESULT_X = RESULT_3 ;
RESULT_LEN = RESULT_X - RESULT ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Accumulator
; --------------------------------------------------------------------------------------------------------------------- ;
ACCUM = $8f ;
ACCUM_0 = $8f ;
ACCUM_1 = $90 ;
ACCUM_2 = $91 ;
ACCUM_3 = $92 ;
ACCUM_4 = $93 ;
ACCUM_X = ACCUM_4 ;
ACCUM_LEN = ACCUM_X - ACCUM ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Pointer to the start of the active buffer
; --------------------------------------------------------------------------------------------------------------------- ;
DIRBUF = $94 ; Ptr : start current buffer - DIR buffer ($0205)
; Note: sometimes DIRBUF does NOT point to the data buffer star ; : but to FILE_DATA behind the FILE_LINK
DIRBUF_LO = $94 ;
DIRBUF_HI = $95 ;
; --------------------------------------------------------------------------------------------------------------------- ;
ICMD = $96 ; IEEE command in (not used on 1541) (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
MYPA = $97 ; MY PA flag $00 (not used on 1541) (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
CONT = $98 ; bit counter during serial bus input/output
; --------------------------------------------------------------------------------------------------------------------- ;
; Buffer Byte Pointers - Point to the next byte to be used of each buffer - set by the B-P command
; --------------------------------------------------------------------------------------------------------------------- ;
BUFTAB = $99 ; Tab : pointer to next byte in buffers #0-#4 - normally: $0300-$0700
BUFTAB_LO = $99 ;
BUFTAB_HI = $9a ;
BUFTAB_0 = $99 ; Ptr : next byte in buffer #0 - default : $0300 [BUFF0]
BUFTAB_0_LO = $99 ;
BUFTAB_0_HI = $9a ;
BUFTAB_1 = $9b ; Ptr : next byte in buffer #1 - default : $0400 [BUFF1]
BUFTAB_1_LO = $9b ;
BUFTAB_1_HI = $9c ;
BUFTAB_2 = $9d ; Ptr : next byte in buffer #2 - default : $0500 [BUFF2]
BUFTAB_2_LO = $9d ;
BUFTAB_2_HI = $9e ;
BUFTAB_3 = $9f ; Ptr : next byte in buffer #3 - default : $0600 [BUFF3]
BUFTAB_3_LO = $9f ;
BUFTAB_3_HI = $a0 ;
BUFTAB_4 = $a1 ; Ptr : next byte in buffer #4 - default : $0700 [BUFF4]
BUFTAB_4_LO = $a1 ;
BUFTAB_4_HI = $a2 ;
; --------------------------------------------------------------------------------------------------------------------- ;
BUFTAB_CB = $a3 ; Ptr : next byte in command buffer - default: $0200
BUFTAB_CB_LO = $a3 ;
BUFTAB_CB_HI = $a4 ;
; --------------------------------------------------------------------------------------------------------------------- ;
BUFTAB_EB = $a5 ; Ptr : next byte in error message buffer - default: $02D5
BUFTAB_EB_LO = $a5 ;
BUFTAB_EB_HI = $a6 ;
; --------------------------------------------------------------------------------------------------------------------- ;
CB = BUFTAB_CB ; Ptr : next byte in command buffer - default: $0200 - CMDBUF
CB_LO = BUFTAB_CB_LO ;
CB_HI = BUFTAB_CB_HI ;
; --------------------------------------------------------------------------------------------------------------------- ;
EB = BUFTAB_EB ; Ptr : next byte in error msg buffer - default: $02D5 - ERRBUF
EB_LO = BUFTAB_EB_LO ;
EB_HI = BUFTAB_EB_HI ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Table of channel numbers assigned to each of the primary buffers
; --------------------------------------------------------------------------------------------------------------------- ;
BUF0 = $a7 ; Tab : primary buffer number assigned to channels
BUF_NUM_MASK = %00111111 ; bit0-bit5: buffer number
BUF_NUM_MASK_SHORT = %00001111 ; bit0-bit3: buffer number
BUF_FLAG_MASK = %11000000 ; bit6-bit7: buffer status flags
BUF_FLAG_MASK_LONG = %11100000 ; bit5-bit7: buffer status flags
BUF_INACT = %10000000 ; bit7 : 1 = buffer inactive
BUF_DIRTY = %01000000 ; bit6 : 1 = buffer 'dirty'
BUF_UNUSED = %11111111 ; : buffer still unused
BUF0_0 = $a7 ;
BUF0_1 = $a8 ;
BUF0_2 = $a9 ;
BUF0_3 = $aa ;
BUF0_4 = $ab ;
BUF0_5 = $ac ;
BUF0_6 = $ad ;
BUF0_X = BUF0_6 ;
BUF0_LEN = BUF0_X - BUF0 + $01 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Table of channel numbers assigned to each of the secondary buffers
; --------------------------------------------------------------------------------------------------------------------- ;
BUF1 = $ae ; Tab : secondary buffer number assigned to channels
BUF1_0 = $ae ;
BUF1_1 = $af ;
BUF1_2 = $b0 ;
BUF1_3 = $b1 ;
BUF1_4 = $b2 ;
BUF1_5 = $b3 ;
BUF1_6 = $b4 ;
BUF1_X = BUF1_6 ;
BUF1_LEN = BUF1_X - BUF1 + $01 ;
BUF_LEN = BUF1_X - BUF0 + $01 ; length BUF0 + BUF1
; --------------------------------------------------------------------------------------------------------------------- ;
; Table LO bytes of record numbers for each buffer
; --------------------------------------------------------------------------------------------------------------------- ;
RECL = $b5 ; Tab : REL files: number of records LO
RECL_0 = $b5 ;
RECL_1 = $b6 ;
RECL_2 = $b7 ;
RECL_3 = $b8 ;
RECL_4 = $b9 ;
RECL_5 = $ba ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Table HI bytes of record numbers for each buffer
; --------------------------------------------------------------------------------------------------------------------- ;
RECH = $bb ; Tab : REL files: number of records HI
RECH_0 = $bb ;
RECH_1 = $bc ;
RECH_2 = $bd ;
RECH_3 = $be ;
RECH_4 = $bf ;
RECH_5 = $c0 ;
; --------------------------------------------------------------------------------------------------------------------- ;
NBKL = RECL ; number of blocks LO - length of file
NBKH = RECH ; Number of Blocks HI - length of file
; --------------------------------------------------------------------------------------------------------------------- ;
; Table of next record numbers for buffers
; --------------------------------------------------------------------------------------------------------------------- ;
NR = $c1 ; Tab : REL files: offset next data byte in buffer assigned to channels
NR_0 = $c1 ;
NR_1 = $c2 ;
NR_2 = $c3 ;
NR_3 = $c4 ;
NR_4 = $c5 ;
NR_5 = $c6 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Table of record size for each buffer
; --------------------------------------------------------------------------------------------------------------------- ;
RS = $c7 ; Tab : REL files: record length in buffer assigned to channels
RS_0 = $c7 ;
RS_1 = $c8 ;
RS_2 = $c9 ;
RS_3 = $ca ;
RS_4 = $cb ;
RS_5 = $cc ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Table of side sectors for each buffer
; --------------------------------------------------------------------------------------------------------------------- ;
SS = $cd ; Tab : buffer number holding side sector of REL file assigned to channels
SS_NUM_MASK = %01111111 ; bit0-bit6: buffer number
SS_ACT_MASK = %10000000 ; bit7 : 1 = no buffer assigned to channel
SS_0 = $cd ;
SS_1 = $ce ;
SS_2 = $cf ;
SS_3 = $d0 ;
SS_4 = $d1 ;
SS_5 = $d2 ;
; --------------------------------------------------------------------------------------------------------------------- ;
F1PTR = $d3 ; Off : file stream 1 pointer
; --------------------------------------------------------------------------------------------------------------------- ;
; Pointer start of record
; --------------------------------------------------------------------------------------------------------------------- ;
RECPTR = $d4 ; Off : current byte in REL file record
; --------------------------------------------------------------------------------------------------------------------- ;
SSNUM = $d5 ; side sector number belonging to current REL file record
; --------------------------------------------------------------------------------------------------------------------- ;
SSIND = $d6 ; Off : TRACK/sector number of current REL file record in side sector
; --------------------------------------------------------------------------------------------------------------------- ;
RELPTR = $d7 ; Off : record in relative file data sector
; --------------------------------------------------------------------------------------------------------------------- ;
; SECTOR of directory entries
; --------------------------------------------------------------------------------------------------------------------- ;
ENTSEC = $d8 ; Tab : sector number of DIR entries
ENTSEC_0 = $d8 ;
ENTSEC_1 = $d9 ;
ENTSEC_2 = $da ;
ENTSEC_3 = $db ;
ENTSEC_4 = $dc ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Index of directory entries
; --------------------------------------------------------------------------------------------------------------------- ;
ENTIND = $dd ; Tab : buffer offset (index) of DIR entries
ENTIND_0 = $dd ;
ENTIND_1 = $de ;
ENTIND_2 = $df ;
ENTIND_3 = $e0 ;
ENTIND_4 = $e1 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Drive number of files
; --------------------------------------------------------------------------------------------------------------------- ;
FILDRV = $e2 ; Tab : drive number of files
FILDRV_NUM = %00000001 ; bit0: drive number
FILDRV_DEFAULT = %10000000 ; bit7: 1 = no drive number explicitly specified in CMD - must try both units
FILDRV_0 = $e2 ;
FILDRV_1 = $e3 ;
FILDRV_2 = $e4 ;
FILDRV_3 = $e5 ;
FILDRV_4 = $e6 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; File type and file status flags
; --------------------------------------------------------------------------------------------------------------------- ;
PATTYP = $e7 ; Tab : file type / file status flags
PATTYP_MASK = %00000111 ; file type
PATTYP_DEL = %00000000 ; file type is DEL
PATTYP_SEQ = %00000001 ; file type is SEQ
PATTYP_PRG = %00000010 ; file type is PRG
PATTYP_USR = %00000011 ; file type is USR
PATTYP_REL = %00000100 ; file type is REL
PATTYP_OPEN = %00100000 ; 1 = file is OPEN / 0 = file has been CLOSED
PATTYP_PROTECT = %01000000 ; 1 = file is write protected
PATTYP_PATTERN = %10000000 ; 1 = wildcard present in file name
PATTYP_CLEAR = %00000000 ; reset all flags
PATTYP_0 = $e7 ;
PATTYP_1 = $e8 ;
PATTYP_2 = $e9 ;
PATTYP_3 = $ea ;
PATTYP_4 = $eb ;
PATTYP_X = PATTYP_4 ;
PATTYP_LEN = PATTYP_X - PATTYP ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Drive number file type and flags file status of files assigned to channels
; --------------------------------------------------------------------------------------------------------------------- ;
FILTYP = $ec ; Tab : channel drive number / file type / file status flags
FILTYP_DRIVE = %00000001 ; drive number
FILTYP_TYPE_MASK = %00001110 ; file type
FILTYP_DEL = %00000000 ; file type is DEL
FILTYP_SEQ = %00000010 ; file type is SEQ
FILTYP_PRG = %00000100 ; file type is PRG
FILTYP_USR = %00000110 ; file type is USR
FILTYP_REL = %00001000 ; file type is REL
FILTYP_DIRECT = %00001110 ; file type is '#' - direct disk access
FILTYP_STATUS_MASK = %11100000 ; file type status
FILTYP_EOR = %00100000 ; end of record
FILTYP_EOF = %01000000 ; end of file
FILTYP_LRE = %10000000 ; last record
FILTYP_0 = $ec ;
FILTYP_1 = $ed ;
FILTYP_2 = $ee ;
FILTYP_3 = $ef ;
FILTYP_4 = $f0 ;
FILTYP_5 = $f1 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; channel input/output flags
; --------------------------------------------------------------------------------------------------------------------- ;
CHNRDY = $f2 ; Tab : channel input/output flags
CHNRDY_CLEAR = %00000000 ; reset all flags
CHNRDY_LISTEN = %00000001 ; bit0 - 1 = ready to LISTEN
CHNRDY_EOI = %00001000 ; bit3 - 0 = end of input
CHNRDY_TALK = %10000000 ; bit7 - 1 = ready to TALK
CHNRDY_0 = $f2 ;
CHNRDY_1 = $f3 ;
CHNRDY_2 = $f4 ;
CHNRDY_3 = $f5 ;
CHNRDY_4 = $f6 ;
CHNRDY_5 = $f7 ;
; --------------------------------------------------------------------------------------------------------------------- ;
EOIFLG = $f8 ; Flag: end of file indicator current channel
EOIFLG_YES = $00 ; end of file
EOIFLG_NO = $08 ; - $ff ;
EOIFLG_NONE = $80 ;
; --------------------------------------------------------------------------------------------------------------------- ;
JOBNUM = $f9 ; current (active) buffer number
; --------------------------------------------------------------------------------------------------------------------- ;
LRUTBL = $fa ; Tab : least used channel number
LRUTBL_0 = $fa ;
LRUTBL_1 = $fb ;
LRUTBL_2 = $fc ;
LRUTBL_3 = $fd ;
LRUTBL_4 = $fe ;
LRUTBL_X = LRUTBL_4 ;
LRUTBL_LEN = LRUTBL_X - LRUTBL ;
; --------------------------------------------------------------------------------------------------------------------- ;
NODRV = $ff ; Flag: table: drive #0/#1 status
NODRV0 = $ff ; Flag: drive #0 status
NODRV_READY = %00000000 ; drive #0 ready
NODRV_NONE = %11111111 ; drive #0 not ready (no disk)
NODRV1 = $0100 ; Flag: drive #1 status (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
; Extended Zero Page - Stacks / Work Areas / GCR Overflow Buffer
; --------------------------------------------------------------------------------------------------------------------- ;
OVRBUF = $0100 ; base address overflow buffer for GCR decode/encode
OVRBUF_OFF = TOPWRT ; Off: overflow buffer
; --------------------------------------------------------------------------------------------------------------------- ;
; Drives DOS version taken from TRACK 18 sector 00 BAM_DOS_VRS ($02)
; --------------------------------------------------------------------------------------------------------------------- ;
DSKVER = $0101 ; Tab : drives DOS version
DSKVER_0 = $0101 ; drive #0 DOS version
DSKVER_1 = $0102 ; drive #1 DOS version (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
ZPEND = $0103 ; end of zero page (unused)
; --------------------------------------------------------------------------------------------------------------------- ;
; Stack area
; --------------------------------------------------------------------------------------------------------------------- ;
STACK_1541 = $0104 ;
STACK_1541_TOP = OVRBUF + TOPWRT ; $45 - top of stack - stack pointer init value
STACK_1541_LEN = STACK_1541_TOP - OVRBUF ;
STACK_1541_FREE = STACK_1541_TOP + $01 ; $146
STACK_1541_FREE_X = BUFGCR - $01 ; $1ba
; --------------------------------------------------------------------------------------------------------------------- ;
; Overflow buffer for GCR/BIN decode/encode
; --------------------------------------------------------------------------------------------------------------------- ;
BUFGCR = $01bb ; overflow buffer start address
BUFGCR_OFF = <BUFGCR ; Off : overflow buffer from OVRBUF
BUFGCR_LEN = CMDBUF - BUFGCR ; $45 - overflow buffer length
; --------------------------------------------------------------------------------------------------------------------- ;
; Storage for disk commands sent to the disk drive from the computer over the serial bus
; --------------------------------------------------------------------------------------------------------------------- ;
CMDBUF = $0200 ; command buffer for input string from computer
CMDBUF_X = $0229 ;
CMDBUF_LEN = CMDBUF_X - CMDBUF ; input buffer size
; --------------------------------------------------------------------------------------------------------------------- ;
; CMD code number - offset into CMDTBL
; --------------------------------------------------------------------------------------------------------------------- ;
CMDNUM = $022a ; number of the CMD to be executed
CMDNUM_VAL = $00 ; VALIDATE
CMDNUM_INI = $01 ; INITIALIZE
CMDNUM_DUP = $02 ; DUPLICATE (not used)
CMDNUM_MEM = $03 ; MEMORY
CMDNUM_BLK = $04 ; BLOCK
CMDNUM_USR = $05 ; USER
CMDNUM_POS = $06 ; POSITION
CMDNUM_UTI = $07 ; UTILITY LOADER (&-Command)
; --------------------------------------------------------------------------------------------------------------------- ;
; CMD numbers tested with STRUCT
; --------------------------------------------------------------------------------------------------------------------- ;
CMDNUM_CPY = $08 ; COPY
CMDNUM_REN = $09 ; RENAME
CMDNUM_SCR = $0a ; SCRATCH
CMDNUM_NEW = $0b ; NEW
; --------------------------------------------------------------------------------------------------------------------- ;
; CMD number load DIR
; --------------------------------------------------------------------------------------------------------------------- ;
CMDNUM_DIR = $0c ; LOAD "$"
CMDNUM_MAX = CMDNUM_DIR ;
; --------------------------------------------------------------------------------------------------------------------- ;
CMDNUM_BFL = $80 ; - $fe ; Flag: B-x commands
CMDNUM_ERR = $ff ; Flag: error - command too long
; --------------------------------------------------------------------------------------------------------------------- ;
; Channel number and current status of each data channel (secondary address)
; --------------------------------------------------------------------------------------------------------------------- ;
LINTAB = $022b ; Tab : current status of each data channel (secondary address)
LINTAB_NUM_MASK = %00001111 ; mask channel numbers
LINTAB_NUM_MASK_LONG = %00111111 ; mask channel numbers
LINTAB_INACT = %11111111 ; inactive (no channel assigned)
LINTAB_OPEN_MASK = %11000000 ; ..
LINTAB_OPEN_R = %00000000 ; 00 - open for read
LINTAB_OPEN_RW = %01000000 ; 01 - open for read/write
LINTAB_OPEN_W = %10000000 ; 10 - open for write
; --------------------------------------------------------------------------------------------------------------------- ;
; data channels
; --------------------------------------------------------------------------------------------------------------------- ;
LINTAB_01 = $022b ; logical index channel # $01 - internal READ
LINTAB_02 = $022c ; logical index channel # $02 - internal WRITE
LINTAB_03 = $022d ; logical index channel # $03 - data channel
LINTAB_04 = $022e ; logical index channel # $04 - data channel
LINTAB_05 = $022f ; logical index channel # $05 - data channel
LINTAB_06 = $0230 ; logical index channel # $06 - data channel
LINTAB_07 = $0231 ; logical index channel # $07 - data channel
LINTAB_08 = $0232 ; logical index channel # $08 - data channel
LINTAB_09 = $0233 ; logical index channel # $09 - data channel
LINTAB_0A = $0234 ; logical index channel # $10 - data channel
LINTAB_0B = $0235 ; logical index channel # $11 - data channel
LINTAB_0C = $0236 ; logical index channel # $12 - data channel
LINTAB_0D = $0237 ; logical index channel # $13 - data channel
LINTAB_0E = $0238 ; logical index channel # $14 - data channel
LINTAB_NUM_DATA_MAX = LINTAB_0E - LINTAB + $01 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; command channel
; --------------------------------------------------------------------------------------------------------------------- ;
LINTAB_0F = $0239 ; logical index channel # $15
LINTAB_NUM_CMD = LINTAB_0F - LINTAB + $01 ; - command channel
; --------------------------------------------------------------------------------------------------------------------- ;
; special channels
; --------------------------------------------------------------------------------------------------------------------- ;
LINTAB_10 = $023a ; logical index channel # $16
LINTAB_NUM_ERROR = LINTAB_10 - LINTAB + $01 ; - error channel
LINTAB_11 = $023b ; logical index channel # $17
LINTAB_NUM_READ = LINTAB_11 - LINTAB + $01 ; - internal READ
LINTAB_12 = $023c ; logical index channel # $18
LINTAB_NUM_WRITE = LINTAB_12 - LINTAB + $01 ; - internal WRITE
LINTAB_13 = $023d ; logical index channel # $19
LINTAB_LEN = LINTAB_13 - LINTAB + $01 ;
; --------------------------------------------------------------------------------------------------------------------- ;
; The data byte to be READ/WRITE for each channel
; --------------------------------------------------------------------------------------------------------------------- ;
CHNDAT = $023e ; Tab : channel data byte
CHNDAT_0 = $023e ; for BUFF0
CHNDAT_1 = $023f ; for BUFF1
CHNDAT_2 = $0240 ; for BUFF2
CHNDAT_3 = $0241 ; for BUFF3
CHNDAT_4 = $0242 ; for BUFF4
CHNDAT_5 = $0243 ; for BUFF5 - Temporary area of next data byte to be written from error message buffer
CHNDAT_X = CHNDAT_5 ;
CHNDAT_LEN = CHNDAT_X - CHNDAT ;
; --------------------------------------------------------------------------------------------------------------------- ;
; Offset last data byte read or written in buffers for each channel
; --------------------------------------------------------------------------------------------------------------------- ;
LSTCHR = $0244 ; Tab : channel last character pointer
LSTCHR_0 = $0244 ; BUFF0
LSTCHR_1 = $0245 ; BUFF1
LSTCHR_2 = $0246 ; BUFF2
LSTCHR_3 = $0247 ; BUFF3
LSTCHR_4 = $0248 ; BUFF4
LSTCHR_5 = $0249 ; BUFF5
LSTCHR_X = LSTCHR_5 ;
LSTCHR_LEN = LSTCHR_X - LSTCHR ;
; --------------------------------------------------------------------------------------------------------------------- ;
TYPE = $024a ; current (active) file type
TYPE_MASK = %00000111 ; file type
TYPE_DEL = %00000000 ; file type is DEL
TYPE_SEQ = %00000001 ; file type is SEQ
TYPE_PRG = %00000010 ; file type is PRG
TYPE_USR = %00000011 ; file type is USR
TYPE_REL = %00000100 ; file type is REL
TYPE_DIRECT = %00000111 ; file type is '#' - direct disk access
; --------------------------------------------------------------------------------------------------------------------- ;
STRSIZ = $024b ; command string size
; --------------------------------------------------------------------------------------------------------------------- ;
TEMPSA = $024c ; temp area for secondary address
; --------------------------------------------------------------------------------------------------------------------- ;
CMD = $024d ; temp area for DC job command
; --------------------------------------------------------------------------------------------------------------------- ;
LSTSEC = $024e ; work area to find the best sector
; --------------------------------------------------------------------------------------------------------------------- ;
; Buffer allocation status
; --------------------------------------------------------------------------------------------------------------------- ;
BUFUSE = $024f ; buffer allocation register
BUFUSE_0 = $024f ; buffer allocation register - drive #0
BUFUSE_1 = $0250 ; buffer allocation register - drive #1
BUFUSE_FREE = %11100000 ; set all buffers to unused
BUFUSE_ALLOC = %11111111 ; set all buffers to allocated
BUFUSE_BUF0 = %00000001 ; buffer #0 is being used
BUFUSE_BUF1 = %00000010 ; buffer #1 is being used
BUFUSE_BUF2 = %00000100 ; buffer #2 is being used
BUFUSE_BUF3 = %00001000 ; buffer #3 is being used
BUFUSE_BUF4 = %00010000 ; buffer #4 is being used
BUFUSE_ERROR = %00100000 ; error message buffer is being used
; --------------------------------------------------------------------------------------------------------------------- ;
; Flag BAM status
; --------------------------------------------------------------------------------------------------------------------- ;