diff --git a/AppleIISd.lst b/AppleIISd.lst index 7196222..9f87cb0 100644 --- a/AppleIISd.lst +++ b/AppleIISd.lst @@ -10,697 +10,717 @@ 10 * 11 ******************************** 12 - 15-JUL-17 18:27 + 16-JUL-17 15:06 14 15 XC ; enable 65C02 code - 16 ORG $C800 ; Expansion ROM - 17 - 18 * Memory defines - 19 - 20 SLOT16 = $2B ; $s0 -> slot * 16 - 21 WORK = $3C - 22 SLOT = $3D ; $0s - 23 CMDLO = $40 - 24 CMDHI = $41 - 25 - 26 CURSLOT = $07F8 ; $Cs - 27 DATA = $C080 - 28 CTRL = DATA+1 - 29 DIV = DATA+2 - 30 SS = DATA+3 - 31 R30 = $0478 - 32 R31 = $04F8 - 33 R32 = $0578 - 34 R33 = $05F8 - 35 - 36 * Constants - 37 - 38 SSNONE = $0F - 39 SS0 = $0E - 40 DUMMY = $FF - 41 + 16 DEBUG = 1 + 17 DO DEBUG + 18 ORG $8000 + 19 ELSE + 20 ORG $C800 ; Expansion ROM + 21 FIN + 22 + 23 * Memory defines + 24 + 25 SLOT16 = $2B ; $s0 -> slot * 16 + 26 WORK = $3C + 27 SLOT = $3D ; $0s + 28 CMDLO = $40 + 29 CMDHI = $41 + 30 + 31 CURSLOT = $07F8 ; $Cs + 32 DATA = $C080 + 33 CTRL = DATA+1 + 34 DIV = DATA+2 + 35 SS = DATA+3 + 36 R30 = $0478 + 37 R31 = $04F8 + 38 R32 = $0578 + 39 R33 = $05F8 + 40 + 41 * Constants 42 - 43 ******************************** - 44 * - 45 * Install SD card driver - 46 * - 47 ******************************** - 48 - 49 * signature bytes - 50 -C800: A2 20 51 LDX #$20 -C802: A0 00 52 LDY #$00 -C804: A2 03 53 LDX #$03 -C806: 86 3C 54 STX WORK + 43 SSNONE = $0F + 44 SS0 = $0E + 45 DUMMY = $FF + 46 + 47 + 48 ******************************** + 49 * + 50 * Install SD card driver + 51 * + 52 ******************************** + 53 + 54 * signature bytes 55 - +8000: A2 20 56 LDX #$20 +8002: A0 00 57 LDY #$00 +8004: A2 03 58 LDX #$03 +8006: 86 3C 59 STX WORK ===== Page 2 ===== - - 57 * find slot nr - 58 -C808: 20 58 FF 59 JSR $FF58 -C80B: BA 60 TSX -C80C: BD 00 01 61 LDA $0100,X -C80F: 29 0F 62 AND #$0F -C811: 85 3D 63 STA SLOT ; $0s -C813: 09 C0 64 ORA #$C0 -C815: 8D F8 07 65 STA CURSLOT ; $Cs -C818: 0A 66 ASL A -C819: 0A 67 ASL A -C81A: 0A 68 ASL A -C81B: 0A 69 ASL A -C81C: 85 2B 70 STA SLOT16 ; $s0 - 71 -C81E: 20 00 C9 72 JSR INIT -C821: 2C FF CF 73 BIT $CFFF - 74 - 75 * - 76 * TODO: check for init error - 77 * - 78 - 79 * see if slot has a driver already - 80 -C824: AE 31 BF 81 LDX $BF31 ; get devcnt -C827: BD 32 BF 82 INSLP LDA $BF32,X ; get a devnum -C82A: 29 70 83 AND #$70 ; isolate slot -C82C: C5 2B 84 CMP SLOT16 ; slot? -C82E: F0 2E 85 BEQ INSOUT ; yes, skip it -C830: CA 86 DEX -C831: 10 F4 87 BPL INSLP ; keep up the search + + 60 + 61 * find slot nr + 62 + 63 DO DEBUG +8008: A9 04 64 LDA #$04 +800A: 85 3D 65 STA SLOT +800C: A9 C4 66 LDA #$C4 +800E: 8D F8 07 67 STA CURSLOT +8011: A9 40 68 LDA #$40 +8013: 85 2B 69 STA SLOT16 + 70 ELSE + 71 JSR $FF58 + 72 TSX + 73 LDA $0100,X + 74 AND #$0F + 75 STA SLOT ; $0s + 76 ORA #$C0 + 77 STA CURSLOT ; $Cs + 78 ASL A + 79 ASL A + 80 ASL A + 81 ASL A + 82 STA SLOT16 ; $s0 + 83 FIN +8015: AA 84 TAX ; X holds now SLOT16 + 85 +8016: 20 00 81 86 JSR INIT +8019: 2C FF CF 87 BIT $CFFF 88 - 89 * restore the devnum to the list - 90 -C833: AE 31 BF 91 LDX $BF31 ; get devcnt again -C836: E0 0D 92 CPX #$0D device table full? -C838: D0 03 93 BNE INSLP2 + 89 * + 90 * TODO: check for init error + 91 * + 92 + 93 * see if slot has a driver already 94 -C83A: 4C 5E C8 95 JMP INSOUT ; do something! - 96 -C83D: BD 31 BF 97 INSLP2 LDA $BF32-1,X ; move all entries down -C840: 9D 32 BF 98 STA $BF32,X ; to make room at front -C843: CA 99 DEX ; for a new entry -C844: D0 F7 100 BNE INSLP2 -C846: A9 04 101 LDA #$04 ; ProFile type device -C848: 05 2B 102 ORA SLOT16 -C84A: 8D 32 BF 103 STA $BF32 ; slot, drive 1 at top of list -C84D: EE 31 BF 104 INC $BF31 ; update devcnt - 105 - - ===== Page 3 ===== - - 107 * now insert the device driver vector +801C: AE 31 BF 95 LDX $BF31 ; get devcnt +801F: BD 32 BF 96 INSLP LDA $BF32,X ; get a devnum +8022: 29 70 97 AND #$70 ; isolate slot +8024: C5 2B 98 CMP SLOT16 ; slot? +8026: F0 31 99 BEQ INSOUT ; yes, skip it +8028: CA 100 DEX +8029: 10 F4 101 BPL INSLP ; keep up the search + 102 + 103 * restore the devnum to the list + 104 +802B: AE 31 BF 105 LDX $BF31 ; get devcnt again +802E: E0 0D 106 CPX #$0D ; device table full? +8030: D0 06 107 BNE INSLP2 108 -C850: A5 3D 109 LDA SLOT -C852: AA 110 TAX -C853: A9 5F 111 LDA #DRIVER + 130 ELSE + 131 LDA CURSLOT + 132 FIN +8056: 9D 11 BF 133 STA $BF11,X + 134 +8059: 60 135 INSOUT RTS + 136 + 137 + 138 ******************************** + 139 * + 140 * Jump table + 141 * + 142 ******************************** + 143 +805A: D8 144 DRIVER CLD + 145 DO DEBUG +805B: A9 04 146 LDA #$04 +805D: 85 3D 147 STA SLOT +805F: A9 C4 148 LDA #$C4 +8061: 8D F8 07 149 STA CURSLOT +8064: A9 40 150 LDA #$40 +8066: 85 2B 151 STA SLOT16 + 152 ELSE + 153 JSR $FF58 ; find slot nr + 154 TSX + 155 LDA $0100,X + 156 AND #$0F + 157 STA SLOT ; $0s + 158 ORA #$C0 + 159 STA CURSLOT ; $Cs + 160 ASL A + 161 ASL A + 162 ASL A + 163 ASL A + 164 STA SLOT16 ; $s0 + 165 FIN +8068: AA 166 TAX ; X holds now SLOT16 167 - 168 ******************************** - 169 * - 170 * Initialize SD card - 171 * - 172 * C Clear - No error - 173 * Set - Error - 174 * A $00 - No error - 175 * $27 - I/O error - Init failed - 176 * $28 - No card inserted - 177 * - 178 ******************************** - 179 - 180 ORG $C900 +8069: 2C FF CF 168 BIT $CFFF +806C: A5 42 169 LDA $42 ; get command +806E: C9 00 170 CMP #$00 +8070: F0 10 171 BEQ :STATUS +8072: C9 01 172 CMP #$01 +8074: F0 0F 173 BEQ :READ + ===== Page 4 ===== + +8076: C9 02 174 CMP #$02 +8078: F0 0E 175 BEQ :WRITE +807A: C9 03 176 CMP #$03 +807C: F0 0D 177 BEQ :FORMAT +807E: 38 178 SEC ; unknown command +807F: A9 01 179 LDA #$01 +8081: 60 180 RTS 181 -C900: D8 182 INIT CLD -C901: A6 2B 183 LDX SLOT16 -C903: A9 03 184 LDA #$03 ; set SPI mode 3 -C905: 9D 81 C0 185 STA CTRL,X -C908: A9 0F 186 LDA #SSNONE -C90A: 9D 83 C0 187 STA SS,X -C90D: A9 07 188 LDA #7 -C90F: 9D 82 C0 189 STA DIV,X -C912: A0 0A 190 LDY #10 -C914: A9 FF 191 LDA #DUMMY - 192 -C916: 9D 80 C0 193 :LOOP STA DATA,X -C919: 3C 81 C0 194 :WAIT BIT CTRL,X -C91C: 10 FB 195 BPL :WAIT -C91E: 88 196 DEY -C91F: D0 F5 197 BNE :LOOP ; do 10 times -C921: A9 0E 198 LDA #SS0 ; set CS low -C923: 9D 83 C0 199 STA SS,X - 200 -C926: A9 BA 201 LDA #CMD0 -C92C: 85 41 204 STA CMDHI -C92E: 20 D9 C9 205 JSR CMD -C931: 20 ED C9 206 JSR GETR1 ; get response -C934: C9 01 207 CMP #$01 -C936: D0 39 208 BNE :ERROR1 ; error! - 209 -C938: A9 C6 210 LDA #CMD8 -C93E: 85 41 213 STA CMDHI -C940: 20 D9 C9 214 JSR CMD -C943: 20 08 CA 215 JSR GETR3 -C946: C9 01 216 CMP #$01 +8082: 4C B8 82 182 :STATUS JMP STATUS +8085: 4C C0 82 183 :READ JMP READ +8088: 4C 06 83 184 :WRITE JMP WRITE +808B: 4C 47 83 185 :FORMAT JMP FORMAT + 186 + 187 * Signature bytes + 188 +808E: 00 00 00 189 DS \ ; fill with zeroes +8091: 00 00 00 00 +8095: 00 00 00 00 +8099: 00 00 00 00 +809D: 00 00 00 00 +80A1: 00 00 00 00 +80A5: 00 00 00 00 +80A9: 00 00 00 00 +80AD: 00 00 00 00 +80B1: 00 00 00 00 +80B5: 00 00 00 00 +80B9: 00 00 00 00 +80BD: 00 00 00 00 +80C1: 00 00 00 00 +80C5: 00 00 00 00 +80C9: 00 00 00 00 +80CD: 00 00 00 00 +80D1: 00 00 00 00 +80D5: 00 00 00 00 +80D9: 00 00 00 00 +80DD: 00 00 00 00 +80E1: 00 00 00 00 +80E5: 00 00 00 00 +80E9: 00 00 00 00 +80ED: 00 00 00 00 +80F1: 00 00 00 00 +80F5: 00 00 00 00 +80F9: 00 00 00 00 +80FD: 00 00 00 + 190 DS -4 ; locate to $C8FC +80FC: FF FF 191 DW $FFFF ; 65535 blocks +80FE: 47 192 DB $47 ; Status bits +80FF: 5A 193 DB #CMD55 -C950: 85 41 223 STA CMDHI -C952: 20 D9 C9 224 JSR CMD -C955: 20 ED C9 225 JSR GETR1 -C958: A9 D8 226 LDA #ACMD4140 -C95E: 85 41 229 STA CMDHI -C960: 20 D9 C9 230 JSR CMD -C963: 20 ED C9 231 JSR GETR1 -C966: C9 01 232 CMP #$01 -C968: F0 E0 233 BEQ :SDV2 ; wait for ready -C96A: C9 00 234 CMP #$00 -C96C: D0 03 235 BNE :ERROR1 ; error! - 236 * send CMD58 - 237 * SD Ver. 2 initialized! -C96E: 4C AE C9 238 JMP :BLOCKSZ - 239 -C971: 4C CA C9 240 :ERROR1 JMP :IOERROR ; needed for far jump - 241 -C974: A9 D2 242 :SDV1 LDA #CMD55 -C97A: 85 41 245 STA CMDHI -C97C: 20 D9 C9 246 JSR CMD ; ignore response -C97F: A9 DE 247 LDA #ACMD410 -C985: 85 41 250 STA CMDHI -C987: 20 D9 C9 251 JSR CMD -C98A: 20 ED C9 252 JSR GETR1 -C98D: C9 01 253 CMP #$01 -C98F: F0 E3 254 BEQ :SDV1 ; wait for ready -C991: C9 00 255 CMP #$00 -C993: D0 03 256 BNE :MMC ; may be MMC card - 257 * SD Ver. 1 initialized! -C995: 4C AE C9 258 JMP :BLOCKSZ - 259 -C998: A9 C0 260 :MMC LDA #CMD1 -C99E: 85 41 263 STA CMDHI -C9A0: 20 D9 C9 264 :LOOP1 JSR CMD -C9A3: 20 ED C9 265 JSR GETR1 -C9A6: C9 01 266 CMP #$01 -C9A8: F0 F6 267 BEQ :LOOP1 ; wait for ready -C9AA: C9 00 268 CMP #$00 -C9AC: D0 1C 269 BNE :IOERROR ; error! - 270 * MMC Ver. 3 initialized! - 271 -C9AE: A9 CC 272 :BLOCKSZ LDA #CMD0 +812A: 85 41 229 STA CMDHI +812C: 20 D7 81 230 JSR CMD +812F: 20 EB 81 231 JSR GETR1 ; get response +8132: C9 01 232 CMP #$01 +8134: D0 39 233 BNE :ERROR1 ; error! + 234 +8136: A9 57 235 LDA #CMD8 +813C: 85 41 238 STA CMDHI +813E: 20 D7 81 239 JSR CMD +8141: 20 06 82 240 JSR GETR3 +8144: C9 01 241 CMP #$01 +8146: D0 2A 242 BNE :SDV1 ; may be SD Ver. 1 + 243 + 244 * check for $01aa match! +8148: A9 63 245 :SDV2 LDA #CMD55 +814E: 85 41 248 STA CMDHI +8150: 20 D7 81 249 JSR CMD +8153: 20 EB 81 250 JSR GETR1 +8156: A9 69 251 LDA #ACMD4140 +815C: 85 41 254 STA CMDHI +815E: 20 D7 81 255 JSR CMD +8161: 20 EB 81 256 JSR GETR1 +8164: C9 01 257 CMP #$01 +8166: F0 E0 258 BEQ :SDV2 ; wait for ready +8168: C9 00 259 CMP #$00 ===== Page 6 ===== -C9B2: A9 CB 274 LDA #>CMD16 -C9B4: 85 41 275 STA CMDHI -C9B6: 20 D9 C9 276 JSR CMD -C9B9: 20 ED C9 277 JSR GETR1 -C9BC: C9 00 278 CMP #$00 -C9BE: D0 0A 279 BNE :IOERROR ; error! - 280 -C9C0: 18 281 :END CLC ; all ok -C9C1: A2 00 282 LDX #0 -C9C3: 90 08 283 BCC :END1 -C9C5: 38 284 :CDERROR SEC -C9C6: A2 28 285 LDX #$28 ; no card error -C9C8: B0 03 286 BCS :END1 -C9CA: 38 287 :IOERROR SEC -C9CB: A2 27 288 LDX #$27 ; init error -C9CD: A9 0F 289 :END1 LDA #SSNONE ; deselect card -C9CF: 9D 83 C0 290 STA SS,X -C9D2: A9 00 291 LDA #0 ; set div to 2 -C9D4: 9D 82 C0 292 STA DIV,X -C9D7: 8A 293 TXA ; retval in A -C9D8: 60 294 RTS - 295 +816A: D0 03 260 BNE :ERROR1 ; error! + 261 * send CMD58 + 262 * SD Ver. 2 initialized! +816C: 4C AC 81 263 JMP :BLOCKSZ + 264 +816F: 4C C8 81 265 :ERROR1 JMP :IOERROR ; needed for far jump + 266 +8172: A9 63 267 :SDV1 LDA #CMD55 +8178: 85 41 270 STA CMDHI +817A: 20 D7 81 271 JSR CMD ; ignore response +817D: A9 6F 272 LDA #ACMD410 +8183: 85 41 275 STA CMDHI +8185: 20 D7 81 276 JSR CMD +8188: 20 EB 81 277 JSR GETR1 +818B: C9 01 278 CMP #$01 +818D: F0 E3 279 BEQ :SDV1 ; wait for ready +818F: C9 00 280 CMP #$00 +8191: D0 03 281 BNE :MMC ; may be MMC card + 282 * SD Ver. 1 initialized! +8193: 4C AC 81 283 JMP :BLOCKSZ + 284 +8196: A9 51 285 :MMC LDA #CMD1 +819C: 85 41 288 STA CMDHI +819E: 20 D7 81 289 :LOOP1 JSR CMD +81A1: 20 EB 81 290 JSR GETR1 +81A4: C9 01 291 CMP #$01 +81A6: F0 F6 292 BEQ :LOOP1 ; wait for ready +81A8: C9 00 293 CMP #$00 +81AA: D0 1C 294 BNE :IOERROR ; error! + 295 * MMC Ver. 3 initialized! 296 - 297 ******************************** - 298 * - 299 * Send SD command - 300 * Call with command in CMDHI and CMDLO - 301 * - 302 ******************************** - 303 -C9D9: 5A 304 CMD PHY -C9DA: A0 00 305 LDY #0 -C9DC: B1 40 306 :LOOP LDA (CMDLO),Y -C9DE: 9D 80 C0 307 STA DATA,X -C9E1: 3C 81 C0 308 :WAIT BIT CTRL,X ; TC is in N -C9E4: 10 FB 309 BPL :WAIT -C9E6: C8 310 INY -C9E7: C0 06 311 CPY #6 -C9E9: 90 F1 312 BCC :LOOP -C9EB: 7A 313 PLY -C9EC: 60 314 RTS - 315 - +81AC: A9 5D 297 :BLOCKSZ LDA #CMD16 +81B2: 85 41 300 STA CMDHI +81B4: 20 D7 81 301 JSR CMD +81B7: 20 EB 81 302 JSR GETR1 +81BA: C9 00 303 CMP #$00 +81BC: D0 0A 304 BNE :IOERROR ; error! + 305 +81BE: 18 306 :END CLC ; all ok +81BF: A0 00 307 LDY #0 +81C1: 90 08 308 BCC :END1 +81C3: 38 309 :CDERROR SEC +81C4: A0 28 310 LDY #$28 ; no card error +81C6: B0 03 311 BCS :END1 +81C8: 38 312 :IOERROR SEC +81C9: A0 27 313 LDY #$27 ; init error +81CB: A9 0F 314 :END1 LDA #SSNONE ; deselect card +81CD: 9D 83 C0 315 STA SS,X +81D0: A9 00 316 LDA #0 ; set div to 2 ===== Page 7 ===== - - 317 ******************************** - 318 * - 319 * Get R1 - 320 * R1 is in A - 321 * + +81D2: 9D 82 C0 317 STA DIV,X +81D5: 98 318 TYA ; retval in A +81D6: 60 319 RTS + 320 + 321 322 ******************************** - 323 -C9ED: A9 FF 324 GETR1 LDA #DUMMY -C9EF: 9D 80 C0 325 STA DATA,X -C9F2: 3C 81 C0 326 :WAIT BIT CTRL,X -C9F5: 10 FB 327 BPL :WAIT -C9F7: BD 80 C0 328 LDA DATA,X ; get response -C9FA: 85 3C 329 STA WORK ; save R1 -C9FC: 29 80 330 AND #$80 -C9FE: D0 ED 331 BNE GETR1 ; wait for MSB=0 -CA00: A9 FF 332 LDA #DUMMY -CA02: 9D 80 C0 333 STA DATA,X ; send another dummy -CA05: A5 3C 334 LDA WORK ; restore R1 -CA07: 60 335 RTS - 336 - 337 - 338 ******************************** - 339 * - 340 * Get R3 - 341 * R1 is in A - 342 * R3 is in scratchpad ram + 323 * + 324 * Send SD command + 325 * Call with command in CMDHI and CMDLO + 326 * + 327 ******************************** + 328 +81D7: 5A 329 CMD PHY +81D8: A0 00 330 LDY #0 +81DA: B1 40 331 :LOOP LDA (CMDLO),Y +81DC: 9D 80 C0 332 STA DATA,X +81DF: 3C 81 C0 333 :WAIT BIT CTRL,X ; TC is in N +81E2: 10 FB 334 BPL :WAIT +81E4: C8 335 INY +81E5: C0 06 336 CPY #6 +81E7: 90 F1 337 BCC :LOOP +81E9: 7A 338 PLY +81EA: 60 339 RTS + 340 + 341 + 342 ******************************** 343 * - 344 ******************************** - 345 -CA08: 20 ED C9 346 GETR3 JSR GETR1 ; get R1 first -CA0B: 48 347 PHA ; save R1 -CA0C: 5A 348 PHY ; save Y -CA0D: A9 04 349 LDA #04 ; load counter -CA0F: 85 3C 350 STA WORK -CA11: A4 3D 351 LDY SLOT -CA13: A9 FF 352 :LOOP LDA #DUMMY ; send dummy -CA15: 9D 80 C0 353 STA DATA,X -CA18: 3C 81 C0 354 :WAIT BIT CTRL,X -CA1B: 10 FB 355 BPL :WAIT -CA1D: BD 80 C0 356 LDA DATA,X -CA20: 48 357 PHA -CA21: C6 3C 358 DEC WORK -CA23: D0 EE 359 BNE :LOOP ; do 4 times -CA25: 68 360 PLA -CA26: 99 F8 05 361 STA R33,Y ; save R3 -CA29: 68 362 PLA -CA2A: 99 78 05 363 STA R32,Y -CA2D: 68 364 PLA -CA2E: 99 F8 04 365 STA R31,Y -CA31: 68 366 PLA -CA32: 9D 78 04 367 STA R30,X -CA35: 7A 368 PLY ; restore Y -CA36: A9 FF 369 LDA #DUMMY -CA38: 9D 80 C0 370 STA DATA,X ; send another dummy -CA3B: 68 371 PLA ; restore R1 -CA3C: 60 372 RTS - 373 + 344 * Get R1 + 345 * R1 is in A + 346 * + 347 ******************************** + 348 +81EB: A9 FF 349 GETR1 LDA #DUMMY +81ED: 9D 80 C0 350 STA DATA,X +81F0: 3C 81 C0 351 :WAIT BIT CTRL,X +81F3: 10 FB 352 BPL :WAIT +81F5: BD 80 C0 353 LDA DATA,X ; get response +81F8: 85 3C 354 STA WORK ; save R1 +81FA: 29 80 355 AND #$80 +81FC: D0 ED 356 BNE GETR1 ; wait for MSB=0 +81FE: A9 FF 357 LDA #DUMMY +8200: 9D 80 C0 358 STA DATA,X ; send another dummy +8203: A5 3C 359 LDA WORK ; restore R1 +8205: 60 360 RTS + 361 + 362 + 363 ******************************** + 364 * + 365 * Get R3 + 366 * R1 is in A + 367 * R3 is in scratchpad ram + 368 * + 369 ******************************** + 370 +8206: 20 EB 81 371 GETR3 JSR GETR1 ; get R1 first +8209: 48 372 PHA ; save R1 +820A: 5A 373 PHY ; save Y ===== Page 8 ===== - 374 - 375 ******************************** - 376 * - 377 * Status request - 378 * $43 Unt number DSSS000 - 379 * $44-45 Unused - 380 * $46-47 Unused - 381 * - 382 * C Clear - No error - 383 * Set - Error - 384 * A $00 - No error - 385 * $27 - I/O error - 386 * $28 - No card inserted / no init - 387 * $2B - Card write protected - 388 * x - Blocks avail (low byte) - 389 * y - Blocks avail (high byte) - 390 * - 391 ******************************** - 392 -CA3D: 18 393 STATUS CLC ; no error -CA3E: A9 00 394 LDA #0 -CA40: A2 FF 395 LDX #$FF ; 32 MB partition -CA42: A0 FF 396 LDY #$FF -CA44: 60 397 RTS +820B: A0 04 374 LDY #04 ; load counter +820D: A9 FF 375 :LOOP LDA #DUMMY ; send dummy +820F: 9D 80 C0 376 STA DATA,X +8212: 3C 81 C0 377 :WAIT BIT CTRL,X +8215: 10 FB 378 BPL :WAIT +8217: BD 80 C0 379 LDA DATA,X +821A: 48 380 PHA +821B: 88 381 DEY +821C: D0 EF 382 BNE :LOOP ; do 4 times +821E: A4 3D 383 LDY SLOT +8220: 68 384 PLA +8221: 99 F8 05 385 STA R33,Y ; save R3 +8224: 68 386 PLA +8225: 99 78 05 387 STA R32,Y +8228: 68 388 PLA +8229: 99 F8 04 389 STA R31,Y +822C: 68 390 PLA +822D: 99 78 04 391 STA R30,Y +8230: 7A 392 PLY ; restore Y +8231: A9 FF 393 LDA #DUMMY +8233: 9D 80 C0 394 STA DATA,X ; send another dummy +8236: 68 395 PLA ; restore R1 +8237: 60 396 RTS + 397 398 - 399 * TODO: check for card detect and write protect! - 400 - 401 - 402 ******************************** - 403 * - 404 * Read 512 byte block - 405 * $43 Unit number DSSS0000 - 406 * $44-45 Address (LO/HI) of buffer - 407 * $46-47 Block number (LO/HI) - 408 * - 409 * C Clear - No error - 410 * Set - Error - 411 * A $00 - No error - 412 * $27 - Bad block number - 413 * $28 - No card inserted - 414 * - 415 ******************************** + 399 ******************************** + 400 * + 401 * Calculate block address + 402 * Block no is in $46-47 + 403 * Address is in R30-R33 + 404 * + 405 ******************************** + 406 +8238: 5A 407 BLOCK PHY ; save Y +8239: A4 3D 408 LDY SLOT +823B: A5 46 409 LDA $46 ; store block num +823D: 99 F8 05 410 STA R33,Y ; in R30-R33 +8240: A5 47 411 LDA $47 +8242: 99 78 05 412 STA R32,Y +8245: A9 00 413 LDA #0 +8247: 99 F8 04 414 STA R31,Y +824A: 99 78 04 415 STA R30,Y 416 - 417 * TODO: check for card detect! - 418 -CA45: A9 0E 419 READ LDA #SS0 ; enable /CS -CA47: 9D 83 C0 420 STA SS,X - 421 -CA4A: 5A 422 PHY ; save Y -CA4B: A4 3D 423 LDY SLOT -CA4D: A5 46 424 LDA $46 ; store block num -CA4F: 99 F8 05 425 STA R33,Y ; in R30-R33 -CA52: A5 47 426 LDA $47 -CA54: 99 78 05 427 STA R32,Y -CA57: A9 00 428 LDA #0 -CA59: 99 F8 04 429 STA R31,Y -CA5C: 99 78 04 430 STA R30,Y +824D: DA 417 PHX +824E: A0 09 418 LDY #9 +8250: A6 3D 419 LDX SLOT ; ASL can't be done with Y +8252: 1E F8 05 420 :LOOP ASL R33,X ; mul block num +8255: 3E 78 05 421 ROL R32,X ; by 512 to get +8258: 3E F8 04 422 ROL R31,X ; real address +825B: 3E 78 04 423 ROL R30,X +825E: 88 424 DEY +825F: D0 F1 425 BNE :LOOP +8261: FA 426 PLX +8262: 7A 427 PLY ; restore Y +8263: 60 428 RTS + 429 + 430 ===== Page 9 ===== - 431 -CA5F: DA 432 PHX -CA60: 5A 433 PHY -CA61: A0 09 434 LDY #9 -CA63: A6 3D 435 LDX SLOT ; ASL can't be done with Y -CA65: 1E F8 05 436 :LOOP ASL R33,X ; mul block num -CA68: 3E 78 05 437 ROL R32,X ; by 512 to get -CA6B: 3E F8 04 438 ROL R31,X ; real address -CA6E: 3E 78 04 439 ROL R30,X -CA71: 88 440 DEY -CA72: D0 F1 441 BNE :LOOP -CA74: 7A 442 PLY -CA75: FA 443 PLX - 444 -CA76: A9 51 445 LDA #$51 ; send CMD17 -CA78: 9D 80 C0 446 STA DATA,X -CA7B: 3C 81 C0 447 :WAIT BIT CTRL,X -CA7E: 10 FB 448 BPL :WAIT -CA80: B9 78 04 449 :ARG LDA R30,Y ; get arg from R30 on -CA83: 9D 80 C0 450 STA DATA,X -CA86: 3C 81 C0 451 :WAIT1 BIT CTRL,X -CA89: 10 FB 452 BPL :WAIT1 -CA8B: B9 F8 04 453 LDA R31,Y -CA8E: 9D 80 C0 454 STA DATA,X -CA91: 3C 81 C0 455 :WAIT11 BIT CTRL,X -CA94: 10 FB 456 BPL :WAIT11 -CA96: B9 78 05 457 LDA R32,Y -CA99: 9D 80 C0 458 STA DATA,X -CA9C: 3C 81 C0 459 :WAIT12 BIT CTRL,X -CA9F: 10 FB 460 BPL :WAIT12 -CAA1: B9 F8 05 461 LDA R33,Y -CAA4: 9D 80 C0 462 STA DATA,X -CAA7: 3C 81 C0 463 :WAIT13 BIT CTRL,X -CAAA: 10 FB 464 BPL :WAIT13 -CAAC: A9 FF 465 LDA #DUMMY -CAAE: 9D 80 C0 466 STA DATA,X ; dummy crc -CAB1: 3C 81 C0 467 :WAIT2 BIT CTRL,X -CAB4: 10 FB 468 BPL :WAIT2 -CAB6: A9 FF 469 :GETR1 LDA #DUMMY -CAB8: 9D 80 C0 470 STA DATA,X ; get R1 -CABB: 3C 81 C0 471 :WAIT3 BIT CTRL,X -CABE: 10 FB 472 BPL :WAIT3 -CAC0: BD 80 C0 473 LDA DATA,X ; get response - 474 * - 475 * TODO: check for error! - 476 * -CAC3: C9 FE 477 CMP #$FE -CAC5: D0 EF 478 BNE :GETR1 ; wait for $FE - 479 -CAC7: 5A 480 PHY -CAC8: A0 02 481 LDY #2 ; read data from card -CACA: 64 3C 482 :LOOPY STZ WORK -CACC: A9 FF 483 :LOOPW LDA #DUMMY -CACE: 9D 80 C0 484 STA DATA,X -CAD1: 3C 81 C0 485 :WAIT4 BIT CTRL,X -CAD4: 10 FB 486 BPL :WAIT4 -CAD6: BD 80 C0 487 LDA DATA,X + 431 ******************************** + 432 * + 433 * Send SD command + 434 * Cmd is in A + 435 * + 436 ******************************** + 437 +8264: 7A 438 COMMAND PLY ; save Y +8265: A4 3D 439 LDY SLOT +8267: 9D 80 C0 440 STA DATA,X ; send command +826A: 3C 81 C0 441 :WAIT BIT CTRL,X +826D: 10 FB 442 BPL :WAIT +826F: B9 78 04 443 :ARG LDA R30,Y ; get arg from R30 on +8272: 9D 80 C0 444 STA DATA,X +8275: 3C 81 C0 445 :WAIT1 BIT CTRL,X +8278: 10 FB 446 BPL :WAIT1 +827A: B9 F8 04 447 LDA R31,Y +827D: 9D 80 C0 448 STA DATA,X +8280: 3C 81 C0 449 :WAIT11 BIT CTRL,X +8283: 10 FB 450 BPL :WAIT11 +8285: B9 78 05 451 LDA R32,Y +8288: 9D 80 C0 452 STA DATA,X +828B: 3C 81 C0 453 :WAIT12 BIT CTRL,X +828E: 10 FB 454 BPL :WAIT12 +8290: B9 F8 05 455 LDA R33,Y +8293: 9D 80 C0 456 STA DATA,X +8296: 3C 81 C0 457 :WAIT13 BIT CTRL,X +8299: 10 FB 458 BPL :WAIT13 +829B: A9 FF 459 LDA #DUMMY +829D: 9D 80 C0 460 STA DATA,X ; dummy crc +82A0: 3C 81 C0 461 :WAIT2 BIT CTRL,X +82A3: 10 FB 462 BPL :WAIT2 +82A5: A9 FF 463 :GETR1 LDA #DUMMY +82A7: 9D 80 C0 464 STA DATA,X ; get R1 +82AA: 3C 81 C0 465 :WAIT3 BIT CTRL,X +82AD: 10 FB 466 BPL :WAIT3 +82AF: BD 80 C0 467 LDA DATA,X ; get response + 468 * + 469 * TODO: check for error! + 470 * +82B2: C9 FE 471 CMP #$FE +82B4: D0 EF 472 BNE :GETR1 ; wait for $FE +82B6: 7A 473 PLY ; restore Y +82B7: 60 474 RTS + 475 + 476 + 477 ******************************** + 478 * + 479 * Status request + 480 * $43 Unit number DSSS000 + 481 * $44-45 Unused + 482 * $46-47 Unused + 483 * + 484 * C Clear - No error + 485 * Set - Error + 486 * A $00 - No error + 487 * $27 - I/O error ===== Page 10 ===== -CAD9: 92 44 488 STA ($44) -CADB: E6 44 489 INC $44 -CADD: D0 02 490 BNE :INW -CADF: E6 45 491 INC $45 ; inc msb on page boundary -CAE1: E6 3C 492 :INW INC WORK -CAE3: D0 E7 493 BNE :LOOPW -CAE5: 88 494 DEY -CAE6: D0 E2 495 BNE :LOOPY -CAE8: 7A 496 PLY - 497 -CAE9: 20 08 CA 498 :OK JSR GETR3 ; read 2 bytes crc -CAEC: A9 0F 499 LDA #SSNONE -CAEE: 9D 83 C0 500 STA SS,X ; disable /CS -CAF1: 18 501 CLC ; no error -CAF2: A9 00 502 LDA #$00 -CAF4: 7A 503 PLY ; restore Y -CAF5: 60 504 RTS - 505 -CAF6: A9 0F 506 :ERROR LDA #SSNONE -CAF8: 9D 83 C0 507 STA SS,X ; disable /CS -CAFB: 38 508 SEC ; an error occured -CAFC: A9 27 509 LDA #$27 -CAFE: 7A 510 PLY ; restore Y -CAFF: 60 511 RTS - 512 - 513 - 514 ******************************** - 515 * - 516 * Write 512 byte block - 517 * $43 Unit number DSSS000 - 518 * $44-45 Address (LO/HI) of buffer - 519 * $46-47 Block number (LO/HI) - 520 * - 521 * C Clear - No error - 522 * Set - Error - 523 * A $00 - No error - 524 * $27 - Bad block number - 525 * $28 - No card inserted - 526 * - 527 ******************************** - 528 - 529 * TODO: check for card detect and write protect! - 530 -CB00: A9 0E 531 WRITE LDA #SS0 ; enable /CS -CB02: 9D 83 C0 532 STA SS,X - 533 -CB05: 5A 534 PHY -CB06: A4 3D 535 LDY SLOT -CB08: A5 46 536 LDA $46 ; store block num -CB0A: 99 F8 05 537 STA R33,Y -CB0D: A5 47 538 LDA $47 -CB0F: 99 78 05 539 STA R32,Y -CB12: A9 00 540 LDA #0 -CB14: 99 F8 04 541 STA R31,Y -CB17: 99 78 04 542 STA R30,Y - 543 -CB1A: DA 544 PHX + 488 * $28 - No card inserted / no init + 489 * $2B - Card write protected + 490 * x - Blocks avail (low byte) + 491 * y - Blocks avail (high byte) + 492 * + 493 ******************************** + 494 +82B8: 18 495 STATUS CLC ; no error +82B9: A9 00 496 LDA #0 +82BB: A2 FF 497 LDX #$FF ; 32 MB partition +82BD: A0 FF 498 LDY #$FF +82BF: 60 499 RTS + 500 + 501 * TODO: check for card detect and write protect! + 502 + 503 + 504 ******************************** + 505 * + 506 * Read 512 byte block + 507 * $43 Unit number DSSS0000 + 508 * $44-45 Address (LO/HI) of buffer + 509 * $46-47 Block number (LO/HI) + 510 * + 511 * C Clear - No error + 512 * Set - Error + 513 * A $00 - No error + 514 * $27 - Bad block number + 515 * $28 - No card inserted + 516 * + 517 ******************************** + 518 + 519 * TODO: check for card detect! + 520 +82C0: 20 38 82 521 READ JSR BLOCK ; calc block address + 522 +82C3: A9 0E 523 LDA #SS0 ; enable /CS +82C5: 9D 83 C0 524 STA SS,X +82C8: A9 51 525 LDA #$51 ; send CMD17 +82CA: 20 64 82 526 JSR COMMAND ; send command + 527 +82CD: 5A 528 PHY +82CE: A0 02 529 LDY #2 ; read data from card +82D0: 64 3C 530 :LOOPY STZ WORK +82D2: A9 FF 531 :LOOPW LDA #DUMMY +82D4: 9D 80 C0 532 STA DATA,X +82D7: 3C 81 C0 533 :WAIT4 BIT CTRL,X +82DA: 10 FB 534 BPL :WAIT4 +82DC: BD 80 C0 535 LDA DATA,X +82DF: 92 44 536 STA ($44) +82E1: E6 44 537 INC $44 +82E3: D0 02 538 BNE :INW +82E5: E6 45 539 INC $45 ; inc msb on page boundary +82E7: E6 3C 540 :INW INC WORK +82E9: D0 E7 541 BNE :LOOPW +82EB: 88 542 DEY +82EC: D0 E2 543 BNE :LOOPY +82EE: 7A 544 PLY ===== Page 11 ===== -CB1B: 5A 545 PHY -CB1C: A0 09 546 LDY #9 -CB1E: A6 3D 547 LDX SLOT ; ASL can't be done with Y -CB20: 1E F8 05 548 :LOOP ASL R33,X ; mul block num -CB23: 3E 78 05 549 ROL R32,X ; by 512 to get -CB26: 3E F8 04 550 ROL R31,X ; real address -CB29: 3E 78 04 551 ROL R30,X -CB2C: 88 552 DEY -CB2D: D0 F1 553 BNE :LOOP -CB2F: 7A 554 PLY -CB30: FA 555 PLX - 556 -CB31: A9 58 557 LDA #$58 ; send CMD24 -CB33: 9D 80 C0 558 STA DATA,X -CB36: 3C 81 C0 559 :WAIT BIT CTRL,X -CB39: 10 FB 560 BPL :WAIT -CB3B: B9 78 04 561 :ARG LDA R30,Y ; get arg from R30 on -CB3E: 9D 80 C0 562 STA DATA,X -CB41: 3C 81 C0 563 :WAIT1 BIT CTRL,X -CB44: 10 FB 564 BPL :WAIT1 -CB46: B9 F8 04 565 LDA R31,Y -CB49: 9D 80 C0 566 STA DATA,X -CB4C: 3C 81 C0 567 :WAIT11 BIT CTRL,X -CB4F: 10 FB 568 BPL :WAIT11 -CB51: B9 78 05 569 LDA R32,Y -CB54: 9D 80 C0 570 STA DATA,X -CB57: 3C 81 C0 571 :WAIT12 BIT CTRL,X -CB5A: 10 FB 572 BPL :WAIT12 -CB5C: B9 F8 05 573 LDA R33,Y -CB5F: 9D 80 C0 574 STA DATA,X -CB62: 3C 81 C0 575 :WAIT13 BIT CTRL,X -CB65: 10 FB 576 BPL :WAIT13 -CB67: A9 FF 577 LDA #DUMMY -CB69: 9D 80 C0 578 STA DATA,X ; dummy crc -CB6C: 3C 81 C0 579 :WAIT2 BIT CTRL,X -CB6F: 10 FB 580 BPL :WAIT2 -CB71: A9 FF 581 :GETR1 LDA #DUMMY -CB73: 9D 80 C0 582 STA DATA,X ; get R1 -CB76: 3C 81 C0 583 :WAIT3 BIT CTRL,X -CB79: 10 FB 584 BPL :WAIT3 -CB7B: BD 80 C0 585 LDA DATA,X ; get response - 586 * - 587 * TODO: check for error! - 588 * -CB7E: C9 FE 589 CMP #$FE -CB80: D0 EF 590 BNE :GETR1 ; wait for $FE - 591 -CB82: 5A 592 PHY -CB83: A0 02 593 LDY #2 ; send data to card -CB85: 64 3C 594 :LOOPY STZ WORK -CB87: B2 44 595 :LOOPW LDA ($44) -CB89: 9D 80 C0 596 STA DATA,X -CB8C: 3C 81 C0 597 :WAIT4 BIT CTRL,X -CB8F: 10 FB 598 BPL :WAIT4 -CB91: E6 44 599 INC $44 -CB93: D0 02 600 BNE :INW -CB95: E6 45 601 INC $45 ; inc msb on page boundary + 545 +82EF: 20 06 82 546 JSR GETR3 ; read 2 bytes crc +82F2: A9 0F 547 LDA #SSNONE +82F4: 9D 83 C0 548 STA SS,X ; disable /CS +82F7: 18 549 CLC ; no error +82F8: A9 00 550 LDA #$00 +82FA: 7A 551 PLY ; restore Y +82FB: 60 552 RTS + 553 +82FC: A9 0F 554 :ERROR LDA #SSNONE +82FE: 9D 83 C0 555 STA SS,X ; disable /CS +8301: 38 556 SEC ; an error occured +8302: A9 27 557 LDA #$27 +8304: 7A 558 PLY ; restore Y +8305: 60 559 RTS + 560 + 561 + 562 ******************************** + 563 * + 564 * Write 512 byte block + 565 * $43 Unit number DSSS000 + 566 * $44-45 Address (LO/HI) of buffer + 567 * $46-47 Block number (LO/HI) + 568 * + 569 * C Clear - No error + 570 * Set - Error + 571 * A $00 - No error + 572 * $27 - Bad block number + 573 * $28 - No card inserted + 574 * + 575 ******************************** + 576 + 577 * TODO: check for card detect and write protect! + 578 +8306: 20 38 82 579 WRITE JSR BLOCK ; calc block address + 580 +8309: A9 0E 581 LDA #SS0 ; enable /CS +830B: 9D 83 C0 582 STA SS,X +830E: A9 58 583 LDA #$58 ; send CMD24 +8310: 20 64 82 584 JSR COMMAND ; send command + 585 +8313: 5A 586 PHY +8314: A0 02 587 LDY #2 ; send data to card +8316: 64 3C 588 :LOOPY STZ WORK +8318: B2 44 589 :LOOPW LDA ($44) +831A: 9D 80 C0 590 STA DATA,X +831D: 3C 81 C0 591 :WAIT4 BIT CTRL,X +8320: 10 FB 592 BPL :WAIT4 +8322: E6 44 593 INC $44 +8324: D0 02 594 BNE :INW +8326: E6 45 595 INC $45 ; inc msb on page boundary +8328: E6 3C 596 :INW INC WORK +832A: D0 EC 597 BNE :LOOPW +832C: 88 598 DEY +832D: D0 E7 599 BNE :LOOPY + 600 +832F: A0 02 601 LDY #2 ; send 2 dummy crc bytes ===== Page 12 ===== -CB97: E6 3C 602 :INW INC WORK -CB99: D0 EC 603 BNE :LOOPW -CB9B: 88 604 DEY -CB9C: D0 E7 605 BNE :LOOPY - 606 -CB9E: A0 02 607 LDY #2 ; send 2 dummy crc bytes -CBA0: 9D 80 C0 608 :CRC STA DATA,X -CBA3: 3C 81 C0 609 :WAIT5 BIT CTRL,X -CBA6: 10 FB 610 BPL :WAIT5 -CBA8: 88 611 DEY -CBA9: D0 F5 612 BNE :CRC -CBAB: 7A 613 PLY - 614 -CBAC: A9 0F 615 :OK LDA #SSNONE ; disable /CS -CBAE: 9D 83 C0 616 STA SS,X -CBB1: 18 617 CLC ; no error -CBB2: A9 00 618 LDA #0 -CBB4: 7A 619 PLY -CBB5: 60 620 RTS - 621 - 622 - 623 ******************************** - 624 * - 625 * Format - 626 * not supported! - 627 * - 628 ******************************** - 629 -CBB6: 38 630 FORMAT SEC -CBB7: A9 01 631 LDA #$01 ; invalid command -CBB9: 60 632 RTS - 633 - 634 - 635 -CBBA: 40 00 00 636 CMD0 HEX 400000 -CBBD: 00 00 95 637 HEX 000095 -CBC0: 41 00 00 638 CMD1 HEX 410000 -CBC3: 00 00 F9 639 HEX 0000F9 -CBC6: 48 00 00 640 CMD8 HEX 480000 -CBC9: 01 AA 87 641 HEX 01AA87 -CBCC: 50 00 00 642 CMD16 HEX 500000 -CBCF: 02 00 FF 643 HEX 0200FF -CBD2: 77 00 00 644 CMD55 HEX 770000 -CBD5: 00 00 65 645 HEX 000065 -CBD8: 69 40 00 646 ACMD4140 HEX 694000 -CBDB: 00 00 77 647 HEX 000077 -CBDE: 69 00 00 648 ACMD410 HEX 690000 -CBE1: 00 00 FF 649 HEX 0000FF - - ===== Page 13 ===== - +8331: 9D 80 C0 602 :CRC STA DATA,X +8334: 3C 81 C0 603 :WAIT5 BIT CTRL,X +8337: 10 FB 604 BPL :WAIT5 +8339: 88 605 DEY +833A: D0 F5 606 BNE :CRC +833C: 7A 607 PLY + 608 +833D: A9 0F 609 LDA #SSNONE ; disable /CS +833F: 9D 83 C0 610 STA SS,X +8342: 18 611 CLC ; no error +8343: A9 00 612 LDA #0 +8345: 7A 613 PLY +8346: 60 614 RTS + 615 + 616 + 617 ******************************** + 618 * + 619 * Format + 620 * not supported! + 621 * + 622 ******************************** + 623 +8347: 38 624 FORMAT SEC +8348: A9 01 625 LDA #$01 ; invalid command +834A: 60 626 RTS + 627 + 628 +834B: 40 00 00 629 CMD0 HEX 400000 +834E: 00 00 95 630 HEX 000095 +8351: 41 00 00 631 CMD1 HEX 410000 +8354: 00 00 F9 632 HEX 0000F9 +8357: 48 00 00 633 CMD8 HEX 480000 +835A: 01 AA 87 634 HEX 01AA87 +835D: 50 00 00 635 CMD16 HEX 500000 +8360: 02 00 FF 636 HEX 0200FF +8363: 77 00 00 637 CMD55 HEX 770000 +8366: 00 00 65 638 HEX 000065 +8369: 69 40 00 639 ACMD4140 HEX 694000 +836C: 00 00 77 640 HEX 000077 +836F: 69 00 00 641 ACMD410 HEX 690000 +8372: 00 00 FF 642 HEX 0000FF ---End assembly, 900 bytes, Errors: 0 +--End assembly, 885 bytes, Errors: 0 Symbol table - alphabetical order: - ACMD410 =$CBDE ACMD4140=$CBD8 CMD =$C9D9 CMD0 =$CBBA - CMD1 =$CBC0 CMD16 =$CBCC CMD55 =$CBD2 CMD8 =$CBC6 - CMDHI =$41 CMDLO =$40 CTRL =$C081 CURSLOT =$07F8 - DATA =$C080 DIV =$C082 DRIVER =$C85F DUMMY =$FF - FORMAT =$CBB6 GETR1 =$C9ED GETR3 =$CA08 INIT =$C900 - INSLP =$C827 INSLP2 =$C83D INSOUT =$C85E R30 =$0478 - R31 =$04F8 R32 =$0578 R33 =$05F8 READ =$CA45 - SLOT =$3D SLOT16 =$2B SS =$C083 SS0 =$0E - SSNONE =$0F STATUS =$CA3D WORK =$3C WRITE =$CB00 - + ACMD410 =$836F ACMD4140=$8369 BLOCK =$8238 CMD =$81D7 + CMD0 =$834B CMD1 =$8351 CMD16 =$835D CMD55 =$8363 + CMD8 =$8357 CMDHI =$41 CMDLO =$40 COMMAND =$8264 + CTRL =$C081 CURSLOT =$07F8 DATA =$C080 DEBUG =$01 + DIV =$C082 DRIVER =$805A DUMMY =$FF FORMAT =$8347 + GETR1 =$81EB GETR3 =$8206 INIT =$8100 INSLP =$801F + INSLP2 =$8038 INSOUT =$8059 R30 =$0478 R31 =$04F8 + R32 =$0578 R33 =$05F8 READ =$82C0 SLOT =$3D + SLOT16 =$2B SS =$C083 SS0 =$0E SSNONE =$0F + ===== Page 13 ===== + + STATUS =$82B8 WORK =$3C WRITE =$8306 Symbol table - numerical order: - SS0 =$0E SSNONE =$0F SLOT16 =$2B WORK =$3C - SLOT =$3D CMDLO =$40 CMDHI =$41 DUMMY =$FF - R30 =$0478 R31 =$04F8 R32 =$0578 R33 =$05F8 - CURSLOT =$07F8 DATA =$C080 CTRL =$C081 DIV =$C082 - SS =$C083 INSLP =$C827 INSLP2 =$C83D INSOUT =$C85E - DRIVER =$C85F INIT =$C900 CMD =$C9D9 GETR1 =$C9ED - GETR3 =$CA08 STATUS =$CA3D READ =$CA45 WRITE =$CB00 - FORMAT =$CBB6 CMD0 =$CBBA CMD1 =$CBC0 CMD8 =$CBC6 - CMD16 =$CBCC CMD55 =$CBD2 ACMD4140=$CBD8 ACMD410 =$CBDE - + DEBUG =$01 SS0 =$0E SSNONE =$0F SLOT16 =$2B + WORK =$3C SLOT =$3D CMDLO =$40 CMDHI =$41 + DUMMY =$FF R30 =$0478 R31 =$04F8 R32 =$0578 + R33 =$05F8 CURSLOT =$07F8 INSLP =$801F INSLP2 =$8038 + INSOUT =$8059 DRIVER =$805A INIT =$8100 CMD =$81D7 + GETR1 =$81EB GETR3 =$8206 BLOCK =$8238 COMMAND =$8264 + STATUS =$82B8 READ =$82C0 WRITE =$8306 FORMAT =$8347 + CMD0 =$834B CMD1 =$8351 CMD8 =$8357 CMD16 =$835D + CMD55 =$8363 ACMD4140=$8369 ACMD410 =$836F DATA =$C080 + CTRL =$C081 DIV =$C082 SS =$C083 diff --git a/AppleIISd.s b/AppleIISd.s index f39d1f9..b3e2ae8 100644 --- a/AppleIISd.s +++ b/AppleIISd.s @@ -13,7 +13,12 @@ DAT XC ; enable 65C02 code +DEBUG = 1 + DO DEBUG + ORG $8000 + ELSE ORG $C800 ; Expansion ROM + FIN * Memory defines @@ -53,9 +58,16 @@ DUMMY = $FF LDX #$03 STX WORK - PAG * find slot nr + DO DEBUG + LDA #$04 + STA SLOT + LDA #$C4 + STA CURSLOT + LDA #$40 + STA SLOT16 + ELSE JSR $FF58 TSX LDA $0100,X @@ -68,6 +80,8 @@ DUMMY = $FF ASL A ASL A STA SLOT16 ; $s0 + FIN + TAX ; X holds now SLOT16 JSR INIT BIT $CFFF @@ -89,10 +103,11 @@ INSLP LDA $BF32,X ; get a devnum * restore the devnum to the list LDX $BF31 ; get devcnt again - CPX #$0D device table full? + CPX #$0D ; device table full? BNE INSLP2 - JMP INSOUT ; do something! + JSR $FF3A ; bell + JMP INSOUT ; do something! INSLP2 LDA $BF32-1,X ; move all entries down STA $BF32,X ; to make room at front @@ -103,14 +118,18 @@ INSLP2 LDA $BF32-1,X ; move all entries down STA $BF32 ; slot, drive 1 at top of list INC $BF31 ; update devcnt - PAG * now insert the device driver vector LDA SLOT + ASL TAX LDA #DRIVER + ELSE LDA CURSLOT + FIN STA $BF11,X INSOUT RTS @@ -123,6 +142,14 @@ INSOUT RTS ******************************** DRIVER CLD + DO DEBUG + LDA #$04 + STA SLOT + LDA #$C4 + STA CURSLOT + LDA #$40 + STA SLOT16 + ELSE JSR $FF58 ; find slot nr TSX LDA $0100,X @@ -135,6 +162,7 @@ DRIVER CLD ASL A ASL A STA SLOT16 ; $s0 + FIN TAX ; X holds now SLOT16 BIT $CFFF @@ -156,10 +184,10 @@ DRIVER CLD :WRITE JMP WRITE :FORMAT JMP FORMAT - PAG * Signature bytes - ORG $C8FC + DS \ ; fill with zeroes + DS -4 ; locate to $C8FC DW $FFFF ; 65535 blocks DB $47 ; Status bits DB #