diff options
| author | 2013-06-11 07:16:42 +0000 | |
|---|---|---|
| committer | 2013-06-11 07:16:42 +0000 | |
| commit | 16f5234d435ee57b65043533f8fa2b105fb15a77 (patch) | |
| tree | c6f95d84c6a1cb89ced5353230a98e1f61a6938e /src/emu/sound | |
| parent | 2dc6458ede8c0039e308c994e50acb3b8de2d1ae (diff) | |
Cleanups and version bumpmame0149
Diffstat (limited to 'src/emu/sound')
| -rw-r--r-- | src/emu/sound/msm5205.c | 20 | ||||
| -rw-r--r-- | src/emu/sound/sp0256.c | 78 | ||||
| -rw-r--r-- | src/emu/sound/sp0256.h | 16 | ||||
| -rw-r--r-- | src/emu/sound/speaker.c | 28 | ||||
| -rw-r--r-- | src/emu/sound/speaker.h | 12 | ||||
| -rw-r--r-- | src/emu/sound/ymf271.c | 12 | ||||
| -rw-r--r-- | src/emu/sound/ymz280b.c | 2 |
7 files changed, 83 insertions, 85 deletions
diff --git a/src/emu/sound/msm5205.c b/src/emu/sound/msm5205.c index 46868fe2726..ce8a60b7a0a 100644 --- a/src/emu/sound/msm5205.c +++ b/src/emu/sound/msm5205.c @@ -85,14 +85,14 @@ void msm5205_device::device_config_complete() const msm5205_interface *intf = reinterpret_cast<const msm5205_interface *>(static_config()); if (intf != NULL) *static_cast<msm5205_interface *>(this) = *intf; - + // or initialize to defaults if none provided else { memset(&m_vclk_cb, 0, sizeof(m_vclk_cb)); m_select = 0; } - + } //------------------------------------------------- @@ -103,14 +103,14 @@ void msm5205_device::device_start() { m_mod_clock = clock(); m_vclk_callback.resolve(m_vclk_cb, *this); - + /* compute the difference tables */ compute_tables(); - + /* stream system initialize */ m_stream = machine().sound().stream_alloc(*this, 0, 1, clock(), this); m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(msm5205_device::vclk_callback), this)); - + /* register for save states */ save_item(NAME(m_mod_clock)); save_item(NAME(m_data)); @@ -127,14 +127,14 @@ void msm5205_device::device_start() //------------------------------------------------- void msm5205_device::device_reset() -{ +{ /* initialize work */ m_data = 0; m_vclk = 0; m_reset = 0; m_signal = 0; m_step = 0; - + /* timer and bitwidth set */ playmode_w(m_select); } @@ -189,7 +189,7 @@ TIMER_CALLBACK_MEMBER( msm5205_device::vclk_callback ) int new_signal; /* callback user handler and latch next data */ - if (!m_vclk_callback.isnull()) + if (!m_vclk_callback.isnull()) m_vclk_callback(1); /* reset check at last hiedge of VCLK */ @@ -237,7 +237,7 @@ void msm5205_device::vclk_w(int vclk) if (m_vclk != vclk) { m_vclk = vclk; - if (!vclk) + if (!vclk) vclk_callback(this, 0); } } @@ -325,7 +325,7 @@ void msm5205_device::change_clock_w(INT32 clock) void msm5205_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) { stream_sample_t *buffer = outputs[0]; - + /* if this voice is active */ if(m_signal) { diff --git a/src/emu/sound/sp0256.c b/src/emu/sound/sp0256.c index 739f570fe72..7fc7a95e705 100644 --- a/src/emu/sound/sp0256.c +++ b/src/emu/sound/sp0256.c @@ -27,7 +27,7 @@ the sp0256_start() call. If the memory map contents is modified during execution (accross of ROM - bank switching) the bitrevbuff() call must be called after the section + bank switching) the bitrevbuff() call must be called after the section of ROM is modified. */ @@ -112,14 +112,14 @@ void sp0256_device::device_config_complete() const sp0256_interface *intf = reinterpret_cast<const sp0256_interface *>(static_config()); if (intf != NULL) *static_cast<sp0256_interface *>(this) = *intf; - + // or initialize to defaults if none provided else { memset(&m_lrq_cb, 0, sizeof(m_lrq_cb)); memset(&m_sby_cb, 0, sizeof(m_sby_cb)); } - + } //------------------------------------------------- @@ -132,14 +132,14 @@ void sp0256_device::device_start() m_sby.resolve(m_sby_cb, *this); m_drq(1); m_sby(1); - + m_stream = machine().sound().stream_alloc(*this, 0, 1, clock() / CLOCK_DIVIDER, this); - + /* -------------------------------------------------------------------- */ /* Configure our internal variables. */ /* -------------------------------------------------------------------- */ m_filt.rng = 1; - + /* -------------------------------------------------------------------- */ /* Allocate a scratch buffer for generating ~10kHz samples. */ /* -------------------------------------------------------------------- */ @@ -147,7 +147,7 @@ void sp0256_device::device_start() save_pointer(NAME(m_scratch), SCBUF_SIZE); m_sc_head = m_sc_tail = 0; - + /* -------------------------------------------------------------------- */ /* Set up the microsequencer's initial state. */ /* -------------------------------------------------------------------- */ @@ -156,7 +156,7 @@ void sp0256_device::device_start() m_lrq = 0x8000; m_page = 0x1000 << 3; m_silent = 1; - + /* -------------------------------------------------------------------- */ /* Setup the ROM. */ /* -------------------------------------------------------------------- */ @@ -165,7 +165,7 @@ void sp0256_device::device_start() // see http://forums.bannister.org/ubbthreads.php?ubb=showflat&Number=72385#Post72385 // TODO: because of this, check if the bitrev functions are even used anywhere else // bitrevbuff(m_rom, 0, 0xffff); - + m_lrq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sp0256_device::set_lrq_timer_proc),this)); // save device variables @@ -208,7 +208,7 @@ void sp0256_device::device_reset() { // reset FIFO and SP0256 m_fifo_head = m_fifo_tail = m_fifo_bitp = 0; - + memset(&m_filt, 0, sizeof(m_filt)); m_halted = 1; m_filt.rpt = -1; @@ -223,7 +223,7 @@ void sp0256_device::device_reset() m_silent = 1; m_drq(1); SET_SBY(1) - + m_lrq = 0; m_lrq_timer->adjust(attotime::from_ticks(50, m_clock)); } @@ -1196,7 +1196,7 @@ WRITE8_MEMBER( sp0256_device::ald_w ) LOG(("sp0256: Droped ALD write\n")); return; } - + /* ---------------------------------------------------------------- */ /* Set LRQ to "busy" and load the 8 LSBs of the data into the ALD */ /* reg. We take the command address, and multiply by 2 bytes to */ @@ -1206,7 +1206,7 @@ WRITE8_MEMBER( sp0256_device::ald_w ) m_ald = (0xff & data) << 4; m_drq(0); SET_SBY(0) - + return; } @@ -1214,13 +1214,13 @@ READ_LINE_MEMBER( sp0256_device::lrq_r ) { // force stream update m_stream->update(); - + return m_lrq == 0x8000; } READ_LINE_MEMBER( sp0256_device::sby_r ) { - // TODO: force stream update?? + // TODO: force stream update?? return m_sby_line; } @@ -1234,7 +1234,7 @@ READ16_MEMBER( sp0256_device::spb640_r ) { return m_lrq; } - + /* -------------------------------------------------------------------- */ /* Offset 1 returns the SPB640 FIFO full status on bit 15. */ /* -------------------------------------------------------------------- */ @@ -1242,7 +1242,7 @@ READ16_MEMBER( sp0256_device::spb640_r ) { return (m_fifo_head - m_fifo_tail) >= 64 ? 0x8000 : 0; } - + /* -------------------------------------------------------------------- */ /* Just return 255 for all other addresses in our range. */ /* -------------------------------------------------------------------- */ @@ -1256,20 +1256,20 @@ WRITE16_MEMBER( sp0256_device::spb640_w ) ald_w(space, 0, data & 0xff); return; } - + if (offset == 1) { /* ---------------------------------------------------------------- */ /* If Bit 10 is set, reset the FIFO, and SP0256. */ /* ---------------------------------------------------------------- */ - + if (data & 0x400) { m_fifo_head = m_fifo_tail = m_fifo_bitp = 0; device_reset(); return; } - + /* ---------------------------------------------------------------- */ /* If the FIFO is full, drop the data. */ /* ---------------------------------------------------------------- */ @@ -1278,16 +1278,16 @@ WRITE16_MEMBER( sp0256_device::spb640_w ) LOG(("spb640: Dropped FIFO write\n")); return; } - + /* ---------------------------------------------------------------- */ /* FIFO up the lower 10 bits of the data. */ /* ---------------------------------------------------------------- */ - + LOG(("spb640: WR_FIFO %.3X %d.%d %d\n", data & 0x3ff, - m_fifo_tail, m_fifo_bitp, m_fifo_head)); - + m_fifo_tail, m_fifo_bitp, m_fifo_head)); + m_fifo[m_fifo_head++ & 63] = data & 0x3ff; - + return; } } @@ -1313,31 +1313,31 @@ void sp0256_device::sound_stream_update(sound_stream &stream, stream_sample_t ** stream_sample_t *output = outputs[0]; int output_index = 0; int length, did_samp/*, old_idx*/; - + while (output_index < samples) { /* ---------------------------------------------------------------- */ /* First, drain as much of our scratch buffer as we can into the */ /* sound buffer. */ /* ---------------------------------------------------------------- */ - + while (m_sc_tail != m_sc_head) { output[output_index++] = m_scratch[m_sc_tail++ & SCBUF_MASK]; m_sc_tail &= SCBUF_MASK; - + if (output_index > samples) break; } - + /* ---------------------------------------------------------------- */ /* If output outputs is full, then we're done. */ /* ---------------------------------------------------------------- */ if (output_index > samples) break; - + length = samples - output_index; - + /* ---------------------------------------------------------------- */ /* Process the current set of filter coefficients as long as the */ /* repeat count holds up and we have room in our scratch buffer. */ @@ -1347,26 +1347,26 @@ void sp0256_device::sound_stream_update(sound_stream &stream, stream_sample_t ** if (length > 0) do { int do_samp; - + /* ------------------------------------------------------------ */ /* If our repeat count expired, emulate the microsequencer. */ /* ------------------------------------------------------------ */ if (m_filt.rpt <= 0) micro(); - + /* ------------------------------------------------------------ */ /* Do as many samples as we can. */ /* ------------------------------------------------------------ */ do_samp = length - did_samp; if (m_sc_head + do_samp - m_sc_tail > SCBUF_SIZE) do_samp = m_sc_tail + SCBUF_SIZE - m_sc_head; - + if (do_samp == 0) break; - + if (m_silent && m_filt.rpt <= 0) { int y = m_sc_head; - + for (int x = 0; x < do_samp; x++) m_scratch[y++ & SCBUF_MASK] = 0; m_sc_head += do_samp; @@ -1375,11 +1375,11 @@ void sp0256_device::sound_stream_update(sound_stream &stream, stream_sample_t ** else { did_samp += lpc12_update(&m_filt, do_samp, - m_scratch, &m_sc_head); + m_scratch, &m_sc_head); } - + m_sc_head &= SCBUF_MASK; - + } while (m_filt.rpt >= 0 && length > did_samp); } } diff --git a/src/emu/sound/sp0256.h b/src/emu/sound/sp0256.h index 91e7d89a0db..b6cd977ef6d 100644 --- a/src/emu/sound/sp0256.h +++ b/src/emu/sound/sp0256.h @@ -81,11 +81,11 @@ public: DECLARE_READ_LINE_MEMBER(sby_r); DECLARE_READ16_MEMBER(spb640_r); DECLARE_WRITE16_MEMBER(spb640_w); - + TIMER_CALLBACK_MEMBER(set_lrq_timer_proc); void set_clock(int clock); void bitrevbuff(UINT8 *buffer, unsigned int start, unsigned int length); - + protected: // device-level overrides virtual void device_config_complete(); @@ -97,20 +97,20 @@ protected: private: UINT32 getb(int len); void micro(); - + sound_stream *m_stream; /* MAME core sound stream */ devcb_resolved_write_line m_drq; /* Data request callback */ devcb_resolved_write_line m_sby; /* Standby callback */ int m_sby_line; /* Standby line state */ int m_cur_len; /* Fullness of current sound buffer. */ - + int m_silent; /* Flag: SP0256 is silent. */ - + INT16 *m_scratch; /* Scratch buffer for audio. */ UINT32 m_sc_head; /* Head pointer into scratch circular buf */ UINT32 m_sc_tail; /* Tail pointer into scratch circular buf */ - + struct lpc12_t m_filt; /* 12-pole filter */ int m_lrq; /* Load ReQuest. == 0 if we can accept a load */ int m_ald; /* Address LoaD. < 0 if no command pending. */ @@ -120,12 +120,12 @@ private: int m_halted; /* True when CPU is halted. */ UINT32 m_mode; /* Mode register. */ UINT32 m_page; /* Page set by SETPAGE */ - + UINT32 m_fifo_head; /* FIFO head pointer (where new data goes). */ UINT32 m_fifo_tail; /* FIFO tail pointer (where data comes from). */ UINT32 m_fifo_bitp; /* FIFO bit-pointer (for partial decles). */ UINT16 m_fifo[64]; /* The 64-decle FIFO. */ - + UINT8 *m_rom; /* 64K ROM. */ emu_timer *m_lrq_timer; diff --git a/src/emu/sound/speaker.c b/src/emu/sound/speaker.c index 0a6783960c5..146843687ad 100644 --- a/src/emu/sound/speaker.c +++ b/src/emu/sound/speaker.c @@ -99,7 +99,7 @@ void speaker_sound_device::device_config_complete() const speaker_interface *intf = reinterpret_cast<const speaker_interface *>(static_config()); if (intf != NULL) *static_cast<speaker_interface *>(this) = *intf; - + // or initialize to defaults if none provided else { @@ -116,7 +116,7 @@ void speaker_sound_device::device_start() { int i; double x; - + m_channel = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate(), this); m_level = 0; @@ -137,7 +137,7 @@ void speaker_sound_device::device_start() /* Note: To avoid time drift due to floating point inaccuracies, * it is good if the speaker time synchronizes itself with the stream timing regularly. */ - + /* Compute filter kernel; */ /* (Done for each device though the data is shared... * No problem really, but should be done as part of system init if I knew how) @@ -157,8 +157,8 @@ void speaker_sound_device::device_start() #define FILTER_STEP (M_PI / 2 / RATE_MULTIPLIER) /* Distribute symmetrically on x axis; center has x=0 if length is odd */ for (i = 0, x = (0.5 - FILTER_LENGTH / 2.) * FILTER_STEP; - i < FILTER_LENGTH; - i++, x += FILTER_STEP) + i < FILTER_LENGTH; + i++, x += FILTER_STEP) { if (x == 0) m_ampl[i] = 1; @@ -180,7 +180,7 @@ void speaker_sound_device::device_start() save_item(NAME(m_channel_last_sample_time)); save_item(NAME(m_interm_sample_index)); save_item(NAME(m_last_update_time)); - + machine().save().register_postload(save_prepost_delegate(FUNC(speaker_sound_device::speaker_postload), this)); } @@ -201,35 +201,35 @@ void speaker_sound_device::sound_stream_update(sound_stream &stream, stream_samp int volume = m_levels[m_level]; double filtered_volume; attotime sampled_time = attotime::zero; - + if (samples > 0) { /* Prepare to update time state */ sampled_time = attotime(0, m_channel_sample_period); if (samples > 1) sampled_time *= samples; - + /* Note: since the stream is in the process of being updated, * stream->sample_time() will return the time before the update! (MAME 0.130) * Avoid using it here in order to avoid a subtle dependence on the stream implementation. */ } - + if (samples-- > 0) { /* Note that first interm. sample may be composed... */ filtered_volume = update_interm_samples_get_filtered_volume(volume); - + /* Composite volume is now quantized to the stream resolution */ *buffer++ = (stream_sample_t)filtered_volume; - + /* Any additional samples will be homogeneous, however may need filtering across samples: */ while (samples-- > 0) { filtered_volume = update_interm_samples_get_filtered_volume(volume); *buffer++ = (stream_sample_t)filtered_volume; } - + /* Update the time state */ m_channel_last_sample_time += sampled_time; m_channel_next_sample_time = m_channel_last_sample_time + attotime(0, m_channel_sample_period); @@ -289,7 +289,7 @@ void speaker_sound_device::level_w(int new_level) /* Finally update speaker state before returning */ m_level = new_level; - + } @@ -394,5 +394,3 @@ double speaker_sound_device::get_filtered_volume() return filtered_volume; } - - diff --git a/src/emu/sound/speaker.h b/src/emu/sound/speaker.h index d90f3c50316..6adda328ca8 100644 --- a/src/emu/sound/speaker.h +++ b/src/emu/sound/speaker.h @@ -12,7 +12,7 @@ #define __SOUND_SPEAKER_H__ // Length of anti-aliasing filter kernel, measured in number of intermediate samples -enum +enum { FILTER_LENGTH = 64 }; @@ -48,21 +48,21 @@ private: // Updates the composed volume array according to time void update_interm_samples(attotime time, int volume); - + // Updates the composed volume array and returns final filtered volume of next stream sample double update_interm_samples_get_filtered_volume(int volume); - + void finalize_interm_sample(int volume); void init_next_interm_sample(); inline double make_fraction(attotime a, attotime b, double timediv); double get_filtered_volume(); - + // Kernel (pulse response) for filtering across samples (while we avoid fancy filtering within samples) double m_ampl[FILTER_LENGTH]; - + sound_stream *m_channel; int m_level; - + /* The volume of a composed sample grows incrementally each time the speaker is over-sampled. * That is in effect a basic average filter. * Another filter can and will be applied to the array of composed samples. diff --git a/src/emu/sound/ymf271.c b/src/emu/sound/ymf271.c index c1148d10d84..2c32a50b7ad 100644 --- a/src/emu/sound/ymf271.c +++ b/src/emu/sound/ymf271.c @@ -1136,7 +1136,7 @@ void ymf271_device::write_register(int slotnum, int reg, int data) slot->ch3_level = data & 0xf; break; } - + default: break; } @@ -1318,7 +1318,7 @@ void ymf271_device::device_timer(emu_timer &timer, device_timer_id id, int param if (!m_irq_handler.isnull()) m_irq_handler(1); } - + // reload timer m_timA->adjust(attotime::from_hz(m_clock) * (384 * 4 * (256 - m_timerA)), 0); break; @@ -1334,7 +1334,7 @@ void ymf271_device::device_timer(emu_timer &timer, device_timer_id id, int param if (!m_irq_handler.isnull()) m_irq_handler(1); } - + // reload timer m_timB->adjust(attotime::from_hz(m_clock) * (384 * 16 * (256 - m_timerB)), 0); break; @@ -1447,7 +1447,7 @@ void ymf271_device::ymf271_write_timer(int data) if (!m_ext_rw && !m_ext_write_handler.isnull()) m_ext_write_handler(m_ext_address, data); break; - + default: break; } @@ -1737,11 +1737,11 @@ void ymf271_device::device_reset() m_slots[i].active = 0; m_slots[i].volume = 0; } - + // reset timers and IRQ m_timA->reset(); m_timB->reset(); - + m_irqstate = 0; m_status = 0; m_enable = 0; diff --git a/src/emu/sound/ymz280b.c b/src/emu/sound/ymz280b.c index 0e8dc68be71..2edc86b200e 100644 --- a/src/emu/sound/ymz280b.c +++ b/src/emu/sound/ymz280b.c @@ -17,7 +17,7 @@ 8-bit PCM, 16-bit PCM ...... 0.172 to 88.2kHz in 512 steps 256 steps total level and 16 steps panpot can be set Voice signal is output in stereo 16-bit 2's complement MSB-first format - + TODO: - Is memory handling 100% correct? At the moment, Konami firebeat.c is the only hardware currently emulated that uses external handlers. |
