Debian Codegraph @

src/engine/platform/swan.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 _SWAN_H
21 #define _SWAN_H
22
23 #include "../dispatch.h"
24 #include "../waveSynth.h"
25 #include "sound/swan.h"
26 #include "sound/swan_mdfn.h"
27 #include "../../fixedQueue.h"
28
29 class DivPlatformSwan: public DivDispatch {
30 struct Channel: public SharedChannel<int> {
31 unsigned char pan;
32 int wave;
33 DivWaveSynth ws;
34 Channel():
35 SharedChannel<int>(15),
36 pan(255),
37 wave(-1) {}
38 };
39 Channel chan[4];
40 DivDispatchOscBuffer* oscBuf[4];
41 bool isMuted[4];
42 bool stereo;
43 bool useMdfn;
44 bool pcm, sweep, furnaceDac, setPos;
45 unsigned char sampleBank, noise;
46 int dacPeriod, dacRate;
47 unsigned int dacPos;
48 int dacSample;
49
50 unsigned char regPool[0x80];
51 struct QueuedWrite {
52 unsigned char addr;
53 unsigned char val;
54 QueuedWrite(): addr(0), val(0) {}
55 QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
56 };
57 FixedQueue<QueuedWrite,256> writes;
58 FixedQueue<DivRegWrite,2048> postDACWrites;
59
60 swan_sound_t ws;
61 WSwan* ws_mdfn;
62
63 void updateWave(int ch);
64 friend void putDispatchChip(void*,int);
65 friend void putDispatchChan(void*,int,int);
66 public:
67 void acquireDirect(blip_buffer_t** bb, size_t len);
68 void acquire(short** buf, size_t len);
69 int dispatch(DivCommand c);
70 void* getChanState(int chan);
71 DivMacroInt* getChanMacroInt(int ch);
72 unsigned short getPan(int chan);
73 DivChannelModeHints getModeHints(int chan);
74 DivDispatchOscBuffer* getOscBuffer(int chan);
75 unsigned char* getRegisterPool();
76 int getRegisterPoolSize();
77 void reset();
78 void forceIns();
79 void tick(bool sysTick=true);
80 void muteChannel(int ch, bool mute);
81 void setFlags(const DivConfig& flags);
82 void notifyWaveChange(int wave);
83 void notifyInsDeletion(void* ins);
84 int getOutputCount();
85 bool hasAcquireDirect();
86 void setUseMdfn(bool use);
87 void poke(unsigned int addr, unsigned short val);
88 void poke(std::vector<DivRegWrite>& wlist);
89 const char** getRegisterSheet();
90 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
91 void quit();
92 ~DivPlatformSwan();
93 private:
94 void calcAndWriteOutVol(int ch, int env);
95 void writeOutVol(int ch);
96 };
97
98 #endif