From d7eecb57f8d2c9fadb41a3a55cb1ea5ebb7f1c34 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Tue, 9 Apr 2019 14:34:28 +0200 Subject: [PATCH] atari5200: get rid of conio_colors table use system color variables instead; improve testcode/lib/atari5200/hello.c test program --- libsrc/atari5200/bgcolor.s | 5 +- libsrc/atari5200/conioscreen.s | 9 ++- libsrc/atari5200/extra/conioscreen_20x12.s | 9 ++- testcode/lib/atari5200/hello.c | 80 ++++++++++++---------- 4 files changed, 54 insertions(+), 49 deletions(-) diff --git a/libsrc/atari5200/bgcolor.s b/libsrc/atari5200/bgcolor.s index bf10dff2c..127d26998 100644 --- a/libsrc/atari5200/bgcolor.s +++ b/libsrc/atari5200/bgcolor.s @@ -2,7 +2,6 @@ ; Christian Groessler, 05-Apr-2019 ; - .import conio_colors .export _bgcolor .include "atari5200.inc" @@ -19,7 +18,7 @@ old_bg_color: _bgcolor: and #3 tax - lda conio_colors,x + lda COLOR0,x ldx old_bg_color sta COLOR4 ; set new value sta old_bg_color @@ -30,7 +29,7 @@ _bgcolor: .segment "ONCE" init_old_bgcolor: - lda conio_colors+3 ; see also conioscreen.s for initialization + lda COLOR0+3 ; see also conioscreen.s for initialization sta old_bg_color rts diff --git a/libsrc/atari5200/conioscreen.s b/libsrc/atari5200/conioscreen.s index d1a709fc3..895e946ef 100644 --- a/libsrc/atari5200/conioscreen.s +++ b/libsrc/atari5200/conioscreen.s @@ -7,7 +7,6 @@ SCREEN_BUF_SIZE = 20 * 24 SCREEN_BUF = $4000 - SCREEN_BUF_SIZE - .import conio_colors .export screen_setup .export screen_width, screen_height .export conio_color @@ -44,13 +43,13 @@ clrscr: sta (SAVMSC),y ; set default colors - lda conio_colors + lda #GTIA_COLOR_WHITE sta COLOR0 - lda conio_colors+1 + lda #GTIA_COLOR_LIGHTRED sta COLOR1 - lda conio_colors+2 + lda #GTIA_COLOR_LIGHTGREEN sta COLOR2 - lda conio_colors+3 + lda #GTIA_COLOR_BLACK sta COLOR3 sta COLOR4 ; background diff --git a/libsrc/atari5200/extra/conioscreen_20x12.s b/libsrc/atari5200/extra/conioscreen_20x12.s index 20ab7ea2b..9cde9826d 100644 --- a/libsrc/atari5200/extra/conioscreen_20x12.s +++ b/libsrc/atari5200/extra/conioscreen_20x12.s @@ -7,7 +7,6 @@ SCREEN_BUF_SIZE = 20 * 12 SCREEN_BUF = $4000 - SCREEN_BUF_SIZE - .import conio_colors .export screen_setup .export screen_width, screen_height .export conio_color @@ -44,13 +43,13 @@ clrscr: sta (SAVMSC),y ; set default colors - lda conio_colors + lda #GTIA_COLOR_WHITE sta COLOR0 - lda conio_colors+1 + lda #GTIA_COLOR_LIGHTRED sta COLOR1 - lda conio_colors+2 + lda #GTIA_COLOR_LIGHTGREEN sta COLOR2 - lda conio_colors+3 + lda #GTIA_COLOR_BLACK sta COLOR3 sta COLOR4 ; background diff --git a/testcode/lib/atari5200/hello.c b/testcode/lib/atari5200/hello.c index 18daf0bdf..830d03a91 100644 --- a/testcode/lib/atari5200/hello.c +++ b/testcode/lib/atari5200/hello.c @@ -22,6 +22,7 @@ static const char Text [] = "Hello world!"; +static unsigned char colors[] = { COLOR_WHITE, COLOR_LIGHTGREEN, COLOR_LIGHTRED, COLOR_BLACK }; @@ -35,6 +36,7 @@ int main (void) { unsigned char XSize, YSize; unsigned char PosY; + unsigned char i = 0; /* Set screen colors */ (void) textcolor (COLOR_WHITE); @@ -47,54 +49,60 @@ int main (void) /* 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; -- 2.39.2