-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPRORWTS.S
1480 lines (1293 loc) · 38.4 KB
/
PRORWTS.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;open/read/write binary file in ProDOS filesystem
;copyright (c) Peter Ferrie 2013-16
!cpu 6502
!to "prorwts",plain
*=$800
;constants
cmdread = 1 ;requires enable_write=1
cmdwrite = 2 ;requires enable_write=1
SETKBD = $fe89
SETVID = $fe93
DEVNUM = $bf30
PHASEOFF = $c080
MOTOROFF = $c088
MOTORON = $c089
Q6L = $c08c
Q6H = $c08d
Q7L = $c08e
Q7H = $c08f
MLI = $bf00
KEY_POINTER = $11 ;ProDOS constant
EOF = $15 ;ProDOS constant
AUX_TYPE = $1f ;ProDOS constant
ROMIN = $c081
LCBANK2 = $c089
CLRAUXRD = $c002
CLRAUXWR = $c004
;options
enable_floppy = 0 ;set to 1 to enable floppy drive support
poll_drive = 0 ;set to 1 to check if disk is in drive
override_adr = 0 ;set to 1 to require an explicit load address
aligned_read = 0 ;set to 1 if all reads can be a multiple of block size
enable_write = 0 ;set to 1 to enable write support
;file must exist already and its size cannot be altered
;writes occur in multiples of block size (256 bytes for floppy, 512 bytes for HDD)
allow_multi = 0 ;set to 1 to allow multiple floppies
check_checksum=0 ;set to 1 to enforce checksum verification for floppies
allow_subdir = 0 ;set to 1 to allow opening subdirectories to access files
might_exist = 0 ;set to 1 if file is not known to always exist already
;makes use of status to indicate success or failure
allow_aux = 0 ;set to 1 to allow read/write directly to/from aux memory
;requires load_high to be set for arbitrary memory access
;else driver must be running from same memory target
;i.e. running from main if accessing main, running from aux if accessing aux
load_high = 0 ;load into banked RAM instead of main RAM
lc_bank = 1 ;load into specified bank (1 or 2) if load_high=1
;zpage usage
!if enable_floppy=1 {
tmpsec = $3c
reqsec = $3d
} ;enable_floppy
!if enable_floppy=1 {
curtrk = $40
} ;enable_floppy
command = $42 ;ProDOS constant
unit = $43 ;ProDOS constant
adrlo = $44 ;ProDOS constant
adrhi = $45 ;ProDOS constant
bloklo = $46 ;ProDOS constant
blokhi = $47 ;ProDOS constant
!if aligned_read=0 {
secsize = $46
secsize1 = $47
secsize2 = $48
} ;aligned_read
!if might_exist=1 {
status = $f3 ;returns non-zero on error
} ;might_exist
!if allow_aux=1 {
auxreq = $f4 ;set to 1 to read/write aux memory, else main memory is used
} ;allow_aux
sizelo = $f5 ;set if enable_write=1 and writing
sizehi = $f6 ;set if enable_write=1 and writing
entries = $f7 ;(internal) total number of entries
reqcmd = $f8 ;set (read/write) if enable_write=1
;if allow_multi=1, bit 7 selects floppy drive in current slot (clear=drive 1, set=drive 2)
ldrlo = $f9 ;set to load address if override_adr=1
ldrhi = $fa ;set to load address if override_adr=1
namlo = $fb ;name of file to access
namhi = $fc ;name of file to access
!if enable_floppy=1 {
step = $fd ;(internal) state for stepper motor
tmptrk = $fe ;(internal) temporary copy of current track
phase = $ff ;(internal) current phase for seek
!if enable_write=1 {
!if load_high=1 {
reloc = $d000 ;$300 bytes code, $100 bytes data
dirbuf = reloc+$400
encbuf = dirbuf+$200
} else { ;load_high
reloc = $bc00 ;$300 bytes code, $100 bytes data
dirbuf = reloc-$200
encbuf = dirbuf-$100
} ;load_high
} else { ;enable_write
!if load_high=1 {
reloc = $d000 ;$200 bytes code, $100 bytes data
dirbuf = reloc+$300
} else { ;load_high
reloc = $bd00 ;$200 bytes code, $100 bytes data
dirbuf = reloc-$200
} ;load_high
} ;enable_write
} else { ;enable_floppy
!if load_high=1 {
reloc = $d000 ;$200 bytes code
!if aligned_read=0 {
dirbuf = reloc+$200
} else { ;aligned_read
dirbuf = reloc+$100
} ;aligned_read
} else { ;load_high
reloc = $be00 ;$200 bytes code
!if aligned_read=0 {
dirbuf = reloc-$200
} else { ;aligned_read
dirbuf = reloc-$100
} ;aligned_read
} ;load_high
} ;enable_floppy
init jsr SETVID
jsr SETKBD
lda DEVNUM
sta x80_parms+1
sta unrunit+1
and #$70
!if (enable_floppy+enable_write)=2 {
sta unrslot1+1
sta unrslot2+1
sta unrslot3+1
sta unrslot4+1
} ;enable_floppy and enable_write
pha
!if enable_floppy=1 {
ora #<PHASEOFF
sta unrseek+1
ora #<MOTOROFF
!if might_exist=1 {
sta unrdrvoff1+1
} ;might_exist
sta unrdrvoff2+1
tax
inx ;MOTORON
!if poll_drive=1 {
stx unrdrvon1+1
} ;poll_drive
stx unrdrvon2+1
inx ;DRV0EN
!if allow_multi=1 {
stx unrdrvsel+1
} ;allow_multi
inx
inx ;Q6L
stx unrread1+1
!if poll_drive=1 {
stx unrread2+1
stx unrread3+1
} ;poll_drive
stx unrread4+1
stx unrread5+1
!if check_checksum=1 {
stx unrread6+1
} ;check_checksum
} ;enable_floppy
ldx #1
stx namlo
inx
stx namhi
jsr MLI
!byte $c7
!word c7_parms
ldx $200
dex
stx sizelo
bmi +++
readblock jsr MLI
!byte $80
!word x80_parms
lda #<(readbuff+4)
sta bloklo
lda #>(readbuff+4)
sta blokhi
inextent ldy #0
lda (bloklo), y
pha
and #$d0
;watch for subdirectory entries
cmp #$d0
bne +
lda (bloklo), y
and #$0f
tax
iny
-- lda (bloklo), y
cmp (namlo), y
beq ifoundname
;match failed, move to next directory in this block, if possible
-
+ pla
clc
lda bloklo
adc #$27
sta bloklo
bcc +
;there can be only one page crossed, so we can increment instead of adc
inc blokhi
+ cmp #<(readbuff+$1ff) ;4+($27*$0d)
lda blokhi
sbc #>(readbuff+$1ff)
bcc inextent
;read next directory block when we reach the end of this block
lda readbuff+2
ldx readbuff+3
bcs +
ifoundname iny
dex
bne --
lda (namlo), y
cmp #'/'
bne -
tya
eor #$ff
adc sizelo
sta sizelo
clc
tya
adc namlo
sta namlo
pla
and #$20
bne ++
ldy #KEY_POINTER+1
lda (bloklo), y
tax
dey
lda (bloklo), y
!if enable_floppy=1 {
sta unrblocklo+1
stx unrblockhi+1
} ;enable_floppy
sta unrhddblocklo+1
stx unrhddblockhi+1
+ sta x80_parms+4
stx x80_parms+5
++ lda sizelo
bne readblock
+++ pla
lsr
lsr
lsr
tax
lsr
ora #$c0
ldy $bf11, x
cpy #$c8 ;max slot+1
bcs set_slot
tya
set_slot sta slot+2
sta unrentry+2
!if enable_floppy=1 {
ldx #>unrelocdsk
ldy #<unrelocdsk
slot lda $cfff
sta unrentry+1
php
beq copydrv
ldx #>unrelochdd
ldy #<unrelochdd
copydrv stx blokhi
sty bloklo
!if load_high=1 {
!if lc_bank=1 {
lda LCBANK2
lda LCBANK2
} else { ;lc_bank
lda ROMIN
lda ROMIN
} ;lc_bank
} ;load_high
ldx #>((bit2tbl-opendir)+$ff)
ldy #0
- lda (bloklo), y
reladr sta reloc, y
iny
bne -
inc blokhi
inc reladr+2
dex
bne -
plp
bne ++
ldx #$16
-- stx bloklo
txa
asl
bit bloklo
beq +
ora bloklo
eor #$ff
and #$7e
- bcs +
lsr
bne -
tya
sta nibtbl-$16, x
!if enable_write=1 {
txa
ora #$80
sta xlattbl, y
} ;enable_write
iny
+ inx
bpl --
++ rts
} else { ;enable_floppy
slot lda $cfff
sta unrentry+1
!if load_high=1 {
!if lc_bank=1 {
lda LCBANK2
lda LCBANK2
} else { ;lc_bank
lda ROMIN
lda ROMIN
} ;lc_bank
} ;load_high
ldy #0
- lda unrelochdd, y
sta reloc, y
lda unrelochdd+$100, y
sta reloc+$100, y
iny
bne -
rts
} ;enable_floppy
c7_parms !byte 1
!word $200
x80_parms !byte 3, $d1
!word readbuff, 2
!if enable_floppy=1 {
unrelocdsk
!pseudopc reloc {
opendir ;read volume directory key block
unrblocklo=unrelocdsk+(*-reloc)
ldx #2
unrblockhi=unrelocdsk+(*-reloc)
lda #0
jsr readdirsel
;include volume directory header in count
readdir
!if might_exist=1 {
ldx dirbuf+37
inx
stx entries
} ;might_exist
firstent lda #<(dirbuf+4)
sta bloklo
lda #>(dirbuf+4)
sta blokhi
nextent ldy #0
!if might_exist=1 {
sty status
} ;might_exist
lda (bloklo), y
!if (might_exist+allow_subdir)>0 {
and #$f0
!if might_exist=1 {
;skip deleted entries without counting
beq ++
} ;might_exist
} ;might_exist or allow_subdir
!if allow_subdir=1 {
;subdirectory entries are seedlings
;but we need to distinguish between them later
cmp #$d0
beq savetype
} ;allow_subdir
;watch for seedling and saplings only
cmp #$30
bcs +
;remember type
savetype
!if allow_subdir=1 {
asl
asl
} else { ;allow_subdir
cmp #$20
} ;allow_subdir
php
;match name lengths before attempting to match names
lda (bloklo), y
and #$0f
tax
inx
!byte $2c
- lda (bloklo), y
cmp (namlo), y
beq foundname
;match failed, check if any directory entries remain
plp
+
!if might_exist=1 {
dec entries
bne ++
nodisk
unrdrvoff1=unrelocdsk+(*-reloc)
lda MOTOROFF
inc status
rts
} ;might_exist
;move to next directory in this block, if possible
++ clc
lda bloklo
adc #$27
sta bloklo
bcc +
;there can be only one page crossed, so we can increment instead of adc
inc blokhi
+ cmp #<(dirbuf+$1ff) ;4+($27*$0d)
lda blokhi
sbc #>(dirbuf+$1ff)
bcc nextent
;read next directory block when we reach the end of this block
ldx dirbuf+2
lda dirbuf+3
jsr readdirsec
bne firstent
foundname iny
dex
bne -
stx entries
!if enable_write=1 {
ldy reqcmd
cpy #cmdwrite ;control carry instead of zero
bne +
;round requested size up to nearest sector if writing
;or nearest block if using aligned reads
lda sizelo
!if aligned_read=0 {
beq +
inc sizehi
} else { ;aligned_read
ldx sizehi
jsr round
sta sizehi
} ;aligned_read
+
} ;enable_write
;cache EOF (file size, loaded backwards)
ldy #EOF+1
lda (bloklo), y
!if (enable_write+aligned_read)>0 {
tax
} else { ;enable_write or aligned_read
sta sizehi
} ;enable_write or aligned_read
dey
lda (bloklo), y
!if (enable_write+aligned_read)>0 {
;round file size up to nearest sector if writing without aligned reads
;or nearest block if using aligned reads
!if aligned_read=0 {
bcc ++
beq +
inx
lda #0
} else { ;aligned_read
!if enable_write=1 {
jsr round
tax
} else { ;enable_write
adc #$fe
txa
adc #1
and #$fe
} ;enable_write
} ;aligned_read
;set requested size to min(length, requested size)
!if enable_write=1 {
+ cpx sizehi
bcs +
++ stx sizehi
+
} else { ;enable_write
sta sizehi
} ;enable_write
} ;enable_write or aligned_read
!if aligned_read=0 {
sta sizelo
} ;aligned_read
;cache AUX_TYPE (load offset for binary files)
!if override_adr=0 {
!if allow_subdir=1 {
pla
tax
} else { ;allow_subdir
plp
} ;allow_subdir
ldy #AUX_TYPE
lda (bloklo), y
pha
iny
lda (bloklo), y
pha
!if allow_subdir=1 {
txa
pha
} ;allow_subdir
} ;override_adr
;cache KEY_POINTER
ldy #KEY_POINTER
lda (bloklo), y
tax
sta dirbuf
iny
lda (bloklo), y
sta dirbuf+256
;read index block in case of sapling
!if allow_subdir=1 {
plp
bpl rdwrfile
php
jsr readdirsec
plp
} else { ;allow_subdir
!if override_adr=1 {
plp
} ;override_adr
bcc rdwrfile
jsr readdirsec
} ;allow_subdir
;restore load offset
rdwrfile
!if override_adr=1 {
ldx ldrhi
lda ldrlo
} else { ;override_adr
pla
tax
pla
} ;override_adr
!if allow_subdir=1 {
;check file type and fake size and load address for subdirectories
bcc +
ldy #2
sty sizehi
ldx #>dirbuf
lda #<dirbuf
+
} ;allow_subdir
sta adrlo
stx adrhi
!if allow_aux=1 {
ldx auxreq
jsr setaux
} ;allow_aux
!if enable_write=1 {
ldy reqcmd
sty command
} ;enable_write
rdwrloop
!if aligned_read=0 {
;set read/write size to min(length, $200)
lda sizelo
ldx sizehi
cpx #2
bcc +
lda #0
ldx #2
+ sta secsize1
stx secsize2
} ;aligned_read
;fetch data block and read/write it
ldy entries
inc entries
ldx dirbuf, y
lda dirbuf+256, y
jsr seekrdwr
!if aligned_read=0 {
;if low count is non-zero then we are done
;(can happen only for partial last block)
lda secsize1
bne rdwrdone
;if count is $1xx then we are done
;(can happen only for partial last block)
dec sizehi
beq rdwrdone
;loop while size-$200 is non-zero
dec sizehi
lda sizehi
ora sizelo
} else { ;aligned_read
;loop while size-$200 is non-zero
dec sizehi
dec sizehi
} ;aligned_read
bne rdwrloop
unrdrvoff2=unrelocdsk+(*-reloc)
rdwrdone lda MOTOROFF
!if allow_aux=1 {
ldx #0
setaux sta CLRAUXRD, x
sta CLRAUXWR, x
} ;allow_aux
seekret rts
;no tricks here, just the regular stuff
seek sty step
asl phase
txa
asl
copy_cur tax
sta tmptrk
sec
sbc phase
beq +++
bcs +
eor #$ff
inx
bcc ++
+ sbc #1
dex
++ cmp step
bcc +
lda step
+ cmp #8
bcs +
tay
sec
+ txa
pha
ldx step1, y
+++ php
bne +
--- clc
lda tmptrk
ldx step2, y
+ stx tmpsec
and #3
rol
tax
lsr
unrseek=unrelocdsk+(*-reloc)
lda PHASEOFF, x
-- ldx #$13
- dex
bne -
dec tmpsec
bne --
bcs ---
plp
beq seekret
pla
inc step
bne copy_cur
step1 !byte 1, $30, $28, $24, $20, $1e, $1d, $1c
step2 !byte $70, $2c, $26, $22, $1f, $1e, $1d, $1c
readadr
- jsr readd5aa
cmp #$96
bne -
ldy #3
- sta curtrk
jsr readnib
rol
sta tmpsec
jsr readnib
and tmpsec
dey
bne -
rts
readd5aa
-- jsr readnib
- cmp #$d5
bne --
jsr readnib
cmp #$aa
bne -
tay ;we need Y=#$AA later
readnib
unrread1=unrelocdsk+(*-reloc)
- lda Q6L
bpl -
rts
!if (enable_write+aligned_read)=2 {
round clc
adc #$ff
txa
adc #1
and #$fe
rts
} ;enable_write and aligned_read
readdirsel ldy #0
sty adrlo
!if aligned_read=0 {
sty secsize1
} ;aligned_read
!if allow_multi=1 {
asl reqcmd
bcc seldrive
iny
seldrive lsr reqcmd
unrdrvsel=unrelocdsk+(*-reloc)
cmp DRV0EN, y
} ;allow_multi
!if poll_drive=1 {
sty status
unrdrvon1=unrelocdsk+(*-reloc)
ldy MOTORON
unrread2=unrelocdsk+(*-reloc)
- ldy Q6L
bpl -
unrread3=unrelocdsk+(*-reloc)
- cpy Q6L
bne readdirsec
inc status
bne -
pla
pla
jmp nodisk
} ;poll_drive
readdirsec ldy #>dirbuf
sty adrhi
!if aligned_read=0 {
ldy #2
sty secsize2
} ;aligned_read
ldy #cmdread
sty command
;convert block number to track/sector
seekrdwr
unrdrvon2=unrelocdsk+(*-reloc)
ldy MOTORON
lsr
txa
ror
lsr
lsr
sta phase
txa
and #3
php
asl
plp
rol
sta reqsec
!if aligned_read=0 {
;set read size to min(first size, $100) and then read address
ldy #0
lda secsize2
bne +
ldy secsize1
+ sty secsize
dec secsize2
} ;aligned_read
jsr readadr
;if track does not match, then seek
ldx curtrk
cpx phase
beq checksec
jsr seek
;force sector mismatch
lda #$ff
;match or read/write sector
checksec jsr cmpsec
!if aligned_read=0 {
;return if less than one sector requested
tya
bne readret
;return if only one sector requested
lda secsize1
cmp secsize2
beq readret
sta secsize
} ;aligned_read
inc reqsec
inc reqsec
;force sector mismatch
cmpsecrd lda #$ff
cmpsec
!if enable_write=1 {
ldy command
cpy #cmdwrite ;we need Y=2 below
beq encsec
} ;enable_write
cmpsec2 cmp reqsec
beq readdata
jsr readadr
beq cmpsec2
;read sector data
readdata jsr readd5aa
eor #$ad ;zero A if match
;; bne * ;lock if read failure
unrread4=unrelocdsk+(*-reloc)
- ldx Q6L
bpl -
eor nibtbl-$96, x
sta bit2tbl-$aa, y
iny
bne -
unrread5=unrelocdsk+(*-reloc)
-- ldx Q6L
bpl --
eor nibtbl-$96, x
sta (adrlo), y ;the real address
iny
!if check_checksum=1 {
!if aligned_read=0 {
bne check_end
} else { ;aligned_read
bne --
} ;aligned_read
unrread6=unrelocdsk+(*-reloc)
- ldx Q6L
bpl -
eor nibtbl-$96, x
bne cmpsecrd
} ;check_checksum
!if aligned_read=0 {
check_end
cpy secsize
bne --
ldy #0
} ;aligned_read
-- ldx #$a9
- inx
beq --
lda (adrlo), y
lsr bit2tbl-$aa, x
rol
lsr bit2tbl-$aa, x
rol
sta (adrlo), y
iny
!if aligned_read=0 {
cpy secsize
} ;aligned_read
bne -
readret inc adrhi
rts
!if enable_write=1 {
encsec
-- ldx #$aa
- dey
lda (adrlo), y
lsr
rol bit2tbl-$aa, x
lsr
rol bit2tbl-$aa, x
sta encbuf, y
lda bit2tbl-$aa, x
and #$3f
sta bit2tbl-$aa, x
inx
bne -
tya
bne --
cmpsecwr jsr readadr
cmp reqsec
bne cmpsecwr
;skip tail #$DE #$AA #$EB some #$FFs ...
ldy #$24
- dey
bpl -
;write sector data
unrslot1=unrelocdsk+(*-reloc)
ldx #$d1
lda Q6H, x ;prime drive
lda Q7L, x ;required by Unidisk
tya
sta Q7H, x
ora Q6L, x
;40 cycles
ldy #4 ;2 cycles
cmp $ea ;3 cycles
cmp ($ea,x) ;6 cycles
- jsr writenib1 ;(29 cycles)
;+6 cycles
dey ;2 cycles
bne - ;3 cycles if taken, 2 if not
;36 cycles
;+10 cycles
ldy #(prolog_e-prolog) ;2 cycles