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