Syscalls

The system offer you a set of calls you can use to do various things. Of course, it is faster to use the hardware directly, but in some cases it may avoid you some bytes of code. To call one of them, first you set the parameters, then use (n being the id of the syscall you want executed) :

SWI
FCB n

You can also use "CALL n" if you use the 6809 language module cartridge.

Note that by adding 0x80 to the ID, you can call the syscall with a JMP instead of a JSR, so the RTS at the end of the subprogram will get back to the last JSR that was executed.

00 - MENU

Back to assembler or basic. This is identical to pressing the "initial prog" button, it calls the reset vector.

02 - PUTC

Put ASCII Char in regB to screen at current cursor position (as defined by 0x201B)

04 - FRM0

Switch screen bank to COLOR ram

06 - FRM1

Switch screen bank to PIXEL ram

08 - BEEP

Emit a beep

0A - GETC

Description

Get character from keyboard. This call does all the needed decoding to actually handle text input.

Output

0C - KTST

Description

Keyboard lowlevel scan. This scans the keyboard at the hardware level and works with raw key codes only.

Output

0E - DRAW

Description

Draw a line on screen from (PLOTX, PLOTY) to (X,Y). If CHDRAW=0, uses color defined by FORME reg. If CHDRAW is not 0, draw line using it as an ASCII value, the coordinates are handled as text one (in range 0..39/0..24), and COLOUR is used instead of FORME.

Input

Output

10 - PLOT

Description

Set a single pixel or character. Works the same way as DRAW.

12 - CHPL

Description

Puts character on screen.

Input

14 - GETP

Description

Get pixel

Input

Output

16 - LPIN

Description

Test lightpen button

Output

18 - GETL

Description

Get lightpen position.

Output

1A - GETS

Description

Read ASCII char from screen.

Input

Output

1C - JOYS

Description

Read joystrick status (if you have the hardware extension to plug a joystick)

Input

Output

1E - NOTE

Description

Play music

Input

20 - K7CO

Description

Cassette read/write

Input

Output

22 - K7MO

Description

Cassette motor control. Stopping is done after a 0.5s delay.

Input

Output

24 - RSCO

Description

Parallel port module control. (needs parallel port hardware expansion)

Input

Output


From now on, the syscalls are actually pointing to the floppy extension ROM. Ensure you have it plugged in before trying to use these.

26 - DKCONT

Description

Floppy control. Can perform various actions depending on DKOPC

Input

Output

See what happens when setting multiple bits.

28 - BOOT

Description

Run bootsector and launch AUTO.BAT.

Output

2A - FRMT

Description

Format floppy

Input

Output

2C - ALLOB

Description

Allocate block. FAT must be loaded.

Input

0x20F6 - Current block number

Output

2E - ALLOD

Description

Initial block allocation for new files. FAT must be loaded. Save the new FAT on disk, with filename, type, flag, and initial block.

Input

Output

30 - ECRSE

Description

Write sector. If an error happens, restore the FAT.

I think this uses the same parameters as read sector if you want to buld the sector yourself.

Input

0x20E9* : Sector buffer

Output

32 - FINTR

Description

Close file. FAT must be loaded and file opened in save mode (2 or 3). FAT written to disk. If open mode is 3, the SCRATCH.DOS file is renamed and erases the existing file with the same name.

Nobody sets the "sector count in last cluster" nor the "byte count in last sector". If you need to know the filesize with a byte precision, you must do it yourself.

Input

Output

34 - LECTAT

Description

Read FAT

Input

0x20ED* : FAT buffer pointer

Output

C flag set on error

36 - MAJCL

Description

Update Cluster.

Input

0x20F6 : next block number

Output

38 - RECFI

Description

Find file. You must read the FAT first.

Input

Output

3A - RECUP

Description

Erase file. You must read the FAT and find the file first. Note the FAT is modified in RAM but not written back to disk, for that you must close the file descriptor.

Output

Undocumented syscalls

The values may be different on other versions of the ROM. This is for version 2.

These ar enot really useful since you can relocate the SWI table in RAM. Unless you are hunting for a way to save 256 bytes avoiding to do that.

IDJump atDescription
103F7Jumps in screen RAM
373FBJumps in user RAM
52CFBJumps in user RAM
723FAJumps in user RAM
9C5F1Jumps in basic ROM
BFDF1Jumps in basic ROM
DD2F4Jumps in basic ROM
F87F3Jumps in user RAM
11F0F3Jumps in basic ROM
13A2F3Jumps in Floppy ROM
15D5F5Jumps in basic ROM
1731F5Jumps in user RAM
1948F2Jumps in user RAM
1BFCF5Jumps in basic ROM
1D0BF6Jumps in screen RAM
1F9BF0Jumps in user RAM
21FFF1Jumps in basic ROM
238BF7Jumps in user RAM
2513A0Jumps in screen RAM
The one below are artifacts of address in the disk ROM, which never changes. They are safe to use on all MO5s. Unfortunately most of them land into screen RAM.

2704A0Jumps in screen RAM
2907A0Jumps in screen RAM
2B0AA0Jumps in screen RAM
2D1CA0Jumps in screen RAM
2F19A0Jumps in screen RAM
3116A0Jumps in screen RAM
3322A0Jumps in user RAM
350DA0Jumps in screen RAM
371FA0Jumps in free area of screen RAM
3910A0Jumps in screen RAM
End of confirmed-to-be-stable syscalls
39131AJumps in screen RAM