Debian Codegraph @

src/engine/platform/dave.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 _DAVE_H
21 #define _DAVE_H
22
23 #include "../dispatch.h"
24 #include "../../fixedQueue.h"
25 #include "sound/dave/dave.hpp"
26
27 class DivPlatformDave: public DivDispatch {
28 struct Channel: public SharedChannel<signed char> {
29 int dacPeriod, dacRate, dacOut;
30 unsigned int dacPos;
31 int dacSample;
32 unsigned char noiseFreq;
33 unsigned char panL;
34 unsigned char panR;
35 unsigned char wave;
36 bool writeVol, highPass, ringMod, swapCounters, lowPass, resetPhase, setPos;
37 Channel():
38 SharedChannel<signed char>(63),
39 dacPeriod(0),
40 dacRate(0),
41 dacOut(0),
42 dacPos(0),
43 dacSample(-1),
44 noiseFreq(0),
45 panL(63),
46 panR(63),
47 wave(0),
48 writeVol(false),
49 highPass(false),
50 ringMod(false),
51 swapCounters(false),
52 lowPass(false),
53 resetPhase(false),
54 setPos(false) {}
55 };
56 Channel chan[6];
57 DivDispatchOscBuffer* oscBuf[6];
58 bool isMuted[6];
59 struct QueuedWrite {
60 unsigned char addr;
61 unsigned char val;
62 QueuedWrite(): addr(0), val(9) {}
63 QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
64 };
65 FixedQueue<QueuedWrite,512> writes;
66 bool writeControl;
67 bool clockDiv;
68
69 Ep128::Dave* dave;
70 unsigned char regPool[32];
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 unsigned short getPan(int chan);
79 void getPaired(int ch, std::vector<DivChannelPair>& ret);
80 DivChannelModeHints getModeHints(int chan);
81 DivSamplePos getSamplePos(int ch);
82 DivDispatchOscBuffer* getOscBuffer(int chan);
83 unsigned char* getRegisterPool();
84 int getRegisterPoolSize();
85 void reset();
86 void forceIns();
87 void tick(bool sysTick=true);
88 void muteChannel(int ch, bool mute);
89 int getOutputCount();
90 bool keyOffAffectsArp(int ch);
91 void setFlags(const DivConfig& flags);
92 void notifyInsDeletion(void* ins);
93 void poke(unsigned int addr, unsigned short val);
94 void poke(std::vector<DivRegWrite>& wlist);
95 const char** getRegisterSheet();
96 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
97 void quit();
98 ~DivPlatformDave();
99 };
100
101 #endif