-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathnew
280 lines (280 loc) · 4.96 KB
/
new
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
.PAGE 'NEW'
;
; NEW: INITIALIZE A DISK, DISK IS
; SOFT-SECTORED, BIT AVAIL. MAP,
; DIRECTORY, & 1ST BLOCK ARE ALL INITED
;
NEW
JSR ONEDRV
LDA FILDRV ; SET UP DRIVE #
BPL N101
LDA #BADFN
JMP CMDERR
N101
AND #1
STA DRVNUM
JSR SETLDS
JSR SETBMP
LDA DRVNUM
ASL A
TAX
LDY FILTBL+1 ; GET DISK ID
CPY CMDSIZ ; IS THIS NEW OR CLEAR?
BEQ N108 ; END OF CMD STRING
LDA CMDBUF,Y
STA DSKID,X ; STORE IN PROPER DRIVE
LDA CMDBUF+1,Y ; Y = 0
STA DSKID+1,X
JSR CLRCHN
JSR FORMAT ; FORMAT THE DRIVE
JMP N110
N108
JSR INITDR
N110
JSR NEWMAP ; CREATE A NEW BAM
LDY #0 ; USE BUFFER NUMBER 0
LDA BUFIND,Y ; GET BUFFER INDEX
STA IP+1
LDA #0
STA IP ; SET IP TO BUFFER
JSR MRKBAM ; MARK THE BAMS USED
JSR MRKBTS ; MARK THE BTS AND CONTENTS USED
LDA #0
STA TRACK
LDA #1
STA SECTOR
JSR USEDTS ; MARK TRACK, SECTOR AND HEAD
JSR MAKDIR ; CREATE A DIRECTORY
JSR SET000 ; SET UP TRACK, SECTOR AND HEAD
JSR SCRBAM
JSR NF05 ; COUNT BLOCKS FREE
JMP ENDCMD ; DONE!!!
;
; TRANSFER THE DIRECTORY HEADER
;
TRNHDR
LDA JOBNUM
TAY
ASL A
TAX
LDA #6
STA BUFTAB,X
LDX FILTBL
LDA #27
JSR TRNAME ; TRANSFER CMD BUF TO BUF0
LDY #$12
LDA DRVNUM ; SET UP CURRENT I.D.
ASL A
TAX
LDA DSKID,X
STA (DIRBUF),Y
INY
LDA DSKID+1,X
STA (DIRBUF),Y
INY
INY
LDA #DOSVER+$30
STA (DIRBUF),Y
INY
LDA VERNUM ; SHOW VER #
STA (DIRBUF),Y
RTS
;
; MARK THE BTS SECTORS USED ALONG WITH
; THE BTS CONTENTS
;
MRKBTS
LDX DRVNUM
LDA BTSTRK,X ; START OF BTS (TRACK)
STA TRACK
LDA BTSSEC,X ; START OF BTS (SECTOR)
STA SECTOR
JSR NXTBTS ; MARK THIS SECTOR, READ NEXT ONE
MRKBT1
LDA (IP),Y
CMP #$FF ; NEW TRACK OR END MARKER
BEQ MRKBT3
STA SECTOR
TYA
PHA
JSR USEDTS ; MARK THE SECTOR USED
PLA
TAY
MRKBT2
INY
BNE MRKBT1
JSR BTSLNK ; READ NEXT LINK
JMP MRKBT1
MRKBT3
INY
BNE MRKBT4
JSR BTSLNK ; READ NEXT LINK
MRKBT4
LDA (IP),Y
CMP #$FF ; ALREADY HAVE ONE $FF
BEQ MRKBT5 ; NOW HAVE TWO, DONE
STA TRACK
JMP MRKBT2
MRKBT5
RTS
;
; MARK AND READ THE NEXT BTS
;
NXTBTS
JSR USEDTS ; MARK THIS LINK USED
LDA #0
STA JOBNUM ; USE JOB NUMBER 0
JSR SETH
JSR DOREAD ; READ THE NEXT BTS
LDY #2
RTS
;
; GET, MARK AND READ THE NEXT BTS
;
BTSLNK
LDA TRACK
PHA ; CURRENT TRACK
LDA SECTOR
PHA ; CURRENT SECTOR
LDA (IP),Y ; .Y = 0
CMP #$FF ; AT THE END?
BEQ BTSLN1 ; YES
STA TRACK
INY
LDA (IP),Y
STA SECTOR
JSR NXTBTS ; MARK AND READ NEXT BTS
PLA
STA SECTOR ; RESTORE CURRENT SECTOR
PLA
STA TRACK ; RESTORE CURRENT TRACK
RTS
BTSLN1
PLA ; ON ENTRY SECTOR
PLA ; ON ENTRY TRACK
PLA ; RETURN FOR MRKBTS
PLA ; RETURN FOR MRKBTS
RTS ; RETURN TO ORIGINAL CALLER
;
; MARK THE BAMS USED
;
MRKBAM
LDX DRVNUM
LDA BAMTRK,X ; START OF BAM (TRACK)
STA TRACK
LDA BAMSEC,X ; START OF BAM (SECTOR)
MRKBA1
STA SECTOR
JSR USEDTS ; MARK TRACK AND SECTOR
LDA #0
STA JOBNUM
JSR SETH
JSR DOREAD ; READ THE BAM
LDY #0
LDA (IP),Y ; TRACK LINK
CMP #$FF ; DONE?
BEQ MRKBA2 ; YES
STA TRACK
INY
LDA (IP),Y ; SECTOR LINK
JMP MRKBA1
MRKBA2
RTS
;
; CREATE THE DIRECTORY
;
MAKDIR
LDA CYLLOW
LSR A ; .A = CYLLOW/2
STA TRACK
LDA #0
STA SECTOR
JSR NXT0 ; GET A DIRECTORY TRACK AND SECTOR
LDX DRVNUM
LDA TRACK
STA DSTRK,X ; START OF DIRECTORY (TRACK)
LDA SECTOR
STA DSSEC,X ; START OF DIRECTORY (SECTOR)
LDA #0
TAY
JSR SETBUF ; CLEAR THE DIRECTORY BUFFER
STA (IP),Y ; .A = 0, .Y = 0
INY
LDA #$FF
STA (IP),Y
LDA #0
STA JOBNUM
JSR SETH
JSR DOWRIT ; WRITE THE DIRECTORY
LDX DRVNUM
LDY #0
LDA DSTRK,X
STA (IP),Y
INY
LDA DSSEC,X
STA (IP),Y
JSR TRNHDR ; TRANSFER THE DIRECTORY HEADER
JSR NXT0 ; GET HEADER TRACK AND SECTOR
LDX DRVNUM
LDA TRACK
STA HSTRK,X ; START OF HEADER (TRACK)
LDA SECTOR
STA HSSEC,X ; START OF HEADER (SECTOR)
LDA #0
STA JOBNUM
JSR SETH
JMP DOWRIT ; WRITE THE HEADER (RTS)
;
; SET TRACK, SECTOR AND HEAD 0
;
SET000
LDA #0
TAY
JSR SETBUF ; CLEAR THE BUFFER
LDX DRVNUM
LDA BTSTRK,X ; START OF BTS (TRACK)
STA (IP),Y ; .Y = 0
INY
LDA BTSSEC,X ; START OF BTS (SECTOR)
STA (IP),Y
INY ; .Y = 2
LDA #0
STA (IP),Y ; MARK IDENTIFIER
INY
LDA #$FF
STA (IP),Y
INY ; .Y = 4
LDA DSTRK,X ; START OF DIRECTORY (TRACK)
STA (IP),Y
INY
LDA DSSEC,X ; START OF DIRECTORY (SECTOR)
STA (IP),Y
INY ; .Y = 6
LDA HSTRK,X ; START OF HEADER (TRACK)
STA (IP),Y
INY
LDA HSSEC,X ; START OF HEADER (SECTOR)
STA (IP),Y
INY ; .Y = 8
LDA BAMTRK,X ; START OF BAM (TRACK)
STA (IP),Y
INY
LDA BAMSEC,X ; START OF BAM (SECTOR)
STA (IP),Y
TXA
ASL A
TAX
INY ; .Y = 10
LDA DSKID,X
STA (IP),Y
INY
LDA DSKID+1,X
STA (IP),Y
LDA #1
STA SECTOR
LDA #0
STA TRACK
STA JOBNUM
JSR SETH
JMP DOWRIT ; WRITE 000 (RTS)
.END