atari5200: conio now uses just four colors altogether

See discussion in PR #870.
This commit is contained in:
Christian Groessler 2019-04-05 01:26:34 +02:00 committed by Oliver Schmidt
parent 79b9a8d2df
commit be6bba66a9
11 changed files with 173 additions and 59 deletions

View File

@ -111,6 +111,14 @@ ANTIC = $D400 ; ANTIC area
POKEY = $E800 ; POKEY area
.include "atari_pokey.inc"
;-------------------------------------------------------------------------
; conio color defines
;-------------------------------------------------------------------------
COLOR_WHITE = 0
COLOR_RED = 1
COLOR_GREEN = 2
COLOR_BLACK = 3
;-------------------------------------------------------------------------
; Cartridge Parameters

View File

@ -79,3 +79,41 @@ VDELAY = GTIA + $1C ;vertical delay
GRACTL = GTIA + $1D ;graphic control
HITCLR = GTIA + $1E ;collision clear
; Hue values
HUE_GREY = 0
HUE_GOLD = 1
HUE_GOLDORANGE = 2
HUE_REDORANGE = 3
HUE_ORANGE = 4
HUE_MAGENTA = 5
HUE_PURPLE = 6
HUE_BLUE = 7
HUE_BLUE2 = 8
HUE_CYAN = 9
HUE_BLUEGREEN = 10
HUE_BLUEGREEN2 = 11
HUE_GREEN = 12
HUE_YELLOWGREEN = 13
HUE_YELLOW = 14
HUE_YELLOWRED = 15
; Color defines, similar to c64 colors (untested)
GTIA_COLOR_BLACK = (HUE_GREY << 4)
GTIA_COLOR_WHITE = (HUE_GREY << 4 | 7 << 1)
GTIA_COLOR_RED = (HUE_REDORANGE << 4 | 1 << 1)
GTIA_COLOR_CYAN = (HUE_CYAN << 4 | 3 << 1)
GTIA_COLOR_VIOLET = (HUE_PURPLE << 4 | 4 << 1)
GTIA_COLOR_GREEN = (HUE_GREEN << 4 | 2 << 1)
GTIA_COLOR_BLUE = (HUE_BLUE << 4 | 2 << 1)
GTIA_COLOR_YELLOW = (HUE_YELLOW << 4 | 7 << 1)
GTIA_COLOR_ORANGE = (HUE_ORANGE << 4 | 5 << 1)
GTIA_COLOR_BROWN = (HUE_YELLOW << 4 | 2 << 1)
GTIA_COLOR_LIGHTRED = (HUE_REDORANGE << 4 | 6 << 1)
GTIA_COLOR_GRAY1 = (HUE_GREY << 4 | 2 << 1)
GTIA_COLOR_GRAY2 = (HUE_GREY << 4 | 3 << 1)
GTIA_COLOR_LIGHTGREEN = (HUE_GREEN << 4 | 6 << 1)
GTIA_COLOR_LIGHTBLUE = (HUE_BLUE << 4 | 6 << 1)
GTIA_COLOR_GRAY3 = (HUE_GREY << 4 | 5 << 1)

View File

@ -131,44 +131,23 @@ struct __gtia_write {
#define HUE_YELLOWRED 15
/* Color defines, similar to c64 colors (untested) */
/* Note that the conio color implementation is monochrome
** (bgcolor and textcolor are only placeholders)
*/
/* Use the defines with the setcolor() or _atari_xxxcolor() functions */
#define COLOR_BLACK _gtia_mkcolor(HUE_GREY,0)
#define COLOR_WHITE _gtia_mkcolor(HUE_GREY,7)
#define COLOR_RED _gtia_mkcolor(HUE_REDORANGE,1)
#define COLOR_CYAN _gtia_mkcolor(HUE_CYAN,3)
#define COLOR_VIOLET _gtia_mkcolor(HUE_PURPLE,4)
#define COLOR_GREEN _gtia_mkcolor(HUE_GREEN,2)
#define COLOR_BLUE _gtia_mkcolor(HUE_BLUE,2)
#define COLOR_YELLOW _gtia_mkcolor(HUE_YELLOW,7)
#define COLOR_ORANGE _gtia_mkcolor(HUE_ORANGE,5)
#define COLOR_BROWN _gtia_mkcolor(HUE_YELLOW,2)
#define COLOR_LIGHTRED _gtia_mkcolor(HUE_REDORANGE,6)
#define COLOR_GRAY1 _gtia_mkcolor(HUE_GREY,2)
#define COLOR_GRAY2 _gtia_mkcolor(HUE_GREY,3)
#define COLOR_LIGHTGREEN _gtia_mkcolor(HUE_GREEN,6)
#define COLOR_LIGHTBLUE _gtia_mkcolor(HUE_BLUE,6)
#define COLOR_GRAY3 _gtia_mkcolor(HUE_GREY,5)
/* TGI color defines */
#define TGI_COLOR_BLACK COLOR_BLACK
#define TGI_COLOR_WHITE COLOR_WHITE
#define TGI_COLOR_RED COLOR_RED
#define TGI_COLOR_CYAN COLOR_CYAN
#define TGI_COLOR_VIOLET COLOR_VIOLET
#define TGI_COLOR_GREEN COLOR_GREEN
#define TGI_COLOR_BLUE COLOR_BLUE
#define TGI_COLOR_YELLOW COLOR_YELLOW
#define TGI_COLOR_ORANGE COLOR_ORANGE
#define TGI_COLOR_BROWN COLOR_BROWN
#define TGI_COLOR_LIGHTRED COLOR_LIGHTRED
#define TGI_COLOR_GRAY1 COLOR_GRAY1
#define TGI_COLOR_GRAY2 COLOR_GRAY2
#define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN
#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
#define TGI_COLOR_GRAY3 COLOR_GRAY3
/* Hardware palette values (for GTIA colxxx registers) */
#define GTIA_COLOR_BLACK _gtia_mkcolor(HUE_GREY,0)
#define GTIA_COLOR_WHITE _gtia_mkcolor(HUE_GREY,7)
#define GTIA_COLOR_RED _gtia_mkcolor(HUE_REDORANGE,1)
#define GTIA_COLOR_CYAN _gtia_mkcolor(HUE_CYAN,3)
#define GTIA_COLOR_VIOLET _gtia_mkcolor(HUE_PURPLE,4)
#define GTIA_COLOR_GREEN _gtia_mkcolor(HUE_GREEN,2)
#define GTIA_COLOR_BLUE _gtia_mkcolor(HUE_BLUE,2)
#define GTIA_COLOR_YELLOW _gtia_mkcolor(HUE_YELLOW,7)
#define GTIA_COLOR_ORANGE _gtia_mkcolor(HUE_ORANGE,5)
#define GTIA_COLOR_BROWN _gtia_mkcolor(HUE_YELLOW,2)
#define GTIA_COLOR_LIGHTRED _gtia_mkcolor(HUE_REDORANGE,6)
#define GTIA_COLOR_GRAY1 _gtia_mkcolor(HUE_GREY,2)
#define GTIA_COLOR_GRAY2 _gtia_mkcolor(HUE_GREY,3)
#define GTIA_COLOR_LIGHTGREEN _gtia_mkcolor(HUE_GREEN,6)
#define GTIA_COLOR_LIGHTBLUE _gtia_mkcolor(HUE_BLUE,6)
#define GTIA_COLOR_GRAY3 _gtia_mkcolor(HUE_GREY,5)
/*****************************************************************************/

View File

@ -377,6 +377,51 @@ extern void atrx15p2_tgi[];
#define ANTIC (*(struct __antic*)0xD400)
/*****************************************************************************/
/* conio and TGI color defines */
/*****************************************************************************/
/* Note that the conio color implementation is monochrome
** (textcolor just sets text brightness low or high, depending on background
** color)
** These values can be used with bordercolor(), bgcolor(), and _setcolor_low()
*/
#define COLOR_BLACK GTIA_COLOR_BLACK
#define COLOR_WHITE GTIA_COLOR_WHITE
#define COLOR_RED GTIA_COLOR_RED
#define COLOR_CYAN GTIA_COLOR_CYAN
#define COLOR_VIOLET GTIA_COLOR_VIOLET
#define COLOR_GREEN GTIA_COLOR_GREEN
#define COLOR_BLUE GTIA_COLOR_BLUE
#define COLOR_YELLOW GTIA_COLOR_YELLOW
#define COLOR_ORANGE GTIA_COLOR_ORANGE
#define COLOR_BROWN GTIA_COLOR_BROWN
#define COLOR_LIGHTRED GTIA_COLOR_LIGHTRED
#define COLOR_GRAY1 GTIA_COLOR_GRAY1
#define COLOR_GRAY2 GTIA_COLOR_GRAY2
#define COLOR_LIGHTGREEN GTIA_COLOR_LIGHTGREEN
#define COLOR_LIGHTBLUE GTIA_COLOR_LIGHTBLUE
#define COLOR_GRAY3 GTIA_COLOR_GRAY3
/* TGI color defines */
#define TGI_COLOR_BLACK COLOR_BLACK
#define TGI_COLOR_WHITE COLOR_WHITE
#define TGI_COLOR_RED COLOR_RED
#define TGI_COLOR_CYAN COLOR_CYAN
#define TGI_COLOR_VIOLET COLOR_VIOLET
#define TGI_COLOR_GREEN COLOR_GREEN
#define TGI_COLOR_BLUE COLOR_BLUE
#define TGI_COLOR_YELLOW COLOR_YELLOW
#define TGI_COLOR_ORANGE COLOR_ORANGE
#define TGI_COLOR_BROWN COLOR_BROWN
#define TGI_COLOR_LIGHTRED COLOR_LIGHTRED
#define TGI_COLOR_GRAY1 COLOR_GRAY1
#define TGI_COLOR_GRAY2 COLOR_GRAY2
#define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN
#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
#define TGI_COLOR_GRAY3 COLOR_GRAY3
/*****************************************************************************/
/* PIA PORTA and PORTB register bits */
/*****************************************************************************/

View File

@ -77,6 +77,12 @@ extern void atr5200std_joy[]; /* referred to by joy_static_stddrv[] */
#include <_antic.h>
#define ANTIC (*(struct __antic*)0xD400)
/* conio color defines */
#define COLOR_WHITE 0x00
#define COLOR_RED 0x01
#define COLOR_GREEN 0x02
#define COLOR_BLACK 0x03
/* The following #define will cause the matching function calls in conio.h
** to be overlaid by macros with the same names, saving the function call
** overhead.

View File

@ -1 +1,37 @@
.include "../atari/bgcolor.s"
;
; Christian Groessler, 05-Apr-2019
;
.import conio_colors
.export _bgcolor
.include "atari5200.inc"
.constructor init_old_bgcolor
.bss
old_bg_color:
.res 1
.code
_bgcolor:
and #3
tax
lda conio_colors,x
ldx old_bg_color
sta COLOR4 ; set new value
sta old_bg_color
txa
ldx #0 ; fix X
rts
.segment "ONCE"
init_old_bgcolor:
lda conio_colors+3 ; see also conioscreen.s for initialization
sta old_bg_color
rts
.end

View File

@ -7,6 +7,7 @@
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
@ -43,16 +44,15 @@ clrscr: sta (SAVMSC),y
; set default colors
lda #40
lda conio_colors
sta COLOR0
lda #202
lda conio_colors+1
sta COLOR1
lda #148
lda conio_colors+2
sta COLOR2
lda #70
lda conio_colors+3
sta COLOR3
lda #0
sta COLOR4
sta COLOR4 ; background
; set display list

View File

@ -82,8 +82,8 @@ putchar:
sta ptr4+1
pla ; get char again
; and #$C0 ; without this we are compatible with the old version. user must not try to output a char >= $3F
ora conio_color
and #$3F ; clear palette index bits
ora conio_color ; use currently selected palette
ldy COLCRS_5200
sta (ptr4),y

View File

@ -7,6 +7,7 @@
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
@ -43,16 +44,15 @@ clrscr: sta (SAVMSC),y
; set default colors
lda #40
lda conio_colors
sta COLOR0
lda #202
lda conio_colors+1
sta COLOR1
lda #148
lda conio_colors+2
sta COLOR2
lda #70
lda conio_colors+3
sta COLOR3
lda #0
sta COLOR4
sta COLOR4 ; background
; set display list

View File

@ -2,6 +2,8 @@
; Christian Groessler, 02-Apr-2019
;
; unsigned char __fastcall__ textcolor (unsigned char color);
;
; "color" value is a palette index (0..3) or COLOR_xxx value (0..3)
.export _textcolor
.import conio_color

View File

@ -69,15 +69,15 @@ int main (void)
gotoxy ((XSize - strlen (Text)) / 2, YSize / 2);
cprintf ("%s", Text);
PosY = wherey () + 1;
PosY = wherey ();
textcolor (0); /* switch to color #0 */
cputsxy(3, PosY++, "COLOR 0");
cputsxy(3, ++PosY, "COLOR 0");
textcolor (1); /* switch to color #1 */
cputsxy(3, PosY++, "COLOR 1");
cputsxy(3, ++PosY, "COLOR 1");
textcolor (2); /* switch to color #2 */
cputsxy(3, PosY++, "COLOR 2");
textcolor (3); /* switch to color #3 */
cputsxy(3, PosY, "COLOR 3");
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__)