1 // FB Alpha '88 Games driver module
2 // Based on MAME driver by Nicola Salmoria
3
4 #include "tiles_generic.h"
5 #include "z80_intf.h"
6 #include "konami_intf.h"
7 #include "konamiic.h"
8 #include "burn_ym2151.h"
9 #include "upd7759.h"
10
11 static UINT8 *AllMem;
12 static UINT8 *MemEnd;
13 static UINT8 *AllRam;
14 static UINT8 *RamEnd;
15 static UINT8 *DrvKonROM;
16 static UINT8 *DrvZ80ROM;
17 static UINT8 *DrvGfxROM0;
18 static UINT8 *DrvGfxROM1;
19 static UINT8 *DrvGfxROM2;
20 static UINT8 *DrvGfxROMExp0;
21 static UINT8 *DrvGfxROMExp1;
22 static UINT8 *DrvGfxROMExp2;
23 static UINT8 *DrvSndROM0;
24 static UINT8 *DrvSndROM1;
25 static UINT8 *DrvBankRAM;
26 static UINT8 *DrvKonRAM;
27 static UINT8 *DrvPalRAM;
28 static UINT8 *DrvZ80RAM;
29 static UINT8 *DrvNVRAM;
30
31 static UINT32 *DrvPalette;
32 static UINT8 DrvRecalc;
33
34 static UINT8 *soundlatch;
35 static UINT8 *nDrvBank;
36
37 static INT32 videobank;
38 static INT32 zoomreadroms;
39 static INT32 k88games_priority;
40 static INT32 UPD7759Device;
41
42 static UINT8 DrvJoy1[8];
43 static UINT8 DrvJoy2[8];
44 static UINT8 DrvJoy3[8];
45 static UINT8 DrvDips[3];
46 static UINT8 DrvInputs[3];
47 static UINT8 DrvReset;
48
49 static struct BurnInputInfo games88InputList[] = {
50 {"P1 Coin", BIT_DIGITAL, DrvJoy1 + 0, "p1 coin" },
51 {"P1 Start", BIT_DIGITAL, DrvJoy2 + 3, "p1 start" },
52 {"P1 Button 1", BIT_DIGITAL, DrvJoy2 + 0, "p1 fire 1" },
53 {"P1 Button 2", BIT_DIGITAL, DrvJoy2 + 1, "p1 fire 2" },
54 {"P1 Button 3", BIT_DIGITAL, DrvJoy2 + 2, "p1 fire 3" },
55
56 {"P2 Coin", BIT_DIGITAL, DrvJoy1 + 1, "p2 coin" },
57 {"P2 Start", BIT_DIGITAL, DrvJoy2 + 7, "p2 start" },
58 {"P2 Button 1", BIT_DIGITAL, DrvJoy2 + 4, "p2 fire 1" },
59 {"P2 Button 2", BIT_DIGITAL, DrvJoy2 + 5, "p2 fire 2" },
60 {"P2 Button 3", BIT_DIGITAL, DrvJoy2 + 6, "p2 fire 3" },
61
62 {"P3 Start", BIT_DIGITAL, DrvJoy3 + 3, "p3 start" },
63 {"P3 Button 1", BIT_DIGITAL, DrvJoy3 + 0, "p3 fire 1" },
64 {"P3 Button 2", BIT_DIGITAL, DrvJoy3 + 1, "p3 fire 2" },
65 {"P3 Button 3", BIT_DIGITAL, DrvJoy3 + 2, "p3 fire 3" },
66
67 {"P4 Start", BIT_DIGITAL, DrvJoy3 + 7, "p4 start" },
68 {"P4 Button 1", BIT_DIGITAL, DrvJoy3 + 4, "p4 fire 1" },
69 {"P4 Button 2", BIT_DIGITAL, DrvJoy3 + 5, "p4 fire 2" },
70 {"P4 Button 3", BIT_DIGITAL, DrvJoy3 + 6, "p4 fire 3" },
71
72 {"Reset", BIT_DIGITAL, &DrvReset, "reset" },
73 {"Service", BIT_DIGITAL, DrvJoy1 + 2, "service" },
74 {"Dip A", BIT_DIPSWITCH, DrvDips + 0, "dip" },
75 {"Dip B", BIT_DIPSWITCH, DrvDips + 1, "dip" },
76 {"Dip C", BIT_DIPSWITCH, DrvDips + 2, "dip" },
77 };
78
79 STDINPUTINFO(games88)
80
81 static struct BurnDIPInfo games88DIPList[]=
82 {
83 DIP_OFFSET(0x14)
84 {0x00, 0xff, 0xff, 0xf0, NULL },
85 {0x01, 0xff, 0xff, 0xff, NULL },
86 {0x02, 0xff, 0xff, 0x7b, NULL },
87
88 // {0 , 0xfe, 0 , 2, "Flip Screen" },
89 // {0x00, 0x01, 0x10, 0x10, "Off" },
90 // {0x00, 0x01, 0x10, 0x00, "On" },
91
92 {0 , 0xfe, 0 , 2, "World Records" },
93 {0x00, 0x01, 0x20, 0x20, "Don't Erase" },
94 {0x00, 0x01, 0x20, 0x00, "Erase on Reset" },
95
96 {0 , 0xfe, 0 , 2, "Service Mode" },
97 {0x00, 0x01, 0x40, 0x40, "Off" },
98 {0x00, 0x01, 0x40, 0x00, "On" },
99
100 {0 , 0xfe, 0 , 16, "Coin A" },
101 {0x01, 0x01, 0x0f, 0x02, "4 Coins 1 Credit" },
102 {0x01, 0x01, 0x0f, 0x05, "3 Coins 1 Credit" },
103 {0x01, 0x01, 0x0f, 0x08, "2 Coins 1 Credit" },
104 {0x01, 0x01, 0x0f, 0x04, "3 Coins 2 Credits" },
105 {0x01, 0x01, 0x0f, 0x01, "4 Coins 3 Credits" },
106 {0x01, 0x01, 0x0f, 0x0f, "1 Coin 1 Credit" },
107 {0x01, 0x01, 0x0f, 0x03, "3 Coins 4 Credits" },
108 {0x01, 0x01, 0x0f, 0x07, "2 Coins 3 Credits" },
109 {0x01, 0x01, 0x0f, 0x0e, "1 Coin 2 Credits" },
110 {0x01, 0x01, 0x0f, 0x06, "2 Coins 5 Credits" },
111 {0x01, 0x01, 0x0f, 0x0d, "1 Coin 3 Credits" },
112 {0x01, 0x01, 0x0f, 0x0c, "1 Coin 4 Credits" },
113 {0x01, 0x01, 0x0f, 0x0b, "1 Coin 5 Credits" },
114 {0x01, 0x01, 0x0f, 0x0a, "1 Coin 6 Credits" },
115 {0x01, 0x01, 0x0f, 0x09, "1 Coin 7 Credits" },
116 {0x01, 0x01, 0x0f, 0x00, "Free Play" },
117
118 {0 , 0xfe, 0 , 16, "Coin B" },
119 {0x01, 0x01, 0xf0, 0x20, "4 Coins 1 Credit" },
120 {0x01, 0x01, 0xf0, 0x50, "3 Coins 1 Credit" },
121 {0x01, 0x01, 0xf0, 0x80, "2 Coins 1 Credit" },
122 {0x01, 0x01, 0xf0, 0x40, "3 Coins 2 Credits" },
123 {0x01, 0x01, 0xf0, 0x10, "4 Coins 3 Credits" },
124 {0x01, 0x01, 0xf0, 0xf0, "1 Coin 1 Credit" },
125 {0x01, 0x01, 0xf0, 0x30, "3 Coins 4 Credits" },
126 {0x01, 0x01, 0xf0, 0x70, "2 Coins 3 Credits" },
127 {0x01, 0x01, 0xf0, 0xe0, "1 Coin 2 Credits" },
128 {0x01, 0x01, 0xf0, 0x60, "2 Coins 5 Credits" },
129 {0x01, 0x01, 0xf0, 0xd0, "1 Coin 3 Credits" },
130 {0x01, 0x01, 0xf0, 0xc0, "1 Coin 4 Credits" },
131 {0x01, 0x01, 0xf0, 0xb0, "1 Coin 5 Credits" },
132 {0x01, 0x01, 0xf0, 0xa0, "1 Coin 6 Credits" },
133 {0x01, 0x01, 0xf0, 0x90, "1 Coin 7 Credits" },
134 {0x01, 0x01, 0xf0, 0x00, "No Coin B" },
135
136 // {0 , 0xfe, 0 , 4, "Cabinet" },
137 // {0x02, 0x01, 0x06, 0x06, "Cocktail" },
138 // {0x02, 0x01, 0x06, 0x04, "Cocktail (A)" },
139 // {0x02, 0x01, 0x06, 0x02, "Upright" },
140 // {0x02, 0x01, 0x06, 0x00, "Upright (D)" },
141
142 {0 , 0xfe, 0 , 4, "Difficulty" },
143 {0x02, 0x01, 0x60, 0x60, "Easy" },
144 {0x02, 0x01, 0x60, 0x40, "Normal" },
145 {0x02, 0x01, 0x60, 0x20, "Hard" },
146 {0x02, 0x01, 0x60, 0x00, "Hardest" },
147
148 {0 , 0xfe, 0 , 2, "Demo Sounds" },
149 {0x02, 0x01, 0x80, 0x80, "Off" },
150 {0x02, 0x01, 0x80, 0x00, "On" },
151 };
152
STDDIPINFO(games88)153 STDDIPINFO(games88)
154
155 static void games88_main_write(UINT16 address, UINT8 data)
156 {
157 switch (address)
158 {
159 case 0x5f84:
160 zoomreadroms = data & 0x04;
161 return;
162
163 case 0x5f88:
164 // watchdog
165 return;
166
167 case 0x5f8c:
168 *soundlatch = data;
169 return;
170
171 case 0x5f90:
172 ZetSetVector(0xff);
173 ZetSetIRQLine(0, CPU_IRQSTATUS_ACK);
174 return;
175 }
176
177 if ((address & 0xf800) == 0x3800)
178 {
179 if (videobank)
180 DrvBankRAM[address & 0x7ff] = data;
181 else
182 K051316Write(0, address & 0x7ff, data);
183
184 return;
185 }
186
187 if ((address & 0xfff0) == 0x5fc0) {
188 K051316WriteCtrl(0, address & 0x0f, data);
189 return;
190 }
191
192 if ((address & 0xc000) == 0x4000) {
193 K052109_051960_w(address & 0x3fff, data);
194 return;
195 }
196 }
197
games88_main_read(UINT16 address)198 static UINT8 games88_main_read(UINT16 address)
199 {
200 switch (address)
201 {
202 case 0x5f94:
203 return (DrvInputs[0] & 0x0f) | (DrvDips[0] & 0xf0);
204
205 case 0x5f95:
206 return DrvInputs[1];
207
208 case 0x5f96:
209 return DrvInputs[2];
210
211 case 0x5f97:
212 return DrvDips[1];
213
214 case 0x5f9b:
215 return DrvDips[2];
216 }
217
218 if ((address & 0xf800) == 0x3800)
219 {
220 if (videobank) {
221 return DrvBankRAM[address & 0x7ff];
222 } else {
223 if (zoomreadroms) {
224 return K051316ReadRom(0, address & 0x7ff);
225 } else {
226 return K051316Read(0, address & 0x7ff);
227 }
228 }
229 }
230
231 if ((address & 0xc000) == 0x4000) {
232 return K052109_051960_r(address & 0x3fff);
233 }
234
235 return 0;
236 }
237
games88_sound_write(UINT16 address,UINT8 data)238 static void __fastcall games88_sound_write(UINT16 address, UINT8 data)
239 {
240 switch (address)
241 {
242 case 0x9000:
243 UPD7759PortWrite(UPD7759Device, data);
244 return;
245
246 case 0xc000:
247 BurnYM2151SelectRegister(data);
248 return;
249
250 case 0xc001:
251 BurnYM2151WriteRegister(data);
252 return;
253
254 case 0xe000:
255 UPD7759Device = (data & 4) >> 2;
256 UPD7759ResetWrite(UPD7759Device, data & 2);
257 UPD7759StartWrite(UPD7759Device, data & 1);
258 return;
259 }
260 }
261
games88_sound_read(UINT16 address)262 static UINT8 __fastcall games88_sound_read(UINT16 address)
263 {
264 switch (address)
265 {
266 case 0xa000:
267 ZetSetIRQLine(0, CPU_IRQSTATUS_NONE);
268 return *soundlatch;
269
270 case 0xc000:
271 case 0xc001:
272 return BurnYM2151Read();
273 }
274
275 return 0;
276 }
277
games88_set_lines(INT32 lines)278 static void games88_set_lines(INT32 lines)
279 {
280 nDrvBank[0] = lines;
281
282 INT32 nBank = 0x10000 + (lines & 0x07) * 0x2000;
283
284 konamiMapMemory(DrvKonROM + nBank, 0x0000, 0x0fff, MAP_ROM);
285
286 if (lines & 8) {
287 konamiMapMemory(DrvPalRAM, 0x1000, 0x1fff, MAP_RAM);
288 } else {
289 konamiMapMemory(DrvKonROM + nBank + 0x1000, 0x1000, 0x1fff, MAP_ROM);
290 konamiMapMemory(DrvPalRAM, 0x1000, 0x1fff, MAP_WRITE);
291 }
292
293 videobank = lines & 0x10;
294 K052109RMRDLine = lines & 0x20;
295 k88games_priority = lines & 0x80;
296 }
297
K052109Callback(INT32 layer,INT32 bank,INT32 * code,INT32 * color,INT32 *,INT32 *)298 static void K052109Callback(INT32 layer, INT32 bank, INT32 *code, INT32 *color, INT32 *, INT32 *)
299 {
300 INT32 layer_colorbase[3] = { 64, 0, 16 };
301
302 *code |= ((*color & 0x0f) << 8) | (bank << 12);
303 *color = layer_colorbase[layer] + ((*color & 0xf0) >> 4);
304 }
305
K051960Callback(INT32 *,INT32 * color,INT32 * priority,INT32 *)306 static void K051960Callback(INT32 *, INT32 *color, INT32 *priority, INT32 *)
307 {
308 *priority = (*color & 0x20) >> 5;
309 *color = 32 + (*color & 0x0f);
310 }
311
K051316Callback(INT32 * code,INT32 * color,INT32 * flags)312 static void K051316Callback(INT32 *code,INT32 *color,INT32 *flags)
313 {
314 *flags = (*color & 0x40) ? 1 : 0;
315 *code |= ((*color & 0x07) << 8);
316 *color = 48 + ((*color & 0x38) >> 3) + ((*color & 0x80) >> 4);
317 }
318
DrvDoReset()319 static INT32 DrvDoReset()
320 {
321 DrvReset = 0;
322
323 memset (AllRam, 0, RamEnd - AllRam);
324
325 konamiOpen(0);
326 konamiReset();
327 konamiClose();
328
329 ZetOpen(0);
330 ZetReset();
331 ZetClose();
332
333 BurnYM2151Reset();
334
335 KonamiICReset();
336
337 UPD7759Reset();
338
339 videobank = 0;
340 zoomreadroms = 0;
341 k88games_priority = 0;
342 UPD7759Device = 0;
343
344 return 0;
345 }
346
MemIndex()347 static INT32 MemIndex()
348 {
349 UINT8 *Next; Next = AllMem;
350
351 DrvKonROM = Next; Next += 0x020000;
352 DrvZ80ROM = Next; Next += 0x010000;
353
354 DrvGfxROM0 = Next; Next += 0x080000;
355 DrvGfxROM1 = Next; Next += 0x100000;
356 DrvGfxROM2 = Next; Next += 0x040000;
357 DrvGfxROMExp0 = Next; Next += 0x100000;
358 DrvGfxROMExp1 = Next; Next += 0x200000;
359 DrvGfxROMExp2 = Next; Next += 0x080000;
360
361 DrvSndROM0 = Next; Next += 0x020000;
362 DrvSndROM1 = Next; Next += 0x020000;
363
364 DrvPalette = (UINT32*)Next; Next += 0x800 * sizeof(UINT32);
365
366 AllRam = Next;
367
368 DrvBankRAM = Next; Next += 0x000800;
369 DrvKonRAM = Next; Next += 0x001000;
370 DrvPalRAM = Next; Next += 0x001000;
371 DrvNVRAM = Next; Next += 0x000800;
372
373 DrvZ80RAM = Next; Next += 0x000800;
374
375 soundlatch = Next; Next += 0x000001;
376 nDrvBank = Next; Next += 0x000002;
377
378 RamEnd = Next;
379 MemEnd = Next;
380
381 return 0;
382 }
383
DrvInit()384 static INT32 DrvInit()
385 {
386 GenericTilesInit();
387
388 BurnAllocMemIndex();
389
390 {
391 if (BurnLoadRom(DrvKonROM + 0x008000, 0, 1)) return 1;
392 if (BurnLoadRom(DrvKonROM + 0x010000, 1, 1)) return 1;
393
394 if (BurnLoadRom(DrvZ80ROM + 0x000000, 2, 1)) return 1;
395
396 if (BurnLoadRom(DrvGfxROM0 + 0x000000, 3, 4)) return 1;
397 if (BurnLoadRom(DrvGfxROM0 + 0x000001, 4, 4)) return 1;
398 if (BurnLoadRom(DrvGfxROM0 + 0x000002, 5, 4)) return 1;
399 if (BurnLoadRom(DrvGfxROM0 + 0x000003, 6, 4)) return 1;
400 if (BurnLoadRom(DrvGfxROM0 + 0x040000, 7, 4)) return 1;
401 if (BurnLoadRom(DrvGfxROM0 + 0x040001, 8, 4)) return 1;
402 if (BurnLoadRom(DrvGfxROM0 + 0x040002, 9, 4)) return 1;
403 if (BurnLoadRom(DrvGfxROM0 + 0x040003, 10, 4)) return 1;
404
405 if (BurnLoadRom(DrvGfxROM1 + 0x000000, 11, 4)) return 1;
406 if (BurnLoadRom(DrvGfxROM1 + 0x000001, 12, 4)) return 1;
407 if (BurnLoadRom(DrvGfxROM1 + 0x000002, 13, 4)) return 1;
408 if (BurnLoadRom(DrvGfxROM1 + 0x000003, 14, 4)) return 1;
409 if (BurnLoadRom(DrvGfxROM1 + 0x040000, 15, 4)) return 1;
410 if (BurnLoadRom(DrvGfxROM1 + 0x040001, 16, 4)) return 1;
411 if (BurnLoadRom(DrvGfxROM1 + 0x040002, 17, 4)) return 1;
412 if (BurnLoadRom(DrvGfxROM1 + 0x040003, 18, 4)) return 1;
413 if (BurnLoadRom(DrvGfxROM1 + 0x080000, 19, 4)) return 1;
414 if (BurnLoadRom(DrvGfxROM1 + 0x080001, 20, 4)) return 1;
415 if (BurnLoadRom(DrvGfxROM1 + 0x080002, 21, 4)) return 1;
416 if (BurnLoadRom(DrvGfxROM1 + 0x080003, 22, 4)) return 1;
417 if (BurnLoadRom(DrvGfxROM1 + 0x0c0000, 23, 4)) return 1;
418 if (BurnLoadRom(DrvGfxROM1 + 0x0c0001, 24, 4)) return 1;
419 if (BurnLoadRom(DrvGfxROM1 + 0x0c0002, 25, 4)) return 1;
420 if (BurnLoadRom(DrvGfxROM1 + 0x0c0003, 26, 4)) return 1;
421
422 if (BurnLoadRom(DrvGfxROM2 + 0x000000, 27, 1)) return 1;
423 if (BurnLoadRom(DrvGfxROM2 + 0x010000, 28, 1)) return 1;
424 if (BurnLoadRom(DrvGfxROM2 + 0x020000, 29, 1)) return 1;
425 if (BurnLoadRom(DrvGfxROM2 + 0x030000, 30, 1)) return 1;
426
427 if (BurnLoadRom(DrvSndROM0 + 0x000000, 31, 1)) return 1;
428 if (BurnLoadRom(DrvSndROM0 + 0x010000, 32, 1)) return 1;
429
430 if (BurnLoadRom(DrvSndROM1 + 0x000000, 33, 1)) return 1;
431 if (BurnLoadRom(DrvSndROM1 + 0x010000, 34, 1)) return 1;
432
433 K052109GfxDecode(DrvGfxROM0, DrvGfxROMExp0, 0x080000);
434 K051960GfxDecode(DrvGfxROM1, DrvGfxROMExp1, 0x100000);
435 }
436
437 konamiInit(0);
438 konamiOpen(0);
439 konamiMapMemory(DrvPalRAM + 0x0000, 0x1000, 0x1fff, MAP_RAM);
440 konamiMapMemory(DrvKonRAM, 0x2000, 0x2fff, MAP_RAM);
441 konamiMapMemory(DrvNVRAM, 0x3000, 0x37ff, MAP_RAM);
442 konamiMapMemory(DrvKonROM + 0x8000, 0x8000, 0xffff, MAP_ROM);
443 konamiSetWriteHandler(games88_main_write);
444 konamiSetReadHandler(games88_main_read);
445 konamiSetlinesCallback(games88_set_lines);
446 konamiClose();
447
448 ZetInit(0);
449 ZetOpen(0);
450 ZetMapMemory(DrvZ80ROM, 0x0000, 0x7fff, MAP_ROM);
451 ZetMapMemory(DrvZ80RAM, 0x8000, 0x87ff, MAP_RAM);
452 ZetSetWriteHandler(games88_sound_write);
453 ZetSetReadHandler(games88_sound_read);
454 ZetClose();
455
456 BurnYM2151InitBuffered(3579545, 1, NULL, 0);
457 BurnTimerAttachZet(3579545);
458 BurnYM2151SetAllRoutes(0.75, BURN_SND_ROUTE_BOTH);
459
460 UPD7759Init(0, UPD7759_STANDARD_CLOCK, DrvSndROM0);
461 UPD7759Init(1, UPD7759_STANDARD_CLOCK, DrvSndROM1);
462 UPD7759SetRoute(0, 0.30, BURN_SND_ROUTE_BOTH);
463 UPD7759SetRoute(1, 0.30, BURN_SND_ROUTE_BOTH);
464 UPD7759SetSyncCallback(0, ZetTotalCycles, 3579545);
465 UPD7759SetSyncCallback(1, ZetTotalCycles, 3579545);
466
467 K052109Init(DrvGfxROM0, DrvGfxROMExp0, 0x7ffff);
468 K052109SetCallback(K052109Callback);
469 K052109AdjustScroll(0, 0);
470
471 K051960Init(DrvGfxROM1, DrvGfxROMExp1, 0xfffff);
472 K051960SetCallback(K051960Callback);
473 K051960SetSpriteOffset(0, 0);
474
475 K051316Init(0, DrvGfxROM2, DrvGfxROMExp2, 0x3ffff, K051316Callback, 4, 0);
476 K051316SetOffset(0, -104, -16);
477
478 DrvDoReset();
479
480 return 0;
481 }
482
DrvExit()483 static INT32 DrvExit()
484 {
485 GenericTilesExit();
486
487 KonamiICExit();
488
489 konamiExit();
490 ZetExit();
491
492 BurnYM2151Exit();
493 UPD7759Exit();
494
495 BurnFreeMemIndex();
496
497 return 0;
498 }
499
DrvDraw()500 static INT32 DrvDraw()
501 {
502 KonamiRecalcPalette(DrvPalRAM, DrvPalette, 0x1000);
503
504 K052109UpdateScroll();
505
506 if (k88games_priority)
507 {
508 if (nBurnLayer & 1) K052109RenderLayer(0, K052109_OPAQUE, 0);
509 if (nSpriteEnable & 1) K051960SpritesRender(1, 1);
510 if (nBurnLayer & 2) K052109RenderLayer(2, 0, 0);
511 if (nBurnLayer & 4) K052109RenderLayer(1, 0, 0);
512 if (nSpriteEnable & 2) K051960SpritesRender(0, 0);
513 if (nBurnLayer & 8) K051316_zoom_draw(0, 0);
514 }
515 else
516 {
517 if (nBurnLayer & 1) K052109RenderLayer(2, K052109_OPAQUE, 0);
518 if (nBurnLayer & 2) K051316_zoom_draw(0, 4);
519 if (nSpriteEnable & 1) K051960SpritesRender(0, 0);
520 if (nBurnLayer & 4) K052109RenderLayer(1, 0, 0);
521 if (nSpriteEnable & 2) K051960SpritesRender(1, 1);
522 if (nBurnLayer & 8) K052109RenderLayer(0, 0, 0);
523 }
524
525 KonamiBlendCopy(DrvPalette);
526
527 return 0;
528 }
529
DrvFrame()530 static INT32 DrvFrame()
531 {
532 if (DrvReset) {
533 DrvDoReset();
534 }
535
536 {
537 memset (DrvInputs, 0xff, 3);
538 for (INT32 i = 0; i < 8; i++) {
539 DrvInputs[0] ^= (DrvJoy1[i] & 1) << i;
540 DrvInputs[1] ^= (DrvJoy2[i] & 1) << i;
541 DrvInputs[2] ^= (DrvJoy3[i] & 1) << i;
542 }
543 }
544
545 konamiNewFrame();
546 ZetNewFrame();
547
548 INT32 nInterleave = 100;
549 INT32 nCyclesTotal[2] = { (((3000000 / 60) * 133) / 100) /* 33% overclock */, 3579545 / 60 };
550 INT32 nCyclesDone[2] = { 0, 0 };
551
552 ZetOpen(0);
553 konamiOpen(0);
554
555 for (INT32 i = 0; i < nInterleave; i++)
556 {
557 CPU_RUN(0, konami);
558 CPU_RUN_TIMER(1);
559 }
560
561 if (K052109_irq_enabled) konamiSetIrqLine(KONAMI_IRQ_LINE, CPU_IRQSTATUS_AUTO);
562
563 if (pBurnSoundOut) {
564 BurnYM2151Render(pBurnSoundOut, nBurnSoundLen);
565 UPD7759Render(pBurnSoundOut, nBurnSoundLen);
566 }
567
568 konamiClose();
569 ZetClose();
570
571 if (pBurnDraw) {
572 DrvDraw();
573 }
574
575 return 0;
576 }
577
DrvScan(INT32 nAction,INT32 * pnMin)578 static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
579 {
580 struct BurnArea ba;
581
582 if (pnMin) {
583 *pnMin = 0x029705;
584 }
585
586 if (nAction & ACB_VOLATILE) {
587 memset(&ba, 0, sizeof(ba));
588
589 ba.Data = AllRam;
590 ba.nLen = RamEnd - AllRam;
591 ba.szName = "All Ram";
592 BurnAcb(&ba);
593
594 konamiCpuScan(nAction);
595 ZetScan(nAction);
596
597 BurnYM2151Scan(nAction, pnMin);
598 UPD7759Scan(nAction, pnMin);
599
600 KonamiICScan(nAction);
601
602 SCAN_VAR(videobank);
603 SCAN_VAR(zoomreadroms);
604 SCAN_VAR(k88games_priority);
605 SCAN_VAR(UPD7759Device);
606 }
607
608 if (nAction & ACB_WRITE) {
609 konamiOpen(0);
610 games88_set_lines(nDrvBank[0]);
611 konamiClose();
612 }
613
614 return 0;
615 }
616
617
618 // '88 Games
619
620 static struct BurnRomInfo games88RomDesc[] = {
621 { "861m01.k18", 0x08000, 0x4a4e2959, 1 | BRF_PRG | BRF_ESS }, // 0 Konami Custom Cpu
622 { "861m02.k16", 0x10000, 0xe19f15f6, 1 | BRF_PRG | BRF_ESS }, // 1
623
624 { "861d01.d9", 0x08000, 0x0ff1dec0, 2 | BRF_PRG | BRF_ESS }, // 2 Z80 Code
625
626 { "861a08.a", 0x10000, 0x77a00dd6, 3 | BRF_GRA }, // 3 K052109 Tiles
627 { "861a08.c", 0x10000, 0xb422edfc, 3 | BRF_GRA }, // 4
628 { "861a09.a", 0x10000, 0xdf8917b6, 3 | BRF_GRA }, // 5
629 { "861a09.c", 0x10000, 0xf577b88f, 3 | BRF_GRA }, // 6
630 { "861a08.b", 0x10000, 0x28a8304f, 3 | BRF_GRA }, // 7
631 { "861a08.d", 0x10000, 0xe01a3802, 3 | BRF_GRA }, // 8
632 { "861a09.b", 0x10000, 0x4917158d, 3 | BRF_GRA }, // 9
633 { "861a09.d", 0x10000, 0x2bb3282c, 3 | BRF_GRA }, // 10
634
635 { "861a05.a", 0x10000, 0xcedc19d0, 4 | BRF_GRA }, // 11 K051960 Tiles
636 { "861a05.e", 0x10000, 0x725af3fc, 4 | BRF_GRA }, // 12
637 { "861a06.a", 0x10000, 0x85e2e30e, 4 | BRF_GRA }, // 13
638 { "861a06.e", 0x10000, 0x6f96651c, 4 | BRF_GRA }, // 14
639 { "861a05.b", 0x10000, 0xdb2a8808, 4 | BRF_GRA }, // 15
640 { "861a05.f", 0x10000, 0x32d830ca, 4 | BRF_GRA }, // 16
641 { "861a06.b", 0x10000, 0xce17eaf0, 4 | BRF_GRA }, // 17
642 { "861a06.f", 0x10000, 0x88310bf3, 4 | BRF_GRA }, // 18
643 { "861a05.c", 0x10000, 0xcf03c449, 4 | BRF_GRA }, // 19
644 { "861a05.g", 0x10000, 0xfd51c4ea, 4 | BRF_GRA }, // 20
645 { "861a06.c", 0x10000, 0xa568b34e, 4 | BRF_GRA }, // 21
646 { "861a06.g", 0x10000, 0x4a55beb3, 4 | BRF_GRA }, // 22
647 { "861a05.d", 0x10000, 0x97d78c77, 4 | BRF_GRA }, // 23
648 { "861a05.h", 0x10000, 0x60d0c8a5, 4 | BRF_GRA }, // 24
649 { "861a06.d", 0x10000, 0xbc70ab39, 4 | BRF_GRA }, // 25
650 { "861a06.h", 0x10000, 0xd906b79b, 4 | BRF_GRA }, // 26
651
652 { "861a04.a", 0x10000, 0x092a8b15, 5 | BRF_GRA }, // 27 K051316 Tiles
653 { "861a04.b", 0x10000, 0x75744b56, 5 | BRF_GRA }, // 28
654 { "861a04.c", 0x10000, 0xa00021c5, 5 | BRF_GRA }, // 29
655 { "861a04.d", 0x10000, 0xd208304c, 5 | BRF_GRA }, // 30
656
657 { "861a07.a", 0x10000, 0x5d035d69, 6 | BRF_SND }, // 31 UPD7759 #0 Samples
658 { "861a07.b", 0x10000, 0x6337dd91, 6 | BRF_SND }, // 32
659
660 { "861a07.c", 0x10000, 0x5067a38b, 7 | BRF_SND }, // 33 UPD7759 #1 Samples
661 { "861a07.d", 0x10000, 0x86731451, 7 | BRF_SND }, // 34
662
663 { "861.g3", 0x00100, 0x429785db, 0 | BRF_OPT }, // 31 Priority Prom
664 };
665
666 STD_ROM_PICK(games88)
667 STD_ROM_FN(games88)
668
669 struct BurnDriver BurnDrvgames88 = {
670 "88games", NULL, NULL, NULL, "1988",
671 "'88 Games\0", NULL, "Konami", "GX861",
672 NULL, NULL, NULL, NULL,
673 BDF_GAME_WORKING, 4, HARDWARE_PREFIX_KONAMI, GBF_SPORTSMISC, 0,
674 NULL, games88RomInfo, games88RomName, NULL, NULL, NULL, NULL, games88InputInfo, games88DIPInfo,
675 DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
676 304, 224, 4, 3
677 };
678
679
680 // Konami '88
681
682 static struct BurnRomInfo konami88RomDesc[] = {
683 { "861.e03", 0x08000, 0x55979bd9, 1 | BRF_PRG | BRF_ESS }, // 0 Konami Custom Cpu
684 { "861.e02", 0x10000, 0x5b7e98a6, 1 | BRF_PRG | BRF_ESS }, // 1
685
686 { "861d01.d9", 0x08000, 0x0ff1dec0, 2 | BRF_PRG | BRF_ESS }, // 2 Z80 Code
687
688 { "861a08.a", 0x10000, 0x77a00dd6, 3 | BRF_GRA }, // 3 K052109 Tiles
689 { "861a08.c", 0x10000, 0xb422edfc, 3 | BRF_GRA }, // 4
690 { "861a09.a", 0x10000, 0xdf8917b6, 3 | BRF_GRA }, // 5
691 { "861a09.c", 0x10000, 0xf577b88f, 3 | BRF_GRA }, // 6
692 { "861a08.b", 0x10000, 0x28a8304f, 3 | BRF_GRA }, // 7
693 { "861a08.d", 0x10000, 0xe01a3802, 3 | BRF_GRA }, // 8
694 { "861a09.b", 0x10000, 0x4917158d, 3 | BRF_GRA }, // 9
695 { "861a09.d", 0x10000, 0x2bb3282c, 3 | BRF_GRA }, // 10
696
697 { "861a05.a", 0x10000, 0xcedc19d0, 4 | BRF_GRA }, // 11 K051960 Tiles
698 { "861a05.e", 0x10000, 0x725af3fc, 4 | BRF_GRA }, // 12
699 { "861a06.a", 0x10000, 0x85e2e30e, 4 | BRF_GRA }, // 13
700 { "861a06.e", 0x10000, 0x6f96651c, 4 | BRF_GRA }, // 14
701 { "861a05.b", 0x10000, 0xdb2a8808, 4 | BRF_GRA }, // 15
702 { "861a05.f", 0x10000, 0x32d830ca, 4 | BRF_GRA }, // 16
703 { "861a06.b", 0x10000, 0xce17eaf0, 4 | BRF_GRA }, // 17
704 { "861a06.f", 0x10000, 0x88310bf3, 4 | BRF_GRA }, // 18
705 { "861a05.c", 0x10000, 0xcf03c449, 4 | BRF_GRA }, // 19
706 { "861a05.g", 0x10000, 0xfd51c4ea, 4 | BRF_GRA }, // 20
707 { "861a06.c", 0x10000, 0xa568b34e, 4 | BRF_GRA }, // 21
708 { "861a06.g", 0x10000, 0x4a55beb3, 4 | BRF_GRA }, // 22
709 { "861a05.d", 0x10000, 0x97d78c77, 4 | BRF_GRA }, // 23
710 { "861a05.h", 0x10000, 0x60d0c8a5, 4 | BRF_GRA }, // 24
711 { "861a06.d", 0x10000, 0xbc70ab39, 4 | BRF_GRA }, // 25
712 { "861a06.h", 0x10000, 0xd906b79b, 4 | BRF_GRA }, // 26
713
714 { "861a04.a", 0x10000, 0x092a8b15, 5 | BRF_GRA }, // 27 K051316 Tiles
715 { "861a04.b", 0x10000, 0x75744b56, 5 | BRF_GRA }, // 28
716 { "861a04.c", 0x10000, 0xa00021c5, 5 | BRF_GRA }, // 29
717 { "861a04.d", 0x10000, 0xd208304c, 5 | BRF_GRA }, // 30
718
719 { "861a07.a", 0x10000, 0x5d035d69, 6 | BRF_SND }, // 31 UPD7759 #0 Samples
720 { "861a07.b", 0x10000, 0x6337dd91, 6 | BRF_SND }, // 32
721
722 { "861a07.c", 0x10000, 0x5067a38b, 7 | BRF_SND }, // 33 UPD7759 #1 Samples
723 { "861a07.d", 0x10000, 0x86731451, 7 | BRF_SND }, // 34
724
725 { "861.g3", 0x00100, 0x429785db, 0 | BRF_OPT }, // 31 Priority Prom
726 };
727
728 STD_ROM_PICK(konami88)
729 STD_ROM_FN(konami88)
730
731 struct BurnDriver BurnDrvKonami88 = {
732 "konami88", "88games", NULL, NULL, "1988",
733 "Konami '88\0", NULL, "Konami", "GX861",
734 NULL, NULL, NULL, NULL,
735 BDF_GAME_WORKING | BDF_CLONE, 4, HARDWARE_PREFIX_KONAMI, GBF_SPORTSMISC, 0,
736 NULL, konami88RomInfo, konami88RomName, NULL, NULL, NULL, NULL, games88InputInfo, games88DIPInfo,
737 DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
738 304, 224, 4, 3
739 };
740
741
742 // Hyper Sports Special (Japan)
743
744 static struct BurnRomInfo hypsptspRomDesc[] = {
745 { "861f03.k18", 0x08000, 0x8c61aebd, 1 | BRF_PRG | BRF_ESS }, // 0 Konami Custom Cpu
746 { "861f02.k16", 0x10000, 0xd2460c28, 1 | BRF_PRG | BRF_ESS }, // 1
747
748 { "861d01.d9", 0x08000, 0x0ff1dec0, 2 | BRF_PRG | BRF_ESS }, // 2 Z80 Code
749
750 { "861a08.a", 0x10000, 0x77a00dd6, 3 | BRF_GRA }, // 3 K052109 Tiles
751 { "861a08.c", 0x10000, 0xb422edfc, 3 | BRF_GRA }, // 4
752 { "861a09.a", 0x10000, 0xdf8917b6, 3 | BRF_GRA }, // 5
753 { "861a09.c", 0x10000, 0xf577b88f, 3 | BRF_GRA }, // 6
754 { "861a08.b", 0x10000, 0x28a8304f, 3 | BRF_GRA }, // 7
755 { "861a08.d", 0x10000, 0xe01a3802, 3 | BRF_GRA }, // 8
756 { "861a09.b", 0x10000, 0x4917158d, 3 | BRF_GRA }, // 9
757 { "861a09.d", 0x10000, 0x2bb3282c, 3 | BRF_GRA }, // 10
758
759 { "861a05.a", 0x10000, 0xcedc19d0, 4 | BRF_GRA }, // 11 K051960 Tiles
760 { "861a05.e", 0x10000, 0x725af3fc, 4 | BRF_GRA }, // 12
761 { "861a06.a", 0x10000, 0x85e2e30e, 4 | BRF_GRA }, // 13
762 { "861a06.e", 0x10000, 0x6f96651c, 4 | BRF_GRA }, // 14
763 { "861a05.b", 0x10000, 0xdb2a8808, 4 | BRF_GRA }, // 15
764 { "861a05.f", 0x10000, 0x32d830ca, 4 | BRF_GRA }, // 16
765 { "861a06.b", 0x10000, 0xce17eaf0, 4 | BRF_GRA }, // 17
766 { "861a06.f", 0x10000, 0x88310bf3, 4 | BRF_GRA }, // 18
767 { "861a05.c", 0x10000, 0xcf03c449, 4 | BRF_GRA }, // 19
768 { "861a05.g", 0x10000, 0xfd51c4ea, 4 | BRF_GRA }, // 20
769 { "861a06.c", 0x10000, 0xa568b34e, 4 | BRF_GRA }, // 21
770 { "861a06.g", 0x10000, 0x4a55beb3, 4 | BRF_GRA }, // 22
771 { "861a05.d", 0x10000, 0x97d78c77, 4 | BRF_GRA }, // 23
772 { "861a05.h", 0x10000, 0x60d0c8a5, 4 | BRF_GRA }, // 24
773 { "861a06.d", 0x10000, 0xbc70ab39, 4 | BRF_GRA }, // 25
774 { "861a06.h", 0x10000, 0xd906b79b, 4 | BRF_GRA }, // 26
775
776 { "861a04.a", 0x10000, 0x092a8b15, 5 | BRF_GRA }, // 27 K051316 Tiles
777 { "861a04.b", 0x10000, 0x75744b56, 5 | BRF_GRA }, // 28
778 { "861a04.c", 0x10000, 0xa00021c5, 5 | BRF_GRA }, // 29
779 { "861a04.d", 0x10000, 0xd208304c, 5 | BRF_GRA }, // 30
780
781 { "861a07.a", 0x10000, 0x5d035d69, 6 | BRF_SND }, // 31 UPD7759 #0 Samples
782 { "861a07.b", 0x10000, 0x6337dd91, 6 | BRF_SND }, // 32
783
784 { "861a07.c", 0x10000, 0x5067a38b, 7 | BRF_SND }, // 33 UPD7759 #1 Samples
785 { "861a07.d", 0x10000, 0x86731451, 7 | BRF_SND }, // 34
786
787 { "861.g3", 0x00100, 0x429785db, 8 | BRF_OPT }, // 31 Priority Prom
788 };
789
790 STD_ROM_PICK(hypsptsp)
791 STD_ROM_FN(hypsptsp)
792
793 struct BurnDriver BurnDrvHypsptsp = {
794 "hypsptsp", "88games", NULL, NULL, "1988",
795 "Hyper Sports Special (Japan)\0", NULL, "Konami", "GX861",
796 NULL, NULL, NULL, NULL,
797 BDF_GAME_WORKING | BDF_CLONE, 4, HARDWARE_PREFIX_KONAMI, GBF_SPORTSMISC, 0,
798 NULL, hypsptspRomInfo, hypsptspRomName, NULL, NULL, NULL, NULL, games88InputInfo, games88DIPInfo,
799 DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x800,
800 304, 224, 4, 3
801 };
802