Debian Codegraph @

src/engine/platform/gb.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 _GB_H
21 #define _GB_H
22
23 #include "../dispatch.h"
24 #include "../waveSynth.h"
25 #include "sound/gb/gb.h"
26 #include "../../fixedQueue.h"
27
28 class DivPlatformGB: public DivDispatch {
29 struct Channel: public SharedChannel<signed char> {
30 unsigned char duty, sweep;
31 bool sweepChanged, released, softEnv, killIt;
32 bool soManyHacksToMakeItDefleCompatible;
33 signed short wave;
34 signed char lastKill;
35 unsigned char envVol, envDir, envLen, soundLen;
36 unsigned short hwSeqPos;
37 short hwSeqDelay;
38 Channel():
39 SharedChannel<signed char>(15),
40 duty(0),
41 sweep(0),
42 sweepChanged(false),
43 released(false),
44 softEnv(false),
45 killIt(false),
46 soManyHacksToMakeItDefleCompatible(false),
47 wave(-1),
48 lastKill(0),
49 envVol(0),
50 envDir(0),
51 envLen(0),
52 soundLen(0),
53 hwSeqPos(0),
54 hwSeqDelay(0) {}
55 };
56 Channel chan[4];
57 DivDispatchOscBuffer* oscBuf[4];
58 bool isMuted[4];
59 bool antiClickEnabled;
60 bool invertWave;
61 bool enoughAlready;
62 bool doubleWave;
63 bool lastDoubleWave;
64 unsigned char lastPan;
65 DivWaveSynth ws;
66 struct QueuedWrite {
67 unsigned char addr;
68 unsigned char val;
69 QueuedWrite(): addr(0), val(0) {}
70 QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
71 };
72 FixedQueue<QueuedWrite,256> writes;
73
74 int antiClickPeriodCount, antiClickWavePos;
75
76 int coreQuality;
77 GB_gameboy_t* gb;
78 GB_model_t model;
79 unsigned char regPool[128];
80
81 unsigned char procMute();
82 void updateWave();
83 friend void putDispatchChip(void*,int);
84 friend void putDispatchChan(void*,int,int);
85 public:
86 void acquire(short** buf, size_t len);
87 int dispatch(DivCommand c);
88 void* getChanState(int chan);
89 DivMacroInt* getChanMacroInt(int ch);
90 unsigned short getPan(int chan);
91 DivDispatchOscBuffer* getOscBuffer(int chan);
92 unsigned char* getRegisterPool();
93 int getRegisterPoolSize();
94 void reset();
95 void forceIns();
96 void tick(bool sysTick=true);
97 void muteChannel(int ch, bool mute);
98 int getPortaFloor(int ch);
99 int getOutputCount();
100 bool getDCOffRequired();
101 void notifyInsChange(int ins);
102 void notifyWaveChange(int wave);
103 void notifyInsDeletion(void* ins);
104 void poke(unsigned int addr, unsigned short val);
105 void poke(std::vector<DivRegWrite>& wlist);
106 const char** getRegisterSheet();
107 void setFlags(const DivConfig& flags);
108 void setCoreQuality(unsigned char q);
109 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
110 void quit();
111 ~DivPlatformGB();
112 };
113
114 #endif