1 // FB Alpha Miss Bubble 2 / Bubble Pong Pong driver module
2 // Based on MAME driver by David Haywood
3 
4 #include "tiles_generic.h"
5 #include "z80_intf.h"
6 #include "burn_ym3526.h"
7 #include "msm6295.h"
8 
9 static UINT8 *AllMem;
10 static UINT8 *MemEnd;
11 static UINT8 *AllRam;
12 static UINT8 *RamEnd;
13 static UINT8 *DrvZ80ROM0;
14 static UINT8 *DrvZ80ROM1;
15 static UINT8 *DrvZ80ROM2;
16 static UINT8 *DrvGfxROM0;
17 static UINT8 *DrvGfxROM1;
18 static UINT8 *DrvSndROM;
19 static UINT8 *DrvVidPROM;
20 static UINT8 *DrvZ80RAM0;
21 static UINT8 *DrvZ80RAM1;
22 static UINT8 *DrvZ80RAM2;
23 static UINT8 *DrvVidRAM;
24 static UINT8 *DrvObjRAM;
25 static UINT8 *DrvShareRAM;
26 static UINT8 *DrvPalRAM;
27 
28 static UINT32 *DrvPalette;
29 static UINT8 DrvRecalc;
30 
31 static UINT8 bgvram;
32 static UINT8 soundlatch;
33 static UINT8 flipscreen;
34 static UINT8 sound_nmi_enable;
35 static UINT8 sound_pending_nmi;
36 static UINT8 sound_cpu_in_reset;
37 static UINT8 video_enable;
38 static UINT8 bankdata[2];
39 
40 static UINT8 *Drvfe00RAM;
41 
42 static UINT8 DrvJoy1[8];
43 static UINT8 DrvJoy2[8];
44 static UINT8 DrvDips[2];
45 static UINT8 DrvInputs[2];
46 static UINT8 DrvReset;
47 
48 static struct BurnInputInfo Missb2InputList[] = {
49 	{"P1 Coin",			BIT_DIGITAL,	DrvJoy1 + 3,	"p1 coin"	},
50 	{"P1 Start",		BIT_DIGITAL,	DrvJoy1 + 6,	"p1 start"	},
51 	{"P1 Left",			BIT_DIGITAL,	DrvJoy1 + 0,	"p1 left"	},
52 	{"P1 Right",		BIT_DIGITAL,	DrvJoy1 + 1,	"p1 right"	},
53 	{"P1 Button 1",		BIT_DIGITAL,	DrvJoy1 + 5,	"p1 fire 1"	},
54 	{"P1 Button 2",		BIT_DIGITAL,	DrvJoy1 + 4,	"p1 fire 2"	},
55 
56 	{"P2 Coin",			BIT_DIGITAL,	DrvJoy1 + 2,	"p2 coin"	},
57 	{"P2 Start",		BIT_DIGITAL,	DrvJoy2 + 6,	"p2 start"	},
58 	{"P2 Left",			BIT_DIGITAL,	DrvJoy2 + 0,	"p2 left"	},
59 	{"P2 Right",		BIT_DIGITAL,	DrvJoy2 + 1,	"p2 right"	},
60 	{"P2 Button 1",		BIT_DIGITAL,	DrvJoy2 + 5,	"p2 fire 1"	},
61 	{"P2 Button 2",		BIT_DIGITAL,	DrvJoy2 + 4,	"p2 fire 2"	},
62 
63 	{"Reset",			BIT_DIGITAL,	&DrvReset,		"reset"		},
64 	{"Service",			BIT_DIGITAL,	DrvJoy2 + 3,	"service"	},
65 	{"Tilt",			BIT_DIGITAL,	DrvJoy2 + 2,	"tilt"		},
66 	{"Dip A",			BIT_DIPSWITCH,	DrvDips + 0,	"dip"		},
67 	{"Dip B",			BIT_DIPSWITCH,	DrvDips + 1,	"dip"		},
68 };
69 
70 STDINPUTINFO(Missb2)
71 
72 static struct BurnDIPInfo Missb2DIPList[]=
73 {
74 	{0x0f, 0xff, 0xff, 0xfe, NULL					},
75 	{0x10, 0xff, 0xff, 0x3f, NULL					},
76 
77 	{0   , 0xfe, 0   ,    2, "Language"				},
78 	{0x0f, 0x01, 0x01, 0x00, "English"				},
79 	{0x0f, 0x01, 0x01, 0x01, "Japanese"				},
80 
81 	{0   , 0xfe, 0   ,    2, "Flip Screen"			},
82 	{0x0f, 0x01, 0x02, 0x02, "Off"					},
83 	{0x0f, 0x01, 0x02, 0x00, "On"					},
84 
85 	{0   , 0xfe, 0   ,    2, "Service Mode"			},
86 	{0x0f, 0x01, 0x04, 0x00, "Off"					},
87 	{0x0f, 0x01, 0x04, 0x04, "On"					},
88 
89 	{0   , 0xfe, 0   ,    2, "Demo Sounds"			},
90 	{0x0f, 0x01, 0x08, 0x00, "Off"					},
91 	{0x0f, 0x01, 0x08, 0x08, "On"					},
92 
93 	{0   , 0xfe, 0   ,    4, "Coin A"				},
94 	{0x0f, 0x01, 0x30, 0x10, "2 Coins 1 Credits"	},
95 	{0x0f, 0x01, 0x30, 0x30, "1 Coin  1 Credits"	},
96 	{0x0f, 0x01, 0x30, 0x00, "2 Coins 3 Credits"	},
97 	{0x0f, 0x01, 0x30, 0x20, "1 Coin  2 Credits"	},
98 
99 	{0   , 0xfe, 0   ,    4, "Coin B"			},
100 	{0x0f, 0x01, 0xc0, 0x40, "2 Coins 1 Credits"	},
101 	{0x0f, 0x01, 0xc0, 0xc0, "1 Coin  1 Credits"	},
102 	{0x0f, 0x01, 0xc0, 0x00, "2 Coins 3 Credits"	},
103 	{0x0f, 0x01, 0xc0, 0x80, "1 Coin  2 Credits"	},
104 
105 	{0   , 0xfe, 0   ,    4, "Difficulty"			},
106 	{0x10, 0x01, 0x03, 0x02, "Easy"					},
107 	{0x10, 0x01, 0x03, 0x03, "Medium"				},
108 	{0x10, 0x01, 0x03, 0x01, "Hard"					},
109 	{0x10, 0x01, 0x03, 0x00, "Hardest"				},
110 
111 	{0   , 0xfe, 0   ,    4, "Bonus Life"			},
112 	{0x10, 0x01, 0x0c, 0x08, "20K 80K"				},
113 	{0x10, 0x01, 0x0c, 0x0c, "30K 100K"				},
114 	{0x10, 0x01, 0x0c, 0x04, "40K 200K"				},
115 	{0x10, 0x01, 0x0c, 0x00, "50K 250K"				},
116 
117 	{0   , 0xfe, 0   ,    4, "Lives"				},
118 	{0x10, 0x01, 0x30, 0x10, "1"					},
119 	{0x10, 0x01, 0x30, 0x00, "2"					},
120 	{0x10, 0x01, 0x30, 0x30, "3"					},
121 	{0x10, 0x01, 0x30, 0x20, "5"					},
122 
123 	{0   , 0xfe, 0   ,    4, "Monster Speed"		},
124 	{0x10, 0x01, 0xc0, 0x00, "Normal"				},
125 	{0x10, 0x01, 0xc0, 0x40, "Medium"				},
126 	{0x10, 0x01, 0xc0, 0x80, "High"					},
127 	{0x10, 0x01, 0xc0, 0xc0, "Very High"			},
128 };
129 
STDDIPINFO(Missb2)130 STDDIPINFO(Missb2)
131 
132 static void bankswitch0(INT32 data)
133 {
134 	bankdata[0] = data;
135 
136 	INT32 bank = ((data ^ 4) & 7) * 0x4000;
137 
138 	ZetMapMemory(DrvZ80ROM0 + 0x10000 + bank, 0x8000, 0xbfff, MAP_ROM);
139 }
140 
missb2_main_write(UINT16 address,UINT8 data)141 static void __fastcall missb2_main_write(UINT16 address, UINT8 data)
142 {
143 	switch (address)
144 	{
145 		case 0xfa00:
146 		{
147 			soundlatch = data;
148 			if (sound_nmi_enable) {
149 				ZetNmi(2);
150 			} else {
151 				sound_pending_nmi = 1;
152 			}
153 		}
154 		return;
155 
156 		case 0xfb40:
157 		{
158 			sound_cpu_in_reset = ~data & 0x10;
159 			if (sound_cpu_in_reset) {
160 				ZetReset(1);
161 			}
162 
163 			bankswitch0(data);
164 
165 			video_enable = data & 0x40;
166 			flipscreen = data & 0x80;
167 		}
168 		return;
169 	}
170 
171 	if (address >= 0xfe00) Drvfe00RAM[address & 0x1ff] = data;
172 }
173 
missb2_main_read(UINT16 address)174 static UINT8 __fastcall missb2_main_read(UINT16 address)
175 {
176 	switch (address)
177 	{
178 		case 0xff00:
179 		case 0xff01:
180 			return DrvDips[address & 1];
181 
182 		case 0xff02:
183 		case 0xff03:
184 			return DrvInputs[address & 1];
185 	}
186 
187 	if (address >= 0xfe00) return Drvfe00RAM[address & 0x1ff];
188 
189 	return 0;
190 }
191 
bankswitch1(INT32 data)192 static void bankswitch1(INT32 data)
193 {
194 	bankdata[1] = data;
195 
196 	INT32 bank = ((data & 2) ? 1 : 0) | ((data & 1) ? 4 : 0);
197 
198 	ZetMapMemory(DrvZ80ROM1 + 0x8000 + bank * 0x1000, 0x9000, 0xafff, MAP_ROM);
199 }
200 
missb2_sub_write(UINT16 address,UINT8 data)201 static void __fastcall missb2_sub_write(UINT16 address, UINT8 data)
202 {
203 	switch (address)
204 	{
205 		case 0xd000:
206 			bankswitch1(data);
207 		return;
208 
209 		case 0xd002:
210 		return;	//nop
211 
212 		case 0xd003:
213 			bgvram = data;
214 		return;
215 	}
216 }
217 
missb2_sound_write(UINT16 address,UINT8 data)218 static void __fastcall missb2_sound_write(UINT16 address, UINT8 data)
219 {
220 	switch (address)
221 	{
222 		case 0x9000:
223 			MSM6295Write(0, data);
224 		return;
225 
226 		case 0xa000:
227 		case 0xa001:
228 			BurnYM3526Write(address & 1, data);
229 		return;
230 
231 		case 0xb000:
232 		return;	//	nop
233 
234 		case 0xb001:
235 			sound_nmi_enable = 1;
236 			if (sound_pending_nmi) {
237 				ZetNmi();
238 				sound_pending_nmi = 0;
239 			}
240 		return;
241 
242 		case 0xb002:
243 			sound_nmi_enable = 0;
244 		return;
245 	}
246 }
247 
missb2_sound_read(UINT16 address)248 static UINT8 __fastcall missb2_sound_read(UINT16 address)
249 {
250 	switch (address)
251 	{
252 		case 0x9000:
253 			return MSM6295Read(0);
254 
255 		case 0xa000:
256 		case 0xa001:
257 			return BurnYM3526Read(address & 1);
258 
259 		case 0xb000:
260 			return soundlatch;
261 
262 		case 0xb001:
263 			return 0; // nop
264 	}
265 
266 	return 0;
267 }
268 
DrvDoReset()269 static INT32 DrvDoReset()
270 {
271 	memset (AllRam, 0, RamEnd - AllRam);
272 
273 	ZetReset(0);
274 	ZetReset(1);
275 
276 	ZetOpen(2);
277 	BurnYM3526Reset();
278 	MSM6295Reset(0);
279 	ZetReset();
280 	ZetClose();
281 
282 	bgvram = 0;
283 	soundlatch = 0;
284 	flipscreen = 0;
285 	sound_nmi_enable = 0;
286 	sound_pending_nmi = 0;
287 	sound_cpu_in_reset = 0;
288 	video_enable = 0;
289 
290 	return 0;
291 }
292 
MemIndex()293 static INT32 MemIndex()
294 {
295 	UINT8 *Next; Next = AllMem;
296 
297 	DrvZ80ROM0		= Next; Next += 0x020000;
298 	DrvZ80ROM1		= Next; Next += 0x010000;
299 	DrvZ80ROM2		= Next; Next += 0x008000;
300 
301 	DrvGfxROM0		= Next; Next += 0x100000;
302 	DrvGfxROM1		= Next; Next += 0x200000;
303 
304 	MSM6295ROM		= Next;
305 	DrvSndROM		= Next; Next += 0x040000;
306 
307 	DrvVidPROM		= Next; Next += 0x000100;
308 
309 	DrvPalette		= (UINT32*)Next; Next += 0x0200 * sizeof(UINT32);
310 
311 	AllRam			= Next;
312 
313 	DrvZ80RAM0		= Next; Next += 0x000200;
314 	DrvZ80RAM1		= Next; Next += 0x000800;
315 	DrvZ80RAM2		= Next; Next += 0x001000;
316 	DrvVidRAM		= Next; Next += 0x001d00;
317 	DrvObjRAM		= Next; Next += 0x000300;
318 	DrvShareRAM		= Next; Next += 0x001800;
319 	DrvPalRAM		= Next; Next += 0x000400;
320 
321 	Drvfe00RAM		= Next; Next += 0x000200;
322 
323 	RamEnd			= Next;
324 
325 	MemEnd			= Next;
326 
327 	return 0;
328 }
329 
DrvGfxDecode(INT32 type)330 static void DrvGfxDecode(INT32 type)
331 {
332 	INT32 Plane0[8] = { (0x40000*8*0)+0, (0x40000*8*0)+4, (0x40000*8*1)+0, (0x40000*8*1)+4,
333 				(0x40000*8*2)+0, (0x40000*8*2)+4, (0x40000*8*3)+0, (0x40000*8*3)+4 };
334 	INT32 XOffs0[8] = { STEP4(3,-1), STEP4(8+3, -1) };
335 	INT32 YOffs0[8] = { STEP8(0,16) };
336 	INT32 Plane1[8] = { STEP8(0,1) };
337 	INT32 XOffs1[2][256] = { { 0, }, { STEP64(0,16), STEP64(0x400,16), STEP64(0x800, 16), STEP64(0xc00, 16) } };
338 	INT32 YOffs1[16] = { STEP16(0,128) };
339 
340 	for (INT32 i = 0; i < 256; i++)
341 	{
342 		INT32 j = (i & 1) | ((i & 2) << 10) | ((i & 4) << 1) | ((i & 8) >> 1) | ((i & 0x10) << 4) | ((i & 0x20) << 5) | ((i & 0x40) << 3) | ((i & 0x80) >> 6);
343 		XOffs1[0][i] = j * 8;
344 		j = ((i & 0xf0) << 4) | (i & 0xf);
345 		XOffs1[1][i] = j * 8;
346 	}
347 
348 	UINT8 *tmp = (UINT8*)BurnMalloc(0x200000);
349 
350 	for (INT32 i = 0; i  < 0x100000; i++) tmp[i] = DrvGfxROM0[i] ^ 0xff;
351 
352 	GfxDecode(0x4000, 8,   8,  8, Plane0, XOffs0, YOffs0, 0x080, tmp, DrvGfxROM0);
353 
354 	memcpy (tmp, DrvGfxROM1, 0x200000);
355 
356 	GfxDecode(0x0200, 8, 256, 16, Plane1, XOffs1[type], YOffs1, 0x8000, tmp, DrvGfxROM1);
357 
358 	BurnFree(tmp);
359 }
360 
DrvInit(INT32 type)361 static INT32 DrvInit(INT32 type)
362 {
363 	AllMem = NULL;
364 	MemIndex();
365 	INT32 nLen = MemEnd - (UINT8 *)0;
366 	if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
367 	memset(AllMem, 0, nLen);
368 	MemIndex();
369 
370 	{
371 		if (BurnLoadRom(DrvZ80ROM0 + 0x00000,   0, 1)) return 1;
372 		if (BurnLoadRom(DrvZ80ROM0 + 0x10000,   1, 1)) return 1;
373 
374 		if (BurnLoadRom(DrvZ80ROM1 + 0x00000,   2, 1)) return 1;
375 
376 		if (BurnLoadRom(DrvZ80ROM2 + 0x00000,   3, 1)) return 1;
377 
378 		if (BurnLoadRom(DrvGfxROM0 + 0x00000,   4, 1)) return 1;
379 		if (BurnLoadRom(DrvGfxROM0 + 0x40000,   5, 1)) return 1;
380 		if (BurnLoadRom(DrvGfxROM0 + 0x80000,   6, 1)) return 1;
381 		if (BurnLoadRom(DrvGfxROM0 + 0xc0000,   7, 1)) return 1;
382 
383 		if (BurnLoadRom(DrvGfxROM1 + 0x100001,  8, 2)) return 1;
384 		if (BurnLoadRom(DrvGfxROM1 + 0x100000,  9, 2)) return 1;
385 		if (BurnLoadRom(DrvGfxROM1 + 0x000001, 10, 2)) return 1;
386 		if (BurnLoadRom(DrvGfxROM1 + 0x000000, 11, 2)) return 1;
387 
388 		if (BurnLoadRom(DrvSndROM + 0x00000,   12, 1)) return 1;
389 
390 		if (BurnLoadRom(DrvVidPROM + 0x00000,  13, 1)) return 1;
391 
392 		DrvGfxDecode(type);
393 	}
394 
395 	ZetInit(0);
396 	ZetOpen(0);
397 	ZetMapMemory(DrvZ80ROM0,		0x0000, 0x7fff, MAP_ROM);
398 	ZetMapMemory(DrvVidRAM,			0xc000, 0xdcff, MAP_RAM);
399 	ZetMapMemory(DrvObjRAM,			0xdd00, 0xdfff, MAP_RAM);
400 	ZetMapMemory(DrvShareRAM,		0xe000, 0xf7ff, MAP_RAM);
401 	ZetMapMemory(DrvPalRAM,			0xf800, 0xf9ff, MAP_RAM);
402 	ZetMapMemory(DrvZ80RAM0,		0xfc00, 0xfdff, MAP_RAM);
403 	ZetSetWriteHandler(missb2_main_write);
404 	ZetSetReadHandler(missb2_main_read);
405 	ZetClose();
406 
407 	ZetInit(1);
408 	ZetOpen(1);
409 	ZetMapMemory(DrvZ80ROM1,		0x0000, 0x7fff, MAP_ROM);
410 	ZetMapMemory(DrvZ80ROM1 + 0xb000,	0xb000, 0xb1ff, MAP_ROM);
411 	ZetMapMemory(DrvPalRAM + 0x0200,	0xc000, 0xc1ff, MAP_RAM);
412 	ZetMapMemory(DrvZ80RAM1,		0xc800, 0xcfff, MAP_RAM);
413 	ZetMapMemory(DrvShareRAM,		0xe000, 0xf7ff, MAP_RAM);
414 	ZetSetWriteHandler(missb2_sub_write);
415 	ZetClose();
416 
417 	ZetInit(2);
418 	ZetOpen(2);
419 	ZetMapMemory(DrvZ80ROM2,		0x0000, 0x7fff, MAP_ROM);
420 	ZetMapMemory(DrvZ80RAM2,		0x8000, 0x8fff, MAP_RAM);
421 	ZetMapMemory(DrvZ80ROM2 + 0xe000,	0xe000, 0xefff, MAP_RAM);
422 	ZetSetWriteHandler(missb2_sound_write);
423 	ZetSetReadHandler(missb2_sound_read);
424 	ZetClose();
425 
426 	BurnYM3526Init(3000000, NULL, 0);
427 	BurnTimerAttachYM3526(&ZetConfig, 3000000);
428 	BurnYM3526SetRoute(BURN_SND_YM3526_ROUTE, 0.40, BURN_SND_ROUTE_BOTH);
429 
430 	MSM6295Init(0, 1056000 / 132, 1);
431 	MSM6295SetRoute(0, 0.40, BURN_SND_ROUTE_BOTH);
432 
433 	GenericTilesInit();
434 
435 	DrvDoReset();
436 
437 	return 0;
438 }
439 
DrvExit()440 static INT32 DrvExit()
441 {
442 	GenericTilesExit();
443 
444 	ZetExit();
445 
446 	BurnYM3526Exit();
447 	MSM6295Exit(0);
448 	MSM6295ROM = NULL;
449 
450 	BurnFree(AllMem);
451 
452 	return 0;
453 }
454 
DrvPaletteUpdate()455 static void DrvPaletteUpdate()
456 {
457 	for (INT32 i = 0; i < 0x400; i+=2)
458 	{
459 		INT32 r = DrvPalRAM[i+0] >> 4;
460 		INT32 g = DrvPalRAM[i+0] & 0xf;
461 		INT32 b = DrvPalRAM[i+1] >> 4;
462 
463 		DrvPalette[i/2] = BurnHighCol(r+r*16,g+g*16, b+b*16, 0);
464 	}
465 }
466 
draw_bg_layer()467 static void draw_bg_layer()
468 {
469 	for (INT32 offs = (bgvram * 16); offs < ((bgvram * 16) | 0xf); offs++)
470 	{
471 		if ((offs & 0xf) == 0 || (offs & 0xf) == 0xf) continue;
472 
473 		RenderCustomTile_Clip(pTransDraw, 256, 16, offs&0x1ff, 0, ((offs & 0xf) * 16) - 16, 0, 8, 0x100, DrvGfxROM1);
474 	}
475 }
476 
draw_sprites()477 static void draw_sprites()
478 {
479 	INT32 sx = 0;
480 
481 	for (INT32 offs = 0; offs < 0x300; offs += 4)
482 	{
483 		if (*(UINT32 *)(&DrvObjRAM[offs]) == 0)
484 			continue;
485 
486 		INT32 gfx_num = DrvObjRAM[offs + 1];
487 		INT32 gfx_attr = DrvObjRAM[offs + 3];
488 		UINT8 *prom_line = DrvVidPROM + 0x80 + ((gfx_num & 0xe0) >> 1);
489 
490 		INT32 gfx_offs = ((gfx_num & 0x1f) * 0x80);
491 		if ((gfx_num & 0xa0) == 0xa0) gfx_offs |= 0x1000;
492 
493 		INT32 sy = -DrvObjRAM[offs + 0];
494 
495 		for (INT32 yc = 0; yc < 32; yc++)
496 		{
497 			if (prom_line[yc / 2] & 0x08) continue;
498 
499 			if (!(prom_line[yc / 2] & 0x04))
500 			{
501 				sx = DrvObjRAM[offs + 2];
502 				if (gfx_attr & 0x40) sx -= 256;
503 			}
504 
505 			for (INT32 xc = 0; xc < 2; xc++)
506 			{
507 				INT32 goffs = gfx_offs + xc * 0x40 + (yc & 7) * 0x02 + (prom_line[yc/2] & 0x03) * 0x10;
508 				INT32 code = DrvVidRAM[goffs] + 256 * (DrvVidRAM[goffs + 1] & 0x03) + 1024 * (gfx_attr & 0x0f);
509 				INT32 flipx = DrvVidRAM[goffs + 1] & 0x40;
510 				INT32 flipy = DrvVidRAM[goffs + 1] & 0x80;
511 				INT32 x = sx + xc * 8;
512 				INT32 y = (sy + yc * 8) & 0xff;
513 
514 				if (flipscreen)
515 				{
516 					x = 248 - x;
517 					y = 248 - y;
518 					flipx = !flipx;
519 					flipy = !flipy;
520 				}
521 
522 				Draw8x8MaskTile(pTransDraw, code & 0x3fff, x, y - 16, flipx, flipy, 0, 8, 0xff, 0, DrvGfxROM0);
523 			}
524 		}
525 
526 		sx += 16;
527 	}
528 }
529 
DrvDraw()530 static INT32 DrvDraw()
531 {
532 	//if (DrvRecalc) {
533 		DrvPaletteUpdate();
534 		DrvRecalc = 1;
535 	//}
536 
537 	BurnTransferClear(0xff);
538 
539 	if (video_enable)
540 	{
541 		if (nBurnLayer & 1) draw_bg_layer();
542 		if (nBurnLayer & 2) draw_sprites();
543 	}
544 
545 	BurnTransferCopy(DrvPalette);
546 
547 	return 0;
548 }
549 
DrvFrame()550 static INT32 DrvFrame()
551 {
552 	if (DrvReset) {
553 		DrvDoReset();
554 	}
555 
556 	ZetNewFrame();
557 
558 	{
559 		memset (DrvInputs, 0xff, 2);
560 
561 		for (INT32 i = 0; i < 8; i++) {
562 			DrvInputs[0] ^= (DrvJoy1[i] & 1) << i;
563 			DrvInputs[1] ^= (DrvJoy2[i] & 1) << i;
564 		}
565 	}
566 
567 	INT32 nInterleave = 100;
568 	INT32 nCyclesTotal[3] = { 6000000 / 60, 6000000 / 60, 3000000 / 60 };
569 	INT32 nCyclesDone[3] = { 0, 0, 0 };
570 
571 	for (INT32 i = 0; i < nInterleave; i++)
572 	{
573 		ZetOpen(0);
574 		nCyclesDone[0] += ZetRun(nCyclesTotal[0] / nInterleave);
575 		if (i == nInterleave - 1) ZetSetIRQLine(0, CPU_IRQSTATUS_HOLD);
576 		ZetClose();
577 
578 		ZetOpen(1);
579 		if (sound_cpu_in_reset) {
580 			nCyclesDone[1] += nCyclesTotal[1] / nInterleave;
581 			ZetIdle(nCyclesTotal[1] / nInterleave);
582 		} else {
583 			nCyclesDone[1] += ZetRun(nCyclesTotal[1] / nInterleave);
584 		}
585 		if (i == nInterleave - 1) ZetSetIRQLine(0, CPU_IRQSTATUS_HOLD);
586 		ZetClose();
587 
588 		ZetOpen(2);
589 		BurnTimerUpdateYM3526((i + 1) * (nCyclesTotal[2] / nInterleave));
590 		if (i == nInterleave - 1) ZetSetIRQLine(0, CPU_IRQSTATUS_HOLD);
591 		ZetClose();
592 	}
593 
594 	ZetOpen(2);
595 
596 	BurnTimerEndFrameYM3526(nCyclesTotal[2]);
597 
598 	if (pBurnSoundOut) {
599 		BurnYM3526Update(pBurnSoundOut, nBurnSoundLen);
600 		MSM6295Render(0, pBurnSoundOut, nBurnSoundLen);
601 	}
602 
603 	ZetClose();
604 
605 	if (pBurnDraw) {
606 		DrvDraw();
607 	}
608 
609 	return 0;
610 }
611 
DrvScan(INT32 nAction,INT32 * pnMin)612 static INT32 DrvScan(INT32 nAction,INT32 *pnMin)
613 {
614 	struct BurnArea ba;
615 
616 	if (pnMin) {
617 		*pnMin = 0x029707;
618 	}
619 
620 	if (nAction & ACB_VOLATILE) {
621 		memset(&ba, 0, sizeof(ba));
622 
623 		ba.Data	  = AllRam;
624 		ba.nLen	  = RamEnd - AllRam;
625 		ba.szName = "All Ram";
626 		BurnAcb(&ba);
627 
628 		ZetScan(nAction);
629 
630 		BurnYM3526Scan(nAction,pnMin);
631 		MSM6295Scan(nAction, pnMin);
632 
633 		SCAN_VAR(bgvram);
634 		SCAN_VAR(soundlatch);
635 		SCAN_VAR(flipscreen);
636 		SCAN_VAR(sound_nmi_enable);
637 		SCAN_VAR(sound_pending_nmi);
638 		SCAN_VAR(sound_cpu_in_reset);
639 		SCAN_VAR(video_enable);
640 		SCAN_VAR(bankdata);
641 	}
642 
643 	if (nAction & ACB_WRITE) {
644 		ZetOpen(0);
645 		bankswitch0(bankdata[0]);
646 		ZetClose();
647 
648 		ZetOpen(1);
649 		bankswitch1(bankdata[1]);
650 		ZetClose();
651 	}
652 
653 	return 0;
654 }
655 
656 
657 // Miss Bubble II
658 
659 static struct BurnRomInfo missb2RomDesc[] = {
660 	{ "msbub2-u.204",		0x10000, 0xb633bdde, 1 | BRF_PRG | BRF_ESS }, //  0 Z80 #0 Code
661 	{ "msbub2-u.203",		0x10000, 0x29fd8afe, 1 | BRF_PRG | BRF_ESS }, //  1
662 
663 	{ "msbub2-u.11",		0x10000, 0x003dc092, 2 | BRF_GRA },           //  2 Z80 #1 Code
664 
665 	{ "msbub2-u.211",		0x08000, 0x08e5d846, 3 | BRF_PRG | BRF_ESS }, //  3 Z80 #2 Code
666 
667 	{ "msbub2-u.14",		0x40000, 0xb3164b47, 4 | BRF_GRA },           //  4 Background Tiles
668 	{ "msbub2-u.126",		0x40000, 0xb0a9a353, 4 | BRF_GRA },           //  5
669 	{ "msbub2-u.124",		0x40000, 0x4b0d8e5b, 4 | BRF_GRA },           //  6
670 	{ "msbub2-u.125",		0x40000, 0x77b710e2, 4 | BRF_GRA },           //  7
671 
672 	{ "msbub2-u.ic1",		0x80000, 0xd621cbc3, 5 | BRF_GRA },           //  8 Sprites
673 	{ "msbub2-u.ic3",		0x80000, 0x90e56035, 5 | BRF_GRA },           //  9
674 	{ "msbub2-u.ic2",		0x80000, 0x694c2783, 5 | BRF_GRA },           // 10
675 	{ "msbub2-u.ic4",		0x80000, 0xbe71c9f0, 5 | BRF_GRA },           // 11
676 
677 	{ "msbub2-u.13",		0x20000, 0x7a4f4272, 6 | BRF_SND },           // 12 OKI Samples
678 
679 	{ "a71-25.bin",			0x00100, 0x2d0f8545, 7 | BRF_GRA },           // 13 Sprite Control PROM
680 };
681 
682 STD_ROM_PICK(missb2)
STD_ROM_FN(missb2)683 STD_ROM_FN(missb2)
684 
685 static INT32 missb2Init()
686 {
687 	return DrvInit(0);
688 }
689 
690 struct BurnDriver BurnDrvMissb2 = {
691 	"missb2", NULL, NULL, NULL, "1996",
692 	"Miss Bubble II\0", NULL, "Alpha Co.", "Miscellaneous",
693 	NULL, NULL, NULL, NULL,
694 	BDF_GAME_WORKING, 2, HARDWARE_MISC_POST90S, GBF_PLATFORM, 0,
695 	NULL, missb2RomInfo, missb2RomName, NULL, NULL, NULL, NULL, Missb2InputInfo, Missb2DIPInfo,
696 	missb2Init, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
697 	256, 224, 4, 3
698 };
699 
700 
701 // Bubble Pong Pong
702 
703 static struct BurnRomInfo bublpongRomDesc[] = {
704 	{ "u204",				0x08000, 0xdaeff303, 1 | BRF_PRG | BRF_ESS }, //  0 Z80 #0 Code
705 	{ "u203",				0x10000, 0x29fd8afe, 1 | BRF_PRG | BRF_ESS }, //  1
706 
707 	{ "ic11",				0x10000, 0xdc1c72ba, 2 | BRF_GRA },           //  2 Z80 #1 Code
708 
709 	{ "s-1.u21",			0x08000, 0x08e5d846, 3 | BRF_PRG | BRF_ESS }, //  3 Z80 #2 Code
710 
711 	{ "mp-6.ic14",			0x40000, 0x00f4896b, 4 | BRF_GRA },           //  4 Background Tiles
712 	{ "mp-5.ic126",			0x40000, 0x1fd30a32, 4 | BRF_GRA },           //  5
713 	{ "5.ic124",			0x40000, 0x55666102, 4 | BRF_GRA },           //  6
714 	{ "6.ic125",			0x40000, 0xaa1c4c32, 4 | BRF_GRA },           //  7
715 
716 	{ "4.ic1",				0x80000, 0x652a49f8, 5 | BRF_GRA },           //  8 Sprites
717 	{ "2.ic3",				0x80000, 0xf8b52c29, 5 | BRF_GRA },           //  9
718 	{ "3.ic2",				0x80000, 0x10263373, 5 | BRF_GRA },           // 10
719 	{ "1.ic4",				0x80000, 0x9e19ad78, 5 | BRF_GRA },           // 11
720 
721 	{ "ic13",				0x20000, 0x7a4f4272, 6 | BRF_SND },           // 12 OKI Samples
722 
723 	{ "a71-25.bin",			0x00100, 0x2d0f8545, 7 | BRF_GRA },           // 13 Sprite Control PROM
724 };
725 
726 STD_ROM_PICK(bublpong)
STD_ROM_FN(bublpong)727 STD_ROM_FN(bublpong)
728 
729 static INT32 bublpongInit()
730 {
731 	return DrvInit(1);
732 }
733 
734 struct BurnDriver BurnDrvBublpong = {
735 	"bublpong", "missb2", NULL, NULL, "1996",
736 	"Bubble Pong Pong\0", NULL, "Top Ltd.", "Miscellaneous",
737 	NULL, NULL, NULL, NULL,
738 	BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_POST90S, GBF_PLATFORM, 0,
739 	NULL, bublpongRomInfo, bublpongRomName, NULL, NULL, NULL, NULL, Missb2InputInfo, Missb2DIPInfo,
740 	bublpongInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
741 	256, 224, 4, 3
742 };
743