-
Notifications
You must be signed in to change notification settings - Fork 1
/
hardbox.asm
6779 lines (5895 loc) · 194 KB
/
hardbox.asm
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
;HardBox Firmware
;Version 2.3 and 2.4 (Corvus)
;Version 2.4 (Mini-Winchester 2.91)
;Version 3.1 (Sunol)
;version: equ 23 ;for version 2.3 (Corvus)
;version: equ 24 ;for version 2.4 (Corvus)
;version: equ 291 ;for version 2.4 (Mini-Winchester 2.91)
;version: equ 31 ;for version 3.1 (Sunol)
IF version = 291
;This is a disassembly of the HardBox code payload inside mwdos291.com.
;MW-1000 Memory Map:
; F000-FFFF ROM 4096
; 0000-EFFF RAM (IC24-IC31) 61440 (Must be 4164)
ELSE
;This is a disassembly of two original 2732 EPROMs from a HardBox,
;labeled "295" (IC3) and "296" (IC4) for version 2.3 and 3.1 and
;labeled "289" (IC3) and "290" (IC4) for version 2.4.
;HardBox Memory Map:
; F000-FFFF ROM High (IC4) 4096
; E000-EFFF ROM Low (IC3) 4096
; C000-DFFF Mirror of 0000-1FFF 8192
; 8000-BFFF Mirror of 0000-3FFF 16384
; 4000-7FFF Mirror of 0000-3FFF 16384
; 0000-3FFF RAM (IC24-IC31) 16384 (Uses 4516 DRAMs instead of 4164)
ENDIF
ppi1: equ 10h ;8255 PPI #1 (IC17)
ppi1_pa: equ ppi1+0 ; Port A: IEEE-488 Data In
ppi1_pb: equ ppi1+1 ; Port B: IEEE-488 Data Out
ppi1_pc: equ ppi1+2 ; Port C: DIP Switches
ppi1_cr: equ ppi1+3 ; Control Register
ppi2: equ 14h ;8255 PPI #2 (IC16)
ppi2_pa: equ ppi2+0 ; Port A:
; PA7 IEEE-488 IFC in (unused)
; PA6 IEEE-488 REN in (unused)
; PA5 IEEE-488 SRQ in (unused)
; PA4 IEEE-488 EOI in
; PA3 IEEE-488 NRFD in
; PA2 IEEE-488 NDAC in
; PA1 IEEE-488 DAV in
; PA0 IEEE-488 ATN in
ppi2_pb: equ ppi2+1 ; Port B:
; PB7 IEEE-488 ATNA out (because LK3 is open)
; PB6 IEEE-488 REN out (unused)
; PB5 IEEE-488 SRQ out (unused)
; PB4 IEEE-488 EOI out
; PB3 IEEE-488 NRFD out
; PB2 IEEE-488 NDAC out
; PB1 IEEE-488 DAV out
; PB0 IEEE-488 ATN out (unused)
ppi2_pc: equ ppi2+2 ; Port C:
; PC7 Unused
; PC6 Unused
; PC5 Corvus DIRC
; PC4 Corvus READY
; PC3 Unused
; PC2 LED "Ready"
; PC1 LED "B"
; PC0 LED "A"
ppi2_cr: equ ppi2+3 ; Control Register
atna: equ 10000000b ;ATNA (With installed IC37 this isn't IFC, leave LK3 open!)
ren: equ 01000000b ;REN (unused)
srq: equ 00100000b ;SRQ (unused)
eoi: equ 00010000b ;EOI
nrfd: equ 00001000b ;NRFD
ndac: equ 00000100b ;NDAC
dav: equ 00000010b ;DAV
atn: equ 00000001b ;ATN
IF version != 291
dirc: equ 00100000b ;Corvus DIRC
ready: equ 00010000b ;Corvus READY
ledrdy: equ 00000100b ;LED "Ready"
ledb: equ 00000010b ;LED "B"
leda: equ 00000001b ;LED "A"
ENDIF
corvus: equ 18h ;Corvus data bus
cr: equ 0dh ;Carriage Return
rvs: equ 12h ;Reverse on
error_00: equ 00h ;"OK"
error_01: equ 01h ;"FILES SCRATED"
error_22: equ 16h ;"READ ERROR"
error_25: equ 19h ;"WRITE ERROR"
error_26: equ 1ah ;"WRITE PROTECTED"
error_30: equ 1eh ;"SYNTAX ERROR"
error_31: equ 1fh ;"SYNTAX ERROR (INVALID COMMAND)"
error_32: equ 20h ;"SYNTAX ERROR (LONG LINE)"
error_33: equ 21h ;"SYNTAX ERROR(INVALID FILENAME)"
error_34: equ 22h ;"SYNTAX ERROR(NO FILENAME)"
error_49: equ 31h
error_50: equ 32h ;"RECORD NOT PRESENT"
error_51: equ 33h ;"OVERFLOW IN RECORD"
error_52: equ 34h ;"FILE TOO LARGE"
error_60: equ 3ch ;"WRITE FILE OPEN"
error_61: equ 3dh ;"FILE NOT OPEN"
error_62: equ 3eh ;"FILE NOT FOUND"
error_63: equ 3fh ;"FILE EXISTS"
error_64: equ 40h ;"FILE TYPE MISMATCH"
error_65: equ 41h ;"NO BLOCK"
error_66: equ 42h ;"ILLEGAL TRACK OR SECTOR"
error_72: equ 48h ;"DISK FULL"
error_84: equ 54h ;" DRIVE NOT CONFIGURED"
error_89: equ 59h ;"USER #"
error_90: equ 5ah ;"INVALID USER NAME"
error_91: equ 5bh ;"PASSWORD INCORRECT"
error_92: equ 5ch ;"PRIVILEGED COMMAND"
IF version != 291
error_93: equ 5dh ;"BAD SECTORS CORRECTED" (only used in version 2.3 and 2.4)
error_94: equ 5eh ;"LOCK ALREADY IN USE"
IF version = 31 ;This is for a SUNOL Hard Drive
error_95: equ 5fh ; "SUNOL DRIVE ERROR"
error_96: equ 60h ; "SUNOL DRIVE SIZE"
error_98: equ 62h ; "VERSION #"
ELSE ;This is for a CORVUS Hard Drive
error_95: equ 5fh ; "CORVUSDRIVE ERROR"
error_96: equ 60h ; "CORVUSDRIVE SIZE"
error_97: equ 61h ; "CORVUS REV A VERSION #"
error_98: equ 62h ; "CORVUS REV B VERSION #"
ENDIF
ENDIF
error_99: equ 63h ;"SMALL SYSTEMS HARDBOX VERSION #"
t_file: equ 01h ;"FILE"
t_write: equ 02h ;"WRITE"
t_error: equ 03h ;" ERROR"
t_syntax: equ 04h ;"SYNTAX"
t_invalid:equ 05h ;"INVALID"
t_command:equ 06h ;"COMMAND"
t_read: equ 07h ;"READ"
t_name: equ 08h ;"WRITE"
t_record: equ 09h ;"RECORD"
t_open: equ 0ah ;" OPEN"
t_not: equ 0bh ;" NOT"
t_user: equ 0ch ;"USER"
t_version:equ 0dh ;" VERSION #"
IF version = 31 ;This is for a SUNOL Hard Drive
t_drive: equ 0eh ; " DRIVE"
t_sunol: equ 0fh ; "SUNOL"
ELSE ;This is for a CORVUS Hard Drive
t_drive: equ 0eh ; "DRIVE"
t_corvus: equ 0fh ; "CORVUS"
ENDIF
IF version = 291
devnum: equ 2000h ;Read from header or set via command "!D" (8 .. 15)
userid: equ 2002h ;Is constantly 0 (0 .. 63)
ELSE
;DIP Switch
;==========
;Switch SW1 SW2 SW3 SW4 SW5 SW6 SW7 SW8
; <------userid-----> <-devnum-->
;Pin 14 15 16 17 13 12 11 10
;Port PC0 PC4 PC5 PC6 PC7 PC3 PC2 PC1
devnum: equ 0000h ;Read via DIP switch or set via command "!D" (8 .. 15)
userid: equ 0002h ;Read via DIP switch (0 .. 31) or set via command "L" (0 .. 63)
ENDIF
;Disk layout on Drive Number 1
;=============================
;Absolute Sector 0 Bytes 0 .. 15: User name (16 Characters) for User Number = 0
;Absolute Sector 0 Bytes 16 .. 31: User name (16 Characters) for User Number = 1
;Absolute Sector 0 Bytes 32 .. 47: User name (16 Characters) for User Number = 2
;Absolute Sector 0 Bytes 48 .. 63: User name (16 Characters) for User Number = 3
;Absolute Sector 0 Bytes 64 .. 79: User name (16 Characters) for User Number = 4
;Absolute Sector 0 Bytes 80 .. 95: User name (16 Characters) for User Number = 5
;Absolute Sector 0 Bytes 96 .. 111: User name (16 Characters) for User Number = 6
;Absolute Sector 0 Bytes 112 .. 127: User name (16 Characters) for User Number = 7
;Absolute Sector 0 Bytes 128 .. 143: User name (16 Characters) for User Number = 8
;Absolute Sector 0 Bytes 144 .. 159: User name (16 Characters) for User Number = 9
;Absolute Sector 0 Bytes 160 .. 175: User name (16 Characters) for User Number = 10
;Absolute Sector 0 Bytes 176 .. 191: User name (16 Characters) for User Number = 11
;Absolute Sector 0 Bytes 192 .. 207: User name (16 Characters) for User Number = 12
;Absolute Sector 0 Bytes 208 .. 223: User name (16 Characters) for User Number = 13
;Absolute Sector 0 Bytes 224 .. 239: User name (16 Characters) for User Number = 14
;Absolute Sector 0 Bytes 240 .. 255: User name (16 Characters) for User Number = 15
;Absolute Sector 1: Same as Sector 0 for User Number 16 .. 31
;Absolute Sector 2: Same as Sector 0 for User Number 32 .. 47
;Absolute Sector 3: Same as Sector 0 for User Number 48 .. 63
;Absolute Sector 4 Bytes 0 .. 31: User parameter (32 Bytes, see below) for User Number = 0
;Absolute Sector 4 Bytes 32 .. 63: User parameter (32 Bytes, see below) for User Number = 1
;Absolute Sector 4 Bytes 64 .. 95: User parameter (32 Bytes, see below) for User Number = 2
;Absolute Sector 4 Bytes 96 .. 127: User parameter (32 Bytes, see below) for User Number = 3
;Absolute Sector 4 Bytes 128 .. 159: User parameter (32 Bytes, see below) for User Number = 4
;Absolute Sector 4 Bytes 160 .. 191: User parameter (32 Bytes, see below) for User Number = 5
;Absolute Sector 4 Bytes 192 .. 223: User parameter (32 Bytes, see below) for User Number = 6
;Absolute Sector 4 Bytes 224 .. 255: User parameter (32 Bytes, see below) for User Number = 7
;Absolute Sector 5: Same as Sector 4 for User Number 8 .. 15
;Absolute Sector 6: Same as Sector 4 for User Number 16 .. 23
;Absolute Sector 7: Same as Sector 4 for User Number 24 .. 31
;Absolute Sector 8: Same as Sector 4 for User Number 32 .. 39
;Absolute Sector 9: Same as Sector 4 for User Number 40 .. 47
;Absolute Sector 10: Same as Sector 4 for User Number 48 .. 55
;Absolute Sector 11: Same as Sector 4 for User Number 56 .. 63
;Absolute Sector 12 Bytes 0 .. 15: User password (16 Characters) for User Number = 0
;Absolute Sector 12 Bytes 16 .. 31: User password (16 Characters) for User Number = 1
;Absolute Sector 12 Bytes 32 .. 47: User password (16 Characters) for User Number = 2
;Absolute Sector 12 Bytes 48 .. 63: User password (16 Characters) for User Number = 3
;Absolute Sector 12 Bytes 64 .. 79: User password (16 Characters) for User Number = 4
;Absolute Sector 12 Bytes 80 .. 95: User password (16 Characters) for User Number = 5
;Absolute Sector 12 Bytes 96 .. 111: User password (16 Characters) for User Number = 6
;Absolute Sector 12 Bytes 112 .. 127: User password (16 Characters) for User Number = 7
;Absolute Sector 12 Bytes 128 .. 143: User password (16 Characters) for User Number = 8
;Absolute Sector 12 Bytes 144 .. 159: User password (16 Characters) for User Number = 9
;Absolute Sector 12 Bytes 160 .. 175: User password (16 Characters) for User Number = 10
;Absolute Sector 12 Bytes 176 .. 191: User password (16 Characters) for User Number = 11
;Absolute Sector 12 Bytes 192 .. 207: User password (16 Characters) for User Number = 12
;Absolute Sector 12 Bytes 208 .. 223: User password (16 Characters) for User Number = 13
;Absolute Sector 12 Bytes 224 .. 239: User password (16 Characters) for User Number = 14
;Absolute Sector 12 Bytes 240 .. 255: User password (16 Characters) for User Number = 15
;Absolute Sector 13: Same as Sector 12 for User Number 16 .. 31
;Absolute Sector 14: Same as Sector 12 for User Number 32 .. 47
;Absolute Sector 15: Same as Sector 12 for User Number 48 .. 63
;Absolute Sector 16 Byte 0: <Unknown or Undefined> (1 ???)
;Absolute Sector 16 Byte 1: <Unknown or Undefined> (20 ??? for 20mb???)
;Absolute Sector 16 Bytes 2 .. 7: <Unknown or Undefined>
;Absolute Sector 16 Bytes 8 .. 9: "HB" as Magic Characters for "HardBox"
;Absolute Sector 16 Bytes 10 .. 255: <Unknown or Undefined>
IF version = 291
;Absolute Sector 32 to 63: Firmware for Hardbox (see payload from mwdos291.com)
ENDIF
;User Parameter
;==============
;Byte 0: Physical Drive Number (1 .. 4 = Drive Number, 0 = Unused Entry)
;Bytes 1 .. 3: Starting Sector Number on Disk
;Bytes 4 .. 5: User Area Size in Kilobytes (1 Kilobyte are 4 Sectors or Blocks)
;Byte 6: Type of User Area (Single User or 0aah for Multi User)
;Bytes 7 .. 8: Maximum Numbers of Files allowed (Reserved for Directory Entries)
;Bytes 9 .. 10: Size (in Kilobytes) allocated for Direct Access (1 Kilobyte are 4 Sectors or Blocks)
;Bytes 11 .. 12: Number of "Tracks per Drive" for Direct Access
;Bytes 13 .. 15: Number of "Sectors per Track" for Direct Access
;Bytes 16 .. 31: User Area Name (16 Characters)
IF version = 291
usrdat: equ 2004h ;usrdat (32 Bytes) are copied from header (offset 0103h to 0122h)
ELSE
usrdat: equ 0004h ;usrdat (32 Bytes) are copied from sectors 4, 5, 6, 7, 8, 9, 10 or 12) depends on userid
ENDIF
phydrv: equ usrdat+ 0 ;Physical drive number (1 .. 4, 1 Byte)
usrsrt: equ usrdat+ 1 ;Starting sector number on drive (An Absolute Sector Number, 3 Bytes)
usrsiz: equ usrdat+ 4 ;User area size in kilobytes, there are 4 blocks (2 Bytes, Maximum is 64 Megabytes)
l000ah: equ usrdat+ 6 ;Type of user area (Single user or Multi-user) (1 Byte) (Disallow write)
maxdir: equ usrdat+ 7 ;Maximum numbers of files allowed (2 Bytes, Maximum is 65535)
usrdir: equ usrdat+ 9 ;Size (in kilobyte) allocated for direct access, these are 4 blocks (2 Bytes, Maximum is 64 Megabytes)
maxtrk: equ usrdat+11 ;# of "tracks per drive" for direct access (2 Bytes)
maxsec: equ usrdat+13 ;# of "sectors per track" for direct access (3 Bytes)
arenam: equ usrdat+16 ;User area name (16 Bytes) ???
;Every sector contain 256 bytes and is accessed via the commands
; - 02h = Read a sector (256 byte sector) and
; - 03h = Write a sector (256 byte sector).
;These commands expected a absolute sector number (logical disk address - DADR) for the access.
;This is a 3 byte address, but from the first byte only the upper nibble is for the address used.
;The lower nibble represents the drive number. So the maximum address is 1048575. With a 256 byte
;sector are 268435456 bytes (262144 kilobytes or 256 megabytes) addressable. The existing drives
;have storages less than this value. The hardbox supports 6, 10 and 20 megabytes drives.
;These storage space is partitioned into separated user areas. Each user ares is divided into
;functional parts:
; 1. Header sector
; This is one sector with 10 disk names and 10 disk ids. These names and ids can be defined by
; the dos commend new "N". A maximum of 10 virtual drive numbers are usable. After the header
; sector additional 3 sectors are reserved.
; 2. Directory
; When a user area is defined, the number of allowed files must be specified. This number is
; used to calculate the size of the directory. For every file is a directory entry reseerved.
; A directory entry on disk need 32 bytes. So in one sector fits 8 directory entries.
; 3. Allocation 1
; All data file sectors are linked with a side sector. The side sector are linked with a super
; side sector. For every directory entriy is space in the super side sectors reserved. Two
; directory entries use one super side sector, because for one directory entry only a maximum
; of 64 links (words with 2 bytes) to a side sector are needed. So every super side sector
; entry is 128 bytes.
; 4. Allocation 2
; Every link in the super side sector points to a side sector. This is a real sector with 128
; links to data file sectors. Each link is a word (2 bytes), too. If a file is larger than 128
; clusters (262144 bytes) an additional side sector is needed. So the maximum size of 16777216
; bytes (16384 kilobytes or 16 megabytes) is possible.
; The DOS reserved for every file one side sector that is needed and an additional side sector
; for every 256 kilobyte user area size. So for 12.5% of all files exists enougth side sectors
; to create large files.
; 5. Storage for files
; Every file is stored in a cluster that contains 8 real sectors with 256 bytes. (Remember the
; CBM DOS use only 254 bytes, because the first two bytes of a sector points to the next
; sector. So these two bytes are unusable for data.) Every data cluster has a cluster number
; as a word (2 bytes). This number is stored as link into the side sector. If the highest is
; set in the link, it's unused. So the maximum of 32768 sectors are addressable. In the memory
; BAM can only 1024 bytes with 8192 bits for 8192 clusters stored. So there are only 8192 used
; and the maximum capacity for all files are 16777216 bytes (16384 kilobytes or 16 megabytes).
; But this format is expandable up to 67108864 bytes (65536 kilobytes or 64 megabytes).
; When the user area is created, only the number of allowed files, the complete user ares size
; and the size allocated for direct access is defined. So the size available for files is
; calculated.
; 6. Direct access sectors
; Additional to the storage for the files is a separated storage area for direct access
; possible. This area is also defined, when the user area is configured. The configured size
; is in kilobytes or in 4 sectors.
; 7. BAM for direct access sectors
; For every direct access aector is a available bit needed. So we need a block available map.
; So for 2 kilobytes (8 sectors) we need a byte. Or with one BAM sector we can manage 2048
; direct access sectors (524288 bytes or 512 kilobytes).
;Header Sector (The first Sector in a User Area)
;===============================================
;Bytes 0 .. 15: Drive Name for Drive Number 0 ("0:..")
;Bytes 16 .. 31: Drive Name for Drive Number 1 ("1:..")
;Bytes 32 .. 47: Drive Name for Drive Number 2 ("2:..")
;Bytes 48 .. 63: Drive Name for Drive Number 3 ("3:..")
;Bytes 64 .. 79: Drive Name for Drive Number 4 ("4:..")
;Bytes 80 .. 95: Drive Name for Drive Number 5 ("5:..")
;Bytes 96 .. 111: Drive Name for Drive Number 6 ("6:..")
;Bytes 112 .. 127: Drive Name for Drive Number 7 ("7:..")
;Bytes 128 .. 143: Drive Name for Drive Number 8 ("8:..")
;Bytes 144 .. 159: Drive Name for Drive Number 9 ("9:..")
;Bytes 160 .. 161: Drive ID for Drive Number 0 ("0:..")
;Bytes 162 .. 163: Drive ID for Drive Number 1 ("1:..")
;Bytes 164 .. 165: Drive ID for Drive Number 2 ("2:..")
;Bytes 166 .. 167: Drive ID for Drive Number 3 ("3:..")
;Bytes 168 .. 169: Drive ID for Drive Number 4 ("4:..")
;Bytes 170 .. 171: Drive ID for Drive Number 5 ("5:..")
;Bytes 172 .. 173: Drive ID for Drive Number 6 ("6:..")
;Bytes 174 .. 175: Drive ID for Drive Number 7 ("7:..")
;Bytes 176 .. 177: Drive ID for Drive Number 8 ("8:..")
;Bytes 178 .. 179: Drive ID for Drive Number 9 ("9:..")
;Bytes 180 .. 255: <Unknown or Undefined>
;Directory Entry (32 Bytes for one File on Disk, additionaly 9 Bytes in Memory)
;==============================================================================
f_attr: equ 00h ;Byte 0: File Attributes
; ---------------
; ------XX (Bits 0 .. 1): File Type
; ---------
; 00: SEQ (Sequential file)
; 01: USR (User file)
; 10: PRG (Program file)
; 11: REL (Relative file)
; ----XX-- (Bits 2 .. 3): <Unknown or Undefined>
; ---X---- (Bit 4): 1 = Global
; --X----- (Bit 5): 1 = Hidden
; -X------ (Bit 6): 1 = Write Protected
; X------- (Bit 7): 1 = Open File
f_drvn: equ 01h ;Byte 1: Drive Number
; 0 .. 9 = Drive Number
; 0e5h = End of Directory (Initialized Value)
; 0ffh = Unused Entry (Deleted Value)
f_name: equ 02h ;Bytes 2 .. 17: File Name (16 Characters)
f_size: equ 12h ;Bytes 18 .. 20: Size in Bytes (3 Bytes), 19 .. 20: Size in Blocks
f_rlen: equ 15h ;Byte 21: Record Length (1 Byte)
;Bytes 22 .. 31: <Unknown or Undefined>
;----- Now only temporary used data bytes, holded in memory only -----
f_cptr: equ 20h ;Bytes 32 .. 34: Current file pointer to read or write (3 Bytes)
f_dirn: equ 23h ;Bytes 35 .. 36: Number of Directory Entry - see dirnum also (2 Bytes)
;Byte 37: ???
f_al1x: equ 26h ;Byte 38: Current Allocation 1 index number
;Byte 39: ???
;Byte 40: ???
typ_seq: equ 0 ;File Type for SEQ (Sequential file)
typ_usr: equ 1 ;File Type for USR (User file)
typ_prg: equ 2 ;File Type for PRG (Program file)
typ_rel: equ 3 ;File Type for REL (Relative file)
;Every File has one Allocation Entry 1. This can have up to 64 Allocation Entries 2, because it
;have a size from 128 bytes. The size from an Allocation Entry 2 is 256 bytes. So this can have
;up to 128 sectors allocated for a file. The biggest size for a file is 8192 sectors or 2097152
;bytes. The data sectors are numbered by a word (16 Bit). It can't be more than 65536 sector
;exists. So the maximum of an user area to use for files is 16777216 bytes or 16384 kilobytes.
;Allocation Entry 1 (128 Bytes for one File)
;===========================================
;Bytes 0 .. 1: (0 .. 32767 = Points to Allocation Entry 2, 32768 .. 65535 = Unused Entry)
;Bytes 2 .. 127: Same as Bytes 0 .. 1
;Allocation Entry 2 (256 Bytes for one Allocation Entry 1)
;=========================================================
;Bytes 0 .. 1: (0 .. 32767 = Points to Data Sector, 32768 .. 65535 = Unused Entry)
;Bytes 2 .. 255: Same as Bytes 0 .. 1
IF version = 291
dirsrt: equ 2024h ;Absolute sector where directory starts (3 bytes, 4 sector after the user area starts)
al1srt: equ 2027h ;Absolute sector where allocation 1 (128 bytes) starts (3 bytes)
al1max: equ 202ah ;Maximum number of Files for Allocation 1 Sectors (2 bytes)
al2srt: equ 202ch ;Absolute sector where allocation 2 (256 bytes) starts (3 bytes)
al2max: equ 202fh ;(2 bytes)
filsrt: equ 2031h ;Absolute sector where the files starts (3 bytes)
l0034h: equ 2034h ;Size (in kilobytes) usable for normal files, these are 4 blocks (2 bytes)
l0036h: equ 2036h ;Starting sector number for direct access (3 bytes)
l0039h: equ 2039h ;(2 bytes)
bamsrt: equ 203bh ;Starting sector number where BAM for direct access starts (3 bytes)
usrnam: equ 203eh ;User name is copied from sector 0, 1, 2 or 3 depends on userid (16 bytes)
bamsec: equ 204eh ;BAM sector number currently in bambuf (1 byte)
defdnu: equ 204fh ;Default Drive number (0 .. 9) set via command "D"
errcod: equ 2050h ;Error code in error message
errtrk: equ 2051h ;Track number in error message (3 bytes)
errsec: equ 2054h ;Sector number in error message (3 bytes)
l0057h: equ 2057h ;BAM table for allocation 2 sectors (1 bit for 1 sector, 1024 bytes are 8192 bits or 8192 sectors)
l0457h: equ 2457h ;BAM table for data files (1 bit for 1 kilobyte, 1024 byte are 8192 bits or 8192 kilobyte) ???
entbufs: equ 2857h ;(16 Directory entry buffer with 41 bytes)
entbuf0: equ entbufs+ 0*41;(Directory entry buffer for channel number 0 with 41 bytes)
entbuf1: equ entbufs+ 1*41;(Directory entry buffer for channel number 1 with 41 bytes)
entbuf2: equ entbufs+ 2*41;(Directory entry buffer for channel number 2 with 41 bytes)
entbuf3: equ entbufs+ 3*41;(Directory entry buffer for channel number 3 with 41 bytes)
entbuf4: equ entbufs+ 4*41;(Directory entry buffer for channel number 4 with 41 bytes)
entbuf5: equ entbufs+ 5*41;(Directory entry buffer for channel number 5 with 41 bytes)
entbuf6: equ entbufs+ 6*41;(Directory entry buffer for channel number 6 with 41 bytes)
entbuf7: equ entbufs+ 7*41;(Directory entry buffer for channel number 7 with 41 bytes)
entbuf8: equ entbufs+ 8*41;(Directory entry buffer for channel number 8 with 41 bytes)
entbuf9: equ entbufs+ 9*41;(Directory entry buffer for channel number 9 with 41 bytes)
entbuf10: equ entbufs+10*41;(Directory entry buffer for channel number 10 with 41 bytes)
entbuf11: equ entbufs+11*41;(Directory entry buffer for channel number 11 with 41 bytes)
entbuf12: equ entbufs+12*41;(Directory entry buffer for channel number 12 with 41 bytes)
entbuf13: equ entbufs+13*41;(Directory entry buffer for channel number 13 with 41 bytes)
entbuf14: equ entbufs+14*41;(Directory entry buffer for channel number 14 with 41 bytes)
entbuf15: equ entbufs+15*41;(Directory entry buffer for channel number 15 with 41 bytes)
sa: equ 2ae7h ;Current channel number, comes with the secondary address (sa)
entptr: equ 2ae8h ;Pointer to a buffer (entbufs) of directory entry with 41 bytes (2 bytes)
al2ptr: equ 2aeah ;Pointer to a buffer (al2bufs) of a Allocation 2 sector with 256 bytes (2 bytes)
bufptr: equ 2aech ;Pointer to a buffer (buffers) of a sector buffer with 256 bytes (2 bytes)
al1ptr: equ 2aeeh ;Pointer to a buffer (al1bufs) of a Allocation 1 sector with 128 bytes (2 bytes)
lsntlk: equ 2af0h ;State of ieee bus (1 byte: bit 1 = TALK active, bit 2 = LISTEN active)
staptr: equ 2af1h ;Pointer to current position of stabuf when writing to control channel (2 bytes)
cmdptr: equ 2af3h ;Pointer to current position of cmdbuf when reading from control channel(2 bytes)
dirbuf: equ 2af5h ;Directory block buffer (256 bytes)
cmdbuf: equ 2bf5h ;Command buffer for writing to control channel 15 (128 bytes)
getbuf: equ 2c75h ;Buffer to read after SA or OPEN bytes, this stores commands (SA and OPEN) or filenames (OPEN) (128 bytes)
stabuf: equ 2cf5h ;Status buffer for reading from control channel 15 (80 Bytes)
filnam: equ 2d45h ;(17 bytes: 16 for the characters and one for end marker or delimiter)
dstnam: equ 2d56h ;(17 bytes: 16 for the characters and one for end marker or delimiter)
drvnum: equ 2d67h ;Drive number (1 byte: 0 .. 9)
dirnum: equ 2d68h ;The number of directory entry to process (2 bytes)
al2idx: equ 2d6ah ;Allocation 2 sector index (1 byte: 0 .. 127)
secidx: equ 2d6bh ;Data sector index (1 byte: 0 .. 255)
l0d6ch: equ 2d6ch ;??? (1 byte)
al1idx: equ 2d6dh ;Allocation 1 sector index (1 byte: 0 .. 63)
dirhid: equ 2d6eh ;Flag for show hidden files on directory ("H": Yes, else: no)
al2bufs: equ 2d6fh ;(16 Allocation 2 sector buffers with 256 bytes)
al2buf0: equ al2bufs+ 0*256;(Allocation 2 sector buffer for channel number 0 with 256 bytes)
al2buf1: equ al2bufs+ 1*256;(Allocation 2 sector buffer for channel number 1 with 256 bytes)
al2buf2: equ al2bufs+ 2*256;(Allocation 2 sector buffer for channel number 2 with 256 bytes)
al2buf3: equ al2bufs+ 3*256;(Allocation 2 sector buffer for channel number 3 with 256 bytes)
al2buf4: equ al2bufs+ 4*256;(Allocation 2 sector buffer for channel number 4 with 256 bytes)
al2buf5: equ al2bufs+ 5*256;(Allocation 2 sector buffer for channel number 5 with 256 bytes)
al2buf6: equ al2bufs+ 6*256;(Allocation 2 sector buffer for channel number 6 with 256 bytes)
al2buf7: equ al2bufs+ 7*256;(Allocation 2 sector buffer for channel number 7 with 256 bytes)
al2buf8: equ al2bufs+ 8*256;(Allocation 2 sector buffer for channel number 8 with 256 bytes)
al2buf9: equ al2bufs+ 9*256;(Allocation 2 sector buffer for channel number 9 with 256 bytes)
al2buf10: equ al2bufs+10*256;(Allocation 2 sector buffer for channel number 10 with 256 bytes)
al2buf11: equ al2bufs+11*256;(Allocation 2 sector buffer for channel number 11 with 256 bytes)
al2buf12: equ al2bufs+12*256;(Allocation 2 sector buffer for channel number 12 with 256 bytes)
al2buf13: equ al2bufs+13*256;(Allocation 2 sector buffer for channel number 13 with 256 bytes)
al2buf14: equ al2bufs+14*256;(Allocation 2 sector buffer for channel number 14 with 256 bytes)
al2buf15: equ al2bufs+15*256;(Allocation 2 sector buffer for channel number 15 with 256 bytes)
al1bufs: equ 3d6fh ;(16 Allocation 1 sector buffers with 128 bytes)
al1buf0: equ al1bufs+ 0*128;(Allocation 1 sector buffer for channel number 0 with 128 bytes)
al1buf1: equ al1bufs+ 1*128;(Allocation 1 sector buffer for channel number 1 with 128 bytes)
al1buf2: equ al1bufs+ 2*128;(Allocation 1 sector buffer for channel number 2 with 128 bytes)
al1buf3: equ al1bufs+ 3*128;(Allocation 1 sector buffer for channel number 3 with 128 bytes)
al1buf4: equ al1bufs+ 4*128;(Allocation 1 sector buffer for channel number 4 with 128 bytes)
al1buf5: equ al1bufs+ 5*128;(Allocation 1 sector buffer for channel number 5 with 128 bytes)
al1buf6: equ al1bufs+ 6*128;(Allocation 1 sector buffer for channel number 6 with 128 bytes)
al1buf7: equ al1bufs+ 7*128;(Allocation 1 sector buffer for channel number 7 with 128 bytes)
al1buf8: equ al1bufs+ 8*128;(Allocation 1 sector buffer for channel number 8 with 128 bytes)
al1buf9: equ al1bufs+ 9*128;(Allocation 1 sector buffer for channel number 9 with 128 bytes)
al1buf10: equ al1bufs+10*128;(Allocation 1 sector buffer for channel number 10 with 128 bytes)
al1buf11: equ al1bufs+11*128;(Allocation 1 sector buffer for channel number 11 with 128 bytes)
al1buf12: equ al1bufs+12*128;(Allocation 1 sector buffer for channel number 12 with 128 bytes)
al1buf13: equ al1bufs+13*128;(Allocation 1 sector buffer for channel number 13 with 128 bytes)
al1buf14: equ al1bufs+14*128;(Allocation 1 sector buffer for channel number 14 with 128 bytes)
al1buf15: equ al1bufs+15*128;(Allocation 1 sector buffer for channel number 15 with 128 bytes)
eoisav: equ 456fh
dirout: equ 4570h ;Here where a directory output line stored before output (??? bytes)
wrtprt: equ 45f0h ;Points to current position to writee to ieee (2 bytes)
endbuf: equ 45f2h ;Points to end of buffer to write to ieee (2 bytes)
l25f4h: equ 45f4h ;(2 bytes)
dirdrv: equ 45f6h ;Save the Drive Number (drvnum) when Directory (open_dir) is processed (1 byte)
dirnam: equ 45f7h ;open_dir parameter (17 bytes: 16 for the characters and one for end marker or delimiter)
pattfn: equ 4608h ;Points to pattern for filename, used in find_first and find_next (2 bytes)
tmpdrv: equ 460ah ;Temporary drive number, used in corv_read_sec und corv_writ_sec (2 bytes)
drvcnf: equ 460ch ;Flag if drive is configured (0: Not Configured, 1: Configured)
l260dh: equ 460dh ;Temporary in cmd_cpy (2 bytes)
l260fh: equ 460fh ;Temporary in put_number (1 byte)
hdrbuf: equ 4610h ;Buffer of header sector (first sector of user area with 256 bytes)
drvnam: equ hdrbuf+ 0;Position 0 starts the drive names of the ten drives
drvid: equ hdrbuf+160;Position 160 starts the drive ids of the ten drives
rdbuf: equ 4710h ;(256 bytes)
cpybuf: equ 4810h ;Temporary buffer, only used for concat command (256 bytes)
bambuf: equ 4910h ;Buffer of BAM sector bamsec used in bam_read_sec and bam_writ_sec or for B-A and B-F (256 bytes)
l4a10h: equ 4a10h ;??? (3 Bytes)
stack: equ 4a93h
buffers: equ 5000h ;(16 sector buffers with 256 bytes)
buffer0: equ buffers+ 0*256;(sector buffer for channel number 0 with 256 bytes)
buffer1: equ buffers+ 1*256;(sector buffer for channel number 1 with 256 bytes)
buffer2: equ buffers+ 2*256;(sector buffer for channel number 2 with 256 bytes)
buffer3: equ buffers+ 3*256;(sector buffer for channel number 3 with 256 bytes)
buffer4: equ buffers+ 4*256;(sector buffer for channel number 4 with 256 bytes)
buffer5: equ buffers+ 5*256;(sector buffer for channel number 5 with 256 bytes)
buffer6: equ buffers+ 6*256;(sector buffer for channel number 6 with 256 bytes)
buffer7: equ buffers+ 7*256;(sector buffer for channel number 7 with 256 bytes)
buffer8: equ buffers+ 8*256;(sector buffer for channel number 8 with 256 bytes)
buffer9: equ buffers+ 9*256;(sector buffer for channel number 9 with 256 bytes)
buffer10: equ buffers+10*256;(sector buffer for channel number 10 with 256 bytes)
buffer11: equ buffers+11*256;(sector buffer for channel number 11 with 256 bytes)
buffer12: equ buffers+12*256;(sector buffer for channel number 12 with 256 bytes)
buffer13: equ buffers+13*256;(sector buffer for channel number 13 with 256 bytes)
buffer14: equ buffers+14*256;(sector buffer for channel number 14 with 256 bytes)
buffer15: equ buffers+15*256;(sector buffer for channel number 15 with 256 bytes)
ELSE
dirsrt: equ 0024h ;Absolute sector where directory starts (3 bytes, 4 sector after the user area starts)
al1srt: equ 0027h ;Absolute sector where allocation 1 (128 bytes) starts (3 bytes)
al1max: equ 002ah ;Maximum number of Files for Allocation 1 Sectors (2 bytes)
al2srt: equ 002ch ;Absolute sector where allocation 2 (256 bytes) starts (3 bytes)
al2max: equ 002fh ;(2 bytes)
filsrt: equ 0031h ;Absolute sector where the files starts (3 bytes)
l0034h: equ 0034h ;Size (in kilobytes) usable for normal files, these are 4 blocks (2 bytes)
l0036h: equ 0036h ;Starting sector number for direct access (3 bytes)
l0039h: equ 0039h ;(2 bytes)
bamsrt: equ 003bh ;Starting sector number where BAM for direct access starts (3 bytes)
usrnam: equ 003eh ;User name is copied from sector 0, 1, 2 or 3 depends on userid (16 bytes)
bamsec: equ 004eh ;BAM sector number currently in bambuf (1 byte)
defdnu: equ 004fh ;Default Drive number (0 .. 9) set via command "D"
errcod: equ 0050h ;Error code in error message
errtrk: equ 0051h ;Track number in error message (3 bytes)
errsec: equ 0054h ;Sector number in error message (3 bytes)
l0057h: equ 0057h ;BAM table for allocation 2 sectors (1 bit for 1 sector, 1024 bytes are 8192 bits or 8192 sectors)
l0457h: equ 0457h ;BAM table for data files (1 bit for 1 kilobyte, 1024 byte are 8192 bits or 8192 kilobyte) ???
entbufs: equ 0857h ;(16 Directory entry buffer with 41 bytes)
entbuf0: equ entbufs+ 0*41;(Directory entry buffer for channel number 0 with 41 bytes)
entbuf1: equ entbufs+ 1*41;(Directory entry buffer for channel number 1 with 41 bytes)
entbuf2: equ entbufs+ 2*41;(Directory entry buffer for channel number 2 with 41 bytes)
entbuf3: equ entbufs+ 3*41;(Directory entry buffer for channel number 3 with 41 bytes)
entbuf4: equ entbufs+ 4*41;(Directory entry buffer for channel number 4 with 41 bytes)
entbuf5: equ entbufs+ 5*41;(Directory entry buffer for channel number 5 with 41 bytes)
entbuf6: equ entbufs+ 6*41;(Directory entry buffer for channel number 6 with 41 bytes)
entbuf7: equ entbufs+ 7*41;(Directory entry buffer for channel number 7 with 41 bytes)
entbuf8: equ entbufs+ 8*41;(Directory entry buffer for channel number 8 with 41 bytes)
entbuf9: equ entbufs+ 9*41;(Directory entry buffer for channel number 9 with 41 bytes)
entbuf10: equ entbufs+10*41;(Directory entry buffer for channel number 10 with 41 bytes)
entbuf11: equ entbufs+11*41;(Directory entry buffer for channel number 11 with 41 bytes)
entbuf12: equ entbufs+12*41;(Directory entry buffer for channel number 12 with 41 bytes)
entbuf13: equ entbufs+13*41;(Directory entry buffer for channel number 13 with 41 bytes)
entbuf14: equ entbufs+14*41;(Directory entry buffer for channel number 14 with 41 bytes)
entbuf15: equ entbufs+15*41;(Directory entry buffer for channel number 15 with 41 bytes)
sa: equ 0ae7h ;Current channel number, comes with the secondary address (sa)
entptr: equ 0ae8h ;Pointer to a buffer (entbufs) of directory entry with 41 bytes (2 bytes)
al2ptr: equ 0aeah ;Pointer to a buffer (al2bufs) of a Allocation 2 sector with 256 bytes (2 bytes)
bufptr: equ 0aech ;Pointer to a buffer (buffers) of a sector buffer with 256 bytes (2 bytes)
al1ptr: equ 0aeeh ;Pointer to a buffer (al1bufs) of a Allocation 1 sector with 128 bytes (2 bytes)
lsntlk: equ 0af0h ;State of ieee bus (1 byte: bit 1 = TALK active, bit 2 = LISTEN active)
staptr: equ 0af1h ;Pointer to current position of stabuf when writing to control channel (2 bytes)
cmdptr: equ 0af3h ;Pointer to current position of cmdbuf when reading from control channel(2 bytes)
dirbuf: equ 0af5h ;Directory block buffer (256 bytes)
cmdbuf: equ 0bf5h ;Command buffer for writing to control channel 15 (128 bytes)
getbuf: equ 0c75h ;Buffer to read after SA or OPEN bytes, this stores commands (SA and OPEN) or filenames (OPEN) (128 bytes)
stabuf: equ 0cf5h ;Status buffer for reading from control channel 15 (80 Bytes)
filnam: equ 0d45h ;(17 bytes: 16 for the characters and one for end marker or delimiter)
dstnam: equ 0d56h ;(17 bytes: 16 for the characters and one for end marker or delimiter)
drvnum: equ 0d67h ;Drive number (1 byte: 0 .. 9)
dirnum: equ 0d68h ;The number of directory entry to process (2 bytes)
al2idx: equ 0d6ah ;Allocation 2 sector index (1 byte: 0 .. 127)
secidx: equ 0d6bh ;Data sector index (1 byte: 0 .. 255)
l0d6ch: equ 0d6ch ;??? (1 byte)
al1idx: equ 0d6dh ;Allocation 1 sector index (1 byte: 0 .. 63)
dirhid: equ 0d6eh ;Flag for show hidden files on directory ("H": Yes, else: no)
al2bufs: equ 0d6fh ;(16 Allocation 2 sector buffers with 256 bytes)
al2buf0: equ al2bufs+ 0*256;(Allocation 2 sector buffer for channel number 0 with 256 bytes)
al2buf1: equ al2bufs+ 1*256;(Allocation 2 sector buffer for channel number 1 with 256 bytes)
al2buf2: equ al2bufs+ 2*256;(Allocation 2 sector buffer for channel number 2 with 256 bytes)
al2buf3: equ al2bufs+ 3*256;(Allocation 2 sector buffer for channel number 3 with 256 bytes)
al2buf4: equ al2bufs+ 4*256;(Allocation 2 sector buffer for channel number 4 with 256 bytes)
al2buf5: equ al2bufs+ 5*256;(Allocation 2 sector buffer for channel number 5 with 256 bytes)
al2buf6: equ al2bufs+ 6*256;(Allocation 2 sector buffer for channel number 6 with 256 bytes)
al2buf7: equ al2bufs+ 7*256;(Allocation 2 sector buffer for channel number 7 with 256 bytes)
al2buf8: equ al2bufs+ 8*256;(Allocation 2 sector buffer for channel number 8 with 256 bytes)
al2buf9: equ al2bufs+ 9*256;(Allocation 2 sector buffer for channel number 9 with 256 bytes)
al2buf10: equ al2bufs+10*256;(Allocation 2 sector buffer for channel number 10 with 256 bytes)
al2buf11: equ al2bufs+11*256;(Allocation 2 sector buffer for channel number 11 with 256 bytes)
al2buf12: equ al2bufs+12*256;(Allocation 2 sector buffer for channel number 12 with 256 bytes)
al2buf13: equ al2bufs+13*256;(Allocation 2 sector buffer for channel number 13 with 256 bytes)
al2buf14: equ al2bufs+14*256;(Allocation 2 sector buffer for channel number 14 with 256 bytes)
al2buf15: equ al2bufs+15*256;(Allocation 2 sector buffer for channel number 15 with 256 bytes)
al1bufs: equ 1d6fh ;(16 Allocation 1 sector buffers with 128 bytes)
al1buf0: equ al1bufs+ 0*128;(Allocation 1 sector buffer for channel number 0 with 128 bytes)
al1buf1: equ al1bufs+ 1*128;(Allocation 1 sector buffer for channel number 1 with 128 bytes)
al1buf2: equ al1bufs+ 2*128;(Allocation 1 sector buffer for channel number 2 with 128 bytes)
al1buf3: equ al1bufs+ 3*128;(Allocation 1 sector buffer for channel number 3 with 128 bytes)
al1buf4: equ al1bufs+ 4*128;(Allocation 1 sector buffer for channel number 4 with 128 bytes)
al1buf5: equ al1bufs+ 5*128;(Allocation 1 sector buffer for channel number 5 with 128 bytes)
al1buf6: equ al1bufs+ 6*128;(Allocation 1 sector buffer for channel number 6 with 128 bytes)
al1buf7: equ al1bufs+ 7*128;(Allocation 1 sector buffer for channel number 7 with 128 bytes)
al1buf8: equ al1bufs+ 8*128;(Allocation 1 sector buffer for channel number 8 with 128 bytes)
al1buf9: equ al1bufs+ 9*128;(Allocation 1 sector buffer for channel number 9 with 128 bytes)
al1buf10: equ al1bufs+10*128;(Allocation 1 sector buffer for channel number 10 with 128 bytes)
al1buf11: equ al1bufs+11*128;(Allocation 1 sector buffer for channel number 11 with 128 bytes)
al1buf12: equ al1bufs+12*128;(Allocation 1 sector buffer for channel number 12 with 128 bytes)
al1buf13: equ al1bufs+13*128;(Allocation 1 sector buffer for channel number 13 with 128 bytes)
al1buf14: equ al1bufs+14*128;(Allocation 1 sector buffer for channel number 14 with 128 bytes)
al1buf15: equ al1bufs+15*128;(Allocation 1 sector buffer for channel number 15 with 128 bytes)
eoisav: equ 256fh
dirout: equ 2570h ;Here where a directory output line stored before output (??? bytes)
wrtprt: equ 25f0h ;Points to current position to writee to ieee (2 bytes)
endbuf: equ 25f2h ;Points to end of buffer to write to ieee (2 bytes)
l25f4h: equ 25f4h ;(2 bytes)
dirdrv: equ 25f6h ;Save the Drive Number (drvnum) when Directory (open_dir) is processed (1 byte)
dirnam: equ 25f7h ;open_dir parameter (17 bytes: 16 for the characters and one for end marker or delimiter)
pattfn: equ 2608h ;Points to pattern for filename, used in find_first and find_next (2 bytes)
tmpdrv: equ 260ah ;Temporary drive number, used in corv_read_sec und corv_writ_sec (2 bytes)
drvcnf: equ 260ch ;Flag if drive is configured (0: Not Configured, 1: Configured)
l260dh: equ 260dh ;Temporary in cmd_cpy (2 bytes)
l260fh: equ 260fh ;Temporary in put_number (1 byte)
hdrbuf: equ 2610h ;Buffer of header sector (first sector of user area with 256 bytes)
drvnam: equ hdrbuf+ 0;Position 0 starts the drive names of the ten drives
drvid: equ hdrbuf+160;Position 160 starts the drive ids of the ten drives
rdbuf: equ 2710h ;(256 bytes)
cpybuf: equ 2810h ;Temporary buffer, only used for concat command (256 bytes)
bambuf: equ 2910h ;Buffer of BAM sector bamsec used in bam_read_sec and bam_writ_sec or for B-A and B-F (256 bytes)
stack: equ 2a93h
buffers: equ 3000h ;(16 sector buffers with 256 bytes)
buffer0: equ buffers+ 0*256;(sector buffer for channel number 0 with 256 bytes)
buffer1: equ buffers+ 1*256;(sector buffer for channel number 1 with 256 bytes)
buffer2: equ buffers+ 2*256;(sector buffer for channel number 2 with 256 bytes)
buffer3: equ buffers+ 3*256;(sector buffer for channel number 3 with 256 bytes)
buffer4: equ buffers+ 4*256;(sector buffer for channel number 4 with 256 bytes)
buffer5: equ buffers+ 5*256;(sector buffer for channel number 5 with 256 bytes)
buffer6: equ buffers+ 6*256;(sector buffer for channel number 6 with 256 bytes)
buffer7: equ buffers+ 7*256;(sector buffer for channel number 7 with 256 bytes)
buffer8: equ buffers+ 8*256;(sector buffer for channel number 8 with 256 bytes)
buffer9: equ buffers+ 9*256;(sector buffer for channel number 9 with 256 bytes)
buffer10: equ buffers+10*256;(sector buffer for channel number 10 with 256 bytes)
buffer11: equ buffers+11*256;(sector buffer for channel number 11 with 256 bytes)
buffer12: equ buffers+12*256;(sector buffer for channel number 12 with 256 bytes)
buffer13: equ buffers+13*256;(sector buffer for channel number 13 with 256 bytes)
buffer14: equ buffers+14*256;(sector buffer for channel number 14 with 256 bytes)
buffer15: equ buffers+15*256;(sector buffer for channel number 15 with 256 bytes)
ENDIF
IF version = 291
org 0100h
jp reset ;0100 c3 00 02
l0103h: ;user data block
db 1 ;Physical drive number (1 .. 4, 1 Byte)
db 0,0,0 ;Starting sector number on drive (An Absolute Sector Number, 3 Bytes)
dw 6080 ;User area size in kilobytes, there are 4 blocks (2 Bytes, Maximum is 64 Megabytes)
db 0 ;Type of user area (Single user or Multi-user) (1 Byte) (Disallow write)
dw 992 ;Maximum numbers of files allowed (2 Bytes, Maximum is 65535)
dw 1017 ;Size (in kilobyte) allocated for direct access, these are 4 blocks (2 Bytes, Maximum is 64 Megabytes)
dw 77 ;# of "tracks per drive" for direct access (2 Bytes)
db 29,0,0 ;# of "sectors per track" for direct access (3 Bytes)
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
l0123h: ;user name
db "HARD DISK "
l0133h:
db 07h ;Max. head number (starting from 0)
l0134h:
dw 0060h ;First cylinder number used for HardBox
l0136h:
db 08h ;IEEE-488 primary address
;unused data (filler)
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0
reset:
xor a ;A=0
out (ppi1_pb),a ;Clear IEEE data out
ld a,atna
out (ppi2_pb),a ;Clear IEEE control out, except ATNA (inactive)
ld a,(l0136h)
ld (devnum),a ;Store device number from header
ELSE
org 0e000h
le000h:
jp reset
reset:
ld a,10011001b ;Set PPI #1 control
; Bit 7: IO 1 = I/O mode (not BSR)
; Bit 6: GA1 0 = Group A as Mode 1 (Simple I/O)
; Bit 5: GA0 0
; Bit 4: PA 1 = Group A, Port A as Input
; Bit 3: PCu 1 = Group A, Port C upper as Input
; Bit 2: GB 0 = Group B as Mode 1 (Simple I/O)
; Bit 1: PB 0 = Group B, Port B as Output
; Bit 0: PCl 1 = Group B, Port C lower as Input
out (ppi1_cr),a
ld a,10011000b ;Set PPI #2 control
; Bit 7: IO 1 = I/O mode (not BSR)
; Bit 6: GA1 0 = Group A as Mode 1 (Simple I/O)
; Bit 5: GA0 0
; Bit 4: PA 1 = Group A, Port A as Input
; Bit 3: PCu 1 = Group A, Port C upper as Input
; Bit 2: GB 0 = Group B as Mode 1 (Simple I/O)
; Bit 1: PB 0 = Group B, Port B as Output
; Bit 0: PCl 0 = Group B, Port C lower as Output
out (ppi2_cr),a
ld a,ledrdy
out (ppi2_pc),a ;Turn off "Ready" LED, turn on "A" and "B" LEDs
xor a ;A=0
out (ppi1_pb),a ;Clear IEEE data out
ld a,atna
out (ppi2_pb),a ;Clear IEEE control out, except ATNA (inactive)
ld c,02h ;C = 2 blinks for RAM failure
ld hl,0000h ;RAM start address
ld de,4000h ;RAM end address + 1
le01eh:
ld (hl),l
inc hl
dec de
ld a,e
or d
jr nz,le01eh
ld hl,0000h ;RAM start address
ld de,4000h ;RAM end address + 1
le02bh:
ld a,(hl)
cp l
jr nz,test_failed
cpl
ld (hl),a
inc hl
dec de
ld a,e
or d
jr nz,le02bh
ld hl,0000h ;RAM start address
ld de,4000h ;RAM end address + 1
le03dh:
ld a,(hl)
cpl
cp l
jr nz,test_failed
inc hl
dec de
ld a,e
or d
jr nz,le03dh
ld sp,stack
ld hl,le000h ;ROM start address
ld bc,1fffh ;Number of code bytes in the ROM
call calc_checksum ;Calculate ROM checksum
ld c,03h ;C = 3 blinks for ROM failure
ld hl,checksum ;HL = address of checksum byte in ROM
cp (hl) ;Any difference from the calculated value?
jr z,test_passed ; No: ROM check passed
test_failed:
;Self-test failed. Blink the LED forever.
;
;C = Number of blinks (2=RAM failed, 3=ROM failed)
;
ld b,c
le05dh:
xor a
out (ppi2_pc),a ;Turn on all LEDs ("Ready" LED, "A" and "B")
ld de,0ffffh
le063h:
dec de
ld a,e
or d
jr nz,le063h ;Delay loop
ld a,ledrdy
out (ppi2_pc),a ;Turn off "Ready" LED, turn on "A" and "B" LEDs
ld de,0ffffh
le06fh:
dec de
ld a,e
or d
jr nz,le06fh ;Delay loop
djnz le05dh ;Decrement B, loop until B=0
ld b,03h
ld de,0ffffh
le07bh:
dec de
ld a,e
or d
jr nz,le07bh ;Delay loop
djnz le07bh ;Decrement B, loop until B=0
jr test_failed
calc_checksum:
;Calculate the ROM checksum.
;
;HL = start address of ROM
;BC = number of bytes to process
;
;Returns the checksum in A.
;
xor a ;A=0
le085h:
add a,(hl) ;Add byte at pointer to A
rrca
ld d,a ;Save A in D
inc hl ;Increment pointer
dec bc ;Decrement byte counter
ld a,b
or c ;Test if byte counter is zero
ld a,d ;Recall A from D
jr nz,le085h ;Loop if more bytes remaining
ret
test_passed:
ld bc,0000h
le093h:
in a,(ppi2_pc)
xor ledrdy
out (ppi2_pc),a ;Invert "Ready" LED
ld de,8000h
le09ch:
in a,(ppi2_pc)
and ready ;Corvus READY
jr z,le0a3h
inc bc
le0a3h:
dec de
ld a,e
or d
jr nz,le09ch
ld a,b
or a
jr z,le093h
ld a,ledrdy
out (ppi2_pc),a ;Turn off "Ready" LED, turn on "A" and "B" LEDs
call corv_init ;Initialize the Corvus controller
in a,(ppi1_pc) ;Read DIP switches
cpl
rra ;Shift 1 bit right
and 00000111b ;Use only these bits ----xxx-
add a,8 ;plus 8 (0=8, 1=9, ... 7=15)
ld (devnum),a
in a,(ppi1_pc) ;Read DIP switches
cpl
ld c,a
rra
rra
rra
rra ;Shift 4 bits right
ld b,4 ;B=04h (4 bits to process)
le0c8h:
rra
rl c
djnz le0c8h
ld a,c
and 00011111b ;Now we have ---04567
ENDIF
init_user:
;Init user with user data
;A=User Number
;
ld sp,stack
;Clear memory from 0004h .. 2a13h
ld hl,usrdat ;HL=0004h
ld de,usrdat+1 ;DE=0005h
ld bc,2a0eh ;BC=2a0eh
ld (hl),00h ;(0004h)=0
;(0005h)=(0004h) or 00h .. (2a13h)=(2a12h) or 00h
ldir ;Copy BC bytes from (HL) to (DE)
IF version = 291
xor a
ld (userid),a ;(userid)=0
ld a,1
ld (drvcnf),a ;(drvcnf)=1
ld hl,cmdbuf ;When we start reading from control channel, we store it into command buffer (cmdbuf)
ld (cmdptr),hl ;(cmdptr)=cmdbuf
ld hl,l0103h ;Pointer to user data block from header
ELSE
ld (userid),a ;Store User Number
xor a
ld (drvcnf),a ;(drvcnf)=0
ld a,error_84 ;" DRIVE NOT CONFIGURED"
call error_out ;Writes the error message " DRIVE NOT CONFIGURED" into the status buffer
ld hl,cmdbuf ;When we start reading from control channel, we store it into command buffer (cmdbuf)
ld (cmdptr),hl ;(cmdptr)=cmdbuf
ld a,(userid) ;Get User Number
cp 01fh ;Is it 31?
jr nz,le100h
xor a ;A=0
ld (userid),a ; Yes: Set it to 0
jp le2aeh ; And don't configure the drive!
le100h:
ld de,16
xor a ;ADE=000010h (Sector 16)
ld b,1 ;B=Corvus drive number (1)
ld hl,rdbuf ;HL=rdbuf (target address)
call corv_read_sec ;Reads a sector (256 bytes)
ld a,(rdbuf+8)
cp "H" ;H for Hard?
jp nz,le2aeh ; No: Unknown format, skip configuring
ld a,(rdbuf+9)
cp "B" ;B for Box?
jp nz,le2aeh ; No: Unknown format, skip configuring
ld hl,drvcnf ;Okay, drive is configured
inc (hl) ;(drvcnf)=(drvcnf)+1
call error_ok ;"OK" overwrites " DRIVE NOT CONFIGURED"
ld a,(userid)
rr a
rr a
rr a
rr a
and 00001111b
ld e,a ;E=(userid)/16
xor a ;A=0
ld d,a ;ADE=0, 1, 2 or 3 depends on (userid) to read the user name
ld b,1 ;B=Corvus drive number (1)
ld hl,rdbuf ;HL=rdbuf (target address)
call corv_read_sec ;Reads the sector (256 bytes) with the user name
ld a,(userid)
add a,a