Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/rb1773.asm @ 2940:824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Deny the disk destroying write with the narrower heads of the 96 tpi drive
when the user has placed a 48 tpi disk in the 96 tpi drive so he can read
it. Double stepping the drive is then done automatically so as to stay in
mechanical synch with the tracks on a 48 tpi disk. But that, until now, did
not make the disk read-only, this patch does that.
Patch by Gene Heskett and Robert Gault.
author | Robert Gault <robert.gault@att.net> |
---|---|
date | Sat, 25 Jan 2014 23:20:06 +0100 |
parents | 011a5f26e9da |
children | 4446149f7ea9 |
rev | line source |
---|---|
1746 | 1 ******************************************************************** |
2 * rb1773 - Western Digital 1773 Disk Controller Driver | |
3 * | |
4 * $Id$ | |
5 * | |
6 * This driver has been tested with the following controllers: | |
7 * - Tandy FD-502 "shortie" disk controller | |
8 * - Disto Super Controller I | |
9 * - Disto Super Controller II | |
10 * | |
11 * This driver can also be assembled to support the no-halt feature of | |
12 * the Disto Super Controller II. | |
13 * | |
14 * | |
15 * A lot of references to **.CYL or <u00B6 using 16 bit registers can be | |
16 * changed to 8 bit registers with a +1 offset, since track #'s >255 are | |
17 * ignored | |
18 * | |
19 * NOTE: 512 bytes is reserved as a physical sector buffer. Any reads/ | |
20 * writes are done from this buffer to the controller. Copies of the 256 | |
21 * byte chunk needed are done by a block memory move | |
22 * | |
23 * | |
24 ********** DISTO SUPER CONTROLLER II NOTES ********** | |
25 * | |
26 * SCII 0=standard controller 1=Disto Super Controller II | |
27 * SCIIALT 0=Normal I/O register 1=Alternative registers; See below | |
28 * | |
29 * Disto Super Controller II Registers: | |
30 * | |
31 * $FF74 RW.Dat --- R/W Buffer data #1 | |
32 * $FF75 mirror of $FF74 | |
33 * $FF76 RW.Ctrl --- Write D0 = 0 FDC Write Op #2 | |
34 * = 1 FDC Read Op #2 | |
35 * D1 = 0 Normal Mode | |
36 * = 1 Buffered I/O Mode | |
37 * D2 = 0 Normal NMI | |
38 * = 1 Masked NMI | |
39 * D3 = 0 No FIRQ (Masked) | |
40 * = 1 Enabled FIRQ | |
41 * Read D7 = FDC INT Status (Inverted) | |
42 * $FF77 mirror of $FF76 | |
43 * #1: any write to $FF76-$FF77 clears Buffer counter | |
44 * #2: in buffered mode only | |
45 * | |
46 * Alternate port is at $FF58-$FF5B in case of hardware conflicts. | |
47 * | |
48 * Edt/Rev YYYY/MM/DD Modified by | |
49 * Comment | |
50 * ------------------------------------------------------------------ | |
51 * 11 1993/05/12 ??? | |
52 * Special opts for TC9 to slow controller reads and writes TFM's | |
53 * between sector buffers & in drive table init/copies. | |
54 * Changed software timing loop (drive spin-up) to F$Sleep for 32 ticks | |
55 * Shrunk (slowed slightly) error returns | |
56 * Added blobstop code | |
57 * | |
58 * 11r1 2003/09/03 Boisy G. Pitre | |
59 * Added code to sense if HW is present or not and return error if not. | |
60 * | |
61 * 1r0 2004/05/20 Boisy G. Pitre | |
62 * Restarted edition due to name change; backported to Level 1 | |
63 * | |
64 * 2004/06/01 Robert Gault | |
65 * Added code to obtain an SCII driver, at least for the Sleep mode. It | |
66 * would be quite difficult and probably not worth the effort to permit | |
67 * selection of both Sleep and IRQ SCII drivers. However, both normal | |
68 * and Alt SCII I/O registers are supported. | |
69 * | |
70 * Cleaned up some errors in the last version of rb1773. | |
71 * | |
72 * 2004/07/11 Robert Gault | |
73 * Corrected the error handling code for read & write to separate SCII errors | |
74 * from OS-9 errors. Changed drive test from compare #4 to compare #N.Drives to | |
75 * permit up to 6 drives using alternate table. | |
76 * | |
77 * 2005/01/27 Robert Gault | |
78 * Separated the sector write and format write loops so that the CPU clock | |
79 * can be slowed down during formats. This "corrects" problems some hardware | |
80 * have with the current NitrOS-9 during formats. | |
1785 | 81 * |
82 * 1r1 2005/04/07 Boisy G. Pitre | |
83 * We now save the contents of D.NMI (Level 2) or D.XNMI (Level 1) before | |
84 * overwriting them, and then restore the original values at term time. | |
2226
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
85 * |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
86 * 2009/03/19 Robert Gault |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
87 * Removed slow down hack from format and write sector but left code just in case. |
2940
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
88 * |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
89 * 2013/12/16 Robert Gault and Gene Heskett |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
90 * Added two new flags, flagWP flagFMT, to prevent disk damage by Writes where |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
91 * the drive head width does not match the disk track density. |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
92 * flagWP <>0 write protects; flagFMT <>0 overrules flagWP so that a Format can |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
93 * write to a disk. |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
94 * A descriptor that does not match your drive can still cause Writes to disks that |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
95 * could possibly cause disk corruption. This cannot be prevented. |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
96 * |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
97 * When LSN0 is read using a 3.5" drive, most of the checks of density, sides, etc. |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
98 * are bypassed as not needed. |
1746 | 99 |
100 nam rb1773 | |
101 ttl Western Digital 1773 Disk Controller Driver | |
102 | |
103 * These lines needed if assembling with on a Color computer. | |
104 *SCII set 1 * 0=not present 1=present | |
105 *SCIIALT set 1 * 0=normal address 1=alternate | |
106 SCIIHACK set 0 * 0=stock model 1=512 byte buffer | |
107 *H6309 set 1 | |
108 *LEVEL set 2 | |
109 * These lines needed if not using latest os9def files. | |
110 *TkPerSec set 60 | |
111 *DPort set $FF40 | |
112 | |
113 * This should be changed for NitrOS9 project to "use defsfile" | |
114 IFP1 | |
115 use defsfile | |
116 ENDC | |
117 | |
118 tylg set Drivr+Objct | |
119 atrv set ReEnt+rev | |
1785 | 120 rev set $01 |
1746 | 121 edition set 1 |
122 | |
123 * Configuration Settings | |
124 N.Drives equ 4 number of drives to support | |
125 TC9 equ 0 Set to 1 for TC9 special slowdowns | |
126 PRECOMP equ 0 Set to 1 to turn on write precompensation | |
127 | |
128 * Disto Super Controller defs | |
129 IFEQ SCIIALT | |
130 RW.Dat equ $FF74 | |
131 RW.Ctrl equ $FF76 | |
132 ELSE | |
133 RW.Dat equ $FF58 | |
134 RW.Ctrl equ $FF5A | |
135 ENDC | |
136 | |
137 | |
138 * WD-17X3 Definitions | |
139 CtrlReg equ $00 Control register for Tandy controllers; not part of WD | |
140 WD_Cmd equ $08 | |
141 WD_Stat equ WD_Cmd | |
142 WD_Trak equ $09 | |
143 WD_Sect equ $0A | |
144 WD_Data equ $0B | |
145 | |
146 * WD-17X3 Commands | |
147 S$Read equ $80 Read sector | |
148 S$Format equ $A0 Format track | |
149 S$FrcInt equ $D0 Force interrupt | |
150 | |
151 * Control Register Definitions | |
152 C_HALT equ %10000000 Halt line to CPU is active when set | |
153 C_SIDSEL equ %01000000 Side select (0 = front side, 1 = back side) | |
154 C_DBLDNS equ %00100000 Density (0 = single, 1 = double) | |
155 C_WPRCMP equ %00010000 Write precompensation (0 = off, 1 = on) | |
156 C_MOTOR equ %00001000 Drive motor (0 = off, 1 = on) | |
157 C_DRV2 equ %00000100 Drive 2 selected when set | |
158 C_DRV1 equ %00000010 Drive 1 selected when set | |
159 C_DRV0 equ %00000001 Drive 0 selected when set | |
160 | |
161 mod eom,name,tylg,atrv,start,size | |
162 | |
163 u0000 rmb DRVBEG+(DRVMEM*N.Drives) | |
164 lastdrv rmb 2 Last drive table accessed (ptr) | |
165 ctlimg rmb 1 Bit mask for control reg (drive #, side,etc) | |
166 u00AA rmb 1 drive change flag | |
167 sectbuf rmb 2 Ptr to 512 byte sector buffer | |
168 currside rmb 1 head flag; 0=front 1 = back | |
169 u00AE rmb 1 LSB of LSN | |
170 IFGT Level-1 | |
171 FBlock rmb 2 block number for format | |
172 FTask rmb 1 task number for format | |
1785 | 173 NMISave rmb 2 |
174 ELSE | |
1807
321957ee26e8
Changed NMISave to be rmb 3 for Level 1 -- Thanks Phill for pointing out the error.
boisy
parents:
1793
diff
changeset
|
175 NMISave rmb 3 |
1746 | 176 ENDC |
177 VIRQPak rmb 2 Vi.Cnt word for VIRQ | |
178 u00B3 rmb 2 Vi.Rst word for VIRQ | |
179 u00B5 rmb 1 Vi.Stat byte for VIRQ (drive motor timeout) | |
180 loglsn rmb 2 OS9's logical sector # | |
181 * Removed next line and added two new ones. RG | |
182 * PCDOS does not ask driver for any info. | |
183 * physlsn rmb 2 PCDOS (512 byte sector) # | |
184 flag512 rmb 1 PCDOS (512 byte sector) 0=no, 1=yes | |
185 flagform rmb 1 SCII format flag | |
2940
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
186 flagWP rmb 1 write protection <>0 |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
187 flagFMT rmb 1 format flag |
1746 | 188 size equ . |
189 | |
190 fcb DIR.+SHARE.+PEXEC.+PWRIT.+PREAD.+EXEC.+UPDAT. | |
191 | |
192 name fcs /rb1773/ | |
193 fcb edition | |
194 | |
195 VIRQCnt fdb TkPerSec*4 Initial count for VIRQ (4 seconds) | |
196 | |
197 IRQPkt fcb $00 Normal bits (flip byte) | |
198 fcb $01 Bit 1 is interrupt request flag (Mask byte) | |
199 fcb 10 Priority byte | |
200 | |
201 * Init | |
202 * | |
203 * Entry: | |
204 * Y = address of device descriptor | |
205 * U = address of device memory area | |
206 * | |
207 * Exit: | |
208 * CC = carry set on error | |
209 * B = error code | |
210 * | |
211 * New code added 09/03/2003 by Boisy G. Pitre | |
212 * Write a pattern to $FF4B and read it back to verify that the hardware | |
213 * does exist. | |
214 Init equ * | |
215 * Two new lines for SCII. RG | |
216 IFNE SCII | |
217 clr RW.Ctrl clear SCII control register | |
218 clr flagform,u clear SCII format flag | |
219 ENDC | |
2940
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
220 clr flagWP,u |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
221 clr flagFMT,u |
1746 | 222 ldx V.PORT,u get Base port address |
223 lda WD_Data,x get byte at FDC Data register | |
224 coma complement it to modify it | |
225 sta WD_Data,x write it | |
226 clrb | |
227 Init2 decb delay a bit... | |
228 bmi Init2 | |
229 suba WD_Data,x read it back | |
230 lbne NoHW if not zero, we didn't read what we wrote | |
231 ** | |
232 IFEQ Level-1 | |
233 clr >D.DskTmr flag drive motor as not running | |
234 ELSE | |
235 clr <D.MotOn flag drive motor as not running | |
236 ENDC | |
237 leax WD_Stat,x point to Status/Command register | |
238 lda #S$FrcInt "Force Interrupt" command | |
239 sta ,x send to FDC | |
240 lbsr FDCDelay time delay for ~ 108 cycles | |
241 lda ,x eat status register | |
242 ldd #$FF*256+N.Drives 'invalid' value & # of drives | |
243 leax DRVBEG,u point to start of drive tables | |
244 l1 sta ,x DD.TOT MSB to bogus value | |
245 sta <V.TRAK,x init current track # to bogus value | |
246 leax <DRVMEM,x point to next drive table | |
247 decb done all drives yet? | |
248 bne l1 no, init them all | |
1785 | 249 *** Fix on 04/06/2005: we now save the contents of D.NMI (Level 2) |
250 *** or D.XNMI (Level 1) before overwriting them. | |
1746 | 251 IFGT Level-1 |
1785 | 252 ldx >D.NMI |
253 stx NMISave,u | |
254 leax >NMISvc,pc point to NMI service routine | |
255 stx >D.NMI install as system NMI | |
1746 | 256 ELSE |
1785 | 257 ldx >D.XNMI |
258 stx NMISave,u | |
259 lda >D.XNMI+2 | |
260 sta NMISave+2,u | |
261 leax >NMISvc,pc point to NMI service routine | |
1746 | 262 stx >D.XNMI+1 NMI jump vector operand |
263 lda #$7E JMP code | |
264 sta >D.XNMI NMI jump vector opcode | |
265 ENDC | |
266 pshs y save device dsc. ptr | |
267 leay >u00B5,u point to Vi.Stat in VIRQ packet | |
268 tfr y,d make it the status register ptr for IRQ | |
269 leay >IRQSvc,pc point to IRQ service routine | |
270 leax >IRQPkt,pc point to IRQ packet | |
271 os9 F$IRQ install IRQ | |
272 puls y Get back device dsc. ptr | |
273 bcs Return If we can't install IRQ, exit | |
274 ldd #512 Request 512 byte sector buffer | |
275 pshs u Preserve device mem ptr | |
276 os9 F$SRqMem Request sector buffer | |
277 tfr u,x Move ptr to sector buffer to x | |
278 puls u Restore device mem ptr | |
279 bcs Return If error, exit with it | |
280 stx >sectbuf,u Save ptr to sector buffer | |
281 | |
282 * GetStat | |
283 * | |
284 * Entry: | |
285 * A = function code | |
286 * Y = address of path descriptor | |
287 * U = address of device memory area | |
288 * | |
289 * Exit: | |
290 * CC = carry set on error | |
291 * B = error code | |
292 * | |
293 GetStat clrb no GetStt calls - return, no error, ignore | |
294 Return rts | |
295 | |
296 * Term | |
297 * | |
298 * Entry: | |
299 * U = address of device memory area | |
300 * | |
301 * Exit: | |
302 * CC = carry set on error | |
303 * B = error code | |
304 * | |
305 Term leay >VIRQPak,u Point to VIRQ packet | |
306 IFNE H6309 | |
307 tfr 0,x "remove" | |
308 ELSE | |
309 ldx #$0000 | |
310 ENDC | |
311 os9 F$VIRQ Remove VIRQ | |
312 IFNE H6309 | |
313 tfr 0,x "remove" | |
314 ELSE | |
315 ldx #$0000 | |
316 ENDC | |
317 leay >IRQSvc,pc point to IRQ service routine | |
318 os9 F$IRQ Remove IRQ | |
1785 | 319 *** Fix: we now restore original D.NMI (Level 2) or D.XNMI (Level 1) |
320 *** before overwriting them. | |
321 IFGT Level-1 | |
322 ldx NMISave,u | |
323 stx >D.NMI | |
324 ELSE | |
325 ldx NMISave,u | |
326 stx >D.XNMI | |
327 lda NMISave+2,u | |
328 sta >D.XNMI+2 | |
329 ENDC | |
330 *** | |
1746 | 331 pshs u Save device mem ptr |
332 ldu >sectbuf,u Get pointer to sector buffer | |
333 ldd #512 Return sector buffer memory | |
334 os9 F$SRtMem | |
335 puls u Restore device mem ptr | |
336 clr >DPort+CtrlReg shut off drive motors | |
337 IFEQ Level-1 | |
338 clr >D.DskTmr Clear out drive motor timeout flag | |
339 ELSE | |
340 clr <D.MotOn Clear out drive motor timeout flag | |
341 ENDC | |
342 ex rts return | |
343 | |
344 * Check if 512 byte sector conversion needed | |
345 * Entry: B:X=LSN | |
346 * U=Static mem ptr | |
347 * Y=Path dsc. ptr | |
348 * Exit: X=New LSN (same as original for 256 byte sectors, 1/2 of original | |
349 * for 512 byte sectors | |
350 * regD changed | |
351 Chk512 equ * | |
352 clr flag512,u set to 256 byte sector | |
353 stx >loglsn,u save OS9 LSN | |
354 lda <PD.TYP,y get device type from path dsc. | |
355 anda #%00000100 mask out all but 512 byte sector flag | |
356 bne Log2Phys 512 byte sectors, go process | |
357 rts RG | |
358 | |
359 * 512 byte sector processing goes here | |
360 * regB should be saved and not just cleared at end because there is | |
361 * a subsequent tst for the msb of lsn. The test is pointless if B | |
362 * is changed. | |
363 Log2Phys pshs b save MSB of LSN; new RG | |
364 * Minor inefficiencies here that I have changed, RG | |
365 tfr x,d | |
366 IFNE H6309 | |
367 lsrd | |
368 ELSE | |
369 lsra | |
370 rorb | |
371 ENDC | |
372 tfr d,x move new LSN back to regX | |
373 * New line for stock SCII controller with 256 max no-halt. | |
374 inc flag512,u set to 512 byte sector | |
375 puls b,pc regB will be tested later for >0 | |
376 | |
377 start lbra Init | |
378 bra Read | |
379 nop | |
380 lbra Write | |
381 bra GetStat | |
382 nop | |
383 lbra SetStat | |
384 bra Term | |
385 nop | |
386 | |
387 * Read | |
388 * | |
389 * Entry: | |
390 * B = MSB of LSN | |
391 * X = LSB of LSN | |
392 * Y = address of path descriptor | |
393 * U = address of device memory area | |
394 * | |
395 * Exit: | |
396 * CC = carry set on error | |
397 * B = error code | |
398 * | |
399 Read bsr Chk512 go check for 512 byte sector/adjust if needed | |
400 lda #%10010001 error flags (see Disto SCII source) | |
401 pshs x preserve sector # | |
402 lbsr ReadWithRetry go read the sector | |
403 puls x restore sector # | |
404 bcs ex if error, exit | |
405 pshs y,x save path dsc ptr & LSN | |
406 leax ,x LSN0?, ie. tstx | |
407 bne L012D no, go calculate normally | |
408 puls y,x yes, restore path dsc ptr & LSN | |
409 lda <PD.TYP,y get type from path dsc. | |
410 bita #TYP.NSF standard OS-9 format? | |
411 beq L00F0 yes, skip ahead | |
412 lbsr MakeDTEntry else make a drive table entry | |
413 pshs y,x save path dsc ptr | |
414 bra L012D | |
415 | |
416 * LSN0, standard OS-9 format - copy part of LSN0 into drive table | |
417 L00F0 ldx >sectbuf,u Get ptr to sector buffer | |
418 pshs y,x Preserve path dsc. ptr & sector buffer ptr | |
419 ldy >lastdrv,u Get last drive table accessed ptr | |
420 IFNE H6309 | |
421 ldw #DD.SIZ # bytes to copy from new LSN0 to drive table | |
422 tfm x+,y+ Copy them | |
423 ELSE | |
424 ldb #DD.SIZ | |
425 L00F0Lp lda ,x+ | |
426 sta ,y+ | |
427 decb | |
428 bne L00F0Lp | |
429 ENDC | |
430 ldy >lastdrv,u Get drive table ptr back | |
431 lda <DD.FMT,y Get format for disk in drive | |
432 ldy 2,s restore path descriptor pointer | |
2940
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
433 * !!!!!!! Most of these tests are pointless with a 3.5" drive RG |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
434 ldb <PD.TYP,y Get path's type settings RG |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
435 bitb #1 test for 3.5" drive |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
436 bne L0128 skip rest of tests if 3.5" drive |
1746 | 437 ldb <PD.DNS,y Get path's density settings |
438 bita #FMT.DNS Disk in drive double density? | |
439 beq L0115 No, all drives can read single, skip ahead | |
440 bitb #DNS.MFM Can our path dsc. handle double density? | |
441 beq erbtyp No, illegal | |
2939
011a5f26e9da
rb1773: Fix comments about 135 TPI versus 48 or 96
Robert Gault <robert.gault@att.net>
parents:
2938
diff
changeset
|
442 L0115 bita #FMT.TDNS Is new disk 96tpi? |
011a5f26e9da
rb1773: Fix comments about 135 TPI versus 48 or 96
Robert Gault <robert.gault@att.net>
parents:
2938
diff
changeset
|
443 beq L011D No, all drives handle 48/135 tpi, so skip ahead |
2940
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
444 sta flagWP,u set write protection |
2939
011a5f26e9da
rb1773: Fix comments about 135 TPI versus 48 or 96
Robert Gault <robert.gault@att.net>
parents:
2938
diff
changeset
|
445 bitb #DNS.DTD Can path dsc. handle 96 tpi? |
011a5f26e9da
rb1773: Fix comments about 135 TPI versus 48 or 96
Robert Gault <robert.gault@att.net>
parents:
2938
diff
changeset
|
446 beq erbtyp No, illegal format |
2940
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
447 clr flagWP,u clear write protection since disk and descriptor match |
1746 | 448 L011D bita #FMT.SIDE Is new disk double sided? |
449 beq L0128 No, all drives handle single sided, we're done | |
450 lda <PD.SID,y Get # sides path dsc. can handle | |
451 suba #2 sides higher or equal to 2? | |
452 blo erbtyp Yes, exit with illegal type error | |
453 L0128 clrb No error | |
454 * LSN's other than 0 come straight here | |
455 L012D ldy 2,s Get path dsc. ptr back?? | |
456 ldx PD.BUF,y Get path dsc. buffer ptr | |
457 * lda <PD.TYP,y Get path dsc. disk type, RG | |
458 ldy >sectbuf,u Get ptr to sector buffer | |
459 IFNE H6309 | |
460 ldw #256 OS9 sector size (even if physical was 512) | |
461 ENDC | |
462 * anda #%00000100 Mask out all but 512 byte sector flag, RG | |
463 * Next replaces the two lines removed, RG | |
464 tst flag512,u Is it a 512 byte sector? | |
465 beq L014B If normal sector, just copy it | |
466 ldd >loglsn,u Get OS9's LSN (twice of the 'real' 512 sector) | |
467 andb #$01 Mask out all but odd/even sector indicator | |
468 beq L014B Even, use 1st half of 512 byte sector | |
469 IFNE H6309 | |
470 addr w,y Odd, bump sector buffer ptr to 2nd half | |
471 ELSE | |
472 leay 256,y | |
473 ENDC | |
474 L014B equ * | |
475 IFNE H6309 | |
476 tfm y+,x+ Copy from physical sector buffer to PD buffer | |
477 puls pc,y,x restore path dsc & sector buffer ptrs & return | |
478 ELSE | |
479 pshs d | |
480 clrb | |
481 L014BLp lda ,y+ | |
482 sta ,x+ | |
483 decb | |
484 bne L014BLp | |
485 puls pc,y,x,d restore path dsc & sector buffer ptrs & return | |
486 ENDC | |
487 | |
488 erbtyp comb | |
489 ldb #E$BTyp Error - wrong type error | |
490 puls pc,y,x | |
491 | |
492 ********************** | |
493 * Read error - retry handler | |
494 Retry | |
495 bcc ReadWithRetry Normal retry, try reading again | |
496 pshs x,d Preserve regs | |
497 lbsr sktrk0 Seek to track 0 (attempt to recalibrate) | |
498 puls x,d Restore regs & try reading again | |
499 | |
500 | |
501 * Read With Retry: Do read with retries | |
502 * | |
503 * ENTER reg B,X=working lsn on disk | |
504 * Y=path descriptor | |
505 * U=driver data | |
506 * A=retry sequence mix of read & seek track 0 | |
507 * EXIT X,Y,U preserved; D,CC changed | |
508 * B=error if any | |
509 * CC=error flag | |
510 ReadWithRetry | |
511 pshs x,d Preserve regs | |
512 bsr ReadSector Go read sector | |
513 puls x,d Restore regs (A=retry flags) | |
514 lbcc L01D7 No error, return | |
515 lsra Shift retry flags | |
516 bne Retry Still more retries allowed, go do them | |
517 * otherwise, final try before we give up | |
518 ReadSector | |
519 lbsr L02AC Do double-step/precomp etc. if needed, seek | |
520 lbcs L01D7 Error somewhere, exit with it | |
521 L0176 ldx >sectbuf,u Get physical sector buffer ptr | |
522 ldb #S$Read Read sector command | |
523 IFNE SCII | |
524 * If SCII not hacked for 512 byte no-halt, must use halt for 512b sectors RG | |
525 IFEQ SCIIHACK | |
526 clra SCII normal mode, normal NMI | |
527 tst flag512,u SCII must use halt mode for 512 byte sectors | |
528 bne L0176B | |
529 ENDC | |
530 lda #7 SCII read, buffered mode, masked NMI | |
531 bsr L01A1B send commands and wait | |
532 * New lines needed because the SCII has error other than OS-9 errors. RG | |
533 bcs ngood | |
534 * This now becomes a subroutine call. RG | |
535 * lbcs L03AF get the errors | |
536 lbsr L03AF get the errors | |
537 bcc good | |
538 ngood rts | |
539 | |
540 good pshs y | |
541 IFNE H6309 | |
542 ldw #256 set counter | |
543 ldy #RW.DAT source of data | |
544 IFNE SCIIHACK | |
545 tst flag512,u | |
546 beq sc2rlp | |
547 ldw #512 bump up counter to 512 byte sector | |
548 ENDC | |
549 * Don't use tfm if no halt important else need orcc #$50 for tfm | |
550 * If an interrupt occurs during a tfm transfer, the SCII counter | |
551 * will update but the tfm will repeat a byte and lose track. | |
552 * If orcc #$50 used, then key presses may be lost even with no-halt | |
553 * mode. | |
554 sc2rlp lda ,y read byte from SCII | |
555 sta ,x+ transfer byte to system buffer | |
556 decw update counter | |
557 bne sc2rlp | |
558 ELSE | |
559 ldy #256 | |
560 IFNE SCIIHACK | |
561 tst flag512,u | |
562 beq sc2rlp | |
563 ldy #512 | |
564 ENDC | |
565 sc2rlp lda >RW.DAT | |
566 sta ,x+ | |
567 leay -1,y | |
568 bne sc2rlp | |
569 ENDC | |
570 clrb no errors | |
571 puls y,pc | |
572 ENDC | |
573 | |
574 L0176B bsr L01A1 Send to controller & time delay to let it settle | |
575 *** Next few lines are commented out for blobstop patches | |
576 *L0180 bita >DPort+WD_Stat check status register | |
577 * bne L0197 eat it & start reading sector | |
578 * leay -1,y bump timeout timer down | |
579 * bne L0180 keep trying until it reaches 0 or sector read | |
580 * lda >ctlimg,u get current drive settings | |
581 * ora #C_MOTOR turn drive motor on | |
582 * sta >DPort+CtrlReg send to controller | |
583 * puls y,cc restore regs | |
584 * lbra L03E0 exit with Read Error | |
585 *** Blobstop fixes | |
586 stb >DPort+CtrlReg send B to control register | |
587 nop allow HALT to take effect | |
588 nop | |
589 bra L0197 and a bit more time | |
590 * Read loop - exited with NMI | |
591 * Entry: X=ptr to sector buffer | |
592 * B=Control register settings | |
593 L0197 lda >DPort+WD_Data get byte from controller | |
594 sta ,x+ store into sector buffer | |
595 * stb >DPort+CtrlReg drive info | |
596 nop -- blobstop fix | |
597 bra L0197 Keep reading until sector done | |
598 | |
599 L01A1 orcc #IntMasks Shut off IRQ & FIRQ | |
600 * No-halt mode must enter here, skipping IRQ shutoff. | |
601 L01A1B stb >DPort+WD_Cmd Send command | |
602 IFNE SCII | |
603 sta >RW.Ctrl tell SCII what to do | |
604 ENDC | |
605 L01A1C ldb #C_DBLDNS+C_MOTOR Double density & motor on | |
606 orb >ctlimg,u Merge with current drive settings | |
607 stb >DPort+CtrlReg Send to control register | |
608 IFNE SCII | |
609 tst flagform,u Format uses halt mode | |
610 bne s512 | |
611 IFEQ SCIIHACK | |
612 tst flag512,u SCII uses halt with 512 byte sectors | |
613 beq s256 | |
614 ELSE | |
615 bra s256 | |
616 ENDC | |
617 ENDC | |
618 s512 ldb #C_HALT+C_DBLDNS+C_MOTOR Enable halt, double density & motor on | |
619 orb >ctlimg,u Merge that with current drive settings | |
620 lbra FDCDelay Time delay to wait for command to settle | |
621 IFNE SCII | |
622 s256 ldb #4 normal mode, NMI masked | |
623 lda #255 time out slices | |
624 pshs a,x | |
625 SC2tmr1 ldx #1 | |
626 lbsr Delay sleep or timer | |
627 dec ,s count | |
628 beq tmout | |
629 tst >RW.Ctrl check status | |
630 bmi SC2tmr1 loop on not ready | |
631 stb RW.Ctrl clear SCII but don't generate NMI | |
632 clrb | |
633 puls a,x,pc | |
634 tmout stb RW.Ctrl clear SCII buffer counter | |
635 lda #$D0 force interrupt | |
636 sta DPort+WD_Cmd | |
637 comb set carry | |
638 puls a,x,pc | |
639 ENDC | |
640 | |
641 * Delay for some number of ticks (1 tick = 1/60 second). | |
642 * For a hard delay, we need to delay for 14833 cycles at .89MHz or | |
643 * 29666 cycles at 1.78MHz | |
644 * Entry: X = number of ticks to delay | |
645 Delay | |
646 pshs d [5+] [4+] | |
647 IFGT Level-1 | |
648 ldd <D.Proc [6] [5] process pointer | |
649 cmpd <D.SysPrc [is it the system? | |
650 beq hardloop [3] [3] | |
651 os9 F$Sleep if not system then sleep | |
652 puls d,pc [5+] [4+] | |
653 ENDC | |
654 hardloop tfr x,d we want X in A,B | |
655 l1@ equ * | |
656 IFEQ Level-1 | |
657 ldx #1482/2 [3] [3] | |
658 ELSE | |
659 IFNE H6309 | |
660 ldx #1854 [3] [3] | |
661 ELSE | |
662 ldx #1482 [3] [3] | |
663 ENDC | |
664 ENDC | |
665 l2@ nop [2] [1] | |
666 nop [2] [1] | |
667 nop [2] [1] | |
668 leax -1,x [4+] [4+] | |
669 bne l2@ [3] [3] | |
670 subd #$0001 [4] [3] | |
671 bne l1@ [3] [3] | |
672 puls d,pc [5+] [4+] | |
673 | |
674 * Write | |
675 * Entry: | |
676 * B = MSB of LSN | |
677 * X = LSB of LSN | |
678 * Y = address of path descriptor | |
679 * U = address of device memory area | |
680 * | |
681 * Exit: | |
682 * CC = carry set on error | |
683 * B = error code | |
684 * | |
2940
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
685 Write tst flagFMT,u |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
686 bne w3 if a format write normally and clear flags |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
687 tst flagWP,u |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
688 beq w2 continue if not a mismatch |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
689 ldb #E$BTyp |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
690 lbra L03E0 report bad type if forced WP |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
691 w3 clr flagFMT,u |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
692 clr flagWP,u |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
693 w2 lbsr Chk512 go adjust LSN for 512 byte sector if needed |
1746 | 694 * Next line was lda #%1001001 which was an error RG |
695 lda #%10010001 retry flags for I/O errors (see Disto SCII source) | |
696 L01C4 pshs x,d preserve LSN, retries | |
697 bsr L01E8 go write the sector | |
698 puls x,d restore LSN, retries | |
699 bcs L01D8 error writing, go to write retry handler | |
700 tst <PD.VFY,y no error, do we want physical verify? | |
701 bne L01D6 no, exit without error | |
702 lbsr verify go re-read & verify 64 out of 256 bytes | |
703 bcs L01D8 error on verify, go to write retry handler | |
704 L01D6 clrb no error & return | |
705 L01D7 rts | |
706 | |
707 * Write error retry handler | |
708 L01D8 lsra Shift retry flags | |
709 lbeq L03AF Too many retries, exit with error | |
710 bcc L01C4 Normal retry, attemp to re-write sector | |
711 pshs x,d Preserve flags & sector # | |
712 lbsr sktrk0 Seek to track 0 (attempt to recalibrate) | |
713 puls x,d Restore flags & sector # | |
714 bra L01C4 Try re-writing now | |
715 | |
716 * 512 byte sector write here | |
717 L01E8 lbsr L02AC Go do double-step/write precomp if needed | |
718 bcs L01D7 Error, exit with it | |
719 pshs y,d Preserve path dsc. ptr & LSN | |
720 * Since I have modified chk512 the next two lines are replaced. RG | |
721 * lda <PD.TYP,y Get device type | |
722 * anda #%00000100 512 byte sector? | |
723 tst flag512,u go if 256 byte sectors | |
724 beq L020D Not 512 then skip ahead | |
725 lbsr L0176 Go read the sector in | |
726 ldd >loglsn,u Get OS9 LSN | |
727 andb #$01 Even or odd? | |
728 beq L020D Even, skip ahead | |
729 ldx >sectbuf,u Get physical sector buffer ptr | |
730 leax >$0100,x Point to 2nd half | |
731 bra L0211 Copy caller's buffer to 2nd half of sector | |
732 | |
733 L020D ldx >sectbuf,u Get physical sector buffer ptr | |
734 | |
735 L0211 ldy PD.BUF,y Get path dsc. buffer ptr | |
736 IFNE H6309 | |
737 ldw #256 Copy write buffer to sector buffer | |
738 tfm y+,x+ | |
739 ELSE | |
740 clrb | |
741 L0211Lp lda ,y+ | |
742 sta ,x+ | |
743 decb | |
744 bne L0211Lp | |
745 ENDC | |
746 puls y,d Get path dsc. ptr & LSN back | |
747 ldx >sectbuf,u Get physical sector buffer ptr again | |
748 * See read routine for explanation of SCII code. RG | |
749 IFNE SCII | |
750 IFEQ SCIIHACK | |
751 clra SCII write, normal mode & NMI | |
752 tst flag512,u | |
753 bne wr512 | |
754 ENDC | |
755 lda #4 SCII normal mode, masked NMI | |
756 sta RW.Ctrl tell SCII | |
757 pshs y | |
758 ldy #RW.Dat Send data to SCII RAM buffer | |
759 IFNE H6309 | |
760 ldw #256 | |
761 tst flag512,u | |
762 beq wrbuf | |
763 ldw #512 | |
764 wrbuf lda ,x+ | |
765 sta ,y | |
766 decw | |
767 bne wrbuf | |
768 ELSE | |
769 ldy #256 | |
770 tst flag512,u | |
771 beq wrbuf | |
772 ldy #512 | |
773 wrbuf lda ,x+ | |
774 sta >RW.DAT | |
775 leay -1,y | |
776 bne wrbuf | |
777 ENDC | |
778 puls y | |
779 ldb #$A0 Write sector command | |
780 lda #6 SCII masked NMI, buffered mode, write | |
781 * See Read section for explanation of error changes below. RG | |
782 * lbra L01A1B send command to controller | |
783 lbsr L01A1B send command to controller | |
784 bcs wngood SCII error, then go | |
785 lbra L03AF check for OS-9 errors | |
786 wngood rts | |
787 ENDC | |
788 wr512 ldb #S$Format | |
789 | |
790 * Format track comes here with B=$F0 (write track) | |
791 * as does write sector with B=$A0 | |
792 *WrTrk pshs y,cc Preserve path dsc. ptr & CC | |
793 WrTrk lbsr L01A1 Send command to controller (including delay) | |
794 *** Commented out for blobstop fixes | |
795 *L0229 bita >DPort+WD_Stat Controller done yet? | |
796 * bne L0240 Yes, go write sector out | |
797 * leay -$01,y No, bump wait counter | |
798 * bne L0229 Still more tries, continue | |
799 * lda >ctlimg,u Get current drive control register settings | |
800 * ora #C_MOTOR Drive motor on (but drive select off) | |
801 * sta >DPort+CtrlReg Send to controller | |
802 * puls y,cc Restore regs | |
803 * lbra L03AF Check for errors from status register | |
804 | |
805 *** added blobstop | |
806 IFGT Level-1 | |
807 lda FBlock+1,u get the block number for format | |
808 beq L0230 if not format, don't do anything | |
809 sta >$FFA1 otherwise map the block in | |
810 * added delay for for MMU line settling. RG 2005/1/23 | |
811 nop | |
812 nop | |
813 ENDC | |
814 L0230 stb >DPort+CtrlReg send data to control register | |
815 * These lines converted to separate sector writes from format. RG | |
2226
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
816 * Removed slow down but left code just in case. RG |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
817 nop |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
818 nop |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
819 * cmpb #$F0 if format, then |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
820 * beq L0240b go to special loop |
1746 | 821 bra L0240 wait a bit for HALT to enable |
822 | |
823 * Write sector routine (Entry: B= drive/side select) (NMI will break out) | |
2226
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
824 * Was part of timing change mentioned above. Removed RG |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
825 L0240 nop --- wait a bit more |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
826 lda ,x+ Get byte from write buffer |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
827 *L0240 lda ,x+ Get byte from write buffer |
1746 | 828 sta >DPort+WD_Data Save to FDC's data register |
829 * EAT 2 CYCLES: TC9 ONLY (TRY 1 CYCLE AND SEE HOW IT WORKS) | |
830 IFEQ TC9-1 | |
831 nop | |
832 nop | |
2226
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
833 * ELSE |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
834 * See above. RG Now removed. |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
835 * nop |
1746 | 836 ENDC |
2226
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
837 * No blob change. |
1746 | 838 * stb >DPort+CtrlReg Set up to read next byte |
839 bra L0240 Go read it | |
2226
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
840 * Special loop for format slows CPU clock. RG Now removed. |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
841 *L0240b |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
842 * IFGT Level-1 |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
843 * sta >$FFD8 |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
844 * ENDC |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
845 *L0240c lda ,x+ |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
846 * sta >DPort+WD_Data |
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
847 * bra L0240c |
1746 | 848 * NMI routine |
849 NMISvc leas R$Size,s Eat register stack | |
2226
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
850 * Added to compensate above change in format loop. RG Now removed. |
1790 | 851 IFGT Level-1 |
2226
3af8e9655158
The clock slow down routine for rb1773 write track has been deactivated. The code is still present in case it needs to be reinstated. RG
robertgault
parents:
2194
diff
changeset
|
852 * sta >$FFD9 |
1746 | 853 ldx <D.SysDAT get pointer to system DAT image |
854 lda 3,x get block number 1 | |
855 sta >$FFA1 map it back into memory | |
856 ENDC | |
857 andcc #^IntMasks turn IRQ's on again | |
858 ldb >DPort+WD_Stat Get status register | |
859 IFNE SCII | |
860 clr RW.Ctrl Clear SCII command register | |
861 ENDC | |
862 bitb #%00000100 Did we lose data in the transfer? | |
863 lbeq L03B2 Otherwise, check for drive errors | |
864 comb -- blobstop error code | |
865 ldb #E$DevBsy -- device busy | |
866 rts -- and exit | |
867 | |
868 verify pshs x,d | |
869 * Removed unneeded code. Data never sent to PD.BUF anyway so there is | |
870 * no need to redirect the PD.BUF pointer. RG | |
871 * ldx PD.BUF,y Get write buffer ptr | |
872 * pshs x Preserve it | |
873 * ldx >sectbuf,u Get sector buffer ptr | |
874 * stx PD.BUF,y Save as write buffer ptr | |
875 * ldx 4,s | |
876 lbsr ReadSector Go read sector we just wrote | |
877 * puls x Get original write buffer ptr | |
878 * stx PD.BUF,y Restore path dsc. version | |
879 bcs L02A3 If error reading, exit with it | |
880 ldx PD.BUF,y Get system buffer ptr | |
881 pshs u,y Preserve device mem, path dsc. ptrs | |
882 * See change in chk512 routine. RG | |
883 * ldb <PD.TYP,y Get type from path dsc. | |
884 ldy >sectbuf,u Get sector buffer ptr | |
885 * andb #%00000100 512 byte sector? | |
886 tst flag512,u 512 byte sector? | |
887 beq L028D No, skip ahead | |
888 ldd >loglsn,u Get OS9's sector # | |
889 andb #$01 Odd/even sector? | |
890 beq L028D Even; compare first half | |
891 leay >$0100,y Odd, compare second half | |
892 L028D tfr x,u Move PD.BUF ptr to U (since cmpx is faster) | |
893 clra check all 256 bytes | |
894 L028F ldx ,u++ Get 2 bytes from original write buffer | |
895 cmpx ,y++ Same as corresponding bytes in re-read sector? | |
896 bne vfybad No, error & return | |
897 inca | |
898 bpl L028F No, continue | |
899 bra L02A1 carry is clear by virtue of last cmpx | |
900 vfybad comb set carry | |
901 L02A1 puls u,y | |
902 L02A3 puls pc,x,d | |
903 | |
904 L02A5 pshs a Save Caller's track # | |
905 ldb <V.TRAK,x Get track # drive is currently on | |
906 bra L02E9 Go save it to controller & continue | |
907 | |
908 L02AC lbsr L0376 Go set up controller for drive, spin motor up | |
909 bsr L032B Get track/sector # (A=Trk, B=Sector) | |
910 pshs a Save track # | |
911 lda >currside,u Get side 1/2 flag | |
912 beq L02C4 Side 1, skip ahead | |
913 lda >ctlimg,u Get control register settings | |
914 ora #C_SIDSEL Set side 2 (drive 3) select | |
915 sta >ctlimg,u Save it back | |
916 L02C4 lda <PD.TYP,y Get drive type settings | |
917 bita #%00000010 ??? (Base 0/1 for sector #?) | |
918 bne L02CC Skip ahead | |
919 incb Bump sector # up by 1 | |
2940
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
920 *!!!!!!!!!!!!!!!!!!!!!critical section on double-stepping |
1746 | 921 L02CC stb >DPort+WD_Sect Save into Sector register |
922 ldx >lastdrv,u Get last drive table accessed | |
923 ldb <V.TRAK,x Get current track # on device | |
2940
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
924 lda <PD.TYP,y Get drive type |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
925 bita #1 3.5" drive |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
926 beq L02CCb go if not 3.5" RG |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
927 lda ,s recover track # |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
928 clr flagWP,u |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
929 bra L02E9 |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
930 L02CCb lda <DD.FMT,x Get drive format specs; actually disk format specs RG |
2939
011a5f26e9da
rb1773: Fix comments about 135 TPI versus 48 or 96
Robert Gault <robert.gault@att.net>
parents:
2938
diff
changeset
|
931 lsra Shift track & bit densities to match PD; bit0 is MF or MFM |
011a5f26e9da
rb1773: Fix comments about 135 TPI versus 48 or 96
Robert Gault <robert.gault@att.net>
parents:
2938
diff
changeset
|
932 eora <PD.DNS,y Check for differences with path densities; bit0 is MF MFM, bit1 is 96tpi |
011a5f26e9da
rb1773: Fix comments about 135 TPI versus 48 or 96
Robert Gault <robert.gault@att.net>
parents:
2938
diff
changeset
|
933 anda #%00000010 Keep only 96 tpi |
1746 | 934 pshs a Save differences |
935 lda 1,s Get track # back | |
936 tst ,s+ Are tpi's different? | |
937 beq L02E9 No, continue normally | |
938 lsla Yes, multiply track # by 2 ('double-step') | |
939 lslb Multiply current track # by 2 ('double-step') | |
2940
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
940 clr flagWP,u |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
941 inc flagWP,u if double-step then prevent future writes |
1746 | 942 L02E9 stb >DPort+WD_Trak Save current track # onto controller |
943 | |
944 * From here to the line before L0307 is for write precomp, but is not used. | |
945 * Unless write precomp is needed, all of this is useless | |
946 * I think most (if not all) drives do NOT need precomp | |
947 IFEQ PRECOMP-1 | |
948 ldb #21 Pre-comp track # | |
949 pshs b Save it | |
950 ldb <PD.DNS,y Get current density settings | |
951 andb #%00000010 Just want to check track density | |
952 beq L02F9 48 tpi, skip ahead | |
953 lsl ,s Multiply pre-comp value by 2 ('double-step') | |
954 L02F9 cmpa ,s+ Is track # high enough to warrant precomp? | |
955 bls L0307 No, continue normally | |
956 ldb >ctlimg,u | |
2938
c91cd2a9b22a
rb1773: Fix typo in write precompensation code
Robert Gault <robert.gault@att.net>
parents:
2226
diff
changeset
|
957 orb #C_WPRCMP Turn on Write precomp |
1746 | 958 stb >ctlimg,u |
959 ENDC | |
960 | |
961 L0307 tst >u00AA,u ??? Get flag (same drive flag?) | |
962 bne L0314 no, skip ahead | |
963 ldb ,s get track # | |
964 cmpb <V.TRAK,x same as current track on this drive? | |
965 beq L0321 yes, skip ahead | |
966 L0314 sta >DPort+WD_Data save track # to data register | |
967 ldb <PD.STP,y get stepping rate | |
968 andb #%00000011 just keep usable settings (6-30 ms) | |
969 eorb #%00011011 set proper bits for controller | |
970 lbsr L03E4 send command to controller & time delay | |
971 L0321 puls a get track # back | |
972 sta <V.TRAK,x save as current track # | |
973 sta >DPort+WD_Trak save to controller | |
974 clrb no error & return | |
975 rts | |
976 | |
977 * Entry: B:X LSN | |
978 * Exit: A=Track # | |
979 * B=Sector # | |
980 * <currside=00 = Head 1 , $FF = Head 2 | |
981 L032B tstb Sector # > 65535? | |
982 bne L033F Yes, illegal for floppy | |
983 tfr x,d Move sector # to D | |
984 leax ,x LSN 0? ie. "tstx" | |
985 beq L0371 Yes, exit this routine | |
986 ldx >lastdrv,u Get previous drive table ptr | |
987 cmpd DD.TOT+1,x Within range of drive spec? | |
988 blo L0343 Yes, go calculate track/sector #'s | |
989 L033F comb Exit with Bad sector # error | |
990 ldb #E$Sect | |
991 rts | |
992 | |
993 * Calculate track/sector #'s? | |
994 * These two sections could be combined into one with a final | |
995 * test of DD.FMT. Then currside can be set and regA can be lsra | |
996 * as needed. RG | |
997 L0343 stb >u00AE,u Save LSB of LSN | |
998 clr ,-s Clear track # on stack | |
999 ldb <DD.FMT,x Get drive format | |
1000 lsrb Shift out # sides into carry | |
1001 ldb >u00AE,u Get LSB of LSN again | |
1002 bcc L0367 Single sided drive, skip ahead | |
1003 bra L035D Double sided drive, skip ahead | |
1004 * Double sided drive handling here | |
1005 L0355 com >currside,u Odd/even sector track flag | |
1006 bne L035D Odd, so don't bump track # up | |
1007 inc ,s Bump up track # | |
1008 | |
1009 * Changed this to more effient code. RG | |
1010 *L035D subb DD.TKS,x Subtract # sectors/track | |
1011 * sbca #$00 | |
1012 L035D subd DD.SPT,x | |
1013 bcc L0355 Still more sectors left, continue | |
1014 bra L036D Wrapped, skip ahead | |
1015 * Single sided drive handling here | |
1016 L0365 inc ,s Bump track # up | |
1017 | |
1018 * See above. RG | |
1019 *L0367 subb DD.TKS,x Subtract # sectors/track | |
1020 * sbca #$00 | |
1021 L0367 subd DD.SPT,x | |
1022 bcc L0365 Still more, go bump the track up | |
1023 * Next possible because upper limit is 256 sectors/track. RG | |
1024 L036D addb DD.TKS,x Bump sector # back up from negative value | |
1025 puls a Get the track # | |
1026 L0371 rts A=track #, B=Sector #, <currside=Odd | |
1027 | |
1028 * Drive control register bit mask table | |
1029 * May want an option here for double sided SDDD disks ex. RG | |
1030 * fcb $1 drive0 | |
1031 * fcb $2 drive1 | |
1032 * fcb $41 drive2 | |
1033 * fcb $42 drive3 | |
1034 * fcb $4 drive4 | |
1035 * fcb $44 drive5 | |
1036 | |
1037 L0372 fcb $01 Drive 0 | |
1038 fcb $02 Drive 1 | |
1039 fcb $04 Drive 2 | |
1040 fcb $40 Drive 3 / Side select | |
1041 | |
1042 * Changes regD; X,Y,U preserved | |
1043 L0376 clr >u00AA,u clear drive change flag | |
1044 chkdrv lda <PD.DRV,y Get drive # requested | |
1045 * It is possible to have more than 4 drive # so the change below. RG | |
1046 * cmpa #4 Drive 0-3? | |
1047 cmpa #N.Drives Drive 0-6 if alternate table used? | |
1048 blo L0385 Yes, continue normally | |
1049 NoHW comb Illegal drive # error | |
1050 ldb #E$Unit | |
1051 rts | |
1052 | |
1053 * Entry: A=drive #, X=LSN (Physical, not OS9 logical if PCDOS disk) | |
1054 L0385 pshs x,d Save sector #, drive # & B??? | |
1055 leax >L0372,pc Point to drive bit mask table | |
1056 ldb a,x Get bit mask for drive # we want | |
1057 stb >ctlimg,u Save mask | |
1058 leax DRVBEG,u Point to beginning of drive tables | |
1059 ldb #DRVMEM Get size of each drive table | |
1060 mul Calculate offset to drive table we want | |
1061 leax d,x Point to it | |
1062 cmpx >lastdrv,u Same as Last drive table accessed? | |
1063 beq L03A6 Yes, skip ahead | |
1064 stx >lastdrv,u Save new drive table ptr | |
1065 com >u00AA,u Set drive change flag | |
1066 L03A6 clr >currside,u Set side (head) flag to side 1 | |
1067 lbsr L04B3 Go set up VIRQ to wait for drive motor | |
1068 puls pc,x,d Restore sector #,drive #,B & return | |
1069 | |
1070 L03AF ldb >DPort+WD_Stat Get status register from FDC | |
1071 * This line needed when returning to Disk Basic but probably | |
1072 * not needed for OS-9. RG | |
1073 IFNE SCII | |
1074 clr RW.Ctrl return SCII to halt mode | |
1075 ENDC | |
1076 L03B2 bitb #%11111000 any of the error bits set? | |
1077 beq L03CA No, exit without error | |
1078 aslb Drive not ready? | |
1079 bcs L03CC Yes, use that error code | |
1080 aslb Write protect error? | |
1081 bcs L03D0 Yes, use that error code | |
1082 aslb Write fault error? | |
1083 bcs L03D4 Yes, use that error code | |
1084 aslb Sector not found? | |
1085 bcs L03D8 Yes, use Seek error code | |
1086 aslb CRC error? | |
1087 bcs L03DC Yes, use that error code | |
1088 L03CA clrb No error & return | |
1089 rts | |
1090 | |
1091 L03CC ldb #E$NotRdy not ready | |
1092 fcb $8C skip 2 bytes | |
1093 | |
1094 L03D0 ldb #E$WP write protect | |
1095 fcb $8C skip 2 bytes | |
1096 | |
1097 L03D4 ldb #E$Write write error | |
1098 fcb $8C | |
1099 | |
1100 L03D8 ldb #E$Seek seek error | |
1101 fcb $8C | |
1102 | |
1103 L03DC ldb #E$CRC CRC error | |
1104 * fcb $8C | |
1105 | |
1106 *L03E0 ldb #E$Read Read error | |
2940
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
1107 L03E0 orcc #Carry set carry |
1746 | 1108 rts |
1109 | |
1110 L03E4 bsr L0404 Send command to controller & waste some time | |
1111 L03E6 ldb >DPort+WD_Stat Check FDC status register | |
1112 bitb #$01 Is controller still busy? | |
1113 beq L0403 No, exit | |
1114 ldd >VIRQCnt,pc Get initial count value for drive motor speed | |
1115 std >VIRQPak,u Save it | |
1116 * Again, I'm trying to match Kevin Darling code. It may not be needed. RG | |
1117 pshs x | |
1118 ldx #1 Sleep remainder of slice | |
1119 lbsr Delay | |
1120 puls x | |
1121 bra L03E6 Wait for controller to finish previous command | |
1122 | |
1123 * Send command to FDC | |
1124 L03F7 lda #C_MOTOR | |
1125 * lda #%00001000 Mask in Drive motor on bit | |
1126 ora >ctlimg,u Merge in drive/side selects | |
1127 sta >DPort+CtrlReg Turn the drive motor on & select drive | |
1128 stb >DPort+WD_Cmd Save command & return | |
1129 L0403 rts | |
1130 | |
1131 L0404 bsr L03F7 Go send command to controller | |
1132 | |
1133 * This loop has been changed from nested LBSRs to timing loop. | |
1134 * People with crystal upgrades should modify the loop counter | |
1135 * to get a 58+ us delay time. MINIMUM 58us. | |
1136 FDCDelay | |
1137 pshs a 14 cycles, plus 3*loop counter | |
1138 IFEQ Level-1 | |
1139 lda #18 (only do about a 100 cycle delay for now) | |
1140 ELSE | |
1141 lda #29 (only do about a 100 cycle delay for now) | |
1142 ENDC | |
1143 L0409 deca for total ~63 us delay (123 cycles max.) | |
1144 bne L0409 | |
1145 puls a,pc restore register and exit | |
1146 | |
1147 * SetStat | |
1148 * | |
1149 * Entry: | |
1150 * A = function code | |
1151 * Y = address of path descriptor | |
1152 * U = address of device memory area | |
1153 * | |
1154 * Exit: | |
1155 * CC = carry set on error | |
1156 * B = error code | |
1157 * | |
1158 SetStat ldx PD.RGS,y Get caller's register stack ptr | |
1159 ldb R$B,x Get function code | |
1160 cmpb #SS.WTrk Write track? | |
1161 beq SSWTrk Yes, go do it | |
1162 cmpb #SS.Reset Restore head to track 0? | |
1163 lbeq sktrk0 Yes, go do it --- beq | |
1164 comb set carry for error | |
1165 ldb #E$UnkSvc return illegal service request error | |
1166 rts | |
1167 | |
2940
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
1168 SSWTrk stb flagFMT,u permit unconditional write on format |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
1169 clr flagWP,u don't protect on a format |
824019cd8744
rb1773: Make 48 TPI floppy disks readonly in 96 TPI drives
Robert Gault <robert.gault@att.net>
parents:
2939
diff
changeset
|
1170 pshs u,y preserve register stack & descriptor |
1746 | 1171 |
1172 * Level 2 Code | |
1173 IFGT Level-1 | |
1174 | |
1175 *--- new code | |
1176 ldb #1 1 block to allocate | |
1177 os9 F$AllRAM allocate some RAM | |
1178 lbcs L0489 error out if at all | |
1179 leax >FBlock,u point to 'my' DAT image | |
1180 std ,x save a copy of the block | |
1181 os9 F$ResTsk reserve a task number for the copy | |
1182 bcs FError error out | |
1183 stb 2,x save temporary task number in FTask,u | |
1184 lslb 2 bytes per entry | |
1185 ldu <D.TskIPt get task image table pointer | |
1186 stx b,u save pointer to the task's DAT image | |
1187 lsrb get the right number again | |
1188 IFNE H6309 | |
1189 tfr 0,u destination is address 0 | |
1190 ELSE | |
1191 ldu #$0000 | |
1192 ENDC | |
1193 *--- end new code | |
1194 | |
1195 ldx 2,s get pointer to descriptor | |
1196 * stu >FBlock,x | |
1197 ldx <D.Proc Get current process ptr | |
1198 lda P$Task,x Get task # for current process | |
1199 * ldb <D.SysTsk Get system task # | |
1200 ldy ,s | |
1201 ldx PD.RGS,y Get register stack ptr | |
1202 ldx R$X,x Get ptr to caller's track buffer | |
1203 ldy #$1A00 Size of track buffer | |
1204 os9 F$Move Copy from caller to temporary task | |
1205 bcs L0479 Error copying, exit | |
1206 puls u,y | |
1207 pshs u,y | |
1208 | |
1209 ENDC | |
1210 * End of Level 2 Code | |
1211 | |
1212 lbsr L0376 Go check drive #/wait for it to spin up | |
1213 ldx PD.RGS,y Get caller's register stack ptr | |
1214 ldb R$Y+1,x Get caller's side/density | |
1215 bitb #$01 Check side | |
1216 beq L0465 Side 1, skip ahead | |
1217 * I think this next line is not needed. RG | |
1218 com >currside,u * Why? This is normally used with | |
1219 * calculate track. RG | |
1220 ldb >ctlimg,u Get current control register settings | |
1221 * orb #%01000000 Mask in side 2 | |
1222 orb #C_SIDSEL Mask in side 2 | |
1223 stb >ctlimg,u Save updated control register | |
1224 L0465 lda R$U+1,x Get caller's track # | |
1225 ldx >lastdrv,u Get current drive table ptr | |
1226 lbsr L02A5 | |
1227 bcs L0489 | |
1228 ldb #$F0 Write track command | |
1229 *--- | |
1230 IFEQ Level-1 | |
1231 ldx PD.RGS,y | |
1232 ldx R$X,x | |
1233 ELSE | |
1234 ldx #$2000 start writing from block 1 | |
1235 ENDC | |
1236 | |
1237 IFNE SCII | |
1238 lda #1 normal unbuffered write | |
1239 * Next line prevents WrTrk from switching to SCII buffered mode. RG | |
1240 sta flagform,u | |
1241 ENDC | |
1242 lbsr WrTrk Go write the track | |
1243 IFNE SCII | |
1244 clr flagform,u permit no-halt mode RG | |
1245 ENDC | |
1246 | |
1247 IFGT Level-1 | |
1248 L0479 ldu 2,s | |
1249 pshs b,cc Preserve error | |
1250 ldb >FTask,u point to task | |
1251 os9 F$RelTsk release the task | |
1252 fcb $8C skip 2 bytes | |
1253 | |
1254 * format comes here when block allocation passes, but task allocation | |
1255 * gives error. So er de-allocate the block. | |
1256 FError | |
1257 pshs b,cc save error code, cc | |
1258 ldx >FBlock,u point to block | |
1259 ldb #1 1 block to return | |
1260 os9 F$DelRAM de-allocate image RAM blocks | |
1261 clr FBlock+1,u ensure that the block # in FBlock is zero. | |
1262 puls b,cc Restore error | |
1263 ENDC | |
1264 | |
1265 L0489 puls pc,u,y Restore regs & return | |
1266 | |
1267 * seek the head to track 0 | |
1268 sktrk0 lbsr chkdrv | |
1269 ldx >lastdrv,u | |
2194 | 1270 clr <V.TRAK,x |
1746 | 1271 lda #1 was 5 but that causes head banging |
1272 L0497 ldb <PD.STP,y | |
1273 andb #%00000011 Just keep usable settings (6-30 ms) | |
1274 eorb #%01001011 Set proper bits for controller | |
1275 pshs a | |
1276 lbsr L03E4 | |
1277 puls a | |
1278 deca | |
1279 bne L0497 | |
1280 ldb <PD.STP,y | |
1281 andb #%00000011 Just keep usable settings (6-30 ms) | |
1282 eorb #%00001011 Set proper bits for controller | |
1283 lbra L03E4 | |
1284 | |
1285 L04B3 pshs y,x,d Preserve regs | |
1286 ldd >VIRQCnt,pc Get VIRQ initial count value | |
1287 std >VIRQPak,u Save it | |
1288 lda >ctlimg,u ?Get drive? | |
1289 ora #C_MOTOR Turn drive motor on for that drive | |
1290 * ora #%00001000 Turn drive motor on for that drive | |
1291 sta >DPort+CtrlReg Send drive motor on command to FDC | |
1292 IFEQ Level-1 | |
1293 lda >D.DskTmr Get VIRQ flag | |
1294 ELSE | |
1295 lda <D.MotOn Get VIRQ flag | |
1296 ENDC | |
1297 bmi L04DE Not installed yet, try installing it | |
1298 bne L04E0 Drive already up to speed, exit without error | |
1299 | |
1300 * Drive motor speed timing loop (could be F$Sleep call now) (was over .5 sec) | |
1301 * 32 was not sufficient for one of my drives. RG | |
1302 ldx #50 wait for 32 ticks; increased it RG | |
1303 lbsr Delay | |
1304 | |
1305 L04DE bsr InsVIRQ Install VIRQ to wait for drive motors | |
1306 L04E0 clrb No error & return | |
1307 puls pc,y,x,d | |
1308 | |
1309 InsVIRQ lda #$01 Flag drive motor is up to speed | |
1310 IFEQ Level-1 | |
1311 sta >D.DskTmr | |
1312 ELSE | |
1313 sta <D.MotOn | |
1314 ENDC | |
1315 ldx #$0001 Install VIRQ entry | |
1316 leay >VIRQPak,u Point to packet | |
1317 clr Vi.Stat,y Reset Status byte | |
1318 ldd >VIRQCnt,pc Get initial VIRQ count value | |
1319 os9 F$VIRQ Install VIRQ | |
1320 bcc VIRQOut No error, exit | |
1321 lda #$80 Flag that VIRQ wasn't installed | |
1322 IFEQ Level-1 | |
1323 sta >D.DskTmr | |
1324 ELSE | |
1325 sta <D.MotOn | |
1326 ENDC | |
1327 VIRQOut clra | |
1328 rts | |
1329 | |
1330 * IRQ service routine for VIRQ (drive motor time) | |
1331 * Entry: U=Ptr to VIRQ memory area | |
1332 IRQSvc pshs a | |
1333 lda <D.DMAReq | |
1334 beq L0509 | |
1335 bsr InsVIRQ | |
1336 bra IRQOut | |
1337 L0509 sta >DPort+CtrlReg | |
1338 * I changed this to a clear. Don't see the point of an AND. RG | |
1339 * IFNE H6309 | |
1340 * aim #$FE,>u00B5,u | |
1341 * ELSE | |
1342 * lda u00B5,u | |
1343 * anda #$FE | |
1344 * sta u00B5,u | |
1345 * ENDC | |
1346 * fdb u00B5 --- so changes in data size won't affect anything | |
1347 clr u00B5,u | |
1348 IFEQ Level-1 | |
1349 clr >D.DskTmr | |
1350 ELSE | |
1351 clr <D.MotOn | |
1352 ENDC | |
1353 IRQOut puls pc,a | |
1354 | |
1355 * Non-OS9 formatted floppies need a drive table entry constructed | |
1356 * by hand since there is no RBF LSN0. | |
1357 * | |
1358 * Entry: X=LSN | |
1359 * Y=Path dsc. ptr | |
1360 * U=Device mem ptr | |
1361 MakeDTEntry | |
1362 pshs x Preserve Logical sector # | |
1363 ldx >lastdrv,u Get last drive table accessed ptr | |
1364 clra | |
1365 pshs x,a Save ptr & NUL byte | |
1366 IFNE H6309 | |
1367 ldw #20 Clear 20 bytes | |
1368 tfm s,x+ | |
1369 ELSE | |
1370 ldb #20 | |
1371 L051ALp clr ,x+ | |
1372 decb | |
1373 bne L051ALp | |
1374 ENDC | |
1375 puls x,a Eat NUL & get back drive table ptr | |
1376 ldb <PD.CYL+1,y Get # cylinders on drive (ignores high byte) | |
1377 lda <PD.SID,y Get # sides | |
1378 mul Calculate # tracks on drive (1 per head) | |
1379 IFNE H6309 | |
1380 decd Adjust to ignore track 0 | |
1381 ELSE | |
1382 subd #$0001 | |
1383 ENDC | |
1384 lda <PD.SCT+1,y Get # sectors/track | |
1385 sta DD.TKS,x Save in drive table | |
1386 sta <DD.SPT+1,x Save in other copy in drive table | |
1387 mul Calculate # sectors on drive (minus track 0) | |
1388 pshs x Preserve drive table ptr | |
1389 tfr d,x Move # sectors on drive to X | |
1390 lda <PD.T0S+1,y Get # sectors on track 0 | |
1391 leax a,x Add that many sectors to total | |
1392 lda <PD.TYP,y Get device type settings | |
1393 anda #%00000100 Mask out all but 512 byte sector flag | |
1394 beq L0550 Not 512 byte sector, skip ahead | |
1395 IFNE H6309 | |
1396 addr x,x Multiply by 2 (convert to 256 byte OS9 sectors) | |
1397 ELSE | |
1398 tfr x,d | |
1399 leax d,x | |
1400 ENDC | |
1401 L0550 tfr x,d Move # sectors to D | |
1402 puls x Get back drive table ptr | |
1403 std DD.TOT+1,x Save # sectors allowed on drive | |
1404 lda #UPDAT.+EXEC. Owner's read/write/exec attributes | |
1405 sta DD.ATT,x Set attributes for disk | |
2939
011a5f26e9da
rb1773: Fix comments about 135 TPI versus 48 or 96
Robert Gault <robert.gault@att.net>
parents:
2938
diff
changeset
|
1406 lda <PD.DNS,y Get density settings this should be bit1 96tpi bit0 MF MFM normally is 1 |
1746 | 1407 lsla Shift for DD.FMT |
1408 pshs a Preserve it a sec | |
1409 lda <PD.SID,y Get # sides | |
1410 deca Adjust to base 0 | |
1411 ora ,s+ Merge with density settings | |
2939
011a5f26e9da
rb1773: Fix comments about 135 TPI versus 48 or 96
Robert Gault <robert.gault@att.net>
parents:
2938
diff
changeset
|
1412 sta <DD.FMT,x Save in device table; normally becomes %11 or 3 |
1746 | 1413 clrb No error? |
1414 puls pc,x Restore original LSN & return | |
1415 | |
1416 emod | |
1417 eom equ * | |
1418 end | |
1419 |