The system monitor entry point is software interrupt 1. The handler reads a byte afterthe SWI instruction, and dispatch the call using the SWI table (which is in RAM and can be modified or moved).
So, the calling code is:
SWI FCB n
Most assemblers will allow this equivalent code:
CALL n
Note that you can add 0x80 to the syscall number. This will jump to it using a JMP instead of a JSR instruction. Since most system calls (except MENU) end with an RTS, be careful of what return address you left on the stack.
This is equivalent to pressing the “initial prog” reset button and calls the reset vector. Most of the time, it gets you back to the BASIC or assembler menu.
Inputs:
Prints the character in register B at the current screen position (stored at 0x201B in monitor direct-page)
Map the color video memory so the CPU can write to it.
Map the shape video memory so the CPU can write to it.
Beep!
Perform a keyboard scan and decode the key pressed.
Output:
Lowlevel keyboard scan.
Output:
Input:
Draws a line from (PLOTX, PLOTY) to (X, Y).
Output:
Input:
Draw a pixel, or put a character, at the position set by X and Y. Works the same way as DRAW.
Output:
Input:
Gets pixel color.If the pixel is set in shape memory, the foreground color for the block is returned. If pixel is not set, background color for the block is returned.
Output:
Output:
Output:
Input:
Set register B to the ASCII code of the character at given position, or 0 if unknown. Ifthe character is accented, you will get a value of 16. Calling GETC again with the same parameters will return the accent code, then the letter. Alternatively, those can be read from the SS2GET and SS3GET variables (0x205C).
Output:
Input:
Scan the joystick. This only works if a “sound and game” expansion is plugged.
Output:
Input:
Play one music note.
Input:
Perform tape read or write
Output:
Input:
Starts or stop the tape drive motor. If bit 1 is set, a delay of 1 second is done. Use this when writing to make sure the block is clearly separated from the previous and next ones, and that the loader has time to process the previous block while the tape continues running when reading.
Output:
Input:
This requires the CC90 parallel port extension, and a printer.
Output:
The default SWI table maps all the following syscalls to the floppy ROM. If there isn't a floppy controller attached to the machine, these will jump to unmapped memory, and crash.
The floppy controller expansions are compatible with TO machines as well. Since the TO doesn't use SWI, but has programs jumping directly in a table at the start of the ROM, it's safe to call the disk ROM vectors that way (but then you won't use SWI overrides, if any)
Input:
General low-level floppy control operation. This performs different actions depending on the value of the DKOPC (0x2048) variable.
Some of these can be combined, for example DKOPC = 88 is “check and write sector”.
Input:
Output:
Input:
Input:
Reads the boot sector from the floppy, and runs it.
The default boot sector for DOS BASIC disk loads the DOS BASIC, then runs AUTO.BAT from the floppy if present. It then drops to the interactive DOS BASIC interpreter.
Output:
Input:
Output:
Input:
Allocate a block in the FAT for the current file.
Output:
Input:
Allocate a directory entry for creating a new file.
Output:
Input:
Updates the disk FAT and catalog from the working copy in memory. This commits all changes done so far and make newly written files visible on disk.
This will not update the “sector count in last cluster” and “byte count in last sector”. If you need a precision greater than a cluster for your file sizes, you have to set them yourself. Other solutions are possible, such as padding ASCII files with EOF characters.
Note it is only useful to call this for file open modes 2 (write) and 3 (write with backup).
Output:
Input:
Reads the disk FAT to the in-memory working copy
Output:
Input:
Locate a file in the FAT and open it for reading or writing. Writing to a file truncates it. The “save and erase” mode opens a temporary file (named SCRATCH.DOS), which will replace the original directory entry when the file is closed.
Output:
Erase the file from the disk directory, and free all the sectors allocated to it in the FAT. The file must be open first. This does not rewrite the working FAT to disk, for this you must use the “end transaction” call.
Output: