1 // FB Alpha Mikie driver module
2 // Based on MAME driver by Allard Van Der Bas
3 
4 #include "tiles_generic.h"
5 #include "z80_intf.h"
6 #include "m6809_intf.h"
7 #include "sn76496.h"
8 
9 static UINT8 *AllMem;
10 static UINT8 *MemEnd;
11 static UINT8 *AllRam;
12 static UINT8 *RamEnd;
13 static UINT8 *DrvM6809ROM;
14 static UINT8 *DrvZ80ROM;
15 static UINT8 *DrvGfxROM0;
16 static UINT8 *DrvGfxROM1;
17 static UINT8 *DrvColPROM;
18 static UINT8 *DrvM6809RAM;
19 static UINT8 *DrvSprRAM;
20 static UINT8 *DrvColRAM;
21 static UINT8 *DrvVidRAM;
22 static UINT8 *DrvZ80RAM;
23 
24 static UINT32 *DrvPalette;
25 static UINT8 DrvRecalc;
26 
27 static UINT8 *soundlatch;
28 static UINT8 *flipscreen;
29 static UINT8 *palette_bank;
30 static UINT8 *irq_mask;
31 static UINT8 *sound_irq;
32 
33 static INT32 watchdog;
34 
35 static UINT8 DrvJoy1[8];
36 static UINT8 DrvJoy2[8];
37 static UINT8 DrvJoy3[8];
38 static UINT8 DrvDips[3];
39 static UINT8 DrvInputs[3];
40 static UINT8 DrvReset;
41 
42 static struct BurnInputInfo MikieInputList[] = {
43 	{"P1 Coin",			BIT_DIGITAL,	DrvJoy1 + 0,	"p1 coin"	},
44 	{"P1 Start",		BIT_DIGITAL,	DrvJoy1 + 3,	"p1 start"	},
45 	{"P1 Up",			BIT_DIGITAL,	DrvJoy2 + 2,	"p1 up"		},
46 	{"P1 Down",			BIT_DIGITAL,	DrvJoy2 + 3,	"p1 down"	},
47 	{"P1 Left",			BIT_DIGITAL,	DrvJoy2 + 0,	"p1 left"	},
48 	{"P1 Right",		BIT_DIGITAL,	DrvJoy2 + 1,	"p1 right"	},
49 	{"P1 Button 1",		BIT_DIGITAL,	DrvJoy2 + 4,	"p1 fire 1"	},
50 	{"P1 Button 2",		BIT_DIGITAL,	DrvJoy2 + 5,	"p1 fire 2"	},
51 
52 	{"P2 Coin",			BIT_DIGITAL,	DrvJoy1 + 1,	"p2 coin"	},
53 	{"P2 Start",		BIT_DIGITAL,	DrvJoy1 + 4,	"p2 start"	},
54 	{"P2 Up",			BIT_DIGITAL,	DrvJoy3 + 2,	"p2 up"		},
55 	{"P2 Down",			BIT_DIGITAL,	DrvJoy3 + 3,	"p2 down"	},
56 	{"P2 Left",			BIT_DIGITAL,	DrvJoy3 + 0,	"p2 left"	},
57 	{"P2 Right",		BIT_DIGITAL,	DrvJoy3 + 1,	"p2 right"	},
58 	{"P2 Button 1",		BIT_DIGITAL,	DrvJoy3 + 4,	"p2 fire 1"	},
59 	{"P2 Button 2",		BIT_DIGITAL,	DrvJoy3 + 5,	"p2 fire 2"	},
60 
61 	{"Reset",			BIT_DIGITAL,	&DrvReset,		"reset"		},
62 	{"Service",			BIT_DIGITAL,	DrvJoy1 + 2,	"service"	},
63 	{"Dip A",			BIT_DIPSWITCH,	DrvDips + 0,	"dip"		},
64 	{"Dip B",			BIT_DIPSWITCH,	DrvDips + 1,	"dip"		},
65 	{"Dip C",			BIT_DIPSWITCH,	DrvDips + 2,	"dip"		},
66 };
67 
68 STDINPUTINFO(Mikie)
69 
70 static struct BurnDIPInfo MikieDIPList[]=
71 {
72 	DIP_OFFSET(0x12)
73 	{0x00, 0xff, 0xff, 0xff, NULL			},
74 	{0x01, 0xff, 0xff, 0x7b, NULL			},
75 	{0x02, 0xff, 0xff, 0xfc, NULL			},
76 
77 	{0   , 0xfe, 0   ,    16, "Coin A"		},
78 	{0x00, 0x01, 0x0f, 0x02, "4 Coins 1 Credits"	},
79 	{0x00, 0x01, 0x0f, 0x05, "3 Coins 1 Credits"	},
80 	{0x00, 0x01, 0x0f, 0x08, "2 Coins 1 Credits"	},
81 	{0x00, 0x01, 0x0f, 0x04, "3 Coins 2 Credits"	},
82 	{0x00, 0x01, 0x0f, 0x01, "4 Coins 3 Credits"	},
83 	{0x00, 0x01, 0x0f, 0x0f, "1 Coin  1 Credits"	},
84 	{0x00, 0x01, 0x0f, 0x03, "3 Coins 4 Credits"	},
85 	{0x00, 0x01, 0x0f, 0x07, "2 Coins 3 Credits"	},
86 	{0x00, 0x01, 0x0f, 0x0e, "1 Coin  2 Credits"	},
87 	{0x00, 0x01, 0x0f, 0x06, "2 Coins 5 Credits"	},
88 	{0x00, 0x01, 0x0f, 0x0d, "1 Coin  3 Credits"	},
89 	{0x00, 0x01, 0x0f, 0x0c, "1 Coin  4 Credits"	},
90 	{0x00, 0x01, 0x0f, 0x0b, "1 Coin  5 Credits"	},
91 	{0x00, 0x01, 0x0f, 0x0a, "1 Coin  6 Credits"	},
92 	{0x00, 0x01, 0x0f, 0x09, "1 Coin  7 Credits"	},
93 	{0x00, 0x01, 0x0f, 0x00, "Free Play"		},
94 
95 	{0   , 0xfe, 0   ,    16, "Coin B"		},
96 	{0x00, 0x01, 0xf0, 0x20, "4 Coins 1 Credits"	},
97 	{0x00, 0x01, 0xf0, 0x50, "3 Coins 1 Credits"	},
98 	{0x00, 0x01, 0xf0, 0x80, "2 Coins 1 Credits"	},
99 	{0x00, 0x01, 0xf0, 0x40, "3 Coins 2 Credits"	},
100 	{0x00, 0x01, 0xf0, 0x10, "4 Coins 3 Credits"	},
101 	{0x00, 0x01, 0xf0, 0xf0, "1 Coin  1 Credits"	},
102 	{0x00, 0x01, 0xf0, 0x30, "3 Coins 4 Credits"	},
103 	{0x00, 0x01, 0xf0, 0x70, "2 Coins 3 Credits"	},
104 	{0x00, 0x01, 0xf0, 0xe0, "1 Coin  2 Credits"	},
105 	{0x00, 0x01, 0xf0, 0x60, "2 Coins 5 Credits"	},
106 	{0x00, 0x01, 0xf0, 0xd0, "1 Coin  3 Credits"	},
107 	{0x00, 0x01, 0xf0, 0xc0, "1 Coin  4 Credits"	},
108 	{0x00, 0x01, 0xf0, 0xb0, "1 Coin  5 Credits"	},
109 	{0x00, 0x01, 0xf0, 0xa0, "1 Coin  6 Credits"	},
110 	{0x00, 0x01, 0xf0, 0x90, "1 Coin  7 Credits"	},
111 	{0x00, 0x01, 0xf0, 0x00, "No Coin B"		},
112 
113 	{0   , 0xfe, 0   ,    4, "Lives"		},
114 	{0x01, 0x01, 0x03, 0x03, "3"			},
115 	{0x01, 0x01, 0x03, 0x02, "4"			},
116 	{0x01, 0x01, 0x03, 0x01, "5"			},
117 	{0x01, 0x01, 0x03, 0x00, "7"			},
118 
119 //	flipscreen not implimented
120 //	{0   , 0xfe, 0   ,    2, "Cabinet"		},
121 //	{0x01, 0x01, 0x04, 0x00, "Upright"		},
122 //	{0x01, 0x01, 0x04, 0x04, "Cocktail"		},
123 
124 	{0   , 0xfe, 0   ,    4, "Bonus Life"		},
125 	{0x01, 0x01, 0x18, 0x18, "20k 70k 50k+"		},
126 	{0x01, 0x01, 0x18, 0x10, "30K 90k 60k+"		},
127 	{0x01, 0x01, 0x18, 0x08, "30k only"		},
128 	{0x01, 0x01, 0x18, 0x00, "40K only"		},
129 
130 	{0   , 0xfe, 0   ,    4, "Difficulty"		},
131 	{0x01, 0x01, 0x60, 0x60, "Easy"			},
132 	{0x01, 0x01, 0x60, 0x40, "Medium"		},
133 	{0x01, 0x01, 0x60, 0x20, "Hard"			},
134 	{0x01, 0x01, 0x60, 0x00, "Hardest"		},
135 
136 	{0   , 0xfe, 0   ,    2, "Demo Sounds"		},
137 	{0x01, 0x01, 0x80, 0x80, "Off"			},
138 	{0x01, 0x01, 0x80, 0x00, "On"			},
139 
140 	{0   , 0xfe, 0   ,    2, "Flip Screen"		},
141 	{0x02, 0x01, 0x01, 0x00, "Off"			},
142 	{0x02, 0x01, 0x01, 0x01, "On"			},
143 
144 	{0   , 0xfe, 0   ,    2, "Upright Controls"	},
145 	{0x02, 0x01, 0x02, 0x02, "Single"		},
146 	{0x02, 0x01, 0x02, 0x00, "Dual"			},
147 };
148 
STDDIPINFO(Mikie)149 STDDIPINFO(Mikie)
150 
151 static void mikie_main_write(UINT16 a, UINT8 d)
152 {
153 	switch (a)
154 	{
155 		case 0x2000:
156 		case 0x2001:
157 			// coin_counter
158 		return;
159 
160 		case 0x2002:
161 			if (*sound_irq == 0 && d == 1) {
162 				ZetSetVector(0xff);
163 				ZetSetIRQLine(0, CPU_IRQSTATUS_ACK);
164 			}
165 			*sound_irq = d;
166 		return;
167 
168 		case 0x2006:
169 			*flipscreen = d & 1;
170 		return;
171 
172 		case 0x2007:
173 			*irq_mask = d & 1;
174 		return;
175 
176 		case 0x2100:
177 			watchdog = 0;
178 		return;
179 
180 		case 0x2200:
181 			*palette_bank = (d & 0x07) << 4;
182 		return;
183 
184 		case 0x2300:
185 		return; // nop
186 
187 		case 0x2400:
188 			*soundlatch = d;
189 		return;
190 	}
191 }
192 
mikie_main_read(UINT16 a)193 static UINT8 mikie_main_read(UINT16 a)
194 {
195 	switch (a)
196 	{
197 		case 0x2400:
198 		case 0x2401:
199 		case 0x2402:
200 			return DrvInputs[a & 3];
201 
202 		case 0x2403:
203 			return DrvDips[2];
204 
205 		case 0x2500:
206 		case 0x2501:
207 			return DrvDips[a & 1];
208 	}
209 
210 	return 0;
211 }
212 
mikie_sound_write(UINT16 a,UINT8 d)213 static void __fastcall mikie_sound_write(UINT16 a, UINT8 d)
214 {
215 	switch (a)
216 	{
217 		case 0x8000:
218 		case 0x8001:
219 		return; // nop
220 
221 		case 0x8002:
222 		case 0x8004:
223 			SN76496Write((a / 4) & 1, d);
224 		return;
225 
226 		case 0x8079:
227 		case 0xa003:
228 		return; // nop
229 	}
230 }
231 
mikie_sound_read(UINT16 a)232 static UINT8 __fastcall mikie_sound_read(UINT16 a)
233 {
234 	switch (a)
235 	{
236 		case 0x8003:
237 			ZetSetIRQLine(0, CPU_IRQSTATUS_NONE);
238 			return *soundlatch;
239 
240 		case 0x8005:
241 			return ZetTotalCycles() / 512;
242 	}
243 
244 	return 0;
245 }
246 
DrvDoReset(INT32 clear_mem)247 static INT32 DrvDoReset(INT32 clear_mem)
248 {
249 	if (clear_mem) {
250 		memset (AllRam, 0, RamEnd - AllRam);
251 	}
252 
253 	M6809Open(0);
254 	M6809Reset();
255 	M6809Close();
256 
257 	ZetOpen(0);
258 	ZetReset();
259 	ZetClose();
260 
261 	watchdog = 0;
262 
263 	HiscoreReset();
264 
265 	return 0;
266 }
267 
DrvPaletteInit()268 static void DrvPaletteInit()
269 {
270 	UINT32 pal[0x100];
271 
272 	for (INT32 i = 0; i < 0x100; i++)
273 	{
274 		INT32 bit0 = (DrvColPROM[i + 0x000] >> 0) & 0x01;
275 		INT32 bit1 = (DrvColPROM[i + 0x000] >> 1) & 0x01;
276 		INT32 bit2 = (DrvColPROM[i + 0x000] >> 2) & 0x01;
277 		INT32 bit3 = (DrvColPROM[i + 0x000] >> 3) & 0x01;
278 		INT32 r = bit0 * 14 + bit1 * 31 + bit2 * 66 + bit3 * 144;
279 
280 		bit0 = (DrvColPROM[i + 0x100] >> 0) & 0x01;
281 		bit1 = (DrvColPROM[i + 0x100] >> 1) & 0x01;
282 		bit2 = (DrvColPROM[i + 0x100] >> 2) & 0x01;
283 		bit3 = (DrvColPROM[i + 0x100] >> 3) & 0x01;
284 		INT32 g = bit0 * 14 + bit1 * 31 + bit2 * 66 + bit3 * 144;
285 
286 		bit0 = (DrvColPROM[i + 0x200] >> 0) & 0x01;
287 		bit1 = (DrvColPROM[i + 0x200] >> 1) & 0x01;
288 		bit2 = (DrvColPROM[i + 0x200] >> 2) & 0x01;
289 		bit3 = (DrvColPROM[i + 0x200] >> 3) & 0x01;
290 		INT32 b = bit0 * 14 + bit1 * 31 + bit2 * 66 + bit3 * 144;
291 
292 		pal[i] = BurnHighCol(r,g,b, 0);
293 	}
294 
295 	for (INT32 i = 0; i < 0x200; i++)
296 	{
297 		for (INT32 j = 0; j < 8; j++)
298 		{
299 			UINT8 ctabentry = (j << 5) | ((~i & 0x100) >> 4) | (DrvColPROM[0x300+i] & 0x0f);
300 			DrvPalette[((i & 0x100) << 3) | (j << 8) | (i & 0xff)] = pal[ctabentry];
301 		}
302 	}
303 
304 	DrvRecalc = 1;
305 }
306 
DrvGfxDecode()307 static INT32 DrvGfxDecode()
308 {
309 	INT32 Plane0[4]  = { STEP4(0,1) };
310 	INT32 Plane1[4]  = { STEP2(0,4), STEP2(256*128*8, 4) };
311 	INT32 XOffs0[8]  = { STEP8(0,4) };
312 	INT32 YOffs0[8]  = { STEP8(0,32) };
313 	INT32 XOffs1[16] = { STEP4(256, 1), STEP4(128, 1), STEP4(0, 1), STEP4(384,1) };
314 	INT32 YOffs1[16] = { STEP8(0,16), STEP8(512, 16) };
315 
316 	UINT8 *buf = (UINT8*)BurnMalloc(0x10000);
317 
318 	memcpy (buf, DrvGfxROM0, 0x4000);
319 
320 	GfxDecode(0x00200, 4,  8,  8, Plane0, XOffs0, YOffs0, 0x100, buf, DrvGfxROM0);
321 
322 	memcpy (buf, DrvGfxROM1, 0x10000);
323 
324 	GfxDecode(0x00100, 4, 16, 16, Plane1, XOffs1, YOffs1, 0x400, buf+0, DrvGfxROM1);
325 	GfxDecode(0x00100, 4, 16, 16, Plane1, XOffs1, YOffs1, 0x400, buf+1, DrvGfxROM1 + 0x10000);
326 
327 	BurnFree(buf);
328 
329 	return 0;
330 }
331 
MemIndex()332 static INT32 MemIndex()
333 {
334 	UINT8 *Next; Next = AllMem;
335 
336 	DrvM6809ROM		= Next; Next += 0x010000;
337 	DrvZ80ROM		= Next; Next += 0x004000;
338 
339 	DrvGfxROM0		= Next; Next += 0x008000;
340 	DrvGfxROM1		= Next; Next += 0x020000;
341 
342 	DrvColPROM		= Next; Next += 0x000500;
343 
344 	DrvPalette		= (UINT32*)Next; Next += 0x1000 * sizeof(UINT32);
345 
346 	AllRam			= Next;
347 
348 	DrvM6809RAM		= Next; Next += 0x000100;
349 	DrvSprRAM		= Next; Next += 0x001000;
350 	DrvColRAM		= Next; Next += 0x000400;
351 	DrvVidRAM		= Next; Next += 0x000400;
352 
353 	DrvZ80RAM		= Next; Next += 0x000400;
354 
355 	soundlatch		= Next; Next += 0x000001;
356 	flipscreen		= Next; Next += 0x000001;
357 	palette_bank	= Next; Next += 0x000001;
358 	irq_mask		= Next; Next += 0x000001;
359 	sound_irq		= Next; Next += 0x000001;
360 
361 	RamEnd			= Next;
362 	MemEnd			= Next;
363 
364 	return 0;
365 }
366 
DrvInit()367 static INT32 DrvInit()
368 {
369 	// Refresh Rate 60.59
370 
371 	BurnAllocMemIndex();
372 
373 	{
374 		if (BurnLoadRom(DrvM6809ROM + 0x0000,  0, 1)) return 1;
375 		if (BurnLoadRom(DrvM6809ROM + 0x2000,  1, 1)) return 1;
376 		if (BurnLoadRom(DrvM6809ROM + 0x6000,  2, 1)) return 1;
377 
378 		if (BurnLoadRom(DrvZ80ROM   + 0x0000,  3, 1)) return 1;
379 
380 		if (BurnLoadRom(DrvGfxROM0  + 0x0000,  4, 1)) return 1;
381 
382 		if (BurnLoadRom(DrvGfxROM1  + 0x0000,  5, 1)) return 1;
383 		if (BurnLoadRom(DrvGfxROM1  + 0x4000,  6, 1)) return 1;
384 		if (BurnLoadRom(DrvGfxROM1  + 0x8000,  7, 1)) return 1;
385 		if (BurnLoadRom(DrvGfxROM1  + 0xc000,  8, 1)) return 1;
386 
387 		if (BurnLoadRom(DrvColPROM  + 0x0000,  9, 1)) return 1;
388 		if (BurnLoadRom(DrvColPROM  + 0x0100, 10, 1)) return 1;
389 		if (BurnLoadRom(DrvColPROM  + 0x0200, 11, 1)) return 1;
390 		if (BurnLoadRom(DrvColPROM  + 0x0300, 12, 1)) return 1;
391 		if (BurnLoadRom(DrvColPROM  + 0x0400, 13, 1)) return 1;
392 
393 		DrvGfxDecode();
394 		DrvPaletteInit();
395 	}
396 
397 	M6809Init(0);
398 	M6809Open(0);
399 	M6809MapMemory(DrvM6809RAM,	0x0000, 0x00ff, MAP_RAM);
400 	M6809MapMemory(DrvSprRAM,	0x2800, 0x37ff, MAP_RAM);
401 	M6809MapMemory(DrvColRAM,	0x3800, 0x3bff, MAP_RAM);
402 	M6809MapMemory(DrvVidRAM,	0x3c00, 0x3fff, MAP_RAM);
403 	M6809MapMemory(DrvM6809ROM,	0x6000, 0xffff, MAP_ROM);
404 	M6809SetWriteHandler(mikie_main_write);
405 	M6809SetReadHandler(mikie_main_read);
406 	M6809Close();
407 
408 	ZetInit(0);
409 	ZetOpen(0);
410 	ZetMapMemory(DrvZ80ROM,		0x0000, 0x3fff, MAP_ROM);
411 	ZetMapMemory(DrvZ80RAM,		0x4000, 0x43ff, MAP_RAM);
412 	ZetSetWriteHandler(mikie_sound_write);
413 	ZetSetReadHandler(mikie_sound_read);
414 	ZetClose();
415 
416 	SN76489AInit(0, 14318180 / 8, 0);
417 	SN76489AInit(1, 14318180 / 4, 1);
418 	SN76496SetRoute(0, 0.40, BURN_SND_ROUTE_BOTH);
419 	SN76496SetRoute(1, 0.40, BURN_SND_ROUTE_BOTH);
420     SN76496SetBuffered(ZetTotalCycles, 3579545);
421 
422 	GenericTilesInit();
423 
424 	DrvDoReset(1);
425 
426 	return 0;
427 }
428 
DrvExit()429 static INT32 DrvExit()
430 {
431 	GenericTilesExit();
432 
433 	M6809Exit();
434 	ZetExit();
435 	SN76496Exit();
436 
437 	BurnFreeMemIndex();
438 
439 	return 0;
440 }
441 
draw_layer(INT32 prio)442 static void draw_layer(INT32 prio)
443 {
444 	for (INT32 offs = 2 * 32; offs < (32 * 32) - (2 * 32); offs++)
445 	{
446 		if ((DrvColRAM[offs] & 0x10) != prio) continue;
447 
448 		INT32 sx = (offs & 0x1f) * 8;
449 		INT32 sy = (offs / 0x20) * 8;
450 
451 		INT32 attr  = DrvColRAM[offs];
452 		INT32 code  = DrvVidRAM[offs] + ((attr & 0x20) << 3);
453 		INT32 color = (attr & 0x0f) + *palette_bank;
454 		INT32 flipx = attr & 0x40;
455 		INT32 flipy = attr & 0x80;
456 
457 		Draw8x8Tile(pTransDraw, code, sx, sy - 16, flipx, flipy, color, 4, 0, DrvGfxROM0);
458 	}
459 }
460 
draw_sprites()461 static void draw_sprites()
462 {
463 	for (INT32 offs = 0; offs < 0x90; offs += 4)
464 	{
465 		int attr    =  DrvSprRAM[offs];
466 		int code    = (DrvSprRAM[offs + 2] & 0x3f) + ((DrvSprRAM[offs + 2] & 0x80) >> 1) + ((DrvSprRAM[offs + 2] & 0x40) << 2) + ((attr & 0x40) << 1);
467 		int color   = (attr & 0x0f) + *palette_bank;
468 		int sx      =  DrvSprRAM[offs + 3];
469 		int sy      = 244 - DrvSprRAM[offs + 1];
470 		int flipx   = ~attr & 0x10;
471 		int flipy   =  attr & 0x20;
472 
473 		if (*flipscreen)
474 		{
475 			sy = 242 - sy;
476 			flipy = !flipy;
477 		}
478 
479 		Draw16x16MaskTile(pTransDraw, code, sx, sy - 16, flipx, flipy, color, 4, 0, 0x800, DrvGfxROM1);
480 	}
481 }
482 
DrvDraw()483 static INT32 DrvDraw()
484 {
485 	if (DrvRecalc) {
486 		DrvPaletteInit();
487 		DrvRecalc = 0;
488 	}
489 
490 	BurnTransferClear();
491 	if (nBurnLayer & 1) draw_layer(0x00);
492 	if (nSpriteEnable & 1) draw_sprites();
493 	if (nBurnLayer & 2) draw_layer(0x10);
494 
495 	BurnTransferCopy(DrvPalette);
496 
497 	return 0;
498 }
499 
DrvFrame()500 static INT32 DrvFrame()
501 {
502 	watchdog++;
503 	if (watchdog == 120) {
504 		DrvDoReset(0);
505 	}
506 
507 	if (DrvReset) {
508 		DrvDoReset(1);
509 	}
510 
511 	{
512 		memset (DrvInputs, 0xff, 3);
513 
514 		for (INT32 i = 0; i < 8; i++) {
515 			DrvInputs[0] ^= (DrvJoy1[i] & 1) << i;
516 			DrvInputs[1] ^= (DrvJoy2[i] & 1) << i;
517 			DrvInputs[2] ^= (DrvJoy3[i] & 1) << i;
518 		}
519 	}
520 
521 	INT32 nInterleave = 256;
522 	INT32 nCyclesTotal[2] = { 1536000 / 60, 3579545 / 60 };
523 	INT32 nCyclesDone[2] = { 0, 0 };
524 
525     M6809NewFrame();
526     ZetNewFrame();
527 
528 	M6809Open(0);
529 	ZetOpen(0);
530 
531 	for (INT32 i = 0; i < nInterleave; i++) {
532 		CPU_RUN(0, M6809);
533 		CPU_RUN(1, Zet);
534 
535 		if (i == 240) {
536 			if (*irq_mask) {
537 				M6809SetIRQLine(0, CPU_IRQSTATUS_HOLD);
538 			}
539 
540 			if (pBurnDraw) {
541 				DrvDraw();
542 			}
543 		}
544 	}
545 
546 	ZetClose();
547 	M6809Close();
548 
549     if (pBurnSoundOut) {
550         SN76496Update(pBurnSoundOut, nBurnSoundLen);
551     }
552 
553 	return 0;
554 }
555 
DrvScan(INT32 nAction,INT32 * pnMin)556 static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
557 {
558 	struct BurnArea ba;
559 
560 	if (pnMin) {
561 		*pnMin = 0x029705;
562 	}
563 
564     if (nAction & ACB_VOLATILE) {
565 		memset(&ba, 0, sizeof(ba));
566 		ba.Data	  = AllRam;
567 		ba.nLen	  = RamEnd - AllRam;
568 		ba.szName = "All Ram";
569 		BurnAcb(&ba);
570 
571 		M6809Scan(nAction);
572 		ZetScan(nAction);
573 
574 		SN76496Scan(nAction, pnMin);
575 
576 		SCAN_VAR(watchdog);
577 	}
578 
579 	return 0;
580 }
581 
582 // Mikie
583 
584 static struct BurnRomInfo mikieRomDesc[] = {
585 	{ "n14.11c",	0x2000, 0xf698e6dd, 1 | BRF_PRG | BRF_ESS }, //  0 M6809 Code
586 	{ "o13.12a",	0x4000, 0x826e7035, 1 | BRF_PRG | BRF_ESS }, //  1
587 	{ "o17.12d",	0x4000, 0x161c25c8, 1 | BRF_PRG | BRF_ESS }, //  2
588 
589 	{ "n10.6e",	0x2000, 0x2cf9d670, 2 | BRF_PRG | BRF_ESS }, //  3 Z80 Code
590 
591 	{ "o11.8i",	0x4000, 0x3c82aaf3, 3 | BRF_GRA },           //  4 Characters
592 
593 	{ "001.f1",	0x4000, 0xa2ba0df5, 4 | BRF_GRA },           //  5 Sprites
594 	{ "003.f3",	0x4000, 0x9775ab32, 4 | BRF_GRA },           //  6
595 	{ "005.h1",	0x4000, 0xba44aeef, 4 | BRF_GRA },           //  7
596 	{ "007.h3",	0x4000, 0x31afc153, 4 | BRF_GRA },           //  8
597 
598 	{ "d19.1i",	0x0100, 0x8b83e7cf, 5 | BRF_GRA },           //  9 Color Proms
599 	{ "d21.3i",	0x0100, 0x3556304a, 5 | BRF_GRA },           // 10
600 	{ "d20.2i",	0x0100, 0x676a0669, 5 | BRF_GRA },           // 11
601 	{ "d22.12h",	0x0100, 0x872be05c, 5 | BRF_GRA },           // 12
602 	{ "d18.f9",	0x0100, 0x7396b374, 5 | BRF_GRA },           // 13
603 };
604 
605 STD_ROM_PICK(mikie)
606 STD_ROM_FN(mikie)
607 
608 struct BurnDriver BurnDrvMikie = {
609 	"mikie", NULL, NULL, NULL, "1984",
610 	"Mikie\0", NULL, "Konami", "GX469",
611 	NULL, NULL, NULL, NULL,
612 	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARDWARE_PREFIX_KONAMI, GBF_ACTION, 0,
613 	NULL, mikieRomInfo, mikieRomName, NULL, NULL, NULL, NULL, MikieInputInfo, MikieDIPInfo,
614 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x1000,
615 	224, 256, 3, 4
616 };
617 
618 
619 // Shinnyuushain Tooru-kun
620 
621 static struct BurnRomInfo mikiejRomDesc[] = {
622 	{ "n14.11c",	0x2000, 0xf698e6dd, 1 | BRF_PRG | BRF_ESS }, //  0 M6809 Code
623 	{ "o13.12a",	0x4000, 0x826e7035, 1 | BRF_PRG | BRF_ESS }, //  1
624 	{ "o17.12d",	0x4000, 0x161c25c8, 1 | BRF_PRG | BRF_ESS }, //  2
625 
626 	{ "n10.6e",	0x2000, 0x2cf9d670, 2 | BRF_PRG | BRF_ESS }, //  3 Z80 Code
627 
628 	{ "q11.8i",	0x4000, 0xc48b269b, 3 | BRF_GRA },           //  4 Characters
629 
630 	{ "q01.f1",	0x4000, 0x31551987, 4 | BRF_GRA },           //  5 Sprites
631 	{ "q03.f3",	0x4000, 0x34414df0, 4 | BRF_GRA },           //  6
632 	{ "q05.h1",	0x4000, 0xf9e1ebb1, 4 | BRF_GRA },           //  7
633 	{ "q07.h3",	0x4000, 0x15dc093b, 4 | BRF_GRA },           //  8
634 
635 	{ "d19.1i",	0x0100, 0x8b83e7cf, 5 | BRF_GRA },           //  9 Color Proms
636 	{ "d21.3i",	0x0100, 0x3556304a, 5 | BRF_GRA },           // 10
637 	{ "d20.2i",	0x0100, 0x676a0669, 5 | BRF_GRA },           // 11
638 	{ "d22.12h",	0x0100, 0x872be05c, 5 | BRF_GRA },           // 12
639 	{ "d18.f9",	0x0100, 0x7396b374, 5 | BRF_GRA },           // 13
640 };
641 
642 STD_ROM_PICK(mikiej)
643 STD_ROM_FN(mikiej)
644 
645 struct BurnDriver BurnDrvMikiej = {
646 	"mikiej", "mikie", NULL, NULL, "1984",
647 	"Shinnyuushain Tooru-kun\0", NULL, "Konami", "GX469",
648 	NULL, NULL, NULL, NULL,
649 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARDWARE_PREFIX_KONAMI, GBF_ACTION, 0,
650 	NULL, mikiejRomInfo, mikiejRomName, NULL, NULL, NULL, NULL, MikieInputInfo, MikieDIPInfo,
651 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x1000,
652 	224, 256, 3, 4
653 };
654 
655 
656 // Mikie (High School Graffiti)
657 
658 static struct BurnRomInfo mikiehsRomDesc[] = {
659 	{ "l14.11c",	0x2000, 0x633f3a6d, 1 | BRF_PRG | BRF_ESS }, //  0 M6809 Code
660 	{ "m13.12a",	0x4000, 0x9c42d715, 1 | BRF_PRG | BRF_ESS }, //  1
661 	{ "m17.12d",	0x4000, 0xcb5c03c9, 1 | BRF_PRG | BRF_ESS }, //  2
662 
663 	{ "h10.6e",	0x2000, 0x4ed887d2, 2 | BRF_PRG | BRF_ESS }, //  3 Z80 Code
664 
665 	{ "l11.8i",	0x4000, 0x5ba9d86b, 3 | BRF_GRA },           //  4 Characters
666 
667 	{ "i01.f1",	0x4000, 0x0c0cab5f, 4 | BRF_GRA },           //  5 Sprites
668 	{ "i03.f3",	0x4000, 0x694da32f, 4 | BRF_GRA },           //  6
669 	{ "i05.h1",	0x4000, 0x00e357e1, 4 | BRF_GRA },           //  7
670 	{ "i07.h3",	0x4000, 0xceeba6ac, 4 | BRF_GRA },           //  8
671 
672 	{ "d19.1i",	0x0100, 0x8b83e7cf, 5 | BRF_GRA },           //  9 Color Proms
673 	{ "d21.3i",	0x0100, 0x3556304a, 5 | BRF_GRA },           // 10
674 	{ "d20.2i",	0x0100, 0x676a0669, 5 | BRF_GRA },           // 11
675 	{ "d22.12h",	0x0100, 0x872be05c, 5 | BRF_GRA },           // 12
676 	{ "d18.f9",	0x0100, 0x7396b374, 5 | BRF_GRA },           // 13
677 };
678 
679 STD_ROM_PICK(mikiehs)
680 STD_ROM_FN(mikiehs)
681 
682 struct BurnDriver BurnDrvMikiehs = {
683 	"mikiehs", "mikie", NULL, NULL, "1984",
684 	"Mikie (High School Graffiti)\0", NULL, "Konami", "GX469",
685 	NULL, NULL, NULL, NULL,
686 	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 2, HARDWARE_PREFIX_KONAMI, GBF_ACTION, 0,
687 	NULL, mikiehsRomInfo, mikiehsRomName, NULL, NULL, NULL, NULL, MikieInputInfo, MikieDIPInfo,
688 	DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x1000,
689 	224, 256, 3, 4
690 };
691