1 // FB Alpha Jaleco D-Day driver module
2 // Based on MAME driver by Pierpaolo Prazzoli, Tomasz Slanina and Angelo Salese
3 
4 #include "tiles_generic.h"
5 #include "z80_intf.h"
6 #include "ay8910.h"
7 
8 static UINT8 *AllMem;
9 static UINT8 *MemEnd;
10 static UINT8 *AllRam;
11 static UINT8 *RamEnd;
12 static UINT8 *DrvZ80ROM0;
13 static UINT8 *DrvZ80ROM1;
14 static UINT8 *DrvGfxROM0;
15 static UINT8 *DrvGfxROM1;
16 static UINT8 *DrvGfxROM2;
17 static UINT8 *DrvColPROM;
18 static UINT8 *DrvZ80RAM0;
19 static UINT8 *DrvZ80RAM1;
20 static UINT8 *DrvVidRAM;
21 static UINT8 *DrvBgRAM;
22 static UINT8 *DrvSprRAM;
23 
24 static UINT32 *DrvPalette;
25 static UINT8 DrvRecalc;
26 
27 static UINT8 bank_address;
28 static UINT8 char_bank;
29 static UINT8 dma_data[4][2];
30 static UINT8 dma_flip[4];
31 static UINT8 nmi_enable[2];
32 static UINT8 soundlatch;
33 static UINT8 prot_addr;
34 
35 static UINT8 DrvJoy1[8];
36 static UINT8 DrvJoy2[8];
37 static UINT8 DrvDips[2];
38 static UINT8 DrvInputs[2];
39 static UINT8 DrvReset;
40 
41 static struct BurnInputInfo DdayjlcInputList[] = {
42 	{"P1 Coin",			BIT_DIGITAL,	DrvJoy2 + 2,	"p1 coin"	},
43 	{"P1 Start",		BIT_DIGITAL,	DrvJoy2 + 0,	"p1 start"	},
44 	{"P1 Up",			BIT_DIGITAL,	DrvJoy1 + 0,	"p1 up"		},
45 	{"P1 Down",			BIT_DIGITAL,	DrvJoy1 + 1,	"p1 down"	},
46 	{"P1 Left",			BIT_DIGITAL,	DrvJoy1 + 3,	"p1 left"	},
47 	{"P1 Right",		BIT_DIGITAL,	DrvJoy1 + 2,	"p1 right"	},
48 	{"P1 Button 1",		BIT_DIGITAL,	DrvJoy1 + 4,	"p1 fire 1"	},
49 	{"P1 Button 2",		BIT_DIGITAL,	DrvJoy1 + 5,	"p1 fire 2"	},
50 	{"P1 Button 3",		BIT_DIGITAL,	DrvJoy1 + 6,	"p1 fire 3"	},
51 	{"P1 Button 4",		BIT_DIGITAL,	DrvJoy1 + 7,	"p1 fire 4"	},
52 
53 	{"Reset",			BIT_DIGITAL,	&DrvReset,		"reset"		},
54 	{"Service",			BIT_DIGITAL,	DrvJoy2 + 4,	"service"	},
55 	{"Dip A",			BIT_DIPSWITCH,	DrvDips + 0,	"dip"		},
56 	{"Dip B",			BIT_DIPSWITCH,	DrvDips + 1,	"dip"		},
57 };
58 
59 STDINPUTINFO(Ddayjlc)
60 
61 static struct BurnDIPInfo DdayjlcDIPList[]=
62 {
63 	{0x0c, 0xff, 0xff, 0x00, NULL					},
64 	{0x0d, 0xff, 0xff, 0x00, NULL					},
65 
66 	{0   , 0xfe, 0   ,    4, "Lives"				},
67 	{0x0c, 0x01, 0x03, 0x00, "3"					},
68 	{0x0c, 0x01, 0x03, 0x01, "4"					},
69 	{0x0c, 0x01, 0x03, 0x02, "5"					},
70 	{0x0c, 0x01, 0x03, 0x03, "6"					},
71 
72 	{0   , 0xfe, 0   ,    8, "Coin A"				},
73 	{0x0c, 0x01, 0x1c, 0x0c, "4 Coins 1 Credits"	},
74 	{0x0c, 0x01, 0x1c, 0x08, "3 Coins 1 Credits"	},
75 	{0x0c, 0x01, 0x1c, 0x04, "2 Coins 1 Credits"	},
76 	{0x0c, 0x01, 0x1c, 0x00, "1 Coin  1 Credits"	},
77 	{0x0c, 0x01, 0x1c, 0x18, "2 Coins 3 Credits"	},
78 	{0x0c, 0x01, 0x1c, 0x10, "1 Coin  2 Credits"	},
79 	{0x0c, 0x01, 0x1c, 0x14, "1 Coin  3 Credits"	},
80 	{0x0c, 0x01, 0x1c, 0x1c, "Free Play"			},
81 
82 	{0   , 0xfe, 0   ,    2, "Extend"				},
83 	{0x0c, 0x01, 0x20, 0x00, "30K"					},
84 	{0x0c, 0x01, 0x20, 0x20, "50K"					},
85 
86 	{0   , 0xfe, 0   ,    2, "Difficulty"			},
87 	{0x0c, 0x01, 0x40, 0x00, "Easy"					},
88 	{0x0c, 0x01, 0x40, 0x40, "Hard"					},
89 
90 	{0   , 0xfe, 0   ,    2, "Cabinet"				},
91 	{0x0c, 0x01, 0x80, 0x00, "Upright"				},
92 	{0x0c, 0x01, 0x80, 0x80, "Cocktail"				},
93 
94 	{0   , 0xfe, 0   ,    8, "Coin B"				},
95 	{0x0d, 0x01, 0x07, 0x03, "4 Coins 1 Credits"	},
96 	{0x0d, 0x01, 0x07, 0x02, "3 Coins 1 Credits"	},
97 	{0x0d, 0x01, 0x07, 0x01, "2 Coins 1 Credits"	},
98 	{0x0d, 0x01, 0x07, 0x00, "1 Coin  1 Credits"	},
99 	{0x0d, 0x01, 0x07, 0x06, "2 Coins 3 Credits"	},
100 	{0x0d, 0x01, 0x07, 0x04, "1 Coin  2 Credits"	},
101 	{0x0d, 0x01, 0x07, 0x05, "1 Coin  3 Credits"	},
102 	{0x0d, 0x01, 0x07, 0x07, "Free Play"			},
103 };
104 
STDDIPINFO(Ddayjlc)105 STDDIPINFO(Ddayjlc)
106 
107 static void bankswitch()
108 {
109 	ZetMapMemory(DrvZ80ROM0 + 0x10000 + (bank_address * 0x4000), 0xa000, 0xdfff, MAP_ROM);
110 }
111 
dma_start(UINT8 data)112 static void dma_start(UINT8 data)
113 {
114 	if (data == 0)
115 	{
116 		UINT16 src  = (dma_data[0][1] * 256) + dma_data[0][0];
117 		UINT16 size = (dma_data[1][1] * 256) + dma_data[1][0];
118 		UINT16 dst  = (dma_data[2][1] * 256) + dma_data[2][0];
119 
120 		for (INT32 i = 0; i <= (size & 0x3ff); i++) // yes, size + 1
121 		{
122 			ZetWriteByte(dst++, ZetReadByte(src++));
123 		}
124 
125 		memset (dma_flip, 0, sizeof(dma_flip));
126 	}
127 }
128 
ddayjc_main_write(UINT16 address,UINT8 data)129 static void __fastcall ddayjc_main_write(UINT16 address, UINT8 data)
130 {
131 	if (address >= 0xa000 && address <= 0xdfff) return; // nop
132 
133 	switch (address)
134 	{
135 		case 0xe000:
136 		case 0xe001:
137 		case 0xe002:
138 		case 0xe003:
139 			dma_data[address & 3][dma_flip[address & 3]] = data;
140 			dma_flip[address & 3] ^= 1;
141 		return;
142 
143 		case 0xe008:
144 		return; // nop
145 
146 		case 0xf000:
147 			soundlatch = data;
148 			ZetSetVector(1, 0xff);
149 			ZetSetIRQLine(1, 0, CPU_IRQSTATUS_HOLD);
150 		return;
151 
152 		case 0xf080:
153 			char_bank = data;
154 		return;
155 
156 		case 0xf081:
157 		return; // nop
158 
159 		case 0xf083:
160 			dma_start(data);
161 		return;
162 
163 		case 0xf084:
164 			bank_address = (bank_address & 0xfe) | (data & 1);
165 		return;
166 
167 		case 0xf085:
168 			bank_address = (bank_address & 0xfd) | ((data & 1) << 1);
169 		return;
170 
171 		case 0xf086:
172 			bank_address = (bank_address & 0xfb) | ((data & 1) << 2);
173 			if (bank_address > 2) bank_address = 0;
174 			bankswitch();
175 		return;
176 
177 		case 0xf101:
178 			nmi_enable[0] = data;
179 		return;
180 
181 		case 0xf102:
182 		case 0xf103:
183 		case 0xf104:
184 		case 0xf105:
185 			prot_addr = (prot_addr & (~(1 << (address - 0xf102)))) | ((data & 1) << (address - 0xf102));
186 		return;
187 	}
188 }
189 
ddayjc_main_read(UINT16 address)190 static UINT8 __fastcall ddayjc_main_read(UINT16 address)
191 {
192 	switch (address)
193 	{
194 		case 0xf000:
195 			return DrvInputs[0];
196 
197 		case 0xf100:
198 		{
199 			static const UINT8 prot_data[0x10] = {
200 				0x02, 0x02, 0x02, 0x02,	0x02, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00,	0x03, 0x01, 0x00, 0x03
201 			};
202 
203 			return (DrvInputs[1] & 0x9f) | ((prot_data[prot_addr] << 5) & 0x60);
204 		}
205 
206 		case 0xf180:
207 			return DrvDips[0];
208 
209 		case 0xf200:
210 			return DrvDips[1];
211 	}
212 
213 	return 0;
214 }
215 
ddayjc_sound_write(UINT16 address,UINT8 data)216 static void __fastcall ddayjc_sound_write(UINT16 address, UINT8 data)
217 {
218 	switch (address)
219 	{
220 		case 0x3000:
221 			AY8910Write(0, 1, data);
222 		return;
223 
224 		case 0x4000:
225 			AY8910Write(0, 0, data);
226 		return;
227 
228 		case 0x5000:
229 			AY8910Write(1, 1, data);
230 		return;
231 
232 		case 0x6000:
233 			AY8910Write(1, 0, data);
234 		return;
235 
236 		case 0x7000:
237 			nmi_enable[1] = data;
238 		return;
239 	}
240 }
241 
ddayjc_sound_read(UINT16 address)242 static UINT8 __fastcall ddayjc_sound_read(UINT16 address)
243 {
244 	switch (address)
245 	{
246 		case 0x3000:
247 			return AY8910Read(0);
248 
249 		case 0x5000:
250 			return AY8910Read(1);
251 	}
252 
253 	return 0;
254 }
255 
tilemap_callback(bg)256 static tilemap_callback( bg )
257 {
258 	UINT8 attr = DrvBgRAM[offs + 0x400];
259 	UINT16 code = DrvBgRAM[offs] + ((attr & 0x08) << 5);
260 
261 	TILE_SET_INFO(0, code, (attr & 0x07) | ((attr >> 3) & 8), 0);
262 }
263 
tilemap_callback(fg)264 static tilemap_callback( fg )
265 {
266 	UINT8 code = DrvVidRAM[offs];
267 
268 	INT32 flags = 0;
269 	INT32 sx = offs & 0x1f;
270 	if (sx < 2 || sx >= 30) flags = TILE_OPAQUE;
271 
272 	TILE_SET_INFO(1, code + (char_bank * 0x100), 2, flags);
273 }
274 
AY8910_0_portA(UINT32)275 static UINT8 AY8910_0_portA(UINT32)
276 {
277 	return soundlatch;
278 }
279 
DrvDoReset()280 static INT32 DrvDoReset()
281 {
282 	memset (AllRam, 0, RamEnd - AllRam);
283 
284 	ZetOpen(0);
285 	bank_address = 0;
286 	bankswitch();
287 	ZetReset();
288 	ZetClose();
289 
290 	ZetReset(1);
291 
292 	AY8910Reset(0);
293 	AY8910Reset(1);
294 
295 	char_bank = 0;
296 	memset (dma_data, 0, sizeof(dma_data));
297 	memset (dma_flip, 0, sizeof(dma_flip));
298 	memset (nmi_enable, 0, sizeof(nmi_enable));
299 	soundlatch = 0;
300 	prot_addr = 0;
301 
302 	return 0;
303 }
304 
MemIndex()305 static INT32 MemIndex()
306 {
307 	UINT8 *Next; Next = AllMem;
308 
309 	DrvZ80ROM0		= Next; Next += 0x01c000;
310 	DrvZ80ROM1		= Next; Next += 0x002000;
311 
312 	DrvGfxROM0		= Next; Next += 0x020000;
313 	DrvGfxROM1		= Next; Next += 0x008000;
314 	DrvGfxROM2		= Next; Next += 0x008000;
315 
316 	DrvColPROM		= Next; Next += 0x000400;
317 
318 	DrvPalette		= (UINT32*)Next; Next += 0x0200 * sizeof(UINT32);
319 
320 	AllRam			= Next;
321 
322 	DrvZ80RAM0		= Next; Next += 0x001000;
323 	DrvZ80RAM1		= Next; Next += 0x000400;
324 	DrvVidRAM		= Next; Next += 0x000400;
325 	DrvBgRAM		= Next; Next += 0x000800;
326 	DrvSprRAM		= Next; Next += 0x000400;
327 
328 	RamEnd			= Next;
329 
330 	MemEnd			= Next;
331 
332 	return 0;
333 }
334 
DrvGfxDecode()335 static INT32 DrvGfxDecode()
336 {
337 	INT32 Plane[2]  = { 0, 0x4000*8 };
338 	INT32 XOffs[16] = { STEP8(64,1), STEP8(0,1) };
339 	INT32 YOffs[16] = { STEP8(0,8), STEP8(128,8) };
340 
341 	UINT8 *tmp = (UINT8*)BurnMalloc(0x8000);
342 	if (tmp == NULL) {
343 		return 1;
344 	}
345 
346 	for (INT32 i = 0; i < 0x8000; i++)
347 	{
348 		tmp[(i & 0x4007) | ((i & 0x2000) >> 10) | ((i & 0x1ff8) << 1)] = DrvGfxROM0[i];
349 	}
350 
351 	GfxDecode(0x0200, 2, 16, 16, Plane, XOffs + 0, YOffs, 0x100, tmp, DrvGfxROM0);
352 
353 	memcpy (tmp, DrvGfxROM1, 0x8000);
354 
355 	GfxDecode(0x0200, 2,  8,  8, Plane, XOffs + 8, YOffs, 0x040, tmp, DrvGfxROM1);
356 
357 	memcpy (tmp, DrvGfxROM2, 0x8000);
358 
359 	GfxDecode(0x0200, 2,  8,  8, Plane, XOffs + 8, YOffs, 0x040, tmp, DrvGfxROM2);
360 
361 	BurnFree(tmp);
362 
363 	return 0;
364 }
365 
DrvInit()366 static INT32 DrvInit()
367 {
368 	BurnAllocMemIndex();
369 
370 	{
371 		if (BurnLoadRom(DrvZ80ROM0 + 0x00000,  0, 1)) return 1;
372 		if (BurnLoadRom(DrvZ80ROM0 + 0x02000,  1, 1)) return 1;
373 		if (BurnLoadRom(DrvZ80ROM0 + 0x04000,  2, 1)) return 1;
374 		if (BurnLoadRom(DrvZ80ROM0 + 0x06000,  3, 1)) return 1;
375 		if (BurnLoadRom(DrvZ80ROM0 + 0x10000,  4, 1)) return 1;
376 		if (BurnLoadRom(DrvZ80ROM0 + 0x12000,  5, 1)) return 1;
377 		if (BurnLoadRom(DrvZ80ROM0 + 0x14000,  6, 1)) return 1;
378 		if (BurnLoadRom(DrvZ80ROM0 + 0x16000,  7, 1)) return 1;
379 		if (BurnLoadRom(DrvZ80ROM0 + 0x18000,  8, 1)) return 1;
380 		if (BurnLoadRom(DrvZ80ROM0 + 0x1a000,  9, 1)) return 1;
381 
382 		if (BurnLoadRom(DrvZ80ROM1 + 0x00000, 10, 1)) return 1;
383 
384 		if (BurnLoadRom(DrvGfxROM0 + 0x00000, 11, 1)) return 1;
385 		if (BurnLoadRom(DrvGfxROM0 + 0x02000, 12, 1)) return 1;
386 		if (BurnLoadRom(DrvGfxROM0 + 0x04000, 13, 1)) return 1;
387 		if (BurnLoadRom(DrvGfxROM0 + 0x06000, 14, 1)) return 1;
388 
389 		if (BurnLoadRom(DrvGfxROM1 + 0x04000, 15, 1)) return 1;
390 		if (BurnLoadRom(DrvGfxROM1 + 0x00000, 16, 1)) return 1;
391 
392 		if (BurnLoadRom(DrvGfxROM2 + 0x04000, 17, 1)) return 1;
393 		if (BurnLoadRom(DrvGfxROM2 + 0x00000, 18, 1)) return 1;
394 
395 		if (BurnLoadRom(DrvColPROM + 0x00000, 19, 1)) return 1;
396 		if (BurnLoadRom(DrvColPROM + 0x00100, 20, 1)) return 1;
397 		if (BurnLoadRom(DrvColPROM + 0x00200, 21, 1)) return 1;
398 		if (BurnLoadRom(DrvColPROM + 0x00300, 22, 1)) return 1;
399 	//	if (BurnLoadRom(DrvColPROM + 0x00400, 23, 1)) return 1; // not used
400 
401 		DrvGfxDecode();
402 	}
403 
404 	ZetInit(0);
405 	ZetOpen(0);
406 	ZetMapMemory(DrvZ80ROM0,		0x0000, 0x7fff, MAP_ROM);
407 	ZetMapMemory(DrvZ80RAM0,		0x8000, 0x8fff, MAP_RAM);
408 	ZetMapMemory(DrvSprRAM,			0x9000, 0x93ff, MAP_RAM);
409 	ZetMapMemory(DrvVidRAM,			0x9400, 0x97ff, MAP_RAM);
410 	ZetMapMemory(DrvBgRAM,			0x9800, 0x9fff, MAP_RAM);
411 //	bank a000-dfff - mapped in DrvDoReset()
412 	ZetSetWriteHandler(ddayjc_main_write);
413 	ZetSetReadHandler(ddayjc_main_read);
414 	ZetClose();
415 
416 	ZetInit(1);
417 	ZetOpen(1);
418 	ZetMapMemory(DrvZ80ROM1,		0x0000, 0x1fff, MAP_ROM);
419 	ZetMapMemory(DrvZ80RAM1,		0x2000, 0x23ff, MAP_RAM);
420 	ZetSetWriteHandler(ddayjc_sound_write);
421 	ZetSetReadHandler(ddayjc_sound_read);
422 	ZetClose();
423 
424 	AY8910Init(0, 2000000, 0);
425 	AY8910Init(1, 2000000, 1);
426 	AY8910SetPorts(0, &AY8910_0_portA, NULL, NULL, NULL);
427 	AY8910SetAllRoutes(0, 0.35, BURN_SND_ROUTE_BOTH);
428 	AY8910SetAllRoutes(1, 0.35, BURN_SND_ROUTE_BOTH);
429 	AY8910SetBuffered(ZetTotalCycles, 3000000);
430 
431 	GenericTilesInit();
432 	GenericTilemapInit(0, TILEMAP_SCAN_ROWS, bg_map_callback, 8, 8, 32, 32);
433 	GenericTilemapInit(1, TILEMAP_SCAN_ROWS, fg_map_callback, 8, 8, 32, 32);
434 	GenericTilemapSetGfx(0, DrvGfxROM2, 2, 8, 8, 0x8000, 0x100, 0xf);
435 	GenericTilemapSetGfx(1, DrvGfxROM1, 2, 8, 8, 0x8000, 0x080, 0xf);
436 	GenericTilemapSetOffsets(TMAP_GLOBAL, 0, -16);
437 	GenericTilemapSetTransparent(1, 0);
438 
439 	DrvDoReset();
440 
441 	return 0;
442 }
443 
DrvExit()444 static INT32 DrvExit()
445 {
446 	GenericTilesExit();
447 
448 	ZetExit();
449 
450 	AY8910Exit(0);
451 	AY8910Exit(1);
452 
453 	BurnFreeMemIndex();
454 
455 	return 0;
456 }
457 
DrvPaletteInit()458 static void DrvPaletteInit()
459 {
460 	for (INT32 i = 0; i < 0x200; i++)
461 	{
462 		UINT8 d = (DrvColPROM[i]) | (DrvColPROM[i + 0x200] * 16);
463 
464 		INT32 bit0 = (d >> 0) & 0x01;
465 		INT32 bit1 = (d >> 1) & 0x01;
466 		INT32 bit2 = (d >> 2) & 0x01;
467 		INT32 r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
468 
469 		bit0 = (d >> 3) & 0x01;
470 		bit1 = (d >> 4) & 0x01;
471 		bit2 = (d >> 5) & 0x01;
472 		INT32 g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
473 
474 		bit0 = 0;
475 		bit1 = (d >> 6) & 0x01;
476 		bit2 = (d >> 7) & 0x01;
477 		INT32 b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
478 
479 		DrvPalette[i] = BurnHighCol(r,g,b,0);
480 	}
481 }
482 
draw_sprites()483 static void draw_sprites()
484 {
485 	for (INT32 i = 0; i < 0x400; i += 4)
486 	{
487 		INT32 sy    = 256 - DrvSprRAM[i + 0] - 24;
488 		INT32 attr  = DrvSprRAM[i + 2];
489 		INT32 code  = DrvSprRAM[i + 1];
490 		INT32 sx    = DrvSprRAM[i + 3] - 16;
491 		INT32 flipx = attr & 0x80;
492 		INT32 flipy = code & 0x80;
493 		INT32 color = attr & 0xf;
494 
495 		code = (code & 0x7f) | ((attr & 0x30) << 3);
496 
497 		Draw16x16MaskTile(pTransDraw, code, sx, sy, flipx, flipy, color, 2, 0, 0, DrvGfxROM0);
498 	}
499 }
500 
DrvDraw()501 static INT32 DrvDraw()
502 {
503 	if (DrvRecalc) {
504 		DrvPaletteInit();
505 		DrvRecalc = 0;
506 	}
507 
508 	BurnTransferClear();
509 
510 	GenericTilemapSetScrollX(0, DrvBgRAM[0] + 8);
511 
512 	if (nBurnLayer & 1) GenericTilemapDraw(0, pTransDraw, 0);
513 
514 	if (nSpriteEnable & 1) draw_sprites();
515 
516 	if (nBurnLayer & 2) GenericTilemapDraw(1, pTransDraw, 0);
517 
518 	BurnTransferCopy(DrvPalette);
519 
520 	return 0;
521 }
522 
DrvFrame()523 static INT32 DrvFrame()
524 {
525 	if (DrvReset) {
526 		DrvDoReset();
527 	}
528 
529 	ZetNewFrame();
530 
531 	{
532 		DrvInputs[0] = 0;
533 		DrvInputs[1] = 0;
534 
535 		for (INT32 i = 0; i < 8; i++) {
536 			DrvInputs[0] ^= (DrvJoy1[i] & 1) << i;
537 			DrvInputs[1] ^= (DrvJoy2[i] & 1) << i;
538 		}
539 
540 		ProcessJoystick(&DrvInputs[0], 0, 0,1,3,2, INPUT_4WAY);
541 	}
542 
543 	INT32 nInterleave = 256;
544 	INT32 nCyclesTotal[2] = { 4000000 / 60, 3000000 / 60 };
545 	INT32 nCyclesDone[2] = { 0, 0 };
546 
547 	for (INT32 i = 0; i < nInterleave; i++)
548 	{
549 		ZetOpen(0);
550 		CPU_RUN(0, Zet);
551 		if (nmi_enable[0] && i == 240) ZetNmi();
552 		ZetClose();
553 
554 		ZetOpen(1);
555 		CPU_RUN(1, Zet);
556 		if (nmi_enable[1] && i == 240) ZetNmi();
557 		ZetClose();
558 	}
559 
560 	if (pBurnSoundOut) {
561 		AY8910Render(pBurnSoundOut, nBurnSoundLen);
562 	}
563 
564 	if (pBurnDraw) {
565 		DrvDraw();
566 	}
567 
568 	return 0;
569 }
570 
DrvScan(INT32 nAction,INT32 * pnMin)571 static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
572 {
573 	struct BurnArea ba;
574 
575 	if (pnMin) {
576 		*pnMin = 0x029702;
577 	}
578 
579 	if (nAction & ACB_VOLATILE) {
580 		memset(&ba, 0, sizeof(ba));
581 
582 		ba.Data	  = AllRam;
583 		ba.nLen	  = RamEnd - AllRam;
584 		ba.szName = "All Ram";
585 		BurnAcb(&ba);
586 
587 		ZetScan(nAction);
588 		AY8910Scan(nAction, pnMin);
589 
590 		SCAN_VAR(bank_address);
591 		SCAN_VAR(char_bank);
592 		SCAN_VAR(dma_data);
593 		SCAN_VAR(dma_flip);
594 		SCAN_VAR(nmi_enable);
595 		SCAN_VAR(soundlatch);
596 		SCAN_VAR(prot_addr);
597 	}
598 
599 	if (nAction & ACB_WRITE) {
600 		ZetOpen(0);
601 		bankswitch();
602 		ZetClose();
603 	}
604 
605 	return 0;
606 }
607 
608 
609 // D-Day (Jaleco set 1)
610 
611 static struct BurnRomInfo ddayjlcRomDesc[] = {
612 	{ "1",		0x2000, 0xdbfb8772, 1 | BRF_PRG | BRF_ESS }, //  0 Z80 #0 Code
613 	{ "2",		0x2000, 0xf40ea53e, 1 | BRF_PRG | BRF_ESS }, //  1
614 	{ "3",		0x2000, 0x0780ef60, 1 | BRF_PRG | BRF_ESS }, //  2
615 	{ "4",		0x2000, 0x75991a24, 1 | BRF_PRG | BRF_ESS }, //  3
616 	{ "5",		0x2000, 0x299b05f2, 1 | BRF_PRG | BRF_ESS }, //  4 Bank Data
617 	{ "6",		0x2000, 0x38ae2616, 1 | BRF_PRG | BRF_ESS }, //  5
618 	{ "7",		0x2000, 0x4210f6ef, 1 | BRF_PRG | BRF_ESS }, //  6
619 	{ "8",		0x2000, 0x91a32130, 1 | BRF_PRG | BRF_ESS }, //  7
620 	{ "9",		0x2000, 0xccb82f09, 1 | BRF_PRG | BRF_ESS }, //  8
621 	{ "10",		0x2000, 0x5452aba1, 1 | BRF_PRG | BRF_ESS }, //  9
622 
623 	{ "11",		0x2000, 0xfe4de019, 2 | BRF_PRG | BRF_ESS }, // 10 Z80 #1 Code
624 
625 	{ "16",		0x2000, 0xa167fe9a, 3 | BRF_GRA },           // 11 Sprites
626 	{ "17",		0x2000, 0x13ffe662, 3 | BRF_GRA },           // 12
627 	{ "18",		0x2000, 0xdebe6531, 3 | BRF_GRA },           // 13
628 	{ "19",		0x2000, 0x5816f947, 3 | BRF_GRA },           // 14
629 
630 	{ "14",		0x1000, 0x2c0e9bbe, 4 | BRF_GRA },           // 15 Foreground Tiles
631 	{ "15",		0x1000, 0xa6eeaa50, 4 | BRF_GRA },           // 16
632 
633 	{ "12",		0x1000, 0x7f7afe80, 5 | BRF_GRA },           // 17 Background Tiles
634 	{ "13",		0x1000, 0xf169b93f, 5 | BRF_GRA },           // 18
635 
636 	{ "4l.bin",	0x0100, 0x2c3fa534, 6 | BRF_GRA },           // 19 Color Data
637 	{ "5p.bin",	0x0100, 0x4fd96b26, 6 | BRF_GRA },           // 20
638 	{ "4m.bin",	0x0100, 0xe0ab9a8f, 6 | BRF_GRA },           // 21
639 	{ "5n.bin",	0x0100, 0x61d85970, 6 | BRF_GRA },           // 22
640 
641 	{ "3l.bin",	0x0100, 0xda6fe846, 0 | BRF_OPT },           // 23 Unused?
642 };
643 
644 STD_ROM_PICK(ddayjlc)
645 STD_ROM_FN(ddayjlc)
646 
647 struct BurnDriver BurnDrvDdayjlc = {
648 	"ddayjlc", NULL, NULL, NULL, "1984",
649 	"D-Day (Jaleco set 1)\0", NULL, "Jaleco", "Miscellaneous",
650 	NULL, NULL, NULL, NULL,
651 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_PRE90S, GBF_MISC, 0,
652 	NULL, ddayjlcRomInfo, ddayjlcRomName, NULL, NULL, NULL, NULL, DdayjlcInputInfo, DdayjlcDIPInfo,
653 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
654 	224, 256, 3, 4
655 };
656 
657 
658 // D-Day (Jaleco set 2)
659 
660 static struct BurnRomInfo ddayjlcaRomDesc[] = {
661 	{ "1a",		0x2000, 0xd8e4f3d4, 1 | BRF_PRG | BRF_ESS }, //  0 Z80 #0 Code
662 	{ "2",		0x2000, 0xf40ea53e, 1 | BRF_PRG | BRF_ESS }, //  1
663 	{ "3",		0x2000, 0x0780ef60, 1 | BRF_PRG | BRF_ESS }, //  2
664 	{ "4",		0x2000, 0x75991a24, 1 | BRF_PRG | BRF_ESS }, //  3
665 	{ "5",		0x2000, 0x299b05f2, 1 | BRF_PRG | BRF_ESS }, //  4 Bank Data
666 	{ "6",		0x2000, 0x38ae2616, 1 | BRF_PRG | BRF_ESS }, //  5
667 	{ "7",		0x2000, 0x4210f6ef, 1 | BRF_PRG | BRF_ESS }, //  6
668 	{ "8",		0x2000, 0x91a32130, 1 | BRF_PRG | BRF_ESS }, //  7
669 	{ "9",		0x2000, 0xccb82f09, 1 | BRF_PRG | BRF_ESS }, //  8
670 	{ "10",		0x2000, 0x5452aba1, 1 | BRF_PRG | BRF_ESS }, //  9
671 
672 	{ "11",		0x2000, 0xfe4de019, 2 | BRF_PRG | BRF_ESS }, // 10 Z80 #1 Code
673 
674 	{ "16",		0x2000, 0xa167fe9a, 3 | BRF_GRA },           // 11 Sprites
675 	{ "17",		0x2000, 0x13ffe662, 3 | BRF_GRA },           // 12
676 	{ "18",		0x2000, 0xdebe6531, 3 | BRF_GRA },           // 13
677 	{ "19",		0x2000, 0x5816f947, 3 | BRF_GRA },           // 14
678 
679 	{ "14",		0x1000, 0x2c0e9bbe, 4 | BRF_GRA },           // 15 Foreground Tiles
680 	{ "15",		0x1000, 0xa6eeaa50, 4 | BRF_GRA },           // 16
681 
682 	{ "12",		0x1000, 0x7f7afe80, 5 | BRF_GRA },           // 17 Background Tiles
683 	{ "13",		0x1000, 0xf169b93f, 5 | BRF_GRA },           // 18
684 
685 	{ "4l.bin",	0x0100, 0x2c3fa534, 6 | BRF_GRA },           // 19 Color Data
686 	{ "5p.bin",	0x0100, 0x4fd96b26, 6 | BRF_GRA },           // 20
687 	{ "4m.bin",	0x0100, 0xe0ab9a8f, 6 | BRF_GRA },           // 21
688 	{ "5n.bin",	0x0100, 0x61d85970, 6 | BRF_GRA },           // 22
689 
690 	{ "3l.bin",	0x0100, 0xda6fe846, 0 | BRF_OPT },           // 23 Unused?
691 };
692 
693 STD_ROM_PICK(ddayjlca)
694 STD_ROM_FN(ddayjlca)
695 
696 struct BurnDriver BurnDrvDdayjlca = {
697 	"ddayjlca", "ddayjlc", NULL, NULL, "1984",
698 	"D-Day (Jaleco set 2)\0", NULL, "Jaleco", "Miscellaneous",
699 	NULL, NULL, NULL, NULL,
700 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_PRE90S, GBF_MISC, 0,
701 	NULL, ddayjlcaRomInfo, ddayjlcaRomName, NULL, NULL, NULL, NULL, DdayjlcInputInfo, DdayjlcDIPInfo,
702 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
703 	224, 256, 3, 4
704 };
705