1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 /***************************************************************************
4 
5 Hot Pinball
6 Gals Pinball
7 
8 driver by Nicola Salmoria
9 
10 Notes:
11 - to start a 2 or more players game, press the start button multiple times
12 - the sprite graphics contain a "(c) Tecmo", and the sprite system is
13   indeed similar to other Tecmo games like Ninja Gaiden.
14 - Clearly based on Tecmo's Super Pinball Action (see spbactn.c)
15 - There seems to be a bug in Hot Pinball's Demo Sounds. If you start the
16   game normally you get no demo sounds. However if you select the "Slide
17   Show" and run all the way through the game will start with demo sounds.
18   Gals Pinball's Demo Sounds works as expected according to DSW setting.
19 
20 TODO:
21 - scrolling is wrong.
22 - sprite/tile priority might be wrong. There is an unknown bit in the fg
23   tilemap, marking some tiles that I'm not currently drawing.
24 
25 Manuals for both games define the controls as 4 push buttons:
26 
27    Left Push Buttons                     Right Push Buttons
28 
29 |   o    |      o       |             |    o    |      o       |
30 |--------+--------------+-------------+------------------------|
31 | Select |     Set      | Select Mode |                        |
32 |  Stage |    Stage     |             |                        |
33 |--------+--------------+-------------+---------+--------------|
34 |Flipper | Shot & Shake |  Game Mode  | Flipper | Shot & Shake |
35 | Left   |    Left      |             |  Right  |    Right     |
36 |--------+--------------+-------------+---------+--------------|
37 
38 ***************************************************************************/
39 
40 #include "emu.h"
41 #include "includes/galspnbl.h"
42 
43 #include "cpu/m68000/m68000.h"
44 #include "cpu/z80/z80.h"
45 #include "sound/okim6295.h"
46 #include "sound/3812intf.h"
47 #include "speaker.h"
48 
49 
soundcommand_w(offs_t offset,uint16_t data,uint16_t mem_mask)50 void galspnbl_state::soundcommand_w(offs_t offset, uint16_t data, uint16_t mem_mask)
51 {
52 	if (ACCESSING_BITS_0_7)
53 	{
54 		m_soundlatch->write(data & 0xff);
55 		m_audiocpu->pulse_input_line(INPUT_LINE_NMI, attotime::zero);
56 	}
57 }
58 
59 
main_map(address_map & map)60 void galspnbl_state::main_map(address_map &map)
61 {
62 	map(0x000000, 0x3fffff).rom();
63 	map(0x700000, 0x703fff).ram();     /* galspnbl work RAM */
64 	map(0x708000, 0x70ffff).ram();     /* galspnbl work RAM, bitmaps are decompressed here */
65 	map(0x800000, 0x803fff).ram();     /* hotpinbl work RAM */
66 	map(0x808000, 0x80ffff).ram();     /* hotpinbl work RAM, bitmaps are decompressed here */
67 	map(0x880000, 0x880fff).ram().share("spriteram");
68 	map(0x8ff400, 0x8fffff).nopw();    /* ??? */
69 	map(0x900000, 0x900fff).ram().share("colorram");
70 	map(0x901000, 0x903fff).nopw();    /* ??? */
71 	map(0x904000, 0x904fff).ram().share("videoram");
72 	map(0x905000, 0x907fff).nopw();    /* ??? */
73 	map(0x980000, 0x9bffff).ram().share("bgvideoram");
74 	map(0xa00000, 0xa00fff).nopw();    /* more palette ? */
75 	map(0xa01000, 0xa017ff).w(m_palette, FUNC(palette_device::write16)).share("palette");
76 	map(0xa01800, 0xa027ff).nopw();    /* more palette ? */
77 	map(0xa80000, 0xa80001).portr("IN0");
78 	map(0xa80010, 0xa80011).portr("IN1").w(FUNC(galspnbl_state::soundcommand_w));
79 	map(0xa80020, 0xa80021).portr("SYSTEM").nopw();     /* w - could be watchdog, but causes resets when picture is shown */
80 	map(0xa80030, 0xa80031).portr("DSW1").nopw();       /* w - irq ack? */
81 	map(0xa80040, 0xa80041).portr("DSW2");
82 	map(0xa80050, 0xa80051).writeonly().share("scroll");    /* ??? */
83 }
84 
audio_map(address_map & map)85 void galspnbl_state::audio_map(address_map &map)
86 {
87 	map(0x0000, 0xefff).rom();
88 	map(0xf000, 0xf7ff).ram();
89 	map(0xf800, 0xf800).rw("oki", FUNC(okim6295_device::read), FUNC(okim6295_device::write));
90 	map(0xf810, 0xf811).w("ymsnd", FUNC(ym3812_device::write));
91 	map(0xfc00, 0xfc00).noprw(); /* irq ack ?? */
92 	map(0xfc20, 0xfc20).r(m_soundlatch, FUNC(generic_latch_8_device::read));
93 }
94 
95 
96 static INPUT_PORTS_START( galspnbl )
97 	PORT_START("IN0")
98 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )            /* tested at 0x0016c6 - doesn't seem tilt related */
99 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )            /* tested at 0x0016d2 - doesn't seem tilt related */
100 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
101 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
102 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME( "Left Flippers" )
103 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME( "Launch Ball / Shake (Left Side)" )
104 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )            /* uncalled (?) code at 0x007ed2 ('hotpinbl') or 0x008106 ('galspnbl') */
105 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
106 
107 	PORT_START("IN1")
108 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
109 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
110 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
111 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
112 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME( "Launch Ball / Shake (Right Side)" )
113 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME( "Right Flippers" )
114 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )            /* uncalled (?) code at 0x007e90 ('hotpinbl') or 0x0080c4 ('galspnbl') */
115 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
116 
117 	PORT_START("SYSTEM")
118 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
119 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 )
120 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 ) PORT_NAME( "Start" )  /* needed to avoid confusion with # of players. Press mulitple times for multiple players */
121 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
122 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
123 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
124 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
125 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
126 
127 	PORT_START("DSW1")  /* 0x700018.b */
128 	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW2:1,2") /* see code at 0x0085c6 ('hotpinbl') or 0x008994 ('galspnbl') */
129 	PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
130 	PORT_DIPSETTING(    0x03, DEF_STR( Normal ) )
131 	PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
132 	PORT_DIPSETTING(    0x00, DEF_STR( Very_Hard ) )
133 	PORT_DIPNAME( 0x0c, 0x0c, "Extra Ball" )        PORT_DIPLOCATION("SW2:3,4")
134 	PORT_DIPSETTING(    0x04, "100K 500K" )
135 	PORT_DIPSETTING(    0x0c, "200K 800K" )
136 	PORT_DIPSETTING(    0x08, "200K only" )
137 	PORT_DIPSETTING(    0x00, DEF_STR( None ) )
138 	PORT_DIPNAME( 0x10, 0x10, "Hit Difficulty" )        PORT_DIPLOCATION("SW2:5")
139 	PORT_DIPSETTING(    0x10, DEF_STR( Normal ) )
140 	PORT_DIPSETTING(    0x00, DEF_STR( Hard ) )
141 	PORT_DIPNAME( 0x20, 0x20, "Slide Show" )        PORT_DIPLOCATION("SW2:6") /* Listed as unused on manuals for both games */
142 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
143 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
144 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )  PORT_DIPLOCATION("SW2:7")
145 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
146 	PORT_DIPSETTING(    0x40, DEF_STR( On ) )
147 	PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW2:8" )
148 
149 	PORT_START("DSW2")  /* 0x700019.b */
150 	PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )       PORT_DIPLOCATION("SW1:1,2,3")
151 	PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
152 	PORT_DIPSETTING(    0x03, DEF_STR( 3C_1C ) )
153 	PORT_DIPSETTING(    0x04, DEF_STR( 2C_1C ) )
154 	PORT_DIPSETTING(    0x01, "2 Coins/1 Credit 3/2" )
155 	PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
156 	PORT_DIPSETTING(    0x06, "1 Coin/1 Credit 2/3" )
157 	PORT_DIPSETTING(    0x00, "1 Coin/1 Credit 5/6" )
158 	PORT_DIPSETTING(    0x05, DEF_STR( 1C_2C ) )
159 	PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )       PORT_DIPLOCATION("SW1:4,5,6")
160 	PORT_DIPSETTING(    0x10, DEF_STR( 4C_1C ) )
161 	PORT_DIPSETTING(    0x18, DEF_STR( 3C_1C ) )
162 	PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )
163 	PORT_DIPSETTING(    0x08, "2 Coins/1 Credit 3/2" )
164 	PORT_DIPSETTING(    0x38, DEF_STR( 1C_1C ) )
165 	PORT_DIPSETTING(    0x30, "1 Coin/1 Credit 2/3" )
166 	PORT_DIPSETTING(    0x00, "1 Coin/1 Credit 5/6" )
167 	PORT_DIPSETTING(    0x28, DEF_STR( 1C_2C ) )
168 	PORT_DIPNAME( 0xc0, 0xc0, "Balls" )         PORT_DIPLOCATION("SW1:7,8")
169 	PORT_DIPSETTING(    0x00, "2" )
170 	PORT_DIPSETTING(    0xc0, "3" )
171 	PORT_DIPSETTING(    0x80, "4" )
172 	PORT_DIPSETTING(    0x40, "5" )
173 INPUT_PORTS_END
174 
175 static INPUT_PORTS_START( hotpinbl )
176 	PORT_INCLUDE( galspnbl )
177 
178 	PORT_MODIFY("IN1")
179 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME( "Right Flippers" )
180 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME( "Launch Ball / Shake (Right Side)" )
181 INPUT_PORTS_END
182 
183 
184 static const gfx_layout tilelayout =
185 {
186 	16,8,
187 	RGN_FRAC(1,2),
188 	4,
189 	{ 0, 1, 2, 3 },
190 	{ 0*4, 1*4, RGN_FRAC(1,2)+0*4, RGN_FRAC(1,2)+1*4, 2*4, 3*4, RGN_FRAC(1,2)+2*4, RGN_FRAC(1,2)+3*4,
191 			16*8+0*4, 16*8+1*4, 16*8+RGN_FRAC(1,2)+0*4, 16*8+RGN_FRAC(1,2)+1*4, 16*8+2*4, 16*8+3*4, 16*8+RGN_FRAC(1,2)+2*4, 16*8+RGN_FRAC(1,2)+3*4 },
192 	{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
193 	32*8
194 };
195 
196 static const gfx_layout spritelayout =
197 {
198 	8,8,
199 	RGN_FRAC(1,2),
200 	4,
201 	{ 0, 1, 2, 3 },
202 	{ 0, 4, RGN_FRAC(1,2)+0, RGN_FRAC(1,2)+4, 8+0, 8+4, 8+RGN_FRAC(1,2)+0, 8+RGN_FRAC(1,2)+4 },
203 	{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
204 	16*8
205 };
206 
207 static GFXDECODE_START( gfx_galspnbl )
208 	GFXDECODE_ENTRY( "gfx1", 0, tilelayout,   512, 16 )
209 	GFXDECODE_ENTRY( "gfx2", 0, spritelayout,   0, 16 )
210 GFXDECODE_END
211 
212 
machine_start()213 void galspnbl_state::machine_start()
214 {
215 }
216 
galspnbl(machine_config & config)217 void galspnbl_state::galspnbl(machine_config &config)
218 {
219 	/* basic machine hardware */
220 	M68000(config, m_maincpu, XTAL(12'000'000));    /* 12 MHz ??? - Use value from Tecmo's Super Pinball Action - NEEDS VERIFICATION!! */
221 	m_maincpu->set_addrmap(AS_PROGRAM, &galspnbl_state::main_map);
222 	m_maincpu->set_vblank_int("screen", FUNC(galspnbl_state::irq3_line_hold)); /* also has vector for 6, but it does nothing */
223 
224 	Z80(config, m_audiocpu, XTAL(4'000'000));       /* 4 MHz ??? - Use value from Tecmo's Super Pinball Action - NEEDS VERIFICATION!! */
225 	m_audiocpu->set_addrmap(AS_PROGRAM, &galspnbl_state::audio_map);    /* NMI is caused by the main CPU */
226 
227 	/* video hardware */
228 	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
229 	m_screen->set_refresh_hz(60);
230 	m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0));
231 	m_screen->set_size(512, 256);
232 	m_screen->set_visarea(0, 512-1, 16, 240-1);
233 	m_screen->set_screen_update(FUNC(galspnbl_state::screen_update_galspnbl));
234 	m_screen->set_palette(m_palette);
235 
236 	MCFG_VIDEO_START_OVERRIDE(galspnbl_state,galspnbl)
237 
238 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_galspnbl);
239 	PALETTE(config, m_palette, FUNC(galspnbl_state::galspnbl_palette)).set_format(palette_device::xBGR_444, 1024 + 32768);
240 
241 	TECMO_SPRITE(config, m_sprgen, 0);
242 	m_sprgen->set_bootleg(true);
243 
244 	/* sound hardware */
245 	SPEAKER(config, "mono").front_center();
246 
247 	GENERIC_LATCH_8(config, m_soundlatch);
248 
249 	ym3812_device &ymsnd(YM3812(config, "ymsnd", XTAL(4'000'000))); /* Use value from Super Pinball Action - NEEDS VERIFICATION!! */
250 	ymsnd.irq_handler().set_inputline(m_audiocpu, 0);
251 	ymsnd.add_route(ALL_OUTPUTS, "mono", 1.0);
252 
253 	/* Use value from Super Pinball Action - clock frequency & pin 7 not verified */
254 	okim6295_device &oki(OKIM6295(config, "oki", XTAL(4'000'000)/4, okim6295_device::PIN7_HIGH));
255 	oki.add_route(ALL_OUTPUTS, "mono", 0.50);
256 }
257 
258 
259 /***************************************************************************
260 
261   Game driver(s)
262 
263 ***************************************************************************/
264 
265 ROM_START( galspnbl )
266 	ROM_REGION( 0x400000, "maincpu", 0 )    /* 68000 code */
267 	ROM_LOAD16_BYTE( "7.rom",        0x000000, 0x80000, CRC(ce0189bf) SHA1(06d8cc6f5b819fe2ca536ce553db6986547a15ba) )
268 	ROM_LOAD16_BYTE( "3.rom",        0x000001, 0x80000, CRC(9b0a8744) SHA1(ac80f22b8b2f4c559c225bf203af698bf59699e7) )
269 	ROM_LOAD16_BYTE( "8.rom",        0x100000, 0x80000, CRC(eee2f087) SHA1(37285ae7b49c9d20ad92b3971db89ba593975154) )
270 	ROM_LOAD16_BYTE( "4.rom",        0x100001, 0x80000, CRC(56298489) SHA1(6dce296d752fa5579e8a3c1db3e563c4f98b6bae) )
271 	ROM_LOAD16_BYTE( "9.rom",        0x200000, 0x80000, CRC(d9e4964c) SHA1(0bb63384ed57a6ee1d45d1f2c181172a3f0b39df) )
272 	ROM_LOAD16_BYTE( "5.rom",        0x200001, 0x80000, CRC(a5e71ee4) SHA1(f41ea4ab07be263157d6c1f4a96ef45c9bccfe39) )
273 	ROM_LOAD16_BYTE( "10.rom",       0x300000, 0x80000, CRC(3a20e1e5) SHA1(850be621547bc9c7519055211392f2684e440462) )
274 	ROM_LOAD16_BYTE( "6.rom",        0x300001, 0x80000, CRC(94927d20) SHA1(0ea1a179956ad9a93a99cccec92f0490044ad1d3) )
275 
276 	ROM_REGION( 0x10000, "audiocpu", 0 )    /* Z80 code */
277 	ROM_LOAD( "2.rom",        0x0000, 0x10000, CRC(fae688a7) SHA1(e1ef7abd18f6a820d1a7f0ceb9a9b1a2c7de41f0) )
278 
279 	ROM_REGION( 0x80000, "gfx1", 0 )
280 	ROM_LOAD( "17.rom",       0x00000, 0x40000, CRC(7d435701) SHA1(f6a2241c95f101d09b18f550689d125abd3ea9c4) )
281 	ROM_LOAD( "18.rom",       0x40000, 0x40000, CRC(136adaac) SHA1(5f5e70a66d256cad9fcdbc5a7fff035f9a3279b9) )
282 
283 	ROM_REGION( 0x40000, "gfx2", 0 )
284 	ROM_LOAD( "15.rom",       0x00000, 0x20000, CRC(4beb840d) SHA1(351cd8da361a55794595d2cf7b0fed9233d0a5a0) )
285 	ROM_LOAD( "16.rom",       0x20000, 0x20000, CRC(93d3c610) SHA1(0cf1f311ec2646a436c37e121634731646c06437) )
286 
287 	ROM_REGION( 0x40000, "oki", 0 ) /* OKIM6295 samples */
288 	ROM_LOAD( "1.rom",        0x00000, 0x40000, CRC(93c06d3d) SHA1(8620d274ca7824e7e72a1ad1da3eaa804d550653) )
289 ROM_END
290 
291 ROM_START( hotpinbl )
292 	ROM_REGION( 0x400000, "maincpu", 0 )    /* 68000 code */
293 	ROM_LOAD16_BYTE( "hp_07.bin",    0x000000, 0x80000, CRC(978cc13e) SHA1(0060aaf7259fdeeacb07e9ced01bdf69c27bdfb6) )
294 	ROM_LOAD16_BYTE( "hp_03.bin",    0x000001, 0x80000, CRC(68388726) SHA1(d8dca9050403be70097a0f833ba189bd2fa87e80) )
295 	ROM_LOAD16_BYTE( "hp_08.bin",    0x100000, 0x80000, CRC(bd16be12) SHA1(36e64705efba8ecdc96a62f55d68e959022fb98f) )
296 	ROM_LOAD16_BYTE( "hp_04.bin",    0x100001, 0x80000, CRC(655b0cf0) SHA1(4348d774155c61b1a29c2618f472a0032f4be9c0) )
297 	ROM_LOAD16_BYTE( "hp_09.bin",    0x200000, 0x80000, CRC(a6368624) SHA1(fa0b3dc4eb33a4b2d00e30676e59feec2fa64c3d) )
298 	ROM_LOAD16_BYTE( "hp_05.bin",    0x200001, 0x80000, CRC(48efd028) SHA1(8c968c4a73069a8f64e7bc339bab0eeb5254c580) )
299 	ROM_LOAD16_BYTE( "hp_10.bin",    0x300000, 0x80000, CRC(a5c63e34) SHA1(de27cfe20e09e8c13ee28d6eb42bfab1ebe33149) )
300 	ROM_LOAD16_BYTE( "hp_06.bin",    0x300001, 0x80000, CRC(513eda91) SHA1(14a43c00ad1f55bff525a14cd53913dd78e80f0c) )
301 
302 	ROM_REGION( 0x10000, "audiocpu", 0 )    /* Z80 code */
303 	ROM_LOAD( "hp_02.bin",    0x0000, 0x10000, CRC(82698269) SHA1(5e27e89f1bdd7c3793d40867c50981f5fac0a7fb) )
304 
305 	ROM_REGION( 0x80000, "gfx1", 0 )
306 	ROM_LOAD( "hp_13.bin",    0x00000, 0x40000, CRC(d53b64b9) SHA1(347b6ec908e23f848e98eed46fb34b49b728556b) )
307 	ROM_LOAD( "hp_14.bin",    0x40000, 0x40000, CRC(2fe3fcee) SHA1(29f96aa3dded6cb0b2fe3d9507fb5638e9778ef3) )
308 
309 	ROM_REGION( 0x40000, "gfx2", 0 )
310 	ROM_LOAD( "hp_11.bin",    0x00000, 0x20000, CRC(deecd7f1) SHA1(752c944d941bfe8f21d32881f32676999ebc5a7f) )
311 	ROM_LOAD( "hp_12.bin",    0x20000, 0x20000, CRC(5fd603c2) SHA1(864686cd1ba5beb6cebfd394b60620106c929abd) )
312 
313 	ROM_REGION( 0x40000, "oki", 0 ) /* OKIM6295 samples */
314 	ROM_LOAD( "hp_01.bin",    0x00000, 0x40000, CRC(93c06d3d) SHA1(8620d274ca7824e7e72a1ad1da3eaa804d550653) )
315 ROM_END
316 
317 
318 GAME( 1995, hotpinbl, 0, galspnbl, hotpinbl, galspnbl_state, empty_init, ROT90, "Comad & New Japan System", "Hot Pinball", MACHINE_SUPPORTS_SAVE )
319 GAME( 1996, galspnbl, 0, galspnbl, galspnbl, galspnbl_state, empty_init, ROT90, "Comad", "Gals Pinball", MACHINE_SUPPORTS_SAVE )
320