Previous 199869 Revisions Next

r32105 Saturday 13th September, 2014 at 13:51:34 UTC by Miodrag Milanović
Removed static config in RC filter and small cleanup (nw)
[src/emu/sound]flt_rc.c flt_rc.h
[src/mame/drivers]39in1.c

trunk/src/mame/drivers/39in1.c
r32104r32105
15191519{
15201520   int index = 0;
15211521
1522   //pxa255_t* pxa255 = pxa255_get_safe_token( device );
1523
1524   //pxa255->iface = device->base_config().static_config();
1525
15261522   for(index = 0; index < 16; index++)
15271523   {
15281524      m_dma_regs.dcsr[index] = 0x00000008;
r32104r32105
15431539   m_lcd_regs.dma[1].eof = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(_39in1_state::pxa255_lcd_dma_eof),this));
15441540   m_lcd_regs.trgbr = 0x00aa5500;
15451541   m_lcd_regs.tcr = 0x0000754f;
1546
1547   //pxa255_register_state_save(device);
15481542}
15491543
15501544void _39in1_state::machine_start()
trunk/src/emu/sound/flt_rc.c
r32104r32105
22#include "flt_rc.h"
33
44
5const flt_rc_config flt_rc_ac_default = {FLT_RC_AC, 10000, 0, 0, CAP_U(1)};
6
7
85// device type definition
96const device_type FILTER_RC = &device_creator<filter_rc_device>;
107
r32104r32105
2320      m_stream(NULL),
2421      m_k(0),
2522      m_memory(0),
26      m_type(0)
23      m_type(FLT_RC_LOWPASS),
24      m_R1(1),
25      m_R2(1),
26      m_R3(1),
27      m_C(0)
2728{
2829}
2930
r32104r32105
3435
3536void filter_rc_device::device_start()
3637{
37   const flt_rc_config *conf = (const flt_rc_config *)static_config();
38
3938   m_stream = stream_alloc(1, 1, machine().sample_rate());
40   if (conf)
41      set_RC_info(conf->type, conf->R1, conf->R2, conf->R3, conf->C);
42   else
43      set_RC_info(FLT_RC_LOWPASS, 1, 1, 1, 0);
39   recalc();
4440}
4541
4642
r32104r32105
7672}
7773
7874
79void filter_rc_device::set_RC_info(int type, double R1, double R2, double R3, double C)
75void filter_rc_device::recalc()
8076{
8177   double Req;
8278
83   m_type = type;
84
8579   switch (m_type)
8680   {
8781      case FLT_RC_LOWPASS:
88         if (C == 0.0)
82         if (m_C == 0.0)
8983         {
9084            /* filter disabled */
9185            m_k = 0x10000;
9286            return;
9387         }
94         Req = (R1 * (R2 + R3)) / (R1 + R2 + R3);
88         Req = (m_R1 * (m_R2 + m_R3)) / (m_R1 + m_R2 + m_R3);
9589         break;
9690      case FLT_RC_HIGHPASS:
9791      case FLT_RC_AC:
98         if (C == 0.0)
92         if (m_C == 0.0)
9993         {
10094            /* filter disabled */
10195            m_k = 0x0;
10296            m_memory = 0x0;
10397            return;
10498         }
105         Req = R1;
99         Req = m_R1;
106100         break;
107101      default:
108102         fatalerror("filter_rc_setRC: Wrong filter type %d\n", m_type);
r32104r32105
110104
111105   /* Cut Frequency = 1/(2*Pi*Req*C) */
112106   /* k = (1-(EXP(-TIMEDELTA/RC)))    */
113   m_k = 0x10000 - 0x10000 * (exp(-1 / (Req * C) / machine().sample_rate()));
107   m_k = 0x10000 - 0x10000 * (exp(-1 / (Req * m_C) / machine().sample_rate()));
114108}
115109
116110
117111void filter_rc_device::filter_rc_set_RC(int type, double R1, double R2, double R3, double C)
118112{
119113   m_stream->update();
120   set_RC_info(type, R1, R2, R3, C);
114   m_type = type;
115   m_R1 = R1;
116   m_R2 = R2;
117   m_R3 = R3;
118   m_C = C;
119   recalc();
121120}
121
122void filter_rc_device::static_set_rc(device_t &device, int type, double R1, double R2, double R3, double C)
123{
124   downcast<filter_rc_device &>(device).m_type = type;
125   downcast<filter_rc_device &>(device).m_R1 = R1;
126   downcast<filter_rc_device &>(device).m_R2 = R2;
127   downcast<filter_rc_device &>(device).m_R3 = R3;
128   downcast<filter_rc_device &>(device).m_C = C;
129}
trunk/src/emu/sound/flt_rc.h
r32104r32105
3131 * Same as FLT_RC_HIGHPASS, but with standard frequency of 16 HZ
3232 * This filter may be setup just with
3333 *
34 * MCFG_SOUND_ADD("tag", FILTER_RC, 0)
35 * MCFG_SOUND_CONFIG(&flt_rc_ac_default)
34 * MCFG_FILTER_RC_ADD("tag", 0)
35 * MCFG_FILTER_RC_AC(&flt_rc_ac_default)
3636 *
3737 * Default behaviour:
3838 *
r32104r32105
4646
4747#define MCFG_FILTER_RC_ADD(_tag, _clock) \
4848   MCFG_DEVICE_ADD(_tag, FILTER_RC, _clock)
49
4950#define MCFG_FILTER_RC_REPLACE(_tag, _clock) \
5051   MCFG_DEVICE_REPLACE(_tag, FILTER_RC, _clock)
5152
53#define MCFG_FILTER_RC_AC() \
54   filter_rc_device::static_set_rc(*device, FLT_RC_AC, 10000, 0, 0, CAP_U(1));
5255
56
5357//**************************************************************************
5458//  TYPE DEFINITIONS
5559//**************************************************************************
r32104r32105
5862#define FLT_RC_HIGHPASS     1
5963#define FLT_RC_AC           2
6064
61struct flt_rc_config
62{
63   int type;
64   double  R1;
65   double  R2;
66   double  R3;
67   double  C;
68};
69
70extern const flt_rc_config flt_rc_ac_default;
71
72
7365// ======================> filter_rc_device
7466
7567class filter_rc_device : public device_t,
r32104r32105
7971   filter_rc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
8072   ~filter_rc_device() { }
8173
74   // static configuration
75   static void static_set_rc(device_t &device, int type, double R1, double R2, double R3, double C);
76   
8277   void filter_rc_set_RC(int type, double R1, double R2, double R3, double C);
8378
8479protected:
r32104r32105
8984   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
9085
9186private:
92   void set_RC_info(int type, double R1, double R2, double R3, double C);
87   void recalc();
9388
9489private:
9590   sound_stream*  m_stream;
9691   int            m_k;
9792   int            m_memory;
9893   int            m_type;
94   double         m_R1;
95   double         m_R2;
96   double         m_R3;
97   double         m_C;
9998};
10099
101100extern const device_type FILTER_RC;
102101
103
104102#endif /* __FLT_RC_H__ */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team