M68K Trap Tasks
The M68K has one system call: trap #15. The task number goes in D0.B, its arguments in the other registers, and the answer comes back in the
registers the task names. The interface is EASy68K's, so a program written for that
simulator runs here unchanged as far as its I/O goes.
Text and graphics share one image, as they do in EASy68K's output window: what a program prints is drawn on the screen at the text cursor and appended to the terminal transcript, which is what testcases assert on. Click the screen panel to give the program the keyboard; the ring around it says the editor's own shortcuts are off while it has focus.
Text I/O tasks 0 to 20
Printing and reading. Everything printed is appended to the terminal transcript and drawn on the screen at the text cursor, because EASy68K has one output window where text and graphics share the image; the transcript is what testcases assert on. Typed input is echoed to both.
0 Display string with CR, LF
Displays up to D1.W characters of the string at (A1), stopping at a NULL, then a new line. See task 13 for the NULL terminated form.
1 Display string
Displays up to D1.W characters of the string at (A1) without a new line. See task 14 for the NULL terminated form.
2 Read string
Reads a line of input. With a screen keyboard the line is typed on the screen and ends with Enter; otherwise the editor asks for it, and a testcase answers it from its scripted input.
3 Display signed number
Displays D1.L in decimal, in the smallest field it fits. See tasks 15 and 20.
4 Read number
Reads a line and parses it as a decimal number.
5 Read character
Reads one character. With a screen keyboard it is taken as soon as it is typed, without waiting for Enter; check task 7 first to poll instead of waiting.
6 Display character
Displays one character.
9 Terminate
Ends the program.
11 Set or get the text cursor, or clear the screen
The text cursor is where printed text lands, in character cells counted from the top left. Clearing with $FF00 clears text and graphics together, since they share one image, and homes the cursor. Positions outside the screen are clamped to it.
13 Display NULL terminated string with CR, LF
Displays the NULL terminated string at (A1), then a new line.
14 Display NULL terminated string
Displays the NULL terminated string at (A1) without a new line.
15 Display unsigned number in a base
Displays D1.L as an unsigned number in the base in D2.B.
17 Display string and number
Task 14 then task 3: the NULL terminated string, then the signed number.
18 Display string and read number
Task 14 then task 4: the NULL terminated string as a prompt, then a number.
20 Display signed number in a field
Task 3 right justified in a field D2.B columns wide. A number too long for the field is displayed in full.
Graphics tasks 33 to 96
Drawing on the screen. The origin is the top left, coordinates are pixels, and drawing outside the screen is ignored. Colors are $00BBGGRR longs, the same encoding EASy68K uses, so its color equates are unchanged. Rectangles and ellipses exclude their right and bottom edges, as they do in EASy68K, which draws them through the Windows GDI.
Colors
A color is a long written $00BBGGRR: blue in bits 23-16, green
in bits 15-8 and red in bits 7-0. These are EASy68K's own equates, and a
program that defines them by name needs no change.
$00000000 black$00000080 maroon$00008000 green$00008080 olive$00800000 navy$00800080 purple$00808000 teal$00808080 gray$000000FF red$0000FF00 lime$0000FFFF yellow$00FF0000 blue$00FF00FF fuchsia$00FFFF00 aqua$00C0C0C0 ltgray$00FFFFFF white33 Set or get the screen size
Resizes the screen and clears it. The minimum is EASy68K’s 640 by 480, which is also the size a program starts with. The windowed and full screen requests are accepted and ignored, since the screen is a panel in the editor.
80 Set pen color
The color lines, outlines, pixels and text are drawn in.
81 Set fill color
The color the insides of rectangles and ellipses and a flood fill are drawn in.
82 Draw pixel
One pixel in the pen color. The pen width does not apply and the drawing point does not move.
83 Get pixel color
Reads the pixel of the image being drawn on, which with double buffering is the off screen one. Outside the screen it answers with the background color.
84 Draw line
A line in the pen color, leaving the drawing point at X2, Y2.
85 Draw line to
A line in the pen color from the drawing point to X, Y, which becomes the new drawing point: a polyline is one task per point.
86 Move to
Moves the drawing point without drawing.
87 Draw rectangle
Filled with the fill color and outlined with the pen. The right and bottom edges are excluded, so a rectangle whose edges meet draws nothing.
88 Draw ellipse
The ellipse inscribed in that rectangle, filled with the fill color and outlined with the pen. A square bounding rectangle draws a circle.
89 Flood fill
Spreads the fill color from X, Y over every neighbouring pixel of the color that was there, four ways.
90 Draw unfilled rectangle
The outline of task 87 in the pen color, with nothing inside.
91 Draw unfilled ellipse
The outline of task 88 in the pen color, with nothing inside.
92 Set drawing mode
Mode 4 draws normally and is the default; mode 2 moves the drawing point without changing any pixel; mode 16 turns double buffering off and mode 17 turns it on, so drawing goes to an off screen image until task 94 shows it.
EASy68K’s bitwise modes (0, 1, 3 and 5 to 15) stop the program with an error naming the mode. Double buffering covers the sprite erasing use of the XOR mode.
93 Set pen width
The width of lines and of the outlines of rectangles and ellipses. A single pixel (task 82) ignores it.
94 Repaint the screen
Shows the off screen image drawn under mode 17. With double buffering off it does nothing but ask for a repaint.
95 Draw text at a pixel position
Draws the string in the pen color with its top left corner at X, Y, over whatever is already there, so a label can sit on a drawing. Control characters are ignored. Text printed with the text tasks lands at the text cursor instead (task 11).
96 Get the drawing point
Where the next line-to would start.
Keyboard and mouse tasks 7 to 61
Polled input from the focused screen. Key codes are EASy68K’s, which every environment in this editor uses. There are no input interrupts: a program asks for the state it wants when it wants it (tasks 60 and 62 are therefore not supported).
Key codes
A letter key is the ASCII code of its capital, so
Ais $41 andZis $5A. Shift, Alt and Ctrl do not change it.A top row digit is its ASCII code, so
0is $30 and9is $39.The function keys are contiguous from F1, so F1 is $70 and F12 is $7B.
The keypad digits with Num Lock on are contiguous from $60.
$08 Backspace$09 Tab$0D Enter$10 Shift$11 Ctrl$12 Alt$14 Caps Lock$1B Esc$20 Space$21 Page Up$22 Page Down$23 End$24 Home$25 Left arrow$26 Up arrow$27 Right arrow$28 Down arrow$2D Insert$2E Delete$BA Semicolon$BB Equals$BC Comma$BD Minus$BE Period$BF Slash$C0 Backquote$DB Open bracket$DC Backslash$DD Close bracket$DE Quote7 Check for keyboard input
Polls without consuming anything: the character it reports is the one task 5 or task 2 reads next. A testcase reports its remaining scripted input the same way.
19 Get key state
Reads whether up to four keys are held right now, one byte of the answer per key code in the same order; with D1.L = 0 it answers with the last key released and the last key pressed instead. A key held down is reported at least once however briefly it was tapped, so a polling loop never misses one.
24 Enable or disable the simulator shortcut keys
Accepted and ignored: the screen panel already hands every key it takes to the program, so there are no simulator shortcuts to give up.
61 Read the mouse
The pointer position is in screen pixels with the same origin drawing uses, whatever the panel’s zoom. The release and press states persist until the next one, so a program that polls slowly still sees every click; the double bit is only ever set on a press.
Program time tasks 8 to 23
Waiting and reading the clock. A delay suspends the program without blocking the editor, so Stop still answers and the screen still repaints while it runs. Testcases run on a virtual clock, where a delay completes at once and the clock starts at zero.
8 Get time
The time the program has been running, in hundredths of a second.
EASy68K counts from midnight; here the clock starts at zero when the run starts, and a testcase’s virtual clock does too. Programs measure elapsed time by subtracting two reads, which is unchanged.
23 Delay
Lets D1.L hundredths of a second of program time pass. The editor stays responsive throughout, and the screen is repainted, so this is how an animation paces itself.
A testcase runs on a virtual clock: the delay completes immediately and advances that clock instead of waiting.
Tasks that are not supported
These stop the program with an error naming the task, rather than doing something the program did not ask for. Everything they configure is either hardware this editor does not have or a decision the editor makes for itself.
Differences from EASy68K
- Everything printed also reaches the terminal transcript, which EASy68K does not have. It is what keeps testcases and the non-graphical view working.
- The screen draws text in one fixed 8 by 16 cell font, so task 21 (font properties) is not supported and the text screen cannot be read back (task 22) or scrolled (task 25).
- Task 92's bitwise drawing modes (0, 1, 3 and 5 to 15) stop the program with an error naming the mode. Double buffering, modes 17 and 94, covers the sprite erasing the XOR mode is usually used for.
- Task 8 counts from the start of the run rather than from midnight, and task 23 completes immediately during a testcase, which runs on a virtual clock.
- Rectangles and ellipses exclude their right and bottom edges. That is what EASy68K does too, because it draws through the Windows GDI, but it surprises people often enough to be worth saying twice.