diff --git a/src/emu/sound/flt_rc.c b/src/emu/sound/flt_rc.c index bad0e95959e..4632b8127bb 100644 --- a/src/emu/sound/flt_rc.c +++ b/src/emu/sound/flt_rc.c @@ -2,9 +2,6 @@ #include "flt_rc.h" -const flt_rc_config flt_rc_ac_default = {FLT_RC_AC, 10000, 0, 0, CAP_U(1)}; - - // device type definition const device_type FILTER_RC = &device_creator; @@ -23,7 +20,11 @@ filter_rc_device::filter_rc_device(const machine_config &mconfig, const char *ta m_stream(NULL), m_k(0), m_memory(0), - m_type(0) + m_type(FLT_RC_LOWPASS), + m_R1(1), + m_R2(1), + m_R3(1), + m_C(0) { } @@ -34,13 +35,8 @@ filter_rc_device::filter_rc_device(const machine_config &mconfig, const char *ta void filter_rc_device::device_start() { - const flt_rc_config *conf = (const flt_rc_config *)static_config(); - m_stream = stream_alloc(1, 1, machine().sample_rate()); - if (conf) - set_RC_info(conf->type, conf->R1, conf->R2, conf->R3, conf->C); - else - set_RC_info(FLT_RC_LOWPASS, 1, 1, 1, 0); + recalc(); } @@ -76,33 +72,31 @@ void filter_rc_device::sound_stream_update(sound_stream &stream, stream_sample_t } -void filter_rc_device::set_RC_info(int type, double R1, double R2, double R3, double C) +void filter_rc_device::recalc() { double Req; - m_type = type; - switch (m_type) { case FLT_RC_LOWPASS: - if (C == 0.0) + if (m_C == 0.0) { /* filter disabled */ m_k = 0x10000; return; } - Req = (R1 * (R2 + R3)) / (R1 + R2 + R3); + Req = (m_R1 * (m_R2 + m_R3)) / (m_R1 + m_R2 + m_R3); break; case FLT_RC_HIGHPASS: case FLT_RC_AC: - if (C == 0.0) + if (m_C == 0.0) { /* filter disabled */ m_k = 0x0; m_memory = 0x0; return; } - Req = R1; + Req = m_R1; break; default: fatalerror("filter_rc_setRC: Wrong filter type %d\n", m_type); @@ -110,12 +104,26 @@ void filter_rc_device::set_RC_info(int type, double R1, double R2, double R3, do /* Cut Frequency = 1/(2*Pi*Req*C) */ /* k = (1-(EXP(-TIMEDELTA/RC))) */ - m_k = 0x10000 - 0x10000 * (exp(-1 / (Req * C) / machine().sample_rate())); + m_k = 0x10000 - 0x10000 * (exp(-1 / (Req * m_C) / machine().sample_rate())); } void filter_rc_device::filter_rc_set_RC(int type, double R1, double R2, double R3, double C) { m_stream->update(); - set_RC_info(type, R1, R2, R3, C); + m_type = type; + m_R1 = R1; + m_R2 = R2; + m_R3 = R3; + m_C = C; + recalc(); +} + +void filter_rc_device::static_set_rc(device_t &device, int type, double R1, double R2, double R3, double C) +{ + downcast(device).m_type = type; + downcast(device).m_R1 = R1; + downcast(device).m_R2 = R2; + downcast(device).m_R3 = R3; + downcast(device).m_C = C; } diff --git a/src/emu/sound/flt_rc.h b/src/emu/sound/flt_rc.h index acf5c628baa..8bfdecec973 100644 --- a/src/emu/sound/flt_rc.h +++ b/src/emu/sound/flt_rc.h @@ -31,8 +31,8 @@ * Same as FLT_RC_HIGHPASS, but with standard frequency of 16 HZ * This filter may be setup just with * - * MCFG_SOUND_ADD("tag", FILTER_RC, 0) - * MCFG_SOUND_CONFIG(&flt_rc_ac_default) + * MCFG_FILTER_RC_ADD("tag", 0) + * MCFG_FILTER_RC_AC(&flt_rc_ac_default) * * Default behaviour: * @@ -46,9 +46,13 @@ #define MCFG_FILTER_RC_ADD(_tag, _clock) \ MCFG_DEVICE_ADD(_tag, FILTER_RC, _clock) + #define MCFG_FILTER_RC_REPLACE(_tag, _clock) \ MCFG_DEVICE_REPLACE(_tag, FILTER_RC, _clock) +#define MCFG_FILTER_RC_AC() \ + filter_rc_device::static_set_rc(*device, FLT_RC_AC, 10000, 0, 0, CAP_U(1)); + //************************************************************************** // TYPE DEFINITIONS @@ -58,18 +62,6 @@ #define FLT_RC_HIGHPASS 1 #define FLT_RC_AC 2 -struct flt_rc_config -{ - int type; - double R1; - double R2; - double R3; - double C; -}; - -extern const flt_rc_config flt_rc_ac_default; - - // ======================> filter_rc_device class filter_rc_device : public device_t, @@ -79,6 +71,9 @@ public: filter_rc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); ~filter_rc_device() { } + // static configuration + static void static_set_rc(device_t &device, int type, double R1, double R2, double R3, double C); + void filter_rc_set_RC(int type, double R1, double R2, double R3, double C); protected: @@ -89,16 +84,19 @@ protected: virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); private: - void set_RC_info(int type, double R1, double R2, double R3, double C); + void recalc(); private: sound_stream* m_stream; int m_k; int m_memory; int m_type; + double m_R1; + double m_R2; + double m_R3; + double m_C; }; extern const device_type FILTER_RC; - #endif /* __FLT_RC_H__ */ diff --git a/src/mame/drivers/39in1.c b/src/mame/drivers/39in1.c index fd5b3851e01..a28e727bb90 100644 --- a/src/mame/drivers/39in1.c +++ b/src/mame/drivers/39in1.c @@ -1519,10 +1519,6 @@ void _39in1_state::pxa255_start() { int index = 0; - //pxa255_t* pxa255 = pxa255_get_safe_token( device ); - - //pxa255->iface = device->base_config().static_config(); - for(index = 0; index < 16; index++) { m_dma_regs.dcsr[index] = 0x00000008; @@ -1543,8 +1539,6 @@ void _39in1_state::pxa255_start() m_lcd_regs.dma[1].eof = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(_39in1_state::pxa255_lcd_dma_eof),this)); m_lcd_regs.trgbr = 0x00aa5500; m_lcd_regs.tcr = 0x0000754f; - - //pxa255_register_state_save(device); } void _39in1_state::machine_start()