summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2020-09-15 15:14:15 -0700
committer Aaron Giles <aaron@aarongiles.com>2020-09-15 15:17:06 -0700
commitea60f78b23d94cd9c57f3de619f51e57503cddc1 (patch)
tree8d5cc779e0c11add74292ca7573e9dbcde4fabaf /src/mame/audio
parent87dce66d84f1fb33f8f09b6ef1b5c86dcc5db8af (diff)
cem3394: Major rework
* Updated to new stream callback * All calculations are now doing in floating point * External input is now done via an input stream * First attempt at implementing a proper filter -- needs some major work; checking in current state to get some assistance
Diffstat (limited to 'src/mame/audio')
-rw-r--r--src/mame/audio/sente6vb.cpp138
-rw-r--r--src/mame/audio/sente6vb.h14
2 files changed, 61 insertions, 91 deletions
diff --git a/src/mame/audio/sente6vb.cpp b/src/mame/audio/sente6vb.cpp
index f4232038c9b..22c9721a18a 100644
--- a/src/mame/audio/sente6vb.cpp
+++ b/src/mame/audio/sente6vb.cpp
@@ -65,6 +65,55 @@
DEFINE_DEVICE_TYPE(SENTE6VB, sente6vb_device, "sente6vb", "Bally Sente 6VB Audio Board")
+
+/*************************************
+*
+* Trivial sound device to spew
+* a MM5837 noise stream to CEM3394
+* inputs
+*
+*************************************/
+
+DECLARE_DEVICE_TYPE(MM5837_NOISE_SOURCE, mm5837_noise_source)
+
+class mm5837_noise_source : public device_t, public device_sound_interface
+{
+public:
+ mm5837_noise_source(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, MM5837_NOISE_SOURCE, tag, owner, clock),
+ device_sound_interface(mconfig, *this),
+ m_stream(nullptr),
+ m_noise_state(0x1ffff)
+ {
+ }
+
+protected:
+ // device-level overrides
+ virtual void device_start() override
+ {
+ m_stream = stream_alloc(0, 1, clock());
+ save_item(NAME(m_noise_state));
+ }
+
+ // sound stream update overrides
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override
+ {
+ for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++)
+ {
+ outputs[0].put(sampindex, BIT(m_noise_state, 0) ? 1.0 : 0.0);
+ m_noise_state = (m_noise_state >> 1) | ((BIT(m_noise_state, 0) ^ BIT(m_noise_state, 3)) << 16);
+ }
+ }
+
+private:
+ sound_stream *m_stream; // sound stream
+ u32 m_noise_state; // noise state
+};
+
+DEFINE_DEVICE_TYPE(MM5837_NOISE_SOURCE, mm5837_noise_source, "mm5837noise", "MM5837")
+
+
+
/*************************************
*
* Sound CPU memory handlers
@@ -123,20 +172,16 @@ void sente6vb_device::device_add_mconfig(machine_config &config)
SPEAKER(config, "mono").front_center();
+ mm5837_noise_source &noise(MM5837_NOISE_SOURCE(config, "noise", 100000));
+
for (auto &cem_device : m_cem_device)
{
CEM3394(config, cem_device, 0);
cem_device->set_vco_zero_freq(431.894);
cem_device->set_filter_zero_freq(1300.0);
cem_device->add_route(ALL_OUTPUTS, "mono", 0.90);
+ noise.add_route(0, *cem_device, 1.0);
}
-
- m_cem_device[0]->set_ext_input_callback(FUNC(sente6vb_device::noise_gen_0));
- m_cem_device[1]->set_ext_input_callback(FUNC(sente6vb_device::noise_gen_1));
- m_cem_device[2]->set_ext_input_callback(FUNC(sente6vb_device::noise_gen_2));
- m_cem_device[3]->set_ext_input_callback(FUNC(sente6vb_device::noise_gen_3));
- m_cem_device[4]->set_ext_input_callback(FUNC(sente6vb_device::noise_gen_4));
- m_cem_device[5]->set_ext_input_callback(FUNC(sente6vb_device::noise_gen_5));
}
@@ -164,24 +209,21 @@ const tiny_rom_entry *sente6vb_device::device_rom_region() const
*
*************************************/
-sente6vb_device::sente6vb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, SENTE6VB, tag, owner, clock)
- , m_pit(*this, "pit")
- , m_counter_0_timer(*this, "8253_0_timer")
- , m_cem_device(*this, "cem%u", 1U)
- , m_audiocpu(*this, "audiocpu")
- , m_uart(*this, "uart")
- , m_send_cb(*this)
- , m_clock_out_cb(*this)
+sente6vb_device::sente6vb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, SENTE6VB, tag, owner, clock),
+ m_pit(*this, "pit"),
+ m_counter_0_timer(*this, "8253_0_timer"),
+ m_cem_device(*this, "cem%u", 1U),
+ m_audiocpu(*this, "audiocpu"),
+ m_uart(*this, "uart"),
+ m_send_cb(*this),
+ m_clock_out_cb(*this)
{
}
void sente6vb_device::device_start()
{
- // create the polynomial tables
- poly17_init();
-
m_send_cb.resolve_safe();
m_clock_out_cb.resolve_safe();
m_uart->write_cts(0);
@@ -197,8 +239,6 @@ void sente6vb_device::device_start()
save_item(NAME(m_chip_select));
save_item(NAME(m_uint));
-
- save_item(NAME(m_noise_position));
}
@@ -215,64 +255,8 @@ void sente6vb_device::device_reset()
m_dac_value = 0;
m_dac_register = 0;
m_chip_select = 0x3f;
-
- // reset the noise generator
- memset(m_noise_position, 0, sizeof(m_noise_position));
-}
-
-
-
-/*************************************
- *
- * MM5837 noise generator
- *
- * NOTE: this is stolen straight from
- * POKEY.c
- *
- *************************************/
-
-void sente6vb_device::poly17_init()
-{
- uint32_t i, x = 0;
- uint8_t *p;
-
- // allocate memory
- p = m_poly17;
-
- // generate the polynomial
- for (i = 0; i < POLY17_SIZE; i++)
- {
- // store new values
- *p++ = x & 1;
-
- // calculate next bit
- x = ((x << POLY17_SHL) + (x >> POLY17_SHR) + POLY17_ADD) & POLY17_SIZE;
- }
-}
-
-
-inline void sente6vb_device::noise_gen_chip(int chip, int count, short *buffer)
-{
- // noise generator runs at 100kHz
- uint32_t step = (100000 << 14) / cem3394_device::SAMPLE_RATE;
- uint32_t noise_counter = m_noise_position[chip];
-
- while (count--)
- {
- *buffer++ = m_poly17[(noise_counter >> 14) & POLY17_SIZE] << 12;
- noise_counter += step;
- }
-
- // remember the noise position
- m_noise_position[chip] = noise_counter;
}
-CEM3394_EXT_INPUT(sente6vb_device::noise_gen_0) { noise_gen_chip(0, count, buffer); }
-CEM3394_EXT_INPUT(sente6vb_device::noise_gen_1) { noise_gen_chip(1, count, buffer); }
-CEM3394_EXT_INPUT(sente6vb_device::noise_gen_2) { noise_gen_chip(2, count, buffer); }
-CEM3394_EXT_INPUT(sente6vb_device::noise_gen_3) { noise_gen_chip(3, count, buffer); }
-CEM3394_EXT_INPUT(sente6vb_device::noise_gen_4) { noise_gen_chip(4, count, buffer); }
-CEM3394_EXT_INPUT(sente6vb_device::noise_gen_5) { noise_gen_chip(5, count, buffer); }
/*************************************
diff --git a/src/mame/audio/sente6vb.h b/src/mame/audio/sente6vb.h
index 9780703a1fd..ee199817360 100644
--- a/src/mame/audio/sente6vb.h
+++ b/src/mame/audio/sente6vb.h
@@ -50,15 +50,7 @@ private:
void update_counter_0_timer();
TIMER_DEVICE_CALLBACK_MEMBER(clock_counter_0_ff);
- void poly17_init();
DECLARE_WRITE_LINE_MEMBER(set_counter_0_ff);
- inline void noise_gen_chip(int chip, int count, short *buffer);
- CEM3394_EXT_INPUT(noise_gen_0);
- CEM3394_EXT_INPUT(noise_gen_1);
- CEM3394_EXT_INPUT(noise_gen_2);
- CEM3394_EXT_INPUT(noise_gen_3);
- CEM3394_EXT_INPUT(noise_gen_4);
- CEM3394_EXT_INPUT(noise_gen_5);
void mem_map(address_map &map);
void io_map(address_map &map);
@@ -78,9 +70,6 @@ private:
bool m_counter_0_out;
bool m_counter_0_timer_active;
- // random number generator states
- uint8_t m_poly17[POLY17_SIZE + 1];
-
// CEM3394 DAC control states
uint16_t m_dac_value;
uint8_t m_dac_register;
@@ -88,9 +77,6 @@ private:
// sound CPU 6850 states
bool m_uint;
-
- // noise generator states
- uint32_t m_noise_position[6];
};
DECLARE_DEVICE_TYPE(SENTE6VB, sente6vb_device)