1 /***************************************************************************
2 
3 Gun Dealer memory map
4 
5 driver by Nicola Salmoria
6 
7 Yam! Yam!? runs on the same hardware but has a protection device which can
8            access RAM at e000. Program writes to e000 and expects a value back
9 		   at e001, then jumps to subroutines at e010 and e020. Also, the
10 		   player and coin inputs appear magically at e004-e006.
11 
12 0000-7fff ROM
13 8000-bfff ROM (banked)
14 c400-c7ff palette RAM
15 c800-cfff background video RAM
16 d000-dfff foreground (scrollable) video RAM.
17 e000-ffff work RAM
18 
19 read:
20 c000      DSW0
21 c001      DSW1
22 c004      COIN (Gun Dealer only)
23 c005      IN1 (Gun Dealer only)
24 c006      IN0 (Gun Dealer only)
25 
26 write:
27 c010-c011 foreground scroll x lo-hi (Yam Yam)
28 c012-c013 foreground scroll y lo-hi (Yam Yam)
29 c014      flip screen
30 c015      Yam Yam only, maybe reset protection device
31 c016      ROM bank selector
32 c020-c021 foreground scroll x hi-lo (Gun Dealer)
33 c022-c023 foreground scroll y hi-lo (Gun Dealer)
34 
35 I/O:
36 read:
37 01        YM2203 read
38 
39 write:
40 00        YM2203 control
41 01        YM2203 write
42 
43 Interrupts:
44 Runs in interrupt mode 0, the interrupt vectors are 0xcf (RST 08h) and
45 0xd7 (RST 10h)
46 
47 ***************************************************************************/
48 
49 #include "driver.h"
50 
51 
52 extern unsigned char *gundealr_bg_videoram,*gundealr_fg_videoram;
53 
54 WRITE_HANDLER( gundealr_paletteram_w );
55 WRITE_HANDLER( gundealr_bg_videoram_w );
56 WRITE_HANDLER( gundealr_fg_videoram_w );
57 WRITE_HANDLER( gundealr_fg_scroll_w );
58 WRITE_HANDLER( yamyam_fg_scroll_w );
59 WRITE_HANDLER( gundealr_flipscreen_w );
60 VIDEO_UPDATE( gundealr );
61 VIDEO_START( gundealr );
62 
63 
64 static int input_ports_hack;
65 
INTERRUPT_GEN(yamyam_interrupt)66 static INTERRUPT_GEN( yamyam_interrupt )
67 {
68 	if (cpu_getiloops() == 0)
69 	{
70 		if (input_ports_hack)
71 		{
72 			unsigned char *RAM = memory_region(REGION_CPU1);
73 			RAM[0xe004] = readinputport(4);	/* COIN */
74 			RAM[0xe005] = readinputport(3);	/* IN1 */
75 			RAM[0xe006] = readinputport(2);	/* IN0 */
76 		}
77 		cpu_set_irq_line_and_vector(0, 0, HOLD_LINE, 0xd7);	/* RST 10h vblank */
78 	}
79 	else if ((cpu_getiloops() & 1) == 1)
80 		cpu_set_irq_line_and_vector(0, 0, HOLD_LINE, 0xcf);	/* RST 08h sound (hand tuned) */
81 }
82 
WRITE_HANDLER(yamyam_bankswitch_w)83 static WRITE_HANDLER( yamyam_bankswitch_w )
84 {
85  	int bankaddress;
86 	unsigned char *RAM = memory_region(REGION_CPU1);
87 
88 	bankaddress = 0x10000 + (data & 0x07) * 0x4000;
89 	cpu_setbank(1,&RAM[bankaddress]);
90 }
91 
WRITE_HANDLER(yamyam_protection_w)92 static WRITE_HANDLER( yamyam_protection_w )
93 {
94 	unsigned char *RAM = memory_region(REGION_CPU1);
95 
96 log_cb(RETRO_LOG_DEBUG, LOGPRE "e000 = %02x\n",RAM[0xe000]);
97 	RAM[0xe000] = data;
98 	if (data == 0x03) RAM[0xe001] = 0x03;
99 	if (data == 0x04) RAM[0xe001] = 0x04;
100 	if (data == 0x05) RAM[0xe001] = 0x05;
101 	if (data == 0x0a) RAM[0xe001] = 0x08;
102 	if (data == 0x0d) RAM[0xe001] = 0x07;
103 
104 	if (data == 0x03)
105 	{
106 		/*
107 		read dip switches
108 		3a 00 c0  ld   a,($c000)
109 		47        ld   b,a
110 		3a 01 c0  ld   a,($c001)
111 		c9        ret
112 		*/
113 		RAM[0xe010] = 0x3a;
114 		RAM[0xe011] = 0x00;
115 		RAM[0xe012] = 0xc0;
116 		RAM[0xe013] = 0x47;
117 		RAM[0xe014] = 0x3a;
118 		RAM[0xe015] = 0x01;
119 		RAM[0xe016] = 0xc0;
120 		RAM[0xe017] = 0xc9;
121 	}
122 	if (data == 0x05)
123 	{
124 		/*
125 		add a to hl
126 		c5        push    bc
127 		010000    ld      bc,#0000
128 		4f        ld      c,a
129 		09        add     hl,bc
130 		c1        pop     bc
131 		c9        ret
132 		*/
133 		RAM[0xe020] = 0xc5;
134 		RAM[0xe021] = 0x01;
135 		RAM[0xe022] = 0x00;
136 		RAM[0xe023] = 0x00;
137 		RAM[0xe024] = 0x4f;
138 		RAM[0xe025] = 0x09;
139 		RAM[0xe026] = 0xc1;
140 		RAM[0xe027] = 0xc9;
141 		/*
142 		lookup data in table
143 		cd20e0    call    #e020
144 		7e        ld      a,(hl)
145 		c9        ret
146 		*/
147 		RAM[0xe010] = 0xcd;
148 		RAM[0xe011] = 0x20;
149 		RAM[0xe012] = 0xe0;
150 		RAM[0xe013] = 0x7e;
151 		RAM[0xe014] = 0xc9;
152 	}
153 }
154 
155 
156 
MEMORY_READ_START(readmem)157 static MEMORY_READ_START( readmem )
158 	{ 0x0000, 0x7fff, MRA_ROM },
159 	{ 0x8000, 0xbfff, MRA_BANK1 },
160 	{ 0xc000, 0xc000, input_port_0_r },	/* DSW0 */
161 	{ 0xc001, 0xc001, input_port_1_r },	/* DSW1 */
162 	{ 0xc004, 0xc004, input_port_2_r },	/* COIN (Gun Dealer only) */
163 	{ 0xc005, 0xc005, input_port_3_r },	/* IN1 (Gun Dealer only) */
164 	{ 0xc006, 0xc006, input_port_4_r },	/* IN0 (Gun Dealer only) */
165 	{ 0xc400, 0xffff, MRA_RAM },
166 MEMORY_END
167 
168 static MEMORY_WRITE_START( writemem )
169 	{ 0x0000, 0xbfff, MWA_ROM },
170 	{ 0xc010, 0xc013, yamyam_fg_scroll_w },		/* Yam Yam only */
171 	{ 0xc014, 0xc014, gundealr_flipscreen_w },
172 	{ 0xc016, 0xc016, yamyam_bankswitch_w },
173 	{ 0xc020, 0xc023, gundealr_fg_scroll_w },	/* Gun Dealer only */
174 	{ 0xc400, 0xc7ff, gundealr_paletteram_w, &paletteram },
175 	{ 0xc800, 0xcfff, gundealr_bg_videoram_w, &gundealr_bg_videoram },
176 	{ 0xd000, 0xdfff, gundealr_fg_videoram_w, &gundealr_fg_videoram },
177 	{ 0xe000, 0xffff, MWA_RAM },
178 MEMORY_END
179 
180 static PORT_READ_START( readport )
181 	{ 0x01, 0x01, YM2203_read_port_0_r },
182 PORT_END
183 
184 static PORT_WRITE_START( writeport )
185 	{ 0x00, 0x00, YM2203_control_port_0_w },
186 	{ 0x01, 0x01, YM2203_write_port_0_w },
187 PORT_END
188 
189 
190 
191 INPUT_PORTS_START( gundealr )
192 	PORT_START	/* DSW0 */
193 	PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
194 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
195 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
196 	PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
197 	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
198 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
199 	PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Difficulty ) )
200 	PORT_DIPSETTING(    0x0c, "Easy" )
201 	PORT_DIPSETTING(    0x08, "Medium" )
202 	PORT_DIPSETTING(    0x04, "Hard" )
203 	PORT_DIPSETTING(    0x00, "Hardest" )
204 	PORT_DIPNAME( 0x10, 0x00, DEF_STR( Demo_Sounds ) )
205 	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
206 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
207 	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
208 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
209 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
210 	PORT_DIPNAME( 0x40, 0x00, DEF_STR( Cabinet ) )
211 	PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
212 	PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )
213 	PORT_DIPNAME( 0x80, 0x00, DEF_STR( Flip_Screen ) )
214 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
215 	PORT_DIPSETTING(    0x80, DEF_STR( On ) )
216 
217 	PORT_START	/* DSW1 */
218 	PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )
219 	PORT_DIPSETTING(    0x00, DEF_STR( 5C_1C ) )
220 	PORT_DIPSETTING(    0x01, DEF_STR( 4C_1C ) )
221 	PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ) )
222 	PORT_DIPSETTING(    0x03, DEF_STR( 2C_1C ) )
223 	PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
224 	PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) )
225 	PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
226 	PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
227 	PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )
228 	PORT_DIPSETTING(    0x00, DEF_STR( 5C_1C ) )
229 	PORT_DIPSETTING(    0x08, DEF_STR( 4C_1C ) )
230 	PORT_DIPSETTING(    0x10, DEF_STR( 3C_1C ) )
231 	PORT_DIPSETTING(    0x18, DEF_STR( 2C_1C ) )
232 	PORT_DIPSETTING(    0x38, DEF_STR( 1C_1C ) )
233 	PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) )
234 	PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) )
235 	PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) )
236 	PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Unknown ) )
237 	PORT_DIPSETTING(    0x00, "0" )
238 	PORT_DIPSETTING(    0x40, "1" )
239 	PORT_DIPSETTING(    0x80, "2" )
240 	PORT_DIPSETTING(    0xc0, "3" )
241 
242 	PORT_START	/* COIN */
243 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
244 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
245 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
246 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
247 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
248 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
249 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
250 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
251 
252 	PORT_START	/* IN1 */
253 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_PLAYER2 )
254 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_PLAYER2 )
255 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_PLAYER2 )
256 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_PLAYER2 )
257 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
258 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
259 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* probably unused */
260 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* probably unused */
261 
262 	PORT_START	/* IN0 */
263 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_PLAYER1 )
264 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_PLAYER1 )
265 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_PLAYER1 )
266 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_PLAYER1 )
267 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
268 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
269 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* probably unused */
270 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* probably unused */
271 INPUT_PORTS_END
272 
273 INPUT_PORTS_START( gundealt )
274 	PORT_START	/* DSW0 */
275 	PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
276 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
277 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
278 	PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
279 	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
280 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
281 	PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Difficulty ) )
282 	PORT_DIPSETTING(    0x0c, "Easy" )
283 	PORT_DIPSETTING(    0x08, "Medium" )
284 	PORT_DIPSETTING(    0x04, "Hard" )
285 	PORT_DIPSETTING(    0x00, "Hardest" )
286 	PORT_DIPNAME( 0x10, 0x00, DEF_STR( Demo_Sounds ) )
287 	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
288 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
289 	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
290 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
291 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
292 	PORT_DIPNAME( 0x40, 0x00, DEF_STR( Cabinet ) )
293 	PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
294 	PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )
295 	PORT_DIPNAME( 0x80, 0x00, DEF_STR( Flip_Screen ) )
296 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
297 	PORT_DIPSETTING(    0x80, DEF_STR( On ) )
298 
299 	PORT_START	/* DSW1 */
300 	PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )
301 	PORT_DIPSETTING(    0x00, DEF_STR( 5C_1C ) )
302 	PORT_DIPSETTING(    0x01, DEF_STR( 4C_1C ) )
303 	PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ) )
304 	PORT_DIPSETTING(    0x03, DEF_STR( 2C_1C ) )
305 	PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
306 	PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) )
307 	PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
308 	PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
309 	PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )
310 	PORT_DIPSETTING(    0x00, DEF_STR( 5C_1C ) )
311 	PORT_DIPSETTING(    0x08, DEF_STR( 4C_1C ) )
312 	PORT_DIPSETTING(    0x10, DEF_STR( 3C_1C ) )
313 	PORT_DIPSETTING(    0x18, DEF_STR( 2C_1C ) )
314 	PORT_DIPSETTING(    0x38, DEF_STR( 1C_1C ) )
315 	PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) )
316 	PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) )
317 	PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) )
318 	PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Unknown ) )
319 	PORT_DIPSETTING(    0x00, "0" )
320 	PORT_DIPSETTING(    0x40, "1" )
321 	PORT_DIPSETTING(    0x80, "2" )
322 	PORT_DIPSETTING(    0xc0, "3" )
323 
324 	PORT_START	/* IN0 */
325 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_PLAYER1 )
326 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_PLAYER1 )
327 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_PLAYER1 )
328 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_PLAYER1 )
329 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
330 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
331 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* probably unused */
332 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* probably unused */
333 
334 	PORT_START	/* IN1 */
335 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_PLAYER2 )
336 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_PLAYER2 )
337 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_PLAYER2 )
338 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_PLAYER2 )
339 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
340 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
341 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* probably unused */
342 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* probably unused */
343 
344 	PORT_START	/* COIN */
345 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
346 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
347 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
348 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
349 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
350 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
351 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
352 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
353 INPUT_PORTS_END
354 
355 INPUT_PORTS_START( yamyam )
356 	PORT_START	/* DSW0 */
357 	PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )
358 	PORT_DIPSETTING(    0x00, "3" )
359 	PORT_DIPSETTING(    0x01, "4" )
360 	PORT_DIPSETTING(    0x02, "5" )
361 	PORT_DIPSETTING(    0x03, "6" )
362 	PORT_DIPNAME( 0x0c, 0x00, "Difficulty?" )
363 	PORT_DIPSETTING(    0x00, "Easy?" )
364 	PORT_DIPSETTING(    0x04, "Medium?" )
365 	PORT_DIPSETTING(    0x08, "Hard?" )
366 	PORT_DIPSETTING(    0x0c, "Hardest?" )
367 	PORT_DIPNAME( 0x10, 0x00, DEF_STR( Demo_Sounds ) )
368 	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
369 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
370 	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
371 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
372 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
373 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Cabinet ) )
374 	PORT_DIPSETTING(    0x40, DEF_STR( Upright ) )
375 	PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
376 	PORT_DIPNAME( 0x80, 0x00, DEF_STR( Flip_Screen ) )
377 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
378 	PORT_DIPSETTING(    0x80, DEF_STR( On ) )
379 
380 	PORT_START	/* DSW1 */
381 	PORT_DIPNAME( 0x07, 0x00, DEF_STR( Coin_A ) )
382 	PORT_DIPSETTING(    0x07, DEF_STR( 5C_1C ) )
383 	PORT_DIPSETTING(    0x06, DEF_STR( 4C_1C ) )
384 	PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
385 	PORT_DIPSETTING(    0x04, DEF_STR( 2C_1C ) )
386 /*	PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) ) */
387 /*	PORT_DIPSETTING(    0x02, DEF_STR( 1C_1C ) ) */
388 /*	PORT_DIPSETTING(    0x01, DEF_STR( 1C_1C ) ) */
389 	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
390 	PORT_DIPNAME( 0x38, 0x00, DEF_STR( Coin_B ) )
391 	PORT_DIPSETTING(    0x38, DEF_STR( 5C_1C ) )
392 	PORT_DIPSETTING(    0x30, DEF_STR( 4C_1C ) )
393 	PORT_DIPSETTING(    0x28, DEF_STR( 3C_1C ) )
394 	PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )
395 /*	PORT_DIPSETTING(    0x18, DEF_STR( 1C_1C ) ) */
396 /*	PORT_DIPSETTING(    0x10, DEF_STR( 1C_1C ) ) */
397 /*	PORT_DIPSETTING(    0x08, DEF_STR( 1C_1C ) ) */
398 	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
399 	PORT_DIPNAME( 0x40, 0x00, DEF_STR( Free_Play ) )
400 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
401 	PORT_DIPSETTING(    0x40, DEF_STR( On ) )
402 	PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
403 
404 	PORT_START	/* COIN */
405 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
406 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
407 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
408 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
409 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
410 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_TILT )	/* "TEST" */
411 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
412 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
413 
414 	PORT_START	/* IN1 */
415 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_PLAYER2 )
416 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_PLAYER2 )
417 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_PLAYER2 )
418 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_PLAYER2 )
419 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
420 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
421 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* probably unused */
422 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* probably unused */
423 
424 	PORT_START	/* IN0 */
425 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_PLAYER1 )
426 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_PLAYER1 )
427 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_PLAYER1 )
428 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_PLAYER1 )
429 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
430 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
431 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* probably unused */
432 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* probably unused */
433 INPUT_PORTS_END
434 
435 
436 
437 static struct GfxLayout charlayout =
438 {
439 	8,8,
440 	RGN_FRAC(1,1),
441 	4,
442 	{ 0, 1, 2, 3 },
443 	{ 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4 },
444 	{ 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
445 	32*8
446 };
447 
448 static struct GfxLayout spritelayout =
449 {
450 	16,16,
451 	RGN_FRAC(1,1),
452 	4,
453 	{ 0, 1, 2, 3 },
454 	{ 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4,
455 			16*32+0*4, 16*32+1*4, 16*32+2*4, 16*32+3*4, 16*32+4*4, 16*32+5*4, 16*32+6*4, 16*32+7*4 },
456 	{ 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
457 			8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 },
458 	128*8
459 };
460 
461 static struct GfxDecodeInfo gfxdecodeinfo[] =
462 {
463 	{ REGION_GFX1, 0, &charlayout,     0, 16 },	/* colors 0-255 */
464 	{ REGION_GFX2, 0, &spritelayout, 256, 16 },	/* colors 256-511 */
465 	{ -1 } /* end of array */
466 };
467 
468 
469 
470 static struct YM2203interface ym2203_interface =
471 {
472 	1,			/* 1 chip */
473 	1500000,	/* 1.5 MHz ?????? */
474 	{ YM2203_VOL(25,25) },
475 	{ 0 },
476 	{ 0 },
477 	{ 0 },
478 	{ 0 }
479 };
480 
481 
482 
483 static MACHINE_DRIVER_START( gundealr )
484 
485 	/* basic machine hardware */
486 	MDRV_CPU_ADD(Z80, 8000000)	/* 8 MHz ??? */
MDRV_CPU_MEMORY(readmem,writemem)487 	MDRV_CPU_MEMORY(readmem,writemem)
488 	MDRV_CPU_PORTS(readport,writeport)
489 	MDRV_CPU_VBLANK_INT(yamyam_interrupt,4)	/* ? */
490 
491 	MDRV_FRAMES_PER_SECOND(60)
492 	MDRV_VBLANK_DURATION(DEFAULT_60HZ_VBLANK_DURATION)
493 
494 	/* video hardware */
495 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
496 	MDRV_SCREEN_SIZE(32*8, 32*8)
497 	MDRV_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
498 	MDRV_GFXDECODE(gfxdecodeinfo)
499 	MDRV_PALETTE_LENGTH(512)
500 
501 	MDRV_VIDEO_START(gundealr)
502 	MDRV_VIDEO_UPDATE(gundealr)
503 
504 	/* sound hardware */
505 	MDRV_SOUND_ADD(YM2203, ym2203_interface)
506 MACHINE_DRIVER_END
507 
508 
509 
510 /***************************************************************************
511 
512   Game driver(s)
513 
514 ***************************************************************************/
515 
516 ROM_START( gundealr )
517 	ROM_REGION( 0x30000, REGION_CPU1, 0 )	/* 64k for code + 128k for banks */
518 	ROM_LOAD( "gundealr.1",   0x00000, 0x10000, CRC(5797e830) SHA1(54bd9fbcafdf3fff55d73ecfe26d8e8df0dd55d9) )
519 	ROM_RELOAD(               0x10000, 0x10000 )	/* banked at 0x8000-0xbfff */
520 
521 	ROM_REGION( 0x10000, REGION_GFX1, ROMREGION_DISPOSE )
522 	ROM_LOAD( "3.6p",         0x00000, 0x10000, CRC(01f99de2) SHA1(2d9e9c50b0669811beb6fa53c0ff1b240fa939c7) )
523 
524 	ROM_REGION( 0x20000, REGION_GFX2, ROMREGION_DISPOSE )
525 	ROM_LOAD( "gundealr.2",   0x00000, 0x20000, CRC(7874ec41) SHA1(2d2ff013cc37ce5966aa4b6c6724234655196102) )
526 ROM_END
527 
528 ROM_START( gundeala )
529 	ROM_REGION( 0x30000, REGION_CPU1, 0 )	/* 64k for code + 128k for banks */
530 	ROM_LOAD( "gundeala.1",   0x00000, 0x10000, CRC(d87e24f1) SHA1(5ac3e20e5848b9cab2a23e083d2566bfd54502d4) )
531 	ROM_RELOAD(               0x10000, 0x10000 )	/* banked at 0x8000-0xbfff */
532 
533 	ROM_REGION( 0x10000, REGION_GFX1, ROMREGION_DISPOSE )
534 	ROM_LOAD( "gundeala.3",   0x00000, 0x10000, CRC(836cf1a3) SHA1(ca57e7fc3e4497d249af963d1c8610e80ca65aa7) )
535 
536 	ROM_REGION( 0x20000, REGION_GFX2, ROMREGION_DISPOSE )
537 	ROM_LOAD( "gundeala.2",   0x00000, 0x20000, CRC(4b5fb53c) SHA1(3b73d9aeed334aece75f551f5b7f3cec0aedbfaa) )
538 ROM_END
539 
540 ROM_START( gundealt )
541 	ROM_REGION( 0x30000, REGION_CPU1, 0 )	/* 64k for code + 128k for banks */
542 	ROM_LOAD( "1.3j",         0x00000, 0x10000, CRC(1d951292) SHA1(a8bd34dfaf31c7dc4f9e0ec1fd7d4e10c5b29a85) )
543 	ROM_RELOAD(               0x10000, 0x10000 )	/* banked at 0x8000-0xbfff */
544 
545 	ROM_REGION( 0x10000, REGION_GFX1, ROMREGION_DISPOSE )
546 	ROM_LOAD( "3.6p",         0x00000, 0x10000, CRC(01f99de2) SHA1(2d9e9c50b0669811beb6fa53c0ff1b240fa939c7) )
547 
548 	ROM_REGION( 0x20000, REGION_GFX2, ROMREGION_DISPOSE )
549 	ROM_LOAD( "2.6b",         0x00000, 0x20000, CRC(508ed0d0) SHA1(ea6b2d07e2e3d4f6c2a622a73b150ee7709b28de) )
550 ROM_END
551 
552 ROM_START( yamyam )
553 	ROM_REGION( 0x30000, REGION_CPU1, 0 )	/* 64k for code + 128k for banks */
554 	ROM_LOAD( "b3.f10",       0x00000, 0x20000, CRC(96ae9088) SHA1(a605882dcdcf1e8cf8b0112f614e696d59acfd97) )
555 	ROM_RELOAD(               0x10000, 0x20000 )	/* banked at 0x8000-0xbfff */
556 
557 	ROM_REGION( 0x10000, REGION_GFX1, ROMREGION_DISPOSE )
558 	ROM_LOAD( "b2.d16",       0x00000, 0x10000, CRC(cb4f84ee) SHA1(54319ecbd74b763757eb6d17c8f7be0705ab0714) )
559 
560 	ROM_REGION( 0x20000, REGION_GFX2, ROMREGION_DISPOSE )
561 	ROM_LOAD( "b1.a16",       0x00000, 0x20000, CRC(b122828d) SHA1(90994ba548893a2eacdd58351cfa3952f4af926a) )
562 ROM_END
563 
564 /* only gfx are different, code is the same */
565 ROM_START( wiseguy )
566 	ROM_REGION( 0x30000, REGION_CPU1, 0 )	/* 64k for code + 128k for banks */
567 	ROM_LOAD( "b3.f10",       0x00000, 0x20000, CRC(96ae9088) SHA1(a605882dcdcf1e8cf8b0112f614e696d59acfd97) )
568 	ROM_RELOAD(               0x10000, 0x20000 )	/* banked at 0x8000-0xbfff */
569 
570 	ROM_REGION( 0x10000, REGION_GFX1, ROMREGION_DISPOSE )
571 	ROM_LOAD( "wguyb2.bin",   0x00000, 0x10000, CRC(1c684c46) SHA1(041bc500e31b02a8bf3ce4683a67de998f938ccc) )
572 
573 	ROM_REGION( 0x20000, REGION_GFX2, ROMREGION_DISPOSE )
574 	ROM_LOAD( "b1.a16",       0x00000, 0x20000, CRC(b122828d) SHA1(90994ba548893a2eacdd58351cfa3952f4af926a) )
575 ROM_END
576 
577 
578 
579 static DRIVER_INIT( gundealr )
580 {
581 	input_ports_hack = 0;
582 }
583 
DRIVER_INIT(yamyam)584 static DRIVER_INIT( yamyam )
585 {
586 	input_ports_hack = 1;
587 	install_mem_write_handler(0, 0xe000, 0xe000, yamyam_protection_w);
588 }
589 
590 
591 
592 GAME( 1990, gundealr, 0,        gundealr, gundealr, gundealr, ROT270, "Dooyong", "Gun Dealer (set 1)" )
593 GAME( 19??, gundeala, gundealr, gundealr, gundealr, gundealr, ROT270, "Dooyong", "Gun Dealer (set 2)" )
594 GAME( 1990, gundealt, gundealr, gundealr, gundealt, gundealr, ROT270, "Tecmo", "Gun Dealer (Tecmo)" )
595 GAME( 1990, yamyam,   0,        gundealr, yamyam,   yamyam,   ROT0,   "Dooyong", "Yam! Yam![Q]" )
596 GAME( 1990, wiseguy,  yamyam,   gundealr, yamyam,   yamyam,   ROT0,   "Dooyong", "Wise Guy" )
597