-
Notifications
You must be signed in to change notification settings - Fork 1
/
driver.asm
2521 lines (2414 loc) · 54.9 KB
/
driver.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
; Diskdriver Talent TDC600
;
; FDC WD37C65
;
; Documentation work by Doug Gabbard, RetroDepot.net
; Original disassembly taken from: https://sourceforge.net/p/msxsyssrc/git/ci/master/tree/
; This can generally be considered to be a Fork/Merge/Pull/Merge/Pull/etc with Arjen's work.
; Though, he has only used a few pointers to data blocks from my suggestions. And mostly, I
; am borrowing from his work, and not the other way around.
; NOTE: Some of this is guess work, as I am fairly unfamiliar with the MSX architecture,
; and have not found all references to locations within the BIOS memory (Such as a call
; to $00DD, which is in the middle of the Paddle Routine). I must speculate that these are
; memory locations in MSX-DOS instead of the BIOS itself. However, I have yet to find where
; these are documented. So I'm making an educated guesses in certain areas of the code...
; EXTRN INIHRD = 78ABH
; EXTRN DRIVES = 7910H
; EXTRN INIENV = 794CH
; EXTRN DSKIO = 752EH
; EXTRN DSKCHG = 7996H
; EXTRN GETDPB = 79D5H
; EXTRN CHOICE = 7C39H
; EXTRN DSKFMT = 7C9FH
; EXTRN MTOFF = 78F8H
; EXTRN OEMSTA = 7F6DH
; EXTRN MYSIZE = 25
; EXTRN SECLEN = Should be 512 - Size of biggest sector
; EXTRN DEFDPB = 74AF - DEFAULT MEDIA F9
; symbols of routines which can be used by the diskdriver
; PUBLIC PROMPT
; PUBLIC SETINT
; PUBLIC PRVINT
; PUBLIC GETSLT
; PUBLIC GETWRK - Gets Base Address of work area in 'IX' and 'HL'. Preserves DE and IY
; PUBLIC DIV16
; PUBLIC ENASLT
; PUBLIC XFER
;---------------------------------
;Workspace as determined by Arjen
;---------------------------------
; +0 Motor-Off Timer
; +1 Disk Change Drive 0 Timer
; +2 Disk Change Drive 1 Timer
; +3 Last Physical Drive
; +4 Last Phantom Drive
; +5 Number of Physical Drives
; +6-10 WD37C65 CMD
; +11 ?? Unknown ?? - Looks like FDC Master Status Register
; +12 FDC Operation Mode
; +13 Media Descriptor (DKSFMT)
; +14 WD37C65 Status ST1
; +15 WD37C65 Status ST2
; +16 WD37C65 Status ST3
; +17 WD37C65 Status C
; +18 WD37C65 Status H
; +19 WD37C65 Status R
; +20 WD37C65 Status N
; +21 ?? Unknown ??
; +22 SlotID Page 2
; +23 SlotID Disk Controller
; +24 slotID Page 0
;---------------------------------
;Register Documentation of WD37C65
;---------------------------------
;Data Register Map
------------------
; +0 & /RD = Main Status Register
; +0 & /WR = Illegal Register
; +1 & /RD = Read from Data Register
; +1 & /WR = Write into Data Register
;Master Status Register
;----------------------
; D0 - FDD0 Busy Flag - If any FDD Flags set, will not read/write. (Seek Mode?)
; D1 - FDD1 Busy Flag - If any FDD Flags set, will not read/write. (Seek Mode?)
; D2 - FDD2 Busy Flag - If any FDD Flags set, will not read/write. (Seek Mode?)
; D3 - FDD3 Busy Flag - If any FDD Flags set, will not read/write. (Seek Mode?)
; D4 - FDC Busy Flag - Read/Write Command in progress. Cannot accept commands.
; D5 - CB / Execution Mode - 1=Execution Phase, 0=Result Phase. Only Non-DMA
; D6 - DIO - Data Direction Flag. If 1, Data from FDC to uP, if 0 Data from uP to FDC.
; D7 - RQM - Request for Master. Indicates Ready to Send/Receive data.
;
; DIO and RQM should be used together to perform check of Ready and Direction.
;Status Register 0
;-----------------
; D0 - Used with D1
; D1 - Used with D0 to determine drive number at interrupt
; D2 - Indicates state of Head at interrupt
; D3 - Always presumed to be 0
; D4 - Equipment Check. Set if Track 0 signal fails after 77 Step Pulses
; D5 - When Seek is Complete this flag is set high
; D6 - When D7+D6 = 10, Invalid Command Issued.
; D7 - When D7+D6 = 00, Normal Termination of Command. 01, Abnormal Termination
;Status Register 1
;-----------------
; D0 - Missing Address Mark Flag
; D1 - Not Writable Flage - Set when WP signal is received during write
; D2 - No Data - Set when FDC cannot find Sector or ID Field
; D3 - Always 0
; D4 - Overrun Flag. Set when not read after a certain time interval
; D5 - Data Error. Set when FDC detects CRC error.
; D6 - Always 0
; D7 - End of Cylinder. Set when FDC to read Sector after last Sector.
;Status Register 2
;-----------------
; D0 - Missing Data Address Mark in Field
; D1 - Bad Cylinder
; D2 - Scan Not. Set when sector with conditions can't be found
; D3 - Scan Equal. Set when scan finds sector with equal conditions
; D4 - Wrong Cylinder.
; D5 - Data Error. FDC found CRC error in data field.
; D6 - Control Mark. Set when FDC finds deleted address mark during read or scan.
; D7 - Always 0
;Status Register 3
;-----------------
; D0 - Unit Select 2. Used to indicate Unit Select 0 signal to FDC
; D1 - Unit Select 1. Used to indicate Unit Select 1 signal to FDC
; D2 - Head Select. Used to indicated Side Select signal to FDC
; D3 - Write Protect. Used by FDC to indicate status of WP signal.
; D4 - Track 0. Used by FDC to indicate Track 0 signal.
; D5 - Ready. Always 1. Drive always assumed to be ready.
; D6 - Write Protect. Assumed same as Write Protect D3 ???
; D7 - Always 0
;Operations Register
;-------------------
; D0 - Drive Select. If 0 and MOEN1 = 1: DS1 Active. If 1 and MOEN1 = 1: DS2
; D1 - Must be 0 for DS1 and DS2 to be active.
; D2 - /SRST. Software Reset - Active with a 0
; D3 - DMAEN - DMA Enable
; D4 - MOEN1 - Motor on Enable. Inverted Output. /MO1 active only in PC/AT
; D5 - MOEN2 - Motor on Enable. Inverted Output. /MO2 active only in PC/AT
; D6 - Doesn't matter. No Function.
; D7 - Mode Select. During Software reset used to select Special(1) or PC/AT(0) Modes.
;---------------------------------
; WD37C65 Commands
;---------------------------------
; The FDC can perform 15 different commands. Each consisting of three phases: Command,
; Execute, and Result. During the command phase the FDC receives the information needed
; to perform an operation. During execution the FDC performs the operation. The Result
; phase the FDC provides status information to the uP.
;FDC Commands
-------------
; Read Read Deleted Data Write Data
; Write Deleted Data Read a Track Read ID
; Format a Track Scan Equal Scan Low or Equal
; Scan High or Equal Recalibrate Sense Interrupt Status
; Specify Sense Drive Status Seek
;
FDCSTA EQU 8000H ; ---LI ;WD37C65 PORT - STATUS REGISTER
FDCDAT EQU 8001H ; --SL- ;WD37C65 PORT - DATA REGISTER
FDCLDO EQU 9000H ; --S-- ;WD37C65 PORT - LOAD OPERATION REGISTER
FDCSTAL EQU 0000H ;WD37C65 PORT - STATUS REGISTER MIRROR
FDCDATL EQU 0001H ;WD37C65 PORT - DATA REGISTER MIRROR
FDCLDOL EQU 1000H ;WD37C65 PORT - LOAD OPERATION REGISTER MIRROR
WRSLT EQU 0014H ; -C---
ENASLT EQU 0024H ; -C---
RAMAD1 EQU 0F342H ; ---L- ;SLOT ADDR OF RAM IN PAGE 1
SECBUF EQU 0F34DH ; --SL- ;TEMPORARY STORAGE FOR FAT SECTOR POINTER
SETROM EQU 0F368H ; -C--- ;SWITCH DISK-ROM TO PAGE 1
ROMBDOS EQU 0F37DH ; -C--- ;INTER-SLOT CALL TO BDOS ROUTINES
EXPTBL EQU 0FCC1H ; ----I
DISINT EQU 0FFCFH ; -C--- ;HOOK TO EXTENDED BIOS - DISABLING INTERRUPTS - BEFORE INTERACT W/ DISK
ENAINT EQU 0FFD4H ; -C--- ;HOOK TO EXTENDED BIOS - ENABLING INTERRUPTS - AFTER INTERACT W/ DISK
SSLTRG EQU 0FFFFH ; --SL- SECONDARY SLOT REGISTER
DEFDPB EQU DSK7203-1
MYSIZE EQU 25
SECLEN EQU 512
ORG 7405H
;---------------------------------------------------
; Subroutine Get current slotid on page
; Inputs B = page
; Outputs Slot ID in 'A'
; Registers: AF,HL affected
;---------------------------------------------------
GTCSLT:
PUSH BC ;Save the values
PUSH DE
LD A,B ;Get input for Page. B=Page (0,1,2,3)
OR A ;If 0, set Z-flag
IN A,(0A8H) ;Read Primary Slot Register into 'A'
JR Z,GTCSLT3 ;If Page 0 is Slot 0, skip ahead
PUSH BC ;Save again, as we'll be decrementing
GTCSLT2:
RRCA ;Rotate twice with carry, appears to calculate
RRCA ;page slot assignment
DJNZ GTCSLT2 ;Decrement 'B' and Jump if not 0
POP BC ;Once Zero, A is calculated, get back 'B'
GTCSLT3:
AND 03H ;Primary Slot Bitmask for 'Page 0'
LD E,A ;Used as an offset: 00XX + HL
LD D,00H
LD HL,EXPTBL ;Load HL with Expanded Slot Table
ADD HL,DE ;Now we have the offset memory location
LD E,A ;Store that offset.
LD A,(HL) ;Get the Expanded Slot Table Page Value
AND 80H ;Test if is expanded
OR E ;Now combine
LD E,A ;And store - Now we have Primary Slot ID???
INC HL ;Now get Secondary Slot Register for Page
INC HL ;Located in SLTTBL+(Offset)
INC HL
INC HL
LD A,B ;Get inpute for Page. B=Page (0,1,2,3)
OR A ;If 0, set Z-Flag
LD A,(HL) ;Get Secondary Slot Register Value
RLCA ;Rotate Page 3 into Page 0 position
RLCA
JR Z,GTCSLT5 ;But if Page 0, Jump Ahead
GTCSLT4:
RRCA ;If not Page 0, Rotate Page 3 back to Page 3
RRCA ;Decrement Page Input until 0, then go on.
DJNZ GTCSLT4
GTCSLT5:
AND 0CH ;Logical And for Page 1
OR E ;Combine with Primary Slot ID
POP DE ;Restore and Return with Slot ID in 'A'
POP BC
RET
;---------------------------------------------------
; Subroutine Set slotid on page 0
; Inputs B = slotid
; Outputs A = New Primary Slot ID
; Registers: AF affected.
;---------------------------------------------------
SSLTID:
DI ;We're writing slots, no interruptions...
PUSH BC ;Save the Slot ID to be written
LD B,A ;Get it in 'A'
AND 03H ;Bitmask for Page 0
LD C,A ;Store it in 'C'
LD A,B ;Get the Slot ID again
BIT 7,A ;Test if Expanded Slot??? Just a guess...
JR NZ,SSLTID2 ;If so, jump and do that....
IN A,(0A8H) ;Otherwise, get current Primary Slots
AND 0FCH ;Bitmask off Page 0
OR C ;Combine with Slot ID for Page
OUT (0A8H),A ;Write the Slot
POP BC ;Get Slot ID back in 'B'
RET ;And return with New Slot ID in 'A'
;But we didn't Enable Interrupts.....
;This may be an issue, not sure......
SSLTID2:
PUSH DE ;We dont want to modify DE....
IN A,(0A8H) ;Get Current Slot ID
AND 0FCH ;Bitmask off Page 0
OR C ;Get New Primary Slot ID
LD D,A ;Store New Primary Slot ID
RRCA ;Rotate Page 3 into 2....why.....
RRCA
AND 0C0H ;Mask what was Page 0, now Page 3
LD E,A ;Store in 'E'
LD A,D ;Get New Primary Slot ID back
AND 3FH ;Mask off Page 3
OR E ;Combine with previous mask of Page 3
OUT (0A8H),A ;And write to Primary Slot Register
LD A,B ;Get Slot ID again
AND 0CH ;Mask off Page 0
RRCA ;Rotate into Page 3
RRCA
LD C,A ;Store it
LD A,(SSLTRG) ;Get Secondary Slot Register
CPL ;We need to invert it.
AND 0FCH ;Bitmask off Page 0
OR C ;Combine with new Page
LD (SSLTRG),A ;Write back to Slot Register
LD A,D ;Get Primary Slot ID back
OUT (0A8H),A ;Write to Primary Slot Register
POP DE ;Restore our registers and return
POP BC
RET ;We didn't re-enable interrupts....
;---------------------------------------------------
; Subroutine Enable FDC on page 0
; Inputs: None
; Outputs: None
; Remarks: GETWRK Gets Slot ID possibly?
;---------------------------------------------------
ENAFDC:
PUSH AF ;Save all registers.
PUSH BC
PUSH DE
PUSH HL
CALL GETWRK ;Get Disk Driver Work Area.
;Stores Work area in 'IX'
;and destroys 'A', and 'HL'
;Also gets slot ID I think...
LD B,0 ;Get Slot ID for Page 0
CALL GTCSLT
LD (IX+24),A ;Store it.
LD B,1 ;Get Slot ID for Page 1
CALL GTCSLT
LD (IX+23),A ;Store it.
LD B,2 ;Get Slot ID for Page 2
CALL GTCSLT
LD (IX+22),A ;Store it.
DI ;Disable Interrupts
LD A,(IX+23) ;Get Slot ID for Page 1 back
CALL SSLTID ;Set Slot ID on Page 0
POP HL ;Restore Registers and Return
POP DE
POP BC
POP AF
RET ;But we didn't Re-Enable Interrupts....
;---------------------------------------------------
;
; DISK PARAMETERS IN BLOCK DATA
;
;---------------------------------------------------
DSKPMT: ;DISK PARAMETERS
DSK3603: ;BLOCK DATA?
;Confirmed by Arjen
DEFB 0F8H ;F8 MEDIA
DEFW 512 ;80 TRACKS
DEFB 0FH ;9 SECTORS
DEFB 04H ;SINGLE SIDED
DEFB 01H ;3.5 360KB
DEFB 02H
DEFW 1
DEFB 2
DEFB 112
DEFW 12
DEFW 355
DEFB 2
DEFW 5
DSK7203: ;BLOCK DATA
DEFB 0F9H ;F9 MEDIA
DEFW 512 ;80 TRACKS
DEFB 0FH ;9 SECTORS
DEFB 04H ;DOUBLE SIDED
DEFB 01H ;3.5 720KB
DEFB 02H
DEFW 1
DEFB 2
DEFB 112
DEFW 14
DEFW 714
DEFB 3
DEFW 7
DSK3203:
DEFB 0FAH ;FA MEDIA
DEFW 512 ;80 TRACKS
DEFB 0FH ;8 SECTORS
DEFB 04H ;SINGLE SIDED
DEFB 01H ;3.5 320KB
DEFB 02H
DEFW 1
DEFB 2
DEFB 112
DEFW 10
DEFW 316
DEFB 1
DEFW 3
DSK6403:
DEFB 0FBH ;FB MEDIA
DEFW 512 ;80 TRACKS
DEFB 0FH ;8 SECTORS
DEFB 04H ;DOUBLE SIDED
DEFB 01H ;3.5 640KB
DEFB 02H
DEFW 1
DEFB 2
DEFB 112
DEFW 12
DEFW 635
DEFB 2
DEFW 5
DSK1805:
DEFB 0FCH ;FC MEDIA
DEFW 512 ;40 TRACKS
DEFB 0FH ;9 SECTORS
DEFB 04H ;SINGLE SIDED
DEFB 00H ;5.25 180KB
DEFB 01H
DEFW 1
DEFB 2
DEFB 64
DEFW 9
DEFW 352
DEFB 2
DEFW 5
DSK3605:
DEFB 0FDH ;FD MEDIA
DEFW 512 ;40 TRACKS
DEFB 0FH ;9 SECTORS
DEFB 04H ;DOUBLE SIDED
DEFB 01H ;5.25 360KB
DEFB 02H
DEFW 1
DEFB 2
DEFB 112
DEFW 12
DEFW 355
DEFB 2
DEFW 5
DSK1605:
DEFB 0FEH ;FE MEDIA
DEFW 512 ;40 TRACKS
DEFB 0FH ;8 SECTORS
DEFB 04H ;SINGLE SIDED
DEFB 00H ;5.25 160KB
DEFB 01H
DEFW 1
DEFB 2
DEFB 64
DEFW 7
DEFW 314
DEFB 1
DEFW 3
DSK3205:
DEFB 0FFH ;FF MEDIA
DEFW 512 ;40 TRACKS
DEFB 0FH ;8 SECTORS
DEFB 04H ;DOUBLE SIDED
DEFB 01H ;5.25 320KB
DEFB 02H
DEFW 1
DEFB 2
DEFB 112
DEFW 10
DEFW 316
DEFB 1
DEFW 3
;---------------------------------------------------------------------------------
; DSKIO
;
; Input: F - Carry Flag reset for read, set for write.
; A - Drive number (starts at 0)
; B - Number of sectors to read/write.
; C - Media descriptor
; DE - Logical sector number (starts at 0)
; HL - Transfer Address
; Outputs: If successful, carry flag cleared. Otherwise carry flag set, error code
; placed in 'A', number of remaining sectors in 'B'.
; Registers: AF,BC,DE,HL,IX,IY may be affected.
;
; The drive number and media descriptor come from the drive parameter block. The
; number of sectors may range from 1 to 255. The logical sector numbers start at zero
; and is incremented in ones, so the I/O system must map these the logical sector
; numbers into tracks and sectors. The logical sector 0 corresponds to track 0,
; sector 1.
;
; The error codes are defined as follows:
;
; 0 Write Protected
; 2 Not Ready
; 4 Data (CRC) error
; 8 Record not found
; 10 Write fault
; 12 Other errors
;---------------------------------------------------------------------------------
DSKIO:
JP NC,DSKIO_READ ;If no Carry, We're Reading from Disk
;Returns to DSKIO2
CALL DISINT ;Disable Interrupts before Disk Access
DI
CALL ENAFDC ;Enable FDC on page 0
CALL C$7563 ;Only used by DSKIO - One of the Write Sectors Routines
DSKIO2: ;Was J.753B
PUSH AF
LD C,100
JR NC,DSKIO3
LD C,0
DSKIO3:
CALL FORCE_READY
LD (IX+0),200
LD A,(IX+12)
AND A
JR NZ,DSKIO4
LD (IX+1),C
JR DSKIO5
;
; -----------------
DSKIO4:
LD (IX+2),C
DSKIO5:
LD A,(IX+24) ; saved slotid on page 0
CALL SSLTID ; Set slotid on page 0
POP AF
EI ;Enable Interrupts and Return
CALL ENAINT
RET
;--------------------
; Subroutine to Write Sectors
;
;--------------------
C$7563:
CALL C.76E4
;
RET C
;
LD A,H
AND A
JP M,J.759E
;
CALL C.79F0
;
CALL C.7A48
;
RET C
;
INC B
DEC B
RET Z
;
LD A,H
AND A
JP M,J.759E
;
PUSH HL
PUSH DE
PUSH BC
LD A,(IX+24) ; saved slotid on page 0
CALL SSLTID ; Set slotid on page 0
LD DE,(SECBUF)
PUSH DE
LD BC,512
CALL XFER
LD A,(IX+23)
CALL SSLTID ; Set slotid on page 0
;
POP HL
POP BC
POP DE
CALL C.75A9
;
POP HL
JR J$75A1
;
; -----------------
J.759E:
CALL C.75A9
J$75A1:
RET C
;
DEC B
RET Z
;
CALL C.77A0
;
JR J.759E
;--------------------
; another Subroutine to Write Sectors
;
;--------------------
C.75A9:
LD E,07H ;Head 1 selected, Unit 0
J$75AB:
CALL FORCE_READY
;
PUSH HL
PUSH DE ;Store Head/Unit selection.
PUSH BC
LD BC,0
LD DE,0
LD A,45H ;Not Multi-Track, MFM mode
CALL FDC_SECTOR_CMD ;Appears to write the command instruction...
;
J.75BC:
LD A,(DE)
RLA
JR C,J.75D0
;
DJNZ J.75BC
;
DEC C
LD A,(DE)
RLA
JR C,J.75D0
;
JR NZ,J.75BC
;
SCF
JR J$75DE
;
; -----------------
J.75CC:
LD A,(DE)
RLA
JR NC,J.75CC
;
J.75D0:
AND 40H ; "@"
JR Z,J$75DB
;
INC E
LD A,(HL)
LD (DE),A
DEC E
INC HL
JR J.75CC
;
; -----------------
J$75DB:
CALL FDC_RD_RESULT
;
J$75DE:
POP BC
POP DE
POP HL
JP C,J$7618
;
LD A,(IX+15)
AND 7FH
RET Z
;
BIT 1,A
JR NZ,J$761C
;
PUSH AF
LD A,(IX+6)
AND 01H ; 1
INC A
CPL
AND (IX+11)
LD (IX+11),A
CALL FDC_SEEK
;
POP AF
DEC E
JP NZ,J$75AB
;
SCF
LD E,A
BIT 4,E
LD A,0AH ; 10
RET NZ
;
BIT 2,E
LD A,08H ; 8
RET NZ
;
BIT 5,E
LD A,04H ; 4
RET NZ
;
LD A,0CH ; 12
RET
;
; -----------------
J$7618:
LD A,02H ; 2
SCF
RET
;
; -----------------
J$761C:
XOR A
SCF
RET
;
; -----------------
DSKIO_READ: ;Was J$761F
CALL DISINT ;Disable Interrupts before Disk Access
DI ;But we Disabled them again???
CALL ENAFDC ;Enable FDC on Page 0
CALL C$762C ;Alternate to C$7563
JP DSKIO2 ;Jump to DSKIO2
;--------------------
; Subroutine to Read Sectors
;
;--------------------
C$762C:
CALL C.76E4
;
RET C
;
LD A,H
AND A
JP M,J.766F
;
CALL C.79F0
;
CALL C$7A23
;
CALL C.7A48
;
RET C
;
INC B
DEC B
RET Z
;
LD A,H
AND A
JP M,J.766F
;
PUSH HL
LD HL,(SECBUF)
CALL C.767A
;
POP HL
RET C
;
PUSH BC
PUSH DE
PUSH HL
LD A,(IX+24) ; saved slotid on page 0
CALL SSLTID ; Set slotid on page 0
;
EX DE,HL
LD HL,(SECBUF)
LD BC,512
CALL XFER
;
LD A,(IX+23)
CALL SSLTID ; Set slotid on page 0
;
POP HL
POP DE
POP BC
AND A
JR J$7673
;
; -----------------
J.766F:
CALL C.767A
;
RET C
;
J$7673:
DEC B
RET Z
;
CALL C.77A0
;
JR J.766F
;--------------------
; Another Subroutine to Read Sectors
;
;--------------------
C.767A:
LD E,07H ;Head 1, Unit 0
J$767C:
CALL FORCE_READY
;
PUSH HL
PUSH DE ;Store Head/Unit selection
PUSH BC
LD BC,0
LD DE,0
LD A,66H ;Not Multi-Side Operation, MFM Mode, Skip Deleted Data Address Mark
CALL FDC_SECTOR_CMD ;Appears to write the command...
;
J.768D:
LD A,(DE)
RLA
JR C,J.76A1
;
DJNZ J.768D
;
DEC C
LD A,(DE)
RLA
JR C,J.76A1
;
JR NZ,J.768D
;
SCF
JR J$76AF
;
; -----------------
J.769D:
LD A,(DE)
RLA
JR NC,J.769D
;
J.76A1:
AND 40H ; "@"
JR Z,J$76AC
;
INC E
LD A,(DE)
LD (HL),A
INC HL
DEC E
JR J.769D
;
; -----------------
J$76AC:
CALL FDC_RD_RESULT
;
J$76AF:
POP BC
POP DE
POP HL
JP C,J$76E0
;
LD A,(IX+15)
AND 7FH
RET Z
;
PUSH AF
LD A,(IX+6)
AND 01H ; 1
INC A
CPL
AND (IX+11)
LD (IX+11),A
CALL FDC_SEEK
;
POP AF
DEC E
JP NZ,J$767C
;
SCF
LD E,A
BIT 2,E
LD A,08H ; 8
RET NZ
;
BIT 5,E
LD A,04H ; 4
RET NZ
;
LD A,0CH ; 12
RET
;
; -----------------
J$76E0:
LD A,02H ; 2
SCF
RET
;--------------------
; Subroutine setup for disk operation
;
;--------------------
C.76E4:
PUSH AF
PUSH BC
PUSH HL
CALL GETWRK ;Gets Work Area in IX and HL
;
POP HL
POP BC
POP AF
CP 02H ; 2
JR C,J$76F5
;
J$76F1:
LD A,0CH ; 12
SCF
RET
;
; -----------------
J$76F5:
PUSH AF
LD A,C
CP 0F8H
JR NC,J$76FE
;
POP AF
JR J$76F1
;
; -----------------
J$76FE:
EX (SP),HL
PUSH HL
PUSH BC
BIT 1,C
LD C,E
LD B,D
LD DE,8
JR NZ,J$770B
INC DE
J$770B:
CALL DIV16
LD A,L
INC A
LD (IX+9),A
LD L,C
POP BC
POP AF
LD H,A
LD A,(IX+5)
DEC A
JR Z,J.7723
LD A,H
OR A
JR Z,J.7723
LD A,11H
J.7723:
ADD A,1CH
PUSH AF
AND 01H ; 1
BIT 0,C
JR Z,J.7732
SRL L
JR NC,J.7732
OR 04H ; 4
J.7732:
LD (IX+6),A
PUSH AF
SRL A
SRL A
AND 01H ; 1
LD (IX+8),A
POP AF
LD D,A
LD A,C
RRCA
RRCA
AND 0C0H
OR D
LD D,A
POP AF
LD (FDCLDOL),A ; PC AT mode, motor on, dma enabled, select drive
LD (IX+12),A
LD A,(IX)
AND A
LD (IX),0FFH
JR NZ,J$7763
;
PUSH HL
LD HL,0
J$775D:
DEC HL
LD A,L
OR H
JR NZ,J$775D
;
POP HL
J$7763:
LD C,L
LD (IX+7),L
LD A,(IX+5)
DEC A
JR Z,J$777A
;
LD A,(IX+3)
CP H
JR Z,J.779B
;
XOR 01H ; 1
LD (IX+3),A
JR J.779B
;
; -----------------
J$777A:
LD A,H
CP (IX+4)
LD (IX+4),A
JR Z,J.779B
;
PUSH IX
PUSH DE
PUSH BC
LD A,(IX+24) ; saved slotid on page 0
CALL SSLTID ; Set slotid on page 0
CALL PROMPT
POP BC
POP DE
POP IX
DI
LD A,(IX+23)
CALL SSLTID ; Set slotid on page 0