author: bocianu bocianu@gmail.com
Handful of useful procedures to fiddle with Atari IO (disk) using xBios. For more informations about xBios - look here: https://xxl.atari.pl/.
Known limitations of xBios:
- New files cannot be created.
- Existing files cannot be extended in length.
- New directories cannot be created programatically.
This library is a part of 'blibs' - set of custom Mad-Pascal libraries.
https://gitlab.com/bocianu/blibs
name: | value: | description: |
---|---|---|
xBIOS_ADDRESS | $800 | Change this value if you are using xbios at non-default location |
xBIOS_VERSION | xBIOS_ADDRESS + $02 | location of version number in memory |
xBIOS_RENAME_ENTRY | xBIOS_ADDRESS + $03 | original xBios procedures vectors |
xBIOS_LOAD_FILE | xBIOS_ADDRESS + $06 | |
xBIOS_OPEN_FILE | xBIOS_ADDRESS + $09 | |
xBIOS_LOAD_DATA | xBIOS_ADDRESS + $0c | |
xBIOS_WRITE_DATA | xBIOS_ADDRESS + $0f | |
xBIOS_OPEN_CURRENT_DIR | xBIOS_ADDRESS + $12 | |
xBIOS_GET_BYTE | xBIOS_ADDRESS + $15 | |
xBIOS_PUT_BYTE | xBIOS_ADDRESS + $18 | |
xBIOS_FLUSH_BUFFER | xBIOS_ADDRESS + $1b | |
xBIOS_SET_LENGTH | xBIOS_ADDRESS + $1e | |
xBIOS_SET_INIAD | xBIOS_ADDRESS + $21 | |
xBIOS_SET_FILE_OFFSET | xBIOS_ADDRESS + $24 | |
xBIOS_SET_RUNAD | xBIOS_ADDRESS + $27 | |
xBIOS_SET_DEFAULT_DEVICE | xBIOS_ADDRESS + $2a | |
xBIOS_OPEN_DIR | xBIOS_ADDRESS + $2d | |
xBIOS_LOAD_BINARY_FILE | xBIOS_ADDRESS + $30 | |
xBIOS_OPEN_DEFAULT_DIR | xBIOS_ADDRESS + $33 | |
xBIOS_SET_DEVICE | xBIOS_ADDRESS + $36 | |
xBIOS_RELOCATE_BUFFER | xBIOS_ADDRESS + $39 | |
xBIOS_GET_ENTRY | xBIOS_ADDRESS + $3c | |
xBIOS_OPEN_DEFAULT_FILE | xBIOS_ADDRESS + $3f | |
xBIOS_READ_SECTOR | xBIOS_ADDRESS + $42 | |
xBIOS_FIND_ENTRY | xBIOS_ADDRESS + $45 | |
xBIOS_SET_BUFFER_SIZE | xBIOS_ADDRESS + $48 |
name: | type: | description: |
---|---|---|
TxBiosConfig | record
end; | Structured type used to store and represent xBios configuration file. |
name: | address: | type: | description: |
---|---|---|---|
xDIRSIZE | xBIOS_ADDRESS + $3e5 | byte | current directory size in sectors (1 byte) |
xSPEED | xBIOS_ADDRESS + $3e6 | byte | STD SPEED |
xHSPEED | xBIOS_ADDRESS + $3e7 | byte | ULTRA SPEED |
xIRQEN | xBIOS_ADDRESS + $3e8 | byte | User IRQ (1 byte) |
xAUDCTL | xBIOS_ADDRESS + $3e9 | byte | AUDCTL |
xFILE | xBIOS_ADDRESS + $3ea | word | File handle (2 bytes) |
xDIR | xBIOS_ADDRESS + $3ec | word | Root directory handle (2 bytes) |
xIOV | xBIOS_ADDRESS + $3ee | word | I/O module entry (2 bytes) |
xBUFFERH | xBIOS_ADDRESS + $3f0 | byte | Buffer adr hi byte (1 byte) |
xBUFSIZE | xBIOS_ADDRESS + $3f1 | byte | Buffer size lo byte $100-SIZE (1 byte) |
xDAUX3 | xBIOS_ADDRESS + $3f2 | byte | Buffer offset (1 byte) |
xSEGMENT | xBIOS_ADDRESS + $3f3 | word | Bytes to go in binary file segment (2 bytes) |
xNOTE | xBIOS_ADDRESS + $3f5 | word | File pointer (2 lower bytes) |
xNOTEH | xBIOS_ADDRESS + $3f7 | byte | File pointer (highest byte) |
xDEVICE | xBIOS_ADDRESS + $3fc | byte | Device ID |
xDCMD | xBIOS_ADDRESS + $3fd | byte | CMD (1 byte) |
xDAUX1 | xBIOS_ADDRESS + $3fe | byte | Sector lo byte (1 byte) |
xDAUX2 | xBIOS_ADDRESS + $3ff | byte | Sector hi byte (1 byte) |
name: | type: | description: |
---|---|---|
xBiosIOresult | byte = 0 | contains result of last IO operation ( 0 = OK, 1 = KO ) |
xBiosIOerror | byte = 0 | contains register X value after last error (for debuging purposes) |
xBiosDirEntryIndex | byte = 0 | contains index of last directory entry, after using xBiosFindEntry or xBiosGetEntry |
xBiosDirEntryStatus | byte = 0 | contains status of last directory entry, after using xBiosGetEntry |
xBiosDirEntrySector | word = 0 | contains starting sector of found directory entry, after using xBiosFindEntry |
name: | description: |
---|---|
xBiosCheck | function xBiosCheck:byte;Checks for the presence of xBios in memory. Looks at address defined as xBiosAddress.
returns: |
xBiosRenameEntry | procedure xBiosRenameEntry(var filename:TString); assembler;This function allows you to rename a file or directory. There is no limit to the characters used in the filename apart from that they must fit a case insensitive “8.3” format without the dot. If your filename is not 8 characters long, pad it out with spaces.
parameters: |
xBiosLoadFile | procedure xBiosLoadFile(var filename:TString); assembler;Loads and runs the file, INIT and RUN headers are supported. In the case the file does not have a defined block RUN will be launched from the beginning of the first block.
parameters: |
xBiosOpenFile | procedure xBiosOpenFile(var filename:TString); assembler;Opens a file in order to carry out subsequent IO operations.
parameters: |
xBiosLoadData | procedure xBiosLoadData(dest: pointer); assembler;Loads data from file to a specified destination address. You can set the file offset (xBiosSetFileOffset) and the amount of data to be loaded (xBiosSetLength). If you do not define these values, data will be loaded from the current position of the file pointer to the end of the file.
parameters: |
xBiosLoadLz4Data | procedure xBiosLoadLz4Data(dest: pointer); assembler;Loads and decompres data from compressed lz4 file to a specified destination address. Based on xxl & fox routine from here: https://xxl.atari.pl/lz4-decompressor/
parameters: |
xBiosWriteData | procedure xBiosWriteData(src: pointer); assembler;Saves data from memory to a file, starting from the current position in the file. You can set the file pointer offset current (xBiosSetFileOffset) and the amount of data to be saved (xBiosSetLength). If you do not define these values, data from the current file position to the end of the file is written to the file.
parameters: |
xBiosOpenCurrentDir | procedure xBiosOpenCurrentDir; assembler;Opens the current directory. |
xBiosGetByte | function xBiosGetByte:byte; assembler;Reads one byte from opened file.
returns: |
xBiosPutByte | procedure xBiosPutByte(b:byte); assembler;Writes one byte into opened file.
parameters: |
xBiosFlushBuffer | procedure xBiosFlushBuffer; assembler;All write operations are cached, use this to flush the buffer to the current file. |
xBiosSetLength | procedure xBiosSetLength(len: word); assembler;Defines the amount of data to process while reading or writing.
parameters: |
xBiosSetInitAd | procedure xBiosSetInitAd(adr: word); assembler;Allows you to change the init address vector INITAD ($2E2) for loaded binary files.
parameters: |
xBiosSetFileOffset | procedure xBiosSetFileOffset(pos: cardinal); assembler;Sets the current read/write position in the current file with a value stored in parameter. This item is calculated relative to the beginning of the file. In DOS speak, the operation is called "POINT". You can only move this pointer forward.
parameters: |
xBiosSetRunAd | procedure xBiosSetRunAd(adr: word); assembler;Allows you to change the run address vector RUNAD ($2E0) for loaded binary files.
parameters: |
xBiosSetDefaultDevice | procedure xBiosSetDefaultDevice; assembler;Restores the standard IO device. |
xBiosOpenDir | procedure xBiosOpenDir(var filename:TString); assembler;Allows you to change the current directory.
parameters: |
xBiosLoadBinaryFile | procedure xBiosLoadBinaryFile; assembler;Loads and runs the binary file from the current read/write position. INIT and RUN headers are supported. |
xBiosOpenDefaultDir | procedure xBiosOpenDefaultDir; assembler;Opens the default directory. |
xBiosSetDevice | procedure xBiosSetDevice(dev: word); assembler;Changes the IO device.
parameters: |
xBiosRelocateBuffer | procedure xBiosRelocateBuffer(adr: word;c:byte); assembler;Changes address of IO buffer. If c = 1, the relocation can be carried out even during IO. The data will not be lost. If c = 0, buffer contents will not be copied to a new location.
parameters: |
xBiosGetEntry | procedure xBiosGetEntry; assembler;Gets another entry in the directory. The xBiosDirEntryIndex returns the index to the filename or folder (byte of buffer address is stored in the variable xBUFFERH). The xBiosDirEntryStatus is set with the status. The xBiosIOresult is set to 1 when the end of the directory is found. |
xBiosOpenDefaultFile | procedure xBiosOpenDefaultFile; assembler;Opens the default file. The function does not search the directory, the file handle is derived from the variable 'xFILE'. |
xBiosReadSector | procedure xBiosReadSector(sector: word); assembler;Loads an sector into a buffer.
parameters: |
xBiosFindEntry | procedure xBiosFindEntry(var filename:TString); assembler;This function allows you to find the specified directory entry. The xBiosDirEntryIndex returns the index to the filename or folder (byte of buffer address is stored in the variable xBUFFERH). The xBiosDirEntrySector returns starting sector number of found entry. If an entry is not found, the xBiosIOresult is set to 1.
parameters: |
xBiosSetBufferSize | procedure xBiosSetBufferSize(size: byte); assembler;This feature allows you to set the buffer size for IO operations. Buffer Size is also stored in the variable xBUFSIZE in bytes format. |
DosGetEntryName | function DosGetEntryName:TString;Reads and returns last directory entry name. Can be invoked only after xBiosGetEntry or xBiosFindEntry.
returns: |
DosReadEntryName | procedure DosReadEntryName(ptr: pointer);overload;Reads and stores last directory entry name at provided memory address. Can be invoked only after xBiosGetEntry or xBiosFindEntry.
parameters: |
DosReadEntryName | procedure DosReadEntryName(var s: TString);overload;Reads and stores last directory entry name in string provided. Can be invoked only after xBiosGetEntry or xBiosFindEntry.
parameters: |
DosHasEntryExt | function DosHasEntryExt(ext: TString):boolean;Checks if last entry extension matches extension provided as an parameter.
parameters:returns: |
DosGetEntrySize | function DosGetEntrySize:word;Reads and returns last directory entry size (in sectors). Can be invoked only after xBiosGetEntry or xBiosFindEntry.
returns: |
DosGetEntrySector | function DosGetEntrySector:word;Returns first sector occupied by last directory entry. Can be invoked after xBiosGetEntry.
returns: |
DosGetEntryStatus | function DosGetEntryStatus:byte;Reads and returns last directory entry status byte. Can be invoked after xBiosFindEntry.
returns: |
DosIsDir | function DosIsDir(status: byte):boolean;Interprets directory entry status byte, returning true if entry is an directory.
returns: |
DosIsFile | function DosIsFile(status: byte):boolean;Interprets directory entry status byte, returning true if entry is an file.
returns: |
DosIsDeleted | function DosIsDeleted(status: byte):boolean;Interprets directory entry status byte, returning true if entry has been deleted.
returns: |
DosIsLocked | function DosIsLocked(status: byte):boolean;Interprets directory entry status byte, returning true if entry has been locked.
returns: |
DosIsOpened | function DosIsOpened(status: byte):boolean;Interprets directory entry status byte, returning true if entry has been opened for writing.
returns: |
DosFileExists | function DosFileExists(var filename:TString):boolean;Checks if file exists in current directory.
parameters:returns: |
DosDirExists | function DosDirExists(var filename:TString):boolean;Checks if subdirectory exists in current directory.
parameters:returns: |
formatFilename | function formatFilename(s:TString; showExt:boolean):TString;Formats xBIOS filenames into common dos, dot separated format.
parameters:returns: |