-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathfastutl.src
1362 lines (1224 loc) · 32.1 KB
/
fastutl.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
.page
.subttl 'fastutl.src'
;NOTE: ALL BURST COMMANDS ARE SENT VIA KERNAL I/O CALLS.
;
;BURST CMD ONE - READ
;
; BYTE BIT 7 6 5 4 3 2 1 0
;============================================================================
; 00 0 1 0 1 0 1 0 1
;----------------------------------------------------------------------------
; 01 0 0 1 1 0 0 0 0
;----------------------------------------------------------------------------
; 02 T E B S 0 0 0 N
;----------------------------------------------------------------------------
; 03 DESTINATION TRACK
;----------------------------------------------------------------------------
; 04 DESTINATION SECTOR
;----------------------------------------------------------------------------
; 05 NUMBER OF SECTORS
;----------------------------------------------------------------------------
; 06 NEXT TRACK (OPTIONAL)
;----------------------------------------------------------------------------
;
;
; RANGE:
;
; MFM ALL VALUES ARE DETERMINED UPON THE PARTICULAR DISK FORMAT.
; GCR SEE SOFTWARE SPECIFICATIONS.
;
;
;SWITCHES:
;
; T - TRANSFER DATA (1=NO TRANSFER)
; E - IGNORE ERROR (1=IGNORE)
; B - BUFFER TRANSFER ONLY (1=BUFFER TRANSFER ONLY)
; S - SIDE SELECT (MFM ONLY)
; N - DRIVE NUMBER
;
;
;
;PROTOCOL:
;
; BURST HANDSHAKE.
;
;
;
;CONVENTIONS:
;
; CMD ONE MUST BE PRECEEDED WITH CMD 3 OR CMD 6 ONCE AFTER
; A NEW DISK IS INSERTED.
;
;
;OUTPUT:
; ONE BURST STATUS BYTE PRECEEDING BURST DATA WILL BE SENT
; FOR EVERY SECTOR TRANSFERED. ON AN ERROR CONDITION
; DATA WILL NOT BE SENT UNLESS THE E BIT IS SET.
.page
;BURST CMD TWO - WRITE
;
; BYTE BIT 7 6 5 4 3 2 1 0
;============================================================================
; 00 0 1 0 1 0 1 0 1
;----------------------------------------------------------------------------
; 01 0 0 1 1 0 0 0 0
;----------------------------------------------------------------------------
; 02 T E B S 0 0 1 N
;----------------------------------------------------------------------------
; 03 DESTINATION TRACK
;----------------------------------------------------------------------------
; 04 DESTINATION SECTOR
;----------------------------------------------------------------------------
; 05 NUMBER OF SECTORS
;----------------------------------------------------------------------------
; 06 NEXT TRACK (OPTIONAL)
;----------------------------------------------------------------------------
;
;
; RANGE:
;
; MFM ALL VALUES ARE DETERMINED UPON THE PARTICULAR DISK FORMAT.
; GCR SEE SOFTWARE SPECIFICATIONS.
;
;
;SWITCHES:
;
; T - TRANSFER DATA (1=NO TRANSFER)
; E - IGNORE ERROR (1=IGNORE)
; B - BUFFER TRANSFER ONLY (1=BUFFER TRANSFER ONLY)
; S - SIDE SELECT (MFM ONLY)
; N - DRIVE NUMBER
;
;
;
;PROTOCOL:
;
; BURST HANDSHAKE.
;
;
;
;CONVENTIONS:
;
; CMD TWO MUST BE PRECEEDED WITH CMD 3 OR CMD 6 ONCE AFTER
; A NEW DISK IS INSERTED.
;
;
;INPUT:
; HOST MUST TRANSFER BURST DATA.
;
;
;OUTPUT:
; ONE BURST STATUS BYTE FOLLOWING EACH WRITE OPERATION.
.page
;BURST CMD THREE - INQUIRE DISK
;
;
; BYTE BIT 7 6 5 4 3 2 1 0
;============================================================================
; 00 0 1 0 1 0 1 0 1
;----------------------------------------------------------------------------
; 01 0 0 1 1 0 0 0 0
;----------------------------------------------------------------------------
; 02 X X X S 0 1 0 N
;----------------------------------------------------------------------------
;
;
;
;SWITCHES:
;
; S - SIDE SELECT (MFM ONLY)
; N - DRIVE NUMBER
;
;
;OUTPUT:
; ONE BURST STATUS BYTE FOLLOWING THE INQUIRE OPERATION.
.page
;BURST CMD FOUR - FORMAT MFM
;
;
; BYTE BIT 7 6 5 4 3 2 1 0
;============================================================================
; 00 0 1 0 1 0 1 0 1
;----------------------------------------------------------------------------
; 01 0 0 1 1 0 0 0 0
;----------------------------------------------------------------------------
; 02 P I D S 0 1 1 N
;----------------------------------------------------------------------------
; 03 M=1 T LOGICAL STARTING SECTOR
;----------------------------------------------------------------------------
; 04 INTERLEAVE (OPTIONAL DEF-0)
;----------------------------------------------------------------------------
; 05 SECTOR SIZE * (OPTIONAL 01 for 256 Byte Sectors)
;----------------------------------------------------------------------------
; 06 LAST TRACK NUMBER (OPTIONAL DEF-39)
;----------------------------------------------------------------------------
; 07 NUMBER OF SECTORS (OPTIONAL DEPENDS ON BYTE 05)
;----------------------------------------------------------------------------
; 08 LOGICAL STARTING TRACK (OPTIONAL DEF-0)
;----------------------------------------------------------------------------
; 09 STARTING TRACK OFFSET (OPTIONAL DEF-0)
;----------------------------------------------------------------------------
; 0A FILL BYTE (OPTIONAL DEF-$E5)
;----------------------------------------------------------------------------
; 0B-?? SECTOR TABLE (OPTIONAL T-BIT SET)
; ----------------------------------------------------------------------------
;
;SWITCHES:
;
; P - PARTIAL FORMAT (1=PARTIAL)
; I - INDEX ADDRESS MARK WRITTEN (1=WRITTEN)
; D - DOUBLE SIDED FLAG (1=FORMAT DOUBLE SIDED)
; S - SIDE SELECT
; T - SECTOR TABLE INCLUDED (1=INCLUDED, ALL OTHER PARMS
; MUST BE INCLUDED)
; N - DRIVE NUMBER
;
;
;PROTOCOL:
;
; CONVENTIONAL.
;
;
;
;CONVENTIONS:
;
; AFTER FORMATTING CMD 3 MUST BE SENT ON CONVENTIONAL FORMAT
; OR CMD 6 ON A NON-CONVENTIONAL FORMAT.
;
;
;OUTPUT:
; NONE. STATUS WILL BE UPDATED WITHIN THE DRIVE.
;
; * 00 - 128 byte sectors
; 01 - 256 byte sectors
; 02 - 512 byte sectors
; 03 - 1024 byte sectors
.page
;BURST CMD FOUR - FORMAT GCR (NO DIRECTORY)
;
;
; BYTE BIT 7 6 5 4 3 2 1 0
;============================================================================
; 00 0 1 0 1 0 1 0 1
;----------------------------------------------------------------------------
; 01 0 0 1 1 0 0 0 0
;----------------------------------------------------------------------------
; 02 X X X X 0 1 1 N
;----------------------------------------------------------------------------
; 03 M=0
;----------------------------------------------------------------------------
; 04 ID LOW
;----------------------------------------------------------------------------
; 05 ID HIGH
;----------------------------------------------------------------------------
;
;
;SWITCHES:
;
; N - DRIVE NUMBER
; X - DON'T CARE.
;
;PROTOCOL:
;
; CONVENTIONAL.
;
;
;CONVENTIONS:
;
; AFTER FORMATTING CMD 3 MUST BE SENT.
;
; NOTE: THIS COMMAND DOES NOT WRITE THE BAM OR THE
; DIRECTORY ENTRIES ( DOUBLE SIDED FLAG WILL NOT BE
; ON TRACK 18, SECTOR 0). IT IS SUGGESTED THAT THE
; CONVENTIONAL 'NEW' FORMAT COMMAND BE USED.
;
;OUTPUT:
; NONE. STATUS WILL BE UPDATED WITHIN THE DRIVE.
.page
;BURST CMD FIVE - SECTOR INTERLEAVE
;
;
; BYTE BIT 7 6 5 4 3 2 1 0
;============================================================================
; 00 0 1 0 1 0 1 0 1
;----------------------------------------------------------------------------
; 01 0 0 1 1 0 0 0 0
;----------------------------------------------------------------------------
; 02 W X X 0 1 0 0 N
;----------------------------------------------------------------------------
; 04 INTERLEAVE
;----------------------------------------------------------------------------
;
;
;SWITCHES:
;
; W - WRITE SWITCH
; N - DRIVE NUMBER
; X - DON'T CARE
;
;PROTOCOL:
;
; CONVENTIONAL, UNLESS THE W-BIT IS SET.
;
;
;CONVENTIONS:
;
; THIS IS A SOFT INTERLEAVE USED FOR MULTI-SECTOR BURST
; READ AND WRITE.
;
;OUTPUT:
; NONE (W=0), INTERLEAVE BURST BYTE (W=1)
.page
;BURST CMD SIX - QUERY DISK FORMAT
;
;
; BYTE BIT 7 6 5 4 3 2 1 0
;============================================================================
; 00 0 1 0 1 0 1 0 1
;----------------------------------------------------------------------------
; 01 0 0 1 1 0 0 0 0
;----------------------------------------------------------------------------
; 02 F X T S 1 0 1 N
;----------------------------------------------------------------------------
; 03 OFFSET (OPTIONAL F-BIT SET)
;----------------------------------------------------------------------------
;
;
;SWITCHES:
;
; F - FORCE FLAG (F=1, WILL STEP THE HEAD WITH THE
; T - END SECTOR TABLE (T=1, SEND)
; N - DRIVE NUMBER
; X - DON'T CARE.
;
;PROTOCOL:
;
; CONVENTIONAL.
;
;
;CONVENTIONS:
;
; THIS IS A METHOD OF DETERMINING THE FORMAT OF THE DISK ON
; ANY PARTICULAR TRACK.
;
;
;OUTPUT:
; BURST STATUS BYTE (IF THERE WAS AN ERROR OR IF THE
; FORMAT IS GCR NO BYTES WILL FOLLOW)
; BURST STATUS BYTE (IF THERE WAS AN ERROR IN COMPILING
; MFM FORMAT INFORMATION NO BYTES
; WILL FOLLOW)
; NUMBER OF SECTORS (THE NUMBER OF SECTORS ON A PARTICULAR
; TRACK)
; LOGICAL TRACK (THE LOGICAL TRACK NUMBER FOUND IN THE
; DISK HEADER)
; MINIMUM SECTOR (THE LOGICAL SECTOR WITH THE LOWEST
; VALUE ADDRESS)
; MAXIMUM SECTOR (THE LOGICAL SECTOR WITH THE HIGHEST
; VALUE ADDRESS)
; CP/M INTERLEAVE (THE HARD INTERLEAVE FOUND ON A PARTICULAR
; TRACK)
;
.page
;BURST CMD SEVEN - INQUIRE STATUS
;
;
; BYTE BIT 7 6 5 4 3 2 1 0
;============================================================================
; 00 0 1 0 1 0 1 0 1
;----------------------------------------------------------------------------
; 01 0 0 1 1 0 0 0 0
;----------------------------------------------------------------------------
; 02 W C X 0 1 1 0 N
;----------------------------------------------------------------------------
; 03 NEW STATUS (W-BIT CLEAR)
;----------------------------------------------------------------------------
;
;SWITCHES:
;
; W - WRITE SWITCH
; C - CHANGE (C=1 & W=0 - FORCE LOGIN DISK,
; C=1 & W=1 - RETURN WHETHER DISK WAS LOGGED
; IE. $XB ERROR OR OLD STATUS)
; N - DRIVE NUMBER
; X - DON'T CARE
;
;PROTOCOL:
;
; BURST.
;
;
;CONVENTIONS:
;
; THIS IS A METHOD OF READING OR WRITING CURRENT STATUS.
;
;
;OUTPUT:
; NONE (W=0), BURST STATUS BYTE (W=1)
;
;
.page
;BURST CMD EIGHT - BACKUP DISK
;
; BYTE BIT 7 6 5 4 3 2 1 0
;============================================================================
; 00 0 1 0 1 0 1 0 1
;----------------------------------------------------------------------------
; 01 0 0 1 1 0 0 0 0
;----------------------------------------------------------------------------
; 02 ? ? ? ? 1 1 1 ?
;----------------------------------------------------------------------------
;
;SWITCHES:
;
; ? - GOT ME
;
.page
;BURST CMD NINE - CHGUTL UTILITY
;
;
; BYTE BIT 7 6 5 4 3 2 1 0
;============================================================================
; 00 0 1 0 1 0 1 0 1
;----------------------------------------------------------------------------
; 01 0 0 1 1 0 0 0 0
;----------------------------------------------------------------------------
; 02 X X X 1 1 1 1 0
;----------------------------------------------------------------------------
; 03 UTILITY COMMANDS: 'S', 'R', 'T', 'M', 'H', #DEV
;----------------------------------------------------------------------------
; 04 COMMAND PARAMETER
;----------------------------------------------------------------------------
;SWITCHES:
;
; X - DON'T CARE.
;
;
;
;UTILITY COMMANDS:
;
; 'S' - DOS SECTOR INTERLEAVE.
; 'R' - DOS RETRIES.
; 'T' - ROM SIGNATURE ANALYSIS.
; 'M' - MODE SELECT.
; 'H' - HEAD SELECT.
; 'V' - WRITE WITH VERIFY.
; #DEV - DEVICE #.
;
;
;NOTE: BYTE 02 IS EQUIVALENT TO A '>'
;
;EXAMPLES:
; "U0>S"+CHR$(SECTOR-INTERLEAVE)
; "U0>R"+CHR$(RETRIES)
; "U0>T"
; "U0>M1"=1571 MODE, "U0>M0"=1541 MODE
; "U0>H0"=SIDE ZERO, "U0>H1"=SIDE ONE (1541 MODE ONLY)
; "U0>V0"=VERIFY ON, "U0>V1"=NO VERIFY (1571 MODE ONLY)
; "U0>"+CHR$(#DEV), WHERE #DEV = 4-30
.page
;BURST CMD TEN - FASTLOAD UTILITY
;
;
; BYTE BIT 7 6 5 4 3 2 1 0
;============================================================================
; 00 0 1 0 1 0 1 0 1
;----------------------------------------------------------------------------
; 01 0 0 1 1 0 0 0 0
;----------------------------------------------------------------------------
; 02 P X X 1 1 1 1 1
;----------------------------------------------------------------------------
; 03 FILE NAME
;----------------------------------------------------------------------------
;
;SWITCHES:
;
; P - SEQUENTIAL FILE BIT (P=1, DOES NOT HAVE TO BE A PROGRAM
; FILE)
; X - DON'T CARE.
;
;PROTOCOL:
;
; BURST.
;
;
;OUTPUT:
; BURST STATUS BYTE PRECEEDING EACH SECTOR TRANSFERED.
;
;STATUS IS AS FOLLOWS:
;
; 0000000X ............. OK
; * 00000010 ............. FILE NOT FOUND
; ** 00011111 ............. EOI
;
;* VALUES BETWEEN THE RANGE 3-15 SHOULD BE CONSIDERED A FILE READ ERROR.
;** EOI STATUS BYTE, FOLLOWED BY NUMBER OF BYTES TO FOLLOW.
.page
;STATUS BYTE BREAK DOWN
;
;
; BIT 7 6 5 4 3 2 1 0
;============================================================================
; MODE DN SECTOR SIZE [ CONTROLLER STATUS ]
;----------------------------------------------------------------------------
;
; Values Represented are in Binary
;
; MODE - 1=MFM, 0=GCR
; DN - DRIVE NUMBER
;
; SECTOR SIZE - (MFM ONLY)
; 00 .... 128 BYTE SECTORS
; 01 .... 256 BYTE SECTORS
; 10 .... 512 BYTE SECTORS
; 11 .... 1024 BYTE SECTORS
;
; CONTROLLER STATUS (GCR)
; 000X .... OK
; 0010 .... SECTOR NOT FOUND
; 0011 .... NO SYNC
; 0100 .... DATA BLOCK NOT FOUND
; 0101 .... DATA BLOCK CHECKSUM ERROR
; 0110 .... FORMAT ERROR
; 0111 .... VERIFY ERROR
; 1000 .... WRITE PROTECT ERROR
; 1001 .... HEADER BLOCK CHECKSUM ERROR
; 1010 .... DATA EXTENDS INTO NEXT BLOCK
; 1011 .... DISK ID MISMATCH/ DISK CHANGE
; 1100 .... RESERVED
; 1101 .... RESERVED
; 1110 .... SYNTAX ERROR
; 1111 .... NO DRIVE PRESENT
;
; CONTROLLER STATUS (MFM)
; 000X .... OK
; 0010 .... SECTOR NOT FOUND
; 0011 .... NO ADDRESS MARK
; 0100 .... RESERVED
; 0101 .... DATA CRC ERROR
; 0110 .... FORMAT ERROR
; 0111 .... VERIFY ERROR
; 1000 .... WRITE PROTECT ERROR
; 1001 .... HEADER BLOCK CHECKSUM ERROR
; 1010 .... RESERVED
; 1011 .... DISK CHANGE
; 1100 .... RESERVED
; 1101 .... RESERVED
; 1110 .... SYNTAX ERROR
; 1111 .... NO DRIVE PRESENT
.page
;
;EXAMPLE BURST ROUTINES WRITTEN ON C 128
; *=$1800
;
; ROUTINE TO READ N-BLOCKS OF DATA
; COMMAND CHANNEL MUST BE OPEN ON DRIVE
; OPEN 15,8,15
; BUFFER AND CMD_BUF, AND CMD_LENGTH MUST BE SETUP
; PRIOR TO CALLING THIS COMMAND.
;
;serial = $0a1c ; fast serial flag
;d2pra = $dd00
;clkout = $10
;d1icr = $dc0d
;d1sdr = $dc0c
;stat = $fa
;buffer = $fb ; $fb & $fc
;
; lda #15 ; logical file number
; ldx #8 ; device number
; ldy #15 ; secondary address
; jsr setlfs ; setup logical file
;
; lda #0 ; noname
; jsr setnam ; setup file name
;
; jsr open ; open logical channel
;
; after the command channel is open subsequent calls should be from 'read'
;
;read lda #$00
; sta stat ; clear status
; lda serial
; and #%10111111 ; clear bit 6 fast serial flag
; sta serial
; ldx #15
; jsr chkout ; open channel for output
; ldx #0
; ldy cmd_length ; length of the command
;1$ lda cmd_buf,x ; get command
; jsr bsout ; send the command
; inx
; dey
; bne 1$
;
; jsr clrchn ; send eoi
; bit serial ; check speed of drive
; bvc error ; slow serial drive
;
; sei
; bit d1icr ; clear interrupt control reg
; ldx cmd_buf+5 ; get # of sectors
; lda d2pra ; read serial port
; eor #clkout ; change state of clock
; sta d2pra ; store back
;
;read_itlda #8
;1$ bit d1icr ; wait for byte
; beq 1$
;
; lda d2pra ; read serial port
; eor #clkout ; change state of clock
; sta d2pra ; store back
;
; Code to check status byte.
;
; 1) This code will check for mode
; whether GCR or MFM.
; 2) Verify sector size.
; 3) Check for error, if ok then continue.
; On error, check error switch if set continue
; otherwise abort.
; 4) Verify switches
;
; lda d1sdr ; get data from serial data reg
; sta stat ; save status
; and #15
; cmp #2 ; just check for (3)
; bcs error
;
; ldy #0 ; even page
;top_rd lda #8
;1$ bit d1icr ; wait for byte
; beq 1$
;
; lda d2pra ; toggle clock
; eor #clkout
; sta d2pra
;
; lda d1sdr ; get data
; sta (buffer),y ; save data
; iny
; bne top_rd ; continue for buffer size
;
; dex
; beq done_read ; done ?
;
; inc buffer+1 ; next buffer
; jmp read_it
;
;done_read
; clc
; .byte $24
;error sec
; rts ; return to sender
;
;cmd_buf .byte 'U0',0,0,0,0,0
;
.page
; *=$1800
;
; ROUTINE TO WRITE N-BLOCKS OF DATA
; COMMAND CHANNEL MUST BE OPEN ON DRIVE
; OPEN 15,8,15
; BUFFER AND CMD_BUF, AND CMD_LENGTH MUST BE SETUP
; PRIOR TO CALLING THIS COMMAND.
;
;serial = $0a1c ; fast serial flag
;d2pra = $dd00
;clkout = $10
;old_clk = $fd
;clkin = $40
;d1icr = $dc0d
;d1sdr = $dc0c
;stat = $fa
;buffer = $fb ; $fb & $fc
;mmureg = $d505
;d1timh = $dc05 ; timer a high
;d1timl = $dc04 ; timer a low
;d1cra = $dc0e ; control reg a
;
; lda #15 ; logical file number
; ldx #8 ; device number
; ldy #15 ; secondary address
; jsr setlfs ; setup logical file
; jsr setnam ; setup file name
;
; jsr open ; open logical channel
;
;
; after the command channel is open subsequent calls should be from 'write'
;
;write lda #$00
; sta stat
; lda serial
; and #%10111111 ; clear bit 6 fast serial flag
; sta serial
; ldx #15
; jsr chkout ; open channel for output
;
; ldx #0
; ldy cmd_length ; length of the command
;1$ lda cmd_buf,x ; get command
; jsr bsout ; send the command
; inx
; dey
; bne 1$
;
; jsr clrchn ; send eoi
;
; bit serial ; check speed of drive
; bvc error
;
; sei
; lda #clkin
; sta old_clk ; clock starts high
;
; ldy #0 ; even page
; ldx cmd_buf+5 ; get # of sectors
;writ_itjsr spout ; serial port out
;1$ lda d2pra ; check clock
; cmp d2pra ; debounce
; bne 1$
;
; eor old_clk
; and #clkin
; beq 1$
;
; lda old_clk ; change status of old clock
; eor #clkin
; sta old_clk
;
; lda (buffer),y ; send data
; sta d1sdr
;
;********* OPTIONAL **********
;
; lda #8 ; put code here or before spin
;2$ bit d1icr ; wait for transmission time
; beq 2$
;
;*****************************
;
; iny
; bne 1$ ; continue for buffer size
;
; talker turn around
;
; WAIT CODE HERE (OPTIONAL)
;
; jsr spin ; serial port input
; bit d1icr ; clear pending
; jsr clklo ; set clk low, tell him we are ready
;
; lda #8
;3$ bit d1icr ; wait for status byte
; beq 3$
;
; lda d1sdr ; get data from serial data reg
; sta stat ; save status
; jsr clkhi ; set clock high
;
; Code to check status byte.
;
; 1) This code will check for mode
; whether GCR or MFM.
; 2) Verify sector size.
; 3) Check for error, if ok then continue.
; On error, check error switch if set continue
; otherwise abort.
; 4) Verify switches
;
; lda stat ; retrieve status
; and #15
; cmp #2 ; just chk for error only (3)
; bcs error ; finish
;
; dex
; beq done_wr ; done ?
;
; inc buffer+1 ; next buffer
; jmp wrt_it
;
;done_wr
; cli
; .byte $24
;error sec
; rts
;
;cmd_buf .byte 'U0',2,0,0,0,0
;
; subroutines
;
; NOTE: spout and spin are C128 kernal vectors (refer to C128 users manual)
;
;
;spout lda mmureg ; change serial direction to output
; ora #$08
; sta mmureg
; lda #$7f
; sta d1icr ; no irq's
; lda #$00
; sta d1timh
; lda #$03
; sta d1timl ; low 6 us bit (fastest)
; lda d1cra
; and #$80 ; keep TOD
; ora #$55
; sta d1cra ; setup CRA for output
; bit d1icr ; clr pending
; rts
;
;spin lda d1cra
; and #$80 ; save TOD
; ora #$08 ; change fast serial for input
; sta d1cra ; input for 6526
; lda mmureg
; and #$f7
; sta mmureg ; mmu serial direction in
; rts
;
;clklo lda d2pra ; set clock low
; ora #clkout
; sta d2pra
; rts
;
;clkhi lda d2pra ; set clock high
; and #$ff-clkout
; sta d2pra
; rts
;
; ****** END EXAMPLES ******
;
.page
; (1) FAST READ
fstrd sta cmd ; save command for dos
sta ctl_cmd ; save command for stbctt
lda ifr1 ; disk change
lsr a
bcc frd_00 ; br, ok
ldx #%00001011 ; no channel
.byte skip2
ndkrd ldx #%01001111 ; no drive
fail jsr upinst ; update dkmode
finbad jsr statqy ; wait for state handshake
final cpx #2
bcs exbad
rts
exbad txa ; retrieve status
and #15 ; bits 0-3 only
ldx #0 ; jobnum
jmp error ; controller error entry
frd_00 jsr spout
bit dkmode ; gcr or mfm ?
bpl rdgcr
; MFM READ
lda #9 ; read cmd
jmp prcmd
rdgcr jsr autoi ; check for auto init
frd_01 cli ; let controller run
lda switch ; check for B
and #%00100000
bne bfonly
lda cmdbuf+3 ; get track
sta hdrs
lda cmdbuf+4 ; get sector
sta hdrs+1
ldx #0 ; job #0
lda ctl_cmd ; read ($80) or fread ($88)
sta jobs,x
jsr stbctt ; hit controller hard
sei ; disable irqs
jsr upinst ; update controller status
bit switch ; check E
bvs igerr
cpx #2 ; error
bcs fail
igerr jsr hskrd ; handshake on state of clkin
lda switch ; check B
bmi notran
bfonly ldy #0 ; even page
frd_02 lda $0300,y ; get data
sta ctl_dat ; setup data
jsr hskrd ; handshake on state
iny
bne frd_02
notran dec cmdbuf+5 ; any more sectors ?
beq exrd
jsr sektr ; next sector
jmp frd_01 ; more to do
exrd cli
jmp chksee ; next track ?
.page
; (2) FAST WRITE
fstwrt
sta cmd ; save command for dos
lda ifr1 ; disk change
lsr a
bcc fwrt_0 ; br, ok
ldx #%00001011 ; no channel
.byte skip2
ndkwrt ldx #%01001111 ; no drv 1
stx ctl_dat ; save status
lda switch ; set internal switch
ora #%00001000
sta switch
fwrt_0 bit dkmode ; gcr or mfm ?
bpl wrtgcr
; MFM WRITE
lda #10
jmp prcmd
wrtgcr jsr autoi ; chk for autoi
lda switch ; transmision required
bmi notrx
fwrt_1 sei ; no irqs
ldy #0 ; even page
fwrt_2 lda pb ; debounce
eor #clkout ; toggle state of clock
bit icr ; clear pending
sta pb
fwrt_4 lda pb
bpl fwrt_3 ; br, attn not low
jsr tstatn ; chk for atn
fwrt_3 lda icr ; wait for byte
and #8
beq fwrt_4 ; chk for attn low only
lda sdr ; get data
sta $0300,y ; put away data
iny
bne fwrt_2 ; more ?
jsr clkhi ; release clock
notrx cli ; let controller run
lda switch ; check for buffer transfer only
and #%00100000
bne nowrt
lda switch ; check internal
and #%00001000
beq notrx0 ; br, ok...
ldx ctl_dat ; get error
jmp fail ; abort
notrx0 lda cmdbuf+3 ; get track
sta hdrs
lda cmdbuf+4 ; get sector
sta hdrs+1
ldx #0 ; job #0
lda #write ; get write job
sta jobs,x
jsr stbctt ; wack controller in the head
sei ; no irqs ok !
jsr spout ; go output
jsr upinst ; update status
jsr hskrd ; send it
jsr burst ; wait for reverse
jsr spinp
cli ; irqs ok now
bit switch ; check error abort switch
bvs nowrt
cpx #2 ; error on job ?
bcs fwrt_5 ; abort ?
nowrt dec cmdbuf+5 ; more sectors ?
beq fwrt_6
jsr sektr ; increment sector
jmp fwrt_1
fwrt_5 jmp exbad
fwrt_6 cli ; done
jmp chksee ; next track ?
.page
; (3) FAST SEEK
fstsek lda cmdbuf+2 ; check drive number
and #1
bne 3$ ; drive 1 - error
lda #1
sta ifr1 ; new disk
lda #5 ; read address cmd
jsr prcmd ; give it to controller
ldx mfmcmd ; get status
cpx #2 ; ok ?
bcc 2$
ldx #0
stx dkmode ; force gcr,drv0,ok
lda #seek ; seek
;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
jsr ptch0c ; *** rom ds 12/08/86 ***, set track
; sta cmd ; give command to dos
;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>