mirror of
https://github.com/cc65/cc65.git
synced 2024-06-26 05:29:30 +00:00
atari5200: get rid of conio_colors table
use system color variables instead; improve testcode/lib/atari5200/hello.c test program
This commit is contained in:
parent
dfb7c0f24d
commit
d7eecb57f8
|
@ -2,7 +2,6 @@
|
||||||
; Christian Groessler, 05-Apr-2019
|
; Christian Groessler, 05-Apr-2019
|
||||||
;
|
;
|
||||||
|
|
||||||
.import conio_colors
|
|
||||||
.export _bgcolor
|
.export _bgcolor
|
||||||
|
|
||||||
.include "atari5200.inc"
|
.include "atari5200.inc"
|
||||||
|
@ -19,7 +18,7 @@ old_bg_color:
|
||||||
_bgcolor:
|
_bgcolor:
|
||||||
and #3
|
and #3
|
||||||
tax
|
tax
|
||||||
lda conio_colors,x
|
lda COLOR0,x
|
||||||
ldx old_bg_color
|
ldx old_bg_color
|
||||||
sta COLOR4 ; set new value
|
sta COLOR4 ; set new value
|
||||||
sta old_bg_color
|
sta old_bg_color
|
||||||
|
@ -30,7 +29,7 @@ _bgcolor:
|
||||||
.segment "ONCE"
|
.segment "ONCE"
|
||||||
|
|
||||||
init_old_bgcolor:
|
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
|
sta old_bg_color
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
SCREEN_BUF_SIZE = 20 * 24
|
SCREEN_BUF_SIZE = 20 * 24
|
||||||
SCREEN_BUF = $4000 - SCREEN_BUF_SIZE
|
SCREEN_BUF = $4000 - SCREEN_BUF_SIZE
|
||||||
|
|
||||||
.import conio_colors
|
|
||||||
.export screen_setup
|
.export screen_setup
|
||||||
.export screen_width, screen_height
|
.export screen_width, screen_height
|
||||||
.export conio_color
|
.export conio_color
|
||||||
|
@ -44,13 +43,13 @@ clrscr: sta (SAVMSC),y
|
||||||
|
|
||||||
; set default colors
|
; set default colors
|
||||||
|
|
||||||
lda conio_colors
|
lda #GTIA_COLOR_WHITE
|
||||||
sta COLOR0
|
sta COLOR0
|
||||||
lda conio_colors+1
|
lda #GTIA_COLOR_LIGHTRED
|
||||||
sta COLOR1
|
sta COLOR1
|
||||||
lda conio_colors+2
|
lda #GTIA_COLOR_LIGHTGREEN
|
||||||
sta COLOR2
|
sta COLOR2
|
||||||
lda conio_colors+3
|
lda #GTIA_COLOR_BLACK
|
||||||
sta COLOR3
|
sta COLOR3
|
||||||
sta COLOR4 ; background
|
sta COLOR4 ; background
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
SCREEN_BUF_SIZE = 20 * 12
|
SCREEN_BUF_SIZE = 20 * 12
|
||||||
SCREEN_BUF = $4000 - SCREEN_BUF_SIZE
|
SCREEN_BUF = $4000 - SCREEN_BUF_SIZE
|
||||||
|
|
||||||
.import conio_colors
|
|
||||||
.export screen_setup
|
.export screen_setup
|
||||||
.export screen_width, screen_height
|
.export screen_width, screen_height
|
||||||
.export conio_color
|
.export conio_color
|
||||||
|
@ -44,13 +43,13 @@ clrscr: sta (SAVMSC),y
|
||||||
|
|
||||||
; set default colors
|
; set default colors
|
||||||
|
|
||||||
lda conio_colors
|
lda #GTIA_COLOR_WHITE
|
||||||
sta COLOR0
|
sta COLOR0
|
||||||
lda conio_colors+1
|
lda #GTIA_COLOR_LIGHTRED
|
||||||
sta COLOR1
|
sta COLOR1
|
||||||
lda conio_colors+2
|
lda #GTIA_COLOR_LIGHTGREEN
|
||||||
sta COLOR2
|
sta COLOR2
|
||||||
lda conio_colors+3
|
lda #GTIA_COLOR_BLACK
|
||||||
sta COLOR3
|
sta COLOR3
|
||||||
sta COLOR4 ; background
|
sta COLOR4 ; background
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
static const char Text [] = "Hello world!";
|
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 XSize, YSize;
|
||||||
unsigned char PosY;
|
unsigned char PosY;
|
||||||
|
unsigned char i = 0;
|
||||||
|
|
||||||
/* Set screen colors */
|
/* Set screen colors */
|
||||||
(void) textcolor (COLOR_WHITE);
|
(void) textcolor (COLOR_WHITE);
|
||||||
|
@ -47,55 +49,61 @@ int main (void)
|
||||||
/* Ask for the screen size */
|
/* Ask for the screen size */
|
||||||
screensize (&XSize, &YSize);
|
screensize (&XSize, &YSize);
|
||||||
|
|
||||||
/* Draw a border around the screen */
|
/* Install joystick driver */
|
||||||
|
|
||||||
/* Top line */
|
|
||||||
cputc (CH_ULCORNER);
|
|
||||||
chline (XSize - 2);
|
|
||||||
cputc (CH_URCORNER);
|
|
||||||
|
|
||||||
/* Vertical line, left side */
|
|
||||||
cvlinexy (0, 1, YSize - 2);
|
|
||||||
|
|
||||||
/* Bottom line */
|
|
||||||
cputc (CH_LLCORNER);
|
|
||||||
chline (XSize - 2);
|
|
||||||
cputc (CH_LRCORNER);
|
|
||||||
|
|
||||||
/* Vertical line, right side */
|
|
||||||
cvlinexy (XSize - 1, 1, YSize - 2);
|
|
||||||
|
|
||||||
/* Write the greeting in the mid of the screen */
|
|
||||||
gotoxy ((XSize - strlen (Text)) / 2, YSize / 2);
|
|
||||||
cprintf ("%s", Text);
|
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) || defined(__ATARI5200__)
|
|
||||||
|
|
||||||
/* Wait for the user to press a button */
|
|
||||||
joy_install (joy_static_stddrv);
|
joy_install (joy_static_stddrv);
|
||||||
while (!joy_read (JOY_1)) ;
|
|
||||||
|
while (1) {
|
||||||
|
/* Draw a border around the screen */
|
||||||
|
|
||||||
|
/* Top line */
|
||||||
|
cputc (CH_ULCORNER);
|
||||||
|
chline (XSize - 2);
|
||||||
|
cputc (CH_URCORNER);
|
||||||
|
|
||||||
|
/* Vertical line, left side */
|
||||||
|
cvlinexy (0, 1, YSize - 2);
|
||||||
|
|
||||||
|
/* Bottom line */
|
||||||
|
cputc (CH_LLCORNER);
|
||||||
|
chline (XSize - 2);
|
||||||
|
cputc (CH_LRCORNER);
|
||||||
|
|
||||||
|
/* Vertical line, right side */
|
||||||
|
cvlinexy (XSize - 1, 1, YSize - 2);
|
||||||
|
|
||||||
|
/* Write the greeting in the mid of the screen */
|
||||||
|
gotoxy ((XSize - strlen (Text)) / 2, YSize / 2);
|
||||||
|
cprintf ("%s", Text);
|
||||||
|
|
||||||
|
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 and release a button */
|
||||||
|
while (!joy_read (JOY_1))
|
||||||
|
;
|
||||||
|
while (joy_read (JOY_1))
|
||||||
|
;
|
||||||
|
|
||||||
|
i = (i + 1) & 3;
|
||||||
|
|
||||||
|
/* Change colors */
|
||||||
|
textcolor (colors[i]);
|
||||||
|
bgcolor ((colors[i] + 3) & 3);
|
||||||
|
|
||||||
|
/* Clear the screen again */
|
||||||
|
clrscr ();
|
||||||
|
}
|
||||||
|
/* not reached */
|
||||||
|
|
||||||
joy_uninstall ();
|
joy_uninstall ();
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* Wait for the user to press a key */
|
|
||||||
cgetc ();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Clear the screen again */
|
|
||||||
clrscr ();
|
|
||||||
|
|
||||||
/* Done */
|
/* Done */
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user