Debian Codegraph @

src/engine/platform/msm6258.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 _MSM6258_H
21 #define _MSM6258_H
22
23 #include "../dispatch.h"
24 #include "../../fixedQueue.h"
25 #include "sound/oki/okim6258.h"
26
27 class DivPlatformMSM6258: public DivDispatch {
28 protected:
29 struct Channel: public SharedChannel<int> {
30 bool furnacePCM;
31 int sample;
32 unsigned char pan;
33 Channel():
34 SharedChannel<int>(8),
35 furnacePCM(false),
36 sample(-1),
37 pan(3) {}
38 };
39 Channel chan[1];
40 DivDispatchOscBuffer* oscBuf[1];
41 bool isMuted[1];
42 struct QueuedWrite {
43 unsigned short addr;
44 unsigned char val;
45 QueuedWrite(): addr(0), val(0) {}
46 QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {}
47 };
48 FixedQueue<QueuedWrite,256> writes;
49 okim6258_device* msm;
50
51 unsigned char sampleBank, msmPan, msmDivider, rateSel, msmClock, clockSel;
52 signed char msmDividerCount, msmClockCount;
53 bool updateSampleFreq;
54 bool variableRate;
55 short msmOut;
56
57 int delay, updateOsc, sample, samplePos;
58
59 friend void putDispatchChip(void*,int);
60 friend void putDispatchChan(void*,int,int);
61
62 int calcVGMRate();
63
64 public:
65 void acquire(short** buf, size_t len);
66 int dispatch(DivCommand c);
67 void* getChanState(int chan);
68 DivMacroInt* getChanMacroInt(int ch);
69 unsigned short getPan(int chan);
70 DivDispatchOscBuffer* getOscBuffer(int chan);
71 unsigned char* getRegisterPool();
72 int getRegisterPoolSize();
73 void reset();
74 void forceIns();
75 void tick(bool sysTick=true);
76 void muteChannel(int ch, bool mute);
77 int getOutputCount();
78 bool keyOffAffectsArp(int ch);
79 bool getLegacyAlwaysSetVolume();
80 void notifyInsChange(int ins);
81 void notifyInsDeletion(void* ins);
82 void poke(unsigned int addr, unsigned short val);
83 void poke(std::vector<DivRegWrite>& wlist);
84 void setFlags(const DivConfig& flags);
85 const char** getRegisterSheet();
86
87 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
88 void quit();
89 ~DivPlatformMSM6258();
90 };
91 #endif