]> git.sur5r.net Git - cc65/blob - include/_antic.h
Added missing pointer star for Basic structure.
[cc65] / include / _antic.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                _antic.h                                   */
4 /*                                                                           */
5 /*                  Internal include file, do not use directly               */
6 /*                                                                           */
7 /*                                                                           */
8 /* "ANTIC, Alphanumeric Television Interface Controller, is responsible for  */
9 /* the generation of playfield graphics which is delivered as a datastream   */
10 /* to the related CTIA/GTIA chip. The CTIA/GTIA provides the coloring of the */
11 /* playfield graphics, and is responsible for adding overlaid sprite         */
12 /* (referred to as "Player/Missile graphics" by Atari).  Atari advertised it */
13 /* as a true microprocessor, in that it has an instruction set to run        */
14 /* programs (called display lists) to process data.  ANTIC has no capacity   */
15 /* for writing back computed values to memory, it merely reads data from     */
16 /* memory and processes it for output to the screen, therefore it is not     */
17 /* Turing complete." - Wikipedia article on "ANTIC" (with edits)             */
18 /*                                                                           */
19 /* (C) 2000 Freddy Offenga <taf_offenga@yahoo.com>                           */
20 /* 24-Jan-2011: Christian Krueger: Added defines for Antic instruction set   */
21 /* 2019-01-16: Bill Kendrick <nbs@sonic.net>: More defines for registers     */
22 /*                                                                           */
23 /*                                                                           */
24 /* This software is provided 'as-is', without any expressed or implied       */
25 /* warranty.  In no event will the authors be held liable for any damages    */
26 /* arising from the use of this software.                                    */
27 /*                                                                           */
28 /* Permission is granted to anyone to use this software for any purpose,     */
29 /* including commercial applications, and to alter it and redistribute it    */
30 /* freely, subject to the following restrictions:                            */
31 /*                                                                           */
32 /* 1. The origin of this software must not be misrepresented; you must not   */
33 /*    claim that you wrote the original software. If you use this software   */
34 /*    in a product, an acknowledgment in the product documentation would be  */
35 /*    appreciated but is not required.                                       */
36 /* 2. Altered source versions must be plainly marked as such, and must not   */
37 /*    be misrepresented as being the original software.                      */
38 /* 3. This notice may not be removed or altered from any source              */
39 /*    distribution.                                                          */
40 /*                                                                           */
41 /*****************************************************************************/
42
43
44 #ifndef __ANTIC_H
45 #define __ANTIC_H
46
47 /*****************************************************************************/
48 /* Define a structure with the ANTIC coprocessor's register offsets          */
49 /*****************************************************************************/
50
51 struct __antic {
52     unsigned char   dmactl; /* (W) direct memory access control */
53     unsigned char   chactl; /* (W) character mode control */
54     unsigned char   dlistl; /* display list pointer low-byte */
55     unsigned char   dlisth; /* display list pointer high-byte */
56     unsigned char   hscrol; /* (W) horizontal scroll enable */
57     unsigned char   vscrol; /* (W) vertical scroll enable */
58     unsigned char   unuse0; /* unused */
59     unsigned char   pmbase; /* (W) msb of p/m base address (for when DMACTL has player and/or missile DMA enabled) */
60     unsigned char   unuse1; /* unused */
61     unsigned char   chbase; /* (W) msb of character set base address */
62     unsigned char   wsync;  /* (W) wait for horizontal synchronization */
63     unsigned char   vcount; /* (R) vertical line counter */
64     unsigned char   penh;   /* (R) light pen horizontal position */
65     unsigned char   penv;   /* (R) light pen vertical position */
66     unsigned char   nmien;  /* (W) non-maskable interrupt enable */
67     union {
68         /* (W) ("NMIRES") nmi reset -- clears the interrupt request register;
69         ** resets all of the NMI status together
70         */
71         unsigned char   nmires;
72
73         /* (R) ("NMIST") nmi status -- holds cause for the NMI interrupt */
74         unsigned char   nmist;
75     };
76 };
77
78
79 /*****************************************************************************/
80 /* DMACTL register options                                                   */
81 /*****************************************************************************/
82
83 /* Initialized to 0x22: DMA fetch, normal playfield, no PMG DMA, double-line PMGs */
84
85 /* Playfield modes: */
86 #define DMACTL_PLAYFIELD_NONE     0x00
87 #define DMACTL_PLAYFIELD_NARROW   0x01 /* e.g., 32 bytes per scanline with thick borders */
88 #define DMACTL_PLAYFIELD_NORMAL   0x02 /* e.g., 40 bytes per scanline with normal borders */
89 #define DMACTL_PLAYFIELD_WIDE     0x03 /* e.g., 48 bytes per scanline with no borders (overscan) */
90
91 /* Other options: */
92
93 /* If not set, GTIA's GRAFP0 thru GRAFP3, and/or GRAFM registers are used for
94 ** player & missile shapes, respectively.  (Modify the registers during the horizontal blank
95 ** (Display List Interrupt), a la "racing the beam" on an Atari VCS/2600, )
96 ** if set, ANTIC's PMBASE will be used to fetch shapes from memory via DMA.
97 */
98 #define DMACTL_DMA_MISSILES    0x04
99 #define DMACTL_DMA_PLAYERS     0x08
100
101 /* Unless set, PMGs (as fetched via DMA) will be double-scanline resolution */
102 #define DMACTL_PMG_SINGLELINE  0x10
103
104 /* Unless set, ANTIC operation is disabled, since it cannot fetch
105 ** Display List instructions
106 */
107 #define DMACTL_DMA_FETCH       0x20
108
109
110 /*****************************************************************************/
111 /* CHACTL register options                                                   */
112 /*****************************************************************************/
113
114 /* Initialized to 2 (CHACTL_CHAR_NORMAL | CHACTL_INV_PRESENT) */
115
116 /* Inverted (upside-down) characters */
117 #define CHACTL_CHAR_NORMAL    0x00
118 #define CHACTL_CHAR_INVERTED  0x04
119
120 /* Inverse (reverse-video) characters */
121 #define CHACTL_INV_TRANS      0x00 /* chars with high-bit shown */
122 #define CHACTL_INV_OPAQUE     0x01 /* chars with high-bit appear as space */
123 #define CHACTL_INV_PRESENT    0x02 /* chars with high-bit are reverse-video */
124
125
126 /*****************************************************************************/
127 /* Values for NMIEN (enabling interrupts) & NMIST (cause for the interrupt)  */
128 /*****************************************************************************/
129
130 /* Display List Interrupts
131 ** Called on a modeline when "DL_DLI" bit is set the ANTIC instruction,
132 ** and jumps through VDSLST vector.
133 */
134 #define NMIEN_DLI   0x80
135
136 /* Vertical Blank Interrupt
137 ** Called during every vertical blank; see SYSVBV, VVBLKI, CRITIC, and VVBLKD,
138 ** as well as the SETVBV routine.
139 */
140 #define NMIEN_VBI   0x40 
141
142 /* [Reset] key pressed */
143 #define NMIEN_RESET 0x20
144
145
146 /*****************************************************************************/
147 /* ANTIC instruction set                                                     */
148 /*****************************************************************************/
149
150 /* Absolute instructions (non mode lines) */
151 #define DL_JMP  ((unsigned char) 1)
152 #define DL_JVB  ((unsigned char) 65)
153
154 #define DL_BLK1 ((unsigned char) 0)   /* 1 blank scanline */
155 #define DL_BLK2 ((unsigned char) 16)  /* 2 blank scanlines */
156 #define DL_BLK3 ((unsigned char) 32)  /* ...etc. */
157 #define DL_BLK4 ((unsigned char) 48)
158 #define DL_BLK5 ((unsigned char) 64)
159 #define DL_BLK6 ((unsigned char) 80)
160 #define DL_BLK7 ((unsigned char) 96)
161 #define DL_BLK8 ((unsigned char) 112)
162
163
164 /* Absolute instructions (mode lines) */
165
166 /* Note: Actual width varies (e.g., 40 vs 32 vs 48) depending on
167 ** normal vs narrow vs wide (overscan) playfield setting; see DMACTL
168 */
169
170 /* Character modes (text, tile graphics, etc.) */
171
172 /* monochrome, 40 character & 8 scanlines per mode line (aka Atari BASIC GRAPHICS 0 via OS's CIO routines) */
173 #define DL_CHR40x8x1    ((unsigned char) 2)
174
175 /* monochrome, 40 character & 10 scanlines per mode line (like GR. 0, with descenders) */
176 #define DL_CHR40x10x1   ((unsigned char) 3)
177
178 /* colour, 40 character & 8 scanlines per mode line (GR. 12) */
179 #define DL_CHR40x8x4    ((unsigned char) 4)
180
181 /* colour, 40 character & 16 scanlines per mode line (GR. 13) */
182 #define DL_CHR40x16x4   ((unsigned char) 5)
183
184 /* colour (duochrome per character), 20 character & 8 scanlines per mode line (GR. 1) */
185 #define DL_CHR20x8x2    ((unsigned char) 6)
186
187 /* colour (duochrome per character), 20 character & 16 scanlines per mode line (GR. 2) */
188 #define DL_CHR20x16x2   ((unsigned char) 7)
189
190
191 /* Bitmap modes */
192
193 /* colour, 40 pixel & 8 scanlines per mode line (GR. 3) */
194 #define DL_MAP40x8x4    ((unsigned char) 8)
195
196 /* 'duochrome', 80 pixel & 4 scanlines per mode line (GR.4) */
197 #define DL_MAP80x4x2    ((unsigned char) 9)
198
199 /* colour, 80 pixel & 4 scanlines per mode line (GR.5) */
200 #define DL_MAP80x4x4    ((unsigned char) 10)
201
202 /* 'duochrome', 160 pixel & 2 scanlines per mode line (GR.6) */
203 #define DL_MAP160x2x2   ((unsigned char) 11)
204
205 /* 'duochrome', 160 pixel & 1 scanline per mode line (GR.14) */
206 #define DL_MAP160x1x2   ((unsigned char) 12)
207
208 /* 4 colours, 160 pixel & 2 scanlines per mode line (GR.7) */
209 #define DL_MAP160x2x4   ((unsigned char) 13)
210
211 /* 4 colours, 160 pixel & 1 scanline per mode line (GR.15) */
212 #define DL_MAP160x1x4   ((unsigned char) 14)
213
214 /* monochrome, 320 pixel & 1 scanline per mode line (GR.8) */
215 #define DL_MAP320x1x1   ((unsigned char) 15)
216
217
218 /* Equivalents, for people familiar with Atari 8-bit OS */
219
220 #define DL_GRAPHICS0    DL_CHR40x8x1
221 #define DL_GRAPHICS1    DL_CHR20x8x2
222 #define DL_GRAPHICS2    DL_CHR20x16x2
223 #define DL_GRAPHICS3    DL_MAP40x8x4
224 #define DL_GRAPHICS4    DL_MAP80x4x2
225 #define DL_GRAPHICS5    DL_MAP80x4x4
226 #define DL_GRAPHICS6    DL_MAP160x2x2
227 #define DL_GRAPHICS7    DL_MAP160x2x4
228 #define DL_GRAPHICS8    DL_MAP320x1x1
229 #define DL_GRAPHICS9    DL_MAP320x1x1  /* N.B.: GRAPHICS 9, 10, and 11 also involve GTIA's PRIOR register */
230 #define DL_GRAPHICS10   DL_MAP320x1x1
231 #define DL_GRAPHICS11   DL_MAP320x1x1
232 #define DL_GRAPHICS12   DL_CHR40x8x4   /* N.B.: Atari 400/800 OS didn't have GRAPHICS 12 or 13 */
233 #define DL_GRAPHICS13   DL_CHR40x16x4
234 #define DL_GRAPHICS14   DL_MAP160x1x2
235 #define DL_GRAPHICS15   DL_MAP160x1x4
236
237 /* Atari 400/800 OS didn't have GRAPHICS 14 or 15, so they were known by "6+" and "7+" */
238 #define DL_GRAPHICS6PLUS DL_GRAPHICS14
239 #define DL_GRAPHICS7PLUS DL_GRAPHICS15
240
241 /* Neither Atari 400/800 nor XL OS supported 10-scanline (descenders) text mode via CIO */
242 #define DL_GRAPHICS0_DESCENDERS  DL_CHR40x10x1
243
244 /* Modifiers to mode lines */
245 #define DL_HSCROL(x)    ((unsigned char)((x) | 16)) /* enable smooth horizontal scrolling on this line; see HSCROL */
246 #define DL_VSCROL(x)    ((unsigned char)((x) | 32)) /* enable smooth vertical scrolling on this line; see VSCROL */
247 #define DL_LMS(x)       ((unsigned char)((x) | 64)) /* Load Memory Scan (next two bytes must be the LSB/MSB of the data to load) */
248
249 /* General modifier */
250 #define DL_DLI(x)       ((unsigned char)((x) | 128)) /* enable Display List Interrupt on this mode line */
251
252
253 /* End of _antic.h */
254 #endif /* #ifndef __ANTIC_H */