1 /***************************************************************************
2 
3 Target Hits (c) 1994 Gaelco (Designed & Developed by Zigurat. Produced by Gaelco)
4 
5 Driver by Manuel Abadia <manu@teleline.es>
6 
7 The DS5002FP has 32KB undumped gameplay code making the game unplayable :_(
8 
9 ***************************************************************************/
10 
11 #include "driver.h"
12 #include "vidhrdw/generic.h"
13 #include "cpu/m68000/m68000.h"
14 
15 extern data16_t *targeth_vregs;
16 extern data16_t *targeth_videoram;
17 extern data16_t *targeth_spriteram;
18 
19 /* from vidhrdw/targeth.c */
20 WRITE16_HANDLER( targeth_vram_w );
21 VIDEO_START( targeth );
22 VIDEO_UPDATE( targeth );
23 
24 
25 static struct GfxLayout tilelayout16_0x080000 =
26 {
27 	16,16,														/* 16x16 tiles */
28 	0x080000/32,												/* number of tiles */
29 	4,															/* bitplanes */
30 	{ 3*0x080000*8, 2*0x080000*8, 1*0x080000*8, 0*0x080000*8 }, /* plane offsets */
31 	{ 0,1,2,3,4,5,6,7, 16*8+0,16*8+1,16*8+2,16*8+3,16*8+4,16*8+5,16*8+6,16*8+7 },
32 	{ 0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8, 8*8,9*8,10*8,11*8,12*8,13*8,14*8,15*8 },
33 	32*8
34 };
35 
36 static struct GfxDecodeInfo gfxdecodeinfo_0x080000[] =
37 {
38 	{ REGION_GFX1, 0x000000, &tilelayout16_0x080000, 0, 64 },
39 	{ -1 }
40 };
41 
42 
INTERRUPT_GEN(targeth_interrupt)43 static INTERRUPT_GEN(targeth_interrupt )
44 {
45 	switch(cpu_getiloops()){
46 		case 0: /* IRQ 2: drives the game */
47 			cpu_set_irq_line(0, 2, HOLD_LINE);
48 			break;
49 		case 1: /* IRQ 4: Read 1P Gun */
50 			cpu_set_irq_line(0, 4, HOLD_LINE);
51 			break;
52 		case 2:	/* IRQ 6: Read 2P Gun */
53 			cpu_set_irq_line(0, 6, HOLD_LINE);
54 			break;
55 	}
56 }
57 
58 
MEMORY_READ16_START(targeth_readmem)59 static MEMORY_READ16_START( targeth_readmem )
60 	{ 0x000000, 0x0fffff, MRA16_ROM },			/* ROM */
61 	{ 0x100000, 0x103fff, MRA16_RAM },			/* Video RAM */
62 	{ 0x108000, 0x108001, input_port_0_word_r },/* Gun 1P X */
63 	{ 0x108002, 0x108003, input_port_1_word_r },/* Gun 1P Y */
64 	{ 0x108004, 0x108005, input_port_2_word_r },/* Gun 2P X */
65 	{ 0x108006, 0x108007, input_port_3_word_r },/* Gun 2P Y */
66 	{ 0x200000, 0x2007ff, MRA16_RAM },			/* Palette */
67 	{ 0x440000, 0x440fff, MRA16_RAM },			/* Sprite RAM */
68 	{ 0x700000, 0x700001, input_port_4_word_r },/* DIPSW #2 */
69 	{ 0x700002, 0x700003, input_port_5_word_r },/* DIPSW #1 */
70 	{ 0x700006, 0x700007, input_port_6_word_r },/* Coins, Start & Fire buttons */
71 	{ 0x700008, 0x700009, input_port_7_word_r },/* Service & Guns Reload? */
72 	{ 0x70000e, 0x70000f, OKIM6295_status_0_lsb_r },/* OKI6295 status register */
73 	{ 0xfe0000, 0xfeffff, MRA16_RAM },			/* Work RAM (partially shared with DS5002FP) */
74 MEMORY_END
75 
76 static WRITE16_HANDLER( OKIM6295_bankswitch_w )
77 {
78 	unsigned char *RAM = memory_region(REGION_SOUND1);
79 
80 	if (ACCESSING_LSB){
81 		memcpy(&RAM[0x30000], &RAM[0x40000 + (data & 0x0f)*0x10000], 0x10000);
82 	}
83 }
84 
WRITE16_HANDLER(targeth_coin_counter_w)85 static WRITE16_HANDLER( targeth_coin_counter_w )
86 {
87 	coin_counter_w( (offset >> 3) & 0x01, data & 0x01);
88 }
89 
MEMORY_WRITE16_START(targeth_writemem)90 static MEMORY_WRITE16_START( targeth_writemem )
91 	{ 0x000000, 0x0fffff, MWA16_ROM },								/* ROM */
92 	{ 0x100000, 0x103fff, targeth_vram_w, &targeth_videoram },		/* Video RAM */
93 	{ 0x108000, 0x108007, MWA16_RAM, &targeth_vregs },				/* Video Registers */
94 	{ 0x10800c, 0x10800d, MWA16_NOP },								/* CLR Video INT */
95 	{ 0x200000, 0x2007ff, paletteram16_xBBBBBGGGGGRRRRR_word_w, &paletteram16 },/* Palette */
96 	{ 0x440000, 0x440fff, MWA16_RAM, &targeth_spriteram },			/* Sprite RAM */
97 	{ 0x70000c, 0x70000d, OKIM6295_bankswitch_w },					/* OKI6295 bankswitch */
98 	{ 0x70000e, 0x70000f, OKIM6295_data_0_lsb_w },					/* OKI6295 data register */
99 	{ 0x70000a, 0x70001b, MWA16_NOP },								/* ??? Guns reload related? */
100 	{ 0x70002a, 0x70003b, targeth_coin_counter_w },					/* Coin counters */
101 	{ 0xfe0000, 0xfeffff, MWA16_RAM },								/* Work RAM (partially shared with DS5002FP) */
102 MEMORY_END
103 
104 
105 INPUT_PORTS_START( targeth )
106 PORT_START	/* Gun 1 X */
107 	PORT_ANALOG( 0x01ff, 200, IPT_LIGHTGUN_X | IPF_PLAYER1, 100, 20, 0, 400 + 4)
108 	PORT_BIT( 0xfe00, IP_ACTIVE_HIGH, IPT_UNKNOWN )
109 
110 PORT_START	/* Gun 1 Y */
111 	PORT_ANALOG( 0x01ff, 128, IPT_LIGHTGUN_Y | IPF_PLAYER1, 100, 20, 4, 255)
112 	PORT_BIT( 0xfe00, IP_ACTIVE_HIGH, IPT_UNKNOWN )
113 
114 PORT_START	/* Gun 2 X */
115 	PORT_ANALOG( 0x01ff, 400 + 4, IPT_LIGHTGUN_X | IPF_PLAYER2, 100, 20, 0, 400 + 4)
116 	PORT_BIT( 0xfe00, IP_ACTIVE_HIGH, IPT_UNKNOWN )
117 
118 PORT_START	/* Gun 2 Y */
119 	PORT_ANALOG( 0x01ff, 255, IPT_LIGHTGUN_Y | IPF_PLAYER2, 100, 20, 4, 255)
120 	PORT_BIT( 0xfe00, IP_ACTIVE_HIGH, IPT_UNKNOWN )
121 
122 PORT_START	/* DSW #2 */
123 	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
124 	PORT_DIPSETTING(    0x01, "Easy" )
125 	PORT_DIPSETTING(    0x03, "Normal" )
126 	PORT_DIPSETTING(    0x02, "Hard" )
127 	PORT_DIPSETTING(    0x00, "Hardest" )
128 	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
129 	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
130 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
131 	PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
132 	PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
133 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
134 	PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
135 	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
136 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
137 	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
138 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
139 	PORT_DIPSETTING(    0x20, DEF_STR( On ) )
140 	PORT_DIPNAME( 0x40, 0x40, "Gun alarm" )	/* This doesn't work. What's supposed to do? */
141 	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
142 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
143 	PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
144 
145 PORT_START	/* DSW #1 */
146 	PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )
147 	PORT_DIPSETTING(    0x02, DEF_STR( 6C_1C ) )
148 	PORT_DIPSETTING(    0x03, DEF_STR( 5C_1C ) )
149 	PORT_DIPSETTING(    0x04, DEF_STR( 4C_1C ) )
150 	PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
151 	PORT_DIPSETTING(    0x06, DEF_STR( 2C_1C ) )
152 	PORT_DIPSETTING(    0x01, DEF_STR( 3C_2C ) )
153 	PORT_DIPSETTING(    0x00, DEF_STR( 4C_3C ) )
154 	PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
155 	PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )
156 	PORT_DIPSETTING(    0x38, DEF_STR( 1C_1C ) )
157 	PORT_DIPSETTING(    0x00, DEF_STR( 3C_4C ) )
158 	PORT_DIPSETTING(    0x08, DEF_STR( 2C_3C ) )
159 	PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) )
160 	PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) )
161 	PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) )
162 	PORT_DIPSETTING(    0x18, DEF_STR( 1C_5C ) )
163 	PORT_DIPSETTING(    0x10, DEF_STR( 1C_6C ) )
164 	PORT_DIPNAME( 0x40, 0x40, "Credit configuration" )
165 	PORT_DIPSETTING(    0x40, "Start 1C/Continue 1C" )
166 	PORT_DIPSETTING(    0x00, "Start 2C/Continue 1C" )
167 	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Free_Play ) )
168 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
169 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
170 
171 PORT_START	/* Button 1, COINSW & STARTSW */
172 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
173 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
174 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
175 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
176 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
177 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
178 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
179 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
180 
181 PORT_START	/* Service & Button 2 */
182 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 )
183 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* this MUST be low or the game doesn't boot */
184 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )	/* Reload 1P? */
185 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )	/* Reload 2P? */
186 	PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNKNOWN )
187 INPUT_PORTS_END
188 
189 
190 static struct OKIM6295interface targeth_okim6295_interface =
191 {
192 	1,                  /* 1 chip */
193 	{ 8000 },			/* 8000 KHz? */
194 	{ REGION_SOUND1 },  /* memory region */
195 	{ 100 }				/* volume */
196 };
197 
198 static MACHINE_DRIVER_START( targeth )
199 
200 	/* basic machine hardware */
201 	MDRV_CPU_ADD(M68000,24000000/2)			/* 12 MHz */
202 	MDRV_CPU_MEMORY(targeth_readmem,targeth_writemem)
203 	MDRV_CPU_VBLANK_INT(targeth_interrupt,3)
204 
205 	MDRV_FRAMES_PER_SECOND(60)
206 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
207 
208 	/* video hardware */
209 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
210 	MDRV_SCREEN_SIZE(64*16, 32*16)				/* 1024x512 */
211 	MDRV_VISIBLE_AREA(0, 24*16-1, 16, 16*16-1)	/* 400x240 */
212 	MDRV_GFXDECODE(gfxdecodeinfo_0x080000)
213 	MDRV_PALETTE_LENGTH(1024)
214 
215 	MDRV_VIDEO_START(targeth)
216 	MDRV_VIDEO_UPDATE(targeth)
217 
218 	/* sound hardware */
219 	MDRV_SOUND_ADD(OKIM6295, targeth_okim6295_interface)
220 MACHINE_DRIVER_END
221 
222 ROM_START( targeth )
223 	ROM_REGION( 0x100000, REGION_CPU1, 0 )	/* 68000 code */
224 	ROM_LOAD16_BYTE(	"targeth.c23",	0x000000, 0x040000, CRC(840887d6) SHA1(9a36b346608d531a62a2e0704ea44f12e07f9d91) )
225 	ROM_LOAD16_BYTE(	"targeth.c22",	0x000001, 0x040000, CRC(d2435eb8) SHA1(ce75a115dad8019c8e66a1c3b3e15f54781f65ae) )
226 
227 	ROM_REGION( 0x200000, REGION_GFX1, ROMREGION_DISPOSE )	/* Graphics */
228 	ROM_LOAD( "targeth.i13",	0x000000, 0x080000, CRC(b892be24) SHA1(9cccaaacf20e77c7358f0ceac60b8a1012f1216c) )
229 	ROM_LOAD( "targeth.i11",	0x080000, 0x080000, CRC(6797faf9) SHA1(112cffe72f91cb46c262e19a47b0cab3237dd60f) )
230 	ROM_LOAD( "targeth.i9",		0x100000, 0x080000, CRC(0e922c1c) SHA1(6920e345c82e76f7e0af6101f39eb65ac1f112b9) )
231 	ROM_LOAD( "targeth.i7",		0x180000, 0x080000, CRC(d8b41000) SHA1(cbe91eb91bdc7a60b2333c6bea37d08a57902669) )
232 
233 	ROM_REGION( 0x140000, REGION_SOUND1, 0 )	/* ADPCM samples - sound chip is OKIM6295 */
234 	ROM_LOAD( "targeth.c1",		0x000000, 0x080000, CRC(d6c9dfbc) SHA1(3ec70dea94fc89df933074012a52de6034571e87) )
235 	/* 0x00000-0x2ffff is fixed, 0x30000-0x3ffff is bank switched from all the ROMs */
236 	ROM_RELOAD(					0x040000, 0x080000 )
237 	ROM_LOAD( "targeth.c3",		0x0c0000, 0x080000, CRC(d4c771df) SHA1(7cc0a86ef6aa3d26ab8f19d198f62112bf012870) )
238 ROM_END
239 
240 GAMEX( 1994, targeth, 0, targeth,targeth, 0, ROT0, "Gaelco", "Target Hits", GAME_UNEMULATED_PROTECTION )
241