| What it does | Inputs | Outputs | Destroys | Notes |
|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Execute a file. | int32_t sys_ExecuteFile(const char *path, char *args); | -1 and Cf set if file does not exist or is not a valid executable format, or if malloc failed somewhere. ExecutingFileFd set to point to file descriptor. -1 if file not found, -2 if /var/PATH not found. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Opens a file from a path and returns file descriptor. | void *fs_OpenFile(char *path); | hl = file descriptor. hl is -1 and Cf set if file does not exist. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| get the memory address of a given sector address. | void *fs_GetSectorAddress(uint16_t sector); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| check if a directory exists. | bool fs_CheckDirExists(char *path); | true if path exists, else false |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| divide by sector size, adding 1 to the result if there is a remainder. Returns 1 if HL is 0 | HL = number to divide | HL = result |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| copies file name from file descriptor | char *fs_CopyFileName(void *fd); | returns -1 on fail | Allocates space for copied file name |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| read data from a file into RAM | int fs_Read(void *dest, int len, uint8_t count, void *fd, int offset); | number of bytes read |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| write data to a file | void *fs_Write(void *data, int len, uint8_t count, void *fd, int offset); | New file descriptor or -1 and Cf set if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| HL+=A | HL number A increment | HL number+increment |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Scans the keypad and updates data registers; checking if a key was pressed | 0 if no keys pressed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Free all memory malloc'd by sys_Malloc | void sys_FreeAll(void); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return current keypress | A = keycode zf set if no key pressed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Scans the keypad and updates data registers |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Allocate memory | void *sys_Malloc(size_t amt); | hl = malloc'd bytes. hl = 0 if failed to malloc Cf set if failed to malloc |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Create a file descriptor with contents stored in RAM. | fs_CreateRamFile(const char *path, uint8_t flags, void *data, size_t len); | HL = file descriptor or HL=0 and Cf set if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| draws a horizontal line to the current buffer | HL line X coordinate E line Y coordinate BC line length |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Insert ram following &usermem[asm_prgm_size], returning a pointer to it. | void* fs_AllocRam(size_t len); | pointer to allocated memory, or 0 if not enough space. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Wait until a key is pressed and return it |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Wait until a key is pressed, wait until it is released or another is pressed, returning the original keycode. | A = keycode |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| clear the screen and display a string. | hl = string | Ensures 8bpp mode, sets the draw location to the buffer and display to vram. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| get user input | uint8_t gui_Input(char *buffer, int max_len); | 0 if user exit, 1 if user enter, 9|12 if user presses down|up arrow key |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Print an integer. Does not swap buffers. | hl = integer |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Clear (Zero) BC bytes at HL |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| move 9 bytes from HL to OP1 |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| compare HL to DE. Returns the resultant of "sbc hl,de" without modifying either. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| copy 8 bytes from HL to DE |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Search for a TI variable in directories listed by $TIVARS | OP1 containing 1 byte var type, 8 byte file name | HL = pointer to 2 byte file length DE = pointer to file data Cf set if file not found or otherwise cannot be opened. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| load DE with 16-bit value at HL, advancing HL+=2 |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Check if there are HL bytes avalible in userMem |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| insert HL bytes into usermem at address DE | hl = bytes to insert, de = address to insert at | hl = new end of file, de = pointer to the space inserted |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Print a string to the current cursor position and blit the buffer when finished. | HL = string |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Get the current keypress and return it in A |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Clear the screen and back buffer |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Set the cursor position to 0,0 |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Display a memory error message |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Currently Nothing |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| return system info. Compatibility define. It actually returns 0xFF0000. lol |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| I honestly don't know. Included this routine for compatibility with USBDDRVCE. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| I honestly don't know. Included for compatibility with USBDRVCE. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Erase flash sector | A sector to erase | calls boot routine $2DC |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Create a file given a path and return a file descriptor. | void *fs_CreateFile(const char *path, uint8_t flags, int len); | file descriptor. Returns 0 if failed to create file. |
if len is zero, the file data section will not be initialized. if len is greater than 65536, this routine fails. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| convert a string to uppercase | HL pointer to string | HL HL+strlen(HL) |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| convert a string to lowercase | HL pointer to string | HL HL+strlen(HL) |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| get absolute path representation of hl | char *fs_AbsPath(const char *path); | hl = absolute path. Will be the same as the input if it is already an absolute path Cf set if failed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| multiply by the number of bytes per sector | HL = number | HL*=fs_sector_size |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| locate and return a pointer to a library from a ".dll" file in a directory listed in "/lib" | OP1 name of library | hl points to file length, de points to file data. Cf set if failed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Opens a file given a path and a file descriptor to start searching in. Returns file descriptor. | void *fs_OpenFileInDir(char *path, void *dir); | hl = file descriptor. hl is -1 if file does not exist, or if trying to start search in a file. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Resizes a file descriptor. | void *fs_SetSize(int len, void *fd); | new file descriptor if success, -1 and Cf set if fail | New file contents will be empty, but old file data will be preserved until the next cleanup. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Overwrite all data stored in a file from a given data pointer. | int WriteFile(void *data, int len, void *fd); | New file descriptor. -1 if failed to write |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| convert a number to a string | HL = number to convert | DE = string string stored at gfx_string_temp |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| delete a file/directory given a path | bool fs_DeleteFile(const char *name); | true/nz if success, false/zf if fail |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| delete a variable in ram from the VAT | OP1 = type byte, 8 byte name of var to delete | Cf set if failed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| create a ram file in the /tivars/ directory | OP1+1 = 8 byte name of var to create A = var type hl = length to allocate for file | hl = pointer to (VAT entry) 2 byte file length, de = pointer to file data Cf set and HL = -1 if failed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| get user input without clearing the provided buffer first. | uint8_t gui_InputNoClear(char *buffer, int max_len); | 0 if user exit, 1 if user enter, 9/12 if user presses down/up arrow key |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| initialize cluster map given data within the file system. | void fs_InitClusterMap(void); | uses the first half of vRam as scrap. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| write BC bytes to flash from HL to DE. | HL, DE, BC | DE points to byte following written data |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| write a byte from A to flash at address DE | A, DE |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Join argv into a space-delimited string. | char *sys_JoinArgv(int argc, char *argv[]); | Pointer to string. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Get the length of a path string | int fs_PathLen(const char *path); | hl = length of path, de = pointer to end of path, a = end of path character |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| return a string representing the parent directory of a given path. | char *fs_ParentDir(const char *path); | HL = string representing path to parent directory. Returns -1 and Cf on fail. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| convert a file.ext string to a file entry | char *fs_StrToFileEntry(char *dest, const char *src); | pointer to file entry, 0 if failed. First byte of file entry will be fsentry_longfilename if file's name is too long for an 8.3 path. Cf set if failed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| list items in a directory | int fs_DirList(void **buffer, const char *path, unsigned int num, unsigned int skip); | Returns number of items read. Returns -1 and Cf on fail. | integer arguments "num" and "skip" must be less than 65536. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Free as block of memory malloc'd by sys_Malloc | void sys_Free(void *ptr); | Cf set if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Jump execution to an executable file and return to caller start afterwards. | hl = program file to execute de = arguments bc = program file to return to | Returns to start of program returned to. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Jump execution to an executable file | hl = file to execute de = arguments |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Initialize a device (if needed) | int drv_InitDevice(device_t* ptr); ptr Pointer to device file. | depends on device, usually -1 and Cf set if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Copy a file given paths and return a file descriptor. | void *fs_CopyFile(const char *src, const char *dest); | file descriptor of new file. Returns 0 if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Find the best unmapped address to sample random numbers from. | void* sys_GetRandomAddress(); | HL = address |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return a random 8-bit number. | uint8_t sys_Random8(); | A = number |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return a random 32-bit number. | uint32_t sys_Random32(); | EUHL = number |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| get the sector a given address lies within | int fs_GetSector(void *address); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| write a byte into a file if the byte can be written | bool fs_WriteByte(uint8_t byte, void *fd, int offset); | Fails if the byte can't be written without swapping |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| rename a file | void *fs_RenameFile(const char *directory, const char *old_name, const char *new_name); | file descriptor. returns zero if failed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Set the text cursor position | void _SetCursorPos(uint8_t row, uint8_t col); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Create a directory given a path and return a file descriptor. | void *fs_CreateDir(const char *path, uint8_t flags); | file descriptor. Returns 0 if failed to create directory. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| clears the back buffer | A color to fill with |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| clears the lcd | A color to fill with |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Sanity check the filesystem and initialize it as needed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Set an error handler for an interrupt caused by the [On] key. | void *sys_SetOnInterruptHandler(void (*handler)(void)); | Returns previous error handler. | user error handler is called after the interrupt is handled. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Print a character to the back buffer and advance the text cursor | A = character to print |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| print a string to the current lcd buffer, advancing curcol | HL pointer to string | HL pointer to character after the last one printed Cf set if a control code is encountered or if the text would overflow the line. A = control code if a control code is encountered. (Cf will be set) | If you need a routine callable from C, this is not the one you'll want to use. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Print an unsigned integer. Dos not swap buffers. | hl = integer |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| get a pointer to a file's data section | void *fs_GetFilePtrRaw(const char *path); | HL = file data pointer, BC = file data length, A = file flags, Cf set and HL = -1 if failed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| execute a file given a pointer to it's path in HL | HL = pointer to file path | same as sys_ExecuteFile |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| turns off the calculator until the on key is pressed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return the next unused process ID, setting the malloc ID. | uint8_t sys_NextProcessId(void); | new process ID, or 0 if failed. | Used for categorizing malloc'd memory and threads. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Decrement PID and return it if threading disabled. Does nothing if threading enabled. | uint8_t sys_PrevProcessId(void); | process ID. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Free all memory allocated by a given process ID | void sys_FreeProcessId(uint8_t id); | DO NOT free process ID 1 since it is used by the OS and should be preserved. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Clean up the filesystem, clearing freed areas. | None | None | Ensures 8bpp mode and draws progress indicator. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Swap lcd_text_fg and lcd_text_fg2 |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Create and write a new file | void *fs_WriteNewFile(const char *name, uint8_t properties, void *data, int len); | HL = file descriptor. HL = -1 and Cf set if failed. | Will overwrite file if it exists. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| set the current font | void *gfx_SetFont(void *data) | HL = old font data | data structure: uint8_t num_bitmaps, uint8_t spacing[], uint8_t data[] |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Reset the current font to the default built-in font |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Free all memory allocated by the currently executing process ID. | void sys_FreeProcessId(void); | Automatically called after program exits. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| decompress a block of zx7-compressed data into a user-provided RAM buffer | void util_Zx7Decompress(void *dest, void *src); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Check how much memory is free in Malloc RAM | int sys_CheckMallocRAM(void); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| compute draw location on the current lcd buffer from XY coodinate. | HL X coordinate E Y coordinate | HL pointer to draw location |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| get pointer to font data | hl = current font data |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Initialise the standard (8bpp) XLibC palette |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| moves the text position 9 rows ahead, and moves the collumn to zero. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| set the lcd to 8bpp mode |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| set the lcd to 16bpp mode |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| draws a sprite to the current buffer at 2x scale | HL pointer to sprite BC X<<8 + Y |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Allocate 32 bytes of memory, 32-byte aligned. | void *sys_Malloc32Align32(void); | hl = malloc'd bytes. hl = 0 if failed to malloc Cf set if failed to malloc |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Allocate 64 bytes of memory, 256-byte aligned. | void *sys_Malloc64Align256(void); | hl = malloc'd bytes. hl = 0 if failed to malloc Cf set if failed to malloc |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| open a file, looking in directories from $PATH variable if file not found | void *sys_OpenFileInPath(const char *path); | pointer to file descriptor |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Similar to sprintf but uses system vars and malloc's the output buffer. | char *sys_VarString(const char *str); | hl string where $VAR's are replaced with their respective values. Returns -1 and Cf set if failed. | $VAR must be terminated with a space " " which is not included in the output. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return remaining free space in the filesystem | int fs_GetFreeSpace(void); | filesystem remaining space in bytes |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return pointer to file data given a file descriptor | void *fs_GetFDPtrRaw(void *fd); | pointer to file data, or -1 and Cf set if file data has not been allocated yet. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return length of file data given a file descriptor | int fs_GetFDLenRaw(void *fd); | length of file data. Will be 0 if data has not been initizlized yet. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Convert a variable name from OP1 into a BOS file name. | OP1 variable type byte, 8 byte name | hl = path Cf set if failed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Starts a thread that does nothing until a key is pressed and unpressed, passes the keypress to the caller via a callback function, then stops. | int th_WaitKeyCycle(void (*callback)(uint8_t key)); | returns 0 and Cf unset on success, -1 and Cf set on fail. | Starts a thread, which won't do anything until handled. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| join two filesystem paths | char *fs_JoinPath(const char *path1, const char *path2); | hl = resultant path. Cf set, hl = -1 if failed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Allocate memory to be treated as persistent | same as sys_Malloc | same as sys_Malloc |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| open a file, looking in directories from var variable if file not found | void *sys_OpenFileInVar(const char *path, const char *var); | pointer to file descriptor |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| return the last path word of a path | char *fs_BaseName(const char *path); | copy of last path word, or same as input if it is the only path word, or pointer to '/' if that is the last character of the path. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Move a file given paths and return a file descriptor. | void *fs_MoveFile(const char *src, const char *dest); | file descriptor of new file. Returns 0 if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Attempt to write data to a file directly, failing if the data can't be written correctly or if the file isnt large enough. | void *fs_WriteDirectly(void *data, int len, uint8_t count, void *fd, int offset); | New file descriptor or -1 and Cf set if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Read flash sector A into the sector cache (VRAM) | returns pointer to sector cache in hl |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Write the currently cached sector back to flash sector A |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| open a file, looking in directories listed in /var/LIB. | void *sys_OpenFileInLib(const char *path); | pointer to file descriptor |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| run threads given a pointer to a file path structure | void sys_LoadHookThreads(void *ptr, size_t len); | data structure: type byte, entry length byte, offset of data in file (2 bytes), stack size byte, file name (null-terminated), end of entry |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| copies the lcd to the back buffer |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| spawn a thread | uint8_t th_CreateThread(void *pc, void *sp, int argc, char **argv); | thread id. 0 if failed | void *sp must be allocated at least 12 bytes behind it. If void *sp is 0, it will use the sp from the caller, minus 24 bytes. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| clears VRAM with null bytes |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Kill a thread by ID, not including child threads. | uint8_t th_KillThread(uint8_t id); | thread ID killed if successful, 0 if failed. | Cannot kill thread ID 0. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| get a pointer to a file's data section | void *fs_GetFilePtr(const char *path); | HL = file data pointer, BC = file data length, A = file flags, Cf set and HL = -1 if failed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return pointer to file data given a file descriptor | void *fs_GetFDPtr(void *fd); | pointer to file data, or -1 and Cf set if file data has not been allocated yet. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return length of file data given a file descriptor | int fs_GetFDLen(void *fd); | length of file data. Will be 0 if data has not been initizlized yet. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Wait until the last pressed keycode changes or there is no key pressed. | None | None |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Malloc a copy of a string. | char *sys_MallocDupStr(const char *str); | Malloc'd copy and Cf unset or zero and Cf set if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Malloc a copy of a string up to N characters. | char *sys_MallocDupStrN(const char *str, size_t len); | Malloc'd copy and Cf unset or zero and Cf set if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Search the symbol table (VAT) for a file specified in OP1 | Same as ti.ChkFindSym, except that 0xFF is treated as a wildcard. | Same as ti.ChkFindSym. DE = data pointer, HL = VAT pointer. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| rename a file | void *fs_Rename(const char *old_name, const char *new_name); | file descriptor. returns zero if failed |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Check if a memory block can be allocated in flash | unsigned int fs_AllocChk(unsigned int len); | hl = first sector that would be allocated, or -1 and Cf set if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Check the executable type of a given file | const char *sys_GetExecType(const char *path); | pointer to executable magic bytes, or -1 and Cf set if failed. | returns pointer to executable code in de and length of executable code in bc if hl != -1 |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Check the executable type of a given file descriptor | const char *sys_GetExecType(void *fd); | pointer to executable magic bytes, or -1 and Cf set if failed. | returns pointer to executable code in de and length of executable code in bc if hl != -1 |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Zx7 compress a block of memory. | int util_Zx7Compress(void *dest, void *src, int len, void (*progress_callback)(int src_offset)); | length in bytes written to dest. | currently doesn't work correctly |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Relocate code in data offsetting 24-bit values (offsets of data) by origin_delta. | void util_Relocate(void *data, unsigned int *offsets, int origin_delta); | relocates data in place. (data MUST be stored in ram, otherwise this will crash) offsets should be terminated with 0xffffff. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return file attribute byte for a given descriptor | uint8_t fs_GetFDAttr(void *fd); | attribute byte in A |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Allocate and initialize a Symbol list. | symlist *util_InitAllocSymList(void); | Pointer to new Symbol list. 0 if failed. | All this does is allocate 6 bytes and set to 0. The memory location doesn't matter as long as it's in RAM and initialized to 0. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Allocate and add an entry to a Symbol list. | symbol *util_AppendSymList(symlist *list, const char *name, unsigned int value, uint8_t flags); | Pointer to new Symbol. 0 if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Remove a symbol by name from a Symbol list. | symbol *util_RemoveFromSymList(symlist *list, const char *name); | Pointer to unlinked symbol. 0 if failed. | Unlinked symbol should be freed manually if not needed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Search a Symbol list for a given symbol. | symbol *util_SearchSymList(symlist *list, const char *name); | Pointer to Symbol. 0 if failed. Returns pointer to symbol preceeding the found symbol in de. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Free a Symbol list. | void util_FreeSymList(symlist *list); | symlist pointer passed should be freed manually if it was malloc'd or initialized from util_InitAllocSymList. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Execute a null-terminated command string. | int32_t sys_Exec(const char *str); | process exit code. exit code also stored in bos.LastCommandResult |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Execute a program with argc/argv. | int sys_ExecV(const char *program, int argc, char *const argv[]); | process exit code. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Execute a command string given its length. | int32_t sys_ExecData(const char *str, size_t len); | process exit code. exit code also stored in bos.LastCommandResult |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Begin execution from begPC to endPC. | int32_t sys_ExecBegin(void); | process exit code. Returns Cf set if begPC >= endPC. exit code also stored in bos.LastCommandResult | exit code is undefined if begPC >= endPC. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Continue Execution from curPC. | int32_t sys_ExecContinue(void); | process exit code. exit code also stored in bos.LastCommandResult |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Compute a SHA256 hash for some data, writing the 32-byte result to a buffer. | void util_SHA256(void* buffer, void* data, unsigned int len); | Nothing. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Convert 8-bit signed integer to a base-10 string. | char *str_ByteToStr(char *dest, uint8_t num); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Convert signed 24-bit integer to a base-10 string. | char *str_IntToStr(char *dest, int num); | pointer to dest. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Convert 32-bit signed integer num to a base-10 string. | char *str_LongToStr(char *dest, uint32_t num); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| convert a base-10 string into a 32-bit integer. | int32_t str_ToInt(const char *str, char** end); | hl = number, *end = character where parsing stopped. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Convert a keycode from sys_GetKey to a text character. | char gui_CharFromCode(uint8_t charset, uint8_t keycode); charset = character set number to pick from. keycode = keycode from sys_GetKey. | character corresponding to the given charset and keycode; 0 if out of bounds or N/A. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| execute a file given a file path, passing arguments via argc/argv. | int sys_ExecuteFileArgcArgv(const char *path, int argc, char *argv[]); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return a pointer to a device structure (if valid) | device_t* drv_OpenDevice(const char *path); path Path of device file to open. | pointer to device structure, -1 and Cf set if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return a pointer to a device structure (if valid) | device_t* drv_OpenDeviceFD(void* fd); fd File descriptor to open as device. | pointer to device structure, -1 if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return a pointer to a device's physical memory address, if applicable. | void *drv_GetDMA(device_t* ptr); ptr Pointer to device file data. | pointer to address, 0 if not applicable. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Read a character from a device file given a descriptor | int drv_GetChar(device_t* ptr); ptr Pointer to device file data. | Data (usually a character) read from device. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Write a character to a device file given a descriptor | int drv_PutChar(device_t* ptr, int c); ptr Pointer to device file data. c Character to write. | Depends on device, usually number of bytes written. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Read from a device file given a descriptor | int drv_Read(device_t* ptr, void *buffer, size_t len, size_t offset); ptr Pointer to device file data. buffer Pointer to read data into. len Length of data to read, in bytes. offset Offset to read data from. | Number of bytes read. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Write to a device file given a descriptor | int drv_Write(device_t* ptr, void *buffer, size_t len, size_t offset); ptr Pointer to device file data. buffer Pointer to data to write. len Length of data to write, in bytes. offset Offset in file to write data. | Number of bytes written. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Print a string to stdout | void gui_PrintStdout(const char* str); | Writes to stdout, which can be the default text printer or a file. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Jump execution to an executable file and return to caller afterwards. | hl = program file to execute de = arguments bc = program file to return to | Returns to caller instead of jumping to return program start. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Open a file given a file name and mode. | void** fsd_Open(const char* path, const char* mode); | file descriptor, or 0 if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Close an open file descriptor, writing changes if needed. | void fsd_Close(void** fd); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Close all open files. | void fsd_CloseAll(); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Read some data from an open file descriptor, advancing the file offset | int fsd_Read(void* buffer, size_t len, size_t count, void** fd); | count if success. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Write some data to an open file descriptor, advancing the file offset. | int fsd_Write(void* buffer, size_t len, size_t count, void** fd); | count if success. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Resize a file in ram. | int fsd_Resize(size_t len, void** fd); | new file size, 0 if failed. | resets file offset if decreasing size. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Write a string to an open file descriptor, advancing the file offset. | int fsd_WriteStr(const char* str, void** fd); | number of bytes written. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Check if a file is currently being stored in RAM | bool fsd_InRam(void** fd); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Check if a file is open | bool fsd_IsOpen(void** fd); | true if open. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Write a file to archive, unloading from RAM. | bool fsd_Archive(void** fd); | true if success. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Read a file from archive into RAM. | bool fsd_UnArchive(void** fd); | true if success. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Seek the read/write offset of a file descriptor. | int fsd_Seek(int pos, int origin, void** fd); | -1 if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return the read/write offset of a file descriptor. | int fsd_Tell(void** fd); | -1 if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Forcefully closes an open file descriptor. Does not write changes or call device deinit. | void fsd_ForceClose(void** fd); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return the data size of a file descriptor. | int fsd_GetSize(void** fd); | -1 if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Return a pointer to a file descriptor's data at the current offset. | void* fsd_GetDataPtr(void** fd); | 0 if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Allocates memory in usermem at asm_prgm_size, advancing asm_prgm_size. | void* sys_AllocHeap(size_t len); | pointer to memory or 0 if failed. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Shows a done message and waits for the user to press a key. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Ensure that the lcd to 8bpp mode. If not in 8bpp mode, clears vram. | Also overwrites ti.mpLcdUpbase to match the current draw buffer. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Ensure that the lcd to 8bpp mode. If not in 16bpp mode, clears vram. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Get the actual size of a directory. | int fs_GetDirSize(const char* path); | returns pointer to first empty entry or non-allocated dirextender in de |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Get the actual size used by a directory. | int fs_GetDirSizeFD(void* fd); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Convert OP1 into a BOS file path in /tivars. | OP1 = Var type, Var name. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Advance curPC until the corresponding "end" or "else" | void sys_ExecSkipUntilEnd(void); |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Convert a base-16 (hex) string to an unsigned 32-bit integer. | uint32_t str_HexToInt(const char* str); | euhl = number, bc = character where parsing stopped. |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Convert a string representation of a number to a signed 32-bit integer. See Notes for details. | int32_t str_IntStrToInt(const char *str); | euhl = number. | If str starts with $ or 0x, it will be processed as a hex string, otherwise a decimal string. If str starts with %, the value will be read from a variable from the current symlist. (defaulting to zero if the variable doesn't exist) |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Convert a 32-bit unsigned integer to a string | char* str_IntToHexStr(char* dest, uint32_t num); | pointer to dest |
| What it does | Inputs | Outputs | Destroys | Notes |
|---|---|---|---|---|
| Cleanup deleted directory entries | None | None | Ensures 8bpp mode and draws progress indicator. |