2.5 Using SD files

SYS_FS_INIT

initialize FAT32 filesystem

do not use this call

SYS_FS_OPENFILE

prepare file for reading or writing

file must exist on SD card

HL: pointer to 8+3 file name

returns

CF: set if file not exists

HL, DE: 4 bytes file size

SYS_FS_CHDIR

change directory

HL: pointer to 8+3 file name

if filename is "/" then directory will be changed to root

returns

CF: reset if successful

LD HL, FILENAME

CALL SYS_FS_CHDIR

...

FILENAME:

.TEXT "SUBDIRXX123"

SYS_FS_BROWSE

browse directory records

CF: set - browse from begining, reset - find next record

returns

CF: set - no more records

IX: pointer to directory record

0..10 - 8+3 filename

11 - file attributes

28..31 - filesize

SCF ; first record

LIST_DIR:

CALL SYS_FS_BROWSE

RET C ; no more records

.... ; check record, etc.

XOR A ; next record

JR LIST_DIR

SYS_FS_GETFILE

load file from card to RAM

HL: pointer to 8+3 filename

DE: RAM address to write

SYS_FS_RUNFILE

load and run program

HL: pointer to 8+3 filename

DE: RAM address to write, launching address

SYS_INI_OPEN

open Windows INI file

HL: pointer to 8+3 file name

DE: pointer to memory address where infile will be temporarily stored

returns

CF: set if inifile not exists or reading error or file size is more than 512B

SYS_INI_KEY

find key

HL: pointer to key name ("=" terminated)

returns

HL: pointer to data

B: length of data

LD HL, ININAME

LD DE, 9000h

CALL SYS_INI_OPEN

JR C, NOINIFILE

LD HL, KEY1

CALL SYS_INI_KEY

JR C, NOKEY

....

ININAME:

.TEXT "INITEST1INI"

KEY1:

.TEXT "PARAMETER1="

Low level calls:

SYS_FS_WR_SEC

write one sector (512B)

SYS_FS_RD_SEC

read one sector

SYS_FS_NEXT_SEC

move to next sector