Debian Codegraph @

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