Debian Codegraph @

src/engine/platform/pokey.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 _POKEY_H
21 #define _POKEY_H
22
23 #include "../dispatch.h"
24 #include "../../fixedQueue.h"
25
26 extern "C" {
27 #include "sound/pokey/mzpokeysnd.h"
28 }
29
30 #include "sound/pokey/AltASAP.hpp"
31
32
33 class DivPlatformPOKEY: public DivDispatch {
34 struct Channel: public SharedChannel<int> {
35 unsigned char wave;
36 bool ctlChanged;
37 Channel():
38 SharedChannel<int>(15),
39 wave(5),
40 ctlChanged(true) {}
41 };
42 Channel chan[4];
43 DivDispatchOscBuffer* oscBuf[4];
44 bool isMuted[4];
45 struct QueuedWrite {
46 unsigned char addr;
47 unsigned char val;
48 QueuedWrite(): addr(0), val(0) {}
49 QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
50 };
51 FixedQueue<QueuedWrite,128> writes;
52 unsigned char audctl, skctl;
53 bool audctlChanged, skctlChanged;
54 unsigned char oscBufDelay;
55 PokeyState pokey;
56 AltASAP::Pokey altASAP;
57 bool useAltASAP;
58 unsigned char regPool[16];
59 friend void putDispatchChip(void*,int);
60 friend void putDispatchChan(void*,int,int);
61 public:
62 void acquire(short** buf, size_t len);
63 void acquireMZ(short* buf, size_t len);
64 void acquireASAP(short* buf, size_t len);
65 int dispatch(DivCommand c);
66 void* getChanState(int chan);
67 DivMacroInt* getChanMacroInt(int ch);
68 void getPaired(int ch, std::vector<DivChannelPair>& ret);
69 DivDispatchOscBuffer* getOscBuffer(int chan);
70 unsigned char* getRegisterPool();
71 int getRegisterPoolSize();
72 void reset();
73 void forceIns();
74 void tick(bool sysTick=true);
75 void muteChannel(int ch, bool mute);
76 bool keyOffAffectsArp(int ch);
77 float getPostAmp();
78 void setFlags(const DivConfig& flags);
79 void notifyInsDeletion(void* ins);
80 void poke(unsigned int addr, unsigned short val);
81 void poke(std::vector<DivRegWrite>& wlist);
82 const char** getRegisterSheet();
83 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
84 void quit();
85 void setAltASAP(bool useAltASAP);
86 ~DivPlatformPOKEY();
87 };
88
89 #endif