]> git.sur5r.net Git - cc65/blob - testcode/lib/atari5200/hello.c
b2088461bc12b46557882d42aa9aadefdbe63150
[cc65] / testcode / lib / atari5200 / hello.c
1 /*
2 ** Fancy hello world program using cc65.
3 **
4 ** Ullrich von Bassewitz (ullrich@von-bassewitz.de)
5 **
6 ** TEST version for atari5200 conio, using all four colors
7 */
8
9
10
11 #include <stdlib.h>
12 #include <string.h>
13 #include <conio.h>
14 #include <joystick.h>
15
16
17
18 /*****************************************************************************/
19 /*                                   Data                                    */
20 /*****************************************************************************/
21
22
23
24 static const char Text [] = "Hello world!";
25
26
27
28 /*****************************************************************************/
29 /*                                   Code                                    */
30 /*****************************************************************************/
31
32
33
34 int main (void)
35 {
36     unsigned char XSize, YSize;
37     unsigned char PosY;
38
39     /* Set screen colors */
40     (void) textcolor (COLOR_WHITE);
41     (void) bordercolor (COLOR_BLACK);
42     (void) bgcolor (COLOR_BLACK);
43
44     /* Clear the screen, put cursor in upper left corner */
45     clrscr ();
46
47     /* Ask for the screen size */
48     screensize (&XSize, &YSize);
49
50     /* Draw a border around the screen */
51
52     /* Top line */
53     cputc (CH_ULCORNER);
54     chline (XSize - 2);
55     cputc (CH_URCORNER);
56
57     /* Vertical line, left side */
58     cvlinexy (0, 1, YSize - 2);
59
60     /* Bottom line */
61     cputc (CH_LLCORNER);
62     chline (XSize - 2);
63     cputc (CH_LRCORNER);
64
65     /* Vertical line, right side */
66     cvlinexy (XSize - 1, 1, YSize - 2);
67
68     /* Write the greeting in the mid of the screen */
69     gotoxy ((XSize - strlen (Text)) / 2, YSize / 2);
70     cprintf ("%s", Text);
71
72     PosY = wherey () + 1;
73     textcolor (0); /* switch to color #0 */
74     cputsxy(3, PosY++, "COLOR 0");
75     textcolor (1); /* switch to color #1 */
76     cputsxy(3, PosY++, "COLOR 1");
77     textcolor (2); /* switch to color #2 */
78     cputsxy(3, PosY++, "COLOR 2");
79     textcolor (3); /* switch to color #3 */
80     cputsxy(3, PosY, "COLOR 3");
81
82 #if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) || defined(__ATARI5200__)
83
84     /* Wait for the user to press a button */
85     joy_install (joy_static_stddrv);
86     while (!joy_read (JOY_1)) ;
87     joy_uninstall ();
88
89 #else
90
91     /* Wait for the user to press a key */
92     cgetc ();
93
94 #endif
95
96     /* Clear the screen again */
97     clrscr ();
98
99     /* Done */
100     return EXIT_SUCCESS;
101 }