]> git.sur5r.net Git - cc65/blob - testcode/lib/pce/conio.c
added waitvblank and fixed get_tv
[cc65] / testcode / lib / pce / conio.c
1
2 #include <conio.h>
3 #include <time.h>
4 #include <joystick.h>
5 #include <string.h>
6 #include <stdlib.h>
7
8 static int datavar = 10;
9
10 void main(void)
11 {
12     int stackvar = 42;
13     int i, j;
14     clock_t clk;
15     char *p;
16
17     joy_install(&joy_static_stddrv);
18
19     clrscr();
20
21     cputs("hello world");
22     cputsxy(0, 2, "colors:" );
23     for (i = 0; i < 16; ++i) {
24         textcolor(i);
25         cputc('X');
26     }
27     textcolor(1);
28
29     gotoxy(0,4);
30     cprintf("datavar:  %02x\n\r", datavar);
31     cprintf("stackvar: %02x\n\r", stackvar);
32
33     j = joy_count();
34     gotoxy(0,10);
35     cprintf("Found %d Joysticks.", j);
36
37     for (i = 0; i < 4; ++i) {
38         gotoxy(0, 17 + i);
39         p = malloc(16);
40         memcpy(p, "01234567890abcdef", 16);
41         cprintf("alloced at: %04p - %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", p,
42             p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]
43         );
44     }
45
46     i = get_tv();
47     gotoxy(30,0);
48     cputs("TV Mode: ");
49     switch(i) {
50         case TV_NTSC:
51             cputs("NTSC");
52             break;
53         case TV_PAL:
54             cputs("PAL");
55             break;
56         case TV_OTHER:
57             cputs("OTHER");
58             break;
59     }
60
61     for(;;) {
62         gotoxy(13,4);
63         cprintf("%02x", datavar);
64         gotoxy(13,5);
65         cprintf("%02x", stackvar);
66         ++datavar; ++stackvar;
67
68         gotoxy(0,8);
69         clk = clock();
70         cprintf("clock: %08lx", clk);
71
72         for (i = 0; i < 4; ++i)
73         {
74             gotoxy(0, 12 + i);
75             j = joy_read (i);
76             cprintf ("pad %d: %02x %-6s%-6s%-6s%-6s%-6s%-6s",
77                      i, j,
78                      (j & joy_masks[JOY_UP])?    "  up  " : " ---- ",
79                      (j & joy_masks[JOY_DOWN])?  " down " : " ---- ",
80                      (j & joy_masks[JOY_LEFT])?  " left " : " ---- ",
81                      (j & joy_masks[JOY_RIGHT])? "right " : " ---- ",
82                      (j & joy_masks[JOY_FIRE])?  " fire " : " ---- ",
83                      (j & joy_masks[JOY_FIRE2])? "fire2 " : " ---- ");
84         }
85         waitvblank();
86     }
87     for(;;);
88 }