Debian Codegraph @

src/engine/platform/sound/c64/extfilt.cc

raw
1 // ---------------------------------------------------------------------------
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 __EXTFILT_CC__
21 #include "extfilt.h"
22
23
24 // ----------------------------------------------------------------------------
25 // Constructor.
26 // ----------------------------------------------------------------------------
27 ExternalFilter::ExternalFilter()
28 {
29 reset();
30 enable_filter(true);
31 set_chip_model(MOS6581);
32
33 // Low-pass: R = 10kOhm, C = 1000pF; w0l = 1/RC = 1/(1e4*1e-9) = 100000
34 // High-pass: R = 1kOhm, C = 10uF; w0h = 1/RC = 1/(1e3*1e-5) = 100
35 // Multiply with 1.048576 to facilitate division by 1 000 000 by right-
36 // shifting 20 times (2 ^ 20 = 1048576).
37
38 w0lp = 104858;
39 w0hp = 105;
40 }
41
42
43 // ----------------------------------------------------------------------------
44 // Enable filter.
45 // ----------------------------------------------------------------------------
46 void ExternalFilter::enable_filter(bool enable)
47 {
48 enabled = enable;
49 }
50
51
52 // ----------------------------------------------------------------------------
53 // Set chip model.
54 // ----------------------------------------------------------------------------
55 void ExternalFilter::set_chip_model(chip_model model)
56 {
57 if (model == MOS6581) {
58 // Maximum mixer DC output level; to be removed if the external
59 // filter is turned off: ((wave DC + voice DC)*voices + mixer DC)*volume
60 // See voice.cc and filter.cc for an explanation of the values.
61 mixer_DC = ((((0x800 - 0x380) + 0x800)*0xff*3 - 0xfff*0xff/18) >> 7)*0x0f;
62 }
63 else {
64 // No DC offsets in the MOS8580.
65 mixer_DC = 0;
66 }
67 }
68
69
70 // ----------------------------------------------------------------------------
71 // SID reset.
72 // ----------------------------------------------------------------------------
73 void ExternalFilter::reset()
74 {
75 // State of filter.
76 Vlp = 0;
77 Vhp = 0;
78 Vo = 0;
79 }