Debian Codegraph @

src/engine/platform/vera.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 _VERA_H
21 #define _VERA_H
22
23 #include "../dispatch.h"
24 #include "../instrument.h"
25
26 struct VERA_PSG;
27 struct VERA_PCM;
28
29 class DivPlatformVERA: public DivDispatch {
30 protected:
31 struct Channel: public SharedChannel<int> {
32 unsigned char pan;
33 unsigned int accum;
34 int noiseval;
35
36 struct PCMChannel {
37 int sample;
38 unsigned int pos;
39 unsigned int len;
40 unsigned char freq;
41 bool depth16, setPos;
42 PCMChannel(): sample(-1), pos(0), len(0), freq(0), depth16(false), setPos(false) {}
43 } pcm;
44 Channel():
45 SharedChannel<int>(0),
46 pan(0),
47 accum(0),
48 noiseval(0),
49 pcm(PCMChannel()) {}
50 };
51 Channel chan[17];
52 DivDispatchOscBuffer* oscBuf[17];
53 bool isMuted[17];
54 unsigned char regPool[69];
55 struct VERA_PSG* psg;
56 struct VERA_PCM* pcm;
57 int lastCenterRate;
58
59 int calcNoteFreq(int ch, int note);
60 friend void putDispatchChip(void*,int);
61 friend void putDispatchChan(void*,int,int);
62
63 public:
64 void acquire(short** buf, size_t len);
65 int dispatch(DivCommand c);
66 void* getChanState(int chan);
67 DivMacroInt* getChanMacroInt(int ch);
68 unsigned short getPan(int chan);
69 DivDispatchOscBuffer* getOscBuffer(int chan);
70 unsigned char* getRegisterPool();
71 int getRegisterPoolSize();
72 void reset();
73 void tick(bool sysTick=true);
74 void muteChannel(int ch, bool mute);
75 void setFlags(const DivConfig& flags);
76 bool getLegacyAlwaysSetVolume();
77 void notifyInsDeletion(void* ins);
78 float getPostAmp();
79 int getOutputCount();
80 void poke(unsigned int addr, unsigned short val);
81 void poke(std::vector<DivRegWrite>& wlist);
82 const char** getRegisterSheet();
83 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
84 void quit();
85 ~DivPlatformVERA();
86 };
87 #endif