annotate 3rdparty/utils/tlindner/sdrive.asm @ 3021:6d8121148774

Added sdrive.
author tlindner
date Sun, 30 Nov 2014 21:43:18 -0800
parents
children dfc911234945
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3021
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
1 ********************************************************************
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
2 * sdrive - Assign disk image to SDC slot
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
3 *
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
4 * $Id$
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
5 *
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
6 * Edt/Rev YYYY/MM/DD Modified by
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
7 * Comment
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
8 * ------------------------------------------------------------------
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
9 * 1 2014/11/30 tim lindner
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
10 * Started writing code.
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
11
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
12 nam sdrive
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
13 ttl Assign disk image to SDC slot
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
14
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
15 ifp1
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
16 use defsfile
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
17 endc
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
18
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
19 * Here are some tweakable options
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
20 DOHELP set 1 1 = include help info
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
21 STACKSZ set 32 estimated stack size in bytes
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
22 PARMSZ set 256 estimated parameter size in bytes
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
23
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
24 * Module header definitions
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
25 tylg set Prgrm+Objct
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
26 atrv set ReEnt+rev
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
27 rev set $00
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
28 edition set 1
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
29
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
30 *********************************************************************
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
31 *** Hardware Addressing
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
32 *********************************************************************
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
33 CTRLATCH equ $FF40 ; controller latch (write)
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
34 CMDREG equ $FF48 ; command register (write)
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
35 STATREG equ $FF48 ; status register (read)
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
36 PREG1 equ $FF49 ; param register 1
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
37 PREG2 equ $FF4A ; param register 2
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
38 PREG3 equ $FF4B ; param register 3
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
39 DATREGA equ PREG2 ; first data register
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
40 DATREGB equ PREG3 ; second data register
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
41 *********************************************************************
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
42 *** STATUS BIT MASKS
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
43 *********************************************************************
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
44 BUSY equ %00000001
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
45 READY equ %00000010
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
46 FAILED equ %10000000
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
47
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
48 mod eom,name,tylg,atrv,start,size
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
49
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
50 org 0
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
51 slot rmb 1
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
52
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
53 cleartop equ . everything up to here gets cleared at start
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
54 * Finally the stack for any PSHS/PULS/BSR/LBSRs that we might do
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
55 rmb STACKSZ+PARMSZ
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
56 size equ .
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
57
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
58 * The utility name and edition goes here
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
59 name fcs /sdrive/
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
60 fcb edition
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
61 * Place constant strings here
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
62 timeout fcc /Timeout./
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
63 fcb C$LF
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
64 fcb C$CR
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
65 timeoutL equ *-timout
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
66
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
67 targetInUse fcc /Target in use./
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
68 fcb C$LF
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
69 fcb C$CR
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
70 targetInUseL equ *-targetInUse
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
71
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
72 dirNotFound fcc /Directory not found./
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
73 fcb C$LF
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
74 fcb C$CR
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
75 dirNotFoundL equ *-dirNotFound
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
76
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
77 pathNameInvalid fcc /Pathname is invalid./
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
78 fcb C$LF
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
79 fcb C$CR
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
80 pathNameInvalidL equ *-pathNameInvalid
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
81
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
82 miscHardware fcc /Miscellaneous hardware error./
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
83 fcb C$LF
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
84 fcb C$CR
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
85 miscHardwareL equ *-miscHardware
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
86
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
87 unknown fcc /Unknown error./
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
88 fcb C$LF
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
89 fcb C$CR
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
90 unknownL equ *-unknown
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
91
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
92 targetNotFound fcc /Target not found./
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
93 fcb C$LF
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
94 fcb C$CR
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
95 targetNotFoundL equ *-targetNotFound
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
96
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
97 IFNE DOHELP
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
98 HlpMsg fcb C$LF
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
99 fcc /Use: sdrive <slot> <image name>/
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
100 fcb C$LF
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
101 fcb C$CR
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
102 fcc / <slot> is a number, either 0 or 1./
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
103 fcb C$LF
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
104 fcb C$CR
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
105 fcc / <image name> is valid path and image name./
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
106 fcb C$LF
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
107 fcb C$CR
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
108 fcc / <image name> can be blank to eject an image./
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
109 fcb C$LF
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
110 fcb C$CR
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
111 HlpMsgL equ *-HlpMsg
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
112 ENDC
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
113 *
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
114 * Here's how registers are set when this process is forked:
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
115 *
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
116 * +-----------------+ <-- Y (highest address)
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
117 * ! Parameter !
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
118 * ! Area !
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
119 * +-----------------+ <-- X, SP
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
120 * ! Data Area !
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
121 * +-----------------+
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
122 * ! Direct Page !
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
123 * +-----------------+ <-- U, DP (lowest address)
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
124 *
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
125 * D = parameter area size
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
126 * PC = module entry point abs. address
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
127 * CC = F=0, I=0, others undefined
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
128
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
129 * The start of the program is here.
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
130 * main program
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
131 start
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
132 cmpd #1
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
133 lbeq ShowHelp
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
134 subb #1
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
135 sbca #0
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
136 clr d,x put null at end of parameter area (not CR)
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
137 leas -3,s make some more room in parameter area
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
138 lbsr SkipSpcs
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
139 clr slot,u
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
140 lda ,x+
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
141 cmpa #'0
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
142 beq slot0
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
143 cmpa #'1
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
144 beq slot1
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
145 lbra ShowHelp
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
146 slot1 inc slot,u
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
147 slot0
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
148 lbsr SkipSpcs skip forward to parameter
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
149 leax -2,x back off two bytes
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
150 * Add M: to start of parameter
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
151 ldd #"M:
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
152 std ,x
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
153 * setup SDC for command mode
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
154 orcc #IntMasks mask interrupts
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
155 lbsr CmdSetup
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
156 bcc sendCommand
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
157 andcc #^IntMasks unmask interrupts
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
158 ldb #$f6 Not ready error code
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
159 lbra Exit
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
160 sendCommand
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
161 ldb #$e0
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
162 orb slot,u
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
163 stb CMDREG send to SDC command register
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
164 exg a,a wait
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
165 lbsr txData transmit buffer to SDC
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
166 lda #$0
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
167 sta CTRLATCH
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
168 andcc #^IntMasks unmask interrupts
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
169 bcc ExitOK
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
170 tstb
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
171 beq timeOutError
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
172 bitb #$20
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
173 bne targetInUseError
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
174 bitb #$10
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
175 bne targetNotFoundError
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
176 bitb #$08
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
177 bne miscHardwareError
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
178 bitb #$04
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
179 bne pathNameInvalidError
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
180 bra unknownError
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
181 targetInUseError
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
182 ldy #targetInUseL
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
183 leax targetInUse,pc
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
184 bra wrtErr
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
185 targetNotFoundError
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
186 ldy #targetNotFoundL
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
187 leax targetNotFound,pc
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
188 bra wrtErr
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
189 miscHardwareError
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
190 ldy #miscHardwareL
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
191 leax miscHardware,pc
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
192 bra wrtErr
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
193 pathNameInvalidError
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
194 ldy #pathNameInvalidL
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
195 leax pathNameInvalid,pc
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
196 bra wrtErr
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
197 unknownError
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
198 ldy #unknownL
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
199 leax unknown,pc
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
200 bra wrtErr
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
201 timeOutError
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
202 ldy #timeoutL
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
203 leax timeout,pc
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
204 wrtErr lda #$2
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
205 os9 I$Write
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
206
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
207 ExitOK clrb
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
208 Exit
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
209 os9 F$Exit
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
210
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
211 ShowHelp equ *
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
212 IFNE DOHELP
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
213 leax >HlpMsg,pcr point to help message
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
214 ldy #HlpMsgL get length
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
215 lda #$02 std error
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
216 os9 I$Write write it
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
217 ENDC
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
218 bra ExitOk
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
219
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
220 * Stolen from BASIC09
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
221 * Convert # in D to ASCII version (decimal)
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
222 L09BA pshs y,x,d Preserve End of data mem ptr,?,Data mem size
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
223 pshs d Preserve data mem size again
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
224 leay <L09ED,pc Point to decimal table (for integers)
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
225 L09C1 ldx #$2F00
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
226 L09C4 puls d Get data mem size
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
227 L09C6 leax >$0100,x Bump X up to $3000
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
228 subd ,y Subtract value from table
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
229 bhs L09C6 No underflow, keep subtracting current power of 10
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
230 addd ,y++ Restore to before underflow state
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
231 pshs d Preserve remainder of this power
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
232 ldd ,y Get next lower power of 10
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
233 tfr x,d Promptly overwrite it with X (doesn't chg flags)
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
234 beq L09E6 If finished table, skip ahead
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
235 cmpd #$3000 Just went through once?
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
236 beq L09C1 Yes, reset X & do again
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
237 * lbsr L1373 Go save A @ [<u0082]
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
238 ldb 11,u Write A to output buffer
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
239 sta b,u
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
240 incb
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
241 stb 11,u
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
242 ldx #$2F01 Reset X differently
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
243 bra L09C4 Go do again
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
244
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
245 L09E6
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
246 * lbsr L1373 Go save A @ [<u0082]
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
247 ldb 11,u Write A to output buffer
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
248 sta b,u
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
249 incb
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
250 stb 11,u
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
251 leas 2,s Eat stack
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
252 puls pc,y,x,d Restore regs & return
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
253
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
254 * Table of decimal values
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
255 L09ED fdb $2710 10000
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
256 fdb $03E8 1000
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
257 fdb $0064 100
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
258 fdb $000A 10
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
259 fdb $0001 1
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
260 fdb $0000 0
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
261
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
262 *********************************************************************
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
263 * Setup Controller for Command Mode
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
264 *********************************************************************
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
265 * EXIT:
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
266 * Carry cleared on success, set on timeout
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
267 * All other registers preserved
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
268 *
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
269 CmdSetup pshs x,a ; preserve registers
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
270 lda #$43 ; put controller into..
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
271 sta CTRLATCH ; Command Mode
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
272 ldx #0 ; long timeout counter = 65536
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
273 busyLp lda STATREG ; read status
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
274 lsra ; move BUSY bit to Carry
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
275 bcc setupExit ; branch if not busy
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
276 leax -1,x ; decrement timeout counter
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
277 bne busyLp ; loop if not timeout
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
278 lda #0 ; clear A without clearing Carry
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
279 sta CTRLATCH ; put controller back in emulation
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
280 setupExit puls a,x,pc ; restore registers and return
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
281
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
282 *********************************************************************
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
283 * Send 256 bytes of Command Data to SDC Controller
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
284 *********************************************************************
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
285 * ENTRY:
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
286 * X = Data Address
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
287 *
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
288 * EXIT:
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
289 * B = Status
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
290 * Carry set on failure or timeout
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
291 * All other registers preserved
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
292 *
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
293 txData pshs u,y,x ; preserve registers
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
294 ldy #DATREGA ; point Y at the data registers
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
295 * Poll for Controller Ready or Failed.
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
296 comb ; set carry in anticipation of failure
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
297 ldx #0 ; max timeout counter = 65536
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
298 txPoll ldb -2,y ; read status register
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
299 bmi txExit ; branch if FAILED bit is set
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
300 bitb #READY ; test the READY bit
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
301 bne txRdy ; branch if ready
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
302 leax -1,x ; decrement timeout counter
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
303 beq txExit ; exit if timeout
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
304 bra txPoll ; poll again
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
305 * Controller Ready. Send the Data.
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
306 txRdy ldx ,s ; re-load data address into X
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
307 ldb #128 ; 128 words to send (256 bytes)
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
308 txWord ldu ,x++ ; get data word from source
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
309 stu ,y ; send to controller
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
310 decb ; decrement word loop counter
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
311 bne txWord ; loop until done
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
312 * Done sending data, wait for result
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
313 ldx #0 ; wait for result
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
314 comb ; assume error
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
315 txWait ldb -2,y ; load status
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
316 bmi txExit ; branch if failed
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
317 lsrb ; clear carry if not busy
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
318 bcc txExit ; test ready bit
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
319 leax -1,x ; decrememnt timeout counter
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
320 bne txWait ; loop back until timeout
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
321 txExit puls x,y,u,pc ; restore registers and return
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
322
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
323 *********************************************************************
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
324 * Retrieve 256 bytes of Response Data from SDC Controller
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
325 *********************************************************************
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
326 * ENTRY:
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
327 * X = Data Storage Address
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
328 *
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
329 * EXIT:
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
330 * B = Status
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
331 * Carry set on failure or timeout
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
332 * All other registers preserved
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
333 *
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
334 rxData pshs u,y,x ; preserve registers
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
335 ldy #DATREGA ; point Y at the data registers
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
336 * Poll for Controller Ready or Failed.
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
337 comb ; set carry in anticipation of failure
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
338 ldx #0 ; max timeout counter = 65536
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
339 rxPoll ldb -2,y ; read status register
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
340 bmi rxExit ; branch if FAILED bit is set
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
341 bitb #READY ; test the READY bit
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
342 bne rxRdy ; branch if ready
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
343 leax -1,x ; decrement timeout counter
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
344 beq rxExit ; exit if timeout
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
345 bra rxPoll ; poll again
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
346 * Controller Ready. Grab the Data.
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
347 rxRdy ldx ,s ; re-load data address into X
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
348 ldb #128 ; 128 words to read (256 bytes)
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
349 rxWord ldu ,y ; read data word from controller
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
350 stu ,x++ ; put into storage
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
351 decb ; decrement word loop counter
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
352 bne rxWord ; loop until done
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
353 clrb ; success! clear the carry flag
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
354 rxExit puls x,y,u,pc ; restore registers and return
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
355
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
356 *********************************************************************
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
357 * This routine skip over spaces and commas
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
358 *********************************************************************
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
359 * Entry:
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
360 * X = ptr to data to parse
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
361 * Exit:
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
362 * X = ptr to first non-whitespace char
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
363 * A = non-whitespace char
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
364 SkipSpcs lda ,x+
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
365 cmpa #C$SPAC
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
366 beq SkipSpcs
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
367 leax -1,x
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
368 rts
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
369
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
370 emod
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
371 eom equ *
6d8121148774 Added sdrive.
tlindner
parents:
diff changeset
372 end