Debian Codegraph @

src/engine/platform/c140.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 _C140_H
21 #define _C140_H
22
23 #include "../dispatch.h"
24 #include "sound/c140_c219.h"
25 #include "../../fixedQueue.h"
26
27 class DivPlatformC140: public DivDispatch {
28 struct Channel: public SharedChannel<int> {
29 unsigned int audPos;
30 int sample, wave;
31 bool setPos, invert, surround, noise, volChangedL, volChangedR, writeCtrl;
32 int chPanL, chPanR;
33 int chVolL, chVolR;
34 int macroVolMul;
35 int macroPanMul;
36 Channel():
37 SharedChannel<int>(255),
38 audPos(0),
39 sample(-1),
40 wave(-1),
41 setPos(false),
42 invert(false),
43 surround(false),
44 noise(false),
45 volChangedL(false),
46 volChangedR(false),
47 writeCtrl(false),
48 chPanL(255),
49 chPanR(255),
50 chVolL(255),
51 chVolR(255),
52 macroVolMul(64),
53 macroPanMul(127) {}
54 };
55 Channel chan[24];
56 DivDispatchOscBuffer* oscBuf[24];
57 bool isMuted[24];
58 unsigned int* sampleOff;
59 bool* sampleLoaded;
60 bool is219;
61 int totalChans;
62 unsigned char groupBank[4];
63 unsigned char bankType;
64
65 unsigned char* sampleMem;
66 size_t sampleMemLen;
67 struct QueuedWrite {
68 unsigned short addr;
69 unsigned char val;
70 bool addrOrVal;
71 QueuedWrite(): addr(0), val(0), addrOrVal(false) {}
72 QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {}
73 };
74 FixedQueue<QueuedWrite,2048> writes;
75 struct c140_t c140;
76 struct c219_t c219;
77 DivMemoryComposition memCompo;
78 unsigned char regPool[512];
79 char bankLabel[4][4];
80 friend void putDispatchChip(void*,int);
81 friend void putDispatchChan(void*,int,int);
82
83 void acquire_219(short** buf, size_t len);
84 void acquire_140(short** buf, size_t len);
85
86 public:
87 void acquire(short** buf, size_t len);
88 int dispatch(DivCommand c);
89 void* getChanState(int chan);
90 DivMacroInt* getChanMacroInt(int ch);
91 unsigned short getPan(int chan);
92 void getPaired(int ch, std::vector<DivChannelPair>& ret);
93 DivDispatchOscBuffer* getOscBuffer(int chan);
94 unsigned char* getRegisterPool();
95 int getRegisterPoolSize();
96 float getPostAmp();
97 void reset();
98 void forceIns();
99 void tick(bool sysTick=true);
100 void muteChannel(int ch, bool mute);
101 int getOutputCount();
102 void notifyInsChange(int ins);
103 void notifyWaveChange(int wave);
104 void notifyInsDeletion(void* ins);
105 void poke(unsigned int addr, unsigned short val);
106 void poke(std::vector<DivRegWrite>& wlist);
107 const char** getRegisterSheet();
108 const void* getSampleMem(int index = 0);
109 size_t getSampleMemCapacity(int index = 0);
110 size_t getSampleMemUsage(int index = 0);
111 bool isSampleLoaded(int index, int sample);
112 const DivMemoryComposition* getMemCompo(int index);
113 void renderSamples(int chipID);
114 int getClockRangeMin();
115 int getClockRangeMax();
116 void set219(bool is_219);
117 void setFlags(const DivConfig& flags);
118 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
119 void quit();
120 DivPlatformC140();
121 ~DivPlatformC140();
122 };
123
124 #endif