Debian Codegraph @

src/engine/platform/msm5232.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 _MSM5232_H
21 #define _MSM5232_H
22
23 #include "../dispatch.h"
24 #include "../../fixedQueue.h"
25 #include "sound/oki/msm5232.h"
26
27 class DivPlatformMSM5232: public DivDispatch {
28 struct Channel: public SharedChannel<signed char> {
29 bool noise;
30 Channel():
31 SharedChannel<signed char>(127),
32 noise(false) {}
33 };
34 Channel chan[8];
35 DivDispatchOscBuffer* oscBuf[8];
36 int partVolume[8];
37 int initPartVolume[8];
38 int clockDriftLFOWave[256];
39 double capacitance[8];
40 bool isMuted[8];
41 bool updateGroup[2];
42 bool updateGroupAR[2];
43 bool updateGroupDR[2];
44 bool groupEnv[2];
45 unsigned char groupControl[2];
46 unsigned char groupAR[2];
47 unsigned char groupDR[2];
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
56 int cycles, curChan, delay, detune, clockDriftAccum;
57 unsigned int clockDriftLFOPos, clockDriftLFOSpeed;
58 short temp[16];
59 msm5232_device* msm;
60 unsigned char regPool[128];
61 friend void putDispatchChip(void*,int);
62 friend void putDispatchChan(void*,int,int);
63 public:
64 void acquire(short** buf, size_t len);
65 int dispatch(DivCommand c);
66 void* getChanState(int chan);
67 DivMacroInt* getChanMacroInt(int ch);
68 DivDispatchOscBuffer* getOscBuffer(int chan);
69 unsigned char* getRegisterPool();
70 int getRegisterPoolSize();
71 void reset();
72 void forceIns();
73 void tick(bool sysTick=true);
74 void muteChannel(int ch, bool mute);
75 int getOutputCount();
76 bool keyOffAffectsArp(int ch);
77 void setFlags(const DivConfig& flags);
78 void notifyInsDeletion(void* ins);
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 ~DivPlatformMSM5232();
85 };
86
87 #endif