M68K Trap Tasks
Calling trap #15
Input routing
Text I/O
tasks 0 to 20Display string with CR, LF
D0.B = 0- In
- A1 = string address, D1.W = length
Display string
D0.B = 1- In
- A1 = string address, D1.W = length
Read string
D0.B = 2- In
- A1 = buffer address
- Out
- The NUL terminated string at (A1), D1.L = its length
Display signed number
D0.B = 3- In
- D1.L = number
Read number
D0.B = 4- Out
- D1.L = number
- Note
- A number too long for 32 bits keeps its low 32 bits.
Read character
D0.B = 5- Out
- D1.B = the character, $0D for Enter
Display character
D0.B = 6- In
- D1.B = ASCII code
Terminate
D0.B = 9Set or get the text cursor, or clear the screen
D0.B = 11- In
- D1.W = $FF00 to clear, $00FF to get, otherwise column in the high byte and row in the low byte
- Out
- For $00FF, D1.W = column in the high byte, row in the low byte
Keyboard echo
D0.B = 12- In
- D1.B = 0 to turn the echo off, anything else to turn it on
Display NUL terminated string with CR, LF
D0.B = 13- In
- A1 = string address
Display NUL terminated string
D0.B = 14- In
- A1 = string address
Display unsigned number in a base
D0.B = 15- In
- D1.L = number, D2.B = base (2 to 36)
- Note
- A base outside 2 to 36 stops the program with an error naming D2.B.
Input prompt and line feed
D0.B = 16- In
- D1.B = 0 to hide the input prompt, 1 to show it, 2 to turn the line feed after Enter off, 3 to turn it on
- Note
- Any other D1.B value stops the program with an error naming the value.
Display string and number
D0.B = 17- In
- A1 = string address, D1.L = number
Display string and read number
D0.B = 18- In
- A1 = string address
- Out
- D1.L = number
Display signed number in a field
D0.B = 20- In
- D1.L = number, D2.B = field width
Graphics
tasks 33 to 96Colors
- black
$00000000 - maroon
$00000080 - green
$00008000 - olive
$00008080 - navy
$00800000 - purple
$00800080 - teal
$00808000 - gray
$00808080 - red
$000000FF - lime
$0000FF00 - yellow
$0000FFFF - blue
$00FF0000 - fuchsia
$00FF00FF - aqua
$00FFFF00 - ltgray
$00C0C0C0 - white
$00FFFFFF
Pictures in Files
Set or get the screen size
D0.B = 33- In
- D1.L = width in the high word and height in the low word, or 0 to get, 1 for windowed, 2 for full screen
- Out
- For D1.L = 0, D1.L = width in the high word, height in the low word
Set pen color
D0.B = 80- In
- D1.L = color as $00BBGGRR
Set fill color
D0.B = 81- In
- D1.L = color as $00BBGGRR
Draw pixel
D0.B = 82- In
- D1.W = X, D2.W = Y
Get pixel color
D0.B = 83- In
- D1.W = X, D2.W = Y
- Out
- D0.L = color as $00BBGGRR
Draw line
D0.B = 84- In
- D1.W = X1, D2.W = Y1, D3.W = X2, D4.W = Y2
Draw line to
D0.B = 85- In
- D1.W = X, D2.W = Y
Move to
D0.B = 86- In
- D1.W = X, D2.W = Y
Draw rectangle
D0.B = 87- In
- D1.W = left X, D2.W = upper Y, D3.W = right X, D4.W = lower Y
Draw ellipse
D0.B = 88- In
- D1.W = left X, D2.W = upper Y, D3.W = right X, D4.W = lower Y
Flood fill
D0.B = 89- In
- D1.W = X, D2.W = Y
Draw unfilled rectangle
D0.B = 90- In
- D1.W = left X, D2.W = upper Y, D3.W = right X, D4.W = lower Y
Draw unfilled ellipse
D0.B = 91- In
- D1.W = left X, D2.W = upper Y, D3.W = right X, D4.W = lower Y
Set drawing mode
D0.B = 92- In
- D1.B = 2, 4, 16 or 17
- Note
- Bitwise modes (0, 1, 3 and 5 to 15) stop the program with an error naming the mode. Double buffering is available for drawing animated sprites.
Set pen width
D0.B = 93- In
- D1.B = width in pixels
Repaint the screen
D0.B = 94Draw text at a pixel position
D0.B = 95- In
- A1 = NUL terminated string, D1.W = X, D2.W = Y
Get the drawing point
D0.B = 96- Out
- D1.W = X, D2.W = Y
Keyboard and mouse
tasks 7 to 61Key codes
Check for keyboard input
D0.B = 7- Out
- D1.B = 1 when a character is waiting, 0 otherwise
Get key state
D0.B = 19- In
- D1.L = four key codes, or 0 for the last keys
- Out
- D1.L = four $FF/$00 bytes, or the last key up in the high word and the last key down in the low word
Enable or disable the simulator shortcut keys
D0.B = 24- In
- D1.L = 0 to enable, 1 to disable
Read the mouse
D0.B = 61- In
- D1.B = 0 for the current state, 1 for the last button release, 2 for the last button press
- Out
- D0.B = Ctrl, Alt, Shift, Double, Middle, Right, Left from bit 6 down; D1.L = Y in the high word, X in the low word
Program time
tasks 8 to 23Get time
D0.B = 8- Out
- D1.L = hundredths of a second
- Note
- A testcase uses a virtual clock starting at 2000-01-01 midnight UTC. Task 23 advances that clock.
Delay
D0.B = 23- In
- D1.L = hundredths of a second
- Note
- A testcase runs on a virtual clock: the delay completes immediately and advances that clock instead of waiting.
Files
tasks 50 to 59Close all files
D0.B = 50- Out
- D0.W = 0
Open an existing file
D0.B = 51- In
- A1 = NUL terminated path
- Out
- D1.L = file number, or -1; D0.W = 0, 3 when it opened for reading only, 2 when it did not open
Open a new file
D0.B = 52- In
- A1 = NUL terminated path
- Out
- D1.L = file number, or -1; D0.W = 0, or 2 when it did not open
Read a file
D0.B = 53- In
- D1.L = file number, A1 = buffer address, D2.L = byte count
- Out
- D2.L = bytes read; D0.W = 0, 1 at the end of the file, 2 on an error
- Note
- A read of no bytes, D2.L = 0, reports 2, including when an earlier read reached the end of the file.
Write a file
D0.B = 54- In
- D1.L = file number, A1 = buffer address, D2.L = byte count
- Out
- D0.W = 0, or 2 on an error
Position a file
D0.B = 55- In
- D1.L = file number, D2.L = position
- Out
- D0.W = 0, or 2 on an error
Close a file
D0.B = 56- In
- D1.L = file number
- Out
- D0.W = 0, or 2 when it was not open
Delete a file
D0.B = 57- In
- A1 = NUL terminated path
- Out
- D0.W = 0, or 2 when there is no File there
File dialog
D0.B = 58- In
- D1.L = 0 to open, 1 to save; A1 = title, A2 = filter, either 0 for none; A3 = a 256 byte buffer
- Out
- The path chosen at (A3), NULs to 256 bytes; D1.L = 1, or 0 when the dialog was cancelled; D0.W = 0, or 2 when the buffer runs past the end of memory
- Note
- Shows a text prompt naming the title and asking for a path from the Project root. A D1.L other than 0 or 1 stops the program with an error naming the value.
Check that a file exists
D0.B = 59- In
- A1 = NUL terminated path
- Out
- D0.W = 0 when the File can be written, 3 when it can only be read, 2 when there is none
Sound
tasks 70 to 77Sound in this editor
Play a sound file
D0.B = 70- In
- A1 = NUL terminated path
- Out
- D0.W = 1 if the play request succeeds; 0 if the player is busy or the file exists but cannot be played. If the path does not exist, D0 is unchanged.
Load a sound file
D0.B = 71- In
- A1 = NUL terminated path, D1.B = slot
Play a loaded sound
D0.B = 72- In
- D1.B = slot
- Out
- D0.W = 1 if the play request succeeds; 0 if the player is busy or the loaded file cannot be played. If the slot is empty, D0 is unchanged.
Play a sound file with DirectX
D0.B = 73- In
- A1 = NUL terminated path
- Out
- D0.W = 1 if the play request succeeds; 0 if the path does not exist or the file cannot be played
- Note
- MIDI files can sound different from EASy68K because the editor uses its own instrument sound bank instead of the Windows synthesizer. DirectMusic segment files cannot be played.
Load a sound file with DirectX
D0.B = 74- In
- A1 = NUL terminated path, D1.B = slot
- Out
- D0.W = 1 if the file is loaded; 0 if the path does not exist or the file cannot be played
Play a loaded DirectX sound
D0.B = 75- In
- D1.B = slot
- Out
- D0.W = 1 if the play request succeeds; 0 if the slot is empty
Control the sound player
D0.B = 76- In
- D1.B = slot, D2.L = 0 to play once, 1 to loop, 2 to stop, 3 to stop all
- Out
- D0.W: control 0 or 1 returns 1 if playback starts, or 0 for an empty slot, unplayable file, or busy player; control 2 returns 1 for the last nonempty slot requested by task 72 or task 76 control 0/1, even if that request failed or playback has ended, or 0 otherwise; control 3 always returns 1. Other controls return 0.
- Note
- Loops stop when the program ends; EASy68K keeps them playing until another program is loaded.
Control the DirectX sound player
D0.B = 77- In
- D1.B = slot, D2.L = 0 to play once, 1 to loop, 2 to stop, 3 to stop all
- Out
- D0.W: controls 0, 1 and 2 return 1 for a nonempty slot, or 0 for an empty slot; control 2 returns 1 even if no sound from that slot is playing. Control 3 stops all DirectX sounds and returns 1 for a nonempty supplied slot, or 0 for an empty slot. Other controls return 0.
- Note
- Control 3 stops every DirectX sound even if the supplied slot is empty; EASy68K stops nothing in that case. Both return 0 in D0.W for the empty slot. Loops stop when the program ends; EASy68K keeps them playing until another program is loaded.