Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/boot_1773.asm @ 1515:30c1d42f3913
Added comments, slow optimization progress
author | boisy |
---|---|
date | Thu, 22 Jan 2004 18:42:14 +0000 |
parents | b7d6cb1df834 |
children | 9a9734ef451c |
rev | line source |
---|---|
230 | 1 ******************************************************************** |
1287 | 2 * Boot - WD1773 Boot module |
230 | 3 * |
4 * $Id$ | |
5 * | |
1287 | 6 * Edt/Rev YYYY/MM/DD Modified by |
7 * Comment | |
230 | 8 * ------------------------------------------------------------------ |
1287 | 9 * 4 1985/??/?? |
10 * Original Tandy distribution version. | |
11 * | |
12 * 6 1998/10/12 Boisy G. Pitre | |
13 * Obtained from L2 Upgrade archive, has 6ms step rate and disk timeout | |
14 * changes. | |
15 * | |
16 * 6r2 2003/05/18 Boisy G. Pitre | |
17 * Added '.' output for each sector for OS-9 L2 and NitrOS9 for | |
18 * Mark Marlette (a special request :). | |
1291
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
19 * |
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
20 * 6r3 2003/08/31 Robert Gault |
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
21 * Put BLOB-stop code in place, changed orb #$30 to orb #$28 |
230 | 22 |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
23 nam Boot |
1287 | 24 ttl WD1773 Boot module |
0 | 25 |
1287 | 26 IFP1 |
0 | 27 use defsfile |
28 use rbfdefs | |
1287 | 29 ENDC |
0 | 30 |
1515 | 31 * Sector Size |
32 SECTSIZE equ 256 | |
33 | |
34 | |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
35 * Step Rate: |
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
36 * $00 = 6ms |
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
37 * $01 = |
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
38 * $02 = |
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
39 * $03 = 30ms |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
1166
diff
changeset
|
40 STEP set $00 |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
41 |
1463
c086c2d613cf
Robert Gault added ability to easily change which drive is used as boot drive.
boisy
parents:
1363
diff
changeset
|
42 *Drive value & number |
c086c2d613cf
Robert Gault added ability to easily change which drive is used as boot drive.
boisy
parents:
1363
diff
changeset
|
43 * $01 = 0 |
c086c2d613cf
Robert Gault added ability to easily change which drive is used as boot drive.
boisy
parents:
1363
diff
changeset
|
44 * $02 = 1 |
c086c2d613cf
Robert Gault added ability to easily change which drive is used as boot drive.
boisy
parents:
1363
diff
changeset
|
45 * $03 = 2 |
c086c2d613cf
Robert Gault added ability to easily change which drive is used as boot drive.
boisy
parents:
1363
diff
changeset
|
46 BootDr set $01 |
c086c2d613cf
Robert Gault added ability to easily change which drive is used as boot drive.
boisy
parents:
1363
diff
changeset
|
47 |
1287 | 48 tylg set Systm+Objct |
0 | 49 atrv set ReEnt+rev |
1291
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
50 rev set $03 |
1287 | 51 edition set 6 |
230 | 52 |
0 | 53 mod eom,name,tylg,atrv,start,size |
230 | 54 |
1515 | 55 drvsel rmb 1 |
1514 | 56 buffptr rmb 2 |
57 currtrak rmb 1 | |
1515 | 58 *ddfmt rmb 1 |
1514 | 59 ddtks rmb 1 no. of sectors per track |
1515 | 60 *ddtot rmb 1 |
1514 | 61 dblsided rmb 1 |
1515 | 62 side rmb 1 |
0 | 63 size equ . |
64 | |
65 name fcs /Boot/ | |
230 | 66 fcb edition |
0 | 67 |
1287 | 68 start clra clear A |
69 ldb #size get our 'stack' size | |
70 MakeStak pshs a save 0 on stack | |
71 decb and continue... | |
72 bne MakeStak until we've created our stack | |
0 | 73 |
1287 | 74 tfr s,u put 'stack statics' in U |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
75 ldx #DPort+8 |
0 | 76 lda #$D0 |
77 sta ,x | |
1515 | 78 lbsr Delay2 delay a bit |
0 | 79 lda ,x |
80 lda #$FF | |
1515 | 81 sta currtrak,u set current track to 255 |
82 leax >NMIRtn,pcr point to NMI routine | |
1166 | 83 IFGT Level-1 |
1515 | 84 stx <D.NMI save address |
1166 | 85 ELSE |
1515 | 86 stx >D.XNMI+1 save address |
0 | 87 lda #$7E |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
1166
diff
changeset
|
88 sta >D.XNMI |
1166 | 89 ENDC |
1515 | 90 lda #$08+BootDr permit alternate drives |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
91 sta >DPort |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
92 |
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
93 * delay loop |
1166 | 94 IFGT Level-1 |
0 | 95 ldd #$C350 |
1166 | 96 ELSE |
249 | 97 ldd #$61A8 |
1166 | 98 ENDC |
1363 | 99 IFNE H6309 |
1287 | 100 nop |
101 ENDC | |
102 L003A nop | |
103 nop | |
1363 | 104 IFNE H6309 |
1287 | 105 nop |
106 nop | |
107 nop | |
108 ENDC | |
0 | 109 subd #$0001 |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
110 bne L003A |
0 | 111 |
1515 | 112 * search for memory to use as a sector buffer |
113 pshs u,y,x,b,a save regs | |
114 ldd #SECTSIZE get sector size in D | |
115 os9 F$SRqMem request that much memory | |
116 bcs L00AA branch if there is an error | |
117 tfr u,d move pointer to D temporarily | |
118 ldu $06,s restore U (saved earlier) | |
119 std buffptr,u save alloced mem pointer in statics | |
1287 | 120 clrb |
0 | 121 |
122 * go get LSN0 | |
1515 | 123 ldx #$0000 we want LSN0 |
124 bsr ReadSect go get it | |
125 bcs L00AA branch if error | |
0 | 126 |
1515 | 127 * From LSN0, we get various pieces of info. |
128 * ldd DD.TOT+1,y | |
129 * std ddtot,u | |
1514 | 130 lda <DD.FMT,y get format byte of LSN0 |
1515 | 131 * sta ddfmt,u save it for ??? |
1514 | 132 anda #FMT.SIDE keep side bit |
133 sta dblsided,u and save it | |
134 lda DD.TKS,y get sectors per track | |
135 sta ddtks,u and save | |
1515 | 136 ldd <DD.BSZ,y get bootfile size |
137 std ,s save on stack | |
138 ldx <DD.BT+1,y get start sector of bootfile | |
139 pshs x push on the stack | |
140 ldd #SECTSIZE load D with sector size | |
141 ldu buffptr,u and point to the buffer pointer | |
142 os9 F$SRtMem return the memory | |
143 ldd $02,s get the bootfile size | |
1166 | 144 IFGT Level-1 |
1287 | 145 os9 F$BtMem |
1166 | 146 ELSE |
1515 | 147 os9 F$SRqMem get the memory from the system |
1166 | 148 ENDC |
1515 | 149 puls x pull bootfile start sector off stack |
150 bcs L00AA branch if error | |
151 stu $02,s save pointer to bootfile mem on stack | |
152 tfr u,d transfer to D for later store | |
153 ldu $06,s restore original U | |
154 * ldd $02,s get pointer to bootfile mem | |
155 std buffptr,u and save pointer | |
156 ldd ,s get bootfile size | |
157 beq L00A3 branch if zero | |
0 | 158 |
159 * this loop reads a sector at a time from the bootfile | |
1515 | 160 * X = start sector |
161 * D = bootfile size | |
162 L0091 pshs x,b,a save params | |
1287 | 163 clrb |
1515 | 164 bsr ReadSect read sector |
165 bcs L00A8 branch if error | |
1287 | 166 IFGT Level-1 |
1515 | 167 lda #'. dump out a period for boot debugging |
168 jsr <D.BtBug do the debug stuff | |
1287 | 169 ENDC |
1515 | 170 puls x,b,a get params |
171 inc buffptr,u point to next 256 bytes | |
172 leax 1,x move to next sector | |
173 subd #SECTSIZE subtract sector bytes from size | |
174 bhi L0091 continue if more space | |
1287 | 175 L00A3 clrb |
0 | 176 puls b,a |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
177 bra L00AC |
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
178 L00A8 leas $04,s |
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
179 L00AA leas $02,s |
1295
cbe5b5313422
Removed poke to FFD9 for CoCo 3 since this is done by rel
boisy
parents:
1291
diff
changeset
|
180 L00AC puls u,y,x |
1287 | 181 leas size,s clean up stack |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
182 clr >DPort shut off floppy disk |
1287 | 183 rts |
0 | 184 |
1463
c086c2d613cf
Robert Gault added ability to easily change which drive is used as boot drive.
boisy
parents:
1363
diff
changeset
|
185 L00B7 lda #$28+BootDr permit alternate drives |
1515 | 186 sta drvsel,u |
1514 | 187 clr currtrak,u |
0 | 188 lda #$05 |
1287 | 189 lbsr L0170 |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
190 ldb #STEP |
1287 | 191 lbra L0195 |
0 | 192 |
1287 | 193 * Read a sector from the 1773 |
194 * Entry: X = LSN to read | |
195 ReadSect lda #$91 | |
196 cmpx #$0000 LSN0? | |
1515 | 197 bne L00DF branch if not |
198 bsr L00DF else branch subroutine | |
199 bcs L00D6 branch if error | |
200 ldy buffptr,u get buffer pointer in Y for caller | |
1287 | 201 clrb |
202 L00D6 rts | |
203 | |
204 L00D7 bcc L00DF | |
0 | 205 pshs x,b,a |
1287 | 206 bsr L00B7 |
0 | 207 puls x,b,a |
1515 | 208 L00DF pshs x,b,a save LSN, command |
1287 | 209 bsr L00EA |
1515 | 210 puls x,b,a get LSN, command |
211 bcc L00D6 branch if OK | |
1287 | 212 lsra |
213 bne L00D7 | |
214 L00EA bsr L013C | |
1515 | 215 bcs L00D6 if error, return to caller |
216 ldx buffptr,u get address of buffer to fill | |
217 orcc #IntMasks mask interrupts | |
218 pshs y save Y | |
0 | 219 ldy #$FFFF |
1463
c086c2d613cf
Robert Gault added ability to easily change which drive is used as boot drive.
boisy
parents:
1363
diff
changeset
|
220 ldb #$80 |
c086c2d613cf
Robert Gault added ability to easily change which drive is used as boot drive.
boisy
parents:
1363
diff
changeset
|
221 stb >DPort+8 |
1515 | 222 ldb drvsel,u |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
223 * Notes on the next line: |
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
224 * The byte in question comes after telling the controller that it should |
1515 | 225 * read a sector. RegB is then loaded (ldb drvsel,u) which means it is set to $29 |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
226 * (%00101001) or the default boot drive if sub L00B7 has been run. At this |
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
227 * point an orb #$30 or orb #%00110000 means that write precomp and double |
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
228 * density flags are or'd in. This does not make any sense at all for a |
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
229 * read command. I suppose the command may not even be needed but $28 just |
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
230 * ensures that motor on and double density are set. |
1308 | 231 * orb #$28 was $30 which RG thinks is an error |
232 * 09/02/03: Futher investigation shows that the OS-9 Level One Booter will | |
233 * FAIL if orb #$28 is used. It does not fail if orb #$30 is used. ???? | |
234 orb #$30 was $30 which RG thinks is an error | |
1515 | 235 tst side,u |
1287 | 236 beq L0107 |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
237 orb #$40 |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
238 L0107 stb >DPort |
1515 | 239 lbsr Delay2 |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
240 orb #$80 |
1291
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
241 * lda #$02 |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
242 *L0111 bita >DPort+8 |
1291
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
243 * bne L0123 |
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
244 * leay -$01,y |
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
245 * bne L0111 |
1515 | 246 * lda drvsel,u |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
247 * sta >DPort |
1291
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
248 * puls y |
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
249 * bra L0138 |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
250 stb >DPort |
1291
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
251 nop |
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
252 nop |
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
253 bra L0123 |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
254 L0123 lda >DPort+$0B |
0 | 255 sta ,x+ |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
256 * stb >DPort |
1291
92e9f7416fc9
Added BLOB-stop fix, changed one line as per Robert Gault's suggestion
boisy
parents:
1287
diff
changeset
|
257 nop |
1287 | 258 bra L0123 |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
259 |
1515 | 260 NMIRtn leas R$Size,s adjust stack |
0 | 261 puls y |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
262 ldb >DPort+8 |
0 | 263 bitb #$04 |
1287 | 264 beq L018F |
265 L0138 comb | |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
266 ldb #E$Read |
1287 | 267 rts |
0 | 268 |
1515 | 269 L013C lda #$08+BootDr permit alternate drives |
270 sta drvsel,u | |
271 clr side,u assume side 0 | |
0 | 272 tfr x,d |
273 cmpd #$0000 | |
1287 | 274 beq L016C |
1515 | 275 clr ,-s clear space on stack |
1514 | 276 tst dblsided,u disk double sided? |
277 beq L0162 branch if not | |
1287 | 278 bra L0158 |
1515 | 279 * Double-sided code |
280 L0152 com side,u | |
1287 | 281 bne L0158 |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
282 inc ,s |
1515 | 283 L0158 subb ddtks,u |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
284 sbca #$00 |
1287 | 285 bcc L0152 |
286 bra L0168 | |
287 L0160 inc ,s | |
1514 | 288 L0162 subb ddtks,u |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
289 sbca #$00 |
1287 | 290 bcc L0160 |
1514 | 291 L0168 addb #18 add sectors per track |
292 puls a get current track indicator off of stack | |
1287 | 293 L016C incb |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
294 stb >DPort+$0A |
1514 | 295 L0170 ldb currtrak,u |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
296 stb >DPort+$09 |
1514 | 297 cmpa currtrak,u |
1287 | 298 beq L018D |
1514 | 299 sta currtrak,u |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
300 sta >DPort+$0B |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
301 ldb #$10+STEP |
1287 | 302 bsr L0195 |
0 | 303 pshs x |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
304 ldx #$222E |
1287 | 305 L0187 leax -$01,x |
306 bne L0187 | |
0 | 307 puls x |
1287 | 308 L018D clrb |
309 rts | |
310 L018F bitb #$98 | |
311 bne L0138 | |
312 clrb | |
313 rts | |
1515 | 314 L0195 bsr Delay1 |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
315 L0197 ldb >DPort+8 |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
316 bitb #$01 |
1287 | 317 bne L0197 |
318 rts | |
1515 | 319 L019F lda drvsel,u |
1296
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
320 sta >DPort |
fe008d68f79b
Added comment from Robert Gault, changed $FF4X to DPort
boisy
parents:
1295
diff
changeset
|
321 stb >DPort+$08 |
1287 | 322 rts |
1515 | 323 |
324 * Delay branches | |
325 Delay1 | |
1363 | 326 IFNE H6309 |
1287 | 327 nop |
328 ENDC | |
329 bsr L019F | |
1515 | 330 Delay2 |
1363 | 331 IFNE H6309 |
1287 | 332 nop |
333 nop | |
334 ENDC | |
1515 | 335 lbsr Delay3 |
336 Delay3 | |
1363 | 337 IFNE H6309 |
1287 | 338 nop |
339 nop | |
340 ENDC | |
1515 | 341 lbsr Delay4 |
342 Delay4 | |
1363 | 343 IFNE H6309 |
1287 | 344 nop |
345 ENDC | |
346 rts | |
210
6bf55704c623
Boot is adapted from OS-9 Level Two boot module, now boots from
boisy
parents:
201
diff
changeset
|
347 |
1166 | 348 IFGT Level-1 |
1287 | 349 * Filler to get $1D0 |
350 Filler fill $39,$1D0-3-* | |
1166 | 351 ENDC |
0 | 352 |
353 emod | |
354 eom equ * | |
48 | 355 end |
1287 | 356 |