trunk/src/mame/drivers/39in1.c
r32104 | r32105 | |
1519 | 1519 | { |
1520 | 1520 | int index = 0; |
1521 | 1521 | |
1522 | | //pxa255_t* pxa255 = pxa255_get_safe_token( device ); |
1523 | | |
1524 | | //pxa255->iface = device->base_config().static_config(); |
1525 | | |
1526 | 1522 | for(index = 0; index < 16; index++) |
1527 | 1523 | { |
1528 | 1524 | m_dma_regs.dcsr[index] = 0x00000008; |
r32104 | r32105 | |
1543 | 1539 | m_lcd_regs.dma[1].eof = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(_39in1_state::pxa255_lcd_dma_eof),this)); |
1544 | 1540 | m_lcd_regs.trgbr = 0x00aa5500; |
1545 | 1541 | m_lcd_regs.tcr = 0x0000754f; |
1546 | | |
1547 | | //pxa255_register_state_save(device); |
1548 | 1542 | } |
1549 | 1543 | |
1550 | 1544 | void _39in1_state::machine_start() |
trunk/src/emu/sound/flt_rc.c
r32104 | r32105 | |
2 | 2 | #include "flt_rc.h" |
3 | 3 | |
4 | 4 | |
5 | | const flt_rc_config flt_rc_ac_default = {FLT_RC_AC, 10000, 0, 0, CAP_U(1)}; |
6 | | |
7 | | |
8 | 5 | // device type definition |
9 | 6 | const device_type FILTER_RC = &device_creator<filter_rc_device>; |
10 | 7 | |
r32104 | r32105 | |
23 | 20 | m_stream(NULL), |
24 | 21 | m_k(0), |
25 | 22 | 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) |
27 | 28 | { |
28 | 29 | } |
29 | 30 | |
r32104 | r32105 | |
34 | 35 | |
35 | 36 | void filter_rc_device::device_start() |
36 | 37 | { |
37 | | const flt_rc_config *conf = (const flt_rc_config *)static_config(); |
38 | | |
39 | 38 | 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(); |
44 | 40 | } |
45 | 41 | |
46 | 42 | |
r32104 | r32105 | |
76 | 72 | } |
77 | 73 | |
78 | 74 | |
79 | | void filter_rc_device::set_RC_info(int type, double R1, double R2, double R3, double C) |
| 75 | void filter_rc_device::recalc() |
80 | 76 | { |
81 | 77 | double Req; |
82 | 78 | |
83 | | m_type = type; |
84 | | |
85 | 79 | switch (m_type) |
86 | 80 | { |
87 | 81 | case FLT_RC_LOWPASS: |
88 | | if (C == 0.0) |
| 82 | if (m_C == 0.0) |
89 | 83 | { |
90 | 84 | /* filter disabled */ |
91 | 85 | m_k = 0x10000; |
92 | 86 | return; |
93 | 87 | } |
94 | | Req = (R1 * (R2 + R3)) / (R1 + R2 + R3); |
| 88 | Req = (m_R1 * (m_R2 + m_R3)) / (m_R1 + m_R2 + m_R3); |
95 | 89 | break; |
96 | 90 | case FLT_RC_HIGHPASS: |
97 | 91 | case FLT_RC_AC: |
98 | | if (C == 0.0) |
| 92 | if (m_C == 0.0) |
99 | 93 | { |
100 | 94 | /* filter disabled */ |
101 | 95 | m_k = 0x0; |
102 | 96 | m_memory = 0x0; |
103 | 97 | return; |
104 | 98 | } |
105 | | Req = R1; |
| 99 | Req = m_R1; |
106 | 100 | break; |
107 | 101 | default: |
108 | 102 | fatalerror("filter_rc_setRC: Wrong filter type %d\n", m_type); |
r32104 | r32105 | |
110 | 104 | |
111 | 105 | /* Cut Frequency = 1/(2*Pi*Req*C) */ |
112 | 106 | /* 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())); |
114 | 108 | } |
115 | 109 | |
116 | 110 | |
117 | 111 | void filter_rc_device::filter_rc_set_RC(int type, double R1, double R2, double R3, double C) |
118 | 112 | { |
119 | 113 | 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(); |
121 | 120 | } |
| 121 | |
| 122 | void 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
r32104 | r32105 | |
31 | 31 | * Same as FLT_RC_HIGHPASS, but with standard frequency of 16 HZ |
32 | 32 | * This filter may be setup just with |
33 | 33 | * |
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) |
36 | 36 | * |
37 | 37 | * Default behaviour: |
38 | 38 | * |
r32104 | r32105 | |
46 | 46 | |
47 | 47 | #define MCFG_FILTER_RC_ADD(_tag, _clock) \ |
48 | 48 | MCFG_DEVICE_ADD(_tag, FILTER_RC, _clock) |
| 49 | |
49 | 50 | #define MCFG_FILTER_RC_REPLACE(_tag, _clock) \ |
50 | 51 | MCFG_DEVICE_REPLACE(_tag, FILTER_RC, _clock) |
51 | 52 | |
| 53 | #define MCFG_FILTER_RC_AC() \ |
| 54 | filter_rc_device::static_set_rc(*device, FLT_RC_AC, 10000, 0, 0, CAP_U(1)); |
52 | 55 | |
| 56 | |
53 | 57 | //************************************************************************** |
54 | 58 | // TYPE DEFINITIONS |
55 | 59 | //************************************************************************** |
r32104 | r32105 | |
58 | 62 | #define FLT_RC_HIGHPASS 1 |
59 | 63 | #define FLT_RC_AC 2 |
60 | 64 | |
61 | | struct flt_rc_config |
62 | | { |
63 | | int type; |
64 | | double R1; |
65 | | double R2; |
66 | | double R3; |
67 | | double C; |
68 | | }; |
69 | | |
70 | | extern const flt_rc_config flt_rc_ac_default; |
71 | | |
72 | | |
73 | 65 | // ======================> filter_rc_device |
74 | 66 | |
75 | 67 | class filter_rc_device : public device_t, |
r32104 | r32105 | |
79 | 71 | filter_rc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
80 | 72 | ~filter_rc_device() { } |
81 | 73 | |
| 74 | // static configuration |
| 75 | static void static_set_rc(device_t &device, int type, double R1, double R2, double R3, double C); |
| 76 | |
82 | 77 | void filter_rc_set_RC(int type, double R1, double R2, double R3, double C); |
83 | 78 | |
84 | 79 | protected: |
r32104 | r32105 | |
89 | 84 | virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); |
90 | 85 | |
91 | 86 | private: |
92 | | void set_RC_info(int type, double R1, double R2, double R3, double C); |
| 87 | void recalc(); |
93 | 88 | |
94 | 89 | private: |
95 | 90 | sound_stream* m_stream; |
96 | 91 | int m_k; |
97 | 92 | int m_memory; |
98 | 93 | int m_type; |
| 94 | double m_R1; |
| 95 | double m_R2; |
| 96 | double m_R3; |
| 97 | double m_C; |
99 | 98 | }; |
100 | 99 | |
101 | 100 | extern const device_type FILTER_RC; |
102 | 101 | |
103 | | |
104 | 102 | #endif /* __FLT_RC_H__ */ |