From 3bc7cec03a501dbf3ad60a652152787744a1e446 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Fri, 31 May 2019 21:33:42 -0400 Subject: [PATCH] sdc: allow the read of 0xff That took an embarrasingly large amount of time to debug for something, in the end, so obvious... --- kernel/sdc.asm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/kernel/sdc.asm b/kernel/sdc.asm index 1e9fc69..b572043 100644 --- a/kernel/sdc.asm +++ b/kernel/sdc.asm @@ -63,14 +63,17 @@ sdcSendRecv: nop ret +sdcIdle: + ld a, 0xff + jp sdcSendRecv + ; sdcSendRecv 0xff until the response is something else than 0xff for a maximum ; of 20 times. Returns 0xff if no response. sdcWaitResp: push bc ld b, 20 .loop: - ld a, 0xff - call sdcSendRecv + call sdcIdle inc a ; if 0xff, it's going to become zero jr nz, .end ; not zero? good, that's our command djnz .loop @@ -286,14 +289,14 @@ sdcReadBlk: ld bc, SDC_BLKSIZE ld hl, SDC_BUF .loop2: - call sdcWaitResp + call sdcIdle ld (hl), a cpi ; a trick to inc HL and dec BC at the same time. ; P/V indicates whether BC reached 0 jp pe, .loop2 ; BC is not zero, loop ; Read our 2 CRC bytes - call sdcWaitResp - call sdcWaitResp + call sdcIdle + call sdcIdle ; success! Let's recall our orginal A arg and put it in SDC_BUFSEC ld a, e ld (SDC_BUFSEC), a