/* Terminal emulator μlibrary, implementing most of the ADM3A. */ /* #include before this file. */ typedef struct _admu admu; /* Call this to initialize an admu struct you have allocated with a * cols*rows buffer you have allocated. */ void admu_init(admu *t, int cols, int rows, unsigned char *screenchars); /* Call this to draw the terminal into a framebuffer with one uint32_t * per pixel. stride is normally equal to width, unless if there are * extra “horizontal overscan” pixels in between the scan lines; it’s * the number of `uint32_t`s from the beginning of one scan line to * the beginning of the next. */ void admu_generate_chars(admu *t, uint32_t *fb, int width, int stride, int height); /* Call this to make the terminal respond to a received character. */ void admu_handle_char(admu *t, unsigned char c); /* This is the size of the font admu uses, in pixels. */ enum { admu_font_w = 5, admu_font_h = 8 }; struct _admu { unsigned char *screenchars; int cursor_pos, rows, cols, pending_cup; enum { admu_ready, admu_esc, admu_cup, admu_cup2 } state; uint32_t font[256][admu_font_h][admu_font_w]; };