1 // FB Alpha Flack Attack driver module
2 // Based on MAME driver by Manuel Abadia
3
4 #include "tiles_generic.h"
5 #include "hd6309_intf.h"
6 #include "z80_intf.h"
7 #include "k007121.h"
8 #include "burn_ym2151.h"
9 #include "k007232.h"
10 #include "watchdog.h"
11
12 static UINT8 *AllMem;
13 static UINT8 *MemEnd;
14 static UINT8 *AllRam;
15 static UINT8 *RamEnd;
16 static UINT8 *DrvHD6309ROM;
17 static UINT8 *DrvZ80ROM;
18 static UINT8 *DrvGfxROM;
19 static UINT8 *DrvSndROM;
20 static UINT8 *DrvZ80RAM;
21 static UINT8 *DrvHD6309RAM;
22 static UINT8 *DrvPalRAM;
23 static UINT8 *DrvVidRAM0;
24 static UINT8 *DrvVidRAM1;
25 static UINT8 *DrvSprRAM;
26 static UINT8 *DrvSprBUF;
27
28 static UINT32 *DrvPalette;
29 static UINT8 DrvRecalc;
30
31 static INT32 multiply_register[2];
32 static UINT8 main_bank;
33 static UINT8 soundlatch;
34 static UINT8 flipscreen;
35
36 static INT32 nExtraCycles;
37
38 static UINT8 DrvJoy1[8];
39 static UINT8 DrvJoy2[8];
40 static UINT8 DrvJoy3[8];
41 static UINT8 DrvDips[3];
42 static UINT8 DrvInputs[3];
43 static UINT8 DrvReset;
44
45 static struct BurnInputInfo FlkatckInputList[] = {
46 {"P1 Coin", BIT_DIGITAL, DrvJoy1 + 0, "p1 coin" },
47 {"P1 Start", BIT_DIGITAL, DrvJoy1 + 3, "p1 start" },
48 {"P1 Up", BIT_DIGITAL, DrvJoy2 + 2, "p1 up" },
49 {"P1 Down", BIT_DIGITAL, DrvJoy2 + 3, "p1 down" },
50 {"P1 Left", BIT_DIGITAL, DrvJoy2 + 0, "p1 left" },
51 {"P1 Right", BIT_DIGITAL, DrvJoy2 + 1, "p1 right" },
52 {"P1 Button 1", BIT_DIGITAL, DrvJoy2 + 4, "p1 fire 1" },
53 {"P1 Button 2", BIT_DIGITAL, DrvJoy2 + 5, "p1 fire 2" },
54
55 {"P2 Coin", BIT_DIGITAL, DrvJoy1 + 1, "p2 coin" },
56 {"P2 Start", BIT_DIGITAL, DrvJoy1 + 4, "p2 start" },
57 {"P2 Up", BIT_DIGITAL, DrvJoy3 + 2, "p2 up" },
58 {"P2 Down", BIT_DIGITAL, DrvJoy3 + 3, "p2 down" },
59 {"P2 Left", BIT_DIGITAL, DrvJoy3 + 0, "p2 left" },
60 {"P2 Right", BIT_DIGITAL, DrvJoy3 + 1, "p2 right" },
61 {"P2 Button 1", BIT_DIGITAL, DrvJoy3 + 4, "p2 fire 1" },
62 {"P2 Button 2", BIT_DIGITAL, DrvJoy3 + 5, "p2 fire 2" },
63
64 {"Reset", BIT_DIGITAL, &DrvReset, "reset" },
65 {"Service", BIT_DIGITAL, DrvJoy1 + 2, "service" },
66 {"Dip A", BIT_DIPSWITCH, DrvDips + 0, "dip" },
67 {"Dip B", BIT_DIPSWITCH, DrvDips + 1, "dip" },
68 {"Dip C", BIT_DIPSWITCH, DrvDips + 2, "dip" },
69 };
70
71 STDINPUTINFO(Flkatck)
72
73 static struct BurnDIPInfo FlkatckDIPList[]=
74 {
75 {0x12, 0xff, 0xff, 0xff, NULL },
76 {0x13, 0xff, 0xff, 0x51, NULL },
77 {0x14, 0xff, 0xff, 0xff, NULL },
78
79 {0 , 0xfe, 0 , 16, "Coin A" },
80 {0x12, 0x01, 0x0f, 0x02, "4 Coins 1 Credits" },
81 {0x12, 0x01, 0x0f, 0x05, "3 Coins 1 Credits" },
82 {0x12, 0x01, 0x0f, 0x08, "2 Coins 1 Credits" },
83 {0x12, 0x01, 0x0f, 0x04, "3 Coins 2 Credits" },
84 {0x12, 0x01, 0x0f, 0x01, "4 Coins 3 Credits" },
85 {0x12, 0x01, 0x0f, 0x0f, "1 Coin 1 Credits" },
86 {0x12, 0x01, 0x0f, 0x03, "3 Coins 4 Credits" },
87 {0x12, 0x01, 0x0f, 0x07, "2 Coins 3 Credits" },
88 {0x12, 0x01, 0x0f, 0x0e, "1 Coin 2 Credits" },
89 {0x12, 0x01, 0x0f, 0x06, "2 Coins 5 Credits" },
90 {0x12, 0x01, 0x0f, 0x0d, "1 Coin 3 Credits" },
91 {0x12, 0x01, 0x0f, 0x0c, "1 Coin 4 Credits" },
92 {0x12, 0x01, 0x0f, 0x0b, "1 Coin 5 Credits" },
93 {0x12, 0x01, 0x0f, 0x0a, "1 Coin 6 Credits" },
94 {0x12, 0x01, 0x0f, 0x09, "1 Coin 7 Credits" },
95 {0x12, 0x01, 0x0f, 0x00, "Free Play" },
96
97 {0 , 0xfe, 0 , 16, "Coin B" },
98 {0x12, 0x01, 0xf0, 0x20, "4 Coins 1 Credits" },
99 {0x12, 0x01, 0xf0, 0x50, "3 Coins 1 Credits" },
100 {0x12, 0x01, 0xf0, 0x80, "2 Coins 1 Credits" },
101 {0x12, 0x01, 0xf0, 0x40, "3 Coins 2 Credits" },
102 {0x12, 0x01, 0xf0, 0x10, "4 Coins 3 Credits" },
103 {0x12, 0x01, 0xf0, 0xf0, "1 Coin 1 Credits" },
104 {0x12, 0x01, 0xf0, 0x30, "3 Coins 4 Credits" },
105 {0x12, 0x01, 0xf0, 0x70, "2 Coins 3 Credits" },
106 {0x12, 0x01, 0xf0, 0xe0, "1 Coin 2 Credits" },
107 {0x12, 0x01, 0xf0, 0x60, "2 Coins 5 Credits" },
108 {0x12, 0x01, 0xf0, 0xd0, "1 Coin 3 Credits" },
109 {0x12, 0x01, 0xf0, 0xc0, "1 Coin 4 Credits" },
110 {0x12, 0x01, 0xf0, 0xb0, "1 Coin 5 Credits" },
111 {0x12, 0x01, 0xf0, 0xa0, "1 Coin 6 Credits" },
112 {0x12, 0x01, 0xf0, 0x90, "1 Coin 7 Credits" },
113 {0x12, 0x01, 0xf0, 0x00, "Invalid" },
114
115 {0 , 0xfe, 0 , 4, "Lives" },
116 {0x13, 0x01, 0x03, 0x03, "1" },
117 {0x13, 0x01, 0x03, 0x02, "2" },
118 {0x13, 0x01, 0x03, 0x01, "3" },
119 {0x13, 0x01, 0x03, 0x00, "5" },
120
121 {0 , 0xfe, 0 , 2, "Cabinet" },
122 {0x13, 0x01, 0x04, 0x00, "Upright" },
123 {0x13, 0x01, 0x04, 0x04, "Cocktail" },
124
125 {0 , 0xfe, 0 , 4, "Bonus Life" },
126 {0x13, 0x01, 0x18, 0x18, "30K, Every 70K" },
127 {0x13, 0x01, 0x18, 0x10, "40K, Every 80K" },
128 {0x13, 0x01, 0x18, 0x08, "30K Only" },
129 {0x13, 0x01, 0x18, 0x00, "40K Only" },
130
131 {0 , 0xfe, 0 , 4, "Difficulty" },
132 {0x13, 0x01, 0x60, 0x60, "Easy" },
133 {0x13, 0x01, 0x60, 0x40, "Normal" },
134 {0x13, 0x01, 0x60, 0x20, "Difficult" },
135 {0x13, 0x01, 0x60, 0x00, "Very Difficult" },
136
137 {0 , 0xfe, 0 , 2, "Demo Sounds" },
138 {0x13, 0x01, 0x80, 0x80, "Off" },
139 {0x13, 0x01, 0x80, 0x00, "On" },
140
141 {0 , 0xfe, 0 , 2, "Flip Screen" },
142 {0x14, 0x01, 0x01, 0x01, "Off" },
143 {0x14, 0x01, 0x01, 0x00, "On" },
144
145 {0 , 0xfe, 0 , 2, "Upright Controls" },
146 {0x14, 0x01, 0x02, 0x02, "Single" },
147 {0x14, 0x01, 0x02, 0x00, "Dual" },
148
149 {0 , 0xfe, 0 , 2, "Service Mode" },
150 {0x14, 0x01, 0x04, 0x04, "Off" },
151 {0x14, 0x01, 0x04, 0x00, "On" },
152 };
153
STDDIPINFO(Flkatck)154 STDDIPINFO(Flkatck)
155
156
157
158 static void bankswitch(INT32 data)
159 {
160 if ((data & 0x03) < 3) {
161 main_bank = data & 3;
162
163 HD6309MapMemory(DrvHD6309ROM + (main_bank * 0x2000), 0x4000, 0x5fff, MAP_ROM);
164 }
165 }
166
flkatck_main_read(UINT16 address)167 static UINT8 flkatck_main_read(UINT16 address)
168 {
169 switch (address)
170 {
171 case 0x0400:
172 return DrvInputs[1];
173
174 case 0x0401:
175 return DrvInputs[2];
176
177 case 0x0402:
178 return DrvDips[2]; // dsw3
179
180 case 0x0403:
181 return DrvInputs[0];
182
183 case 0x0406:
184 return DrvDips[1];
185
186 case 0x0407:
187 return DrvDips[0];
188 }
189
190 return 0;
191 }
192
flkatck_main_write(UINT16 address,UINT8 data)193 static void flkatck_main_write(UINT16 address, UINT8 data)
194 {
195 if ((address & 0xfff8) == 0x0000) {
196 k007121_ctrl_write(0, address & 7, data);
197 }
198
199 if (address < 0x100) {
200 DrvHD6309RAM[address] = data;
201 return;
202 }
203
204 switch (address & ~3)
205 {
206 case 0x0410:
207 bankswitch(data); // and coin counters - data & 0x18
208 return;
209
210 case 0x0414:
211 soundlatch = data;
212 return;
213
214 case 0x0418:
215 ZetSetIRQLine(0, CPU_IRQSTATUS_HOLD);
216 return;
217
218 case 0x041c:
219 BurnWatchdogWrite();
220 return;
221 }
222 }
223
flkatck_sound_write(UINT16 address,UINT8 data)224 static void __fastcall flkatck_sound_write(UINT16 address, UINT8 data)
225 {
226 switch (address)
227 {
228 case 0x9000:
229 case 0x9001:
230 multiply_register[address & 1] = data;
231 return;
232
233 case 0x9006:
234 return;
235
236 case 0xb000:
237 case 0xb001:
238 case 0xb002:
239 case 0xb003:
240 case 0xb004:
241 case 0xb005:
242 case 0xb006:
243 case 0xb007:
244 case 0xb008:
245 case 0xb009:
246 case 0xb00a:
247 case 0xb00b:
248 case 0xb00c:
249 case 0xb00d:
250 K007232WriteReg(0, address & 0x0f, data);
251 return;
252
253 case 0xc000:
254 case 0xc001:
255 BurnYM2151Write(address & 1, data);
256 return;
257 }
258 }
259
flkatck_sound_read(UINT16 address)260 static UINT8 __fastcall flkatck_sound_read(UINT16 address)
261 {
262 switch (address)
263 {
264 case 0x9000:
265 return (multiply_register[0] * multiply_register[1]) & 0xff;
266
267 case 0x9001:
268 case 0x9004:
269 return 0;
270
271 case 0xa000:
272 return soundlatch;
273
274 case 0xb000:
275 case 0xb001:
276 case 0xb002:
277 case 0xb003:
278 case 0xb004:
279 case 0xb005:
280 case 0xb006:
281 case 0xb007:
282 case 0xb008:
283 case 0xb009:
284 case 0xb00a:
285 case 0xb00b:
286 case 0xb00c:
287 case 0xb00d:
288 return K007232ReadReg(0, address & 0x0f);
289
290 case 0xc000:
291 case 0xc001:
292 return BurnYM2151Read();
293 }
294
295 return 0;
296 }
297
tilemap_callback(bg)298 static tilemap_callback( bg )
299 {
300 UINT8 ctrl_0 = k007121_ctrl_read(0,0);
301 UINT8 ctrl_2 = k007121_ctrl_read(0,2);
302 UINT8 ctrl_3 = k007121_ctrl_read(0,3);
303 UINT8 ctrl_4 = k007121_ctrl_read(0,4);
304 UINT8 ctrl_5 = k007121_ctrl_read(0,5);
305 UINT8 attr = DrvVidRAM0[offs];
306 INT32 bit0 = (ctrl_5 >> 0) & 0x03;
307 INT32 bit1 = (ctrl_5 >> 2) & 0x03;
308 INT32 bit2 = (ctrl_5 >> 4) & 0x03;
309 INT32 bit3 = (ctrl_5 >> 6) & 0x03;
310 INT32 bank = ((attr & 0x80) >> 7) |
311 ((attr >> (bit0 + 2)) & 0x02) |
312 ((attr >> (bit1 + 1)) & 0x04) |
313 ((attr >> (bit2 )) & 0x08) |
314 ((attr >> (bit3 - 1)) & 0x10) |
315 ((ctrl_3 & 0x01) << 5);
316 INT32 mask = (ctrl_4 & 0xf0) >> 4;
317
318 bank = (bank & ~(mask << 1)) | ((ctrl_4 & mask) << 1);
319
320 if ((attr == 0x0d) && (!ctrl_0) && (!ctrl_2))
321 bank = 0;
322
323 TILE_SET_INFO(0, DrvVidRAM0[offs + 0x400] + (bank * 256), (attr & 0x0f) + 16, (attr & 0x20) ? TILE_FLIPY : 0);
324 }
325
tilemap_callback(fg)326 static tilemap_callback( fg )
327 {
328 TILE_SET_INFO(0, DrvVidRAM1[offs + 0x400], DrvVidRAM1[offs], 0);
329 }
330
DrvK007232VolCallback(INT32 v)331 static void DrvK007232VolCallback(INT32 v)
332 {
333 K007232SetVolume(0, 0, (v >> 4) * 0x11, 0);
334 K007232SetVolume(0, 1, 0, (v & 0x0f) * 0x11);
335 }
336
DrvDoReset(INT32 clear_mem)337 static INT32 DrvDoReset(INT32 clear_mem)
338 {
339 if (clear_mem) {
340 memset (AllRam, 0, RamEnd - AllRam);
341 }
342
343 HD6309Open(0);
344 bankswitch(0);
345 HD6309Reset();
346 HD6309Close();
347
348 ZetOpen(0);
349 ZetReset();
350 ZetClose();
351
352 BurnYM2151Reset();
353 K007232Reset(0);
354 k007232_set_bank(0, 0, 1);
355
356 k007121_reset();
357
358 BurnWatchdogReset();
359
360 multiply_register[0] = 0;
361 multiply_register[1] = 0;
362 flipscreen = 0;
363 soundlatch = 0;
364
365 nExtraCycles = 0;
366
367 return 0;
368 }
369
MemIndex()370 static INT32 MemIndex()
371 {
372 UINT8 *Next; Next = AllMem;
373
374 DrvHD6309ROM = Next; Next += 0x010000;
375 DrvZ80ROM = Next; Next += 0x008000;
376
377 DrvGfxROM = Next; Next += 0x100000;
378
379 DrvSndROM = Next; Next += 0x040000;
380
381 DrvPalette = (UINT32*)Next; Next += 0x200 * sizeof(UINT32);
382
383 AllRam = Next;
384
385 DrvZ80RAM = Next; Next += 0x000800;
386
387 DrvHD6309RAM = Next; Next += 0x004000;
388 DrvPalRAM = Next; Next += 0x000400;
389 DrvVidRAM0 = Next; Next += 0x000800;
390 DrvVidRAM1 = Next; Next += 0x000800;
391 DrvSprRAM = Next; Next += 0x000800;
392 DrvSprBUF = Next; Next += 0x000800;
393
394 RamEnd = Next;
395 MemEnd = Next;
396
397 return 0;
398 }
399
graphics_expand()400 static void graphics_expand()
401 {
402 for (INT32 i = 0x80000-1; i >= 0; i--)
403 {
404 DrvGfxROM[i*2+1] = DrvGfxROM[i^1] & 0xf;
405 DrvGfxROM[i*2+0] = DrvGfxROM[i^1] >> 4;
406 }
407 }
408
DrvInit(INT32 rom_layout)409 static INT32 DrvInit(INT32 rom_layout)
410 {
411 AllMem = NULL;
412 MemIndex();
413 INT32 nLen = MemEnd - (UINT8 *)0;
414 if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
415 memset(AllMem, 0, nLen);
416 MemIndex();
417
418 {
419 if (BurnLoadRom(DrvHD6309ROM + 0x00000, 0, 1)) return 1;
420
421 if (BurnLoadRom(DrvZ80ROM + 0x00000, 1, 1)) return 1;
422
423 if (BurnLoadRom(DrvSndROM + 0x00000, 2, 1)) return 1;
424
425 if (rom_layout == 0)
426 {
427 if (BurnLoadRom(DrvGfxROM + 0x00000, 3, 1)) return 1;
428 }
429 else
430 {
431 if (BurnLoadRom(DrvGfxROM + 0x00001, 3, 2)) return 1;
432 if (BurnLoadRom(DrvGfxROM + 0x00000, 4, 2)) return 1;
433 if (BurnLoadRom(DrvGfxROM + 0x20001, 5, 2)) return 1;
434 if (BurnLoadRom(DrvGfxROM + 0x20000, 6, 2)) return 1;
435 if (BurnLoadRom(DrvGfxROM + 0x40001, 7, 2)) return 1;
436 if (BurnLoadRom(DrvGfxROM + 0x40000, 8, 2)) return 1;
437 if (BurnLoadRom(DrvGfxROM + 0x60001, 9, 2)) return 1;
438 if (BurnLoadRom(DrvGfxROM + 0x60000, 10, 2)) return 1;
439 }
440
441 graphics_expand();
442 }
443
444 HD6309Init(1);
445 HD6309Open(0);
446 HD6309MapMemory(DrvHD6309RAM, 0x0000, 0x00ff, MAP_ROM); // write through handler
447 HD6309MapMemory(DrvHD6309RAM + 0x0100, 0x0100, 0x03ff, MAP_RAM);
448 HD6309MapMemory(DrvPalRAM, 0x0800, 0x0bff, MAP_RAM);
449 HD6309MapMemory(DrvHD6309RAM + 0x1000, 0x1000, 0x17ff, MAP_RAM);
450 HD6309MapMemory(DrvSprBUF, 0x1800, 0x1fff, MAP_RAM);
451 HD6309MapMemory(DrvVidRAM0, 0x2000, 0x27ff, MAP_RAM);
452 HD6309MapMemory(DrvVidRAM1, 0x2800, 0x2fff, MAP_RAM);
453 HD6309MapMemory(DrvHD6309RAM + 0x3000, 0x3000, 0x3fff, MAP_RAM);
454 HD6309MapMemory(DrvHD6309ROM + 0x6000, 0x6000, 0xffff, MAP_ROM);
455 HD6309SetWriteHandler(flkatck_main_write);
456 HD6309SetReadHandler(flkatck_main_read);
457 HD6309Close();
458
459 ZetInit(0);
460 ZetOpen(0);
461 ZetMapMemory(DrvZ80ROM, 0x0000, 0x7fff, MAP_RAM);
462 ZetMapMemory(DrvZ80RAM, 0x8000, 0x87ff, MAP_RAM);
463 ZetSetWriteHandler(flkatck_sound_write);
464 ZetSetReadHandler(flkatck_sound_read);
465 ZetClose();
466
467 BurnWatchdogInit(DrvDoReset, 180);
468
469 BurnYM2151Init(3579545);
470 BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT);
471 BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT);
472
473 K007232Init(0, 3579545, DrvSndROM, 0x40000);
474 K007232SetPortWriteHandler(0, DrvK007232VolCallback);
475 K007232PCMSetAllRoutes(0, 0.35, BURN_SND_ROUTE_BOTH);
476
477 GenericTilesInit();
478 GenericTilemapInit(0, TILEMAP_SCAN_ROWS, bg_map_callback, 8, 8, 32, 32);
479 GenericTilemapInit(1, TILEMAP_SCAN_ROWS, fg_map_callback, 8, 8, 32, 32);
480 GenericTilemapSetGfx(0, DrvGfxROM, 4, 8, 8, 0x100000, 0x100, 0xf);
481 GenericTilemapSetOffsets(TMAP_GLOBAL, 0, -16);
482
483 k007121_init(0, (0x100000 / (8 * 8)) - 1);
484
485 DrvDoReset(1);
486
487 return 0;
488 }
489
DrvExit()490 static INT32 DrvExit()
491 {
492 GenericTilesExit();
493
494 HD6309Exit();
495 ZetExit();
496
497 K007232Exit();
498 BurnYM2151Exit();
499
500 BurnFree (AllMem);
501
502 return 0;
503 }
504
DrvPaletteUpdate()505 static void DrvPaletteUpdate()
506 {
507 for (INT32 i = 0; i < 0x400; i+=2)
508 {
509 UINT16 p = (DrvPalRAM[i+1] * 256) + DrvPalRAM[i];
510
511 UINT8 r = (p & 0x1f);
512 UINT8 g = (p >> 5) & 0x1f;
513 UINT8 b = (p >> 10) & 0x1f;
514
515 r = (r << 3) | (r >> 2);
516 g = (g << 3) | (g >> 2);
517 b = (b << 3) | (b >> 2);
518
519 DrvPalette[i/2] = BurnHighCol(r,g,b,0);
520 }
521 }
522
DrvDraw()523 static INT32 DrvDraw()
524 {
525 if (DrvRecalc) {
526 DrvPaletteUpdate();
527 DrvRecalc = 1;
528 }
529
530 GenericTilemapSetScrollX(0, k007121_ctrl_read(0, 0) - 40);
531 GenericTilemapSetScrollY(0, k007121_ctrl_read(0, 2));
532
533 BurnTransferClear();
534
535 if (nBurnLayer & 1) GenericTilemapDraw(0, pTransDraw, 0);
536
537 if (nSpriteEnable & 1) k007121_draw(0, pTransDraw, DrvGfxROM, NULL, DrvSprRAM, 0, 40, 16, 0, -1, 0x0000);
538
539 GenericTilesSetClip(-1, 40, -1, -1);
540 if (nBurnLayer & 2) GenericTilemapDraw(1, pTransDraw, 0);
541 GenericTilesClearClip();
542
543 BurnTransferCopy(DrvPalette);
544
545 return 0;
546 }
547
DrvFrame()548 static INT32 DrvFrame()
549 {
550 BurnWatchdogUpdate();
551
552 if (DrvReset) {
553 DrvDoReset(1);
554 }
555
556 {
557 memset (DrvInputs, 0xff, 3 * sizeof(UINT8));
558
559 for (INT32 i = 0; i < 8; i++) {
560 DrvInputs[0] ^= (DrvJoy1[i] & 1) << i;
561 DrvInputs[1] ^= (DrvJoy2[i] & 1) << i;
562 DrvInputs[2] ^= (DrvJoy3[i] & 1) << i;
563 }
564 }
565
566 INT32 nSoundBufferPos = 0;
567 INT32 nInterleave = 256;
568 INT32 nCyclesTotal[2] = { 3000000 / 60, 3579545 / 60 };
569 INT32 nCyclesDone[2] = { nExtraCycles, 0 };
570
571 HD6309Open(0);
572 ZetOpen(0);
573
574 for (INT32 i = 0; i < nInterleave; i++)
575 {
576 nCyclesDone[0] += HD6309Run((nCyclesTotal[0] * (i + 1) / nInterleave) - nCyclesDone[0]);
577 if (i == 240) {
578 if (k007121_ctrl_read(0, 7) & 0x02)
579 HD6309SetIRQLine(0, CPU_IRQSTATUS_HOLD);
580
581 if (pBurnDraw) { // missing text in service mode if drawn after vbl
582 DrvDraw();
583 }
584
585 memcpy(DrvSprRAM, DrvSprBUF, 0x800);
586 }
587
588 nCyclesDone[1] += ZetRun(nCyclesTotal[1] / nInterleave);
589
590 if (pBurnSoundOut && i&1) {
591 INT32 nSegmentLength = nBurnSoundLen / (nInterleave / 2);
592 INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
593 BurnYM2151Render(pSoundBuf, nSegmentLength);
594 nSoundBufferPos += nSegmentLength;
595 }
596 }
597
598 if (pBurnSoundOut) {
599 INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
600 if (nSegmentLength) {
601 INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
602 BurnYM2151Render(pSoundBuf, nSegmentLength);
603 }
604 K007232Update(0, pBurnSoundOut, nBurnSoundLen); // only update K007232 once per frame
605 }
606
607 ZetClose();
608 HD6309Close();
609
610 nExtraCycles = nCyclesDone[0] - nCyclesTotal[0];
611
612 return 0;
613 }
614
DrvScan(INT32 nAction,INT32 * pnMin)615 static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
616 {
617 struct BurnArea ba;
618
619 if (pnMin) {
620 *pnMin = 0x029702;
621 }
622
623 if (nAction & ACB_VOLATILE) {
624 memset(&ba, 0, sizeof(ba));
625
626 ba.Data = AllRam;
627 ba.nLen = RamEnd - AllRam;
628 ba.szName = "All Ram";
629 BurnAcb(&ba);
630
631 HD6309Scan(nAction);
632 ZetScan(nAction);
633 BurnWatchdogScan(nAction);
634
635 k007121_scan(nAction);
636
637 BurnYM2151Scan(nAction, pnMin);
638 K007232Scan(nAction, pnMin);
639
640 SCAN_VAR(soundlatch);
641 SCAN_VAR(flipscreen);
642 SCAN_VAR(multiply_register);
643 SCAN_VAR(main_bank);
644 SCAN_VAR(nExtraCycles);
645 }
646
647 if (nAction & ACB_WRITE)
648 {
649 HD6309Open(0);
650 bankswitch(main_bank);
651 HD6309Close();
652 }
653
654 return 0;
655 }
656
657
658 // MX5000
659
660 static struct BurnRomInfo mx5000RomDesc[] = {
661 { "669_r01.16c", 0x10000, 0x79b226fc, 1 | BRF_PRG | BRF_ESS }, // 0 HD6309 Code
662
663 { "669_m02.16b", 0x08000, 0x7e11e6b9, 2 | BRF_PRG | BRF_ESS }, // 1 Z80 Code
664
665 { "mask2m.11a", 0x40000, 0x6d1ea61c, 3 | BRF_SND }, // 2 k007232 Samples
666
667 { "mask4m.5e", 0x80000, 0xff1d718b, 4 | BRF_GRA }, // 3 Graphics
668 };
669
670 STD_ROM_PICK(mx5000)
STD_ROM_FN(mx5000)671 STD_ROM_FN(mx5000)
672
673 static INT32 Mx5000Init()
674 {
675 return DrvInit(0);
676 }
677
678 struct BurnDriver BurnDrvMx5000 = {
679 "mx5000", NULL, NULL, NULL, "1987",
680 "MX5000\0", NULL, "Konami", "GX669",
681 NULL, NULL, NULL, NULL,
682 BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_PREFIX_KONAMI, GBF_VERSHOOT, 0,
683 NULL, mx5000RomInfo, mx5000RomName, NULL, NULL, NULL, NULL, FlkatckInputInfo, FlkatckDIPInfo,
684 Mx5000Init, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
685 224, 280, 3, 4
686 };
687
688
689 // Flak Attack (Japan)
690
691 static struct BurnRomInfo flkatckRomDesc[] = {
692 { "669_p01.16c", 0x10000, 0xc5cd2807, 1 | BRF_PRG | BRF_ESS }, // 0 HD6309 Code
693
694 { "669_m02.16b", 0x08000, 0x7e11e6b9, 2 | BRF_PRG | BRF_ESS }, // 1 Z80 Code
695
696 { "mask2m.11a", 0x40000, 0x6d1ea61c, 3 | BRF_SND }, // 2 k007232 Samples
697
698 { "mask4m.5e", 0x80000, 0xff1d718b, 4 | BRF_GRA }, // 3 Graphics
699 };
700
701 STD_ROM_PICK(flkatck)
702 STD_ROM_FN(flkatck)
703
704 struct BurnDriver BurnDrvFlkatck = {
705 "flkatck", "mx5000", NULL, NULL, "1987",
706 "Flak Attack (Japan)\0", NULL, "Konami", "GX669",
707 NULL, NULL, NULL, NULL,
708 BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_PREFIX_KONAMI, GBF_VERSHOOT, 0,
709 NULL, flkatckRomInfo, flkatckRomName, NULL, NULL, NULL, NULL, FlkatckInputInfo, FlkatckDIPInfo,
710 Mx5000Init, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
711 224, 280, 3, 4
712 };
713
714
715 // Flak Attack (Japan, PWB 450593 sub-board)
716
717 static struct BurnRomInfo flkatckaRomDesc[] = {
718 { "669_p01.16c", 0x10000, 0xc5cd2807, 1 | BRF_PRG | BRF_ESS }, // 0 HD6309 Code
719
720 { "669_m02.16b", 0x08000, 0x7e11e6b9, 2 | BRF_PRG | BRF_ESS }, // 1 Z80 Code
721
722 { "mask2m.11a", 0x40000, 0x6d1ea61c, 3 | BRF_GRA }, // 2 k007232 Samples
723
724 { "669_f03a.4b", 0x10000, 0xf0ed4c1e, 4 | BRF_GRA }, // 3 Graphics
725 { "669_f03e.4d", 0x10000, 0x95a57a26, 4 | BRF_GRA }, // 4
726 { "669_f03b.5b", 0x10000, 0xe2593f3c, 4 | BRF_GRA }, // 5
727 { "669_f03f.5d", 0x10000, 0xc6c9903e, 4 | BRF_GRA }, // 6
728 { "669_f03c.6b", 0x10000, 0x47be92dd, 4 | BRF_GRA }, // 7
729 { "669_f03g.6d", 0x10000, 0x70d35fbd, 4 | BRF_GRA }, // 8
730 { "669_f03d.7b", 0x10000, 0x18d48f9e, 4 | BRF_GRA }, // 9
731 { "669_f03h.7d", 0x10000, 0xabfe76e7, 4 | BRF_GRA }, // 10
732 };
733
734 STD_ROM_PICK(flkatcka)
STD_ROM_FN(flkatcka)735 STD_ROM_FN(flkatcka)
736
737 static INT32 FlkatckaInit()
738 {
739 return DrvInit(1);
740 }
741
742 struct BurnDriver BurnDrvFlkatcka = {
743 "flkatcka", "mx5000", NULL, NULL, "1987",
744 "Flak Attack (Japan, PWB 450593 sub-board)\0", NULL, "Konami", "GX669",
745 NULL, NULL, NULL, NULL,
746 BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_PREFIX_KONAMI, GBF_VERSHOOT, 0,
747 NULL, flkatckaRomInfo, flkatckaRomName, NULL, NULL, NULL, NULL, FlkatckInputInfo, FlkatckDIPInfo,
748 FlkatckaInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x200,
749 224, 280, 3, 4
750 };
751