1 // license:BSD-3-Clause
2 // copyright-holders:Stefan Jokisch
3 /*************************************************************************
4 
5     Atari Drag Race hardware
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_DRAGRACE_H
9 #define MAME_INCLUDES_DRAGRACE_H
10 
11 #pragma once
12 
13 #include "machine/timer.h"
14 #include "machine/watchdog.h"
15 #include "sound/discrete.h"
16 #include "emupal.h"
17 #include "screen.h"
18 #include "tilemap.h"
19 
20 /* Discrete Sound Input Nodes */
21 #define DRAGRACE_SCREECH1_EN    NODE_01
22 #define DRAGRACE_SCREECH2_EN    NODE_02
23 #define DRAGRACE_LOTONE_EN      NODE_03
24 #define DRAGRACE_HITONE_EN      NODE_04
25 #define DRAGRACE_EXPLODE1_EN    NODE_05
26 #define DRAGRACE_EXPLODE2_EN    NODE_06
27 #define DRAGRACE_MOTOR1_DATA    NODE_07
28 #define DRAGRACE_MOTOR2_DATA    NODE_08
29 #define DRAGRACE_MOTOR1_EN      NODE_80
30 #define DRAGRACE_MOTOR2_EN      NODE_81
31 #define DRAGRACE_KLEXPL1_EN     NODE_82
32 #define DRAGRACE_KLEXPL2_EN     NODE_83
33 #define DRAGRACE_ATTRACT_EN     NODE_09
34 
35 
36 class dragrace_state : public driver_device
37 {
38 public:
dragrace_state(const machine_config & mconfig,device_type type,const char * tag)39 	dragrace_state(const machine_config &mconfig, device_type type, const char *tag) :
40 		driver_device(mconfig, type, tag),
41 		m_playfield_ram(*this, "playfield_ram"),
42 		m_position_ram(*this, "position_ram"),
43 		m_discrete(*this, "discrete"),
44 		m_maincpu(*this, "maincpu"),
45 		m_watchdog(*this, "watchdog"),
46 		m_gfxdecode(*this, "gfxdecode"),
47 		m_screen(*this, "screen")
48 	{
49 	}
50 
51 	void dragrace(machine_config &config);
52 
53 private:
54 	void speed1_w(uint8_t data);
55 	void speed2_w(uint8_t data);
56 	uint8_t dragrace_input_r(offs_t offset);
57 	uint8_t dragrace_steering_r();
58 	uint8_t dragrace_scanline_r();
59 	TILE_GET_INFO_MEMBER(get_tile_info);
60 	void dragrace_palette(palette_device &palette) const;
61 	uint32_t screen_update_dragrace(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
62 	TIMER_DEVICE_CALLBACK_MEMBER(dragrace_frame_callback);
63 	void dragrace_update_misc_flags( address_space &space );
64 
65 	virtual void machine_start() override;
66 	virtual void machine_reset() override;
67 	virtual void video_start() override;
68 	void dragrace_map(address_map &map);
69 
70 	/* memory pointers */
71 	required_shared_ptr<uint8_t> m_playfield_ram;
72 	required_shared_ptr<uint8_t> m_position_ram;
73 
74 	/* video-related */
75 	tilemap_t  *m_bg_tilemap;
76 
77 	/* misc */
78 	int       m_gear[2];
79 
80 	/* devices */
81 	required_device<discrete_sound_device> m_discrete;
82 	required_device<cpu_device> m_maincpu;
83 	required_device<watchdog_timer_device> m_watchdog;
84 	required_device<gfxdecode_device> m_gfxdecode;
85 	required_device<screen_device> m_screen;
86 };
87 
88 /*----------- defined in audio/dragrace.c -----------*/
89 DISCRETE_SOUND_EXTERN( dragrace_discrete );
90 
91 #endif // MAME_INCLUDES_DRAGRACE_H
92