Debian Codegraph @

src/engine/platform/supervision.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 _SUPERVISION_H
21 #define _SUPERVISION_H
22
23 #include "../dispatch.h"
24 #include "../../fixedQueue.h"
25 #include "sound/supervision.h"
26
27 class DivPlatformSupervision: public DivDispatch {
28 struct Channel: public SharedChannel<signed char> {
29 unsigned int duty, len, pan, pcm; // pcm is channel 3 ONLY
30 int sample, hasOffset; // again, for channel 3 ONLY
31 bool setPos, kon, initWrite;
32 Channel():
33 SharedChannel<signed char>(63),
34 duty(0),
35 len(0x1f),
36 pan(3),
37 pcm(false),
38 hasOffset(0),
39 setPos(false),
40 kon(false),
41 initWrite(true) {}
42 };
43 Channel chan[4];
44 DivDispatchOscBuffer* oscBuf[4];
45 bool isMuted[4];
46 struct QueuedWrite {
47 unsigned char addr;
48 unsigned char val;
49 QueuedWrite(): addr(0), val(9) {}
50 QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
51 };
52 FixedQueue<QueuedWrite,512> writes;
53
54 int curChan;
55 int tempL[32];
56 int tempR[32];
57 int coreQuality;
58 unsigned char regPool[64];
59 unsigned int* sampleOff;
60 unsigned int* sampleLen;
61 bool* sampleLoaded;
62 DivMemoryComposition memCompo;
63 unsigned char* sampleMem;
64 size_t sampleMemLen;
65 unsigned char dutySwap;
66 unsigned char otherFlags;
67 unsigned int sampleOffset;
68 unsigned char noiseReg[3];
69 struct svision_t svision;
70
71 friend void putDispatchChip(void*,int);
72 friend void putDispatchChan(void*,int,int);
73 public:
74 void acquire(short** buf, size_t len);
75 int dispatch(DivCommand c);
76 void* getChanState(int chan);
77 DivMacroInt* getChanMacroInt(int ch);
78 DivDispatchOscBuffer* getOscBuffer(int chan);
79 unsigned char* getRegisterPool();
80 int getRegisterPoolSize();
81 void reset();
82 void forceIns();
83 void tick(bool sysTick=true);
84 void muteChannel(int ch, bool mute);
85 int getOutputCount();
86 bool keyOffAffectsArp(int ch);
87 void setFlags(const DivConfig& flags);
88 void notifyInsDeletion(void* ins);
89 void poke(unsigned int addr, unsigned short val);
90 void poke(std::vector<DivRegWrite>& wlist);
91 const char** getRegisterSheet();
92 const void* getSampleMem(int index);
93 size_t getSampleMemCapacity(int index);
94 size_t getSampleMemUsage(int index);
95 bool isSampleLoaded(int index, int sample);
96 const DivMemoryComposition* getMemCompo(int index);
97 void renderSamples(int chipID);
98 bool getDCOffRequired();
99 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
100 void quit();
101 DivPlatformSupervision();
102 ~DivPlatformSupervision();
103 };
104
105 #endif