1 // license:BSD-3-Clause
2 // copyright-holders:Aaron Giles
3 /***************************************************************************
4
5 Gottlieb hardware
6
7 ***************************************************************************/
8
9 #include "cpu/m6502/m6502.h"
10 #include "machine/mos6530.h"
11 #include "machine/6532riot.h"
12 #include "sound/ay8910.h"
13 #include "sound/sp0250.h"
14 #include "sound/votrax.h"
15
16
17 //**************************************************************************
18 // GLOBAL VARIABLES
19 //**************************************************************************
20
DECLARE_DEVICE_TYPE(GOTTLIEB_SOUND_REV0,gottlieb_sound_r0_device)21 DECLARE_DEVICE_TYPE(GOTTLIEB_SOUND_REV0, gottlieb_sound_r0_device)
22 DECLARE_DEVICE_TYPE(GOTTLIEB_SOUND_REV1, gottlieb_sound_r1_device)
23 DECLARE_DEVICE_TYPE(GOTTLIEB_SOUND_REV1_VOTRAX, gottlieb_sound_r1_with_votrax_device)
24 DECLARE_DEVICE_TYPE(GOTTLIEB_SOUND_REV2, gottlieb_sound_r2_device)
25
26
27 //**************************************************************************
28 // TYPE DEFINITIONS
29 //**************************************************************************
30
31 // ======================> gottlieb_sound_r0_device
32
33 // rev 0 sound board
34 class gottlieb_sound_r0_device : public device_t, public device_mixer_interface
35 {
36 public:
37 // construction/destruction
38 gottlieb_sound_r0_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
39
40 // read/write
41 void write(offs_t offset, uint8_t data);
42
43 // internal communications
44 DECLARE_INPUT_CHANGED_MEMBER(audio_nmi);
45
46 protected:
47 // device-level overrides
48 virtual void device_add_mconfig(machine_config &config) override;
49 virtual ioport_constructor device_input_ports() const override;
50 virtual void device_start() override;
51
52 void gottlieb_sound_r0_map(address_map &map);
53
54 private:
55 // devices
56 required_device<m6502_device> m_audiocpu;
57 required_device<mos6530_device> m_r6530;
58
59 uint8_t m_sndcmd;
60
61 uint8_t r6530b_r();
62 };
63
64 // ======================> gottlieb_sound_r1_device
65
66 // rev 1 sound board, with unpopulated VOTRAX
67 class gottlieb_sound_r1_device : public device_t, public device_mixer_interface
68 {
69 public:
70 // construction/destruction
71 gottlieb_sound_r1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
72
73 // read/write
74 void write(u8 data);
75
76 protected:
77 gottlieb_sound_r1_device(
78 const machine_config &mconfig,
79 device_type type,
80 const char *tag,
81 device_t *owner,
82 uint32_t clock);
83
84 // device-level overrides
85 virtual void device_add_mconfig(machine_config &config) override;
86 virtual ioport_constructor device_input_ports() const override;
87 virtual void device_start() override;
88
89 virtual void gottlieb_sound_r1_map(address_map &map);
90
91 private:
92 // devices
93 required_device<riot6532_device> m_riot;
94 };
95
96 // fully populated rev 1 sound board
97 class gottlieb_sound_r1_with_votrax_device : public gottlieb_sound_r1_device
98 {
99 public:
100 // construction/destruction
101 gottlieb_sound_r1_with_votrax_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
102
103 protected:
104 // device-level overrides
105 virtual void device_add_mconfig(machine_config &config) override;
106 virtual ioport_constructor device_input_ports() const override;
107 virtual void device_start() override;
108 virtual void device_post_load() override;
109
110 // internal communications
111 void votrax_data_w(uint8_t data);
112 void speech_clock_dac_w(uint8_t data);
113
114 virtual void gottlieb_sound_r1_map(address_map &map) override;
115
116 private:
117 // devices
118 required_device<votrax_sc01_device> m_votrax;
119
120 // internal state
121 uint8_t m_last_speech_clock;
122 };
123
124
125 // ======================> gottlieb_sound_r2_device
126
127 // fully populated rev 2 sound board
128 class gottlieb_sound_r2_device : public device_t, public device_mixer_interface
129 {
130 public:
131 // construction/destruction
132 gottlieb_sound_r2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
133
134 // configuration helpers
enable_cobram3_mods()135 void enable_cobram3_mods() { m_cobram3_mod = true; }
136
137 // read/write
138 void write(u8 data);
139
140 // internal communications
141 uint8_t speech_data_r();
142 uint8_t audio_data_r();
143 void signal_audio_nmi_w(uint8_t data);
144 void nmi_rate_w(uint8_t data);
145 CUSTOM_INPUT_MEMBER( speech_drq_custom_r );
146 void speech_control_w(uint8_t data);
147 void sp0250_latch_w(uint8_t data);
148 void psg_latch_w(uint8_t data);
149
150 void gottlieb_sound_r2_map(address_map &map);
151 void gottlieb_speech_r2_map(address_map &map);
152 protected:
153 // device-level overrides
154 virtual void device_add_mconfig(machine_config &config) override;
155 virtual ioport_constructor device_input_ports() const override;
156 virtual void device_start() override;
157 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
158
159 private:
160 // internal helpers
161 void nmi_timer_adjust();
162 void nmi_state_update();
163
164 // timer IDs
165 enum
166 {
167 TID_NMI_GENERATE,
168 TID_NMI_CLEAR,
169 TID_SOUND_LATCH_WRITE
170 };
171
172 // devices
173 required_device<m6502_device> m_audiocpu;
174 required_device<m6502_device> m_speechcpu;
175 required_device<ay8913_device> m_ay1;
176 required_device<ay8913_device> m_ay2;
177 optional_device<sp0250_device> m_sp0250;
178
179 // internal state
180 bool m_cobram3_mod;
181 emu_timer * m_nmi_timer;
182 uint8_t m_nmi_rate;
183 uint8_t m_nmi_state;
184 uint8_t m_audiocpu_latch;
185 uint8_t m_speechcpu_latch;
186 uint8_t m_speech_control;
187 uint8_t m_last_command;
188 uint8_t m_psg_latch;
189 uint8_t m_psg_data_latch;
190 uint8_t m_sp0250_latch;
191 };
192
193