-
Notifications
You must be signed in to change notification settings - Fork 82
/
hdinitdr
154 lines (154 loc) · 3.53 KB
/
hdinitdr
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
;*************************************
;
; INITIALIZE A DRIVE <HD>
;
;*************************************
INITDR
JSR CLDCHN ;CLOSE ALL CHANNELS THIS DR
LDA DRVNUM ;DRIVE
ASL A ;TIMES 2
TAX ;*
LDA REALID,X ;MAKE CURNT = REAL
STA DSKID,X ;*
LDA REALID+1,X ;*
STA DSKID+1,X ;*
JSR TRDY ;TEST IF READY
BEQ INITDA ;BR IF RDY
LDA #DNRDY ;DEVICE NOT READY
JSR CMDERR ;*
INITDA
JSR HDCSUD ;GET RDY FOR BUMP
ORA #BUMP ;DO RESTORE
JSR DOIT ;*
JSR HDISU ;SET UP BAM POINTER
JSR HDORV ;READ VOLUME LABEL
;
; GET ADDR OF FIRST BAM
;
LDY #HDBAM1 ;PT TO 1ST BAM PTR
JSR HDNXB ;LINK TO NEXT
;
; GET ADDR OF FIRST DIRECTORY SECTOR
;
LDY #HDDB1 ;PT TO FIRST PTR
LDA (HDBMP),Y ;GET SECTOR ADDR
STA HDDS,X ;SAVE IN MEMORY
INY ;BUMP TO TRACK
LDA (HDBMP),Y ;GET TRACK
STA HDDT,X ;SAVE IT TOO
;
; GET NUMBER OF SURFACES & OPTIONS
;
LDY #HDOPTN ;PT TO BYTE
LDA (HDBMP),Y ;GET OPTN
STA HDNSUR,X ;SAVE IN MEM
;
; SAVE DISK ID IN MEMORY
;
LDA DRVNUM ;DRIVE * 2
ASL A ;*
TAX ;*
LDY #HDUVID ;USER VOLUME ID
LDA (HDBMP),Y ;GET IT
STA DSKID,X ;SAVE 1ST ID BYTE
INY ;BUMP TO NEXT
LDA (HDBMP),Y ;GET NEXT
STA DSKID+1,X ;SAVE 2ND BYTE
;
; ZERO COUNT OF # FREE SECTORS
;
LDX DRVNUM ;COUNT IS PER DRIVE
;*************************(RR)
BNE ZCNT
LDA DSKID ;SET REALID = DSKID
STA REALID ;FOR DRIVE 0 ONLY
LDA DSKID+1 ;*
STA REALID+1 ;*
ZCNT
;**************************(RR)
LDA #0 ;ZERO THEM
STA HDNFRL,X ;LOW COUNT
STA HDNFRH,X ;HIGH COUNT
;
; COPY FLAG INTO MEMORY
;
LDY #HDFLAG ;PT TO FLAG
LDA (HDBMP),Y ;GET FLAG
STA HDDFLG,X ;COPY TO MEMORY
;
; NOW READ EACH BAM
;
LDA #0 ;BEGINNING WITH ZONE 0
STA HDTMP ;*
INITD1
LDX HDTMP ;GET ZONE #
JSR HDCIND ;CALC INDEX
;
; SAVE BAM ADDR IN TABLE
;
LDA SECTOR ;SAVE ADDR OF THIS BAM
STA HDZAS,X ;*
LDA TRACK ;*
STA HDZAT,X ;*
JSR HDORB ;READ IT
;
; SAVE LAST CYLINDER FOR BAM IN MEMORY
;
LDY #HDLCYL ;GET LAST CYL FOR BAM
LDA (HDBMP),Y ;*
LDY DRVNUM ;CHK WHICH DRIVE
BNE INITD2 ;BR IF FLOPPY
LDY HDTMP ;TABLE IS BY ZONE
STA HDZLOC,Y ;ZONE LOCATOR TABLE
BNE INITD3 ;BRA
INITD2
LDY HDTMP ;GET ZONE NUMBER
STA HDFZLC,Y ;FLOPPY ZONE LOCATOR
INITD3
;
; COUNT # FREE SECTORS THIS BAM
;
LDX DRVNUM
LDY #HDBIT1 ;PT TO FIRST BYTE
INITD5
LDA #8 ;8 BITS PER BYTE
STA HDTMP1 ;COUNTER
LDA (HDBMP),Y ;GET BYTE
INITD6
ASL A ;SHIFT & COUNT BITS
BCC INITD7 ;BR IF NOT SET
INC HDNFRL,X ;BUMP LOW COUNT
BNE INITD7
INC HDNFRH,X ;BUMP HIGH COUNT
INITD7
DEC HDTMP1 ;COUNT DOWN #BITS
BNE INITD6 ;LOOP TILL BYTE DONE
INY ;BUMP TO NEXT BYTE
BNE INITD5 ;BR TILL BAM BITS COUNTED
;
; LINK TO NEXT BAM
;
INC HDTMP ;BUMP ZONE POINTER
LDY #HDNXTB ;POINT TO NEXT BAM ADDR
JSR HDNXB ;LINK TO IT
LDA SECTOR ;CHECK IF END OF BAMS
CMP #255 ;*
BNE INITD1 ;BR IF NOT END OF LIST
;
; ALL BAMS READ
;
; NOW MARK BAM FULL SWITCHES = NOT FULL
;
LDX DRVNUM ;DRIVE #
LDA HDTMP ;GET NUMBER OF ZONES ACTUAL
STA HDNZA,X ;SAVE FOR LATTER USE
LDY #HDNZ ;#OF ZONES TO CLEAR
LDA #0 ;CLEAR = 00
INITD4
STA HDZFUL,X ;CLEAR A SWITCH
INX ;BUMP TO NEXT
INX ;*
DEY ;CHK IF DONE
BNE INITD4 ;BR IF NOT DONE
RTS ;EXIT TO CALLER
.END