Debian Codegraph @

src/engine/platform/sm8521.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 _SM8521_H
21 #define _SM8521_H
22
23 #include "../dispatch.h"
24 #include "../../fixedQueue.h"
25 #include "../waveSynth.h"
26 #include "sound/sm8521.h"
27
28 class DivPlatformSM8521: public DivDispatch {
29 const unsigned char volMap[3]={0x42,0x44,0x4a};
30
31 const unsigned char freqMap[3][2]={{0x46,0x47},{0x48,0x49},{0x4c,0x4d}};
32
33 struct Channel: public SharedChannel<signed char> {
34 int antiClickPeriodCount, antiClickWavePos;
35 signed short wave;
36 bool volumeChanged;
37 DivWaveSynth ws;
38 Channel():
39 SharedChannel<signed char>(31),
40 antiClickPeriodCount(0),
41 antiClickWavePos(0),
42 wave(-1),
43 volumeChanged(false) {}
44 };
45 Channel chan[3];
46 DivDispatchOscBuffer* oscBuf[3];
47 bool isMuted[3];
48 struct QueuedWrite {
49 unsigned short addr;
50 unsigned char val;
51 QueuedWrite(): addr(0), val(0) {}
52 QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {}
53 };
54 FixedQueue<QueuedWrite,128> writes;
55
56 bool antiClickEnabled;
57 int coreQuality, lastOut;
58 struct sm8521_t sm8521;
59 unsigned char regPool[256];
60 void updateWave(int ch);
61 friend void putDispatchChip(void*,int);
62 friend void putDispatchChan(void*,int,int);
63 public:
64 void acquireDirect(blip_buffer_t** bb, 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 bool hasAcquireDirect();
78 void setFlags(const DivConfig& flags);
79 void notifyWaveChange(int wave);
80 void notifyInsDeletion(void* ins);
81 void poke(unsigned int addr, unsigned short val);
82 void poke(std::vector<DivRegWrite>& wlist);
83 const char** getRegisterSheet();
84 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
85 void quit();
86 ~DivPlatformSM8521();
87 };
88
89 #endif