Make a shell

When terse-host opens, the first thing you see, the launcher with its tiles, is not part of the host. It is a Terse32 program like any other, the shell, with one device the others lack: Machines, device 8, which starts other machines and says where their screens go. You can write your own.

The smallest shell

This one starts the built-in program hello and gives it the whole screen and the keyboard:

#include "terse.h"

static const uint8_t builtin[32]; /* all zero */

int main(void)
{
    uint32_t h = mach_start_named(builtin, "hello", 5);
    mach_place(h, 0, 0, 640, 480);
    mach_focus(h);
    for (;;)
        terse_wait_frame();
}

Each machine is a whole separate Terse32 machine, with its own memory, devices and budget. The shell only decides what runs and where it is seen.

Build and run it

Save it as myshell.c and build it, listing device 8 besides the usual terminal (2) and line display (3):

terse build myshell.c --device 2:0 --device 3:0 --device 8:0

Then:

terse run --shell myshell.terse --frames 30 --dump

runs it headless and prints the shell's screen, then each machine's: a line -- machine 1 running 0 0 640 480 hello -- and hello's text. In a window:

terse-host --shell myshell.terse

Where to take it

From here a shell is a matter of taste: a list of programs to choose from (mach_builtin lists the built-in ones), several machines tiled side by side, a key that brings the shell back (the host sends it a home event), saving and restoring machines. The reference shell, programs/shell, does all of these in about 2,000 lines of C.

What you have now

A system of machines under your own shell. That is the end of the guide's part for implementers; the last page is for people who want to use Tersenet: Using Tersenet.

Every call of device 8 is in The Machines device, and panels, the 3D view and input routing in Screens, panels and input.