Debian Codegraph @

src/engine/platform/ym2203.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 _YM2203_H
21 #define _YM2203_H
22
23 #include "fmshared_OPN.h"
24 #include "sound/ymfm/ymfm_opn.h"
25 extern "C" {
26 #include "../../../extern/YM2608-LLE/fmopna_2608.h"
27 }
28
29 #include "ay.h"
30
31 class DivPlatformYM2203: public DivPlatformOPN {
32 protected:
33 const unsigned short chanOffs[3]={
34 0x00, 0x01, 0x02
35 };
36
37 const unsigned char konOffs[3]={
38 0, 1, 2
39 };
40
41 OPNChannel chan[7];
42 DivDispatchOscBuffer* oscBuf[7];
43 bool isMuted[7];
44 ym3438_t fm_nuked;
45 ymfm::ym2203* fm;
46 ymfm::ym2203::output_data fmout;
47 DivOPNInterface iface;
48 fmopna_t fm_lle;
49 unsigned int dacVal;
50 unsigned int dacVal2;
51 int dacOut[2];
52 int rssOut[6];
53 bool lastSH;
54 bool lastSH2;
55 bool lastS;
56
57 DivPlatformAY8910* ay;
58 unsigned char sampleBank;
59
60 bool extMode, noExtMacros;
61 unsigned char prescale, nukedMult;
62
63 friend void putDispatchChip(void*,int);
64
65 inline void commitState(int ch, DivInstrument* ins);
66
67 void acquire_combo(short** buf, size_t len);
68 void acquire_ymfm(short** buf, size_t len);
69 void acquire_lle(short** buf, size_t len);
70
71 public:
72 unsigned char isCSM;
73 void acquire(short** buf, size_t len);
74 void fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len);
75 int dispatch(DivCommand c);
76 void* getChanState(int chan);
77 DivMacroInt* getChanMacroInt(int ch);
78 DivDispatchOscBuffer* getOscBuffer(int chan);
79 unsigned char* getRegisterPool();
80 int getRegisterPoolSize();
81 void reset();
82 void forceIns();
83 void tick(bool sysTick=true);
84 void muteChannel(int ch, bool mute);
85 int getOutputCount();
86 bool keyOffAffectsArp(int ch);
87 void notifyInsChange(int ins);
88 virtual void notifyInsDeletion(void* ins);
89 void setSkipRegisterWrites(bool val);
90 void poke(unsigned int addr, unsigned short val);
91 void poke(std::vector<DivRegWrite>& wlist);
92 const char** getRegisterSheet();
93 void setFlags(const DivConfig& flags);
94 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
95 void quit();
96 DivPlatformYM2203():
97 DivPlatformOPN(2, 3, 6, 6, 6, 4720270.0, 36, 16, false, 6),
98 prescale(0x2d),
99 isCSM(0) {}
100 ~DivPlatformYM2203();
101 };
102 #endif