Skip to content
John Westhoff edited this page Dec 12, 2017 · 1 revision

At boot, the following video modes are tried:

ModeResolutionColors
0x1181024x76816M
0x115800x60016M
0x112640x48016M
0x111640x48064K

Note that the 0x111 video mode is nearly unusable, and only exists so that VMWare Player can boot. In the future, selecting a video mode from the list of available modes is probably preferable to simply trying a number of different, potentially unsupported, modes.

At boot, the root graphics window is opened. This window contains the entire visible screen, and will never close.

Each process has an array of up to five windows. When a process is created, it inherits the windows of its parent, except for the initial process which has the root window open. A process may create new windows through the draw_create system call, which creates a new window that is a subset of a window already open by the process. In this way, a process' windows are sandboxed - a process cannot create a window larger than what its parent has passed on to it. Windows are reference-counted, and when all processes owning a window are dead, the window is freed.

Draws are issued to the window through the draw_write system call. The draw_write system call sends a null-terminated buffer of graphics_commands to the kernel, which then performs all of the draw operations through one system call. There is a standard buffer for the graphics_commands provided in user-io, which also provides functions for filling the buffer. The draw_write call is stateful, and within a call the window being drawn to is set by a command, and which window is being drawn to persists until either a command switches which window is being drawn to or it reaches the end of the graphics_command buffer. The current foreground drawing color is persistent through even calls to draw_write, and will only change when a command is issued to change it.

Each graphics_command is a struct containing an integer identifying the type of command followed by an array of four integers providing the arguments for the command. Not every command uses all four arguments, and those that don't simply ignore the extra arguments. The list of valid commands is as follows:

Command NameArgumentsDescription
GRAPHICS_WINDOWWsets the draw window to W
GRAPHICS_COLORR G Bsets the draw color to (R, G, B)
GRAPHICS_RECTX Y W Hdraws a rectangle with width W and height H at (X, Y)
GRAPHICS_CLEARX Y W Hclears a rectangle with width W and height H at (X, Y)
GRAPHICS_LINEX Y W Hdraws a line starting at (X, Y) that travels W pixels horizontally and H pixels vertically
GRAPHICS_TEXTX Y Sdraws a string S at (X, Y) (note that S is a char*, so strings are passed by reference)

Clone this wiki locally