Previous 199869 Revisions Next

r31967 Sunday 7th September, 2014 at 13:29:39 UTC by Fabio Priuli
another small step: moved antic start procedure to antic.c. nw.
[src/mame/includes]atari.h
[src/mame/video]antic.c atari.c

trunk/src/mame/includes/atari.h
r31966r31967
560560extern ANTIC antic;
561561
562562void antic_start(running_machine &machine);
563void antic_vstart(running_machine &machine);
563564void antic_reset(void);
564565void antic_render(address_space &space, VIDEO *video, int param1, int param2, int param3);
565566
trunk/src/mame/video/atari.c
r31966r31967
1414
1515#define LOG(x)  do { if (VERBOSE) logerror x; } while (0)
1616
17/*************************************************************************
18 * The priority tables tell which playfield, player or missile colors
19 * have precedence about the others, depending on the contents of the
20 * "prior" register. There are 64 possible priority selections.
21 * The table is here to make it easier to build the 'illegal' priority
22 * combinations that produce black or 'ILL' color.
23 *************************************************************************/
2417
25/*************************************************************************
26 * calculate player/missile priorities (GTIA prior at $D00D)
27 * prior   color priorities in descending order
28 * ------------------------------------------------------------------
29 * bit 0   PL0    PL1    PL2    PL3    PF0    PF1    PF2    PF3/P4 BK
30 *         all players in front of all playfield colors
31 * bit 1   PL0    PL1    PF0    PF1    PF2    PF3/P4 PL2    PL3    BK
32 *         pl 0+1 in front of pf 0-3 in front of pl 2+3
33 * bit 2   PF0    PF1    PF2    PF3/P4 PL0    PL1    PL2    PL3    BK
34 *         all playfield colors in front of all players
35 * bit 3   PF0    PF1    PL0    PL1    PL2    PL3    PF2    PF3/P4 BK
36 *         pf 0+1 in front of all players in front of pf 2+3
37 * bit 4   missiles colors are PF3 (P4)
38 *         missiles have the same priority as pf3
39 * bit 5   PL0+PL1 and PL2+PL3 bits xored
40 *         00: playfield, 01: PL0/2, 10: PL1/3 11: black (EOR)
41 * bit 7+6 CTIA mod (00) or GTIA mode 1 to 3 (01, 10, 11)
42 *************************************************************************/
43
44/* player/missile #4 color is equal to playfield #3 */
45#define PM4 PF3
46
47/* bit masks for players and missiles */
48#define P0 0x01
49#define P1 0x02
50#define P2 0x04
51#define P3 0x08
52#define M0 0x10
53#define M1 0x20
54#define M2 0x40
55#define M3 0x80
56
5718/************************************************************************
58 * Contents of the following table:
59 *
60 * PL0 -PL3  are the player/missile colors 0 to 3
61 * P000-P011 are the 4 available color clocks for playfield color 0
62 * P100-P111 are the 4 available color clocks for playfield color 1
63 * P200-P211 are the 4 available color clocks for playfield color 2
64 * P300-P311 are the 4 available color clocks for playfield color 3
65 * ILL       is some undefined color. On my 800XL it looked light yellow ;)
66 *
67 * Each line holds the 8 bitmasks and resulting colors for player and
68 * missile number 0 to 3 in their fixed priority order.
69 * The 8 lines per block are for the 8 available playfield colors.
70 * Yes, 8 colors because the text modes 2,3 and graphics mode F can
71 * be combined with players. The result is the players color with
72 * luminance of the modes foreground (ie. colpf1).
73 * Any combination of players/missiles (256) is checked for the highest
74 * priority player or missile and the resulting color is stored into
75 * antic.prio_table. The second part (20-3F) contains the resulting
76 * color values for the EOR mode, which is derived from the *visible*
77 * player/missile colors calculated for the first part (00-1F).
78 * The priorities of combining priority bits (which games use!) are:
79 ************************************************************************/
80static const UINT8 _pm_colors[32][8*2*8] = {
81   {
82      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 00
83      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
84      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
85         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
86      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
87      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
88      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
89      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
90   },
91   {
92      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 01
93      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
94      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
95         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
96      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
97      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
98      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
99      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
100   },
101   {
102      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 02
103      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2,   0,P2,   0,M3,   0,P3,   0,
104      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2,   0,P2,   0,M3,   0,P3,   0,
105         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
106      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
107      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
108      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
109      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
110   },
111   {
112      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 03
113      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
114      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
115         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
116      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
117      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
118      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
119      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
120   },
121   {
122      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 04
123      M0,   0,P0,   0,M1,   0,P1,   0,M2,   0,P2,   0,M3,   0,P3,   0,
124      M0,   0,P0,   0,M1,   0,P1,   0,M2,   0,P2,   0,M3,   0,P3,   0,
125         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
126      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
127      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
128      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
129      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
130   },
131   {
132      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 05
133      M0, ILL,P0, ILL,M1, ILL,P1, ILL,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
134      M0,   0,P0,   0,M1,   0,P1,   0,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
135         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
136      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
137      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
138      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
139      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
140   },
141   {
142      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 06
143      M0,   0,P0, ILL,M1,   0,P1, ILL,M2,   0,P2,   0,M3,   0,P3,   0,
144      M0,   0,P0,   0,M1,   0,P1,   0,M2,   0,P2,   0,M3,   0,P3,   0,
145         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
146      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
147      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
148      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
149      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
150   },
151   {
152      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 07
153      M0, ILL,P0, ILL,M1, ILL,P1, ILL,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
154      M0,   0,P0,   0,M1,   0,P1,   0,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
155         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
156      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
157      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
158      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
159      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
160   },
161   {
162      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 08
163      M0,   0,P0,   0,M1,   0,P1,   0,M2,   0,P2,   0,M3,   0,P3,   0,
164      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
165         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
166      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
167      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
168      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
169      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
170   },
171   {
172      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 09
173      M0, ILL,P0, ILL,M1, ILL,P1, ILL,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
174      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
175         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
176      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
177      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
178      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
179      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
180   },
181   {
182      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 0A
183      M0, ILL,P0, ILL,M1, ILL,P1, ILL,M2,   0,P2,   0,M3,   0,P3,   0,
184      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
185         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
186      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
187      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
188      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
189      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
190   },
191   {
192      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 0B
193      M0, ILL,P0, ILL,M1, ILL,P1, ILL,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
194      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
195         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
196      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
197      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
198      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
199      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
200   },
201   {
202      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 0C
203      M0,   0,P0,   0,M1,   0,P1,   0,M2,   0,P2,   0,M3,   0,P3,   0,
204      M0,   0,P0,   0,M1,   0,P1,   0,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
205         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
206      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
207      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
208      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
209      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
210   },
211   {
212      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 0D
213      M0,   0,P0,   0,M1,   0,P1,   0,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
214      M0,   0,P0,   0,M1,   0,P1,   0,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
215         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
216      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
217      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
218      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
219      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
220   },
221   {
222      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 0E
223      M0,   0,P0,   0,M1,   0,P1,   0,M2,   0,P2,   0,M3,   0,P3,   0,
224      M0,   0,P0,   0,M1,   0,P1,   0,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
225         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
226      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
227      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
228      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
229      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
230   },
231   {
232      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 0F
233      M0,   0,P0,   0,M1,   0,P1,   0,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
234      M0,   0,P0,   0,M1,   0,P1,   0,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
235         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
236      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
237      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
238      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
239      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
240   },
241   {
242      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 10
243      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
244      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
245         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
246      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
247      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
248      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
249      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
250   },
251   {
252      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 11
253      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
254      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
255         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
256      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
257      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
258      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
259      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
260   },
261   {
262      P0, PL0,P1, PL1,M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2, PL2,P3, PL3,  // 12
263      P0, PL0,P1, PL1,M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,   0,P3,   0,
264      P0, PL0,P1, PL1,M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,   0,P3,   0,
265         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
266      P0,P000,P1,P100,M0,P400,M1,P400,M2,P400,M3,P400,P2,P200,P3,P300,
267      P0,P001,P1,P101,M0,P401,M1,P401,M2,P401,M3,P401,P2,P201,P3,P301,
268      P0,P010,P1,P110,M0,P410,M1,P410,M2,P410,M3,P410,P2,P210,P3,P310,
269      P0,P011,P1,P111,M0,P411,M1,P411,M2,P411,M3,P411,P2,P211,P3,P311
270   },
271   {
272      P0, PL0,P1, PL1,M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2, PL2,P3, PL3,  // 13
273      P0, PL0,P1, PL1,M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2, PL2,P3, PL3,
274      P0, PL0,P1, PL1,M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2, ILL,P3, ILL,
275         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
276      P0,P000,P1,P100,M0,P400,M1,P400,M2,P400,M3,P400,P2,P200,P3,P300,
277      P0,P001,P1,P101,M0,P401,M1,P401,M2,P401,M3,P401,P2,P201,P3,P301,
278      P0,P010,P1,P110,M0,P410,M1,P410,M2,P410,M3,P410,P2,P210,P3,P310,
279      P0,P011,P1,P111,M0,P411,M1,P411,M2,P411,M3,P411,P2,P211,P3,P311
280   },
281   {
282      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P0, PL0,P1, PL1,P2, PL2,P3, PL3,  // 14
283      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P0,   0,P1,   0,P2,   0,P3,   0,
284      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P0,   0,P1,   0,P2,   0,P3,   0,
285         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
286      M0,P400,M1,P400,M2,P400,M3,P400,P0,P000,P1,P100,P2,P200,P3,P300,
287      M0,P401,M1,P401,M2,P401,M3,P401,P0,P001,P1,P101,P2,P201,P3,P301,
288      M0,P410,M1,P410,M2,P410,M3,P410,P0,P010,P1,P110,P2,P210,P3,P310,
289      M0,P411,M1,P411,M2,P411,M3,P411,P0,P011,P1,P111,P2,P211,P3,P311
290   },
291   {
292      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,P0, PL0,P1, PL1, PL2,P3, PL3,  // 15
293      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,P0, ILL,P1, ILL, PL2,P3, PL3,
294      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,P0,   0,P1,   0, ILL,P3, ILL,
295         0,   0, 0,   0, 0,   0, 0,   0, 0, 0,    0, 0,   0,   0, 0,   0,
296      M0,P000,M1,P100,M2,P200,M3,P300,P2,P0,P000,P1,P100,P200,P3,P300,
297      M0,P001,M1,P101,M2,P201,M3,P301,P2,P0,P001,P1,P101,P201,P3,P301,
298      M0,P010,M1,P110,M2,P210,M3,P310,P2,P0,P010,P1,P110,P210,P3,P310,
299      M0,P011,M1,P111,M2,P211,M3,P311,P2,P0,P011,P1,P111,P211,P3,P311
300   },
301   {
302      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P0, PL0,P1, PL1,P2, PL2,P3, PL3,  // 16
303      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P0, ILL,P1, ILL,P2,   0,P3,   0,
304      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P0,   0,P1,   0,P2,   0,P3,   0,
305         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
306      M0,P000,M1,P100,M2,P200,M3,P300,P0,P000,P1,P100,P2,P200,P3,P300,
307      M0,P001,M1,P101,M2,P201,M3,P301,P0,P001,P1,P101,P2,P201,P3,P301,
308      M0,P010,M1,P110,M2,P210,M3,P310,P0,P010,P1,P110,P2,P210,P3,P310,
309      M0,P011,M1,P111,M2,P211,M3,P311,P0,P011,P1,P111,P2,P211,P3,P311
310   },
311   {
312      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,P0, PL0,P1, PL1, PL2,P3, PL3,  // 17
313      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,P0, ILL,P1, ILL, PL2,P3, PL3,
314      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,P0,   0,P1,   0, ILL,P3, ILL,
315         0,   0, 0,   0, 0,   0, 0,   0, 0, 0,    0, 0,   0,   0, 0,   0,
316      M0,P000,M1,P100,M2,P200,M3,P300,P2,P0,P000,P1,P100,P200,P3,P300,
317      M0,P001,M1,P101,M2,P201,M3,P301,P2,P0,P001,P1,P101,P201,P3,P301,
318      M0,P010,M1,P110,M2,P210,M3,P310,P2,P0,P010,P1,P110,P210,P3,P310,
319      M0,P011,M1,P111,M2,P211,M3,P311,P2,P0,P011,P1,P111,P211,P3,P311
320   },
321   {
322      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 18
323      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
324      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
325         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
326      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
327      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
328      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
329      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
330   },
331   {
332      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 19
333      P0, ILL,P1, ILL,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
334      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
335         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
336      P0,P000,P1,P100,P2,P200,P3,P300,M0,P000,M1,P100,M2,P200,M3,P300,
337      P0,P001,P1,P101,P2,P201,P3,P301,M0,P001,M1,P101,M2,P201,M3,P301,
338      P0,P010,P1,P110,P2,P210,P3,P310,M0,P010,M1,P110,M2,P210,M3,P310,
339      P0,P011,P1,P111,P2,P211,P3,P311,M0,P011,M1,P111,M2,P211,M3,P311
340   },
341   {
342      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 1A
343      P0, ILL,P1, ILL,P2,   0,P3,   0,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
344      P0, PL0,P1, PL1,P2, ILL,P3, ILL,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
345         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
346      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
347      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
348      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
349      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
350   },
351   {
352      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 1B
353      P0, ILL,P1, ILL,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
354      P0, PL0,P1, PL1,P2, ILL,P3, ILL,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
355         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
356      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
357      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
358      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
359      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
360   },
361   {
362      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 1C
363      P0,   0,P1,   0,P2,   0,P3,   0,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
364      P0,   0,P1,   0,P2, ILL,P3, ILL,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
365         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
366      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
367      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
368      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
369      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
370   },
371   {
372      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 1D
373      P0,   0,P1,   0,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
374      P0,   0,P1,   0,P2, ILL,P3, ILL,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
375         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
376      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
377      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
378      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
379      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
380   },
381   {
382      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 1E
383      P0,   0,P1,   0,P2,   0,P3,   0,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
384      P0,   0,P1,   0,P2, ILL,P3, ILL,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
385         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
386      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
387      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
388      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
389      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
390   },
391   {
392      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 1F
393      P0,   0,P1,   0,P2,   0,P3,   0,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
394      P0,   0,P1,   0,P2, ILL,P3, ILL,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
395         0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
396      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
397      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
398      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
399      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
400   }
401};
402
403/************************************************************************
404 * prio_init
405 * Initialize player/missile priority lookup tables
406 ************************************************************************/
407void atari_common_state::prio_init()
408{
409   int i, j, pm, p, c;
410   const UINT8 * prio;
411
412   /* 32 priority bit combinations */
413   for( i = 0; i < 32; i++ )
414   {
415      /* 8 playfield colors */
416      for( j = 0; j < 8; j++ )
417      {
418         prio = &_pm_colors[i][j*16];
419         /* 256 player/missile combinations to build */
420         for( pm = 0; pm < 256; pm++ )
421         {
422            c = PFD; /* assume playfield color */
423            for( p = 0; (c == PFD) && (p < 16); p += 2 )
424            {
425               if (((prio[p] & pm) == prio[p]) && (prio[p+1]))
426                  c = prio[p+1];
427            }
428            antic.prio_table[i][(j << 8) + pm] = c;
429            if( (c==PL0 || c==P000 || c==P001 || c==P010 || c==P011) &&
430               (pm & (P0+P1))==(P0+P1))
431               c = EOR;
432            if( (c==PL2 || c==P200 || c==P201 || c==P210 || c==P211) &&
433               (pm & (P2+P3))==(P2+P3))
434               c = EOR;
435            antic.prio_table[32 + i][(j << 8) + pm] = c;
436         }
437      }
438   }
439}
440
441/************************************************************************
442 * cclk_init
443 * Initialize "color clock" lookup tables
444 ************************************************************************/
445void atari_common_state::cclk_init()
446{
447   static const UINT8 _pf_21[4] =   {T00,T01,T10,T11};
448   static const UINT8 _pf_1b[4] =   {G00,G01,G10,G11};
449   static const UINT8 _pf_210b[4] = {PBK,PF0,PF1,PF2};
450   static const UINT8 _pf_310b[4] = {PBK,PF0,PF1,PF3};
451   int i;
452   UINT8 * dst;
453
454   /* setup color translation for the ANTIC modes */
455   for( i = 0; i < 256; i++ )
456   {
457      /****** text mode (2,3) **********/
458      dst = (UINT8 *)&antic.pf_21[0x000+i];
459      *dst++ = _pf_21[(i>>6)&3];
460      *dst++ = _pf_21[(i>>4)&3];
461      *dst++ = _pf_21[(i>>2)&3];
462      *dst++ = _pf_21[(i>>0)&3];
463
464      /****** 4 color text (4,5) with pf2, D, E **********/
465      dst = (UINT8 *)&antic.pf_x10b[0x000+i];
466      *dst++ = _pf_210b[(i>>6)&3];
467      *dst++ = _pf_210b[(i>>4)&3];
468      *dst++ = _pf_210b[(i>>2)&3];
469      *dst++ = _pf_210b[(i>>0)&3];
470      dst = (UINT8 *)&antic.pf_x10b[0x100+i];
471      *dst++ = _pf_310b[(i>>6)&3];
472      *dst++ = _pf_310b[(i>>4)&3];
473      *dst++ = _pf_310b[(i>>2)&3];
474      *dst++ = _pf_310b[(i>>0)&3];
475
476      /****** pf0 color text (6,7), 9, B, C **********/
477      dst = (UINT8 *)&antic.pf_3210b2[0x000+i*2];
478      *dst++ = (i&0x80)?PF0:PBK;
479      *dst++ = (i&0x40)?PF0:PBK;
480      *dst++ = (i&0x20)?PF0:PBK;
481      *dst++ = (i&0x10)?PF0:PBK;
482      *dst++ = (i&0x08)?PF0:PBK;
483      *dst++ = (i&0x04)?PF0:PBK;
484      *dst++ = (i&0x02)?PF0:PBK;
485      *dst++ = (i&0x01)?PF0:PBK;
486
487      /****** pf1 color text (6,7), 9, B, C **********/
488      dst = (UINT8 *)&antic.pf_3210b2[0x200+i*2];
489      *dst++ = (i&0x80)?PF1:PBK;
490      *dst++ = (i&0x40)?PF1:PBK;
491      *dst++ = (i&0x20)?PF1:PBK;
492      *dst++ = (i&0x10)?PF1:PBK;
493      *dst++ = (i&0x08)?PF1:PBK;
494      *dst++ = (i&0x04)?PF1:PBK;
495      *dst++ = (i&0x02)?PF1:PBK;
496      *dst++ = (i&0x01)?PF1:PBK;
497
498      /****** pf2 color text (6,7), 9, B, C **********/
499      dst = (UINT8 *)&antic.pf_3210b2[0x400+i*2];
500      *dst++ = (i&0x80)?PF2:PBK;
501      *dst++ = (i&0x40)?PF2:PBK;
502      *dst++ = (i&0x20)?PF2:PBK;
503      *dst++ = (i&0x10)?PF2:PBK;
504      *dst++ = (i&0x08)?PF2:PBK;
505      *dst++ = (i&0x04)?PF2:PBK;
506      *dst++ = (i&0x02)?PF2:PBK;
507      *dst++ = (i&0x01)?PF2:PBK;
508
509      /****** pf3 color text (6,7), 9, B, C **********/
510      dst = (UINT8 *)&antic.pf_3210b2[0x600+i*2];
511      *dst++ = (i&0x80)?PF3:PBK;
512      *dst++ = (i&0x40)?PF3:PBK;
513      *dst++ = (i&0x20)?PF3:PBK;
514      *dst++ = (i&0x10)?PF3:PBK;
515      *dst++ = (i&0x08)?PF3:PBK;
516      *dst++ = (i&0x04)?PF3:PBK;
517      *dst++ = (i&0x02)?PF3:PBK;
518      *dst++ = (i&0x01)?PF3:PBK;
519
520      /****** 4 color graphics 4 cclks (8) **********/
521      dst = (UINT8 *)&antic.pf_210b4[i*4];
522      *dst++ = _pf_210b[(i>>6)&3];
523      *dst++ = _pf_210b[(i>>6)&3];
524      *dst++ = _pf_210b[(i>>6)&3];
525      *dst++ = _pf_210b[(i>>6)&3];
526      *dst++ = _pf_210b[(i>>4)&3];
527      *dst++ = _pf_210b[(i>>4)&3];
528      *dst++ = _pf_210b[(i>>4)&3];
529      *dst++ = _pf_210b[(i>>4)&3];
530      *dst++ = _pf_210b[(i>>2)&3];
531      *dst++ = _pf_210b[(i>>2)&3];
532      *dst++ = _pf_210b[(i>>2)&3];
533      *dst++ = _pf_210b[(i>>2)&3];
534      *dst++ = _pf_210b[(i>>0)&3];
535      *dst++ = _pf_210b[(i>>0)&3];
536      *dst++ = _pf_210b[(i>>0)&3];
537      *dst++ = _pf_210b[(i>>0)&3];
538
539      /****** 4 color graphics 2 cclks (A) **********/
540      dst = (UINT8 *)&antic.pf_210b2[i*2];
541      *dst++ = _pf_210b[(i>>6)&3];
542      *dst++ = _pf_210b[(i>>6)&3];
543      *dst++ = _pf_210b[(i>>4)&3];
544      *dst++ = _pf_210b[(i>>4)&3];
545      *dst++ = _pf_210b[(i>>2)&3];
546      *dst++ = _pf_210b[(i>>2)&3];
547      *dst++ = _pf_210b[(i>>0)&3];
548      *dst++ = _pf_210b[(i>>0)&3];
549
550      /****** high resolution graphics (F) **********/
551      dst = (UINT8 *)&antic.pf_1b[i];
552      *dst++ = _pf_1b[(i>>6)&3];
553      *dst++ = _pf_1b[(i>>4)&3];
554      *dst++ = _pf_1b[(i>>2)&3];
555      *dst++ = _pf_1b[(i>>0)&3];
556
557      /****** gtia mode 1 **********/
558      dst = (UINT8 *)&antic.pf_gtia1[i];
559      *dst++ = GT1+((i>>4)&15);
560      *dst++ = GT1+((i>>4)&15);
561      *dst++ = GT1+(i&15);
562      *dst++ = GT1+(i&15);
563
564      /****** gtia mode 2 **********/
565      dst = (UINT8 *)&antic.pf_gtia2[i];
566      *dst++ = GT2+((i>>4)&15);
567      *dst++ = GT2+((i>>4)&15);
568      *dst++ = GT2+(i&15);
569      *dst++ = GT2+(i&15);
570
571      /****** gtia mode 3 **********/
572      dst = (UINT8 *)&antic.pf_gtia3[i];
573      *dst++ = GT3+((i>>4)&15);
574      *dst++ = GT3+((i>>4)&15);
575      *dst++ = GT3+(i&15);
576      *dst++ = GT3+(i&15);
577
578   }
579
580   /* setup used color tables */
581   for( i = 0; i < 256; i++ )
582   {
583      /* used colors in text modes 2,3 */
584      antic.uc_21[i] = (i) ? PF2 | PF1 : PF2;
585
586      /* used colors in text modes 4,5 and graphics modes D,E */
587      switch( i & 0x03 )
588      {
589         case 0x01: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break;
590         case 0x02: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break;
591         case 0x03: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break;
592      }
593      switch( i & 0x0c )
594      {
595         case 0x04: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break;
596         case 0x08: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break;
597         case 0x0c: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break;
598      }
599      switch( i & 0x30 )
600      {
601         case 0x10: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break;
602         case 0x20: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break;
603         case 0x30: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break;
604      }
605      switch( i & 0xc0 )
606      {
607         case 0x40: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break;
608         case 0x80: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break;
609         case 0xc0: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break;
610      }
611
612      /* used colors in text modes 6,7 and graphics modes 9,B,C */
613      if( i )
614      {
615         antic.uc_3210b2[0x000+i*2] |= PF0;
616         antic.uc_3210b2[0x200+i*2] |= PF1;
617         antic.uc_3210b2[0x400+i*2] |= PF2;
618         antic.uc_3210b2[0x600+i*2] |= PF3;
619      }
620
621      /* used colors in graphics mode 8 */
622      switch( i & 0x03 )
623      {
624         case 0x01: antic.uc_210b4[i*4] |= PF0; break;
625         case 0x02: antic.uc_210b4[i*4] |= PF1; break;
626         case 0x03: antic.uc_210b4[i*4] |= PF2; break;
627      }
628      switch( i & 0x0c )
629      {
630         case 0x04: antic.uc_210b4[i*4] |= PF0; break;
631         case 0x08: antic.uc_210b4[i*4] |= PF1; break;
632         case 0x0c: antic.uc_210b4[i*4] |= PF2; break;
633      }
634      switch( i & 0x30 )
635      {
636         case 0x10: antic.uc_210b4[i*4] |= PF0; break;
637         case 0x20: antic.uc_210b4[i*4] |= PF1; break;
638         case 0x30: antic.uc_210b4[i*4] |= PF2; break;
639      }
640      switch( i & 0xc0 )
641      {
642         case 0x40: antic.uc_210b4[i*4] |= PF0; break;
643         case 0x80: antic.uc_210b4[i*4] |= PF1; break;
644         case 0xc0: antic.uc_210b4[i*4] |= PF2; break;
645      }
646
647      /* used colors in graphics mode A */
648      switch( i & 0x03 )
649      {
650         case 0x01: antic.uc_210b2[i*2] |= PF0; break;
651         case 0x02: antic.uc_210b2[i*2] |= PF1; break;
652         case 0x03: antic.uc_210b2[i*2] |= PF2; break;
653      }
654      switch( i & 0x0c )
655      {
656         case 0x04: antic.uc_210b2[i*2] |= PF0; break;
657         case 0x08: antic.uc_210b2[i*2] |= PF1; break;
658         case 0x0c: antic.uc_210b2[i*2] |= PF2; break;
659      }
660      switch( i & 0x30 )
661      {
662         case 0x10: antic.uc_210b2[i*2] |= PF0; break;
663         case 0x20: antic.uc_210b2[i*2] |= PF1; break;
664         case 0x30: antic.uc_210b2[i*2] |= PF2; break;
665      }
666      switch( i & 0xc0 )
667      {
668         case 0x40: antic.uc_210b2[i*2] |= PF0; break;
669         case 0x80: antic.uc_210b2[i*2] |= PF1; break;
670         case 0xc0: antic.uc_210b2[i*2] |= PF2; break;
671      }
672
673      /* used colors in graphics mode F */
674      if( i )
675         antic.uc_1b[i] |= PF1;
676
677      /* used colors in GTIA graphics modes */
678      /* GTIA 1 is 16 different luminances with hue of colbk */
679      antic.uc_g1[i] = 0x00;
680      /* GTIA 2 is all 9 colors (8..15 is colbk) */
681      switch( i & 0x0f )
682      {
683         case 0x00: antic.uc_g2[i] = 0x10; break;
684         case 0x01: antic.uc_g2[i] = 0x20; break;
685         case 0x02: antic.uc_g2[i] = 0x40; break;
686         case 0x03: antic.uc_g2[i] = 0x80; break;
687         case 0x04: antic.uc_g2[i] = 0x01; break;
688         case 0x05: antic.uc_g2[i] = 0x02; break;
689         case 0x06: antic.uc_g2[i] = 0x04; break;
690         case 0x07: antic.uc_g2[i] = 0x08; break;
691         default:   antic.uc_g2[i] = 0x00;
692      }
693
694      /* GTIA 3 is 16 different hues with luminance of colbk */
695      antic.uc_g3[i] = 0x00;
696   }
697}
698
699/************************************************************************
70019 * atari_vh_start
70120 * Initialize the ATARI800 video emulation
70221 ************************************************************************/
22
70323void atari_common_state::video_start()
70424{
70525   palette_device *m_palette = machine().first_screen()->palette();
70626
707   LOG(("atari antic_vh_start\n"));
708   memset(&antic, 0, sizeof(antic));
709
710   antic.bitmap = auto_bitmap_ind16_alloc(machine(), machine().first_screen()->width(), machine().first_screen()->height());
711
71227   m_antic_render1 = 0;
71328   m_antic_render2 = 0;
71429   m_antic_render3 = 0;
715   antic.cclk_expand = auto_alloc_array(machine(), UINT32, 21 * 256);
71630
717   antic.pf_21       = &antic.cclk_expand[ 0 * 256];
718   antic.pf_x10b     = &antic.cclk_expand[ 1 * 256];
719   antic.pf_3210b2   = &antic.cclk_expand[ 3 * 256];
720   antic.pf_210b4    = &antic.cclk_expand[11 * 256];
721   antic.pf_210b2    = &antic.cclk_expand[15 * 256];
722   antic.pf_1b       = &antic.cclk_expand[17 * 256];
723   antic.pf_gtia1    = &antic.cclk_expand[18 * 256];
724   antic.pf_gtia2    = &antic.cclk_expand[19 * 256];
725   antic.pf_gtia3    = &antic.cclk_expand[20 * 256];
726
727   antic.used_colors = auto_alloc_array(machine(), UINT8, 21 * 256);
728
729   memset(antic.used_colors, 0, 21 * 256 * sizeof(UINT8));
730
731   antic.uc_21       = &antic.used_colors[ 0 * 256];
732   antic.uc_x10b     = &antic.used_colors[ 1 * 256];
733   antic.uc_3210b2   = &antic.used_colors[ 3 * 256];
734   antic.uc_210b4    = &antic.used_colors[11 * 256];
735   antic.uc_210b2    = &antic.used_colors[15 * 256];
736   antic.uc_1b       = &antic.used_colors[17 * 256];
737   antic.uc_g1       = &antic.used_colors[18 * 256];
738   antic.uc_g2       = &antic.used_colors[19 * 256];
739   antic.uc_g3       = &antic.used_colors[20 * 256];
740
74131   for (int i = 0; i < 256; i++)
74232      m_gtia->set_color_lookup(i, (m_palette->pen(0) << 8) + m_palette->pen(0));
743
744   LOG(("atari cclk_init\n"));
745   cclk_init();
746
747   for (int i = 0; i < 64; i++)
748      antic.prio_table[i] = auto_alloc_array(machine(), UINT8, 8*256);
749
750   LOG(("atari prio_init\n"));
751   prio_init();
752
753   for (int i = 0; i < machine().first_screen()->height(); i++)
754      antic.video[i] = auto_alloc_clear(machine(), VIDEO);
33   
34   antic_vstart(machine());
75535}
75636
75737/************************************************************************
trunk/src/mame/video/antic.c
r31966r31967
7575ANTIC_RENDERER( gtia_mode_3_48 );
7676
7777
78
79/*************************************************************************
80 * The priority tables tell which playfield, player or missile colors
81 * have precedence about the others, depending on the contents of the
82 * "prior" register. There are 64 possible priority selections.
83 * The table is here to make it easier to build the 'illegal' priority
84 * combinations that produce black or 'ILL' color.
85 *************************************************************************/
86
87/*************************************************************************
88 * calculate player/missile priorities (GTIA prior at $D00D)
89 * prior   color priorities in descending order
90 * ------------------------------------------------------------------
91 * bit 0   PL0    PL1    PL2    PL3    PF0    PF1    PF2    PF3/P4 BK
92 *         all players in front of all playfield colors
93 * bit 1   PL0    PL1    PF0    PF1    PF2    PF3/P4 PL2    PL3    BK
94 *         pl 0+1 in front of pf 0-3 in front of pl 2+3
95 * bit 2   PF0    PF1    PF2    PF3/P4 PL0    PL1    PL2    PL3    BK
96 *         all playfield colors in front of all players
97 * bit 3   PF0    PF1    PL0    PL1    PL2    PL3    PF2    PF3/P4 BK
98 *         pf 0+1 in front of all players in front of pf 2+3
99 * bit 4   missiles colors are PF3 (P4)
100 *         missiles have the same priority as pf3
101 * bit 5   PL0+PL1 and PL2+PL3 bits xored
102 *         00: playfield, 01: PL0/2, 10: PL1/3 11: black (EOR)
103 * bit 7+6 CTIA mod (00) or GTIA mode 1 to 3 (01, 10, 11)
104 *************************************************************************/
105
106/* player/missile #4 color is equal to playfield #3 */
107#define PM4 PF3
108
109/* bit masks for players and missiles */
110#define P0 0x01
111#define P1 0x02
112#define P2 0x04
113#define P3 0x08
114#define M0 0x10
115#define M1 0x20
116#define M2 0x40
117#define M3 0x80
118
119/************************************************************************
120 * Contents of the following table:
121 *
122 * PL0 -PL3  are the player/missile colors 0 to 3
123 * P000-P011 are the 4 available color clocks for playfield color 0
124 * P100-P111 are the 4 available color clocks for playfield color 1
125 * P200-P211 are the 4 available color clocks for playfield color 2
126 * P300-P311 are the 4 available color clocks for playfield color 3
127 * ILL       is some undefined color. On my 800XL it looked light yellow ;)
128 *
129 * Each line holds the 8 bitmasks and resulting colors for player and
130 * missile number 0 to 3 in their fixed priority order.
131 * The 8 lines per block are for the 8 available playfield colors.
132 * Yes, 8 colors because the text modes 2,3 and graphics mode F can
133 * be combined with players. The result is the players color with
134 * luminance of the modes foreground (ie. colpf1).
135 * Any combination of players/missiles (256) is checked for the highest
136 * priority player or missile and the resulting color is stored into
137 * antic.prio_table. The second part (20-3F) contains the resulting
138 * color values for the EOR mode, which is derived from the *visible*
139 * player/missile colors calculated for the first part (00-1F).
140 * The priorities of combining priority bits (which games use!) are:
141 ************************************************************************/
142static const UINT8 _pm_colors[32][8*2*8] = {
143   {
144      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 00
145      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
146      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
147      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
148      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
149      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
150      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
151      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
152   },
153   {
154      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 01
155      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
156      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
157      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
158      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
159      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
160      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
161      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
162   },
163   {
164      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 02
165      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2,   0,P2,   0,M3,   0,P3,   0,
166      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2,   0,P2,   0,M3,   0,P3,   0,
167      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
168      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
169      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
170      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
171      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
172   },
173   {
174      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 03
175      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
176      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
177      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
178      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
179      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
180      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
181      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
182   },
183   {
184      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 04
185      M0,   0,P0,   0,M1,   0,P1,   0,M2,   0,P2,   0,M3,   0,P3,   0,
186      M0,   0,P0,   0,M1,   0,P1,   0,M2,   0,P2,   0,M3,   0,P3,   0,
187      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
188      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
189      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
190      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
191      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
192   },
193   {
194      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 05
195      M0, ILL,P0, ILL,M1, ILL,P1, ILL,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
196      M0,   0,P0,   0,M1,   0,P1,   0,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
197      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
198      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
199      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
200      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
201      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
202   },
203   {
204      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 06
205      M0,   0,P0, ILL,M1,   0,P1, ILL,M2,   0,P2,   0,M3,   0,P3,   0,
206      M0,   0,P0,   0,M1,   0,P1,   0,M2,   0,P2,   0,M3,   0,P3,   0,
207      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
208      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
209      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
210      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
211      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
212   },
213   {
214      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 07
215      M0, ILL,P0, ILL,M1, ILL,P1, ILL,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
216      M0,   0,P0,   0,M1,   0,P1,   0,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
217      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
218      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
219      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
220      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
221      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
222   },
223   {
224      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 08
225      M0,   0,P0,   0,M1,   0,P1,   0,M2,   0,P2,   0,M3,   0,P3,   0,
226      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
227      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
228      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
229      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
230      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
231      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
232   },
233   {
234      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 09
235      M0, ILL,P0, ILL,M1, ILL,P1, ILL,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
236      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
237      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
238      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
239      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
240      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
241      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
242   },
243   {
244      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 0A
245      M0, ILL,P0, ILL,M1, ILL,P1, ILL,M2,   0,P2,   0,M3,   0,P3,   0,
246      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
247      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
248      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
249      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
250      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
251      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
252   },
253   {
254      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 0B
255      M0, ILL,P0, ILL,M1, ILL,P1, ILL,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
256      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
257      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
258      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
259      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
260      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
261      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
262   },
263   {
264      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 0C
265      M0,   0,P0,   0,M1,   0,P1,   0,M2,   0,P2,   0,M3,   0,P3,   0,
266      M0,   0,P0,   0,M1,   0,P1,   0,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
267      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
268      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
269      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
270      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
271      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
272   },
273   {
274      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 0D
275      M0,   0,P0,   0,M1,   0,P1,   0,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
276      M0,   0,P0,   0,M1,   0,P1,   0,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
277      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
278      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
279      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
280      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
281      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
282   },
283   {
284      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 0E
285      M0,   0,P0,   0,M1,   0,P1,   0,M2,   0,P2,   0,M3,   0,P3,   0,
286      M0,   0,P0,   0,M1,   0,P1,   0,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
287      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
288      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
289      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
290      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
291      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
292   },
293   {
294      M0, PL0,P0, PL0,M1, PL1,P1, PL1,M2, PL2,P2, PL2,M3, PL3,P3, PL3,  // 0F
295      M0,   0,P0,   0,M1,   0,P1,   0,M2, PL2,P2, PL2,M3, PL3,P3, PL3,
296      M0,   0,P0,   0,M1,   0,P1,   0,M2, ILL,P2, ILL,M3, ILL,P3, ILL,
297      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
298      M0,P000,P0,P000,M1,P100,P1,P100,M2,P200,P2,P200,M3,P300,P3,P300,
299      M0,P001,P0,P001,M1,P101,P1,P101,M2,P201,P2,P201,M3,P301,P3,P301,
300      M0,P010,P0,P010,M1,P110,P1,P110,M2,P210,P2,P210,M3,P310,P3,P310,
301      M0,P011,P0,P011,M1,P111,P1,P111,M2,P211,P2,P211,M3,P311,P3,P311
302   },
303   {
304      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 10
305      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
306      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
307      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
308      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
309      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
310      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
311      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
312   },
313   {
314      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 11
315      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
316      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
317      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
318      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
319      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
320      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
321      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
322   },
323   {
324      P0, PL0,P1, PL1,M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2, PL2,P3, PL3,  // 12
325      P0, PL0,P1, PL1,M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,   0,P3,   0,
326      P0, PL0,P1, PL1,M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,   0,P3,   0,
327      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
328      P0,P000,P1,P100,M0,P400,M1,P400,M2,P400,M3,P400,P2,P200,P3,P300,
329      P0,P001,P1,P101,M0,P401,M1,P401,M2,P401,M3,P401,P2,P201,P3,P301,
330      P0,P010,P1,P110,M0,P410,M1,P410,M2,P410,M3,P410,P2,P210,P3,P310,
331      P0,P011,P1,P111,M0,P411,M1,P411,M2,P411,M3,P411,P2,P211,P3,P311
332   },
333   {
334      P0, PL0,P1, PL1,M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2, PL2,P3, PL3,  // 13
335      P0, PL0,P1, PL1,M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2, PL2,P3, PL3,
336      P0, PL0,P1, PL1,M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2, ILL,P3, ILL,
337      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
338      P0,P000,P1,P100,M0,P400,M1,P400,M2,P400,M3,P400,P2,P200,P3,P300,
339      P0,P001,P1,P101,M0,P401,M1,P401,M2,P401,M3,P401,P2,P201,P3,P301,
340      P0,P010,P1,P110,M0,P410,M1,P410,M2,P410,M3,P410,P2,P210,P3,P310,
341      P0,P011,P1,P111,M0,P411,M1,P411,M2,P411,M3,P411,P2,P211,P3,P311
342   },
343   {
344      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P0, PL0,P1, PL1,P2, PL2,P3, PL3,  // 14
345      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P0,   0,P1,   0,P2,   0,P3,   0,
346      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P0,   0,P1,   0,P2,   0,P3,   0,
347      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
348      M0,P400,M1,P400,M2,P400,M3,P400,P0,P000,P1,P100,P2,P200,P3,P300,
349      M0,P401,M1,P401,M2,P401,M3,P401,P0,P001,P1,P101,P2,P201,P3,P301,
350      M0,P410,M1,P410,M2,P410,M3,P410,P0,P010,P1,P110,P2,P210,P3,P310,
351      M0,P411,M1,P411,M2,P411,M3,P411,P0,P011,P1,P111,P2,P211,P3,P311
352   },
353   {
354      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,P0, PL0,P1, PL1, PL2,P3, PL3,  // 15
355      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,P0, ILL,P1, ILL, PL2,P3, PL3,
356      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,P0,   0,P1,   0, ILL,P3, ILL,
357      0,   0, 0,   0, 0,   0, 0,   0, 0, 0,    0, 0,   0,   0, 0,   0,
358      M0,P000,M1,P100,M2,P200,M3,P300,P2,P0,P000,P1,P100,P200,P3,P300,
359      M0,P001,M1,P101,M2,P201,M3,P301,P2,P0,P001,P1,P101,P201,P3,P301,
360      M0,P010,M1,P110,M2,P210,M3,P310,P2,P0,P010,P1,P110,P210,P3,P310,
361      M0,P011,M1,P111,M2,P211,M3,P311,P2,P0,P011,P1,P111,P211,P3,P311
362   },
363   {
364      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P0, PL0,P1, PL1,P2, PL2,P3, PL3,  // 16
365      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P0, ILL,P1, ILL,P2,   0,P3,   0,
366      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P0,   0,P1,   0,P2,   0,P3,   0,
367      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
368      M0,P000,M1,P100,M2,P200,M3,P300,P0,P000,P1,P100,P2,P200,P3,P300,
369      M0,P001,M1,P101,M2,P201,M3,P301,P0,P001,P1,P101,P2,P201,P3,P301,
370      M0,P010,M1,P110,M2,P210,M3,P310,P0,P010,P1,P110,P2,P210,P3,P310,
371      M0,P011,M1,P111,M2,P211,M3,P311,P0,P011,P1,P111,P2,P211,P3,P311
372   },
373   {
374      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,P0, PL0,P1, PL1, PL2,P3, PL3,  // 17
375      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,P0, ILL,P1, ILL, PL2,P3, PL3,
376      M0, PM4,M1, PM4,M2, PM4,M3, PM4,P2,P0,   0,P1,   0, ILL,P3, ILL,
377      0,   0, 0,   0, 0,   0, 0,   0, 0, 0,    0, 0,   0,   0, 0,   0,
378      M0,P000,M1,P100,M2,P200,M3,P300,P2,P0,P000,P1,P100,P200,P3,P300,
379      M0,P001,M1,P101,M2,P201,M3,P301,P2,P0,P001,P1,P101,P201,P3,P301,
380      M0,P010,M1,P110,M2,P210,M3,P310,P2,P0,P010,P1,P110,P210,P3,P310,
381      M0,P011,M1,P111,M2,P211,M3,P311,P2,P0,P011,P1,P111,P211,P3,P311
382   },
383   {
384      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 18
385      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
386      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
387      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
388      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
389      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
390      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
391      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
392   },
393   {
394      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 19
395      P0, ILL,P1, ILL,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
396      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
397      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
398      P0,P000,P1,P100,P2,P200,P3,P300,M0,P000,M1,P100,M2,P200,M3,P300,
399      P0,P001,P1,P101,P2,P201,P3,P301,M0,P001,M1,P101,M2,P201,M3,P301,
400      P0,P010,P1,P110,P2,P210,P3,P310,M0,P010,M1,P110,M2,P210,M3,P310,
401      P0,P011,P1,P111,P2,P211,P3,P311,M0,P011,M1,P111,M2,P211,M3,P311
402   },
403   {
404      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 1A
405      P0, ILL,P1, ILL,P2,   0,P3,   0,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
406      P0, PL0,P1, PL1,P2, ILL,P3, ILL,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
407      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
408      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
409      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
410      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
411      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
412   },
413   {
414      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 1B
415      P0, ILL,P1, ILL,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
416      P0, PL0,P1, PL1,P2, ILL,P3, ILL,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
417      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
418      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
419      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
420      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
421      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
422   },
423   {
424      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 1C
425      P0,   0,P1,   0,P2,   0,P3,   0,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
426      P0,   0,P1,   0,P2, ILL,P3, ILL,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
427      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
428      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
429      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
430      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
431      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
432   },
433   {
434      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 1D
435      P0,   0,P1,   0,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
436      P0,   0,P1,   0,P2, ILL,P3, ILL,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
437      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
438      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
439      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
440      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
441      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
442   },
443   {
444      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 1E
445      P0,   0,P1,   0,P2,   0,P3,   0,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
446      P0,   0,P1,   0,P2, ILL,P3, ILL,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
447      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
448      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
449      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
450      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
451      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
452   },
453   {
454      P0, PL0,P1, PL1,P2, PL2,P3, PL3,M0, PM4,M1, PM4,M2, PM4,M3, PM4,  // 1F
455      P0,   0,P1,   0,P2,   0,P3,   0,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
456      P0,   0,P1,   0,P2, ILL,P3, ILL,M0, PM4,M1, PM4,M2, PM4,M3, PM4,
457      0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0,
458      P0,P000,P1,P100,P2,P200,P3,P300,M0,P400,M1,P400,M2,P400,M3,P400,
459      P0,P001,P1,P101,P2,P201,P3,P301,M0,P401,M1,P401,M2,P401,M3,P401,
460      P0,P010,P1,P110,P2,P210,P3,P310,M0,P410,M1,P410,M2,P410,M3,P410,
461      P0,P011,P1,P111,P2,P211,P3,P311,M0,P411,M1,P411,M2,P411,M3,P411
462   }
463};
464
465/************************************************************************
466 * prio_init
467 * Initialize player/missile priority lookup tables
468 ************************************************************************/
469void prio_init()
470{
471   int i, j, pm, p, c;
472   const UINT8 * prio;
473   
474   /* 32 priority bit combinations */
475   for( i = 0; i < 32; i++ )
476   {
477      /* 8 playfield colors */
478      for( j = 0; j < 8; j++ )
479      {
480         prio = &_pm_colors[i][j*16];
481         /* 256 player/missile combinations to build */
482         for( pm = 0; pm < 256; pm++ )
483         {
484            c = PFD; /* assume playfield color */
485            for( p = 0; (c == PFD) && (p < 16); p += 2 )
486            {
487               if (((prio[p] & pm) == prio[p]) && (prio[p+1]))
488                  c = prio[p+1];
489            }
490            antic.prio_table[i][(j << 8) + pm] = c;
491            if( (c==PL0 || c==P000 || c==P001 || c==P010 || c==P011) &&
492               (pm & (P0+P1))==(P0+P1))
493               c = EOR;
494            if( (c==PL2 || c==P200 || c==P201 || c==P210 || c==P211) &&
495               (pm & (P2+P3))==(P2+P3))
496               c = EOR;
497            antic.prio_table[32 + i][(j << 8) + pm] = c;
498         }
499      }
500   }
501}
502
503/************************************************************************
504 * cclk_init
505 * Initialize "color clock" lookup tables
506 ************************************************************************/
507static void cclk_init()
508{
509   static const UINT8 _pf_21[4] =   {T00,T01,T10,T11};
510   static const UINT8 _pf_1b[4] =   {G00,G01,G10,G11};
511   static const UINT8 _pf_210b[4] = {PBK,PF0,PF1,PF2};
512   static const UINT8 _pf_310b[4] = {PBK,PF0,PF1,PF3};
513   int i;
514   UINT8 * dst;
515   
516   /* setup color translation for the ANTIC modes */
517   for( i = 0; i < 256; i++ )
518   {
519      /****** text mode (2,3) **********/
520      dst = (UINT8 *)&antic.pf_21[0x000+i];
521      *dst++ = _pf_21[(i>>6)&3];
522      *dst++ = _pf_21[(i>>4)&3];
523      *dst++ = _pf_21[(i>>2)&3];
524      *dst++ = _pf_21[(i>>0)&3];
525     
526      /****** 4 color text (4,5) with pf2, D, E **********/
527      dst = (UINT8 *)&antic.pf_x10b[0x000+i];
528      *dst++ = _pf_210b[(i>>6)&3];
529      *dst++ = _pf_210b[(i>>4)&3];
530      *dst++ = _pf_210b[(i>>2)&3];
531      *dst++ = _pf_210b[(i>>0)&3];
532      dst = (UINT8 *)&antic.pf_x10b[0x100+i];
533      *dst++ = _pf_310b[(i>>6)&3];
534      *dst++ = _pf_310b[(i>>4)&3];
535      *dst++ = _pf_310b[(i>>2)&3];
536      *dst++ = _pf_310b[(i>>0)&3];
537     
538      /****** pf0 color text (6,7), 9, B, C **********/
539      dst = (UINT8 *)&antic.pf_3210b2[0x000+i*2];
540      *dst++ = (i&0x80)?PF0:PBK;
541      *dst++ = (i&0x40)?PF0:PBK;
542      *dst++ = (i&0x20)?PF0:PBK;
543      *dst++ = (i&0x10)?PF0:PBK;
544      *dst++ = (i&0x08)?PF0:PBK;
545      *dst++ = (i&0x04)?PF0:PBK;
546      *dst++ = (i&0x02)?PF0:PBK;
547      *dst++ = (i&0x01)?PF0:PBK;
548     
549      /****** pf1 color text (6,7), 9, B, C **********/
550      dst = (UINT8 *)&antic.pf_3210b2[0x200+i*2];
551      *dst++ = (i&0x80)?PF1:PBK;
552      *dst++ = (i&0x40)?PF1:PBK;
553      *dst++ = (i&0x20)?PF1:PBK;
554      *dst++ = (i&0x10)?PF1:PBK;
555      *dst++ = (i&0x08)?PF1:PBK;
556      *dst++ = (i&0x04)?PF1:PBK;
557      *dst++ = (i&0x02)?PF1:PBK;
558      *dst++ = (i&0x01)?PF1:PBK;
559     
560      /****** pf2 color text (6,7), 9, B, C **********/
561      dst = (UINT8 *)&antic.pf_3210b2[0x400+i*2];
562      *dst++ = (i&0x80)?PF2:PBK;
563      *dst++ = (i&0x40)?PF2:PBK;
564      *dst++ = (i&0x20)?PF2:PBK;
565      *dst++ = (i&0x10)?PF2:PBK;
566      *dst++ = (i&0x08)?PF2:PBK;
567      *dst++ = (i&0x04)?PF2:PBK;
568      *dst++ = (i&0x02)?PF2:PBK;
569      *dst++ = (i&0x01)?PF2:PBK;
570     
571      /****** pf3 color text (6,7), 9, B, C **********/
572      dst = (UINT8 *)&antic.pf_3210b2[0x600+i*2];
573      *dst++ = (i&0x80)?PF3:PBK;
574      *dst++ = (i&0x40)?PF3:PBK;
575      *dst++ = (i&0x20)?PF3:PBK;
576      *dst++ = (i&0x10)?PF3:PBK;
577      *dst++ = (i&0x08)?PF3:PBK;
578      *dst++ = (i&0x04)?PF3:PBK;
579      *dst++ = (i&0x02)?PF3:PBK;
580      *dst++ = (i&0x01)?PF3:PBK;
581     
582      /****** 4 color graphics 4 cclks (8) **********/
583      dst = (UINT8 *)&antic.pf_210b4[i*4];
584      *dst++ = _pf_210b[(i>>6)&3];
585      *dst++ = _pf_210b[(i>>6)&3];
586      *dst++ = _pf_210b[(i>>6)&3];
587      *dst++ = _pf_210b[(i>>6)&3];
588      *dst++ = _pf_210b[(i>>4)&3];
589      *dst++ = _pf_210b[(i>>4)&3];
590      *dst++ = _pf_210b[(i>>4)&3];
591      *dst++ = _pf_210b[(i>>4)&3];
592      *dst++ = _pf_210b[(i>>2)&3];
593      *dst++ = _pf_210b[(i>>2)&3];
594      *dst++ = _pf_210b[(i>>2)&3];
595      *dst++ = _pf_210b[(i>>2)&3];
596      *dst++ = _pf_210b[(i>>0)&3];
597      *dst++ = _pf_210b[(i>>0)&3];
598      *dst++ = _pf_210b[(i>>0)&3];
599      *dst++ = _pf_210b[(i>>0)&3];
600     
601      /****** 4 color graphics 2 cclks (A) **********/
602      dst = (UINT8 *)&antic.pf_210b2[i*2];
603      *dst++ = _pf_210b[(i>>6)&3];
604      *dst++ = _pf_210b[(i>>6)&3];
605      *dst++ = _pf_210b[(i>>4)&3];
606      *dst++ = _pf_210b[(i>>4)&3];
607      *dst++ = _pf_210b[(i>>2)&3];
608      *dst++ = _pf_210b[(i>>2)&3];
609      *dst++ = _pf_210b[(i>>0)&3];
610      *dst++ = _pf_210b[(i>>0)&3];
611     
612      /****** high resolution graphics (F) **********/
613      dst = (UINT8 *)&antic.pf_1b[i];
614      *dst++ = _pf_1b[(i>>6)&3];
615      *dst++ = _pf_1b[(i>>4)&3];
616      *dst++ = _pf_1b[(i>>2)&3];
617      *dst++ = _pf_1b[(i>>0)&3];
618     
619      /****** gtia mode 1 **********/
620      dst = (UINT8 *)&antic.pf_gtia1[i];
621      *dst++ = GT1+((i>>4)&15);
622      *dst++ = GT1+((i>>4)&15);
623      *dst++ = GT1+(i&15);
624      *dst++ = GT1+(i&15);
625     
626      /****** gtia mode 2 **********/
627      dst = (UINT8 *)&antic.pf_gtia2[i];
628      *dst++ = GT2+((i>>4)&15);
629      *dst++ = GT2+((i>>4)&15);
630      *dst++ = GT2+(i&15);
631      *dst++ = GT2+(i&15);
632     
633      /****** gtia mode 3 **********/
634      dst = (UINT8 *)&antic.pf_gtia3[i];
635      *dst++ = GT3+((i>>4)&15);
636      *dst++ = GT3+((i>>4)&15);
637      *dst++ = GT3+(i&15);
638      *dst++ = GT3+(i&15);
639     
640   }
641   
642   /* setup used color tables */
643   for( i = 0; i < 256; i++ )
644   {
645      /* used colors in text modes 2,3 */
646      antic.uc_21[i] = (i) ? PF2 | PF1 : PF2;
647     
648      /* used colors in text modes 4,5 and graphics modes D,E */
649      switch( i & 0x03 )
650      {
651         case 0x01: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break;
652         case 0x02: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break;
653         case 0x03: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break;
654      }
655      switch( i & 0x0c )
656      {
657         case 0x04: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break;
658         case 0x08: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break;
659         case 0x0c: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break;
660      }
661      switch( i & 0x30 )
662      {
663         case 0x10: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break;
664         case 0x20: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break;
665         case 0x30: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break;
666      }
667      switch( i & 0xc0 )
668      {
669         case 0x40: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break;
670         case 0x80: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break;
671         case 0xc0: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break;
672      }
673     
674      /* used colors in text modes 6,7 and graphics modes 9,B,C */
675      if( i )
676      {
677         antic.uc_3210b2[0x000+i*2] |= PF0;
678         antic.uc_3210b2[0x200+i*2] |= PF1;
679         antic.uc_3210b2[0x400+i*2] |= PF2;
680         antic.uc_3210b2[0x600+i*2] |= PF3;
681      }
682     
683      /* used colors in graphics mode 8 */
684      switch( i & 0x03 )
685      {
686         case 0x01: antic.uc_210b4[i*4] |= PF0; break;
687         case 0x02: antic.uc_210b4[i*4] |= PF1; break;
688         case 0x03: antic.uc_210b4[i*4] |= PF2; break;
689      }
690      switch( i & 0x0c )
691      {
692         case 0x04: antic.uc_210b4[i*4] |= PF0; break;
693         case 0x08: antic.uc_210b4[i*4] |= PF1; break;
694         case 0x0c: antic.uc_210b4[i*4] |= PF2; break;
695      }
696      switch( i & 0x30 )
697      {
698         case 0x10: antic.uc_210b4[i*4] |= PF0; break;
699         case 0x20: antic.uc_210b4[i*4] |= PF1; break;
700         case 0x30: antic.uc_210b4[i*4] |= PF2; break;
701      }
702      switch( i & 0xc0 )
703      {
704         case 0x40: antic.uc_210b4[i*4] |= PF0; break;
705         case 0x80: antic.uc_210b4[i*4] |= PF1; break;
706         case 0xc0: antic.uc_210b4[i*4] |= PF2; break;
707      }
708     
709      /* used colors in graphics mode A */
710      switch( i & 0x03 )
711      {
712         case 0x01: antic.uc_210b2[i*2] |= PF0; break;
713         case 0x02: antic.uc_210b2[i*2] |= PF1; break;
714         case 0x03: antic.uc_210b2[i*2] |= PF2; break;
715      }
716      switch( i & 0x0c )
717      {
718         case 0x04: antic.uc_210b2[i*2] |= PF0; break;
719         case 0x08: antic.uc_210b2[i*2] |= PF1; break;
720         case 0x0c: antic.uc_210b2[i*2] |= PF2; break;
721      }
722      switch( i & 0x30 )
723      {
724         case 0x10: antic.uc_210b2[i*2] |= PF0; break;
725         case 0x20: antic.uc_210b2[i*2] |= PF1; break;
726         case 0x30: antic.uc_210b2[i*2] |= PF2; break;
727      }
728      switch( i & 0xc0 )
729      {
730         case 0x40: antic.uc_210b2[i*2] |= PF0; break;
731         case 0x80: antic.uc_210b2[i*2] |= PF1; break;
732         case 0xc0: antic.uc_210b2[i*2] |= PF2; break;
733      }
734     
735      /* used colors in graphics mode F */
736      if( i )
737         antic.uc_1b[i] |= PF1;
738     
739      /* used colors in GTIA graphics modes */
740      /* GTIA 1 is 16 different luminances with hue of colbk */
741      antic.uc_g1[i] = 0x00;
742      /* GTIA 2 is all 9 colors (8..15 is colbk) */
743      switch( i & 0x0f )
744      {
745         case 0x00: antic.uc_g2[i] = 0x10; break;
746         case 0x01: antic.uc_g2[i] = 0x20; break;
747         case 0x02: antic.uc_g2[i] = 0x40; break;
748         case 0x03: antic.uc_g2[i] = 0x80; break;
749         case 0x04: antic.uc_g2[i] = 0x01; break;
750         case 0x05: antic.uc_g2[i] = 0x02; break;
751         case 0x06: antic.uc_g2[i] = 0x04; break;
752         case 0x07: antic.uc_g2[i] = 0x08; break;
753         default:   antic.uc_g2[i] = 0x00;
754      }
755     
756      /* GTIA 3 is 16 different hues with luminance of colbk */
757      antic.uc_g3[i] = 0x00;
758   }
759}
760
761
762
78763ANTIC antic;
79764
80765void antic_start(running_machine &machine)
r31966r31967
84769   machine.save().save_pointer(NAME((UINT8 *) &antic.w), sizeof(antic.w));
85770}
86771
772void antic_vstart(running_machine &machine)
773{   
774   LOG(("atari antic_vh_start\n"));
775   memset(&antic, 0, sizeof(antic));
776   
777   antic.bitmap = auto_bitmap_ind16_alloc(machine, machine.first_screen()->width(), machine.first_screen()->height());
778   
779   antic.cclk_expand = auto_alloc_array(machine, UINT32, 21 * 256);
780   
781   antic.pf_21       = &antic.cclk_expand[ 0 * 256];
782   antic.pf_x10b     = &antic.cclk_expand[ 1 * 256];
783   antic.pf_3210b2   = &antic.cclk_expand[ 3 * 256];
784   antic.pf_210b4    = &antic.cclk_expand[11 * 256];
785   antic.pf_210b2    = &antic.cclk_expand[15 * 256];
786   antic.pf_1b       = &antic.cclk_expand[17 * 256];
787   antic.pf_gtia1    = &antic.cclk_expand[18 * 256];
788   antic.pf_gtia2    = &antic.cclk_expand[19 * 256];
789   antic.pf_gtia3    = &antic.cclk_expand[20 * 256];
790   
791   antic.used_colors = auto_alloc_array(machine, UINT8, 21 * 256);
792   
793   memset(antic.used_colors, 0, 21 * 256 * sizeof(UINT8));
794   
795   antic.uc_21       = &antic.used_colors[ 0 * 256];
796   antic.uc_x10b     = &antic.used_colors[ 1 * 256];
797   antic.uc_3210b2   = &antic.used_colors[ 3 * 256];
798   antic.uc_210b4    = &antic.used_colors[11 * 256];
799   antic.uc_210b2    = &antic.used_colors[15 * 256];
800   antic.uc_1b       = &antic.used_colors[17 * 256];
801   antic.uc_g1       = &antic.used_colors[18 * 256];
802   antic.uc_g2       = &antic.used_colors[19 * 256];
803   antic.uc_g3       = &antic.used_colors[20 * 256];
804   
805   LOG(("atari cclk_init\n"));
806   cclk_init();
807   
808   for (int i = 0; i < 64; i++)
809      antic.prio_table[i] = auto_alloc_array(machine, UINT8, 8*256);
810   
811   LOG(("atari prio_init\n"));
812   prio_init();
813   
814   for (int i = 0; i < machine.first_screen()->height(); i++)
815      antic.video[i] = auto_alloc_clear(machine, VIDEO);
816}
817
87818/**************************************************************
88819 *
89820 * Reset ANTIC

Previous 199869 Revisions Next


© 1997-2024 The MAME Team