1 // license:BSD-3-Clause
2 // copyright-holders:Brad Oliver, Nicola Salmoria
3 /*************************************************************************
4 
5     Atari Battle Zone hardware
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_BZONE_H
9 #define MAME_INCLUDES_BZONE_H
10 
11 #pragma once
12 
13 #include "audio/redbaron.h"
14 #include "machine/er2055.h"
15 #include "machine/mathbox.h"
16 #include "sound/discrete.h"
17 #include "screen.h"
18 
19 #define BZONE_MASTER_CLOCK (XTAL(12'096'000))
20 #define BZONE_CLOCK_3KHZ   (BZONE_MASTER_CLOCK / 4096)
21 
22 class bzone_state : public driver_device
23 {
24 public:
bzone_state(const machine_config & mconfig,device_type type,const char * tag)25 	bzone_state(const machine_config &mconfig, device_type type, const char *tag) :
26 		driver_device(mconfig, type, tag),
27 		m_maincpu(*this, "maincpu"),
28 		m_mathbox(*this, "mathbox"),
29 		m_discrete(*this, "discrete"),
30 		m_screen(*this, "screen"),
31 		m_startled(*this, "startled")
32 	{ }
33 
34 	DECLARE_READ_LINE_MEMBER(clock_r);
35 	void init_bradley();
36 	void bzone(machine_config &config);
37 
38 protected:
39 	void bzone_coin_counter_w(offs_t offset, uint8_t data);
40 	uint8_t analog_data_r();
41 	void analog_select_w(offs_t offset, uint8_t data);
42 	virtual void machine_start() override;
43 	INTERRUPT_GEN_MEMBER(bzone_interrupt);
44 	void bzone_sounds_w(uint8_t data);
45 
46 	void bzone_base(machine_config &config);
47 	void bzone_audio(machine_config &config);
48 	void bzone_map(address_map &map);
49 
50 	required_device<cpu_device> m_maincpu;
51 	required_device<mathbox_device> m_mathbox;
52 	optional_device<discrete_device> m_discrete;
53 	required_device<screen_device> m_screen;
54 	output_finder<> m_startled;
55 
56 private:
57 	uint8_t m_analog_data;
58 };
59 
60 
61 class redbaron_state : public bzone_state
62 {
63 public:
redbaron_state(const machine_config & mconfig,device_type type,const char * tag)64 	redbaron_state(const machine_config &mconfig, device_type type, const char *tag) :
65 		bzone_state(mconfig, type, tag),
66 		m_earom(*this, "earom"),
67 		m_redbaronsound(*this, "custom"),
68 		m_fake_ports(*this, "FAKE%u", 1U)
69 	{ }
70 
71 	void redbaron(machine_config &config);
72 
73 protected:
74 	uint8_t redbaron_joy_r();
75 	void redbaron_joysound_w(uint8_t data);
76 	uint8_t earom_read();
77 	void earom_write(offs_t offset, uint8_t data);
78 	void earom_control_w(uint8_t data);
79 
80 	virtual void machine_start() override;
81 	virtual void machine_reset() override;
82 
83 	void redbaron_map(address_map &map);
84 
85 private:
86 	required_device<er2055_device> m_earom;
87 	required_device<redbaron_sound_device> m_redbaronsound;
88 	required_ioport_array<2> m_fake_ports;
89 	uint8_t m_rb_input_select;
90 };
91 
92 #endif // MAME_INCLUDES_BZONE_H
93