written code for reading file from SD card, not tested yet
This commit is contained in:
1 parent
1de5af7cb4
commit
b7f579525b
5 files changed
+91
-4
No files matched your search
@@ -49,12 +49,90 @@ fs_hvsr_read_file_open:
|
||||
|
||||
; Found the file - load it
|
||||
|
||||
; XXX provide implementation
|
||||
jsr fs_hvsr_direntmem_restore ; restore $1000 memory content
|
||||
|
||||
lda #$18 ; dos_openfile
|
||||
sta HTRAP00
|
||||
+nop
|
||||
|
||||
; XXX check error code
|
||||
|
||||
jmp dos_EXIT_CLC
|
||||
; XXX check for errors
|
||||
|
||||
; Read the first 512-byte chunk
|
||||
|
||||
lda #$03 ; mode: read file
|
||||
sta SD_MODE
|
||||
|
||||
jsr fs_hvsr_read_file
|
||||
jmp dos_EXIT
|
||||
|
||||
fs_hvsr_read_file:
|
||||
|
||||
; Read chunk of data to SD card buffer
|
||||
|
||||
lda #$1A ; dos_readfile
|
||||
sta HTRAP00
|
||||
+nop
|
||||
|
||||
; XXX check error code
|
||||
|
||||
; Store number of bytes read
|
||||
|
||||
stx SD_ACPTR_LEN+0
|
||||
sty SD_ACPTR_LEN+1
|
||||
|
||||
; Check if any data was read
|
||||
|
||||
lda SD_ACPTR_LEN+0
|
||||
ora SD_ACPTR_LEN+0
|
||||
bne @copy
|
||||
|
||||
lda #$20 ; dos_closefile
|
||||
sta HTRAP00
|
||||
+nop
|
||||
|
||||
lda #$00
|
||||
sec
|
||||
rts
|
||||
|
||||
@copy:
|
||||
|
||||
; Set pointer to new data
|
||||
|
||||
lda #<SD_FILEBUF
|
||||
sta SD_ACPTR_PTR+0
|
||||
lda #>SD_FILEBUF
|
||||
sta SD_ACPTR_PTR+1
|
||||
|
||||
; Copy data to SD_FILEBUF
|
||||
|
||||
lda #%10000000 ; select SD card buffer
|
||||
tsb SD_BUFCTL
|
||||
|
||||
lda #$02
|
||||
sta DMA_ADDRBANK ; $D702
|
||||
lda #$00
|
||||
sta DMA_ADDRMB ; $D704
|
||||
|
||||
lda #>(@dmalist-$4000)
|
||||
sta DMA_ADDRMSB ; $D701
|
||||
lda #<(@dmalist-$4000)
|
||||
sta DMA_ETRIG ; $D705
|
||||
|
||||
clc
|
||||
rts
|
||||
|
||||
@dmalist:
|
||||
|
||||
!byte $0A ; use F018A list format (it is shorter by 1 byte)
|
||||
!byte $80, $FF ; src. address is $FFxxxxx
|
||||
!byte $81, $00 ; dst. address is $00xxxxx
|
||||
!byte $00 ; end of options
|
||||
!byte $00 ; operation: COPY
|
||||
!word $0200 ; data size if 512 bytes
|
||||
!byte $00, $6E, $0D ; src. addr is $xxD6E00
|
||||
!byte <SD_FILEBUF, >SD_FILEBUF - $80, $01 ; dst. addr is $xx1xxxx (internal buffer)
|
||||
|
||||
fs_hvsr_file_not_found:
|
||||
|
||||
|
||||
Reference in new issue
Block a user