1 // license:BSD-3-Clause
2 // copyright-holders:Phil Stroffolino
3 /***************************************************************************
4 
5     Atari Fire Truck + Super Bug + Monte Carlo driver
6 
7 ***************************************************************************/
8 
9 #include "emu.h"
10 #include "includes/firetrk.h"
11 
12 #include "cpu/m6800/m6800.h"
13 #include "sound/discrete.h"
14 #include "speaker.h"
15 
16 #include "superbug.lh"
17 
18 static constexpr XTAL MASTER_CLOCK = 12.096_MHz_XTAL;
19 
20 
set_service_mode(int enable)21 void firetrk_state::set_service_mode(int enable)
22 {
23 	m_in_service_mode = enable;
24 
25 	/* watchdog is disabled during service mode */
26 	m_watchdog->watchdog_enable(!enable);
27 
28 	/* change CPU clock speed according to service switch change */
29 	m_maincpu->set_unscaled_clock(enable ? (MASTER_CLOCK/16) : (MASTER_CLOCK/12));
30 }
31 
32 
INPUT_CHANGED_MEMBER(firetrk_state::service_mode_switch_changed)33 INPUT_CHANGED_MEMBER(firetrk_state::service_mode_switch_changed)
34 {
35 	set_service_mode(newval);
36 }
37 
38 
INPUT_CHANGED_MEMBER(firetrk_state::firetrk_horn_changed)39 INPUT_CHANGED_MEMBER(firetrk_state::firetrk_horn_changed)
40 {
41 	m_discrete->write(FIRETRUCK_HORN_EN, newval);
42 }
43 
44 
INPUT_CHANGED_MEMBER(firetrk_state::gear_changed)45 INPUT_CHANGED_MEMBER(firetrk_state::gear_changed)
46 {
47 	if (newval)
48 	{
49 		m_gear = param;
50 		output().set_value("P1gear", m_gear+1);
51 	}
52 }
53 
54 
TIMER_DEVICE_CALLBACK_MEMBER(firetrk_state::firetrk_scanline)55 TIMER_DEVICE_CALLBACK_MEMBER(firetrk_state::firetrk_scanline)
56 {
57 	int scanline = param;
58 
59 	// periodic IRQs are generated by inverse 16V signal
60 	if ((scanline & 0x1f) == 0 && scanline != 0)
61 		m_maincpu->pulse_input_line(0, attotime::from_hz(MASTER_CLOCK/2/64));
62 
63 	// vblank interrupt
64 	// NMIs are disabled during service mode
65 	if (!m_in_service_mode && scanline == 240)
66 		m_maincpu->pulse_input_line(INPUT_LINE_NMI, attotime::zero);
67 }
68 
69 
firetrk_output_w(uint8_t data)70 void firetrk_state::firetrk_output_w(uint8_t data)
71 {
72 	/* BIT0 => START1 LAMP */
73 	m_leds[0] = BIT(~data, 0);
74 
75 	/* BIT1 => START2 LAMP */
76 	m_leds[1]= BIT(~data, 1);
77 
78 	/* BIT2 => FLASH       */
79 	m_flash = data & 0x04;
80 
81 	/* BIT3 => TRACK LAMP  */
82 	m_leds[3] = BIT(~data, 3);
83 
84 	/* BIT4 => ATTRACT     */
85 	m_discrete->write(FIRETRUCK_ATTRACT_EN, data & 0x10);
86 	machine().bookkeeping().coin_lockout_w(0, !(data & 0x10));
87 	machine().bookkeeping().coin_lockout_w(1, !(data & 0x10));
88 
89 	/* BIT5 => START3 LAMP */
90 	m_leds[2] = BIT(~data, 5);
91 
92 	/* BIT6 => UNUSED      */
93 
94 	/* BIT7 => BELL OUT    */
95 	m_discrete->write(FIRETRUCK_BELL_EN, data & 0x80);
96 }
97 
98 
superbug_output_w(offs_t offset,uint8_t data)99 void firetrk_state::superbug_output_w(offs_t offset, uint8_t data)
100 {
101 	/* BIT0 => START LAMP */
102 	m_leds[0] = BIT(offset, 0);
103 
104 	/* BIT1 => ATTRACT    */
105 	m_discrete->write(SUPERBUG_ATTRACT_EN, offset & 0x02);
106 	machine().bookkeeping().coin_lockout_w(0, !(offset & 0x02));
107 	machine().bookkeeping().coin_lockout_w(1, !(offset & 0x02));
108 
109 	/* BIT2 => FLASH      */
110 	m_flash = offset & 0x04;
111 
112 	/* BIT3 => TRACK LAMP */
113 	m_leds[1] = BIT(offset, 3);
114 }
115 
116 
montecar_output_1_w(uint8_t data)117 void firetrk_state::montecar_output_1_w(uint8_t data)
118 {
119 	/* BIT0 => START LAMP    */
120 	m_leds[0] = BIT(~data, 0);
121 
122 	/* BIT1 => TRACK LAMP    */
123 	m_leds[1] = BIT(~data, 1);
124 
125 	/* BIT2 => ATTRACT       */
126 	m_discrete->write(MONTECAR_ATTRACT_INV, data & 0x04);
127 
128 	/* BIT3 => UNUSED        */
129 	/* BIT4 => UNUSED        */
130 
131 	/* BIT5 => COIN3 COUNTER */
132 	machine().bookkeeping().coin_counter_w(0, data & 0x80);
133 
134 	/* BIT6 => COIN2 COUNTER */
135 	machine().bookkeeping().coin_counter_w(1, data & 0x40);
136 
137 	/* BIT7 => COIN1 COUNTER */
138 	machine().bookkeeping().coin_counter_w(2, data & 0x20);
139 }
140 
141 
montecar_output_2_w(uint8_t data)142 void firetrk_state::montecar_output_2_w(uint8_t data)
143 {
144 	m_flash = data & 0x80;
145 
146 	m_discrete->write(MONTECAR_BEEPER_EN, data & 0x10);
147 	m_discrete->write(MONTECAR_DRONE_LOUD_DATA, data & 0x0f);
148 }
149 
150 
machine_reset()151 void firetrk_state::machine_reset()
152 {
153 	set_service_mode(0);
154 }
155 
156 
firetrk_dip_r(offs_t offset)157 uint8_t firetrk_state::firetrk_dip_r(offs_t offset)
158 {
159 	uint8_t val0 = m_dips[0]->read();
160 	uint8_t val1 = m_dips[1]->read();
161 
162 	if (val1 & (1 << (2 * offset + 0))) val0 |= 1;
163 	if (val1 & (1 << (2 * offset + 1))) val0 |= 2;
164 
165 	return val0;
166 }
167 
168 
montecar_dip_r(offs_t offset)169 uint8_t firetrk_state::montecar_dip_r(offs_t offset)
170 {
171 	uint8_t val0 = m_dips[0]->read();
172 	uint8_t val1 = m_dips[1]->read();
173 
174 	if (val1 & (1 << (3 - offset))) val0 |= 1;
175 	if (val1 & (1 << (7 - offset))) val0 |= 2;
176 
177 	return val0;
178 }
179 
180 
181 template <int P>
READ_LINE_MEMBER(firetrk_state::steer_dir_r)182 READ_LINE_MEMBER(firetrk_state::steer_dir_r)
183 {
184 	return m_steer_dir[P];
185 }
186 
187 
188 template <int P>
READ_LINE_MEMBER(firetrk_state::steer_flag_r)189 READ_LINE_MEMBER(firetrk_state::steer_flag_r)
190 {
191 	return m_steer_flag[P];
192 }
193 
194 
195 template <int P>
READ_LINE_MEMBER(firetrk_state::skid_r)196 READ_LINE_MEMBER(firetrk_state::skid_r)
197 {
198 	uint32_t ret;
199 
200 	if (P != 2)
201 		ret = m_skid[P];
202 	else
203 		ret = m_skid[0] | m_skid[1];
204 
205 	return ret;
206 }
207 
208 
209 template <int P>
READ_LINE_MEMBER(firetrk_state::crash_r)210 READ_LINE_MEMBER(firetrk_state::crash_r)
211 {
212 	uint32_t ret;
213 
214 	if (P != 2)
215 		ret = m_crash[P];
216 	else
217 		ret = m_crash[0] | m_crash[1];
218 
219 	return ret;
220 }
221 
222 
223 template <int P>
READ_LINE_MEMBER(firetrk_state::gear_r)224 READ_LINE_MEMBER(firetrk_state::gear_r)
225 {
226 	return (m_gear == P) ? 1 : 0;
227 }
228 
229 
firetrk_input_r(offs_t offset)230 uint8_t firetrk_state::firetrk_input_r(offs_t offset)
231 {
232 	/* update steering wheels */
233 	for (int i = 0; i < 2; i++)
234 	{
235 		uint32_t const new_dial = m_steer[i].read_safe(0);
236 		int32_t const delta = new_dial - m_dial[i];
237 
238 		if (delta != 0)
239 		{
240 			m_steer_flag[i] = 0;
241 			m_steer_dir[i] = (delta < 0) ? 1 : 0;
242 
243 			m_dial[i] = m_dial[i] + delta;
244 		}
245 	}
246 
247 	return ((m_bit_0.read_safe(0) & (1 << offset)) ? 0x01 : 0) |
248 			((m_bit_6.read_safe(0) & (1 << offset)) ? 0x40 : 0) |
249 			((m_bit_7.read_safe(0) & (1 << offset)) ? 0x80 : 0);
250 }
251 
252 
montecar_input_r(offs_t offset)253 uint8_t firetrk_state::montecar_input_r(offs_t offset)
254 {
255 	uint8_t ret = firetrk_input_r(offset);
256 
257 	if (m_crash[0])
258 		ret |= 0x02;
259 
260 	/* can this be right, bit 0 again ???? */
261 	if (m_crash[1])
262 		ret |= 0x01;
263 
264 	return ret;
265 }
266 
267 
blink_on_w(uint8_t data)268 void firetrk_state::blink_on_w(uint8_t data)
269 {
270 	*m_blink = true;
271 }
272 
273 
montecar_car_reset_w(uint8_t data)274 void firetrk_state::montecar_car_reset_w(uint8_t data)
275 {
276 	m_crash[0] = 0;
277 	m_skid[0] = 0;
278 }
279 
280 
montecar_drone_reset_w(uint8_t data)281 void firetrk_state::montecar_drone_reset_w(uint8_t data)
282 {
283 	m_crash[1] = 0;
284 	m_skid[1] = 0;
285 }
286 
287 
steer_reset_w(uint8_t data)288 void firetrk_state::steer_reset_w(uint8_t data)
289 {
290 	m_steer_flag[0] = 1;
291 	m_steer_flag[1] = 1;
292 }
293 
294 
crash_reset_w(uint8_t data)295 void firetrk_state::crash_reset_w(uint8_t data)
296 {
297 	m_crash[0] = 0;
298 	m_crash[1] = 0;
299 }
300 
301 
firetrk_map(address_map & map)302 void firetrk_state::firetrk_map(address_map &map)
303 {
304 	map.global_mask(0x3fff);
305 	map(0x0000, 0x00ff).mirror(0x0700).ram().share("alpha_num_ram");
306 	map(0x0800, 0x08ff).mirror(0x0700).ram().share("playfield_ram");
307 	map(0x1000, 0x1000).mirror(0x001f).writeonly().share("scroll_y");
308 	map(0x1020, 0x1020).mirror(0x001f).writeonly().share("scroll_x");
309 	map(0x1040, 0x1040).mirror(0x001f).w(FUNC(firetrk_state::crash_reset_w));
310 	map(0x1060, 0x1060).mirror(0x001f).w(FUNC(firetrk_state::firetrk_skid_reset_w));
311 	map(0x1080, 0x1080).mirror(0x001f).writeonly().share("car_rot");
312 	map(0x10a0, 0x10a0).mirror(0x001f).w(FUNC(firetrk_state::steer_reset_w));
313 	map(0x10c0, 0x10c0).mirror(0x001f).w(m_watchdog, FUNC(watchdog_timer_device::reset_w));
314 	map(0x10e0, 0x10e0).mirror(0x001f).w(FUNC(firetrk_state::blink_on_w)).share("blink");
315 	map(0x1400, 0x1400).mirror(0x001f).w(FUNC(firetrk_state::firetrk_motor_snd_w));
316 	map(0x1420, 0x1420).mirror(0x001f).w(FUNC(firetrk_state::firetrk_crash_snd_w));
317 	map(0x1440, 0x1440).mirror(0x001f).w(FUNC(firetrk_state::firetrk_skid_snd_w));
318 	map(0x1460, 0x1460).mirror(0x001f).writeonly().share("drone_x");
319 	map(0x1480, 0x1480).mirror(0x001f).writeonly().share("drone_y");
320 	map(0x14a0, 0x14a0).mirror(0x001f).writeonly().share("drone_rot");
321 	map(0x14c0, 0x14c0).mirror(0x001f).w(FUNC(firetrk_state::firetrk_output_w));
322 	map(0x14e0, 0x14e0).mirror(0x001f).w(FUNC(firetrk_state::firetrk_xtndply_w));
323 	map(0x1800, 0x1807).mirror(0x03f8).r(FUNC(firetrk_state::firetrk_input_r)).nopw();
324 	map(0x1c00, 0x1c03).mirror(0x03fc).r(FUNC(firetrk_state::firetrk_dip_r));
325 	map(0x2000, 0x3fff).rom();
326 }
327 
328 
superbug_map(address_map & map)329 void firetrk_state::superbug_map(address_map &map)
330 {
331 	map.global_mask(0x1fff);
332 	map(0x0000, 0x00ff).ram();
333 	map(0x0100, 0x0100).mirror(0x001f).writeonly().share("scroll_y");
334 	map(0x0120, 0x0120).mirror(0x001f).writeonly().share("scroll_x");
335 	map(0x0140, 0x0140).mirror(0x001f).w(FUNC(firetrk_state::crash_reset_w));
336 	map(0x0160, 0x0160).mirror(0x001f).w(FUNC(firetrk_state::firetrk_skid_reset_w));
337 	map(0x0180, 0x0180).mirror(0x001f).writeonly().share("car_rot");
338 	map(0x01a0, 0x01a0).mirror(0x001f).w(FUNC(firetrk_state::steer_reset_w));
339 	map(0x01c0, 0x01c0).mirror(0x001f).w(m_watchdog, FUNC(watchdog_timer_device::reset_w));
340 	map(0x01e0, 0x01e0).mirror(0x001f).w(FUNC(firetrk_state::blink_on_w)).share("blink");
341 	map(0x0200, 0x0207).mirror(0x0018).r(FUNC(firetrk_state::firetrk_input_r));
342 	map(0x0220, 0x0220).mirror(0x001f).w(FUNC(firetrk_state::firetrk_xtndply_w));
343 	map(0x0240, 0x0243).mirror(0x001c).r(FUNC(firetrk_state::firetrk_dip_r));
344 	map(0x0260, 0x026f).mirror(0x0010).w(FUNC(firetrk_state::superbug_output_w));
345 	map(0x0280, 0x0280).mirror(0x001f).w(FUNC(firetrk_state::superbug_motor_snd_w));
346 	map(0x02a0, 0x02a0).mirror(0x001f).w(FUNC(firetrk_state::firetrk_crash_snd_w));
347 	map(0x02c0, 0x02c0).mirror(0x001f).w(FUNC(firetrk_state::firetrk_skid_snd_w));
348 	map(0x0400, 0x041f).ram().share("alpha_num_ram");
349 	map(0x0500, 0x05ff).ram().share("playfield_ram");
350 	map(0x0800, 0x1fff).rom();
351 }
352 
353 
montecar_map(address_map & map)354 void firetrk_state::montecar_map(address_map &map)
355 {
356 	map.global_mask(0x3fff);
357 	map(0x0000, 0x00ff).mirror(0x0700).ram().share("alpha_num_ram");
358 	map(0x0800, 0x08ff).mirror(0x0700).ram().share("playfield_ram");
359 	map(0x1000, 0x1000).mirror(0x001f).writeonly().share("scroll_y");
360 	map(0x1020, 0x1020).mirror(0x001f).writeonly().share("scroll_x");
361 	map(0x1040, 0x1040).mirror(0x001f).w(FUNC(firetrk_state::montecar_drone_reset_w));
362 	map(0x1060, 0x1060).mirror(0x001f).w(FUNC(firetrk_state::montecar_car_reset_w));
363 	map(0x1080, 0x1080).mirror(0x001f).writeonly().share("car_rot");
364 	map(0x10a0, 0x10a0).mirror(0x001f).w(FUNC(firetrk_state::steer_reset_w));
365 	map(0x10c0, 0x10c0).mirror(0x001f).w(m_watchdog, FUNC(watchdog_timer_device::reset_w));
366 	map(0x10e0, 0x10e0).mirror(0x001f).w(FUNC(firetrk_state::montecar_skid_reset_w));
367 	map(0x1400, 0x1400).mirror(0x001f).w(FUNC(firetrk_state::firetrk_motor_snd_w));
368 	map(0x1420, 0x1420).mirror(0x001f).w(FUNC(firetrk_state::firetrk_crash_snd_w));
369 	map(0x1440, 0x1440).mirror(0x001f).w(FUNC(firetrk_state::firetrk_skid_snd_w));
370 	map(0x1460, 0x1460).mirror(0x001f).writeonly().share("drone_x");
371 	map(0x1480, 0x1480).mirror(0x001f).writeonly().share("drone_y");
372 	map(0x14a0, 0x14a0).mirror(0x001f).writeonly().share("drone_rot");
373 	map(0x14c0, 0x14c0).mirror(0x001f).w(FUNC(firetrk_state::montecar_output_1_w));
374 	map(0x14e0, 0x14e0).mirror(0x001f).w(FUNC(firetrk_state::montecar_output_2_w));
375 	map(0x1800, 0x1807).mirror(0x03f8).r(FUNC(firetrk_state::montecar_input_r)).nopw();
376 	map(0x1c00, 0x1c03).mirror(0x03fc).r(FUNC(firetrk_state::montecar_dip_r));
377 	map(0x2000, 0x3fff).rom();
378 }
379 
380 
381 static INPUT_PORTS_START( firetrk )
382 	PORT_START("STEER_1")
383 	PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) PORT_PLAYER(1)
384 
385 	PORT_START("STEER_2")
386 	PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) PORT_PLAYER(2)
387 
388 	PORT_START("DIP_0")
389 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) /* other DIPs connect here */
390 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) /* other DIPs connect here */
391 	PORT_DIPNAME( 0x0c, 0x08, DEF_STR( Coinage ))
392 	PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ))
393 	PORT_DIPSETTING(    0x08, DEF_STR( 1C_1C ))
394 	PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ))
395 	PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ))
396 	PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unused ))
397 	PORT_DIPSETTING(    0x10, DEF_STR( Off ))
398 	PORT_DIPSETTING(    0x00, DEF_STR( On ))
399 	PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unused ))
400 	PORT_DIPSETTING(    0x20, DEF_STR( Off ))
401 	PORT_DIPSETTING(    0x00, DEF_STR( On ))
402 
403 	PORT_START("DIP_1")
404 	PORT_DIPNAME( 0x03, 0x00, DEF_STR( Language ) )
405 	PORT_DIPSETTING(    0x00, DEF_STR( English ) )
406 	PORT_DIPSETTING(    0x01, DEF_STR( French ) )
407 	PORT_DIPSETTING(    0x02, DEF_STR( Spanish ) )
408 	PORT_DIPSETTING(    0x03, DEF_STR( German ) )
409 	PORT_DIPNAME( 0x0c, 0x04, "Play Time" )
410 	PORT_DIPSETTING(    0x00, "60 Seconds" )
411 	PORT_DIPSETTING(    0x04, "90 Seconds" )
412 	PORT_DIPSETTING(    0x08, "120 Seconds" )
413 	PORT_DIPSETTING(    0x0c, "150 Seconds" )
414 	PORT_DIPNAME( 0x30, 0x20, "Extended Play" )
415 	PORT_DIPSETTING(    0x10, "Liberal" )
416 	PORT_DIPSETTING(    0x20, DEF_STR( Medium ) )
417 	PORT_DIPSETTING(    0x30, "Conservative" )
418 	PORT_DIPSETTING(    0x00, "Never" )
419 
420 	PORT_START("BIT_0")
421 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
422 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Gas") PORT_PLAYER(1)
423 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, steer_dir_r<0>)
424 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, steer_dir_r<1>)
425 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Bell") PORT_PLAYER(2)
426 	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_TILT )
427 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, skid_r<2>)
428 	PORT_SERVICE( 0x80, IP_ACTIVE_HIGH ) PORT_CHANGED_MEMBER(DEVICE_SELF, firetrk_state, service_mode_switch_changed, 0)
429 
430 	PORT_START("BIT_6")
431 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("Front Player Start")
432 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("Back Player Start")
433 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START3 ) PORT_NAME("Both Players Start")
434 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Track Select") PORT_PLAYER(1)
435 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED )
436 	PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_CUSTOM ) PORT_VBLANK("screen")
437 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Cabinet ))
438 	PORT_DIPSETTING(    0x00, "Smokey Joe (1 Player)" )
439 	PORT_DIPSETTING(    0x40, "Fire Truck (2 Players)" )
440 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SERVICE2 ) PORT_NAME("Diag Hold")
441 
442 	PORT_START("BIT_7")
443 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
444 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED )
445 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, steer_flag_r<0>)
446 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, steer_flag_r<1>)
447 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN1 )
448 	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_COIN2 )
449 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, crash_r<2>)
450 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_NAME("Diag Step")
451 
452 	PORT_START("HORN")
453 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Horn") PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, firetrk_state, firetrk_horn_changed, 0)
454 
455 	PORT_START("R27")
456 	PORT_ADJUSTER( 20, "R27 - Motor Frequency" )
457 INPUT_PORTS_END
458 
459 
460 static INPUT_PORTS_START( superbug )
461 	PORT_START("STEER_1")
462 	PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10)
463 
464 	PORT_START("DIP_0")
465 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) /* other DIPs connect here */
466 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) /* other DIPs connect here */
467 
468 	PORT_START("DIP_1")
469 	PORT_DIPNAME( 0x03, 0x02, DEF_STR( Coinage ))
470 	PORT_DIPSETTING(    0x03, DEF_STR( 2C_1C ))
471 	PORT_DIPSETTING(    0x02, DEF_STR( 1C_1C ))
472 	PORT_DIPSETTING(    0x01, DEF_STR( 1C_2C ))
473 	PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ))
474 	PORT_DIPNAME( 0x0c, 0x04, "Play Time" )
475 	PORT_DIPSETTING(    0x00, "60 seconds" )
476 	PORT_DIPSETTING(    0x04, "90 seconds" )
477 	PORT_DIPSETTING(    0x08, "120 seconds" )
478 	PORT_DIPSETTING(    0x0c, "150 seconds" )
479 	PORT_DIPNAME( 0x30, 0x20, "Extended Play" )
480 	PORT_DIPSETTING(    0x10, "Liberal" )
481 	PORT_DIPSETTING(    0x20, DEF_STR( Medium ) )
482 	PORT_DIPSETTING(    0x30, "Conservative" )
483 	PORT_DIPSETTING(    0x00, "Never" )
484 	PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Language ) )
485 	PORT_DIPSETTING(    0x00, DEF_STR( English ) )
486 	PORT_DIPSETTING(    0x40, DEF_STR( French ) )
487 	PORT_DIPSETTING(    0x80, DEF_STR( Spanish ) )
488 	PORT_DIPSETTING(    0xc0, DEF_STR( German ) )
489 
490 	PORT_START("BIT_0")
491 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, gear_r<1>)
492 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Gas")
493 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, steer_dir_r<0>)
494 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MEMORY_RESET ) PORT_NAME("Hiscore Reset")
495 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED )
496 	PORT_SERVICE( 0x20, IP_ACTIVE_HIGH )
497 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, skid_r<0>)
498 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_TILT )
499 
500 	PORT_START("BIT_7")
501 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, gear_r<2>)
502 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, gear_r<0>)
503 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, steer_flag_r<0>)
504 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN1 )
505 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN2 )
506 	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )
507 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, crash_r<0>)
508 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("Track Select")
509 
510 	PORT_START("GEAR")
511 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Gear 1") PORT_CHANGED_MEMBER(DEVICE_SELF, firetrk_state, gear_changed, 0)
512 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Gear 2") PORT_CHANGED_MEMBER(DEVICE_SELF, firetrk_state, gear_changed, 1)
513 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Gear 3") PORT_CHANGED_MEMBER(DEVICE_SELF, firetrk_state, gear_changed, 2)
514 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("Gear 4") PORT_CHANGED_MEMBER(DEVICE_SELF, firetrk_state, gear_changed, 3)
515 
516 	PORT_START("R62")
517 	PORT_ADJUSTER( 20, "R62 - Motor Frequency" )
518 INPUT_PORTS_END
519 
520 
521 static INPUT_PORTS_START( montecar )
522 	PORT_START("STEER_1")
523 	PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) PORT_PLAYER(1)
524 
525 	PORT_START("DIP_0")
526 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) /* other DIPs connect here */
527 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) /* other DIPs connect here */
528 	PORT_DIPNAME( 0x0c, 0x0c, "Coin 3 Multiplier" )
529 	PORT_DIPSETTING(    0x0c, "1" )
530 	PORT_DIPSETTING(    0x08, "4" )
531 	PORT_DIPSETTING(    0x04, "5" )
532 	PORT_DIPSETTING(    0x00, "6" )
533 	PORT_DIPNAME( 0x10, 0x10, "Coin 2 Multiplier" )
534 	PORT_DIPSETTING(    0x10, "1" )
535 	PORT_DIPSETTING(    0x00, "2" )
536 	PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unused ))
537 	PORT_DIPSETTING(    0x20, DEF_STR( Off ))
538 	PORT_DIPSETTING(    0x00, DEF_STR( On ))
539 
540 	PORT_START("DIP_1")
541 	PORT_DIPNAME( 0x03, 0x02, DEF_STR( Coinage ))
542 	PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ))
543 	PORT_DIPSETTING(    0x02, DEF_STR( 1C_1C ))
544 	PORT_DIPSETTING(    0x01, DEF_STR( 1C_2C ))
545 	PORT_DIPSETTING(    0x03, DEF_STR( Free_Play ))
546 	PORT_DIPNAME( 0x0c, 0x08, "Extended Play" )
547 	PORT_DIPSETTING(    0x04, "Liberal" )
548 	PORT_DIPSETTING(    0x08, DEF_STR( Medium ) )
549 	PORT_DIPSETTING(    0x00, "Conservative" )
550 	PORT_DIPSETTING(    0x0c, "Never" )
551 	PORT_DIPNAME( 0x30, 0x20, "Play Time" )
552 	PORT_DIPSETTING(    0x30, "60 Seconds" )
553 	PORT_DIPSETTING(    0x10, "90 Seconds" )
554 	PORT_DIPSETTING(    0x20, "120 Seconds" )
555 	PORT_DIPSETTING(    0x00, "150 Seconds" )
556 	PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Language ) )
557 	PORT_DIPSETTING(    0xc0, DEF_STR( English ) )
558 	PORT_DIPSETTING(    0x80, DEF_STR( Spanish ) )
559 	PORT_DIPSETTING(    0x40, DEF_STR( French ) )
560 	PORT_DIPSETTING(    0x00, DEF_STR( German ) )
561 
562 	PORT_START("BIT_6")
563 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, gear_r<0>)
564 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, gear_r<1>)
565 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, gear_r<2>)
566 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("Track Select")
567 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Gas")
568 	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_VBLANK("screen")
569 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, steer_dir_r<0>)
570 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, skid_r<1>)
571 
572 	PORT_START("BIT_7")
573 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 )
574 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_TILT )
575 	PORT_SERVICE( 0x04, IP_ACTIVE_HIGH ) PORT_CHANGED_MEMBER(DEVICE_SELF, firetrk_state, service_mode_switch_changed, 0)
576 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN1 )
577 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN2 )
578 	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_CUSTOM )
579 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, steer_flag_r<0>)
580 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(firetrk_state, skid_r<0>)
581 
582 	PORT_START("GEAR")
583 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Gear 1") PORT_CHANGED_MEMBER(DEVICE_SELF, firetrk_state, gear_changed, 0)
584 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Gear 2") PORT_CHANGED_MEMBER(DEVICE_SELF, firetrk_state, gear_changed, 1)
585 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Gear 3") PORT_CHANGED_MEMBER(DEVICE_SELF, firetrk_state, gear_changed, 2)
586 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("Gear 4") PORT_CHANGED_MEMBER(DEVICE_SELF, firetrk_state, gear_changed, 3)
587 
588 	PORT_START("R89")
589 	PORT_ADJUSTER( 20, "R89 - Motor Frequency" )
590 
591 	PORT_START("R88")
592 	PORT_ADJUSTER( 25, "R88 - Drone Motor Frequency" )
593 INPUT_PORTS_END
594 
595 
596 static const gfx_layout firetrk_text_layout =
597 {
598 	16, 16, /* width, height */
599 	32,     /* total         */
600 	1,      /* planes        */
601 	{ 0 },  /* plane offsets */
602 	{
603 		0x1c, 0x1d, 0x1e, 0x1f, 0x04, 0x05, 0x06, 0x07,
604 		0x0c, 0x0d, 0x0e, 0x0f, 0x14, 0x15, 0x16, 0x17
605 	},
606 	{
607 		0x000, 0x020, 0x040, 0x060, 0x080, 0x0a0, 0x0c0, 0x0e0,
608 		0x100, 0x120, 0x140, 0x160, 0x180, 0x1a0, 0x1c0, 0x1e0
609 	},
610 	0x200
611 };
612 
613 
614 static const gfx_layout superbug_text_layout =
615 {
616 	16, 16, /* width, height */
617 	32,     /* total         */
618 	1,      /* planes        */
619 	{ 0 },  /* plane offsets */
620 	{
621 		0x0c, 0x0d, 0x0e, 0x0f, 0x14, 0x15, 0x16, 0x17,
622 		0x1c, 0x1d, 0x1e, 0x1f, 0x04, 0x05, 0x06, 0x07
623 	},
624 	{
625 		0x000, 0x020, 0x040, 0x060, 0x080, 0x0a0, 0x0c0, 0x0e0,
626 		0x100, 0x120, 0x140, 0x160, 0x180, 0x1a0, 0x1c0, 0x1e0
627 	},
628 	0x200
629 };
630 
631 
632 static const gfx_layout montecar_text_layout =
633 {
634 	8, 8,   /* width, height */
635 	64,     /* total         */
636 	1,      /* planes        */
637 	{ 0 },  /* plane offsets */
638 	{
639 		0xc, 0xd, 0xe, 0xf, 0x4, 0x5, 0x6, 0x7
640 	},
641 	{
642 		0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70
643 	},
644 	0x80
645 };
646 
647 
648 static const gfx_layout firetrk_tile_layout =
649 {
650 	16, 16, /* width, height */
651 	64,     /* total         */
652 	1,      /* planes        */
653 	{ 0 },  /* plane offsets */
654 	{
655 		0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
656 		0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf
657 	},
658 	{
659 		0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
660 		0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0
661 	},
662 	0x100
663 };
664 
665 
666 static const gfx_layout superbug_tile_layout =
667 {
668 	16, 16, /* width, height */
669 	64,     /* total         */
670 	1,      /* planes        */
671 	{ 0 },  /* plane offsets */
672 	{
673 		0x07, 0x06, 0x05, 0x04, 0x0f, 0x0e, 0x0d, 0x0c,
674 		0x17, 0x16, 0x15, 0x14, 0x1f, 0x1e, 0x1d, 0x1c
675 	},
676 	{
677 		0x000, 0x020, 0x040, 0x060, 0x080, 0x0a0, 0x0c0, 0x0e0,
678 		0x100, 0x120, 0x140, 0x160, 0x180, 0x1a0, 0x1c0, 0x1e0
679 	},
680 	0x200
681 };
682 
683 
684 static const gfx_layout firetrk_car_layout1 =
685 {
686 	32, 32, /* width, height */
687 	4,      /* total         */
688 	1,      /* planes        */
689 	{ 0 },  /* plane offsets */
690 	{
691 		0x000, 0x040, 0x080, 0x0c0, 0x100, 0x140, 0x180, 0x1c0,
692 		0x200, 0x240, 0x280, 0x2c0, 0x300, 0x340, 0x380, 0x3c0,
693 		0x400, 0x440, 0x480, 0x4c0, 0x500, 0x540, 0x580, 0x5c0,
694 		0x600, 0x640, 0x680, 0x6c0, 0x700, 0x740, 0x780, 0x7c0
695 	},
696 	{
697 		0x04, 0x05, 0x06, 0x07, 0x0c, 0x0d, 0x0e, 0x0f,
698 		0x14, 0x15, 0x16, 0x17, 0x1c, 0x1d, 0x1e, 0x1f,
699 		0x24, 0x25, 0x26, 0x27, 0x2c, 0x2d, 0x2e, 0x2f,
700 		0x34, 0x35, 0x36, 0x37, 0x3c, 0x3d, 0x3e, 0x3b
701 	},
702 	0x800
703 };
704 
705 
706 static const gfx_layout superbug_car_layout1 =
707 {
708 	32, 32, /* width, height */
709 	4,      /* total         */
710 	1,      /* planes        */
711 	{ 0 },  /* plane offsets */
712 	{
713 		0x0000, 0x0100, 0x0200, 0x0300, 0x0400, 0x0500, 0x0600, 0x0700,
714 		0x0800, 0x0900, 0x0a00, 0x0b00, 0x0c00, 0x0d00, 0x0e00, 0x0f00,
715 		0x1000, 0x1100, 0x1200, 0x1300, 0x1400, 0x1500, 0x1600, 0x1700,
716 		0x1800, 0x1900, 0x1a00, 0x1b00, 0x1c00, 0x1d00, 0x1e00, 0x1f00
717 	},
718 	{
719 		0x04, 0x0c, 0x14, 0x1c, 0x24, 0x2c, 0x34, 0x3c,
720 		0x44, 0x4c, 0x54, 0x5c, 0x64, 0x6c, 0x74, 0x7c,
721 		0x84, 0x8c, 0x94, 0x9c, 0xa4, 0xac, 0xb4, 0xbc,
722 		0xc4, 0xcc, 0xd4, 0xdc, 0xe4, 0xec, 0xf4, 0xfc
723 	},
724 	0x001
725 };
726 
727 
728 static const gfx_layout montecar_car_layout =
729 {
730 	32, 32, /* width, height */
731 	8,      /* total         */
732 	2,      /* planes        */
733 			/* plane offsets */
734 	{ 1, 0 },
735 	{
736 		0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e,
737 		0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
738 		0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e,
739 		0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e
740 	},
741 	{
742 		0x000, 0x040, 0x080, 0x0c0, 0x100, 0x140, 0x180, 0x1c0,
743 		0x200, 0x240, 0x280, 0x2c0, 0x300, 0x340, 0x380, 0x3c0,
744 		0x400, 0x440, 0x480, 0x4c0, 0x500, 0x540, 0x580, 0x5c0,
745 		0x600, 0x640, 0x680, 0x6c0, 0x700, 0x740, 0x780, 0x7c0
746 	},
747 	0x800
748 };
749 
750 
751 static const gfx_layout firetrk_car_layout2 =
752 {
753 	32, 32, /* width, height */
754 	4,      /* total         */
755 	1,      /* planes        */
756 	{ 0 },  /* plane offsets */
757 	{
758 		0x04, 0x05, 0x06, 0x07, 0x0c, 0x0d, 0x0e, 0x0f,
759 		0x14, 0x15, 0x16, 0x17, 0x1c, 0x1d, 0x1e, 0x1f,
760 		0x24, 0x25, 0x26, 0x27, 0x2c, 0x2d, 0x2e, 0x2f,
761 		0x34, 0x35, 0x36, 0x37, 0x3c, 0x3d, 0x3e, 0x3b
762 	},
763 	{
764 		0x000, 0x040, 0x080, 0x0c0, 0x100, 0x140, 0x180, 0x1c0,
765 		0x200, 0x240, 0x280, 0x2c0, 0x300, 0x340, 0x380, 0x3c0,
766 		0x400, 0x440, 0x480, 0x4c0, 0x500, 0x540, 0x580, 0x5c0,
767 		0x600, 0x640, 0x680, 0x6c0, 0x700, 0x740, 0x780, 0x7c0
768 	},
769 	0x800
770 };
771 
772 
773 static const gfx_layout superbug_car_layout2 =
774 {
775 	32, 32, /* width, height */
776 	4,      /* total         */
777 	1,      /* planes        */
778 	{ 0 },  /* plane offsets */
779 	{
780 		0x04, 0x0c, 0x14, 0x1c, 0x24, 0x2c, 0x34, 0x3c,
781 		0x44, 0x4c, 0x54, 0x5c, 0x64, 0x6c, 0x74, 0x7c,
782 		0x84, 0x8c, 0x94, 0x9c, 0xa4, 0xac, 0xb4, 0xbc,
783 		0xc4, 0xcc, 0xd4, 0xdc, 0xe4, 0xec, 0xf4, 0xfc
784 	},
785 	{
786 		0x0000, 0x0100, 0x0200, 0x0300, 0x0400, 0x0500, 0x0600, 0x0700,
787 		0x0800, 0x0900, 0x0a00, 0x0b00, 0x0c00, 0x0d00, 0x0e00, 0x0f00,
788 		0x1000, 0x1100, 0x1200, 0x1300, 0x1400, 0x1500, 0x1600, 0x1700,
789 		0x1800, 0x1900, 0x1a00, 0x1b00, 0x1c00, 0x1d00, 0x1e00, 0x1f00
790 	},
791 	0x001
792 };
793 
794 static const uint32_t firetrk_trailer_layout_xoffset[64] =
795 {
796 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
797 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
798 	0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
799 	0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
800 	0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
801 	0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
802 	0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
803 	0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f
804 };
805 
806 static const uint32_t firetrk_trailer_layout_yoffset[64] =
807 {
808 	0x000, 0x040, 0x080, 0x0c0, 0x100, 0x140, 0x180, 0x1c0,
809 	0x200, 0x240, 0x280, 0x2c0, 0x300, 0x340, 0x380, 0x3c0,
810 	0x400, 0x440, 0x480, 0x4c0, 0x500, 0x540, 0x580, 0x5c0,
811 	0x600, 0x640, 0x680, 0x6c0, 0x700, 0x740, 0x780, 0x7c0,
812 	0x800, 0x840, 0x880, 0x8c0, 0x900, 0x940, 0x980, 0x9c0,
813 	0xa00, 0xa40, 0xa80, 0xac0, 0xb00, 0xb40, 0xb80, 0xbc0,
814 	0xc00, 0xc40, 0xc80, 0xcc0, 0xd00, 0xd40, 0xd80, 0xdc0,
815 	0xe00, 0xe40, 0xe80, 0xec0, 0xf00, 0xf40, 0xf80, 0xfc0
816 };
817 
818 static const gfx_layout firetrk_trailer_layout =
819 {
820 	64, 64, /* width, height */
821 	8,      /* total         */
822 	1,      /* planes        */
823 	{ 0 },
824 	EXTENDED_XOFFS,
825 	EXTENDED_YOFFS,
826 	0x1000,
827 	firetrk_trailer_layout_xoffset,
828 	firetrk_trailer_layout_yoffset
829 };
830 
831 
832 static GFXDECODE_START( gfx_firetrk )
833 	GFXDECODE_ENTRY( "gfx1", 0, firetrk_text_layout, 26, 1 )
834 	GFXDECODE_ENTRY( "gfx2", 0, firetrk_tile_layout, 0, 8 )
835 	GFXDECODE_ENTRY( "gfx2", 0, firetrk_tile_layout, 16, 3 )
836 	GFXDECODE_ENTRY( "gfx3", 0, firetrk_car_layout1, 22, 2 )
837 	GFXDECODE_ENTRY( "gfx3", 0, firetrk_car_layout2, 22, 2 )
838 	GFXDECODE_ENTRY( "gfx4", 0, firetrk_trailer_layout, 22, 2 )
839 GFXDECODE_END
840 
841 
GFXDECODE_START(gfx_superbug)842 static GFXDECODE_START( gfx_superbug )
843 	GFXDECODE_ENTRY( "gfx1", 0, superbug_text_layout, 26, 1 )
844 	GFXDECODE_ENTRY( "gfx2", 0, superbug_tile_layout, 0, 8 )
845 	GFXDECODE_ENTRY( "gfx2", 0, superbug_tile_layout, 16, 3 )
846 	GFXDECODE_ENTRY( "gfx3", 0, superbug_car_layout1, 22, 2 )
847 	GFXDECODE_ENTRY( "gfx3", 0, superbug_car_layout2, 22, 2 )
848 GFXDECODE_END
849 
850 
851 static GFXDECODE_START( gfx_montecar )
852 	GFXDECODE_ENTRY( "gfx1", 0, montecar_text_layout, 44, 1 )
853 	GFXDECODE_ENTRY( "gfx2", 0, firetrk_tile_layout, 0, 8 )
854 	GFXDECODE_ENTRY( "gfx2", 0, firetrk_tile_layout, 16, 4 )
855 	GFXDECODE_ENTRY( "gfx3", 0, montecar_car_layout, 24, 1 )
856 	GFXDECODE_ENTRY( "gfx4", 0, montecar_car_layout, 28, 4 )
857 GFXDECODE_END
858 
859 
860 void firetrk_state::firetrk(machine_config &config)
861 {
862 	/* basic machine hardware */
863 	M6800(config, m_maincpu, MASTER_CLOCK/12); /* 750Khz during service mode */
864 	m_maincpu->set_addrmap(AS_PROGRAM, &firetrk_state::firetrk_map);
865 	TIMER(config, "scantimer").configure_scanline(FUNC(firetrk_state::firetrk_scanline), "screen", 0, 1);
866 
867 	WATCHDOG_TIMER(config, m_watchdog).set_vblank_count("screen", 5);
868 
869 	/* video hardware */
870 	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
871 	m_screen->set_video_attributes(VIDEO_ALWAYS_UPDATE);
872 	m_screen->set_raw(MASTER_CLOCK/2, 384, 0, 320, 262, 0, 240);
873 	m_screen->set_screen_update(FUNC(firetrk_state::screen_update_firetrk));
874 	m_screen->set_palette(m_palette);
875 
876 	PALETTE(config, m_palette, FUNC(firetrk_state::firetrk_palette), 28);
877 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_firetrk);
878 
879 	/* sound hardware */
880 	SPEAKER(config, "mono").front_center();
881 
882 	DISCRETE(config, m_discrete, firetrk_discrete).add_route(ALL_OUTPUTS, "mono", 1.0);
883 }
884 
885 
superbug(machine_config & config)886 void firetrk_state::superbug(machine_config &config)
887 {
888 	firetrk(config);
889 
890 	/* basic machine hardware */
891 	m_maincpu->set_addrmap(AS_PROGRAM, &firetrk_state::superbug_map);
892 
893 	/* video hardware */
894 	m_screen->set_screen_update(FUNC(firetrk_state::screen_update_superbug));
895 
896 	MCFG_VIDEO_START_OVERRIDE(firetrk_state,superbug)
897 	m_gfxdecode->set_info(gfx_superbug);
898 
899 	/* sound hardware */
900 	DISCRETE(config.replace(), m_discrete, superbug_discrete).add_route(ALL_OUTPUTS, "mono", 1.0);
901 }
902 
903 
montecar(machine_config & config)904 void firetrk_state::montecar(machine_config &config)
905 {
906 	firetrk(config);
907 
908 	/* basic machine hardware */
909 	m_maincpu->set_addrmap(AS_PROGRAM, &firetrk_state::montecar_map);
910 
911 	/* video hardware */
912 	m_screen->set_screen_update(FUNC(firetrk_state::screen_update_montecar));
913 
914 	MCFG_VIDEO_START_OVERRIDE(firetrk_state,montecar)
915 	m_gfxdecode->set_info(gfx_montecar);
916 
917 	m_palette->set_entries(46);
918 	m_palette->set_init(FUNC(firetrk_state::montecar_palette));
919 
920 	/* sound hardware */
921 	DISCRETE(config.replace(), m_discrete, montecar_discrete).add_route(ALL_OUTPUTS, "mono", 1.0);
922 }
923 
924 
925 ROM_START( firetrk )
926 	ROM_REGION( 0x4000, "maincpu", 0 )
927 	ROM_LOAD(          "032823-02.c1", 0x2000, 0x800, CRC(9570bdd3) SHA1(4d26a9490d05d53da55fc59459a4dce5bca6c761) )
928 	ROM_LOAD(          "032824-01.d1", 0x2800, 0x800, CRC(a5fc5629) SHA1(bf20510d8623eda2740ff296a7813a3e6f7ec76e) )
929 	ROM_LOAD_NIB_HIGH( "032816-01.k1", 0x3000, 0x800, CRC(c0535598) SHA1(15cb6985b0b22140b7fae1e050e0b63dd4d0f793) ) // one PCB has been found with this ROM labeled 032816-02.k1, CRC matches
930 	ROM_LOAD_NIB_LOW ( "032820-01.k2", 0x3000, 0x800, CRC(5733f9ed) SHA1(0f19a40793dadfb7de2c2b54a44929b414d0f4ed) )
931 	ROM_LOAD_NIB_HIGH( "032815-01.j1", 0x3800, 0x800, CRC(506ee759) SHA1(d111356c84f3d9942a27fbe243e716d14c258a16) )
932 	ROM_LOAD_NIB_LOW ( "032819-01.j2", 0x3800, 0x800, CRC(f1c3fa87) SHA1(d75cf4ad0bcac3289c068837fc24cfe84ce7542a) )
933 
934 	ROM_REGION( 0x0800, "gfx1", 0 ) /* text */
935 	ROM_LOAD( "032827-01.r3", 0x000, 0x800, CRC(cca31d2b) SHA1(78235176c9cb2abd73a5778b54560b87634ca0e4) )
936 
937 	ROM_REGION( 0x0800, "gfx2", 0 ) /* tiles */
938 	ROM_LOAD( "032828-02.f5", 0x000, 0x800, CRC(68ef5f19) SHA1(df227d6a57bba6298ebdeb5a118878da21d889f6) )
939 
940 	ROM_REGION( 0x0400, "gfx3", 0 ) /* cab */
941 	ROM_LOAD( "032831-01.p7", 0x000, 0x400, CRC(bb8d144f) SHA1(9a1355ea6f88e96926c32e0e36ac0525b0243906) )
942 
943 	ROM_REGION( 0x1000, "gfx4", 0 ) /* trailer */
944 	ROM_LOAD( "032829-01.j5", 0x000, 0x800, CRC(e7267d71) SHA1(7132b98622e899227a378ba8c010dde39c479978) )
945 	ROM_LOAD( "032830-01.l5", 0x800, 0x800, CRC(e4d8b685) SHA1(30978658899c83e32dabdf554a13cf5e5235c725) )
946 
947 	ROM_REGION( 0x100, "proms", 0 )
948 	ROM_LOAD( "009114.prm", 0x0000, 0x100, CRC(b8094b4c) SHA1(82dc6799a19984f3b204ee3aeeb007e55afc8be3) ) /* sync */
949 ROM_END
950 
951 
952 ROM_START( superbug )
953 	ROM_REGION( 0x2000, "maincpu", 0 )
954 	ROM_LOAD( "009121.d1", 0x0800, 0x800, CRC(350df308) SHA1(b957c830bb95e0752ea9793e3edcfdd52235e0ab) )
955 	ROM_LOAD( "009122.c1", 0x1000, 0x800, CRC(eb6e3e37) SHA1(5237f6bd3a7a3eca737c728296230cf0d1f436b0) )
956 	ROM_LOAD( "009123.a1", 0x1800, 0x800, CRC(f42c6bbe) SHA1(41470984fe951eac9f6dc77862b00ecfe8aaa51d) )
957 
958 	ROM_REGION( 0x0800, "gfx1", 0 ) /* text */
959 	ROM_LOAD( "009124.m3", 0x0000, 0x400, CRC(f8af8dd5) SHA1(49ab85550f546f85048e2f73163837c602dde568) )
960 	ROM_LOAD( "009471.n3", 0x0400, 0x400, CRC(52250698) SHA1(cc55254c54dbcd3fd1465c82a715f2e567f44951) )
961 
962 	ROM_REGION( 0x1000, "gfx2", 0 ) /* tiles */
963 	ROM_LOAD( "009126.f5", 0x0000, 0x400, CRC(ee695137) SHA1(295fdfef88e0c841fe8ad505151ca0837e77ef83) )
964 	ROM_LOAD( "009472.h5", 0x0400, 0x400, CRC(5ddb80ac) SHA1(bdbbbba6efdd4cca75630d203f7c7eaf41b1a32d) )
965 	ROM_LOAD( "009127.e5", 0x0800, 0x400, CRC(be1386b4) SHA1(17e92df58b25075ec7a383a958db02b42066578a) )
966 	ROM_RELOAD(          0x0C00, 0x400 )
967 
968 	ROM_REGION( 0x0400, "gfx3", 0 ) /* car */
969 	ROM_LOAD( "009125.k6", 0x0000, 0x400, CRC(a3c835df) SHA1(e9b6dba1919c389bb55a8fe3c074b6702322e4e5) )
970 
971 	ROM_REGION( 0x0100, "proms", 0 )
972 	ROM_LOAD( "009114.prm", 0x0000, 0x100, CRC(b8094b4c) SHA1(82dc6799a19984f3b204ee3aeeb007e55afc8be3) ) /* sync */
973 ROM_END
974 
975 
976 ROM_START( montecar )
977 	ROM_REGION( 0x4000, "maincpu", 0 )
978 	ROM_LOAD( "35766-01.h1", 0x2000, 0x800, CRC(d3695f09) SHA1(8aa3b3921acd0d2c3230d610843042613defcba9) )
979 	ROM_LOAD( "35765-01.f1", 0x2800, 0x800, CRC(9491a7ee) SHA1(712959c5f97be3db7be1d5bd70c780d4da2f6d47) )
980 	ROM_LOAD( "35764-01.d1", 0x3000, 0x800, CRC(899aaf4e) SHA1(84fab58d135ffc6e4b076d438b4d588b394364b6) )
981 	ROM_LOAD( "35763-01.c1", 0x3800, 0x800, CRC(378bfe47) SHA1(fd6b28907340a2ffc82a4e634273c3f03ab76642) )
982 
983 	ROM_REGION( 0x0400, "gfx1", 0 ) /* text */
984 	ROM_LOAD( "35778-01.m4", 0x0000, 0x400, CRC(294ee08e) SHA1(fbb0656468a027b2795073d811affc93c50994ec) )
985 
986 	ROM_REGION( 0x0800, "gfx2", 0 ) /* tiles */
987 	ROM_LOAD( "35775-01.e6", 0x0000, 0x800, CRC(504106e9) SHA1(33eae2cf39b24eaf5b438a2af3060b2fdc0012b5) )
988 
989 	ROM_REGION( 0x0800, "gfx3", 0 ) /* car */
990 	ROM_LOAD( "35779-01.m6", 0x0000, 0x800, CRC(4fbb3fe1) SHA1(4267cd098a19892322d21f8fa7b55896158f8d6a) )
991 
992 	ROM_REGION( 0x0800, "gfx4", 0 ) /* drone */
993 	ROM_LOAD( "35780-01.b6", 0x0000, 0x800, CRC(9d0f1374) SHA1(52d1130d48dc877e1e47e26b2e4548633ed91b21) )
994 
995 	ROM_REGION( 0x300, "proms", 0 )
996 	ROM_LOAD( "35785-01.e7", 0x0000, 0x200, CRC(386c543a) SHA1(04edda180e6ff432b438947ffa46621ca0a823b4) ) /* color */
997 	ROM_LOAD( "9114.prm",    0x0200, 0x100, CRC(b8094b4c) SHA1(82dc6799a19984f3b204ee3aeeb007e55afc8be3) ) /* sync */
998 ROM_END
999 
1000 
1001 GAMEL( 1977, superbug, 0, superbug, superbug, firetrk_state, empty_init, ROT270, "Atari (Kee Games)", "Super Bug", 0, layout_superbug )
1002 GAME(  1978, firetrk,  0, firetrk,  firetrk,  firetrk_state, empty_init, ROT270, "Atari", "Fire Truck / Smokey Joe", 0 )
1003 GAME(  1979, montecar, 0, montecar, montecar, firetrk_state, empty_init, ROT270, "Atari", "Monte Carlo", 0 )
1004