trunk/src/mame/includes/gottlieb.h
r32635 | r32636 | |
6 | 6 | |
7 | 7 | ***************************************************************************/ |
8 | 8 | |
| 9 | #include "emu.h" |
| 10 | #include "audio/gottlieb.h" |
9 | 11 | #include "cpu/i86/i86.h" |
10 | 12 | #include "cpu/m6502/m6502.h" |
11 | | #include "machine/6532riot.h" |
12 | | #include "sound/dac.h" |
13 | | #include "sound/ay8910.h" |
14 | | #include "sound/sp0250.h" |
15 | 13 | #include "sound/samples.h" |
16 | | #include "sound/votrax.h" |
17 | 14 | #include "machine/ldpr8210.h" |
18 | 15 | |
19 | 16 | |
20 | | // set to 0 to enable Votrax device and disable samples |
21 | | #define USE_FAKE_VOTRAX (1) |
22 | | |
23 | | |
24 | 17 | #define GOTTLIEB_VIDEO_HCOUNT 318 |
25 | 18 | #define GOTTLIEB_VIDEO_HBLANK 256 |
26 | 19 | #define GOTTLIEB_VIDEO_VCOUNT 256 |
27 | 20 | #define GOTTLIEB_VIDEO_VBLANK 240 |
28 | 21 | |
29 | 22 | |
30 | | //************************************************************************** |
31 | | // GLOBAL VARIABLES |
32 | | //************************************************************************** |
33 | 23 | |
34 | | extern const device_type GOTTLIEB_SOUND_REV1; |
35 | | extern const device_type GOTTLIEB_SOUND_REV1_WITH_VOTRAX; |
36 | | extern const device_type GOTTLIEB_SOUND_REV2; |
37 | 24 | |
38 | | |
39 | | |
40 | | //************************************************************************** |
41 | | // DEVICE CONFIGURATION MACROS |
42 | | //************************************************************************** |
43 | | |
44 | | #define MCFG_GOTTLIEB_SOUND_R1_ADD(_tag) \ |
45 | | MCFG_DEVICE_ADD(_tag, GOTTLIEB_SOUND_REV1, 0) |
46 | | #define MCFG_GOTTLIEB_SOUND_R1_ADD_VOTRAX(_tag) \ |
47 | | MCFG_DEVICE_ADD(_tag, GOTTLIEB_SOUND_REV1_WITH_VOTRAX, 0) |
48 | | |
49 | | #define MCFG_GOTTLIEB_SOUND_R2_ADD(_tag) \ |
50 | | MCFG_DEVICE_ADD(_tag, GOTTLIEB_SOUND_REV2, 0) |
51 | | #define MCFG_GOTTLIEB_SOUND_R2_ADD_COBRAM3(_tag) \ |
52 | | MCFG_DEVICE_ADD(_tag, GOTTLIEB_SOUND_REV2, 0) \ |
53 | | gottlieb_sound_r2_device::static_enable_cobram3_mods(*device); |
54 | | |
55 | | |
56 | | //************************************************************************** |
57 | | // TYPE DEFINITIONS |
58 | | //************************************************************************** |
59 | | |
60 | | // ======================> gottlieb_sound_r1_device |
61 | | |
62 | | // rev 1 sound board, with unpopulated VOTRAX |
63 | | class gottlieb_sound_r1_device : public device_t, |
64 | | public device_mixer_interface |
65 | | { |
66 | | public: |
67 | | // construction/destruction |
68 | | gottlieb_sound_r1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
69 | | gottlieb_sound_r1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, bool populate_votrax); |
70 | | |
71 | | // read/write |
72 | | DECLARE_WRITE8_MEMBER( write ); |
73 | | |
74 | | // internal communications |
75 | | DECLARE_WRITE_LINE_MEMBER( snd_interrupt ); |
76 | | DECLARE_WRITE8_MEMBER( r6532_portb_w ); |
77 | | DECLARE_WRITE8_MEMBER( votrax_data_w ); |
78 | | DECLARE_WRITE8_MEMBER( speech_clock_dac_w ); |
79 | | DECLARE_WRITE_LINE_MEMBER( votrax_request ); |
80 | | |
81 | | protected: |
82 | | // device-level overrides |
83 | | virtual machine_config_constructor device_mconfig_additions() const; |
84 | | virtual ioport_constructor device_input_ports() const; |
85 | | virtual void device_start(); |
86 | | |
87 | | private: |
88 | | // devices |
89 | | required_device<m6502_device> m_audiocpu; |
90 | | required_device<riot6532_device> m_riot; |
91 | | required_device<dac_device> m_dac; |
92 | | optional_device<votrax_sc01_device> m_votrax; |
93 | | |
94 | | // internal state |
95 | | //bool m_populate_votrax; |
96 | | UINT8 m_last_speech_clock; |
97 | | |
98 | | #if USE_FAKE_VOTRAX |
99 | | protected: |
100 | | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
101 | | private: |
102 | | void fake_votrax_data_w(UINT8 data); |
103 | | void trigger_sample(UINT8 data); |
104 | | optional_device<samples_device> m_samples; |
105 | | UINT8 m_score_sample; |
106 | | UINT8 m_random_offset; |
107 | | UINT8 m_votrax_queue[100]; |
108 | | UINT8 m_votrax_queuepos; |
109 | | #endif |
110 | | }; |
111 | | |
112 | | // fully populated rev 1 sound board |
113 | | class gottlieb_sound_r1_with_votrax_device : public gottlieb_sound_r1_device |
114 | | { |
115 | | public: |
116 | | // construction/destruction |
117 | | gottlieb_sound_r1_with_votrax_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
118 | | |
119 | | protected: |
120 | | // device-level overrides |
121 | | virtual machine_config_constructor device_mconfig_additions() const; |
122 | | virtual ioport_constructor device_input_ports() const; |
123 | | }; |
124 | | |
125 | | |
126 | | // ======================> gottlieb_sound_r2_device |
127 | | |
128 | | // fully populated rev 2 sound board |
129 | | class gottlieb_sound_r2_device : public device_t, |
130 | | public device_mixer_interface |
131 | | { |
132 | | public: |
133 | | // construction/destruction |
134 | | gottlieb_sound_r2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
135 | | |
136 | | // static configuration helpers |
137 | | static void static_enable_cobram3_mods(device_t &device); |
138 | | |
139 | | // read/write |
140 | | DECLARE_WRITE8_MEMBER( write ); |
141 | | |
142 | | // internal communications |
143 | | DECLARE_READ8_MEMBER( speech_data_r ); |
144 | | DECLARE_READ8_MEMBER( audio_data_r ); |
145 | | DECLARE_WRITE8_MEMBER( signal_audio_nmi_w ); |
146 | | DECLARE_WRITE8_MEMBER( nmi_rate_w ); |
147 | | CUSTOM_INPUT_MEMBER( speech_drq_custom_r ); |
148 | | DECLARE_WRITE8_MEMBER( dac_w ); |
149 | | DECLARE_WRITE8_MEMBER( speech_control_w ); |
150 | | DECLARE_WRITE8_MEMBER( sp0250_latch_w ); |
151 | | DECLARE_WRITE8_MEMBER( psg_latch_w ); |
152 | | |
153 | | protected: |
154 | | // device-level overrides |
155 | | virtual machine_config_constructor device_mconfig_additions() const; |
156 | | virtual ioport_constructor device_input_ports() const; |
157 | | virtual void device_start(); |
158 | | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
159 | | |
160 | | private: |
161 | | // internal helpers |
162 | | void nmi_timer_adjust(); |
163 | | void nmi_state_update(); |
164 | | |
165 | | // timer IDs |
166 | | enum |
167 | | { |
168 | | TID_NMI_GENERATE, |
169 | | TID_NMI_CLEAR, |
170 | | TID_SOUND_LATCH_WRITE |
171 | | }; |
172 | | |
173 | | // devices |
174 | | required_device<m6502_device> m_audiocpu; |
175 | | required_device<m6502_device> m_speechcpu; |
176 | | required_device<dac_device> m_dac; |
177 | | required_device<ay8913_device> m_ay1; |
178 | | required_device<ay8913_device> m_ay2; |
179 | | optional_device<sp0250_device> m_sp0250; |
180 | | |
181 | | // internal state |
182 | | bool m_cobram3_mod; |
183 | | emu_timer * m_nmi_timer; |
184 | | UINT8 m_nmi_rate; |
185 | | UINT8 m_nmi_state; |
186 | | UINT8 m_audiocpu_latch; |
187 | | UINT8 m_speechcpu_latch; |
188 | | UINT8 m_speech_control; |
189 | | UINT8 m_last_command; |
190 | | UINT8 m_dac_data[2]; |
191 | | UINT8 m_psg_latch; |
192 | | UINT8 m_psg_data_latch; |
193 | | UINT8 m_sp0250_latch; |
194 | | }; |
195 | | |
196 | | |
197 | 25 | // ======================> gottlieb_state |
198 | 26 | |
199 | 27 | // shared driver state |
r32635 | r32636 | |
311 | 139 | protected: |
312 | 140 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
313 | 141 | }; |
314 | | |
315 | | /*----------- defined in audio/gottlieb.c -----------*/ |
316 | | |
317 | | MACHINE_CONFIG_EXTERN( qbert_knocker ); |
318 | | |
319 | | #if USE_FAKE_VOTRAX |
320 | | MACHINE_CONFIG_EXTERN( reactor_samples ); |
321 | | MACHINE_CONFIG_EXTERN( qbert_samples ); |
322 | | #endif |
trunk/src/mame/drivers/gottlieb.c
r32635 | r32636 | |
194 | 194 | |
195 | 195 | ***************************************************************************/ |
196 | 196 | |
197 | | #include "emu.h" |
198 | | #include "machine/6532riot.h" |
199 | | #include "sound/ay8910.h" |
200 | | #include "sound/dac.h" |
201 | | #include "sound/samples.h" |
| 197 | #include "includes/gottlieb.h" |
202 | 198 | #include "machine/nvram.h" |
203 | | #include "includes/gottlieb.h" |
204 | 199 | |
205 | 200 | |
206 | 201 | #define LOG_AUDIO_DECODE (0) |
r32635 | r32636 | |
642 | 637 | |
643 | 638 | |
644 | 639 | |
| 640 | |
| 641 | //************************************************************************** |
| 642 | // QBERT MECHANICAL KNOCKER |
| 643 | //************************************************************************** |
| 644 | |
| 645 | //------------------------------------------------- |
| 646 | // qbert cabinets have a mechanical knocker near the floor, |
| 647 | // MAME simulates this with a sample. |
| 648 | // (like all MAME samples, it is optional. If you actually have |
| 649 | // a real kicker/knocker, hook it up via output "knocker0") |
| 650 | //------------------------------------------------- |
| 651 | |
| 652 | void gottlieb_state::qbert_knocker(UINT8 knock) |
| 653 | { |
| 654 | output_set_value("knocker0", knock); |
| 655 | |
| 656 | // start sound on rising edge |
| 657 | if (knock & ~m_knocker_prev) |
| 658 | m_knocker_sample->start(0, 0); |
| 659 | m_knocker_prev = knock; |
| 660 | } |
| 661 | |
| 662 | static const char *const qbert_knocker_names[] = |
| 663 | { |
| 664 | "*qbert", |
| 665 | "knocker", |
| 666 | 0 /* end of array */ |
| 667 | }; |
| 668 | |
| 669 | MACHINE_CONFIG_FRAGMENT( qbert_knocker ) |
| 670 | MCFG_SPEAKER_ADD("knocker", 0.0, 0.0, 1.0) |
| 671 | |
| 672 | MCFG_SOUND_ADD("knocker_sam", SAMPLES, 0) |
| 673 | MCFG_SAMPLES_CHANNELS(1) |
| 674 | MCFG_SAMPLES_NAMES(qbert_knocker_names) |
| 675 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "knocker", 1.0) |
| 676 | MACHINE_CONFIG_END |
| 677 | |
| 678 | |
| 679 | |
645 | 680 | /************************************* |
646 | 681 | * |
647 | 682 | * Interrupt generation |
trunk/src/mame/audio/gottlieb.c
r32635 | r32636 | |
2 | 2 | // copyright-holders:Aaron Giles |
3 | 3 | /*************************************************************************** |
4 | 4 | |
5 | | gottlieb.h |
| 5 | gottlieb.c |
6 | 6 | |
7 | 7 | Gottlieb 6502-based sound hardware implementations. |
8 | 8 | |
r32635 | r32636 | |
10 | 10 | |
11 | 11 | ***************************************************************************/ |
12 | 12 | |
13 | | #include "emu.h" |
14 | | #include "includes/gottlieb.h" |
| 13 | #include "audio/gottlieb.h" |
15 | 14 | |
16 | 15 | |
17 | 16 | #define SOUND1_CLOCK XTAL_3_579545MHz |
r32635 | r32636 | |
247 | 246 | #endif |
248 | 247 | |
249 | 248 | |
250 | | |
251 | 249 | //************************************************************************** |
252 | | // QBERT MECHANICAL KNOCKER |
253 | | //************************************************************************** |
254 | | |
255 | | //------------------------------------------------- |
256 | | // qbert cabinets have a mechanical knocker near the floor, |
257 | | // MAME simulates this with a sample. |
258 | | // (like all MAME samples, it is optional. If you actually have |
259 | | // a real kicker/knocker, hook it up via output "knocker0") |
260 | | //------------------------------------------------- |
261 | | |
262 | | void gottlieb_state::qbert_knocker(UINT8 knock) |
263 | | { |
264 | | output_set_value("knocker0", knock); |
265 | | |
266 | | // start sound on rising edge |
267 | | if (knock & ~m_knocker_prev) |
268 | | m_knocker_sample->start(0, 0); |
269 | | m_knocker_prev = knock; |
270 | | } |
271 | | |
272 | | static const char *const qbert_knocker_names[] = |
273 | | { |
274 | | "*qbert", |
275 | | "knocker", |
276 | | 0 /* end of array */ |
277 | | }; |
278 | | |
279 | | MACHINE_CONFIG_FRAGMENT( qbert_knocker ) |
280 | | MCFG_SPEAKER_ADD("knocker", 0.0, 0.0, 1.0) |
281 | | |
282 | | MCFG_SOUND_ADD("knocker_sam", SAMPLES, 0) |
283 | | MCFG_SAMPLES_CHANNELS(1) |
284 | | MCFG_SAMPLES_NAMES(qbert_knocker_names) |
285 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "knocker", 1.0) |
286 | | MACHINE_CONFIG_END |
287 | | |
288 | | |
289 | | |
290 | | //************************************************************************** |
291 | 250 | // REV 1 SOUND BOARD: 6502 + DAC |
292 | 251 | //************************************************************************** |
293 | 252 | |
trunk/src/mame/audio/gottlieb.h
r0 | r32636 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:Aaron Giles |
| 3 | /*************************************************************************** |
| 4 | |
| 5 | Gottlieb hardware |
| 6 | |
| 7 | ***************************************************************************/ |
| 8 | |
| 9 | #include "emu.h" |
| 10 | #include "cpu/m6502/m6502.h" |
| 11 | #include "machine/6532riot.h" |
| 12 | #include "sound/dac.h" |
| 13 | #include "sound/ay8910.h" |
| 14 | #include "sound/sp0250.h" |
| 15 | #include "sound/votrax.h" |
| 16 | |
| 17 | |
| 18 | // set to 0 to enable Votrax device and disable samples |
| 19 | #define USE_FAKE_VOTRAX (1) |
| 20 | |
| 21 | |
| 22 | |
| 23 | //************************************************************************** |
| 24 | // GLOBAL VARIABLES |
| 25 | //************************************************************************** |
| 26 | |
| 27 | extern const device_type GOTTLIEB_SOUND_REV1; |
| 28 | extern const device_type GOTTLIEB_SOUND_REV1_WITH_VOTRAX; |
| 29 | extern const device_type GOTTLIEB_SOUND_REV2; |
| 30 | |
| 31 | |
| 32 | |
| 33 | //************************************************************************** |
| 34 | // DEVICE CONFIGURATION MACROS |
| 35 | //************************************************************************** |
| 36 | |
| 37 | #define MCFG_GOTTLIEB_SOUND_R1_ADD(_tag) \ |
| 38 | MCFG_DEVICE_ADD(_tag, GOTTLIEB_SOUND_REV1, 0) |
| 39 | #define MCFG_GOTTLIEB_SOUND_R1_ADD_VOTRAX(_tag) \ |
| 40 | MCFG_DEVICE_ADD(_tag, GOTTLIEB_SOUND_REV1_WITH_VOTRAX, 0) |
| 41 | |
| 42 | #define MCFG_GOTTLIEB_SOUND_R2_ADD(_tag) \ |
| 43 | MCFG_DEVICE_ADD(_tag, GOTTLIEB_SOUND_REV2, 0) |
| 44 | #define MCFG_GOTTLIEB_SOUND_R2_ADD_COBRAM3(_tag) \ |
| 45 | MCFG_DEVICE_ADD(_tag, GOTTLIEB_SOUND_REV2, 0) \ |
| 46 | gottlieb_sound_r2_device::static_enable_cobram3_mods(*device); |
| 47 | |
| 48 | |
| 49 | //************************************************************************** |
| 50 | // TYPE DEFINITIONS |
| 51 | //************************************************************************** |
| 52 | |
| 53 | // ======================> gottlieb_sound_r1_device |
| 54 | |
| 55 | // rev 1 sound board, with unpopulated VOTRAX |
| 56 | class gottlieb_sound_r1_device : public device_t, public device_mixer_interface |
| 57 | { |
| 58 | public: |
| 59 | // construction/destruction |
| 60 | gottlieb_sound_r1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 61 | gottlieb_sound_r1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, bool populate_votrax); |
| 62 | |
| 63 | // read/write |
| 64 | DECLARE_WRITE8_MEMBER( write ); |
| 65 | |
| 66 | // internal communications |
| 67 | DECLARE_WRITE_LINE_MEMBER( snd_interrupt ); |
| 68 | DECLARE_WRITE8_MEMBER( r6532_portb_w ); |
| 69 | DECLARE_WRITE8_MEMBER( votrax_data_w ); |
| 70 | DECLARE_WRITE8_MEMBER( speech_clock_dac_w ); |
| 71 | DECLARE_WRITE_LINE_MEMBER( votrax_request ); |
| 72 | |
| 73 | protected: |
| 74 | // device-level overrides |
| 75 | virtual machine_config_constructor device_mconfig_additions() const; |
| 76 | virtual ioport_constructor device_input_ports() const; |
| 77 | virtual void device_start(); |
| 78 | |
| 79 | private: |
| 80 | // devices |
| 81 | required_device<m6502_device> m_audiocpu; |
| 82 | required_device<riot6532_device> m_riot; |
| 83 | required_device<dac_device> m_dac; |
| 84 | optional_device<votrax_sc01_device> m_votrax; |
| 85 | |
| 86 | // internal state |
| 87 | //bool m_populate_votrax; |
| 88 | UINT8 m_last_speech_clock; |
| 89 | |
| 90 | #if USE_FAKE_VOTRAX |
| 91 | protected: |
| 92 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 93 | private: |
| 94 | void fake_votrax_data_w(UINT8 data); |
| 95 | void trigger_sample(UINT8 data); |
| 96 | optional_device<samples_device> m_samples; |
| 97 | UINT8 m_score_sample; |
| 98 | UINT8 m_random_offset; |
| 99 | UINT8 m_votrax_queue[100]; |
| 100 | UINT8 m_votrax_queuepos; |
| 101 | #endif |
| 102 | }; |
| 103 | |
| 104 | // fully populated rev 1 sound board |
| 105 | class gottlieb_sound_r1_with_votrax_device : public gottlieb_sound_r1_device |
| 106 | { |
| 107 | public: |
| 108 | // construction/destruction |
| 109 | gottlieb_sound_r1_with_votrax_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 110 | |
| 111 | protected: |
| 112 | // device-level overrides |
| 113 | virtual machine_config_constructor device_mconfig_additions() const; |
| 114 | virtual ioport_constructor device_input_ports() const; |
| 115 | }; |
| 116 | |
| 117 | |
| 118 | // ======================> gottlieb_sound_r2_device |
| 119 | |
| 120 | // fully populated rev 2 sound board |
| 121 | class gottlieb_sound_r2_device : public device_t, public device_mixer_interface |
| 122 | { |
| 123 | public: |
| 124 | // construction/destruction |
| 125 | gottlieb_sound_r2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 126 | |
| 127 | // static configuration helpers |
| 128 | static void static_enable_cobram3_mods(device_t &device); |
| 129 | |
| 130 | // read/write |
| 131 | DECLARE_WRITE8_MEMBER( write ); |
| 132 | |
| 133 | // internal communications |
| 134 | DECLARE_READ8_MEMBER( speech_data_r ); |
| 135 | DECLARE_READ8_MEMBER( audio_data_r ); |
| 136 | DECLARE_WRITE8_MEMBER( signal_audio_nmi_w ); |
| 137 | DECLARE_WRITE8_MEMBER( nmi_rate_w ); |
| 138 | CUSTOM_INPUT_MEMBER( speech_drq_custom_r ); |
| 139 | DECLARE_WRITE8_MEMBER( dac_w ); |
| 140 | DECLARE_WRITE8_MEMBER( speech_control_w ); |
| 141 | DECLARE_WRITE8_MEMBER( sp0250_latch_w ); |
| 142 | DECLARE_WRITE8_MEMBER( psg_latch_w ); |
| 143 | |
| 144 | protected: |
| 145 | // device-level overrides |
| 146 | virtual machine_config_constructor device_mconfig_additions() const; |
| 147 | virtual ioport_constructor device_input_ports() const; |
| 148 | virtual void device_start(); |
| 149 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 150 | |
| 151 | private: |
| 152 | // internal helpers |
| 153 | void nmi_timer_adjust(); |
| 154 | void nmi_state_update(); |
| 155 | |
| 156 | // timer IDs |
| 157 | enum |
| 158 | { |
| 159 | TID_NMI_GENERATE, |
| 160 | TID_NMI_CLEAR, |
| 161 | TID_SOUND_LATCH_WRITE |
| 162 | }; |
| 163 | |
| 164 | // devices |
| 165 | required_device<m6502_device> m_audiocpu; |
| 166 | required_device<m6502_device> m_speechcpu; |
| 167 | required_device<dac_device> m_dac; |
| 168 | required_device<ay8913_device> m_ay1; |
| 169 | required_device<ay8913_device> m_ay2; |
| 170 | optional_device<sp0250_device> m_sp0250; |
| 171 | |
| 172 | // internal state |
| 173 | bool m_cobram3_mod; |
| 174 | emu_timer * m_nmi_timer; |
| 175 | UINT8 m_nmi_rate; |
| 176 | UINT8 m_nmi_state; |
| 177 | UINT8 m_audiocpu_latch; |
| 178 | UINT8 m_speechcpu_latch; |
| 179 | UINT8 m_speech_control; |
| 180 | UINT8 m_last_command; |
| 181 | UINT8 m_dac_data[2]; |
| 182 | UINT8 m_psg_latch; |
| 183 | UINT8 m_psg_data_latch; |
| 184 | UINT8 m_sp0250_latch; |
| 185 | }; |
| 186 | |
| 187 | |
| 188 | /*----------- defined in audio/gottlieb.c -----------*/ |
| 189 | |
| 190 | #if USE_FAKE_VOTRAX |
| 191 | MACHINE_CONFIG_EXTERN( reactor_samples ); |
| 192 | MACHINE_CONFIG_EXTERN( qbert_samples ); |
| 193 | #endif |