1 // FB Alpha Joyful Road / Munch Mobile driver module
2 // Based on MAME driver by Phil Stroffolino
3
4 /*
5 To do (Remove as completed):
6 Video frequency is not correct, should be 57hz.
7 */
8
9 #include "tiles_generic.h"
10 #include "z80_intf.h"
11 #include "ay8910.h"
12
13 static UINT8 *AllMem;
14 static UINT8 *MemEnd;
15 static UINT8 *AllRam;
16 static UINT8 *RamEnd;
17 static UINT8 *DrvZ80ROM0;
18 static UINT8 *DrvZ80ROM1;
19 static UINT8 *DrvGfxROM0;
20 static UINT8 *DrvMapROM1;
21 static UINT8 *DrvGfxROM1;
22 static UINT8 *DrvGfxROM2;
23 static UINT8 *DrvColPROM;
24 static UINT8 *DrvZ80RAM0;
25 static UINT8 *DrvZ80RAM1;
26 static UINT8 *DrvVidRAM;
27 static UINT8 *DrvStatRAM;
28 static UINT8 *DrvSprXRAM;
29 static UINT8 *DrvSprTRAM;
30 static UINT8 *DrvSprARAM;
31 static UINT8 *DrvVRegs;
32
33 static UINT16 *DrvBGBitmap;
34
35 static UINT32 *DrvPalette;
36 static UINT8 DrvRecalc;
37
38 static UINT8 flipscreen;
39 static UINT8 nmi_enable;
40 static UINT8 soundlatch;
41 static UINT8 palette_bank;
42
43 static UINT8 DrvJoy1[8];
44 static UINT8 DrvJoy2[8];
45 static UINT8 DrvJoy3[8];
46 static UINT8 DrvDips[2];
47 static UINT8 DrvInputs[3];
48 static UINT8 DrvReset;
49
50 static struct BurnInputInfo DrvInputList[] = {
51 {"P1 Coin", BIT_DIGITAL, DrvJoy1 + 0, "p1 coin" },
52
53 {"P1 Start", BIT_DIGITAL, DrvJoy1 + 3, "p1 start" },
54 {"P1 Left Stick Up", BIT_DIGITAL, DrvJoy2 + 0, "p1 up" },
55 {"P1 Left Stick Down", BIT_DIGITAL, DrvJoy2 + 1, "p1 down" },
56 {"P1 Left Stick Left", BIT_DIGITAL, DrvJoy2 + 2, "p1 left" },
57 {"P1 Left Stick Right", BIT_DIGITAL, DrvJoy2 + 3, "p1 right" },
58 {"P1 Right Stick Left", BIT_DIGITAL, DrvJoy2 + 4, "p3 left" },
59 {"P1 Right Stick Right",BIT_DIGITAL, DrvJoy2 + 5, "p3 right" },
60
61 {"P2 Start", BIT_DIGITAL, DrvJoy1 + 4, "p2 start" },
62 {"P2 Left Stick Up", BIT_DIGITAL, DrvJoy3 + 0, "p2 up" },
63 {"P2 Left Stick Down", BIT_DIGITAL, DrvJoy3 + 1, "p2 down" },
64 {"P2 Left Stick Left", BIT_DIGITAL, DrvJoy3 + 2, "p2 left" },
65 {"P2 Left Stick Right", BIT_DIGITAL, DrvJoy3 + 3, "p2 right" },
66 {"P2 Right Stick Left", BIT_DIGITAL, DrvJoy3 + 4, "p4 left" },
67 {"P2 Right Stick Right",BIT_DIGITAL, DrvJoy3 + 5, "p4 right" },
68
69 {"Reset", BIT_DIGITAL, &DrvReset, "reset" },
70 {"Service", BIT_DIGITAL, DrvJoy1 + 2, "service" },
71 {"Dip A", BIT_DIPSWITCH, DrvDips + 0, "dips" },
72 {"Dip B", BIT_DIPSWITCH, DrvDips + 1, "dips" },
73 };
74
75 STDINPUTINFO(Drv)
76
77 static struct BurnDIPInfo DrvDIPList[]=
78 {
79 {0x11, 0xff, 0xff, 0x00, NULL },
80 {0x12, 0xff, 0xff, 0x88, NULL },
81
82 {0 , 0xfe, 0 , 2, "Continue after game over? (Cheat)" },
83 {0x11, 0x01, 0x01, 0x00, "Off" },
84 {0x11, 0x01, 0x01, 0x01, "On" },
85
86 {0 , 0xfe, 0 , 12, "Coin A" },
87 {0x11, 0x01, 0x1e, 0x14, "3 Coins 1 Credit" },
88 {0x11, 0x01, 0x1e, 0x10, "2 Coins 1 Credit" },
89 {0x11, 0x01, 0x1e, 0x16, "3 Coins 2 Credits" },
90 {0x11, 0x01, 0x1e, 0x00, "1 Coin 1 Credit" },
91 {0x11, 0x01, 0x1e, 0x12, "2 Coins 3 Credits" },
92 {0x11, 0x01, 0x1e, 0x02, "1 Coin 2 Credits" },
93 {0x11, 0x01, 0x1e, 0x04, "1 Coins 3 Credits" },
94 {0x11, 0x01, 0x1e, 0x06, "1 Coin 4 Credits" },
95 {0x11, 0x01, 0x1e, 0x08, "1 Coin 5 Credits" },
96 {0x11, 0x01, 0x1e, 0x0a, "1 Coin 6 Credits" },
97 {0x11, 0x01, 0x1e, 0x0c, "1 Coin 7 Credits" },
98 {0x11, 0x01, 0x1e, 0x0e, "1 Coin 8 Credits" },
99
100 {0 , 0xfe, 0 , 8, "First Bonus" },
101 {0x11, 0x01, 0xe0, 0x00, "10000" },
102 {0x11, 0x01, 0xe0, 0x20, "20000" },
103 {0x11, 0x01, 0xe0, 0x40, "30000" },
104 {0x11, 0x01, 0xe0, 0x60, "40000" },
105 {0x11, 0x01, 0xe0, 0x80, "50000" },
106 {0x11, 0x01, 0xe0, 0xa0, "60000" },
107 {0x11, 0x01, 0xe0, 0xc0, "70000" },
108 {0x11, 0x01, 0xe0, 0xe0, "None" },
109
110 {0 , 0xfe, 0 , 4, "Second Bonus (First +)" },
111 {0x12, 0x01, 0x03, 0x00, "30000" },
112 {0x12, 0x01, 0x03, 0x01, "40000" },
113 {0x12, 0x01, 0x03, 0x02, "100000" },
114 {0x12, 0x01, 0x03, 0x03, "None" },
115
116 {0 , 0xfe, 0 , 4, "Lives" },
117 {0x12, 0x01, 0x0c, 0x00, "1" },
118 {0x12, 0x01, 0x0c, 0x04, "2" },
119 {0x12, 0x01, 0x0c, 0x08, "3" },
120 {0x12, 0x01, 0x0c, 0x0c, "5" },
121
122 {0 , 0xfe, 0 , 2, "Freeze" },
123 {0x12, 0x01, 0x10, 0x00, "Off" },
124 {0x12, 0x01, 0x10, 0x10, "On" },
125
126 {0 , 0xfe, 0 , 2, "Demo Sounds" },
127 {0x12, 0x01, 0x20, 0x20, "Off" },
128 {0x12, 0x01, 0x20, 0x00, "On" },
129
130 {0 , 0xfe, 0 , 1, "Cabinet" },
131 {0x12, 0x01, 0x40, 0x00, "Upright" },
132 // {0x12, 0x01, 0x40, 0x40, "Cocktail" }, // not supported
133
134 {0 , 0xfe, 0 , 2, "Additional Bonus (Second)" },
135 {0x12, 0x01, 0x80, 0x00, "No" },
136 {0x12, 0x01, 0x80, 0x80, "Yes" },
137 };
138
STDDIPINFO(Drv)139 STDDIPINFO(Drv)
140
141 static void __fastcall mnchmobl_main_write(UINT16 address, UINT8 data)
142 {
143 switch (address)
144 {
145 case 0xbaba:
146 return; // nop
147
148 case 0xbe00: {
149 soundlatch = data;
150 ZetClose();
151 ZetOpen(1);
152 ZetSetIRQLine(0, CPU_IRQSTATUS_HOLD);
153 ZetClose();
154 ZetOpen(0);
155 }
156 return;
157
158 case 0xbe01:
159 palette_bank = data & 0x03;
160 return;
161
162 case 0xbe11:
163 case 0xbe21:
164 case 0xbe31:
165 return; // nop
166
167 case 0xbe41:
168 flipscreen = data;
169 return;
170
171 case 0xbe61:
172 nmi_enable = data;
173 return;
174
175 case 0xbf00:
176 case 0xbf01:
177 case 0xbf02:
178 case 0xbf03:
179 case 0xbf04:
180 case 0xbf05:
181 case 0xbf06:
182 case 0xbf07:
183 DrvVRegs[address & 7] = data;
184 return;
185 }
186 }
187
mnchmobl_main_read(UINT16 address)188 static UINT8 __fastcall mnchmobl_main_read(UINT16 address)
189 {
190 switch (address)
191 {
192 case 0xbe02:
193 return DrvDips[0];
194
195 case 0xbe03:
196 return DrvDips[1];
197
198 case 0xbf01:
199 return DrvInputs[0];
200
201 case 0xbf02:
202 return DrvInputs[1];
203
204 case 0xbf03:
205 return DrvInputs[2];
206 }
207 bprintf(0, _T("u-mr %X.\n"), address);
208 return 0;
209 }
210
mnchmobl_sound_write(UINT16 address,UINT8 data)211 static void __fastcall mnchmobl_sound_write(UINT16 address, UINT8 data)
212 {
213 switch (address & ~0x1fff)
214 {
215 case 0x4000:
216 AY8910Write(0, (~address >> 12) & 1, data);
217 return;
218
219 case 0x6000:
220 AY8910Write(1, (~address >> 12) & 1, data);
221 return;
222
223 case 0x8000:
224 AY8910Reset(0);
225 return;
226
227 case 0xa000:
228 AY8910Reset(1);
229 return;
230
231 case 0xc000:
232 ZetSetIRQLine(0x20, CPU_IRQSTATUS_NONE);
233 return;
234 }
235 }
236
mnchmobl_sound_read(UINT16 address)237 static UINT8 __fastcall mnchmobl_sound_read(UINT16 address)
238 {
239 switch (address & ~0x1fff)
240 {
241 case 0x2000:
242 //ZetSetIRQLine(0, CPU_IRQSTATUS_NONE);
243 return soundlatch;
244
245 case 0x8000:
246 AY8910Reset(0);
247 return 0;
248
249 case 0xa000:
250 AY8910Reset(1);
251 return 0;
252 }
253
254 return 0;
255 }
256
DrvDoReset()257 static INT32 DrvDoReset()
258 {
259 memset (AllRam, 0, RamEnd - AllRam);
260
261 ZetOpen(0);
262 ZetReset();
263 ZetClose();
264
265 ZetOpen(1);
266 ZetReset();
267 ZetClose();
268
269 AY8910Reset(0);
270 AY8910Reset(1);
271
272 HiscoreReset();
273
274 flipscreen = 0;
275 nmi_enable = 0;
276 soundlatch = 0;
277 palette_bank = 0;
278
279 return 0;
280 }
281
MemIndex()282 static INT32 MemIndex()
283 {
284 UINT8 *Next; Next = AllMem;
285
286 DrvZ80ROM0 = Next; Next += 0x004000;
287 DrvZ80ROM1 = Next; Next += 0x002000;
288
289 DrvGfxROM0 = Next; Next += 0x004000;
290 DrvMapROM1 = Next; Next += 0x021000;
291 DrvGfxROM1 = Next; Next += 0x042000;
292 DrvGfxROM2 = Next; Next += 0x040000;
293
294 DrvColPROM = Next; Next += 0x000100;
295
296 DrvPalette = (UINT32*)Next; Next += 0x00100 * sizeof(UINT32);
297
298 AllRam = Next;
299
300 DrvZ80RAM0 = Next; Next += 0x000400;
301 DrvZ80RAM1 = Next; Next += 0x000800;
302 DrvVidRAM = Next; Next += 0x000100;
303 DrvStatRAM = Next; Next += 0x000100;
304 DrvSprXRAM = Next; Next += 0x000400;
305 DrvSprTRAM = Next; Next += 0x000400;
306 DrvSprARAM = Next; Next += 0x000400;
307
308 DrvVRegs = Next; Next += 0x0000080;
309
310 DrvBGBitmap = (UINT16*)Next; Next += (512 * 512) * sizeof(UINT16);
311
312 RamEnd = Next;
313
314 MemEnd = Next;
315
316 return 0;
317 }
318
DrvPaletteInit()319 static void DrvPaletteInit()
320 {
321 for (INT32 i = 0; i < 0x100; i++)
322 {
323 INT32 bit0 = (DrvColPROM[i] >> 0) & 1;
324 INT32 bit1 = (DrvColPROM[i] >> 1) & 1;
325 INT32 bit2 = (DrvColPROM[i] >> 2) & 1;
326
327 INT32 r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
328
329 bit0 = (DrvColPROM[i] >> 3) & 1;
330 bit1 = (DrvColPROM[i] >> 4) & 1;
331 bit2 = (DrvColPROM[i] >> 5) & 1;
332
333 INT32 g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
334
335 bit0 = (DrvColPROM[i] >> 6) & 1;
336 bit1 = (DrvColPROM[i] >> 7) & 1;
337
338 INT32 b = 0x4f * bit0 + 0xa8 * bit1;
339
340 DrvPalette[i] = BurnHighCol(r,g,b,0);
341 }
342 }
343
DrvGfxDecode()344 static INT32 DrvGfxDecode()
345 {
346 INT32 Plane0[4] = { 0, 8, 0x8000, 0x8008 };
347 INT32 Plane1[4] = { 8,12,0,4 };
348 INT32 Plane2[3] = { 0x4000*8,0x2000*8,0 };
349 INT32 Plane3[3] = { 0,0,0 }; // monochrome
350
351 INT32 XOffs0[8] = { STEP8(7,-1) };
352 INT32 XOffs1[8] = { 0,0,1,1,2,2,3,3 };
353 INT32 XOffs2[32] =
354 {
355 7,7,6,6,5,5,4,4,3,3,2,2,1,1,0,0,
356 0x8000+7,0x8000+7,0x8000+6,0x8000+6,0x8000+5,0x8000+5,0x8000+4,0x8000+4,
357 0x8000+3,0x8000+3,0x8000+2,0x8000+2,0x8000+1,0x8000+1,0x8000+0,0x8000+0
358 };
359 INT32 YOffs0[8] = { STEP8(0,16) };
360 INT32 YOffs2[32] = { STEP32(0,8) };
361
362 UINT8 *tmp = (UINT8*)BurnMalloc(0x10000);
363 if (tmp == NULL) {
364 return 1;
365 }
366
367 memcpy (tmp, DrvGfxROM0, 0x2000);
368
369 GfxDecode(0x0100, 4, 8, 8, Plane0, XOffs0, YOffs0, 0x080, tmp, DrvGfxROM0);
370
371 memcpy (tmp, DrvGfxROM1, 0x1000);
372
373 GfxDecode(0x0080, 4, 8, 8, Plane1, XOffs1, YOffs0, 0x080, tmp, DrvGfxROM1);
374
375 memcpy (tmp, DrvGfxROM2, 0x6000);
376
377 GfxDecode(0x0080, 3, 32, 32, Plane2, XOffs2, YOffs2, 0x100, tmp, DrvGfxROM2);
378
379 memcpy (tmp, DrvGfxROM2 + 0x20000, 0x2000);
380
381 GfxDecode(0x0080, 3, 32, 32, Plane3, XOffs2, YOffs2, 0x100, tmp, DrvGfxROM2 + 0x20000);
382
383 BurnFree(tmp);
384
385 return 0;
386 }
387
DrvInit()388 static INT32 DrvInit()
389 {
390 AllMem = NULL;
391 MemIndex();
392 INT32 nLen = MemEnd - (UINT8 *)0;
393 if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
394 memset(AllMem, 0, nLen);
395 MemIndex();
396
397 {
398 if (BurnLoadRom(DrvZ80ROM0 + 0x00000, 0, 1)) return 1;
399 if (BurnLoadRom(DrvZ80ROM0 + 0x02000, 1, 1)) return 1;
400
401 if (BurnLoadRom(DrvZ80ROM1 + 0x00000, 2, 1)) return 1;
402
403 if (BurnLoadRom(DrvGfxROM0 + 0x00000, 3, 1)) return 1;
404 if (BurnLoadRom(DrvGfxROM0 + 0x01000, 4, 1)) return 1;
405
406 if (BurnLoadRom(DrvMapROM1 + 0x00000, 5, 1)) return 1;
407
408 if (BurnLoadRom(DrvGfxROM1 + 0x00000, 6, 1)) return 1;
409
410 if (BurnLoadRom(DrvGfxROM2 + 0x00000, 7, 1)) return 1;
411 if (BurnLoadRom(DrvGfxROM2 + 0x02000, 8, 1)) return 1;
412 if (BurnLoadRom(DrvGfxROM2 + 0x04000, 9, 1)) return 1;
413
414 if (BurnLoadRom(DrvGfxROM2 + 0x20000, 10, 1)) return 1;
415
416 if (BurnLoadRom(DrvColPROM + 0x00000, 11, 1)) return 1;
417
418 DrvPaletteInit();
419 DrvGfxDecode();
420 }
421
422 ZetInit(0);
423 ZetOpen(0);
424 ZetMapMemory(DrvZ80ROM0, 0x0000, 0x3fff, MAP_ROM);
425 ZetMapMemory(DrvZ80RAM0, 0x8000, 0x83ff, MAP_RAM);
426 ZetMapMemory(DrvSprXRAM, 0xa000, 0xa3ff, MAP_RAM);
427 ZetMapMemory(DrvSprXRAM, 0xa400, 0xa7ff, MAP_RAM);
428 ZetMapMemory(DrvSprTRAM, 0xa800, 0xabff, MAP_RAM);
429 ZetMapMemory(DrvSprTRAM, 0xac00, 0xafff, MAP_RAM);
430 ZetMapMemory(DrvSprARAM, 0xb000, 0xb3ff, MAP_RAM);
431 ZetMapMemory(DrvSprARAM, 0xb400, 0xb7ff, MAP_RAM);
432 ZetMapMemory(DrvVidRAM, 0xb800, 0xb8ff, MAP_RAM);
433 ZetMapMemory(DrvVidRAM, 0xb900, 0xb9ff, MAP_RAM);
434 ZetMapMemory(DrvStatRAM, 0xbc00, 0xbcff, MAP_RAM);
435 ZetSetWriteHandler(mnchmobl_main_write);
436 ZetSetReadHandler(mnchmobl_main_read);
437 ZetClose();
438
439 ZetInit(1);
440 ZetOpen(1);
441 ZetMapMemory(DrvZ80ROM1, 0x0000, 0x1fff, MAP_ROM);
442 ZetMapMemory(DrvZ80RAM1, 0xe000, 0xe7ff, MAP_RAM);
443 ZetMapMemory(DrvZ80RAM1, 0xe800, 0xefff, MAP_RAM);
444 ZetMapMemory(DrvZ80RAM1, 0xf000, 0xf7ff, MAP_RAM);
445 ZetMapMemory(DrvZ80RAM1, 0xf800, 0xffff, MAP_RAM);
446 ZetSetWriteHandler(mnchmobl_sound_write);
447 ZetSetReadHandler(mnchmobl_sound_read);
448 ZetClose();
449
450 AY8910Init(0, 1875000, 0);
451 AY8910Init(1, 1875000, 1);
452 AY8910SetAllRoutes(0, 0.50, BURN_SND_ROUTE_BOTH);
453 AY8910SetAllRoutes(1, 0.50, BURN_SND_ROUTE_BOTH);
454
455 GenericTilesInit();
456
457 DrvDoReset();
458
459 return 0;
460 }
461
DrvExit()462 static INT32 DrvExit()
463 {
464 GenericTilesExit();
465 ZetExit();
466 AY8910Exit(0);
467 AY8910Exit(1);
468
469 BurnFree(AllMem);
470
471 return 0;
472 }
473
draw_status()474 static void draw_status()
475 {
476 for (INT32 row = 0; row < 4; row++) {
477
478 INT32 sx = ((row & 1) << 3) + ((~row & 2) ? 304 : 0);
479
480 for (INT32 sy = 0; sy < 256; sy+=8) {
481 INT32 code = DrvStatRAM[((~row & 3) << 5) + (sy >> 3)];
482
483 Render8x8Tile_Clip(pTransDraw, code, sx, sy, 0, 4, 0, DrvGfxROM0);
484 }
485 }
486 }
487
draw_background()488 static void draw_background()
489 {
490 INT32 scrollx = (-(DrvVRegs[6] *2 + (DrvVRegs[7] >> 7)) - 64 - 128 - 16) & 0x1ff;
491
492 GenericTilesSetClipRaw(0, 512, 0, 512);
493
494 for (INT32 offs = 0; offs < 16 * 16; offs++)
495 {
496 INT32 sy = (offs % 16) * 32;
497 INT32 sx = (offs / 16) * 32;
498
499 INT32 code_offset = DrvVidRAM[offs];
500
501 for (INT32 row = 0; row < 4; row++)
502 {
503 for (INT32 col = 0; col < 4; col++)
504 {
505 INT32 code = DrvMapROM1[col + code_offset * 4 + row * 0x400] & 0x7f;
506
507 Render8x8Tile_Clip(DrvBGBitmap, code, (sx + (col * 8)), sy + (row * 8), palette_bank + 0x04, 4, 0, DrvGfxROM1);
508 }
509 }
510 }
511
512 GenericTilesClearClipRaw();
513
514 // copy the BGBitmap to pTransDraw
515 for (INT32 sy = 0; sy < nScreenHeight; sy++) {
516
517 UINT16 *src = DrvBGBitmap + sy * 512;
518 UINT16 *dst = pTransDraw + sy * nScreenWidth;
519
520 for (INT32 sx = 0; sx < nScreenWidth; sx++) {
521 dst[sx] = src[(sx-scrollx)&0x1ff];
522 }
523 }
524
525 }
526
draw_sprites()527 static void draw_sprites()
528 {
529 int scroll = DrvVRegs[6];
530 int flags = DrvVRegs[7];
531 int xadjust = - 128 - 16 - ((flags & 0x80) ? 1 : 0);
532 int bank = (flags & 0x40) ? 0x80 : 0;
533
534 int color_base = (palette_bank * 4) + 3;
535
536 int firstsprite = DrvVRegs[4] & 0x3f;
537
538 for (INT32 i = firstsprite; i < firstsprite + 0x40; i++)
539 {
540 for (INT32 j = 0; j < 8; j++)
541 {
542 INT32 offs = (j << 6) | (i & 0x3f);
543 INT32 attributes = DrvSprARAM[offs];
544
545 if (attributes & 0x80)
546 {
547 INT32 tile_number = DrvSprTRAM[offs] ^ 0x7f;
548 INT32 sx = DrvSprXRAM[offs];
549 INT32 sy = ((offs >> 6) << 5) + ((attributes >> 2) & 0x1f);
550
551 sx = (sx >> 1) | (tile_number & 0x80);
552 sx = 2 * ((- 32 - scroll - sx) & 0xff) + xadjust;
553
554 INT32 color = color_base - (attributes & 0x03);
555
556 Render32x32Tile_Mask_Clip(pTransDraw, (tile_number & 0x7f) + bank, sx, sy, color, 3, 7, 0x80, DrvGfxROM2);
557 }
558 }
559 }
560 }
561
DrvDraw()562 static INT32 DrvDraw()
563 {
564 if (DrvRecalc) {
565 DrvPaletteInit();
566 DrvRecalc = 0;
567 }
568 BurnTransferClear();
569 if (nBurnLayer & 1) draw_background();
570 if (nBurnLayer & 2) draw_sprites();
571 if (nBurnLayer & 4) draw_status();
572
573 BurnTransferCopy(DrvPalette);
574
575 return 0;
576 }
577
DrvFrame()578 static INT32 DrvFrame()
579 {
580 if (DrvReset) {
581 DrvDoReset();
582 }
583
584 {
585 memset (DrvInputs, 0xff, 3);
586
587 for (INT32 i = 0; i < 8; i++) {
588 DrvInputs[0] ^= (DrvJoy1[i] & 1) << i;
589 DrvInputs[1] ^= (DrvJoy2[i] & 1) << i;
590 DrvInputs[2] ^= (DrvJoy3[i] & 1) << i;
591 }
592 }
593
594 INT32 nInterleave = 256;
595 INT32 nCyclesTotal[2] = { 3750000 / 57, 3750000 / 57 }; // 57HZ...
596 INT32 nCyclesDone[2] = { 0, 0 };
597
598 for (INT32 i = 0; i < nInterleave; i++)
599 {
600 ZetOpen(0);
601 INT32 nSegment = nCyclesTotal[0] / nInterleave;
602 nCyclesDone[0] += ZetRun(nSegment);
603 if (i == 220) { // 220? weird? probably due to hz? any higher and car flickers
604 if (nmi_enable) ZetNmi();
605 ZetSetIRQLine(0, CPU_IRQSTATUS_HOLD);
606 }
607 ZetClose();
608
609 ZetOpen(1);
610 nCyclesDone[1] += ZetRun(nSegment);
611 if (i == 220) {
612 ZetSetIRQLine(0x20, CPU_IRQSTATUS_ACK); // nmi
613 }
614 ZetClose();
615 }
616
617 if (pBurnSoundOut) {
618 AY8910Render(pBurnSoundOut, nBurnSoundLen);
619 }
620
621 if (pBurnDraw) {
622 DrvDraw();
623 }
624
625 return 0;
626 }
627
DrvScan(INT32 nAction,INT32 * pnMin)628 static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
629 {
630 struct BurnArea ba;
631
632 if (pnMin) {
633 *pnMin = 0x029702;
634 }
635
636 if (nAction & ACB_VOLATILE) {
637 memset(&ba, 0, sizeof(ba));
638
639 ba.Data = AllRam;
640 ba.nLen = RamEnd - AllRam;
641 ba.szName = "All Ram";
642 BurnAcb(&ba);
643
644 ZetScan(nAction);
645 AY8910Scan(nAction, pnMin);
646
647 SCAN_VAR(flipscreen);
648 SCAN_VAR(nmi_enable);
649 SCAN_VAR(soundlatch);
650 SCAN_VAR(palette_bank);
651 }
652
653 return 0;
654 }
655
656
657 // Joyful Road (Japan)
658
659 static struct BurnRomInfo joyfulrRomDesc[] = {
660 { "m1j.10e", 0x2000, 0x1fe86e25, 1 | BRF_PRG | BRF_ESS }, // 0 - Z80 #0 Code
661 { "m2j.10d", 0x2000, 0xb144b9a6, 1 | BRF_PRG | BRF_ESS }, // 1
662
663 { "mu.2j", 0x2000, 0x420adbd4, 2 | BRF_PRG | BRF_ESS }, // 2 - Z80 #1 Code
664
665 { "s1.10a", 0x1000, 0xc0bcc301, 3 | BRF_GRA }, // 3 - Characters
666 { "s2.10b", 0x1000, 0x96aa11ca, 3 | BRF_GRA }, // 4
667
668 { "b1.2c", 0x1000, 0x8ce3a403, 4 | BRF_GRA }, // 5 - Background Tile Map
669
670 { "b2.2b", 0x1000, 0x0df28913, 5 | BRF_GRA }, // 6 - Background Tiles
671
672 { "f1j.1g", 0x2000, 0x93c3c17e, 6 | BRF_GRA }, // 7 - Sprites
673 { "f2j.3g", 0x2000, 0xb3fb5bd2, 6 | BRF_GRA }, // 8
674 { "f3j.5g", 0x2000, 0x772a7527, 6 | BRF_GRA }, // 9
675 { "h", 0x2000, 0x332584de, 6 | BRF_GRA }, // 10 - Monochrome Sprites
676
677 { "a2001.clr", 0x0100, 0x1b16b907, 7 | BRF_GRA }, // 11 - Color PROMs
678 };
679
680 STD_ROM_PICK(joyfulr)
681 STD_ROM_FN(joyfulr)
682
683 struct BurnDriver BurnDrvJoyfulr = {
684 "joyfulr", NULL, NULL, NULL, "1983",
685 "Joyful Road (Japan)\0", NULL, "SNK", "Miscellaneous",
686 NULL, NULL, NULL, NULL,
687 BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 4, HARDWARE_MISC_PRE90S, GBF_RACING | GBF_ACTION, 0,
688 NULL, joyfulrRomInfo, joyfulrRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
689 DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x100,
690 240, 320, 3, 4
691 };
692
693
694 // Munch Mobile (US)
695
696 static struct BurnRomInfo mnchmoblRomDesc[] = {
697 { "m1.10e", 0x2000, 0xa4bebc6a, 1 | BRF_PRG | BRF_ESS }, // 0 - Z80 #0 Code
698 { "m2.10d", 0x2000, 0xf502d466, 1 | BRF_PRG | BRF_ESS }, // 1
699
700 { "mu.2j", 0x2000, 0x420adbd4, 2 | BRF_PRG | BRF_ESS }, // 2 - Z80 #1 Code
701
702 { "s1.10a", 0x1000, 0xc0bcc301, 3 | BRF_GRA }, // 3 - Characters
703 { "s2.10b", 0x1000, 0x96aa11ca, 3 | BRF_GRA }, // 4
704
705 { "b1.2c", 0x1000, 0x8ce3a403, 4 | BRF_GRA }, // 5 - Background Tile Map
706
707 { "b2.2b", 0x1000, 0x0df28913, 5 | BRF_GRA }, // 6 - Background Tiles
708
709 { "f1.1g", 0x2000, 0xb75411d4, 6 | BRF_GRA }, // 7 - Sprites
710 { "f2.3g", 0x2000, 0x539a43ba, 6 | BRF_GRA }, // 8
711 { "f3.5g", 0x2000, 0xec996706, 5 | BRF_GRA }, // 9
712 { "h", 0x2000, 0x332584de, 6 | BRF_GRA }, // 10 - Monochrome Sprites
713
714 { "a2001.clr", 0x0100, 0x1b16b907, 7 | BRF_GRA }, // 11 - Color PROMs
715 };
716
717 STD_ROM_PICK(mnchmobl)
718 STD_ROM_FN(mnchmobl)
719
720 struct BurnDriver BurnDrvMnchmobl = {
721 "mnchmobl", "joyfulr", NULL, NULL, "1983",
722 "Munch Mobile (US)\0", NULL, "SNK (Centuri license)", "Miscellaneous",
723 NULL, NULL, NULL, NULL,
724 BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_HISCORE_SUPPORTED, 4, HARDWARE_MISC_PRE90S, GBF_RACING | GBF_ACTION, 0,
725 NULL, mnchmoblRomInfo, mnchmoblRomName, NULL, NULL, NULL, NULL, DrvInputInfo, DrvDIPInfo,
726 DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x100,
727 240, 320, 3, 4
728 };
729