forked from opencode.energia.arti.ee/vt1200
40 lines
772 B
C
40 lines
772 B
C
/*
|
|
* input.c -- Task 4 acceptance: link main.c against stubs for the game, inject
|
|
* keys, and record the bytes main.c sends to game_input().
|
|
*/
|
|
#include "game.h"
|
|
#include "x11.h"
|
|
#include "xlib.h"
|
|
|
|
int term_width, term_height;
|
|
/* game.c globals main.c sets or reads; the real game supplies these */
|
|
int onlyascii, use_gfxchar, monochrome;
|
|
int quit;
|
|
long tick_interval;
|
|
volatile vt_u32 mark[128];
|
|
|
|
void cleanup_game(void) {}
|
|
void wait_display(void);
|
|
|
|
int init_game(void)
|
|
{
|
|
mark[0] = 0x494E5054UL; /* INPT */
|
|
vt_x11_term_init();
|
|
x11_clearscr();
|
|
return 0;
|
|
}
|
|
|
|
long update(long msec)
|
|
{
|
|
(void)msec;
|
|
mark[1] = mark[1] + 1;
|
|
return 100;
|
|
}
|
|
|
|
void game_input(int c)
|
|
{
|
|
int n = (int)mark[2];
|
|
if(n < 100) mark[3 + n] = (vt_u32)(unsigned char)c;
|
|
mark[2] = (vt_u32)(n + 1);
|
|
}
|