more work towards SD card support

This commit is contained in:
FeralChild64 committed 2020-10-05 19:47:22 +02:00
1 parent 79c094dce5
commit 219916aa4e
2 files changed
+30 -1

No files matched your search

+2
View File
@@ -75,6 +75,8 @@ sdcard_helper_fail:
sdcard_wait_ready:
; XXX if card does not get ready, try to reset it
lda SD_CTL
; Sometimes we see this result, i.e., sdcard.vhdl thinks it is done,
; but sdcardio.vhdl thinks not. This means a read error.
+28 -1
View File
@@ -42,23 +42,50 @@ sdcard_writesector_try_loop:
jsr sdcard_writesector_copy_data
; Wait till card is ready
jsr sdcard_wait_ready
bcs sdcard_writesector_fail
; Write command
lda #CARD_CMD_WRITE ; $03
sta SD_CTL
; Wait for command completion
jsr sdcard_wait_ready
bcs sdcard_writesector_fail
; Check result
lda SD_CTL
and #$67
bne sdcard_writesector_verify
; Write failed - retry
jsr sdcard_reset
dec CARD_TMP_RETRIES
bne sdcard_writesector_try_loop
; FALLTROUGH
sdcard_writesector_fail:
sec
rts
sdcard_writesector_verify:
; There is a bug in the SD controller; you have to read between writes,
; or it gets really upset
; XXX