Debian Codegraph @

src/engine/platform/sid2.h

raw
1 /**
2 * Furnace Tracker - multi-system chiptune tracker
3 * Copyright (C) 2021-2025 tildearrow and contributors
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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef _SID2_H
21 #define _SID2_H
22
23 #include "../dispatch.h"
24 #include "../../fixedQueue.h"
25 #include "sound/sid2/sid.h"
26
27 class DivPlatformSID2: public DivDispatch {
28 struct Channel: public SharedChannel<signed char> {
29 int prevFreq;
30 unsigned char wave, attack, decay, sustain, release;
31 short duty;
32 bool filter;
33 bool resetMask, resetFilter, resetDuty, gate, ring, sync, test;
34 unsigned char vol;
35 unsigned char filtControl, filtRes;
36 unsigned char noise_mode;
37 unsigned char mix_mode;
38 int filtCut;
39 short cutoff_slide;
40 short pw_slide;
41 Channel():
42 SharedChannel<signed char>(15),
43 prevFreq(0x1ffff),
44 wave(0),
45 attack(0),
46 decay(0),
47 sustain(0),
48 release(0),
49 duty(0),
50 filter(false),
51 resetMask(false),
52 resetFilter(false),
53 resetDuty(false),
54 gate(true),
55 ring(false),
56 sync(false),
57 test(false),
58 vol(15),
59 filtControl(0),
60 filtRes(0),
61 noise_mode(0),
62 mix_mode(0),
63 filtCut(0),
64 cutoff_slide(0),
65 pw_slide(0) {}
66 };
67 Channel chan[3];
68 DivDispatchOscBuffer* oscBuf[3];
69 bool isMuted[3];
70 float fakeLow[3];
71 float fakeBand[3];
72 float fakeCutTable[4096];
73 struct QueuedWrite {
74 unsigned char addr;
75 unsigned char val;
76 QueuedWrite(): addr(0), val(0) {}
77 QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
78 };
79 FixedQueue<QueuedWrite,128> writes;
80
81 unsigned char writeOscBuf;
82
83 bool keyPriority, needInitTables;
84 unsigned char chanOrder[3];
85 unsigned char testAD, testSR;
86
87 SID2* sid2;
88 unsigned char regPool[32];
89
90 friend void putDispatchChip(void*,int);
91 friend void putDispatchChan(void*,int,int);
92
93 void updateFilter(int channel);
94 public:
95 void acquire(short** buf, size_t len);
96 int dispatch(DivCommand c);
97 void* getChanState(int chan);
98 DivDispatchOscBuffer* getOscBuffer(int chan);
99 unsigned char* getRegisterPool();
100 int getRegisterPoolSize();
101 void reset();
102 void forceIns();
103 void tick(bool sysTick=true);
104 void muteChannel(int ch, bool mute);
105 void setFlags(const DivConfig& flags);
106 void notifyInsChange(int ins);
107 bool getDCOffRequired();
108 bool getWantPreNote();
109 bool isVolGlobal();
110 float getPostAmp();
111 DivMacroInt* getChanMacroInt(int ch);
112 void getPaired(int ch, std::vector<DivChannelPair>& ret);
113 DivChannelModeHints getModeHints(int chan);
114 void notifyInsDeletion(void* ins);
115 void poke(unsigned int addr, unsigned short val);
116 void poke(std::vector<DivRegWrite>& wlist);
117 const char** getRegisterSheet();
118 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
119 void setChipModel(bool is6581);
120 void setCore(unsigned char which);
121 void quit();
122 ~DivPlatformSID2();
123 };
124
125 #endif