1 /***************************************************************************
2 
3 Thunder Hoop II: Strikes Back (c) 1994 Gaelco
4 
5 Driver by Manuel Abadia <manu@teleline.es>
6 
7 Very similar to maniacsq and biomtoy but protected :_(
8 The DS5002FP has up to 128 KB undumped gameplay code
9 
10 ***************************************************************************/
11 
12 #include "driver.h"
13 #include "vidhrdw/generic.h"
14 #include "cpu/m68000/m68000.h"
15 
16 extern data16_t *thoop2_vregs;
17 extern data16_t *thoop2_videoram;
18 extern data16_t *thoop2_spriteram;
19 
20 /* from vidhrdw/thoop2.c */
21 WRITE16_HANDLER( thoop2_vram_w );
22 VIDEO_START( thoop2 );
23 VIDEO_UPDATE( thoop2 );
24 
25 
26 static struct GfxLayout thoop2_tilelayout =
27 {
28 	8,8,									/* 8x8 tiles */
29 	0x400000/16,							/* number of tiles */
30 	4,										/* 4 bpp */
31 	{ 0*0x400000*8+8, 0*0x400000*8, 1*0x400000*8+8, 1*0x400000*8 },
32 	{ 0, 1, 2, 3, 4, 5, 6, 7 },
33 	{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
34 	16*8
35 };
36 
37 static struct GfxLayout thoop2_tilelayout_16 =
38 {
39 	16,16,									/* 16x16 tiles */
40 	0x400000/64,							/* number of tiles */
41 	4,										/* 4 bpp */
42 	{ 0*0x400000*8+8, 0*0x400000*8, 1*0x400000*8+8, 1*0x400000*8 },
43 	{ 0, 1, 2, 3, 4, 5, 6, 7,
44 		16*16+0, 16*16+1, 16*16+2, 16*16+3, 16*16+4, 16*16+5, 16*16+6, 16*16+7 },
45 	{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
46 	  8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16, },
47 	64*8
48 };
49 
50 
51 static struct GfxDecodeInfo thoop2_gfxdecodeinfo[] =
52 {
53 	{ REGION_GFX1, 0x000000, &thoop2_tilelayout, 0,		64 },
54 	{ REGION_GFX1, 0x000000, &thoop2_tilelayout_16, 0,	64 },
55 	{ -1 }
56 };
57 
58 
MEMORY_READ16_START(thoop2_readmem)59 static MEMORY_READ16_START( thoop2_readmem )
60 	{ 0x000000, 0x0fffff, MRA16_ROM },			/* ROM */
61 	{ 0x100000, 0x101fff, MRA16_RAM },			/* Video RAM */
62 	{ 0x200000, 0x2007ff, MRA16_RAM },			/* Palette */
63 	{ 0x440000, 0x440fff, MRA16_RAM },			/* Sprite RAM */
64 	{ 0x700000, 0x700001, input_port_0_word_r },/* DIPSW #2 */
65 	{ 0x700002, 0x700003, input_port_1_word_r },/* DIPSW #1 */
66 	{ 0x700004, 0x700005, input_port_2_word_r },/* INPUT #1 */
67 	{ 0x700006, 0x700007, input_port_3_word_r },/* INPUT #2 */
68 	{ 0x700008, 0x700009, input_port_4_word_r },/* INPUT #3 */
69 	{ 0x70000e, 0x70000f, OKIM6295_status_0_lsb_r },/* OKI6295 status register */
70 	{ 0xfe0000, 0xfeffff, MRA16_RAM },			/* Work RAM (partially shared with DS5002FP) */
71 MEMORY_END
72 
73 static WRITE16_HANDLER( OKIM6295_bankswitch_w )
74 {
75 	unsigned char *RAM = memory_region(REGION_SOUND1);
76 
77 	if (ACCESSING_LSB){
78 		memcpy(&RAM[0x30000], &RAM[0x40000 + (data & 0x0f)*0x10000], 0x10000);
79 	}
80 }
81 
WRITE16_HANDLER(thoop2_coin_w)82 WRITE16_HANDLER( thoop2_coin_w )
83 {
84 	if (ACCESSING_LSB){
85 		switch ((offset >> 3)){
86 			case 0x00:	/* Coin Lockouts */
87 			case 0x01:
88 				coin_lockout_w((offset >> 3) & 0x01, ~data & 0x01);
89 				break;
90 			case 0x02:	/* Coin Counters */
91 			case 0x03:
92 				coin_counter_w((offset >> 3) & 0x01, data & 0x01);
93 				break;
94 		}
95 	}
96 
97 	/* 04b unknown. Sound related? */
98 	/* 05b unknown */
99 }
100 
MEMORY_WRITE16_START(thoop2_writemem)101 static MEMORY_WRITE16_START( thoop2_writemem )
102 	{ 0x000000, 0x0fffff, MWA16_ROM },								/* ROM */
103 	{ 0x100000, 0x101fff, thoop2_vram_w, &thoop2_videoram },		/* Video RAM */
104 	{ 0x108000, 0x108007, MWA16_RAM, &thoop2_vregs },				/* Video Registers */
105 	{ 0x10800c, 0x10800d, watchdog_reset16_w },						/* INT 6 ACK/Watchdog timer */
106 	{ 0x200000, 0x2007ff, paletteram16_xBBBBBGGGGGRRRRR_word_w, &paletteram16 },/* Palette */
107 	{ 0x440000, 0x440fff, MWA16_RAM, &thoop2_spriteram },			/* Sprite RAM */
108 	{ 0x70000c, 0x70000d, OKIM6295_bankswitch_w },					/* OKI6295 bankswitch */
109 	{ 0x70000e, 0x70000f, OKIM6295_data_0_lsb_w },					/* OKI6295 data register */
110 	{ 0x70000a, 0x70005b, thoop2_coin_w },							/* Coin Counters + Coin Lockout */
111 	{ 0xfe0000, 0xfeffff, MWA16_RAM },								/* Work RAM (partially shared with DS5002FP) */
112 MEMORY_END
113 
114 
115 INPUT_PORTS_START( thoop2 )
116 
117 PORT_START	/* DSW #2 */
118 	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
119 	PORT_DIPSETTING(    0x03, "Normal" )
120 	PORT_DIPSETTING(    0x02, "Easy" )
121 	PORT_DIPSETTING(    0x01, "Hard" )
122 	PORT_DIPSETTING(    0x00, "Hardest" )
123 	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
124 	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
125 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
126 	PORT_DIPNAME( 0x18, 0x18, DEF_STR( Lives ) )
127 	PORT_DIPSETTING(    0x18, "2" )
128 	PORT_DIPSETTING(    0x10, "3" )
129 	PORT_DIPSETTING(    0x08, "4" )
130 	PORT_DIPSETTING(    0x00, "1" )
131 	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
132 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
133 	PORT_DIPSETTING(    0x20, DEF_STR( On ) )
134 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
135 	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
136 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
137 	PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
138 
139 
140 PORT_START	/* DSW #1 */
141 	PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_B ) )
142 	PORT_DIPSETTING(    0x02, DEF_STR( 6C_1C ) )
143 	PORT_DIPSETTING(    0x03, DEF_STR( 5C_1C ) )
144 	PORT_DIPSETTING(    0x04, DEF_STR( 4C_1C ) )
145 	PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
146 	PORT_DIPSETTING(    0x06, DEF_STR( 2C_1C ) )
147 	PORT_DIPSETTING(    0x01, DEF_STR( 3C_2C ) )
148 	PORT_DIPSETTING(    0x00, DEF_STR( 4C_3C ) )
149 	PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
150 	PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_A ) )
151 	PORT_DIPSETTING(    0x38, DEF_STR( 1C_1C ) )
152 	PORT_DIPSETTING(    0x00, DEF_STR( 3C_4C ) )
153 	PORT_DIPSETTING(    0x08, DEF_STR( 2C_3C ) )
154 	PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) )
155 	PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) )
156 	PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) )
157 	PORT_DIPSETTING(    0x18, DEF_STR( 1C_5C ) )
158 	PORT_DIPSETTING(    0x10, DEF_STR( 1C_6C ) )
159 	PORT_DIPNAME( 0x40, 0x40, "Credit configuration" )
160 	PORT_DIPSETTING(    0x40, "Start 1C/Continue 1C" )
161 	PORT_DIPSETTING(    0x00, "Start 2C/Continue 1C" )
162 	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Free_Play ) )
163 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
164 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
165 
166 PORT_START	/* 1P INPUTS & COINSW */
167 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
168 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
169 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
170 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
171 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
172 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
173 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
174 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
175 
176 PORT_START	/* 2P INPUTS & STARTSW */
177 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
178 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
179 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
180 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
181 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
182 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
183 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
184 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
185 
186 PORT_START	/* INPUTS, TEST & SERVICE */
187 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 )
188 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE2 )	/* test button */
189 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
190 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
191 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
192 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
193 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
194 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
195 INPUT_PORTS_END
196 
197 
198 static struct OKIM6295interface thoop2_okim6295_interface =
199 {
200 	1,                  /* 1 chip */
201 	{ 8000 },			/* 8000 KHz? */
202 	{ REGION_SOUND1 },  /* memory region */
203 	{ 100 }				/* volume */
204 };
205 
206 static MACHINE_DRIVER_START( thoop2 )
207 
208 	/* basic machine hardware */
209 	MDRV_CPU_ADD(M68000,24000000/2)			/* 12 MHz */
210 	MDRV_CPU_MEMORY(thoop2_readmem,thoop2_writemem)
211 	MDRV_CPU_VBLANK_INT(irq6_line_hold,1)
212 
213 	MDRV_FRAMES_PER_SECOND(60)
214 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
215 
216 	/* video hardware */
217 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
218 	MDRV_SCREEN_SIZE(32*16, 32*16)
219 	MDRV_VISIBLE_AREA(0, 320-1, 16, 256-1)
220 	MDRV_GFXDECODE(thoop2_gfxdecodeinfo)
221 	MDRV_PALETTE_LENGTH(1024)
222 
223 	MDRV_VIDEO_START(thoop2)
224 	MDRV_VIDEO_UPDATE(thoop2)
225 
226 	/* sound hardware */
227 	MDRV_SOUND_ADD(OKIM6295, thoop2_okim6295_interface)
228 MACHINE_DRIVER_END
229 
230 
231 ROM_START( thoop2 )
232 	ROM_REGION( 0x100000, REGION_CPU1, 0 )	/* 68000 code */
233 	ROM_LOAD16_BYTE(	"th2c23.040",	0x000000, 0x080000, CRC(3e465753) SHA1(1ea1173b9fe5d652e7b5fafb822e2535cecbc198) )
234 	ROM_LOAD16_BYTE(	"th2c22.040",	0x000001, 0x080000, CRC(837205b7) SHA1(f78b90c2be0b4dddaba26f074ea00eff863cfdb2) )
235 
236 	ROM_REGION( 0x800000, REGION_GFX1, ROMREGION_DISPOSE )
237 	ROM_LOAD( "th2-h8.32m",		0x000000, 0x400000, CRC(60328a11) SHA1(fcdb374d2fc7ef5351a4181c471d192199dc2081) )
238 	ROM_LOAD( "th2-h12.32m",	0x400000, 0x400000, CRC(b25c2d3e) SHA1(d70f3e4e2432d80c2ac87cd81208ada303bac04a) )
239 
240 	ROM_REGION( 0x140000, REGION_SOUND1, 0 )	/* ADPCM samples - sound chip is OKIM6295 */
241 	ROM_LOAD( "th2-c1.080",		0x000000, 0x100000, CRC(8fac8c30) SHA1(8e49bb596144761eae95f3e1266e57fb386664f2) )
242 	ROM_RELOAD(					0x040000, 0x100000 )
243 	/* 0x00000-0x2ffff is fixed, 0x30000-0x3ffff is bank switched */
244 ROM_END
245 
246 GAMEX( 1994, thoop2,  0, thoop2, thoop2,  0, ROT0, "Gaelco", "TH Strikes Back", GAME_UNEMULATED_PROTECTION )
247