Debian Codegraph @

src/engine/platform/sms.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 _SMS_H
21 #define _SMS_H
22
23 #include "../dispatch.h"
24 #include "sound/sn76496.h"
25 extern "C" {
26 #include "../../../extern/Nuked-PSG/ympsg.h"
27 }
28 #include "../../fixedQueue.h"
29
30 class DivPlatformSMS: public DivDispatch {
31 struct Channel: public SharedChannel<signed char> {
32 int actualNote;
33 bool writeVol;
34 Channel():
35 SharedChannel<signed char>(15),
36 actualNote(0),
37 writeVol(false) {}
38 };
39 Channel chan[4];
40 DivDispatchOscBuffer* oscBuf[4];
41 bool isMuted[4];
42 unsigned char lastPan;
43 unsigned char oldValue;
44 unsigned char snNoiseMode;
45 unsigned char regPool[16];
46 unsigned char chanLatch;
47 int lastOut[2];
48 int divider=16;
49 double toneDivider=64.0;
50 double noiseDivider=64.0;
51 bool updateSNMode;
52 bool resetPhase;
53 bool isRealSN;
54 bool stereo;
55 bool nuked;
56 bool easyNoise;
57 sn76496_base_device* sn;
58 ympsg_t sn_nuked;
59 struct QueuedWrite {
60 unsigned short addr;
61 unsigned char val;
62 bool addrOrVal;
63 QueuedWrite(): addr(0), val(0), addrOrVal(false) {}
64 QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {}
65 };
66 FixedQueue<QueuedWrite,128> writes;
67 friend void putDispatchChip(void*,int);
68 friend void putDispatchChan(void*,int,int);
69
70 double NOTE_SN(int ch, int note);
71 int snCalcFreq(int ch);
72 void poolWrite(unsigned short a, unsigned char v);
73
74 void acquire_nuked(short** buf, size_t len);
75 void acquire_mame(blip_buffer_t** bb, size_t len);
76 public:
77 void acquire(short** buf, size_t len);
78 void acquireDirect(blip_buffer_t** bb, size_t len);
79 int dispatch(DivCommand c);
80 void* getChanState(int chan);
81 DivMacroInt* getChanMacroInt(int ch);
82 unsigned short getPan(int chan);
83 DivDispatchOscBuffer* getOscBuffer(int chan);
84 int mapVelocity(int ch, float vel);
85 float getGain(int ch, int vol);
86 unsigned char* getRegisterPool();
87 int getRegisterPoolSize();
88 void reset();
89 void forceIns();
90 void tick(bool sysTick=true);
91 void muteChannel(int ch, bool mute);
92 int getOutputCount();
93 bool keyOffAffectsArp(int ch);
94 bool keyOffAffectsPorta(int ch);
95 bool hasAcquireDirect();
96 bool getLegacyAlwaysSetVolume();
97 float getPostAmp();
98 int getPortaFloor(int ch);
99 void setFlags(const DivConfig& flags);
100 void notifyInsDeletion(void* ins);
101 void poke(unsigned int addr, unsigned short val);
102 void poke(std::vector<DivRegWrite>& wlist);
103 const char** getRegisterSheet();
104 void setNuked(bool value);
105 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
106 void quit();
107 ~DivPlatformSMS();
108 };
109
110 #endif