1 // Gigas / Freekick / Counter Run / Perfect Billiard for FBA, ported by vbt, based on driver by Tomasz Slanina and David Haywood
2 
3 #include "tiles_generic.h"
4 #include "z80_intf.h"
5 #include "driver.h"
6 #include "bitswap.h"
7 #include "sn76496.h"
8 #include "mc8123.h"
9 #include "8255ppi.h"
10 
11 static UINT8 DrvJoy1[8];
12 static UINT8 DrvJoy2[8];
13 
14 static UINT8 DrvInputs[2];
15 static UINT8 DrvDip[3];
16 static INT16 DrvDial1;
17 static INT16 DrvDial2;
18 static UINT8 DrvReset;
19 
20 static UINT8 DrvRecalc;
21 
22 static UINT8 *AllMem;
23 static UINT8 *MemEnd;
24 static UINT8 *AllRam;
25 static UINT8 *RamEnd;
26 static UINT8 *DrvRAM;
27 static UINT8 *DrvMainROM;
28 static UINT8 *DrvMainROMdec;
29 static UINT8 *DrvSndROM;
30 static UINT8 *DrvVidRAM;
31 static UINT8 *DrvSprRAM;
32 static UINT8 *DrvColRAM;
33 static UINT8 *DrvGfxROM0;
34 static UINT8 *DrvGfxROM1;
35 static UINT8 *DrvColPROM;
36 static UINT8 *MC8123Key;
37 static UINT32 *DrvPalette;
38 static UINT8 DrvZ80Bank0;
39 typedef void (*RenderSprite)(INT32);
40 static RenderSprite DrawSprite;
41 
42 static UINT8 nmi_enable;
43 static UINT8 flipscreen;
44 static UINT8 coin;
45 static UINT8 spinner;
46 static UINT8 ff_data;
47 static UINT16 romaddr;
48 
49 static UINT8 use_encrypted = 0;
50 static UINT8 countrunbmode = 0;
51 static UINT8 pbillrdmode = 0;
52 
53 static void DrvPaletteInit();
54 
55 static struct BurnInputInfo PbillrdInputList[] = {
56 	{"P1 Coin",		BIT_DIGITAL,	DrvJoy1 + 7,	"p1 coin"},
57 	{"P1 Start",		BIT_DIGITAL,	DrvJoy1 + 6,	"p1 start"},
58 	{"P1 Up",		BIT_DIGITAL,	DrvJoy1 + 5,	"p1 up"},
59 	{"P1 Down",		BIT_DIGITAL,	DrvJoy1 + 4,	"p1 down"},
60 	{"P1 Left",		BIT_DIGITAL,	DrvJoy1 + 3,	"p1 left"},
61 	{"P1 Right",		BIT_DIGITAL,	DrvJoy1 + 2,	"p1 right"},
62 	{"P1 Button 1",		BIT_DIGITAL,	DrvJoy1 + 0,	"p1 fire 1"},
63 	{"P1 Button 2",		BIT_DIGITAL,	DrvJoy1 + 1,	"p1 fire 2"},
64 
65 	{"P2 Coin",		BIT_DIGITAL,	DrvJoy2 + 7,	"p2 coin"},
66 	{"P2 Start",		BIT_DIGITAL,	DrvJoy2 + 6,	"p2 start"},
67 	{"P2 Up",		BIT_DIGITAL,	DrvJoy2 + 5,	"p2 up"},
68 	{"P2 Down",		BIT_DIGITAL,	DrvJoy2 + 4,	"p2 down"},
69 	{"P2 Left",		BIT_DIGITAL,	DrvJoy2 + 3,	"p2 left"},
70 	{"P2 Right",		BIT_DIGITAL,	DrvJoy2 + 2,	"p2 right"},
71 	{"P2 Button 1",		BIT_DIGITAL,	DrvJoy2 + 0,	"p2 fire 1"},
72 	{"P2 Button 2",		BIT_DIGITAL,	DrvJoy2 + 1,	"p2 fire 2"},
73 
74 	{"Reset",		BIT_DIGITAL,	&DrvReset,	"reset"},
75 	{"Dip A",		BIT_DIPSWITCH,	DrvDip + 0,	"dip"},
76 	{"Dip B",		BIT_DIPSWITCH,	DrvDip + 1,	"dip"},
77 };
78 
79 STDINPUTINFO(Pbillrd)
80 
81 
82 static struct BurnDIPInfo PbillrdDIPList[]=
83 {
84 	{0x11, 0xff, 0xff, 0x1f, NULL		},
85 	{0x12, 0xff, 0xff, 0xff, NULL		},
86 
87 	{0   , 0xfe, 0   ,    2, "Balls"		},
88 	{0x11, 0x01, 0x01, 0x01, "3"		},
89 	{0x11, 0x01, 0x01, 0x00, "5"		},
90 
91 	{0   , 0xfe, 0   ,    4, "Bonus Ball"		},
92 	{0x11, 0x01, 0x06, 0x06, "10000, 30000 & 50000 Points"		},
93 	{0x11, 0x01, 0x06, 0x02, "20000 & 60000 Points"		},
94 	{0x11, 0x01, 0x06, 0x04, "30000 & 80000 Points"		},
95 	{0x11, 0x01, 0x06, 0x00, "Only 20000 Points"		},
96 
97 	{0   , 0xfe, 0   ,    2, "Allow Continue"		},
98 	{0x11, 0x01, 0x10, 0x00, "No"		},
99 	{0x11, 0x01, 0x10, 0x10, "Yes"		},
100 
101 	{0   , 0xfe, 0   ,    2, "Shot"		},
102 	{0x11, 0x01, 0x20, 0x00, "2"		},
103 	{0x11, 0x01, 0x20, 0x20, "3"		},
104 
105 	{0   , 0xfe, 0   ,    2, "Cabinet"		},
106 	{0x11, 0x01, 0x40, 0x00, "Upright"		},
107 	{0x11, 0x01, 0x40, 0x40, "Cocktail"		},
108 
109 	{0   , 0xfe, 0   ,    2, "Flip Screen"		},
110 	{0x11, 0x01, 0x80, 0x00, "Off"		},
111 	{0x11, 0x01, 0x80, 0x80, "On"		},
112 
113 	{0   , 0xfe, 0   ,   16, "Coin A"		},
114 	{0x12, 0x01, 0x0f, 0x00, "5 Coins 1 Credits"		},
115 	{0x12, 0x01, 0x0f, 0x0c, "4 Coins 1 Credits"		},
116 	{0x12, 0x01, 0x0f, 0x0e, "3 Coins 1 Credits"		},
117 	{0x12, 0x01, 0x0f, 0x05, "2 Coins 1 Credits"		},
118 	{0x12, 0x01, 0x0f, 0x06, "3 Coins 2 Credits"		},
119 	{0x12, 0x01, 0x0f, 0x04, "4 Coins 3 Credits"		},
120 	{0x12, 0x01, 0x0f, 0x0f, "1 Coin  1 Credits"		},
121 	{0x12, 0x01, 0x0f, 0x08, "4 Coins 5 Credits"		},
122 	{0x12, 0x01, 0x0f, 0x0a, "3 Coins 4 Credits"		},
123 	{0x12, 0x01, 0x0f, 0x09, "2 Coins 3 Credits"		},
124 	{0x12, 0x01, 0x0f, 0x02, "3 Coins/5 Credits"		},
125 	{0x12, 0x01, 0x0f, 0x07, "1 Coin  2 Credits"		},
126 	{0x12, 0x01, 0x0f, 0x01, "2 Coins 5 Credits"		},
127 	{0x12, 0x01, 0x0f, 0x0b, "1 Coin  3 Credits"		},
128 	{0x12, 0x01, 0x0f, 0x03, "1 Coin  4 Credits"		},
129 	{0x12, 0x01, 0x0f, 0x0d, "1 Coin  5 Credits"		},
130 
131 	{0   , 0xfe, 0   ,    16, "Coin B"		},
132 	{0x12, 0x01, 0xf0, 0x00, "5 Coins 1 Credits"		},
133 	{0x12, 0x01, 0xf0, 0xc0, "4 Coins 1 Credits"		},
134 	{0x12, 0x01, 0xf0, 0xe0, "3 Coins 1 Credits"		},
135 	{0x12, 0x01, 0xf0, 0x50, "2 Coins 1 Credits"		},
136 	{0x12, 0x01, 0xf0, 0x60, "3 Coins 2 Credits"		},
137 	{0x12, 0x01, 0xf0, 0x40, "4 Coins 3 Credits"		},
138 	{0x12, 0x01, 0xf0, 0xf0, "1 Coin  1 Credits"		},
139 	{0x12, 0x01, 0xf0, 0x80, "4 Coins 5 Credits"		},
140 	{0x12, 0x01, 0xf0, 0xa0, "3 Coins 4 Credits"		},
141 	{0x12, 0x01, 0xf0, 0x90, "2 Coins 3 Credits"		},
142 	{0x12, 0x01, 0xf0, 0x20, "3 Coins/5 Credits"		},
143 	{0x12, 0x01, 0xf0, 0x70, "1 Coin  2 Credits"		},
144 	{0x12, 0x01, 0xf0, 0x10, "2 Coins 5 Credits"		},
145 	{0x12, 0x01, 0xf0, 0xb0, "1 Coin  3 Credits"		},
146 	{0x12, 0x01, 0xf0, 0x30, "1 Coin  4 Credits"		},
147 	{0x12, 0x01, 0xf0, 0xd0, "1 Coin  5 Credits"		},
148 };
149 
150 STDDIPINFO(Pbillrd)
151 
152 static struct BurnInputInfo GigasInputList[] = {
153 
154 	{"P1 Coin",		BIT_DIGITAL,	DrvJoy1 + 7,	"p1 coin"},
155 	{"P1 Start",		BIT_DIGITAL,	DrvJoy1 + 6,	"p1 start"},
156 	{"P1 Left",		BIT_DIGITAL,	DrvJoy1 + 3,	"p1 left"},
157 	{"P1 Right",		BIT_DIGITAL,	DrvJoy1 + 2,	"p1 right"},
158 	{"P1 Button 1",		BIT_DIGITAL,	DrvJoy1 + 0,	"p1 fire 1"},
159 	{"P1 Button 2",		BIT_DIGITAL,	DrvJoy1 + 1,	"p1 fire 2"},
160 
161 	{"P2 Coin",		BIT_DIGITAL,	DrvJoy2 + 7,	"p2 coin"},
162 	{"P2 Start",		BIT_DIGITAL,	DrvJoy2 + 6,	"p2 start"},
163 	{"P2 Left",		BIT_DIGITAL,	DrvJoy2 + 3,	"p2 left"},
164 	{"P2 Right",		BIT_DIGITAL,	DrvJoy2 + 2,	"p2 right"},
165 	{"P2 Button 1",		BIT_DIGITAL,	DrvJoy2 + 0,	"p2 fire 1"},
166 	{"P2 Button 2",		BIT_DIGITAL,	DrvJoy2 + 1,	"p2 fire 2"},
167 
168 	{"Reset",		BIT_DIGITAL,	&DrvReset,	"reset"},
169 	{"Dip A",		BIT_DIPSWITCH,	DrvDip + 0,	"dip"},
170 	{"Dip B",		BIT_DIPSWITCH,	DrvDip + 1,	"dip"},
171 	{"Dip C",		BIT_DIPSWITCH,	DrvDip + 2,	"dip"},
172 };
173 
174 STDINPUTINFO(Gigas)
175 
176 static struct BurnDIPInfo GigasDIPList[]=
177 {
178 	{0x0d, 0xff, 0xff, 0x3f, NULL		},
179 	{0x0e, 0xff, 0xff, 0xff, NULL		},
180 
181 	{0   , 0xfe, 0   ,    2, "Lives"		},
182 	{0x0d, 0x01, 0x01, 0x01, "3"		},
183 	{0x0d, 0x01, 0x01, 0x00, "5"		},
184 
185 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
186 	{0x0d, 0x01, 0x06, 0x06, "20000 & 60000, Every 60000 Points"		},
187 	{0x0d, 0x01, 0x06, 0x02, "20000 & 60000 Points"		},
188 	{0x0d, 0x01, 0x06, 0x04, "30000 & 80000, Every 80000 Points"		},
189 	{0x0d, 0x01, 0x06, 0x00, "Only 20000 Points"		},
190 
191 	{0   , 0xfe, 0   ,    4, "Difficulty"		},
192 	{0x0d, 0x01, 0x18, 0x18, "Easy"		},
193 	{0x0d, 0x01, 0x18, 0x10, "Normal"		},
194 	{0x0d, 0x01, 0x18, 0x08, "Hard"		},
195 	{0x0d, 0x01, 0x18, 0x00, "Hardest"		},
196 
197 	{0   , 0xfe, 0   ,    2, "Allow Continue"		},
198 	{0x0d, 0x01, 0x20, 0x00, "No"		},
199 	{0x0d, 0x01, 0x20, 0x20, "Yes"		},
200 
201 	{0   , 0xfe, 0   ,    2, "Cabinet"		},
202 	{0x0d, 0x01, 0x40, 0x00, "Upright"		},
203 	{0x0d, 0x01, 0x40, 0x40, "Cocktail"		},
204 
205 	{0   , 0xfe, 0   ,    2, "Flip Screen"		},
206 	{0x0d, 0x01, 0x80, 0x00, "Off"		},
207 	{0x0d, 0x01, 0x80, 0x80, "On"		},
208 
209 	{0   , 0xfe, 0   ,   16, "Coin A"		},
210 	{0x0e, 0x01, 0x0f, 0x00, "5 Coins 1 Credits"		},
211 	{0x0e, 0x01, 0x0f, 0x0c, "4 Coins 1 Credits"		},
212 	{0x0e, 0x01, 0x0f, 0x0e, "3 Coins 1 Credits"		},
213 	{0x0e, 0x01, 0x0f, 0x05, "2 Coins 1 Credits"		},
214 	{0x0e, 0x01, 0x0f, 0x06, "3 Coins 2 Credits"		},
215 	{0x0e, 0x01, 0x0f, 0x04, "4 Coins 3 Credits"		},
216 	{0x0e, 0x01, 0x0f, 0x0f, "1 Coin  1 Credits"		},
217 	{0x0e, 0x01, 0x0f, 0x08, "4 Coins 5 Credits"		},
218 	{0x0e, 0x01, 0x0f, 0x0a, "3 Coins 4 Credits"		},
219 	{0x0e, 0x01, 0x0f, 0x09, "2 Coins 3 Credits"		},
220 	{0x0e, 0x01, 0x0f, 0x02, "3 Coins/5 Credits"		},
221 	{0x0e, 0x01, 0x0f, 0x07, "1 Coin  2 Credits"		},
222 	{0x0e, 0x01, 0x0f, 0x01, "2 Coins 5 Credits"		},
223 	{0x0e, 0x01, 0x0f, 0x0b, "1 Coin  3 Credits"		},
224 	{0x0e, 0x01, 0x0f, 0x03, "1 Coin  4 Credits"		},
225 	{0x0e, 0x01, 0x0f, 0x0d, "1 Coin  5 Credits"		},
226 
227 	{0   , 0xfe, 0   ,    16, "Coin B"		},
228 	{0x0e, 0x01, 0xf0, 0x00, "5 Coins 1 Credits"		},
229 	{0x0e, 0x01, 0xf0, 0xc0, "4 Coins 1 Credits"		},
230 	{0x0e, 0x01, 0xf0, 0xe0, "3 Coins 1 Credits"		},
231 	{0x0e, 0x01, 0xf0, 0x50, "2 Coins 1 Credits"		},
232 	{0x0e, 0x01, 0xf0, 0x60, "3 Coins 2 Credits"		},
233 	{0x0e, 0x01, 0xf0, 0x40, "4 Coins 3 Credits"		},
234 	{0x0e, 0x01, 0xf0, 0xf0, "1 Coin  1 Credits"		},
235 	{0x0e, 0x01, 0xf0, 0x80, "4 Coins 5 Credits"		},
236 	{0x0e, 0x01, 0xf0, 0xa0, "3 Coins 4 Credits"		},
237 	{0x0e, 0x01, 0xf0, 0x90, "2 Coins 3 Credits"		},
238 	{0x0e, 0x01, 0xf0, 0x20, "3 Coins/5 Credits"		},
239 	{0x0e, 0x01, 0xf0, 0x70, "1 Coin  2 Credits"		},
240 	{0x0e, 0x01, 0xf0, 0x10, "2 Coins 5 Credits"		},
241 	{0x0e, 0x01, 0xf0, 0xb0, "1 Coin  3 Credits"		},
242 	{0x0e, 0x01, 0xf0, 0x30, "1 Coin  4 Credits"		},
243 	{0x0e, 0x01, 0xf0, 0xd0, "1 Coin  5 Credits"		},
244 };
245 
246 STDDIPINFO(Gigas)
247 
248 static struct BurnDIPInfo Gigasm2DIPList[]=
249 {
250 	{0x0d, 0xff, 0xff, 0x3f, NULL		},
251 	{0x0e, 0xff, 0xff, 0xff, NULL		},
252 
253 	{0   , 0xfe, 0   ,    2, "Lives"		},
254 	{0x0d, 0x01, 0x01, 0x01, "3"		},
255 	{0x0d, 0x01, 0x01, 0x00, "5"		},
256 
257 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
258 	{0x0d, 0x01, 0x06, 0x06, "20000 & 60000, Every 60000 Points"		},
259 	{0x0d, 0x01, 0x06, 0x02, "20000 & 60000 Points"		},
260 	{0x0d, 0x01, 0x06, 0x04, "30000 & 80000, Every 80000 Points"		},
261 	{0x0d, 0x01, 0x06, 0x00, "Only 20000 Points"		},
262 
263 	{0   , 0xfe, 0   ,    4, "Difficulty"		},
264 	{0x0d, 0x01, 0x18, 0x18, "Easy"		},
265 	{0x0d, 0x01, 0x18, 0x10, "Normal"		},
266 	{0x0d, 0x01, 0x18, 0x08, "Hard"		},
267 	{0x0d, 0x01, 0x18, 0x00, "Hardest"		},
268 
269 	{0   , 0xfe, 0   ,    2, "Allow Continue"		},
270 	{0x0d, 0x01, 0x20, 0x00, "No"		},
271 	{0x0d, 0x01, 0x20, 0x20, "Yes"		},
272 
273 	{0   , 0xfe, 0   ,    2, "Cabinet"		},
274 	{0x0d, 0x01, 0x40, 0x00, "Upright"		},
275 	{0x0d, 0x01, 0x40, 0x40, "Cocktail"		},
276 
277 	{0   , 0xfe, 0   ,    2, "Flip Screen"		},
278 	{0x0d, 0x01, 0x80, 0x00, "Off"		},
279 	{0x0d, 0x01, 0x80, 0x80, "On"		},
280 
281 	{0   , 0xfe, 0   ,   16, "Coin A"		},
282 	{0x0e, 0x01, 0x0f, 0x00, "5 Coins 1 Credits"		},
283 	{0x0e, 0x01, 0x0f, 0x0c, "4 Coins 1 Credits"		},
284 	{0x0e, 0x01, 0x0f, 0x0e, "3 Coins 1 Credits"		},
285 	{0x0e, 0x01, 0x0f, 0x05, "2 Coins 1 Credits"		},
286 	{0x0e, 0x01, 0x0f, 0x06, "3 Coins 2 Credits"		},
287 	{0x0e, 0x01, 0x0f, 0x04, "4 Coins 3 Credits"		},
288 	{0x0e, 0x01, 0x0f, 0x0f, "1 Coin  1 Credits"		},
289 	{0x0e, 0x01, 0x0f, 0x08, "4 Coins 5 Credits"		},
290 	{0x0e, 0x01, 0x0f, 0x0a, "3 Coins 4 Credits"		},
291 	{0x0e, 0x01, 0x0f, 0x09, "2 Coins 3 Credits"		},
292 	{0x0e, 0x01, 0x0f, 0x02, "3 Coins/5 Credits"		},
293 	{0x0e, 0x01, 0x0f, 0x07, "1 Coin  2 Credits"		},
294 	{0x0e, 0x01, 0x0f, 0x01, "2 Coins 5 Credits"		},
295 	{0x0e, 0x01, 0x0f, 0x0b, "1 Coin  3 Credits"		},
296 	{0x0e, 0x01, 0x0f, 0x03, "1 Coin  4 Credits"		},
297 	{0x0e, 0x01, 0x0f, 0x0d, "1 Coin  5 Credits"		},
298 
299 	{0   , 0xfe, 0   ,    16, "Coin B"		},
300 	{0x0e, 0x01, 0xf0, 0x00, "5 Coins 1 Credits"		},
301 	{0x0e, 0x01, 0xf0, 0xc0, "4 Coins 1 Credits"		},
302 	{0x0e, 0x01, 0xf0, 0xe0, "3 Coins 1 Credits"		},
303 	{0x0e, 0x01, 0xf0, 0x50, "2 Coins 1 Credits"		},
304 	{0x0e, 0x01, 0xf0, 0x60, "3 Coins 2 Credits"		},
305 	{0x0e, 0x01, 0xf0, 0x40, "4 Coins 3 Credits"		},
306 	{0x0e, 0x01, 0xf0, 0xf0, "1 Coin  1 Credits"		},
307 	{0x0e, 0x01, 0xf0, 0x80, "4 Coins 5 Credits"		},
308 	{0x0e, 0x01, 0xf0, 0xa0, "3 Coins 4 Credits"		},
309 	{0x0e, 0x01, 0xf0, 0x90, "2 Coins 3 Credits"		},
310 	{0x0e, 0x01, 0xf0, 0x20, "3 Coins/5 Credits"		},
311 	{0x0e, 0x01, 0xf0, 0x70, "1 Coin  2 Credits"		},
312 	{0x0e, 0x01, 0xf0, 0x10, "2 Coins 5 Credits"		},
313 	{0x0e, 0x01, 0xf0, 0xb0, "1 Coin  3 Credits"		},
314 	{0x0e, 0x01, 0xf0, 0x30, "1 Coin  4 Credits"		},
315 	{0x0e, 0x01, 0xf0, 0xd0, "1 Coin  5 Credits"		},
316 };
317 
318 STDDIPINFO(Gigasm2)
319 
320 static struct BurnDIPInfo OmegaDIPList[]=
321 {
322 	{0x0d, 0xff, 0xff, 0x06, NULL		},
323 	{0x0e, 0xff, 0xff, 0xff, NULL		},
324 	{0x0f, 0xff, 0xff, 0xc3, NULL		},
325 
326 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
327 	{0x0d, 0x01, 0x06, 0x06, "20000 & 60000, Every 60000 Points"		},
328 	{0x0d, 0x01, 0x06, 0x02, "30000 & 80000, Every 80000 Points"		},
329 	{0x0d, 0x01, 0x06, 0x04, "20000 & 60000 Points"		},
330 	{0x0d, 0x01, 0x06, 0x00, "Only 20000 Points"		},
331 
332 	{0   , 0xfe, 0   ,    16, "Coin A"		},
333 	{0x0e, 0x01, 0x0f, 0x00, "5 Coins 1 Credits"		},
334 	{0x0e, 0x01, 0x0f, 0x0e, "3 Coins 1 Credits"		},
335 	{0x0e, 0x01, 0x0f, 0x05, "2 Coins 1 Credits"		},
336 	{0x0e, 0x01, 0x0f, 0x06, "3 Coins 2 Credits"		},
337 	{0x0e, 0x01, 0x0f, 0x0f, "1 Coin  1 Credits"		},
338 	{0x0e, 0x01, 0x0f, 0x0a, "3 Coins 4 Credits"		},
339 	{0x0e, 0x01, 0x0f, 0x09, "2 Coins 3 Credits"		},
340 	{0x0e, 0x01, 0x0f, 0x02, "3 Coins/5 Credits"		},
341 	{0x0e, 0x01, 0x0f, 0x07, "1 Coin  2 Credits"		},
342 	{0x0e, 0x01, 0x0f, 0x01, "2 Coins 5 Credits"		},
343 	{0x0e, 0x01, 0x0f, 0x0b, "1 Coin  3 Credits"		},
344 	{0x0e, 0x01, 0x0f, 0x03, "1 Coin  4 Credits"		},
345 	{0x0e, 0x01, 0x0f, 0x0d, "1 Coin  5 Credits"		},
346 	{0x0e, 0x01, 0x0f, 0x0c, "1 Coin/10 Credits"		},
347 	{0x0e, 0x01, 0x0f, 0x04, "1 Coin/25 Credits"		},
348 	{0x0e, 0x01, 0x0f, 0x08, "1 Coin/50 Credits"		},
349 
350 	{0   , 0xfe, 0   ,    16, "Coin B"		},
351 	{0x0e, 0x01, 0xf0, 0x00, "5 Coins 1 Credits"		},
352 	{0x0e, 0x01, 0xf0, 0xe0, "3 Coins 1 Credits"		},
353 	{0x0e, 0x01, 0xf0, 0x50, "2 Coins 1 Credits"		},
354 	{0x0e, 0x01, 0xf0, 0x60, "3 Coins 2 Credits"		},
355 	{0x0e, 0x01, 0xf0, 0xf0, "1 Coin  1 Credits"		},
356 	{0x0e, 0x01, 0xf0, 0xa0, "3 Coins 4 Credits"		},
357 	{0x0e, 0x01, 0xf0, 0x90, "2 Coins 3 Credits"		},
358 	{0x0e, 0x01, 0xf0, 0x20, "3 Coins/5 Credits"		},
359 	{0x0e, 0x01, 0xf0, 0x70, "1 Coin  2 Credits"		},
360 	{0x0e, 0x01, 0xf0, 0x10, "2 Coins 5 Credits"		},
361 	{0x0e, 0x01, 0xf0, 0xb0, "1 Coin  3 Credits"		},
362 	{0x0e, 0x01, 0xf0, 0x30, "1 Coin  4 Credits"		},
363 	{0x0e, 0x01, 0xf0, 0xd0, "1 Coin  5 Credits"		},
364 	{0x0e, 0x01, 0xf0, 0xc0, "1 Coin/10 Credits"		},
365 	{0x0e, 0x01, 0xf0, 0x40, "1 Coin/25 Credits"		},
366 	{0x0e, 0x01, 0xf0, 0x80, "1 Coin/50 Credits"		},
367 
368 	{0   , 0xfe, 0   ,    2, "Hopper Status?"		},
369 	{0x0f, 0x01, 0x01, 0x01, "Off"		},
370 	{0x0f, 0x01, 0x01, 0x00, "On"		},
371 
372 	{0   , 0xfe, 0   ,    2, "Invulnerability"		},
373 	{0x0f, 0x01, 0x02, 0x02, "Off"		},
374 	{0x0f, 0x01, 0x02, 0x00, "On"		},
375 
376 	{0   , 0xfe, 0   ,    4, "Prize Version"		},
377 	{0x0f, 0x01, 0xc0, 0xc0, "Off"		},
378 	{0x0f, 0x01, 0xc0, 0x80, "On Setting 1"		},
379 	{0x0f, 0x01, 0xc0, 0x40, "On Setting 2"		},
380 	{0x0f, 0x01, 0xc0, 0x00, "On Setting 3"		},
381 };
382 
383 STDDIPINFO(Omega)
384 
385 static struct BurnInputInfo FreekckInputList[] = {
386 	{"P1 Coin",		BIT_DIGITAL,	DrvJoy1 + 7,	"p1 coin"},
387 	{"P1 Start",		BIT_DIGITAL,	DrvJoy1 + 6,	"p1 start"},
388 	{"P1 Up",		BIT_DIGITAL,	DrvJoy1 + 5,	"p1 up"},
389 	{"P1 Down",		BIT_DIGITAL,	DrvJoy1 + 4,	"p1 down"},
390 	{"P1 Left",		BIT_DIGITAL,	DrvJoy1 + 3,	"p1 left"},
391 	{"P1 Right",		BIT_DIGITAL,	DrvJoy1 + 2,	"p1 right"},
392 	{"P1 Button 1",		BIT_DIGITAL,	DrvJoy1 + 1,	"p1 fire 1"},
393 	{"P1 Button 2",		BIT_DIGITAL,	DrvJoy1 + 0,	"p1 fire 2"},
394 
395 	{"P2 Coin",		BIT_DIGITAL,	DrvJoy2 + 7,	"p2 coin"},
396 	{"P2 Start",		BIT_DIGITAL,	DrvJoy2 + 6,	"p2 start"},
397 	{"P2 Up",		BIT_DIGITAL,	DrvJoy2 + 5,	"p2 up"},
398 	{"P2 Down",		BIT_DIGITAL,	DrvJoy2 + 4,	"p2 down"},
399 	{"P2 Left",		BIT_DIGITAL,	DrvJoy2 + 3,	"p2 left"},
400 	{"P2 Right",		BIT_DIGITAL,	DrvJoy2 + 2,	"p2 right"},
401 	{"P2 Button 1",		BIT_DIGITAL,	DrvJoy2 + 1,	"p2 fire 1"},
402 	{"P2 Button 2",		BIT_DIGITAL,	DrvJoy2 + 0,	"p2 fire 2"},
403 
404 	{"Reset",		BIT_DIGITAL,	&DrvReset,	"reset"},
405 	{"Dip A",		BIT_DIPSWITCH,	DrvDip + 0,	"dip"},
406 	{"Dip B",		BIT_DIPSWITCH,	DrvDip + 1,	"dip"},
407 	{"Dip C",		BIT_DIPSWITCH,	DrvDip + 2,	"dip"},
408 };
409 
410 STDINPUTINFO(Freekck)
411 
412 
413 static struct BurnDIPInfo FreekckDIPList[]=
414 {
415 	{0x11, 0xff, 0xff, 0xbf, NULL		},
416 	{0x12, 0xff, 0xff, 0xff, NULL		},
417 	{0x13, 0xff, 0xff, 0xfe, NULL		},
418 
419 	{0   , 0xfe, 0   ,    2, "Lives"		},
420 	{0x11, 0x01, 0x01, 0x01, "3"		},
421 	{0x11, 0x01, 0x01, 0x00, "5"		},
422 
423 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
424 	{0x11, 0x01, 0x06, 0x06, "2-3-4-5-60000 Points"		},
425 	{0x11, 0x01, 0x06, 0x02, "3-4-5-6-7-80000 Points"		},
426 	{0x11, 0x01, 0x06, 0x04, "20000 & 60000 Points"		},
427 	{0x11, 0x01, 0x06, 0x00, "ONLY 20000 Points"		},
428 
429 	{0   , 0xfe, 0   ,    4, "Difficulty"		},
430 	{0x11, 0x01, 0x18, 0x18, "Easy"		},
431 	{0x11, 0x01, 0x18, 0x10, "Normal"		},
432 	{0x11, 0x01, 0x18, 0x08, "Hard"		},
433 	{0x11, 0x01, 0x18, 0x00, "Hardest"		},
434 
435 	{0   , 0xfe, 0   ,    2, "Allow Continue"		},
436 	{0x11, 0x01, 0x20, 0x00, "No"		},
437 	{0x11, 0x01, 0x20, 0x20, "Yes"		},
438 
439 	{0   , 0xfe, 0   ,    2, "Cabinet"		},
440 	{0x11, 0x01, 0x40, 0x00, "Upright"		},
441 	{0x11, 0x01, 0x40, 0x40, "Cocktail"		},
442 
443 	{0   , 0xfe, 0   ,    2, "Flip Screen"		},
444 	{0x11, 0x01, 0x80, 0x80, "Off"		},
445 	{0x11, 0x01, 0x80, 0x00, "On"		},
446 
447 	{0   , 0xfe, 0   ,    16, "Coin A"		},
448 	{0x12, 0x01, 0x0f, 0x00, "5 Coins 1 Credits"		},
449 	{0x12, 0x01, 0x0f, 0x0c, "4 Coins 1 Credits"		},
450 	{0x12, 0x01, 0x0f, 0x0e, "3 Coins 1 Credits"		},
451 	{0x12, 0x01, 0x0f, 0x05, "2 Coins 1 Credits"		},
452 	{0x12, 0x01, 0x0f, 0x06, "3 Coins 2 Credits"		},
453 	{0x12, 0x01, 0x0f, 0x04, "4 Coins 3 Credits"		},
454 	{0x12, 0x01, 0x0f, 0x0f, "1 Coin  1 Credits"		},
455 	{0x12, 0x01, 0x0f, 0x08, "4 Coins 5 Credits"		},
456 	{0x12, 0x01, 0x0f, 0x0a, "3 Coins 4 Credits"		},
457 	{0x12, 0x01, 0x0f, 0x09, "2 Coins 3 Credits"		},
458 	{0x12, 0x01, 0x0f, 0x02, "3 Coins/5 Credits"		},
459 	{0x12, 0x01, 0x0f, 0x07, "1 Coin  2 Credits"		},
460 	{0x12, 0x01, 0x0f, 0x01, "2 Coins 5 Credits"		},
461 	{0x12, 0x01, 0x0f, 0x0b, "1 Coin  3 Credits"		},
462 	{0x12, 0x01, 0x0f, 0x03, "1 Coin  4 Credits"		},
463 	{0x12, 0x01, 0x0f, 0x0d, "1 Coin  5 Credits"		},
464 
465 	{0   , 0xfe, 0   ,    16, "Coin B"		},
466 	{0x12, 0x01, 0xf0, 0x00, "5 Coins 1 Credits"		},
467 	{0x12, 0x01, 0xf0, 0xe0, "3 Coins 1 Credits"		},
468 	{0x12, 0x01, 0xf0, 0x50, "2 Coins 1 Credits"		},
469 	{0x12, 0x01, 0xf0, 0x60, "3 Coins 2 Credits"		},
470 	{0x12, 0x01, 0xf0, 0xf0, "1 Coin  1 Credits"		},
471 	{0x12, 0x01, 0xf0, 0xa0, "3 Coins 4 Credits"		},
472 	{0x12, 0x01, 0xf0, 0x90, "2 Coins 3 Credits"		},
473 	{0x12, 0x01, 0xf0, 0x20, "3 Coins/5 Credits"		},
474 	{0x12, 0x01, 0xf0, 0x70, "1 Coin  2 Credits"		},
475 	{0x12, 0x01, 0xf0, 0x10, "2 Coins 5 Credits"		},
476 	{0x12, 0x01, 0xf0, 0xb0, "1 Coin  3 Credits"		},
477 	{0x12, 0x01, 0xf0, 0x30, "1 Coin  4 Credits"		},
478 	{0x12, 0x01, 0xf0, 0xd0, "1 Coin  5 Credits"		},
479 	{0x12, 0x01, 0xf0, 0xc0, "1 Coin/10 Credits"		},
480 	{0x12, 0x01, 0xf0, 0x40, "1 Coin/25 Credits"		},
481 	{0x12, 0x01, 0xf0, 0x80, "1 Coin/50 Credits"		},
482 
483 	{0   , 0xfe, 0   ,    2, "Manufacturer"		},
484 	{0x13, 0x01, 0x01, 0x00, "Nihon System"		},
485 	{0x13, 0x01, 0x01, 0x01, "Sega/Nihon System"		},
486 
487 	{0   , 0xfe, 0   ,    0, "Coin Slots"		},
488 	{0x13, 0x01, 0x80, 0x00, "1"		},
489 	{0x13, 0x01, 0x80, 0x80, "2"		},
490 };
491 
492 STDDIPINFO(Freekck)
493 
494 static struct BurnInputInfo CountrunInputList[] = {
495 
496 	{"P1 Coin",		BIT_DIGITAL,	DrvJoy1 + 7,	"p1 coin"},
497 	{"P1 Start",		BIT_DIGITAL,	DrvJoy1 + 6,	"p1 start"},
498 	{"P1 Up",		BIT_DIGITAL,	DrvJoy1 + 5,	"p1 up"},
499 	{"P1 Down",		BIT_DIGITAL,	DrvJoy1 + 4,	"p1 down"},
500 	{"P1 Left",		BIT_DIGITAL,	DrvJoy1 + 3,	"p1 left"},
501 	{"P1 Right",		BIT_DIGITAL,	DrvJoy1 + 2,	"p1 right"},
502 	{"P1 Button 1",		BIT_DIGITAL,	DrvJoy1 + 1,	"p1 fire 1"},
503 	{"P1 Button 2",		BIT_DIGITAL,	DrvJoy1 + 0,	"p1 fire 2"},
504 
505 	{"P2 Coin",		BIT_DIGITAL,	DrvJoy2 + 7,	"p2 coin"},
506 	{"P2 Start",		BIT_DIGITAL,	DrvJoy2 + 6,	"p2 start"},
507 	{"P2 Up",		BIT_DIGITAL,	DrvJoy2 + 5,	"p2 up"},
508 	{"P2 Down",		BIT_DIGITAL,	DrvJoy2 + 4,	"p2 down"},
509 	{"P2 Left",		BIT_DIGITAL,	DrvJoy2 + 3,	"p2 left"},
510 	{"P2 Right",		BIT_DIGITAL,	DrvJoy2 + 2,	"p2 right"},
511 	{"P2 Button 1",		BIT_DIGITAL,	DrvJoy2 + 1,	"p2 fire 1"},
512 	{"P2 Button 2",		BIT_DIGITAL,	DrvJoy2 + 0,	"p2 fire 2"},
513 
514 	{"Reset",		BIT_DIGITAL,	&DrvReset,	"reset"},
515 	{"Dip A",		BIT_DIPSWITCH,	DrvDip + 0,	"dip"},
516 	{"Dip B",		BIT_DIPSWITCH,	DrvDip + 1,	"dip"},
517 	{"Dip C",		BIT_DIPSWITCH,	DrvDip + 2,	"dip"},
518 };
519 
520 STDINPUTINFO(Countrun)
521 
522 
523 static struct BurnDIPInfo CountrunDIPList[]=
524 {
525 	{0x11, 0xff, 0xff, 0xbf, NULL		},
526 	{0x12, 0xff, 0xff, 0xff, NULL		},
527 	{0x13, 0xff, 0xff, 0xfe, NULL		},
528 
529 	{0   , 0xfe, 0   ,    2, "Lives"		},
530 	{0x11, 0x01, 0x01, 0x01, "3"		},
531 	{0x11, 0x01, 0x01, 0x00, "2"		},
532 
533 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
534 	{0x11, 0x01, 0x06, 0x06, "20000, 60000 and every 60000 Points"		},
535 	{0x11, 0x01, 0x06, 0x02, "30000, 80000 and every 80000 Points"		},
536 	{0x11, 0x01, 0x06, 0x04, "20000 & 60000 Points"		},
537 	{0x11, 0x01, 0x06, 0x00, "ONLY 20000 Points"		},
538 
539 	{0   , 0xfe, 0   ,    4, "Difficulty"		},
540 	{0x11, 0x01, 0x18, 0x18, "Easy"		},
541 	{0x11, 0x01, 0x18, 0x10, "Normal"		},
542 	{0x11, 0x01, 0x18, 0x08, "Hard"		},
543 	{0x11, 0x01, 0x18, 0x00, "Hardest"		},
544 
545 	{0   , 0xfe, 0   ,    2, "Allow Continue"		},
546 	{0x11, 0x01, 0x20, 0x00, "No"		},
547 	{0x11, 0x01, 0x20, 0x20, "Yes"		},
548 
549 	{0   , 0xfe, 0   ,    2, "Cabinet"		},
550 	{0x11, 0x01, 0x40, 0x00, "Upright"		},
551 	{0x11, 0x01, 0x40, 0x40, "Cocktail"		},
552 
553 	{0   , 0xfe, 0   ,    2, "Flip Screen"		},
554 	{0x11, 0x01, 0x80, 0x80, "Off"		},
555 	{0x11, 0x01, 0x80, 0x00, "On"		},
556 
557 	{0   , 0xfe, 0   ,    16, "Coin A"		},
558 	{0x12, 0x01, 0x0f, 0x00, "5 Coins 1 Credits"		},
559 	{0x12, 0x01, 0x0f, 0x0c, "4 Coins 1 Credits"		},
560 	{0x12, 0x01, 0x0f, 0x0e, "3 Coins 1 Credits"		},
561 	{0x12, 0x01, 0x0f, 0x05, "2 Coins 1 Credits"		},
562 	{0x12, 0x01, 0x0f, 0x06, "3 Coins 2 Credits"		},
563 	{0x12, 0x01, 0x0f, 0x04, "4 Coins 3 Credits"		},
564 	{0x12, 0x01, 0x0f, 0x0f, "1 Coin  1 Credits"		},
565 	{0x12, 0x01, 0x0f, 0x08, "4 Coins 5 Credits"		},
566 	{0x12, 0x01, 0x0f, 0x0a, "3 Coins 4 Credits"		},
567 	{0x12, 0x01, 0x0f, 0x09, "2 Coins 3 Credits"		},
568 	{0x12, 0x01, 0x0f, 0x02, "3 Coins/5 Credits"		},
569 	{0x12, 0x01, 0x0f, 0x07, "1 Coin  2 Credits"		},
570 	{0x12, 0x01, 0x0f, 0x01, "2 Coins 5 Credits"		},
571 	{0x12, 0x01, 0x0f, 0x0b, "1 Coin  3 Credits"		},
572 	{0x12, 0x01, 0x0f, 0x03, "1 Coin  4 Credits"		},
573 	{0x12, 0x01, 0x0f, 0x0d, "1 Coin  5 Credits"		},
574 
575 	{0   , 0xfe, 0   ,    16, "Coin B"		},
576 	{0x12, 0x01, 0xf0, 0x00, "5 Coins 1 Credits"		},
577 	{0x12, 0x01, 0xf0, 0xe0, "3 Coins 1 Credits"		},
578 	{0x12, 0x01, 0xf0, 0x50, "2 Coins 1 Credits"		},
579 	{0x12, 0x01, 0xf0, 0x60, "3 Coins 2 Credits"		},
580 	{0x12, 0x01, 0xf0, 0xf0, "1 Coin  1 Credits"		},
581 	{0x12, 0x01, 0xf0, 0xa0, "3 Coins 4 Credits"		},
582 	{0x12, 0x01, 0xf0, 0x90, "2 Coins 3 Credits"		},
583 	{0x12, 0x01, 0xf0, 0x20, "3 Coins/5 Credits"		},
584 	{0x12, 0x01, 0xf0, 0x70, "1 Coin  2 Credits"		},
585 	{0x12, 0x01, 0xf0, 0x10, "2 Coins 5 Credits"		},
586 	{0x12, 0x01, 0xf0, 0xb0, "1 Coin  3 Credits"		},
587 	{0x12, 0x01, 0xf0, 0x30, "1 Coin  4 Credits"		},
588 	{0x12, 0x01, 0xf0, 0xd0, "1 Coin  5 Credits"		},
589 	{0x12, 0x01, 0xf0, 0xc0, "1 Coin/10 Credits"		},
590 	{0x12, 0x01, 0xf0, 0x40, "1 Coin/25 Credits"		},
591 	{0x12, 0x01, 0xf0, 0x80, "1 Coin/50 Credits"		},
592 
593 	{0   , 0xfe, 0   ,    2, "Manufacturer"		},
594 	{0x13, 0x01, 0x01, 0x00, "Nihon System"		},
595 	{0x13, 0x01, 0x01, 0x01, "Sega/Nihon System"		},
596 
597 	{0   , 0xfe, 0   ,    0, "Coin Slots"		},
598 	{0x13, 0x01, 0x80, 0x00, "1"		},
599 	{0x13, 0x01, 0x80, 0x80, "2"		},
600 
601 };
602 
STDDIPINFO(Countrun)603 STDDIPINFO(Countrun)
604 
605 static INT32 DrvDoReset()
606 {
607 	memset (AllRam, 0, RamEnd - AllRam);
608 	coin = 0;
609 	nmi_enable = 0;
610 	ff_data = 0;
611 	romaddr = 0;
612 	flipscreen = 0;
613 
614 	spinner = 0;
615 	DrvDial1 = 0;
616 	DrvDial2 = 0;
617 
618 	ZetOpen(0);
619 	ZetReset();
620 	ZetClose();
621 
622 	return 0;
623 }
624 
freekick_draw_sprite(INT32 offs)625 void freekick_draw_sprite(INT32 offs)
626 {
627 	INT32 sx = DrvSprRAM[offs + 3];
628 	INT32 sy = 232 - DrvSprRAM[offs + 0];
629 	INT32 code = DrvSprRAM[offs + 1] + ((DrvSprRAM[offs + 2] & 0x20) << 3);
630 
631 	INT32 flipx  = DrvSprRAM[offs + 2] & 0x80;    //?? unused ?
632 	INT32 flipy  = !(DrvSprRAM[offs + 2] & 0x40);
633 	INT32 color = DrvSprRAM[offs + 2] & 0x1f;
634 
635 	if (flipy)
636 	{
637 		if (flipx)
638 		{
639 			Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, code, sx, sy, color, 3, 0, 256, DrvGfxROM1);
640 		}
641 		else
642 		{
643 			Render16x16Tile_Mask_FlipY_Clip(pTransDraw, code, sx, sy, color, 3, 0, 256, DrvGfxROM1);
644 		}
645 	}
646 	else
647 	{
648 		if (flipx)
649 		{
650 			Render16x16Tile_Mask_FlipX_Clip(pTransDraw, code, sx, sy, color, 3, 0, 256, DrvGfxROM1);
651 		}
652 		else
653 		{
654 			Render16x16Tile_Mask_Clip(pTransDraw, code, sx, sy, color, 3, 0, 256, DrvGfxROM1);
655 		}
656 	}
657 }
658 
gigas_draw_sprite(INT32 offs)659 static void gigas_draw_sprite(INT32 offs)
660 {
661 	INT32 sx = DrvSprRAM[offs + 3];
662 	INT32 sy = DrvSprRAM[offs + 2];
663 	INT32 code = DrvSprRAM[offs + 0] | ((DrvSprRAM[offs + 1] & 0x20) << 3);
664 
665 	INT32 flipx = 0;
666 	INT32 flipy = 0;
667 	INT32 color = DrvSprRAM[offs + 1] & 0x1f;
668 
669 	if (pbillrdmode) {
670 		code = DrvSprRAM[offs + 0];
671 		color = DrvSprRAM[offs + 1] & 0x0f;
672 	}
673 
674 	if (0)
675 	{
676 		sx = 240 - sx;
677 		flipx = !flipx;
678 	}
679 	if (1)
680 	{
681 		sy = 224 - sy;
682 		flipy = !flipy;
683 	}
684 
685 	if (flipy)
686 	{
687 		if (flipx)
688 		{
689 			Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, code, sx, sy, color, 3, 0, 256, DrvGfxROM1);
690 		}
691 		else
692 		{
693 			Render16x16Tile_Mask_FlipY_Clip(pTransDraw, code, sx, sy, color, 3, 0, 256, DrvGfxROM1);
694 		}
695 	}
696 	else
697 	{
698 		if (flipx)
699 		{
700 			Render16x16Tile_Mask_FlipX_Clip(pTransDraw, code, sx, sy, color, 3, 0, 256, DrvGfxROM1);
701 		}
702 		else
703 		{
704 			Render16x16Tile_Mask_Clip(pTransDraw, code, sx, sy, color, 3, 0, 256, DrvGfxROM1);
705 		}
706 	}
707 }
708 
DrvDraw()709 static INT32 DrvDraw()
710 {
711 
712 	if (DrvRecalc)
713 	{
714 		DrvPaletteInit();
715 		DrvRecalc = 0;
716 	}
717 
718 	// Draw tiles
719 	for (INT32 offs = 0x3ff; offs >= 0; offs--)
720 	{
721 		INT32 sx = (offs % 32) * 8;
722 		INT32 sy = (offs / 32) * 8;
723 
724 		INT32 code  = DrvVidRAM[offs] + ((DrvVidRAM[offs + 0x400] & 0xe0) << 3);
725 		INT32 color = DrvVidRAM[offs + 0x400] & 0x1f;
726 		sy -= 16;
727 
728 		if(sy >= 0)
729 			Render8x8Tile_Clip(pTransDraw, code, sx, sy, color, 3, 0, DrvGfxROM0);
730 	}
731 
732 	for (INT32 offs = 0; offs < 0x100; offs += 4)
733 	{
734 		DrawSprite(offs);
735 	}
736 
737 	BurnTransferCopy(DrvPalette);
738 
739 	return 0;
740 }
741 
freekick_write(UINT16 address,UINT8 data)742 static void __fastcall freekick_write(UINT16 address, UINT8 data)
743 {
744 	switch (address)
745 	{
746 //	AM_RANGE(0xec00, 0xec03) AM_DEVREADWRITE("ppi8255_0", i8255_device, read, write)
747 		case 0xec00:
748 		case 0xec01:
749 		case 0xec02:
750 		case 0xec03:
751 			ppi8255_w(0, address & 0x03, data);
752 			return;
753 
754 //	AM_RANGE(0xf000, 0xf003) AM_DEVREADWRITE("ppi8255_1", i8255_device, read, write)
755 		case 0xf000:
756 		case 0xf001:
757 		case 0xf002:
758 		case 0xf003:
759 			ppi8255_w(1, address & 0x03, data);
760 			return;
761 
762 //	AM_RANGE(0xf800, 0xf800) AM_READ_PORT("IN0") AM_WRITE(flipscreen_w)
763 		case 0xf800:
764 		case 0xf801:
765 			return;
766 
767 		case 0xf802:
768 		case 0xf803:
769 			coin = ~data & 1;
770 			return;
771 
772 		case 0xf804:
773 //			bprintf(0, _T("nmi enable %X\n"), data);
774 			nmi_enable = data & 1;
775 			return;
776 
777 // AM_RANGE(0xf806, 0xf806) AM_WRITE(spinner_select_w)
778 		case 0xf806:
779 			spinner = data & 1;
780 		return;
781 
782 		case 0xfc00:
783 			SN76496Write(0, data);
784 		return;
785 
786 		case 0xfc01:
787 			SN76496Write(1, data);
788 		return;
789 
790 		case 0xfc02:
791 			SN76496Write(2, data);
792 		return;
793 
794 		case 0xfc03:
795 			SN76496Write(3, data);
796 		return;
797 	}
798 }
799 
freekick_read(UINT16 address)800 UINT8 __fastcall freekick_read(UINT16 address)
801 {
802 	switch (address)
803 	{
804 //	AM_RANGE(0xec00, 0xec03) AM_DEVREADWRITE("ppi8255_0", i8255_device, read, write)
805 		case 0xec00:
806 		case 0xec01:
807 		case 0xec02:
808 		case 0xec03:
809 			return ppi8255_r(0, address & 0x03);
810 
811 //	AM_RANGE(0xf000, 0xf003) AM_DEVREADWRITE("ppi8255_1", i8255_device, read, write)
812 		case 0xf000:
813 		case 0xf001:
814 		case 0xf002:
815 		case 0xf003:
816 			return ppi8255_r(1, address & 0x03);
817 
818 		case 0xf800: {
819 			return DrvInputs[0];
820 		}
821 
822 		case 0xf801: {
823 			return DrvInputs[1];
824 		}
825 
826 //	AM_RANGE(0xf802, 0xf802) AM_READNOP //MUST return bit 0 = 0, otherwise game resets
827 		case 0xf802:
828 			return 0;
829 
830 //	AM_RANGE(0xf803, 0xf803) AM_READ(spinner_r)
831 		case 0xf803:
832 		{
833 			if(spinner)
834 				return DrvDial2;
835 			else
836 				return DrvDial1;
837 		}
838 	}
839 	return 0;
840 }
841 
pbillrd_setbank(UINT8 banknum)842 static void pbillrd_setbank(UINT8 banknum)
843 {
844 	DrvZ80Bank0 = banknum; // for savestates
845 
846 	UINT32 bankloc = 0x10000 + banknum * 0x4000;
847 
848 	if (use_encrypted) {
849 		ZetMapArea(0x8000, 0xbfff, 0, DrvMainROM + bankloc); // read
850 		ZetMapArea(0x8000, 0xbfff, 2, DrvMainROMdec + bankloc, DrvMainROM + bankloc); // fetch ops(encrypted), opargs(unencrypted)
851 	} else {
852 		ZetMapArea(0x8000, 0xbfff, 0, DrvMainROM + bankloc); // read
853 		ZetMapArea(0x8000, 0xbfff, 2, DrvMainROM + bankloc); // fetch
854 	}
855 }
856 
gigas_write(UINT16 address,UINT8 data)857 static void __fastcall gigas_write(UINT16 address, UINT8 data)
858 {
859 //	AM_RANGE(0xe000, 0xe000) AM_WRITENOP
860 //	AM_RANGE(0xe002, 0xe003) AM_WRITE(coin_w)
861 //	AM_RANGE(0xe004, 0xe004) AM_WRITE(nmi_enable_w)
862 //	AM_RANGE(0xe005, 0xe005) AM_WRITENOP
863 	switch (address)
864 	{
865 		case 0xe000:
866 //		case 0xe001:
867 //			flipscreen = data;
868 			return;
869 
870 		case 0xe002:
871 		case 0xe003:
872 			coin = ~data & 1;
873 			return;
874 
875 		case 0xe004: //bprintf(0, _T("nmi enable %X\n"), data);
876 			nmi_enable = data & 1;
877 			return;
878 		case 0xe005:
879 			return;
880 // 	AM_RANGE(0xf000, 0xf000) AM_WRITE(SMH_NOP) //bankswitch ?
881 
882 		case 0xf000: {
883 			if (pbillrdmode) {
884 				pbillrd_setbank(data & 1);
885 			}
886 			return;
887 		}
888 
889 //	AM_RANGE(0xfc00, 0xfc00) AM_WRITE(sn76496_0_w)
890 //	AM_RANGE(0xfc01, 0xfc01) AM_WRITE(sn76496_1_w)
891 //	AM_RANGE(0xfc02, 0xfc02) AM_WRITE(sn76496_2_w)
892 //	AM_RANGE(0xfc03, 0xfc03) AM_WRITE(sn76496_3_w)
893 
894 		case 0xfc00:
895 			SN76496Write(0, data);
896 		return;
897 
898 		case 0xfc01:
899 			SN76496Write(1, data);
900 		return;
901 
902 		case 0xfc02:
903 			SN76496Write(2, data);
904 		return;
905 
906 		case 0xfc03:
907 			SN76496Write(3, data);
908 		return;
909 	}
910 }
911 
gigas_read(UINT16 address)912 UINT8 __fastcall gigas_read(UINT16 address)
913 {
914 	switch (address)
915 	{
916 		case 0xe000:
917 		{
918 			return DrvInputs[0];
919 			//	AM_RANGE(0xe000, 0xe000) AM_READ_PORT("IN0") AM_WRITENOP // probably not flipscreen
920 		}
921 
922 		case 0xe800:
923 		{
924 			return DrvInputs[1];
925 			//	AM_RANGE(0xe800, 0xe800) AM_READ_PORT("IN1")
926 		}
927 
928 		case 0xf000: {
929 			return DrvDip[0];//	AM_RANGE(0xf000, 0xf000) AM_READ_PORT("DSW1") AM_WRITENOP //bankswitch ?
930 		}
931 
932 		case 0xf800: {
933 			return DrvDip[1];//	AM_RANGE(0xf800, 0xf800) AM_READ_PORT("DSW2")
934 		}
935 	}
936 	return 0;
937 }
938 
freekick_in(UINT16 address)939 UINT8 __fastcall freekick_in(UINT16 address)
940 {
941 	switch (address & 0xff)
942 	{
943 		case 0xff:
944             // 	AM_RANGE(0xff, 0xff) AM_READWRITE(freekick_ff_r, freekick_ff_w)
945 			return ff_data;
946 		break;
947 	}
948 
949 	return 0;
950 }
951 
freekick_out(UINT16 address,UINT8 data)952 void __fastcall freekick_out(UINT16 address, UINT8 data)
953 {
954 	switch (address & 0xff)
955 	{
956 		case 0xff:
957             // 	AM_RANGE(0xff, 0xff) AM_READWRITE(freekick_ff_r, freekick_ff_w)
958 			ff_data = data;
959 		break;
960 	}
961 }
962 
freekick_ppiread_1_c()963 static UINT8 freekick_ppiread_1_c()
964 {
965 	return DrvSndROM[romaddr & 0x7fff];
966 }
967 
freekick_ppi_write_1_a(UINT8 data)968 static void freekick_ppi_write_1_a(UINT8 data)
969 {
970 	romaddr = (romaddr & 0xff00) | data;
971 }
972 
freekick_ppi_write_1_b(UINT8 data)973 static void freekick_ppi_write_1_b(UINT8 data)
974 {
975 	romaddr = (romaddr & 0x00ff) | (data << 8);
976 }
977 
freekick_ppiread_2_a()978 static UINT8 freekick_ppiread_2_a()
979 {
980 	return DrvDip[0];
981 }
982 
freekick_ppiread_2_b()983 static UINT8 freekick_ppiread_2_b()
984 {
985 	return DrvDip[1];
986 }
987 
freekick_ppiread_2_c()988 static UINT8 freekick_ppiread_2_c()
989 {
990 	return DrvDip[2];
991 }
992 
gigas_in(UINT16 address)993 UINT8 __fastcall gigas_in(UINT16 address)
994 {
995 	switch (address & 0xff)
996 	{
997 		case 0x00:
998 			if(spinner)
999 				return DrvDial2;
1000 			else
1001 				return DrvDial1;
1002 		break;
1003 
1004 		case 0x01:
1005 			return DrvDip[2];
1006 		break;
1007 	}
1008 
1009 	return 0;
1010 }
1011 
gigas_out(UINT16 address,UINT8 data)1012 void __fastcall gigas_out(UINT16 address, UINT8 data)
1013 {
1014 	switch (address & 0xff)
1015 	{
1016 		case 0x00:
1017 			spinner = data & 1;
1018 		break;
1019 	}
1020 }
1021 
1022 
MemIndex()1023 static INT32 MemIndex()
1024 {
1025 	UINT8 *Next; Next = AllMem;
1026 
1027 	DrvMainROM	 	= Next; Next += 0x40000;
1028 	DrvMainROMdec   = Next; Next += 0x20000;
1029 	DrvSndROM		= Next; Next += 0x10000;
1030 	DrvGfxROM0		= Next; Next += 0x20000; // 0x800 * 8 * 8
1031 	DrvGfxROM1		= Next; Next += 0x20000; // 0x200 * 16 * 16
1032 	MC8123Key		= Next; Next += 0x02000;
1033 	DrvColPROM		= Next; Next += 0x00600;
1034 	DrvPalette		= (UINT32*)Next; Next += 0x0400 * sizeof(UINT32); // à faire
1035 
1036 	AllRam			= Next;
1037 
1038 	DrvRAM			= Next; Next += 0x02000; // 0x0e000 - 0x0c000
1039 	DrvVidRAM		= Next; Next += 0x00800;
1040 	DrvSprRAM		= Next; Next += 0x00100;
1041 	DrvColRAM		= Next; Next += 0x00600;
1042 
1043 	RamEnd			= Next;
1044 
1045 	MemEnd			= Next;
1046 
1047 	return 0;
1048 }
1049 
DrvGfxDecode()1050 static void DrvGfxDecode()
1051 {
1052 	INT32 Planes0[3] = { RGN_FRAC(0xc000, 2,3), RGN_FRAC(0xc000, 1,3), RGN_FRAC(0xc000, 0,3) };
1053 	INT32 XOffs0[8]  = {0, 1, 2, 3, 4, 5, 6, 7};
1054 	INT32 YOffs0[8]  = {STEP8(0, 8)};
1055 
1056 	INT32 Planes1[3] = { RGN_FRAC(0xc000, 0,3),RGN_FRAC(0xc000, 2,3),RGN_FRAC(0xc000, 1,3) };
1057 	INT32 XOffs1[16] = {0, 1, 2, 3, 4, 5, 6, 7,128+0,128+1,128+2,128+3,128+4,128+5,128+6,128+7};
1058 
1059 //	INT32 YOffs1[16] = {0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8,12*8,13*8,14*8,15*8};
1060 	INT32 YOffs1[16] = {15*8, 14*8, 13*8, 12*8, 11*8, 10*8, 9*8, 8*8, 7*8, 6*8, 5*8, 4*8,3*8,2*8,1*8,0*8};
1061 
1062 	UINT8 *tmp = (UINT8*)BurnMalloc(0xc000);
1063 	if (tmp == NULL) {
1064 		return;
1065 	}
1066 
1067 	memcpy (tmp, DrvGfxROM0, 0xc000);
1068 	GfxDecode(0x0800, 3,  8,  8, Planes0, XOffs0, YOffs0, 0x40, tmp, DrvGfxROM0);
1069 
1070 	memcpy (tmp, DrvGfxROM1, 0xc000);
1071 	GfxDecode(0x0200, 3, 16, 16, Planes1, XOffs1, YOffs1, 0x100, tmp, DrvGfxROM1);
1072 
1073 	BurnFree (tmp);
1074 }
1075 
DrvPaletteInit()1076 static void DrvPaletteInit()
1077 {
1078 	INT32 len = 0x200;
1079 
1080 	for (INT32 i = 0; i < len; i++)
1081 	{
1082 		INT32 bit0,bit1,bit2,bit3,r,g,b;
1083 
1084 		bit0 = (DrvColPROM[i + len * 0] >> 0) & 0x01;
1085 		bit1 = (DrvColPROM[i + len * 0] >> 1) & 0x01;
1086 		bit2 = (DrvColPROM[i + len * 0] >> 2) & 0x01;
1087 		bit3 = (DrvColPROM[i + len * 0] >> 3) & 0x01;
1088 		r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
1089 
1090 		bit0 = (DrvColPROM[i + len * 1] >> 0) & 0x01;
1091 		bit1 = (DrvColPROM[i + len * 1] >> 1) & 0x01;
1092 		bit2 = (DrvColPROM[i + len * 1] >> 2) & 0x01;
1093 		bit3 = (DrvColPROM[i + len * 1] >> 3) & 0x01;
1094 		g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
1095 
1096 		bit0 = (DrvColPROM[i + len * 2] >> 0) & 0x01;
1097 		bit1 = (DrvColPROM[i + len * 2] >> 1) & 0x01;
1098 		bit2 = (DrvColPROM[i + len * 2] >> 2) & 0x01;
1099 		bit3 = (DrvColPROM[i + len * 2] >> 3) & 0x01;
1100 		b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
1101 
1102 		DrvPalette[i] = BurnHighCol(r, g, b, 0);
1103 	}
1104 }
1105 
1106 /*static INT32 GigasDecode()
1107 {
1108 	mc8123_decrypt_rom(0, 0, DrvMainROM, DrvMainROM + 0x10000, MC8123Key);
1109 	return 0;
1110 }*/
1111 
LoadRoms()1112 static INT32 LoadRoms()
1113 {
1114 	INT32 rom_number = 0;
1115 
1116 	countrunbmode = !strcmp(BurnDrvGetTextA(DRV_NAME), "countrunb");
1117 
1118 	if (!strcmp(BurnDrvGetTextA(DRV_NAME), "countrunb") ||
1119 		!strcmp(BurnDrvGetTextA(DRV_NAME), "freekick") ||
1120 		!strcmp(BurnDrvGetTextA(DRV_NAME), "freekicka") ||
1121 		!strcmp(BurnDrvGetTextA(DRV_NAME), "freekickb1") ||
1122 		!strcmp(BurnDrvGetTextA(DRV_NAME), "freekickb2") ||
1123 		!strcmp(BurnDrvGetTextA(DRV_NAME), "freekickb3")
1124 	)
1125 	{
1126 		if (BurnLoadRom(DrvMainROM,  rom_number++, 1)) return 1;
1127 		if (!strcmp(BurnDrvGetTextA(DRV_NAME), "freekickb3")) {
1128 			if (BurnLoadRom(DrvMainROM + 0x08000,  rom_number++, 1)) return 1;
1129 		}
1130 		if (BurnLoadRom(DrvSndROM,   rom_number++, 1)) return 1;	// sound rom
1131 	}
1132 
1133 	if (!strcmp(BurnDrvGetTextA(DRV_NAME), "pbillrd") ||
1134 		!strcmp(BurnDrvGetTextA(DRV_NAME), "pbillrdsa"))
1135 	{
1136 		if (BurnLoadRom(DrvMainROM,  rom_number++, 1)) return 1;
1137 		if (BurnLoadRom(DrvMainROM + 0x04000,  rom_number++, 1)) return 1;
1138 		memmove(DrvMainROM + 0x10000, DrvMainROM + 0x08000, 0x4000);
1139 		if (BurnLoadRom(DrvMainROM + 0x14000,  rom_number++, 1)) return 1;
1140 
1141 		if (!strcmp(BurnDrvGetTextA(DRV_NAME), "pbillrdsa")) {
1142 			if (BurnLoadRom(MC8123Key,  rom_number++, 1)) return 1;
1143 			mc8123_decrypt_rom(0, 2, DrvMainROM, DrvMainROMdec, MC8123Key);
1144 			use_encrypted = 1;
1145 		}
1146 	}
1147 
1148 	if (!strcmp(BurnDrvGetTextA(DRV_NAME), "omega") ||
1149 	    !strcmp(BurnDrvGetTextA(DRV_NAME), "gigas"))
1150 	{
1151 		if (BurnLoadRom(DrvMainROM,  rom_number++, 1)) return 1;
1152 		if (BurnLoadRom(DrvMainROM + 0x04000,  rom_number++, 1)) return 1;
1153 
1154 		if (BurnLoadRom(MC8123Key,  rom_number++, 1)) return 1;
1155 
1156 		mc8123_decrypt_rom(0, 1, DrvMainROM, DrvMainROMdec, MC8123Key);
1157 		use_encrypted = 1;
1158 	}
1159 
1160 	if (!strcmp(BurnDrvGetTextA(DRV_NAME), "gigasb"))
1161 	{
1162 		if (BurnLoadRom(DrvMainROM + 0x10000,  rom_number++, 1)) return 1;
1163 		memmove(DrvMainROM + 0x00000, DrvMainROM + 0x14000, 0x4000);
1164 
1165 		if (BurnLoadRom(DrvMainROM + 0x14000,  rom_number++, 1)) return 1;
1166 		memmove(DrvMainROM + 0x04000, DrvMainROM + 0x1c000, 0x8000);
1167 	}
1168 
1169 	if (!strcmp(BurnDrvGetTextA(DRV_NAME), "gigasm2b"))
1170 	{
1171 		if (BurnLoadRom(DrvMainROM + 0x10000,  rom_number++, 1)) return 1;
1172 		memmove(DrvMainROM + 0x00000, DrvMainROM + 0x14000, 0x4000);
1173 
1174 		if (BurnLoadRom(DrvMainROM + 0x14000,  rom_number++, 1)) return 1;
1175 		memmove(DrvMainROM + 0x04000, DrvMainROM + 0x18000, 0x4000);
1176 
1177 		if (BurnLoadRom(DrvMainROM + 0x18000,  rom_number++, 1)) return 1;
1178 		memmove(DrvMainROM + 0x08000, DrvMainROM + 0x1c000, 0x4000);
1179 	}
1180 
1181 	// Gfx char
1182 	if (BurnLoadRom(DrvGfxROM0  + 0x00000,  rom_number++, 1)) return 1; // ( "4.3k", 0x00000, 0x04000
1183 	if (BurnLoadRom(DrvGfxROM0  + 0x04000,  rom_number++, 1)) return 1; // ( "5.3h", 0x04000, 0x04000
1184 	if (BurnLoadRom(DrvGfxROM0  + 0x08000,  rom_number++, 1)) return 1; // ( "6.3g", 0x08000, 0x04000
1185 
1186 	// Gfx sprite
1187 	if (BurnLoadRom(DrvGfxROM1  + 0x00000,  rom_number++, 1)) return 1; // ( "1.3p", 0x00000, 0x04000
1188 	if (BurnLoadRom(DrvGfxROM1  + 0x04000,  rom_number++, 1)) return 1; // ( "3.3l", 0x04000, 0x04000
1189 	if (BurnLoadRom(DrvGfxROM1  + 0x08000,  rom_number++, 1)) return 1; // ( "2.3n", 0x08000, 0x04000
1190 	// Opcode Decryption PROMS
1191 	//		GigasDecode(); - not used due to incomplete "gigas" romset.
1192 
1193 	// Palette
1194 	if (BurnLoadRom(DrvColPROM + 0x000000,	rom_number++, 1)) return 1; // ( "3a.bin", 0x0000, 0x0100
1195 	if (BurnLoadRom(DrvColPROM + 0x000100,  rom_number++, 1)) return 1; // ( "4d.bin", 0x0100, 0x0100
1196 	if (BurnLoadRom(DrvColPROM + 0x000200,	rom_number++, 1)) return 1; // ( "4a.bin", 0x0200, 0x0100
1197 	if (BurnLoadRom(DrvColPROM + 0x000300,	rom_number++, 1)) return 1; // ( "3d.bin", 0x0300, 0x0100
1198 	if (BurnLoadRom(DrvColPROM + 0x000400,	rom_number++, 1)) return 1; // ( "3b.bin", 0x0400, 0x0100
1199 	if (BurnLoadRom(DrvColPROM + 0x000500,	rom_number++, 1)) return 1; // ( "3c.bin", 0x0500, 0x0100
1200 
1201 	return 0;
1202 }
1203 
DrvFreeKickInit()1204 static INT32 DrvFreeKickInit()
1205 {
1206 	DrawSprite = freekick_draw_sprite;
1207 	AllMem = NULL;
1208 	MemIndex();
1209 	INT32 nLen = MemEnd - (UINT8 *)0;
1210 	if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1211 	memset(AllMem, 0, nLen);
1212 	MemIndex();
1213 
1214 	LoadRoms();
1215 
1216 	DrvPaletteInit();
1217 
1218 	DrvGfxDecode();
1219 
1220 	ZetInit(0);
1221 	ZetOpen(0);
1222 //	AM_RANGE(0x0000, 0xcfff) AM_ROM
1223 	ZetMapArea(0x0000, 0xcfff, 0, DrvMainROM);
1224 	ZetMapArea(0x0000, 0xcfff, 2, DrvMainROM); //+0x10000,DrvMainROM);
1225 //	AM_RANGE(0xd000, 0xdfff) AM_RAM
1226 	ZetMapMemory(DrvRAM,		0xd000, 0xdfff, MAP_RAM);
1227 //	AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(freek_videoram_w) AM_SHARE("videoram")    // tilemap
1228 	ZetMapMemory(DrvVidRAM,		0xe000, 0xe7ff, MAP_RAM);
1229 //	AM_RANGE(0xe800, 0xe8ff) AM_RAM AM_SHARE("spriteram")   // sprites
1230 	ZetMapMemory(DrvSprRAM,		0xe800, 0xe8ff, MAP_RAM);
1231 
1232 	ppi8255_init(2);
1233 
1234 	ppi8255_set_read_ports(0, NULL, NULL, freekick_ppiread_1_c);
1235 	ppi8255_set_write_ports(0, freekick_ppi_write_1_a, freekick_ppi_write_1_b, NULL);
1236 	ppi8255_set_read_ports(1, freekick_ppiread_2_a, freekick_ppiread_2_b, freekick_ppiread_2_c);
1237 
1238 	ZetSetReadHandler(freekick_read);
1239 	ZetSetWriteHandler(freekick_write);
1240 	ZetSetInHandler(freekick_in);
1241 	ZetSetOutHandler(freekick_out);
1242 
1243 	ZetClose();
1244 
1245 	SN76489AInit(0, 12000000/4, 0);
1246 	SN76489AInit(1, 12000000/4, 1);
1247 	SN76489AInit(2, 12000000/4, 1);
1248 	SN76489AInit(3, 12000000/4, 1);
1249 
1250 	SN76496SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
1251 	SN76496SetRoute(1, 1.00, BURN_SND_ROUTE_BOTH);
1252 	SN76496SetRoute(2, 1.00, BURN_SND_ROUTE_BOTH);
1253 	SN76496SetRoute(3, 1.00, BURN_SND_ROUTE_BOTH);
1254 
1255 	GenericTilesInit();
1256 
1257 	DrvDoReset();
1258 
1259 	return 0;
1260 }
1261 
DrvInit()1262 static INT32 DrvInit()
1263 {
1264 	DrawSprite = gigas_draw_sprite;
1265 
1266 	AllMem = NULL;
1267 	MemIndex();
1268 	INT32 nLen = MemEnd - (UINT8 *)0;
1269 	if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
1270 	memset(AllMem, 0, nLen);
1271 	MemIndex();
1272 
1273 	LoadRoms();
1274 
1275 	DrvPaletteInit();
1276 
1277 	DrvGfxDecode();
1278 
1279 	ZetInit(0);
1280 	ZetOpen(0);
1281 
1282 	if (pbillrdmode) {
1283 		ZetMapArea(0x0000, 0x7fff, 0, DrvMainROM); // read
1284 		ZetMapArea(0x0000, 0x7fff, 2, DrvMainROM); // fetch
1285 
1286 		if (use_encrypted) {
1287 			ZetMapArea(0x0000, 0x7fff, 0, DrvMainROM);
1288 			ZetMapArea(0x0000, 0x7fff, 2, DrvMainROMdec, DrvMainROM); // fetch ops(encrypted), opargs(unencrypted)
1289 		}
1290 		pbillrd_setbank(0);
1291 	} else { // gigas*
1292 		ZetMapArea(0x0000, 0xbfff, 0, DrvMainROM);
1293 		ZetMapArea(0x0000, 0xbfff, 2, DrvMainROM + 0x10000, DrvMainROM);
1294 
1295 		if (use_encrypted) {
1296 			ZetMapArea(0x0000, 0xbfff, 0, DrvMainROM);
1297 			ZetMapArea(0x0000, 0xbfff, 2, DrvMainROMdec, DrvMainROM); // fetch ops(encrypted), opargs(unencrypted)
1298 		}
1299 	}
1300 
1301 
1302 //	AM_RANGE(0xc000, 0xcfff) AM_RAM
1303 	ZetMapMemory(DrvRAM,		0xc000, 0xcfff, MAP_RAM);
1304 //	AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(freek_videoram_w) AM_SHARE("videoram")
1305 	ZetMapMemory(DrvVidRAM,		0xd000, 0xd7ff, MAP_RAM);
1306 //	AM_RANGE(0xd800, 0xd8ff) AM_RAM AM_SHARE("spriteram")
1307 	ZetMapMemory(DrvSprRAM,		0xd800, 0xd8ff, MAP_RAM);
1308 //	AM_RANGE(0xd900, 0xdfff) AM_RAM
1309 	ZetMapMemory(DrvRAM + 0x1000,		0xd900, 0xdfff, MAP_RAM);
1310 
1311 	ppi8255_init(1);
1312 
1313 	ZetSetReadHandler(gigas_read); // Memory
1314 	ZetSetWriteHandler(gigas_write);
1315 
1316 	ZetSetInHandler(gigas_in); // IO Port
1317 	ZetSetOutHandler(gigas_out);
1318 
1319 	ZetClose();
1320 
1321 	SN76489AInit(0, 12000000/4, 0);
1322 	SN76489AInit(1, 12000000/4, 1);
1323 	SN76489AInit(2, 12000000/4, 1);
1324 	SN76489AInit(3, 12000000/4, 1);
1325 
1326 	SN76496SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
1327 	SN76496SetRoute(1, 1.00, BURN_SND_ROUTE_BOTH);
1328 	SN76496SetRoute(2, 1.00, BURN_SND_ROUTE_BOTH);
1329 	SN76496SetRoute(3, 1.00, BURN_SND_ROUTE_BOTH);
1330 
1331 	GenericTilesInit();
1332 
1333 	DrvDoReset();
1334 
1335 	return 0;
1336 }
1337 
DrvExit()1338 static INT32 DrvExit()
1339 {
1340 	GenericTilesExit();
1341 	ZetExit();
1342 	SN76496Exit();
1343 	ppi8255_exit();
1344 	BurnFree (AllMem);
1345 
1346 	countrunbmode = 0;
1347 	pbillrdmode = 0;
1348 	use_encrypted = 0;
1349 
1350 	return 0;
1351 }
1352 
DrvFrame()1353 static INT32 DrvFrame()
1354 {
1355 	if (DrvReset) {
1356 		DrvDoReset();
1357 	}
1358 
1359 	DrvInputs[0] = 0xff; // Active LOW
1360 	DrvInputs[1] = 0xff;
1361 
1362 	for (INT32 i = 0; i < 8; i++) {
1363 		DrvInputs[0] ^= (DrvJoy1[i] & 1) << i;
1364 		DrvInputs[1] ^= (DrvJoy2[i] & 1) << i;
1365 	}
1366 
1367 	{ // spinner calculation stuff.
1368 		if (DrvJoy1[2]) DrvDial1 -= 0x04;
1369 		if (DrvJoy1[3]) DrvDial1 += 0x04;
1370 		if (DrvDial1 >= 0x100) DrvDial1 = 0;
1371 		if (DrvDial1 < 0) DrvDial1 = 0xfc;
1372 
1373 		if (DrvJoy2[2]) DrvDial2 -= 0x04;
1374 		if (DrvJoy2[3]) DrvDial2 += 0x04;
1375 		if (DrvDial2 >= 0x100) DrvDial2 = 0;
1376 		if (DrvDial2 < 0) DrvDial2 = 0xfc;
1377 	}
1378 
1379 	INT32 nInterleave = 256;
1380 	INT32 nCyclesTotal = nCyclesTotal = (countrunbmode) ? 6000000 / 60 : 3072000 / 60;
1381 
1382 	ZetOpen(0);
1383 	for (INT32 i = 0; i < nInterleave; i++) {
1384 		ZetRun(nCyclesTotal / nInterleave);
1385 
1386 		if (i % 128 == 127)
1387 			ZetSetIRQLine(0, CPU_IRQSTATUS_HOLD); // audio irq
1388 
1389 
1390 		if (i == (nInterleave - 1) && nmi_enable) { // vblank
1391 			ZetNmi();
1392 		}
1393 	}
1394 	ZetClose();
1395 
1396 	if (pBurnSoundOut) {
1397 		SN76496Update(0, pBurnSoundOut, nBurnSoundLen);
1398 		SN76496Update(1, pBurnSoundOut, nBurnSoundLen);
1399 		SN76496Update(2, pBurnSoundOut, nBurnSoundLen);
1400 		SN76496Update(3, pBurnSoundOut, nBurnSoundLen);
1401 	}
1402 
1403 	if (pBurnDraw) {
1404 		DrvDraw();
1405 	}
1406 
1407 	return 0;
1408 }
1409 
DrvScan(INT32 nAction,INT32 * pnMin)1410 static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
1411 {
1412 	struct BurnArea ba;
1413 
1414 	if (pnMin != NULL) {
1415 		*pnMin = 0x029698;
1416 	}
1417 
1418 	if (nAction & ACB_MEMORY_RAM) {
1419 		memset(&ba, 0, sizeof(ba));
1420 		ba.Data	  = AllRam;
1421 		ba.nLen	  = RamEnd-AllRam;
1422 		ba.szName = "All Ram";
1423 		BurnAcb(&ba);
1424 	}
1425 
1426 	if (nAction & ACB_DRIVER_DATA) {
1427 
1428 		ZetScan(nAction);
1429 
1430 		SN76496Scan(nAction, pnMin);
1431 
1432 		SCAN_VAR(nmi_enable);
1433 		SCAN_VAR(flipscreen);
1434 		SCAN_VAR(coin);
1435 		SCAN_VAR(spinner);
1436 		SCAN_VAR(ff_data);
1437 		SCAN_VAR(romaddr);
1438 		SCAN_VAR(DrvDial1);
1439 		SCAN_VAR(DrvDial2);
1440 		SCAN_VAR(DrvZ80Bank0);
1441 	}
1442 
1443 	if (nAction & ACB_WRITE && pbillrdmode) {
1444 		ZetOpen(0);
1445 		pbillrd_setbank(DrvZ80Bank0);
1446 		ZetClose();
1447 	}
1448 
1449 	return 0;
1450 }
1451 
pbillrdInit()1452 static INT32 pbillrdInit()
1453 {
1454 	pbillrdmode = 1;
1455 
1456 	return DrvInit();
1457 }
1458 
1459 // Perfect Billiard
1460 
1461 static struct BurnRomInfo pbillrdRomDesc[] = {
1462 	{ "pb.18",		0x4000, 0x9e6275ac, 1 }, //  0 maincpu
1463 	{ "pb.7",		0x8000, 0xdd438431, 1 }, //  1
1464 	{ "pb.9",		0x4000, 0x089ce80a, 1 }, //  2
1465 
1466 	{ "pb.4",		0x4000, 0x2f4d4dd3, 2 }, //  3 gfx1
1467 	{ "pb.5",		0x4000, 0x9dfccbd3, 2 }, //  4
1468 	{ "pb.6",		0x4000, 0xb5c3f6f6, 2 }, //  5
1469 
1470 	{ "10619.3r",	0x2000, 0x3296b9d9, 3 }, //  6 gfx2
1471 	{ "10621.3m",	0x2000, 0x3dca8e4b, 3 }, //  7
1472 	{ "10620.3n",	0x2000, 0xee76b079, 3 }, //  8
1473 
1474 	{ "82s129.3a",	0x0100, 0x44802169, 4 }, //  9 proms
1475 	{ "82s129.4d",	0x0100, 0x69ca07cc, 4 }, // 10
1476 	{ "82s129.4a",	0x0100, 0x145f950a, 4 }, // 11
1477 	{ "82s129.3d",	0x0100, 0x43d24e17, 4 }, // 12
1478 	{ "82s129.3b",	0x0100, 0x7fdc872c, 4 }, // 13
1479 	{ "82s129.3c",	0x0100, 0xcc1657e5, 4 }, // 14
1480 };
1481 
1482 STD_ROM_PICK(pbillrd)
1483 STD_ROM_FN(pbillrd)
1484 
1485 struct BurnDriver BurnDrvPbillrd = {
1486 	"pbillrd", NULL, NULL, NULL, "1987",
1487 	"Perfect Billiard\0", NULL, "Nihon System", "Miscellaneous",
1488 	NULL, NULL, NULL, NULL,
1489 	BDF_GAME_WORKING, 2, HARDWARE_MISC_PRE90S, GBF_SPORTSMISC, 0,
1490 	NULL, pbillrdRomInfo, pbillrdRomName, NULL, NULL, NULL, NULL, PbillrdInputInfo, PbillrdDIPInfo,
1491 	pbillrdInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
1492 	256, 224, 4, 3
1493 };
1494 
1495 // Perfect Billiard (MC-8123, 317-5008)
1496 
1497 static struct BurnRomInfo pbillrdsaRomDesc[] = {
1498 	{ "20",				0x4000, 0xda020258, 1 }, //  0 maincpu
1499 	{ "17",				0x8000, 0x9bb3d467, 1 }, //  1
1500 	{ "19",				0x4000, 0x2335e6dd, 1 }, //  2
1501 
1502 	{ "317-5008.key",	0x2000, 0x9223f06d, 2 }, //  3 user1
1503 
1504 	{ "pb.4",			0x4000, 0x2f4d4dd3, 3 }, //  4 gfx1
1505 	{ "pb.5",			0x4000, 0x9dfccbd3, 3 }, //  5
1506 	{ "pb.6",			0x4000, 0xb5c3f6f6, 3 }, //  6
1507 
1508 	{ "1",				0x4000, 0xc8ed651e, 4 }, //  7 gfx2
1509 	{ "3",				0x4000, 0x5282fc86, 4 }, //  8
1510 	{ "2",				0x4000, 0xe9f73f5b, 4 }, //  9
1511 
1512 	{ "82s129.3a",		0x0100, 0x44802169, 5 }, // 10 proms
1513 	{ "82s129.4d",		0x0100, 0x69ca07cc, 5 }, // 11
1514 	{ "82s129.4a",		0x0100, 0x145f950a, 5 }, // 12
1515 	{ "82s129.3d",		0x0100, 0x43d24e17, 5 }, // 13
1516 	{ "82s129.3b",		0x0100, 0x7fdc872c, 5 }, // 14
1517 	{ "82s129.3c",		0x0100, 0xcc1657e5, 5 }, // 15
1518 };
1519 
1520 STD_ROM_PICK(pbillrdsa)
1521 STD_ROM_FN(pbillrdsa)
1522 
1523 struct BurnDriver BurnDrvPbillrds = {
1524 	"pbillrdsa", "pbillrd", NULL, NULL, "1987",
1525 	"Perfect Billiard (MC-8123, 317-5008)\0", NULL, "Nihon System", "Miscellaneous",
1526 	NULL, NULL, NULL, NULL,
1527 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_PRE90S, GBF_SPORTSMISC, 0,
1528 	NULL, pbillrdsaRomInfo, pbillrdsaRomName, NULL, NULL, NULL, NULL, PbillrdInputInfo, PbillrdDIPInfo,
1529 	pbillrdInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
1530 	256, 224, 4, 3
1531 };
1532 
1533 
1534 // Free Kick (NS6201-A 1987.10)
1535 
1536 static struct BurnRomInfo freekickRomDesc[] = {
1537 	{ "ns6201-a_1987.10_free_kick.cpu",	0xd000, 0x6d172850, 1 }, //  0 maincpu
1538 
1539 	{ "11.1e",			0x8000, 0xa6030ba9, 2 }, //  1 user1
1540 
1541 	{ "12.1h",			0x4000, 0xfb82e486, 3 }, //  2 gfx1
1542 	{ "13.1j",			0x4000, 0x3ad78ee2, 3 }, //  3
1543 	{ "14.1l",			0x4000, 0x0185695f, 3 }, //  4
1544 
1545 	{ "15.1m",			0x4000, 0x0fa7c13c, 4 }, //  5 gfx2
1546 	{ "16.1p",			0x4000, 0x2b996e89, 4 }, //  6
1547 	{ "17.1r",			0x4000, 0xe7894def, 4 }, //  7
1548 
1549 	{ "24s10n.8j",		0x0100, 0x53a6bc21, 5 }, //  8 proms
1550 	{ "24s10n.7j",		0x0100, 0x38dd97d8, 5 }, //  9
1551 	{ "24s10n.8k",		0x0100, 0x18e66087, 5 }, // 10
1552 	{ "24s10n.7k",		0x0100, 0xbc21797a, 5 }, // 11
1553 	{ "24s10n.8h",		0x0100, 0x8aac5fd0, 5 }, // 12
1554 	{ "24s10n.7h",		0x0100, 0xa507f941, 5 }, // 13
1555 };
1556 
1557 STD_ROM_PICK(freekick)
1558 STD_ROM_FN(freekick)
1559 
1560 struct BurnDriver BurnDrvFreekick = {
1561 	"freekick", NULL, NULL, NULL, "1987",
1562 	"Free Kick (NS6201-A 1987.10)\0", NULL, "Nihon System (Merit license)", "Miscellaneous",
1563 	NULL, NULL, NULL, NULL,
1564 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_BREAKOUT, 0,
1565 	NULL, freekickRomInfo, freekickRomName, NULL, NULL, NULL, NULL, FreekckInputInfo, FreekckDIPInfo,
1566 	DrvFreeKickInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
1567 	224, 256, 3, 4
1568 };
1569 
1570 // Free Kick (NS6201-A 1987.9)
1571 
1572 static struct BurnRomInfo freekickaRomDesc[] = {
1573 	{ "ns6201-a_1987.9_free_kick.cpu",	0xd000, 0xacc0a278, 1 | BRF_PRG | BRF_ESS }, //  0 maincpu
1574 
1575 	{ "11.1e",			0x8000, 0xa6030ba9, 2 | BRF_GRA },           //  1 user1
1576 
1577 	{ "12.1h",			0x4000, 0xfb82e486, 3 | BRF_GRA },           //  2 gfx1
1578 	{ "13.1j",			0x4000, 0x3ad78ee2, 3 | BRF_GRA },           //  3
1579 	{ "14.1l",			0x4000, 0x0185695f, 3 | BRF_GRA },           //  4
1580 
1581 	{ "15.1m",			0x4000, 0x0fa7c13c, 4 | BRF_GRA },           //  5 gfx2
1582 	{ "16.1p",			0x4000, 0x2b996e89, 4 | BRF_GRA },           //  6
1583 	{ "17.1r",			0x4000, 0xe7894def, 4 | BRF_GRA },           //  7
1584 
1585 	{ "24s10n.8j",		0x0100, 0x53a6bc21, 5 | BRF_GRA },           //  8 proms
1586 	{ "24s10n.7j",		0x0100, 0x38dd97d8, 5 | BRF_GRA },           //  9
1587 	{ "24s10n.8k",		0x0100, 0x18e66087, 5 | BRF_GRA },           // 10
1588 	{ "24s10n.7k",		0x0100, 0xbc21797a, 5 | BRF_GRA },           // 11
1589 	{ "24s10n.8h",		0x0100, 0x8aac5fd0, 5 | BRF_GRA },           // 12
1590 	{ "24s10n.7h",		0x0100, 0xa507f941, 5 | BRF_GRA },           // 13
1591 };
1592 
1593 STD_ROM_PICK(freekicka)
1594 STD_ROM_FN(freekicka)
1595 
1596 struct BurnDriver BurnDrvFreekicka = {
1597 	"freekicka", "freekick", NULL, NULL, "1987",
1598 	"Free Kick (NS6201-A 1987.9)\0", NULL, "Nihon System", "Miscellaneous",
1599 	NULL, NULL, NULL, NULL,
1600 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_MISC_PRE90S, GBF_BREAKOUT, 0,
1601 	NULL, freekickaRomInfo, freekickaRomName, NULL, NULL, NULL, NULL, FreekckInputInfo, FreekckDIPInfo,
1602 	DrvFreeKickInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
1603 	224, 256, 3, 4
1604 };
1605 
1606 // Free Kick (bootleg set 1)
1607 
1608 static struct BurnRomInfo freekickb1RomDesc[] = {
1609 	{ "freekbl8.q7",		0x10000, 0x4208cfe5, 1 | BRF_PRG | BRF_ESS }, 	 //  0 maincpu
1610 
1611 	{ "11.1e",				0x08000, 0xa6030ba9, 2 | BRF_GRA },           	 //  1 user1
1612 
1613 	{ "12.1h",				0x04000, 0xfb82e486, 3 | BRF_GRA },           	 //  2 gfx1
1614 	{ "13.1j",				0x04000, 0x3ad78ee2, 3 | BRF_GRA },           	 //  3
1615 	{ "14.1l",				0x04000, 0x0185695f, 3 | BRF_GRA },           	 //  4
1616 
1617 	{ "15.1m",				0x04000, 0x0fa7c13c, 4 | BRF_GRA },           	 //  5 gfx2
1618 	{ "16.1p",				0x04000, 0x2b996e89, 4 | BRF_GRA },           	 //  6
1619 	{ "17.1r",				0x04000, 0xe7894def, 4 | BRF_GRA },           	 //  7
1620 
1621 	{ "24s10n.8j",			0x00100, 0x53a6bc21, 5 | BRF_GRA },           	 //  8 proms
1622 	{ "24s10n.7j",			0x00100, 0x38dd97d8, 5 | BRF_GRA },           	 //  9
1623 	{ "24s10n.8k",			0x00100, 0x18e66087, 5 | BRF_GRA },           	 // 10
1624 	{ "24s10n.7k",			0x00100, 0xbc21797a, 5 | BRF_GRA },           	 // 11
1625 	{ "24s10n.8h",			0x00100, 0x8aac5fd0, 5 | BRF_GRA },           	 // 12
1626 	{ "24s10n.7h",			0x00100, 0xa507f941, 5 | BRF_GRA },           	 // 13
1627 
1628 	{ "pal16l8.q10.bin",	0x00001, 0x00000000, 6 | BRF_NODUMP | BRF_GRA }, // 14 pals
1629 	{ "pal16l8.r1.bin",		0x00001, 0x00000000, 6 | BRF_NODUMP | BRF_GRA }, // 15
1630 	{ "pal16l8.s1.bin",		0x00001, 0x00000000, 6 | BRF_NODUMP | BRF_GRA }, // 16
1631 };
1632 
1633 STD_ROM_PICK(freekickb1)
1634 STD_ROM_FN(freekickb1)
1635 
1636 struct BurnDriver BurnDrvFreekickb1 = {
1637 	"freekickb1", "freekick", NULL, NULL, "1987",
1638 	"Free Kick (bootleg set 1)\0", NULL, "bootleg", "Miscellaneous",
1639 	NULL, NULL, NULL, NULL,
1640 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_MISC_PRE90S, GBF_BREAKOUT, 0,
1641 	NULL, freekickb1RomInfo, freekickb1RomName, NULL, NULL, NULL, NULL, FreekckInputInfo, FreekckDIPInfo,
1642 	DrvFreeKickInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
1643 	224, 256, 3, 4
1644 };
1645 
1646 // Free Kick (bootleg set 3)
1647 
1648 static struct BurnRomInfo freekickb3RomDesc[] = {
1649 	{ "1",			0x8000, 0x214e1868, 1 }, //  0 maincpu
1650 	{ "2",			0x8000, 0x734cdfc7, 1 }, //  1
1651 
1652 	{ "11.1e",		0x8000, 0xa6030ba9, 2 }, //  2 user1
1653 
1654 	{ "12.1h",		0x4000, 0xfb82e486, 3 }, //  3 gfx1
1655 	{ "13.1j",		0x4000, 0x3ad78ee2, 3 }, //  4
1656 	{ "14.1l",		0x4000, 0x0185695f, 3 }, //  5
1657 
1658 	{ "15.1m",		0x4000, 0x0fa7c13c, 4 }, //  6 gfx2
1659 	{ "16.1p",		0x4000, 0x2b996e89, 4 }, //  7
1660 	{ "17.1r",		0x4000, 0xe7894def, 4 }, //  8
1661 
1662 	{ "24s10n.8j",	0x0100, 0x53a6bc21, 5 }, //  9 proms
1663 	{ "24s10n.7j",	0x0100, 0x38dd97d8, 5 }, // 10
1664 	{ "24s10n.8k",	0x0100, 0x18e66087, 5 }, // 11
1665 	{ "24s10n.7k",	0x0100, 0xbc21797a, 5 }, // 12
1666 	{ "24s10n.8h",	0x0100, 0x8aac5fd0, 5 }, // 13
1667 	{ "24s10n.7h",	0x0100, 0xa507f941, 5 }, // 14
1668 	{ "n82s123an",	0x0020, 0x5ed93a02, 5 }, // 15
1669 };
1670 
1671 STD_ROM_PICK(freekickb3)
1672 STD_ROM_FN(freekickb3)
1673 
1674 struct BurnDriver BurnDrvFreekickb3 = {
1675 	"freekickb3", "freekick", NULL, NULL, "1987",
1676 	"Free Kick (bootleg set 3)\0", NULL, "bootleg", "Miscellaneous",
1677 	NULL, NULL, NULL, NULL,
1678 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_BREAKOUT, 0,
1679 	NULL, freekickb3RomInfo, freekickb3RomName, NULL, NULL, NULL, NULL, FreekckInputInfo, FreekckDIPInfo,
1680 	DrvFreeKickInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
1681 	224, 256, 3, 4
1682 };
1683 
1684 
1685 // Counter Run (NS6201-A 1988.3)
1686 
1687 static struct BurnRomInfo countrunRomDesc[] = {
1688 	{ "ns6201-a_1988.3_counter_run.cpu",	0x10000, 0x00000000, 1 | BRF_NODUMP }, //  0 maincpu
1689 
1690 	{ "c-run.e1",		0x08000, 0x2c3b6f8f, 2 }, //  1 user1
1691 
1692 	{ "c-run.h1",		0x04000, 0x3385b7b5, 3 }, //  2 gfx1
1693 	{ "c-run.j1",		0x04000, 0x58dc148d, 3 }, //  3
1694 	{ "c-run.l1",		0x04000, 0x3201f1e9, 3 }, //  4
1695 
1696 	{ "c-run.m1",		0x04000, 0x1efab3b4, 4 }, //  5 gfx2
1697 	{ "c-run.p1",		0x04000, 0xd0bf8d42, 4 }, //  6
1698 	{ "c-run.r1",		0x04000, 0x4bb4a3e3, 4 }, //  7
1699 
1700 	{ "24s10n.8j",		0x00100, 0x63c114ad, 5 }, //  8 proms
1701 	{ "24s10n.7j",		0x00100, 0xd16f95cc, 5 }, //  9
1702 	{ "24s10n.8k",		0x00100, 0x217db2c1, 5 }, // 10
1703 	{ "24s10n.7k",		0x00100, 0x8d983949, 5 }, // 11
1704 	{ "24s10n.8h",		0x00100, 0x33e87550, 5 }, // 12
1705 	{ "24s10n.7h",		0x00100, 0xc77d0077, 5 }, // 13
1706 };
1707 
1708 STD_ROM_PICK(countrun)
1709 STD_ROM_FN(countrun)
1710 
1711 struct BurnDriver BurnDrvCountrun = {
1712 	"countrun", NULL, NULL, NULL, "1988",
1713 	"Counter Run (NS6201-A 1988.3)\0", "Please use countrunb instead!", "Nihon System (Sega license)", "Miscellaneous",
1714 	NULL, NULL, NULL, NULL,
1715 	0, 2, HARDWARE_MISC_PRE90S, GBF_RACING, 0,
1716 	NULL, countrunRomInfo, countrunRomName, NULL, NULL, NULL, NULL, CountrunInputInfo, CountrunDIPInfo,
1717 	DrvFreeKickInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
1718 	256, 224, 4, 3
1719 };
1720 
1721 // Counter Run (bootleg set 1)
1722 
1723 static struct BurnRomInfo countrunbRomDesc[] = {
1724 	{ "rom_cpu.bin",	0x10000, 0xf65639ae, 1 }, //  0 maincpu
1725 
1726 	{ "c-run.e1",		0x08000, 0x2c3b6f8f, 2 }, //  1 user1
1727 
1728 	{ "c-run.h1",		0x04000, 0x3385b7b5, 3 }, //  2 gfx1
1729 	{ "c-run.j1",		0x04000, 0x58dc148d, 3 }, //  3
1730 	{ "c-run.l1",		0x04000, 0x3201f1e9, 3 }, //  4
1731 
1732 	{ "c-run.m1",		0x04000, 0x1efab3b4, 4 }, //  5 gfx2
1733 	{ "c-run.p1",		0x04000, 0xd0bf8d42, 4 }, //  6
1734 	{ "c-run.r1",		0x04000, 0x4bb4a3e3, 4 }, //  7
1735 
1736 	{ "24s10n.8j",		0x00100, 0x63c114ad, 5 }, //  8 proms
1737 	{ "24s10n.7j",		0x00100, 0xd16f95cc, 5 }, //  9
1738 	{ "24s10n.8k",		0x00100, 0x217db2c1, 5 }, // 10
1739 	{ "24s10n.7k",		0x00100, 0x8d983949, 5 }, // 11
1740 	{ "24s10n.8h",		0x00100, 0x33e87550, 5 }, // 12
1741 	{ "24s10n.7h",		0x00100, 0xc77d0077, 5 }, // 13
1742 };
1743 
1744 STD_ROM_PICK(countrunb)
1745 STD_ROM_FN(countrunb)
1746 
1747 struct BurnDriver BurnDrvCountrunb = {
1748 	"countrunb", "countrun", NULL, NULL, "1988",
1749 	"Counter Run (bootleg set 1)\0", NULL, "bootleg", "Miscellaneous",
1750 	NULL, NULL, NULL, NULL,
1751 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_PRE90S, GBF_RACING, 0,
1752 	NULL, countrunbRomInfo, countrunbRomName, NULL, NULL, NULL, NULL, CountrunInputInfo, CountrunDIPInfo,
1753 	DrvFreeKickInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
1754 	256, 224, 4, 3
1755 };
1756 
1757 // Gigas (bootleg)
1758 
1759 static struct BurnRomInfo gigasbRomDesc[] = {
1760 	{ "g-7.r8",	0x08000, 0xdaf4e88d, 1 }, //  0 maincpu
1761 	{ "g-8.t8",	0x10000, 0x4ab4c1f1, 1 }, //  1
1762 
1763 	{ "g-4.3l",	0x04000, 0x8ed78981, 2 }, //  2 gfx1
1764 	{ "g-5.3k",	0x04000, 0x0645ec2d, 2 }, //  3
1765 	{ "g-6.3fh",0x04000, 0x99e9cb27, 2 }, //  4
1766 
1767 	{ "g-1.3t",	0x04000, 0xd78fae6e, 3 }, //  5 gfx2
1768 	{ "g-3.3p",	0x04000, 0x37df4a4c, 3 }, //  6
1769 	{ "g-2.3r",	0x04000, 0x3a46e354, 3 }, //  7
1770 
1771 	{ "1.pr",	0x00100, 0xa784e71f, 4 }, //  8 proms
1772 	{ "6.pr",	0x00100, 0x376df30c, 4 }, //  9
1773 	{ "5.pr",	0x00100, 0x4edff5bd, 4 }, // 10
1774 	{ "4.pr",	0x00100, 0xfe201a4e, 4 }, // 11
1775 	{ "2.pr",	0x00100, 0x5796cc4a, 4 }, // 12
1776 	{ "3.pr",	0x00100, 0x28b5ee4c, 4 }, // 13
1777 };
1778 
1779 STD_ROM_PICK(gigasb)
1780 STD_ROM_FN(gigasb)
1781 
1782 struct BurnDriver BurnDrvGigasb = {
1783 	"gigasb", "gigas", NULL, NULL, "1986",
1784 	"Gigas (bootleg)\0", NULL, "bootleg", "Miscellaneous",
1785 	NULL, NULL, NULL, NULL,
1786 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_BREAKOUT, 0,
1787 	NULL, gigasbRomInfo, gigasbRomName, NULL, NULL, NULL, NULL, GigasInputInfo, GigasDIPInfo,
1788 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
1789 	224, 256, 3, 4
1790 };
1791 
1792 // Gigas Mark II (bootleg)
1793 // bootleg of Gigas MarkII without the MC-8123
1794 
1795 static struct BurnRomInfo gigasm2bRomDesc[] = {
1796 	{ "8.rom",	0x08000, 0xc00a4a6c, 1 }, //  0 maincpu
1797 	{ "7.rom",	0x08000, 0x92bd9045, 1 }, //  1
1798 	{ "9.rom",	0x08000, 0xa3ef809c, 1 }, //  1
1799 
1800 	{ "4.rom",	0x04000, 0x20b3405f, 2 }, //  2 gfx1
1801 	{ "5.rom",	0x04000, 0xd04ecfa8, 2 }, //  3
1802 	{ "6.rom",	0x04000, 0x33776801, 2 }, //  4
1803 
1804 	{ "1.rom",	0x04000, 0xf64cbd1e, 3 }, //  5 gfx2
1805 	{ "3.rom",	0x04000, 0xc228df19, 3 }, //  6
1806 	{ "2.rom",	0x04000, 0xa6ad9ce2, 3 }, //  7
1807 
1808 	{ "1.pr",	0x00100, 0xa784e71f, 4 }, //  8 proms
1809 	{ "6.pr",	0x00100, 0x376df30c, 4 }, //  9
1810 	{ "5.pr",	0x00100, 0x4edff5bd, 4 }, // 10
1811 	{ "4.pr",	0x00100, 0xfe201a4e, 4 }, // 11
1812 	{ "2.pr",	0x00100, 0x5796cc4a, 4 }, // 12
1813 	{ "3.pr",	0x00100, 0x28b5ee4c, 4 }, // 13
1814 };
1815 
1816 STD_ROM_PICK(gigasm2b)
1817 STD_ROM_FN(gigasm2b)
1818 
1819 struct BurnDriver BurnDrvGigasm2b = {
1820 	"gigasm2b", "gigasm2", NULL, NULL, "1986",
1821 	"Gigas Mark II\0", NULL, "bootleg", "Miscellaneous",
1822 	NULL, NULL, NULL, NULL,
1823 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_BREAKOUT, 0,
1824 	NULL, gigasm2bRomInfo, gigasm2bRomName, NULL, NULL, NULL, NULL, GigasInputInfo, Gigasm2DIPInfo,
1825 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
1826 	224, 256, 3, 4
1827 };
1828 
1829 // Gigas (MC-8123, 317-5002)
1830 
1831 static struct BurnRomInfo gigasRomDesc[] = {
1832 	{ "8.8n",			0x04000, 0x34ea8262, BRF_ESS | BRF_PRG }, //  0 maincpu
1833 	{ "7.8r",			0x08000, 0x43653909, BRF_ESS | BRF_PRG }, //  1
1834 
1835 	{ "317-5002.key",	0x02000, 0x86a7e5f6, BRF_ESS | BRF_PRG }, //  2
1836 
1837 	{ "4.3k",			0x04000, 0x8ed78981, BRF_GRA }, 		  //  3 gfx1
1838 	{ "5.3h",			0x04000, 0x0645ec2d, BRF_GRA }, 		  //  4
1839 	{ "6.3g",			0x04000, 0x99e9cb27, BRF_GRA }, 		  //  5
1840 
1841 	{ "1.3p",			0x04000, 0xd78fae6e, BRF_GRA }, 		  //  6 gfx2
1842 	{ "3.3l",			0x04000, 0x37df4a4c, BRF_GRA }, 		  //  7
1843 	{ "2.3n",			0x04000, 0x3a46e354, BRF_GRA }, 		  //  8
1844 
1845 	{ "tbp24s10n.3a",	0x00100, 0xa784e71f, BRF_OPT }, 	 	  //  9 proms
1846 	{ "tbp24s10n.4d",	0x00100, 0x376df30c, BRF_OPT }, 		  // 10
1847 	{ "tbp24s10n.4a",	0x00100, 0x4edff5bd, BRF_OPT }, 		  // 11
1848 	{ "tbp24s10n.3d",	0x00100, 0xfe201a4e, BRF_OPT }, 		  // 12
1849 	{ "tbp24s10n.3b",	0x00100, 0x5796cc4a, BRF_OPT }, 	  	  // 13
1850 	{ "tbp24s10n.3c",	0x00100, 0x28b5ee4c, BRF_OPT }, 		  // 14
1851 };
1852 STD_ROM_PICK(gigas)
1853 STD_ROM_FN(gigas)
1854 
1855 struct BurnDriver BurnDrvGigas = {
1856 	"gigas", NULL, NULL, NULL, "1986",
1857 	"Gigas (MC-8123, 317-5002)\0", NULL, "SEGA", "Miscellaneous",
1858 	NULL, NULL, NULL, NULL,
1859 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_BREAKOUT, 0,
1860 	NULL, gigasRomInfo, gigasRomName, NULL, NULL, NULL, NULL, GigasInputInfo, GigasDIPInfo,
1861 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
1862 	224, 256, 3, 4
1863 };
1864 
1865 // Gigas Mark II (MC-8123, 317-5002)
1866 // Gigas Mark II is a romswap/upgrade to gigas, and uses the same MC-8123 (317-5002).
1867 
1868 static struct BurnRomInfo gigasm2RomDesc[] = {
1869 	{ "18.8n",			0x04000, 0x32e83d80, BRF_ESS | BRF_PRG }, //  0 maincpu
1870 	{ "17.8r",			0x08000, 0x460dadd2, BRF_ESS | BRF_PRG }, //  1
1871 
1872 	{ "14.3k",			0x04000, 0x20b3405f, BRF_GRA }, 		  //  2 gfx1
1873 	{ "15.3h",			0x04000, 0xd04ecfa8, BRF_GRA }, 		  //  3
1874 	{ "16.3g",			0x04000, 0x33776801, BRF_GRA }, 		  //  4
1875 
1876 	{ "11.3p",			0x04000, 0xf64cbd1e, BRF_GRA }, 		  //  5 gfx2
1877 	{ "13.3l",			0x04000, 0xc228df19, BRF_GRA }, 		  //  6
1878 	{ "12.3n",			0x04000, 0xa6ad9ce2, BRF_GRA }, 		  //  7
1879 
1880 	{ "tbp24s10n.3a",	0x00100, 0xa784e71f, BRF_OPT }, 	 	  //  8 proms
1881 	{ "tbp24s10n.4d",	0x00100, 0x376df30c, BRF_OPT }, 		  //  9
1882 	{ "tbp24s10n.4a",	0x00100, 0x4edff5bd, BRF_OPT }, 		  // 10
1883 	{ "tbp24s10n.3d",	0x00100, 0xfe201a4e, BRF_OPT }, 		  // 11
1884 	{ "tbp24s10n.3b",	0x00100, 0x5796cc4a, BRF_OPT }, 	  	  // 12
1885 	{ "tbp24s10n.3c",	0x00100, 0x28b5ee4c, BRF_OPT }, 		  // 13
1886 
1887 	{ "317-5002.key",	0x02000, 0x86a7e5f6, BRF_ESS | BRF_PRG }, // 14
1888 };
1889 STD_ROM_PICK(gigasm2)
1890 STD_ROM_FN(gigasm2)
1891 
1892 struct BurnDriver BurnDrvGigasm2 = {
1893 	"gigasm2", NULL, NULL, NULL, "1986",
1894 	"Gigas Mark II (MC-8123, 317-5002)\0", "Please use gigasm2b instead!", "SEGA", "Miscellaneous",
1895 	NULL, NULL, NULL, NULL,
1896 	BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_BREAKOUT, 0,
1897 	NULL, gigasm2RomInfo, gigasm2RomName, NULL, NULL, NULL, NULL, GigasInputInfo, Gigasm2DIPInfo,
1898 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
1899 	224, 256, 3, 4
1900 };
1901 
1902 // Omega
1903 
1904 static struct BurnRomInfo omegaRomDesc[] = {
1905 	{ "17.m10",		0x4000, 0xc7de0993, BRF_PRG | BRF_ESS }, //  0 maincpu
1906 	{ "8.n10",		0x8000, 0x9bb61910, BRF_PRG | BRF_ESS }, //  1
1907 
1908 	{ "omega.key",  0x2000, 0x0a63943f, BRF_PRG | BRF_ESS }, //  2 maincpu:key
1909 
1910 	{ "4.f10",		0x4000, 0xbf780a8e, BRF_GRA },           //  3 gfx1
1911 	{ "5.h10",		0x4000, 0xb491647f, BRF_GRA },           //  4
1912 	{ "6.j10",		0x4000, 0x65beba5b, BRF_GRA },           //  5
1913 
1914 	{ "3.d10",		0x4000, 0xc678b202, BRF_GRA },           //  6 gfx2
1915 	{ "1.a10",		0x4000, 0xe0aeada9, BRF_GRA },           //  7
1916 	{ "2.c10",		0x4000, 0xdbc0a47f, BRF_GRA },           //  8
1917 
1918 	{ "tbp24s10n.3f",	0x0100, 0x75ec7472, BRF_GRA },           //  9 proms
1919 	{ "tbp24s10n.4f",	0x0100, 0x5113a114, BRF_GRA },           // 10
1920 	{ "tbp24s10n.3g",	0x0100, 0xb6b5d4a0, BRF_GRA },           // 11
1921 	{ "tbp24s10n.4g",	0x0100, 0x931bc299, BRF_GRA },           // 12
1922 	{ "tbp24s10n.3e",	0x0100, 0x899e089d, BRF_GRA },           // 13
1923 	{ "tbp24s10n.4e",	0x0100, 0x28321dd8, BRF_GRA },           // 14
1924 };
1925 
1926 STD_ROM_PICK(omega)
1927 STD_ROM_FN(omega)
1928 
1929 struct BurnDriver BurnDrvOmega = {
1930 	"omega", NULL, NULL, NULL, "1986",
1931 	"Omega\0", NULL, "Nihon System", "Miscellaneous",
1932 	NULL, NULL, NULL, NULL,
1933 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_PRE90S, GBF_BREAKOUT, 0,
1934 	NULL, omegaRomInfo, omegaRomName, NULL, NULL, NULL, NULL, GigasInputInfo, OmegaDIPInfo,
1935 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
1936 	224, 256, 3, 4
1937 };
1938 
1939 
1940