aboutsummaryrefslogtreecommitdiff
path: root/src/keybuftest.c
blob: 4ea7f129247fe22e07b963ac50392880753e849d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <peekpoke.h>
#include <conio.h>

#include "keybuf.h"

#define RTCLOK 0x14

void read_input(void) {
	char got[20];
	char c, *p = got;

	while( (c = keybuf_cgetc()) )
		putchar(c);

		// *p++ = c;

	/*
	*p = '\0';

	if(p != got)
		fputs(got, stdout);
		*/
}

void process(void) {
	POKE(RTCLOK, 0);
	while(PEEK(RTCLOK) < 30) {
		keybuf_poll_kbd();
	}
}

void idle(void) {
	char c;
	POKE(RTCLOK, 0);
	while(PEEK(RTCLOK) < 30) {
		if( (c = keybuf_cgetc()) )
			putchar(c);
	}
}

void main(void) {
	cursor(1);
	keybuf_init();

	while(1) {
		process();
		read_input();
		idle();
	}
}