]> git.sur5r.net Git - cc65/blob - include/_gtia.h
Some PIA register #defines
[cc65] / include / _gtia.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 _gtia.h                                   */
4 /*                                                                           */
5 /*                  Internal include file, do not use directly               */
6 /*                                                                           */
7 /* "GTIA, Graphic Television Interface Adaptor, is a custom chip used in the */
8 /* Atari 8-bit family of computers and in the Atari 5200 console. In these   */
9 /* systems, GTIA chip works together with ANTIC to produce video display.    */
10 /* ANTIC generates the playfield graphics (text and bitmap) while GTIA       */
11 /* provides the color for the playfield and adds overlay objects known as    */
12 /* player/missile graphics (sprites)" - Wikipedia article on "GTIA"          */
13 /*                                                                           */
14 /*                                                                           */
15 /* (C) 2000 Freddy Offenga <taf_offenga@yahoo.com>                           */
16 /* 2019-01-12: Bill Kendrick <nbs@sonic.net>: More defines for registers     */
17 /*                                                                           */
18 /*                                                                           */
19 /* This software is provided 'as-is', without any expressed or implied       */
20 /* warranty.  In no event will the authors be held liable for any damages    */
21 /* arising from the use of this software.                                    */
22 /*                                                                           */
23 /* Permission is granted to anyone to use this software for any purpose,     */
24 /* including commercial applications, and to alter it and redistribute it    */
25 /* freely, subject to the following restrictions:                            */
26 /*                                                                           */
27 /* 1. The origin of this software must not be misrepresented; you must not   */
28 /*    claim that you wrote the original software. If you use this software   */
29 /*    in a product, an acknowledgment in the product documentation would be  */
30 /*    appreciated but is not required.                                       */
31 /* 2. Altered source versions must be plainly marked as such, and must not   */
32 /*    be misrepresented as being the original software.                      */
33 /* 3. This notice may not be removed or altered from any source              */
34 /*    distribution.                                                          */
35 /*                                                                           */
36 /*****************************************************************************/
37
38
39 #ifndef __GTIA_H
40 #define __GTIA_H
41
42 /* Define a structure with the GTIA register offsets for write (W) */
43 struct __gtia_write {
44     unsigned char   hposp0; /* 0x00: horizontal position of player 0 */
45     unsigned char   hposp1; /* 0x01: horizontal position of player 1 */
46     unsigned char   hposp2; /* 0x02: horizontal position of player 2 */
47     unsigned char   hposp3; /* 0x03: horizontal position of player 3 */
48     unsigned char   hposm0; /* 0x04: horizontal position of missile 0 */
49     unsigned char   hposm1; /* 0x05: horizontal position of missile 1 */
50     unsigned char   hposm2; /* 0x06: horizontal position of missile 2 */
51     unsigned char   hposm3; /* 0x07: horizontal position of missile 3 */
52
53     unsigned char   sizep0; /* 0x08: size of player 0 */
54     unsigned char   sizep1; /* 0x09: size of player 1 */
55     unsigned char   sizep2; /* 0x0A: size of player 2 */
56     unsigned char   sizep3; /* 0x0B: size of player 3 */
57     unsigned char   sizem;  /* 0x0C: size of missiles */
58
59 #define PMG_SIZE_NORMAL 0x0
60 #define PMG_SIZE_DOUBLE 0x1
61 #define PMG_SIZE_QUAD   0x2
62
63     unsigned char   grafp0; /* 0x0D: graphics shape player 0 (used when ANTIC is not instructed to use DMA; see DMACTL) */
64     unsigned char   grafp1; /* 0x0E: graphics shape player 1 */
65     unsigned char   grafp2; /* 0x0F: graphics shape player 2 */
66     unsigned char   grafp3; /* 0x10: graphics shape player 3 */
67     unsigned char   grafm;  /* 0x11: graphics shape missiles */
68
69     unsigned char   colpm0; /* 0x12: color player and missile 0 */
70     unsigned char   colpm1; /* 0x13: color player and missile 1 */
71     unsigned char   colpm2; /* 0x14: color player and missile 2 */
72     unsigned char   colpm3; /* 0x15: color player and missile 3 */
73     unsigned char   colpf0; /* 0x16: color playfield 0 */
74     unsigned char   colpf1; /* 0x17: color playfield 1 */
75     unsigned char   colpf2; /* 0x18: color playfield 2 */
76     unsigned char   colpf3; /* 0x19: color playfield 3 */
77     unsigned char   colbk;  /* 0x1A: color background */
78
79 /* See the "HUE_..." #defines in "atari.h" for the hue values to use with color registers, above */
80 /* Bitwise OR (|) with 0x00 (darkest) through 0x0F (lightest) (only even values are unique) */
81
82     unsigned char   prior;  /* 0x1B: priority selection */
83
84 #define PRIOR_P03_PF03          0x01 /* Players 0-3, then Playfields 0-3, then background */
85 #define PRIOR_P01_PF03_P23      0x02 /* Players 0-1, then Playfields 0-3, then Players 2-3, then background */
86 #define PRIOR_PF03_P03          0x04 /* Playfields 0-3, then Players 0-3, then background */
87 #define PRIOR_PF01_P03_PF23     0x08 /* Playfields 0-1, then Players 0-3, then Playfields 2-3, then background */
88
89 #define PRIOR_5TH_PLAYER        0x10 /* Four missiles combine to be a 5th player (uses COLPF3) */
90 #define PRIOR_OVERLAP_3RD_COLOR 0x20 /* Overlap of players 0 and 1, and of players 2 and 3, results in a third color
91                                         (else overlap is black). The resulting color is a logical OR of the two player colors. */
92
93 #define PRIOR_GFX_MODE_9        0x40 /* 80x192 16 shade mode (shades of the background (COLBK) hue; brightness in COLBK cause additional effects) */
94 #define PRIOR_GFX_MODE_10       0x80 /* 80x192 9 color mode (COLPM0 (acts as background) thru COLPM3, followed by COLPF0 thru COLPF4) */
95 #define PRIOR_GFX_MODE_11       0xC0 /* 80x192 16 hue mode (hues of the background (COLBK) brightness) */
96
97     unsigned char   vdelay; /* 0x1C: vertical delay (for one-line resolution movement of vertical position of an object when two line resolution display is enabled */
98
99 #define VDELAY_MISSILE0 0x01
100 #define VDELAY_MISSILE1 0x02
101 #define VDELAY_MISSILE2 0x04
102 #define VDELAY_MISSILE3 0x08
103 #define VDELAY_PLAYER0  0x10
104 #define VDELAY_PLAYER1  0x20
105 #define VDELAY_PLAYER2  0x40
106 #define VDELAY_PLAYER3  0x80
107
108     unsigned char   gractl; /* 0x1D: stick/paddle latch, p/m control */
109
110 #define GRACTL_MISSLES              0x01 /* enable missiles */
111 #define GRACTL_PLAYERS              0x02 /* enable players */
112 #define GRACTL_LATCH_TRIGGER_INPUTS 0x04 /* "latch" triggers; once pressed, will give a continuous pressed input until this bit is cleared */
113
114     unsigned char   hitclr; /* 0x1E: clear p/m collision */
115     unsigned char   consol; /* 0x1F: builtin speaker */
116 };
117
118 /* Define a structure with the GTIA register offsets for read (R) */
119 struct __gtia_read {
120     unsigned char   m0pf;       /* 0x00: missile 0 to playfield collision */
121     unsigned char   m1pf;       /* 0x01: missile 1 to playfield collision */
122     unsigned char   m2pf;       /* 0x02: missile 2 to playfield collision */
123     unsigned char   m3pf;       /* 0x03: missile 3 to playfield collision */
124     unsigned char   p0pf;       /* 0x04: player 0 to playfield collision */
125     unsigned char   p1pf;       /* 0x05: player 1 to playfield collision */
126     unsigned char   p2pf;       /* 0x06: player 2 to playfield collision */
127     unsigned char   p3pf;       /* 0x07: player 3 to playfield collision */
128     unsigned char   m0pl;       /* 0x08: missile 0 to player collision */
129     unsigned char   m1pl;       /* 0x09: missile 1 to player collision */
130     unsigned char   m2pl;       /* 0x0A: missile 2 to player collision */
131     unsigned char   m3pl;       /* 0x0B: missile 3 to player collision */
132     unsigned char   p0pl;       /* 0x0C: player 0 to player collision */
133     unsigned char   p1pl;       /* 0x0D: player 1 to player collision */
134     unsigned char   p2pl;       /* 0x0E: player 2 to player collision */
135     unsigned char   p3pl;       /* 0x0F: player 3 to player collision */
136
137     unsigned char   trig0;      /* 0x10: joystick trigger 0 (0=pressed, 1=released) */
138     unsigned char   trig1;      /* 0x11: joystick trigger 1 */
139     unsigned char   trig2;      /* 0x12: joystick trigger 2 */
140     unsigned char   trig3;      /* 0x13: joystick trigger 3 */
141
142     unsigned char   pal;        /* 0x14: pal/ntsc flag */
143
144 #define TV_STD_PAL  0x1
145 #define TV_STD_NTSC 0xE
146 /* 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 */
147 /* Note: Seems like it's not possible to test for SECAM */
148
149     unsigned char   unused[10];
150
151     unsigned char   consol;     /* 0x1F: console buttons */
152
153 #define CONSOL_START(x)     !((unsigned char)((x) & 1)) /* true if Start pressed */
154 #define CONSOL_SELECT(x)    !((unsigned char)((x) & 2)) /* true if Select pressed */
155 #define CONSOL_OPTION(x)    !((unsigned char)((x) & 4)) /* true if Option pressed */
156
157 };
158
159 /* End of _gtia.h */
160 #endif /* #ifndef __GTIA_H */