-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtrdos.z80s
11832 lines (11813 loc) · 175 KB
/
trdos.z80s
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
; trdos.z80s
; This file is part of TR-DOS Disassembled
; By Marcos Cruz (programandala.net), 2016, 2017
org 0x0000
include inc/zx_spectrum_rom_routines.z80s
include inc/zx_spectrum_char_codes.z80s
sys_swap: equ 0x5b00
sys_bankm: equ 0x5b5c
sys_tstack: equ 0x5bff
sys_kstate: equ 0x5c00
sys_kstate.1: equ 0x5c01
sys_repdel: equ 0x5c09
sys_strms: equ 0x5c10
sys_chars: equ 0x5c36
sys_rasp: equ 0x5c38
sys_err_nr: equ 0x5c3a
sys_flags: equ 0x5c3b
sys_tv_flag: equ 0x5c3c
sys_err_sp: equ 0x5c3d
sys_newppc: equ 0x5c42
sys_nsppc: equ 0x5c44
sys_ppc: equ 0x5c45
sys_bordcr: equ 0x5c48
sys_vars: equ 0x5c4b
sys_chans: equ 0x5c4f
sys_curchl: equ 0x5c51
sys_prog: equ 0x5c53
sys_datadd: equ 0x5c57
sys_e_line: equ 0x5c59
sys_k_cur: equ 0x5c5b
sys_ch_add: equ 0x5c5d
sys_worksp: equ 0x5c61
sys_stkbot: equ 0x5c63
sys_stkend: equ 0x5c65
sys_df_sz: equ 0x5c6b
sys_udg: equ 0x5c7b
sys_attr_p: equ 0x5c8d
sys_attr_t: equ 0x5c8f
sys_membot: equ 0x5c92
sys_ramtop: equ 0x5cb2
sys_p_ramt: equ 0x5cb4
sys_p_ramt.high: equ 0x5cb5
trdos_variable.interface_1_zone: equ 0x5cb6
trdos_variable.0xc9: equ 0x5cc2
trdos_variable.unknown_23747: equ 0x5cc3
trdos_variable.drive_a_mode: equ 0x5cc8
trdos_variable.drive_c_mode: equ 0x5cca
trdos_variable.cat_current_sector: equ 0x5ccc
trdos_variable.disk_drive_ready: equ 0x5ccd
trdos_variable.sector_rw_flag: equ 0x5cce
trdos_variable.stack_sp_copy: equ 0x5ccf
trdos_variable.basic_program_autostart: equ 0x5cd1
trdos_variable.basic_program_autostart.high: equ 0x5cd2
trdos_variable.unknown_23763: equ 0x5cd3
trdos_variable.move_command_deleted_files: equ 0x5cd4
trdos_variable.move_command_first_sector: equ 0x5cd5
trdos_variable.bad_sectors_or_move_command_first_track: equ 0x5cd6
trdos_variable.start_file_parameter_or_number_of_tracks: equ 0x5cd7
trdos_variable.start_file_parameter.high: equ 0x5cd8
trdos_variable.ch_add: equ 0x5cd9
trdos_variable.ch_add.high: equ 0x5cda
trdos_variable.stream_or_file_size: equ 0x5cdb
trdos_variable.file_size.high: equ 0x5cdc
trdos_variable.filename: equ 0x5cdd
trdos_variable.filename.2: equ 0x5cdf
trdos_variable.filename.4: equ 0x5ce1
trdos_variable.filename.6: equ 0x5ce3
trdos_variable.file_type: equ 0x5ce5
trdos_variable.file_start: equ 0x5ce6
trdos_variable.file_start.high: equ 0x5ce7
trdos_variable.file_length_in_bytes: equ 0x5ce8
trdos_variable.file_length_in_bytes.high: equ 0x5ce9
trdos_variable.file_length_in_sectors: equ 0x5cea
trdos_variable.file_first_sector: equ 0x5ceb
trdos_variable.c_file_start_or_b_file_size: equ 0x5ced
trdos_variable.file_2_length_in_bytes: equ 0x5cef
trdos_variable.file_2_length_in_sectors: equ 0x5cf1
trdos_variable.file_2_first_sector: equ 0x5cf2
trdos_variable.current_sector: equ 0x5cf4
trdos_variable.current_track: equ 0x5cf5
trdos_variable.current_temporary_drive: equ 0x5cf6
trdos_variable.cleared: equ 0x5cf7
trdos_variable.two_files_drive: equ 0x5cf8
trdos_variable.cat_drive_or_read_verify_flag: equ 0x5cf9
trdos_variable.drive_a_step_rate: equ 0x5cfa
trdos_variable.drive_c_step_rate: equ 0x5cfc
trdos_variable.last_fdc_command: equ 0x5cfe
trdos_variable.sector: equ 0x5cff
trdos_variable.buffer: equ 0x5d00
trdos_variable.hl_copy: equ 0x5d02
trdos_variable.de_copy: equ 0x5d04
trdos_variable.bytes_compared_by_find_command: equ 0x5d06
trdos_variable.deleted_files: equ 0x5d07
trdos_variable.filename_first_char: equ 0x5d08
trdos_variable.data_file_mode: equ 0x5d09
trdos_variable.buffer_flag: equ 0x5d0c
trdos_variable.file_number_for_copying: equ 0x5d0d
trdos_variable.command_mode: equ 0x5d0e
trdos_variable.error_code: equ 0x5d0f
trdos_variable.error_code_msb: equ 0x5d10
trdos_variable.command_line_address: equ 0x5d11
trdos_variable.err_sp_copy: equ 0x5d13
trdos_variable.show_screen_flag: equ 0x5d15
trdos_variable.system_register: equ 0x5d16
trdos_variable.show_title_flag: equ 0x5d17
trdos_variable.interface_1_flag: equ 0x5d18
trdos_variable.default_drive: equ 0x5d19
trdos_variable.internal_address_of_finishing_proc: equ 0x5d1a
trdos_variable.sp_copy: equ 0x5d1c
trdos_variable.find_command_found_file: equ 0x5d1e
trdos_variable.unknown_23839: equ 0x5d1f
trdos_variable.entered_line_3_first_chars: equ 0x5d20
trdos_variable.entered_line_3_first_chars.1: equ 0x5d21
trdos_variable.move_command_blocks: equ 0x5d23
trdos_variable.tmp_buffer_address: equ 0x5d25
trdos_variable.k_channel.output: equ 0x5d26
trdos_variable.r_channel.input.high: equ 0x5d33
trdos_sector_buffer.next_free_sector: equ 0x5e06
trdos_sector_buffer.next_free_track: equ 0x5e07
trdos_sector_buffer.disk_type: equ 0x5e08
trdos_sector_buffer.files: equ 0x5e09
trdos_sector_buffer.free_sectors: equ 0x5e0a
trdos_sector_buffer.sectors_per_track: equ 0x5e0c
trdos_sector_buffer.deleted_files: equ 0x5e19
trdos_sector_buffer.disc_title: equ 0x5e1a
di
ld de,0xFFFF
ld a,0x07
jr l0009h
nop
l0009h:
out (0xFE),a
ld a,0x3F
jr l0013h
nop
rst_10:
jp print_character_A
l0013h:
ld i,a
jp l001bh
rst_18:
jp print_message_at_HL
l001bh:
nop
nop
nop
jr l0024h
rst_20:
jp call_zx_spectrum_rom_routine_stored_at_the_address_on_tos
ret
l0024h:
ld h,d
ld l,e
jr l002bh
jp l2323h
l002bh:
ld (hl),0x02
dec hl
cp h
jr nz,l002bh
jr l003ah
; BLOCK 'not_used_0033' (start 0x0033 end 0x003a)
not_used_0033_start:
defb 0xFF
defb 0xFF
defb 0xFF
defb 0xFF
defb 0xFF
defb 0xFB
defb 0xC9
l003ah:
or a
sbc hl,de
add hl,de
inc hl
jr nc,l0047h
dec (hl)
jr z,l0047h
dec (hl)
jr z,l003ah
l0047h:
dec hl
ld (sys_p_ramt),hl
ld de,l3eafh
ld bc,0x00A8
ld a,e
ex de,hl
ld sp,0x6000
ld (0x5F00),hl
ld hl,l0079h
push hl
ld hl,trdos_entry.call_pushed_address
push hl
ld hl,0xB8ED
jr l0069h
jp magic_button_nmi_request
l0069h:
ld (0x5F10),hl
push af
ld a,0xC9
ld (0x5F12),a
pop af
ld hl,(0x5F00)
jp 0x5F10
l0079h:
ex de,hl
inc hl
ld (sys_udg),hl
dec hl
ld bc,0x1E40
ld (sys_rasp),bc
ld (sys_ramtop),hl
ld hl,zx_spectrum_font_char_0
ld (sys_chars),hl
ld hl,(sys_ramtop)
ld (hl),0x3E
dec hl
ld sp,hl
dec hl
dec hl
ld (sys_err_sp),hl
ld de,l1303h
push de
im 1
ld iy,sys_err_nr
ld hl,trdos_variable.interface_1_zone
ld (sys_chans),hl
ld de,l15afh
ld bc,0x0015
ex de,hl
call sub_0117h
ex de,hl
dec hl
ld (sys_datadd),hl
inc hl
ld (sys_prog),hl
ld (sys_vars),hl
ld (hl),0x80
inc hl
ld (sys_e_line),hl
ld (hl),0x0D
inc hl
ld (hl),0x80
inc hl
ld (sys_worksp),hl
ld (sys_stkbot),hl
ld (sys_stkend),hl
ld a,0x38
ld (sys_attr_p),a
ld (sys_attr_t),a
ld (sys_bordcr),a
ld hl,0x0523
ld (sys_repdel),hl
dec (iy-0x3A)
dec (iy-0x36)
ld hl,0x15C6
ld de,sys_strms
ld bc,0x000D+1
call sub_0117h
set 1,(iy+0x01)
ld hl,trdos_variable.0xc9
ld (hl),0xC9
rst 0x20
defw rom_clear_prb
ld hl,sys_df_sz
ld (hl),0x02
ld hl,l128bh
push hl
ld a,0xAA
ld (sys_swap),a
ei
jp enter_trdos_from_basic
sub_0117h:
ld (0x5F00),hl
ld hl,trdos_entry.call_pushed_address
push hl
ld hl,0xB0ED
ld (0x5F10),hl
ld hl,(0x5F00)
jp 0x5F10
l012ah:
call sub_20e5h
call cls
ld hl,(sys_e_line)
inc hl
ld e,(hl)
inc hl
ld d,(hl)
ld a,d
or e
ex de,hl
jr z,l0140h
xor a
ld (trdos_variable.error_code_msb),a
l0140h:
push hl
call sub_0232h
pop hl
ld (sys_newppc),hl
xor a
ld (sys_nsppc),a
rst 0x20
defw rom_set_min
ld hl,(sys_prog)
dec hl
ld (sys_datadd),hl
ld sp,(sys_err_sp)
ld a,(trdos_variable.error_code_msb)
or a
ld hl,0x1B76
jr z,l0166h
rst 0x20
defw rom_report_0 ; Error report: "OK"
l0166h:
push hl
ld hl,trdos_variable.0xc9
push hl
ret
do_interpret_rem_command_in_basic:
call sub_20f1h
call allocate_the_sector_buffer
ld a,0xFF
ld (trdos_variable.show_screen_flag),a
xor a
ld (trdos_variable.cleared),a
ld a,0xAA
ld (trdos_variable.show_title_flag),a
ld hl,finishing_proc_0x0201
ld (trdos_variable.internal_address_of_finishing_proc),hl
ld hl,0x0000
add hl,sp
ld (trdos_variable.sp_copy),hl
dec hl
dec hl
ld sp,hl
call sub_021dh
ld hl,(sys_ramtop)
ld de,(sys_ch_add)
sbc hl,de
ex de,hl
jr nc,l01a5h
or a
ld de,0x0100+1
sbc hl,de
l01a5h:
ld (sys_ch_add),hl
l01a8h:
call sub_01c7h
l01abh:
jp z,exit_dos
cp 0xEA
inc hl
jr nz,l01a8h
call sub_01c7h
jr z,l01abh
cp 0x3A
jp nz,exit_dos
inc hl
call sub_3048h
ld hl,(trdos_variable.command_line_address)
jp l030ah
sub_01c7h:
ld a,(hl)
cp char.carriage_return
ret z
cp 0x80
ret z
or a
ret
call sub_1e43h
exit_dos:
ld hl,0x0000
ld (trdos_variable.two_files_drive),hl
call sub_20e5h
call sub_1d63h
ld hl,trdos_variable.show_title_flag
ld (hl),0xAA
ld hl,trdos_variable.unknown_23839
ld a,(hl)
or a
ld (hl),0x00
jr nz,l01f3h
call remove_fp
call empty_command_line
l01f3h:
ld sp,(trdos_variable.sp_copy)
ld hl,(trdos_variable.internal_address_of_finishing_proc)
ld bc,(trdos_variable.error_code)
ld b,0x00
jp (hl)
finishing_proc_0x0201:
call sub_0232h
bit 7,(iy+0x00)
ret nz
ld de,trdos_variable.0xc9
ld sp,(sys_err_sp)
push de
ret
empty_command_line:
call get_char
cp char.carriage_return
ret z
call next_char
jr empty_command_line
sub_021dh:
ld hl,(sys_err_sp)
ld (trdos_variable.err_sp_copy),hl
ld hl,(trdos_variable.sp_copy)
dec hl
dec hl
ld (sys_err_sp),hl
ld de,l3d16h
ld (hl),e
inc hl
ld (hl),d
ret
sub_0232h:
ld hl,(trdos_variable.err_sp_copy)
ld (sys_err_sp),hl
ret
l0239h:
ld hl,0x0000
ld (trdos_variable.cleared),hl
add hl,sp
ld (trdos_variable.sp_copy),hl
dec hl
dec hl
ld sp,hl
call sub_021dh
ld hl,trdos_variable.show_title_flag
ld a,(hl)
cp 0xAA
ld a,0x00
ld (trdos_variable.error_code),a
jp z,finishing_proc_0x02CB
ld (hl),0xAA
call cls
call open_channel_2
ld hl,trdos_title_start
rst 0x18
call sub_106eh
ld a,(trdos_variable.interface_1_zone)
cp 0xF4
jr z,l0271h
ld hl,message_interface_1_start
rst 0x18
l0271h:
ld a,(sys_swap)
cp 0xAA
jr nz,finishing_proc_0x02CB
call sub_20f1h
l027bh:
ld hl,(sys_e_line)
ld a,0xFE
ld (trdos_variable.command_mode),a
ld (hl),0xF7
inc hl
ld (hl),0x22
inc hl
ld (hl),0x62
inc hl
ld (hl),0x6F
inc hl
ld (hl),0x6F
inc hl
ld (hl),0x74
inc hl
ld (hl),0x22
inc hl
ld (sys_k_cur),hl
ld (hl),0x0D
inc hl
ld (hl),0x80
inc hl
ld (sys_worksp),hl
ld (sys_stkbot),hl
ld (sys_stkend),hl
set 3,(iy+0x01)
jr l02efh
sub_02b0h:
ld b,0x03
l02b2h:
ld a,(hl)
ld (de),a
inc hl
inc de
djnz l02b2h
ret
sub_02b9h:
ld b,0x20
l02bbh:
push bc
xor 0x08
out (0xFF),a
push af
ld a,0x05
call sub_3dffh
pop af
pop bc
djnz l02bbh
ret
finishing_proc_0x02CB:
ld hl,(trdos_variable.sp_copy)
dec hl
dec hl
ld sp,hl
call sub_20f1h
call open_channel_0
ld a,(trdos_variable.system_register)
or 0x03
call sub_02b9h
ld a,(trdos_variable.system_register)
call sub_02b9h
xor a
ld (trdos_variable.show_screen_flag),a
call sub_2135h
call sub_3032h
l02efh:
call cls_lower
ld hl,finishing_proc_0x02CB
ld (trdos_variable.internal_address_of_finishing_proc),hl
xor a
ld (trdos_variable.error_code),a
ld hl,(sys_e_line)
push hl
ld de,trdos_variable.entered_line_3_first_chars
call sub_02b0h
pop hl
ld (trdos_variable.command_line_address),hl
l030ah:
ld a,(hl)
ld b,a
and 0x80
ld a,b
jr z,l031ah
cp 0xFE
jr z,l031ah
push af
call init_default_disk_drive
pop af
l031ah:
ld hl,token_commands_table_start
dec hl
ld c,0x00
l0320h:
inc c
ld d,a
ld a,0x15
cp c
jp c,exit_dos
ld a,d
inc hl
cp (hl)
jr nz,l0320h
cp 0xFE
call nz,allocate_the_sector_buffer
ld a,0x09
ld (trdos_variable.bytes_compared_by_find_command),a
xor a
ld (trdos_variable.error_code),a
ld (trdos_variable.bad_sectors_or_move_command_first_track),a
ld (trdos_variable.error_code_msb),a
ld hl,sys_flags
res 7,(hl)
ld b,0x00
ld hl,token_commands_addresses_table_start
dec c
sla c
add hl,bc
ld e,(hl)
inc hl
ld d,(hl)
ex de,hl
push hl
ld de,l0359h
push de
jp (hl)
l0359h:
ld hl,sys_flags
set 7,(hl)
pop hl
jp (hl)
; BLOCK 'trdos_title' (start 0x0360 end 0x03ac)
trdos_title_start:
defb 0x16
defb 0x01
defb 0x05
defb "*"
defb " "
defb "T"
defb "R"
defb "-"
defb "D"
defb "O"
defb "S"
defb " "
defb "V"
defb "e"
defb "r"
defb " "
defb "5"
defb "."
defb "0"
defb "3"
defb " "
defb "*"
defb 0x0D
defb 0x0D
defb 0x7F
defb " "
defb "1"
defb "9"
defb "8"
defb "6"
defb " "
defb "T"
defb "e"
defb "c"
defb "h"
defb "n"
defb "o"
defb "l"
defb "o"
defb "g"
defb "y"
defb " "
defb "R"
defb "e"
defb "s"
defb "e"
defb "a"
defb "r"
defb "c"
defb "h"
defb " "
defb "L"
defb "t"
defb "d"
defb "."
defb 0x16
defb 0x05
defb 0x0B
defb "("
defb "U"
defb "."
defb "K"
defb "."
defb ")"
defb 0x16
defb 0x07
defb 0x05
defb "B"
defb "E"
defb "T"
defb "A"
defb " "
defb "1"
defb "2"
defb "8"
defb 0x00
l03ach:
call read_sector_8_of_track_0
call print_carriage_return
call print_carriage_return
l03b5h:
ld bc,(trdos_sector_buffer.free_sectors)
call print_number_in_BC
ld hl,message.cr.free
rst 0x18
jp_exit_dos:
jp exit_dos
print_error_number_A_whose_message_is_at_HL:
push af
ld a,(trdos_variable.command_mode)
cp 0xFE
jr nz,l03cdh
pop af
ret
l03cdh:
pop af
ld (trdos_variable.error_code),a
ld a,(trdos_variable.show_screen_flag)
or a
call z,print_message_at_HL
ret
print_no_files_error_and_exit_DOS:
ld hl,message.cr.no_files
ld a,0x01
jp print_error_number_A_whose_message_is_at_HL_and_exit_DOS
print_OK_and_exit_DOS:
ld hl,message.ok
xor a
jp print_error_number_A_whose_message_is_at_HL_and_exit_DOS
read_cat_sector_0_into_tmp_buffer:
xor a
ld (trdos_variable.cat_current_sector),a
read_current_cat_sector_into_tmp_buffer:
ld de,(trdos_variable.cat_current_sector)
ld d,0x00
read_sector_DE_into_tmp_buffer:
call allocate_the_sector_buffer
ld hl,trdos_variable.tmp_buffer_address
ld b,0x01
jp read_sectors
read_sector_8_of_track_0:
call allocate_the_sector_buffer
ld de,0x0008
jr read_sector_DE_into_tmp_buffer
read_system_track:
call read_sector_8_of_track_0
ld a,(trdos_sector_buffer.sectors_per_track)
cp 0x10
jr z,sectors_per_track_are_correct_so_disk_is_recognized
ld hl,message.cr.disc_error
rst 0x18
jr jp_exit_dos
sectors_per_track_are_correct_so_disk_is_recognized:
call sub_3e11h
res 0,(hl)
res 1,(hl)
ld a,(trdos_sector_buffer.disk_type)
bit 0,a
jr nz,l0425h
set 0,(hl)
l0425h:
bit 3,a
ret nz
set 1,(hl)
ret
z_if_next_command_line_char_is_carriage_return:
ld hl,(trdos_variable.command_line_address)
inc hl
ld a,(hl)
cp char.carriage_return
ret
cli_command.cat:
call z_if_next_command_line_char_is_carriage_return
ld bc,0x0001+1
ld (trdos_variable.stream_or_file_size),bc
jr z,print_catalogue_of_current_temporary_drive
cp '#' ; channel?
jr nz,l045dh
ld (sys_ch_add),hl
call sub_1e0bh
call get_char
cp char.carriage_return
jr z,print_catalogue_of_current_temporary_drive
cp 0x2C
jp nz,error.wrong_drive_letter
call next_char
call expt_exp
jr l0460h
l045dh:
call parse_expression
l0460h:
call pop_hl_if_checking_syntax
call stk_fetch
ex de,hl
call parse_possible_drive_letter_in_filename_at_HL
print_catalogue_of_current_temporary_drive:
call pop_hl_if_checking_syntax
ld a,(trdos_variable.current_temporary_drive)
ld (trdos_variable.cat_drive_or_read_verify_flag),a
call read_system_track
ld a,(trdos_variable.stream_or_file_size)
print_catalogue_to_stream_A:
cp 0x02
push af
call z,cls
pop af
cp 0x11
jp nc,error.wrong_drive_letter
call chan_open
ld a,0xFF
ld (trdos_variable.two_files_drive),a
ld hl,message.cr.title
rst 0x18
ld hl,trdos_sector_buffer.disc_title
rst 0x18
call print_carriage_return
ld a,(trdos_sector_buffer.files)
ld hl,trdos_sector_buffer.deleted_files
sub (hl)
push hl
call print_number_in_A
ld hl,message.files.cr
rst 0x18
pop hl
ld c,(hl)
call print_number_in_C
ld hl,message.del_file
rst 0x18
call read_cat_sector_0_into_tmp_buffer
ld hl,trdos_variable.tmp_buffer_address
print_catalogue.line:
call init_cat_drive
call print_carriage_return
ld a,(trdos_variable.current_temporary_drive)
add a,"A" ; first drive letter
rst 0x10
ld b,0x02
print_catalogue.file:
call init_cat_drive
push bc
ld a,":"
rst 0x10
push hl
call print_filename_at_HL
ld bc,0x000D
pop hl
push hl
add hl,bc
ld c,(hl)
push bc
ld a,c
ld b,0x02
cp 0x0A
jr c,l04dfh
dec b
l04dfh:
cp 0x64
jr nc,l04e8h
l04e3h:
ld a,0x20
rst 0x10
djnz l04e3h
l04e8h:
pop bc
call print_number_in_BC
pop hl
pop bc
ld de,0x10
add hl,de
djnz print_catalogue.file
jr print_catalogue.line
init_cat_drive:
push hl
push bc
ld a,(trdos_variable.cat_drive_or_read_verify_flag)
ld hl,trdos_variable.current_temporary_drive
cp (hl)
call nz,init_disk_drive_in_A_register
pop bc
pop hl
jp l2fc6h
sub_0507h:
ld de,0x10
add hl,de
ret
sub_050ch:
push hl
push bc
ld bc,0xA1DB
add hl,bc
jr c,l0517h
pop bc
pop hl
ret
l0517h:
ld hl,trdos_variable.cat_current_sector
inc (hl)
call read_current_cat_sector_into_tmp_buffer
pop bc
pop hl
ld hl,trdos_variable.tmp_buffer_address
ret
check_drive_letter_and_convert_to_number:
and 0xDF
sbc a,"A" ; first drive letter
jp c,error.wrong_drive_letter
cp 0x04
jp nc,error.wrong_drive_letter
ret
fetch_drive_letter_from_the_calculator_stack:
call stk_fetch
ld a,c
cp b
jp z,error.wrong_drive_letter
ret
cli_command.new:
call sub_1dcdh
call pop_hl_if_checking_syntax
call sub_102eh
call sub_1cb0h
ld a,(trdos_variable.current_temporary_drive)
ld (trdos_variable.two_files_drive),a
jp nz,print_no_files_error_and_exit_DOS
push bc
call read_file_descriptor_C
call sub_1cb0h
push af
ld a,(trdos_variable.two_files_drive)
ld hl,trdos_variable.current_temporary_drive
cp (hl)
jp nz,error.wrong_drive_letter
call read_system_track
pop af
jp z,error.file_exists
pop bc
l0569h:
call write_file_descriptor_C
call sub_1e43h
jp print_OK_and_exit_DOS
check_error_code_msb:
ld a,(trdos_variable.error_code_msb)
or a
ret
check_deleted_files_and_exit_DOS:
ld a,(trdos_variable.deleted_files)
or a
jp z,print_no_files_error_and_exit_DOS
jp print_OK_and_exit_DOS
sub_0581h:
push bc
call cls
ld a,(trdos_variable.current_temporary_drive)
add a,"A" ; first drive letter
call print_character_A
ld a,":"
call print_character_A
ld hl,trdos_variable.filename
call print_filename_at_HL
ld hl,message.file_exists
call print_message_at_HL
call get_uppercase_pressed_key
cp "Y" ; Yes?
push af
call cls
pop af
pop bc
ret nz
push bc
call cls
pop bc
call sub_0781h
xor a
ret
sub_05b4h:
ld a,(trdos_variable.file_type)
cp "#" ; data file type?
jr z,l05bdh
xor a
ret
l05bdh:
ld a,0x0A
ld (trdos_variable.bytes_compared_by_find_command),a
call sub_1cb3h
ld a,0x09
ld (trdos_variable.bytes_compared_by_find_command),a
ret
l05cbh:
ld a,(trdos_variable.filename)
cp 0x2A
jp nz,print_no_files_error_and_exit_DOS
call stk_fetch
ex de,hl
call parse_possible_drive_letter_in_filename_at_HL
ld a,(hl)
cp 0x2A
jp nz,error.wrong_drive_letter
ld a,(trdos_variable.current_temporary_drive)
ld (trdos_variable.cat_drive_or_read_verify_flag),a
ld a,(trdos_variable.cat_drive_or_read_verify_flag)
call init_disk_drive_in_A_register
call read_system_track
ld a,0xFF
ld (trdos_variable.file_number_for_copying),a
l05f4h:
ld a,(trdos_variable.two_files_drive)
call init_disk_drive_in_A_register
call read_system_track
ld a,(trdos_variable.file_number_for_copying)
inc a
ld (trdos_variable.file_number_for_copying),a
ld c,a
call read_file_descriptor_C
ld a,(trdos_variable.filename)
cp 0x00
jp z,print_OK_and_exit_DOS
cp 0x01
jr z,l05f4h
ld hl,trdos_variable.file_start
ld de,trdos_variable.c_file_start_or_b_file_size
ld bc,0x0007
ldir
ld a,(trdos_variable.cat_drive_or_read_verify_flag)
call init_disk_drive_in_A_register
call sub_1cb3h
jr nz,l0634h
call sub_05b4h
jr nz,l0634h
call sub_0581h
jr nz,l05f4h