sdc: tidy up

This commit is contained in:
Virgil Dupras 2019-06-19 09:24:16 -04:00
parent d9ae82c81e
commit 66fbd20e21

View File

@ -356,11 +356,9 @@ sdcReadBlk:
; actual data, but at this point, we don't have any error conditions ; actual data, but at this point, we don't have any error conditions
; left, success is guaranteed. To avoid needlesssly INCing hl, let's ; left, success is guaranteed. To avoid needlesssly INCing hl, let's
; set sector and dirty along the way ; set sector and dirty along the way
ld a, e ; sector number LSB ld (hl), e ; sector number LSB
ld (hl), a inc hl
inc hl ; sector number MSB ld (hl), d ; sector number MSB
ld a, d
ld (hl), a
inc hl ; dirty flag inc hl ; dirty flag
xor a ; unset xor a ; unset
ld (hl), a ld (hl), a
@ -425,24 +423,23 @@ sdcWriteBlk:
ld ix, (SDC_BUFPTR) ; HL points to sector LSB ld ix, (SDC_BUFPTR) ; HL points to sector LSB
xor a xor a
cp (ix+2) ; dirty flag cp (ix+2) ; dirty flag
jr z, .dontWrite ; A is already 0 pop ix
ret z ; don't write if dirst flag is zero
push bc push bc
push de push de
push hl push hl
call sdcCRC ; DE -> new CRC. HL -> pointer to buf CRC call sdcCRC ; DE -> new CRC. HL -> pointer to buf CRC
ld a, d ; write computed CRC ld (hl), d ; write computed CRC
ld (hl), a
inc hl inc hl
ld a, e ld (hl), e
ld (hl), a
out (SDC_PORT_CSLOW), a out (SDC_PORT_CSLOW), a
ld a, (ix) ; sector LSB ld hl, (SDC_BUFPTR) ; sector LSB
ld e, a ld e, (hl) ; sector LSB
ld a, (ix+1) ; sector MSB inc hl
ld d, a ld d, (hl) ; sector MSB
ld hl, 0 ; high addr word always zero, DE already set ld hl, 0 ; high addr word always zero, DE already set
ld a, 0b01011000 ; CMD24 ld a, 0b01011000 ; CMD24
call sdcCmd call sdcCmd
@ -503,8 +500,6 @@ sdcWriteBlk:
pop hl pop hl
pop de pop de
pop bc pop bc
.dontWrite:
pop ix
ret ret
; Considering the first 15 bits of EHL, select the most appropriate of our two ; Considering the first 15 bits of EHL, select the most appropriate of our two