1 // license:BSD-3-Clause
2 // copyright-holders:Stefan Jokisch
3 #ifndef MAME_INCLUDES_SPRINT4_H
4 #define MAME_INCLUDES_SPRINT4_H
5 
6 #pragma once
7 
8 #include "machine/watchdog.h"
9 #include "sound/discrete.h"
10 #include "emupal.h"
11 #include "screen.h"
12 #include "tilemap.h"
13 
14 class sprint4_state : public driver_device
15 {
16 public:
17 	enum
18 	{
19 		TIMER_NMI
20 	};
21 
sprint4_state(const machine_config & mconfig,device_type type,const char * tag)22 	sprint4_state(const machine_config &mconfig, device_type type, const char *tag) :
23 		driver_device(mconfig, type, tag),
24 		m_maincpu(*this, "maincpu"),
25 		m_watchdog(*this, "watchdog"),
26 		m_discrete(*this, "discrete"),
27 		m_gfxdecode(*this, "gfxdecode"),
28 		m_screen(*this, "screen"),
29 		m_palette(*this, "palette"),
30 		m_videoram(*this, "videoram")
31 	{ }
32 
33 	void sprint4(machine_config &config);
34 
35 	template <int N> DECLARE_READ_LINE_MEMBER(lever_r);
36 	template <int N> DECLARE_READ_LINE_MEMBER(wheel_r);
37 	template <int N> DECLARE_READ_LINE_MEMBER(collision_flipflop_r);
38 
39 private:
40 	uint8_t wram_r(offs_t offset);
41 	uint8_t analog_r(offs_t offset);
42 	uint8_t coin_r(offs_t offset);
43 	uint8_t collision_r(offs_t offset);
44 	uint8_t options_r(offs_t offset);
45 	void wram_w(offs_t offset, uint8_t data);
46 	void collision_reset_w(offs_t offset, uint8_t data);
47 	void da_latch_w(uint8_t data);
48 	void video_ram_w(offs_t offset, uint8_t data);
49 	void bang_w(uint8_t data);
50 	void attract_w(uint8_t data);
51 
52 	virtual void machine_start() override;
53 	virtual void machine_reset() override;
54 	virtual void video_start() override;
55 	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
56 	void sprint4_palette(palette_device &palette) const;
57 
58 	TILE_GET_INFO_MEMBER(tile_info);
59 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
60 	DECLARE_WRITE_LINE_MEMBER(screen_vblank);
61 	TIMER_CALLBACK_MEMBER(nmi_callback);
62 
63 	void sprint4_cpu_map(address_map &map);
64 
65 	required_device<cpu_device> m_maincpu;
66 	required_device<watchdog_timer_device> m_watchdog;
67 	required_device<discrete_sound_device> m_discrete;
68 	required_device<gfxdecode_device> m_gfxdecode;
69 	required_device<screen_device> m_screen;
70 	required_device<palette_device> m_palette;
71 
72 	required_shared_ptr<uint8_t> m_videoram;
73 
74 	int m_da_latch;
75 	int m_steer_FF1[4];
76 	int m_steer_FF2[4];
77 	int m_gear[4];
78 	uint8_t m_last_wheel[4];
79 	int m_collision[4];
80 	tilemap_t* m_playfield;
81 	bitmap_ind16 m_helper;
82 	emu_timer *m_nmi_timer;
83 };
84 
85 #endif // MAME_INCLUDES_SPRINT4_H
86