Debian Codegraph @

src/engine/platform/saa.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 _SAA_H
21 #define _SAA_H
22
23 #include "../dispatch.h"
24 #include "../../fixedQueue.h"
25 #include "../../../extern/SAASound/src/SAASound.h"
26
27 class DivPlatformSAA1099: public DivDispatch {
28 protected:
29 struct Channel: public SharedChannel<int> {
30 unsigned char freqH, freqL;
31 unsigned char psgMode;
32 unsigned char pan;
33 Channel():
34 SharedChannel<int>(15),
35 freqH(0),
36 freqL(0),
37 psgMode(1),
38 pan(255) {}
39 };
40 Channel chan[6];
41 DivDispatchOscBuffer* oscBuf[6];
42 bool isMuted[6];
43 struct QueuedWrite {
44 unsigned short addr;
45 unsigned char val;
46 bool addrOrVal;
47 QueuedWrite(): addr(0), val(0), addrOrVal(false) {}
48 QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {}
49 };
50 FixedQueue<QueuedWrite,256> writes;
51 int coreQuality;
52 CSAASound* saa_saaSound;
53 unsigned char regPool[32];
54 unsigned char lastBusy;
55
56 bool dacMode;
57 int dacPeriod;
58 int dacRate;
59 int dacPos;
60 int dacSample;
61 unsigned char sampleBank;
62
63 int delay;
64
65 bool extMode;
66
67 short oldWrites[16];
68 short pendingWrites[16];
69 short* saaBuf[2];
70 size_t saaBufLen;
71 unsigned char saaEnv[2];
72 unsigned char saaNoise[2];
73 friend void putDispatchChip(void*,int);
74 friend void putDispatchChan(void*,int,int);
75
76 void acquire_saaSound(short** buf, size_t len);
77
78 public:
79 void acquire(short** buf, size_t len);
80 int dispatch(DivCommand c);
81 void* getChanState(int chan);
82 DivMacroInt* getChanMacroInt(int ch);
83 unsigned short getPan(int chan);
84 DivDispatchOscBuffer* getOscBuffer(int chan);
85 unsigned char* getRegisterPool();
86 int getRegisterPoolSize();
87 void reset();
88 void forceIns();
89 void tick(bool sysTick=true);
90 void muteChannel(int ch, bool mute);
91 void setFlags(const DivConfig& flags);
92 int getOutputCount();
93 int getPortaFloor(int ch);
94 bool keyOffAffectsArp(int ch);
95 bool getLegacyAlwaysSetVolume();
96 void notifyInsDeletion(void* ins);
97 void poke(unsigned int addr, unsigned short val);
98 void poke(std::vector<DivRegWrite>& wlist);
99 const char** getRegisterSheet();
100 void setCoreQuality(unsigned char q);
101 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
102 void quit();
103 };
104 #endif