sdc: fix bug preventing us from reading beyond first sector
This commit is contained in:
parent
8cfe834edb
commit
312e95479e
@ -109,8 +109,7 @@ sdcCmd:
|
|||||||
call sdcSendRecv
|
call sdcSendRecv
|
||||||
|
|
||||||
; And now we just have to wait for a valid response...
|
; And now we just have to wait for a valid response...
|
||||||
call sdcWaitResp
|
jp sdcWaitResp ; return
|
||||||
ret
|
|
||||||
|
|
||||||
; Send a command that expects a R1 response, handling CS.
|
; Send a command that expects a R1 response, handling CS.
|
||||||
sdcCmdR1:
|
sdcCmdR1:
|
||||||
@ -319,28 +318,23 @@ sdcGetC:
|
|||||||
|
|
||||||
xor a
|
xor a
|
||||||
ld hl, (SDC_PTR)
|
ld hl, (SDC_PTR)
|
||||||
|
bit 0, h
|
||||||
|
jr nz, .highbuf ; first bit set? no need to read a sector. Also,
|
||||||
|
; we already know that we're in the "highbuf"
|
||||||
|
; zone.
|
||||||
cp l ; is L zero?
|
cp l ; is L zero?
|
||||||
jr nz, .mem ; non-zero? no need to read a sector
|
jr nz, .lowbuf ; non-zero? no need to read a sector
|
||||||
ld a, h
|
|
||||||
and 0x1
|
|
||||||
jr nz, .mem ; if H has first bit set, no need to read a
|
|
||||||
; sector
|
|
||||||
; Oh, first 9 bits unset. Se need to read a sector
|
; Oh, first 9 bits unset. Se need to read a sector
|
||||||
; H is already in A. We just need a right shift.
|
ld a, h
|
||||||
rra ; now that's our sector
|
rrca ; now that's our sector
|
||||||
call sdcReadBlk
|
call sdcReadBlk
|
||||||
jr nz, .error
|
jr nz, .error
|
||||||
.mem:
|
.lowbuf:
|
||||||
; Read byte from memory at proper offset
|
; Read byte from memory at proper offset in lowbuf (first 0x100 bytes)
|
||||||
; Higher 256 bytes or lower ones?
|
|
||||||
ld a, h
|
|
||||||
and 0x1
|
|
||||||
jr nz, .highbuf
|
|
||||||
; We're on the lower part
|
|
||||||
ld hl, SDC_BUF
|
ld hl, SDC_BUF
|
||||||
jr .read
|
jr .read
|
||||||
.highbuf:
|
.highbuf:
|
||||||
; We're on the higher part
|
; Read byte from memory at proper offset in highbuf (0x100-0x1ff)
|
||||||
ld hl, SDC_BUF+0x100
|
ld hl, SDC_BUF+0x100
|
||||||
.read:
|
.read:
|
||||||
; HL is now placed either on the lower or higher half of SDC_BUF and
|
; HL is now placed either on the lower or higher half of SDC_BUF and
|
||||||
@ -364,3 +358,12 @@ sdcGetC:
|
|||||||
.end:
|
.end:
|
||||||
pop hl
|
pop hl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
sdcSeek:
|
||||||
|
ld (SDC_PTR), hl
|
||||||
|
ret
|
||||||
|
|
||||||
|
sdcTell:
|
||||||
|
ld hl, (SDC_PTR)
|
||||||
|
ret
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user