Previous 199869 Revisions Next

r35080 Monday 16th February, 2015 at 21:53:42 UTC by hap
improved wildfire sound
[src/mess/drivers]wildfire.c

trunk/src/mess/drivers/wildfire.c
r243591r243592
1313
1414
1515  TODO:
16  - bad sound, A12 seems to strobe too fast
16  - sound emulation could still be improved
1717  - when the game strobes a led faster, it should appear brighter, for example when
1818    the ball hits one of the bumpers
1919  - some 7segs digits are wrong (mcu on-die decoder is customizable?)
r243591r243592
2828#include "wildfire.lh" // this is a test layout, external artwork is necessary
2929
3030// master clock is a single stage RC oscillator: R=?K, C=?pf,
31// S2150 default frequency is 850kHz
31// S2000 default frequency is 850kHz
3232#define MASTER_CLOCK (850000)
3333
3434
r243591r243592
3838   wildfire_state(const machine_config &mconfig, device_type type, const char *tag)
3939      : driver_device(mconfig, type, tag),
4040      m_maincpu(*this, "maincpu"),
41      m_speaker(*this, "speaker")
41      m_speaker(*this, "speaker"),
42      m_a12_decay_timer(*this, "a12_decay")
4243   { }
4344
4445   required_device<cpu_device> m_maincpu;
4546   required_device<speaker_sound_device> m_speaker;
47   required_device<timer_device> m_a12_decay_timer;
4648
4749   UINT8 m_d;
4850   UINT16 m_a;
49   UINT8 m_f;
51   UINT8 m_q2;
52   UINT8 m_q3;
5053
5154   UINT16 m_display_state[0x10];
5255   UINT16 m_display_cache[0x10];
r243591r243592
5962   TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick);
6063   bool index_is_7segled(int index);
6164   void display_update();
65   
66   TIMER_DEVICE_CALLBACK_MEMBER(reset_q2);
67   void write_a12(int state);
6268   void sound_update();
6369
6470   virtual void machine_start();
r243591r243592
153159
154160/***************************************************************************
155161
162  Sound
163
164***************************************************************************/
165
166// Sound output is via a speaker between transistors Q2(from A12) and Q3(from F_out)
167// A12 to Q2 has a little electronic circuit going, causing a slight delay.
168// (see patent US4334679 FIG.5, the 2 resistors are 10K and the cap is a 4.7uF electrolytic)
169
170// decay time, in steps of 1ms
171#define A12_DECAY_TIME 5 /* a complete guess */
172
173void wildfire_state::sound_update()
174{
175   m_speaker->level_w(m_q2 & m_q3);
176}
177
178WRITE_LINE_MEMBER(wildfire_state::write_f)
179{
180   // F_out pin: speaker out
181   m_q3 = (state) ? 1 : 0;
182   sound_update();
183}
184
185TIMER_DEVICE_CALLBACK_MEMBER(wildfire_state::reset_q2)
186{
187   m_q2 = 0;
188   sound_update();
189}
190
191void wildfire_state::write_a12(int state)
192{
193   if (state)
194   {
195      m_a12_decay_timer->adjust(attotime::never);
196      m_q2 = state;
197      sound_update();
198   }
199   else if (m_a >> 12 & 1)
200   {
201      // falling edge
202      m_a12_decay_timer->adjust(attotime::from_msec(A12_DECAY_TIME));
203   }
204}
205
206
207
208/***************************************************************************
209
156210  I/O
157211
158212***************************************************************************/
r243591r243592
166220
167221WRITE16_MEMBER(wildfire_state::write_a)
168222{
223   data ^= 0x1fff; // active-low
224   
225   // A12: enable speaker
226   write_a12(data >> 12 & 1);
227
169228   // A0-A2: select 7segleds
170229   // A3-A11: select other leds
171   m_a = data ^ 0x1fff; // active-low
230   m_a = data;
172231   display_update();
173
174   // A12: enable speaker
175   sound_update();
176232}
177233
178WRITE_LINE_MEMBER(wildfire_state::write_f)
179{
180   m_f = (state) ? 1 : 0;
181   sound_update();
182}
183234
184void wildfire_state::sound_update()
185{
186   m_speaker->level_w(m_a >> 12 & m_f);
187}
188235
189
190
191236/***************************************************************************
192237
193238  Inputs
r243591r243592
219264
220265   m_d = 0;
221266   m_a = 0;
222   m_f = 0;
267   m_q2 = 0;
268   m_q3 = 0;
223269
224270   // register for savestates
225271   save_item(NAME(m_display_state));
r243591r243592
228274
229275   save_item(NAME(m_d));
230276   save_item(NAME(m_a));
231   save_item(NAME(m_f));
277   save_item(NAME(m_q2));
278   save_item(NAME(m_q3));
232279}
233280
234281
r243591r243592
242289   MCFG_AMI_S2152_FOUT_CB(WRITELINE(wildfire_state, write_f))
243290
244291   MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", wildfire_state, display_decay_tick, attotime::from_msec(1))
292   MCFG_TIMER_DRIVER_ADD("a12_decay", wildfire_state, reset_q2)
245293
246294   MCFG_DEFAULT_LAYOUT(layout_wildfire)
247295


Previous 199869 Revisions Next


© 1997-2024 The MAME Team