1 // FB Alpha Deco Cassette driver module
2 // Based on MAME driver by Juergen Buchmueller, David Haywood, Ajrhacker
3 // Uses tape loader & protection code by Juergen Buchmueller, David Haywood
4 // Some graphics routines by Juergen Buchmueller, David Haywood, Ajrhacker
5 
6 /*
7 note --
8 cflyball, cpsoccer, coozumou, & zeroize overload bios (glitches normal)
9 */
10 
11 #include "tiles_generic.h"
12 #include "m6502_intf.h"
13 #include "bitswap.h"
14 #include "flt_rc.h"
15 #include "i8x41.h"
16 #include "ay8910.h"
17 
18 static UINT8 *AllMem;
19 static UINT8 *MemEnd;
20 static UINT8 *AllRam;
21 static UINT8 *RamEnd;
22 static UINT8 *DrvMainBIOS;
23 static UINT8 *DrvSoundBIOS;
24 static UINT8 *DrvCassette;
25 static UINT32 DrvCassetteLen; // here for now
26 static UINT8 *DrvDongle;
27 static UINT8 *DrvGfxData;
28 static UINT8 *DrvMCUROM;
29 static UINT8 *DrvCharExp;
30 static UINT8 *DrvTileExp;
31 static UINT8 *DrvObjExp;
32 static UINT8 *DrvMainRAM;
33 static UINT8 *DrvCharRAM;
34 static UINT8 *DrvFgRAM;
35 static UINT8 *DrvColRAM;
36 static UINT8 *DrvTileRAM;
37 static UINT8 *DrvObjRAM;
38 static UINT8 *DrvPalRAM;
39 static UINT8 *DrvSoundRAM;
40 static UINT8 *DrvPalLut;
41 static UINT32 *DrvPaletteTable;
42 static UINT32 *DrvPalette;
43 static UINT8 DrvRecalc;
44 
45 static UINT16 *pTempDraw[2];
46 
47 static UINT8 decocass_reset;
48 
49 static UINT8 watchdog_count;
50 static UINT8 watchdog_flip;
51 static INT32 watchdog;
52 
53 static UINT8 soundlatch;
54 static UINT8 soundlatch2;
55 static UINT8 sound_ack;
56 static UINT8 audio_nmi_enabled;
57 static UINT8 audio_nmi_state;
58 
59 static INT32 burgertime_mode = 0; // for sound-fix
60 static INT32 skater_mode = 0;
61 
62 static INT32 e900_enable = 0;
63 static INT32 e900_gfxbank = 0;
64 
65 static UINT8 mux_data;
66 
67 static UINT8 color_missiles;
68 static UINT8 mode_set;
69 static UINT8 color_center_bot;
70 static UINT8 back_h_shift;
71 static UINT8 back_vl_shift;
72 static UINT8 back_vr_shift;
73 static UINT8 part_h_shift;
74 static UINT8 part_v_shift;
75 static UINT8 center_h_shift_space;
76 static UINT8 center_v_shift;
77 
78 static INT32 vblank;
79 static INT32 flipscreen = 0;
80 
81 static UINT8 i8041_p1;
82 static UINT8 i8041_p2;
83 
84 static void (*prot_write)(UINT16, UINT8) = NULL;
85 static UINT8 (*prot_read)(UINT16) = NULL;
86 
87 #define E5XX_MASK   0x02
88 
89 #define MAKE_MAP(m0,m1,m2,m3,m4,m5,m6,m7)	\
90 	((UINT32)(m0)) | \
91 	((UINT32)(m1) << 3) | \
92 	((UINT32)(m2) << 6) | \
93 	((UINT32)(m3) << 9) | \
94 	((UINT32)(m4) << 12) | \
95 	((UINT32)(m5) << 15) | \
96 	((UINT32)(m6) << 18) | \
97 	((UINT32)(m7) << 21)
98 
99 #define T1MAP(x, m) (((m)>>(x*3))&7)
100 
101 static UINT32 type1_inmap = 0;
102 static UINT32 type1_outmap = 0;
103 static UINT8  type1_latch1 = 0;
104 static UINT8 *type1_map = NULL;
105 
106 #define T1PROM 1
107 #define T1DIRECT 2
108 #define T1LATCH 4
109 #define T1LATCHINV 8
110 
111 static UINT8 type2_xx_latch = 0;
112 static UINT8 type2_d2_latch = 0;
113 static UINT8 type2_promaddr = 0;
114 
115 enum {
116 	TYPE3_SWAP_01,
117 	TYPE3_SWAP_12,
118 	TYPE3_SWAP_13,
119 	TYPE3_SWAP_24,
120 	TYPE3_SWAP_25,
121 	TYPE3_SWAP_34_0,
122 	TYPE3_SWAP_34_7,
123 	TYPE3_SWAP_45,
124 	TYPE3_SWAP_23_56,
125 	TYPE3_SWAP_56,
126 	TYPE3_SWAP_67
127 };
128 
129 static UINT8 type3_pal_19 = 0;
130 static UINT16 type3_ctrs = 0;
131 static UINT8 type3_swap = 0;
132 static UINT8 type3_d0_latch = 0;
133 
134 static UINT16 type4_ctrs = 0;
135 static UINT8 type4_latch = 0;
136 
137 static UINT8 DrvJoy1[8];
138 static UINT8 DrvJoy2[8];
139 static UINT8 DrvJoy3[8];
140 static UINT8 DrvJoy4[8];
141 static UINT8 DrvJoy5[8];
142 static UINT8 DrvJoy6[8];
143 static UINT8 DrvJoy7[8];
144 static UINT8 DrvJoy8[8];
145 static UINT8 DrvJoy9[8];
146 static UINT8 DrvJoy10[8];
147 static UINT8 DrvJoy11[8];
148 static UINT8 DrvInputs[11];
149 static UINT8 DrvDips[3]; // #2 is bios dip
150 static UINT8 DrvReset;
151 
152 static INT32 fourway_mode = 0;
153 
154 // analog inputs - not emulated - unused by games in this system.
155 
156 static struct BurnInputInfo DecocassInputList[] = {
157 	{"P1 Coin",		BIT_DIGITAL,	DrvJoy3 + 7,	"p1 coin"	},
158 	{"P1 Start",		BIT_DIGITAL,	DrvJoy3 + 3,	"p1 start"	},
159 	{"P1 Up",		BIT_DIGITAL,	DrvJoy1 + 2,	"p1 up"		},
160 	{"P1 Down",		BIT_DIGITAL,	DrvJoy1 + 3,	"p1 down"	},
161 	{"P1 Left",		BIT_DIGITAL,	DrvJoy1 + 1,	"p1 left"	},
162 	{"P1 Right",		BIT_DIGITAL,	DrvJoy1 + 0,	"p1 right"	},
163 	{"P1 Button 1",		BIT_DIGITAL,	DrvJoy1 + 4,	"p1 fire 1"	},
164 	{"P1 Button 2",		BIT_DIGITAL,	DrvJoy1 + 5,	"p1 fire 2"	},
165 
166 	{"P2 Coin",		BIT_DIGITAL,	DrvJoy3 + 6,	"p2 coin"	},
167 	{"P2 Start",		BIT_DIGITAL,	DrvJoy3 + 4,	"p2 start"	},
168 	{"P2 Up",		BIT_DIGITAL,	DrvJoy2 + 2,	"p2 up"		},
169 	{"P2 Down",		BIT_DIGITAL,	DrvJoy2 + 3,	"p2 down"	},
170 	{"P2 Left",		BIT_DIGITAL,	DrvJoy2 + 1,	"p2 left"	},
171 	{"P2 Right",		BIT_DIGITAL,	DrvJoy2 + 0,	"p2 right"	},
172 	{"P2 Button 1",		BIT_DIGITAL,	DrvJoy2 + 4,	"p2 fire 1"	},
173 	{"P2 Button 2",		BIT_DIGITAL,	DrvJoy2 + 5,	"p2 fire 2"	},
174 
175 	{"Reset",		BIT_DIGITAL,	&DrvReset,	"reset"		},
176 	{"Dip A",		BIT_DIPSWITCH,	DrvDips + 0,	"dip"		},
177 	{"Dip B",		BIT_DIPSWITCH,	DrvDips + 1,	"dip"		},
178 	{"Bios setting",	BIT_DIPSWITCH,	DrvDips + 2,	"dip"		},
179 };
180 
181 STDINPUTINFO(Decocass)
182 
183 static struct BurnDIPInfo DecocassDIPList[]=
184 {
185 	{0x11, 0xff, 0xff, 0xff, NULL			},
186 	{0x12, 0xff, 0xff, 0xff, NULL			},
187 	{0x13, 0xff, 0xff, 0x00, NULL			},
188 
189 	{0   , 0xfe, 0   ,    4, "Coin A"		},
190 	{0x11, 0x01, 0x03, 0x00, "2 Coins 1 Credits"	},
191 	{0x11, 0x01, 0x03, 0x03, "1 Coin  1 Credits"	},
192 	{0x11, 0x01, 0x03, 0x02, "1 Coin  2 Credits"	},
193 	{0x11, 0x01, 0x03, 0x01, "1 Coin  3 Credits"	},
194 
195 	{0   , 0xfe, 0   ,    4, "Coin B"		},
196 	{0x11, 0x01, 0x0c, 0x00, "2 Coins 1 Credits"	},
197 	{0x11, 0x01, 0x0c, 0x0c, "1 Coin  1 Credits"	},
198 	{0x11, 0x01, 0x0c, 0x08, "1 Coin  2 Credits"	},
199 	{0x11, 0x01, 0x0c, 0x04, "1 Coin  3 Credits"	},
200 
201 	{0   , 0xfe, 0   ,    4, "Type of Tape"		},
202 	{0x11, 0x01, 0x30, 0x00, "MT (Big)"		},
203 	{0x11, 0x01, 0x30, 0x10, "invalid?"		},
204 	{0x11, 0x01, 0x30, 0x20, "invalid?"		},
205 	{0x11, 0x01, 0x30, 0x30, "MD (Small)"		},
206 
207 	{0   , 0xfe, 0   ,    2, "Cabinet"		},
208 	{0x11, 0x01, 0x40, 0x00, "Upright"		},
209 	{0x11, 0x01, 0x40, 0x40, "Cocktail"		},
210 
211 	{0   , 0xfe, 0   ,    6, "Country Code"		},
212 	{0x12, 0x01, 0xe0, 0xe0, "A"			},
213 	{0x12, 0x01, 0xe0, 0xc0, "B"			},
214 	{0x12, 0x01, 0xe0, 0xa0, "C"			},
215 	{0x12, 0x01, 0xe0, 0x80, "D"			},
216 	{0x12, 0x01, 0xe0, 0x60, "E"			},
217 	{0x12, 0x01, 0xe0, 0x40, "F"			},
218 
219 	{0   , 0xfe, 0   ,    4, "Bios Version"		},
220 	{0x13, 0x01, 0x03, 0x00, "Japan A, Newer"	},
221 	{0x13, 0x01, 0x03, 0x01, "Japan A, Older"	},
222 	{0x13, 0x01, 0x03, 0x02, "USA B, Newer"		},
223 	{0x13, 0x01, 0x03, 0x03, "USA B, Older"		},
224 };
225 
226 STDDIPINFO(Decocass)
227 
228 static struct BurnDIPInfo CtsttapeDIPList[]=
229 {
230 	{0x13, 0xff, 0xff, 0x02, NULL			},
231 };
232 
233 STDDIPINFOEXT(Ctsttape,	Decocass,	Ctsttape)
234 
235 static struct BurnDIPInfo DecomultDIPList[]=
236 {
237 	{0x13, 0xff, 0xff, 0xff, NULL			},
238 };
239 
240 STDDIPINFOEXT(Decomult,	Decocass,	Decomult)
241 
242 static struct BurnDIPInfo ChwyDIPList[]=
243 {
244 	{0x12, 0xff, 0xff, 0xff, NULL			},
245 	{0x13, 0xff, 0xff, 0x02, NULL			},
246 
247 	{0   , 0xfe, 0   ,    2, "Lives"		},
248 	{0x12, 0x01, 0x01, 0x01, "3"			},
249 	{0x12, 0x01, 0x01, 0x00, "5"			},
250 };
251 
252 STDDIPINFOEXT(Chwy,	Decocass,	Chwy)
253 
254 static struct BurnDIPInfo CptennisDIPList[]=
255 {
256 	{0x12, 0xff, 0xff, 0xff, NULL			},
257 	{0x13, 0xff, 0xff, 0x02, NULL			},
258 
259 	{0   , 0xfe, 0   ,    2, "Lives"		},
260 	{0x12, 0x01, 0x01, 0x01, "2"			},
261 	{0x12, 0x01, 0x01, 0x00, "3"			},
262 };
263 
264 STDDIPINFOEXT(Cptennis,	Decocass,	Cptennis)
265 
266 static struct BurnDIPInfo CptennisjDIPList[]=
267 {
268 	{0x12, 0xff, 0xff, 0xff, NULL			},
269 	{0x13, 0xff, 0xff, 0x00, NULL			},
270 
271 	{0   , 0xfe, 0   ,    2, "Lives"		},
272 	{0x12, 0x01, 0x01, 0x01, "2"			},
273 	{0x12, 0x01, 0x01, 0x00, "3"			},
274 };
275 
276 STDDIPINFOEXT(Cptennisj,	Decocass,	Cptennisj)
277 
278 static struct BurnDIPInfo CmanhatDIPList[]=
279 {
280 	{0x12, 0xff, 0xff, 0xff, NULL			},
281 	{0x13, 0xff, 0xff, 0x00, NULL			},
282 
283 	{0   , 0xfe, 0   ,    2, "Lives"		},
284 	{0x12, 0x01, 0x01, 0x01, "4"			},
285 	{0x12, 0x01, 0x01, 0x00, "6"			},
286 };
287 
288 STDDIPINFOEXT(Cmanhat,	Decocass,	Cmanhat)
289 
290 static struct BurnDIPInfo CterraniDIPList[]=
291 {
292 	{0x12, 0xff, 0xff, 0xff, NULL			},
293 	{0x13, 0xff, 0xff, 0x02, NULL			},
294 
295 	{0   , 0xfe, 0   ,    2, "Lives"		},
296 	{0x12, 0x01, 0x01, 0x01, "3"			},
297 	{0x12, 0x01, 0x01, 0x00, "5"			},
298 
299 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
300 	{0x12, 0x01, 0x06, 0x00, "None"			},
301 	{0x12, 0x01, 0x06, 0x06, "3000"			},
302 	{0x12, 0x01, 0x06, 0x04, "5000"			},
303 	{0x12, 0x01, 0x06, 0x02, "7000"			},
304 
305 	{0   , 0xfe, 0   ,    2, "Rocket Movement"	},
306 	{0x12, 0x01, 0x08, 0x08, "Easy"			},
307 	{0x12, 0x01, 0x08, 0x00, "Difficult"		},
308 
309 	{0   , 0xfe, 0   ,    2, "Alien Craft Movement"	},
310 	{0x12, 0x01, 0x10, 0x10, "Easy"			},
311 	{0x12, 0x01, 0x10, 0x00, "Difficult"		},
312 };
313 
314 STDDIPINFOEXT(Cterrani,	Decocass,	Cterrani)
315 
316 static struct BurnDIPInfo CastfantDIPList[]=
317 {
318 	{0x12, 0xff, 0xff, 0xff, NULL			},
319 	{0x13, 0xff, 0xff, 0x02, NULL			},
320 
321 	{0   , 0xfe, 0   ,    2, "Lives"		},
322 	{0x12, 0x01, 0x01, 0x01, "3"			},
323 	{0x12, 0x01, 0x01, 0x00, "5"			},
324 };
325 
326 STDDIPINFOEXT(Castfant,	Decocass,	Castfant)
327 
328 static struct BurnDIPInfo CsuperasDIPList[]=
329 {
330 	{0x12, 0xff, 0xff, 0xef, NULL			},
331 	{0x13, 0xff, 0xff, 0x02, NULL			},
332 
333 	{0   , 0xfe, 0   ,    2, "Lives"		},
334 	{0x12, 0x01, 0x01, 0x01, "3"			},
335 	{0x12, 0x01, 0x01, 0x00, "5"			},
336 
337 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
338 	{0x12, 0x01, 0x06, 0x00, "None"			},
339 	{0x12, 0x01, 0x06, 0x06, "20000"		},
340 	{0x12, 0x01, 0x06, 0x04, "30000"		},
341 	{0x12, 0x01, 0x06, 0x02, "40000"		},
342 
343 	{0   , 0xfe, 0   ,    2, "Alien Craft Movement"	},
344 	{0x12, 0x01, 0x08, 0x08, "Easy"			},
345 	{0x12, 0x01, 0x08, 0x00, "Difficult"		},
346 };
347 
348 STDDIPINFOEXT(Csuperas, Decocass, Csuperas)
349 
350 static struct BurnDIPInfo CtislandDIPList[]=
351 {
352 	{0x12, 0xff, 0xff, 0xef, NULL			},
353 	{0x13, 0xff, 0xff, 0x02, NULL			},
354 
355 	{0   , 0xfe, 0   ,    2, "Lives"		},
356 	{0x12, 0x01, 0x01, 0x01, "3"			},
357 	{0x12, 0x01, 0x01, 0x00, "5"			},
358 
359 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
360 	{0x12, 0x01, 0x06, 0x06, "15000"		},
361 	{0x12, 0x01, 0x06, 0x04, "20000"		},
362 	{0x12, 0x01, 0x06, 0x02, "25000"		},
363 	{0x12, 0x01, 0x06, 0x00, "30000"		},
364 };
365 
366 STDDIPINFOEXT(Ctisland, Decocass, Ctisland)
367 
368 static struct BurnDIPInfo Cocean1aDIPList[]=
369 {
370 	{0x12, 0xff, 0xff, 0xff, NULL			},
371 	{0x13, 0xff, 0xff, 0x00, NULL			},
372 
373 	{0   , 0xfe, 0   ,    8, "1 Coin Credit"	},
374 	{0x11, 0x01, 0x07, 0x07, "1"			},
375 	{0x11, 0x01, 0x07, 0x06, "2"			},
376 	{0x11, 0x01, 0x07, 0x05, "5"			},
377 	{0x11, 0x01, 0x07, 0x04, "10"			},
378 	{0x11, 0x01, 0x07, 0x03, "20"			},
379 	{0x11, 0x01, 0x07, 0x02, "30"			},
380 	{0x11, 0x01, 0x07, 0x01, "40"			},
381 	{0x11, 0x01, 0x07, 0x00, "50"			},
382 
383 	{0   , 0xfe, 0   ,    2, "None"			},
384 	{0x11, 0x01, 0x08, 0x08, "Off"			},
385 	{0x11, 0x01, 0x08, 0x00, "None"			},
386 
387 	{0   , 0xfe, 0   ,    4, "Key Switch Credit"	},
388 	{0x12, 0x01, 0x03, 0x03, "1 Coin 10 Credits"	},
389 	{0x12, 0x01, 0x03, 0x02, "1 Coin 20 Credits"	},
390 	{0x12, 0x01, 0x03, 0x01, "1 Coin 50 Credits"	},
391 	{0x12, 0x01, 0x03, 0x00, "1 Coin 100 Credits"	},
392 
393 	{0   , 0xfe, 0   ,    2, "Game Select"		},
394 	{0x12, 0x01, 0x04, 0x04, "1 to 8 Lines"		},
395 	{0x12, 0x01, 0x04, 0x00, "Center Line"		},
396 
397 	{0   , 0xfe, 0   ,    2, "Background Music"	},
398 	{0x12, 0x01, 0x08, 0x08, "Off"			},
399 	{0x12, 0x01, 0x08, 0x00, "On"			},
400 
401 	{0   , 0xfe, 0   ,    2, "Pay Out %"		},
402 	{0x12, 0x01, 0x10, 0x10, "Payout 75%"		},
403 	{0x12, 0x01, 0x10, 0x00, "Payout 85%"		},
404 };
405 
406 STDDIPINFOEXT(Cocean1a,	Decocass,	Cocean1a)
407 
408 static struct BurnDIPInfo Cocean6bDIPList[]=
409 {
410 	{0x12, 0xff, 0xff, 0xff, NULL			},
411 	{0x13, 0xff, 0xff, 0x02, NULL			},
412 
413 	{0   , 0xfe, 0   ,    8, "1 Coin Credit"	},
414 	{0x11, 0x01, 0x07, 0x07, "1"			},
415 	{0x11, 0x01, 0x07, 0x06, "2"			},
416 	{0x11, 0x01, 0x07, 0x05, "5"			},
417 	{0x11, 0x01, 0x07, 0x04, "10"			},
418 	{0x11, 0x01, 0x07, 0x03, "20"			},
419 	{0x11, 0x01, 0x07, 0x02, "30"			},
420 	{0x11, 0x01, 0x07, 0x01, "40"			},
421 	{0x11, 0x01, 0x07, 0x00, "50"			},
422 
423 	{0   , 0xfe, 0   ,    2, "None"			},
424 	{0x11, 0x01, 0x08, 0x08, "Off"			},
425 	{0x11, 0x01, 0x08, 0x00, "None"			},
426 
427 	{0   , 0xfe, 0   ,    4, "Key Switch Credit"	},
428 	{0x12, 0x01, 0x03, 0x03, "1 Coin 10 Credits"	},
429 	{0x12, 0x01, 0x03, 0x02, "1 Coin 20 Credits"	},
430 	{0x12, 0x01, 0x03, 0x01, "1 Coin 50 Credits"	},
431 	{0x12, 0x01, 0x03, 0x00, "1 Coin 100 Credits"	},
432 
433 	{0   , 0xfe, 0   ,    2, "Game Select"		},
434 	{0x12, 0x01, 0x04, 0x04, "1 to 8 Lines"		},
435 	{0x12, 0x01, 0x04, 0x00, "Center Line"		},
436 
437 	{0   , 0xfe, 0   ,    2, "Background Music"	},
438 	{0x12, 0x01, 0x08, 0x08, "Off"			},
439 	{0x12, 0x01, 0x08, 0x00, "On"			},
440 
441 	{0   , 0xfe, 0   ,    2, "Pay Out %"		},
442 	{0x12, 0x01, 0x10, 0x10, "Payout 75%"		},
443 	{0x12, 0x01, 0x10, 0x00, "Payout 85%"		},
444 };
445 
446 STDDIPINFOEXT(Cocean6b,	Decocass,	Cocean6b)
447 
448 static struct BurnDIPInfo ClocknchDIPList[]=
449 {
450 	{0x12, 0xff, 0xff, 0xff, NULL			},
451 	{0x13, 0xff, 0xff, 0x02, NULL			},
452 
453 	{0   , 0xfe, 0   ,    2, "Lives"		},
454 	{0x12, 0x01, 0x01, 0x01, "3"			},
455 	{0x12, 0x01, 0x01, 0x00, "5"			},
456 
457 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
458 	{0x12, 0x01, 0x06, 0x00, "None"			},
459 	{0x12, 0x01, 0x06, 0x06, "15000"		},
460 	{0x12, 0x01, 0x06, 0x04, "20000"		},
461 	{0x12, 0x01, 0x06, 0x02, "30000"		},
462 
463 	{0   , 0xfe, 0   ,    2, "Game Speed"		},
464 	{0x12, 0x01, 0x08, 0x08, "Slow"			},
465 	{0x12, 0x01, 0x08, 0x00, "Hard"			},
466 };
467 
468 STDDIPINFOEXT(Clocknch,	Decocass,	Clocknch)
469 
470 static struct BurnDIPInfo ClocknchjDIPList[]=
471 {
472 	{0x12, 0xff, 0xff, 0xff, NULL			},
473 	{0x13, 0xff, 0xff, 0x00, NULL			},
474 
475 	{0   , 0xfe, 0   ,    2, "Lives"		},
476 	{0x12, 0x01, 0x01, 0x01, "3"			},
477 	{0x12, 0x01, 0x01, 0x00, "5"			},
478 
479 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
480 	{0x12, 0x01, 0x06, 0x00, "None"			},
481 	{0x12, 0x01, 0x06, 0x06, "15000"		},
482 	{0x12, 0x01, 0x06, 0x04, "20000"		},
483 	{0x12, 0x01, 0x06, 0x02, "30000"		},
484 };
485 
486 STDDIPINFOEXT(Clocknchj,	Decocass,	Clocknchj)
487 
488 static struct BurnDIPInfo CprogolfDIPList[]=
489 {
490 	{0x12, 0xff, 0xff, 0xff, NULL			},
491 	{0x13, 0xff, 0xff, 0x02, NULL			},
492 
493 	{0   , 0xfe, 0   ,    2, "Lives"		},
494 	{0x12, 0x01, 0x01, 0x01, "2"			},
495 	{0x12, 0x01, 0x01, 0x00, "3"			},
496 
497 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
498 	{0x12, 0x01, 0x06, 0x00, "None"			},
499 	{0x12, 0x01, 0x06, 0x02, "6 Under"		},
500 	{0x12, 0x01, 0x06, 0x04, "3 Under"		},
501 	{0x12, 0x01, 0x06, 0x06, "1 Under"		},
502 
503 	{0   , 0xfe, 0   ,    2, "Number of Strokes"	},
504 	{0x12, 0x01, 0x08, 0x00, "Par +2"		},
505 	{0x12, 0x01, 0x08, 0x08, "Par +3"		},
506 
507 	{0   , 0xfe, 0   ,    2, "Stroke Power/Ball Direction"		},
508 	{0x12, 0x01, 0x10, 0x10, "Off"			},
509 	{0x12, 0x01, 0x10, 0x00, "On"			},
510 };
511 
512 STDDIPINFOEXT(Cprogolf,	Decocass,	Cprogolf)
513 
514 static struct BurnDIPInfo CprogolfjDIPList[]=
515 {
516 	{0x12, 0xff, 0xff, 0xff, NULL			},
517 	{0x13, 0xff, 0xff, 0x00, NULL			},
518 
519 	{0   , 0xfe, 0   ,    2, "Lives"		},
520 	{0x12, 0x01, 0x01, 0x01, "2"			},
521 	{0x12, 0x01, 0x01, 0x00, "3"			},
522 
523 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
524 	{0x12, 0x01, 0x06, 0x00, "None"			},
525 	{0x12, 0x01, 0x06, 0x02, "6 Under"		},
526 	{0x12, 0x01, 0x06, 0x04, "3 Under"		},
527 	{0x12, 0x01, 0x06, 0x06, "1 Under"		},
528 
529 	{0   , 0xfe, 0   ,    2, "Number of Strokes"	},
530 	{0x12, 0x01, 0x08, 0x00, "Par +2"		},
531 	{0x12, 0x01, 0x08, 0x08, "Par +3"		},
532 
533 	{0   , 0xfe, 0   ,    2, "Stroke Power/Ball Direction"		},
534 	{0x12, 0x01, 0x10, 0x10, "Off"			},
535 	{0x12, 0x01, 0x10, 0x00, "On"			},
536 };
537 
538 STDDIPINFOEXT(Cprogolfj,	Decocass,	Cprogolfj)
539 
540 static struct BurnDIPInfo CexploreDIPList[]=
541 {
542 	{0x12, 0xff, 0xff, 0xff, NULL			},
543 	{0x13, 0xff, 0xff, 0x02, NULL			},
544 
545 	{0   , 0xfe, 0   ,    2, "Lives"		},
546 	{0x12, 0x01, 0x01, 0x01, "3"			},
547 	{0x12, 0x01, 0x01, 0x00, "5"			},
548 
549 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
550 	{0x12, 0x01, 0x06, 0x00, "None"			},
551 	{0x12, 0x01, 0x06, 0x06, "10000"		},
552 	{0x12, 0x01, 0x06, 0x04, "1500000"		},
553 	{0x12, 0x01, 0x06, 0x02, "30000"		},
554 
555 	{0   , 0xfe, 0   ,    2, "Difficulty"		},
556 	{0x12, 0x01, 0x08, 0x08, "Easy"			},
557 	{0x12, 0x01, 0x08, 0x00, "Difficult"		},
558 
559 	{0   , 0xfe, 0   ,    2, "Number of UFOs"	},
560 	{0x12, 0x01, 0x10, 0x10, "Few"			},
561 	{0x12, 0x01, 0x10, 0x00, "Many"			},
562 };
563 
564 STDDIPINFOEXT(Cexplore,	Decocass,	Cexplore)
565 
566 static struct BurnDIPInfo CluckypoDIPList[]=
567 {
568 	{0x12, 0xff, 0xff, 0xff, NULL			},
569 	{0x13, 0xff, 0xff, 0x02, NULL			},
570 
571 	{0   , 0xfe, 0   ,    2, "Show Dealer Hand"	},
572 	{0x12, 0x01, 0x01, 0x00, "Yes"			},
573 	{0x12, 0x01, 0x01, 0x01, "No"			},
574 };
575 
576 STDDIPINFOEXT(Cluckypo,	Decocass,	Cluckypo)
577 
578 static struct BurnDIPInfo Cdiscon1DIPList[]=
579 {
580 	{0x12, 0xff, 0xff, 0xff, NULL			},
581 	{0x13, 0xff, 0xff, 0x02, NULL			},
582 
583 	{0   , 0xfe, 0   ,    2, "Lives"		},
584 	{0x12, 0x01, 0x01, 0x01, "3"			},
585 	{0x12, 0x01, 0x01, 0x00, "5"			},
586 
587 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
588 	{0x12, 0x01, 0x06, 0x00, "None"			},
589 	{0x12, 0x01, 0x06, 0x06, "10000"		},
590 	{0x12, 0x01, 0x06, 0x04, "20000"		},
591 	{0x12, 0x01, 0x06, 0x02, "30000"		},
592 
593 	{0   , 0xfe, 0   ,    2, "Music Weapons"	},
594 	{0x12, 0x01, 0x08, 0x00, "2"			},
595 	{0x12, 0x01, 0x08, 0x08, "1"			},
596 };
597 
598 STDDIPINFOEXT(Cdiscon1,	Decocass,	Cdiscon1)
599 
600 static struct BurnDIPInfo CsweethtDIPList[]=
601 {
602 	{0x12, 0xff, 0xff, 0xff, NULL			},
603 	{0x13, 0xff, 0xff, 0x02, NULL			},
604 
605 	{0   , 0xfe, 0   ,    2, "Lives"		},
606 	{0x12, 0x01, 0x01, 0x01, "3"			},
607 	{0x12, 0x01, 0x01, 0x00, "5"			},
608 
609 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
610 	{0x12, 0x01, 0x06, 0x00, "None"			},
611 	{0x12, 0x01, 0x06, 0x06, "10000"		},
612 	{0x12, 0x01, 0x06, 0x04, "20000"		},
613 	{0x12, 0x01, 0x06, 0x02, "30000"		},
614 
615 	{0   , 0xfe, 0   ,    2, "Music Weapons"	},
616 	{0x12, 0x01, 0x08, 0x00, "8"			},
617 	{0x12, 0x01, 0x08, 0x08, "5"			},
618 };
619 
620 STDDIPINFOEXT(Csweetht,	Decocass,	Csweetht)
621 
622 static struct BurnDIPInfo CtornadoDIPList[]=
623 {
624 	{0x12, 0xff, 0xff, 0xff, NULL			},
625 	{0x13, 0xff, 0xff, 0x02, NULL			},
626 
627 	{0   , 0xfe, 0   ,    2, "Lives"		},
628 	{0x12, 0x01, 0x01, 0x01, "3"			},
629 	{0x12, 0x01, 0x01, 0x00, "5"			},
630 
631 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
632 	{0x12, 0x01, 0x06, 0x00, "None"			},
633 	{0x12, 0x01, 0x06, 0x06, "10000"		},
634 	{0x12, 0x01, 0x06, 0x04, "20000"		},
635 	{0x12, 0x01, 0x06, 0x02, "30000"		},
636 
637 	{0   , 0xfe, 0   ,    2, "Crash Bombs"		},
638 	{0x12, 0x01, 0x08, 0x08, "3"			},
639 	{0x12, 0x01, 0x08, 0x00, "5"			},
640 
641 	{0   , 0xfe, 0   ,    2, "Alens' Speed"		},
642 	{0x12, 0x01, 0x10, 0x10, "Slow"			},
643 	{0x12, 0x01, 0x10, 0x00, "Fast"			},
644 };
645 
646 STDDIPINFOEXT(Ctornado,	Decocass,	Ctornado)
647 
648 static struct BurnDIPInfo CmissnxDIPList[]=
649 {
650 	{0x12, 0xff, 0xff, 0xff, NULL			},
651 	{0x13, 0xff, 0xff, 0x02, NULL			},
652 
653 	{0   , 0xfe, 0   ,    2, "Lives"		},
654 	{0x12, 0x01, 0x01, 0x01, "3"			},
655 	{0x12, 0x01, 0x01, 0x00, "5"			},
656 
657 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
658 	{0x12, 0x01, 0x06, 0x00, "None"			},
659 	{0x12, 0x01, 0x06, 0x06, "5000"			},
660 	{0x12, 0x01, 0x06, 0x04, "10000"		},
661 	{0x12, 0x01, 0x06, 0x02, "15000"		},
662 
663 	{0   , 0xfe, 0   ,    4, "Difficulty"		},
664 	{0x12, 0x01, 0x18, 0x18, "Easy"			},
665 	{0x12, 0x01, 0x18, 0x10, "Normal"		},
666 	{0x12, 0x01, 0x18, 0x08, "Hard"			},
667 	{0x12, 0x01, 0x18, 0x00, "Hardest"		},
668 };
669 
670 STDDIPINFOEXT(Cmissnx,	Decocass,	Cmissnx)
671 
672 static struct BurnDIPInfo CbtimeDIPList[]=
673 {
674 	{0x12, 0xff, 0xff, 0xff, NULL			},
675 	{0x13, 0xff, 0xff, 0x02, NULL			},
676 
677 	{0   , 0xfe, 0   ,    2, "Lives"		},
678 	{0x12, 0x01, 0x01, 0x01, "3"			},
679 	{0x12, 0x01, 0x01, 0x00, "5"			},
680 
681 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
682 	{0x12, 0x01, 0x06, 0x06, "20000"		},
683 	{0x12, 0x01, 0x06, 0x04, "30000"		},
684 	{0x12, 0x01, 0x06, 0x02, "40000"		},
685 	{0x12, 0x01, 0x06, 0x00, "50000"		},
686 
687 	{0   , 0xfe, 0   ,    2, "Enemies"		},
688 	{0x12, 0x01, 0x08, 0x08, "4"			},
689 	{0x12, 0x01, 0x08, 0x00, "6"			},
690 
691 	{0   , 0xfe, 0   ,    2, "End of Level Pepper"	},
692 	{0x12, 0x01, 0x10, 0x10, "No"			},
693 	{0x12, 0x01, 0x10, 0x00, "Yes"			},
694 };
695 
696 STDDIPINFOEXT(Cbtime,	Decocass,	Cbtime)
697 
698 static struct BurnDIPInfo ChamburgerDIPList[]=
699 {
700 	{0x12, 0xff, 0xff, 0xff, NULL			},
701 	{0x13, 0xff, 0xff, 0x00, NULL			},
702 
703 	{0   , 0xfe, 0   ,    2, "Lives"		},
704 	{0x12, 0x01, 0x01, 0x01, "3"			},
705 	{0x12, 0x01, 0x01, 0x00, "5"			},
706 
707 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
708 	{0x12, 0x01, 0x06, 0x06, "20000"		},
709 	{0x12, 0x01, 0x06, 0x04, "30000"		},
710 	{0x12, 0x01, 0x06, 0x02, "40000"		},
711 	{0x12, 0x01, 0x06, 0x00, "50000"		},
712 
713 	{0   , 0xfe, 0   ,    2, "Enemies"		},
714 	{0x12, 0x01, 0x08, 0x08, "4"			},
715 	{0x12, 0x01, 0x08, 0x00, "6"			},
716 
717 	{0   , 0xfe, 0   ,    2, "End of Level Pepper"	},
718 	{0x12, 0x01, 0x10, 0x10, "No"			},
719 	{0x12, 0x01, 0x10, 0x00, "Yes"			},
720 };
721 
722 STDDIPINFOEXT(Chamburger,	Decocass,	Chamburger)
723 
724 static struct BurnDIPInfo CburnrubDIPList[]=
725 {
726 	{0x12, 0xff, 0xff, 0xff, NULL			},
727 	{0x13, 0xff, 0xff, 0x02, NULL			},
728 
729 	{0   , 0xfe, 0   ,    2, "Lives"		},
730 	{0x12, 0x01, 0x01, 0x01, "3"			},
731 	{0x12, 0x01, 0x01, 0x00, "5"			},
732 
733 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
734 	{0x12, 0x01, 0x06, 0x02, "20000"		},
735 	{0x12, 0x01, 0x06, 0x00, "30000"		},
736 	{0x12, 0x01, 0x06, 0x06, "Every 30000"		},
737 	{0x12, 0x01, 0x06, 0x04, "Every 70000"		},
738 
739 	{0   , 0xfe, 0   ,    2, "Allow Continue"	},
740 	{0x12, 0x01, 0x08, 0x08, "Off"			},
741 	{0x12, 0x01, 0x08, 0x00, "On"			},
742 };
743 
744 STDDIPINFOEXT(Cburnrub,	Decocass,	Cburnrub)
745 
746 static struct BurnDIPInfo CgraplopDIPList[]=
747 {
748 	{0x12, 0xff, 0xff, 0xff, NULL			},
749 	{0x13, 0xff, 0xff, 0x02, NULL			},
750 
751 	{0   , 0xfe, 0   ,    2, "Lives"		},
752 	{0x12, 0x01, 0x01, 0x01, "3"			},
753 	{0x12, 0x01, 0x01, 0x00, "5"			},
754 
755 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
756 	{0x12, 0x01, 0x06, 0x00, "None"			},
757 	{0x12, 0x01, 0x06, 0x06, "20000"		},
758 	{0x12, 0x01, 0x06, 0x04, "50000"		},
759 	{0x12, 0x01, 0x06, 0x02, "70000"		},
760 
761 	{0   , 0xfe, 0   ,    2, "Number of Up Sign"	},
762 	{0x12, 0x01, 0x08, 0x08, "Few"			},
763 	{0x12, 0x01, 0x08, 0x00, "Many"			},
764 
765 	{0   , 0xfe, 0   ,    2, "Falling Speed"	},
766 	{0x12, 0x01, 0x10, 0x10, "Easy"			},
767 	{0x12, 0x01, 0x10, 0x00, "Difficult"		},
768 };
769 
770 STDDIPINFOEXT(Cgraplop,	Decocass,	Cgraplop)
771 
772 static struct BurnDIPInfo ClapapaDIPList[]=
773 {
774 	{0x12, 0xff, 0xff, 0xff, NULL			},
775 	{0x13, 0xff, 0xff, 0x02, NULL			},
776 
777 	{0   , 0xfe, 0   ,    2, "Lives"		},
778 	{0x12, 0x01, 0x01, 0x01, "3"			},
779 	{0x12, 0x01, 0x01, 0x00, "5"			},
780 };
781 
782 STDDIPINFOEXT(Clapapa,	Decocass,	Clapapa)
783 
784 static struct BurnDIPInfo CnightstDIPList[]=
785 {
786 	{0x12, 0xff, 0xff, 0xff, NULL			},
787 	{0x13, 0xff, 0xff, 0x02, NULL			},
788 
789 	{0   , 0xfe, 0   ,    2, "Lives"		},
790 	{0x12, 0x01, 0x01, 0x01, "3"			},
791 	{0x12, 0x01, 0x01, 0x00, "5"			},
792 
793 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
794 	{0x12, 0x01, 0x06, 0x06, "When Night Star Completed (First 2 Times)"		},
795 	{0x12, 0x01, 0x06, 0x04, "When Night Star Completed (First Time Only)"		},
796 	{0x12, 0x01, 0x06, 0x02, "Every 70000"		},
797 	{0x12, 0x01, 0x06, 0x00, "30000 Only"		},
798 
799 	{0   , 0xfe, 0   ,    2, "Number of Missles"	},
800 	{0x12, 0x01, 0x08, 0x08, "Few"			},
801 	{0x12, 0x01, 0x08, 0x00, "Many"			},
802 
803 	{0   , 0xfe, 0   ,    2, "Enemy's Speed"	},
804 	{0x12, 0x01, 0x10, 0x10, "Slow"			},
805 	{0x12, 0x01, 0x10, 0x00, "Fast"			},
806 };
807 
808 STDDIPINFOEXT(Cnightst,	Decocass,	Cnightst)
809 
810 static struct BurnDIPInfo CprobowlDIPList[]=
811 {
812 	{0x12, 0xff, 0xff, 0xff, NULL			},
813 	{0x13, 0xff, 0xff, 0x02, NULL			},
814 
815 	{0   , 0xfe, 0   ,    2, "Show Bonus Instructions"	},
816 	{0x12, 0x01, 0x01, 0x00, "Off"			},
817 	{0x12, 0x01, 0x01, 0x01, "On"			},
818 };
819 
820 STDDIPINFOEXT(Cprobowl,	Decocass,	Cprobowl)
821 
822 static struct BurnDIPInfo CskaterDIPList[]=
823 {
824 	{0x12, 0xff, 0xff, 0xff, NULL			},
825 	{0x13, 0xff, 0xff, 0x00, NULL			},
826 
827 	{0   , 0xfe, 0   ,    2, "Lives"		},
828 	{0x12, 0x01, 0x01, 0x01, "3"			},
829 	{0x12, 0x01, 0x01, 0x00, "5"			},
830 
831 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
832 	{0x12, 0x01, 0x06, 0x00, "60000"		},
833 	{0x12, 0x01, 0x06, 0x06, "20000"		},
834 	{0x12, 0x01, 0x06, 0x04, "30000"		},
835 	{0x12, 0x01, 0x06, 0x02, "40000"		},
836 
837 	{0   , 0xfe, 0   ,    2, "Enemy's Speed"	},
838 	{0x12, 0x01, 0x08, 0x08, "Easy"			},
839 	{0x12, 0x01, 0x08, 0x00, "Difficult"		},
840 
841 	{0   , 0xfe, 0   ,    2, "Number of Skates"	},
842 	{0x12, 0x01, 0x10, 0x10, "Small"		},
843 	{0x12, 0x01, 0x10, 0x00, "Large"		},
844 };
845 
846 STDDIPINFOEXT(Cskater,	Decocass,	Cskater)
847 
848 static struct BurnDIPInfo CpsoccerDIPList[]=
849 {
850 	{0x12, 0xff, 0xff, 0xff, NULL			},
851 	{0x13, 0xff, 0xff, 0x02, NULL			},
852 
853 	{0   , 0xfe, 0   ,    2, "Lives"		},
854 	{0x12, 0x01, 0x01, 0x01, "3"			},
855 	{0x12, 0x01, 0x01, 0x00, "5"			},
856 
857 	{0   , 0xfe, 0   ,    4, "Number of Nice Goal"	},
858 	{0x12, 0x01, 0x06, 0x00, "None"			},
859 	{0x12, 0x01, 0x06, 0x06, "5"			},
860 	{0x12, 0x01, 0x06, 0x04, "10"			},
861 	{0x12, 0x01, 0x06, 0x02, "20"			},
862 
863 	{0   , 0xfe, 0   ,    2, "Demo Sounds"		},
864 	{0x12, 0x01, 0x08, 0x00, "Off"			},
865 	{0x12, 0x01, 0x08, 0x08, "On"			},
866 
867 	{0   , 0xfe, 0   ,    2, "Difficulty"		},
868 	{0x12, 0x01, 0x10, 0x10, "Easy"			},
869 	{0x12, 0x01, 0x10, 0x00, "Difficult"		},
870 };
871 
872 STDDIPINFOEXT(Cpsoccer,	Decocass,	Cpsoccer)
873 
874 static struct BurnDIPInfo CpsoccerjDIPList[]=
875 {
876 	{0x12, 0xff, 0xff, 0xff, NULL			},
877 	{0x13, 0xff, 0xff, 0x00, NULL			},
878 
879 	{0   , 0xfe, 0   ,    2, "Lives"		},
880 	{0x12, 0x01, 0x01, 0x01, "3"			},
881 	{0x12, 0x01, 0x01, 0x00, "5"			},
882 
883 	{0   , 0xfe, 0   ,    4, "Number of Nice Goal"	},
884 	{0x12, 0x01, 0x06, 0x00, "None"			},
885 	{0x12, 0x01, 0x06, 0x06, "5"			},
886 	{0x12, 0x01, 0x06, 0x04, "10"			},
887 	{0x12, 0x01, 0x06, 0x02, "20"			},
888 
889 	{0   , 0xfe, 0   ,    2, "Demo Sounds"		},
890 	{0x12, 0x01, 0x08, 0x00, "Off"			},
891 	{0x12, 0x01, 0x08, 0x08, "On"			},
892 
893 	{0   , 0xfe, 0   ,    2, "Difficulty"		},
894 	{0x12, 0x01, 0x10, 0x10, "Easy"			},
895 	{0x12, 0x01, 0x10, 0x00, "Difficult"		},
896 };
897 
898 STDDIPINFOEXT(Cpsoccerj,	Decocass,	Cpsoccerj)
899 
900 static struct BurnDIPInfo CsdtenisDIPList[]=
901 {
902 	{0x12, 0xff, 0xff, 0xff, NULL			},
903 	{0x13, 0xff, 0xff, 0x00, NULL			},
904 
905 	{0   , 0xfe, 0   ,    2, "Lives"		},
906 	{0x12, 0x01, 0x01, 0x01, "2"			},
907 	{0x12, 0x01, 0x01, 0x00, "1"			},
908 
909 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
910 	{0x12, 0x01, 0x06, 0x00, "None"			},
911 	{0x12, 0x01, 0x06, 0x06, "Every 1set"		},
912 	{0x12, 0x01, 0x06, 0x04, "Every 2set"		},
913 	{0x12, 0x01, 0x06, 0x02, "Every 3set"		},
914 
915 	{0   , 0xfe, 0   ,    2, "Speed Level"		},
916 	{0x12, 0x01, 0x08, 0x08, "Low Speed"		},
917 	{0x12, 0x01, 0x08, 0x00, "High Speed"		},
918 
919 	{0   , 0xfe, 0   ,    2, "Attack Level"		},
920 	{0x12, 0x01, 0x10, 0x10, "Easy"			},
921 	{0x12, 0x01, 0x10, 0x00, "Difficult"		},
922 };
923 
924 STDDIPINFOEXT(Csdtenis,	Decocass, Csdtenis)
925 
926 static struct BurnDIPInfo CzeroizeDIPList[]=
927 {
928 	{0x12, 0xff, 0xff, 0xff, NULL			},
929 	{0x13, 0xff, 0xff, 0x02, NULL			},
930 
931 	{0   , 0xfe, 0   ,    2, "Lives"		},
932 	{0x12, 0x01, 0x01, 0x01, "3"			},
933 	{0x12, 0x01, 0x01, 0x00, "5"			},
934 
935 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
936 	{0x12, 0x01, 0x06, 0x06, "None"			},
937 	{0x12, 0x01, 0x06, 0x04, "50000"		},
938 	{0x12, 0x01, 0x06, 0x02, "70000"		},
939 	{0x12, 0x01, 0x06, 0x00, "90000"		},
940 };
941 
942 STDDIPINFOEXT(Czeroize,	Decocass,	Czeroize)
943 
944 static struct BurnDIPInfo CppicfDIPList[]=
945 {
946 	{0x12, 0xff, 0xff, 0xff, NULL			},
947 	{0x13, 0xff, 0xff, 0x02, NULL			},
948 
949 	{0   , 0xfe, 0   ,    2, "Lives"		},
950 	{0x12, 0x01, 0x01, 0x01, "3"			},
951 	{0x12, 0x01, 0x01, 0x00, "5"			},
952 
953 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
954 	{0x12, 0x01, 0x06, 0x00, "None"			},
955 	{0x12, 0x01, 0x06, 0x06, "30000"		},
956 	{0x12, 0x01, 0x06, 0x04, "50000"		},
957 	{0x12, 0x01, 0x06, 0x02, "70000"		},
958 
959 	{0   , 0xfe, 0   ,    2, "Infinite Lives"	},
960 	{0x12, 0x01, 0x10, 0x10, "Off"			},
961 	{0x12, 0x01, 0x10, 0x00, "On"			},
962 };
963 
964 STDDIPINFOEXT(Cppicf,	Decocass,	Cppicf)
965 
966 static struct BurnDIPInfo CscrtryDIPList[]=
967 {
968 	{0x12, 0xff, 0xff, 0xff, NULL			},
969 	{0x13, 0xff, 0xff, 0x02, NULL			},
970 
971 	{0   , 0xfe, 0   ,    2, "Lives"		},
972 	{0x12, 0x01, 0x01, 0x01, "2"			},
973 	{0x12, 0x01, 0x01, 0x00, "4"			},
974 
975 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
976 	{0x12, 0x01, 0x06, 0x00, "None"			},
977 	{0x12, 0x01, 0x06, 0x06, "30000"		},
978 	{0x12, 0x01, 0x06, 0x04, "50000"		},
979 	{0x12, 0x01, 0x06, 0x02, "70000"		},
980 
981 	{0   , 0xfe, 0   ,    2, "Difficulty"		},
982 	{0x12, 0x01, 0x08, 0x08, "Easy"			},
983 	{0x12, 0x01, 0x08, 0x00, "Difficult"		},
984 
985 	{0   , 0xfe, 0   ,    2, "Timer(Don't Change)"	},
986 	{0x12, 0x01, 0x10, 0x10, "Timer decrease"	},
987 	{0x12, 0x01, 0x10, 0x00, "Timer infinity"	},
988 };
989 
990 STDDIPINFOEXT(Cscrtry,	Decocass,	Cscrtry)
991 
992 static struct BurnDIPInfo CoozumouDIPList[]=
993 {
994 	{0x12, 0xff, 0xff, 0xff, NULL			},
995 	{0x13, 0xff, 0xff, 0x00, NULL			},
996 
997 	{0   , 0xfe, 0   ,    2, "Lives"		},
998 	{0x12, 0x01, 0x01, 0x01, "2"			},
999 	{0x12, 0x01, 0x01, 0x00, "4"			},
1000 
1001 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
1002 	{0x12, 0x01, 0x06, 0x00, "None"			},
1003 	{0x12, 0x01, 0x06, 0x06, "30000"		},
1004 	{0x12, 0x01, 0x06, 0x04, "50000"		},
1005 	{0x12, 0x01, 0x06, 0x02, "70000"		},
1006 
1007 	{0   , 0xfe, 0   ,    2, "Difficulty"		},
1008 	{0x12, 0x01, 0x08, 0x08, "Easy"			},
1009 	{0x12, 0x01, 0x08, 0x00, "Difficult"		},
1010 
1011 	{0   , 0xfe, 0   ,    2, "Timer(Don't Change)"	},
1012 	{0x12, 0x01, 0x10, 0x10, "Timer decrease"	},
1013 	{0x12, 0x01, 0x10, 0x00, "Timer infinity"	},
1014 };
1015 
1016 STDDIPINFOEXT(Coozumou,	Decocass,	Coozumou)
1017 
1018 static struct BurnDIPInfo CfghticeDIPList[]=
1019 {
1020 	{0x12, 0xff, 0xff, 0xff, NULL			},
1021 	{0x13, 0xff, 0xff, 0x03, NULL			},
1022 
1023 	{0   , 0xfe, 0   ,    2, "Lives"		},
1024 	{0x12, 0x01, 0x01, 0x01, "3"			},
1025 	{0x12, 0x01, 0x01, 0x00, "5"			},
1026 
1027 	{0   , 0xfe, 0   ,    4, "Very Difficult"	},
1028 	{0x12, 0x01, 0x06, 0x04, "Very Easy"		},
1029 	{0x12, 0x01, 0x06, 0x06, "Easy"			},
1030 	{0x12, 0x01, 0x06, 0x00, "Difficult"		},
1031 	{0x12, 0x01, 0x06, 0x02, "Very Difficult"	},
1032 
1033 	{0   , 0xfe, 0   ,    2, "Enemy's Speed"	},
1034 	{0x12, 0x01, 0x08, 0x08, "Normal"		},
1035 	{0x12, 0x01, 0x08, 0x00, "Fast"			},
1036 
1037 	{0   , 0xfe, 0   ,    2, "Service Mode"		},
1038 	{0x12, 0x01, 0x10, 0x10, "Off"			},
1039 	{0x12, 0x01, 0x10, 0x00, "On"			},
1040 };
1041 
1042 STDDIPINFOEXT(Cfghtice,	Decocass,	Cfghtice)
1043 
1044 static struct BurnDIPInfo CbdashDIPList[]=
1045 {
1046 	{0x12, 0xff, 0xff, 0xff, NULL			},
1047 	{0x13, 0xff, 0xff, 0x03, NULL			},
1048 
1049 	{0   , 0xfe, 0   ,    2, "Lives"		},
1050 	{0x12, 0x01, 0x01, 0x01, "3"			},
1051 	{0x12, 0x01, 0x01, 0x00, "5"			},
1052 
1053 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
1054 	{0x12, 0x01, 0x06, 0x00, "None"			},
1055 	{0x12, 0x01, 0x06, 0x06, "20000"		},
1056 	{0x12, 0x01, 0x06, 0x04, "30000"		},
1057 	{0x12, 0x01, 0x06, 0x02, "40000"		},
1058 
1059 	{0   , 0xfe, 0   ,    4, "Difficulty"		},
1060 	{0x12, 0x01, 0x18, 0x18, "Normal"		},
1061 	{0x12, 0x01, 0x18, 0x10, "Hard"			},
1062 	{0x12, 0x01, 0x18, 0x08, "Harder"		},
1063 	{0x12, 0x01, 0x18, 0x00, "Hardest"		},
1064 };
1065 
1066 STDDIPINFOEXT(Cbdash,	Decocass,	Cbdash)
1067 
1068 static struct BurnDIPInfo CfishingDIPList[]=
1069 {
1070 	{0x12, 0xff, 0xff, 0xef, NULL			},
1071 	{0x13, 0xff, 0xff, 0x03, NULL			},
1072 
1073 	{0   , 0xfe, 0   ,    2, "Lives"		},
1074 	{0x12, 0x01, 0x01, 0x01, "3"			},
1075 	{0x12, 0x01, 0x01, 0x00, "5"			},
1076 
1077 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
1078 	{0x12, 0x01, 0x06, 0x00, "None"			},
1079 	{0x12, 0x01, 0x06, 0x06, "10000"		},
1080 	{0x12, 0x01, 0x06, 0x04, "20000"		},
1081 	{0x12, 0x01, 0x06, 0x02, "30000"		},
1082 
1083 	{0   , 0xfe, 0   ,    2, "Difficulty"		},
1084 	{0x12, 0x01, 0x08, 0x08, "Easy"			},
1085 	{0x12, 0x01, 0x08, 0x00, "Difficult"		},
1086 };
1087 
1088 STDDIPINFOEXT(Cfishing,	Decocass,	Cfishing)
1089 
1090 static struct BurnDIPInfo CfishingjDIPList[]=
1091 {
1092 	{0x12, 0xff, 0xff, 0xef, NULL			},
1093 	{0x13, 0xff, 0xff, 0x00, NULL			},
1094 
1095 	{0   , 0xfe, 0   ,    2, "Lives"		},
1096 	{0x12, 0x01, 0x01, 0x01, "3"			},
1097 	{0x12, 0x01, 0x01, 0x00, "5"			},
1098 
1099 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
1100 	{0x12, 0x01, 0x06, 0x00, "None"			},
1101 	{0x12, 0x01, 0x06, 0x06, "10000"		},
1102 	{0x12, 0x01, 0x06, 0x04, "20000"		},
1103 	{0x12, 0x01, 0x06, 0x02, "30000"		},
1104 
1105 	{0   , 0xfe, 0   ,    2, "Difficulty"		},
1106 	{0x12, 0x01, 0x08, 0x08, "Easy"			},
1107 	{0x12, 0x01, 0x08, 0x00, "Difficult"		},
1108 };
1109 
1110 STDDIPINFOEXT(Cfishingj,	Decocass,	Cfishingj)
1111 
1112 static struct BurnDIPInfo Cfboy0a1DIPList[]=
1113 {
1114 	{0x12, 0xff, 0xff, 0xff, NULL			},
1115 	{0x13, 0xff, 0xff, 0x00, NULL			},
1116 
1117 	{0   , 0xfe, 0   ,    2, "Number of The Deco Kids"	},
1118 	{0x12, 0x01, 0x01, 0x01, "3"			},
1119 	{0x12, 0x01, 0x01, 0x00, "5"			},
1120 
1121 	{0   , 0xfe, 0   ,    4, "Bonus Points"		},
1122 	{0x12, 0x01, 0x06, 0x06, "5000"			},
1123 	{0x12, 0x01, 0x06, 0x04, "10000"		},
1124 	{0x12, 0x01, 0x06, 0x02, "15000"		},
1125 	{0x12, 0x01, 0x06, 0x00, "None"			},
1126 
1127 	{0   , 0xfe, 0   ,    2, "Number of Alien Missiles"	},
1128 	{0x12, 0x01, 0x08, 0x08, "Easy"			},
1129 	{0x12, 0x01, 0x08, 0x00, "Difficult"		},
1130 
1131 	{0   , 0xfe, 0   ,    2, "Alien Craft Movement"	},
1132 	{0x12, 0x01, 0x10, 0x10, "Easy"			},
1133 	{0x12, 0x01, 0x10, 0x00, "Difficult"		},
1134 };
1135 
1136 STDDIPINFOEXT(Cfboy0a1,	Decocass,	Cfboy0a1)
1137 
1138 static struct BurnDIPInfo CflyballDIPList[]=
1139 {
1140 	{0x12, 0xff, 0xff, 0xff, NULL			},
1141 	{0x13, 0xff, 0xff, 0x02, NULL			},
1142 
1143 	{0   , 0xfe, 0   ,    2, "Lives"		},
1144 	{0x12, 0x01, 0x01, 0x01, "3"			},
1145 	{0x12, 0x01, 0x01, 0x00, "5"			},
1146 
1147 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
1148 	{0x12, 0x01, 0x06, 0x00, "None"			},
1149 	{0x12, 0x01, 0x06, 0x06, "20000"			},
1150 	{0x12, 0x01, 0x06, 0x04, "50000"		},
1151 	{0x12, 0x01, 0x06, 0x02, "70000"		},
1152 
1153 	{0   , 0xfe, 0   ,    2, "Push Backs"		},
1154 	{0x12, 0x01, 0x08, 0x08, "2"			},
1155 	{0x12, 0x01, 0x08, 0x00, "3"			},
1156 };
1157 
1158 STDDIPINFOEXT(Cflyball,	Decocass,	Cflyball)
1159 
1160 static struct BurnInputInfo CdsteljnInputList[] = {
1161 	{"P1 Coin",		BIT_DIGITAL,	DrvJoy3 + 7,	"p1 coin"	},
1162 	{"P1 Start",		BIT_DIGITAL,	DrvJoy3 + 3,	"p1 start"	},
1163 	{"P1 Up",		BIT_DIGITAL,	DrvJoy1 + 2,	"p1 up"		},
1164 	{"P1 Down",		BIT_DIGITAL,	DrvJoy1 + 3,	"p1 down"	},
1165 	{"P1 Left",		BIT_DIGITAL,	DrvJoy1 + 1,	"p1 left"	},
1166 	{"P1 Right",		BIT_DIGITAL,	DrvJoy1 + 0,	"p1 right"	},
1167 	{"P1 Button 1",		BIT_DIGITAL,	DrvJoy1 + 4,	"p1 fire 1"	},
1168 	{"P1 Button 2",		BIT_DIGITAL,	DrvJoy1 + 5,	"p1 fire 2"	},
1169 	{"A",			BIT_DIGITAL,	DrvJoy5 + 0,	"mah a"		},
1170 	{"B",			BIT_DIGITAL,	DrvJoy5 + 1,	"mah b"		},
1171 	{"C",			BIT_DIGITAL,	DrvJoy5 + 2,	"mah c"		},
1172 	{"D",			BIT_DIGITAL,	DrvJoy5 + 3,	"mah d"		},
1173 	{"E",			BIT_DIGITAL,	DrvJoy5 + 4,	"mah e"		},
1174 	{"F",			BIT_DIGITAL,	DrvJoy5 + 5,	"mah f"		},
1175 	{"G",			BIT_DIGITAL,	DrvJoy5 + 6,	"mah g"		},
1176 	{"H",			BIT_DIGITAL,	DrvJoy6 + 0,	"mah h"		},
1177 	{"I",			BIT_DIGITAL,	DrvJoy6 + 1,	"mah i"		},
1178 	{"J",			BIT_DIGITAL,	DrvJoy6 + 2,	"mah j"		},
1179 	{"K",			BIT_DIGITAL,	DrvJoy6 + 3,	"mah k"		},
1180 	{"L",			BIT_DIGITAL,	DrvJoy6 + 4,	"mah l"		},
1181 	{"M",			BIT_DIGITAL,	DrvJoy6 + 5,	"mah m"		},
1182 	{"N",			BIT_DIGITAL,	DrvJoy6 + 6,	"mah n"		},
1183 	{"Pon",			BIT_DIGITAL,	DrvJoy7 + 1,	"mah pon"	},
1184 	{"Chi",			BIT_DIGITAL,	DrvJoy7 + 0,	"mah chi"	},
1185 	{"Kan",			BIT_DIGITAL,	DrvJoy7 + 2,	"mah kan"	},
1186 	{"Ron",			BIT_DIGITAL,	DrvJoy7 + 4,	"mah ron"	},
1187 	{"Reach",		BIT_DIGITAL,	DrvJoy7 + 3,	"mah reach"	},
1188 
1189 	{"P2 Coin",		BIT_DIGITAL,	DrvJoy3 + 6,	"p2 coin"	},
1190 	{"P2 Start",		BIT_DIGITAL,	DrvJoy3 + 4,	"p2 start"	},
1191 	{"P2 Up",		BIT_DIGITAL,	DrvJoy2 + 2,	"p2 up"		},
1192 	{"P2 Down",		BIT_DIGITAL,	DrvJoy2 + 3,	"p2 down"	},
1193 	{"P2 Left",		BIT_DIGITAL,	DrvJoy2 + 1,	"p2 left"	},
1194 	{"P2 Right",		BIT_DIGITAL,	DrvJoy2 + 0,	"p2 right"	},
1195 	{"P2 Button 1",		BIT_DIGITAL,	DrvJoy2 + 4,	"p2 fire 1"	},
1196 	{"P2 Button 2",		BIT_DIGITAL,	DrvJoy2 + 5,	"p2 fire 2"	},
1197 	{"A",			BIT_DIGITAL,	DrvJoy9 + 0,	"mah a"		},
1198 	{"B",			BIT_DIGITAL,	DrvJoy9 + 1,	"mah b"		},
1199 	{"C",			BIT_DIGITAL,	DrvJoy9 + 2,	"mah c"		},
1200 	{"D",			BIT_DIGITAL,	DrvJoy9 + 3,	"mah d"		},
1201 	{"E",			BIT_DIGITAL,	DrvJoy9 + 4,	"mah e"		},
1202 	{"F",			BIT_DIGITAL,	DrvJoy9 + 5,	"mah f"		},
1203 	{"G",			BIT_DIGITAL,	DrvJoy9 + 6,	"mah g"		},
1204 	{"H",			BIT_DIGITAL,	DrvJoy10 + 0,	"mah h"		},
1205 	{"I",			BIT_DIGITAL,	DrvJoy10 + 1,	"mah i"		},
1206 	{"J",			BIT_DIGITAL,	DrvJoy10 + 2,	"mah j"		},
1207 	{"K",			BIT_DIGITAL,	DrvJoy10 + 3,	"mah k"		},
1208 	{"L",			BIT_DIGITAL,	DrvJoy10 + 4,	"mah l"		},
1209 	{"M",			BIT_DIGITAL,	DrvJoy10 + 5,	"mah m"		},
1210 	{"N",			BIT_DIGITAL,	DrvJoy10 + 6,	"mah n"		},
1211 	{"Pon",			BIT_DIGITAL,	DrvJoy11 + 1,	"mah pon"	},
1212 	{"Chi",			BIT_DIGITAL,	DrvJoy11 + 0,	"mah chi"	},
1213 	{"Kan",			BIT_DIGITAL,	DrvJoy11 + 2,	"mah kan"	},
1214 	{"Ron",			BIT_DIGITAL,	DrvJoy11 + 4,	"mah ron"	},
1215 	{"Reach",		BIT_DIGITAL,	DrvJoy11 + 3,	"mah reach"	},
1216 
1217 	{"Reset",		BIT_DIGITAL,	&DrvReset,	"reset"		},
1218 	{"Dip A",		BIT_DIPSWITCH,	DrvDips + 0,	"dip"		},
1219 	{"Dip B",		BIT_DIPSWITCH,	DrvDips + 1,	"dip"		},
1220 	{"Dip C",		BIT_DIPSWITCH,	DrvDips + 2,	"dip"		},
1221 };
1222 
1223 STDINPUTINFO(Cdsteljn)
1224 
1225 static struct BurnDIPInfo CdsteljnDIPList[]=
1226 {
1227 	{0x37, 0xff, 0xff, 0xff, NULL			},
1228 	{0x38, 0xff, 0xff, 0xff, NULL			},
1229 	{0x39, 0xff, 0xff, 0x00, NULL			},
1230 
1231 	{0   , 0xfe, 0   ,    4, "Coin A"		},
1232 	{0x37, 0x01, 0x03, 0x00, "2 Coins 1 Credits"	},
1233 	{0x37, 0x01, 0x03, 0x03, "1 Coin  1 Credits"	},
1234 	{0x37, 0x01, 0x03, 0x02, "1 Coin  2 Credits"	},
1235 	{0x37, 0x01, 0x03, 0x01, "1 Coin  3 Credits"	},
1236 
1237 	{0   , 0xfe, 0   ,    4, "Coin B"		},
1238 	{0x37, 0x01, 0x0c, 0x00, "2 Coins 1 Credits"	},
1239 	{0x37, 0x01, 0x0c, 0x0c, "1 Coin  1 Credits"	},
1240 	{0x37, 0x01, 0x0c, 0x08, "1 Coin  2 Credits"	},
1241 	{0x37, 0x01, 0x0c, 0x04, "1 Coin  3 Credits"	},
1242 
1243 	{0   , 0xfe, 0   ,    4, "Type of Tape"		},
1244 	{0x37, 0x01, 0x30, 0x00, "MT (Big)"		},
1245 	{0x37, 0x01, 0x30, 0x10, "invalid?"		},
1246 	{0x37, 0x01, 0x30, 0x20, "invalid?"		},
1247 	{0x37, 0x01, 0x30, 0x30, "MD (Small)"		},
1248 
1249 	{0   , 0xfe, 0   ,    2, "Cabinet"		},
1250 	{0x37, 0x01, 0x40, 0x00, "Upright"		},
1251 	{0x37, 0x01, 0x40, 0x40, "Cocktail"		},
1252 
1253 	{0   , 0xfe, 0   ,    6, "Country Code"		},
1254 	{0x38, 0x01, 0xe0, 0xe0, "A"			},
1255 	{0x38, 0x01, 0xe0, 0xc0, "B"			},
1256 	{0x38, 0x01, 0xe0, 0xa0, "C"			},
1257 	{0x38, 0x01, 0xe0, 0x80, "D"			},
1258 	{0x38, 0x01, 0xe0, 0x60, "E"			},
1259 	{0x38, 0x01, 0xe0, 0x40, "F"			},
1260 
1261 	{0   , 0xfe, 0   ,    4, "Bios Version"		},
1262 	{0x39, 0x01, 0x03, 0x00, "Japan A, Newer"	},
1263 	{0x39, 0x01, 0x03, 0x01, "Japan A, Older"	},
1264 	{0x39, 0x01, 0x03, 0x02, "USA B, Newer"		},
1265 	{0x39, 0x01, 0x03, 0x03, "USA B, Older"		},
1266 };
1267 
1268 STDDIPINFO(Cdsteljn)
1269 
1270 #define TAPE_CLOCKRATE	4800
1271 #define TAPE_LEADER 	TAPE_CLOCKRATE
1272 #define TAPE_GAP		TAPE_CLOCKRATE*3/2
1273 #define TAPE_HOLE		TAPE_CLOCKRATE/400
1274 #define TAPE_PRE_GAP	34
1275 #define TAPE_LEADIN 	(TAPE_PRE_GAP + 1)
1276 #define TAPE_HEADER 	(TAPE_LEADIN + 1)
1277 #define TAPE_BLOCK		(TAPE_HEADER + 256)
1278 #define TAPE_CRC16_MSB	(TAPE_BLOCK + 1)
1279 #define TAPE_CRC16_LSB	(TAPE_CRC16_MSB + 1)
1280 #define TAPE_TRAILER	(TAPE_CRC16_LSB + 1)
1281 #define TAPE_LEADOUT	(TAPE_TRAILER + 1)
1282 #define TAPE_LONGCLOCK	(TAPE_LEADOUT + 1)
1283 #define TAPE_POST_GAP	(TAPE_LONGCLOCK + 34)
1284 #define TAPE_CHUNK		TAPE_POST_GAP
1285 
1286 static double tape_time0 = 0;
1287 static INT32 tape_speed = 0;
1288 static INT32 tape_timer = 0;
1289 static INT32 tape_dir = 0;
1290 
1291 static INT64 tape_freerun = 0; // continuously counts up from mcu clock
1292 
tapetimer()1293 static double tapetimer()
1294 {
1295 	return tape_freerun * (1.0 / 500000);
1296 }
1297 
tapetimer_reset()1298 static void tapetimer_reset()
1299 {
1300 	tape_freerun = 0;
1301 }
1302 
1303 static INT32 firsttime = 1;
1304 static INT32 tape_blocks;
1305 static INT32 tape_length;
1306 static INT32 tape_bot_eot;
1307 static UINT8 crc16_lsb;
1308 static UINT8 crc16_msb;
1309 static UINT8 tape_crc16_lsb[256];
1310 static UINT8 tape_crc16_msb[256];
1311 
tape_crc16(UINT8 data)1312 static void tape_crc16(UINT8 data)
1313 {
1314 	UINT8 c0, c1;
1315 	UINT8 old_lsb = crc16_lsb;
1316 	UINT8 old_msb = crc16_msb;
1317 	UINT8 feedback;
1318 
1319 	feedback = ((data >> 7) ^ crc16_msb) & 1;
1320 
1321 	c0 = crc16_lsb & 1;
1322 	c1 = crc16_msb & 1;
1323 	crc16_msb = (crc16_msb >> 1) | (c0 << 7);
1324 	crc16_lsb = (crc16_lsb >> 1) | (c1 << 7);
1325 
1326 	if (feedback)
1327 		crc16_lsb |= 0x80;
1328 	else
1329 		crc16_lsb &= ~0x80;
1330 
1331 	if (((old_lsb >> 6) ^ feedback) & 1)
1332 		crc16_lsb |= 0x20;
1333 	else
1334 		crc16_lsb &= ~0x20;
1335 
1336 	if (((old_msb >> 1) ^ feedback) & 1)
1337 		crc16_msb |= 0x01;
1338 	else
1339 		crc16_msb &= ~0x01;
1340 }
1341 
tape_update(void)1342 static void tape_update(void)
1343 {
1344 	INT32 offset, rclk, rdata, tape_bit, tape_byte, tape_block;
1345 	double tape_time = tape_time0;
1346 
1347 	if (tape_timer) tape_time += tape_dir * tapetimer();
1348 
1349 	if (tape_time < 0.0) tape_time = 0.0;
1350 	else if (tape_time > 999.9) tape_time = 999.9;
1351 
1352 	offset = (int)(tape_time * TAPE_CLOCKRATE + 0.499995);
1353 
1354 	rclk = 0;
1355 	rdata = 0;
1356 
1357 	if (offset < TAPE_LEADER)	// LEADER area
1358 	{
1359 		if (offset < 0) offset = 0;
1360 
1361 		if (tape_bot_eot == 0)
1362 		{
1363 			tape_bot_eot = 1;
1364 		}
1365 	}
1366 	else
1367 	if (offset < TAPE_LEADER + TAPE_GAP)	// GAP between LEADER and BOT hole
1368 	{
1369 		if (tape_bot_eot == 1)
1370 		{
1371 			tape_bot_eot = 0;
1372 		}
1373 	}
1374 	else
1375 	if (offset < TAPE_LEADER + TAPE_GAP + TAPE_HOLE)	// during BOT hole
1376 	{
1377 		if (tape_bot_eot == 0)
1378 		{
1379 			tape_bot_eot = 1;
1380 		}
1381 	}
1382 	else
1383 	if (offset < tape_length - TAPE_LEADER - TAPE_GAP - TAPE_HOLE)
1384 	{
1385 		offset -= TAPE_LEADER + TAPE_GAP + TAPE_HOLE;
1386 
1387 		if (tape_bot_eot == 1)	// data area
1388 		{
1389 			tape_bot_eot = 0;
1390 		}
1391 		rclk = (offset ^ 1) & 1;
1392 		tape_bit = (offset / 2) % 8;
1393 		tape_byte = (offset / 16) % TAPE_CHUNK;
1394 		tape_block = offset / 16 / TAPE_CHUNK;
1395 
1396 		if (tape_byte < TAPE_PRE_GAP)
1397 		{
1398 			rclk = 0;
1399 			rdata = 0;
1400 		}
1401 		else if (tape_byte < TAPE_LEADIN)
1402 		{
1403 			rdata = (0x00 >> tape_bit) & 1;
1404 		}
1405 		else if (tape_byte < TAPE_HEADER)
1406 		{
1407 			rdata = (0xaa >> tape_bit) & 1;
1408 		}
1409 		else if (tape_byte < TAPE_BLOCK)
1410 		{
1411 			UINT8 *ptr = DrvCassette + tape_block * 256 + tape_byte - TAPE_HEADER;
1412 			rdata = (*ptr >> tape_bit) & 1;
1413 		}
1414 		else if (tape_byte < TAPE_CRC16_MSB)
1415 		{
1416 			rdata = (tape_crc16_msb[tape_block] >> tape_bit) & 1;
1417 		}
1418 		else if (tape_byte < TAPE_CRC16_LSB)
1419 		{
1420 			rdata = (tape_crc16_lsb[tape_block] >> tape_bit) & 1;
1421 		}
1422 		else if (tape_byte < TAPE_TRAILER)
1423 		{
1424 			rdata = (0xaa >> tape_bit) & 1;
1425 		}
1426 		else if (tape_byte < TAPE_LEADOUT)
1427 		{
1428 			rdata = (0x00 >> tape_bit) & 1;
1429 		}
1430 		else if (tape_byte < TAPE_LONGCLOCK)
1431 		{
1432 			rclk = 1;
1433 			rdata = 0;
1434 		}
1435 	}
1436 	else if (offset < tape_length - TAPE_LEADER - TAPE_GAP)// during EOT hole
1437 	{
1438 		if (tape_bot_eot == 0)
1439 		{
1440 			tape_bot_eot = 1;
1441 		}
1442 	}
1443 	else if (offset < tape_length - TAPE_LEADER)	// GAP between EOT and trailer
1444 	{
1445 		if (tape_bot_eot == 1)
1446 		{
1447 			tape_bot_eot = 0;
1448 		}
1449 	}
1450 	else	// TRAILER area
1451 	{
1452 		if (tape_bot_eot == 0)
1453 		{
1454 			tape_bot_eot = 1;
1455 
1456 		}
1457 		offset = tape_length - 1;
1458 	}
1459 
1460 	i8041_p2 = (i8041_p2 & ~0xe0) | (tape_bot_eot << 5) | (rclk << 6) | (rdata << 7);
1461 }
1462 
tape_stop(void)1463 static void tape_stop(void)
1464 {
1465 	if (tape_timer) {
1466 		tape_time0 += tape_dir * tapetimer();
1467 		tape_timer = 0; // timer off.
1468 	}
1469 }
1470 
decocass_init_common()1471 static void decocass_init_common()
1472 {
1473 	UINT8 *image = DrvCassette;
1474 	INT32 i, offs;
1475 
1476 	tape_dir = 0;
1477 	tape_speed = 0;
1478 	tape_timer = 0;
1479 
1480 	firsttime = 1;
1481 	tape_blocks = 0;
1482 
1483 	for (i = DrvCassetteLen / 256 - 1; !tape_blocks && i > 0; i--)
1484 		for (offs = 256 * i; !tape_blocks && offs < 256 * i + 256; offs++)
1485 			if (image[offs])
1486 				tape_blocks = i+1;
1487 	for (i = 0; i < tape_blocks; i++)
1488 	{
1489 		crc16_lsb = 0;
1490 		crc16_msb = 0;
1491 		for (offs = 256 * i; offs < 256 * i + 256; offs++)
1492 		{
1493 			tape_crc16(image[offs] << 7);
1494 			tape_crc16(image[offs] << 6);
1495 			tape_crc16(image[offs] << 5);
1496 			tape_crc16(image[offs] << 4);
1497 			tape_crc16(image[offs] << 3);
1498 			tape_crc16(image[offs] << 2);
1499 			tape_crc16(image[offs] << 1);
1500 			tape_crc16(image[offs] << 0);
1501 		}
1502 		tape_crc16_lsb[i] = crc16_lsb;
1503 		tape_crc16_msb[i] = crc16_msb;
1504 	}
1505 
1506 	tape_length = tape_blocks * TAPE_CHUNK * 8 * 2 + 2 * (TAPE_LEADER + TAPE_GAP + TAPE_HOLE);
1507 
1508 	tapetimer_reset();
1509 
1510 	tape_time0 = (double)(TAPE_LEADER + TAPE_GAP - TAPE_HOLE) / TAPE_CLOCKRATE;
1511 
1512 	tape_bot_eot = 0;
1513 
1514 	decocass_reset = 0;
1515 	i8041_p1 = 0xff;
1516 	i8041_p2 = 0xff;
1517 
1518 	if (!type1_inmap) type1_inmap = MAKE_MAP(0,1,2,3,4,5,6,7);
1519 	if (!type1_outmap) type1_outmap = MAKE_MAP(0,1,2,3,4,5,6,7);
1520 
1521 	type2_d2_latch = 0;
1522 	type2_xx_latch = 0;
1523 	type2_promaddr = 0;
1524 
1525 	type3_pal_19 = 0;
1526 	type3_ctrs = 0;
1527 	type3_d0_latch = 0;
1528 
1529 	type4_ctrs = 0;
1530 	type4_latch = 0;
1531 }
1532 
decocass_type1_read(UINT16 offset)1533 static UINT8 decocass_type1_read(UINT16 offset)
1534 {
1535 	if (!type1_map)
1536 		return 0x00;
1537 
1538 	UINT8 data;
1539 
1540 	if (1 == (offset & 1))
1541 	{
1542 		if (0 == (offset & E5XX_MASK))
1543 			data = i8x41_get_register(I8X41_STAT);
1544 		else
1545 			data = 0xff;
1546 
1547 		data = (BIT(data, 0) << 0) | (BIT(data, 1) << 1) | 0x7c;
1548 	}
1549 	else
1550 	{
1551 		INT32 promaddr;
1552 		UINT8 save;
1553 		UINT8 *prom = DrvDongle;
1554 
1555 		if (firsttime)
1556 		{
1557 			firsttime = 0;
1558 			type1_latch1 = 0;    /* reset latch (??) */
1559 		}
1560 
1561 		if (0 == (offset & E5XX_MASK))
1562 			data = i8x41_get_register(I8X41_DATA);
1563 		else
1564 			data = 0xff;
1565 
1566 		save = data;    /* save the unmodifed data for the latch */
1567 
1568 		promaddr = 0;
1569 		INT32 promshift = 0;
1570 
1571 		for (INT32 i=0;i<8;i++)
1572 		{
1573 			if (type1_map[i] == T1PROM) { promaddr |= (((data >> T1MAP(i,type1_inmap)) & 1) << promshift); promshift++; }
1574 		}
1575 
1576 		data = 0;
1577 		promshift = 0;
1578 
1579 		for (INT32 i=0;i<8;i++)
1580 		{
1581 			if (type1_map[i] == T1PROM)     { data |= (((prom[promaddr] >> promshift) & 1)               << T1MAP(i,type1_outmap)); promshift++; }
1582 			if (type1_map[i] == T1LATCHINV) { data |= ((1 - ((type1_latch1 >> T1MAP(i,type1_inmap)) & 1)) << T1MAP(i,type1_outmap)); }
1583 			if (type1_map[i] == T1LATCH)    { data |= (((type1_latch1 >> T1MAP(i,type1_inmap)) & 1)    << T1MAP(i,type1_outmap)); }
1584 			if (type1_map[i] == T1DIRECT)   { data |= (((save >> T1MAP(i,type1_inmap)) & 1)        << T1MAP(i,type1_outmap)); }
1585 		}
1586 
1587 		type1_latch1 = save;        /* latch the data for the next A0 == 0 read */
1588 	}
1589 	return data;
1590 }
1591 
decocass_nodongle_read(UINT16 offset)1592 static UINT8 decocass_nodongle_read(UINT16 offset)
1593 {
1594 	if ((offset & 0x02) == 0)
1595 	{
1596 		return i8x41_get_register((offset & 1) ? I8X41_STAT : I8X41_DATA);
1597 	}
1598 
1599 	return 0xff;
1600 }
1601 
decocass_type2_read(UINT16 offset)1602 static UINT8 decocass_type2_read(UINT16 offset)
1603 {
1604 	if (type2_xx_latch == 1)
1605 	{
1606 		if (offset & 1)
1607 			return DrvDongle[256 * type2_d2_latch + type2_promaddr];
1608 
1609 		return 0xff;
1610 	}
1611 	else
1612 	{
1613 		if ((offset & 0x02) == 0)
1614 			return i8x41_get_register((offset & 1) ? I8X41_STAT : I8X41_DATA);
1615 
1616 		return offset;
1617 	}
1618 
1619 	return 0;
1620 }
1621 
decocass_type2_write(UINT16 offset,UINT8 data)1622 static void decocass_type2_write(UINT16 offset, UINT8 data)
1623 {
1624 	if (type2_xx_latch == 1)
1625 	{
1626 		if ((offset & 1) == 0)
1627 		{
1628 			type2_promaddr = data;
1629 			return;
1630 		}
1631 	}
1632 
1633 	if (offset & 1)
1634 	{
1635 		if ((data & 0xf0) == 0xc0)
1636 		{
1637 			type2_xx_latch = 1;
1638 			type2_d2_latch = (data & 0x04) ? 1 : 0;
1639 		}
1640 	}
1641 
1642 	i8x41_set_register((offset & 1) ? I8X41_CMND : I8X41_DATA, data);
1643 }
1644 
decocass_type3_read(UINT16 offset)1645 static UINT8 decocass_type3_read(UINT16 offset)
1646 {
1647 	UINT8 data, save;
1648 
1649 	if (1 == (offset & 1))
1650 	{
1651 		if (1 == type3_pal_19)
1652 		{
1653 			UINT8 *prom = DrvDongle;
1654 			data = prom[type3_ctrs];
1655 			if (++type3_ctrs == 4096)
1656 				type3_ctrs = 0;
1657 		}
1658 		else
1659 		{
1660 			if (0 == (offset & E5XX_MASK))
1661 			{
1662 				data = i8x41_get_register(1 ? I8X41_STAT : I8X41_DATA);
1663 			}
1664 			else
1665 			{
1666 				data = 0xff;    /* open data bus? */
1667 			}
1668 		}
1669 	}
1670 	else
1671 	{
1672 		if (1 == type3_pal_19)
1673 		{
1674 			save = data = 0xff;    /* open data bus? */
1675 		}
1676 		else
1677 		{
1678 			if (0 == (offset & E5XX_MASK))
1679 			{
1680 				save = i8x41_get_register(0 ? I8X41_STAT : I8X41_DATA);
1681 
1682 				switch (type3_swap)
1683 				{
1684 				case TYPE3_SWAP_01:
1685 					data =
1686 						(BIT(save, 1) << 0) |
1687 						(type3_d0_latch << 1) |
1688 						(BIT(save, 2) << 2) |
1689 						(BIT(save, 3) << 3) |
1690 						(BIT(save, 4) << 4) |
1691 						(BIT(save, 5) << 5) |
1692 						(BIT(save, 6) << 6) |
1693 						(BIT(save, 7) << 7);
1694 					break;
1695 				case TYPE3_SWAP_12:
1696 					data =
1697 						(type3_d0_latch << 0) |
1698 						(BIT(save, 2) << 1) |
1699 						(BIT(save, 1) << 2) |
1700 						(BIT(save, 3) << 3) |
1701 						(BIT(save, 4) << 4) |
1702 						(BIT(save, 5) << 5) |
1703 						(BIT(save, 6) << 6) |
1704 						(BIT(save, 7) << 7);
1705 					break;
1706 				case TYPE3_SWAP_13:
1707 					data =
1708 						(type3_d0_latch << 0) |
1709 						(BIT(save, 3) << 1) |
1710 						(BIT(save, 2) << 2) |
1711 						(BIT(save, 1) << 3) |
1712 						(BIT(save, 4) << 4) |
1713 						(BIT(save, 5) << 5) |
1714 						(BIT(save, 6) << 6) |
1715 						(BIT(save, 7) << 7);
1716 					break;
1717 				case TYPE3_SWAP_24:
1718 					data =
1719 						(type3_d0_latch << 0) |
1720 						(BIT(save, 1) << 1) |
1721 						(BIT(save, 4) << 2) |
1722 						(BIT(save, 3) << 3) |
1723 						(BIT(save, 2) << 4) |
1724 						(BIT(save, 5) << 5) |
1725 						(BIT(save, 6) << 6) |
1726 						(BIT(save, 7) << 7);
1727 					break;
1728 				case TYPE3_SWAP_25:
1729 					data =
1730 						(type3_d0_latch << 0) |
1731 						(BIT(save, 1) << 1) |
1732 						(BIT(save, 5) << 2) |
1733 						(BIT(save, 3) << 3) |
1734 						(BIT(save, 4) << 4) |
1735 						(BIT(save, 2) << 5) |
1736 						(BIT(save, 6) << 6) |
1737 						(BIT(save, 7) << 7);
1738 					break;
1739 				case TYPE3_SWAP_34_0:
1740 					data =
1741 						(type3_d0_latch << 0) |
1742 						(BIT(save, 1) << 1) |
1743 						(BIT(save, 2) << 2) |
1744 						(BIT(save, 3) << 4) |
1745 						(BIT(save, 4) << 3) |
1746 						(BIT(save, 5) << 5) |
1747 						(BIT(save, 6) << 6) |
1748 						(BIT(save, 7) << 7);
1749 					break;
1750 				case TYPE3_SWAP_34_7:
1751 					data =
1752 						(BIT(save, 7) << 0) |
1753 						(BIT(save, 1) << 1) |
1754 						(BIT(save, 2) << 2) |
1755 						(BIT(save, 4) << 3) |
1756 						(BIT(save, 3) << 4) |
1757 						(BIT(save, 5) << 5) |
1758 						(BIT(save, 6) << 6) |
1759 						(type3_d0_latch << 7);
1760 					break;
1761 				case TYPE3_SWAP_45:
1762 					data =
1763 						type3_d0_latch |
1764 						(BIT(save, 1) << 1) |
1765 						(BIT(save, 2) << 2) |
1766 						(BIT(save, 3) << 3) |
1767 						(BIT(save, 5) << 4) |
1768 						(BIT(save, 4) << 5) |
1769 						(BIT(save, 6) << 6) |
1770 						(BIT(save, 7) << 7);
1771 					break;
1772 				case TYPE3_SWAP_23_56:
1773 					data =
1774 						(type3_d0_latch << 0) |
1775 						(BIT(save, 1) << 1) |
1776 						(BIT(save, 3) << 2) |
1777 						(BIT(save, 2) << 3) |
1778 						(BIT(save, 4) << 4) |
1779 						(BIT(save, 6) << 5) |
1780 						(BIT(save, 5) << 6) |
1781 						(BIT(save, 7) << 7);
1782 					break;
1783 				case TYPE3_SWAP_56:
1784 					data =
1785 						type3_d0_latch |
1786 						(BIT(save, 1) << 1) |
1787 						(BIT(save, 2) << 2) |
1788 						(BIT(save, 3) << 3) |
1789 						(BIT(save, 4) << 4) |
1790 						(BIT(save, 6) << 5) |
1791 						(BIT(save, 5) << 6) |
1792 						(BIT(save, 7) << 7);
1793 					break;
1794 				case TYPE3_SWAP_67:
1795 					data =
1796 						type3_d0_latch |
1797 						(BIT(save, 1) << 1) |
1798 						(BIT(save, 2) << 2) |
1799 						(BIT(save, 3) << 3) |
1800 						(BIT(save, 4) << 4) |
1801 						(BIT(save, 5) << 5) |
1802 						(BIT(save, 7) << 6) |
1803 						(BIT(save, 6) << 7);
1804 					break;
1805 				default:
1806 					data =
1807 						type3_d0_latch |
1808 						(BIT(save, 1) << 1) |
1809 						(BIT(save, 2) << 2) |
1810 						(BIT(save, 3) << 3) |
1811 						(BIT(save, 4) << 4) |
1812 						(BIT(save, 5) << 5) |
1813 						(BIT(save, 6) << 6) |
1814 						(BIT(save, 7) << 7);
1815 				}
1816 				type3_d0_latch = save & 1;
1817 			}
1818 			else
1819 			{
1820 				save = 0xff;    /* open data bus? */
1821 				data =
1822 					type3_d0_latch |
1823 					(BIT(save, 1) << 1) |
1824 					(BIT(save, 2) << 2) |
1825 					(BIT(save, 3) << 3) |
1826 					(BIT(save, 4) << 4) |
1827 					(BIT(save, 5) << 5) |
1828 					(BIT(save, 6) << 7) |
1829 					(BIT(save, 7) << 6);
1830 				type3_d0_latch = save & 1;
1831 			}
1832 		}
1833 	}
1834 
1835 	return data;
1836 }
1837 
decocass_type3_write(UINT16 offset,UINT8 data)1838 static void decocass_type3_write(UINT16 offset,UINT8 data)
1839 {
1840 	if (1 == (offset & 1))
1841 	{
1842 		if (1 == type3_pal_19)
1843 		{
1844 			type3_ctrs = data << 4;
1845 			return;
1846 		}
1847 		else if (0xc0 == (data & 0xf0))
1848 			type3_pal_19 = 1;
1849 	}
1850 
1851 	i8x41_set_register((offset & 1) ? I8X41_CMND : I8X41_DATA, data);
1852 }
1853 
decocass_type4_read(UINT16 offset)1854 static UINT8 decocass_type4_read(UINT16 offset)
1855 {
1856 	if (offset & 1)
1857 	{
1858 		if ((offset & E5XX_MASK) == 0)
1859 		{
1860 			return i8x41_get_register(I8X41_STAT);
1861 		}
1862 	}
1863 	else
1864 	{
1865 		if (type4_latch)
1866 		{
1867 			UINT8 data = DrvDongle[type4_ctrs];
1868 			type4_ctrs = (type4_ctrs + 1) & 0x7fff;
1869 			return data;
1870 		}
1871 		else
1872 		{
1873 			if ((offset & E5XX_MASK) == 0)
1874 			{
1875 				return i8x41_get_register(I8X41_DATA);
1876 			}
1877 		}
1878 	}
1879 
1880 	return 0xff;
1881 }
1882 
decocass_type4_write(UINT16 offset,UINT8 data)1883 static void decocass_type4_write(UINT16 offset, UINT8 data)
1884 {
1885 	if (offset & 1)
1886 	{
1887 		if (type4_latch)
1888 		{
1889 			type4_ctrs = (type4_ctrs & 0x00ff) | ((data & 0x7f) << 8);
1890 			return;
1891 		}
1892 		else if ((data & 0xf0) == 0xc0)
1893 		{
1894 			type4_latch = 1;
1895 		}
1896 	}
1897 	else
1898 	{
1899 		if (type4_latch)
1900 		{
1901 			type4_ctrs = (type4_ctrs & 0xff00) | data;
1902 			return;
1903 		}
1904 	}
1905 
1906 	i8x41_set_register((offset & 1) ? I8X41_CMND : I8X41_DATA, data);
1907 }
1908 
decocass_e5xx_read(UINT8 offset)1909 static UINT8 decocass_e5xx_read(UINT8 offset)
1910 {
1911 	if (2 == (offset & E5XX_MASK))
1912 	{
1913 		return  (BIT(i8041_p1, 7)   << 0) |   /* D0 = P17 - REQ/ */
1914 			(BIT(i8041_p2, 0)   << 1) |   /* D1 = P20 - FNO/ */
1915 			(BIT(i8041_p2, 1)   << 2) |   /* D2 = P21 - EOT/ */
1916 			(BIT(i8041_p2, 2)   << 3) |   /* D3 = P22 - ERR/ */
1917 			((tape_bot_eot)     << 4) |   /* D4 = BOT/EOT (direct from drive) */
1918 			(1                  << 5) |   /* D5 floating input */
1919 			(1                  << 6) |   /* D6 floating input */
1920 			((0) << 7);                   /* D7 = cassette present (active low) */
1921 	}
1922 	else
1923 	{
1924 		if (prot_read) {
1925 			return prot_read(offset);
1926 		} else {
1927 			return 0xff;
1928 		}
1929 	}
1930 
1931 	return 0;
1932 }
1933 
decocass_e5xx_write(UINT8 offset,UINT8 data)1934 static void decocass_e5xx_write(UINT8 offset, UINT8 data)
1935 {
1936 	if (prot_write)
1937 	{
1938 		prot_write(offset, data);
1939 		return;
1940 	}
1941 
1942 	if (0 == (offset & E5XX_MASK))
1943 	{
1944 		i8x41_set_register((offset & 1) ? I8X41_CMND : I8X41_DATA, data);
1945 	}
1946 }
1947 
decode_chars_one(INT32 offset)1948 static inline void decode_chars_one(INT32 offset)
1949 {
1950 	offset &= 0x1fff;
1951 
1952 	UINT8 a = DrvCharRAM[0x0000 + offset];
1953 	UINT8 b = DrvCharRAM[0x2000 + offset];
1954 	UINT8 c = DrvCharRAM[0x4000 + offset];
1955 
1956 	UINT8 *d = DrvCharExp + (offset * 8);
1957 
1958 	for (INT32 bit = 0; bit < 8; bit++)
1959 	{
1960 		UINT8 p;
1961 		p  = ((a >> bit) & 1) << 0;
1962 		p |= ((b >> bit) & 1) << 1;
1963 		p |= ((c >> bit) & 1) << 2;
1964 
1965 		d[bit ^ 7] = p;
1966 	}
1967 }
1968 
decode_tiles_one(INT32 offset)1969 static inline void decode_tiles_one(INT32 offset)
1970 {
1971 	offset &= 0x3ff;
1972 
1973 	INT32 i = offset * 8;
1974 
1975 	UINT8 a = DrvTileRAM[0x0000 + offset];
1976 	UINT8 b = DrvTileRAM[0x0400 + offset] >> 4;
1977 	UINT8 c = DrvTileRAM[0x0400 + offset];
1978 
1979 	for (INT32 bit = 0; bit < 4; bit++)
1980 	{
1981 		INT32 z = 0xf ^ bit ^ ((i & 0x1e00) >> 1) ^ ((i & 0x78) << 1) ^ ((i & 0x180) >> 5);
1982 
1983 		UINT8 p;
1984 		p  = ((a >> bit) & 1) << 0;
1985 		p |= ((b >> bit) & 1) << 1;
1986 		p |= ((c >> bit) & 1) << 2;
1987 
1988 		DrvTileExp[z] = p;
1989 	}
1990 }
1991 
decode_obj_one(INT32 offset)1992 static inline void decode_obj_one(INT32 offset)
1993 {
1994 	offset &= 0x3ff;
1995 
1996 	for (INT32 bit = 0; bit < 8; bit++)
1997 	{
1998 		INT32 z = (offset * 8) + bit;
1999 
2000 		z = (~z & 0x3f) | ((~z & 0x1f80) >> 1) | ((z & 0x40) << 6);
2001 
2002 		DrvObjExp[z] = (DrvObjRAM[offset] >> bit) & 1;
2003 	}
2004 }
2005 
decode_ram_tiles()2006 static void decode_ram_tiles()
2007 {
2008 	for (INT32 i = 0; i < 0x2000; i++)
2009 		decode_chars_one(i);
2010 
2011 	for (INT32 i = 0; i < 0x400; i++)
2012 		decode_tiles_one(i);
2013 
2014 	for (INT32 i = 0; i < 0x400; i++)
2015 		decode_obj_one(i);
2016 
2017 }
2018 
set_gfx_bank(INT32 bank)2019 static void set_gfx_bank(INT32 bank)
2020 {
2021 	e900_gfxbank = bank;
2022 
2023 	if (bank == 3 || !e900_enable) return;
2024 
2025 	UINT8 *ptr = DrvCharRAM; // bank == 0
2026 
2027 	if (bank == 1) ptr = DrvGfxData;
2028 	if (bank == 2) ptr = DrvGfxData + 0x5000;
2029 
2030 	M6502MapMemory(ptr, 0x6000, 0xafff, MAP_ROM);
2031 }
2032 
decocass_main_write(UINT16 address,UINT8 data)2033 static void decocass_main_write(UINT16 address, UINT8 data)
2034 {
2035 	//bprintf (0, _T("MW %4.4x, %2.2x\n"), address, data);
2036 
2037 	if (address >= 0x6000 && address <= 0xbfff) {
2038 		DrvCharRAM[address - 0x6000] = data;
2039 		decode_chars_one(address - 0x6000);
2040 		return;
2041 	}
2042 
2043 	if ((address & 0xf800) == 0xd000) {
2044 		DrvTileRAM[address & 0x7ff] = data;
2045 		decode_tiles_one(address);
2046 		return;
2047 	}
2048 
2049 	if ((address & 0xfc00) == 0xd800) {
2050 		DrvObjRAM[address & 0x3ff] = data;
2051 		decode_obj_one(address);
2052 		return;
2053 	}
2054 
2055 	if ((address & 0xfc00) == 0xc800) {
2056 		address = ((address >> 5) & 0x1f) | ((address & 0x1f) << 5);
2057 		DrvFgRAM[address] = data;
2058 		return;
2059 	}
2060 
2061 	if ((address & 0xfc00) == 0xcc00) {
2062 		address = ((address >> 5) & 0x1f) | ((address & 0x1f) << 5);
2063 		DrvColRAM[address] = data;
2064 		return;
2065 	}
2066 
2067 	if ((address & 0xff00) == 0xe000) {
2068 		DrvPalRAM[address & 0xff] = data;
2069 
2070 		INT32 offset = (address & 31) ^ 16;
2071 		data ^= 0xff;
2072 
2073 		UINT8 r = (data >>  0) & 7;
2074 		UINT8 g = (data >>  3) & 7;
2075 		UINT8 b = (data >>  6) & 3;
2076 
2077 		r = (r << 5) | (r << 2) | (r >> 1);
2078 		g = (g << 5) | (g << 2) | (g >> 1);
2079 		b = (b << 6) | (b << 4) | (b << 2) | (b << 0);
2080 
2081 		DrvPaletteTable[offset] = (r << 16) + (g << 8) + b;
2082 
2083 		DrvRecalc = 1; // needs to traverse the entire table for duplicates etc.
2084 
2085 		return;
2086 	}
2087 
2088 	if ((address & 0xff00) == 0xe500) {
2089 		decocass_e5xx_write(address & 0xff, data);
2090 		return;
2091 	}
2092 
2093 	switch (address)
2094 	{
2095 		case 0xe300:
2096 			watchdog_count = data & 0x0f;
2097 		return;
2098 
2099 		case 0xe301:
2100 			watchdog_flip = data;
2101 		return;
2102 
2103 		case 0xe302:
2104 			color_missiles = data & 0x77;
2105 		return;
2106 
2107 		case 0xe400:
2108 		{
2109 			decocass_reset = data;
2110 
2111 			if (data & 1)
2112 			{
2113 				M6502Close();
2114 				M6502Open(1);
2115 				M6502Reset();
2116 				M6502Close();
2117 				M6502Open(0);
2118 
2119 				audio_nmi_enabled = 0;
2120 
2121 				M6502SetIRQLine(0x20, (audio_nmi_enabled && audio_nmi_state) ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_NONE);
2122 			}
2123 
2124 			if ((data & 8) ^ 8)
2125 			{
2126 				i8x41_reset();
2127 			}
2128 		}
2129 		return;
2130 
2131 		case 0xe402:
2132 			mode_set = data;
2133 		return;
2134 
2135 		case 0xe403:
2136 			back_h_shift = data;
2137 		return;
2138 
2139 		case 0xe404:
2140 			back_vl_shift = data;
2141 		return;
2142 
2143 		case 0xe405:
2144 			back_vr_shift = data;
2145 		return;
2146 
2147 		case 0xe406:
2148 			part_h_shift = data;
2149 		return;
2150 
2151 		case 0xe407:
2152 			part_v_shift = data;
2153 		return;
2154 
2155 		case 0xe410:
2156 			color_center_bot = data;
2157 		return;
2158 
2159 		case 0xe411:
2160 			center_h_shift_space = data;
2161 		return;
2162 
2163 		case 0xe412:
2164 			center_v_shift = data;
2165 		return;
2166 
2167 		case 0xe413:
2168 			// coin counter (not emulated)
2169 			mux_data = (data & 0xc) >> 2; // cdsteljn
2170 		return;
2171 
2172 		case 0xe414:
2173 		{
2174 			soundlatch = data;
2175 			sound_ack |= 0x80;
2176 			sound_ack &= ~0x40;
2177 			M6502Close();
2178 			M6502Open(1);
2179 			M6502SetIRQLine(0, CPU_IRQSTATUS_ACK);
2180 			M6502Close();
2181 			M6502Open(0);
2182 		}
2183 		return;
2184 
2185 		case 0xe415:
2186 		case 0xe416:
2187 			// Unused analog stuff.
2188 		return;
2189 
2190 		case 0xe417:
2191 			M6502SetIRQLine(0x20, CPU_IRQSTATUS_NONE);
2192 		return;
2193 
2194 		case 0xe420:
2195 		case 0xe421:
2196 		case 0xe422:
2197 		case 0xe423:
2198 		case 0xe424:
2199 		case 0xe425:
2200 		case 0xe426:
2201 		case 0xe427:
2202 		case 0xe428:
2203 		case 0xe429:
2204 		case 0xe42a:
2205 		case 0xe42b:
2206 		case 0xe42c:
2207 		case 0xe42d:
2208 		case 0xe42e:
2209 		case 0xe42f:
2210 			// adc_w (UNEMULATED)
2211 		return;
2212 
2213 		case 0xe900:
2214 			set_gfx_bank(data & 3);
2215 		return;
2216 	}
2217 
2218 	bprintf (0, _T("MW %4.4x, %2.2x\n"), address, data);
2219 }
2220 
input_read(INT32 offset)2221 static UINT8 input_read(INT32 offset)
2222 {
2223 	offset &= 7;
2224 
2225 	switch (offset & 7)
2226 	{
2227 		case 0:
2228 		case 1:
2229 		case 2:
2230 			return DrvInputs[offset];
2231 
2232 		case 3:
2233 		case 4:
2234 		case 5:
2235 		case 6:
2236 			return 0; // Unused analog stuff.
2237 	}
2238 
2239 	return 0xff;
2240 }
2241 
decocass_main_read(UINT16 address)2242 static UINT8 decocass_main_read(UINT16 address)
2243 {
2244 	if ((address & 0xfc00) == 0xc800) {
2245 		address = ((address >> 5) & 0x1f) | ((address & 0x1f) << 5);
2246 		return DrvFgRAM[address];
2247 	}
2248 
2249 	if ((address & 0xfc00) == 0xcc00) {
2250 		address = ((address >> 5) & 0x1f) | ((address & 0x1f) << 5);
2251 		return DrvColRAM[address];
2252 	}
2253 
2254 	if ((address & 0xff00) == 0xe500) {
2255 		return decocass_e5xx_read(address&0xff);
2256 	}
2257 
2258 	if ((address & 0xff00) == 0xe600) {
2259 		if ((BurnDrvGetGenreFlags() & GBF_MAHJONG) && (address & 6) == 0)
2260 			return DrvInputs[3 + mux_data + ((address & 1) * 4)];
2261 		return input_read(address);
2262 	}
2263 
2264 	switch (address)
2265 	{
2266 		case 0xe300:
2267 			return (DrvDips[0] & 0x7f) | (vblank ? 0x80 : 0);
2268 
2269 		case 0xe301:
2270 			return DrvDips[1];
2271 
2272 		case 0xe414:
2273 			return 0xc0; // sound command (0xc0 ok)
2274 
2275 		case 0xe700:
2276 			return soundlatch2;
2277 
2278 		case 0xe701:
2279 			return sound_ack;
2280 	}
2281 
2282 	bprintf (0, _T("MR %4.4x\n"), address);
2283 
2284 	return 0;
2285 }
2286 
2287 // BurgerTime Anti-migraine 8910fixer Hack.  See d_btime.cpp for notes.
2288 static UINT8 last01[3] = {0xff,0xff};
2289 static UINT8 last02[3] = {0xff,0xff};
2290 static UINT8 ignext = 0;
2291 
checkhiss_add02(UINT8 data)2292 static void checkhiss_add02(UINT8 data)
2293 {
2294 	last02[1] = last02[0];
2295 	last02[0] = data;
2296 }
2297 
checkhiss_and_add01(UINT8 data)2298 static void checkhiss_and_add01(UINT8 data)
2299 {
2300 	last01[1] = last01[0];
2301 	last01[0] = data;
2302 
2303 	if (last01[0] == 0 && last02[0] == 1 && last01[1] == 0 && last02[1] == 0)
2304 	{
2305 		ignext = 1; // next command will be VolA
2306 	}
2307 	if (last01[0] == 0 && last02[0] == 3 && last01[1] == 0 && last02[1] == 2)
2308 	{
2309 		ignext = 1; // next command will be VolB
2310 	}
2311 	if (last01[0] == 0 && last02[0] == 5 && last01[1] == 0 && last02[1] == 4)
2312 	{
2313 		ignext = 1; // next command will be VolC
2314 	}
2315 }
2316 
decocass_sound_write(UINT16 address,UINT8 data)2317 static void decocass_sound_write(UINT16 address, UINT8 data)
2318 {
2319 	if ((address & 0xf800) == 0x1000) {
2320 		audio_nmi_enabled = 1;
2321 		M6502SetIRQLine(0x20, (audio_nmi_enabled && audio_nmi_state) ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_NONE);
2322 		return;
2323 	}
2324 
2325 	if ((address & 0xf800) == 0x1800) {
2326 		sound_ack &= ~0x40;
2327 		return;
2328 	}
2329 
2330 	switch (address & 0xf000)
2331 	{
2332 		case 0x2000:
2333 			if (burgertime_mode && ignext) {
2334 				data = 0; // set volume to 0
2335 				ignext = 0;
2336 			}
2337 			AY8910Write(0, 1, data);
2338 			if (burgertime_mode) checkhiss_and_add01(data);
2339 		return;
2340 
2341 		case 0x4000:
2342 			AY8910Write(0, 0, data);
2343 			if (burgertime_mode) checkhiss_add02(data);
2344 		return;
2345 
2346 		case 0x6000:
2347 			AY8910Write(1, 1, data);
2348 		return;
2349 
2350 		case 0x8000:
2351 			AY8910Write(1, 0, data);
2352 		return;
2353 
2354 		case 0xc000:
2355 			soundlatch2 = data;
2356 			sound_ack |= 0x40;
2357 		return;
2358 	}
2359 }
2360 
decocass_sound_read(UINT16 address)2361 static UINT8 decocass_sound_read(UINT16 address)
2362 {
2363 	if ((address & 0xf800) == 0x1000) {
2364 		audio_nmi_enabled = 1;
2365 		M6502SetIRQLine(0x20, (audio_nmi_enabled && audio_nmi_state) ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_NONE);
2366 		return 0xff;
2367 	}
2368 
2369 	if ((address & 0xf800) == 0x1800) {
2370 		sound_ack &= ~0x40;
2371 		return 0xFF;
2372 	}
2373 
2374 	switch (address & 0xf000)
2375 	{
2376 		case 0xa000:
2377 			M6502SetIRQLine(0, CPU_IRQSTATUS_NONE);
2378 			sound_ack &= ~0x80;
2379 			return soundlatch;
2380 	}
2381 
2382 
2383 	return 0;
2384 }
2385 
2386 
2387 // i8041 tape intf
2388 
i8041_p1_write(UINT8 data)2389 static void i8041_p1_write(UINT8 data)
2390 {
2391 	if ((data ^ i8041_p1) & 0x10)
2392 	{
2393 		tape_stop(); // iq_132
2394 
2395 		if (0 == (data & 0x10))
2396 		{
2397 			tape_dir = -1;
2398 			tape_timer = 1;
2399 			tapetimer_reset();
2400 		}
2401 		else
2402 		{
2403 			tape_dir = 0;
2404 			tape_speed = 0;
2405 		}
2406 	}
2407 
2408 	if ((data ^ i8041_p1) & 0x20)
2409 	{
2410 		tape_stop();
2411 
2412 		if (0 == (data & 0x20))
2413 		{
2414 			tape_dir = +1;
2415 			tape_timer = 1;
2416 			tapetimer_reset();
2417 		}
2418 		else
2419 		{
2420 			tape_dir = 0;
2421 			tape_speed = 0;
2422 		}
2423 	}
2424 
2425 
2426 	if (tape_timer && (data ^ i8041_p1) & 0x04)
2427 	{
2428 		tape_stop();
2429 		tape_speed = (0 == (data & 0x04)) ? 1 : 0;
2430 
2431 		if (tape_dir < 0)
2432 		{
2433 			tape_dir = (tape_speed) ? -7 : -1;
2434 			tape_timer = 1;
2435 			tapetimer_reset();
2436 		}
2437 		else
2438 		if (tape_dir > 0)
2439 		{
2440 			tape_dir = (tape_speed) ? +7 : +1;
2441 			tape_timer = 1;
2442 			tapetimer_reset();
2443 		}
2444 	}
2445 
2446 	i8041_p1 = data;
2447 }
2448 
i8041_p1_read()2449 static UINT8 i8041_p1_read()
2450 {
2451 	return i8041_p1;
2452 }
2453 
i8041_p2_write(UINT8 data)2454 static void i8041_p2_write(UINT8 data)
2455 {
2456 	i8041_p2 = data;
2457 }
2458 
i8041_p2_read()2459 static UINT8 i8041_p2_read()
2460 {
2461 	tape_update();
2462 
2463 	return i8041_p2;
2464 }
2465 
i8x41_read_ports(UINT16 port)2466 static UINT8 i8x41_read_ports(UINT16 port)
2467 {
2468 	switch (port)
2469 	{
2470 		case 0x01:
2471 			return i8041_p1_read();
2472 
2473 		case 0x02:
2474 			return i8041_p2_read();
2475 	}
2476 
2477 	return 0;
2478 }
2479 
i8x41_write_ports(UINT16 port,UINT8 data)2480 static void i8x41_write_ports(UINT16 port, UINT8 data)
2481 {
2482 	switch (port)
2483 	{
2484 		case 0x01:
2485 			i8041_p1_write(data);
2486 		return;
2487 
2488 		case 0x02:
2489 			i8041_p2_write(data);
2490 		return;
2491 	}
2492 }
2493 
tilemap_scan(fg)2494 static tilemap_scan( fg )
2495 {
2496 	return (31 - col) * 32 + row;
2497 }
2498 
tilemap_callback(fg)2499 static tilemap_callback( fg )
2500 {
2501 	UINT16 code = DrvFgRAM[offs] + ((DrvColRAM[offs] & 3) * 256);
2502 
2503 	TILE_SET_INFO(1, code, color_center_bot & 1, 0);
2504 }
2505 
BurnGetRomLen(INT32 nIndex)2506 static INT32 BurnGetRomLen(INT32 nIndex)
2507 {
2508 	struct BurnRomInfo ri;
2509 	BurnDrvGetRomInfo(&ri, nIndex);
2510 	return ri.nLen;
2511 }
2512 
DrvDoReset()2513 static INT32 DrvDoReset()
2514 {
2515 	// load bios roms
2516 	// call before cpu resets to catch vectors!
2517 	if (DrvDips[2] != 0xff) // widel multi
2518 	{
2519 		INT32 bios_sets = 4; // total bios sets supported
2520 		INT32 bios_select = ((DrvDips[2] % bios_sets) * 8) + 0x80;
2521 
2522 		if (BurnLoadRom(DrvMainBIOS, bios_select + 0, 1)) return 1; // main m6502 bios
2523 
2524 		if (BurnGetRomLen(bios_select + 1)) { // older bios' use split main rom
2525 			if (BurnLoadRom(DrvMainBIOS + 0x800, bios_select + 1, 1)) return 1;
2526 		}
2527 
2528 		// split type uses 1k rather than 2k rom
2529 		if (BurnLoadRom(DrvSoundBIOS + ((DrvDips[2] & 1) ? 0x400 : 0), bios_select + 2, 1)) return 1;
2530 
2531 		// load the mcu bios
2532 		if (BurnLoadRom(DrvMCUROM, 0x80 + (bios_sets * 8), 1)) return 1;
2533 	}
2534 
2535 	memset (AllRam, 0, RamEnd - AllRam);
2536 
2537 	M6502Open(0);
2538 	set_gfx_bank(0);
2539 	M6502Reset();
2540 	M6502Close();
2541 
2542 	M6502Open(1);
2543 	M6502Reset();
2544 	M6502Close();
2545 
2546 	i8x41_reset();
2547 
2548 	AY8910Reset(0);
2549 	AY8910Reset(1);
2550 
2551 	decocass_reset = 0;
2552 
2553 	watchdog_count = 0;
2554 	watchdog_flip = 0;
2555 	watchdog = 0;
2556 
2557 	soundlatch = 0;
2558 	soundlatch2 = 0;
2559 	sound_ack = 0;
2560 	audio_nmi_enabled = 0;
2561 	audio_nmi_state = 0;
2562 
2563 	color_missiles = 0;
2564 	mode_set = 0;
2565 	color_center_bot = 0;
2566 	back_h_shift = 0;
2567 	back_vl_shift = 0;
2568 	back_vr_shift = 0;
2569 	part_h_shift = 0;
2570 	part_v_shift = 0;
2571 	center_h_shift_space = 0;
2572 	center_v_shift = 0;
2573 
2574 	mux_data = 0;
2575 
2576 	decocass_init_common();
2577 
2578 	DrvInputs[2] = 0xc0;
2579 
2580 	return 0;
2581 }
2582 
MemIndex()2583 static INT32 MemIndex()
2584 {
2585 	UINT8 *Next; Next = AllMem;
2586 
2587 	DrvMainBIOS		= Next; Next += 0x001000;
2588 	DrvSoundBIOS		= Next; Next += 0x001000;
2589 	DrvCassette		= Next; Next += 0x0020000;
2590 	DrvGfxData		= Next; Next += 0x00a0000;
2591 	DrvDongle		= Next; Next += 0x0100000; // 1mb (needed for widel multi)
2592 	I8x41Mem		= Next;
2593 	DrvMCUROM		= Next; Next += 0x0009000; // 0x400 + 0x500 for ram, for now
2594 
2595 	DrvCharExp		= Next; Next += 0x0100000;
2596 	DrvTileExp		= Next; Next += 0x0011000;
2597 	DrvObjExp		= Next; Next += 0x0008000;
2598 
2599 	DrvPalette		= (UINT32*)Next; Next += 0x00400 * sizeof(UINT32);
2600 
2601 	DrvPalLut		= Next; Next += 0x0000400;
2602 	DrvPaletteTable		= (UINT32*)Next; Next += 0x00200 * sizeof(UINT32);
2603 
2604 	pTempDraw[0]		= (UINT16*)Next; Next += 512 * 512 * sizeof(UINT16);
2605 	pTempDraw[1]		= (UINT16*)Next; Next += 512 * 512 * sizeof(UINT16);
2606 
2607 	AllRam			= Next;
2608 
2609 	DrvMainRAM		= Next; Next += 0x006000;
2610 	DrvCharRAM		= Next; Next += 0x006000;
2611 	DrvFgRAM		= Next; Next += 0x000400;
2612 	DrvColRAM		= Next; Next += 0x000400;
2613 	DrvTileRAM		= Next; Next += 0x000800;
2614 	DrvObjRAM		= Next; Next += 0x000400;
2615 
2616 	DrvPalRAM		= Next; Next += 0x000100;
2617 	DrvPaletteTable = (UINT32*)Next; Next += 0x00200 * sizeof(UINT32);
2618 
2619 	DrvSoundRAM		= Next; Next += 0x001000;
2620 
2621 	RamEnd			= Next;
2622 
2623 	MemEnd			= Next;
2624 
2625 	return 0;
2626 }
2627 
BurnPaletteLut()2628 static void BurnPaletteLut()
2629 {
2630 	for (INT32 i = 0; i < 32; i++) { // char/sprite layer
2631 		DrvPalLut[i] = i;
2632 		DrvPalLut[i+32] = BITSWAP08(i, 7,6,5,4,3,1,2,0);
2633 	}
2634 }
2635 
DecocassGetRoms()2636 static INT32 DecocassGetRoms()
2637 {
2638 	char* pRomName;
2639 	struct BurnRomInfo ri;
2640 
2641 	UINT8 *gfx = DrvGfxData;
2642 	UINT8 *dnl = DrvDongle;
2643 	UINT8 *mbi = DrvMainBIOS;
2644 	UINT8 *sbi = DrvSoundBIOS;
2645 
2646 	memset (gfx, 0xff, 0xa000);
2647 
2648 	for (INT32 i = 0; !BurnDrvGetRomName(&pRomName, i, 0); i++)
2649 	{
2650 		BurnDrvGetRomInfo(&ri, i);
2651 
2652 		if ((ri.nType & BRF_PRG) && (ri.nType & 0x0f) == 1) {
2653 			if (BurnLoadRom(dnl, i, 1)) return 1;
2654 			dnl += ri.nLen;
2655 			continue;
2656 		}
2657 
2658 		if ((ri.nType & BRF_PRG) && (ri.nType & 0x0f) == 2) {
2659 			if (BurnLoadRom(DrvCassette, i, 1)) return 1;
2660 			DrvCassetteLen = BurnGetRomLen(i);
2661 			continue;
2662 		}
2663 
2664 		if ((ri.nType & BRF_GRA) && (ri.nType & 0x0f) == 3) {
2665 			if (BurnLoadRom(gfx, i, 1)) return 1;
2666 			gfx += ri.nLen;
2667 			continue;
2668 		}
2669 
2670 	// widel multi
2671 		if ((ri.nType & BRF_BIOS) && (ri.nType & 0x0f) == 8) {
2672 			if (BurnLoadRom(mbi, i, 1)) return 1;
2673 			if (ri.nLen != 0x1000 && mbi == DrvMainBIOS) memcpy (DrvMainBIOS + 0x800, DrvMainBIOS, 0x800);
2674 			mbi += ri.nLen;
2675 			continue;
2676 		}
2677 
2678 		if ((ri.nType & BRF_BIOS) && (ri.nType & 0x0f) == 9) {
2679 			if (BurnLoadRom(sbi, i, 1)) return 1;
2680 			if (ri.nLen != 0x800 && sbi == DrvSoundBIOS) memcpy (DrvSoundBIOS + 0x400, DrvSoundBIOS, 0x400);
2681 			sbi += ri.nLen;
2682 			continue;
2683 		}
2684 
2685 		if ((ri.nType & BRF_BIOS) && (ri.nType & 0x0f) == 10) {
2686 			if (BurnLoadRom(DrvMCUROM, i, 1)) return 1;
2687 			continue;
2688 		}
2689 	}
2690 
2691 	return 0;
2692 }
2693 
DecocassInit(UINT8 (* read)(UINT16),void (* write)(UINT16,UINT8))2694 static INT32 DecocassInit(UINT8 (*read)(UINT16),void (*write)(UINT16,UINT8))
2695 {
2696 	BurnSetRefreshRate(57.44);
2697 
2698 	prot_write = write;
2699 	prot_read = read;
2700 
2701 	AllMem = NULL;
2702 	MemIndex();
2703 	INT32 nLen = MemEnd - (UINT8 *)0;
2704 	if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
2705 	memset(AllMem, 0, nLen);
2706 	MemIndex();
2707 
2708 	{
2709 		if (DecocassGetRoms()) return 1;
2710 
2711 		BurnPaletteLut();
2712 		decocass_init_common();
2713 	}
2714 
2715 	M6502Init(0, TYPE_DECO222);
2716 	M6502Open(0);
2717 	M6502MapMemory(DrvMainRAM,	0x0000, 0x5fff, MAP_RAM);
2718 	M6502MapMemory(DrvCharRAM,	0x6000, 0xbfff, MAP_ROM);
2719 	M6502MapMemory(DrvFgRAM,	0xc000, 0xc3ff, MAP_RAM);
2720 	M6502MapMemory(DrvColRAM,	0xc400, 0xc7ff, MAP_RAM);
2721 	M6502MapMemory(DrvTileRAM,	0xd000, 0xd7ff, MAP_ROM);
2722 	M6502MapMemory(DrvObjRAM,	0xd800, 0xdbff, MAP_ROM);
2723 	M6502MapMemory(DrvPalRAM,	0xe000, 0xe0ff, MAP_ROM);
2724 	M6502MapMemory(DrvMainBIOS,	0xf000, 0xffff, MAP_ROM);
2725 	M6502SetWriteHandler(decocass_main_write);
2726 	M6502SetReadHandler(decocass_main_read);
2727 	M6502Close();
2728 
2729 	M6502Init(1, TYPE_M6502);
2730 	M6502Open(1);
2731 	M6502MapMemory(DrvSoundRAM,	0x0000, 0x0fff, MAP_RAM);
2732 	M6502MapMemory(DrvSoundBIOS,	0xf800, 0xffff, MAP_ROM);
2733 	M6502SetWriteHandler(decocass_sound_write);
2734 	M6502SetReadHandler(decocass_sound_read);
2735 	M6502Close();
2736 
2737 	i8x41_init(NULL);
2738 	i8x41_set_read_port(i8x41_read_ports);
2739 	i8x41_set_write_port(i8x41_write_ports);
2740 
2741 	AY8910Init(0, 1500000, 0);
2742 	AY8910Init(1, 1500000, 1);
2743 	AY8910SetAllRoutes(0, 0.20, BURN_SND_ROUTE_BOTH);
2744 	AY8910SetAllRoutes(1, 0.20, BURN_SND_ROUTE_BOTH);
2745 
2746 	GenericTilesInit();
2747 	GenericTilemapInit(2, fg_map_scan, fg_map_callback, 8, 8, 32, 32);
2748 	GenericTilemapSetGfx(1, DrvCharExp, 3, 8, 8, 0x10000, 0, 0x03);
2749 	GenericTilemapSetOffsets(2, 0, -8);
2750 	GenericTilemapSetTransparent(2,0);
2751 
2752 	DrvDoReset();
2753 
2754 	return 0;
2755 }
2756 
DrvExit()2757 static INT32 DrvExit()
2758 {
2759 	GenericTilesExit();
2760 
2761 	M6502Exit();
2762 	i8x41_exit();
2763 
2764 	AY8910Exit(0);
2765 	AY8910Exit(1);
2766 
2767 	BurnFree(AllMem);
2768 
2769 	prot_write = NULL;
2770 	prot_read = NULL;
2771 	type1_inmap = 0;
2772 	type1_outmap = 0;
2773 
2774 	burgertime_mode = 0;
2775 	skater_mode = 0;
2776 
2777 	fourway_mode = 0;
2778 
2779 	e900_enable = 0;
2780 
2781 	return 0;
2782 }
2783 
DrvPaletteUpdate()2784 static void DrvPaletteUpdate()
2785 {
2786 	for (INT32 i = 0; i < 64; i++) {
2787 		UINT32 p = DrvPaletteTable[DrvPalLut[i]];
2788 
2789 		DrvPalette[i] = BurnHighCol(p >> 16, (p >> 8) & 0xff, p & 0xff, 0);
2790 	}
2791 }
2792 
draw_object()2793 static void draw_object()
2794 {
2795 	INT32 crossing = mode_set & 3;
2796 
2797 	if ((crossing == 0 || BIT(mode_set, 6)) && !BIT(mode_set, 5)) // in daylight or during explosion
2798 		return;
2799 
2800 	INT32 color = (BITSWAP08(color_center_bot, 0, 1, 7, 2, 3, 4, 5, 6) & 0x27) | 0x08;
2801 
2802 	INT32 sy = 64 - part_v_shift + ((skater_mode) ? 1 : 0);
2803 	if (sy < 0)
2804 		sy += 256;
2805 	INT32 sx = part_h_shift - 128 + 1;
2806 
2807 	const UINT8 *objdata0 = DrvObjExp + 0 * (64 * 64);
2808 	const UINT8 *objdata1 = DrvObjExp + 1 * (64 * 64);
2809 
2810 	for (INT32 y = 0; y < nScreenHeight; y++)
2811 	{
2812 		const INT32 dy = y - sy + 8;
2813 		for (INT32 x = 0; x < nScreenWidth; x++)
2814 		{
2815 			const INT32 dx = x - sx;
2816 
2817 			bool pri2 = false;
2818 			INT32 scroll = back_h_shift;
2819 
2820 			switch (crossing)
2821 			{
2822 				case 0: pri2 = true; break; // outside tunnel (for reference; not usually handled in this loop)
2823 				case 1: pri2 = (x >= scroll); break; // exiting tunnel
2824 				case 2: break; // inside tunnel
2825 				case 3: pri2 = (x < scroll); break; // entering tunnel
2826 			}
2827 
2828 			if (BIT(mode_set, 7))
2829 			{
2830 				// check coordinates against object data
2831 				if ((dy >= -64 && dy < 0 && dx >= 64 && dx < 128 && objdata0[((-1 - dy) * 64 + dx - 64) & 0xfff] != 0) ||
2832 					(dy >= 0 && dy < 64 && dx >= 64 && dx < 128 && objdata0[(dy * 64 + dx - 64) & 0xfff] != 0) ||
2833 					(dy >= -64 && dy < 0 && dx >= 0 && dx < 64 && objdata1[((-1 - dy) * 64 + dx) & 0xfff] != 0) ||
2834 					(dy >= 0 && dy < 64 && dx >= 0 && dx < 64 && objdata1[(dy * 64 + dx) & 0xfff] != 0))
2835 				{
2836 					pri2 = true;
2837 					if (BIT(mode_set, 5) && pPrioDraw[(y * nScreenWidth) + x] == 0) //priority.pix8(y, x) == 0) // least priority?
2838 						pTransDraw[(y * nScreenWidth) + x] = color;
2839 				}
2840 			}
2841 
2842 			if (!pri2)
2843 				pTransDraw[(y * nScreenWidth) + x] |= 0x10;
2844 		}
2845 	}
2846 }
2847 
draw_missiles(INT32 missile_y_adjust,INT32 missile_y_adjust_flip_screen,UINT8 * missile_ram,INT32 interleave)2848 static void draw_missiles(INT32 missile_y_adjust, INT32 missile_y_adjust_flip_screen, UINT8 *missile_ram, INT32 interleave)
2849 {
2850 	INT32 x;
2851 
2852 	INT32 min_y = 0;
2853 	INT32 max_y = nScreenHeight - 1;
2854 	INT32 min_x = 0;
2855 	INT32 max_x = nScreenWidth - 1;
2856 
2857 	for (INT32 i = 0, offs = 0; i < 8; i++, offs += 4 * interleave)
2858 	{
2859 		INT32 sx, sy;
2860 
2861 		sy = 255 - missile_ram[offs + 0 * interleave];
2862 		sx = 255 - missile_ram[offs + 2 * interleave];
2863 		if (flipscreen)
2864 		{
2865 			sx = 240 - sx;
2866 			sy = 240 - sy + missile_y_adjust_flip_screen;
2867 		}
2868 		sy -= missile_y_adjust;
2869 		if (sy >= min_y && sy <= max_y)
2870 			for (x = 0; x < 4; x++)
2871 			{
2872 				if (sx >= min_x && sx <= max_x) {
2873 					pTransDraw[(sy * nScreenWidth) + sx] = (color_missiles & 7) | 8;
2874 					pPrioDraw[(sy * nScreenWidth) + sx] |= 1 << 2;
2875 				}
2876 				sx++;
2877 			}
2878 
2879 		sy = 255 - missile_ram[offs + 1 * interleave];
2880 		sx = 255 - missile_ram[offs + 3 * interleave];
2881 		if (flipscreen)
2882 		{
2883 			sx = 240 - sx;
2884 			sy = 240 - sy + missile_y_adjust_flip_screen;
2885 		}
2886 		sy -= missile_y_adjust;
2887 		if (sy >= min_y && sy <= max_y)
2888 			for (x = 0; x < 4; x++)
2889 			{
2890 				if (sx >= min_x && sx <= max_x) {
2891 					pTransDraw[(sy * nScreenWidth) + sx] = ((color_missiles >> 4) & 7) | 8;
2892 					pPrioDraw[(sy * nScreenWidth) + sx] |= 1 << 3;
2893 				}
2894 				sx++;
2895 			}
2896 	}
2897 }
2898 
draw_sprites(INT32 color,INT32 sprite_y_adjust,INT32 sprite_y_adjust_flip_screen,UINT8 * sprite_ram,INT32 interleave)2899 static void draw_sprites(INT32 color, INT32 sprite_y_adjust, INT32 sprite_y_adjust_flip_screen, UINT8 *sprite_ram, INT32 interleave)
2900 {
2901 	for (INT32 i = 0, offs = 0; i < 8; i++, offs += 4 * interleave)
2902 	{
2903 		INT32 sx, sy, flipx, flipy;
2904 
2905 		if (!(sprite_ram[offs + 0] & 0x01))
2906 			continue;
2907 
2908 		sx = 240 - sprite_ram[offs + 3 * interleave];
2909 		sy = 240 - sprite_ram[offs + 2 * interleave];
2910 
2911 		flipx = sprite_ram[offs + 0] & 0x04;
2912 		flipy = sprite_ram[offs + 0] & 0x02;
2913 
2914 		if (flipscreen)
2915 		{
2916 			sx = 240 - sx;
2917 			sy = 240 - sy + sprite_y_adjust_flip_screen;
2918 
2919 			flipx = !flipx;
2920 			flipy = !flipy;
2921 		}
2922 
2923 		sy -= sprite_y_adjust;
2924 
2925 		INT32 code = sprite_ram[offs + interleave];
2926 
2927 		code *= 4;
2928 
2929 		if (flipy) {
2930 			if (flipx) {
2931 				Render8x8Tile_Prio_Mask_FlipXY_Clip(pTransDraw, code + 1, sx + 0, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2932 				Render8x8Tile_Prio_Mask_FlipXY_Clip(pTransDraw, code + 3, sx + 8, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2933 				Render8x8Tile_Prio_Mask_FlipXY_Clip(pTransDraw, code + 0, sx + 0, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2934 				Render8x8Tile_Prio_Mask_FlipXY_Clip(pTransDraw, code + 2, sx + 8, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2935 			} else {
2936 				Render8x8Tile_Prio_Mask_FlipY_Clip(pTransDraw, code + 3, sx + 0, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2937 				Render8x8Tile_Prio_Mask_FlipY_Clip(pTransDraw, code + 1, sx + 8, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2938 				Render8x8Tile_Prio_Mask_FlipY_Clip(pTransDraw, code + 2, sx + 0, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2939 				Render8x8Tile_Prio_Mask_FlipY_Clip(pTransDraw, code + 0, sx + 8, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2940 			}
2941 		} else {
2942 			if (flipx) {
2943 				Render8x8Tile_Prio_Mask_FlipX_Clip(pTransDraw, code + 0, sx + 0, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2944 				Render8x8Tile_Prio_Mask_FlipX_Clip(pTransDraw, code + 2, sx + 8, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2945 				Render8x8Tile_Prio_Mask_FlipX_Clip(pTransDraw, code + 1, sx + 0, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2946 				Render8x8Tile_Prio_Mask_FlipX_Clip(pTransDraw, code + 3, sx + 8, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2947 			} else {
2948 				Render8x8Tile_Prio_Mask_Clip(pTransDraw, code + 2, sx + 0, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2949 				Render8x8Tile_Prio_Mask_Clip(pTransDraw, code + 0, sx + 8, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2950 				Render8x8Tile_Prio_Mask_Clip(pTransDraw, code + 3, sx + 0, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2951 				Render8x8Tile_Prio_Mask_Clip(pTransDraw, code + 1, sx + 8, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2952 			}
2953 		}
2954 
2955 		sy += (flipscreen ? -256 : 256);
2956 
2957 		// Wrap around
2958 		if (flipy) {
2959 			if (flipx) {
2960 				Render8x8Tile_Prio_Mask_FlipXY_Clip(pTransDraw, code + 1, sx + 0, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2961 				Render8x8Tile_Prio_Mask_FlipXY_Clip(pTransDraw, code + 3, sx + 8, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2962 				Render8x8Tile_Prio_Mask_FlipXY_Clip(pTransDraw, code + 0, sx + 0, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2963 				Render8x8Tile_Prio_Mask_FlipXY_Clip(pTransDraw, code + 2, sx + 8, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2964 			} else {
2965 				Render8x8Tile_Prio_Mask_FlipY_Clip(pTransDraw, code + 3, sx + 0, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2966 				Render8x8Tile_Prio_Mask_FlipY_Clip(pTransDraw, code + 1, sx + 8, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2967 				Render8x8Tile_Prio_Mask_FlipY_Clip(pTransDraw, code + 2, sx + 0, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2968 				Render8x8Tile_Prio_Mask_FlipY_Clip(pTransDraw, code + 0, sx + 8, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2969 			}
2970 		} else {
2971 			if (flipx) {
2972 				Render8x8Tile_Prio_Mask_FlipX_Clip(pTransDraw, code + 0, sx + 0, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2973 				Render8x8Tile_Prio_Mask_FlipX_Clip(pTransDraw, code + 2, sx + 8, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2974 				Render8x8Tile_Prio_Mask_FlipX_Clip(pTransDraw, code + 1, sx + 0, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2975 				Render8x8Tile_Prio_Mask_FlipX_Clip(pTransDraw, code + 3, sx + 8, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2976 			} else {
2977 				Render8x8Tile_Prio_Mask_Clip(pTransDraw, code + 2, sx + 0, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2978 				Render8x8Tile_Prio_Mask_Clip(pTransDraw, code + 0, sx + 8, sy + 0, color, 3, 0, 0, 1 << 1, DrvCharExp);
2979 				Render8x8Tile_Prio_Mask_Clip(pTransDraw, code + 3, sx + 0, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2980 				Render8x8Tile_Prio_Mask_Clip(pTransDraw, code + 1, sx + 8, sy + 8, color, 3, 0, 0, 1 << 1, DrvCharExp);
2981 			}
2982 		}
2983 	}
2984 }
2985 
draw_center()2986 static void draw_center()
2987 {
2988 	INT32 min_y = 0;
2989 	INT32 max_y = nScreenHeight - 1;
2990 
2991 	INT32 sx, sy, x, y, color;
2992 
2993 	color = 0;
2994 	if (color_center_bot & 0x10)
2995 		color |= 4;
2996 	if (color_center_bot & 0x20)
2997 		color |= 2;
2998 	if (color_center_bot & 0x40)
2999 		color |= 1;
3000 	if (color_center_bot & 0x80)
3001 		color = (color & 4) + ((color << 1) & 2) + ((color >> 1) & 1);
3002 
3003 	sy = center_v_shift - 8;
3004 	sx = (center_h_shift_space >> 2) & 0x3c;
3005 
3006 	for (y = 0; y < 4; y++)
3007 		if ((sy + y) >= min_y && (sy + y) <= max_y)
3008 		{
3009 			if (((sy + y) & color_center_bot & 3) == (sy & color_center_bot & 3))
3010 				for (x = 0; x < 256; x++)
3011 					if (0 != (x & 16) || 0 != (center_h_shift_space & 1))
3012 						pTransDraw[(sy + y) * nScreenWidth + ((sx + x) & 255)] = color;
3013 		}
3014 }
3015 
draw_edge(INT32 which,bool opaque)3016 static void draw_edge(INT32 which, bool opaque)
3017 {
3018 	INT32 scrolly_l = back_vl_shift + 8;
3019 	INT32 scrolly_r = 256 - back_vr_shift + 8;
3020 
3021 	// bit 0x04 of the mode select effectively selects between two banks of data
3022 	if (0 == (mode_set & 0x04))
3023 		scrolly_r += 256;
3024 	else
3025 		scrolly_l += 256;
3026 
3027 	INT32 scrollx = 256 - back_h_shift;
3028 	INT32 scrolly = (which) ? scrolly_r : scrolly_l;
3029 
3030 	INT32 miny = (which) ? (nScreenHeight/2) : 0;
3031 	INT32 maxy = (which) ? nScreenHeight : (nScreenHeight / 2);
3032 
3033 	for (INT32 y=miny; y<maxy;y++)
3034 	{
3035 		INT32 srcline = (y + scrolly) & 0x1ff;
3036 		UINT16* src = pTempDraw[which] + srcline * 512;
3037 		UINT16* dst = pTransDraw + y * nScreenWidth;
3038 
3039 		for (INT32 x=0; x<nScreenWidth;x++)
3040 		{
3041 			INT32 srccol = 0;
3042 
3043 			// 2 bits control the x scroll mode, allowing it to wrap either half of the tilemap, or transition one way or the other between the two halves
3044 
3045 			switch (mode_set & 3)
3046 			{
3047 				case 0x00: srccol = ((x + scrollx) & 0xff); break; // hwy normal case
3048 				case 0x01: srccol = (x + scrollx + 0x100) & 0x1ff; break; // manhattan building top
3049 				case 0x02: srccol = ((x + scrollx) & 0xff) + 0x100; break; // manhattan normal case
3050 				case 0x03: srccol = (x + scrollx) & 0x1ff; break; // hwy, burnrub etc.
3051 			}
3052 
3053 			UINT16 pix = src[srccol];
3054 
3055 			if ((pix & 0x3) || opaque)
3056 			{
3057 				if (pix!=0) dst[x] = pix; // if (pix!=0) because it needs to inherit the background fill from underneath it.
3058 			}
3059 		}
3060 	}
3061 }
3062 
predraw_bg()3063 static void predraw_bg()
3064 {
3065 	INT32 color = (color_center_bot >> 7) & 1;
3066 
3067 	color = (color * 4) + 1;
3068 
3069 	color = (color << 3);
3070 
3071 	if (~nSpriteEnable & 2) memset(pTempDraw[0], 0, 512*512*sizeof(UINT16));
3072 	if (~nSpriteEnable & 4) memset(pTempDraw[1], 0, 512*512*sizeof(UINT16));
3073 
3074 	for (INT32 offs = 0; offs < 32 * 32; offs++)
3075 	{
3076 		INT32 sy = (offs & 0x1f) * 16;
3077 		INT32 sx = (offs / 0x20) * 16;
3078 
3079 		INT32 ofst = (offs & 7) ^ ((offs & 0x1e0) >> 2) ^ ((offs & 0x10) << 5) ^ ((offs & 0x200) >> 1) ^ 0x078;
3080 		if (offs & 0x008) ofst ^= 0x087;
3081 
3082 		INT32 code = DrvTileRAM[ofst] >> 4;
3083 
3084 		{
3085 			UINT8 *gfx0 = DrvTileExp + (code * 0x100);
3086 			UINT8 *gfx1 = DrvTileExp + (code * 0x100) + (15 * 16);
3087 
3088 			UINT16 *ds0 = pTempDraw[0] + (sy * 512) + sx;
3089 			UINT16 *ds1 = pTempDraw[1] + (sy * 512) + sx;
3090 
3091 			for (INT32 y = 0; y < 16; y++)
3092 			{
3093 				for (INT32 x = 0; x < 16; x++)
3094 				{
3095 					if (!(ofst & 0x80)) if (nSpriteEnable & 2) ds0[x] = gfx0[x] + color;
3096 					if ( (ofst & 0x80)) if (nSpriteEnable & 4) ds1[x] = gfx1[x] + color;
3097 				}
3098 				ds0 += 512;
3099 				ds1 += 512;
3100 				gfx0 += 16;
3101 				gfx1 -= 16;
3102 			}
3103 		}
3104 	}
3105 }
3106 
DrvDraw()3107 static INT32 DrvDraw()
3108 {
3109 	if (DrvRecalc) {
3110 		DrvPaletteUpdate();
3111 		DrvRecalc = 0;
3112 	}
3113 
3114 	BurnTransferClear(8);
3115 
3116 	predraw_bg();
3117 
3118 	if (mode_set & 0x08)
3119 	{
3120 		draw_edge(0, true);
3121 		draw_edge(1, true);
3122 	}
3123 
3124 	if (mode_set & 0x20)
3125 	{
3126 		if (nBurnLayer & 2) draw_center();
3127 	}
3128 	else
3129 	{
3130 		if (nBurnLayer & 2) draw_center();
3131 		if (mode_set & 0x08)
3132 		{
3133 			draw_edge(0, false);
3134 			draw_edge(1, false);
3135 		}
3136 	}
3137 
3138 	if (nBurnLayer & 4) GenericTilemapDraw(2, pTransDraw, (skater_mode) ? 1 : 0);
3139 
3140 	if (nSpriteEnable & 1) draw_sprites((color_center_bot >> 1) & 1, 8, 0, DrvFgRAM, 0x20);
3141 
3142 	if (nBurnLayer & 8) draw_missiles(1+8, 0, DrvColRAM, 0x20);
3143 
3144 	if (nBurnLayer & 1) draw_object();
3145 
3146 	BurnTransferCopy(DrvPalette);
3147 
3148 	return 0;
3149 }
3150 
DrvFrame()3151 static INT32 DrvFrame()
3152 {
3153 	if ((watchdog_flip & 0x04) == 0)
3154 		watchdog = 0;
3155 	else if (watchdog_count-- > 0)
3156 		watchdog = 0;
3157 
3158 	watchdog++;
3159 	if (watchdog > 180) {
3160 		M6502Open(0);
3161 		M6502Reset();
3162 		M6502Close();
3163 
3164 		M6502Open(1);
3165 		M6502Reset();
3166 		M6502Close();
3167 
3168 		watchdog = 0;
3169 	}
3170 
3171 	if (DrvReset) {
3172 		DrvDoReset();
3173 	}
3174 
3175 	M6502NewFrame();
3176 
3177 	{
3178 		INT32 prev = DrvInputs[2] & 0xc0;
3179 
3180 		memset (DrvInputs, 0, 11);
3181 
3182 		DrvInputs[2] = 0xc0;
3183 
3184 		for (INT32 i = 0; i < 8; i++) {
3185 			DrvInputs[0] ^= (DrvJoy1[i] & 1) << i;
3186 			DrvInputs[1] ^= (DrvJoy2[i] & 1) << i;
3187 			DrvInputs[2] ^= (DrvJoy3[i] & 1) << i;
3188 		}
3189 
3190 		if (fourway_mode) {
3191 			ProcessJoystick(&DrvInputs[0], 0, 2,3,1,0, INPUT_4WAY | INPUT_CLEAROPPOSITES );
3192 			ProcessJoystick(&DrvInputs[1], 1, 2,3,1,0, INPUT_4WAY | INPUT_CLEAROPPOSITES );
3193 		}
3194 
3195 		if (BurnDrvGetGenreFlags() & GBF_MAHJONG) {
3196 			for (INT32 i = 0; i < 8; i++) {
3197 				DrvInputs[ 3] ^= (DrvJoy4[i] & 1) << i;
3198 				DrvInputs[ 4] ^= (DrvJoy5[i] & 1) << i;
3199 				DrvInputs[ 5] ^= (DrvJoy6[i] & 1) << i;
3200 				DrvInputs[ 6] ^= (DrvJoy7[i] & 1) << i;
3201 				DrvInputs[ 7] ^= (DrvJoy8[i] & 1) << i;
3202 				DrvInputs[ 8] ^= (DrvJoy9[i] & 1) << i;
3203 				DrvInputs[ 9] ^= (DrvJoy10[i] & 1) << i;
3204 				DrvInputs[10] ^= (DrvJoy11[i] & 1) << i;
3205 			}
3206 		}
3207 
3208 		if (prev != (DrvInputs[2] & 0xc0) && (DrvInputs[2] & 0xc0) == 0xc0) {
3209 			M6502Open(0);
3210 			M6502SetIRQLine(0x20, CPU_IRQSTATUS_ACK);
3211 			M6502Close();
3212 		}
3213 	}
3214 
3215 	INT32 nInterleave = 272;
3216 	INT32 nCyclesTotal[3] = { (INT32)((double)750000 / 57.444853), (INT32)((double)500000 / 57.444853), (INT32)((double)500000 / 57.444853) }; //1.5mhz -> .75mhz?
3217 	INT32 nCyclesDone[3]  = { 0, 0, 0 };
3218 	INT32 nSoundBufferPos = 0;
3219 
3220 	vblank = 1;
3221 
3222 	for (INT32 i = 0; i < nInterleave; i++)
3223 	{
3224 		M6502Open(0);
3225 		INT32 nSegment = (i + 1) * nCyclesTotal[0] / nInterleave;
3226 		nCyclesDone[0] += M6502Run(nSegment - nCyclesDone[0]);
3227 		M6502Close();
3228 
3229 		if (i == 248) vblank = 1;
3230 		if (i == 8) {
3231 			vblank = 0;
3232 		}
3233 		if (i == 248) {
3234 			if (pBurnDraw) {
3235 				BurnDrvRedraw();
3236 			}
3237 		}
3238 
3239 		M6502Open(1);
3240 		if (decocass_reset & 1)
3241 		{
3242 			nSegment = (i + 1) * nCyclesTotal[1] / nInterleave;
3243 			nCyclesDone[1] += nSegment - nCyclesDone[1];
3244 		}
3245 		else
3246 		{
3247 			nSegment = (i + 1) * nCyclesTotal[1] / nInterleave;
3248 			nCyclesDone[1] += M6502Run(nSegment - nCyclesDone[1]);
3249 
3250 			if ((i+1)%8 == 7)
3251 			{
3252 				audio_nmi_state = (i+1) & 8;
3253 				M6502SetIRQLine(0x20, (audio_nmi_enabled && audio_nmi_state) ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_NONE);
3254 			}
3255 		}
3256 		M6502Close();
3257 
3258 		if (decocass_reset & 0x08)
3259 		{
3260 			nSegment = (i + 1) * nCyclesTotal[2] / nInterleave;
3261 			INT32 derp = nSegment - nCyclesDone[2];
3262 			nCyclesDone[2] += derp;
3263 			tape_freerun += derp;
3264 		}
3265 		else
3266 		{
3267 			nSegment = (i + 1) * nCyclesTotal[2] / nInterleave;
3268 			INT32 derp = i8x41_run(nSegment - nCyclesDone[2]);
3269 			nCyclesDone[2] += derp;
3270 			tape_freerun += derp;
3271 
3272 		}
3273 		if (pBurnSoundOut && i&1) {
3274 			INT32 nSegmentLength = nBurnSoundLen / (nInterleave / 2);
3275 			INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
3276 			AY8910Render(pSoundBuf, nSegmentLength);
3277 			nSoundBufferPos += nSegmentLength;
3278 		}
3279 	}
3280 
3281 	if (pBurnSoundOut) {
3282 		INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
3283 		INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
3284 		if (nSegmentLength) {
3285 			AY8910Render(pSoundBuf, nSegmentLength);
3286 		}
3287 	}
3288 
3289 	return 0;
3290 }
3291 
3292 
DrvScan(INT32 nAction,INT32 * pnMin)3293 static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
3294 {
3295 	struct BurnArea ba;
3296 
3297 	if (pnMin != NULL) {
3298 		*pnMin = 0x029719;
3299 	}
3300 
3301 	if (nAction & ACB_MEMORY_RAM) {
3302 		memset(&ba, 0, sizeof(ba));
3303 		ba.Data	  = AllRam;
3304 		ba.nLen	  = RamEnd-AllRam;
3305 		ba.szName = "All Ram";
3306 		BurnAcb(&ba);
3307 
3308 		memset(&ba, 0, sizeof(ba));
3309 		ba.Data	  = I8x41Mem;
3310 		ba.nLen	  = 0x900;
3311 		ba.szName = "MCU Ram";
3312 		BurnAcb(&ba);
3313 	}
3314 
3315 	if (nAction & ACB_DRIVER_DATA) {
3316 		M6502Scan(nAction);
3317 		i8x41_scan(nAction);
3318 
3319 		AY8910Scan(nAction, pnMin);
3320 
3321 		SCAN_VAR(watchdog_count);
3322 		SCAN_VAR(watchdog_flip);
3323 		SCAN_VAR(watchdog);
3324 
3325 		SCAN_VAR(color_missiles);
3326 		SCAN_VAR(mode_set);
3327 		SCAN_VAR(color_center_bot);
3328 
3329 		SCAN_VAR(back_h_shift);
3330 		SCAN_VAR(back_vl_shift);
3331 		SCAN_VAR(back_vr_shift);
3332 		SCAN_VAR(part_h_shift);
3333 		SCAN_VAR(part_v_shift);
3334 		SCAN_VAR(center_h_shift_space);
3335 		SCAN_VAR(center_v_shift);
3336 
3337 		SCAN_VAR(flipscreen);
3338 
3339 		SCAN_VAR(soundlatch);
3340 		SCAN_VAR(sound_ack);
3341 		SCAN_VAR(soundlatch2);
3342 		SCAN_VAR(mux_data);
3343 
3344 		SCAN_VAR(decocass_reset);
3345 		SCAN_VAR(audio_nmi_enabled);
3346 		SCAN_VAR(audio_nmi_state);
3347 
3348 		SCAN_VAR(i8041_p1);
3349 		SCAN_VAR(i8041_p2);
3350 
3351 		SCAN_VAR(type1_latch1);
3352 
3353 		SCAN_VAR(type2_d2_latch);
3354 		SCAN_VAR(type2_xx_latch);
3355 		SCAN_VAR(type2_promaddr);
3356 
3357 		SCAN_VAR(type3_pal_19);
3358 		SCAN_VAR(type3_ctrs);
3359 		SCAN_VAR(type3_d0_latch);
3360 
3361 		SCAN_VAR(type4_ctrs);
3362 		SCAN_VAR(type4_latch);
3363 
3364 		SCAN_VAR(tape_time0);
3365 		SCAN_VAR(tape_speed);
3366 		SCAN_VAR(tape_timer);
3367 		SCAN_VAR(tape_dir);
3368 
3369 		SCAN_VAR(tape_freerun);
3370 
3371 		SCAN_VAR(firsttime);
3372 		SCAN_VAR(tape_bot_eot);
3373 	}
3374 
3375 	if (nAction & ACB_WRITE) {
3376 		decode_ram_tiles();
3377 		M6502Open(0);
3378 		set_gfx_bank(e900_gfxbank);
3379 		M6502Close();
3380 	}
3381 
3382 	return 0;
3383 }
3384 
3385 // necessary for setting up bios relationship
3386 static struct BurnRomInfo emptyRomDesc[] = {
3387 	{ "", 0, 0, 0 },
3388 };
3389 
3390 // DECO Cassette System
3391 
3392 static struct BurnRomInfo decocassRomDesc[] = {
3393 	{ "v0a-.7e",   		0x1000, 0x3d33ac34, BRF_BIOS | BRF_PRG }, // 0x80 - BIOS "A" Japan (Main M6502)
3394 	{ "",             	0x0000, 0x00000000, 0                  }, // 0x81
3395 
3396 	{ "v1-.5a",     	0x0800, 0xb66b2c2a, BRF_BIOS | BRF_PRG }, // 0x82 - BIOS "A" Japan (Sound M6502)
3397 
3398 	{ "v2.3m",		0x0020, 0x238fdb40, BRF_BIOS | BRF_OPT }, // 0x83 - BIOS "A" Japan (prom)
3399 	{ "v4.10d",		0x0020, 0x3b5836b4, BRF_BIOS | BRF_OPT }, // 0x84 - BIOS "A" Japan (prom)
3400 	{ "v3.3j",		0x0020, 0x51eef657, BRF_BIOS | BRF_OPT }, // 0x85 - BIOS "A" Japan (prom)
3401 
3402 	{ "",             	0x0000, 0x00000000, 0                  }, // 0x86
3403 	{ "",             	0x0000, 0x00000000, 0                  }, // 0x87
3404 
3405 	{ "dsp-3_p0-a.m9",      0x0800, 0x2541e34b, BRF_BIOS | BRF_PRG }, // 0x88 - BIOS "A" Japan, Older (Main M6502)
3406 	{ "dsp-3_p1-.l9",       0x0800, 0x3bfff5f3, BRF_BIOS | BRF_PRG }, // 0x89 - BIOS "A" Japan, Older (Main M6502)
3407 
3408 	{ "rms-3_p2-.c9",       0x0400, 0x6c4a891f, BRF_BIOS | BRF_PRG }, // 0x8a - BIOS "A" Japan, Older (Sound M6502)
3409 
3410 	{ "dsp-3_p3-.e5",       0x0020, 0x539a5a64, BRF_BIOS | BRF_OPT }, // 0x8b - BIOS "A" Japan, Older (prom)
3411 	{ "rms-3_p4-.f6",       0x0020, 0x9014c0fd, BRF_BIOS | BRF_OPT }, // 0x8c - BIOS "A" Japan, Older (prom)
3412 	{ "dsp-3_p5-.m4",       0x0020, 0xe52089a0, BRF_BIOS | BRF_OPT }, // 0x8d - BIOS "A" Japan, Older (prom)
3413 
3414 	{ "",             	0x0000, 0x00000000, 0                  }, // 0x8e
3415 	{ "",             	0x0000, 0x00000000, 0                  }, // 0x8f
3416 
3417 	{ "v0b-.7e",  		0x1000, 0x23d929b7, BRF_BIOS | BRF_PRG }, // 0x90 - BIOS "B" USA (Main M6502)
3418 	{ "",             	0x0000, 0x00000000, 0                  }, // 0x91
3419 
3420 	{ "v1-.5a",     	0x0800, 0xb66b2c2a, BRF_BIOS | BRF_PRG }, // 0x92 - BIOS "B" USA (Sound M6502)
3421 
3422 	{ "v2.3m",		0x0020, 0x238fdb40, BRF_BIOS | BRF_OPT }, // 0x93 - BIOS "B" USA (prom)
3423 	{ "v4.10d",		0x0020, 0x3b5836b4, BRF_BIOS | BRF_OPT }, // 0x94 - BIOS "B" USA (prom)
3424 	{ "v3.3j",		0x0020, 0x51eef657, BRF_BIOS | BRF_OPT }, // 0x95 - BIOS "B" USA (prom)
3425 
3426 	{ "",             	0x0000, 0x00000000, 0                  }, // 0x96
3427 	{ "",             	0x0000, 0x00000000, 0                  }, // 0x97
3428 
3429 	{ "dsp-3_p0-b.m9",      0x0800, 0xb67a91d9, BRF_BIOS | BRF_PRG }, // 0x98 - BIOS "B" USA, Older (Main M6502)
3430 	{ "dsp-3_p1-.l9",       0x0800, 0x3bfff5f3, BRF_BIOS | BRF_PRG }, // 0x99 - BIOS "B" USA, Older (Main M6502)
3431 
3432 	{ "rms-3_p2-.c9",       0x0400, 0x6c4a891f, BRF_BIOS | BRF_PRG }, // 0x9a - BIOS "B" USA, older (Sound M6502)
3433 
3434 	{ "dsp-3_p3-.e5",       0x0020, 0x539a5a64, BRF_BIOS | BRF_OPT }, // 0x9b - BIOS "B" USA, older (prom)
3435 	{ "rms-3_p4-.f6",       0x0020, 0x9014c0fd, BRF_BIOS | BRF_OPT }, // 0x9c - BIOS "B" USA, older (prom)
3436 	{ "dsp-3_p5-.m4",       0x0020, 0xe52089a0, BRF_BIOS | BRF_OPT }, // 0x9d - BIOS "B" USA, older (prom)
3437 
3438 	{ "",             	0x0000, 0x00000000, 0                  }, // 0x9e
3439 	{ "",             	0x0000, 0x00000000, 0                  }, // 0x9f
3440 
3441 	{ "cassmcu.1c", 	0x0400, 0xa6df18fd, BRF_BIOS | BRF_PRG }, // 0xa0 - MCU BIOS (Shared)
3442 
3443 #ifdef ROM_VERIFY
3444 	{ "v0d-.7e",		0x1000, 0x1e0c22b1, BRF_BIOS | BRF_PRG }, // 0xa1 - handcrafted (single byte changed) because ctisland3 requires region D
3445 #endif
3446 };
3447 
3448 STD_ROM_PICK(decocass)
STD_ROM_FN(decocass)3449 STD_ROM_FN(decocass)
3450 
3451 static INT32 BiosInit()
3452 {
3453 	return 1;
3454 }
3455 
3456 struct BurnDriver BurnDrvDecocass = {
3457 	"decocass", NULL, NULL, NULL, "1981",
3458 	"DECO Cassette System Bios\0", "BIOS only", "Data East", "Cassette System",
3459 	NULL, NULL, NULL, NULL,
3460 	BDF_BOARDROM | BDF_ORIENTATION_VERTICAL, 0, HARDWARE_PREFIX_DATAEAST, GBF_BIOS, 0,
3461 	NULL, decocassRomInfo, decocassRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, DecocassDIPInfo,
3462 	BiosInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3463 	240, 256, 3, 4
3464 };
3465 
3466 
3467 // Test Tape (DECO Cassette) (US)
3468 
3469 static struct BurnRomInfo ctsttapeRomDesc[] = {
3470 	{ "de-0061.pro",	0x0020, 0xe09ae5de, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3471 
3472 	{ "testtape.cas",	0x2000, 0x4f9d8efb, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3473 };
3474 
3475 STDROMPICKEXT(ctsttape, ctsttape, decocass)
3476 STD_ROM_FN(ctsttape)
3477 
3478 static UINT8 type1_pass_136_table[8] ={ T1PROM,T1DIRECT,T1PROM,T1DIRECT,T1PROM,T1PROM,T1DIRECT,T1PROM };
3479 
CtsttapeInit()3480 static INT32 CtsttapeInit()
3481 {
3482 	type1_map = type1_pass_136_table;
3483 
3484 	return DecocassInit(decocass_type1_read,NULL);
3485 }
3486 
3487 struct BurnDriver BurnDrvCtsttape = {
3488 	"ctsttape", NULL, "decocass", NULL, "1981",
3489 	"Test Tape (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
3490 	NULL, NULL, NULL, NULL,
3491 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_MISC, 0,
3492 	NULL, ctsttapeRomInfo, ctsttapeRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CtsttapeDIPInfo,
3493 	CtsttapeInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3494 	240, 256, 3, 4
3495 };
3496 
3497 
3498 // Highway Chase (DECO Cassette) (US)
3499 
3500 static struct BurnRomInfo chwyRomDesc[] = {
3501 	{ "chwy.pro",		0x0020, 0x2fae678e, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3502 
3503 	{ "chwy.cas",		0x8000, 0x68a48064, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3504 };
3505 
3506 STDROMPICKEXT(chwy, chwy, decocass)
3507 STD_ROM_FN(chwy)
3508 
3509 static UINT8 type1_latch_27_pass_3_inv_2_table[8] = { T1PROM,T1PROM,T1LATCHINV,T1DIRECT,T1PROM,T1PROM,T1PROM,T1LATCH };
3510 
ChwyInit()3511 static INT32 ChwyInit()
3512 {
3513 	type1_map = type1_latch_27_pass_3_inv_2_table;
3514 
3515 	return DecocassInit(decocass_type1_read,NULL);
3516 }
3517 
3518 struct BurnDriver BurnDrvChwy = {
3519 	"chwy", NULL, "decocass", NULL, "1980",
3520 	"Highway Chase (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
3521 	NULL, NULL, NULL, NULL,
3522 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_VERSHOOT, 0,
3523 	NULL, chwyRomInfo, chwyRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, ChwyDIPInfo,
3524 	ChwyInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3525 	240, 256, 3, 4
3526 };
3527 
3528 
3529 // Manhattan (DECO Cassette) (Japan)
3530 
3531 static struct BurnRomInfo cmanhatRomDesc[] = {
3532 	{ "manhattan.pro",	0x0020, 0x1bc9fccb, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3533 
3534 	{ "manhattan.cas",	0x6000, 0x92dae2b1, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3535 };
3536 
3537 STDROMPICKEXT(cmanhat, cmanhat, decocass)
3538 STD_ROM_FN(cmanhat)
3539 
3540 static UINT8 type1_latch_xab_pass_x54_table[8] = { T1PROM,T1PROM,T1DIRECT,T1PROM,T1DIRECT,T1PROM,T1DIRECT,T1PROM };
3541 
CmanhatInit()3542 static INT32 CmanhatInit()
3543 {
3544 	type1_map = type1_latch_xab_pass_x54_table;
3545 
3546 	return DecocassInit(decocass_type1_read,NULL);
3547 }
3548 
3549 struct BurnDriver BurnDrvCmanhat = {
3550 	"cmanhat", NULL, "decocass", NULL, "1981",
3551 	"Manhattan (DECO Cassette) (Japan)\0", NULL, "Data East Corporation", "Cassette System",
3552 	NULL, NULL, NULL, NULL,
3553 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_ACTION, 0,
3554 	NULL, cmanhatRomInfo, cmanhatRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CmanhatDIPInfo,
3555 	CmanhatInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3556 	240, 256, 3, 4
3557 };
3558 
3559 
3560 // Terranean (DECO Cassette) (US)
3561 
3562 static struct BurnRomInfo cterraniRomDesc[] = {
3563 	{ "dp-1040.dgl",	0x0020, 0xe09ae5de, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3564 
3565 	{ "dt-1040.cas",	0x8000, 0xeb71adbc, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3566 };
3567 
3568 STDROMPICKEXT(cterrani, cterrani, decocass)
3569 STD_ROM_FN(cterrani)
3570 
3571 static UINT8 type1_latch_26_pass_3_inv_2_table[8] = { T1PROM,T1PROM,T1LATCHINV,T1DIRECT,T1PROM, T1PROM,T1LATCH,T1PROM };
3572 
CterraniInit()3573 static INT32 CterraniInit()
3574 {
3575 	type1_map = type1_latch_26_pass_3_inv_2_table;
3576 	type1_inmap = MAKE_MAP(0,1,2,3,4,5,6,7);
3577 	type1_outmap = MAKE_MAP(0,1,2,3,4,5,6,7);
3578 
3579 	return DecocassInit(decocass_type1_read,NULL);
3580 }
3581 
3582 struct BurnDriver BurnDrvCterrani = {
3583 	"cterrani", NULL, "decocass", NULL, "1981",
3584 	"Terranean (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
3585 	NULL, NULL, NULL, NULL,
3586 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_VERSHOOT, 0,
3587 	NULL, cterraniRomInfo, cterraniRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CterraniDIPInfo,
3588 	CterraniInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3589 	240, 256, 3, 4
3590 };
3591 
3592 
3593 // Astro Fantasia (DECO Cassette) (US)
3594 
3595 static struct BurnRomInfo castfantRomDesc[] = {
3596 	{ "de-0061.pro",	0x0020, 0xe09ae5de, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3597 
3598 	{ "castfant.cas",	0x8000, 0x6d77d1b5, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3599 };
3600 
3601 STDROMPICKEXT(castfant, castfant, decocass)
3602 STD_ROM_FN(castfant)
3603 
3604 static UINT8 type1_latch_16_pass_3_inv_1_table[8] = { T1PROM,T1LATCHINV,T1PROM,T1DIRECT,T1PROM,T1PROM,T1LATCH,T1PROM };
3605 
CastfantInit()3606 static INT32 CastfantInit()
3607 {
3608 	type1_map = type1_latch_16_pass_3_inv_1_table;
3609 
3610 	return DecocassInit(decocass_type1_read,NULL);
3611 }
3612 
3613 struct BurnDriver BurnDrvCastfant = {
3614 	"castfant", NULL, "decocass", NULL, "1981",
3615 	"Astro Fantasia (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
3616 	NULL, NULL, NULL, NULL,
3617 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_VERSHOOT, 0,
3618 	NULL, castfantRomInfo, castfantRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CastfantDIPInfo,
3619 	CastfantInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3620 	240, 256, 3, 4
3621 };
3622 
3623 
3624 // Super Astro Fighter (DECO Cassette) (US)
3625 
3626 static struct BurnRomInfo csuperasRomDesc[] = {
3627 	{ "de-0061.pro",	0x0020, 0xe09ae5de, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3628 
3629 	{ "csuperas.cas",	0x8000, 0xfabcd07f, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3630 };
3631 
STDROMPICKEXT(csuperas,csuperas,decocass)3632 STDROMPICKEXT(csuperas, csuperas, decocass)
3633 STD_ROM_FN(csuperas)
3634 
3635 static INT32 CsuperasInit()
3636 {
3637 	type1_map = type1_latch_26_pass_3_inv_2_table;
3638 	type1_inmap = MAKE_MAP(0,1,2,3,5,4,6,7);
3639 	type1_outmap = MAKE_MAP(0,1,2,3,5,4,6,7);
3640 
3641 	return DecocassInit(decocass_type1_read,NULL);
3642 }
3643 
3644 struct BurnDriver BurnDrvCsuperas = {
3645 	"csuperas", NULL, "decocass", NULL, "1981",
3646 	"Super Astro Fighter (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
3647 	NULL, NULL, NULL, NULL,
3648 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_VERSHOOT, 0,
3649 	NULL, csuperasRomInfo, csuperasRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CsuperasDIPInfo,
3650 	CsuperasInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3651 	240, 256, 3, 4
3652 };
3653 
3654 
3655 // Ocean to Ocean (Medal) (DECO Cassette MD) (No.10/Ver.1,Japan)
3656 
3657 static struct BurnRomInfo cocean1aRomDesc[] = {
3658 	{ "dp-1100-a.rom",	0x0020, 0x1bc9fccb, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data'
3659 
3660 	{ "dt-1101-a-0.cas",	0x3e00, 0xdb8ab848, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3661 };
3662 
3663 STDROMPICKEXT(cocean1a, cocean1a, decocass)
3664 STD_ROM_FN(cocean1a)
3665 
3666 static UINT8 type1_map1100[8] = { T1PROM,T1PROM,T1LATCHINV,T1PROM,T1DIRECT,T1PROM,T1LATCH,T1PROM };
3667 
Cocean1aInit()3668 static INT32 Cocean1aInit()
3669 {
3670 	type1_map = type1_map1100;
3671 	type1_inmap = MAKE_MAP(0,1,2,3,4,5,6,7);
3672 	type1_outmap = MAKE_MAP(0,1,2,3,4,5,6,7);
3673 
3674 	return DecocassInit(decocass_type1_read,NULL);
3675 }
3676 
3677 struct BurnDriver BurnDrvCocean1a = {
3678 	"cocean1a", NULL, "decocass", NULL, "1981",
3679 	"Ocean to Ocean (Medal) (DECO Cassette MD) (No.10/Ver.1,Japan)\0", NULL, "Data East Corporation", "Cassette System",
3680 	NULL, NULL, NULL, NULL,
3681 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_CASINO, 0,
3682 	NULL, cocean1aRomInfo, cocean1aRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, Cocean1aDIPInfo,
3683 	Cocean1aInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3684 	240, 256, 3, 4
3685 };
3686 
3687 
3688 // Ocean to Ocean (Medal) (DECO Cassette MD) (No.10/Ver.6,US)
3689 
3690 static struct BurnRomInfo cocean6bRomDesc[] = {
3691 	{ "dp-1100-b.rom",	0x0020, 0xe09ae5de, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3692 
3693 	{ "dt-1106-b-0.cas",	0x4500, 0xfa6ffc95, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3694 };
3695 
3696 STDROMPICKEXT(cocean6b, cocean6b, decocass)
3697 STD_ROM_FN(cocean6b)
3698 
3699 struct BurnDriver BurnDrvCocean6b = {
3700 	"cocean6b", "cocean1a", "decocass", NULL, "1981",
3701 	"Ocean to Ocean (Medal) (DECO Cassette MD) (No.10/Ver.6,US)\0", NULL, "Data East Corporation", "Cassette System",
3702 	NULL, NULL, NULL, NULL,
3703 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_CASINO, 0,
3704 	NULL, cocean6bRomInfo, cocean6bRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, Cocean6bDIPInfo,
3705 	Cocean1aInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3706 	240, 256, 3, 4
3707 };
3708 
3709 
3710 // Lock'n'Chase (DECO Cassette) (US)
3711 
3712 static struct BurnRomInfo clocknchRomDesc[] = {
3713 	{ "dp-1110_b.dgl",	0x0020, 0xe09ae5de, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3714 
3715 	{ "clocknch.cas",	0x8000, 0xc9d163a4, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3716 };
3717 
STDROMPICKEXT(clocknch,clocknch,decocass)3718 STDROMPICKEXT(clocknch, clocknch, decocass)
3719 STD_ROM_FN(clocknch)
3720 
3721 static INT32 ClocknchInit()
3722 {
3723 	type1_map = type1_latch_26_pass_3_inv_2_table;
3724 	type1_inmap = MAKE_MAP(0,1,3,2,4,5,6,7);
3725 	type1_outmap = MAKE_MAP(0,1,3,2,4,5,6,7);
3726 
3727 	return DecocassInit(decocass_type1_read,NULL);
3728 }
3729 
3730 struct BurnDriver BurnDrvClocknch = {
3731 	"clocknch", NULL, "decocass", NULL, "1981",
3732 	"Lock'n'Chase (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
3733 	NULL, NULL, NULL, NULL,
3734 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_MAZE, 0,
3735 	NULL, clocknchRomInfo, clocknchRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, ClocknchDIPInfo,
3736 	ClocknchInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3737 	240, 256, 3, 4
3738 };
3739 
3740 
3741 // Lock'n'Chase (DECO Cassette) (Japan)
3742 
3743 static struct BurnRomInfo clocknchjRomDesc[] = {
3744 	{ "a-0061.dgl",		0x0020, 0x1bc9fccb, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3745 
3746 	{ "dt-1111-a-0.bin",	0x6300, 0x9753e815, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3747 };
3748 
3749 STDROMPICKEXT(clocknchj, clocknchj, decocass)
3750 STD_ROM_FN(clocknchj)
3751 
3752 static UINT8 type1_map_clocknchj[8] = { T1PROM,T1PROM,T1DIRECT,T1LATCHINV,T1PROM,T1PROM,T1LATCH,T1PROM };
3753 
ClocknchjInit()3754 static INT32 ClocknchjInit()
3755 {
3756 	type1_map = type1_map_clocknchj;
3757 	type1_inmap = MAKE_MAP(0,1,2,3,4,5,6,7);
3758 	type1_outmap = MAKE_MAP(0,1,2,3,4,5,6,7);
3759 
3760 	return DecocassInit(decocass_type1_read,NULL);
3761 }
3762 
3763 struct BurnDriver BurnDrvClocknchj = {
3764 	"clocknchj", "clocknch", "decocass", NULL, "1981",
3765 	"Lock'n'Chase (DECO Cassette) (Japan)\0", NULL, "Data East Corporation", "Cassette System",
3766 	NULL, NULL, NULL, NULL,
3767 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_MAZE, 0,
3768 	NULL, clocknchjRomInfo, clocknchjRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, ClocknchjDIPInfo,
3769 	ClocknchjInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3770 	240, 256, 3, 4
3771 };
3772 
3773 
3774 // Flash Boy (vertical) [DECO Cassette MD] (No.12/Ver.0/Set.1,Japan)
3775 
3776 static struct BurnRomInfo cfboy0a1RomDesc[] = {
3777 	{ "dp-1120-a.rom",	0x0020, 0x1bc9fccb, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3778 
3779 	{ "dt-1120-a-1.cas",	0x6a00, 0xc6746dc0, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3780 };
3781 
3782 STDROMPICKEXT(cfboy0a1, cfboy0a1, decocass)
3783 STD_ROM_FN(cfboy0a1)
3784 
3785 static UINT8 type1_map1120[8] = { T1PROM,T1PROM,T1LATCHINV,T1DIRECT,T1PROM,T1LATCH,T1PROM,T1PROM };
3786 
Cfboy0a1Init()3787 static INT32 Cfboy0a1Init()
3788 {
3789 	type1_map = type1_map1120;
3790 	type1_inmap = MAKE_MAP(0,1,2,3,4,5,6,7);
3791 	type1_outmap = MAKE_MAP(0,1,2,3,4,5,6,7);
3792 
3793 	return DecocassInit(decocass_type1_read,NULL);
3794 }
3795 
3796 struct BurnDriver BurnDrvCfboy0a1 = {
3797 	"cfboy0a1", NULL, "decocass", NULL, "1981",
3798 	"Flash Boy (vertical) [DECO Cassette MD] (No.12/Ver.0/Set.1,Japan)\0", NULL, "Data East Corporation", "Cassette System",
3799 	NULL, NULL, NULL, NULL,
3800 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_VERSHOOT, 0,
3801 	NULL, cfboy0a1RomInfo, cfboy0a1RomName, NULL, NULL, NULL, NULL, DecocassInputInfo, Cfboy0a1DIPInfo,
3802 	Cfboy0a1Init, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3803 	240, 256, 3, 4
3804 };
3805 
3806 
3807 // Tournament Pro Golf (DECO Cassette) (US)
3808 
3809 static struct BurnRomInfo cprogolfRomDesc[] = {
3810 	{ "dp-1130_b.dgl",	0x0020, 0xe09ae5de, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3811 
3812 	{ "dt-1130_9b.cas",	0x8000, 0x02123cd1, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3813 };
3814 
STDROMPICKEXT(cprogolf,cprogolf,decocass)3815 STDROMPICKEXT(cprogolf, cprogolf, decocass)
3816 STD_ROM_FN(cprogolf)
3817 
3818 static INT32 CprogolfInit()
3819 {
3820 	type1_map = type1_latch_26_pass_3_inv_2_table;
3821 	type1_inmap = MAKE_MAP(1,0,2,3,4,5,6,7);
3822 	type1_outmap = MAKE_MAP(1,0,2,3,4,5,6,7);
3823 
3824 	return DecocassInit(decocass_type1_read,NULL);
3825 }
3826 
3827 struct BurnDriver BurnDrvCprogolf = {
3828 	"cprogolf", NULL, "decocass", NULL, "1981",
3829 	"Tournament Pro Golf (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
3830 	NULL, NULL, NULL, NULL,
3831 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSMISC, 0,
3832 	NULL, cprogolfRomInfo, cprogolfRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CprogolfDIPInfo,
3833 	CprogolfInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3834 	240, 256, 3, 4
3835 };
3836 
3837 
3838 // Tournament Pro Golf (DECO Cassette) (Japan)
3839 
3840 static struct BurnRomInfo cprogolfjRomDesc[] = {
3841 	{ "a-0061.dgl",		0x0020, 0x1bc9fccb, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3842 
3843 	{ "dt-113_a.cas",	0x8000, 0x8408248f, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3844 };
3845 
STDROMPICKEXT(cprogolfj,cprogolfj,decocass)3846 STDROMPICKEXT(cprogolfj, cprogolfj, decocass)
3847 STD_ROM_FN(cprogolfj)
3848 
3849 static INT32 CprogolfjInit()
3850 {
3851 	type1_map = type1_latch_26_pass_3_inv_2_table;
3852 	type1_inmap = MAKE_MAP(1,0,2,3,4,5,6,7);
3853 	type1_outmap = MAKE_MAP(1,0,2,3,4,5,6,7);
3854 
3855 	return DecocassInit(decocass_type1_read,NULL);
3856 }
3857 
3858 struct BurnDriver BurnDrvCprogolfj = {
3859 	"cprogolfj", "cprogolf", "decocass", NULL, "1981",
3860 	"Tournament Pro Golf (DECO Cassette) (Japan)\0", NULL, "Data East Corporation", "Cassette System",
3861 	NULL, NULL, NULL, NULL,
3862 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSMISC, 0,
3863 	NULL, cprogolfjRomInfo, cprogolfjRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CprogolfjDIPInfo,
3864 	CprogolfjInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3865 	240, 256, 3, 4
3866 };
3867 
3868 
3869 // 18 Challenge Pro Golf (DECO Cassette) (Japan)
3870 
3871 static struct BurnRomInfo cprogolf18RomDesc[] = {
3872 	{ "de-0061-a-0.rom",	0x0020, 0x1bc9fccb, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3873 
3874 	{ "progolf18.cas",	0x6700, 0x3024396c, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3875 };
3876 
3877 STDROMPICKEXT(cprogolf18, cprogolf18, decocass)
3878 STD_ROM_FN(cprogolf18)
3879 
3880 struct BurnDriver BurnDrvCprogolf18 = {
3881 	"cprogolf18", "cprogolf", "decocass", NULL, "1982",
3882 	"18 Challenge Pro Golf (DECO Cassette) (Japan)\0", NULL, "Data East Corporation", "Cassette System",
3883 	NULL, NULL, NULL, NULL,
3884 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSMISC, 0,
3885 	NULL, cprogolf18RomInfo, cprogolf18RomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CprogolfjDIPInfo,
3886 	CprogolfjInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3887 	240, 256, 3, 4
3888 };
3889 
3890 
3891 // DS Telejan (DECO Cassette) (Japan)
3892 
3893 static struct BurnRomInfo cdsteljnRomDesc[] = {
3894 	{ "a-0061.dgl",		0x0020, 0x1bc9fccb, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3895 
3896 	{ "dt-1144-a3.cas",	0x7300, 0x1336a912, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3897 };
3898 
STDROMPICKEXT(cdsteljn,cdsteljn,decocass)3899 STDROMPICKEXT(cdsteljn, cdsteljn, decocass)
3900 STD_ROM_FN(cdsteljn)
3901 
3902 static INT32 CdsteljnInit()
3903 {
3904 	type1_map = type1_latch_27_pass_3_inv_2_table;
3905 
3906 	return DecocassInit(decocass_type1_read,NULL);
3907 }
3908 
3909 struct BurnDriver BurnDrvCdsteljn = {
3910 	"cdsteljn", NULL, "decocass", NULL, "1981",
3911 	"DS Telejan (DECO Cassette) (Japan)\0", NULL, "Data East Corporation", "Cassette System",
3912 	NULL, NULL, NULL, NULL,
3913 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_MAHJONG, 0,
3914 	NULL, cdsteljnRomInfo, cdsteljnRomName, NULL, NULL, NULL, NULL, CdsteljnInputInfo, CdsteljnDIPInfo,
3915 	CdsteljnInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3916 	240, 256, 3, 4
3917 };
3918 
3919 
3920 // Lucky Poker (DECO Cassette) (US)
3921 
3922 static struct BurnRomInfo cluckypoRomDesc[] = {
3923 	{ "dp-1150_b.dgl",	0x0020, 0xe09ae5de, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3924 
3925 	{ "cluckypo.cas",	0x8000, 0x2070c243, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3926 };
3927 
STDROMPICKEXT(cluckypo,cluckypo,decocass)3928 STDROMPICKEXT(cluckypo, cluckypo, decocass)
3929 STD_ROM_FN(cluckypo)
3930 
3931 static INT32 CluckypoInit()
3932 {
3933 	type1_map = type1_latch_26_pass_3_inv_2_table;
3934 	type1_inmap = MAKE_MAP(0,3,2,1,4,5,6,7);
3935 	type1_outmap = MAKE_MAP(0,3,2,1,4,5,6,7);
3936 
3937 	return DecocassInit(decocass_type1_read,NULL);
3938 }
3939 
3940 struct BurnDriver BurnDrvCluckypo = {
3941 	"cluckypo", NULL, "decocass", NULL, "1981",
3942 	"Lucky Poker (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
3943 	NULL, NULL, NULL, NULL,
3944 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_CASINO, 0,
3945 	NULL, cluckypoRomInfo, cluckypoRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CluckypoDIPInfo,
3946 	CluckypoInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3947 	240, 256, 3, 4
3948 };
3949 
3950 
3951 // Treasure Island (DECO Cassette) (US) (set 1)
3952 
3953 static struct BurnRomInfo ctislandRomDesc[] = {
3954 	{ "de-0061.pro",	0x0020, 0xe09ae5de, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3955 
3956 	{ "ctisland.cas",	0x8000, 0x3f63b8f8, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3957 
3958 	{ "deco-ti.x1",		0x1000, 0xa7f8aeba, 3 | BRF_GRA },           //  2 Overlay data
3959 	{ "deco-ti.x2",		0x1000, 0x2a0d3c91, 3 | BRF_GRA },           //  3
3960 	{ "deco-ti.x3",		0x1000, 0x3a26b97c, 3 | BRF_GRA },           //  4
3961 	{ "deco-ti.x4",		0x1000, 0x1cbe43de, 3 | BRF_GRA },           //  5
3962 };
3963 
STDROMPICKEXT(ctisland,ctisland,decocass)3964 STDROMPICKEXT(ctisland, ctisland, decocass)
3965 STD_ROM_FN(ctisland)
3966 
3967 static INT32 CtislandInit()
3968 {
3969 	type1_map = type1_latch_26_pass_3_inv_2_table;
3970 	type1_inmap = MAKE_MAP(2,1,0,3,4,5,6,7);
3971 	type1_outmap = MAKE_MAP(2,1,0,3,4,5,6,7);
3972 
3973 	e900_enable = 1;
3974 
3975 	fourway_mode = 1;
3976 
3977 	return DecocassInit(decocass_type1_read,NULL);
3978 }
3979 
3980 struct BurnDriver BurnDrvCtisland = {
3981 	"ctisland", NULL, "decocass", NULL, "1981",
3982 	"Treasure Island (DECO Cassette) (US) (set 1)\0", NULL, "Data East Corporation", "Cassette System",
3983 	NULL, NULL, NULL, NULL,
3984 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_PLATFORM, 0,
3985 	NULL, ctislandRomInfo, ctislandRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CtislandDIPInfo,
3986 	CtislandInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
3987 	240, 256, 3, 4
3988 };
3989 
3990 
3991 // Treasure Island (DECO Cassette) (US) (set 2)
3992 
3993 static struct BurnRomInfo ctisland2RomDesc[] = {
3994 	{ "de-0061.pro",	0x0020, 0xe09ae5de, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
3995 
3996 	{ "ctislnd2.cas",	0x8000, 0x2854b4c0, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
3997 
3998 	{ "deco-ti.x1",		0x1000, 0xa7f8aeba, 3 | BRF_GRA },           //  2 Overlay data
3999 	{ "deco-ti.x2",		0x1000, 0x2a0d3c91, 3 | BRF_GRA },           //  3
4000 	{ "deco-ti.x3",		0x1000, 0x3a26b97c, 3 | BRF_GRA },           //  4
4001 	{ "deco-ti.x4",		0x1000, 0x1cbe43de, 3 | BRF_GRA },           //  5
4002 };
4003 
4004 STDROMPICKEXT(ctisland2, ctisland2, decocass)
4005 STD_ROM_FN(ctisland2)
4006 
4007 struct BurnDriver BurnDrvCtisland2 = {
4008 	"ctisland2", "ctisland", "decocass", NULL, "1981",
4009 	"Treasure Island (DECO Cassette) (US) (set 2)\0", NULL, "Data East Corporation", "Cassette System",
4010 	NULL, NULL, NULL, NULL,
4011 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_PLATFORM, 0,
4012 	NULL, ctisland2RomInfo, ctisland2RomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CtislandDIPInfo,
4013 	CtislandInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4014 	240, 256, 3, 4
4015 };
4016 
4017 
4018 // Treasure Island (DECO Cassette) (unk)
4019 
4020 static struct BurnRomInfo ctisland3RomDesc[] = {
4021 #ifdef ROM_VERIFY
4022 	{ "ctisland3.pro",	0x0020, 0xb87b56a7, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4023 #else
4024 	{ "de-0061.pro",	0x0020, 0xe09ae5de, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4025 #endif
4026 
4027 	{ "ctislnd3.cas",	0x8000, 0x45464e1e, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4028 
4029 	{ "deco-ti.x1",		0x1000, 0xa7f8aeba, 3 | BRF_GRA },           //  2 Overlay data
4030 	{ "deco-ti.x2",		0x1000, 0x2a0d3c91, 3 | BRF_GRA },           //  3
4031 	{ "deco-ti.x3",		0x1000, 0x3a26b97c, 3 | BRF_GRA },           //  4
4032 	{ "deco-ti.x4",		0x1000, 0x1cbe43de, 3 | BRF_GRA },           //  5
4033 };
4034 
4035 STDROMPICKEXT(ctisland3, ctisland3, decocass)
4036 STD_ROM_FN(ctisland3)
4037 
4038 struct BurnDriver BurnDrvCtisland3 = {
4039 	"ctisland3", "ctisland", "decocass", NULL, "1981",
4040 	"Treasure Island (DECO Cassette) (unk)\0", NULL, "Data East Corporation", "Cassette System",
4041 	NULL, NULL, NULL, NULL,
4042 	BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_PLATFORM, 0,
4043 	NULL, ctisland3RomInfo, ctisland3RomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CtislandDIPInfo,
4044 	CtislandInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4045 	240, 256, 3, 4
4046 };
4047 
4048 
4049 // Explorer (DECO Cassette) (US)
4050 
4051 static struct BurnRomInfo cexploreRomDesc[] = {
4052 	{ "dp-1180_b.dgl",	      0x0020, 0xc7a9ac8f, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4053 
4054 	{ "cexplore.cas",	      0x8000, 0xfae49c66, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4055 
4056 	{ "x1_made_in_japan_18.x1",   0x1000, 0xf2ca58f0, 3 | BRF_GRA },           //  2 Overlay data
4057 	{ "x2_made_in_japan_18.x2",   0x1000, 0x75d999bf, 3 | BRF_GRA },           //  3
4058 	{ "x3_made_in_japan_18.x3",   0x1000, 0x941539c6, 3 | BRF_GRA },           //  4
4059 	{ "x4_made_in_japan_18.x4",   0x1000, 0x73388544, 3 | BRF_GRA },           //  5
4060 	{ "x5_made_in_japan_18.x5",   0x1000, 0xb40699c5, 3 | BRF_GRA },           //  6
4061 	{ "y1_made_in_japan_18.y1",   0x1000, 0xd887dc50, 3 | BRF_GRA },           //  7
4062 	{ "y2_made_in_japan_18.y2",   0x1000, 0xfe325d0d, 3 | BRF_GRA },           //  8
4063 	{ "y3_made_in_japan_18.y3",   0x1000, 0x7a787ecf, 3 | BRF_GRA },           //  9
4064 	{ "y4_made_in_japan_18.y4",   0x1000, 0xac30e8c7, 3 | BRF_GRA },           // 10
4065 	{ "y5_made_in_japan_18.y5",   0x1000, 0x0a6b8f03, 3 | BRF_GRA },           // 11
4066 };
4067 
4068 STDROMPICKEXT(cexplore, cexplore, decocass)
4069 STD_ROM_FN(cexplore)
4070 
4071 static UINT8 type1_latch_26_pass_5_inv_2_table[8] = { T1PROM,T1PROM,T1LATCHINV,T1PROM,T1PROM,T1DIRECT,T1LATCH,T1PROM };
4072 
CexploreInit()4073 static INT32 CexploreInit()
4074 {
4075 	type1_map = type1_latch_26_pass_5_inv_2_table;
4076 
4077 	e900_enable = 1;
4078 
4079 	return DecocassInit(decocass_type1_read,NULL);
4080 }
4081 
4082 struct BurnDriver BurnDrvCexplore = {
4083 	"cexplore", NULL, "decocass", NULL, "1982",
4084 	"Explorer (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4085 	NULL, NULL, NULL, NULL,
4086 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_SHOOT, 0,
4087 	NULL, cexploreRomInfo, cexploreRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CexploreDIPInfo,
4088 	CexploreInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4089 	240, 256, 3, 4
4090 };
4091 
4092 
4093 // Disco No.1 (DECO Cassette) (US)
4094 
4095 static struct BurnRomInfo cdiscon1RomDesc[] = {
4096 	{ "dp-1190_b.dgl",	0x0800, 0x0f793fab, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4097 
4098 	{ "cdiscon1.cas",	0x8000, 0x1429a397, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4099 };
4100 
STDROMPICKEXT(cdiscon1,cdiscon1,decocass)4101 STDROMPICKEXT(cdiscon1, cdiscon1, decocass)
4102 STD_ROM_FN(cdiscon1)
4103 
4104 static INT32 Cdiscon1Init()
4105 {
4106 	fourway_mode = 1;
4107 
4108 	return DecocassInit(decocass_type2_read, decocass_type2_write);
4109 }
4110 
4111 struct BurnDriver BurnDrvCdiscon1 = {
4112 	"cdiscon1", NULL, "decocass", NULL, "1982",
4113 	"Disco No.1 (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4114 	NULL, NULL, NULL, NULL,
4115 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_ACTION, 0,
4116 	NULL, cdiscon1RomInfo, cdiscon1RomName, NULL, NULL, NULL, NULL, DecocassInputInfo, Cdiscon1DIPInfo,
4117 	Cdiscon1Init, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4118 	240, 256, 3, 4
4119 };
4120 
4121 
4122 // Sweet Heart (DECO Cassette) (US)
4123 
4124 static struct BurnRomInfo csweethtRomDesc[] = {
4125 	{ "cdiscon1.pro",	0x0800, 0x0f793fab, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4126 
4127 	{ "csweetht.cas",	0x8000, 0x175ef706, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4128 };
4129 
4130 STDROMPICKEXT(csweetht, csweetht, decocass)
4131 STD_ROM_FN(csweetht)
4132 
4133 struct BurnDriver BurnDrvCsweetht = {
4134 	"csweetht", "cdiscon1", "decocass", NULL, "1982",
4135 	"Sweet Heart (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4136 	NULL, NULL, NULL, NULL,
4137 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_ACTION, 0,
4138 	NULL, csweethtRomInfo, csweethtRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CsweethtDIPInfo,
4139 	Cdiscon1Init, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4140 	240, 256, 3, 4
4141 };
4142 
4143 
4144 // Tornado (DECO Cassette) (US)
4145 
4146 static struct BurnRomInfo ctornadoRomDesc[] = {
4147 	{ "ctornado.pro",	0x0800, 0xc9a91697, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4148 
4149 	{ "ctornado.cas",	0x8000, 0xe4e36ce0, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4150 };
4151 
STDROMPICKEXT(ctornado,ctornado,decocass)4152 STDROMPICKEXT(ctornado, ctornado, decocass)
4153 STD_ROM_FN(ctornado)
4154 
4155 static INT32 CtornadoInit()
4156 {
4157 	return DecocassInit(decocass_type2_read, decocass_type2_write);
4158 }
4159 
4160 struct BurnDriver BurnDrvCtornado = {
4161 	"ctornado", NULL, "decocass", NULL, "1982",
4162 	"Tornado (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4163 	NULL, NULL, NULL, NULL,
4164 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_SHOOT, 0,
4165 	NULL, ctornadoRomInfo, ctornadoRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CtornadoDIPInfo,
4166 	CtornadoInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4167 	240, 256, 3, 4
4168 };
4169 
4170 
4171 // Mission-X (DECO Cassette) (US)
4172 
4173 static struct BurnRomInfo cmissnxRomDesc[] = {
4174 	{ "dp-121_b.dgl",	0x0800, 0x8a41c071, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4175 
4176 	{ "cmissnx.cas",	0x8000, 0x3a094e11, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4177 };
4178 
STDROMPICKEXT(cmissnx,cmissnx,decocass)4179 STDROMPICKEXT(cmissnx, cmissnx, decocass)
4180 STD_ROM_FN(cmissnx)
4181 
4182 static INT32 CmissnxInit()
4183 {
4184 	return DecocassInit(decocass_type2_read, decocass_type2_write);
4185 }
4186 
4187 struct BurnDriver BurnDrvCmissnx = {
4188 	"cmissnx", NULL, "decocass", NULL, "1982",
4189 	"Mission-X (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4190 	NULL, NULL, NULL, NULL,
4191 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_VERSHOOT, 0,
4192 	NULL, cmissnxRomInfo, cmissnxRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CmissnxDIPInfo,
4193 	CmissnxInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4194 	240, 256, 3, 4
4195 };
4196 
4197 
4198 // Pro Tennis (DECO Cassette) (US)
4199 
4200 static struct BurnRomInfo cptennisRomDesc[] = {
4201 	{ "cptennis.pro",	0x0800, 0x59b8cede, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4202 
4203 	{ "cptennis.cas",	0x8000, 0x6bb257fe, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4204 };
4205 
STDROMPICKEXT(cptennis,cptennis,decocass)4206 STDROMPICKEXT(cptennis, cptennis, decocass)
4207 STD_ROM_FN(cptennis)
4208 
4209 static INT32 CptennisInit()
4210 {
4211 	return DecocassInit(decocass_type2_read, decocass_type2_write);
4212 }
4213 
4214 struct BurnDriver BurnDrvCptennis = {
4215 	"cptennis", NULL, "decocass", NULL, "1982",
4216 	"Pro Tennis (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4217 	NULL, NULL, NULL, NULL,
4218 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSMISC, 0,
4219 	NULL, cptennisRomInfo, cptennisRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CptennisDIPInfo,
4220 	CptennisInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4221 	240, 256, 3, 4
4222 };
4223 
4224 
4225 // Pro Tennis (DECO Cassette) (Japan)
4226 
4227 static struct BurnRomInfo cptennisjRomDesc[] = {
4228 	{ "dp-1220-a-0.rom",	0x0800, 0x1c603239, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4229 
4230 	{ "dt-1222-a-0.bin",	0x6a00, 0xee29eba7, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4231 };
4232 
4233 STDROMPICKEXT(cptennisj, cptennisj, decocass)
4234 STD_ROM_FN(cptennisj)
4235 
4236 struct BurnDriver BurnDrvCptennisj = {
4237 	"cptennisj", "cptennis", "decocass", NULL, "1982",
4238 	"Pro Tennis (DECO Cassette) (Japan)\0", NULL, "Data East Corporation", "Cassette System",
4239 	NULL, NULL, NULL, NULL,
4240 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSMISC, 0,
4241 	NULL, cptennisjRomInfo, cptennisjRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CptennisjDIPInfo,
4242 	CptennisInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4243 	240, 256, 3, 4
4244 };
4245 
4246 
4247 // Angler Dangler (DECO Cassette) (US)
4248 
4249 static struct BurnRomInfo cadanglrRomDesc[] = {
4250 	{ "dp-1250-a-0.dgl",	0x1000, 0x92a3b387, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4251 
4252 	{ "dt-1255-b-0.cas",	0x7400, 0xeb985257, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4253 };
4254 
STDROMPICKEXT(cadanglr,cadanglr,decocass)4255 STDROMPICKEXT(cadanglr, cadanglr, decocass)
4256 STD_ROM_FN(cadanglr)
4257 
4258 static INT32 CadanglrInit()
4259 {
4260 	type3_swap = TYPE3_SWAP_01;
4261 
4262 	return DecocassInit(decocass_type3_read,decocass_type3_write);
4263 }
4264 
4265 struct BurnDriver BurnDrvCadanglr = {
4266 	"cadanglr", NULL, "decocass", NULL, "1982",
4267 	"Angler Dangler (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4268 	NULL, NULL, NULL, NULL,
4269 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSMISC, 0,
4270 	NULL, cadanglrRomInfo, cadanglrRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CfishingDIPInfo,
4271 	CadanglrInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4272 	240, 256, 3, 4
4273 };
4274 
4275 
4276 // Fishing (DECO Cassette) (Japan)
4277 
4278 static struct BurnRomInfo cfishingRomDesc[] = {
4279 	{ "dp-1250-a-0.dgl",	0x1000, 0x92a3b387, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4280 
4281 	{ "dt-1250-a-0.cas",	0x7500, 0xd4a16425, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4282 };
4283 
4284 STDROMPICKEXT(cfishing, cfishing, decocass)
4285 STD_ROM_FN(cfishing)
4286 
4287 struct BurnDriver BurnDrvCfishing = {
4288 	"cfishing", "cadanglr", "decocass", NULL, "1982",
4289 	"Fishing (DECO Cassette) (Japan)\0", NULL, "Data East Corporation", "Cassette System",
4290 	NULL, NULL, NULL, NULL,
4291 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSMISC, 0,
4292 	NULL, cfishingRomInfo, cfishingRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CfishingjDIPInfo,
4293 	CadanglrInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4294 	240, 256, 3, 4
4295 };
4296 
4297 
4298 // Burger Time (DECO Cassette) (US)
4299 
4300 static struct BurnRomInfo cbtimeRomDesc[] = {
4301 	{ "dp-126_b.dgl",	0x1000, 0x25bec0f0, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4302 
4303 	{ "dt-126_7b.cas",	0x8000, 0x56d7dc58, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4304 };
4305 
STDROMPICKEXT(cbtime,cbtime,decocass)4306 STDROMPICKEXT(cbtime, cbtime, decocass)
4307 STD_ROM_FN(cbtime)
4308 
4309 static INT32 CbtimeInit()
4310 {
4311 	type3_swap = TYPE3_SWAP_12;
4312 
4313 	burgertime_mode = 1;
4314 	fourway_mode = 1;
4315 
4316 	return DecocassInit(decocass_type3_read,decocass_type3_write);
4317 }
4318 
4319 struct BurnDriver BurnDrvCbtime = {
4320 	"cbtime", NULL, "decocass", NULL, "1983",
4321 	"Burger Time (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4322 	NULL, NULL, NULL, NULL,
4323 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_PLATFORM | GBF_ACTION, 0,
4324 	NULL, cbtimeRomInfo, cbtimeRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CbtimeDIPInfo,
4325 	CbtimeInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4326 	240, 256, 3, 4
4327 };
4328 
4329 
4330 // Hamburger (DECO Cassette) (Japan)
4331 
4332 static struct BurnRomInfo chamburgerRomDesc[] = {
4333 	{ "dp-126_a.dgl",	0x1000, 0x25bec0f0, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4334 
4335 	{ "dt-126_a.cas",	0x8000, 0x334fb987, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4336 };
4337 
4338 STDROMPICKEXT(chamburger, chamburger, decocass)
4339 STD_ROM_FN(chamburger)
4340 
4341 struct BurnDriver BurnDrvChamburger = {
4342 	"chamburger", "cbtime", "decocass", NULL, "1982",
4343 	"Hamburger (DECO Cassette) (Japan)\0", NULL, "Data East Corporation", "Cassette System",
4344 	NULL, NULL, NULL, NULL,
4345 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_PLATFORM | GBF_ACTION, 0,
4346 	NULL, chamburgerRomInfo, chamburgerRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, ChamburgerDIPInfo,
4347 	CbtimeInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4348 	240, 256, 3, 4
4349 };
4350 
4351 
4352 // Burnin' Rubber (DECO Cassette) (US) (set 1)
4353 
4354 static struct BurnRomInfo cburnrubRomDesc[] = {
4355 	{ "dp-127_b.pro",	0x1000, 0x9f396832, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4356 
4357 	{ "cburnrub.cas",	0x8000, 0x4528ac22, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4358 };
4359 
STDROMPICKEXT(cburnrub,cburnrub,decocass)4360 STDROMPICKEXT(cburnrub, cburnrub, decocass)
4361 STD_ROM_FN(cburnrub)
4362 
4363 static INT32 CburnrubInit()
4364 {
4365 	type3_swap = TYPE3_SWAP_67;
4366 
4367 	return DecocassInit(decocass_type3_read,decocass_type3_write);
4368 }
4369 
4370 struct BurnDriver BurnDrvCburnrub = {
4371 	"cburnrub", NULL, "decocass", NULL, "1982",
4372 	"Burnin' Rubber (DECO Cassette) (US) (set 1)\0", NULL, "Data East Corporation", "Cassette System",
4373 	NULL, NULL, NULL, NULL,
4374 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_RACING | GBF_ACTION, 0,
4375 	NULL, cburnrubRomInfo, cburnrubRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CburnrubDIPInfo,
4376 	CburnrubInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4377 	240, 256, 3, 4
4378 };
4379 
4380 
4381 // Burnin' Rubber (DECO Cassette) (US) (set 2)
4382 
4383 static struct BurnRomInfo cburnrub2RomDesc[] = {
4384 	{ "dp-127_b.pro",	0x1000, 0x9f396832, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4385 
4386 	{ "cburnrb2.cas",	0x8000, 0x84a9ed66, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4387 };
4388 
4389 STDROMPICKEXT(cburnrub2, cburnrub2, decocass)
4390 STD_ROM_FN(cburnrub2)
4391 
4392 struct BurnDriver BurnDrvCburnrub2 = {
4393 	"cburnrub2", "cburnrub", "decocass", NULL, "1982",
4394 	"Burnin' Rubber (DECO Cassette) (US) (set 2)\0", NULL, "Data East Corporation", "Cassette System",
4395 	NULL, NULL, NULL, NULL,
4396 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_RACING | GBF_ACTION, 0,
4397 	NULL, cburnrub2RomInfo, cburnrub2RomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CburnrubDIPInfo,
4398 	CburnrubInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4399 	240, 256, 3, 4
4400 };
4401 
4402 
4403 // Bump 'n' Jump (DECO Cassette) (US)
4404 
4405 static struct BurnRomInfo cbnjRomDesc[] = {
4406 	{ "dp-127_b.pro",	0x1000, 0x9f396832, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4407 
4408 	{ "cbnj.cas",		0x8000, 0xeed41560, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4409 };
4410 
4411 STDROMPICKEXT(cbnj, cbnj, decocass)
4412 STD_ROM_FN(cbnj)
4413 
4414 struct BurnDriver BurnDrvCbnj = {
4415 	"cbnj", "cburnrub", "decocass", NULL, "1982",
4416 	"Bump 'n' Jump (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4417 	NULL, NULL, NULL, NULL,
4418 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_RACING | GBF_ACTION, 0,
4419 	NULL, cbnjRomInfo, cbnjRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CburnrubDIPInfo,
4420 	CburnrubInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4421 	240, 256, 3, 4
4422 };
4423 
4424 
4425 // Cluster Buster (DECO Cassette) (US)
4426 
4427 static struct BurnRomInfo cgraplopRomDesc[] = {
4428 	{ "cgraplop.pro",	0x1000, 0xee93787d, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4429 
4430 	{ "cgraplop.cas",	0x8000, 0xd2c1c1bb, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4431 };
4432 
STDROMPICKEXT(cgraplop,cgraplop,decocass)4433 STDROMPICKEXT(cgraplop, cgraplop, decocass)
4434 STD_ROM_FN(cgraplop)
4435 
4436 static INT32 CgraplopInit()
4437 {
4438 	type3_swap = TYPE3_SWAP_56;
4439 
4440 	return DecocassInit(decocass_type3_read,decocass_type3_write);
4441 }
4442 
4443 struct BurnDriver BurnDrvCgraplop = {
4444 	"cgraplop", NULL, "decocass", NULL, "1983",
4445 	"Cluster Buster (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4446 	NULL, NULL, NULL, NULL,
4447 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_BREAKOUT, 0,
4448 	NULL, cgraplopRomInfo, cgraplopRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CgraplopDIPInfo,
4449 	CgraplopInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4450 	240, 256, 3, 4
4451 };
4452 
4453 
4454 // Graplop (no title screen) (DECO Cassette) (US)
4455 
4456 static struct BurnRomInfo cgraplop2RomDesc[] = {
4457 	{ "cgraplop.pro",	0x1000, 0xee93787d, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4458 
4459 	{ "cgraplop2.cas",	0x8000, 0x2e728981, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4460 };
4461 
STDROMPICKEXT(cgraplop2,cgraplop2,decocass)4462 STDROMPICKEXT(cgraplop2, cgraplop2, decocass)
4463 STD_ROM_FN(cgraplop2)
4464 
4465 static INT32 Cgraplop2Init()
4466 {
4467 	type3_swap = TYPE3_SWAP_67;
4468 
4469 	return DecocassInit(decocass_type3_read,decocass_type3_write);
4470 }
4471 
4472 struct BurnDriver BurnDrvCgraplop2 = {
4473 	"cgraplop2", "cgraplop", "decocass", NULL, "1983",
4474 	"Graplop (no title screen) (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4475 	NULL, NULL, NULL, NULL,
4476 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_BREAKOUT, 0,
4477 	NULL, cgraplop2RomInfo, cgraplop2RomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CgraplopDIPInfo,
4478 	Cgraplop2Init, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4479 	240, 256, 3, 4
4480 };
4481 
4482 
4483 // Rootin' Tootin' / La-Pa-Pa (DECO Cassette) (US)
4484 
4485 static struct BurnRomInfo clapapaRomDesc[] = {
4486 	{ "clapapa.pro",	0x1000, 0xe172819a, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4487 
4488 	{ "clapapa.cas",	0x8000, 0x4ffbac24, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4489 };
4490 
STDROMPICKEXT(clapapa,clapapa,decocass)4491 STDROMPICKEXT(clapapa, clapapa, decocass)
4492 STD_ROM_FN(clapapa)
4493 
4494 static INT32 ClapapaInit()
4495 {
4496 	type3_swap = TYPE3_SWAP_34_7;
4497 	burgertime_mode = 1;
4498 
4499 	return DecocassInit(decocass_type3_read,decocass_type3_write);
4500 }
4501 
4502 struct BurnDriver BurnDrvClapapa = {
4503 	"clapapa", NULL, "decocass", NULL, "1983",
4504 	"Rootin' Tootin' / La-Pa-Pa (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4505 	NULL, NULL, NULL, NULL,
4506 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_MAZE, 0,
4507 	NULL, clapapaRomInfo, clapapaRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, ClapapaDIPInfo,
4508 	ClapapaInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4509 	240, 256, 3, 4
4510 };
4511 
4512 
4513 // Rootin' Tootin' (DECO Cassette) (US)
4514 
4515 static struct BurnRomInfo clapapa2RomDesc[] = {
4516 	{ "clapapa.pro",	0x1000, 0xe172819a, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4517 
4518 	{ "clapapa2.cas",	0x8000, 0x069dd3c4, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4519 };
4520 
4521 STDROMPICKEXT(clapapa2, clapapa2, decocass)
4522 STD_ROM_FN(clapapa2)
4523 
4524 struct BurnDriver BurnDrvClapapa2 = {
4525 	"clapapa2", "clapapa", "decocass", NULL, "1983",
4526 	"Rootin' Tootin' (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4527 	NULL, NULL, NULL, NULL,
4528 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_MAZE, 0,
4529 	NULL, clapapa2RomInfo, clapapa2RomName, NULL, NULL, NULL, NULL, DecocassInputInfo, ClapapaDIPInfo,
4530 	ClapapaInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4531 	240, 256, 3, 4
4532 };
4533 
4534 
4535 // Skater (DECO Cassette) (Japan)
4536 
4537 static struct BurnRomInfo cskaterRomDesc[] = {
4538 	{ "dp-130_a.dgl",	0x1000, 0x469e80a8, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4539 
4540 	{ "dt-130_a.cas",	0x8000, 0x1722e5e1, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4541 };
4542 
STDROMPICKEXT(cskater,cskater,decocass)4543 STDROMPICKEXT(cskater, cskater, decocass)
4544 STD_ROM_FN(cskater)
4545 
4546 static INT32 CskaterInit()
4547 {
4548 	type3_swap = TYPE3_SWAP_45;
4549 	skater_mode = 1; // object "under tilemap" + 1px correction
4550 
4551 	return DecocassInit(decocass_type3_read,decocass_type3_write);
4552 }
4553 
4554 struct BurnDriver BurnDrvCskater = {
4555 	"cskater", NULL, "decocass", NULL, "1983",
4556 	"Skater (DECO Cassette) (Japan)\0", NULL, "Data East Corporation", "Cassette System",
4557 	NULL, NULL, NULL, NULL,
4558 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_ACTION, 0,
4559 	NULL, cskaterRomInfo, cskaterRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CskaterDIPInfo,
4560 	CskaterInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4561 	240, 256, 3, 4
4562 };
4563 
4564 
4565 // Pro Bowling (DECO Cassette) (US)
4566 
4567 static struct BurnRomInfo cprobowlRomDesc[] = {
4568 	{ "cprobowl.pro",	0x1000, 0xe3a88e60, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4569 
4570 	{ "cprobowl.cas",	0x8000, 0xcb86c5e1, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4571 };
4572 
STDROMPICKEXT(cprobowl,cprobowl,decocass)4573 STDROMPICKEXT(cprobowl, cprobowl, decocass)
4574 STD_ROM_FN(cprobowl)
4575 
4576 static INT32 CprobowlInit()
4577 {
4578 	type3_swap = TYPE3_SWAP_34_0;
4579 
4580 	return DecocassInit(decocass_type3_read,decocass_type3_write);
4581 }
4582 
4583 struct BurnDriver BurnDrvCprobowl = {
4584 	"cprobowl", NULL, "decocass", NULL, "1983",
4585 	"Pro Bowling (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4586 	NULL, NULL, NULL, NULL,
4587 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSMISC, 0,
4588 	NULL, cprobowlRomInfo, cprobowlRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CprobowlDIPInfo,
4589 	CprobowlInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4590 	240, 256, 3, 4
4591 };
4592 
4593 
4594 // Night Star (DECO Cassette) (US) (set 1)
4595 
4596 static struct BurnRomInfo cnightstRomDesc[] = {
4597 	{ "cnightst.pro",	0x1000, 0x553b0fbc, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4598 
4599 	{ "cnightst.cas",	0x8000, 0xc6f844cb, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4600 };
4601 
STDROMPICKEXT(cnightst,cnightst,decocass)4602 STDROMPICKEXT(cnightst, cnightst, decocass)
4603 STD_ROM_FN(cnightst)
4604 
4605 static INT32 CnightstInit()
4606 {
4607 	type3_swap = TYPE3_SWAP_13;
4608 
4609 	return DecocassInit(decocass_type3_read,decocass_type3_write);
4610 }
4611 
4612 struct BurnDriver BurnDrvCnightst = {
4613 	"cnightst", NULL, "decocass", NULL, "1983",
4614 	"Night Star (DECO Cassette) (US) (set 1)\0", NULL, "Data East Corporation", "Cassette System",
4615 	NULL, NULL, NULL, NULL,
4616 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_VERSHOOT, 0,
4617 	NULL, cnightstRomInfo, cnightstRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CnightstDIPInfo,
4618 	CnightstInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4619 	240, 256, 3, 4
4620 };
4621 
4622 
4623 // Night Star (DECO Cassette) (US) (set 2)
4624 
4625 static struct BurnRomInfo cnightst2RomDesc[] = {
4626 	{ "cnightst.pro",	0x1000, 0x553b0fbc, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4627 
4628 	{ "cnights2.cas",	0x8000, 0x1a28128c, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4629 };
4630 
4631 STDROMPICKEXT(cnightst2, cnightst2, decocass)
4632 STD_ROM_FN(cnightst2)
4633 
4634 struct BurnDriver BurnDrvCnightst2 = {
4635 	"cnightst2", "cnightst", "decocass", NULL, "1983",
4636 	"Night Star (DECO Cassette) (US) (set 2)\0", NULL, "Data East Corporation", "Cassette System",
4637 	NULL, NULL, NULL, NULL,
4638 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_VERSHOOT, 0,
4639 	NULL, cnightst2RomInfo, cnightst2RomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CnightstDIPInfo,
4640 	CnightstInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4641 	240, 256, 3, 4
4642 };
4643 
4644 
4645 // Pro Soccer (DECO Cassette) (US)
4646 
4647 static struct BurnRomInfo cpsoccerRomDesc[] = {
4648 	{ "cprosocc.pro",	0x01000, 0x919fabb2, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4649 
4650 	{ "cprosocc.cas",	0x10000, 0x76b1ad2c, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4651 };
4652 
STDROMPICKEXT(cpsoccer,cpsoccer,decocass)4653 STDROMPICKEXT(cpsoccer, cpsoccer, decocass)
4654 STD_ROM_FN(cpsoccer)
4655 
4656 static INT32 CpsoccerInit()
4657 {
4658 	type3_swap = TYPE3_SWAP_24;
4659 
4660 	return DecocassInit(decocass_type3_read,decocass_type3_write);
4661 }
4662 
4663 struct BurnDriver BurnDrvCpsoccer = {
4664 	"cpsoccer", NULL, "decocass", NULL, "1983",
4665 	"Pro Soccer (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4666 	NULL, NULL, NULL, NULL,
4667 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSFOOTBALL, 0,
4668 	NULL, cpsoccerRomInfo, cpsoccerRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CpsoccerDIPInfo,
4669 	CpsoccerInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4670 	240, 256, 3, 4
4671 };
4672 
4673 
4674 // Pro Soccer (DECO Cassette) (Japan)
4675 
4676 static struct BurnRomInfo cpsoccerjRomDesc[] = {
4677 	{ "dp-133_a.dgl",	0x01000, 0x919fabb2, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4678 
4679 	{ "dt-133_a.cas",	0x10000, 0xde682a29, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4680 };
4681 
4682 STDROMPICKEXT(cpsoccerj, cpsoccerj, decocass)
4683 STD_ROM_FN(cpsoccerj)
4684 
4685 struct BurnDriver BurnDrvCpsoccerj = {
4686 	"cpsoccerj", "cpsoccer", "decocass", NULL, "1983",
4687 	"Pro Soccer (DECO Cassette) (Japan)\0", NULL, "Data East Corporation", "Cassette System",
4688 	NULL, NULL, NULL, NULL,
4689 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSFOOTBALL, 0,
4690 	NULL, cpsoccerjRomInfo, cpsoccerjRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CpsoccerjDIPInfo,
4691 	CpsoccerInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4692 	240, 256, 3, 4
4693 };
4694 
4695 
4696 // Super Doubles Tennis (DECO Cassette) (Japan)
4697 
4698 static struct BurnRomInfo csdtenisRomDesc[] = {
4699 	{ "dp-134_a.dgl",	0x01000, 0xe484d2f5, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4700 
4701 	{ "dt-134_a.cas",	0x10000, 0x9a69d961, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4702 };
4703 
STDROMPICKEXT(csdtenis,csdtenis,decocass)4704 STDROMPICKEXT(csdtenis, csdtenis, decocass)
4705 STD_ROM_FN(csdtenis)
4706 
4707 static INT32 CsdtenisInit()
4708 {
4709 	type3_swap = TYPE3_SWAP_23_56;
4710 
4711 	return DecocassInit(decocass_type3_read,decocass_type3_write);
4712 }
4713 
4714 struct BurnDriver BurnDrvCsdtenis = {
4715 	"csdtenis", NULL, "decocass", NULL, "1983",
4716 	"Super Doubles Tennis (DECO Cassette) (Japan)\0", NULL, "Data East Corporation", "Cassette System",
4717 	NULL, NULL, NULL, NULL,
4718 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSMISC, 0,
4719 	NULL, csdtenisRomInfo, csdtenisRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CsdtenisDIPInfo,
4720 	CsdtenisInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4721 	240, 256, 3, 4
4722 };
4723 
4724 
4725 // Zeroize (DECO Cassette) (US)
4726 
4727 static struct BurnRomInfo czeroizeRomDesc[] = {
4728 	{ "czeroize.pro",	0x01000, 0x00000000, 0 | BRF_NODUMP | BRF_PRG | BRF_ESS }, //  0 Dongle data
4729 
4730 	{ "czeroize.cas",	0x10000, 0x3ef0a406, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4731 };
4732 
STDROMPICKEXT(czeroize,czeroize,decocass)4733 STDROMPICKEXT(czeroize, czeroize, decocass)
4734 STD_ROM_FN(czeroize)
4735 
4736 static INT32 CzeroizeInit()
4737 {
4738 	type3_swap = TYPE3_SWAP_23_56;
4739 
4740 	INT32 nRet = DecocassInit(decocass_type3_read,decocass_type3_write);
4741 
4742 	if (nRet == 0)
4743 	{
4744 		// hack around missing dongle
4745 		DrvDongle[0x8a0] = 0x18;
4746 		DrvDongle[0x8a1] = 0xf7;
4747 
4748 	}
4749 
4750 	return nRet;
4751 }
4752 
4753 struct BurnDriver BurnDrvCzeroize = {
4754 	"czeroize", NULL, "decocass", NULL, "1983",
4755 	"Zeroize (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4756 	NULL, NULL, NULL, NULL,
4757 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_ACTION, 0,
4758 	NULL, czeroizeRomInfo, czeroizeRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CzeroizeDIPInfo,
4759 	CzeroizeInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4760 	240, 256, 3, 4
4761 };
4762 
4763 
4764 // Peter Pepper's Ice Cream Factory (DECO Cassette) (US) (set 1)
4765 
4766 static struct BurnRomInfo cppicfRomDesc[] = {
4767 	{ "cppicf.pro",		0x1000, 0x0b1a1ecb, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4768 
4769 	{ "cppicf.cas",		0x8000, 0x8c02f160, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4770 };
4771 
STDROMPICKEXT(cppicf,cppicf,decocass)4772 STDROMPICKEXT(cppicf, cppicf, decocass)
4773 STD_ROM_FN(cppicf)
4774 
4775 static INT32 CppicfInit()
4776 {
4777 	type3_swap = TYPE3_SWAP_01;
4778 
4779 	return DecocassInit(decocass_type3_read,decocass_type3_write);
4780 }
4781 
4782 struct BurnDriver BurnDrvCppicf = {
4783 	"cppicf", NULL, "decocass", NULL, "1984",
4784 	"Peter Pepper's Ice Cream Factory (DECO Cassette) (US) (set 1)\0", NULL, "Data East Corporation", "Cassette System",
4785 	NULL, NULL, NULL, NULL,
4786 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_PLATFORM, 0,
4787 	NULL, cppicfRomInfo, cppicfRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CppicfDIPInfo,
4788 	CppicfInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4789 	240, 256, 3, 4
4790 };
4791 
4792 
4793 // Peter Pepper's Ice Cream Factory (DECO Cassette) (US) (set 2)
4794 
4795 static struct BurnRomInfo cppicf2RomDesc[] = {
4796 	{ "cppicf.pro",		0x1000, 0x0b1a1ecb, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4797 
4798 	{ "cppicf2.cas",	0x8000, 0x78ffa1bc, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4799 };
4800 
4801 STDROMPICKEXT(cppicf2, cppicf2, decocass)
4802 STD_ROM_FN(cppicf2)
4803 
4804 struct BurnDriver BurnDrvCppicf2 = {
4805 	"cppicf2", "cppicf", "decocass", NULL, "1984",
4806 	"Peter Pepper's Ice Cream Factory (DECO Cassette) (US) (set 2)\0", NULL, "Data East Corporation", "Cassette System",
4807 	NULL, NULL, NULL, NULL,
4808 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_PLATFORM, 0,
4809 	NULL, cppicf2RomInfo, cppicf2RomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CppicfDIPInfo,
4810 	CppicfInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4811 	240, 256, 3, 4
4812 };
4813 
4814 
4815 // Fighting Ice Hockey (DECO Cassette) (US)
4816 
4817 static struct BurnRomInfo cfghticeRomDesc[] = {
4818 	{ "cfghtice.pro",	0x01000, 0x5abd27b5, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4819 
4820 	{ "cfghtice.cas",	0x10000, 0x906dd7fb, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4821 };
4822 
STDROMPICKEXT(cfghtice,cfghtice,decocass)4823 STDROMPICKEXT(cfghtice, cfghtice, decocass)
4824 STD_ROM_FN(cfghtice)
4825 
4826 static INT32 CfghticeInit()
4827 {
4828 	type3_swap = TYPE3_SWAP_25;
4829 
4830 	return DecocassInit(decocass_type3_read,decocass_type3_write);
4831 }
4832 
4833 struct BurnDriver BurnDrvCfghtice = {
4834 	"cfghtice", NULL, "decocass", NULL, "1984",
4835 	"Fighting Ice Hockey (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4836 	NULL, NULL, NULL, NULL,
4837 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSMISC, 0,
4838 	NULL, cfghticeRomInfo, cfghticeRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CfghticeDIPInfo,
4839 	CfghticeInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4840 	240, 256, 3, 4
4841 };
4842 
4843 
4844 // Scrum Try (DECO Cassette) (US) (set 1)
4845 
4846 static struct BurnRomInfo cscrtryRomDesc[] = {
4847 	{ "cscrtry.pro",	0x8000, 0x7bc3460b, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4848 
4849 	{ "cscrtry.cas",	0x8000, 0x5625f0ca, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4850 };
4851 
STDROMPICKEXT(cscrtry,cscrtry,decocass)4852 STDROMPICKEXT(cscrtry, cscrtry, decocass)
4853 STD_ROM_FN(cscrtry)
4854 
4855 static INT32 CscrtryInit()
4856 {
4857 	return DecocassInit(decocass_type4_read,decocass_type4_write);
4858 }
4859 
4860 struct BurnDriver BurnDrvCscrtry = {
4861 	"cscrtry", NULL, "decocass", NULL, "1984",
4862 	"Scrum Try (DECO Cassette) (US) (set 1)\0", NULL, "Data East Corporation", "Cassette System",
4863 	NULL, NULL, NULL, NULL,
4864 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSMISC, 0,
4865 	NULL, cscrtryRomInfo, cscrtryRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CscrtryDIPInfo,
4866 	CscrtryInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4867 	240, 256, 3, 4
4868 };
4869 
4870 
4871 // Scrum Try (DECO Cassette) (US) (set 2)
4872 
4873 static struct BurnRomInfo cscrtry2RomDesc[] = {
4874 	{ "cscrtry.pro",	0x8000, 0x7bc3460b, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4875 
4876 	{ "cscrtry2.cas",	0x8000, 0x04597842, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4877 };
4878 
4879 STDROMPICKEXT(cscrtry2, cscrtry2, decocass)
4880 STD_ROM_FN(cscrtry2)
4881 
4882 struct BurnDriver BurnDrvCscrtry2 = {
4883 	"cscrtry2", "cscrtry", "decocass", NULL, "1984",
4884 	"Scrum Try (DECO Cassette) (US) (set 2)\0", NULL, "Data East Corporation", "Cassette System",
4885 	NULL, NULL, NULL, NULL,
4886 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_CLONE, 2, HARDWARE_PREFIX_DATAEAST, GBF_SPORTSMISC, 0,
4887 	NULL, cscrtry2RomInfo, cscrtry2RomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CscrtryDIPInfo,
4888 	CscrtryInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4889 	240, 256, 3, 4
4890 };
4891 
4892 
4893 // Oozumou - The Grand Sumo (DECO Cassette) (Japan)
4894 
4895 static struct BurnRomInfo coozumouRomDesc[] = {
4896 	{ "dp-141_a.dgl",	0x08000, 0xbc379d2c, 1 | BRF_PRG | BRF_ESS }, //  0 Dongle data
4897 
4898 	{ "dt-141_1a.cas",	0x10000, 0x20c2e86a, 2 | BRF_PRG | BRF_ESS }, //  1 Cassette data
4899 };
4900 
4901 STDROMPICKEXT(coozumou, coozumou, decocass)
4902 STD_ROM_FN(coozumou)
4903 
4904 struct BurnDriver BurnDrvCoozumou = {
4905 	"coozumou", NULL, "decocass", NULL, "1984",
4906 	"Oozumou - The Grand Sumo (DECO Cassette) (Japan)\0", NULL, "Data East Corporation", "Cassette System",
4907 	NULL, NULL, NULL, NULL,
4908 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_VSFIGHT, 0,
4909 	NULL, coozumouRomInfo, coozumouRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CoozumouDIPInfo,
4910 	CscrtryInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4911 	240, 256, 3, 4
4912 };
4913 
4914 
4915 // Boulder Dash (DECO Cassette) (US)
4916 
4917 static struct BurnRomInfo cbdashRomDesc[] = {
4918 	{ "cbdash.cas",		0x8000, 0xcba4c1af, 2 | BRF_PRG | BRF_ESS }, //  0 Cassette data
4919 };
4920 
STDROMPICKEXT(cbdash,cbdash,decocass)4921 STDROMPICKEXT(cbdash, cbdash, decocass)
4922 STD_ROM_FN(cbdash)
4923 
4924 static INT32 CbdashInit()
4925 {
4926 	INT32 nRet = DecocassInit(decocass_type4_read,decocass_type4_write);
4927 
4928 	if (nRet == 0)
4929 	{
4930 		memset (DrvDongle, 0x55, 0x8000);
4931 	}
4932 
4933 	return nRet;
4934 }
4935 
4936 struct BurnDriver BurnDrvCbdash = {
4937 	"cbdash", NULL, "decocass", NULL, "1985",
4938 	"Boulder Dash (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4939 	NULL, NULL, NULL, NULL,
4940 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_MAZE, 0,
4941 	NULL, cbdashRomInfo, cbdashRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CbdashDIPInfo,
4942 	CbdashInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4943 	240, 256, 3, 4
4944 };
4945 
4946 
4947 // Flying Ball (DECO Cassette) (US)
4948 
4949 static struct BurnRomInfo cflyballRomDesc[] = {
4950 	{ "cflyball.cas",	0x10000, 0xcb40d043, 2 | BRF_PRG | BRF_ESS }, //  0 Cassette data
4951 };
4952 
STDROMPICKEXT(cflyball,cflyball,decocass)4953 STDROMPICKEXT(cflyball, cflyball, decocass)
4954 STD_ROM_FN(cflyball)
4955 
4956 static INT32 CflyballInit()
4957 {
4958 	return DecocassInit(decocass_nodongle_read,NULL);
4959 }
4960 
4961 struct BurnDriver BurnDrvCflyball = {
4962 	"cflyball", NULL, "decocass", NULL, "1985",
4963 	"Flying Ball (DECO Cassette) (US)\0", NULL, "Data East Corporation", "Cassette System",
4964 	NULL, NULL, NULL, NULL,
4965 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_PREFIX_DATAEAST, GBF_BREAKOUT, 0,
4966 	NULL, cflyballRomInfo, cflyballRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, CflyballDIPInfo,
4967 	CflyballInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
4968 	240, 256, 3, 4
4969 };
4970 
4971 
4972 
4973 
4974 
4975 static UINT32 widel_ctrs = 0;
4976 static UINT8 widel_latch = 0;
4977 
decocass_widel_read(UINT16 offset)4978 static UINT8 decocass_widel_read(UINT16 offset)
4979 {
4980 	if (offset & 1)
4981 	{
4982 		if ((offset & E5XX_MASK) == 0)
4983 		{
4984 			if (widel_latch) widel_ctrs = (widel_ctrs + 0x100) & 0xfffff;
4985 
4986 			return i8x41_get_register(I8X41_STAT);
4987 		}
4988 	}
4989 	else
4990 	{
4991 		if (widel_latch)
4992 		{
4993 			UINT8 data = DrvDongle[widel_ctrs];
4994 			widel_ctrs = (widel_ctrs + 1) & 0xfffff;
4995 			return data;
4996 		}
4997 		else if ((offset & E5XX_MASK) == 0)
4998 		{
4999 			return i8x41_get_register(I8X41_DATA);
5000 		}
5001 	}
5002 
5003 	return 0xff;
5004 }
5005 
decocass_widel_write(UINT16 offset,UINT8 data)5006 static void decocass_widel_write(UINT16 offset, UINT8 data)
5007 {
5008 	if (offset & 1)
5009 	{
5010 		if (widel_latch)
5011 		{
5012 			widel_ctrs = 0;
5013 			return;
5014 		}
5015 		else if (0xc0 == (data & 0xf0))
5016 		{
5017 			widel_latch = 1;
5018 		}
5019 	}
5020 	else
5021 	{
5022 		if (widel_latch)
5023 		{
5024 			widel_ctrs = (widel_ctrs & 0xfff00) | data;
5025 			return;
5026 		}
5027 	}
5028 
5029 	i8x41_set_register((offset & 1) ? I8X41_CMND : I8X41_DATA, data);
5030 }
5031 
5032 
5033 // Deco Cassette System Multigame (ROM based)
5034 
5035 static struct BurnRomInfo decomultRomDesc[] = {
5036 	{ "widldeco.low",	0x80000, 0xfd4dc36c,  1 | BRF_PRG | BRF_ESS },  //  0 Dongle data
5037 	{ "widldeco.hgh",	0x80000, 0xa8a30112,  1 | BRF_PRG | BRF_ESS },  //  1
5038 
5039 	{ "widlbios.v0b",	0x00800, 0x9ad7c451,  8 | BRF_BIOS | BRF_ESS }, //  2 Main M6502 BIOS
5040 
5041 	{ "v1-.5a",		0x00800, 0xb66b2c2a,  9 | BRF_BIOS | BRF_ESS }, //  3 Sound M6502 BIOS
5042 
5043 	{ "cassmcu.1c", 	0x00400, 0xa6df18fd, 10 | BRF_BIOS | BRF_ESS }, //  4 MCU BIOS
5044 
5045 	{ "v2.3m",		0x00020, 0x238fdb40,  0 | BRF_OPT },            //  5 Unknown PROMs
5046 	{ "v4.10d",		0x00020, 0x3b5836b4,  0 | BRF_OPT },            //  6
5047 	{ "v3.3j", 		0x00020, 0x51eef657,  0 | BRF_OPT },            //  7
5048 };
5049 
5050 STD_ROM_PICK(decomult)
STD_ROM_FN(decomult)5051 STD_ROM_FN(decomult)
5052 
5053 static INT32 DecomultInit()
5054 {
5055 	return DecocassInit(decocass_widel_read,decocass_widel_write);
5056 }
5057 
5058 struct BurnDriver BurnDrvDecomult = {
5059 	"decomult", NULL, "decocass", NULL, "2008",
5060 	"Deco Cassette System Multigame (ROM based)\0", NULL, "bootleg (David Widel)", "Cassette System",
5061 	NULL, NULL, NULL, NULL,
5062 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_BOOTLEG, 2, HARDWARE_PREFIX_DATAEAST, GBF_MISC, 0,
5063 	NULL, decomultRomInfo, decomultRomName, NULL, NULL, NULL, NULL, DecocassInputInfo, DecomultDIPInfo,
5064 	DecomultInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x40,
5065 	240, 256, 3, 4
5066 };
5067