1 /*
2 China Gate.
3 By Paul Hampson from First Principles
4 (IE: Roms + a description of their contents and a list of CPUs on board.)
5 
6 Based on ddragon.c:
7 "Double Dragon, Double Dragon (bootleg) & Double Dragon II"
8 "By Carlos A. Lozano & Rob Rosenbrock et. al."
9 
10 NOTES:
11 A couple of things unaccounted for:
12 
13 No backgrounds ROMs from the original board...
14 - This may be related to the SubCPU. I don't think it's contributing
15   much right now, but I could be wrong. And it would explain that vast
16   expanse of bankswitch ROM on a slave CPU....
17 - Just had a look at the sprites, and they seem like kosher sprites all
18   the way up.... So it must be hidden in the sub-cpu somewhere?
19 - Got two bootleg sets with background gfx roms. Using those on the
20   original games for now.
21 
22 OBVIOUS SPEED PROBLEMS...
23 - Timers are too fast and/or too slow, and the whole thing's moving too fast
24 
25 Port 0x2800 on the Sub CPU.
26 - All those I/O looking ports on the main CPU (0x3exx and 0x3fxx)
27 - One's scroll control. Prolly other vidhrdw control as well.
28 - Location 0x1a2ec in cgate51.bin (The main CPU's ROM) is 88. This is
29   copied to videoram, and causes that minor visual discrepancy on
30   the title screen. But the CPU tests that part of the ROM and passes
31   it OK. Since it's just a simple summing of words, another word
32   somewhere (or others in total) has lost 0x8000. Or the original
33   game had this problem. (Not on the screenshot I got)
34 - The Japanese ones have a different title screen so I can't check.
35 
36 ADPCM in the bootlegs is not quite right.... Misusing the data?
37 - They're nibble-swapped versions of the original roms...
38 - There's an Intel i8748 CPU on the bootlegs (bootleg 1 lists D8749 but
39   the microcode dump's the same). This in conjunction with the different
40   ADPCM chip (msm5205) are used to 'fake' a M6295.
41 - Bootleg 1 ADPCM is now wired up, but still not working :-(
42   Definantly sync problems between the i8049 and the m5205 which need
43   further looking at.
44 
45 
46 There's also a few small dumps from the boards.
47 
48 
49 MAJOR DIFFERENCES FROM DOUBLE DRAGON:
50 Sound system is like Double Dragon II (In fact for MAME's
51 purposes it's identical. I think DD3 and one or two others
52 also use this. Was it an addon on the original?
53 The dual-CPU setup looked similar to DD at first, but
54 the second CPU doesn't talk to the sprite RAM at all, but
55 just through the shared memory (which DD1 doesn't have,
56 except for the sprite RAM.)
57 Also the 2nd CPU in China Gate has just as much code as
58 the first CPU, and bankswitches similarly, where DD1 and DD2 have
59 different Sprite CPUs but only a small bank of code each.
60 More characters and colours of characters than DD1 or 2.
61 More sprites than DD1, less than DD2.
62 But the formats are the same (allowing for extra chars and colours)
63 Video hardware's like DD1 (thank god)
64 Input is unique but has a few similarities to DD2 (the coin inputs)
65 
66 
67 */
68 
69 
70 
71 #include "driver.h"
72 #include "vidhrdw/generic.h"
73 #include "cpu/m6809/m6809.h"
74 #include "cpu/z80/z80.h"
75 #include "cpu/i8039/i8039.h"
76 #include "sound/2151intf.h"
77 #include "sound/2203intf.h"
78 
79 /**************** Video stuff ******************/
80 
81 WRITE_HANDLER( ddragon_bgvideoram_w );
82 WRITE_HANDLER( ddragon_fgvideoram_w );
83 
84 VIDEO_START( chinagat );
85 VIDEO_UPDATE( ddragon );
86 
87 extern int technos_video_hw;
88 extern int ddragon_scrollx_hi, ddragon_scrolly_hi;
89 extern data8_t *ddragon_scrollx_lo;
90 extern data8_t *ddragon_scrolly_lo;
91 extern data8_t *ddragon_bgvideoram,*ddragon_fgvideoram;
92 
93 /**************** Machine stuff ******************/
94 static int sprite_irq, sound_irq, adpcm_sound_irq;
95 static int saiyugb1_adpcm_addr;
96 static int saiyugb1_i8748_P1;
97 static int saiyugb1_i8748_P2;
98 static int saiyugb1_pcm_shift;
99 static int saiyugb1_pcm_nibble;
100 static int saiyugb1_mcu_command;
101 #if 0
102 static int saiyugb1_m5205_clk;
103 #endif
104 
105 
106 
MACHINE_INIT(chinagat)107 static MACHINE_INIT( chinagat )
108 {
109 	technos_video_hw = 1;
110 	sprite_irq = M6809_IRQ_LINE;
111 	sound_irq = IRQ_LINE_NMI;
112 }
113 
WRITE_HANDLER(chinagat_video_ctrl_w)114 WRITE_HANDLER( chinagat_video_ctrl_w )
115 {
116 	/***************************
117 	---- ---x   X Scroll MSB
118 	---- --x-   Y Scroll MSB
119 	---- -x--   Flip screen
120 	--x- ----   Enable video ???
121 	****************************/
122 
123 	ddragon_scrolly_hi = ( ( data & 0x02 ) << 7 );
124 	ddragon_scrollx_hi = ( ( data & 0x01 ) << 8 );
125 
126 	flip_screen_set(~data & 0x04);
127 }
128 
WRITE_HANDLER(chinagat_bankswitch_w)129 static WRITE_HANDLER( chinagat_bankswitch_w )
130 {
131 	data8_t *RAM = memory_region(REGION_CPU1);
132 	cpu_setbank( 1,&RAM[ 0x10000 + (0x4000 * (data & 7)) ] );
133 }
134 
WRITE_HANDLER(chinagat_sub_bankswitch_w)135 static WRITE_HANDLER( chinagat_sub_bankswitch_w )
136 {
137 	data8_t *RAM = memory_region( REGION_CPU2 );
138 	cpu_setbank( 4,&RAM[ 0x10000 + (0x4000 * (data & 7)) ] );
139 }
140 
WRITE_HANDLER(chinagat_sub_IRQ_w)141 static WRITE_HANDLER( chinagat_sub_IRQ_w )
142 {
143 	cpu_set_irq_line( 1, sprite_irq, (sprite_irq == IRQ_LINE_NMI) ? PULSE_LINE : HOLD_LINE );
144 }
145 
WRITE_HANDLER(chinagat_cpu_sound_cmd_w)146 static WRITE_HANDLER( chinagat_cpu_sound_cmd_w )
147 {
148 	soundlatch_w( offset, data );
149 	cpu_set_irq_line( 2, sound_irq, (sound_irq == IRQ_LINE_NMI) ? PULSE_LINE : HOLD_LINE );
150 }
151 
READ_HANDLER(saiyugb1_mcu_command_r)152 static READ_HANDLER( saiyugb1_mcu_command_r )
153 {
154 #if 0
155 	if (saiyugb1_mcu_command == 0x78)
156 	{
157 		timer_suspendcpu(3, 1, SUSPEND_REASON_HALT);	/* Suspend (speed up) */
158 	}
159 #endif
160 	return saiyugb1_mcu_command;
161 }
162 
WRITE_HANDLER(saiyugb1_mcu_command_w)163 static WRITE_HANDLER( saiyugb1_mcu_command_w )
164 {
165 	saiyugb1_mcu_command = data;
166 #if 0
167 	if (data != 0x78)
168 	{
169 		timer_suspendcpu(3, 0, SUSPEND_REASON_HALT);	/* Wake up */
170 	}
171 #endif
172 }
173 
WRITE_HANDLER(saiyugb1_adpcm_rom_addr_w)174 static WRITE_HANDLER( saiyugb1_adpcm_rom_addr_w )
175 {
176 	/* i8748 Port 1 write */
177 	saiyugb1_i8748_P1 = data;
178 }
179 
WRITE_HANDLER(saiyugb1_adpcm_control_w)180 static WRITE_HANDLER( saiyugb1_adpcm_control_w )
181 {
182 	/* i8748 Port 2 write */
183 
184 	data8_t *saiyugb1_adpcm_rom = memory_region(REGION_SOUND1);
185 
186 	if (data & 0x80)	/* Reset m5205 and disable ADPCM ROM outputs */
187 	{
188 		log_cb(RETRO_LOG_DEBUG, LOGPRE "ADPCM output disabled\n");
189 		saiyugb1_pcm_nibble = 0x0f;
190 		MSM5205_reset_w(0,1);
191 	}
192 	else
193 	{
194 		if ( (saiyugb1_i8748_P2 & 0xc) != (data & 0xc) )
195 		{
196 			if ((saiyugb1_i8748_P2 & 0xc) == 0)	/* Latch MSB Address */
197 			{
198 /*/				log_cb(RETRO_LOG_DEBUG, LOGPRE "Latching MSB\n");*/
199 				saiyugb1_adpcm_addr = (saiyugb1_adpcm_addr & 0x3807f) | (saiyugb1_i8748_P1 << 7);
200 			}
201 			if ((saiyugb1_i8748_P2 & 0xc) == 4)	/* Latch LSB Address */
202 			{
203 /*/				log_cb(RETRO_LOG_DEBUG, LOGPRE "Latching LSB\n");*/
204 				saiyugb1_adpcm_addr = (saiyugb1_adpcm_addr & 0x3ff80) | (saiyugb1_i8748_P1 >> 1);
205 				saiyugb1_pcm_shift = (saiyugb1_i8748_P1 & 1) * 4;
206 			}
207 		}
208 
209 		saiyugb1_adpcm_addr = ((saiyugb1_adpcm_addr & 0x07fff) | (data & 0x70 << 11));
210 
211 		saiyugb1_pcm_nibble = saiyugb1_adpcm_rom[saiyugb1_adpcm_addr & 0x3ffff];
212 
213 		saiyugb1_pcm_nibble = (saiyugb1_pcm_nibble >> saiyugb1_pcm_shift) & 0x0f;
214 
215 /*/		log_cb(RETRO_LOG_DEBUG, LOGPRE "Writing %02x to m5205. $ROM=%08x  P1=%02x  P2=%02x  Prev_P2=%02x  Nibble=%08x\n",saiyugb1_pcm_nibble,saiyugb1_adpcm_addr,saiyugb1_i8748_P1,data,saiyugb1_i8748_P2,saiyugb1_pcm_shift);*/
216 
217 		if ( ((saiyugb1_i8748_P2 & 0xc) >= 8) && ((data & 0xc) == 4) )
218 		{
219 			MSM5205_data_w (0, saiyugb1_pcm_nibble);
220 			log_cb(RETRO_LOG_DEBUG, LOGPRE "Writing %02x to m5205\n",saiyugb1_pcm_nibble);
221 		}
222 		log_cb(RETRO_LOG_DEBUG, LOGPRE "$ROM=%08x  P1=%02x  P2=%02x  Prev_P2=%02x  Nibble=%1x  PCM_data=%02x\n",saiyugb1_adpcm_addr,saiyugb1_i8748_P1,data,saiyugb1_i8748_P2,saiyugb1_pcm_shift,saiyugb1_pcm_nibble);
223 	}
224 	saiyugb1_i8748_P2 = data;
225 }
226 
WRITE_HANDLER(saiyugb1_m5205_clk_w)227 static WRITE_HANDLER( saiyugb1_m5205_clk_w )
228 {
229 	/* i8748 T0 output clk mode */
230 	/* This signal goes through a divide by 8 counter */
231 	/* to the xtal pins of the MSM5205 */
232 
233 	/* Actually, T0 output clk mode is not supported by the i8048 core */
234 
235 #if 0
236 	saiyugb1_m5205_clk++;
237 	if (saiyugb1_m5205_clk == 8)
238 	}
239 		MSM5205_vclk_w (0, 1);		/* ??? */
240 		saiyugb1_m5205_clk = 0;
241 	}
242 	else
243 	}
244 		MSM5205_vclk_w (0, 0);		/* ??? */
245 	}
246 #endif
247 }
248 
READ_HANDLER(saiyugb1_m5205_irq_r)249 static READ_HANDLER( saiyugb1_m5205_irq_r )
250 {
251 	if (adpcm_sound_irq)
252 	{
253 		adpcm_sound_irq = 0;
254 		return 1;
255 	}
256 	return 0;
257 }
saiyugb1_m5205_irq_w(int num)258 static void saiyugb1_m5205_irq_w(int num)
259 {
260 	adpcm_sound_irq = 1;
261 }
262 
MEMORY_READ_START(readmem)263 static MEMORY_READ_START( readmem )
264 	{ 0x0000, 0x1fff, MRA_BANK2 },
265 	{ 0x3f00, 0x3f00, input_port_0_r },
266 	{ 0x3f01, 0x3f01, input_port_1_r },
267 	{ 0x3f02, 0x3f02, input_port_2_r },
268 	{ 0x3f03, 0x3f03, input_port_3_r },
269 	{ 0x3f04, 0x3f04, input_port_4_r },
270 	{ 0x4000, 0x7fff, MRA_BANK1 },
271 	{ 0x8000, 0xffff, MRA_ROM },
272 MEMORY_END
273 
274 static MEMORY_WRITE_START( writemem )
275 	{ 0x0000, 0x1fff, MWA_BANK2 },
276 	{ 0x2000, 0x27ff, ddragon_fgvideoram_w, &ddragon_fgvideoram },
277 	{ 0x2800, 0x2fff, ddragon_bgvideoram_w, &ddragon_bgvideoram },
278 	{ 0x3000, 0x317f, paletteram_xxxxBBBBGGGGRRRR_split1_w, &paletteram },
279 	{ 0x3400, 0x357f, paletteram_xxxxBBBBGGGGRRRR_split2_w, &paletteram_2 },
280 	{ 0x3800, 0x397f, MWA_BANK3, &spriteram, &spriteram_size },
281 	{ 0x3e00, 0x3e00, chinagat_cpu_sound_cmd_w },
282 /*	{ 0x3e01, 0x3e01, MWA_NOP },*/
283 /*	{ 0x3e02, 0x3e02, MWA_NOP },*/
284 /*	{ 0x3e03, 0x3e03, MWA_NOP },*/
285 	{ 0x3e04, 0x3e04, chinagat_sub_IRQ_w },
286 	{ 0x3e06, 0x3e06, MWA_RAM, &ddragon_scrolly_lo },
287 	{ 0x3e07, 0x3e07, MWA_RAM, &ddragon_scrollx_lo },
288 	{ 0x3f00, 0x3f00, chinagat_video_ctrl_w },
289 	{ 0x3f01, 0x3f01, chinagat_bankswitch_w },
290 	{ 0x4000, 0xffff, MWA_ROM },
291 MEMORY_END
292 
293 static MEMORY_READ_START( sub_readmem )
294 	{ 0x0000, 0x1fff, MRA_BANK2 },
295 /*	{ 0x2a2b, 0x2a2b, MRA_NOP },  // What lives here? /*/
296 /*	{ 0x2a30, 0x2a30, MRA_NOP },  // What lives here? /*/
297 	{ 0x4000, 0x7fff, MRA_BANK4 },
298 	{ 0x8000, 0xffff, MRA_ROM },
299 MEMORY_END
300 
301 static MEMORY_WRITE_START( sub_writemem )
302 	{ 0x0000, 0x1fff, MWA_BANK2 },
303 	{ 0x2000, 0x2000, chinagat_sub_bankswitch_w },
304 	{ 0x2800, 0x2800, MWA_RAM }, /* Called on CPU start and after return from jump table */
305 	{ 0x4000, 0xffff, MWA_ROM },
306 MEMORY_END
307 
308 static MEMORY_READ_START( sound_readmem )
309 	{ 0x0000, 0x7fff, MRA_ROM },
310 	{ 0x8000, 0x87ff, MRA_RAM },
311 	{ 0x8801, 0x8801, YM2151_status_port_0_r },
312 	{ 0x9800, 0x9800, OKIM6295_status_0_r },
313 	{ 0xA000, 0xA000, soundlatch_r },
314 MEMORY_END
315 
316 static MEMORY_WRITE_START( sound_writemem )
317 	{ 0x0000, 0x7fff, MWA_ROM },
318 	{ 0x8000, 0x87ff, MWA_RAM },
319 	{ 0x8800, 0x8800, YM2151_register_port_0_w },
320 	{ 0x8801, 0x8801, YM2151_data_port_0_w },
321 	{ 0x9800, 0x9800, OKIM6295_data_0_w },
322 MEMORY_END
323 
324 static MEMORY_READ_START( ym2203c_sound_readmem )
325 	{ 0x0000, 0x7fff, MRA_ROM },
326 	{ 0x8000, 0x87ff, MRA_RAM },
327 	{ 0x8800, 0x8800, YM2203_status_port_0_r },
328 /*	{ 0x8802, 0x8802, OKIM6295_status_0_r },*/
329 	{ 0x8804, 0x8804, YM2203_status_port_1_r },
330 /*	{ 0x8801, 0x8801, YM2151_status_port_0_r },*/
331 /*	{ 0x9800, 0x9800, OKIM6295_status_0_r },*/
332 	{ 0xA000, 0xA000, soundlatch_r },
333 MEMORY_END
334 
335 static MEMORY_WRITE_START( ym2203c_sound_writemem )
336 	{ 0x0000, 0x7fff, MWA_ROM },
337 	{ 0x8000, 0x87ff, MWA_RAM },
338 /* 8804 and/or 8805 make a gong sound when the coin goes in*/
339 /* but only on the title screen....*/
340 
341 	{ 0x8800, 0x8800, YM2203_control_port_0_w },
342 	{ 0x8801, 0x8801, YM2203_write_port_0_w },
343 /*	{ 0x8802, 0x8802, OKIM6295_data_0_w },*/
344 /*	{ 0x8803, 0x8803, OKIM6295_data_0_w },*/
345 	{ 0x8804, 0x8804, YM2203_control_port_1_w },
346 	{ 0x8805, 0x8805, YM2203_write_port_1_w },
347 /*	{ 0x8804, 0x8804, MWA_RAM },*/
348 /*	{ 0x8805, 0x8805, MWA_RAM },*/
349 
350 /*	{ 0x8800, 0x8800, YM2151_register_port_0_w },*/
351 /*	{ 0x8801, 0x8801, YM2151_data_port_0_w },*/
352 /*	{ 0x9800, 0x9800, OKIM6295_data_0_w },*/
353 MEMORY_END
354 
355 static MEMORY_READ_START( saiyugb1_sound_readmem )
356 	{ 0x0000, 0x7fff, MRA_ROM },
357 	{ 0x8000, 0x87ff, MRA_RAM },
358 	{ 0x8801, 0x8801, YM2151_status_port_0_r },
359 	{ 0xA000, 0xA000, soundlatch_r },
360 MEMORY_END
361 
362 static MEMORY_WRITE_START( saiyugb1_sound_writemem )
363 	{ 0x0000, 0x7fff, MWA_ROM },
364 	{ 0x8000, 0x87ff, MWA_RAM },
365 	{ 0x8800, 0x8800, YM2151_register_port_0_w },
366 	{ 0x8801, 0x8801, YM2151_data_port_0_w },
367 	{ 0x9800, 0x9800, saiyugb1_mcu_command_w },
368 MEMORY_END
369 
370 static MEMORY_READ_START( i8748_readmem )
371 	{ 0x0000, 0x03ff, MRA_ROM },
372 	{ 0x0400, 0x07ff, MRA_ROM },	/* i8749 version */
373 MEMORY_END
374 
375 static MEMORY_WRITE_START( i8748_writemem )
376 	{ 0x0000, 0x03ff, MWA_ROM },
377 	{ 0x0400, 0x07ff, MWA_ROM },
378 MEMORY_END
379 
380 static PORT_READ_START( i8748_readport )
381 	{ I8039_bus, I8039_bus, saiyugb1_mcu_command_r },
382 	{ I8039_t1,  I8039_t1,  saiyugb1_m5205_irq_r },
383 PORT_END
384 
385 static PORT_WRITE_START( i8748_writeport )
386 	{ I8039_t0,  I8039_t0,  saiyugb1_m5205_clk_w }, 		/* Drives the clock on the m5205 at 1/8 of this frequency */
387 	{ I8039_p1,  I8039_p1,  saiyugb1_adpcm_rom_addr_w },
388 	{ I8039_p2,  I8039_p2,  saiyugb1_adpcm_control_w },
389 PORT_END
390 
391 
392 
393 INPUT_PORTS_START( chinagat )
394 	PORT_START
395 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_VBLANK )
396 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN1 )
397 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 )
398 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN3 )
399 	PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNKNOWN )
400 
401 	PORT_START
402 	PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )
403 	PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )
404 	PORT_DIPSETTING(    0x01, DEF_STR( 3C_1C ) )
405 	PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) )
406 	PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
407 	PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) )
408 	PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
409 	PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
410 	PORT_DIPSETTING(    0x03, DEF_STR( 1C_5C ) )
411 	PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )
412 	PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )
413 	PORT_DIPSETTING(    0x08, DEF_STR( 3C_1C ) )
414 	PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
415 	PORT_DIPSETTING(    0x38, DEF_STR( 1C_1C ) )
416 	PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) )
417 	PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) )
418 	PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) )
419 	PORT_DIPSETTING(    0x18, DEF_STR( 1C_5C ) )
420 	/*PORT_DIPNAME( 0x40, 0x00, DEF_STR( Cabinet ) )
421 	PORT_DIPSETTING(	0x00, DEF_STR( Upright ) )
422 	PORT_DIPSETTING(	0x40, DEF_STR( Cocktail ) )*/
423 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
424 	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) )
425 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
426 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
427 
428 	PORT_START
429 	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
430 	PORT_DIPSETTING(	0x01, "Easy" )
431 	PORT_DIPSETTING(	0x03, "Normal" )
432 	PORT_DIPSETTING(	0x02, "Hard" )
433 	PORT_DIPSETTING(	0x00, "Hardest" )
434 	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Demo_Sounds ) )
435 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
436 	PORT_DIPSETTING(    0x04, DEF_STR( On ))
437 	PORT_DIPNAME( 0x30, 0x30, "Timer" )
438 	PORT_DIPSETTING(    0x00, "50" )
439 	PORT_DIPSETTING(    0x20, "55" )
440 	PORT_DIPSETTING(    0x30, "60" )
441 	PORT_DIPSETTING(    0x10, "70" )
442 	PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Lives ) )
443 	PORT_DIPSETTING(    0x00, "1" )
444 	PORT_DIPSETTING(    0xc0, "2" )
445 	PORT_DIPSETTING(    0x80, "3" )
446 	PORT_DIPSETTING(    0x40, "4" )
447 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
448 
449 	PORT_START
450 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
451 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
452 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )
453 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )
454 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
455 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
456 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
457 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
458 
459 	PORT_START
460 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
461 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER2 )
462 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER2 )
463 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER2 )
464 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
465 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
466 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
467 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
468 INPUT_PORTS_END
469 
470 static struct GfxLayout charlayout =
471 {
472 	8,8,			/* 8*8 chars */
473 	RGN_FRAC(1,1),	/* num of characters */
474 	4,				/* 4 bits per pixel */
475 	{ 0, 2, 4, 6 },		/* plane offset */
476 	{ 1, 0, 65, 64, 129, 128, 193, 192 },
477 	{ STEP8(0,8) },			/* { 0*8, 1*8 ... 6*8, 7*8 }, */
478 	32*8 /* every char takes 32 consecutive bytes */
479 };
480 
481 static struct GfxLayout tilelayout =
482 {
483 	16,16,			/* 16x16 chars */
484 	RGN_FRAC(1,2),	/* num of Tiles/Sprites */
485 	4,				/* 4 bits per pixel */
486 	{ RGN_FRAC(1,2)+0, RGN_FRAC(1,2)+4, 0,4 }, /* plane offset */
487 	{ 3, 2, 1, 0, 16*8+3, 16*8+2, 16*8+1, 16*8+0,
488 		32*8+3,32*8+2 ,32*8+1 ,32*8+0 ,48*8+3 ,48*8+2 ,48*8+1 ,48*8+0 },
489 	{ STEP16(0,8) },		/* { 0*8, 1*8 ... 14*8, 15*8 }, */
490 	64*8 /* every char takes 64 consecutive bytes */
491 };
492 
493 static struct GfxDecodeInfo gfxdecodeinfo[] =
494 {
495 	{ REGION_GFX1, 0, &charlayout,   0,16 },	/*  8x8  chars */
496 	{ REGION_GFX2, 0, &tilelayout, 128, 8 },	/* 16x16 sprites */
497 	{ REGION_GFX3, 0, &tilelayout, 256, 8 },	/* 16x16 background tiles */
498 	{ -1 } /* end of array */
499 };
500 
chinagat_irq_handler(int irq)501 static void chinagat_irq_handler(int irq) {
502 	cpu_set_irq_line( 2, 0, irq ? ASSERT_LINE : CLEAR_LINE );
503 }
504 
505 static struct YM2151interface ym2151_interface =
506 {
507 	1,			/* 1 chip */
508 	3579545,	/* 3.579545 oscillator */
509 	{ YM3012_VOL(80,MIXER_PAN_LEFT,80,MIXER_PAN_RIGHT) },	/* only right channel is connected */
510 	{ chinagat_irq_handler }
511 };
512 
513 
514 static struct OKIM6295interface okim6295_interface =
515 {
516 	1,					/* 1 chip */
517 	{ 11000 },			/* ??? frequency (Hz) */
518 	{ REGION_SOUND1 },	/* memory region */
519 	{ 45 }
520 };
521 
522 /* This on the bootleg board, instead of the m6295 */
523 static struct MSM5205interface msm5205_interface =
524 {
525 	1,							/* 1 chip */
526 	9263750 / 24,				/* 385989.6 Hz from the 9.26375MHz oscillator */
527 	{ saiyugb1_m5205_irq_w },	/* Interrupt function */
528 	{ MSM5205_S64_4B },			/* vclk input mode (6030Hz, 4-bit) */
529 	{ 60 }
530 };
531 
INTERRUPT_GEN(chinagat_interrupt)532 static INTERRUPT_GEN( chinagat_interrupt )
533 {
534 	cpu_set_irq_line(0, 1, HOLD_LINE);	/* hold the FIRQ line */
535 	cpu_set_nmi_line(0, PULSE_LINE);	/* pulse the NMI line */
536 }
537 
538 /* This is only on the second bootleg board */
539 static struct YM2203interface ym2203_interface =
540 {
541 	2,			/* 2 chips */
542 	3579545,	/* 3.579545 oscillator */
543 	{ YM2203_VOL(80,50), YM2203_VOL(80,50) },
544 	{ 0 },
545 	{ 0 },
546 	{ 0 },
547 	{ 0 },
548 	{ chinagat_irq_handler }
549 };
550 
551 static MACHINE_DRIVER_START( chinagat )
552 
553 	/* basic machine hardware */
554 	MDRV_CPU_ADD(HD6309,12000000/8)		/* 1.5 MHz (12MHz oscillator ???) */
555 	MDRV_CPU_MEMORY(readmem,writemem)
556 	MDRV_CPU_VBLANK_INT(chinagat_interrupt,1)
557 
558 	MDRV_CPU_ADD(HD6309,12000000/8)		/* 1.5 MHz (12MHz oscillator ???) */
559 	MDRV_CPU_MEMORY(sub_readmem,sub_writemem)
560 
561 	MDRV_CPU_ADD(Z80, 3579545)	/* 3.579545 MHz */
562 	MDRV_CPU_MEMORY(sound_readmem,sound_writemem)
563 
564 	MDRV_FRAMES_PER_SECOND(56)
565 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
566 	MDRV_INTERLEAVE(100) /* heavy interleaving to sync up sprite<->main cpu's */
567 
568 	MDRV_MACHINE_INIT(chinagat)
569 
570 	/* video hardware */
571 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
572 	MDRV_SCREEN_SIZE(32*8, 32*8)
573 	MDRV_VISIBLE_AREA(1*8, 31*8-1, 2*8, 30*8-1)
574 	MDRV_GFXDECODE(gfxdecodeinfo)
575 	MDRV_PALETTE_LENGTH(384)
576 
577 	MDRV_VIDEO_START(chinagat)
578 	MDRV_VIDEO_UPDATE(ddragon)
579 
580 	/* sound hardware */
581 	MDRV_SOUND_ADD(YM2151, ym2151_interface)
582 	MDRV_SOUND_ADD(OKIM6295, okim6295_interface)
583 MACHINE_DRIVER_END
584 
585 static MACHINE_DRIVER_START( saiyugb1 )
586 
587 	/* basic machine hardware */
588 	MDRV_CPU_ADD(M6809,12000000/8)		/* 68B09EP 1.5 MHz (12MHz oscillator) */
589 	MDRV_CPU_MEMORY(readmem,writemem)
590 	MDRV_CPU_VBLANK_INT(chinagat_interrupt,1)
591 
592 	MDRV_CPU_ADD(M6809,12000000/8)		/* 68B09EP 1.5 MHz (12MHz oscillator) */
593 	MDRV_CPU_MEMORY(sub_readmem,sub_writemem)
594 
595 	MDRV_CPU_ADD(Z80, 3579545)		/* 3.579545 MHz oscillator */
596 	MDRV_CPU_MEMORY(saiyugb1_sound_readmem,saiyugb1_sound_writemem)
597 
598 	MDRV_CPU_ADD(I8048,9263750/3)		/* 3.087916 MHz (9.263750 MHz oscillator) */
599 	MDRV_CPU_MEMORY(i8748_readmem,i8748_writemem)
600 	MDRV_CPU_PORTS(i8748_readport,i8748_writeport)
601 
602 	MDRV_FRAMES_PER_SECOND(56)
603 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
604 	MDRV_INTERLEAVE(100)	/* heavy interleaving to sync up sprite<->main cpu's */
605 
606 	MDRV_MACHINE_INIT(chinagat)
607 
608 	/* video hardware */
609 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
610 	MDRV_SCREEN_SIZE(32*8, 32*8)
611 	MDRV_VISIBLE_AREA(1*8, 31*8-1, 2*8, 30*8-1)
612 	MDRV_GFXDECODE(gfxdecodeinfo)
613 	MDRV_PALETTE_LENGTH(384)
614 
615 	MDRV_VIDEO_START(chinagat)
616 	MDRV_VIDEO_UPDATE(ddragon)
617 
618 	/* sound hardware */
619 	MDRV_SOUND_ADD(YM2151, ym2151_interface)
620 	MDRV_SOUND_ADD(MSM5205, msm5205_interface)
621 MACHINE_DRIVER_END
622 
623 static MACHINE_DRIVER_START( saiyugb2 )
624 
625 	/* basic machine hardware */
626 	MDRV_CPU_ADD(M6809,12000000/8)		/* 1.5 MHz (12MHz oscillator) */
627 	MDRV_CPU_MEMORY(readmem,writemem)
628 	MDRV_CPU_VBLANK_INT(chinagat_interrupt,1)
629 
630 	MDRV_CPU_ADD(M6809,12000000/8)		/* 1.5 MHz (12MHz oscillator) */
631 	MDRV_CPU_MEMORY(sub_readmem,sub_writemem)
632 
633 	MDRV_CPU_ADD(Z80, 3579545)		/* 3.579545 MHz oscillator */
634 	MDRV_CPU_MEMORY(ym2203c_sound_readmem,ym2203c_sound_writemem)
635 
636 	MDRV_FRAMES_PER_SECOND(56)
637 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
638 	MDRV_INTERLEAVE(100) /* heavy interleaving to sync up sprite<->main cpu's */
639 
640 	MDRV_MACHINE_INIT(chinagat)
641 
642 	/* video hardware */
643 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
644 	MDRV_SCREEN_SIZE(32*8, 32*8)
645 	MDRV_VISIBLE_AREA(1*8, 31*8-1, 2*8, 30*8-1)
646 	MDRV_GFXDECODE(gfxdecodeinfo)
647 	MDRV_PALETTE_LENGTH(384)
648 
649 	MDRV_VIDEO_START(chinagat)
650 	MDRV_VIDEO_UPDATE(ddragon)
651 
652 	/* sound hardware */
653 	MDRV_SOUND_ADD(YM2203, ym2203_interface)
654 MACHINE_DRIVER_END
655 
656 
657 /***************************************************************************
658 
659   Game driver(s)
660 
661 ***************************************************************************/
662 
663 ROM_START( chinagat )
664 	ROM_REGION( 0x28000, REGION_CPU1, 0 )	/* Main CPU: 128KB for code (bankswitched using $3F01) */
665 	ROM_LOAD( "cgate51.bin", 0x10000, 0x18000, CRC(439a3b19) SHA1(01393b4302ac7a66390270b01e2757582240f6b8) )	/* Banks 0x4000 long @ 0x4000 */
666 	ROM_CONTINUE(            0x08000, 0x08000 )				/* Static code */
667 
668 	ROM_REGION( 0x28000, REGION_CPU2, 0 )	/* Slave CPU: 128KB for code (bankswitched using $2000) */
669 	ROM_LOAD( "23j4-0.48",   0x10000, 0x18000, CRC(2914af38) SHA1(3d690fa50b7d36a22de82c026d59a16126a7b73c) ) /* Banks 0x4000 long @ 0x4000 */
670 	ROM_CONTINUE(            0x08000, 0x08000 )				/* Static code */
671 
672 	ROM_REGION( 0x10000, REGION_CPU3, 0 )	/* Music CPU, 64KB */
673 	ROM_LOAD( "23j0-0.40",   0x00000, 0x08000, CRC(9ffcadb6) SHA1(606dbdd73aee3cabb2142200ac6f8c96169e4b19) )
674 
675 	ROM_REGION(0x20000, REGION_GFX1, ROMREGION_DISPOSE )	/* Text */
676 	ROM_LOAD( "cgate18.bin", 0x00000, 0x20000, CRC(8d88d64d) SHA1(57265138ebb0c6419542cce5953aee7335bfa2bd) )	/* 0,1,2,3 */
677 
678 	ROM_REGION(0x80000, REGION_GFX2, ROMREGION_DISPOSE )	/* Sprites */
679 	ROM_LOAD( "23j7-0.103",  0x00000, 0x20000, CRC(2f445030) SHA1(3fcf32097e655e963d952d01a30396dc195269ca) )	/* 2,3 */
680 	ROM_LOAD( "23j8-0.102",  0x20000, 0x20000, CRC(237f725a) SHA1(47bebe5b9878ca10fe6efd4f353717e53a372416) )	/* 2,3 */
681 	ROM_LOAD( "23j9-0.101",  0x40000, 0x20000, CRC(8caf6097) SHA1(50ad192f831b055586a4a9974f8c6c2f2063ede5) )	/* 0,1 */
682 	ROM_LOAD( "23ja-0.100",  0x60000, 0x20000, CRC(f678594f) SHA1(4bdcf9407543925f4630a8c7f1f48b85f76343a9) )	/* 0,1 */
683 
684 	ROM_REGION(0x40000, REGION_GFX3, ROMREGION_DISPOSE )	/* Background */
685 	ROM_LOAD( "a1-13", 0x00000, 0x10000, BAD_DUMP CRC(b745cac4) SHA1(759767ca7c5123b03b9e1a42bb105d194cb76400) )
686 	ROM_LOAD( "a1-12", 0x10000, 0x10000, BAD_DUMP CRC(3c864299) SHA1(cb12616e4d6c53a82beb4cd51510a632894b359c) )
687 	ROM_LOAD( "a1-15", 0x20000, 0x10000, BAD_DUMP CRC(2f268f37) SHA1(f82cfe3b2001d5ed2a709ca9c51febcf624bb627) )
688 	ROM_LOAD( "a1-14", 0x30000, 0x10000, BAD_DUMP CRC(aef814c8) SHA1(f6b9229ca7beb9a0e47d1f6a1083c6102fdd20c8) )
689 
690 	ROM_REGION(0x40000, REGION_SOUND1, 0 )	/* ADPCM */
691 	ROM_LOAD( "23j1-0.53", 0x00000, 0x20000, CRC(f91f1001) SHA1(378402a3c966cabd61e9662ae5decd66672a228b) )
692 	ROM_LOAD( "23j2-0.52", 0x20000, 0x20000, CRC(8b6f26e9) SHA1(7da26ae846814b3957b19c38b6bf7e83617dc6cc) )
693 
694 	ROM_REGION(0x300, REGION_USER1, 0 )	/* Unknown Bipolar PROMs */
695 	ROM_LOAD( "23jb-0.16", 0x000, 0x200, CRC(46339529) SHA1(64f4c42a826d67b7cbaa8a23a45ebc4eb6248891) )	/* 82S131 on video board */
696 	ROM_LOAD( "23j5-0.45", 0x200, 0x100, CRC(fdb130a9) SHA1(4c4f214229b9fab2b5d69c745ec5428787b89e1f) )	/* 82S129 on main board */
697 ROM_END
698 
699 
700 ROM_START( saiyugou )
701 	ROM_REGION( 0x28000, REGION_CPU1, 0 )	/* Main CPU: 128KB for code (bankswitched using $3F01) */
702 	ROM_LOAD( "23j3-0.51",  0x10000, 0x18000, CRC(aa8132a2) SHA1(87c3bd447767f263113c4865afc905a0e484a625) )	/* Banks 0x4000 long @ 0x4000 */
703 	ROM_CONTINUE(           0x08000, 0x08000)				/* Static code */
704 
705 	ROM_REGION( 0x28000, REGION_CPU2, 0 )	/* Slave CPU: 128KB for code (bankswitched using $2000) */
706 	ROM_LOAD( "23j4-0.48",  0x10000, 0x18000, CRC(2914af38) SHA1(3d690fa50b7d36a22de82c026d59a16126a7b73c) )	/* Banks 0x4000 long @ 0x4000 */
707 	ROM_CONTINUE(           0x08000, 0x08000)				/* Static code */
708 
709 	ROM_REGION( 0x10000, REGION_CPU3, 0 )	/* Music CPU, 64KB */
710 	ROM_LOAD( "23j0-0.40",  0x00000, 0x8000, CRC(9ffcadb6) SHA1(606dbdd73aee3cabb2142200ac6f8c96169e4b19) )
711 
712 	ROM_REGION(0x20000, REGION_GFX1, ROMREGION_DISPOSE )	/* Text */
713 	ROM_LOAD( "23j6-0.18",  0x00000, 0x20000, CRC(86d33df0) SHA1(3419959c28703c5177de9c11b61e1dba9e76aca5) )	/* 0,1,2,3 */
714 
715 	ROM_REGION(0x80000, REGION_GFX2, ROMREGION_DISPOSE )	/* Sprites */
716 	ROM_LOAD( "23j7-0.103", 0x00000, 0x20000, CRC(2f445030) SHA1(3fcf32097e655e963d952d01a30396dc195269ca) )	/* 2,3 */
717 	ROM_LOAD( "23j8-0.102", 0x20000, 0x20000, CRC(237f725a) SHA1(47bebe5b9878ca10fe6efd4f353717e53a372416) )	/* 2,3 */
718 	ROM_LOAD( "23j9-0.101", 0x40000, 0x20000, CRC(8caf6097) SHA1(50ad192f831b055586a4a9974f8c6c2f2063ede5) )	/* 0,1 */
719 	ROM_LOAD( "23ja-0.100", 0x60000, 0x20000, CRC(f678594f) SHA1(4bdcf9407543925f4630a8c7f1f48b85f76343a9) )	/* 0,1 */
720 
721 	ROM_REGION(0x40000, REGION_GFX3, ROMREGION_DISPOSE )	/* Background */
722 	ROM_LOAD( "a2-13", 0x00000, 0x10000, BAD_DUMP CRC(b745cac4) SHA1(759767ca7c5123b03b9e1a42bb105d194cb76400) )
723 	ROM_LOAD( "a2-12", 0x10000, 0x10000, BAD_DUMP CRC(3c864299) SHA1(cb12616e4d6c53a82beb4cd51510a632894b359c) )
724 	ROM_LOAD( "a2-15", 0x20000, 0x10000, BAD_DUMP CRC(2f268f37) SHA1(f82cfe3b2001d5ed2a709ca9c51febcf624bb627) )
725 	ROM_LOAD( "a2-14", 0x30000, 0x10000, BAD_DUMP CRC(aef814c8) SHA1(f6b9229ca7beb9a0e47d1f6a1083c6102fdd20c8) )
726 
727 	ROM_REGION(0x40000, REGION_SOUND1, 0 )	/* ADPCM */
728 	ROM_LOAD( "23j1-0.53", 0x00000, 0x20000, CRC(f91f1001) SHA1(378402a3c966cabd61e9662ae5decd66672a228b) )
729 	ROM_LOAD( "23j2-0.52", 0x20000, 0x20000, CRC(8b6f26e9) SHA1(7da26ae846814b3957b19c38b6bf7e83617dc6cc) )
730 
731 	ROM_REGION(0x300, REGION_USER1, 0 )	/* Unknown Bipolar PROMs */
732 	ROM_LOAD( "23jb-0.16", 0x000, 0x200, CRC(46339529) SHA1(64f4c42a826d67b7cbaa8a23a45ebc4eb6248891) )	/* 82S131 on video board */
733 	ROM_LOAD( "23j5-0.45", 0x200, 0x100, CRC(fdb130a9) SHA1(4c4f214229b9fab2b5d69c745ec5428787b89e1f) )	/* 82S129 on main board */
734 ROM_END
735 
736 ROM_START( saiyugb1 )
737 	ROM_REGION( 0x28000, REGION_CPU1, 0 )	/* Main CPU: 128KB for code (bankswitched using $3F01) */
738 	ROM_LOAD( "23j3-0.51",  0x10000, 0x18000, CRC(aa8132a2) SHA1(87c3bd447767f263113c4865afc905a0e484a625) )	/* Banks 0x4000 long @ 0x4000 */
739 	/* Orientation of bootleg ROMs which are split, but otherwise the same.
740 	   ROM_LOAD( "a-5.bin", 0x10000, 0x10000, CRC(39795aa5) )	   Banks 0x4000 long @ 0x4000
741 	   ROM_LOAD( "a-9.bin", 0x20000, 0x08000, CRC(051ebe92) )	   Banks 0x4000 long @ 0x4000
742 	*/
743 	ROM_CONTINUE(           0x08000, 0x08000 )				/* Static code */
744 
745 	ROM_REGION( 0x28000, REGION_CPU2, 0 )	/* Slave CPU: 128KB for code (bankswitched using $2000) */
746 	ROM_LOAD( "23j4-0.48",  0x10000, 0x18000, CRC(2914af38) SHA1(3d690fa50b7d36a22de82c026d59a16126a7b73c) )	/* Banks 0x4000 long @ 0x4000 */
747 	/* Orientation of bootleg ROMs which are split, but otherwise the same.
748 	   ROM_LOAD( "a-4.bin", 0x10000, 0x10000, CRC(9effddc1) )	   Banks 0x4000 long @ 0x4000
749 	   ROM_LOAD( "a-8.bin", 0x20000, 0x08000, CRC(a436edb8) )	   Banks 0x4000 long @ 0x4000
750 	*/
751 	ROM_CONTINUE(           0x08000, 0x08000 )				/* Static code */
752 
753 	ROM_REGION( 0x10000, REGION_CPU3, 0 )	/* Music CPU, 64KB */
754 	ROM_LOAD( "a-1.bin",  0x00000, 0x8000,  CRC(46e5a6d4) SHA1(965ed7bdb727ab32ce3322ca49f1a4e3786e8051) )
755 
756 	ROM_REGION( 0x800, REGION_CPU4, 0 )		/* ADPCM CPU, 1KB */
757 	ROM_LOAD( "mcu8748.bin", 0x000, 0x400, CRC(6d28d6c5) SHA1(20582c62a72545e68c2e155b063ee7e95e1228ce) )
758 
759 	ROM_REGION(0x20000, REGION_GFX1, ROMREGION_DISPOSE )	/* Text */
760 	ROM_LOAD( "23j6-0.18",  0x00000, 0x20000, CRC(86d33df0) SHA1(3419959c28703c5177de9c11b61e1dba9e76aca5) )	/* 0,1,2,3 */
761 	/* Orientation of bootleg ROMs which are split, but otherwise the same.
762 	   ROM_LOAD( "a-2.bin", 0x00000, 0x10000, CRC(baa5a3b9) )	   0,1
763 	   ROM_LOAD( "a-3.bin", 0x10000, 0x10000, CRC(532d59be) )	   2,3
764 	*/
765 
766 	ROM_REGION(0x80000, REGION_GFX2, ROMREGION_DISPOSE )	/* Sprites */
767 	ROM_LOAD( "23j7-0.103",  0x00000, 0x20000, CRC(2f445030) SHA1(3fcf32097e655e963d952d01a30396dc195269ca) )	/* 2,3 */
768 	ROM_LOAD( "23j8-0.102",  0x20000, 0x20000, CRC(237f725a) SHA1(47bebe5b9878ca10fe6efd4f353717e53a372416) )	/* 2,3 */
769 	ROM_LOAD( "23j9-0.101",  0x40000, 0x20000, CRC(8caf6097) SHA1(50ad192f831b055586a4a9974f8c6c2f2063ede5) )	/* 0,1 */
770 	ROM_LOAD( "23ja-0.100",  0x60000, 0x20000, CRC(f678594f) SHA1(4bdcf9407543925f4630a8c7f1f48b85f76343a9) )	/* 0,1 */
771 	/* Orientation of bootleg ROMs which are split, but otherwise the same
772 	   ROM_LOAD( "a-23.bin", 0x00000, 0x10000, CRC(12b56225) )	   2,3
773 	   ROM_LOAD( "a-22.bin", 0x10000, 0x10000, CRC(b592aa9b) )	   2,3
774 	   ROM_LOAD( "a-21.bin", 0x20000, 0x10000, CRC(a331ba3d) )	   2,3
775 	   ROM_LOAD( "a-20.bin", 0x30000, 0x10000, CRC(2515d742) )	   2,3
776 	   ROM_LOAD( "a-19.bin", 0x40000, 0x10000, CRC(d796f2e4) )	   0,1
777 	   ROM_LOAD( "a-18.bin", 0x50000, 0x10000, CRC(c9e1c2f9) )	   0,1
778 	   ROM_LOAD( "a-17.bin", 0x60000, 0x10000, CRC(00b6db0a) )	   0,1
779 	   ROM_LOAD( "a-16.bin", 0x70000, 0x10000, CRC(f196818b) )	   0,1
780 	*/
781 
782 	ROM_REGION(0x40000, REGION_GFX3, ROMREGION_DISPOSE )	/* Background */
783 	ROM_LOAD( "a-13", 0x00000, 0x10000, CRC(b745cac4) SHA1(759767ca7c5123b03b9e1a42bb105d194cb76400) )
784 	ROM_LOAD( "a-12", 0x10000, 0x10000, CRC(3c864299) SHA1(cb12616e4d6c53a82beb4cd51510a632894b359c) )
785 	ROM_LOAD( "a-15", 0x20000, 0x10000, CRC(2f268f37) SHA1(f82cfe3b2001d5ed2a709ca9c51febcf624bb627) )
786 	ROM_LOAD( "a-14", 0x30000, 0x10000, CRC(aef814c8) SHA1(f6b9229ca7beb9a0e47d1f6a1083c6102fdd20c8) )
787 
788 	/* Some bootlegs have incorrectly halved the ADPCM data ! */
789 	/* These are same as the 128k sample except nibble-swapped */
790 	ROM_REGION(0x40000, REGION_SOUND1, 0 )	/* ADPCM */		/* Bootleggers wrong data */
791 	ROM_LOAD ( "a-6.bin",   0x00000, 0x10000, CRC(4da4e935) SHA1(235a1589165a23cfad29e07cf66d7c3a777fc904) )	/* 0x8000, 0x7cd47f01 */
792 	ROM_LOAD ( "a-7.bin",   0x10000, 0x10000, CRC(6284c254) SHA1(e01be1bd4768ae0ccb1cec65b3a6bc80ed7a4b00) )	/* 0x8000, 0x7091959c */
793 	ROM_LOAD ( "a-10.bin",  0x20000, 0x10000, CRC(b728ec6e) SHA1(433b5f907e4918e89b79bd927e2993ad3030017b) )	/* 0x8000, 0x78349cb6 */
794 	ROM_LOAD ( "a-11.bin",  0x30000, 0x10000, CRC(a50d1895) SHA1(0c2c1f8a2e945d6c53ce43413f0e63ced45bae17) )	/* 0x8000, 0xaa5b6834 */
795 
796 	ROM_REGION(0x300, REGION_USER1, 0 )	/* Unknown Bipolar PROMs */
797 	ROM_LOAD( "23jb-0.16", 0x000, 0x200, CRC(46339529) SHA1(64f4c42a826d67b7cbaa8a23a45ebc4eb6248891) )	/* 82S131 on video board */
798 	ROM_LOAD( "23j5-0.45", 0x200, 0x100, CRC(fdb130a9) SHA1(4c4f214229b9fab2b5d69c745ec5428787b89e1f) )	/* 82S129 on main board */
799 ROM_END
800 
801 ROM_START( saiyugb2 )
802 	ROM_REGION( 0x28000, REGION_CPU1, 0 )	/* Main CPU: 128KB for code (bankswitched using $3F01) */
803 	ROM_LOAD( "23j3-0.51",   0x10000, 0x18000, CRC(aa8132a2) SHA1(87c3bd447767f263113c4865afc905a0e484a625) )	/* Banks 0x4000 long @ 0x4000 */
804 	/* Orientation of bootleg ROMs which are split, but otherwise the same.
805 	   ROM_LOAD( "sai5.bin", 0x10000, 0x10000, CRC(39795aa5) )	   Banks 0x4000 long @ 0x4000
806 	   ROM_LOAD( "sai9.bin", 0x20000, 0x08000, CRC(051ebe92) )	   Banks 0x4000 long @ 0x4000
807 	*/
808 	ROM_CONTINUE(            0x08000, 0x08000 )				/* Static code */
809 
810 	ROM_REGION( 0x28000, REGION_CPU2, 0 )	/* Slave CPU: 128KB for code (bankswitched using $2000) */
811 	ROM_LOAD( "23j4-0.48", 0x10000, 0x18000, CRC(2914af38) SHA1(3d690fa50b7d36a22de82c026d59a16126a7b73c) )	/* Banks 0x4000 long @ 0x4000 */
812 	/* Orientation of bootleg ROMs which are split, but otherwise the same.
813 	   ROM_LOAD( "sai4.bin", 0x10000, 0x10000, CRC(9effddc1) )	   Banks 0x4000 long @ 0x4000
814 	   ROM_LOAD( "sai8.bin", 0x20000, 0x08000, CRC(a436edb8) )	   Banks 0x4000 long @ 0x4000
815 	*/
816 	ROM_CONTINUE(         0x08000, 0x08000 )				/* Static code */
817 
818 	ROM_REGION( 0x10000, REGION_CPU3, 0 )	/* Music CPU, 64KB */
819 	ROM_LOAD( "sai-alt1.bin", 0x00000, 0x8000, CRC(8d397a8d) SHA1(52599521c3dbcecc1ae56bb80dc855e76d700134) )
820 
821 /*	ROM_REGION( 0x800, REGION_CPU4, 0 )		 // ADPCM CPU, 1KB /*/
822 /*	ROM_LOAD( "sgr-8749.bin", 0x000, 0x800, CRC(9237e8c5) )  // same as above but padded with 00 for different mcu /*/
823 
824 	ROM_REGION(0x20000, REGION_GFX1, ROMREGION_DISPOSE )	/* Text */
825 	ROM_LOAD( "23j6-0.18", 0x00000, 0x20000, CRC(86d33df0) SHA1(3419959c28703c5177de9c11b61e1dba9e76aca5) )	/* 0,1,2,3 */
826 	/* Orientation of bootleg ROMs which are split, but otherwise the same.
827 	   ROM_LOAD( "sai2.bin", 0x00000, 0x10000, CRC(baa5a3b9) )	   0,1
828 	   ROM_LOAD( "sai3.bin", 0x10000, 0x10000, CRC(532d59be) )	   2,3
829 	*/
830 
831 	ROM_REGION(0x80000, REGION_GFX2, ROMREGION_DISPOSE )	/* Sprites */
832 	ROM_LOAD( "23j7-0.103",   0x00000, 0x20000, CRC(2f445030) SHA1(3fcf32097e655e963d952d01a30396dc195269ca) )	/* 2,3 */
833 	ROM_LOAD( "23j8-0.102",   0x20000, 0x20000, CRC(237f725a) SHA1(47bebe5b9878ca10fe6efd4f353717e53a372416) )	/* 2,3 */
834 	ROM_LOAD( "23j9-0.101",   0x40000, 0x20000, CRC(8caf6097) SHA1(50ad192f831b055586a4a9974f8c6c2f2063ede5) )	/* 0,1 */
835 	ROM_LOAD( "23ja-0.100",   0x60000, 0x20000, CRC(f678594f) SHA1(4bdcf9407543925f4630a8c7f1f48b85f76343a9) )	/* 0,1 */
836 	/* Orientation of bootleg ROMs which are split, but otherwise the same
837 	   ROM_LOAD( "sai23.bin", 0x00000, 0x10000, CRC(12b56225) )	   2,3
838 	   ROM_LOAD( "sai22.bin", 0x10000, 0x10000, CRC(b592aa9b) )	   2,3
839 	   ROM_LOAD( "sai21.bin", 0x20000, 0x10000, CRC(a331ba3d) )	   2,3
840 	   ROM_LOAD( "sai20.bin", 0x30000, 0x10000, CRC(2515d742) )	   2,3
841 	   ROM_LOAD( "sai19.bin", 0x40000, 0x10000, CRC(d796f2e4) )	   0,1
842 	   ROM_LOAD( "sai18.bin", 0x50000, 0x10000, CRC(c9e1c2f9) )	   0,1
843 	   ROM_LOAD( "roku17.bin",0x60000, 0x10000, CRC(00b6db0a) )	   0,1
844 	   ROM_LOAD( "sai16.bin", 0x70000, 0x10000, CRC(f196818b) )	   0,1
845 	*/
846 
847 	ROM_REGION(0x40000, REGION_GFX3, ROMREGION_DISPOSE )	/* Background */
848 	ROM_LOAD( "a-13", 0x00000, 0x10000, CRC(b745cac4) SHA1(759767ca7c5123b03b9e1a42bb105d194cb76400) )
849 	ROM_LOAD( "a-12", 0x10000, 0x10000, CRC(3c864299) SHA1(cb12616e4d6c53a82beb4cd51510a632894b359c) )
850 	ROM_LOAD( "a-15", 0x20000, 0x10000, CRC(2f268f37) SHA1(f82cfe3b2001d5ed2a709ca9c51febcf624bb627) )
851 	ROM_LOAD( "a-14", 0x30000, 0x10000, CRC(aef814c8) SHA1(f6b9229ca7beb9a0e47d1f6a1083c6102fdd20c8) )
852 
853 	ROM_REGION(0x40000, REGION_SOUND1, 0 )	/* ADPCM */
854 	/* These are same as the 128k sample except nibble-swapped */
855 	/* Some bootlegs have incorrectly halved the ADPCM data !  Bootleggers wrong data */
856 	ROM_LOAD ( "a-6.bin",   0x00000, 0x10000, CRC(4da4e935) SHA1(235a1589165a23cfad29e07cf66d7c3a777fc904) )	/* 0x8000, 0x7cd47f01 */
857 	ROM_LOAD ( "a-7.bin",   0x10000, 0x10000, CRC(6284c254) SHA1(e01be1bd4768ae0ccb1cec65b3a6bc80ed7a4b00) )	/* 0x8000, 0x7091959c */
858 	ROM_LOAD ( "a-10.bin",  0x20000, 0x10000, CRC(b728ec6e) SHA1(433b5f907e4918e89b79bd927e2993ad3030017b) )	/* 0x8000, 0x78349cb6 */
859 	ROM_LOAD ( "a-11.bin",  0x30000, 0x10000, CRC(a50d1895) SHA1(0c2c1f8a2e945d6c53ce43413f0e63ced45bae17) )	/* 0x8000, 0xaa5b6834 */
860 
861 	ROM_REGION(0x300, REGION_USER1, 0 )	/* Unknown Bipolar PROMs */
862 	ROM_LOAD( "23jb-0.16", 0x000, 0x200, CRC(46339529) SHA1(64f4c42a826d67b7cbaa8a23a45ebc4eb6248891) )	/* 82S131 on video board */
863 	ROM_LOAD( "23j5-0.45", 0x200, 0x100, CRC(fdb130a9) SHA1(4c4f214229b9fab2b5d69c745ec5428787b89e1f) )	/* 82S129 on main board */
864 ROM_END
865 
866 
867 
868 /*   ( YEAR  NAME      PARENT    MACHINE   INPUT     INIT    MONITOR COMPANY    FULLNAME     FLAGS ) */
869 GAME ( 1988, chinagat, 0,        chinagat, chinagat, 0     , ROT0, "[Technos] (Taito Romstar license)", "China Gate (US)" )
870 GAME ( 1988, saiyugou, chinagat, chinagat, chinagat, 0     , ROT0, "Technos", "Sai Yu Gou Ma Roku (Japan)" )
871 GAMEX( 1988, saiyugb1, chinagat, saiyugb1, chinagat, 0     , ROT0, "bootleg", "Sai Yu Gou Ma Roku (Japan bootleg 1)", GAME_IMPERFECT_SOUND )
872 GAME ( 1988, saiyugb2, chinagat, saiyugb2, chinagat, 0     , ROT0, "bootleg", "Sai Yu Gou Ma Roku (Japan bootleg 2)" )
873