1 // license:BSD-3-Clause
2 // copyright-holders:Aaron Giles
3 /***************************************************************************
4 
5     Atari Shuuz hardware
6 
7     driver by Aaron Giles
8 
9     Games supported:
10         * Shuuz (1990) [2 sets]
11 
12     Known bugs:
13         * none at this time
14 
15 ****************************************************************************
16 
17     Memory map (TBA)
18 
19 ***************************************************************************/
20 
21 
22 #include "emu.h"
23 #include "includes/shuuz.h"
24 
25 #include "cpu/m68000/m68000.h"
26 #include "machine/eeprompar.h"
27 #include "machine/watchdog.h"
28 #include "sound/okim6295.h"
29 #include "emupal.h"
30 #include "speaker.h"
31 
32 
machine_start()33 void shuuz_state::machine_start()
34 {
35 	save_item(NAME(m_cur));
36 }
37 
38 /*************************************
39  *
40  *  Initialization
41  *
42  *************************************/
43 
latch_w(uint16_t data)44 void shuuz_state::latch_w(uint16_t data)
45 {
46 }
47 
48 
49 
50 /*************************************
51  *
52  *  LETA I/O
53  *
54  *************************************/
55 
leta_r(offs_t offset)56 uint16_t shuuz_state::leta_r(offs_t offset)
57 {
58 	/* trackball -- rotated 45 degrees? */
59 	int which = offset & 1;
60 
61 	/* when reading the even ports, do a real analog port update */
62 	if (which == 0)
63 	{
64 		int dx = (int8_t)ioport("TRACKX")->read();
65 		int dy = (int8_t)ioport("TRACKY")->read();
66 
67 		m_cur[0] = dx + dy;
68 		m_cur[1] = dx - dy;
69 	}
70 
71 	/* clip the result to -0x3f to +0x3f to remove directional ambiguities */
72 	return m_cur[which];
73 }
74 
75 
76 
77 /*************************************
78  *
79  *  Additional I/O
80  *
81  *************************************/
82 
special_port0_r()83 uint16_t shuuz_state::special_port0_r()
84 {
85 	int result = ioport("SYSTEM")->read();
86 
87 	if ((result & 0x0800) && get_hblank(*m_screen))
88 		result &= ~0x0800;
89 
90 	return result;
91 }
92 
93 
94 
95 /*************************************
96  *
97  *  Main CPU memory handlers
98  *
99  *************************************/
100 
main_map(address_map & map)101 void shuuz_state::main_map(address_map &map)
102 {
103 	map(0x000000, 0x03ffff).rom();
104 	map(0x100000, 0x100fff).rw("eeprom", FUNC(eeprom_parallel_28xx_device::read), FUNC(eeprom_parallel_28xx_device::write)).umask16(0x00ff);
105 	map(0x101000, 0x101fff).w("eeprom", FUNC(eeprom_parallel_28xx_device::unlock_write16));
106 	map(0x102000, 0x102001).w("watchdog", FUNC(watchdog_timer_device::reset16_w));
107 	map(0x103000, 0x103003).r(FUNC(shuuz_state::leta_r));
108 	map(0x105000, 0x105001).rw(FUNC(shuuz_state::special_port0_r), FUNC(shuuz_state::latch_w));
109 	map(0x105002, 0x105003).portr("BUTTONS");
110 	map(0x106001, 0x106001).rw("oki", FUNC(okim6295_device::read), FUNC(okim6295_device::write));
111 	map(0x107000, 0x107007).noprw();
112 	map(0x3e0000, 0x3e07ff).ram().w("palette", FUNC(palette_device::write16)).share("palette");
113 	map(0x3effc0, 0x3effff).rw(m_vad, FUNC(atari_vad_device::control_read), FUNC(atari_vad_device::control_write));
114 	map(0x3f4000, 0x3f5eff).ram().w(m_vad, FUNC(atari_vad_device::playfield_latched_msb_w)).share("vad:playfield");
115 	map(0x3f5f00, 0x3f5f7f).ram().share("vad:eof");
116 	map(0x3f5f80, 0x3f5fff).share("vad:mob:slip");
117 	map(0x3f6000, 0x3f7fff).ram().w(m_vad, FUNC(atari_vad_device::playfield_upper_w)).share("vad:playfield_ext");
118 	map(0x3f8000, 0x3fcfff).ram();
119 	map(0x3fd000, 0x3fd3ff).ram().share("vad:mob");
120 	map(0x3fd400, 0x3fffff).ram();
121 }
122 
123 
124 
125 /*************************************
126  *
127  *  Port definitions
128  *
129  *************************************/
130 
131 static INPUT_PORTS_START( shuuz )
132 	PORT_START("SYSTEM")
133 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
134 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
135 	PORT_BIT( 0x07fc, IP_ACTIVE_LOW, IPT_UNUSED )
136 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen")
137 	PORT_BIT( 0xf000, IP_ACTIVE_LOW, IPT_UNUSED )
138 
139 	PORT_START("BUTTONS")
140 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
141 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
142 	PORT_BIT( 0x07fc, IP_ACTIVE_LOW, IPT_UNUSED )
143 	PORT_SERVICE( 0x0800, IP_ACTIVE_LOW )
144 	PORT_BIT( 0xf000, IP_ACTIVE_LOW, IPT_UNUSED )
145 
146 	PORT_START("TRACKX")
147 	PORT_BIT( 0xff, 0, IPT_TRACKBALL_X ) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_PLAYER(1)
148 	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
149 
150 	PORT_START("TRACKY")
151 	PORT_BIT( 0xff, 0, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_REVERSE PORT_PLAYER(1)
152 	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
153 INPUT_PORTS_END
154 
155 
156 static INPUT_PORTS_START( shuuz2 )
157 	PORT_START("SYSTEM")
158 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
159 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
160 	PORT_BIT( 0x00fc, IP_ACTIVE_LOW, IPT_UNUSED )
161 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Step Debug SW") PORT_CODE(KEYCODE_S)
162 	PORT_BIT( 0x0600, IP_ACTIVE_LOW, IPT_UNUSED )
163 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen")
164 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Playfield Debug SW") PORT_CODE(KEYCODE_Y)
165 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Reset Debug SW") PORT_CODE(KEYCODE_E)
166 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Crosshair Debug SW") PORT_CODE(KEYCODE_C)
167 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Freeze Debug SW") PORT_CODE(KEYCODE_F)
168 
169 	PORT_START("BUTTONS")
170 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
171 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
172 	PORT_BIT( 0x00fc, IP_ACTIVE_LOW, IPT_UNUSED )
173 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Replay Debug SW") PORT_CODE(KEYCODE_R)
174 	PORT_BIT( 0x0600, IP_ACTIVE_LOW, IPT_UNUSED )
175 	PORT_SERVICE( 0x0800, IP_ACTIVE_LOW )
176 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
177 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
178 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
179 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
180 
181 	PORT_START("TRACKX")
182 	PORT_BIT( 0xff, 0, IPT_TRACKBALL_X ) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_PLAYER(1)
183 	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
184 
185 	PORT_START("TRACKY")
186 	PORT_BIT( 0xff, 0, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_REVERSE PORT_PLAYER(1)
187 	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
188 INPUT_PORTS_END
189 
190 
191 
192 /*************************************
193  *
194  *  Graphics definitions
195  *
196  *************************************/
197 
198 static const gfx_layout pfmolayout =
199 {
200 	8,8,
201 	RGN_FRAC(1,2),
202 	4,
203 	{ 0, 4, 0+RGN_FRAC(1,2), 4+RGN_FRAC(1,2) },
204 	{ 0, 1, 2, 3, 8, 9, 10, 11 },
205 	{ 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
206 	16*8
207 };
208 
209 
210 static GFXDECODE_START( gfx_shuuz )
211 	GFXDECODE_ENTRY( "gfx1", 0, pfmolayout,  256, 16 )      /* sprites & playfield */
212 	GFXDECODE_ENTRY( "gfx2", 0, pfmolayout,    0, 16 )      /* sprites & playfield */
213 GFXDECODE_END
214 
215 
216 
217 /*************************************
218  *
219  *  Machine driver
220  *
221  *************************************/
222 
shuuz(machine_config & config)223 void shuuz_state::shuuz(machine_config &config)
224 {
225 	/* basic machine hardware */
226 	M68000(config, m_maincpu, 14.318181_MHz_XTAL/2);
227 	m_maincpu->set_addrmap(AS_PROGRAM, &shuuz_state::main_map);
228 
229 	EEPROM_2816(config, "eeprom").lock_after_write(true);
230 
231 	WATCHDOG_TIMER(config, "watchdog");
232 
233 	/* video hardware */
234 	GFXDECODE(config, m_gfxdecode, "palette", gfx_shuuz);
235 	PALETTE(config, "palette").set_format(palette_device::IRGB_1555, 1024);
236 
237 	ATARI_VAD(config, m_vad, 0, m_screen);
238 	m_vad->scanline_int_cb().set_inputline(m_maincpu, M68K_IRQ_4);
239 	TILEMAP(config, "vad:playfield", m_gfxdecode, 2, 8, 8, TILEMAP_SCAN_COLS, 64, 64).set_info_callback(FUNC(shuuz_state::get_playfield_tile_info));
240 	ATARI_MOTION_OBJECTS(config, "vad:mob", 0, m_screen, shuuz_state::s_mob_config).set_gfxdecode(m_gfxdecode);
241 
242 	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
243 	m_screen->set_video_attributes(VIDEO_UPDATE_BEFORE_VBLANK);
244 	/* note: these parameters are from published specs, not derived */
245 	/* the board uses a VAD chip to generate video signals */
246 	m_screen->set_raw(14.318181_MHz_XTAL/2, 456, 0, 336, 262, 0, 240);
247 	m_screen->set_screen_update(FUNC(shuuz_state::screen_update));
248 	m_screen->set_palette("palette");
249 
250 	/* sound hardware */
251 	SPEAKER(config, "mono").front_center();
252 
253 	OKIM6295(config, "oki", 14.318181_MHz_XTAL/16, okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "mono", 1.0);
254 }
255 
256 
257 
258 /*************************************
259  *
260  *  ROM definition(s)
261  *
262  *************************************/
263 
264 ROM_START( shuuz )
265 	ROM_REGION( 0x40000, "maincpu", 0 ) /* 4*64k for 68000 code */
266 	ROM_LOAD16_BYTE( "136083-4010.23p",     0x00000, 0x20000, CRC(1c2459f8) SHA1(4b8daf196e3ba17cf958a3c1af4e4dacfb79b9e7) )
267 	ROM_LOAD16_BYTE( "136083-4011.13p",     0x00001, 0x20000, CRC(6db53a85) SHA1(7f9b3ea78fa65221931bfdab1aa5f1913ffed753) )
268 
269 	ROM_REGION( 0x080000, "gfx1", ROMREGION_INVERT )
270 	ROM_LOAD( "136083-2030.43x", 0x000000, 0x20000, CRC(8ecf1ed8) SHA1(47143f1eaf43027c5301eb6009d8a56a98328894) )
271 	ROM_LOAD( "136083-2032.20x", 0x020000, 0x20000, CRC(5af184e6) SHA1(630969466c606d1f51da81911fb365a4cac4685c) )
272 	ROM_LOAD( "136083-2031.87x", 0x040000, 0x20000, CRC(72e9db63) SHA1(be13830b38c2603bbd6b875abdc1675788a60b24) )
273 	ROM_LOAD( "136083-2033.65x", 0x060000, 0x20000, CRC(8f552498) SHA1(7fd323f3b30747a8645d7a9676fdf8f973b6632a) )
274 
275 	ROM_REGION( 0x100000, "gfx2", ROMREGION_INVERT )
276 	ROM_LOAD( "136083-1020.43u", 0x000000, 0x20000, CRC(d21ad039) SHA1(5389745eff6690c1890f98a9630869b1084fb2f3) )
277 	ROM_LOAD( "136083-1022.20u", 0x020000, 0x20000, CRC(0c10bc90) SHA1(11272757ecad42a4fae49046bd1b01d5ff7f7d4f) )
278 	ROM_LOAD( "136083-1024.43m", 0x040000, 0x20000, CRC(adb09347) SHA1(5294dfb3d4aa83525795ca03c2f328ab9a666baf) )
279 	ROM_LOAD( "136083-1026.20m", 0x060000, 0x20000, CRC(9b20e13d) SHA1(726b6fb548c0906a5baa90b9698f99a6af9ecc36) )
280 	ROM_LOAD( "136083-1021.87u", 0x080000, 0x20000, CRC(8388910c) SHA1(62c6b1885bed042ef72fb62464923a33f9b464f1) )
281 	ROM_LOAD( "136083-1023.65u", 0x0a0000, 0x20000, CRC(71353112) SHA1(0aab14379e1b562b81cdd52eb209e264a12232c4) )
282 	ROM_LOAD( "136083-1025.87m", 0x0c0000, 0x20000, CRC(f7b20a64) SHA1(667c539fa809d3ae4a1c127e2044dd3a4e533266) )
283 	ROM_LOAD( "136083-1027.65m", 0x0e0000, 0x20000, CRC(55d54952) SHA1(73e1a388ea48bab567bde8958ee228432ebfbf67) )
284 
285 	ROM_REGION( 0x40000, "oki", 0 ) /* ADPCM data */
286 	ROM_LOAD( "136083-1040.75b", 0x00000, 0x20000, CRC(0896702b) SHA1(d826bb4812d393889584c7c656c317fd5745a05f) )
287 	ROM_LOAD( "136083-1041.65b", 0x20000, 0x20000, CRC(b3b07ce9) SHA1(f1128a143b72867c16b9803b0beb0188420cbfb5) )
288 
289 	ROM_REGION( 0x0005, "pals", 0 )
290 	ROM_LOAD( "136083-1050.55c", 0x0000, 0x0001, NO_DUMP ) /* GAL16V8A-25LP */
291 	ROM_LOAD( "136083-1051.45e", 0x0000, 0x0001, NO_DUMP ) /* GAL16V8A-25LP */
292 	ROM_LOAD( "136083-1052.32l", 0x0000, 0x0001, NO_DUMP ) /* GAL16V8A-25LP */
293 	ROM_LOAD( "136083-1053.85n", 0x0000, 0x0001, NO_DUMP ) /* GAL16V8A-25LP */
294 	ROM_LOAD( "136083-1054.97n", 0x0000, 0x0001, NO_DUMP ) /* GAL16V8A-25LP */
295 ROM_END
296 
297 
298 ROM_START( shuuz2 )
299 	ROM_REGION( 0x40000, "maincpu", 0 ) /* 4*64k for 68000 code */
300 	ROM_LOAD16_BYTE( "136083-23p.rom",     0x00000, 0x20000, CRC(98aec4e7) SHA1(8cbe6e7835ecf0ef74a2de723ef970a63d3bddd1) )
301 	ROM_LOAD16_BYTE( "136083-13p.rom",     0x00001, 0x20000, CRC(dd9d5d5c) SHA1(0bde6be55532c232b1d27824c2ce61f33501cbb0) )
302 
303 	ROM_REGION( 0x080000, "gfx1", ROMREGION_INVERT )
304 	ROM_LOAD( "136083-2030.43x", 0x000000, 0x20000, CRC(8ecf1ed8) SHA1(47143f1eaf43027c5301eb6009d8a56a98328894) )
305 	ROM_LOAD( "136083-2032.20x", 0x020000, 0x20000, CRC(5af184e6) SHA1(630969466c606d1f51da81911fb365a4cac4685c) )
306 	ROM_LOAD( "136083-2031.87x", 0x040000, 0x20000, CRC(72e9db63) SHA1(be13830b38c2603bbd6b875abdc1675788a60b24) )
307 	ROM_LOAD( "136083-2033.65x", 0x060000, 0x20000, CRC(8f552498) SHA1(7fd323f3b30747a8645d7a9676fdf8f973b6632a) )
308 
309 	ROM_REGION( 0x100000, "gfx2", ROMREGION_INVERT )
310 	ROM_LOAD( "136083-1020.43u", 0x000000, 0x20000, CRC(d21ad039) SHA1(5389745eff6690c1890f98a9630869b1084fb2f3) )
311 	ROM_LOAD( "136083-1022.20u", 0x020000, 0x20000, CRC(0c10bc90) SHA1(11272757ecad42a4fae49046bd1b01d5ff7f7d4f) )
312 	ROM_LOAD( "136083-1024.43m", 0x040000, 0x20000, CRC(adb09347) SHA1(5294dfb3d4aa83525795ca03c2f328ab9a666baf) )
313 	ROM_LOAD( "136083-1026.20m", 0x060000, 0x20000, CRC(9b20e13d) SHA1(726b6fb548c0906a5baa90b9698f99a6af9ecc36) )
314 	ROM_LOAD( "136083-1021.87u", 0x080000, 0x20000, CRC(8388910c) SHA1(62c6b1885bed042ef72fb62464923a33f9b464f1) )
315 	ROM_LOAD( "136083-1023.65u", 0x0a0000, 0x20000, CRC(71353112) SHA1(0aab14379e1b562b81cdd52eb209e264a12232c4) )
316 	ROM_LOAD( "136083-1025.87m", 0x0c0000, 0x20000, CRC(f7b20a64) SHA1(667c539fa809d3ae4a1c127e2044dd3a4e533266) )
317 	ROM_LOAD( "136083-1027.65m", 0x0e0000, 0x20000, CRC(55d54952) SHA1(73e1a388ea48bab567bde8958ee228432ebfbf67) )
318 
319 	ROM_REGION( 0x40000, "oki", 0 ) /* ADPCM data */
320 	ROM_LOAD( "136083-1040.75b", 0x00000, 0x20000, CRC(0896702b) SHA1(d826bb4812d393889584c7c656c317fd5745a05f) )
321 	ROM_LOAD( "136083-1041.65b", 0x20000, 0x20000, CRC(b3b07ce9) SHA1(f1128a143b72867c16b9803b0beb0188420cbfb5) )
322 
323 	ROM_REGION( 0x0005, "pals", 0 )
324 	ROM_LOAD( "136083-1050.55c", 0x0000, 0x0001, NO_DUMP ) /* GAL16V8A-25LP */
325 	ROM_LOAD( "136083-1051.45e", 0x0000, 0x0001, NO_DUMP ) /* GAL16V8A-25LP */
326 	ROM_LOAD( "136083-1052.32l", 0x0000, 0x0001, NO_DUMP ) /* GAL16V8A-25LP */
327 	ROM_LOAD( "136083-1053.85n", 0x0000, 0x0001, NO_DUMP ) /* GAL16V8A-25LP */
328 	ROM_LOAD( "136083-1054.97n", 0x0000, 0x0001, NO_DUMP ) /* GAL16V8A-25LP */
329 ROM_END
330 
331 
332 
333 /*************************************
334  *
335  *  Game driver(s)
336  *
337  *************************************/
338 
339 GAME( 1990, shuuz,  0,     shuuz, shuuz,  shuuz_state, empty_init, ROT0, "Atari Games", "Shuuz (version 8.0)", MACHINE_SUPPORTS_SAVE )
340 GAME( 1990, shuuz2, shuuz, shuuz, shuuz2, shuuz_state, empty_init, ROT0, "Atari Games", "Shuuz (version 7.1)", MACHINE_SUPPORTS_SAVE )
341