Debian Codegraph @

src/engine/platform/pce.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 _PCE_H
21 #define _PCE_H
22
23 #include "../dispatch.h"
24 #include "../../fixedQueue.h"
25 #include "../waveSynth.h"
26 #include "sound/pce_psg.h"
27
28 class DivPlatformPCE: public DivDispatch {
29 struct Channel: public SharedChannel<signed char> {
30 int antiClickPeriodCount, antiClickWavePos;
31 int dacPeriod, dacRate, dacOut;
32 unsigned int dacPos;
33 int dacSample;
34 unsigned char pan;
35 bool noise, pcm, furnaceDac, deferredWaveUpdate, setPos;
36 signed short wave;
37 int macroVolMul, noiseSeek;
38 DivWaveSynth ws;
39 Channel():
40 SharedChannel<signed char>(31),
41 antiClickPeriodCount(0),
42 antiClickWavePos(0),
43 dacPeriod(0),
44 dacRate(0),
45 dacOut(0),
46 dacPos(0),
47 dacSample(-1),
48 pan(255),
49 noise(false),
50 pcm(false),
51 furnaceDac(false),
52 deferredWaveUpdate(false),
53 setPos(false),
54 wave(-1),
55 macroVolMul(31),
56 noiseSeek(0) {}
57 };
58 Channel chan[6];
59 DivDispatchOscBuffer* oscBuf[6];
60 bool isMuted[6];
61 bool antiClickEnabled;
62 bool updateLFO;
63 struct QueuedWrite {
64 unsigned char addr;
65 unsigned char val;
66 QueuedWrite(): addr(0), val(9) {}
67 QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
68 };
69 FixedQueue<QueuedWrite,512> writes;
70 unsigned char lastPan;
71
72 int curChan;
73 unsigned char sampleBank, lfoMode, lfoSpeed;
74 PCE_PSG* pce;
75 unsigned char regPool[128];
76 void updateWave(int ch);
77 friend void putDispatchChip(void*,int);
78 friend void putDispatchChan(void*,int,int);
79 public:
80 void acquire(short** buf, size_t len);
81 void acquireDirect(blip_buffer_t** bb, size_t len);
82 int dispatch(DivCommand c);
83 void* getChanState(int chan);
84 DivMacroInt* getChanMacroInt(int ch);
85 unsigned short getPan(int chan);
86 void getPaired(int ch, std::vector<DivChannelPair>& ret);
87 DivChannelModeHints getModeHints(int chan);
88 DivSamplePos getSamplePos(int ch);
89 DivDispatchOscBuffer* getOscBuffer(int chan);
90 int mapVelocity(int ch, float vel);
91 float getGain(int ch, int vol);
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 getOutputCount();
99 bool keyOffAffectsArp(int ch);
100 bool hasAcquireDirect();
101 void setFlags(const DivConfig& flags);
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 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
108 void quit();
109 ~DivPlatformPCE();
110 };
111
112 #endif