From: Bill Kendrick Date: Fri, 18 Jan 2019 06:44:25 +0000 (-0800) Subject: Atari colors into _gtia.h; NMIRES/NMIST as union X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=af8eb57f63f8306ea3c575c6671c933482582fef;p=cc65 Atari colors into _gtia.h; NMIRES/NMIST as union Use a C "union" to give both read (NMIST) and write (NMIRES) labels to their shared register in ANTIC. (h/t @groessler). Consolodate duplicated color definitions (HUE_..., COLOR_... and TGI_COLOR_...; and the "_gtia_mkcolor()" macro), found in both "atari.h" and "atari5200.h", moving it to "_gtia.h", which they both share (and which makes the most sense). --- diff --git a/include/_antic.h b/include/_antic.h index f9d880b0a..717f7f820 100644 --- a/include/_antic.h +++ b/include/_antic.h @@ -64,10 +64,15 @@ struct __antic { unsigned char penh; /* (R) light pen horizontal position */ unsigned char penv; /* (R) light pen vertical position */ unsigned char nmien; /* (W) non-maskable interrupt enable */ - unsigned char nmires; - /* (W) ("NMIRES") nmi reset -- clears the interrupt request register; resets all of the NMI status together - ** (R) ("NMIST") nmi status -- holds cause for the NMI interrupt - */ + union { + /* (W) ("NMIRES") nmi reset -- clears the interrupt request register; + ** resets all of the NMI status together + */ + unsigned char nmires; + + /* (R) ("NMIST") nmi status -- holds cause for the NMI interrupt */ + unsigned char nmist; + }; }; diff --git a/include/_gtia.h b/include/_gtia.h index 25181e875..ae3e69445 100644 --- a/include/_gtia.h +++ b/include/_gtia.h @@ -98,10 +98,77 @@ struct __gtia_write { #define PMG_SIZE_QUAD 0x2 /* four color clocks per pixel */ -/* COLPM0-COLPM3, COLPF0-COLPF3, COLBK color registers: -** See the "HUE_..." #defines in "atari.h" for the hue values; -** Bitwise OR (|) with 0x00 (darkest) through 0x0F (lightest) (only even values are unique) +/* COLPM0-COLPM3, COLPF0-COLPF3, COLBK color registers */ + +/*****************************************************************************/ +/* Color definitions */ +/*****************************************************************************/ + +/* Make a GTIA color value */ +#define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1)) + +/* Luminance values go from 0 (black) to 7 (white) */ + +/* Hue values */ +/* (These can vary depending on TV standard (NTSC vs PAL), +** tint potentiometer settings, TV tint settings, emulator palette, etc.) +*/ +#define HUE_GREY 0 +#define HUE_GOLD 1 +#define HUE_GOLDORANGE 2 +#define HUE_REDORANGE 3 +#define HUE_ORANGE 4 +#define HUE_MAGENTA 5 +#define HUE_PURPLE 6 +#define HUE_BLUE 7 +#define HUE_BLUE2 8 +#define HUE_CYAN 9 +#define HUE_BLUEGREEN 10 +#define HUE_BLUEGREEN2 11 +#define HUE_GREEN 12 +#define HUE_YELLOWGREEN 13 +#define HUE_YELLOW 14 +#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 /*****************************************************************************/ diff --git a/include/atari.h b/include/atari.h index ba2a43549..e06967ff9 100644 --- a/include/atari.h +++ b/include/atari.h @@ -91,77 +91,6 @@ #define CH_VLINE 0x7C -/*****************************************************************************/ -/* Color definitions */ -/*****************************************************************************/ - -/* Make a GTIA color value */ -#define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1)) - -/* Luminance values go from 0 (black) to 7 (white) */ - -/* Hue values */ -/* (These can vary depending on TV standard (NTSC vs PAL), -** tint potentiometer settings, TV tint settings, emulator palette, etc.) -*/ -#define HUE_GREY 0 -#define HUE_GOLD 1 -#define HUE_GOLDORANGE 2 -#define HUE_REDORANGE 3 -#define HUE_ORANGE 4 -#define HUE_MAGENTA 5 -#define HUE_PURPLE 6 -#define HUE_BLUE 7 -#define HUE_BLUE2 8 -#define HUE_CYAN 9 -#define HUE_BLUEGREEN 10 -#define HUE_BLUEGREEN2 11 -#define HUE_GREEN 12 -#define HUE_YELLOWGREEN 13 -#define HUE_YELLOW 14 -#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 - - /*****************************************************************************/ /* Masks for joy_read */ /*****************************************************************************/ diff --git a/include/atari5200.h b/include/atari5200.h index 12c2bb349..67c11c1df 100644 --- a/include/atari5200.h +++ b/include/atari5200.h @@ -46,47 +46,6 @@ /* the addresses of the static drivers */ extern void atr5200std_joy[]; /* referred to by joy_static_stddrv[] */ -/* make GTIA color value */ -#define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1)) - -/* luminance values go from 0 (black) to 7 (white) */ - -/* hue values */ -#define HUE_GREY 0 -#define HUE_GOLD 1 -#define HUE_GOLDORANGE 2 -#define HUE_REDORANGE 3 -#define HUE_ORANGE 4 -#define HUE_MAGENTA 5 -#define HUE_PURPLE 6 -#define HUE_BLUE 7 -#define HUE_BLUE2 8 -#define HUE_CYAN 9 -#define HUE_BLUEGREEN 10 -#define HUE_BLUEGREEN2 11 -#define HUE_GREEN 12 -#define HUE_YELLOWGREEN 13 -#define HUE_YELLOW 14 -#define HUE_YELLOWRED 15 - -/* Color defines, similar to c64 colors (untested) */ -#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) - /* Masks for joy_read */ #define JOY_UP_MASK 0x01 #define JOY_DOWN_MASK 0x02