Debian Codegraph @

src/engine/platform/mmc5.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 _MMC5_H
21 #define _MMC5_H
22
23 #include "../dispatch.h"
24
25 class DivPlatformMMC5: public DivDispatch {
26 struct Channel: public SharedChannel<signed char> {
27 int prevFreq;
28 unsigned char duty, sweep;
29 bool sweepChanged, furnaceDac, setPos;
30 Channel():
31 SharedChannel<signed char>(15),
32 prevFreq(65535),
33 duty(0),
34 sweep(8),
35 sweepChanged(false),
36 furnaceDac(false),
37 setPos(false) {}
38 };
39 Channel chan[5];
40 DivDispatchOscBuffer* oscBuf[3];
41 bool isMuted[5];
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,128> writes;
49 int dacPeriod, dacRate;
50 unsigned int dacPos;
51 int dacSample;
52 unsigned char sampleBank;
53 unsigned char writeOscBuf;
54 struct _mmc5* mmc5;
55 unsigned char regPool[128];
56
57 friend void putDispatchChip(void*,int);
58 friend void putDispatchChan(void*,int,int);
59
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 DivDispatchOscBuffer* getOscBuffer(int chan);
66 unsigned char* getRegisterPool();
67 int getRegisterPoolSize();
68 void reset();
69 void forceIns();
70 void tick(bool sysTick=true);
71 void muteChannel(int ch, bool mute);
72 bool keyOffAffectsArp(int ch);
73 bool hasAcquireDirect();
74 float getPostAmp();
75 void setFlags(const DivConfig& flags);
76 void notifyInsDeletion(void* ins);
77 void poke(unsigned int addr, unsigned short val);
78 void poke(std::vector<DivRegWrite>& wlist);
79 const char** getRegisterSheet();
80 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
81 void quit();
82 ~DivPlatformMMC5();
83 };
84
85 #endif