Debian Codegraph @

src/engine/platform/n163.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 _N163_H
21 #define _N163_H
22
23 #include "../dispatch.h"
24 #include "../../fixedQueue.h"
25 #include "../waveSynth.h"
26 #include "vgsound_emu/src/n163/n163.hpp"
27
28 class DivPlatformN163: public DivDispatch {
29 struct Channel: public SharedChannel<signed char> {
30 signed char resVol;
31 short wave, wavePos, waveLen;
32 short curWavePos, curWaveLen;
33 bool waveMode;
34 bool volumeChanged;
35 bool waveChanged, waveUpdated;
36 DivWaveSynth ws;
37 Channel():
38 SharedChannel<signed char>(15),
39 resVol(15),
40 wave(-1),
41 wavePos(0),
42 waveLen(0),
43 curWavePos(0),
44 curWaveLen(0),
45 waveMode(0),
46 volumeChanged(false),
47 waveChanged(false),
48 waveUpdated(false) {}
49 };
50 Channel chan[8];
51 DivDispatchOscBuffer* oscBuf[8];
52 bool isMuted[8];
53 struct QueuedWrite {
54 unsigned char addr;
55 unsigned char val;
56 unsigned char mask;
57 QueuedWrite(): addr(0), val(0), mask(~0) {}
58 QueuedWrite(unsigned char a, unsigned char v, unsigned char m=~0): addr(a), val(v), mask(m) {}
59 };
60 FixedQueue<QueuedWrite,2048> writes;
61 unsigned char initChanMax;
62 unsigned char chanMax;
63 short loadWave, loadPos;
64 bool multiplex, lenCompensate;
65
66 n163_core n163;
67 unsigned char regPool[128];
68 DivMemoryComposition memCompo;
69 void updateWave(int ch, int wave, int pos, int len);
70 void updateWaveCh(int ch);
71 friend void putDispatchChip(void*,int);
72 friend void putDispatchChan(void*,int,int);
73
74 public:
75 void acquire(short** buf, size_t len);
76 int dispatch(DivCommand c);
77 void* getChanState(int chan);
78 DivMacroInt* getChanMacroInt(int ch);
79 DivDispatchOscBuffer* getOscBuffer(int chan);
80 unsigned char* getRegisterPool();
81 int getRegisterPoolSize();
82 void reset();
83 void forceIns();
84 void tick(bool sysTick=true);
85 void muteChannel(int ch, bool mute);
86 const DivMemoryComposition* getMemCompo(int index);
87 void setFlags(const DivConfig& flags);
88 void notifyWaveChange(int wave);
89 void notifyInsChange(int ins);
90 void notifyInsDeletion(void* ins);
91 void poke(unsigned int addr, unsigned short val);
92 void poke(std::vector<DivRegWrite>& wlist);
93 const char** getRegisterSheet();
94 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
95 void quit();
96 ~DivPlatformN163();
97 };
98
99 #endif