-
Notifications
You must be signed in to change notification settings - Fork 82
/
lccfmt2.src
293 lines (192 loc) · 3.54 KB
/
lccfmt2.src
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
.page
.subttl lccfmt2
ds08 lda #$66 ;min block size 282*5/4 -256=85
sta dtrck
ldx sectr ;total bytes= min*#secors
ldy #0
tya
ds10 clc ;min*#sectors
adc dtrck
bcc ds14
iny
ds14 iny
dex
bne ds10
eor #$ff ;get 2s comp
sec
adc #0
clc
adc tral+1
bcs ds15
dec tral
ds15 tax
tya
eor #$ff
sec
adc #0
clc
adc tral
bpl ds17
lda #tobig ;not enough space
jmp fmterr
ds17 tay
txa
ldx #0
ds20 sec
sbc sectr
bcs ds22
dey
bmi ds30
ds22 inx
bne ds20
ds30 stx dtrck
;-----rom05-bc---09/12/84------------- 1541-II FAB- back to original value ---
cpx #gap2 ;test for min size
;-----------------------------------------------------------------------------
bcs ds32
lda #tosmal ;gap2 to small
jmp fmterr
ds32 clc
adc sectr
sta remdr ;get remaider size
; create header images
lda #0
sta sect
ldy #0
ldx drive
mak10 lda hbid ;hbid cs s t id id 0f 0f
sta buff0,y
iny
iny ;skip checksum
lda sect ;store sector #
sta buff0,y
iny
lda ftnum ;store track #
sta buff0,y
iny
lda dskid+1,x ;store id low
sta buff0,y
iny
lda dskid,x ;store id hi
sta buff0,y
iny
lda #$0f ;store gap1 bytes
sta buff0,y
iny
sta buff0,y
iny
lda #0 ;create checksum
eor buff0-6,y
eor buff0-5,y
eor buff0-4,y
eor buff0-3,y
sta buff0-7,y ;store checksum
inc sect ;goto next sector
lda sect ;test if done yet
cmp sectr
bcc mak10 ;more to do
tya ;save block size
pha
; create data block of zero
inx ;.x=0
txa
crtdat sta buff2,x
inx
bne crtdat
; convert header block to gcr
lda #>buff0
sta bufpnt+1 ;point at buffer
jsr fbtog ;convert to gcr with no bid char
pla ;restore block size
tay ;move buffer up 79 bytes
dey ;for i=n-1 to 0:mem{i+69}:=mem{i}:next
jsr movup ;move buf0 up 69 bytes
jsr movovr ;move ovrbuf up to buffer
; convert data block to gcr write image
;
; leave it in ovrbuf and buffer
lda #>buff2 ;point at buffer
sta bufpnt+1
jsr chkblk ;get block checksum
sta chksum
jsr bingcr
; start the format now
;
; write out sync header gap1 data block
lda #0 ;init counter
sta hdrpnt
;<><><><><><><><><><><><><><><><><><><><><><><><><><><><>
jsr jclear ;*rom ds 09/05/85*, clear disk
; jsr clear
;<><><><><><><><><><><><><><><><><><><><><><><><><><><><>
wrtsyn lda #$ff ;write sync
sta data2
ldx #numsyn ;write 4 sync
wrts10 bvc *
clv
dex
bne wrts10
ldx #10 ;write out header
ldy hdrpnt
wrts20 bvc *
clv
lda buff0,y ;get header data
sta data2
iny
dex
bne wrts20
;* write out gap1
ldx #gap1-2 ;write gcr bytes
wrts30 bvc *
clv
lda #$55
sta data2
dex
bne wrts30
;* write out data block
lda #$ff ;write data block sync
ldx #numsyn
dbsync bvc *
clv
sta data2
dex
bne dbsync
ldx #256-topwrt ;write out ovrbuf
wrts40 bvc *
clv
lda ovrbuf,x
sta data2
inx
bne wrts40
ldy #0
wrts50 bvc *
clv
lda (bufpnt),y
sta data2
iny
bne wrts50
lda #$55 ;write gap2(dtrck)
ldx dtrck
wgp2 bvc *
clv
sta data2
dex
bne wgp2
; ldx #20 ;write erase trail gap
;wgp3 bvc *
; clv
; dex
; bne wgp3
lda hdrpnt ;advance header pointer
clc
adc #10
sta hdrpnt
; done writing sector
dec sect ;go to next on
bne wrtsyn ;more to do
bvc * ;wait for last one to write
clv
bvc *
clv
jsr kill ;goto read mode
; .end