Debian Codegraph @

src/engine/platform/gbadma.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 _GBA_DMA_H
21 #define _GBA_DMA_H
22
23 #include "../dispatch.h"
24 #include "../waveSynth.h"
25
26 class DivPlatformGBADMA: public DivDispatch {
27 struct Channel: public SharedChannel<int> {
28 unsigned int audLoc;
29 unsigned short audLen;
30 int audDat;
31 int audPos;
32 int audSub;
33 int dmaCount;
34 int sample, wave;
35 int pan;
36 bool useWave, setPos;
37 int envVol;
38 DivWaveSynth ws;
39 Channel():
40 SharedChannel<int>(2),
41 audLoc(0),
42 audLen(0),
43 audDat(0),
44 audPos(0),
45 audSub(0),
46 dmaCount(0),
47 sample(-1),
48 wave(-1),
49 pan(3),
50 useWave(false),
51 setPos(false),
52 envVol(2) {}
53 };
54 Channel chan[2];
55 DivDispatchOscBuffer* oscBuf[2];
56 bool isMuted[2];
57 unsigned int* sampleOff;
58 bool* sampleLoaded;
59 int outDepth;
60
61 signed char* sampleMem;
62 size_t sampleMemLen;
63 // maximum wavetable length is currently hardcoded to 256
64 signed char wtMem[256*2];
65 DivMemoryComposition romMemCompo;
66 DivMemoryComposition wtMemCompo;
67
68 friend void putDispatchChip(void*,int);
69 friend void putDispatchChan(void*,int,int);
70
71 public:
72 void acquire(short** buf, size_t len);
73 int dispatch(DivCommand c);
74 void* getChanState(int chan);
75 DivDispatchOscBuffer* getOscBuffer(int chan);
76 void reset();
77 void forceIns();
78 void tick(bool sysTick=true);
79 void muteChannel(int ch, bool mute);
80 int getOutputCount();
81 DivMacroInt* getChanMacroInt(int ch);
82 unsigned short getPan(int chan);
83 DivSamplePos getSamplePos(int ch);
84 void setFlags(const DivConfig& flags);
85 void notifyInsChange(int ins);
86 void notifyWaveChange(int wave);
87 void notifyInsDeletion(void* ins);
88 const void* getSampleMem(int index = 0);
89 size_t getSampleMemCapacity(int index = 0);
90 size_t getSampleMemUsage(int index = 0);
91 bool isSampleLoaded(int index, int sample);
92 const DivMemoryComposition* getMemCompo(int index);
93 void renderSamples(int chipID);
94 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
95 void quit();
96 DivPlatformGBADMA();
97 ~DivPlatformGBADMA();
98
99 private:
100 void updateWave(int ch);
101 };
102
103 #endif