Debian Codegraph @

src/engine/platform/vrc6.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 _VRC6_H
21 #define _VRC6_H
22
23 #include "../../fixedQueue.h"
24 #include "../dispatch.h"
25 #include "vgsound_emu/src/vrcvi/vrcvi.hpp"
26
27
28 class DivPlatformVRC6: public DivDispatch, public vrcvi_intf {
29 struct Channel: public SharedChannel<signed char> {
30 int dacPeriod, dacRate, dacOut;
31 unsigned int dacPos;
32 int dacSample;
33 unsigned char duty;
34 bool pcm, furnaceDac, setPos;
35 Channel():
36 SharedChannel<signed char>(15),
37 dacPeriod(0),
38 dacRate(0),
39 dacOut(0),
40 dacPos(0),
41 dacSample(-1),
42 duty(0),
43 pcm(false),
44 furnaceDac(false),
45 setPos(false) {}
46 };
47 Channel chan[3];
48 DivDispatchOscBuffer* oscBuf[3];
49 bool isMuted[3];
50 struct QueuedWrite {
51 unsigned short addr;
52 unsigned char val;
53 QueuedWrite(): addr(0), val(0) {}
54 QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {}
55 };
56 FixedQueue<QueuedWrite,64> writes;
57 unsigned char sampleBank;
58 vrcvi_core vrc6;
59 int prevSample;
60 unsigned char regPool[13];
61
62 friend void putDispatchChip(void*,int);
63 friend void putDispatchChan(void*,int,int);
64
65 public:
66 void acquireDirect(blip_buffer_t** bb, size_t len);
67 int dispatch(DivCommand c);
68 void* getChanState(int chan);
69 DivMacroInt* getChanMacroInt(int ch);
70 DivSamplePos getSamplePos(int ch);
71 DivDispatchOscBuffer* getOscBuffer(int chan);
72 unsigned char* getRegisterPool();
73 int getRegisterPoolSize();
74 void reset();
75 void forceIns();
76 void tick(bool sysTick=true);
77 void muteChannel(int ch, bool mute);
78 bool keyOffAffectsArp(int ch);
79 bool hasAcquireDirect();
80 void setFlags(const DivConfig& flags);
81 void notifyInsDeletion(void* ins);
82 void poke(unsigned int addr, unsigned short val);
83 void poke(std::vector<DivRegWrite>& wlist);
84 const char** getRegisterSheet();
85 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
86 void quit();
87 DivPlatformVRC6() : vrc6(*this) {};
88 ~DivPlatformVRC6();
89 };
90
91 #endif