Debian Codegraph @

src/engine/platform/ymz280b.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 _YMZ280B_H
21 #define _YMZ280B_H
22
23 #include "../dispatch.h"
24 #include "sound/ymz280b.h"
25
26 class DivPlatformYMZ280B: public DivDispatch {
27 struct Channel: public SharedChannel<int> {
28 unsigned int audPos;
29 int sample, wave;
30 int panning;
31 bool setPos, isNewYMZ;
32 int macroVolMul;
33 Channel():
34 SharedChannel<int>(255),
35 audPos(0),
36 sample(-1),
37 wave(-1),
38 panning(8),
39 setPos(false),
40 isNewYMZ(false),
41 macroVolMul(64) {}
42 };
43 Channel chan[8];
44 DivDispatchOscBuffer* oscBuf[8];
45 bool isMuted[8];
46 int chipType;
47 unsigned int* sampleOff;
48 bool* sampleLoaded;
49
50 unsigned char* sampleMem;
51 size_t sampleMemLen;
52 ymz280b_device ymz280b;
53 DivMemoryComposition memCompo;
54 unsigned char regPool[256];
55 friend void putDispatchChip(void*,int);
56 friend void putDispatchChan(void*,int,int);
57
58 public:
59 void acquire(short** buf, size_t len);
60 int dispatch(DivCommand c);
61 void* getChanState(int chan);
62 DivMacroInt* getChanMacroInt(int ch);
63 unsigned short getPan(int chan);
64 DivDispatchOscBuffer* getOscBuffer(int chan);
65 unsigned char* getRegisterPool();
66 int getRegisterPoolSize();
67 void reset();
68 void forceIns();
69 void tick(bool sysTick=true);
70 void muteChannel(int ch, bool mute);
71 float getPostAmp();
72 int getOutputCount();
73 void setChipModel(int type);
74 void notifyInsChange(int ins);
75 void notifyWaveChange(int wave);
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 const void* getSampleMem(int index = 0);
81 size_t getSampleMemCapacity(int index = 0);
82 size_t getSampleMemUsage(int index = 0);
83 bool isSampleLoaded(int index, int sample);
84 const DivMemoryComposition* getMemCompo(int index);
85 void renderSamples(int chipID);
86 void setFlags(const DivConfig& flags);
87 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
88 void quit();
89 DivPlatformYMZ280B();
90 ~DivPlatformYMZ280B();
91 private:
92 void writeOutVol(int ch);
93 };
94
95 #endif