1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
// license:BSD-3-Clause
// copyright-holders:K.Wilkins
#pragma once
#ifndef __DISC_MTH_H__
#define __DISC_MTH_H__
/***********************************************************************
*
* MAME - Discrete sound system emulation library
*
* Written by K.Wilkins (mame@esplexo.co.uk)
*
* (c) K.Wilkins 2000
*
* Coding started in November 2000
*
* Additions/bugfix February 2003 - Derrick Renaud, F.Palazzolo, K.Wilkins
* Discrete parallel tasks 2009 - Couriersud
* Discrete classes 2010 - Couriersud
*
***********************************************************************/
#include "discrete.h"
DISCRETE_CLASS_STEP(dst_adder, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_clamp, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_divide, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_gain, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_logic_inv, 1, /* no context */ );
DISCRETE_CLASS_STEP_RESET(dst_bits_decode, 8,
int m_count;
int m_decode_x_time;
int m_from;
int m_last_val;
int m_last_had_x_time;
);
DISCRETE_CLASS_STEP(dst_logic_and, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_logic_nand, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_logic_or, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_logic_nor, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_logic_xor, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_logic_nxor, 1, /* no context */ );
DISCRETE_CLASS_STEP_RESET(dst_logic_dff, 1,
int m_last_clk;
);
DISCRETE_CLASS_STEP_RESET(dst_logic_jkff, 1,
double m_v_out;
int m_last_clk;
);
DISCRETE_CLASS_STEP_RESET(dst_logic_shift, 1,
double m_t_left; /* time unused during last sample in seconds */
UINT32 m_shift_data;
UINT32 m_bit_mask;
UINT8 m_clock_type;
UINT8 m_reset_on_high;
UINT8 m_shift_r;
UINT8 m_last;
);
DISCRETE_CLASS_STEP(dst_lookup_table, 1, /* no context */ );
DISCRETE_CLASS_STEP_RESET(dst_multiplex, 1,
int m_size;
);
DISCRETE_CLASS_STEP_RESET(dst_oneshot, 1,
double m_countdown;
int m_state;
int m_last_trig;
int m_type;
);
DISCRETE_CLASS_STEP_RESET(dst_ramp, 1,
double m_v_out;
double m_step;
int m_dir; /* 1 if End is higher then Start */
int m_last_en; /* Keep track of the last enable value */
);
DISCRETE_CLASS_STEP_RESET(dst_samphold, 1,
double m_last_input;
int m_clocktype;
);
DISCRETE_CLASS_STEP(dst_switch, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_aswitch, 1, /* no context */ );
DISCRETE_CLASS_STEP(, 1, /* no context */ );
class DISCRETE_CLASS_NAME(dst_transform): public discrete_base_node, public discrete_step_interface
{
DISCRETE_CLASS_CONSTRUCTOR(dst_transform, base)
DISCRETE_CLASS_DESTRUCTOR(dst_transform)
public:
enum token {
TOK_END = 0,
TOK_MULT,
TOK_DIV,
TOK_ADD,
TOK_MINUS,
TOK_0,
TOK_1,
TOK_2,
TOK_3,
TOK_4,
TOK_DUP,
TOK_ABS, /* absolute value */
TOK_NEG, /* * -1 */
TOK_NOT, /* Logical NOT of Last Value */
TOK_EQUAL, /* Logical = */
TOK_GREATER, /* Logical > */
TOK_LESS, /* Logical < */
TOK_AND, /* Bitwise AND */
TOK_OR, /* Bitwise OR */
TOK_XOR /* Bitwise XOR */
};
void step(void);
void reset(void);
protected:
private:
DISCRETE_CLASS_INPUT(I_IN0, 0);
DISCRETE_CLASS_INPUT(I_IN1, 1);
DISCRETE_CLASS_INPUT(I_IN2, 2);
DISCRETE_CLASS_INPUT(I_IN3, 3);
DISCRETE_CLASS_INPUT(I_IN4, 4);
enum token precomp[32];
};
/* Component specific */
DISCRETE_CLASS_STEP_RESET(dst_comp_adder, 1,
double m_total[256];
);
DISCRETE_CLASS_STEP_RESET(dst_dac_r1, 1,
double m_v_out;
double m_exponent;
double m_last_v;
double m_v_step[256];
int m_has_c_filter;
);
DISCRETE_CLASS_STEP_RESET(dst_diode_mix, 1,
int m_size;
double m_v_junction[8];
);
DISCRETE_CLASS_STEP_RESET(dst_integrate, 1,
double m_v_out;
double m_change;
double m_v_max_in; /* v1 - norton VBE */
double m_v_max_in_d; /* v1 - norton VBE - diode drop */
double m_v_max_out;
);
#define DISC_MIXER_MAX_INPS 8
DISCRETE_CLASS_STEP_RESET(dst_mixer, 1,
int m_type;
int m_size;
int m_r_node_bit_flag;
int m_c_bit_flag;
double m_r_total;
const double * m_r_node[DISC_MIXER_MAX_INPS]; /* Either pointer to resistance node output OR NULL */
double m_r_last[DISC_MIXER_MAX_INPS];
double m_exponent_rc[DISC_MIXER_MAX_INPS]; /* For high pass filtering cause by cIn */
double m_v_cap[DISC_MIXER_MAX_INPS]; /* cap voltage of each input */
double m_exponent_c_f; /* Low pass on mixed inputs */
double m_exponent_c_amp; /* Final high pass caused by out cap and amp input impedance */
double m_v_cap_f; /* cap voltage of cF */
double m_v_cap_amp; /* cap voltage of cAmp */
double m_gain; /* used for DISC_MIXER_IS_OP_AMP_WITH_RI */
);
DISCRETE_CLASS_STEP_RESET(dst_op_amp, 1,
UINT8 m_has_cap;
UINT8 m_has_r1;
UINT8 m_has_r4;
double m_v_max;
double m_i_fixed;
double m_v_cap;
double m_exponent;
);
DISCRETE_CLASS_STEP_RESET(dst_op_amp_1sht, 1,
double m_v_out;
double m_i_fixed;
double m_v_max;
double m_r34ratio;
double m_v_cap1;
double m_v_cap2;
double m_exponent1c;
double m_exponent1d;
double m_exponent2;
);
DISCRETE_CLASS_STEP_RESET(dst_tvca_op_amp, 1,
double m_v_out_max; /* Maximum output voltage */
double m_v_trig[2]; /* Voltage used to charge cap1 based on function F3 */
double m_v_trig2; /* Voltage used to charge cap2 */
double m_v_trig3; /* Voltage used to charge cap3 */
double m_i_fixed; /* Fixed current going into - input */
double m_exponent_c[2]; /* Charge exponents based on function F3 */
double m_exponent_d[2]; /* Discharge exponents based on function F3 */
double m_exponent2[2]; /* Discharge/charge exponents based on function F4 */
double m_exponent3[2]; /* Discharge/charge exponents based on function F5 */
double m_exponent4; /* Discharge/charge exponents for c4 */
double m_v_cap1; /* charge on cap c1 */
double m_v_cap2; /* charge on cap c2 */
double m_v_cap3; /* charge on cap c3 */
double m_v_cap4; /* charge on cap c4 */
double m_r67; /* = r6 + r7 (for easy use later) */
UINT8 m_has_c4;
UINT8 m_has_r4;
);
DISCRETE_CLASS_STEP(dst_xtime_buffer, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_xtime_and, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_xtime_or, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_xtime_xor, 1, /* no context */ );
#endif /* __DISC_WAV_H__ */
|