Debian Codegraph @

src/engine/platform/lynx.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 _LYNX_H
21 #define _LYNX_H
22
23 #include "../dispatch.h"
24 #include "sound/lynx/Mikey.hpp"
25
26 class DivPlatformLynx: public DivDispatch {
27
28 struct MikeyFreqDiv {
29 unsigned char clockDivider;
30 unsigned char backup;
31
32 MikeyFreqDiv(int frequency);
33 };
34
35 struct MikeyDuty {
36 unsigned char int_feedback7;
37 unsigned char feedback;
38 int val;
39
40 MikeyDuty(int duty);
41 };
42
43 struct Channel: public SharedChannel<signed char> {
44 MikeyFreqDiv fd;
45 MikeyDuty duty;
46 int actualNote, lfsr, sample, samplePos, sampleAccum, sampleBaseFreq, sampleFreq;
47 unsigned char pan;
48 bool pcm, setPos, updateLFSR;
49 int macroVolMul;
50 Channel():
51 SharedChannel<signed char>(127),
52 fd(0),
53 duty(0),
54 actualNote(0),
55 lfsr(0),
56 sample(-1),
57 samplePos(0),
58 sampleAccum(0),
59 sampleBaseFreq(0),
60 sampleFreq(0),
61 pan(0xff),
62 pcm(false),
63 setPos(false),
64 updateLFSR(false),
65 macroVolMul(127) {}
66 };
67 Channel chan[4];
68 DivDispatchOscBuffer* oscBuf[4];
69 bool isMuted[4];
70 bool tuned;
71 std::unique_ptr<Lynx::Mikey> mikey;
72 struct QueuedWrite {
73 unsigned char addr;
74 unsigned char val;
75 QueuedWrite(): addr(0), val(9) {}
76 QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
77 };
78 FixedQueue<QueuedWrite,512> writes;
79 friend void putDispatchChip(void*,int);
80 friend void putDispatchChan(void*,int,int);
81
82 void processDAC(int sRate);
83 public:
84 void acquire(short** buf, size_t len);
85 void fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len);
86 int dispatch(DivCommand c);
87 void* getChanState(int chan);
88 DivMacroInt* getChanMacroInt(int ch);
89 unsigned short getPan(int chan);
90 DivSamplePos getSamplePos(int ch);
91 DivDispatchOscBuffer* getOscBuffer(int chan);
92 unsigned char* getRegisterPool();
93 int getRegisterPoolSize();
94 void reset();
95 void forceIns();
96 void tick(bool sysTick=true);
97 void muteChannel(int ch, bool mute);
98 int getOutputCount();
99 bool keyOffAffectsArp(int ch);
100 bool keyOffAffectsPorta(int ch);
101 bool getLegacyAlwaysSetVolume();
102 //int getPortaFloor(int ch);
103 void setFlags(const DivConfig& flags);
104 void notifyInsDeletion(void* ins);
105 void poke(unsigned int addr, unsigned short val);
106 void poke(std::vector<DivRegWrite>& wlist);
107 const char** getRegisterSheet();
108 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
109 void quit();
110 ~DivPlatformLynx();
111 };
112
113 #endif