1 /*****************************************************************************
2 
3 B-Wings  (c) 1984 Data East Corporation
4 Zaviga   (c) 1984 Data East Corporation
5 
6 drivers by Acho A. Tang
7 
8 
9 JUL-2003
10 
11 Known issues:
12 
13 - The main program is responsible for sprite clipping but occational
14   glitches can be seen at the top and bottom screen edges. (post rotate)
15 
16 - B-Wings bosses sometimes flicker. (sync issue)
17 
18 - The text layer has an unknown attribute. (needs verification)
19 
20 - Zaviga's DIPs are incomplete. (manual missing)
21 
22 *****************************************************************************/
23 /* Directives*/
24 
25 #include "driver.h"
26 #include "vidhrdw/generic.h"
27 #include "cpu/m6809/m6809.h"
28 #include "cpu/m6502/m6502.h"
29 
30 #define BW_DEBUG 0
31 #define BW_CHEAT 0
32 
33 #define MAX_SOUNDS 16
34 
35 /******************************************************************************/
36 /* Imports*/
37 
38 extern struct GfxLayout bwing_tilelayout;
39 
40 extern WRITE_HANDLER( bwing_paletteram_w );
41 extern WRITE_HANDLER( bwing_videoram_w );
42 extern WRITE_HANDLER( bwing_spriteram_w );
43 extern WRITE_HANDLER( bwing_scrollreg_w );
44 extern WRITE_HANDLER( bwing_scrollram_w );
45 extern READ_HANDLER( bwing_scrollram_r );
46 extern VIDEO_START( bwing );
47 extern VIDEO_UPDATE( bwing );
48 
49 /******************************************************************************/
50 /* Local Vars*/
51 
52 static data8_t sound_fifo[MAX_SOUNDS];
53 static data8_t *bwp123_membase[3], *bwp3_rombase;
54 static data8_t *bwp1_sharedram1, *bwp2_sharedram1;
55 static size_t bwp3_romsize;
56 static int bwp3_nmimask, bwp3_u8F_d, ffcount, ffhead, fftail;
57 
58 /******************************************************************************/
59 /* Interrupt Handlers*/
60 
INTERRUPT_GEN(bwp1_interrupt)61 INTERRUPT_GEN ( bwp1_interrupt )
62 {
63 	static int coin = 0;
64 	data8_t latch_data;
65 
66 	switch (cpu_getiloops())
67 	{
68 		case 0:
69 			if (ffcount)
70 			{
71 				ffcount--;
72 				latch_data = sound_fifo[fftail];
73 				fftail = (fftail + 1) & (MAX_SOUNDS - 1);
74 				soundlatch_w(0, latch_data);
75 				cpu_set_irq_line(2, DECO16_IRQ_LINE, HOLD_LINE); /* SNDREQ*/
76 			}
77 		break;
78 
79 		case 1:
80 			if (~readinputport(4) & 0x03)
81 				{ if (!coin) { coin = 1; cpu_set_nmi_line(0, ASSERT_LINE); } }
82 			else
83 				coin = 0;
84 		break;
85 
86 		case 2:
87 			if (readinputport(5)) cpu_set_irq_line(0, M6809_FIRQ_LINE, ASSERT_LINE);
88 		break;
89 	}
90 }
91 
92 
INTERRUPT_GEN(bwp3_interrupt)93 INTERRUPT_GEN ( bwp3_interrupt ) { if (!bwp3_nmimask) cpu_set_nmi_line(2, ASSERT_LINE); }
94 
95 /******************************************************************************/
96 /* Memory and I/O Handlers*/
97 
WRITE_HANDLER(bwp12_sharedram1_w)98 static WRITE_HANDLER( bwp12_sharedram1_w ) { bwp1_sharedram1[offset] = bwp2_sharedram1[offset] = data; }
WRITE_HANDLER(bwp3_u8F_w)99 static WRITE_HANDLER( bwp3_u8F_w ) { bwp3_u8F_d = data; } /* prepares custom chip for various operations*/
WRITE_HANDLER(bwp3_nmiack_w)100 static WRITE_HANDLER( bwp3_nmiack_w ) { cpu_set_nmi_line(2, CLEAR_LINE); }
WRITE_HANDLER(bwp3_nmimask_w)101 static WRITE_HANDLER( bwp3_nmimask_w ) { bwp3_nmimask = data & 0x80; }
102 
103 
READ_HANDLER(bwp1_io_r)104 static READ_HANDLER( bwp1_io_r )
105 {
106 	if (offset == 0) return(readinputport(0));
107 	if (offset == 1) return(readinputport(1));
108 	if (offset == 2) return(readinputport(2));
109 	if (offset == 3) return(readinputport(3));
110 	if (offset == 4) return(readinputport(4));
111 
112 	return((bwp123_membase[0])[0x1b00 + offset]);
113 }
114 
115 
WRITE_HANDLER(bwp1_ctrl_w)116 static WRITE_HANDLER( bwp1_ctrl_w )
117 {
118 	switch (offset)
119 	{
120 		/* MSSTB*/
121 		case 0: cpu_set_irq_line(1, M6809_IRQ_LINE, ASSERT_LINE); break;
122 
123 		/* IRQACK*/
124 		case 1: cpu_set_irq_line(0, M6809_IRQ_LINE, CLEAR_LINE); break;
125 
126 		/* FIRQACK*/
127 		case 2: cpu_set_irq_line(0, M6809_FIRQ_LINE, CLEAR_LINE); break;
128 
129 		/* NMIACK*/
130 		case 3: cpu_set_nmi_line(0, CLEAR_LINE); break;
131 
132 		/* SWAP(bank-swaps sprite RAM between 1800 & 1900; ignored bc. they're treated as a single chunk.)*/
133 		case 4: break;
134 
135 		/* SNDREQ*/
136 		case 5:
137 			if (data == 0x80) /* protection trick to screw CPU1 & 3*/
138 				cpu_set_nmi_line(1, ASSERT_LINE); /* SNMI*/
139 			else
140 			if (ffcount < MAX_SOUNDS)
141 			{
142 				ffcount++;
143 				sound_fifo[ffhead] = data;
144 				ffhead = (ffhead + 1) & (MAX_SOUNDS - 1);
145 			}
146 		break;
147 
148 		/* BANKSEL(supposed to bank-switch CPU0 4000-7fff(may also 8000-bfff) 00=bank 0, 80=bank 1, unused)*/
149 		case 6: break;
150 
151 		/* hardwired to SWAP*/
152 		case 7: break;
153 	}
154 
155 	#if BW_DEBUG
156 		(bwp123_membase[0])[0x1c00 + offset] = data;
157 	#endif
158 }
159 
160 
WRITE_HANDLER(bwp2_ctrl_w)161 static WRITE_HANDLER( bwp2_ctrl_w )
162 {
163 	switch (offset)
164 	{
165 		case 0: cpu_set_irq_line(0, M6809_IRQ_LINE, ASSERT_LINE); break; /* SMSTB*/
166 
167 		case 1: cpu_set_irq_line(1, M6809_FIRQ_LINE, CLEAR_LINE); break;
168 
169 		case 2: cpu_set_irq_line(1, M6809_IRQ_LINE, CLEAR_LINE); break;
170 
171 		case 3: cpu_set_nmi_line(1, CLEAR_LINE); break;
172 	}
173 
174 	#if BW_DEBUG
175 		(bwp123_membase[1])[0x1800 + offset] = data;
176 	#endif
177 }
178 
179 /******************************************************************************/
180 /* CPU Memory Maps*/
181 
182 /* Main CPU*/
MEMORY_READ_START(bwp1_readmem)183 static MEMORY_READ_START( bwp1_readmem )
184 	{ 0x1b00, 0x1b07, bwp1_io_r },
185 	{ 0x0000, 0x1fff, MRA_RAM },
186 	{ 0x2000, 0x3fff, bwing_scrollram_r },
187 	{ 0x4000, 0xffff, MRA_ROM },
188 MEMORY_END
189 
190 static MEMORY_WRITE_START( bwp1_writemem )
191 	{ 0x0000, 0x07ff, bwp12_sharedram1_w, &bwp1_sharedram1 },
192 	{ 0x0800, 0x0fff, MWA_RAM },
193 	{ 0x1000, 0x13ff, bwing_videoram_w, &videoram },
194 	{ 0x1800, 0x19ff, bwing_spriteram_w, &buffered_spriteram },
195 	{ 0x1a00, 0x1aff, bwing_paletteram_w, &paletteram },
196 	{ 0x1b00, 0x1b07, bwing_scrollreg_w },
197 	{ 0x1c00, 0x1c07, bwp1_ctrl_w },
198 	{ 0x2000, 0x3fff, bwing_scrollram_w },
199 	{ 0x1000, 0x1fff, MWA_RAM }, /* falls through*/
200 	{ 0x4000, 0xffff, MWA_NOP }, /* "B-Wings US" writes to 9631-9632(debug?)*/
201 MEMORY_END
202 
203 
204 /* Sub CPU*/
205 static MEMORY_READ_START( bwp2_readmem )
206 	{ 0x0000, 0x0fff, MRA_RAM },
207 	{ 0xa000, 0xffff, MRA_ROM },
208 MEMORY_END
209 
210 static MEMORY_WRITE_START( bwp2_writemem )
211 	{ 0x0000, 0x07ff, bwp12_sharedram1_w, &bwp2_sharedram1 },
212 	{ 0x0800, 0x0fff, MWA_RAM },
213 	{ 0x1800, 0x1803, bwp2_ctrl_w },
214 	{ 0xa000, 0xffff, MWA_ROM },
215 MEMORY_END
216 
217 
218 /* Sound CPU*/
219 static MEMORY_READ_START( bwp3_readmem )
220 	{ 0x0000, 0x01ff, MRA_RAM },
221 	{ 0xa000, 0xa000, soundlatch_r },
222 	{ 0xe000, 0xffff, MRA_ROM },
223 MEMORY_END
224 
225 static MEMORY_WRITE_START( bwp3_writemem )
226 	{ 0x0000, 0x01ff, MWA_RAM },
227 	{ 0x0200, 0x0200, DAC_0_signed_data_w },
228 	{ 0x1000, 0x1000, bwp3_nmiack_w },
229 	{ 0x2000, 0x2000, AY8910_write_port_0_w },
230 	{ 0x4000, 0x4000, AY8910_control_port_0_w },
231 	{ 0x6000, 0x6000, AY8910_write_port_1_w },
232 	{ 0x8000, 0x8000, AY8910_control_port_1_w },
233 	{ 0xd000, 0xd000, bwp3_nmimask_w },
234 	{ 0xe000, 0xffff, MWA_ROM, &bwp3_rombase, &bwp3_romsize },
235 MEMORY_END
236 
237 static PORT_READ_START( bwp3_readport )
238 	{ 0x00, 0x00, input_port_6_r },
239 PORT_END
240 
241 static PORT_WRITE_START( bwp3_writeport )
242 	{ 0x00, 0x00, bwp3_u8F_w },
243 PORT_END
244 
245 /******************************************************************************/
246 /* I/O Port Maps*/
247 
248 INPUT_PORTS_START( bwing )
249 	PORT_START
250 	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) )
251 	PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
252 	PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
253 	PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
254 	PORT_DIPSETTING(    0x01, DEF_STR( 1C_3C ) )
255 	PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_B ) )
256 	PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
257 	PORT_DIPSETTING(    0x0c, DEF_STR( 1C_1C ) )
258 	PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
259 	PORT_DIPSETTING(    0x04, DEF_STR( 1C_3C ) )
260 	PORT_DIPNAME( 0x10, 0x10, "Diag" )
261 	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
262 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
263 	PORT_DIPNAME( 0x20, 0x00, DEF_STR( Cabinet ) )
264 	PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
265 	PORT_DIPSETTING(    0x20, DEF_STR( Cocktail ) )
266 #if BW_CHEAT /* undocumented and only labeled as "KEEP OFF" in B-Wings*/
267 	PORT_DIPNAME( 0x40, 0x40, "Invincibility" )
268 	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
269 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
270 	PORT_DIPNAME( 0x80, 0x80, "Infinite" )
271 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
272 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
273 #else
274 	PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNKNOWN )
275 #endif
276 
277 	PORT_START
278 	PORT_DIPNAME( 0x01, 0x01, DEF_STR( Lives ) )
279 	PORT_DIPSETTING(    0x00, "5" )
280 	PORT_DIPSETTING(    0x01, "3" )
281 	PORT_DIPNAME( 0x06, 0x06, "Bonus" )
282 	PORT_DIPSETTING(    0x00, "40000" )
283 	PORT_DIPSETTING(    0x02, "20000 80000" )
284 	PORT_DIPSETTING(    0x04, "20000 60000" )
285 	PORT_DIPSETTING(    0x06, "20000 40000" )
286 	PORT_DIPNAME( 0x08, 0x08, "Enemy Crafts" )
287 	PORT_DIPSETTING(    0x00, "Hard" )
288 	PORT_DIPSETTING(    0x08, "Normal" )
289 	PORT_DIPNAME( 0x10, 0x10, "Enemy Missiles" )
290 	PORT_DIPSETTING(    0x00, "Hard" )
291 	PORT_DIPSETTING(    0x10, "Normal" )
292 	PORT_DIPNAME( 0x20, 0x20, "Freeze" )
293 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
294 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
295 	PORT_DIPNAME( 0x40, 0x00, "Country" )
296 	PORT_DIPSETTING(    0x00, "Japan/US" )
297 	PORT_DIPSETTING(    0x40, "Japan Only" )
298 	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
299 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
300 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
301 
302 	PORT_START
303 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
304 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
305 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
306 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
307 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
308 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
309 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
310 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
311 
312 	PORT_START
313 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL )
314 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL )
315 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP  | IPF_8WAY | IPF_COCKTAIL )
316 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL )
317 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
318 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
319 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
320 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
321 
322 	PORT_START
323 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
324 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
325 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
326 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
327 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
328 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
329 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 )
330 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
331 
332 	PORT_START
333 	PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_TILT )
334 
335 	PORT_START
336 	PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_VBLANK )
337 
338 	PORT_START /* a matter of taste*/
339 	PORT_DIPNAME( 0x07, 0x00, "RGB" )
340 	PORT_DIPSETTING(    0x00, "Default" )
341 	PORT_DIPSETTING(    0x01, "More Red" )
342 	PORT_DIPSETTING(    0x02, "More Green" )
343 	PORT_DIPSETTING(    0x03, "More Blue" )
344 	PORT_DIPSETTING(    0x04, "Max" )
345 INPUT_PORTS_END
346 
347 /******************************************************************************/
348 /* Graphics Layouts*/
349 
350 static struct GfxLayout charlayout =
351 {
352 	8, 8,
353 	256,
354 	2,
355 	{ 0, 0x4000 },
356 	{ 7, 6, 5, 4, 3, 2, 1, 0 },
357 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
358 	8*8
359 };
360 
361 static struct GfxLayout spritelayout =
362 {
363 	16, 16,
364 	512,
365 	3,
366 	{ 0x40000, 0x20000, 0 },
367 	{ 7, 6, 5, 4, 3, 2, 1, 0, 128+7, 128+6, 128+5, 128+4, 128+3, 128+2, 128+1, 128+0 },
368 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
369 	  8*8, 9*8,10*8,11*8,12*8,13*8,14*8,15*8 },
370 	32*8
371 };
372 
373 
374 static struct GfxDecodeInfo gfxdecodeinfo[] =
375 {
376 	{ REGION_GFX1,  0, &charlayout,       0x00, 1 }, /* chars*/
377 	{ REGION_GFX2,  0, &spritelayout,     0x20, 2 }, /* sprites*/
378 	{ REGION_USER1, 0, &bwing_tilelayout, 0x10, 2 }, /* foreground tiles place holder*/
379 	{ REGION_USER1, 0, &bwing_tilelayout, 0x30, 2 }, /* background tiles place holder*/
380 	{ -1 }
381 };
382 
383 /******************************************************************************/
384 /* Hardware Definitions*/
385 
MACHINE_INIT(bwing)386 MACHINE_INIT( bwing )
387 {
388 	bwp3_nmimask = 0;
389 	fftail = ffhead = ffcount = 0;
390 }
391 
392 
393 static struct AY8910interface ay8910_interface =
394 {
395 	2,
396 	1500000,
397 	{ 50, 50 },
398 	{ 0 },
399 	{ 0 },
400 	{ 0 },
401 	{ 0 }
402 };
403 
404 static struct DACinterface dac_interface =
405 {
406 	1,
407 	{ 10 }
408 };
409 
410 
411 static MACHINE_DRIVER_START( bwing )
412 
413 	/* basic machine hardware*/
414 	MDRV_CPU_ADD(M6809, 2000000)
MDRV_CPU_MEMORY(bwp1_readmem,bwp1_writemem)415 	MDRV_CPU_MEMORY(bwp1_readmem, bwp1_writemem)
416 	MDRV_CPU_VBLANK_INT(bwp1_interrupt, 3)
417 
418 	MDRV_CPU_ADD(M6809, 2000000)
419 	MDRV_CPU_MEMORY(bwp2_readmem, bwp2_writemem)
420 /*	MDRV_CPU_VBLANK_INT(irq1_line_assert, 1) */ /* vblank triggers FIRQ on CPU2 by design (unused)*/
421 
422 	MDRV_CPU_ADD(DECO16, 2000000)
423 	MDRV_CPU_FLAGS(CPU_AUDIO_CPU)
424 	MDRV_CPU_MEMORY(bwp3_readmem, bwp3_writemem)
425 	MDRV_CPU_PORTS(bwp3_readport, bwp3_writeport)
426 	MDRV_CPU_PERIODIC_INT(bwp3_interrupt, 1000)
427 
428 	MDRV_FRAMES_PER_SECOND(60)
429 	MDRV_VBLANK_DURATION(600)	/* must be long enough for polling*/
430 	MDRV_INTERLEAVE(300)		/* high enough?*/
431 
432 	/* video hardware*/
433 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_BEFORE_VBLANK)
434 	MDRV_GFXDECODE(gfxdecodeinfo)
435 	MDRV_SCREEN_SIZE(32*8, 32*8)
436 	MDRV_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
437 	MDRV_PALETTE_LENGTH(64)
438 
439 	MDRV_VIDEO_START(bwing)
440 	MDRV_VIDEO_UPDATE(bwing)
441 
442 	/* sound hardware*/
443 	MDRV_SOUND_ADD(AY8910, ay8910_interface)
444 	MDRV_SOUND_ADD(DAC, dac_interface)
445 
446 MACHINE_DRIVER_END
447 
448 /******************************************************************************/
449 /* ROM Maps*/
450 
451 ROM_START( bwing )
452 	/* Top Board(SCU-01)*/
453 	ROM_REGION( 0x10000, REGION_CPU1, 0 ) /* main CPU*/
454 	ROM_LOAD( "bw_bv-02.10a", 0x04000, 0x04000, CRC(5ce74ab5) SHA1(b414f0bbe1c4c5b4c810bb4b9fba16aaf86520ff) )
455 	ROM_LOAD( "bw_bv-01.7a",  0x08000, 0x04000, CRC(b960c707) SHA1(086cb0f22fb59922bf0369bf6b382a241d979ec3) )
456 	ROM_LOAD( "bw_bv-00.4a",  0x0c000, 0x04000, CRC(926bef63) SHA1(d4bd2e91fa0abc5e9472d4b684c076bdc3c29f5b) )
457 
458 	ROM_REGION( 0x10000, REGION_CPU2, 0 ) /* sub CPU*/
459 	ROM_LOAD( "bw_bv-06.10d", 0x0a000, 0x02000, CRC(91a21a4c) SHA1(042eed60119a861f6b3ccfbe68d880f182a8a8e1) )
460 	ROM_LOAD( "bw_bv-05.9d",  0x0c000, 0x02000, CRC(f283f39a) SHA1(9f7f4c39d49f4dfff73fe74cd457480e8a43a3c5) )
461 	ROM_LOAD( "bw_bv-04.7d",  0x0e000, 0x02000, CRC(29ae75b6) SHA1(48c94e996857f2ac995bcd25f0e67b9f7c17d807) )
462 
463 	ROM_REGION( 0x10000, REGION_CPU3, 0 ) /* sound CPU(encrypted)*/
464 	ROM_LOAD( "bw_bv-03.13a", 0x0e000, 0x02000, CRC(e8ac9379) SHA1(aaf5c20aa33ed05747a8a27739e9d09e094a518d) )
465 
466 	/* Bottom Board(CCU-01)*/
467 	ROM_REGION( 0x01000, REGION_GFX1, ROMREGION_DISPOSE ) /* chars*/
468 	ROM_LOAD( "bw_bv-10.5c",  0x00000, 0x01000, CRC(edca6901) SHA1(402c80e7519cf3a43b9fef52c9923961220a48b6) )
469 
470 	/* Middle Board(MCU-01)*/
471 	ROM_REGION( 0x0c000, REGION_GFX2, ROMREGION_DISPOSE ) /* sprites*/
472 	ROM_LOAD( "bw_bv-07.1l",  0x00000, 0x04000, CRC(3d5ab2be) SHA1(2b3a039914ebfcc3993da74853a67546fc22c191) )
473 	ROM_LOAD( "bw_bv-08.1k",  0x04000, 0x04000, CRC(7a585f1e) SHA1(99e5d947b6b1fa96b90c676a282376d67fc377f0) )
474 	ROM_LOAD( "bw_bv-09.1h",  0x08000, 0x04000, CRC(a14c0b57) SHA1(5033354793d77922f5ef7f268cbe212e551efadf) )
475 
476 	/* GPU Banks*/
477 	ROM_REGION( 0x08000, REGION_USER1, 0 )
478 	ROM_FILL(0x00000, 0x08000, 0)
479 ROM_END
480 
481 
482 ROM_START( bwings )
483 	/* Top Board(SCU-01)*/
484 	ROM_REGION( 0x10000, REGION_CPU1, 0 ) /* main CPU*/
485 	ROM_LOAD( "bw_bv-02.10a", 0x04000, 0x04000, CRC(5ce74ab5) SHA1(b414f0bbe1c4c5b4c810bb4b9fba16aaf86520ff) )
486 	ROM_LOAD( "bv02.bin",     0x06000, 0x02000, CRC(2f84654e) SHA1(11b5343219b46d03f686ea348181c509121b9e3c) ) /* only the lower 8k is different*/
487 	ROM_LOAD( "bw_bv-01.7a",  0x08000, 0x04000, CRC(b960c707) SHA1(086cb0f22fb59922bf0369bf6b382a241d979ec3) )
488 	ROM_LOAD( "bv00.bin",     0x0c000, 0x04000, CRC(0bbc1222) SHA1(cfdf621a423a5ce4ba44a980e683d2abf044d6b9) ) /* different*/
489 
490 	ROM_REGION( 0x10000, REGION_CPU2, 0 ) /* sub CPU*/
491 	ROM_LOAD( "bw_bv-06.10d", 0x0a000, 0x02000, CRC(91a21a4c) SHA1(042eed60119a861f6b3ccfbe68d880f182a8a8e1) )
492 	ROM_LOAD( "bw_bv-05.9d",  0x0c000, 0x02000, CRC(f283f39a) SHA1(9f7f4c39d49f4dfff73fe74cd457480e8a43a3c5) )
493 	ROM_LOAD( "bw_bv-04.7d",  0x0e000, 0x02000, CRC(29ae75b6) SHA1(48c94e996857f2ac995bcd25f0e67b9f7c17d807) )
494 
495 	ROM_REGION( 0x10000, REGION_CPU3, 0 ) /* sound CPU(encrypted)*/
496 	ROM_LOAD( "bw_bv-03.13a", 0x0e000, 0x02000, CRC(e8ac9379) SHA1(aaf5c20aa33ed05747a8a27739e9d09e094a518d) )
497 
498 	/* Bottom Board(CCU-01)*/
499 	ROM_REGION( 0x01000, REGION_GFX1, ROMREGION_DISPOSE ) /* chars*/
500 	ROM_LOAD( "bw_bv-10.5c",  0x00000, 0x01000, CRC(edca6901) SHA1(402c80e7519cf3a43b9fef52c9923961220a48b6) )
501 
502 	/* Middle Board(MCU-01)*/
503 	ROM_REGION( 0x0c000, REGION_GFX2, ROMREGION_DISPOSE ) /* sprites*/
504 	ROM_LOAD( "bw_bv-07.1l",  0x00000, 0x04000, CRC(3d5ab2be) SHA1(2b3a039914ebfcc3993da74853a67546fc22c191) )
505 	ROM_LOAD( "bw_bv-08.1k",  0x04000, 0x04000, CRC(7a585f1e) SHA1(99e5d947b6b1fa96b90c676a282376d67fc377f0) )
506 	ROM_LOAD( "bw_bv-09.1h",  0x08000, 0x04000, CRC(a14c0b57) SHA1(5033354793d77922f5ef7f268cbe212e551efadf) )
507 
508 	/* GPU Banks*/
509 	ROM_REGION( 0x08000, REGION_USER1, 0 )
510 	ROM_FILL(0x00000, 0x08000, 0)
511 ROM_END
512 
513 
514 ROM_START( batwings )
515 	/* Top Board(SCU-01)*/
516 	ROM_REGION( 0x10000, REGION_CPU1, 0 ) /* main CPU*/
517 	ROM_LOAD( "bv-02-.10a",   0x04000, 0x04000, CRC(6074a86b) SHA1(0ce1bd74450144fd3c6556787d6c5c5d4531d830) )  /* different*/
518 	ROM_LOAD( "bw_bv-01.7a",  0x08000, 0x04000, CRC(b960c707) SHA1(086cb0f22fb59922bf0369bf6b382a241d979ec3) )
519 	ROM_LOAD( "bv-00-.4a",    0x0c000, 0x04000, CRC(1f83804c) SHA1(afd5eb0822db4fd982062945ca27e66ed9680645) )  /* different*/
520 
521 	ROM_REGION( 0x10000, REGION_CPU2, 0 ) /* sub CPU*/
522 	ROM_LOAD( "bv-06-.10d", 0x0a000, 0x02000, NO_DUMP ) /* bad dump filled with 0x7e, no substitute found*/
523 	ROM_LOAD( "bv-05-.9d",  0x0c000, 0x02000, CRC(1e393300) SHA1(8d847256eb5dbccf5f524ec3aa836073d70b4edc) )  /* different*/
524 	ROM_LOAD( "bv-04-.7d",  0x0e000, 0x02000, CRC(6548c5bb) SHA1(d12cc8d0d5692c3de766f5c42c818dd8f685760a) )  /* different*/
525 
526 	ROM_REGION( 0x10000, REGION_CPU3, 0 ) /* sound CPU(encrypted)*/
527 	ROM_LOAD( "bw_bv-03.13a", 0x0e000, 0x02000, CRC(e8ac9379) SHA1(aaf5c20aa33ed05747a8a27739e9d09e094a518d) )
528 
529 	/* Bottom Board(CCU-01)*/
530 	ROM_REGION( 0x01000, REGION_GFX1, ROMREGION_DISPOSE ) /* chars*/
531 	ROM_LOAD( "bw_bv-10.5c",  0x00000, 0x01000, CRC(edca6901) SHA1(402c80e7519cf3a43b9fef52c9923961220a48b6) )
532 
533 	/* Middle Board(MCU-01)*/
534 	ROM_REGION( 0x0c000, REGION_GFX2, ROMREGION_DISPOSE ) /* sprites*/
535 	ROM_LOAD( "bw_bv-07.1l",  0x00000, 0x04000, CRC(3d5ab2be) SHA1(2b3a039914ebfcc3993da74853a67546fc22c191) )
536 	ROM_LOAD( "bw_bv-08.1k",  0x04000, 0x04000, CRC(7a585f1e) SHA1(99e5d947b6b1fa96b90c676a282376d67fc377f0) )
537 	ROM_LOAD( "bw_bv-09.1h",  0x08000, 0x04000, CRC(a14c0b57) SHA1(5033354793d77922f5ef7f268cbe212e551efadf) )
538 
539 	/* GPU Banks*/
540 	ROM_REGION( 0x08000, REGION_USER1, 0 )
541 	ROM_FILL(0x00000, 0x08000, 0)
542 ROM_END
543 
544 
545 ROM_START( zaviga )
546 	/* Top Board(DE-0169-0)*/
547 	ROM_REGION( 0x10000, REGION_CPU1, 0 ) /* main CPU*/
548 	ROM_LOAD( "as04", 0x04000, 0x04000, CRC(b79f5da2) SHA1(b39748666d3f7fb1ac46d282cce09fe9531df6b1) )
549 	ROM_LOAD( "as02", 0x08000, 0x04000, CRC(6addd16a) SHA1(940637c49bf9f38c77176ed2ae212048e9e7fd8f) )
550 	ROM_LOAD( "as00", 0x0c000, 0x04000, CRC(c6ae4af0) SHA1(6f6f14385b20f9c9c312f816036c608fe8514b00) )
551 
552 	ROM_REGION( 0x10000, REGION_CPU2, 0 ) /* sub CPU*/
553 	ROM_LOAD( "as08", 0x0a000, 0x02000, CRC(b6187b3a) SHA1(d2d7c5b185f59986f45d8ec3ddf9b95364e57d96) )
554 	ROM_LOAD( "as07", 0x0c000, 0x02000, CRC(dc1170e3) SHA1(c8e4d1564fd272d726d0e4ffd4f33f67f1b37cd7) )
555 	ROM_LOAD( "as06", 0x0e000, 0x02000, CRC(ba888f84) SHA1(f94de8553cd4704d9b3349ded881a7cc62fa9b57) )
556 
557 	ROM_REGION( 0x10000, REGION_CPU3, 0 ) /* sound CPU(encrypted)*/
558 	ROM_LOAD( "as05", 0x0e000, 0x02000, CRC(afe9b0ac) SHA1(3c653cd4fff7f4e00971249900b5a810b6e74dfe) )
559 
560 	/* Bottom Board(DE-0170-0)*/
561 	ROM_REGION( 0x01000, REGION_GFX1, ROMREGION_DISPOSE ) /* chars*/
562 	ROM_LOAD( "as14", 0x00000, 0x01000, CRC(62132c1d) SHA1(6b101e220a440488da17de8446f4e2c8ec7c7de9) )
563 
564 	/* Middle Board(DE-0171-0)*/
565 	ROM_REGION( 0x0c000, REGION_GFX2, ROMREGION_DISPOSE ) /* sprites*/
566 	ROM_LOAD( "as11", 0x00000, 0x04000, CRC(aa84af24) SHA1(af4ff085dc44b3d1493ec1c8b4a8d18dccecc872) )
567 	ROM_LOAD( "as12", 0x04000, 0x04000, CRC(84af9041) SHA1(8fbd5995ca8e708cd7fb9cdfcdb174e12084f526) )
568 	ROM_LOAD( "as13", 0x08000, 0x04000, CRC(15d0922b) SHA1(b8d715a9e610531472d516c19f6035adbce93c84) )
569 
570 	/* GPU Banks*/
571 	ROM_REGION( 0x08000, REGION_USER1, 0 )
572 	ROM_FILL(0x00000, 0x08000, 0)
573 ROM_END
574 
575 
576 ROM_START( zavigaj )
577 	/* Top Board(DE-0169-0)*/
578 	ROM_REGION( 0x10000, REGION_CPU1, 0 ) /* main CPU*/
579 	ROM_LOAD( "as04", 0x04000, 0x04000, CRC(b79f5da2) SHA1(b39748666d3f7fb1ac46d282cce09fe9531df6b1) )
580 	ROM_LOAD( "as02", 0x08000, 0x04000, CRC(6addd16a) SHA1(940637c49bf9f38c77176ed2ae212048e9e7fd8f) )
581 	ROM_LOAD( "as00", 0x0c000, 0x04000, CRC(c6ae4af0) SHA1(6f6f14385b20f9c9c312f816036c608fe8514b00) )
582 
583 	ROM_REGION( 0x10000, REGION_CPU2, 0 ) /* sub CPU*/
584 	ROM_LOAD( "as08",     0x0a000, 0x02000, CRC(b6187b3a) SHA1(d2d7c5b185f59986f45d8ec3ddf9b95364e57d96) )
585 	ROM_LOAD( "as07",     0x0c000, 0x02000, CRC(dc1170e3) SHA1(c8e4d1564fd272d726d0e4ffd4f33f67f1b37cd7) )
586 	ROM_LOAD( "as06-.7d", 0x0e000, 0x02000, CRC(b02d270c) SHA1(beea3d44d367543b5b5075c5892580e690691e75) )  /* different*/
587 
588 	ROM_REGION( 0x10000, REGION_CPU3, 0 ) /* sound CPU(encrypted)*/
589 	ROM_LOAD( "as05", 0x0e000, 0x02000, CRC(afe9b0ac) SHA1(3c653cd4fff7f4e00971249900b5a810b6e74dfe) )
590 
591 	/* Bottom Board(DE-0170-0)*/
592 	ROM_REGION( 0x01000, REGION_GFX1, ROMREGION_DISPOSE ) /* chars*/
593 	ROM_LOAD( "as14", 0x00000, 0x01000, CRC(62132c1d) SHA1(6b101e220a440488da17de8446f4e2c8ec7c7de9) )
594 
595 	/* Middle Board(DE-0171-0)*/
596 	ROM_REGION( 0x0c000, REGION_GFX2, ROMREGION_DISPOSE ) /* sprites*/
597 	ROM_LOAD( "as11", 0x00000, 0x04000, CRC(aa84af24) SHA1(af4ff085dc44b3d1493ec1c8b4a8d18dccecc872) )
598 	ROM_LOAD( "as12", 0x04000, 0x04000, CRC(84af9041) SHA1(8fbd5995ca8e708cd7fb9cdfcdb174e12084f526) )
599 	ROM_LOAD( "as13", 0x08000, 0x04000, CRC(15d0922b) SHA1(b8d715a9e610531472d516c19f6035adbce93c84) )
600 
601 	/* GPU Banks*/
602 	ROM_REGION( 0x08000, REGION_USER1, 0 )
603 	ROM_FILL(0x00000, 0x08000, 0)
604 ROM_END
605 
606 /******************************************************************************/
607 /* Initializations*/
608 
609 static void fix_bwp3(void)
610 {
611 	unsigned char *rom = bwp3_rombase;
612 	int i, j = bwp3_romsize;
613 	unsigned char ah, al;
614 
615 	/* swap nibbles*/
616 	for (i=0; i<j; i++) { ah = al = rom[i]; rom[i] = (ah >> 4) | (al << 4); }
617 
618 	/* relocate vectors*/
619 	rom[j-(0x10-0x4)] = rom[j-(0x10-0xb)] = rom[j-(0x10-0x6)];
620 	rom[j-(0x10-0x5)] = rom[j-(0x10-0xa)] = rom[j-(0x10-0x7)];
621 }
622 
623 
DRIVER_INIT(bwing)624 static DRIVER_INIT( bwing )
625 {
626 	bwp123_membase[0] = memory_region(REGION_CPU1);
627 	bwp123_membase[1] = memory_region(REGION_CPU2);
628 	bwp123_membase[2] = memory_region(REGION_CPU3);
629 
630 	fix_bwp3();
631 }
632 
633 /******************************************************************************/
634 /* Game Entries*/
635 
636 GAME ( 1984, bwing,        0, bwing, bwing, bwing, ROT90, "Data East Corporation", "B-Wings (Japan)" )
637 GAME ( 1984, bwings,   bwing, bwing, bwing, bwing, ROT90, "Data East Corporation", "Battle Wings" )
638 GAMEX( 1984, batwings, bwing, bwing, bwing, bwing, ROT90, "Data East Corporation", "Battle Wings (alt)", GAME_NOT_WORKING )
639 
640 GAME ( 1984, zaviga,       0, bwing, bwing, bwing, ROT90, "Data East Corporation", "Zaviga" )
641 GAME ( 1984, zavigaj, zaviga, bwing, bwing, bwing, ROT90, "Data East Corporation", "Zaviga (Japan)" )
642