1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-26 15:48:05 +11:00

sdc: allow the read of 0xff

That took an embarrasingly large amount of time to debug for something,
in the end, so obvious...
This commit is contained in:
Virgil Dupras 2019-05-31 21:33:42 -04:00
parent 2e8af376e3
commit 3bc7cec03a

View File

@ -63,14 +63,17 @@ sdcSendRecv:
nop nop
ret ret
sdcIdle:
ld a, 0xff
jp sdcSendRecv
; sdcSendRecv 0xff until the response is something else than 0xff for a maximum ; sdcSendRecv 0xff until the response is something else than 0xff for a maximum
; of 20 times. Returns 0xff if no response. ; of 20 times. Returns 0xff if no response.
sdcWaitResp: sdcWaitResp:
push bc push bc
ld b, 20 ld b, 20
.loop: .loop:
ld a, 0xff call sdcIdle
call sdcSendRecv
inc a ; if 0xff, it's going to become zero inc a ; if 0xff, it's going to become zero
jr nz, .end ; not zero? good, that's our command jr nz, .end ; not zero? good, that's our command
djnz .loop djnz .loop
@ -286,14 +289,14 @@ sdcReadBlk:
ld bc, SDC_BLKSIZE ld bc, SDC_BLKSIZE
ld hl, SDC_BUF ld hl, SDC_BUF
.loop2: .loop2:
call sdcWaitResp call sdcIdle
ld (hl), a ld (hl), a
cpi ; a trick to inc HL and dec BC at the same time. cpi ; a trick to inc HL and dec BC at the same time.
; P/V indicates whether BC reached 0 ; P/V indicates whether BC reached 0
jp pe, .loop2 ; BC is not zero, loop jp pe, .loop2 ; BC is not zero, loop
; Read our 2 CRC bytes ; Read our 2 CRC bytes
call sdcWaitResp call sdcIdle
call sdcWaitResp call sdcIdle
; success! Let's recall our orginal A arg and put it in SDC_BUFSEC ; success! Let's recall our orginal A arg and put it in SDC_BUFSEC
ld a, e ld a, e
ld (SDC_BUFSEC), a ld (SDC_BUFSEC), a