1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 /***************************************************************************
4 
5 Shanghai 3           (c)1993 Sunsoft     (68000     YM2149 OKI6295)
6 Hebereke no Popoon   (c)1994 Sunsoft     (68000 Z80 YM3438 OKI6295)
7 Blocken              (c)1994 KID / Visco (68000 Z80 YM3438 OKI6295)
8 
9 These games use the custom blitter GA9201 KA01-0249 (120pin IC)
10 
11 driver by Nicola Salmoria
12 
13 TODO:
14 all games:
15 - Blitter needs to be device-ized
16 shangha3:
17 - The zoom used for the "100" floating score when you remove tiles is very
18   rough.
19 heberpop:
20 - Unknown writes to sound ports 40/41
21 blocken:
22 - incomplete zoom support, and missing rotation support. Setting the game in
23   Game Mode B shows a decent test case for it by starting a play.
24 - attract mode tries to read at 0x80000-0xfffff area, returning 0 in there
25   freezes the demo play for some frames (MT #00985). For now I've returned $ff,
26   but needs HW tests to check out what lies in there (maybe a ROM mirror).
27 - how to play screen is bogus, it basically loses sync pretty soon.
28 
29 Notes:
30 - a Blocken PCB shot shows a 48 MHz xtal, game is definitely too slow at
31   8 MHz (noticeable thru colour cycling effects)
32 - Confirmed OSC is 48MHz and OKI resonator is 1.056MHz.
33 - Hebereke no Popoon has various debug mode switches, the ones found so far:
34   $30878e: bit 0 enable, active low.
35            If enabled correctly all of the non gameplay screens become
36        text stubs;
37   $aff14: a non-zero value enables CPU usage in 2p mode.
38           As a side-effect this also makes winning condition to never
39       satisfy, it goes on indefinitely with the selected characters and
40       input methods.
41 
42 ***************************************************************************/
43 
44 #include "emu.h"
45 #include "includes/shangha3.h"
46 
47 #include "cpu/m68000/m68000.h"
48 #include "cpu/z80/z80.h"
49 #include "sound/ay8910.h"
50 #include "sound/2612intf.h"
51 #include "speaker.h"
52 
53 
54 /* this looks like a simple protection check */
55 /*
56 write    read
57 78 78 -> 0
58 9b 10 -> 1
59 9b 20 -> 3
60 9b 40 -> 7
61 9b 80 -> f
62 08    -> e
63 10    -> c
64 20    -> 8
65 40    -> 0
66 */
shangha3_prot_r()67 uint16_t shangha3_state::shangha3_prot_r()
68 {
69 	static const int result[] = { 0x0,0x1,0x3,0x7,0xf,0xe,0xc,0x8,0x0};
70 
71 	logerror("PC %04x: read 20004e\n",m_maincpu->pc());
72 
73 	return result[m_prot_count++ % 9];
74 }
75 
shangha3_prot_w(uint16_t data)76 void shangha3_state::shangha3_prot_w(uint16_t data)
77 {
78 	logerror("PC %04x: write %02x to 20004e\n",m_maincpu->pc(),data);
79 }
80 
shangha3_coinctrl_w(uint8_t data)81 void shangha3_state::shangha3_coinctrl_w(uint8_t data)
82 {
83 	machine().bookkeeping().coin_lockout_w(0,~data & 0x04);
84 	machine().bookkeeping().coin_lockout_w(1,~data & 0x04);
85 	machine().bookkeeping().coin_counter_w(0,data & 0x01);
86 	machine().bookkeeping().coin_counter_w(1,data & 0x02);
87 }
88 
heberpop_coinctrl_w(uint8_t data)89 void shangha3_state::heberpop_coinctrl_w(uint8_t data)
90 {
91 	/* the sound ROM bank is selected by the main CPU! */
92 	m_oki->set_rom_bank((data >> 3) & 1);
93 
94 	machine().bookkeeping().coin_lockout_w(0,~data & 0x04);
95 	machine().bookkeeping().coin_lockout_w(1,~data & 0x04);
96 	machine().bookkeeping().coin_counter_w(0,data & 0x01);
97 	machine().bookkeeping().coin_counter_w(1,data & 0x02);
98 }
99 
blocken_coinctrl_w(uint8_t data)100 void shangha3_state::blocken_coinctrl_w(uint8_t data)
101 {
102 	/* the sound ROM bank is selected by the main CPU! */
103 	m_okibank->set_entry((data >> 4) & 3);
104 
105 	machine().bookkeeping().coin_lockout_w(0,~data & 0x04);
106 	machine().bookkeeping().coin_lockout_w(1,~data & 0x04);
107 	machine().bookkeeping().coin_counter_w(0,data & 0x01);
108 	machine().bookkeeping().coin_counter_w(1,data & 0x02);
109 }
110 
111 
irq_ack_w(uint16_t data)112 void shangha3_state::irq_ack_w(uint16_t data)
113 {
114 	m_maincpu->set_input_line(4, CLEAR_LINE);
115 }
116 
cgrom_r(offs_t offset)117 uint8_t shangha3_state::cgrom_r(offs_t offset)
118 {
119 	return m_cgrom[offset];
120 }
121 
shangha3_map(address_map & map)122 void shangha3_state::shangha3_map(address_map &map)
123 {
124 	map(0x000000, 0x07ffff).rom();
125 	map(0x100000, 0x100fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
126 	map(0x200000, 0x200001).portr("INPUTS");
127 	map(0x200002, 0x200003).portr("SYSTEM");
128 	map(0x200008, 0x200009).w(FUNC(shangha3_state::blitter_go_w));
129 	map(0x20000a, 0x20000b).w(FUNC(shangha3_state::irq_ack_w));
130 	map(0x20000c, 0x20000c).w(FUNC(shangha3_state::shangha3_coinctrl_w));
131 	map(0x20001f, 0x20001f).r("aysnd", FUNC(ym2149_device::data_r));
132 	map(0x20002f, 0x20002f).w("aysnd", FUNC(ym2149_device::data_w));
133 	map(0x20003f, 0x20003f).w("aysnd", FUNC(ym2149_device::address_w));
134 	map(0x20004e, 0x20004f).rw(FUNC(shangha3_state::shangha3_prot_r), FUNC(shangha3_state::shangha3_prot_w));
135 	map(0x20006f, 0x20006f).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write));
136 	map(0x300000, 0x30ffff).ram().share("ram"); /* gfx & work ram */
137 	map(0x340001, 0x340001).w(FUNC(shangha3_state::flipscreen_w));
138 	map(0x360000, 0x360001).w(FUNC(shangha3_state::gfxlist_addr_w));
139 }
140 
heberpop_map(address_map & map)141 void shangha3_state::heberpop_map(address_map &map)
142 {
143 	map(0x000000, 0x0fffff).rom();
144 	map(0x100000, 0x100fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
145 	map(0x200000, 0x200001).portr("INPUTS");
146 	map(0x200002, 0x200003).portr("SYSTEM");
147 	map(0x200004, 0x200005).portr("DSW");
148 	map(0x200008, 0x200009).w(FUNC(shangha3_state::blitter_go_w));
149 	map(0x20000a, 0x20000b).w(FUNC(shangha3_state::irq_ack_w));
150 	map(0x20000d, 0x20000d).w(FUNC(shangha3_state::heberpop_coinctrl_w));
151 	map(0x20000f, 0x20000f).w(m_soundlatch, FUNC(generic_latch_8_device::write));
152 	map(0x300000, 0x30ffff).ram().share("ram"); /* gfx & work ram */
153 	map(0x340001, 0x340001).w(FUNC(shangha3_state::flipscreen_w));
154 	map(0x360000, 0x360001).w(FUNC(shangha3_state::gfxlist_addr_w));
155 	map(0x800000, 0xb7ffff).r(FUNC(shangha3_state::cgrom_r));
156 }
157 
blocken_map(address_map & map)158 void shangha3_state::blocken_map(address_map &map)
159 {
160 	map(0x000000, 0x0fffff).rom();
161 	map(0x100000, 0x100001).portr("INPUTS");
162 	map(0x100002, 0x100003).portr("SYSTEM").nopw(); // w -> unknown purpose
163 	map(0x100004, 0x100005).portr("DSW");
164 	map(0x100008, 0x100009).w(FUNC(shangha3_state::blitter_go_w));
165 	map(0x10000a, 0x10000b).nopr().w(FUNC(shangha3_state::irq_ack_w)); // r -> unknown purpose (value doesn't matter, left-over?)
166 	map(0x10000d, 0x10000d).w(FUNC(shangha3_state::blocken_coinctrl_w));
167 	map(0x10000f, 0x10000f).w(m_soundlatch, FUNC(generic_latch_8_device::write));
168 	map(0x200000, 0x200fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
169 	map(0x300000, 0x30ffff).ram().share("ram"); /* gfx & work ram */
170 	map(0x340001, 0x340001).w(FUNC(shangha3_state::flipscreen_w));
171 	map(0x360000, 0x360001).w(FUNC(shangha3_state::gfxlist_addr_w));
172 	map(0x800000, 0xb7ffff).r(FUNC(shangha3_state::cgrom_r));
173 }
174 
175 
heberpop_sound_map(address_map & map)176 void shangha3_state::heberpop_sound_map(address_map &map)
177 {
178 	map(0x0000, 0xf7ff).rom();
179 	map(0xf800, 0xffff).ram();
180 }
181 
heberpop_sound_io_map(address_map & map)182 void shangha3_state::heberpop_sound_io_map(address_map &map)
183 {
184 	map.global_mask(0xff);
185 	map(0x00, 0x03).rw("ymsnd", FUNC(ym3438_device::read), FUNC(ym3438_device::write));
186 	map(0x80, 0x80).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write));
187 	map(0xc0, 0xc0).r(m_soundlatch, FUNC(generic_latch_8_device::read));
188 }
189 
190 /* $00000-$20000 stays the same in all sound banks, */
191 /* the second half of the bank is what gets switched */
blocken_oki_map(address_map & map)192 void shangha3_state::blocken_oki_map(address_map &map)
193 {
194 	map(0x00000, 0x1ffff).rom();
195 	map(0x20000, 0x3ffff).bankr("okibank");
196 }
197 
198 static INPUT_PORTS_START( shangha3 )
199 	PORT_START("INPUTS")
200 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
201 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
202 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
203 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
204 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
205 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
206 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
207 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
208 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
209 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
210 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
211 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
212 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
213 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
214 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
215 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
216 
217 	PORT_START("SYSTEM")
218 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
219 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
220 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 )
221 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_START1 )
222 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START2 )
223 	PORT_SERVICE_NO_TOGGLE(0x0020, IP_ACTIVE_LOW)
224 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
225 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen")
226 
227 	PORT_START("DSW1") /* Dipswitch locations assigned as per service mode */
228 	PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )       PORT_DIPLOCATION("SWA:1,2,3")
229 	PORT_DIPSETTING(    0x00, DEF_STR( 5C_1C ) )
230 	PORT_DIPSETTING(    0x04, DEF_STR( 4C_1C ) )
231 	PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ) )
232 	PORT_DIPSETTING(    0x06, DEF_STR( 2C_1C ) )
233 	PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
234 	PORT_DIPSETTING(    0x03, DEF_STR( 1C_2C ) )
235 	PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
236 	PORT_DIPSETTING(    0x01, DEF_STR( 1C_4C ) )
237 	PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )       PORT_DIPLOCATION("SWA:4,5,6")
238 	PORT_DIPSETTING(    0x00, DEF_STR( 5C_1C ) )
239 	PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
240 	PORT_DIPSETTING(    0x10, DEF_STR( 3C_1C ) )
241 	PORT_DIPSETTING(    0x30, DEF_STR( 2C_1C ) )
242 	PORT_DIPSETTING(    0x38, DEF_STR( 1C_1C ) )
243 	PORT_DIPSETTING(    0x18, DEF_STR( 1C_2C ) )
244 	PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) )
245 	PORT_DIPSETTING(    0x08, DEF_STR( 1C_4C ) )
246 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SWA:7")
247 	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
248 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
249 	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SWA:8")
250 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
251 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
252 
253 	PORT_START("DSW2") /* Dipswitch locations assigned as per service mode */
254 	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SWB:1,2")
255 	PORT_DIPSETTING(    0x01, DEF_STR( Easy ) )
256 	PORT_DIPSETTING(    0x03, DEF_STR( Normal ) )
257 	PORT_DIPSETTING(    0x02, DEF_STR( Hard ) )
258 	PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
259 	PORT_DIPNAME( 0x0c, 0x0c, "Base Time" )         PORT_DIPLOCATION("SWB:3,4")
260 	PORT_DIPSETTING(    0x04, "70 sec" )
261 	PORT_DIPSETTING(    0x0c, "80 sec" )
262 	PORT_DIPSETTING(    0x08, "90 sec" )
263 	PORT_DIPSETTING(    0x00, "100 sec" )
264 	PORT_DIPNAME( 0x30, 0x30, "Additional Time" )       PORT_DIPLOCATION("SWB:5,6")
265 	PORT_DIPSETTING(    0x10, "4 sec" )
266 	PORT_DIPSETTING(    0x30, "5 sec" )
267 	PORT_DIPSETTING(    0x20, "6 sec" )
268 	PORT_DIPSETTING(    0x00, "7 sec" )
269 	PORT_DIPNAME( 0x40, 0x00, DEF_STR( Demo_Sounds ) )  PORT_DIPLOCATION("SWB:7")
270 	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
271 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
272 	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) )  PORT_DIPLOCATION("SWB:8")
273 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
274 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
275 INPUT_PORTS_END
276 
277 static INPUT_PORTS_START( heberpop )
278 	PORT_START("INPUTS")
279 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
280 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
281 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
282 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
283 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
284 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
285 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
286 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") /* vblank?? has to toggle */
287 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
288 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
289 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
290 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
291 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
292 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
293 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
294 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") /* vblank?? has to toggle */
295 
296 	PORT_START("SYSTEM")
297 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
298 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
299 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 )
300 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_START1 )
301 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START2 )
302 	PORT_SERVICE_NO_TOGGLE(0x0020, IP_ACTIVE_LOW)
303 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
304 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
305 
306 	PORT_START("DSW") /* Dipswitch locations assigned as per service mode */
307 	PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Difficulty ) )       PORT_DIPLOCATION("SW1:1,2")
308 	PORT_DIPSETTING(      0x0002, DEF_STR( Very_Easy) )
309 	PORT_DIPSETTING(      0x0001, DEF_STR( Easy ) )
310 	PORT_DIPSETTING(      0x0003, DEF_STR( Normal ) )
311 	PORT_DIPSETTING(      0x0000, DEF_STR( Hard ) )
312 	PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:3")
313 	PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
314 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
315 	PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:4")
316 	PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
317 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
318 	PORT_DIPNAME( 0x0010, 0x0010, "Allow Diagonal Moves" )      PORT_DIPLOCATION("SW1:5")
319 	PORT_DIPSETTING(      0x0000, DEF_STR( No ) )
320 	PORT_DIPSETTING(      0x0010, DEF_STR( Yes ) )
321 	PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Demo_Sounds ) )      PORT_DIPLOCATION("SW1:6")
322 	PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
323 	PORT_DIPSETTING(      0x0020, DEF_STR( On ) )
324 	PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:7")
325 	PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
326 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
327 	PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:8")
328 	PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
329 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
330 	PORT_DIPNAME( 0x0700, 0x0700, DEF_STR( Coin_A ) )       PORT_DIPLOCATION("SW2:1,2,3")
331 	PORT_DIPSETTING(      0x0000, DEF_STR( 5C_1C ) )
332 	PORT_DIPSETTING(      0x0400, DEF_STR( 4C_1C ) )
333 	PORT_DIPSETTING(      0x0200, DEF_STR( 3C_1C ) )
334 	PORT_DIPSETTING(      0x0600, DEF_STR( 2C_1C ) )
335 	PORT_DIPSETTING(      0x0700, DEF_STR( 1C_1C ) )
336 	PORT_DIPSETTING(      0x0300, DEF_STR( 1C_2C ) )
337 	PORT_DIPSETTING(      0x0500, DEF_STR( 1C_3C ) )
338 	PORT_DIPSETTING(      0x0100, DEF_STR( 1C_4C ) )
339 	PORT_DIPNAME( 0x3800, 0x3800, DEF_STR( Coin_B ) )       PORT_DIPLOCATION("SW2:4,5,6")
340 	PORT_DIPSETTING(      0x0000, DEF_STR( 5C_1C ) )
341 	PORT_DIPSETTING(      0x2000, DEF_STR( 4C_1C ) )
342 	PORT_DIPSETTING(      0x1000, DEF_STR( 3C_1C ) )
343 	PORT_DIPSETTING(      0x3000, DEF_STR( 2C_1C ) )
344 	PORT_DIPSETTING(      0x3800, DEF_STR( 1C_1C ) )
345 	PORT_DIPSETTING(      0x1800, DEF_STR( 1C_2C ) )
346 	PORT_DIPSETTING(      0x2800, DEF_STR( 1C_3C ) )
347 	PORT_DIPSETTING(      0x0800, DEF_STR( 1C_4C ) )
348 	PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW2:7")
349 	PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
350 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
351 	PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW2:8")
352 	PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
353 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
354 INPUT_PORTS_END
355 
356 static INPUT_PORTS_START( blocken )
357 	PORT_START("INPUTS")
358 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
359 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
360 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
361 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
362 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
363 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
364 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
365 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") /* vblank?? has to toggle */
366 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
367 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
368 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
369 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
370 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
371 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
372 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
373 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") /* vblank?? has to toggle */
374 
375 	PORT_START("SYSTEM")
376 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
377 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
378 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 )
379 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_START1 )
380 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START2 )
381 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_SERVICE )  /* keeping this pressed on boot generates "BAD DIPSW" */
382 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
383 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
384 
385 	PORT_START("DSW") /* Dipswitch locations assigned as per service mode */
386 	PORT_SERVICE_DIPLOC(  0x0001, IP_ACTIVE_LOW, "SW1:1" )
387 	PORT_DIPNAME( 0x0006, 0x0006, DEF_STR( Difficulty ) )       PORT_DIPLOCATION("SW1:2,3")
388 	PORT_DIPSETTING(      0x0004, DEF_STR( Easy ) )
389 	PORT_DIPSETTING(      0x0006, DEF_STR( Normal ) )
390 	PORT_DIPSETTING(      0x0002, DEF_STR( Hard ) )
391 	PORT_DIPSETTING(      0x0000, DEF_STR( Very_Hard ) )
392 	PORT_DIPNAME( 0x0008, 0x0008, "Game Type" )         PORT_DIPLOCATION("SW1:4")
393 	PORT_DIPSETTING(      0x0008, "A" )
394 	PORT_DIPSETTING(      0x0000, "B" )
395 	PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Players ) )      PORT_DIPLOCATION("SW1:5,6")
396 	PORT_DIPSETTING(      0x0030, "1" )
397 	PORT_DIPSETTING(      0x0020, "2" )
398 	PORT_DIPSETTING(      0x0010, "3" )
399 	PORT_DIPSETTING(      0x0000, "4" )
400 	PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Demo_Sounds ) )      PORT_DIPLOCATION("SW1:7")
401 	PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
402 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
403 	PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )      PORT_DIPLOCATION("SW1:8")
404 	PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
405 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
406 	PORT_DIPNAME( 0x0f00, 0x0f00, DEF_STR( Coin_A ) )       PORT_DIPLOCATION("SW2:1,2,3,4")
407 	PORT_DIPSETTING(      0x0200, DEF_STR( 4C_1C ) )
408 	PORT_DIPSETTING(      0x0500, DEF_STR( 3C_1C ) )
409 	PORT_DIPSETTING(      0x0800, DEF_STR( 2C_1C ) )
410 	PORT_DIPSETTING(      0x0400, DEF_STR( 3C_2C ) )
411 	PORT_DIPSETTING(      0x0100, DEF_STR( 4C_3C ) )
412 	PORT_DIPSETTING(      0x0f00, DEF_STR( 1C_1C ) )
413 	PORT_DIPSETTING(      0x0300, DEF_STR( 3C_4C ) )
414 	PORT_DIPSETTING(      0x0700, DEF_STR( 2C_3C ) )
415 	PORT_DIPSETTING(      0x0e00, DEF_STR( 1C_2C ) )
416 	PORT_DIPSETTING(      0x0600, DEF_STR( 2C_5C ) )
417 	PORT_DIPSETTING(      0x0d00, DEF_STR( 1C_3C ) )
418 	PORT_DIPSETTING(      0x0c00, DEF_STR( 1C_4C ) )
419 	PORT_DIPSETTING(      0x0b00, DEF_STR( 1C_5C ) )
420 	PORT_DIPSETTING(      0x0a00, DEF_STR( 1C_6C ) )
421 	PORT_DIPSETTING(      0x0900, DEF_STR( 1C_7C ) )
422 	PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
423 	PORT_DIPNAME( 0xf000, 0xf000, DEF_STR( Coin_B ) )       PORT_DIPLOCATION("SW2:5,6,7,8")
424 	PORT_DIPSETTING(      0x2000, DEF_STR( 4C_1C ) )
425 	PORT_DIPSETTING(      0x5000, DEF_STR( 3C_1C ) )
426 	PORT_DIPSETTING(      0x8000, DEF_STR( 2C_1C ) )
427 	PORT_DIPSETTING(      0x0000, DEF_STR( 5C_3C ) )
428 	PORT_DIPSETTING(      0x4000, DEF_STR( 3C_2C ) )
429 	PORT_DIPSETTING(      0x1000, DEF_STR( 4C_3C ) )
430 	PORT_DIPSETTING(      0xf000, DEF_STR( 1C_1C ) )
431 	PORT_DIPSETTING(      0x3000, DEF_STR( 3C_4C ) )
432 	PORT_DIPSETTING(      0x7000, DEF_STR( 2C_3C ) )
433 	PORT_DIPSETTING(      0xe000, DEF_STR( 1C_2C ) )
434 	PORT_DIPSETTING(      0x6000, DEF_STR( 2C_5C ) )
435 	PORT_DIPSETTING(      0xd000, DEF_STR( 1C_3C ) )
436 	PORT_DIPSETTING(      0xc000, DEF_STR( 1C_4C ) )
437 	PORT_DIPSETTING(      0xb000, DEF_STR( 1C_5C ) )
438 	PORT_DIPSETTING(      0xa000, DEF_STR( 1C_6C ) )
439 	PORT_DIPSETTING(      0x9000, DEF_STR( 1C_7C ) )
440 INPUT_PORTS_END
441 
442 
443 
444 static const gfx_layout charlayout =
445 {
446 	16,16,
447 	RGN_FRAC(1,1),
448 	4,
449 	{ 0, 1, 2, 3 },
450 	{ 1*4, 0*4, 3*4, 2*4, 5*4, 4*4, 7*4, 6*4,
451 			9*4, 8*4, 11*4, 10*4, 13*4, 12*4, 15*4, 14*4 },
452 	{ STEP16(0,4*16) },
453 	128*8
454 };
455 
456 static GFXDECODE_START( gfx_shangha3 )
457 	GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 128 )
458 GFXDECODE_END
459 
460 
shangha3(machine_config & config)461 void shangha3_state::shangha3(machine_config &config)
462 {
463 	/* basic machine hardware */
464 	M68000(config, m_maincpu, 48_MHz_XTAL/3); // TMP68HC000N-16
465 	m_maincpu->set_addrmap(AS_PROGRAM, &shangha3_state::shangha3_map);
466 	m_maincpu->set_vblank_int("screen", FUNC(shangha3_state::irq4_line_assert));
467 
468 	/* video hardware */
469 	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
470 //  m_screen->set_refresh_hz(60);
471 //  m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
472 //  m_screen->set_size(24*16, 16*16);
473 //  m_screen->set_visarea(0*16, 24*16-1, 1*16, 15*16-1);
474 	m_screen->set_raw(48_MHz_XTAL/6, 512, 0, 24*16, 263, 1*16, 15*16); /* refresh rate is unknown */
475 	m_screen->set_screen_update(FUNC(shangha3_state::screen_update));
476 	m_screen->set_palette(m_palette);
477 
478 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_shangha3);
479 
480 	PALETTE(config, m_palette).set_format(palette_device::RGBx_555, 2048).enable_shadows();
481 
482 	/* sound hardware */
483 	SPEAKER(config, "mono").front_center();
484 
485 	ym2149_device &aysnd(YM2149(config, "aysnd", 48_MHz_XTAL/32)); // 1.5MHz
486 	aysnd.port_a_read_callback().set_ioport("DSW1");
487 	aysnd.port_b_read_callback().set_ioport("DSW2");
488 	aysnd.add_route(ALL_OUTPUTS, "mono", 0.30);
489 
490 	OKIM6295(config, m_oki, 1.056_MHz_XTAL, okim6295_device::PIN7_HIGH); // pin 7 not verified
491 	m_oki->add_route(ALL_OUTPUTS, "mono", 1.0);
492 }
493 
heberpop(machine_config & config)494 void shangha3_state::heberpop(machine_config &config)
495 {
496 	/* basic machine hardware */
497 	M68000(config, m_maincpu, 48_MHz_XTAL/3); // TMP68HC000N-16 like the others??
498 	m_maincpu->set_addrmap(AS_PROGRAM, &shangha3_state::heberpop_map);
499 	m_maincpu->set_vblank_int("screen", FUNC(shangha3_state::irq4_line_assert));
500 
501 	Z80(config, m_audiocpu, 48_MHz_XTAL/8);  /* 6 MHz ??? */
502 	m_audiocpu->set_addrmap(AS_PROGRAM, &shangha3_state::heberpop_sound_map);
503 	m_audiocpu->set_addrmap(AS_IO, &shangha3_state::heberpop_sound_io_map);  /* NMI triggered by YM3438 */
504 
505 	/* video hardware */
506 	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
507 //  m_screen->set_refresh_hz(60);
508 //  m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
509 //  m_screen->set_size(24*16, 16*16);
510 //  m_screen->set_visarea(0*16, 24*16-1, 1*16, 15*16-1);
511 	m_screen->set_raw(48_MHz_XTAL/6, 512, 0, 24*16, 263, 1*16, 15*16); /* refresh rate is unknown */
512 	m_screen->set_screen_update(FUNC(shangha3_state::screen_update));
513 	m_screen->set_palette(m_palette);
514 
515 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_shangha3);
516 
517 	PALETTE(config, m_palette).set_format(palette_device::RGBx_555, 2048).enable_shadows();
518 
519 	/* sound hardware */
520 	SPEAKER(config, "mono").front_center();
521 
522 	GENERIC_LATCH_8(config, m_soundlatch);
523 	m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, 0);
524 
525 	ym3438_device &ymsnd(YM3438(config, "ymsnd", 48_MHz_XTAL/6)); /* 8 MHz? */
526 	ymsnd.irq_handler().set_inputline("audiocpu", INPUT_LINE_NMI);
527 	ymsnd.add_route(0, "mono", 0.40);
528 	ymsnd.add_route(1, "mono", 0.40);
529 
530 	OKIM6295(config, m_oki, 1.056_MHz_XTAL, okim6295_device::PIN7_HIGH); // pin 7 not verified
531 	m_oki->add_route(ALL_OUTPUTS, "mono", 1.0);
532 }
533 
blocken(machine_config & config)534 void shangha3_state::blocken(machine_config &config)
535 {
536 	/* basic machine hardware */
537 	M68000(config, m_maincpu, 48_MHz_XTAL/3); // TMP68HC000N-16
538 	m_maincpu->set_addrmap(AS_PROGRAM, &shangha3_state::blocken_map);
539 	m_maincpu->set_vblank_int("screen", FUNC(shangha3_state::irq4_line_assert));
540 
541 	Z80(config, m_audiocpu, 48_MHz_XTAL/8);   /* 6 MHz? */
542 	m_audiocpu->set_addrmap(AS_PROGRAM, &shangha3_state::heberpop_sound_map);
543 	m_audiocpu->set_addrmap(AS_IO, &shangha3_state::heberpop_sound_io_map);  /* NMI triggered by YM3438 */
544 
545 	/* video hardware */
546 	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
547 //  m_screen->set_refresh_hz(60);
548 //  m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
549 //  m_screen->set_size(24*16, 16*16);
550 //  m_screen->set_visarea(0*16, 24*16-1, 1*16, 15*16-1);
551 	m_screen->set_raw(48_MHz_XTAL/6, 512, 0, 24*16, 263, 1*16, 15*16); /* refresh rate is unknown */
552 	m_screen->set_screen_update(FUNC(shangha3_state::screen_update));
553 	m_screen->set_palette(m_palette);
554 
555 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_shangha3);
556 
557 	PALETTE(config, m_palette).set_format(palette_device::RGBx_555, 2048).enable_shadows();
558 
559 	/* sound hardware */
560 	SPEAKER(config, "mono").front_center();
561 
562 	GENERIC_LATCH_8(config, m_soundlatch);
563 	m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, 0);
564 
565 	ym3438_device &ymsnd(YM3438(config, "ymsnd", 48_MHz_XTAL/6)); /* 8 MHz? */
566 	ymsnd.irq_handler().set_inputline("audiocpu", INPUT_LINE_NMI);
567 	ymsnd.add_route(0, "mono", 0.40);
568 	ymsnd.add_route(1, "mono", 0.40);
569 
570 	OKIM6295(config, m_oki, 1.056_MHz_XTAL, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 not verified
571 	m_oki->set_addrmap(0, &shangha3_state::blocken_oki_map);
572 	m_oki->add_route(ALL_OUTPUTS, "mono", 1.0);
573 }
574 
575 
576 
577 /***************************************************************************
578 
579   Game driver(s)
580 
581 ***************************************************************************/
582 
583 
584 /*
585 
586 Shanghai 3  (c)  1993 Sunsoft
587 
588 SUN04C
589 +-------------------------------------+
590 |        M6295 IC75                   |
591 |    1.056MHz  SW2                    |
592 | VOL  YM2149F SW1                    |
593 |                                     |
594 |                                     |
595 |J                    M M             |
596 |A                    2 2             |
597 |M        M                           |
598 |M        1    M    +------+     IC48*|
599 |A             3    |GA9201|     IC47*|
600 |         M         | KA01 |     IC46*|
601 |         1    M    | 0249 |     IC44*|
602 |              3    +------+          |
603 |    68000                        I   |
604 | I I                             C   |
605 | C C 48MHz                       4   |
606 | 3 2                             3   |
607 +-------------------------------------+
608 
609    CPU: TMP68HC000-16
610  Sound: YM2149F, OKI M6295
611  Video: GA9201 KA01-0249 (QFP120)
612    OSC: 48MHz, 1.056MHz (resonator)
613 Memory: M1 = TMM2018AP-45 (2K x 8 SRAM)
614         M2 = LH52B256D-70LL (32K x 8 SRAM)
615         M3 = TC514280BJL-70 (256K x 4 DRAM)
616  Other: SW1 & SW2 - 8-position dipswitch
617         VOL - Volume pot
618 
619 * = unpopulated 32 pin ROM sockets silkscreened 27C040
620 
621 NOTE: For the "World" set, it differs from the US set (besides the US set having the data repeated) by 2 bytes.
622 
623   0xB8B == 0x00 for world, 0x12 for US set (flag to show FBI warning screen)
624 0x32800 == 0xB9 for world, 0xCB for US set (checksum adjustment)
625 
626 */
627 
628 ROM_START( shangha3 ) /* PCB labeled SUN04C - Has two additional tiles sets to choose from. */
629 	ROM_REGION( 0x80000, "maincpu", 0 )
630 	ROM_LOAD16_BYTE( "ic3",  0x0000, 0x40000, CRC(4a9cdcfd) SHA1(c27b767ef2de90b36095b49baae9fa514f461c2c) ) /* ST M27C2001 EPROM with no label */
631 	ROM_LOAD16_BYTE( "ic2",  0x0001, 0x40000, CRC(714bfdbc) SHA1(0ce611624e8a5e28cba5443b63b8872eed9f68fc) ) /* ST M27C2001 EPROM with no label */
632 
633 	ROM_REGION( 0x400000, "gfx1", 0 )
634 	ROM_LOAD( "s3j_char-a1.ic43", 0x0000, 0x200000, CRC(2dbf9d17) SHA1(dd94ddc4bb02ab544aa3f89b614afc46678cc48d) ) /* 42pin mask ROM */
635 	ROM_LOAD( "27c4000.ic44", 0x200000, 0x080000, CRC(6344ffb7) SHA1(06bc5bcf94973ec152e7abf9cc658ef319eb4b65) ) // korean fonts, vs mode how to play etc? (probably for Korean program ROMs we don't have, but was on World board)
636 
637 	ROM_REGION( 0x40000, "oki", 0 ) /* samples for M6295 */
CRC(f0cdc86a)638 	ROM_LOAD( "s3j_v10.ic75", 0x0000, 0x40000, CRC(f0cdc86a) SHA1(b1017a9841a56e0f5d2714f550f64ed1f4e238e6) )
639 ROM_END
640 
641 ROM_START( shangha3u ) /* PCB labeled SUN04C - Shows FBI "Winners Don't Use Drugs" splash screen (once). Has two additional tiles sets to choose from. */
642 	ROM_REGION( 0x100000, "maincpu", 0 )
643 	ROM_LOAD16_BYTE( "ic3.ic3",  0x0000, 0x80000, CRC(53ef4988) SHA1(63f098d95865928a553e945fe60dea79aa16c603) ) /* ST M27C4001 EPROM labeled IC3 */
644 	ROM_LOAD16_BYTE( "ic2.ic2",  0x0001, 0x80000, CRC(fdea0232) SHA1(8983a646412df01b6bc66994700796e7b7fcbb61) ) /* ST M27C4001 EPROM labeled IC2 */
645 	/* both program ROMs are double sized with the identical halves */
646 
647 	ROM_REGION( 0x200000, "gfx1", 0 )
648 	ROM_LOAD( "s3j_char-a1.ic43", 0x0000, 0x200000, CRC(2dbf9d17) SHA1(dd94ddc4bb02ab544aa3f89b614afc46678cc48d) ) /* 42pin mask ROM */
649 
650 	ROM_REGION( 0x80000, "oki", 0 ) /* samples for M6295 */
651 	ROM_LOAD( "ic75.ic75", 0x0000, 0x80000, CRC(a8136d8c) SHA1(8028bda5642c2546c1ac8da78dbff4084829f03b) ) /* 27C4001 with 1st & 2nd halves == s3j_v10.ic75 */
652 ROM_END
653 
654 ROM_START( shangha3up ) /* PCB labeled SUN04 with a sticker labeled PCB 001, a prototyping version of the later SUN04C */
655 	ROM_REGION( 0x100000, "maincpu", 0 )
656 	ROM_LOAD16_BYTE( "syan3u_evn_10-7.ic3",  0x0000, 0x40000, CRC(a1f5275a) SHA1(71a024205bd5e6385bd9d746c339f0327bd1c1d6) ) /* ST M27C2001 EPROM hand written label:  SYAN3U  EVN 10/7 */
657 	ROM_LOAD16_BYTE( "syan3u_odd_10-7.ic2",  0x0001, 0x40000, CRC(fe3960bf) SHA1(545473260d959b8ed8145263d54f5f4523a844c4) ) /* ST M27C2001 EPROM hand written label:  SYAN3U  ODD 10/7 */
658 
659 	ROM_REGION( 0x200000, "gfx1", 0 ) /* same data as the 42 pin mask S3J CHAR-A1 */
660 	ROM_LOAD( "s3j_chr-a1_1_sum_53b1_93.9.20.ic80", 0x000000, 0x80000, CRC(fcaf795b) SHA1(312d85f39087564d67f12e0287f508b94b1493af) ) /* HN27C4001 hand written label:  S3J-CHR-A1  #1  SUM: 53B1  93.9.20 */
661 	ROM_LOAD( "s3j_chr-a1_2_sum_0e32_93.9.20.ic81", 0x080000, 0x80000, CRC(5a564f50) SHA1(34ca2ecd7101961e657034082802d89db5b4b7bd) ) /* HN27C4001 hand written label:  S3J-CHR-A1  #2  SUM: 0E32  93.9.20 */
662 	ROM_LOAD( "s3j_chr-a1_3_sum_0d9a_93.9.20.ic82", 0x100000, 0x80000, CRC(2b333c69) SHA1(6e720de5d222be25857ab18902636587e8c6afb8) ) /* HN27C4001 hand written label:  S3J-CHR-A1  #3  SUM: 0D9A  93.9.20 */
663 	ROM_LOAD( "s3j_chr-a1_4_sum_27e7_93.9.20.ic83", 0x180000, 0x80000, CRC(19be7039) SHA1(53839460b53144120cc2f68992c054062efa939b) ) /* HN27C4001 hand written label:  S3J-CHR-A1  #4  SUM: 27E7  93.9.20 */
664 
665 	ROM_REGION( 0x40000, "oki", 0 ) /* samples for M6295 */
666 	ROM_LOAD( "pcm_9-16_0166.ic75", 0x0000, 0x40000, CRC(f0cdc86a) SHA1(b1017a9841a56e0f5d2714f550f64ed1f4e238e6) ) /* Hand written label:  <kanji for Shanghai III>  PCM  9/16 0166 */
667 ROM_END
668 
669 ROM_START( shangha3j ) /* PCB labeled SUN04C */
670 	ROM_REGION( 0x80000, "maincpu", 0 )
671 	ROM_LOAD16_BYTE( "s3j_v11.ic3",  0x0000, 0x40000, CRC(e98ce9c8) SHA1(359e117aebb644d7b235add7e71ed6891243d451) )
672 	ROM_LOAD16_BYTE( "s3j_v11.ic2",  0x0001, 0x40000, CRC(09174620) SHA1(1d1639c07895f715facfe153fbdb6ae0f3cdd876) )
673 
674 	ROM_REGION( 0x200000, "gfx1", 0 )
675 	ROM_LOAD( "s3j_char-a1.ic43", 0x0000, 0x200000, CRC(2dbf9d17) SHA1(dd94ddc4bb02ab544aa3f89b614afc46678cc48d) ) /* 42pin mask ROM */
676 
677 	ROM_REGION( 0x40000, "oki", 0 ) /* samples for M6295 */
678 	ROM_LOAD( "s3j_v10.ic75", 0x0000, 0x40000, CRC(f0cdc86a) SHA1(b1017a9841a56e0f5d2714f550f64ed1f4e238e6) )
679 ROM_END
680 
681 ROM_START( heberpop ) /* PCB labeled SUN-06 */
682 	ROM_REGION( 0x100000, "maincpu", 0 )
683 	ROM_LOAD16_BYTE( "hbp_ic31.ic31",  0x0000, 0x80000, CRC(c430d264) SHA1(4be12b1fa90da09047db3a31171ffda8ab8bd851) )
684 	ROM_LOAD16_BYTE( "hbp_ic32.ic32",  0x0001, 0x80000, CRC(bfa555a8) SHA1(754f581554022b98ba8e78ee96f846faa2cedc69) )
685 
686 	ROM_REGION( 0x10000, "audiocpu", 0 )
687 	ROM_LOAD( "hbp_ic34_v1.0.ic34",  0x0000, 0x10000, CRC(0cf056c6) SHA1(9992cd3879d9a57fcb784fc1e11d6b6d87e5a366) )
688 
689 	ROM_REGION( 0x380000, "gfx1", ROMREGION_ERASEFF )
690 	ROM_LOAD( "hbp_ic98_v1.0.ic98",   0x000000, 0x80000, CRC(a599100a) SHA1(f2e517256a42b3fa4a047bbe742d714f568cc117) )
691 	ROM_LOAD( "hbp_ic99_v1.0.ic99",   0x080000, 0x80000, CRC(fb8bb12f) SHA1(78c1fec1371d312e113d92803dd59acc36604989) )
692 	ROM_LOAD( "hbp_ic100_v1.0.ic100", 0x100000, 0x80000, CRC(05a0f765) SHA1(4f44cf367c3697eb6c245297c9d05160d7d94e24) )
693 	ROM_LOAD( "hbp_ic101_v1.0.ic101", 0x180000, 0x80000, CRC(151ba025) SHA1(b6ebe60872957a2625e666d53a5a4bc941a1f21c) )
694 	ROM_LOAD( "hbp_ic102_v1.0.ic102", 0x200000, 0x80000, CRC(2b5e341a) SHA1(c7ad2dafb3433296c117978434e1699290267891) )
695 	ROM_LOAD( "hbp_ic103_v1.0.ic103", 0x280000, 0x80000, CRC(efa0e745) SHA1(fc1d52d35b3c902d8b25403b0e13f86a04039bc4) )
696 	ROM_LOAD( "hbp_ic104_v1.0.ic104", 0x300000, 0x80000, CRC(bb896bbb) SHA1(4311876628beb82cbacdab4d055c3738e74241b0) )
697 
698 	ROM_REGION( 0x80000, "oki", 0 ) /* samples for M6295 */
699 	ROM_LOAD( "hbp_ic53_v1.0.ic53",  0x0000, 0x80000, CRC(a4483aa0) SHA1(be301d8ac6d69f5c3fdbcb85bd557090e46da1ff) )
700 ROM_END
701 
702 ROM_START( blocken ) /* PCB labeled KID-07 */
703 	ROM_REGION( 0x100000, "maincpu", ROMREGION_ERASEFF )
704 	ROM_LOAD16_BYTE( "ic31j.bin",    0x0000, 0x20000, CRC(ec8de2a3) SHA1(09a6b8c1b656b17ab3d1fc057902487e4f94cf02) )
705 	ROM_LOAD16_BYTE( "ic32j.bin",    0x0001, 0x20000, CRC(79b96240) SHA1(c1246bd4b91fa45c581a8fdf90cc6beb85adf8ec) )
706 
707 	ROM_REGION( 0x10000, "audiocpu", 0 )
708 	ROM_LOAD( "ic34.bin",     0x0000, 0x10000, CRC(23e446ff) SHA1(82c03b45b337696b0f8293c446544d7ee080d415) )
709 
710 	ROM_REGION( 0x380000, "gfx1", ROMREGION_ERASEFF )
711 	ROM_LOAD( "ic98j.bin",    0x000000, 0x80000, CRC(35dda273) SHA1(95850d12ca1557c14bc471ddf925aaf423313ff0) )
712 	ROM_LOAD( "ic99j.bin",    0x080000, 0x80000, CRC(ce43762b) SHA1(e1c51ea0b54b5febdee127619e15f1cda650cb4c) )
713 	/* 100000-1fffff empty */
714 	ROM_LOAD( "ic100j.bin",   0x200000, 0x80000, CRC(a34786fd) SHA1(7d4879cbaa055c2ddbe6d20dd946bf0e3e069d4d) )
715 	/* 280000-37ffff empty */
716 
717 	ROM_REGION( 0x80000, "oki", 0 ) /* samples for M6295 */
718 	ROM_LOAD( "ic53.bin",     0x0000, 0x80000, CRC(86108c56) SHA1(aa405fa2eec5cc178ef6226f229a12dac09504f0) )
719 ROM_END
720 
721 
722 
723 void shangha3_state::init_shangha3()
724 {
725 	m_do_shadows = 1;
726 
727 	save_item(NAME(m_prot_count));
728 }
729 
init_heberpop()730 void shangha3_state::init_heberpop()
731 {
732 	m_do_shadows = 0;
733 
734 	// sound CPU runs in IM 0
735 	m_audiocpu->set_input_line_vector(0, 0xff);  /* Z80 - RST 38h */
736 }
737 
init_blocken()738 void shangha3_state::init_blocken()
739 {
740 	init_heberpop();
741 	m_okibank->configure_entries(0, 4, memregion("oki")->base(), 0x20000);
742 }
743 
744 GAME( 1993, shangha3,   0,        shangha3, shangha3, shangha3_state, init_shangha3, ROT0, "Sunsoft", "Shanghai III (World)", MACHINE_SUPPORTS_SAVE )
745 GAME( 1993, shangha3u,  shangha3, shangha3, shangha3, shangha3_state, init_shangha3, ROT0, "Sunsoft", "Shanghai III (US)", MACHINE_SUPPORTS_SAVE )
746 GAME( 1993, shangha3up, shangha3, shangha3, shangha3, shangha3_state, init_shangha3, ROT0, "Sunsoft", "Shanghai III (US, prototype)", MACHINE_SUPPORTS_SAVE )
747 GAME( 1993, shangha3j,  shangha3, shangha3, shangha3, shangha3_state, init_shangha3, ROT0, "Sunsoft", "Shanghai III (Japan)", MACHINE_SUPPORTS_SAVE )
748 GAME( 1994, heberpop,   0,        heberpop, heberpop, shangha3_state, init_heberpop, ROT0, "Sunsoft / Atlus", "Hebereke no Popoon (Japan)", MACHINE_SUPPORTS_SAVE )
749 GAME( 1994, blocken,    0,        blocken,  blocken,  shangha3_state, init_blocken,  ROT0, "Visco / KID", "Blocken (Japan)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE )
750