Skip to content

VDI reference

The VDI is the drawing layer. Opcodes are the standard GEM ones; GDP sub-opcodes are written 11.n. Every primitive is clipped to the workstation’s clip rectangle. The device is true-colour (RGBA-8888); see the GEM overview for how applications detect that.

CallOpNotes
v_opnwk1open a physical device. id 1–10 = screen; 31–40 = metafile; 21–30 (printer) reserved for the planned PDF device
v_clswk2close a physical workstation (finalises a metafile)
v_clrwk3clear the workstation to pen 0
v_updwk4flush (a no-op for the screen; the PDF device will flush a page)
v_opnvwk100open a virtual workstation (16 slots; handle 1 = the physical screen)
v_clsvwk101close a virtual workstation
vq_extnd102extended inquiry; reports true colour (work_out[5]==0, 32 planes) and arbitrary text rotation
vs_clip129per-workstation clip rectangle; honoured by every primitive
vst_load_fonts119map OS/Fonts files to ids 2…N (opened on first use); returns the count
vst_unload_fonts120no-op (faces are cheap and kept)

The device mechanism is driver-based, so adding a device is a driver behind v_opnwk. The metafile device (id 31–40) records subsequent calls to a .gem file and replays them onto any workstation; raster copies are inlined into the record so images survive replay.

CallOpNotes
v_pline6polyline; Cohen–Sutherland clipped, width + dash, end styles
v_gtext8graphic text; FreeType, UTF-8, sized / aligned / rotated / effected
v_fillarea9filled polygon (even-odd, pattern-masked)
v_cellarray10grid of coloured cells scaled into a rectangle
v_contourfill1034-connected seed fill (boundary or seed-colour)
v_bar11.1filled rectangle
v_arc11.2circular arc (line colour)
v_pieslice11.3filled pie slice
v_circle11.4filled circle
v_ellipse11.5filled ellipse
v_ellarc11.6elliptical arc
v_ellpie11.7filled elliptical pie
v_rbox11.8rounded-rectangle outline
v_rfbox11.9filled rounded rectangle
v_justified11.10text spread to a width (word and/or character spacing)
v_pmarker7polymarkers (dot, plus, asterisk, square, cross, diamond)
vr_recfl114fill rectangle (honours interior / style / perimeter)

Curves are adaptively segmented, so arcs and rounded boxes stay smooth at any size or line width. The line pen is round, giving uniform thickness at every angle, and dash phase is distance-projected so dashes don’t “walk” as a line rotates.

CallOpNotes
vs_color14set a palette pen (RGB 0–1000)
vsl_type15line type 1 (solid) … 6, 7 = user (vsl_udsty)
vsl_width16line width (round pen)
vsl_color17line colour
vsl_ends108end styles: square (flat) / arrow / round, per end
vsl_udsty113user-defined 16-bit dash mask (used by line type 7)
vsm_type / vsm_height / vsm_color18 / 19 / 20marker type / size / colour
vst_height12text size in pixels
vst_point107text size in points (72 dpi ⇒ 1pt = 1px)
vst_color22text colour
vst_rotation13text baseline angle, any angle (1/10°, CCW)
vst_effects106bold / light / italic / underline / outline / shadow (combinable)
vst_alignment39horizontal (left/centre/right) + vertical anchor
vst_font21select a face by id (1 = system; 2…N from OS/Fonts, opened on first use)
vsf_interior23hollow / solid / pattern / hatch / user
vsf_style24fill style index (24 patterns + 12 hatches)
vsf_color25fill colour
vsf_perimeter104outline filled areas
vsf_udpat112user-defined 16×16 fill pattern
vswr_mode32writing mode: replace / transparent / XOR / reverse-transparent
CallOpNotes
vst_arbpt / vst_arbpt32246arbitrary point size (the 32-bit form takes 16.16)
vst_setsize / vst_setsize32252character width independent of height (condensed / expanded)
vst_width231character width in pixels
vst_skew253arbitrary text shear angle
vst_kern237pair kerning (engages only if the face has a kern table)
vst_track_offset237uniform letter-spacing
vst_charmap / vst_map_mode236character-set mapping — Unicode-native, so reports Unicode
vst_fg_color / vst_bg_color200 / 201text foreground / opaque-text background pen
vst_name230select a face by family name
v_setrgb138set a pen directly from 8-bit RGB
vsf_xperimeter104perimeter drawn with the current line style
v_bez / v_bez_fill6.13 / 9.13Bézier path stroke / fill (adaptive flattening)
v_bez_qual5.99Bézier flattening quality (0–100 %)
v_bez_on / v_bez_off11.13enable / query Bézier capability
CallOpNotes
vro_cpyfm109opaque raster copy (device-format MFDB)
vrt_cpyfm121colour a 1-bpp source (fg/bg pens) honouring the writing mode
vr_trnfm110standard (planar) ↔ device (RGBA chunky) conversion via the palette
v_get_pixel105read back the matching palette pen (−1 if no match)
vr_transfer_bits170scaled bitmap combine — logic ops, plus extended blends (alpha src-over, additive, subtractive, weighted, highlight)
vr_clip_rects_by_dst / _by_src171clip a transfer rect pair (and the 32-bit forms)
vs_hilite/min/max/weight_color207the colours driving the extended raster blends
vq_hilite/min/max/weight_color209read those colours back

vr_transfer_bits is the compositor’s scale-and-blend primitive: it does the nearest-neighbour scaling for window content and the per-pixel alpha compositing the theme engine needs.

CallOpNotes
vq_color26read back a pen (RGB 0–1000)
vql_attributes / vqm_ / vqf_ / vqt_attributes35–38current line / marker / fill / text attributes
vqt_extent116text bounding box (4 corners; size / effects / rotation aware)
vqt_width117one character’s cell width + bearings
vqt_name130a font’s id + name (enumerate to build a font menu)
vqt_fontinfo131structural metrics: char range + the five baseline-relative distances
vqt_f_extent240fractional text extent (summed without per-glyph rounding)
vqt_real_extent240.4200the tight inked bounding box
vqt_advance / vqt_advance32247sub-pixel character advance (integer + 1/65536, or 16.16)
vqt_pairkern235pair-kern delta for two characters
vqt_trackkern234track-kerning offset
vqt_justified132the per-character offsets a justified line would use
vqt_name_and_id230.100look up a font id + canonical name by name
vqt_ext_name130.1name + format / classification flags
vqt_char_index190encoding map (Unicode-native ⇒ identity)
vq_scrninfo102.1screen pixel format (direct RGBA-8888: bpp + per-channel bits/shifts)
vq_cellarray27read a region back as a grid of pen indices

Input devices read a host-fed state (the SDL backend on the host, the AES event pump on hardware). Each device has two modes (vsin_mode): request blocks until the device fires, sample returns the current state at once.

CallOpNotes
vsin_mode33request / sample per device class
vrq_locator / vsm_locator28pointer position + terminator
vrq_valuator / vsm_valuator29a scalar input (dial / wheel)
vrq_choice / vsm_choice30a numbered selection
vrq_string / vsm_string31a typed line
v_show_c / v_hide_c122 / 123pointer visibility (hide nests)
vq_mouse124pointer position + button mask
vq_key_s128keyboard shift / ctrl / alt state
vex_butv / vex_motv / vex_curv / vex_timv125–127 / 118exchange an input-interrupt vector
vex_wheelv134mouse-wheel handler
vsc_form111set the mouse-pointer shape (16×16 mono cursor)
CallOpNotes
v_opnbm / v_clsbm100.1 / 101.1open / close an off-screen bitmap as a workstation
v_open_bm100.3modern open-bitmap variant
v_resize_bm100.2re-point a bitmap workstation at a new MFDB
v_getoutline / v_get_outline243a glyph’s outline as a Bézier path (round-trips through v_bez)
v_killoutline242free an outline (a no-op — outlines are written to the caller’s arrays)
v_flushcache251drop the rasterised glyph cache