aboutsummaryrefslogtreecommitdiff
path: root/uitest/test.c
blob: 3cd3fc5100cea671c073d04f9ba9de21b2139c06 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <atari.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include "../src/screen.h"
#include "../src/edbox.h"

void got_line(void) {
	scr_print(SCR_CURR, edit_box);
}

int main() {
	char i, s;
	char buf[40];

	OS.color2 = 0xc2;
	OS.color1 = 0x0e;

	scr_init();
	edbox_callback = got_line;

	/*
	for(i = 0; i < 4; i++) {
		sprintf(buf, "screen%d", i);
		s = scr_create(buf, 0);
		scr_set_topic(s + 1, "This is screen #%d.");
	}
	*/

	for(i = 0; i < 19; i++) {
		sprintf(buf, "line %d\n", i);
		scr_print(0, buf);
	}

	scr_print_current("login:\n");
	strcpy(buf, "Urchlay");
	edbox_readline(buf, sizeof(buf));
	scr_print_current("You are logged in as ");
	scr_print_current(buf);

	scr_print_current("Hold Start and press:\n");
	scr_print_current("N: Create new screen, C: Close screen\n");
	scr_print_current("1-7: Switch to screen (if exists).\n");
	scr_print_current("To enter text, just start typing.\n");

	while(1) {
		if(OS.ch != 0xff) {
			if(GTIA_READ.consol == 6) { /* start pressed */
				i = cgetc();
				if(i >= '1' && i <= '7') {
					if(scr_status[i - '1'] != SCR_UNUSED)
						scr_display(i - '1');
				} else if(i == 'n') {
					s = scr_create("new screen", 1);
					if(s != 0xff) {
						scr_print(0, "Screen #");
						scr_putc(0, s + '1');
						scr_print(0, " created.\n");
					} else {
						scr_print(scr_current, "Can't create screen (all in use)\n");
					}
				} else if(i == 'c') {
					scr_destroy(scr_current);
				}
			} else {
				edbox_keystroke();
			}
		}
	}
	return 0;
}