Debian Codegraph @

src/hardware/snd_pc98/sound/opngen.h

raw symbols SCIP
1
2 enum {
3 #if defined(SUPPORT_PX)
4 OPNCH_MAX = 30,
5 #else // defined(SUPPORT_PX)
6 OPNCH_MAX = 12,
7 #endif // defined(SUPPORT_PX)
8 OPNA_CLOCK = 55466 * 72,
9 };
10
11 #define OPN_CHMASK 0x80000000U
12 #define OPN_STEREO 0x80000000U
13 #define OPN_MONORAL 0x00000000U
14
15 #if defined(OPNGENX86)
16
17 enum {
18 FMDIV_BITS = 8,
19 FMDIV_ENT = (1 << FMDIV_BITS),
20 FMVOL_SFTBIT = 4
21 };
22
23 #define SIN_BITS 11
24 #define EVC_BITS 10
25 #define ENV_BITS 16
26 #define KF_BITS 6
27 #define FREQ_BITS 21
28 #define ENVTBL_BIT 14
29 #define SINTBL_BIT 14
30
31 #elif defined(OPNGENARM)
32
33 enum {
34 FMDIV_BITS = 8,
35 FMDIV_ENT = (1 << FMDIV_BITS),
36 FMVOL_SFTBIT = 4
37 };
38
39 #define SIN_BITS 8
40 #define EVC_BITS 7
41 #define ENV_BITS 16
42 #define KF_BITS 6
43 #define FREQ_BITS 20
44 #define ENVTBL_BIT 14
45 #define SINTBL_BIT 14 // env+sin 30bit max
46
47 #else
48
49 enum {
50 FMDIV_BITS = 8,
51 FMDIV_ENT = (1 << FMDIV_BITS),
52 FMVOL_SFTBIT = 4
53 };
54
55 #define SIN_BITS 10
56 #define EVC_BITS 10
57 #define ENV_BITS 16
58 #define KF_BITS 6
59 #define FREQ_BITS 21
60 #define ENVTBL_BIT 14
61 #define SINTBL_BIT 15
62
63 #endif
64
65 #define TL_BITS (FREQ_BITS+2)
66 #define OPM_OUTSB (TL_BITS + 2 - 16) // OPM output 16bit
67
68 #define SIN_ENT (1L << SIN_BITS)
69 #define EVC_ENT (1L << EVC_BITS)
70
71 #define EC_ATTACK 0 // ATTACK start
72 #define EC_DECAY (EVC_ENT << ENV_BITS) // DECAY start
73 #define EC_OFF ((2 * EVC_ENT) << ENV_BITS) // OFF
74
75 #define TL_MAX (EVC_ENT * 2)
76
77 enum {
78 OPNSLOT1 = 0, // slot number
79 OPNSLOT2 = 2,
80 OPNSLOT3 = 1,
81 OPNSLOT4 = 3,
82
83 EM_ATTACK = 4,
84 EM_DECAY1 = 3,
85 EM_DECAY2 = 2,
86 EM_RELEASE = 1,
87 EM_OFF = 0
88 };
89
90 typedef struct {
91 SINT32 *detune1; // detune1
92 SINT32 totallevel; // total level
93 SINT32 decaylevel; // decay level
94 const SINT32 *attack; // attack ratio
95 const SINT32 *decay1; // decay1 ratio
96 const SINT32 *decay2; // decay2 ratio
97 const SINT32 *release; // release ratio
98 SINT32 freq_cnt; // frequency count
99 SINT32 freq_inc; // frequency step
100 SINT32 multiple; // multiple
101 UINT8 keyscale; // key scale
102 UINT8 env_mode; // envelope mode
103 UINT8 envratio; // envelope ratio
104 UINT8 ssgeg1; // SSG-EG
105
106 SINT32 env_cnt; // envelope count
107 SINT32 env_end; // envelope end count
108 SINT32 env_inc; // envelope step
109 SINT32 env_inc_attack; // envelope attack step
110 SINT32 env_inc_decay1; // envelope decay1 step
111 SINT32 env_inc_decay2; // envelope decay2 step
112 SINT32 env_inc_release; // envelope release step
113 } OPNSLOT;
114
115 typedef struct {
116 OPNSLOT slot[4];
117 UINT8 algorithm; // algorithm
118 UINT8 feedback; // self feedback
119 UINT8 playing;
120 UINT8 outslot;
121 SINT32 op1fb; // operator1 feedback
122 SINT32 *connect1; // operator1 connect
123 SINT32 *connect3; // operator3 connect
124 SINT32 *connect2; // operator2 connect
125 SINT32 *connect4; // operator4 connect
126 UINT32 keynote[4]; // key note // ver0.27
127
128 UINT8 keyfunc[4]; // key function
129 UINT8 kcode[4]; // key code
130 UINT8 pan; // pan
131 UINT8 extop; // extendopelator-enable
132 UINT8 stereo; // stereo-enable
133 UINT8 padding2;
134 } OPNCH;
135
136 typedef struct {
137 UINT playchannels;
138 UINT playing;
139 SINT32 feedback2;
140 SINT32 feedback3;
141 SINT32 feedback4;
142 SINT32 outdl;
143 SINT32 outdc;
144 SINT32 outdr;
145 SINT32 calcremain;
146 UINT8 keyreg[OPNCH_MAX];
147 } _OPNGEN, *OPNGEN;
148
149 typedef struct {
150 SINT32 calc1024;
151 SINT32 fmvol;
152 UINT ratebit;
153 UINT vr_en;
154 SINT32 vr_l;
155 SINT32 vr_r;
156
157 SINT32 sintable[SIN_ENT];
158 SINT32 envtable[EVC_ENT];
159 SINT32 envcurve[EVC_ENT*2 + 1];
160 } OPNCFG;
161
162
163 #ifdef __cplusplus
164 extern "C" {
165 #endif
166
167 void opngen_initialize(UINT rate);
168 void opngen_setvol(UINT vol);
169 void opngen_setVR(REG8 channel, REG8 value);
170
171 void opngen_reset(void);
172 void opngen_setcfg(REG8 maxch, UINT32 flag);
173 void opngen_setextch(UINT chnum, REG8 data);
174 void opngen_setreg(REG8 chbase, UINT reg, REG8 value);
175 void opngen_keyon(UINT chnum, REG8 value);
176
177 void SOUNDCALL opngen_getpcm(void *hdl, SINT32 *pcm, UINT count);
178 void SOUNDCALL opngen_getpcmvr(void *hdl, SINT32 *pcm, UINT count);
179
180 #ifdef __cplusplus
181 }
182 #endif
183