-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathramdos12.src
More file actions
5009 lines (4971 loc) · 106 KB
/
Copy pathramdos12.src
File metadata and controls
5009 lines (4971 loc) · 106 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
;
; change list after v1.0
;
version .macro ; declare 3 char version here
.byte "4.3"
.endm
;
; when who version what
; -------- --- ---- ---------------------------------------------
; 11/13/87 fab V4.3 Added patch to correctly handle CLOSE for
; C128 opration. Patch added to match posted
; version of RAMDOS128.BIN.
;
; 10/26/87 fab V4.2 RBASIN did not check for prior status error-
; added code at DISK_IO to exit if bad status.
; This caused a problem especially for Relative
; file reads of empty records.
;
; EOF_CHECK did not preserve prior status-
; added ora status/ sta status. This caused a
; problem for file read loops expecting some kind
; of error status when past end of file.
;
; READ_BYTE did not set TIMEOUT status bit, and
; now it does (eg, read past EOF & you get ST=66).
;
; Relative file writes did not report OVERFLOW
; if given too much data for one record, and
; instead placed the excess data into subsequent
; records. Changed write_byte_rel to properly
; update current record only and report error.
; Fix assumes that a chkin/out implies a prior
; clrchn was performed.
;
; CLOSEing the command channel now closes all
; other user channels on disk side, as it should.
; Also, for C128 mode only, the status of carry
; is important as it should be (i.e., c=1 means
; not a real CLOSE, just remove crap from tables).
;
; 8/26/87 fab V4.1 Added NEW command. Simply sets disk_end=start.
;
; Added range check to set_unit_number (4-30).
;
; F access command string failed when a parameter
; was equal to <CR>. It's okay now.
;
; Added code to strip trailing <CR> if any from
; any filename processed by init_get_filename.
;
; 8/24/87 hcd V4.0 added 'F' access ( as opposed to 'RWMA' ).
;
; F access allows both reading and writing a
; file like sequential read and sequential
; write access. The file pointer merely points to
; the byte to operate on for reads or writes.
;
; F access is legal for SEQ or PRG files only.
;
; F access allows the POSITION command to be used
; to position the r/w head at any byte in the
; file. Positioning the head past the end of the
; file causes the file to be expanded, $FF is the
; padding char.
;
; The format for the F access version of the
; position command is:
;
; P:<channel><lpage><hpage>[<byte>]
;
; where:
;
; <channel> is the file's channel
; <hpage><lpage><byte> is a three byte
; pointer into the file. Three nulls
; would point the the first byte in the
; file.
;
; <byte> is optional, if omitted it
; defaults to zero.
;
; Note the odd order for the arguements.
;
;
;
; 8/20/87 hcd V3.6 added flush block call to read_byte_default.
; This is required before all DMAs directly
; to disk ram. Its omission had caused strange
; happenings when a file was opened for write,
; and a previously open read file was then opened.
;
; The rule is that any system calls which
; access disk memory directly ( as opposed to
; accessing disk memory via the default page ),
; must flush the default block before execution,
; and must unflush the block after execution.
;
; added flush block to do_load also.
;
; Corrected "FILE TOO LARGE" mispelling.
;
; Fixed bug with cleanup command write call
; to interpret command. Bad commands would
; shown errors because the command would be
; interpreted ( via cleanup ), then the commands
; cr would be interpreted as an ok command
; clearing the error channel. Fix was implemented
; by causeing commands of a single <cr> to
; have no effect on error channel.
;
; Caused serial buss timeout bit to be set when
; an attempt to read past the end of a file
; occurs. This is to accomodate BASIC7.0 DOS
; input command which is not satisfied by a
; simple EOF status.
;
; 7/20/87 hcd V3.5 BA ( the system bank variable ) was corrected
; to reflect the proper address. It was $cb.
; It is $c6.
;
; Corrected "FILE NAME EXSISTS" mispelling.
;
; Corrected "FILES SCRATCHED" error message
; where the number of files scratched was
; incorrect.
;
; Removed enhancement allowing for files
; > 10K block long. This causes the
; directory format display to be correct.
; ( filenames were shifted one char right )
;
; Caused cleanup_command_write to force any
; command in buffer to interpreted. This is
; in line with serial buss standard that clrch
; can terminate a command.
;
; 5/27/87 hcd V3.4 corrected save bug (saved 1 too many bytes
; causing load to load 1 too many)
;
; 4/8/87 hcd V3.3 corrected bug in sniff_disk_size which
; smelled 512k when only 256k exsisted
; on some ramdisk units. (erp)
;
; 11/12/86 hcd V3.2 added copyright message to jump vectors.
; corrected error 73 text to include Vx.x
; correctly from version macro.
;
; 11/11/86 hcd V3.1 added USR files.
; corrected error in M-W for unit change.
; corrected pattern matching bug where ending *
; in filename may mean 0-n chars.
;
;
;c64 = 1 ; define this flag to force c65 assy
rel_flag =1 ; define this flag to enable rel file code....
position_flag =1 ; define this flag to allow position command on
; program and relative files.
;
;
.ifdef position_flag
.ifndef rel_flag
*** error *** illegal to assemble with position and no rel files
.endif
.endif
;
.ifdef c64
;
.nam C64 RAMDISK DOS
;
default_unit_number = $08 unit 8
default_interface_page = $cf place for interface page
;
swapped_dos_base = $6000 install the dos here boss....
;
.else
.nam C128 RAMDISK DOS
;
default_unit_number = $09 unit 9
default_interface_page = $0e place for interface page
;
down_load_area = $3e4 start of down load area
swapped_dos_base = $2000
;
.endif
;
curzpg = $fe
curram = swapped_dos_base
code_start = swapped_dos_base+$300
swapped_code_start = swapped_dos_base
swapped_code_size = $1fff
;
.blist
.nclist
.include macros
;
* = code_start
;
jmp install ; install at default location
jmp reinstall ; reinstall at default location
jmp install_on_page ; install anywhere
jmp reinstall_on_page ; reinstall anywhere
jmp copyright_message ; print copyright message
;
;
.subttl "EQUATES"
;**************************************************************
; EQUATES
;**************************************************************
;
cr = $0d
;
; kernal_declares
;
status = $90
svxt = $92
verck = $93
ldtnd = $98
dfltn = $99
dflto = $9a
eal = $ae
eah = $af
fnlen = $b7
la = $b8
sa = $b9
fa = $ba
fnadr = $bb
stal = $c1
stah = $c2
memuss = $c3
.ifndef c64
ba = $c6
fnbank = $c7
.endif
;
inmi = $0318
iopen = $031a
iclose = $031c
ichkin = $031e
ickout = $0320
iclrch = $0322
ibasin = $0324
ibsout = $0326
; istop
igetin = $032a
iclall = $032c
; exmon
iload = $0330
isave = $0332
;
d1prb = $dc01 key scan port
d1ddrb = $dc03 key scan port ddr
d2icr = $dd0d icr for nmni 6526
;
.ifdef c64
fat = $0263
;
print = $e716 ; direct entry to screen printer.
;
cheap_open = $f34a
jxrmv = $f2f2 remove lat fat sat entry whose index is in .a
lookup = $f30f
jltlk = $f314
getlfs = $f31f ; jz100
;
_luking = $f5af print looking for filename
loding = $f5d2 print loading
_saving = $f68f print saving filename
;
no_restor_restore = $fe69 ; run stop restore less the restor....
fake_nmi = $fe72 ; calls nmi232, and does a prend...
;
kernal_error = $f715 ; kernal error handler
ud60 = $f6bc
;
.else
;
fat = $036c
;
system_vector = $0a00
;
print = $c00c direct entry into screen print...
;
cheap_open = $efbd
jxrmv = $f1e5 remove lat fat sat entry whose index is in .a
lookup = $f202
jltlk = $f207
getlfs = $f212
;
_luking = $f50f print looking for filename
loding = $f533 print loading
_saving = $f5bc print saving filename
;
no_restor_restore = $fa56 ; run stop restore less the restor....
fake_nmi = $fa5f ; calls nmi232, and does a prend...
;
kernal_error = $f699 ; kernal error handler
fnadry = $f7ae ; indirect load file name address
getcfg = $ff6b ; .a <= mmu setting for config .x
ud60 = $f63d
;
.endif
;
cint = $ff81
ioinit = $ff84
restor = $ff8a
clrch = $ffcc
stop = $ffe1
;
;
.subttl "ram declarations"
;*************************************************************************
; GENERAL SYSTEM RAM
;*************************************************************************
;
ram data_block,256 data block buffer
;
dir_filelen = data_block number of blocks for this file
dir_access = data_block+2 access char if open, null otherwise ( R,W,L,$ )
dir_filetype = data_block+3 type char for file ( S,P,L )
dir_last_byte = data_block+4 pointer to last byte
dir_end_record = data_block+5 two bytes indicating number of rel file records
dir_record_len = data_block+7 record length for rel files
dir_filename = data_block+8
; use rest of file for data
dir_data_start = dir_filename+18
dir_data_offset = dir_data_start-data_block
dir_load_addr = dir_data_offset+data_block
dir_load_data_offset = dir_data_offset+2
;
ram first_block,2 ; pointer to location of first data
; on disk after dos code and ram
ram disk_end,2 ; pointer to one past last data block in disk
; ( if disk_end == first_block then disk empty )
ram disk_max,2 ; highest legal value for disk_end
; ; this is the number of blocks on the disk
ram channel_blocks,2 ; this stores the pointer to channel
; storage on disk ( less than first block )
ram default_channel_number ; current channel in default_channel
;
ram cleanup_vector,2 ; pointer to cleanup routine for fastop
;
default_channel = curram
ram channel_access,1 ( R,W,L,$ ) read/write/relative/directory
ram directory_block,2 ( first_block - 1 )
ram current_byte,1
ram current_block,2 point directly to next byte
ram end_byte,1
ram end_block,2 point directly to last byte
.ifdef rel_flag
ram current_record_byte rel file, current byte in record
ram current_record,2 index of current record
ram current_record_len length of current record
; ram rel_write_flag flag for interface to disk_unlsn for rel only
ram end_record,2 index of last record in rel file
ram record_len length of physical record
.endif
default_channel_end
channel_len = curram-default_channel used to allocate channels
;
;
ram default_block,2 ; current block in the data_block buffer
;
zpage pntr,2 all I want is a pointer to use
ram pntr_save,2 save this too shithead....
;
;
ram eof_flag internal eof flag
ram data_byte data byte buffer
ram interface_page page number of the dma interface block
ram disk_fa our unit number ( can you say 9 )
ram alt_filename,17 alternate filename for copy/rename
;
;
;
.subttl "DMA DECLARATIONS"
;****************************************************************************
; DMA DECLARES
;****************************************************************************
;
;
.ifndef c64
mmucr = $ff00 ; mmu configuration
mmurcr = $d506
.endif
;
dma = $df00 ; base of dma unit
vicspeed = $d030 ; must do for c64 mode on c128
;
dma_status = dma ; dma status
; b7 - irq pending
; b6 - dma complete
; b5 - block verify error
; b4 - size register
; b3-0 - version
;
dma_cmd = dma+1 ; dma command
; b7 =1 arm transfer
; b6
; b5 =1 autoload enable
; b4 =1 disable $ff00 decode
; b3
; b2
; b1:b0
; 00 write c128 --> disk
; 01 read c128 <-- disk
; 10 swap c128 <-> disk
; 11 compare c128 == disk
;
dma_immediate_write = %10110000
dma_immediate_read = %10110001
dma_immediate_swap = %10110010
dma_immediate_compare = %10110011
;
dma_banked_write = %10100000
dma_banked_read = %10100001
dma_banked_swap = %10100010
dma_banked_compare = %10100011
;
dma_fastop_write = %10010000
dma_fastop_read = %10010001
;
dma_cpu_addr = dma+2 ; c128 addr
dma_disk_addr = dma+4 ; disk low order adder
dma_disk_block = dma+5 ; disk block ( two bytes )
dma_disk_bank = dma+6 ; disk bank
;
dma_len = dma+7 ; two bytes for length of transfer
;
dma_ifr = dma+9 ; interupt mask register
dma_acr = dma+10 ; address_control_register
;
;
;
.subttl "COPYRIGHT MESSAGE"
;************************************************************************
; COPYRIGHT MESSAGE
;************************************************************************
;
copyright_message
ldx #0
10$ txa
pha
lda 100$,x
jsr print
pla
tax
inx
cpx #110$-100$
bne 10$
rts
;
100$ .byte $0d
.byte "(C) 1986 COMMODORE ELECTRONICS, LTD. ",$0d
.byte " ALL RIGHTS RESERVED. ",$0d
110$ ;
;
;
.subttl "ERROR TEXT"
;************************************************************************
; ERROR TEXT
;************************************************************************
;
error .macro %n,%s,%a,%b,%c,%d
%s = %n
.ifb <%d>
.ifb <%c>
.ifb <%b>
.byte %n,"%a",0
.else
.byte %n,"%a %b",0
.endif
.else
.byte %n,"%a %b %c",0
.endif
.else
.byte %n,"%a %b %c %d",0
.endif
.endm
;
error_text
ERROR 00,OK,OK
ERROR 01,FILES_SCRATCHED,FILES,SCRATCHED
ERROR 13,DOS_CONFUSED,DOS,CONFUSED
ERROR 30,SYNTAX_ERROR,SYNTAX,ERROR
ERROR 31,ILLEGAL_COMMAND,SYNTAX,ERROR
ERROR 32,LONG_LINE,SYNTAX,ERROR
ERROR 33,ILLEGAL_WILD_CARD,SYNTAX,ERROR
ERROR 34,NO_FILENAME,SYNTAX,ERROR
ERROR 50,RECORD_NOT_PRESENT,RECORD,NOT,PRESENT
ERROR 51,OVERFLOW_IN_RECORD,OVERFLOW,IN,RECORD
ERROR 52,FILE_TOO_LARGE,FILE,TOO,LARGE
ERROR 60,FILE_OPEN,FILE,OPEN
ERROR 61,FILE_NOT_OPEN,FILE,NOT,OPEN
ERROR 62,FILE_NOT_FOUND,FILE,NOT,FOUND
ERROR 63,FILE_EXISTS,FILE,EXISTS
ERROR 64,FILE_TYPE_MISMATCH,FILE,TYPE,MISMATCH
ERROR 66,ILLEGAL_TRACK_AND_SECTOR,ILLEGAL,TRACK,AND,SECTOR
ERROR 70,NO_CHANNEL,NO,CHANNEL
ERROR 72,DISK_FULL,DISK,FULL
;
INIT_ERROR = 73
.byte 73,"CBM DOS V"
version
.ifdef c64
.byte " 1764",0
.else
.byte " 1750",0
.endif
;
ERROR 00,NULL,BAD,ERROR,NUMBER
;
;
;
.subttl "ERROR CHANNEL"
;************************************************************************
; ERROR CHANNEL
;************************************************************************
;
; ERROR_CHANNEL
;
; read_error_channel
; returns one byte from error channel
; sets eof flag at end of error
; error_channel_scratch_set_up
; formats message for this message
; entry: x,a = number of files scratched
; clear_error
; resets any pending errors to ok message
; error_channel_init_set_up
; inits error channel
; error_channel_set_up
; general purpose error entry ( .a = error number )
; format_error_message
; formats all error messages
; entry: a = error number
;
error_pntr = pntr
;
ram error_number
ram error_track
ram error_sector
;
max_error_length = 50
ram error_line,max_error_length
;
ram error_current_byte
ram error_end_byte
;
;
error_cleanup
clc
adc error_current_byte advance current byte by .a
sta error_current_byte
rts
;
read_error_channel
ldx error_current_byte if at end of error message
cpx error_end_byte
bcc 10$
jsr clear_error clear error message
clc
jmp disk_system_return_cr_eof return cr_eof
;
10$ ldi error_cleanup cleanup vector point to error cleanup
std cleanup_vector
ldi error_line-swapped_code_start
clc dma_disk_addr points to appropriate error line
adc error_current_byte
bcc 20$
inx
20$ std dma_disk_addr
lda #0
sta dma_disk_bank
;
lda error_end_byte .a <= number of bytes left to return to user
sec
sbc error_current_byte
;
ldx system_reg_x restore x,y
ldy system_reg_y
sec this is a read operation
jmp return_execute_fastop return via fastop
;
;
;
ram scratched_files_temp,2
ram scratched_files_temp2,2
ram scratched_files_digit
;
error_channel_scratch_set_up ;
std scratched_files_temp save number of files trashed
ldy #1
jsr format_error_message_scratch format first part of line
;
lda #0 clear the digit
sta scratched_files_digit
;
ldi 10000 try 10000's
jsr 100$
ldi 1000 try 1000's
jsr 100$
ldi 100 try 100's
jsr 100$
;
lda scratched_files_temp use exsisting software for last two digits
jsr add_error_decimal
jsr add_error_comma do the comma and trailing '00'
lda #0
jmp add_error_decimal and return
;
;
100$ std scratched_files_temp2 save subtractor
;
lda scratched_files_digit clear ones digit
and #$f0
sta scratched_files_digit
;
110$ lda scratched_files_temp while can subtract temp2 from temp1
sec
sbc scratched_files_temp2
tax
lda scratched_files_temp+1
sbc scratched_files_temp2+1
bcc 120$ do
sta scratched_files_temp+1 save result
stx scratched_files_temp
lda scratched_files_digit inc digit and or in the $30
adc #$00
ora #$30
sta scratched_files_digit
bne 110$
;
120$ lda scratched_files_digit if digit <> 0
beq 130$
jsr add_error_byte add digit to error message
130$ rts return
;
;
error_channel_init_set_up
ldy #73
.byte $2c
clear_error
error_channel_ok_set_up
ldy #0
lda #0
tax
jmp format_error_message
;
error_channel_set_up
tay
ldd current_block
;
format_error_message
jsr format_error_message_scratch
;
lda error_track
jsr add_error_decimal
jsr add_error_comma
lda error_sector
jmp add_error_decimal
;
format_error_message_scratch
sty error_number
stx error_track
sta error_sector
;
lda #0
sta error_current_byte
sta error_end_byte
lda error_number
jsr add_error_decimal
jsr add_error_comma
lda #$20
jsr add_error_byte
jsr add_error_text
jsr add_error_comma
rts
;
add_error_decimal
cmp #100
bcc 30$
cmp #200
bcc 10$
sbc #200
pha
lda #2
jmp 20$
10$ sec
sbc #100
pha
lda #1
20$ jsr add_error_digit
pla
30$ ldx #$ff
40$ inx
sec
sbc #10
bcs 40$
pha
txa
jsr add_error_digit
pla
clc
adc #10
; jmp add_error_digit
;
add_error_digit
ora #$30
.byte $2c
add_error_comma
lda #','
add_error_byte
ldx error_end_byte
sta error_line,x
cpx #max_error_length-2
beq 80$
inc error_end_byte
80$ lda #0
sta error_line+1,x
clc
rts
;
add_error_text
ldi error_text error_pntr <= start of messages
std error_pntr
20$ lda error_number do a <= error number
ldx #0 if (error_pntr) = .a
cmp (error_pntr,x)
beq 70$ break
jsr 100$ read until one past null
bne 20$ while not at a second null
;
;
70$ jsr 110$ do point and fetch next byte
beq 80$ if null, break
jsr add_error_byte add byte to message
jmp 70$ loop
80$ clc exit happy
rts
;
100$ jsr 110$ do point to and fetch next byte
bne 100$ while byte not null
110$ incd error_pntr point to next byte
ldx #0 .a <= next byte
lda (error_pntr,x)
rts return
;
.subttl "SELECT CHANNELS"
;******************************************************************
; SELECT_CHANNELS
;******************************************************************
;
num_channels = 17
directory_channel = 16
;
init_channels
ldx #num_channels-1
10$ txa
jsr select_channel_a
jsr clear_channel
ldx default_channel_number
dex
bpl 10$
rts
;
clear_channel ; set all channel data to zero
ldx #channel_len-1
lda #0
20$ sta default_channel,x
dex
bpl 20$
rts
;
select_channel_given_sa
lda sa
and #$0f
.byte $2c
;
select_dir_channel
lda #16
;
select_channel_a
cmp default_channel_number
beq 80$
;
10$ pha save channel to get
;
ldi default_channel set up cpu addr
std dma_cpu_addr
lda channel_blocks+1 set up bank
sta dma_disk_bank
ldi channel_len set up length
std dma_len
;
;
lda default_channel_number write the default channel
ldy #dma_immediate_write
jsr 50$
pla mark new channel number
sta default_channel_number
ldy #dma_immediate_read
jsr 50$ read the new channel
80$ lda default_channel_number .a <= channel number
ldx channel_access .x <= channel open flag
clc
rts
;
50$ asl a
tax
lda 100$,x
sta dma_disk_addr set up byte address
lda 100$+1,x
adc channel_blocks correct for page boundary
sta dma_disk_block
sty dma+1 do dat dma, oh yeah, do wah do wah
rts
;
;
channel_offset_temp = 0
100$
.rept num_channels
.word channel_offset_temp
channel_offset_temp = channel_offset_temp+channel_len
.iflt $200-channel_offset_temp
*** CHANNELS TOO LARGE ****
.endif
.endr
;
;
.subttl "ACCESS DISK"
;******************************************************************
; ACCESS_DISK
;******************************************************************
;
;
access_new_current_block
std current_block
access_current_block
ldd current_block
access_block_a
access_block
cpd default_block if already have desired block
beq access_block_ret go return
phd save block to load
jsr flush_block flush the current block to disk
pld recall block to load
std default_block save as current block
;
;
unflush_block ; read the new default block in.
ldy #dma_immediate_read
.byte $2c
flush_block
ldy #dma_immediate_write y <= write ( auto load )
jsr dma_data_block_setup set up dma controller
ldd default_block x,a <= default block pla
std dma_disk_block write block to dma controller
sty dma+1 do the dma
access_block_ret
clc return happy
rts
;
;
dma_data_block_setup ; set up dma controller for data block
ldx #110$-100$-1 ( y must be preserved )
10$ lda 100$,x
sta dma+2,x
dex
bpl 10$
rts
;
100$ .word data_block ; c128 addr
.byte 0 ; low order ramdisk address
.word 0 ; ramdisk block - overwritten
.word $100 ; number of bytes to move
.word 0 ; ifr
.word 0 ; increment both sets of registers
110$
;
;
;
;
.subttl "READ BYTE"
;**************************************************************************
; READ BYTE
;**************************************************************************
;
;
read_byte_given_sa
jsr select_channel_given_sa
cmp #15 if error channel
bne 10$
jmp read_error_channel
10$ cpx #0 if channel not open
bne 20$
lda #$46 ;<4.2 fab>
sta status ;<4.2 fab> set EOF and TIMEOUT bits
lda #no_channel
jmp disk_system_return_error
;
20$ cpx #'$ if not directory channel
bne read_byte_default
jmp directory_read
;
read_byte_default_cleanup
tay save number of bytes moved
beq 80$ exit iff none
clc current_byte += number of bytes moved
adc current_byte
sta current_byte
bcc 10$
incd current_block
10$ jsr unflush_block unflush the block ( think about it... )
80$ rts return
;
;
;
read_byte_default
;
lda channel_access
cmp #'R
beq 10$
.ifdef rel_flag
.ifdef position_flag
cmp #'F
beq 10$
.endif
cmp #'L if rel file
bne 90$
jmp read_byte_rel call special routinue
.endif
90$ lda #file_open
jmp disk_system_return_error
;
10$ sec a,x,y <= end_byte - current_byte - 1
lda end_byte
sbc current_byte
tay
lda end_block
sbc current_block
tax
lda end_block+1
sbc current_block+1
bcs 20$ if < 0
jmp disk_system_return_eof_timeout
;
20$ bne 25$ .y <= min( xay, $ff )
txa
beq 50$
25$ ldy #$ff
;
50$ tya save y while we flush the block....
pha
jsr flush_block
pla
tay if y = 0
bne 60$ ( must be time for last byte )
;
lda #$40 set eof status
sta status
iny y <= 1
;
60$ ldi read_byte_default_cleanup
; x,a <= cleanup vector
sec this is a read operation
jmp io_fastop setup fastop and return
;
;
.subttl "WRITE BYTE"
;**************************************************************************
; WRITE_BYTE
;**************************************************************************
;
write_byte_given_sa
jsr select_channel_given_sa
cmp #15 if command channel
bne 10$
jmp command_channel_write
;
10$ cpx #'W if write access
beq write_byte_default
;
.ifdef rel_flag
.ifdef position_flag
cpx #'F if fast access
beq write_byte_default
.endif
cpx #'L if relative access
bne 90$
jmp write_byte_rel
.endif
;
90$ lda #no_channel complain no channel
jmp disk_system_return_error
;
;
cleanup_write_byte