Table of Contents

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.

00 - Soft reset

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.

02 - Put character

Inputs:

Prints the character in register B at the current screen position (stored at 0x201B in monitor direct-page)

04 - Map color VRAM page

Map the color video memory so the CPU can write to it.

06 - Map shape VRAM page

Map the shape video memory so the CPU can write to it.

08 - Beep

Beep!

0A - Get character

Perform a keyboard scan and decode the key pressed.

Output:

0C - Keyboard test

Lowlevel keyboard scan.

Output:

0E - DRAW

Input:

Draws a line from (PLOTX, PLOTY) to (X, Y).

Output:

10 - PLOT

Input:

Draw a pixel, or put a character, at the position set by X and Y. Works the same way as DRAW.

Output:

12 - Character plot

14 - Get pixel

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:

16 - Lightpen test

Output:

18 - Lightpen scan

Output:

1A - Read character from screen

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:

1C - Joystick scan

Input:

Scan the joystick. This only works if a “sound and game” expansion is plugged.

Output:

1E - Music generation

Input:

Play one music note.

20 - Tape control

Input:

Perform tape read or write

Output:

22 - Tape motor

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:

Extensions

24 - Printer control

Input:

This requires the CC90 parallel port extension, and a printer.

Output:

Disk ROM

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)

26 - Disk control

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”.

DKOPC = 1: Reset

Input:

Output:

DKOPC = 2: Read sector

Input:

DKOPC = 4: Single density

DKOPC = 8: Write sector

Input:

DKOPC = 10: Double density

DKOPC = 20: Seek track 0

DKOPC = 40: Seek track

DKOPC = 80: Check sector

28 - Boot from floppy

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:

2A - Format floppy

Input:

Output:

2C - Allocate block

Input:

Allocate a block in the FAT for the current file.

Output:

2E - Allocate directory entry

Input:

Allocate a directory entry for creating a new file.

Output:

30 - Overwrite file with safe backup

32 - End transaction (Close file)

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:

34 - Read disk FAT

Input:

Reads the disk FAT to the in-memory working copy

Output:

36 - Update cluster

38 - Open file

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:

3A - Erase file

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: