Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/ddisk.asm @ 1821:82e134e51305
Fixed fatal read errors on the Dragon 64.
author | afra |
---|---|
date | Sun, 24 Apr 2005 02:16:01 +0000 |
parents | 11f38ece79ef |
children | c074e97abf3d |
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 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
19 * The Dragon Alpha/Professional uses the same FDC chip as |
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. | |
1734 | 57 * |
58 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
59 nam DDisk |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
60 ttl Dragon Floppy driver |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
61 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
62 * 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
|
63 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
64 ifp1 |
1729 | 65 use defsfile.dragon |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
66 endc |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
67 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
68 IFNE DragonAlpha |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
69 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
70 * 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
|
71 * 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
|
72 * disk controler. |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
73 |
1735 | 74 DPPIADA EQU DPPIA2DA |
75 DPPIACRA EQU DPPIA2CRA | |
76 DPPIADB EQU DPPIA2DB | |
77 DPPIACRB EQU DPPIA2CRB | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
78 |
1735 | 79 PIADA EQU DPPIADA+IO ; Side A Data/DDR |
80 PIACRA EQU DPPIACRA+IO ; Side A Control. | |
81 PIADB EQU DPPIADB+IO ; Side A Data/DDR | |
82 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
|
83 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
84 ;WD2797 Floppy disk controler, used in Alpha Note registers in reverse order ! |
1821 | 85 DPCMDREG EQU DPCmdRegA ; command/status |
86 DPTRKREG EQU DPTrkRegA ; Track register | |
87 DPSECREG EQU DPSecRegA ; Sector register | |
88 DPDATAREG EQU DPDataRegA ; Data register | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
89 |
1735 | 90 CMDREG EQU DPCMDREG+IO ; command/status |
91 TRKREG EQU DPTRKREG+IO ; Track register | |
92 SECREG EQU DPSECREG+IO ; Sector register | |
93 DATAREG EQU DPDATAREG+IO ; Data register | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
94 |
1729 | 95 ; Disk IO bitmasks |
96 | |
1735 | 97 NMIEn EQU NMIEnA |
1729 | 98 WPCEn EQU WPCEnA |
99 SDensEn EQU SDensEnA | |
100 MotorOn EQU MotorOnA | |
101 | |
1735 | 102 ; These are the bits that we know the function of on the Alpha interface |
103 KnownBits EQU Drive0A+Drive1A+Drive2A+Drive3A+MotorOnA+WPCEnA | |
104 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
105 ELSE |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
106 |
1735 | 107 DPPIADA EQU DPPIA1DA |
108 DPPIACRA EQU DPPIA1CRA | |
109 DPPIADB EQU DPPIA1DB | |
110 DPPIACRB EQU DPPIA1CRB | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
111 |
1735 | 112 PIADA EQU DPPIADA+IO ; Side A Data/DDR |
113 PIACRA EQU DPPIACRA+IO ; Side A Control. | |
114 PIADB EQU DPPIADB+IO ; Side A Data/DDR | |
115 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
|
116 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
117 ;WD2797 Floppy disk controler, used in DragonDos. |
1735 | 118 DPCMDREG EQU DPCmdRegD ; command/status |
119 DPTRKREG EQU DPTrkRegD ; Track register | |
120 DPSECREG EQU DPSecRegD ; Sector register | |
121 DPDATAREG EQU DPDataRegD ; Data register | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
122 |
1735 | 123 CMDREG EQU DPCMDREG+IO ; command/status |
124 TRKREG EQU DPTRKREG+IO ; Track register | |
125 SECREG EQU DPSECREG+IO ; Sector register | |
126 DATAREG EQU DPDATAREG+IO ; Data register | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
127 |
1729 | 128 ; Disk IO bitmasks |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
129 |
1735 | 130 NMIEn EQU NMIEnD |
1729 | 131 WPCEn EQU WPCEnD |
132 SDensEn EQU SDensEnD | |
133 MotorOn EQU MotorOnD | |
134 | |
135 ENDC | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
136 |
1735 | 137 tylg set Drivr+Objct |
138 atrv set ReEnt+rev | |
139 rev set $00 | |
140 edition set 3 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
141 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
142 MaxDrv set 4 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
143 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
144 mod eom,name,tylg,atrv,start,size |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
145 |
1735 | 146 org DrvBeg |
147 RMB MaxDrv*DrvMem | |
1734 | 148 CDrvTab rmb 2 |
149 DrivSel rmb 1 ; Saved drive mask | |
1735 | 150 Settle rmb 1 ; Head settle time |
1734 | 151 SavePIA0CRB rmb 1 ; Saved copy of PIA0 control reg b |
1735 | 152 SaveACIACmd rmb 1 ; Saved copy of ACIA command reg |
153 BuffPtr rmb 2 ; Buffer pointer | |
154 SideSel rmb 1 ; Side select. | |
155 NMIFlag rmb 1 ; Flag for Alpha, should this NMI do an RTI ? | |
156 | |
1821 | 157 DskError rmb 1 |
158 | |
1735 | 159 VIRQPak rmb 2 ; Vi.Cnt word for VIRQ |
160 u00B3 rmb 2 ; Vi.Rst word for VIRQ | |
161 u00B5 rmb 1 ; Vi.Stat byte for VIRQ (drive motor timeout) | |
162 | |
163 VIRQInstalled rmb 1 ; Is VIRQ Installed yet ? | |
1734 | 164 size equ . |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
165 |
1735 | 166 fcb $FF |
167 name equ * | |
168 fcs /DDisk/ | |
169 fcb edition | |
170 | |
171 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
|
172 |
1821 | 173 start lbra Init ; Initialise Driver |
174 lbra Read ; Read sector | |
175 lbra Write ; Write sector | |
176 lbra GetStat ; Get status | |
177 lbra SetStat ; Set status | |
178 lbra Term ; Terminate device | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
179 |
1821 | 180 IRQPkt fcb $00 ; Normal bits (flip byte) |
181 fcb $01 ; Bit 1 is interrupt request flag (Mask byte) | |
182 fcb 10 ; Priority byte | |
1729 | 183 |
184 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
185 * Init |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
186 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
187 * Entry: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
188 * Y = address of device descriptor |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
189 * U = address of device memory area |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
190 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
191 * Exit: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
192 * CC = carry set on error |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
193 * B = error code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
194 * |
1734 | 195 DragonDebug EQU 1 |
196 Init | |
1735 | 197 IFNE DragonDebug |
198 pshs x ; This is here so I can find disk driver in mess | |
199 ldx #$AA55 ; by setting register breakpoint to X=$AA55 ! | |
200 puls x | |
201 ENDC | |
202 | |
203 clra | |
204 sta >D.DskTmr ; Zero motor timer | |
205 | |
206 IFNE DragonAlpha ; Turn off all drives | |
207 lbsr AlphaDskCtl | |
208 ELSE | |
209 sta >DskCtl | |
210 ENDC | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
211 |
1735 | 212 ldx #CmdReg ; Reset controler |
213 lda #FrcInt | |
214 sta ,x | |
215 lbsr Delay | |
216 lda ,x | |
217 lda #$FF | |
218 ldb #MaxDrv | |
219 leax DrvBeg,u | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
220 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
221 InitDriveData |
1735 | 222 sta DD.Tot,x ; Set total sectors = $FF |
223 sta <V.Trak,x ; Set current track = 0 | |
224 leax <DrvMem,x ; Skip to next drive | |
225 decb | |
226 bne InitDriveData | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
227 |
1735 | 228 leax >NMIService,pcr ; Setup NMI handler |
229 stx >D.XNMI+1 | |
230 lda #$7E ; $7E = JMP | |
231 sta >D.XNMI | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
232 |
1735 | 233 clr VIRQInstalled,u ;flag not installed yet |
234 | |
235 pshs y ; save device dsc. ptr | |
236 leay >u00B5,u ; point to Vi.Stat in VIRQ packet | |
237 tfr y,d ; make it the status register ptr for IRQ | |
238 leay >IRQSvc,pc ; point to IRQ service routine | |
239 leax >IRQPkt,pc ; point to IRQ packet | |
240 os9 F$IRQ ; install IRQ | |
241 puls y ; Get back device dsc. ptr | |
1729 | 242 |
1735 | 243 ldd #$0100 ; Request a page of system ram |
244 pshs u ; used to verify writes | |
245 os9 F$SRqMem | |
246 tfr u,x | |
247 puls u | |
248 bcs Return | |
249 stx >BuffPtr,u ; Save verify page pointer | |
250 clrb | |
251 Return rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
252 |
1729 | 253 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
254 * GetStat |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
255 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
256 * Entry: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
257 * A = function code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
258 * Y = address of path descriptor |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
259 * U = address of device memory area |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
260 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
261 * Exit: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
262 * CC = carry set on error |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
263 * B = error code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
264 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
265 GetStat |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
266 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
267 * Term |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
268 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
269 * Entry: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
270 * U = address of device memory area |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
271 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
272 * Exit: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
273 * CC = carry set on error |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
274 * B = error code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
275 * |
1735 | 276 Term clrb |
277 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
278 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
279 * Read |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
280 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
281 * Entry: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
282 * B = MSB of the disk's LSN |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
283 * X = LSB of the disk's LSN |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
284 * Y = address of path descriptor |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
285 * U = address of device memory area |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
286 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
287 * Exit: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
288 * CC = carry set on error |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
289 * B = error code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
290 * |
1735 | 291 Read |
292 lda #$91 ; Retry count | |
293 cmpx #$0000 ; LSN ? | |
294 bne ReadDataWithRetry ; No : Just do read, | |
295 bsr ReadDataWithRetry ; Yes : do read and copy disk params | |
296 bcs ReadDataExit | |
297 ldx PD.Buf,y | |
298 pshs y,x | |
299 ldy >CDrvTab,u | |
300 ldb #DD.Siz-1 | |
301 L0082 lda b,x | |
302 sta b,y | |
303 decb | |
304 bpl L0082 | |
305 clrb | |
306 puls pc,y,x | |
1734 | 307 ReadDataExit |
1735 | 308 rts |
1727
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 ; Read Retry |
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 ReadDataRetry |
1821 | 313 |
314 lbsr RetryErrorDisplay | |
315 | |
1735 | 316 bcc ReadDataWithRetry ; Retry entry point |
317 pshs x,b,a | |
318 lbsr ResetTrack0 ; Reset track 0 | |
319 puls x,b,a | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
320 |
1734 | 321 ReadDataWithRetry |
1735 | 322 pshs x,b,a ; Normal entry point |
323 bsr DoReadData | |
324 puls x,b,a | |
325 bcc ReadDataExit | |
326 lsra ; Check for retry | |
327 bne ReadDataRetry | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
328 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
329 DoReadData |
1735 | 330 lbsr SeekTrack |
331 bcs ReadDataExit | |
332 ldx PD.Buf,y ; Target address for data | |
333 pshs y,dp,cc | |
334 ldb #ReadCmnd ; Read command | |
335 bsr PrepDiskRW ; Prepare disk | |
1821 | 336 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
337 DoReadDataLoop |
1735 | 338 lda <DPPIACRB ; Is data ready ? |
339 bmi ReadDataReady ; Yes : read it | |
340 leay -1,y | |
341 bne DoReadDataLoop | |
342 bsr RestoreSavedIO | |
343 puls y,dp,cc | |
344 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
|
345 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
346 ReadDataWait |
1735 | 347 sync ; Sync to inturrupts, wait for data |
348 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
349 ReadDataReady |
1735 | 350 lda <DPDataReg ; Read data from FDC |
351 ldb <DPPIADB ; Clear PIA inturrupt status | |
352 sta ,x+ ; save data in memory | |
353 bra ReadDataWait ; do next | |
354 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
355 PrepDiskRW |
1821 | 356 |
357 clr DskError,u | |
358 | |
1735 | 359 lda #$FF ; Make DP=$FF, to make io easier |
360 tfr a,dp | |
361 lda <DPAciaCmd ; Save ACIA Command reg | |
362 sta >SaveACIACmd,u | |
363 anda #$FE ; Disable ACIA inturrupt | |
364 sta <DPAciaCmd | |
365 bita #$40 ; Is Tx inturrupt enabled ? | |
366 beq L00DE | |
367 L00D8 lda <DPAciaStat ; Yes, wait for Tx to complete | |
368 bita #$10 | |
369 beq L00D8 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
370 |
1735 | 371 L00DE orcc #$50 ; Mask inturrupts |
372 lda <DPPia0CRB ; Save PIA0 IRQ Status | |
373 sta >SavePIA0CRB,u | |
374 lda #$34 ; Disable it. | |
375 sta <DPPia0CRB | |
376 lda <DPACIACmd ; Disable ACIA Inturrupt | |
377 anda #$FE | |
378 sta <DPACIACmd | |
379 lda <DPPIACRB ; Set PIA to generate FIRQ on FDC DRQ | |
380 ora #$03 | |
381 sta <DPPIACRB | |
382 lda <DPPIADB ; Clear any outstanding inturrupt | |
383 ldy #$FFFF | |
384 lda #NMIEn+MotorOn ; Enable NMI, and turn motor on | |
385 ora >DrivSel,u ; mask in drives | |
386 ORB >SideSel,U ; Set up Side | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
387 |
1735 | 388 IFNE DragonAlpha ; Turn on drives & NMI |
389 lbsr AlphaDskCtl | |
1821 | 390 stb <DPCmdReg ; issue command to controler |
1735 | 391 ELSE |
1821 | 392 stb <DPCmdReg ; issue command to controler |
393 sta <DPDskCtl | |
1735 | 394 ENDC |
1729 | 395 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
396 |
1735 | 397 rts |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
398 |
1734 | 399 ; |
400 ; Restore saved iO states of peripherals. | |
401 ; | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
402 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
403 RestoreSavedIO |
1735 | 404 lda >DrivSel,u ; Deselect drives, but leave motor on |
405 ora #MotorOn | |
406 IFNE DragonAlpha ; Turn off drives & NMI | |
407 lbsr AlphaDskCtl | |
408 ELSE | |
1821 | 409 sta <DPDskCtl |
1735 | 410 ENDC |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
411 |
1735 | 412 lda >SavePIA0CRB,u ; Recover PIA0 state |
413 sta <DPPia0CRB | |
414 lda <DPPIACRB ; Recover ACIA state | |
415 anda #$FC | |
416 sta <DPPIACRB ; Disable Drive FIRQ source. | |
417 lda >SaveACIACmd,u | |
418 sta <DPAciaCmd | |
419 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
420 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
421 * Write |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
422 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
423 * Entry: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
424 * B = MSB of the disk's LSN |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
425 * X = LSB of the disk's LSN |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
426 * Y = address of path descriptor |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
427 * U = address of device memory area |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
428 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
429 * Exit: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
430 * CC = carry set on error |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
431 * B = error code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
432 * |
1735 | 433 Write lda #$91 ; Retry byte |
434 L0124 pshs x,b,a | |
435 bsr DoWrite ; Attempt to do write | |
436 puls x,b,a | |
437 bcs WriteDataRetry ; On error, retry | |
438 tst <PD.Vfy,y ; Written, should we verify ? | |
439 bne WriteDone ; no : return | |
440 lbsr WriteVerify ; yes : verify write | |
441 bcs WriteDataRetry ; verify error, retry write | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
442 WriteDone |
1735 | 443 clrb ; Return status ok |
444 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
445 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
446 WriteDataRetry |
1735 | 447 lsra ; Retry data write |
448 lbeq RetWriteError ; All retries exhausted ?, return error | |
449 bcc L0124 | |
450 pshs x,b,a ; Reset to track 0 | |
451 lbsr ResetTrack0 | |
452 puls x,b,a | |
453 bra L0124 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
454 |
1735 | 455 DoWrite lbsr SeekTrack ; Seek to correct track & sector |
456 lbcs ReadDataExit | |
457 ldx PD.Buf,y ; Get data buffer in X | |
458 pshs y,dp,cc | |
459 ldb #WritCmnd ; Write command | |
1734 | 460 |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
461 WriteTrackCmd |
1735 | 462 lbsr PrepDiskRW ; Prepare for disk r/w |
1821 | 463 lda ,x+ ; get byte to write |
1735 | 464 L015A ldb <DPPIACRB ; Ready to write ? |
465 bmi WriteDataReady ; Yes, do it. | |
466 leay -1,y | |
467 bne L015A | |
468 bsr RestoreSavedIO ; Restore saved peripheral states | |
469 puls y,dp,cc | |
470 lbra RetWriteError ; Return write error | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
471 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
472 WriteDataWait |
1735 | 473 lda ,x+ ; Get next byte to write |
474 sync ; Wait for drive | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
475 WriteDataReady |
1735 | 476 sta <DPDataReg ; Write data to FDC |
477 ldb <DPPIADB ; Clear pending FDC inturrupt | |
478 bra WriteDataWait | |
479 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
480 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
481 ; The following block of code is needed for the Dragon Alpha, because |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
482 ; we currently do not know how to disable it's NMI in hardware, |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
483 ; So we check a flag here, and if set we simply return from inturrupt |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
484 ; as if nothing happened ! |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
485 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
486 NMIService |
1735 | 487 IFNE DragonAlpha |
488 pshs cc ; Save flags | |
489 tst >NMIFlag,u ; Check NMI enable flag | |
490 bne DoNMI ; if enabled, continue with handler | |
491 puls cc ; else restore flags and return | |
492 RTI | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
493 |
1735 | 494 DoNMI puls cc ; restore flags |
495 ENDC | |
1727
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 RealNMI |
1735 | 498 leas R$Size,s ; Drop regs from stack |
499 bsr RestoreSavedIO ; Restore saved IO states | |
500 puls y,dp,cc | |
501 ldb >CmdReg | |
1821 | 502 |
503 stb DskError,u | |
504 | |
505 bitb #LostMask ; check for lost record | |
1735 | 506 lbne RetReadError ; yes : return read error |
507 lbra TestForError ; esle test for other errors | |
508 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
509 ; Verify a written sector. |
1735 | 510 WriteVerify |
511 pshs x,b,a | |
512 ldx PD.Buf,y ; Swap buffer pointers | |
513 pshs x | |
514 ldx >BuffPtr,u | |
515 stx PD.Buf,y | |
516 ldx 4,s | |
517 lbsr DoReadData ; Read data back in | |
518 puls x | |
519 stx PD.Buf,y ; Swab buffer pointers back | |
520 bcs VerifyEnd | |
521 lda #$20 | |
522 pshs u,y,a | |
523 ldy >BuffPtr,u | |
524 tfr x,u | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
525 VerifyLoop |
1735 | 526 ldx ,u ; Compare every 4th word |
527 cmpx ,y | |
528 bne VerifyErrorEnd | |
529 leau 8,u | |
530 leay 8,y ; Increment pointers | |
531 dec ,s | |
532 bne VerifyLoop | |
533 bra VerifyEndOk ; Verify succeeded. | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
534 VerifyErrorEnd |
1735 | 535 orcc #Carry ; Flag error |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
536 VerifyEndOk |
1735 | 537 puls u,y,a |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
538 VerifyEnd |
1735 | 539 puls pc,x,b,a |
1734 | 540 ; |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
541 ; Seek to a track |
1734 | 542 ; |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
543 SeekTrack |
1735 | 544 CLR >Settle,U ; default no settle |
545 LBSR SelectDrive ; select and start correct d | |
546 TSTB | |
547 BNE E.Sect | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
548 |
1735 | 549 TFR X,D |
550 LDX >CDrvTab,U | |
551 CMPD #0 ; Skip calculation of track 0 | |
552 BEQ SeekT1 | |
553 CMPD DD.TOT+1,X ; Has an illegal LSN been | |
554 BLO SeekT2 | |
555 E.Sect COMB | |
556 LDB #E$Sect | |
557 RTS | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
558 |
1735 | 559 SeekT2 CLR ,-S ; Calculate track number |
560 SUBD PD.T0S,Y ; subtract no. of sectors in track 0 | |
561 BHS SeekT4 | |
562 ADDD PD.T0S,Y ; if -ve we are on track 0, so add back on again | |
563 BRA SeekT3 | |
564 SeekT4 INC ,S | |
565 SUBD DD.Spt,X ; sectors per track for rest of disk | |
566 BHS SeekT4 ; repeat, until -ve, incrementing track count | |
567 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
|
568 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
569 ; At this point the byte on the top of the stack contains the track |
1734 | 570 ; 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
|
571 |
1735 | 572 SeekT3 PULS A ; retrieve track count |
573 LBSR SetWPC ; set write precompensation | |
574 PSHS B | |
575 LDB DD.Fmt,X ; Is the media double sided ? | |
576 LSRB | |
577 BCC SingleSidedDisk ; skip if not | |
578 LDB PD.Sid,Y ; Is the drive double sided ? | |
579 DECB | |
580 BNE SetupSideMask ; yes : deal with it. | |
581 PULS B ; No then its an error | |
582 COMB | |
583 LDB #E$BTyp | |
584 RTS | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
585 |
1734 | 586 SetupSideMask |
1735 | 587 BSR SetSide ; Media & drive are double sided |
588 BRA SeekT9 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
589 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
590 SingleSidedDisk |
1735 | 591 clr >SideSel,U ; Single sided, make sure sidesel set correctly |
592 BRA SeekT9 | |
1734 | 593 |
1735 | 594 SeekT1 clr >SideSel,U ; make sure sidesel is always 0 if lsn0 |
595 PSHS B | |
596 SeekT9 LDB PD.Typ,Y ; Dragon and Coco disks | |
597 BITB #TYP.SBO ; count sectors from 1 no | |
598 BNE SeekT8 | |
599 PULS B | |
1821 | 600 INCB ; so increment sector number |
1735 | 601 BRA SeekT11 |
602 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
|
603 |
1735 | 604 SeekT11 STB >SecReg ; Write sector number to controler |
605 LBSR Delay | |
606 CMPB >SecReg | |
607 BNE SeekT11 | |
1729 | 608 |
1735 | 609 SeekTS LDB <V.Trak,X ; Entry point for SS.WTrk command |
610 STB >TrkReg | |
611 TST >Settle,U ; If settle has been flagged then wait for settle | |
612 BNE SeekT5 | |
613 CMPA <V.Trak,X ; otherwise check if this is | |
614 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
|
615 |
1735 | 616 SeekT5 STA <V.Trak,X ; Do the seek |
617 STA >DataReg ; Write track no to controler | |
618 LDB #SeekCmnd | |
619 ORB PD.Stp,Y ; Set Step Rate according to Parameter block | |
620 LBSR FDCCommand | |
621 PSHS X | |
622 LDX #$222E ; Wait for head to settle | |
623 SeekT7 LEAX -1,X | |
624 BNE SeekT7 | |
625 PULS X | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
626 |
1735 | 627 SeekT6 CLRB ; return no error to caller |
628 RTS | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
629 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
630 ; Set Side2 Mask |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
631 ; A contains the track number on entry |
1735 | 632 SetSide LSRA ; Get bit 0 into carry & devide track no by 2 |
633 PSHS A | |
634 BCC Side0 ; Side 0 if even track no. | |
635 LDA #Sid2Sel ; Odd track no. so side 2 | |
636 BRA Side | |
637 Side0 CLRA | |
638 Side STA >SideSel,U | |
639 PULS A,PC | |
1734 | 640 |
641 ; | |
642 ; Select drive and start drive motors. | |
643 ; On entry A=drive number. | |
644 ; | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
645 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
646 SelectDrive |
1735 | 647 lbsr StartMotor ; Start motor |
648 lda <PD.Drv,y ; Check it's a valid drive | |
649 cmpa #MaxDrv | |
650 bcs SelectDriveValid ; yes : continue | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
651 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
652 RetErrorBadUnit |
1735 | 653 comb ; Return bad unit error |
654 ldb #E$Unit | |
655 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
656 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
657 SelectDriveValid |
1735 | 658 pshs x,b,a ; Unit valid so slect it |
659 sta >DrivSel,u ; Get DD table address | |
660 leax DrvBeg,u ; Calculate offset into table | |
661 ldb #DrvMem | |
662 mul | |
663 leax d,x | |
664 cmpx >CDrvTab,u | |
665 beq SelectDriveEnd | |
666 stx >CDrvTab,u ; Force seek if different drive | |
667 com >Settle,u | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
668 SelectDriveEnd |
1735 | 669 puls pc,x,b,a |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
670 |
1734 | 671 ; |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
672 ; Analise device status return. |
1734 | 673 ; |
674 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
675 TestForError |
1735 | 676 bitb #ErrMask |
677 beq TestErrorEnd | |
678 bitb #NotRMask ; not ready | |
679 bne RetErrorNotReady | |
680 bitb #WPMask ; Write protect | |
681 bne RetErrorWP | |
682 bitb #RTypMask ; Wrong type ? | |
683 bne RetWriteError | |
684 bitb #RNFMask ; Record Not found | |
685 bne RetErrorSeek | |
686 bitb #CRCMask | |
687 bne RetErrorCRC | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
688 TestErrorEnd |
1735 | 689 clrb |
690 rts | |
1734 | 691 ; |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
692 ; Return error code |
1734 | 693 ; |
694 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
695 RetErrorNotReady |
1735 | 696 comb |
697 ldb #E$NotRdy | |
698 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
699 RetErrorWP |
1735 | 700 comb |
701 ldb #E$WP | |
702 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
703 RetWriteError |
1735 | 704 comb |
705 ldb #E$Write | |
706 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
707 RetErrorSeek |
1735 | 708 comb |
709 ldb #E$Seek | |
710 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
711 RetErrorCRC |
1735 | 712 comb |
713 ldb #E$CRC | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
714 rts |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
715 RetReadError |
1735 | 716 comb |
717 ldb #E$Read | |
718 rts | |
1734 | 719 ; |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
720 ; Issue a command to FDC and wait till it's ready |
1734 | 721 ; |
722 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
723 FDCCommand |
1735 | 724 bsr FDCCmd |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
725 FDCCmdWait |
1735 | 726 ldb >CmdReg ; Poll until not busy |
727 bitb #$01 | |
728 beq Delay3 | |
729 bra FDCCmdWait | |
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 FDCCmdMotorOn |
1735 | 732 lda #MotorOn ; Turn on motor |
733 ora >DrivSel,u | |
734 | |
735 IFNE DragonAlpha | |
736 lbsr AlphaDskCtl | |
737 ELSE | |
738 sta >DskCtl | |
739 ENDC | |
740 | |
741 bsr SetupVIRQ | |
742 | |
743 stb >CmdReg ; Send Command to FDC | |
744 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
745 |
1735 | 746 SetupVIRQ |
747 pshs D | |
748 ldd >VIRQCnt,pc ; Get VIRQ initial count value | |
749 std >VIRQPak,u ; Save it | |
750 lda VIRQInstalled,u ; Installed yet ? | |
751 beq DoInsVIRQ ; Not installed yet, try installing it | |
752 SetupVIRQExit | |
753 PULS D | |
754 rts | |
755 | |
756 DoInsVIRQ | |
757 bsr InsVIRQ | |
758 bra SetupVIRQExit | |
759 | |
760 InsVIRQ pshs D,y,x | |
761 lda #$01 ; Flag drive motor is up to speed | |
762 IFEQ Level-1 | |
763 sta >D.DskTmr | |
764 ELSE | |
765 sta <D.MotOn | |
766 ENDC | |
767 | |
768 ldx #$0001 ; Install VIRQ entry | |
769 leay >VIRQPak,u ; Point to packet | |
770 clr Vi.Stat,y ; Reset Status byte | |
771 ldd >VIRQCnt,pc ; Get initial VIRQ count value | |
772 os9 F$VIRQ ; Install VIRQ | |
773 bcs VIRQOut ; Error, exit | |
774 inc VIRQInstalled,u ; Flag it's installed | |
775 VIRQOut puls X,Y,D | |
776 rts | |
777 | |
778 * IRQ service routine for VIRQ (drive motor time) | |
779 * Entry: U=Ptr to VIRQ memory area | |
780 IRQSvc pshs a | |
781 lda <D.DMAReq | |
782 beq L0509 | |
783 bsr InsVIRQ | |
784 bra IRQOut | |
785 L0509 | |
786 IFNE DragonAlpha | |
787 lbsr AlphaDskCtl | |
788 ELSE | |
789 sta >DskCtl | |
790 ENDC | |
791 | |
792 clr u00B5,u | |
793 clr VIRQInstalled,u | |
794 IFEQ Level-1 | |
795 clr >D.DskTmr | |
796 ELSE | |
797 clr <D.MotOn | |
798 ENDC | |
799 IRQOut puls pc,a | |
800 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
801 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
802 FDCCmd |
1735 | 803 bsr FDCCmdMotorOn |
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 ; Delay routine ! |
1735 | 806 Delay lbsr Delay2 |
807 Delay2 lbsr Delay3 | |
808 Delay3 rts | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
809 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
810 * SetStat |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
811 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
812 * Entry: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
813 * A = function code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
814 * Y = address of path descriptor |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
815 * U = address of device memory area |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
816 * |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
817 * Exit: |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
818 * CC = carry set on error |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
819 * B = error code |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
820 * |
1735 | 821 SetStat ldx PD.Rgs,y ; Retrieve request |
822 ldb R$B,x | |
1734 | 823 |
1735 | 824 cmpb #SS.Reset ; Restore to track 0. |
825 beq ResetTrack0 | |
826 cmpb #SS.Wtrk ; Write (format) a track | |
827 beq DoWriteTrack | |
828 comb | |
829 ldb #E$UnkSvc | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
830 SetStatEnd |
1735 | 831 rts |
1734 | 832 ; |
833 ; Write (format) a track | |
834 ; | |
835 | |
836 DoWriteTrack | |
1735 | 837 lbsr SelectDrive ; Select drive |
838 lda R$Y+1,x | |
839 LBSR SetSide ; Set Side 2 if appropriate | |
840 LDA R$U+1,X | |
841 BSR SetWPC ; Set WPC by disk type | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
842 |
1734 | 843 ;L02D5 |
1735 | 844 ldx >CDrvTab,u |
845 lbsr SeekTS ; Move to correct track | |
846 bcs SetStatEnd | |
847 ldx PD.Rgs,y | |
848 ldx R$X,x | |
849 ldb #WtTkCmnd | |
850 pshs y,dp,cc | |
851 lbra WriteTrackCmd | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
852 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
853 ; Reset track 0 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
854 ResetTrack0 |
1735 | 855 lbsr SelectDrive ; Select drive |
856 ldx >CDrvTab,u | |
857 clr <V.Trak,x ; Set current track as 0 | |
858 lda #$05 | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
859 ResetTrack0Loop |
1735 | 860 ldb #StpICmnd ; Step away from track 0 5 times |
861 pshs a | |
862 lbsr FDCCommand | |
863 puls a | |
864 deca | |
865 bne ResetTrack0Loop | |
866 ldb #RestCmnd ; Now issue a restore | |
867 lbra FDCCommand | |
1734 | 868 ; |
869 ;Start drive motors | |
870 ; | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
871 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
872 StartMotor |
1735 | 873 pshs x,b,a |
874 lda >D.DskTmr ; if timer <> 0 then skip as motor already on | |
875 bne MotorsRunning | |
876 lda #MotorOn ; else spin up | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
877 |
1735 | 878 IFNE DragonAlpha |
879 bsr AlphaDskCtl | |
880 ELSE | |
881 sta >DskCtl | |
882 ENDC | |
883 | |
884 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
|
885 StartMotorLoop |
1735 | 886 nop |
887 nop | |
888 leax -1,x | |
889 bne StartMotorLoop | |
1729 | 890 |
1735 | 891 MotorsRunning |
892 lbsr SetupVIRQ | |
893 ; lda #$F0 ; Start external motor timer | |
894 ; sta >D.DskTmr ; external to driver | |
895 puls pc,x,b,a | |
896 | |
1734 | 897 ; |
898 ; Set Write Precompensation according to media type | |
899 ; | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
900 |
1735 | 901 SetWPC PSHS A,B |
902 LDB PD.DNS,Y | |
903 BITB #T80Mask ; Is it 96 tpi drive | |
904 BNE SetWP1 | |
905 ASLA ; no then double | |
906 SetWP1 CMPA #32 ; WPC needed ? | |
907 BLS SetWP2 | |
908 LDA >DrivSel,U | |
909 ORA #WPCEn | |
910 STA >DrivSel,U | |
911 SetWP2 PULS A,B,PC | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
912 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
913 |
1735 | 914 IFNE DragonAlpha |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
915 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
916 ; 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
|
917 ; 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
|
918 ; 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
|
919 ; Drive selects, motor on and enable precomp. |
1729 | 920 ; This code now expects Alpha NMI/DDEN etc codes, as defined |
921 ; at top of this file (and dgndefs). The exception to this is | |
922 ; the drive number is still passed in the bottom 2 bits and | |
923 ; converted with a lookup table. | |
924 ; We do not need to preserve the ROM select bit as this code | |
925 ; operates in RAM only mode. | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
926 ; Also sets NMIFlag. |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
927 |
1729 | 928 |
929 DrvTab FCB Drive0A,Drive1A,Drive2A,Drive3A | |
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 AlphaDskCtl |
1735 | 932 PSHS x,A,B,CC |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
933 |
1735 | 934 PSHS A |
935 ANDA #NMIEn ; mask out nmi enable bit | |
936 sta >NMIFlag,u ; Save it for later use | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
937 |
1735 | 938 lda ,s ; Convert drives |
939 anda #%00000011 ; mask out drive number | |
940 leax DrvTab,pcr ; point at table | |
941 lda a,x ; get bitmap | |
942 ldb ,s | |
943 andb #%11111100 ; mask out drive number | |
944 stb ,s | |
945 ora ,s ; recombine | |
946 sta ,s | |
947 | |
948 bita #MotorOn ; test motor on ? | |
949 bne MotorRunning | |
950 | |
951 clra ; No, turn off other bits. | |
952 MotorRunning | |
953 anda #KnownBits ; Mask out bits we do not know the function of | |
954 sta ,s | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
955 |
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
956 |
1735 | 957 lda #AYIOREG ; AY-8912 IO register |
958 sta PIA2DB ; Output to PIA | |
959 ldb #AYREGLatch ; Latch register to modify | |
960 stb PIA2DA | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
961 |
1735 | 962 clr PIA2DA ; Idle AY |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
963 |
1735 | 964 lda ,s+ ; Fetch saved Drive Selects |
965 sta PIA2DB ; output to PIA | |
966 ldb #AYWriteReg ; Write value to latched register | |
967 stb PIA2DA ; Set register | |
1729 | 968 |
1735 | 969 clr PIA2DA ; Idle AY |
970 | |
971 PULS x,A,B,CC | |
972 RTS | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
973 |
1735 | 974 ENDC |
1821 | 975 |
976 | |
977 ShowReg | |
978 pshs d,x,y,cc,dp,u | |
979 pshs x | |
980 leax RegBuffD,pcr | |
981 bsr RegDToHex | |
982 | |
983 puls d | |
984 leax RegBuffX,pcr | |
985 bsr RegDToHex | |
986 | |
987 tfr Y,D | |
988 leax RegBuffY,pcr | |
989 bsr RegDToHex | |
990 | |
991 tfr u,d | |
992 leax RegBuffU,pcr | |
993 bsr RegDToHex | |
994 | |
995 tfr s,d | |
996 leax RegBuffS,pcr | |
997 bsr RegDToHex | |
998 | |
999 tfr cc,a | |
1000 leax RegBuffCC,pcr | |
1001 bsr RegAToHex | |
1002 | |
1003 tfr dp,a | |
1004 leax RegBuffDP,pcr | |
1005 bsr RegAToHex | |
1006 | |
1007 lda #1 * stdout | |
1008 leax RegBuff,pcr | |
1009 ldy #RegBuffEnd-RegBuff | |
1010 os9 I$write | |
1011 | |
1012 ShowRegEnd | |
1013 puls d,x,y,cc,dp,u | |
1014 rts | |
1015 | |
1016 RegDtoHex | |
1017 pshs d | |
1018 bsr RegAToHex | |
1019 tfr b,a | |
1020 bsr RegAToHex | |
1021 puls d | |
1022 rts | |
1023 | |
1024 RegAToHex | |
1025 pshs d,y | |
1026 | |
1027 leay HexTable,pcr | |
1028 tfr a,b | |
1029 anda #$f0 | |
1030 lsra | |
1031 lsra | |
1032 lsra | |
1033 lsra | |
1034 lda a,y | |
1035 sta ,x+ | |
1036 tfr b,a | |
1037 anda #$0f | |
1038 lda a,y | |
1039 sta ,x+ | |
1040 | |
1041 puls d,y | |
1042 rts | |
1043 | |
1044 RetryErrorDisplay | |
1045 pshs a,x,cc | |
1046 | |
1047 lda DskError,u | |
1048 leax ErrCode,pcr | |
1049 bsr RegAToHex | |
1050 | |
1051 leax RetryMess,pcr | |
1052 bsr PrintStdOut | |
1053 puls a,x,cc,pc | |
1054 | |
1055 | |
1056 PrintDot | |
1057 pshs x,cc | |
1058 leax DotMess,pcr | |
1059 bsr PrintStdOut | |
1060 puls x,cc,pc | |
1061 | |
1062 | |
1063 PrintReadDone | |
1064 pshs x,cc | |
1065 leax ReadDoneMess,pcr | |
1066 bsr PrintStdOut | |
1067 puls x,cc,pc | |
1068 | |
1069 PrintReadDoneFail | |
1070 pshs x,cc | |
1071 leax ReadDoneFailMess,pcr | |
1072 bsr PrintStdOut | |
1073 puls x,cc,pc | |
1074 | |
1075 | |
1076 PrintStdOut | |
1077 pshs d,x,y,u,cc,dp | |
1078 leax -2,x | |
1079 ldy ,x++ | |
1080 lda #1 | |
1081 os9 I$write | |
1082 puls d,x,y,u,cc,dp,pc | |
1083 | |
1084 PrintCtrlByte | |
1085 pshs a,cc,x | |
1086 | |
1087 leax CtrlCode,pcr | |
1088 bsr RegAToHex | |
1089 | |
1090 leax CtrlMess,pcr | |
1091 ldy #CtrlMessLen | |
1092 bsr PrintStdOut | |
1093 puls a,cc,x,pc | |
1094 | |
1095 PrintCmdByte | |
1096 pshs a,cc,x | |
1097 | |
1098 leax CmdCode,pcr | |
1099 bsr RegAToHex | |
1100 | |
1101 leax CmdMess,pcr | |
1102 bsr PrintStdOut | |
1103 puls a,cc,x,pc | |
1104 | |
1105 PrintNMIMess | |
1106 pshs x,cc | |
1107 leax NMIMess,pcr | |
1108 bsr PrintStdOut | |
1109 puls x,cc,pc | |
1110 | |
1111 | |
1112 PrintTimeout | |
1113 pshs x,cc | |
1114 leax TimeoutMess,pcr | |
1115 bsr PrintStdOut | |
1116 puls x,cc,pc | |
1117 | |
1118 RegBuff | |
1119 fcc "A B X Y U " | |
1120 fcb C$CR,C$LF | |
1121 RegBuffD | |
1122 fcc "0000 " | |
1123 RegBuffX | |
1124 fcc "0000 " | |
1125 RegBuffY | |
1126 fcc "0000 " | |
1127 RegBuffU | |
1128 fcc "0000 " | |
1129 RegBuffS | |
1130 fcc "0000 " | |
1131 RegBuffCC | |
1132 fcc "00 " | |
1133 RegBuffDP | |
1134 fcc "00 " | |
1135 | |
1136 fcb C$CR,C$LF,0 | |
1137 RegBuffEnd | |
1138 | |
1139 HexTable | |
1140 fcc "0123456789ABCDEF" | |
1141 | |
1142 | |
1143 fdb RetryMessLen | |
1144 RetryMess | |
1145 fcc "Read error: retry (" | |
1146 ErrCode fcc "00)" | |
1147 fcb C$CR,C$LF,0 | |
1148 | |
1149 RetryMessLen EQU *-RetryMess | |
1150 | |
1151 | |
1152 fdb CtrlMessLen | |
1153 CtrlMess | |
1154 fcc "Control byte (" | |
1155 CtrlCode fcc "00)" | |
1156 fcb C$CR,C$LF,0 | |
1157 CtrlMessLen EQU *-CtrlMess | |
1158 | |
1159 | |
1160 | |
1161 fdb CtrlMessLen | |
1162 CmdMess | |
1163 fcc "Command byte (" | |
1164 CmdCode fcc "00)" | |
1165 fcb C$CR,C$LF,0 | |
1166 CmdMessLen EQU *-CmdMess | |
1167 | |
1168 fdb 1 | |
1169 DotMess fcc "." | |
1170 fcb 0 | |
1171 | |
1172 | |
1173 fdb ReadDoneMessLen | |
1174 ReadDoneMess | |
1175 fcc "Read Succeded" | |
1176 fcb C$CR,C$LF,0 | |
1177 ReadDoneMessLen EQU *-ReadDoneMess | |
1178 | |
1179 fdb ReadDoneFailMessLen | |
1180 ReadDoneFailMess | |
1181 fcc "Read Failed" | |
1182 fcb C$CR,C$LF,0 | |
1183 ReadDoneFailMessLen EQU *-ReadDoneFailMess | |
1184 | |
1185 | |
1186 fdb NMIMessLen | |
1187 NMIMess | |
1188 fcc "In NMI" | |
1189 fcb C$CR,C$LF,0 | |
1190 NMIMessLen EQU *-NMIMess | |
1191 | |
1192 fdb TimeoutMessLen | |
1193 TimeoutMess | |
1194 fcc "Timout !" | |
1195 fcb C$CR,C$LF,0 | |
1196 TimeoutMessLen EQU *-TimeoutMess | |
1727
78ce0a5ffc8e
Incorporated changes and additions made by Phill Harvey-Smith for the
boisy
parents:
1533
diff
changeset
|
1197 |
1735 | 1198 emod |
1199 eom equ * | |
1200 end |