]> git.sur5r.net Git - cc65/blobdiff - include/_gtia.h
Code review changes and improved formatting.
[cc65] / include / _gtia.h
index 25d26093c27850d77c6e78f319d5fdbdf189879a..ae3e6944561dd1b9534366a241765182c3789780 100644 (file)
@@ -13,7 +13,7 @@
 /*                                                                           */
 /*                                                                           */
 /* (C) 2000 Freddy Offenga <taf_offenga@yahoo.com>                           */
-/* 2019-01-14: Bill Kendrick <nbs@sonic.net>: More defines for registers     */
+/* 2019-01-16: Bill Kendrick <nbs@sonic.net>: More defines for registers     */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 #ifndef __GTIA_H
 #define __GTIA_H
 
-/* Define a structure with the GTIA register offsets for write (W) */
+/*****************************************************************************/
+/* Define a structure with the GTIA register offsets for write (W)           */
+/*****************************************************************************/
+
 struct __gtia_write {
     unsigned char   hposp0; /* 0x00: horizontal position of player 0 */
     unsigned char   hposp1; /* 0x01: horizontal position of player 1 */
@@ -86,18 +89,91 @@ struct __gtia_write {
 };
 
 
-/* Values for SIZEP0-SIZEP3 and SIZEM registers: */
+/*****************************************************************************/
+/* (W) Values for SIZEP0-SIZEP3 and SIZEM registers:                         */
+/*****************************************************************************/
+
 #define PMG_SIZE_NORMAL 0x0 /* one color clock per pixel */
 #define PMG_SIZE_DOUBLE 0x1 /* two color clocks per pixel */
 #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
+
 
-/* PRIOR register values */
+/*****************************************************************************/
+/* (W) PRIOR register values                                                 */
+/*****************************************************************************/
 
 #define PRIOR_P03_PF03          0x01 /* Players 0-3, then Playfields 0-3, then background */
 #define PRIOR_P01_PF03_P23      0x02 /* Players 0-1, then Playfields 0-3, then Players 2-3, then background */
@@ -106,35 +182,41 @@ struct __gtia_write {
 
 #define PRIOR_5TH_PLAYER        0x10 /* Four missiles combine to be a 5th player (uses COLPF3) */
 
-#define PRIOR_OVERLAP_3RD_COLOR 0x20 /* Overlap of players result in a 3rd color */
-/* Overlap of players 0 & 1 and of players 2 & 3 results in a third color,
-** the logical OR of the two players' colors;
-** Other overlaps (e.g., players 0 and 2) result in black (0x00).
+/* Causes overlap of players 0 & 1 and of players 2 & 3 to result in a third color,
+** the logical OR of the two players' colors, and other overlaps (e.g., players 0 and 2)
+** to result in black (0x00).
 */
+#define PRIOR_OVERLAP_3RD_COLOR 0x20
+
+
+/*****************************************************************************/
+/* (W) GTIA special graphics mode options for GPRIOR                         */
+/*****************************************************************************/
 
-/* GTIA special graphics mode options */
 /* Pixels are 2 color clocks wide, and one scanline tall
 ** (so 80x192 in normal playfield width).
 ** May be used with both bitmap and character modelines.
 */
 
-#define PRIOR_GFX_MODE_9        0x40
 /* 16 shade shades of the background (COLBK) hue;
 ** Note: brightnesses other than 0 (darkest) in COLBK cause additional effects
 */
+#define PRIOR_GFX_MODE_9        0x40
 
-#define PRIOR_GFX_MODE_10       0x80
 /* 9 color palette mode;
 ** COLPM0 (acts as background) thru COLPM3, followed by COLPF0 thru COLPF3, and COLBK
 */
+#define PRIOR_GFX_MODE_10       0x80
 
-#define PRIOR_GFX_MODE_11       0xC0
 /* 16 hues of the background (COLBK) brightness;
 ** Note: hues other than 0 (greys) in COLBK caus additional effects
 */
+#define PRIOR_GFX_MODE_11       0xC0
 
 
-/* VDELAY register values */
+/*****************************************************************************/
+/* (W) VDELAY register values                                                */
+/*****************************************************************************/
 
 #define VDELAY_MISSILE0 0x01
 #define VDELAY_MISSILE1 0x02
@@ -146,18 +228,23 @@ struct __gtia_write {
 #define VDELAY_PLAYER3  0x80
 
 
-/* GRACTL register values */
+/*****************************************************************************/
+/* (W) GRACTL register values                                                */
+/*****************************************************************************/
 
 #define GRACTL_MISSLES              0x01 /* enable missiles */
 #define GRACTL_PLAYERS              0x02 /* enable players */
 
-#define GRACTL_LATCH_TRIGGER_INPUTS 0x04
 /* "Latch" triggers; once pressed, will give a continuous
 ** pressed input until this bit is cleared
 */
+#define GRACTL_LATCH_TRIGGER_INPUTS 0x04
 
 
-/* Define a structure with the GTIA register offsets for read (R) */
+/*****************************************************************************/
+/* Define a structure with the GTIA register offsets for read (R)            */
+/*****************************************************************************/
+
 struct __gtia_read {
     unsigned char   m0pf;       /* 0x00: missile 0 to playfield collision */
     unsigned char   m1pf;       /* 0x01: missile 1 to playfield collision */
@@ -189,15 +276,22 @@ struct __gtia_read {
 };
 
 
-/* PAL register possible values */
+/*****************************************************************************/
+/* (R) PAL register possible values                                          */
+/*****************************************************************************/
+
+/* Note: This only tells you whether the GTIA is PAL or NTSC; some NTSC
+** systems are modded with PAL ANTIC chips; testing VCOUNT limits can be
+** done to check for that.  Seems like it's not possible to test for SECAM
+*/
 
 #define TV_STD_PAL  0x1
 #define TV_STD_NTSC 0xE
-/* Note: This only tells you whether the GTIA is PAL or NTSC; some NTSC systems are modded with PAL ANTIC chips; testing VCOUNT limits can be done to check for that */
-/* Note: Seems like it's not possible to test for SECAM */
 
 
-/* Reading console keys (Start, Select, Option) via CONSOL register: */
+/*****************************************************************************/
+/* Macros for reading console keys (Start/Select/Option) via CONSOL register */
+/*****************************************************************************/
 
 #define CONSOL_START(x)     !((unsigned char)((x) & 1)) /* true if Start pressed */
 #define CONSOL_SELECT(x)    !((unsigned char)((x) & 2)) /* true if Select pressed */