forked from arti/vt1200
59 lines
1.3 KiB
C
59 lines
1.3 KiB
C
/*
|
|
* render.c -- Task 3 acceptance: draw a border, a playfield outline and
|
|
* TERMTRIS through the cell-grid backend, then keep the window alive so the
|
|
* loader can snapshot it.
|
|
*/
|
|
#include "xlib.h"
|
|
#include "x11.h"
|
|
|
|
extern int vt_install_xg(void);
|
|
|
|
volatile vt_u32 mark[16];
|
|
int term_width, term_height;
|
|
static const char *word = "TERMTRIS";
|
|
|
|
static void put(int row, int col, const char *s, unsigned char attr)
|
|
{
|
|
x11_setcursor(row, col);
|
|
while(*s) x11_ibmchar((unsigned char)*s++, attr);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
int r, c;
|
|
|
|
mark[0] = 0x524E4452UL; /* RNDR */
|
|
if(vt_x11_init() != 0) return 1;
|
|
mark[1] = (vt_u32)vt_dpy;
|
|
mark[2] = vt_win;
|
|
mark[3] = vt_gc;
|
|
mark[5] = (vt_u32)VT_XPENDING(vt_dpy);
|
|
|
|
x11_clearscr();
|
|
for(c = 0; c < 80; c++) {
|
|
x11_setcursor(0, c); x11_ibmchar('#', 0x70);
|
|
x11_setcursor(23, c); x11_ibmchar('#', 0x70);
|
|
}
|
|
for(r = 0; r < 24; r++) {
|
|
x11_setcursor(r, 0); x11_ibmchar('#', 0x70);
|
|
x11_setcursor(r, 79); x11_ibmchar('#', 0x70);
|
|
}
|
|
for(r = 2; r < 20; r++) {
|
|
for(c = 4; c <= 13; c++) {
|
|
int edge = (r == 2 || r == 19 || c == 4 || c == 13);
|
|
x11_setcursor(r, c);
|
|
x11_ibmchar(edge ? '#' : '.', edge ? 0x70 : 0x07);
|
|
}
|
|
}
|
|
put(1, 20, word, 0x70);
|
|
put(21, 20, "0123456789", 0x70);
|
|
put(22, 20, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0x70);
|
|
vt_x11_flush();
|
|
mark[4] = 0x464C5553UL; /* FLUS */
|
|
|
|
for(;;) {
|
|
VT_SLEEP(100);
|
|
}
|
|
return 0;
|
|
}
|