static const char Text [] = "Hello world!";
+static unsigned char colors[] = { COLOR_WHITE, COLOR_LIGHTGREEN, COLOR_LIGHTRED, COLOR_BLACK };
{
unsigned char XSize, YSize;
unsigned char PosY;
+ unsigned char i = 0;
/* Set screen colors */
(void) textcolor (COLOR_WHITE);
/* Ask for the screen size */
screensize (&XSize, &YSize);
- /* Draw a border around the screen */
+ /* Install joystick driver */
+ joy_install (joy_static_stddrv);
- /* Top line */
- cputc (CH_ULCORNER);
- chline (XSize - 2);
- cputc (CH_URCORNER);
+ while (1) {
+ /* Draw a border around the screen */
- /* Vertical line, left side */
- cvlinexy (0, 1, YSize - 2);
+ /* Top line */
+ cputc (CH_ULCORNER);
+ chline (XSize - 2);
+ cputc (CH_URCORNER);
- /* Bottom line */
- cputc (CH_LLCORNER);
- chline (XSize - 2);
- cputc (CH_LRCORNER);
+ /* Vertical line, left side */
+ cvlinexy (0, 1, YSize - 2);
- /* Vertical line, right side */
- cvlinexy (XSize - 1, 1, YSize - 2);
+ /* Bottom line */
+ cputc (CH_LLCORNER);
+ chline (XSize - 2);
+ cputc (CH_LRCORNER);
- /* Write the greeting in the mid of the screen */
- gotoxy ((XSize - strlen (Text)) / 2, YSize / 2);
- cprintf ("%s", Text);
+ /* Vertical line, right side */
+ cvlinexy (XSize - 1, 1, YSize - 2);
- PosY = wherey ();
- textcolor (0); /* switch to color #0 */
- cputsxy(3, ++PosY, "COLOR 0");
- textcolor (1); /* switch to color #1 */
- cputsxy(3, ++PosY, "COLOR 1");
- textcolor (2); /* switch to color #2 */
- cputsxy(3, ++PosY, "COLOR 2");
- textcolor (3); /* switch to color #3 */ /* color #3 is the background color. So written text isn't visible. */
- cputsxy(3, ++PosY, "COLOR 3");
+ /* Write the greeting in the mid of the screen */
+ gotoxy ((XSize - strlen (Text)) / 2, YSize / 2);
+ cprintf ("%s", Text);
-#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) || defined(__ATARI5200__)
+ PosY = wherey ();
+ textcolor (colors[i]); /* switch to color #0 */
+ cputsxy(3, ++PosY, "COLOR 0");
+ textcolor ((colors[i] + 1) & 3); /* switch to color #1 */
+ cputsxy(3, ++PosY, "COLOR 1");
+ textcolor ((colors[i] + 2) & 3); /* switch to color #2 */
+ cputsxy(3, ++PosY, "COLOR 2");
+ textcolor ((colors[i] + 3) & 3); /* switch to color #3 */ /* color #3 is the background color. So written text isn't visible. */
+ cputsxy(3, ++PosY, "COLOR 3");
- /* Wait for the user to press a button */
- joy_install (joy_static_stddrv);
- while (!joy_read (JOY_1)) ;
- joy_uninstall ();
+ /* Wait for the user to press and release a button */
+ while (!joy_read (JOY_1))
+ ;
+ while (joy_read (JOY_1))
+ ;
-#else
+ i = (i + 1) & 3;
- /* Wait for the user to press a key */
- cgetc ();
+ /* Change colors */
+ textcolor (colors[i]);
+ bgcolor ((colors[i] + 3) & 3);
-#endif
+ /* Clear the screen again */
+ clrscr ();
+ }
+ /* not reached */
- /* Clear the screen again */
- clrscr ();
+ joy_uninstall ();
/* Done */
return EXIT_SUCCESS;