83Plus:Software:usb8x/Asm Interface/MSD
The mass storage driver works through a series of U_CALL entry points, much like the HID driver.
It requires two RAM buffers, one for internal use and one for a sector buffer. File handles used for opened files (explained later) also require around 27 bytes. The size of all three of these buffers can be obtained through the MSDVersion U_CALL. The size of the internal buffer is typically 254 bytes and the sector buffer is 512 bytes.
The entry point which requires these buffers is the MSD_Initialize U_CALL. Its memory can be dynamically allocated to appBackUpScreen (taking up practically all of it) with the code below:
U_CALL MSDVersion ld de,appBackUpScreen push de add hl,de ex de,hl pop hl U_CALL MSD_Initialize
For file system operations, you will then make calls to UFI_Initialize and FAT_Initialize. All three of these will return with the carry flag set if there are problems, with more detailed information in offErrorCode.
If all three functions succeed, the following entry points can be called.
Entry Points
MSDVersion | Gets mass storage driver version and memory requirements |
MSD_Initialize | Initializes mass storage driver |
UFI_Initialize | Initializes connected mass storage device for sector read/write operations |
UFI_Read | Reads sector at (MSDLBA) address into sector buffer |
UFI_Write | Writes memory in sector buffer to (MSDLBA) address |
FAT_Initialize | Initializes connected mass storage device for FAT16 file system operations |
DOS_openFile | Opens a file and populates file handle with important information |
DOS_fileSeek | Sets seek pointer for file handle to specified offset |
DOS_fileRead | Read bytes from a file |
DOS_fileWrite | Write bytes to a file and grow if necessary |
DOS_createFile | Create new file in specified directory with size 0 |
DOS_createDirectory | Create new subdirectory in specified directory |
DOS_deleteFileEntry | Delete file or folder (including contents) |
DOS_countFilesInDir | Get number of files/folders in specified directory |
DOS_getNextFile | Get first/next file in specified directory |
DOS_getFileSize | Get size of file |
DOS_getDirEntry | Get directory entry for specified file/folder |
FAT_nameConvertTo11 | Convert name to 11-character format (ex. "README TXT") |
FAT_nameConvertFrom11 | Convert name to ASCIIZ format (ex. "readme.txt") |
FAT_lookupPath | Find whether specified file/directory exists |
FAT_findFileInCluster | Get directory entry for a file in specified folder |
FAT_getStartingCluster | Get starting cluster of specified directory |