Debian Codegraph @

mednafen/wswan/sound.c

raw symbols SCIP
1 /* Mednafen - Multi-system Emulator
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18 #include <string.h>
19 #include <stdlib.h>
20
21 #include "wswan.h"cxx . . $ `<file>/mednafen/wswan/wswan.h`/
22 #include "sound.h"cxx . . $ `<file>/mednafen/wswan/sound.h`/
23 #include "v30mz.h"cxx . . $ `<file>/mednafen/wswan/v30mz.h`/
24 #include "wswan-memory.h"cxx . . $ `<file>/mednafen/wswan/wswan-memory.h`/
25 #include "../state_inline.h"cxx . . $ `<file>/mednafen/state_inline.h`/
26
27 #include "../include/blip/Blip_Buffer.h"cxx . . $ `<file>/mednafen/include/blip/Blip_Buffer.h`/
28
29 static Blip_Synthcxx . . $ Blip_Synth# WaveSynthcxx . . $ WaveSynth.;
30
31 static Blip_Buffercxx . . $ Blip_Buffer# sbufcxx . . $ sbuf.[2];
32
33 static uint16cxx . . $ uint16# periodcxx . . $ period.[4];
34 static uint8cxx . . $ uint8# volumecxx . . $ volume.[4]; /* left volume in upper 4 bits, right in lower 4 bits */
35 static uint8cxx . . $ uint8# voice_volumecxx . . $ voice_volume.;
36
37 static uint8cxx . . $ uint8# sweep_stepcxx . . $ sweep_step., sweep_valuecxx . . $ sweep_value.;
38 static uint8cxx . . $ uint8# noise_controlcxx . . $ noise_control.;
39 static uint8cxx . . $ uint8# controlcxx . . $ control.;
40 static uint8cxx . . $ uint8# output_controlcxx . . $ output_control.;
41
42 static int32cxx . . $ int32# sweep_8192_dividercxx . . $ sweep_8192_divider.;
43 static uint8cxx . . $ uint8# sweep_countercxx . . $ sweep_counter.;
44 static uint8cxx . . $ uint8# SampleRAMPoscxx . . $ SampleRAMPos.;
45
46 static int32cxx . . $ int32# sample_cachecxx . . $ sample_cache.[4][2];
47
48 static int32cxx . . $ int32# last_v_valcxx . . $ last_v_val.;
49
50 static uint8cxx . . $ uint8# HyperVoicecxx . . $ HyperVoice.;
51 static int32cxx . . $ int32# last_hv_valcxx . . $ last_hv_val.[2];
52 static uint8cxx . . $ uint8# HVoiceCtrlcxx . . $ HVoiceCtrl., HVoiceChanCtrlcxx . . $ HVoiceChanCtrl.;
53
54 static int32cxx . . $ int32# period_countercxx . . $ period_counter.[4];
55 static int32cxx . . $ int32# last_valcxx . . $ last_val.[4][2]; /* Last outputted value, l&r */
56 static uint8cxx . . $ uint8# sample_poscxx . . $ sample_pos.[4];
57 static uint16cxx . . $ uint16# nregcxx . . $ nreg.;
58 static uint32cxx . . $ uint32# last_tscxx . . $ last_ts.;
59
60
61 #define MK_SAMPLE_CACHEcxx . . $ `mednafen/wswan/sound.c:61:9`! \
62 { \
63 int sample = (((wsRAM[((SampleRAMPos << 6) + (sample_pos[ch] >> 1) + (ch << 4)) ] >> ((sample_pos[ch] & 1) ? 4 : 0)) & 0x0F)); \
64 sample_cache[ch][0] = sample * ((volume[ch] >> 4) & 0x0F); \
65 sample_cache[ch][1] = sample * ((volume[ch] >> 0) & 0x0F); \
66 }
67
68 #define MK_SAMPLE_CACHE_NOISEcxx . . $ `mednafen/wswan/sound.c:68:9`! \
69 { \
70 int sample = ((nreg & 1) ? 0xF : 0x0); \
71 sample_cache[ch][0] = sample * ((volume[ch] >> 4) & 0x0F); \
72 sample_cache[ch][1] = sample * ((volume[ch] >> 0) & 0x0F); \
73 }
74
75 #define MK_SAMPLE_CACHE_VOICEcxx . . $ `mednafen/wswan/sound.c:75:9`! \
76 { \
77 int sample = volume[ch]; \
78 int half = sample >> 1; \
79 sample_cache[ch][0] = (voice_volume & 4) ? sample : (voice_volume & 8) ? half : 0; \
80 sample_cache[ch][1] = (voice_volume & 1) ? sample : (voice_volume & 2) ? half : 0; \
81 }
82
83 #define SYNCSAMPLEcxx . . $ `mednafen/wswan/sound.c:83:9`!(wt) \
84 { \
85 int32 left = sample_cache[ch][0], right = sample_cache[ch][1]; \
86 Blip_Synth_offset(&WaveSynth, wt, left - last_val[ch][0], &sbuf[0]); \
87 Blip_Synth_offset(&WaveSynth, wt, right - last_val[ch][1], &sbuf[1]); \
88 last_val[ch][0] = left; \
89 last_val[ch][1] = right; \
90 }
91
92 #define SYNCSAMPLE_NOISEcxx . . $ `mednafen/wswan/sound.c:92:9`!(wt) SYNCSAMPLEcxx . . $ `mednafen/wswan/sound.c:83:9`!(wt)
93
94 void WSwan_SoundUpdatecxx . . $ WSwan_SoundUpdate(49f6e7a06ebc5aa8).(void)
95 {
96 unsigned int ch;
97 int32cxx . . $ int32# run_time = v30mz_timestampcxx . . $ v30mz_timestamp. - last_tscxx . . $ last_ts.;
98
99 for(ch = 0; ch < 4; ch++)
100 {
101 /* Channel is disabled? */
102 if(!(controlcxx . . $ control. & (1 << ch)))
103 continue;
104
105 if(ch == 1 && (controlcxx . . $ control. & 0x20)) /* Direct D/A mode? */
106 {
107 MK_SAMPLE_CACHE_VOICEcxx . . $ `mednafen/wswan/sound.c:75:9`!;
108 SYNCSAMPLEcxx . . $ `mednafen/wswan/sound.c:83:9`!(v30mz_timestamp);
109 }
110 else if(ch == 2 && (controlcxx . . $ control. & 0x40) && sweep_valuecxx . . $ sweep_value.) /* Sweep */
111 {
112 uint32cxx . . $ uint32# tmp_pt = 2048 - periodcxx . . $ period.[ch];
113 uint32cxx . . $ uint32# meow_timestamp = v30mz_timestampcxx . . $ v30mz_timestamp. - run_time;
114 uint32cxx . . $ uint32# tmp_run_time = run_time;
115
116 while(tmp_run_time)
117 {
118 int32cxx . . $ int32# sub_run_time = tmp_run_time;
119
120 if(sub_run_time > sweep_8192_dividercxx . . $ sweep_8192_divider.)
121 sub_run_time = sweep_8192_dividercxx . . $ sweep_8192_divider.;
122
123 sweep_8192_dividercxx . . $ sweep_8192_divider. -= sub_run_time;
124 if(sweep_8192_dividercxx . . $ sweep_8192_divider. <= 0)
125 {
126 sweep_8192_dividercxx . . $ sweep_8192_divider. += 8192;
127 sweep_countercxx . . $ sweep_counter.--;
128 if(sweep_countercxx . . $ sweep_counter. <= 0)
129 {
130 sweep_countercxx . . $ sweep_counter. = sweep_stepcxx . . $ sweep_step. + 1;
131 periodcxx . . $ period.[ch] = (periodcxx . . $ period.[ch] + (int8cxx . . $ int8#)sweep_valuecxx . . $ sweep_value.) & 0x7FF;
132 }
133 }
134
135 meow_timestamp += sub_run_time;
136 if(tmp_pt > 4)
137 {
138 period_countercxx . . $ period_counter.[ch] -= sub_run_time;
139 while(period_countercxx . . $ period_counter.[ch] <= 0)
140 {
141 sample_poscxx . . $ sample_pos.[ch] = (sample_poscxx . . $ sample_pos.[ch] + 1) & 0x1F;
142
143 MK_SAMPLE_CACHEcxx . . $ `mednafen/wswan/sound.c:61:9`!;
144 SYNCSAMPLEcxx . . $ `mednafen/wswan/sound.c:83:9`!(meow_timestamp + period_counter[ch]);
145 period_countercxx . . $ period_counter.[ch] += tmp_pt;
146 }
147 }
148 tmp_run_time -= sub_run_time;
149 }
150 }
151 else if(ch == 3 && (controlcxx . . $ control. & 0x80) && (noise_controlcxx . . $ noise_control. & 0x10)) /* Noise */
152 {
153 uint32cxx . . $ uint32# tmp_pt = 2048 - periodcxx . . $ period.[ch];
154
155 period_countercxx . . $ period_counter.[ch] -= run_time;
156 while(period_countercxx . . $ period_counter.[ch] <= 0)
157 {
158 static const uint8cxx . . $ uint8# stab[8] = { 14, 10, 13, 4, 8, 6, 9, 11 };
159
160 nregcxx . . $ nreg. = ((nregcxx . . $ nreg. << 1) | ((1 ^ (nregcxx . . $ nreg. >> 7) ^ (nregcxx . . $ nreg. >> stab[noise_controlcxx . . $ noise_control. & 0x7])) & 1)) & 0x7FFF;
161
162 if(controlcxx . . $ control. & 0x80)
163 {
164 MK_SAMPLE_CACHE_NOISEcxx . . $ `mednafen/wswan/sound.c:68:9`!;
165 SYNCSAMPLE_NOISEcxx . . $ `mednafen/wswan/sound.c:92:9`!(v30mz_timestamp + period_counter[ch]);
166 }
167 else if(tmp_pt > 4)
168 {
169 sample_poscxx . . $ sample_pos.[ch] = (sample_poscxx . . $ sample_pos.[ch] + 1) & 0x1F;
170 MK_SAMPLE_CACHEcxx . . $ `mednafen/wswan/sound.c:61:9`!;
171 SYNCSAMPLEcxx . . $ `mednafen/wswan/sound.c:83:9`!(v30mz_timestamp + period_counter[ch]);
172 }
173 period_countercxx . . $ period_counter.[ch] += tmp_pt;
174 }
175 }
176 else
177 {
178 uint32cxx . . $ uint32# tmp_pt = 2048 - periodcxx . . $ period.[ch];
179
180 if(tmp_pt > 4)
181 {
182 period_countercxx . . $ period_counter.[ch] -= run_time;
183 while(period_countercxx . . $ period_counter.[ch] <= 0)
184 {
185 sample_poscxx . . $ sample_pos.[ch] = (sample_poscxx . . $ sample_pos.[ch] + 1) & 0x1F;
186
187 MK_SAMPLE_CACHEcxx . . $ `mednafen/wswan/sound.c:61:9`!;
188 SYNCSAMPLEcxx . . $ `mednafen/wswan/sound.c:83:9`!(v30mz_timestamp + period_counter[ch]);
189 period_countercxx . . $ period_counter.[ch] += tmp_pt;
190 }
191 }
192 }
193 }
194
195 if(HVoiceCtrlcxx . . $ HVoiceCtrl. & 0x80)
196 {
197 int32cxx . . $ int32# left, right;
198 int16cxx . . $ int16# sample = (uint8cxx . . $ uint8#)HyperVoicecxx . . $ HyperVoice.;
199
200 switch(HVoiceCtrlcxx . . $ HVoiceCtrl. & 0xC)
201 {
202 case 0x0: sample = (uint16cxx . . $ uint16#)sample << (8 - (HVoiceCtrlcxx . . $ HVoiceCtrl. & 3)); break;
203 case 0x4: sample = (uint16cxx . . $ uint16#)(sample | -0x100) << (8 - (HVoiceCtrlcxx . . $ HVoiceCtrl. & 3)); break;
204 case 0x8: sample = (uint16cxx . . $ uint16#)((int8cxx . . $ int8#)sample) << (8 - (HVoiceCtrlcxx . . $ HVoiceCtrl. & 3)); break;
205 case 0xC: sample = (uint16cxx . . $ uint16#)sample << 8; break;
206 }
207 /* bring back to 11bit, keeping signedness */
208 sample >>= 5;
209
210 left = (HVoiceChanCtrlcxx . . $ HVoiceChanCtrl. & 0x40) ? sample : 0;
211 right = (HVoiceChanCtrlcxx . . $ HVoiceChanCtrl. & 0x20) ? sample : 0;
212
213 Blip_Synth_offsetcxx . . $ Blip_Synth_offset(274adf3324c166ac).(&WaveSynthcxx . . $ WaveSynth., v30mz_timestampcxx . . $ v30mz_timestamp., left - last_hv_valcxx . . $ last_hv_val.[0], &sbufcxx . . $ sbuf.[0]);
214 Blip_Synth_offsetcxx . . $ Blip_Synth_offset(274adf3324c166ac).(&WaveSynthcxx . . $ WaveSynth., v30mz_timestampcxx . . $ v30mz_timestamp., right - last_hv_valcxx . . $ last_hv_val.[0], &sbufcxx . . $ sbuf.[1]);
215 last_hv_valcxx . . $ last_hv_val.[0] = left;
216 last_hv_valcxx . . $ last_hv_val.[1] = right;
217 }
218 last_tscxx . . $ last_ts. = v30mz_timestampcxx . . $ v30mz_timestamp.;
219 }
220
221 void WSwan_SoundWritecxx . . $ WSwan_SoundWrite(cc289a6b3dfc48da).(uint32cxx . . $ uint32# A, uint8cxx . . $ uint8# V)
222 {
223 WSwan_SoundUpdatecxx . . $ WSwan_SoundUpdate(49f6e7a06ebc5aa8).();
224
225 if(A >= 0x80 && A <= 0x87)
226 {
227 int ch = (A - 0x80) >> 1;
228
229 if(A & 1)
230 periodcxx . . $ period.[ch] = (periodcxx . . $ period.[ch] & 0x00FF) | ((V & 0x07) << 8);
231 else
232 periodcxx . . $ period.[ch] = (periodcxx . . $ period.[ch] & 0x0700) | ((V & 0xFF) << 0);
233 }
234 else if(A >= 0x88 && A <= 0x8B)
235 volumecxx . . $ volume.[A - 0x88] = V;
236 else if(A == 0x8C)
237 sweep_valuecxx . . $ sweep_value. = V;
238 else if(A == 0x8D)
239 {
240 sweep_stepcxx . . $ sweep_step. = V;
241 sweep_countercxx . . $ sweep_counter. = sweep_stepcxx . . $ sweep_step. + 1;
242 sweep_8192_dividercxx . . $ sweep_8192_divider. = 8192;
243 }
244 else if(A == 0x8E)
245 {
246 if(V & 0x8)
247 nregcxx . . $ nreg. = 0;
248
249 noise_controlcxx . . $ noise_control. = V & 0x17;
250 }
251 else if(A == 0x90)
252 {
253 int n;
254 for(n = 0; n < 4; n++)
255 {
256 if(!(controlcxx . . $ control. & (1 << n)) && (V & (1 << n)))
257 {
258 period_countercxx . . $ period_counter.[n] = 1;
259 sample_poscxx . . $ sample_pos.[n] = 0x1F;
260 }
261 }
262 controlcxx . . $ control. = V;
263 }
264 else if(A == 0x91)
265 output_controlcxx . . $ output_control. = V & 0xF;
266 else if(A == 0x92)
267 nregcxx . . $ nreg. = (nregcxx . . $ nreg. & 0xFF00) | (V << 0);
268 else if(A == 0x93)
269 nregcxx . . $ nreg. = (nregcxx . . $ nreg. & 0x00FF) | ((V & 0x7F) << 8);
270 else if(A == 0x94)
271 voice_volumecxx . . $ voice_volume. = V & 0xF;
272 else switch(A)
273 {
274 case 0x6A: HVoiceCtrlcxx . . $ HVoiceCtrl. = V; break;
275 case 0x6B: HVoiceChanCtrlcxx . . $ HVoiceChanCtrl. = V & 0x6F; break;
276 case 0x8F: SampleRAMPoscxx . . $ SampleRAMPos. = V; break;
277 case 0x95: HyperVoicecxx . . $ HyperVoice. = V; break; /* Pick a port, any port?! */
278 }
279 WSwan_SoundUpdatecxx . . $ WSwan_SoundUpdate(49f6e7a06ebc5aa8).();
280 }
281
282 uint8cxx . . $ uint8# WSwan_SoundReadcxx . . $ WSwan_SoundRead(32407b39b2dfce37).(uint32cxx . . $ uint32# A)
283 {
284 WSwan_SoundUpdatecxx . . $ WSwan_SoundUpdate(49f6e7a06ebc5aa8).();
285
286 if(A >= 0x80 && A <= 0x87)
287 {
288 int ch = (A - 0x80) >> 1;
289
290 if(A & 1)
291 return(periodcxx . . $ period.[ch] >> 8);
292 return(periodcxx . . $ period.[ch]);
293 }
294 else if(A >= 0x88 && A <= 0x8B)
295 return(volumecxx . . $ volume.[A - 0x88]);
296 else switch(A)
297 {
298 case 0x6A: return(HVoiceCtrlcxx . . $ HVoiceCtrl.);
299 case 0x6B: return(HVoiceChanCtrlcxx . . $ HVoiceChanCtrl.);
300 case 0x8C: return(sweep_valuecxx . . $ sweep_value.);
301 case 0x8D: return(sweep_stepcxx . . $ sweep_step.);
302 case 0x8E: return(noise_controlcxx . . $ noise_control.);
303 case 0x8F: return(SampleRAMPoscxx . . $ SampleRAMPos.);
304 case 0x90: return(controlcxx . . $ control.);
305 case 0x91: return(output_controlcxx . . $ output_control. | 0x80);
306 case 0x92: return((nregcxx . . $ nreg. >> 0) & 0xFF);
307 case 0x93: return((nregcxx . . $ nreg. >> 8) & 0xFF);
308 case 0x94: return(voice_volumecxx . . $ voice_volume.);
309 default:
310 break;
311 }
312
313 return 0;
314 }
315
316 int32cxx . . $ int32# WSwan_SoundFlushcxx . . $ WSwan_SoundFlush(33dfaf4ca3af819f).(int16cxx . . $ int16# **SoundBuf, int32cxx . . $ int32# *SoundBufSize)
317 {
318 int32cxx . . $ int32# RequiredSize = 0;
319 int32cxx . . $ int32# FrameCount = 0;
320
321 WSwan_SoundUpdatecxx . . $ WSwan_SoundUpdate(49f6e7a06ebc5aa8).();
322
323 Blip_Buffer_end_framecxx . . $ Blip_Buffer_end_frame(f1fd343ab937da1b).(&sbufcxx . . $ sbuf.[0], v30mz_timestampcxx . . $ v30mz_timestamp.);
324 Blip_Buffer_end_framecxx . . $ Blip_Buffer_end_frame(f1fd343ab937da1b).(&sbufcxx . . $ sbuf.[1], v30mz_timestampcxx . . $ v30mz_timestamp.);
325
326 RequiredSize = Blip_Buffer_samples_availcxx . . $ Blip_Buffer_samples_avail(834ca95a49b29351).(&sbufcxx . . $ sbuf.[0]) << 1;
327 RequiredSize = (RequiredSize + 1) & ~1;
328
329 if (SoundBuf && *SoundBuf)
330 {
331 /* Check if sound buffer needs to be resized */
332 if (*SoundBufSize < RequiredSize)
333 {
334 int16cxx . . $ int16# *newBuf = (int16cxx . . $ int16#*)realloccxx . . $ realloc(417ab160f6baadc6).(*SoundBuf,
335 RequiredSize * sizeof(int16cxx . . $ int16#));
336
337 if (newBuf)
338 {
339 *SoundBuf = newBuf;
340 *SoundBufSize = RequiredSize;
341 }
342 }
343
344 FrameCount = Blip_Buffer_read_samplescxx . . $ Blip_Buffer_read_samples(3914bcd8cd4abe38).(&sbufcxx . . $ sbuf.[0], *SoundBuf , *SoundBufSize);
345 FrameCount = Blip_Buffer_read_samplescxx . . $ Blip_Buffer_read_samples(3914bcd8cd4abe38).(&sbufcxx . . $ sbuf.[1], *SoundBuf + 1, *SoundBufSize);
346 }
347
348 last_tscxx . . $ last_ts. = 0;
349
350 return(FrameCount);
351 }
352
353 /* Call before wsRAM is updated */
354 void WSwan_SoundCheckRAMWritecxx . . $ WSwan_SoundCheckRAMWrite(cb2f890c2fdad230).(uint32cxx . . $ uint32# A)
355 {
356 if((A >> 6) == SampleRAMPoscxx . . $ SampleRAMPos.)
357 WSwan_SoundUpdatecxx . . $ WSwan_SoundUpdate(49f6e7a06ebc5aa8).();
358 }
359
360 static void RedoVolumecxx . . $ RedoVolume(49f6e7a06ebc5aa8).(void)
361 {
362 double eff_volume = 1.0 / 4;
363
364 Blip_Synth_set_volumecxx . . $ Blip_Synth_set_volume(77258eebb41af760).(&WaveSynthcxx . . $ WaveSynth., eff_volume, 256);
365 }
366
367 void WSwan_SoundInitcxx . . $ WSwan_SoundInit(49f6e7a06ebc5aa8).(void)
368 {
369 unsigned i;
370 for(i = 0; i < 2; i++)
371 {
372 Blip_Buffer_initcxx . . $ Blip_Buffer_init(e49e6e859576dfef).(&sbufcxx . . $ sbuf.[i]);
373 Blip_Buffer_set_sample_ratecxx . . $ Blip_Buffer_set_sample_rate(33010d6d4f65ccd3).(&sbufcxx . . $ sbuf.[i], 44100, 60);
374 Blip_Buffer_set_clock_ratecxx . . $ Blip_Buffer_set_clock_rate(d1345b21825f9f3a).(&sbufcxx . . $ sbuf.[i], (long)(3072000));
375 Blip_Buffer_bass_freqcxx . . $ Blip_Buffer_bass_freq(f1fd343ab937da1b).(&sbufcxx . . $ sbuf.[i], 20);
376 }
377
378 RedoVolumecxx . . $ RedoVolume(49f6e7a06ebc5aa8).();
379 }
380
381 void WSwan_SoundKillcxx . . $ WSwan_SoundKill(49f6e7a06ebc5aa8).(void)
382 {
383 int i;
384 for(i = 0; i < 2; i++)
385 {
386 Blip_Buffer_deinitcxx . . $ Blip_Buffer_deinit(e49e6e859576dfef).(&sbufcxx . . $ sbuf.[i]);
387 }
388 }
389
390 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! WSwan_SetSoundRatecxx . . $ WSwan_SetSoundRate(dfa6e707f7696010).(uint32cxx . . $ uint32# rate)
391 {
392 unsigned i;
393 for(i = 0; i < 2; i++)
394 Blip_Buffer_set_sample_ratecxx . . $ Blip_Buffer_set_sample_rate(33010d6d4f65ccd3).(&sbufcxx . . $ sbuf.[i], rate ? rate : 44100, 60);
395
396 return(truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
397 }
398
399 int WSwan_SoundStateActioncxx . . $ WSwan_SoundStateAction(a45b884b8cf568d5).(StateMemcxx . . $ StateMem# *sm, int load, int data_only)
400 {
401 SFORMATcxx . . $ SFORMAT# StateRegs[] =
402 {
403 SFARRAY16cxx . . $ `mednafen/state_inline.h:12:9`!(period, 4),
404 SFARRAYcxx . . $ `mednafen/state_inline.h:9:9`!(volume, 4),
405 SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(voice_volume),
406 SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(sweep_step),
407 SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(sweep_value),
408 SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(noise_control),
409 SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(control),
410 SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(output_control),
411 SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(HVoiceCtrl),
412 SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(HVoiceChanCtrl),
413
414 SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(sweep_8192_divider),
415 SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(sweep_counter),
416 SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(SampleRAMPos),
417 SFARRAY32cxx . . $ `mednafen/state_inline.h:15:9`!(period_counter, 4),
418 SFARRAYcxx . . $ `mednafen/state_inline.h:9:9`!(sample_pos, 4),
419 SFVARcxx . . $ `mednafen/state_inline.h:6:9`!(nreg),
420 SFENDcxx . . $ `mednafen/state_inline.h:20:9`!
421 };
422
423 if(!MDFNSS_StateActioncxx . . $ MDFNSS_StateAction(3f628545d3b0df83).(sm, load, data_only, StateRegs, "PSG", falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!))
424 return 0;
425
426 if(load)
427 {
428 unsigned ch;
429 if(sweep_8192_dividercxx . . $ sweep_8192_divider. < 1)
430 sweep_8192_dividercxx . . $ sweep_8192_divider. = 1;
431
432 for(ch = 0; ch < 4; ch++)
433 {
434 periodcxx . . $ period.[ch] &= 0x7FF;
435
436 if(period_countercxx . . $ period_counter.[ch] < 1)
437 period_countercxx . . $ period_counter.[ch] = 1;
438
439 sample_poscxx . . $ sample_pos.[ch] &= 0x1F;
440 }
441 }
442
443 return 1;
444 }
445
446 void WSwan_SoundResetcxx . . $ WSwan_SoundReset(49f6e7a06ebc5aa8).(void)
447 {
448 unsigned y,ch;
449
450 memsetcxx . . $ memset(d1de1e4fb215f1c6).(periodcxx . . $ period., 0, sizeof(periodcxx . . $ period.));
451 memsetcxx . . $ memset(d1de1e4fb215f1c6).(volumecxx . . $ volume., 0, sizeof(volumecxx . . $ volume.));
452 voice_volumecxx . . $ voice_volume. = 0;
453 sweep_stepcxx . . $ sweep_step. = 0;
454 sweep_valuecxx . . $ sweep_value. = 0;
455 noise_controlcxx . . $ noise_control. = 0;
456 controlcxx . . $ control. = 0;
457 output_controlcxx . . $ output_control. = 0;
458
459 sweep_8192_dividercxx . . $ sweep_8192_divider. = 8192;
460 sweep_countercxx . . $ sweep_counter. = 0;
461 SampleRAMPoscxx . . $ SampleRAMPos. = 0;
462
463 for(ch = 0; ch < 4; ch++)
464 period_countercxx . . $ period_counter.[ch] = 1;
465
466 memsetcxx . . $ memset(d1de1e4fb215f1c6).(sample_poscxx . . $ sample_pos., 0, sizeof(sample_poscxx . . $ sample_pos.));
467 nregcxx . . $ nreg. = 0;
468
469 memsetcxx . . $ memset(d1de1e4fb215f1c6).(sample_cachecxx . . $ sample_cache., 0, sizeof(sample_cachecxx . . $ sample_cache.));
470 memsetcxx . . $ memset(d1de1e4fb215f1c6).(last_valcxx . . $ last_val., 0, sizeof(last_valcxx . . $ last_val.));
471 last_v_valcxx . . $ last_v_val. = 0;
472
473 HyperVoicecxx . . $ HyperVoice. = 0;
474 last_hv_valcxx . . $ last_hv_val.[0] = last_hv_valcxx . . $ last_hv_val.[1] = 0;
475 HVoiceCtrlcxx . . $ HVoiceCtrl. = 0;
476 HVoiceChanCtrlcxx . . $ HVoiceChanCtrl. = 0;
477
478 for(y = 0; y < 2; y++)
479 Blip_Buffer_clearcxx . . $ Blip_Buffer_clear(f1fd343ab937da1b).(&sbufcxx . . $ sbuf.[y], 1);
480 }