The routines in MTXLib are currently mostly direct equivalents to MTX BASIC commands. See the Memotech documentation for further details. The routines are generally direct entries into MTX ROM routines, with no error checking. Incorrect parameter values will, at best, result in one of the usual MTX BASIC cryptic error codes, or may result in a crash requiring a reboot.
Read a value from a Z80 I/O port. The full 16 bit address is used. The only known MTX add-on which makes use of the high byte of the address is Speculator.
Include file: ioport.h
Write a to from a Z80 I/O port. The full 16 bit address is used. The only known MTX add-on which makes use of the high byte of the address is Speculator. The data is specified as 16-bit as this results in a more efficient subroutine call. Only the lower byte of the data variable is actually used.
Include file: ioport.h
Displays a character.
Include file: stdio.h
Reads a character from the keyboard. Waits until the key has been released.
Include file: stdio.h
Adjusts a value asigned to a sprite.
p = Parameter to assign (see table below).
n = Sprite number.
v - Value to assign.
p | Meaning | Range for v |
---|---|---|
0 | Pattern | 0 - 127 for size 0 sprites 0 - 31 for size 1 sprites |
1 | Colour | 0 - 15 |
2 | X position | 0 - 255 |
3 | Y position | 0 - 255 |
4 | X speed | 0 - 255 (128 - 255 treated as negative) |
5 | Y speed | 0 - 255 (128 - 255 treated as negative) |
Include file: mtxscrn.h
Sets plotting attributes on a graphics screen.
p = 0 - Inverse print.
p = 1 - Over print.
p = 2 - Unplot.
p = 3 - Over-plot.
state = 0 - Off.
state = 1 - On.
Include file: mtxscrn.h
Clears the screen.
Include file: mtxscrn.h
Sets the colour for the graphics screen.
p = 0 - Print paper.
p = 1 - Print ink.
p = 2 - Non-print paper.
p = 3 - Non-print ink.
p = 4 - Border colour.
n = Colour (0-15).
Include file: mtxscrn.h
Create and select a virtual screen.
n = Virtual screen number (0 - 7).
t = Type of screen (0 = text, 1 = graphics).
x = Horizontal position of left corner (0 - 39 or 31).
y = Vertical position of top corner (0 - 23).
w = Width of virtual screen (x + w <= 40 or 32).
h = Height of virtual screen (y + h <= 24).
s = Physical screen width (40 or 32).
Include file: mtxscrn.h
Move the cursor down one line.
Include file: mtxscrn.h
Move the cursor to top left.
Include file: mtxscrn.h
Move the cursor left one character.
Include file: mtxscrn.h
Turn off the flashing cursor.
Include file: mtxscrn.h
Turn on the flashing cursor.
Include file: mtxscrn.h
Move the cursor right one character.
Include file: mtxscrn.h
Move the cursor up one line.
Include file: mtxscrn.h
Set parameters to control sprites:
p | Meaning | Range for v |
---|---|---|
0 | Speed (1 is fastest) | 1 - 255, 0 = 256 |
1 | Distance to move | 1 - 255 |
2 | Number of sprites | 0 - 32 |
3 | Number of circling sprites | 0 - 32 |
4 | Plot sprite number | 0 - 32 |
5 | Number of moving sprites | 0 - 32 |
6 | Magnitude and size | 0 = 8x8 mag 1 1 = 8x8 mag 2 2 = 16x16 mag 1 3 = 16x16 mag 2 |
Include file: mtxscrn.h
Sets the cursor position.
x = Horizontal position (0 - 31 or 39).
y = Vertical position (0 - 23).
Include file: mtxscrn.h
Erase to end of line.
Include file: mtxscrn.h
Define a pattern for a character or sprite.
p> | Meaning | n | d1 ... d8 |
---|---|---|---|
0 | Redefine an ASCII character | 32 - 127 | Pixels for each row |
1 | Redefine a non-ASCII character | 129 - 154 | Pixels for each row |
2 | Colours for each row of a character | 147 - 154 | 16 * paper + ink |
3 | Pattern for 8x8 sprite | 0 - 127 | Pixels for each row |
4 | NW quarter of a 16x16 sprite | 0 - 31 | Pixels for each row |
5 | SW quarter of a 16x16 sprite | 0 - 31 | Pixels for each row |
6 | NE quarter of a 16x16 sprite | 0 - 31 | Pixels for each row |
7 | SE quarter of a 16x16 sprite | 0 - 31 | Pixels for each row |
Include file: mtxscrn.h
Set the ink colour (0 - 15).
Include file: mtxscrn.h
Test for a key pressed. Returns the character code, or zero if no key pressed.
Include file: mtxscrn.h
Plot a line from (x1, y1) to (x2, y2).
Include file: mtxscrn.h
Controls a sprite in a number of ways. The value of p can be summed to perform multiple actions. The value of d must be consistent with all the selected actions.
n = Sprite number (1 - 32).
p | Meaning | d |
---|---|---|
1 | Move sprite 1 step | Direction of movement (0 - 8) |
2 | Change the sprites pattern | Pattern number (0 - 31 or 127) |
4 | Change the direction of sprite movement | Direction of movement (0 - 8) |
8 | Plot at centre of sprite | Ignored |
Include file: mtxscrn.h
Selects page mode for the screen.
Include file: mtxscrn.h
Selects the paper colour (0 - 15).
Include file: mtxscrn.h
Plots a point at (x, y).
Include file: mtxscrn.h
Selects scroll mode for the screen.
Defines a sprite:
n = Sprite number (1 - 32).
p = Pattern number (0 - 127 for 8x8 sprites, 0 - 31 for 16x16 sprites).
xp = Horizontal position of sprite centre (0 - 4059).
yp = Vertical position of sprite centre (0 - 4059).
xs = Horizontal speed (-128 - 127).
ys = Vertical speed (-128 - 127).
c = Colour (0 - 15).
Include file: mtxscrn.h
Move the graphics screen relative to the sprite planes.
dir = Direction (0 - 7).
dis = Distance (0 - 255).
Include file: mtxscrn.h
Select a virtual screen.
n = Virtual screen number (0 - 7).
Include file: mtxscrn.h
Turn off all sound.
Include file: mtxsnd.h
Pause for a period. The duration of the pause is determined by the number of interrupts occurring. By default, in BASIC, that is one every 8ms.
wait = Number of interrupt periods to wait for.
Include file: mtxsnd.h
Define the number of sound buffers to use for each channel.
Include file: mtxsnd.h
Starts a sound. The sound will continue untill changed by another command.
chan = Sound channel (0 - 3).
freq = Frequency (0 - 1023).
vol = Volume (0 - 15).
Include file: mtxsnd.h
Define a sound transition. The duration is specified in multiples of 16ms, and the frequency and volume increments are applied every 16ms.
chan = Sound channel (0 - 3).
freq = Frequency (0 - 8191).
vol = Volume (0 - 1023).
finc = Frequency increment.
vinc = Volume increment.
durn = Duration of transition.
mode = 0 - Continue from previous frequency and volume (ignore new values).
mode = 1 - Start at specified new frequency and volume.
Include file: mtxsnd.h