1 // license:BSD-3-Clause
2 // copyright-holders:Mike Balfour
3 /*************************************************************************
4 
5     Atari Subs hardware
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_SUBS_H
9 #define MAME_INCLUDES_SUBS_H
10 
11 #pragma once
12 
13 #include "sound/discrete.h"
14 #include "emupal.h"
15 
16 /* Discrete Sound Input Nodes */
17 #define SUBS_SONAR1_EN          NODE_01
18 #define SUBS_SONAR2_EN          NODE_02
19 #define SUBS_LAUNCH_DATA        NODE_03
20 #define SUBS_CRASH_DATA         NODE_04
21 #define SUBS_CRASH_EN           NODE_05
22 #define SUBS_EXPLODE_EN         NODE_06
23 #define SUBS_NOISE_RESET        NODE_07
24 
25 
26 class subs_state : public driver_device
27 {
28 public:
subs_state(const machine_config & mconfig,device_type type,const char * tag)29 	subs_state(const machine_config &mconfig, device_type type, const char *tag) :
30 		driver_device(mconfig, type, tag),
31 		m_maincpu(*this, "maincpu"),
32 		m_gfxdecode(*this, "gfxdecode"),
33 		m_palette(*this, "palette"),
34 		m_discrete(*this, "discrete"),
35 		m_spriteram(*this, "spriteram"),
36 		m_videoram(*this, "videoram")
37 	{ }
38 
39 	void subs(machine_config &config);
40 
41 private:
42 	required_device<cpu_device> m_maincpu;
43 	required_device<gfxdecode_device> m_gfxdecode;
44 	required_device<palette_device> m_palette;
45 	required_device<discrete_device> m_discrete;
46 
47 	required_shared_ptr<uint8_t> m_spriteram;
48 	required_shared_ptr<uint8_t> m_videoram;
49 
50 	int m_steering_buf1;
51 	int m_steering_buf2;
52 	int m_steering_val1;
53 	int m_steering_val2;
54 	int m_last_val_1;
55 	int m_last_val_2;
56 
57 	void steer_reset_w(uint8_t data);
58 	uint8_t control_r(offs_t offset);
59 	uint8_t coin_r(offs_t offset);
60 	uint8_t options_r(offs_t offset);
61 	DECLARE_WRITE_LINE_MEMBER(invert1_w);
62 	DECLARE_WRITE_LINE_MEMBER(invert2_w);
63 	void noise_reset_w(uint8_t data);
64 
65 	virtual void machine_start() override;
66 	virtual void machine_reset() override;
67 	void subs_palette(palette_device &palette) const;
68 
69 	uint32_t screen_update_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
70 	uint32_t screen_update_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
71 
72 	INTERRUPT_GEN_MEMBER(interrupt);
73 
74 	int steering_1();
75 	int steering_2();
76 
77 	void main_map(address_map &map);
78 };
79 
80 /*----------- defined in audio/subs.c -----------*/
81 
82 DISCRETE_SOUND_EXTERN( subs_discrete );
83 
84 #endif // MAME_INCLUDES_SUBS_H
85