Debian Codegraph @

src/resid/wave.cpp

raw symbols SCIP
1 // ---------------------------------------------------------------------------cxx . . $ `<file>/src/resid/wave.cpp`/
2 // This file is part of reSID, a MOS6581 SID emulator engine.
3 // Copyright (C) 2004 Dag Lem <[email protected]>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // ---------------------------------------------------------------------------
19
20 #define __WAVE_CC__cxx . . $ `src/resid/wave.cpp:20:9`!
21 #include "wave.h"cxx . . $ `<file>/src/resid/wave.h`/
22
23 // ----------------------------------------------------------------------------
24 // Constructor.
25 // ----------------------------------------------------------------------------
26 WaveformGeneratorcxx . . $ WaveformGenerator#::WaveformGeneratorcxx . . $ WaveformGenerator#WaveformGenerator(49f6e7a06ebc5aa8).()
27 {
28 sync_sourcecxx . . $ WaveformGenerator#sync_source. = this;
29
30 set_chip_modelcxx . . $ WaveformGenerator#set_chip_model(cea143c94d31b99f).(MOS6581cxx . . $ MOS6581.);
31
32 resetcxx . . $ WaveformGenerator#reset(49f6e7a06ebc5aa8).();
33 }
34
35
36 // ----------------------------------------------------------------------------
37 // Set sync source.
38 // ----------------------------------------------------------------------------
39 void WaveformGeneratorcxx . . $ WaveformGenerator#::set_sync_sourcecxx . . $ WaveformGenerator#set_sync_source(567819d4c5355d59).(WaveformGeneratorcxx . . $ WaveformGenerator#* source)
40 {
41 sync_sourcecxx . . $ WaveformGenerator#sync_source. = source;
42 source->sync_destcxx . . $ WaveformGenerator#sync_dest. = this;
43 }
44
45
46 // ----------------------------------------------------------------------------
47 // Set chip model.
48 // ----------------------------------------------------------------------------
49 void WaveformGeneratorcxx . . $ WaveformGenerator#::set_chip_modelcxx . . $ WaveformGenerator#set_chip_model(cea143c94d31b99f).(chip_modelcxx . . $ chip_model# model)
50 {
51 if (model == MOS6581cxx . . $ MOS6581.) {
52 wave__STcxx . . $ WaveformGenerator#wave__ST. = wave6581__STcxx . . $ WaveformGenerator#wave6581__ST.;
53 wave_P_Tcxx . . $ WaveformGenerator#wave_P_T. = wave6581_P_Tcxx . . $ WaveformGenerator#wave6581_P_T.;
54 wave_PS_cxx . . $ WaveformGenerator#wave_PS_. = wave6581_PS_cxx . . $ WaveformGenerator#wave6581_PS_.;
55 wave_PSTcxx . . $ WaveformGenerator#wave_PST. = wave6581_PSTcxx . . $ WaveformGenerator#wave6581_PST.;
56 }
57 else {
58 wave__STcxx . . $ WaveformGenerator#wave__ST. = wave8580__STcxx . . $ WaveformGenerator#wave8580__ST.;
59 wave_P_Tcxx . . $ WaveformGenerator#wave_P_T. = wave8580_P_Tcxx . . $ WaveformGenerator#wave8580_P_T.;
60 wave_PS_cxx . . $ WaveformGenerator#wave_PS_. = wave8580_PS_cxx . . $ WaveformGenerator#wave8580_PS_.;
61 wave_PSTcxx . . $ WaveformGenerator#wave_PST. = wave8580_PSTcxx . . $ WaveformGenerator#wave8580_PST.;
62 }
63 }
64
65
66 // ----------------------------------------------------------------------------
67 // Register functions.
68 // ----------------------------------------------------------------------------
69 void WaveformGeneratorcxx . . $ WaveformGenerator#::writeFREQ_LOcxx . . $ WaveformGenerator#writeFREQ_LO(cb2f890c2fdad230).(reg8cxx . . $ reg8# freq_lo)
70 {
71 freqcxx . . $ WaveformGenerator#freq. = freqcxx . . $ WaveformGenerator#freq. & 0xff00 | freq_lo & 0x00ff;
72 }
73
74 void WaveformGeneratorcxx . . $ WaveformGenerator#::writeFREQ_HIcxx . . $ WaveformGenerator#writeFREQ_HI(cb2f890c2fdad230).(reg8cxx . . $ reg8# freq_hi)
75 {
76 freqcxx . . $ WaveformGenerator#freq. = (freq_hi << 8) & 0xff00 | freqcxx . . $ WaveformGenerator#freq. & 0x00ff;
77 }
78
79 void WaveformGeneratorcxx . . $ WaveformGenerator#::writePW_LOcxx . . $ WaveformGenerator#writePW_LO(cb2f890c2fdad230).(reg8cxx . . $ reg8# pw_lo)
80 {
81 pwcxx . . $ WaveformGenerator#pw. = pwcxx . . $ WaveformGenerator#pw. & 0xf00 | pw_lo & 0x0ff;
82 }
83
84 void WaveformGeneratorcxx . . $ WaveformGenerator#::writePW_HIcxx . . $ WaveformGenerator#writePW_HI(cb2f890c2fdad230).(reg8cxx . . $ reg8# pw_hi)
85 {
86 pwcxx . . $ WaveformGenerator#pw. = (pw_hi << 8) & 0xf00 | pwcxx . . $ WaveformGenerator#pw. & 0x0ff;
87 }
88
89 void WaveformGeneratorcxx . . $ WaveformGenerator#::writeCONTROL_REGcxx . . $ WaveformGenerator#writeCONTROL_REG(cb2f890c2fdad230).(reg8cxx . . $ reg8# control)
90 {
91 waveformcxx . . $ WaveformGenerator#waveform. = (control >> 4) & 0x0f;
92 ring_modcxx . . $ WaveformGenerator#ring_mod. = control & 0x04;
93 synccxx . . $ WaveformGenerator#sync. = control & 0x02;
94
95 reg8cxx . . $ reg8# test_next = control & 0x08;
96
97 // Test bit set.
98 // The accumulator and the shift register are both cleared.
99 // NB! The shift register is not really cleared immediately. It seems like
100 // the individual bits in the shift register start to fade down towards
101 // zero when test is set. All bits reach zero within approximately
102 // $2000 - $4000 cycles.
103 // This is not modeled. There should fortunately be little audible output
104 // from this peculiar behavior.
105 if (test_next) {
106 accumulatorcxx . . $ WaveformGenerator#accumulator. = 0;
107 shift_registercxx . . $ WaveformGenerator#shift_register. = 0;
108 }
109 // Test bit cleared.
110 // The accumulator starts counting, and the shift register is reset to
111 // the value 0x7ffff8.
112 // NB! The shift register will not actually be set to this exact value if the
113 // shift register bits have not had time to fade to zero.
114 // This is not modeled.
115 else if (testcxx . . $ WaveformGenerator#test.) {
116 shift_registercxx . . $ WaveformGenerator#shift_register. = 0x7ffff8;
117 }
118
119 testcxx . . $ WaveformGenerator#test. = test_next;
120
121 // The gate bit is handled by the EnvelopeGenerator.
122 }
123
124 reg8cxx . . $ reg8# WaveformGeneratorcxx . . $ WaveformGenerator#::readOSCcxx . . $ WaveformGenerator#readOSC(db52760e79bf9054).()
125 {
126 return outputcxx . . $ WaveformGenerator#output(db52760e79bf9054).() >> 4;
127 }
128
129 // ----------------------------------------------------------------------------
130 // SID reset.
131 // ----------------------------------------------------------------------------
132 void WaveformGeneratorcxx . . $ WaveformGenerator#::resetcxx . . $ WaveformGenerator#reset(49f6e7a06ebc5aa8).()
133 {
134 accumulatorcxx . . $ WaveformGenerator#accumulator. = 0;
135 shift_registercxx . . $ WaveformGenerator#shift_register. = 0x7ffff8;
136 freqcxx . . $ WaveformGenerator#freq. = 0;
137 pwcxx . . $ WaveformGenerator#pw. = 0;
138
139 testcxx . . $ WaveformGenerator#test. = 0;
140 ring_modcxx . . $ WaveformGenerator#ring_mod. = 0;
141 synccxx . . $ WaveformGenerator#sync. = 0;
142
143 msb_risingcxx . . $ WaveformGenerator#msb_rising. = false;
144 }