Grace for DOS

Grace for DOS is an implementation of the Grace programming lanugage for MS-DOS–compatible systems. It consists of an interpreter that evaluates textual Grace source files, and a library that can be used with DJGPP to compile the Grace program to a native DOS executable.

Grace for DOS runs under DOSBox, DOSBox Staging, or DOSBox-X, or native MS-DOS.

Interpreter

Download GRACE.EXE and run grace file.grc to interpret the source code. If you just want to run some Grace code on DOS, this is the one you want.

Library

The library download contains the Grace interpreter, a libgrace.a static library, and some header files, along with a minimal C bootstrap program and Makefile. It’s intended that you put your source code in PROGRAM.GRC and run make with DJGPP in your PATH and other environment variables.

Download gracedos.zip.

VGA module

Both the interpreter and the library include an increasingly-misnamed “vga” module that can be accessed via import "vga" as vga. This module provides access to the VGA memory and mode, text properties and output, mouse and keyboard input, and timing-related operations.

vga.mode:=
Exposes VGA modesetting. vga.mode := 19 enters mode 13h 320x200x256, and some other methods are specialised for that mode. Mode 3 is standard text mode.
vga.at(offset) put(byte)
Sets location offset in the VGA memory to the given value 0-255.
vga.setColour(col) atX(x) Y(y)
In mode 13h only: sets pixel (x, y) to colour col.
vga.rectFrom(x1, y1) to(x2, y2) colour(col)
In mode 13h only: fills a rectangle between upper-left (x1, y1) and lower-right (x2, y2). To draw a single-pixel line, the coordinates must be different by 1. Uses moderately fast memory-copying to fill.
vga.drawSprite(bytes, width, height) atX(x) Y(y)
When given a Blob value (as returned from getResource), interprets its bytes as a width by height mode 13h sprite, and puts the pixels starting from top-left corner (x, y). Colour value 255 is transparent. :
vga.mouseEnabled:=
Enables mouse display and input when set to true, disables when set to false.
vga.mouseVisible:=
Hides the mouse pointer while it is enabled when set to false.
vga.mouseX
Returns the current X coordinate of the mouse, 0-640.
vga.mouseY
Returns the current Y coordinate of the mouse.
vga.mouseButton
Returns the currently-pressed mouse button(s) as a number. 1 is left.
vga.puts(text)
Writes text to the screen at the current location. In mode 13h, draws using the BIOS font and the current text foreground and background colours. Otherwise, writes text to the console normally.
vga.puts(text) at(x, y)
Writes text to the screen at the current location. In mode 13h, draws using the BIOS font and the current text foreground and background colours at pixel location (x, y). Otherwise, writes text to the console normally at text coordinate (x, y).
vga.goToXY(x, y)
Moves the text cursor to text location (x, y).
vga.textbg(col)
Sets the text background colour to col for future output. In text mode, this can only be a dark colour 0-7, but in mode 13h may be any palette index.
vga.textcolour(col)
Sets the text foreground colour to col for future output.
vga.putTextByte(b)
Given a number 0-255, writes that byte as text, allowing for characters > 127 to be printed using the system font.
vga.getch
Returns a single character from the keyboard buffer as a string, blocking until one is present.
vga.kbhit
Returns true if there has been a key pressed on the keyboard that is yet to be read.
vga.delay(duration)
Pauses the program for duration milliseconds. Uses a spinloop around gettimeofday to work around a DosBox classic bug.
vga.clock
Returns the system “clocks” counter.
vga.timeofday
Returns the time of day in floating-point seconds.

Collections

GRACE.EXE includes a module collections.grace within it, which can be imported with import “collections” as collections Then def lst = collections.list [1, 2, 3] lst.add 4 print(lst.at 2) lst.add 2.5 at 2 for (lst) do { item -> } def dct = collections.dictionary [ “key1” :: 1, “key2” :: 2 ] dct.at “key3” put 3 print(dct.at “key3”)

Lists have size, at(index), at(index)put(value), add(value), add(value)at(index), clear, removeAt(index), removeItem(value), do(block1), reversed, map(block1), map(block1)combine(block2), zip(iterable)do(block2), first, flatMap(block1), join(separator), contains(value), without(predicate).

Dictionaries have size, at(key), at(key)put(value), containsKey(key), keys, values, bindings.

Technical base

This implementation uses the model and backend from Fast & Easy ASTs for Flexible Embedded Interpreters <https://doi.org/10.1145/3759426.3760977>.

Michael Homer — 2026 f929e369