Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/ddisk.asm @ 2152:74fb212cb659
Changelog comes from higher up
author | boisy |
---|---|
date | Wed, 14 May 2008 02:13:22 +0000 |
parents | 58bb6cac8939 |
children | c505ae3120c4 |
rev | line source |
---|---|
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
1 ******************************************************************** |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
2 * DDisk - Dragon Floppy driver |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
3 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
4 * $Id$ |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
5 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
6 * Edt/Rev YYYY/MM/DD Modified by |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
7 * Comment |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
8 * ------------------------------------------------------------------ |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
9 * - ????/??/?? |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
10 * Original Dragon Data distribution version |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
11 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
12 * Added Defines for IO ports. |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
13 * 2004/11/09, P.Harvey-Smith |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
14 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
15 * Dragon Alpha code, 2004-11-09, P.Harvey-Smith. |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
16 * I am not sure of how to disable NMI on the Alpha, it is |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
17 * simulated in software using the NMIFlag. |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
18 * |
1832 | 19 * The Dragon Alpha/Professional uses the same FDC chip as |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
20 * DragonDos, however it is mapped between FF2C and FF2F, |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
21 * also the register order is REVERSED, so command/status is at |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
22 * FF2F. |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
23 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
24 * Drive Selects, motor and write precompensation is controled |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
25 * through the IO port of an AY-8912, which itself is connected |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
26 * to a 3rd PIA mapped at FF24 to FF27, this PIA also has it's |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
27 * inturrupt lines connected to the CPU's FIRQ. |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
28 * |
1729 | 29 * 2004-11-15, P.Harvey-Smith. |
30 * Fixed bug in inturrupt handling code that was making the | |
31 * Dragon Alpha crash if a disk was accessed with no disk | |
32 * in the drive. As the Alpha is using a simulated NMI disable | |
33 * we have to ensure that the NMI enabling routine has completed | |
34 * BEFORE isuing a command to the disk controler, or if the | |
35 * inturrupt happens in the middle of the enable routine it | |
36 * causes the machine to crash ! | |
37 * | |
1734 | 38 * 2004-11-24, P.Harvey-Smith. |
39 * Fixed up so that double sided disks now work, origional | |
40 * double sided code taken from Jon Bird's pages at : | |
41 * http://www.onastick.clara.net/dragon.html and modified | |
42 * for NitrOS9. | |
1735 | 43 * |
1821 | 44 * 2004-11-27, P.Harvey-Smith. |
1735 | 45 * Reformatted with tab=8. |
46 * | |
1821 | 47 * 2005-04-22, P.Harvey-Smith. |
48 * Hopefully fixed a bug that was causing the Dragon 64 target to | |
49 * crash and burn when reading disks, this made a successfull boot | |
50 * almost imposible ! Fixed by writing disk command before writing | |
51 * disc control register, the Alpha target needs them the other way | |
52 * around. Still has a problem doing lots of retries. | |
53 * | |
54 * 2005-04-24, P.Harvey-Smith. | |
55 * Fixed constant lost data errors reading disks, again by slightly | |
56 * re-ordering the instructions in the read data loop. | |
1822
c074e97abf3d
Removed debugging code/messages, tested successfully on real Dragons
afra
parents:
1821
diff
changeset
|
57 * |
c074e97abf3d
Removed debugging code/messages, tested successfully on real Dragons
afra
parents:
1821
diff
changeset
|
58 * 2005-04-24, P.Harvey-Smith. |
c074e97abf3d
Removed debugging code/messages, tested successfully on real Dragons
afra
parents:
1821
diff
changeset
|
59 * Removed debugging code/messages. |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
60 * |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
61 * 2005-05-31, P.Harvey-Smith. |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
62 * Added ability to read, write and format standard OS-9 format disks |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
63 * including single denity, and disks with track 0 single denisity, but |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
64 * all other tracks double density. |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
65 * |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
66 * Added code to make step rates work as on the rb1773 driver, they where |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
67 * previously working back to front. |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
68 * |
1838 | 69 * 2005-06-06, P.Harvey-Smith. |
70 * Verified as working on a real Alpha, by Richard Harding. | |
71 * | |
72 * 2005-06-16, P.Harvey-Smith. | |
73 * Added NMI enable/disable code, as I know know how to enable/disable | |
74 * NMI on the Alpha, having disasembled the Alpha's OS9's ddisk. | |
75 * | |
1842 | 76 * 2005-06-17, P.Harvey-Smith. |
77 * Ok, this'll teach me to submit code before testing on the real hardware ! | |
78 * Seperated NMI disable/drive select code on alpha, as above patches | |
79 * worked fine on Mess, but not on real hardware (timing problems). | |
80 * | |
1971
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
81 * 2006-01-08, P.Harvey-Smith. |
1970 | 82 * Added support for Dragon 32, that has had a memory upgraded to 64K, |
83 * this is treated like the Dragon 64 EXCEPT that the code to manipulate | |
84 * the ACIA is not included. This is required due to the incomplete | |
85 * address decoding, writes to the non-existant ACIA would hit the PIA | |
86 * at FF00, and cause a crash. | |
1971
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
87 * |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
88 * 2006-01-08, P.Harvey-Smith. |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
89 * Since I now have a genuine Dragon 5.25" drive, found that nitros format |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
90 * fell over accessing it, this was due to the step rate not being set |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
91 * correctly in the drive recalibrate routine, I ahve corrected this to |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
92 * use the value in the descriptor. |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
93 * |
1734 | 94 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
95 nam DDisk |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
96 ttl Dragon Floppy driver |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
97 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
98 * Disassembled 02/04/21 22:37:46 by Disasm v1.6 (C) 1988 by RML |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
99 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
100 ifp1 |
2037 | 101 use defsfile |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
102 endc |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
103 |
2103 | 104 IFNE dalpha |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
105 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
106 * Dragon Alpha has a third PIA at FF24, this is used for |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
107 * Drive select / motor control, and provides FIRQ from the |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
108 * disk controler. |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
109 |
1735 | 110 DPPIADA EQU DPPIA2DA |
111 DPPIACRA EQU DPPIA2CRA | |
112 DPPIADB EQU DPPIA2DB | |
113 DPPIACRB EQU DPPIA2CRB | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
114 |
1735 | 115 PIADA EQU DPPIADA+IO ; Side A Data/DDR |
116 PIACRA EQU DPPIACRA+IO ; Side A Control. | |
117 PIADB EQU DPPIADB+IO ; Side A Data/DDR | |
118 PIACRB EQU DPPIACRB+IO ; Side A Control. | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
119 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
120 ;WD2797 Floppy disk controler, used in Alpha Note registers in reverse order ! |
1821 | 121 DPCMDREG EQU DPCmdRegA ; command/status |
122 DPTRKREG EQU DPTrkRegA ; Track register | |
123 DPSECREG EQU DPSecRegA ; Sector register | |
124 DPDATAREG EQU DPDataRegA ; Data register | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
125 |
1735 | 126 CMDREG EQU DPCMDREG+IO ; command/status |
127 TRKREG EQU DPTRKREG+IO ; Track register | |
128 SECREG EQU DPSECREG+IO ; Sector register | |
129 DATAREG EQU DPDATAREG+IO ; Data register | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
130 |
1729 | 131 ; Disk IO bitmasks |
132 | |
1735 | 133 NMIEn EQU NMIEnA |
1729 | 134 WPCEn EQU WPCEnA |
135 SDensEn EQU SDensEnA | |
136 MotorOn EQU MotorOnA | |
137 | |
1735 | 138 ; These are the bits that we know the function of on the Alpha interface |
1832 | 139 KnownBits EQU Drive0A+Drive1A+Drive2A+Drive3A+MotorOnA+SDensEnA+WPCEnA |
1735 | 140 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
141 ELSE |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
142 |
1735 | 143 DPPIADA EQU DPPIA1DA |
144 DPPIACRA EQU DPPIA1CRA | |
145 DPPIADB EQU DPPIA1DB | |
146 DPPIACRB EQU DPPIA1CRB | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
147 |
1735 | 148 PIADA EQU DPPIADA+IO ; Side A Data/DDR |
149 PIACRA EQU DPPIACRA+IO ; Side A Control. | |
150 PIADB EQU DPPIADB+IO ; Side A Data/DDR | |
151 PIACRB EQU DPPIACRB+IO ; Side A Control. | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
152 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
153 ;WD2797 Floppy disk controler, used in DragonDos. |
1735 | 154 DPCMDREG EQU DPCmdRegD ; command/status |
155 DPTRKREG EQU DPTrkRegD ; Track register | |
156 DPSECREG EQU DPSecRegD ; Sector register | |
157 DPDATAREG EQU DPDataRegD ; Data register | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
158 |
1735 | 159 CMDREG EQU DPCMDREG+IO ; command/status |
160 TRKREG EQU DPTRKREG+IO ; Track register | |
161 SECREG EQU DPSECREG+IO ; Sector register | |
162 DATAREG EQU DPDATAREG+IO ; Data register | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
163 |
1729 | 164 ; Disk IO bitmasks |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
165 |
1735 | 166 NMIEn EQU NMIEnD |
1729 | 167 WPCEn EQU WPCEnD |
168 SDensEn EQU SDensEnD | |
169 MotorOn EQU MotorOnD | |
170 | |
171 ENDC | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
172 |
1735 | 173 tylg set Drivr+Objct |
174 atrv set ReEnt+rev | |
175 rev set $00 | |
176 edition set 3 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
177 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
178 MaxDrv set 4 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
179 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
180 mod eom,name,tylg,atrv,start,size |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
181 |
1735 | 182 org DrvBeg |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
183 DrvTab RMB MaxDrv*DrvMem ; Drive tables, 1 per drive |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
184 CDrvTab rmb 2 ; Pointer to current drive table entry above |
1734 | 185 DrivSel rmb 1 ; Saved drive mask |
1735 | 186 Settle rmb 1 ; Head settle time |
1734 | 187 SavePIA0CRB rmb 1 ; Saved copy of PIA0 control reg b |
1735 | 188 SaveACIACmd rmb 1 ; Saved copy of ACIA command reg |
189 BuffPtr rmb 2 ; Buffer pointer | |
190 SideSel rmb 1 ; Side select. | |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
191 Density rmb 1 ; Density 0=double, %00001000=single D64, %00100000=single Alpha |
1735 | 192 |
1822
c074e97abf3d
Removed debugging code/messages, tested successfully on real Dragons
afra
parents:
1821
diff
changeset
|
193 DskError rmb 1 ; hardware disk error |
1821 | 194 |
1735 | 195 VIRQPak rmb 2 ; Vi.Cnt word for VIRQ |
196 u00B3 rmb 2 ; Vi.Rst word for VIRQ | |
197 u00B5 rmb 1 ; Vi.Stat byte for VIRQ (drive motor timeout) | |
198 | |
199 VIRQInstalled rmb 1 ; Is VIRQ Installed yet ? | |
1734 | 200 size equ . |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
201 |
1735 | 202 fcb $FF |
203 name equ * | |
204 fcs /DDisk/ | |
205 fcb edition | |
206 | |
207 VIRQCnt fdb TkPerSec*4 Initial count for VIRQ (4 seconds) | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
208 |
1821 | 209 start lbra Init ; Initialise Driver |
210 lbra Read ; Read sector | |
211 lbra Write ; Write sector | |
212 lbra GetStat ; Get status | |
213 lbra SetStat ; Set status | |
214 lbra Term ; Terminate device | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
215 |
1821 | 216 IRQPkt fcb $00 ; Normal bits (flip byte) |
217 fcb $01 ; Bit 1 is interrupt request flag (Mask byte) | |
218 fcb 10 ; Priority byte | |
1729 | 219 |
220 | |
1971
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
221 nop |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
222 nop |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
223 nop |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
224 lbsr ResetTrack0 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
225 * Init |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
226 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
227 * Entry: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
228 * Y = address of device descriptor |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
229 * U = address of device memory area |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
230 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
231 * Exit: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
232 * CC = carry set on error |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
233 * B = error code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
234 * |
1971
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
235 DragonDebug EQU 0 |
1734 | 236 Init |
1735 | 237 IFNE DragonDebug |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
238 pshs y ; This is here so I can find disk driver in mess |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
239 ldy #$AA55 ; by setting register breakpoint to y=$AA55 ! |
1971
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
240 sty $8000 |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
241 puls y |
1735 | 242 ENDC |
243 | |
244 clra | |
245 sta >D.DskTmr ; Zero motor timer | |
246 | |
2103 | 247 IFNE dalpha ; Turn off all drives |
1842 | 248 lbsr AlphaDskCtl |
1838 | 249 |
1842 | 250 lda #NMICA2Dis ; Set PIA2 CA2 as output & disable NMI |
1838 | 251 sta PIA2CRA |
252 | |
1735 | 253 ELSE |
254 sta >DskCtl | |
255 ENDC | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
256 |
1735 | 257 ldx #CmdReg ; Reset controler |
258 lda #FrcInt | |
259 sta ,x | |
260 lbsr Delay | |
261 lda ,x | |
262 lda #$FF | |
263 ldb #MaxDrv | |
264 leax DrvBeg,u | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
265 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
266 InitDriveData |
1735 | 267 sta DD.Tot,x ; Set total sectors = $FF |
268 sta <V.Trak,x ; Set current track = 0 | |
269 leax <DrvMem,x ; Skip to next drive | |
270 decb | |
271 bne InitDriveData | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
272 |
1735 | 273 leax >NMIService,pcr ; Setup NMI handler |
274 stx >D.XNMI+1 | |
275 lda #$7E ; $7E = JMP | |
276 sta >D.XNMI | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
277 |
1735 | 278 clr VIRQInstalled,u ;flag not installed yet |
279 | |
280 pshs y ; save device dsc. ptr | |
281 leay >u00B5,u ; point to Vi.Stat in VIRQ packet | |
282 tfr y,d ; make it the status register ptr for IRQ | |
283 leay >IRQSvc,pc ; point to IRQ service routine | |
284 leax >IRQPkt,pc ; point to IRQ packet | |
285 os9 F$IRQ ; install IRQ | |
286 puls y ; Get back device dsc. ptr | |
1729 | 287 |
1735 | 288 ldd #$0100 ; Request a page of system ram |
289 pshs u ; used to verify writes | |
290 os9 F$SRqMem | |
291 tfr u,x | |
292 puls u | |
293 bcs Return | |
294 stx >BuffPtr,u ; Save verify page pointer | |
295 clrb | |
296 Return rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
297 |
1729 | 298 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
299 * GetStat |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
300 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
301 * Entry: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
302 * A = function code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
303 * Y = address of path descriptor |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
304 * U = address of device memory area |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
305 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
306 * Exit: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
307 * CC = carry set on error |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
308 * B = error code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
309 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
310 GetStat |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
311 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
312 * Term |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
313 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
314 * Entry: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
315 * U = address of device memory area |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
316 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
317 * Exit: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
318 * CC = carry set on error |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
319 * B = error code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
320 * |
1735 | 321 Term clrb |
322 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
323 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
324 * Read |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
325 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
326 * Entry: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
327 * B = MSB of the disk's LSN |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
328 * X = LSB of the disk's LSN |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
329 * Y = address of path descriptor |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
330 * U = address of device memory area |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
331 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
332 * Exit: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
333 * CC = carry set on error |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
334 * B = error code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
335 * |
1735 | 336 Read |
337 lda #$91 ; Retry count | |
338 cmpx #$0000 ; LSN ? | |
339 bne ReadDataWithRetry ; No : Just do read, | |
340 bsr ReadDataWithRetry ; Yes : do read and copy disk params | |
341 bcs ReadDataExit | |
342 ldx PD.Buf,y | |
343 pshs y,x | |
344 ldy >CDrvTab,u | |
345 ldb #DD.Siz-1 | |
346 L0082 lda b,x | |
347 sta b,y | |
348 decb | |
349 bpl L0082 | |
350 clrb | |
351 puls pc,y,x | |
1734 | 352 ReadDataExit |
1735 | 353 rts |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
354 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
355 ; Read Retry |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
356 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
357 ReadDataRetry |
1735 | 358 bcc ReadDataWithRetry ; Retry entry point |
359 pshs x,b,a | |
360 lbsr ResetTrack0 ; Reset track 0 | |
361 puls x,b,a | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
362 |
1734 | 363 ReadDataWithRetry |
1735 | 364 pshs x,b,a ; Normal entry point |
365 bsr DoReadData | |
366 puls x,b,a | |
367 bcc ReadDataExit | |
368 lsra ; Check for retry | |
369 bne ReadDataRetry | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
370 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
371 DoReadData |
1735 | 372 lbsr SeekTrack |
373 bcs ReadDataExit | |
374 ldx PD.Buf,y ; Target address for data | |
375 pshs y,dp,cc | |
376 ldb #ReadCmnd ; Read command | |
377 bsr PrepDiskRW ; Prepare disk | |
1821 | 378 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
379 DoReadDataLoop |
1735 | 380 lda <DPPIACRB ; Is data ready ? |
381 bmi ReadDataReady ; Yes : read it | |
1896
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
382 |
1735 | 383 leay -1,y |
384 bne DoReadDataLoop | |
385 bsr RestoreSavedIO | |
386 puls y,dp,cc | |
387 lbra RetReadError ; Return read error to caller | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
388 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
389 ReadDataWait |
1735 | 390 sync ; Sync to inturrupts, wait for data |
391 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
392 ReadDataReady |
1735 | 393 lda <DPDataReg ; Read data from FDC |
394 ldb <DPPIADB ; Clear PIA inturrupt status | |
395 sta ,x+ ; save data in memory | |
396 bra ReadDataWait ; do next | |
397 | |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
398 ; |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
399 ; Prepare to do disk read/write. |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
400 ; |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
401 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
402 PrepDiskRW |
1821 | 403 |
404 clr DskError,u | |
405 | |
1896
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
406 lda #$FF ; Make DP=$FF, to make i/o faster |
1735 | 407 tfr a,dp |
1896
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
408 |
1970 | 409 ; |
410 ; Do not attempt to talk to ACIA if this machine does not have one ! | |
411 ; | |
412 | |
413 IFEQ Upgraded32 | |
1735 | 414 lda <DPAciaCmd ; Save ACIA Command reg |
415 sta >SaveACIACmd,u | |
416 anda #$FE ; Disable ACIA inturrupt | |
417 sta <DPAciaCmd | |
418 bita #$40 ; Is Tx inturrupt enabled ? | |
419 beq L00DE | |
420 L00D8 lda <DPAciaStat ; Yes, wait for Tx to complete | |
421 bita #$10 | |
422 beq L00D8 | |
1970 | 423 ENDC |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
424 |
1735 | 425 L00DE orcc #$50 ; Mask inturrupts |
426 lda <DPPia0CRB ; Save PIA0 IRQ Status | |
427 sta >SavePIA0CRB,u | |
428 lda #$34 ; Disable it. | |
429 sta <DPPia0CRB | |
1970 | 430 |
431 IFEQ Upgraded32 | |
1735 | 432 lda <DPACIACmd ; Disable ACIA Inturrupt |
433 anda #$FE | |
434 sta <DPACIACmd | |
1970 | 435 ENDC |
436 | |
1735 | 437 lda <DPPIACRB ; Set PIA to generate FIRQ on FDC DRQ |
438 ora #$03 | |
439 sta <DPPIACRB | |
440 lda <DPPIADB ; Clear any outstanding inturrupt | |
441 ldy #$FFFF | |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
442 |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
443 lda #NMIEn+MotorOn ; Enable NMI, and turn motor on |
1735 | 444 ora >DrivSel,u ; mask in drives |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
445 ora >Density,u ; mask in density |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
446 |
1735 | 447 ORB >SideSel,U ; Set up Side |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
448 |
2103 | 449 IFNE dalpha ; Turn on drives & NMI |
1735 | 450 lbsr AlphaDskCtl |
1842 | 451 stb <DPCmdReg ; issue command to controler |
452 lda #NMICA2En ; Enable NMI | |
453 sta <DPPIA2CRA | |
1735 | 454 ELSE |
1821 | 455 stb <DPCmdReg ; issue command to controler |
456 sta <DPDskCtl | |
1735 | 457 ENDC |
1729 | 458 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
459 |
1735 | 460 rts |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
461 |
1734 | 462 ; |
463 ; Restore saved iO states of peripherals. | |
464 ; | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
465 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
466 RestoreSavedIO |
2103 | 467 IFNE dalpha |
1896
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
468 lda #NMICA2Dis ; Disable NMI (Alpha) |
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
469 sta <DPPIA2CRA |
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
470 ENDC |
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
471 |
1735 | 472 lda >DrivSel,u ; Deselect drives, but leave motor on |
473 ora #MotorOn | |
1896
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
474 |
2103 | 475 IFNE dalpha ; Turn off drives & NMI |
1735 | 476 lbsr AlphaDskCtl |
477 ELSE | |
1821 | 478 sta <DPDskCtl |
1735 | 479 ENDC |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
480 |
1735 | 481 lda >SavePIA0CRB,u ; Recover PIA0 state |
482 sta <DPPia0CRB | |
1970 | 483 |
484 lda <DPPIACRB ; Disable Drive FIRQ source. | |
1735 | 485 anda #$FC |
1970 | 486 sta <DPPIACRB |
487 | |
488 IFEQ Upgraded32 | |
489 lda >SaveACIACmd,u ; Recover ACIA state | |
1735 | 490 sta <DPAciaCmd |
1970 | 491 ENDC |
492 | |
1735 | 493 rts |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
494 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
495 * Write |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
496 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
497 * Entry: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
498 * B = MSB of the disk's LSN |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
499 * X = LSB of the disk's LSN |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
500 * Y = address of path descriptor |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
501 * U = address of device memory area |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
502 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
503 * Exit: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
504 * CC = carry set on error |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
505 * B = error code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
506 * |
1735 | 507 Write lda #$91 ; Retry byte |
508 L0124 pshs x,b,a | |
509 bsr DoWrite ; Attempt to do write | |
510 puls x,b,a | |
511 bcs WriteDataRetry ; On error, retry | |
512 tst <PD.Vfy,y ; Written, should we verify ? | |
513 bne WriteDone ; no : return | |
514 lbsr WriteVerify ; yes : verify write | |
515 bcs WriteDataRetry ; verify error, retry write | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
516 WriteDone |
1735 | 517 clrb ; Return status ok |
518 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
519 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
520 WriteDataRetry |
1735 | 521 lsra ; Retry data write |
522 lbeq RetWriteError ; All retries exhausted ?, return error | |
523 bcc L0124 | |
524 pshs x,b,a ; Reset to track 0 | |
525 lbsr ResetTrack0 | |
526 puls x,b,a | |
527 bra L0124 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
528 |
1735 | 529 DoWrite lbsr SeekTrack ; Seek to correct track & sector |
530 lbcs ReadDataExit | |
531 ldx PD.Buf,y ; Get data buffer in X | |
532 pshs y,dp,cc | |
533 ldb #WritCmnd ; Write command | |
1734 | 534 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
535 WriteTrackCmd |
1735 | 536 lbsr PrepDiskRW ; Prepare for disk r/w |
1821 | 537 lda ,x+ ; get byte to write |
1735 | 538 L015A ldb <DPPIACRB ; Ready to write ? |
539 bmi WriteDataReady ; Yes, do it. | |
540 leay -1,y | |
541 bne L015A | |
542 bsr RestoreSavedIO ; Restore saved peripheral states | |
543 puls y,dp,cc | |
544 lbra RetWriteError ; Return write error | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
545 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
546 WriteDataWait |
1735 | 547 lda ,x+ ; Get next byte to write |
548 sync ; Wait for drive | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
549 WriteDataReady |
1735 | 550 sta <DPDataReg ; Write data to FDC |
551 ldb <DPPIADB ; Clear pending FDC inturrupt | |
552 bra WriteDataWait | |
553 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
554 |
1838 | 555 ; |
556 ; NMI Handler code. | |
557 ; | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
558 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
559 NMIService |
1735 | 560 leas R$Size,s ; Drop regs from stack |
561 bsr RestoreSavedIO ; Restore saved IO states | |
562 puls y,dp,cc | |
563 ldb >CmdReg | |
1821 | 564 |
565 stb DskError,u | |
566 | |
567 bitb #LostMask ; check for lost record | |
1735 | 568 lbne RetReadError ; yes : return read error |
569 lbra TestForError ; esle test for other errors | |
570 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
571 ; Verify a written sector. |
1735 | 572 WriteVerify |
573 pshs x,b,a | |
574 ldx PD.Buf,y ; Swap buffer pointers | |
575 pshs x | |
576 ldx >BuffPtr,u | |
577 stx PD.Buf,y | |
578 ldx 4,s | |
579 lbsr DoReadData ; Read data back in | |
580 puls x | |
581 stx PD.Buf,y ; Swab buffer pointers back | |
582 bcs VerifyEnd | |
583 lda #$20 | |
584 pshs u,y,a | |
585 ldy >BuffPtr,u | |
586 tfr x,u | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
587 VerifyLoop |
1735 | 588 ldx ,u ; Compare every 4th word |
589 cmpx ,y | |
590 bne VerifyErrorEnd | |
591 leau 8,u | |
592 leay 8,y ; Increment pointers | |
593 dec ,s | |
594 bne VerifyLoop | |
595 bra VerifyEndOk ; Verify succeeded. | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
596 VerifyErrorEnd |
1735 | 597 orcc #Carry ; Flag error |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
598 VerifyEndOk |
1735 | 599 puls u,y,a |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
600 VerifyEnd |
1735 | 601 puls pc,x,b,a |
1734 | 602 ; |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
603 ; Seek to a track |
1734 | 604 ; |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
605 SeekTrack |
1735 | 606 CLR >Settle,U ; default no settle |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
607 LBSR SelectDrive ; select and start correct drive |
1735 | 608 TSTB |
609 BNE E.Sect | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
610 |
1735 | 611 TFR X,D |
612 LDX >CDrvTab,U | |
613 CMPD #0 ; Skip calculation of track 0 | |
614 BEQ SeekT1 | |
615 CMPD DD.TOT+1,X ; Has an illegal LSN been | |
616 BLO SeekT2 | |
617 E.Sect COMB | |
618 LDB #E$Sect | |
619 RTS | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
620 |
1735 | 621 SeekT2 CLR ,-S ; Calculate track number |
622 SUBD PD.T0S,Y ; subtract no. of sectors in track 0 | |
623 BHS SeekT4 | |
624 ADDD PD.T0S,Y ; if -ve we are on track 0, so add back on again | |
625 BRA SeekT3 | |
626 SeekT4 INC ,S | |
627 SUBD DD.Spt,X ; sectors per track for rest of disk | |
628 BHS SeekT4 ; repeat, until -ve, incrementing track count | |
629 ADDD DD.Spt,X ; re add sectors/track to get sector number on track | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
630 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
631 ; At this point the byte on the top of the stack contains the track |
1734 | 632 ; number, and B contains the sector number on that track. |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
633 |
1735 | 634 SeekT3 PULS A ; retrieve track count |
635 LBSR SetWPC ; set write precompensation | |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
636 LBSR SetDensity ; Set density |
1735 | 637 PSHS B |
638 LDB DD.Fmt,X ; Is the media double sided ? | |
639 LSRB | |
640 BCC SingleSidedDisk ; skip if not | |
641 LDB PD.Sid,Y ; Is the drive double sided ? | |
642 DECB | |
643 BNE SetupSideMask ; yes : deal with it. | |
644 PULS B ; No then its an error | |
645 COMB | |
646 LDB #E$BTyp | |
647 RTS | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
648 |
1734 | 649 SetupSideMask |
1735 | 650 BSR SetSide ; Media & drive are double sided |
651 BRA SeekT9 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
652 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
653 SingleSidedDisk |
1735 | 654 clr >SideSel,U ; Single sided, make sure sidesel set correctly |
655 BRA SeekT9 | |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
656 |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
657 SeekT1 LBSR SetDensity ; make sure density set correctly even for LSN0 ! |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
658 |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
659 clr >SideSel,U ; make sure sidesel is always 0 if lsn0 |
1735 | 660 PSHS B |
661 SeekT9 LDB PD.Typ,Y ; Dragon and Coco disks | |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
662 BITB #TYP.CCF ; count sectors from 1 no |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
663 BEQ SeekT8 |
1735 | 664 PULS B |
1821 | 665 INCB ; so increment sector number |
1735 | 666 BRA SeekT11 |
667 SeekT8 PULS B ; Count from 0 for other types | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
668 |
1735 | 669 SeekT11 STB >SecReg ; Write sector number to controler |
670 LBSR Delay | |
671 CMPB >SecReg | |
672 BNE SeekT11 | |
1729 | 673 |
1735 | 674 SeekTS LDB <V.Trak,X ; Entry point for SS.WTrk command |
675 STB >TrkReg | |
676 TST >Settle,U ; If settle has been flagged then wait for settle | |
677 BNE SeekT5 | |
678 CMPA <V.Trak,X ; otherwise check if this is | |
679 BEQ SeekT6 ; track number to the last | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
680 |
1735 | 681 SeekT5 STA <V.Trak,X ; Do the seek |
682 STA >DataReg ; Write track no to controler | |
1971
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
683 bsr GetStepInB ; get step rate |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
684 ORB #SeekCmnd ; add seek command |
1735 | 685 LBSR FDCCommand |
686 PSHS X | |
687 LDX #$222E ; Wait for head to settle | |
688 SeekT7 LEAX -1,X | |
689 BNE SeekT7 | |
690 PULS X | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
691 |
1735 | 692 SeekT6 CLRB ; return no error to caller |
693 RTS | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
694 |
1971
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
695 ; |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
696 ; Get step rate in bottom 2 bits of B |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
697 ; |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
698 GetStepInB |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
699 ldb PD.Stp,Y ; Set Step Rate according to Parameter block |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
700 andb #%00000011 ; mask in only step rate bits |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
701 eorb #%00000011 ; flip bits to make correct encoding |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
702 rts |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
703 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
704 ; Set Side2 Mask |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
705 ; A contains the track number on entry |
1735 | 706 SetSide LSRA ; Get bit 0 into carry & devide track no by 2 |
707 PSHS A | |
708 BCC Side0 ; Side 0 if even track no. | |
709 LDA #Sid2Sel ; Odd track no. so side 2 | |
710 BRA Side | |
711 Side0 CLRA | |
712 Side STA >SideSel,U | |
713 PULS A,PC | |
1734 | 714 |
715 ; | |
716 ; Select drive and start drive motors. | |
717 ; On entry A=drive number. | |
718 ; | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
719 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
720 SelectDrive |
1735 | 721 lbsr StartMotor ; Start motor |
722 lda <PD.Drv,y ; Check it's a valid drive | |
723 cmpa #MaxDrv | |
724 bcs SelectDriveValid ; yes : continue | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
725 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
726 RetErrorBadUnit |
1735 | 727 comb ; Return bad unit error |
728 ldb #E$Unit | |
729 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
730 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
731 SelectDriveValid |
1735 | 732 pshs x,b,a ; Unit valid so slect it |
733 sta >DrivSel,u ; Get DD table address | |
734 leax DrvBeg,u ; Calculate offset into table | |
735 ldb #DrvMem | |
736 mul | |
737 leax d,x | |
738 cmpx >CDrvTab,u | |
739 beq SelectDriveEnd | |
740 stx >CDrvTab,u ; Force seek if different drive | |
741 com >Settle,u | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
742 SelectDriveEnd |
1735 | 743 puls pc,x,b,a |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
744 |
1734 | 745 ; |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
746 ; Analise device status return. |
1734 | 747 ; |
748 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
749 TestForError |
1735 | 750 bitb #ErrMask |
751 beq TestErrorEnd | |
752 bitb #NotRMask ; not ready | |
753 bne RetErrorNotReady | |
754 bitb #WPMask ; Write protect | |
755 bne RetErrorWP | |
756 bitb #RTypMask ; Wrong type ? | |
757 bne RetWriteError | |
758 bitb #RNFMask ; Record Not found | |
759 bne RetErrorSeek | |
760 bitb #CRCMask | |
761 bne RetErrorCRC | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
762 TestErrorEnd |
1735 | 763 clrb |
764 rts | |
1734 | 765 ; |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
766 ; Return error code |
1734 | 767 ; |
768 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
769 RetErrorNotReady |
1735 | 770 comb |
771 ldb #E$NotRdy | |
772 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
773 RetErrorWP |
1735 | 774 comb |
775 ldb #E$WP | |
776 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
777 RetWriteError |
1735 | 778 comb |
779 ldb #E$Write | |
780 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
781 RetErrorSeek |
1735 | 782 comb |
783 ldb #E$Seek | |
784 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
785 RetErrorCRC |
1735 | 786 comb |
787 ldb #E$CRC | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
788 rts |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
789 RetReadError |
1735 | 790 comb |
791 ldb #E$Read | |
792 rts | |
1734 | 793 ; |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
794 ; Issue a command to FDC and wait till it's ready |
1734 | 795 ; |
796 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
797 FDCCommand |
1735 | 798 bsr FDCCmd |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
799 FDCCmdWait |
1735 | 800 ldb >CmdReg ; Poll until not busy |
801 bitb #$01 | |
802 beq Delay3 | |
803 bra FDCCmdWait | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
804 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
805 FDCCmdMotorOn |
1735 | 806 lda #MotorOn ; Turn on motor |
807 ora >DrivSel,u | |
808 | |
2103 | 809 IFNE dalpha |
1735 | 810 lbsr AlphaDskCtl |
811 ELSE | |
812 sta >DskCtl | |
813 ENDC | |
814 | |
815 bsr SetupVIRQ | |
816 | |
817 stb >CmdReg ; Send Command to FDC | |
818 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
819 |
1735 | 820 SetupVIRQ |
821 pshs D | |
822 ldd >VIRQCnt,pc ; Get VIRQ initial count value | |
823 std >VIRQPak,u ; Save it | |
824 lda VIRQInstalled,u ; Installed yet ? | |
825 beq DoInsVIRQ ; Not installed yet, try installing it | |
826 SetupVIRQExit | |
827 PULS D | |
828 rts | |
829 | |
830 DoInsVIRQ | |
831 bsr InsVIRQ | |
832 bra SetupVIRQExit | |
833 | |
834 InsVIRQ pshs D,y,x | |
835 lda #$01 ; Flag drive motor is up to speed | |
836 IFEQ Level-1 | |
837 sta >D.DskTmr | |
838 ELSE | |
839 sta <D.MotOn | |
840 ENDC | |
841 | |
842 ldx #$0001 ; Install VIRQ entry | |
843 leay >VIRQPak,u ; Point to packet | |
844 clr Vi.Stat,y ; Reset Status byte | |
845 ldd >VIRQCnt,pc ; Get initial VIRQ count value | |
846 os9 F$VIRQ ; Install VIRQ | |
847 bcs VIRQOut ; Error, exit | |
848 inc VIRQInstalled,u ; Flag it's installed | |
849 VIRQOut puls X,Y,D | |
850 rts | |
851 | |
852 * IRQ service routine for VIRQ (drive motor time) | |
853 * Entry: U=Ptr to VIRQ memory area | |
854 IRQSvc pshs a | |
855 lda <D.DMAReq | |
856 beq L0509 | |
857 bsr InsVIRQ | |
858 bra IRQOut | |
859 L0509 | |
2103 | 860 IFNE dalpha |
1735 | 861 lbsr AlphaDskCtl |
862 ELSE | |
863 sta >DskCtl | |
864 ENDC | |
865 | |
866 clr u00B5,u | |
867 clr VIRQInstalled,u | |
868 IFEQ Level-1 | |
869 clr >D.DskTmr | |
870 ELSE | |
871 clr <D.MotOn | |
872 ENDC | |
873 IRQOut puls pc,a | |
874 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
875 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
876 FDCCmd |
1735 | 877 bsr FDCCmdMotorOn |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
878 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
879 ; Delay routine ! |
1735 | 880 Delay lbsr Delay2 |
881 Delay2 lbsr Delay3 | |
882 Delay3 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
883 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
884 * SetStat |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
885 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
886 * Entry: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
887 * A = function code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
888 * Y = address of path descriptor |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
889 * U = address of device memory area |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
890 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
891 * Exit: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
892 * CC = carry set on error |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
893 * B = error code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
894 * |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
895 SetStat |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
896 ldx PD.Rgs,y ; Retrieve request |
1735 | 897 ldb R$B,x |
1734 | 898 |
1735 | 899 cmpb #SS.Reset ; Restore to track 0. |
900 beq ResetTrack0 | |
901 cmpb #SS.Wtrk ; Write (format) a track | |
902 beq DoWriteTrack | |
903 comb | |
904 ldb #E$UnkSvc | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
905 SetStatEnd |
1735 | 906 rts |
1734 | 907 ; |
908 ; Write (format) a track | |
909 ; | |
910 | |
911 DoWriteTrack | |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
912 |
1735 | 913 lbsr SelectDrive ; Select drive |
914 lda R$Y+1,x | |
915 LBSR SetSide ; Set Side 2 if appropriate | |
916 LDA R$U+1,X | |
917 BSR SetWPC ; Set WPC by disk type | |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
918 bsr SetDensity ; Set density |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
919 |
1734 | 920 ;L02D5 |
1735 | 921 ldx >CDrvTab,u |
922 lbsr SeekTS ; Move to correct track | |
923 bcs SetStatEnd | |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
924 |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
925 ldx PD.Rgs,y |
1735 | 926 ldx R$X,x |
927 ldb #WtTkCmnd | |
928 pshs y,dp,cc | |
929 lbra WriteTrackCmd | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
930 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
931 ; Reset track 0 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
932 ResetTrack0 |
1735 | 933 lbsr SelectDrive ; Select drive |
934 ldx >CDrvTab,u | |
935 clr <V.Trak,x ; Set current track as 0 | |
936 lda #$05 | |
1971
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
937 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
938 ResetTrack0Loop |
1971
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
939 lbsr GetStepInB ; Get step rate for this drive |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
940 orb #StpICmnd ; Step away from track 0 5 times |
1735 | 941 pshs a |
942 lbsr FDCCommand | |
943 puls a | |
944 deca | |
1971
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
945 bne ResetTrack0Loop |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
946 |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
947 lbsr GetStepInB ; Get step rate for this drive |
136a4e706aa6
Fixed step rate issues on recalibrate on original Dragon 5.25" drives
afra
parents:
1970
diff
changeset
|
948 orb #RestCmnd ; Now issue a restore |
1735 | 949 lbra FDCCommand |
1734 | 950 ; |
951 ;Start drive motors | |
952 ; | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
953 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
954 StartMotor |
1735 | 955 pshs x,b,a |
956 lda >D.DskTmr ; if timer <> 0 then skip as motor already on | |
957 bne MotorsRunning | |
958 lda #MotorOn ; else spin up | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
959 |
2103 | 960 IFNE dalpha |
1735 | 961 bsr AlphaDskCtl |
962 ELSE | |
963 sta >DskCtl | |
964 ENDC | |
965 | |
966 ldx #$A000 ; Wait a little while for motors to get up to speed | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
967 StartMotorLoop |
1735 | 968 nop |
969 nop | |
970 leax -1,x | |
971 bne StartMotorLoop | |
1729 | 972 |
1735 | 973 MotorsRunning |
974 lbsr SetupVIRQ | |
975 ; lda #$F0 ; Start external motor timer | |
976 ; sta >D.DskTmr ; external to driver | |
977 puls pc,x,b,a | |
978 | |
1734 | 979 ; |
980 ; Set Write Precompensation according to media type | |
981 ; | |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
982 ; Entry : |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
983 ; A = Track no |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
984 |
1735 | 985 SetWPC PSHS A,B |
986 LDB PD.DNS,Y | |
987 BITB #T80Mask ; Is it 96 tpi drive | |
988 BNE SetWP1 | |
989 ASLA ; no then double | |
990 SetWP1 CMPA #32 ; WPC needed ? | |
991 BLS SetWP2 | |
992 LDA >DrivSel,U | |
993 ORA #WPCEn | |
994 STA >DrivSel,U | |
995 SetWP2 PULS A,B,PC | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
996 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
997 |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
998 ; |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
999 ; Set density acording to disk type. |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1000 ; |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1001 ; Entry A = Track no |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1002 ; |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1003 |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1004 SetDensity |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1005 PSHS A,B |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1006 ldb PD.TYP,Y ; Dragon/CoCo disk ? |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1007 bitb #TYP.CCF |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1008 bne SetDouble ; Always double density |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1009 |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1010 LDB PD.DNS,Y ; Get density flags from Path descriptor |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1011 |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1012 bitb #DNS.MFM ; Disk is MFM ? |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1013 beq SetSingle ; no : set single density |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1014 |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1015 cmpa #0 ; track 0 ? |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1016 bne SetDouble ; not track 0, exit |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1017 |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1018 tst SideSel,u ; is this side 0 ? |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1019 bne SetDouble ; no : use double density |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1020 |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1021 bitb #DNS.MFM0 ; track 0 mfm ? |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1022 bne SetDouble |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1023 |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1024 SetSingle |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1025 lda #SDensEn ; flag single density |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1026 sta Density,u |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1027 bra ExitDensity |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1028 |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1029 SetDouble |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1030 clr Density,u ; flag double density |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1031 |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1032 ExitDensity |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1033 puls a,b,pc |
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1034 |
2103 | 1035 IFNE dalpha |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
1036 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
1037 ; Translate DragonDos Drive select mechinisim to work on Alpha |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
1038 ; Takes byte that would be output to $FF48, reformats it and |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
1039 ; outputs to Alpha AY-8912's IO port, which is connected to |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
1040 ; Drive selects, motor on and enable precomp. |
1729 | 1041 ; This code now expects Alpha NMI/DDEN etc codes, as defined |
1042 ; at top of this file (and dgndefs). The exception to this is | |
1043 ; the drive number is still passed in the bottom 2 bits and | |
1044 ; converted with a lookup table. | |
1045 ; We do not need to preserve the ROM select bit as this code | |
1046 ; operates in RAM only mode. | |
1047 | |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1048 ADrvTab FCB Drive0A,Drive1A,Drive2A,Drive3A |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
1049 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
1050 AlphaDskCtl |
1735 | 1051 PSHS x,A,B,CC |
1896
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
1052 |
1735 | 1053 PSHS A |
1896
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
1054 anda #DDosDriveMask ; mask out dragondos format drive number |
1833
ed9f51e468fa
Added ability to read/write/format Single density disks.
afra
parents:
1832
diff
changeset
|
1055 leax ADrvTab,pcr ; point at table |
1735 | 1056 lda a,x ; get bitmap |
1057 ldb ,s | |
1896
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
1058 andb #AlphaCtrlMask ; mask out drive number bits |
1735 | 1059 stb ,s |
1896
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
1060 ora ,s ; recombine drive no & ctrl bits |
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
1061 ; sta ,s |
1735 | 1062 |
1063 bita #MotorOn ; test motor on ? | |
1064 bne MotorRunning | |
1065 | |
1066 clra ; No, turn off other bits. | |
1067 MotorRunning | |
1832 | 1068 anda #Mask58 ; Mask out 5/8 bit to force the use of 5.25" clock |
1069 sta ,s | |
1896
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
1070 |
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
1071 orcc #$50 ; disable inturrupts |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
1072 |
1735 | 1073 lda #AYIOREG ; AY-8912 IO register |
1074 sta PIA2DB ; Output to PIA | |
1075 ldb #AYREGLatch ; Latch register to modify | |
1076 stb PIA2DA | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
1077 |
1735 | 1078 clr PIA2DA ; Idle AY |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
1079 |
1896
3826bfe7d2e5
Timing fixes for Dragon Alpha, should now boot more reliably
afra
parents:
1842
diff
changeset
|
1080 lda ,s+ ; Fetch saved Drive Selects etc |
1735 | 1081 sta PIA2DB ; output to PIA |
1082 ldb #AYWriteReg ; Write value to latched register | |
1083 stb PIA2DA ; Set register | |
1729 | 1084 |
1735 | 1085 clr PIA2DA ; Idle AY |
1086 | |
1087 PULS x,A,B,CC | |
1088 RTS | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
1089 |
1735 | 1090 ENDC |
1821 | 1091 |
1092 | |
1735 | 1093 emod |
1094 eom equ * | |
1095 end |