| 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 _GA20_H |
| 21 |
#define _GA20_H |
| 22 |
|
| 23 |
#include "../dispatch.h" |
| 24 |
#include "../../fixedQueue.h" |
| 25 |
#include "../macroInt.h" |
| 26 |
#include "sound/ga20/iremga20.h" |
| 27 |
|
| 28 |
class DivPlatformGA20: public DivDispatch, public iremga20_intf { |
| 29 |
struct Channel: public SharedChannel<int> { |
| 30 |
int prevFreq; |
| 31 |
unsigned int audPos; |
| 32 |
int sample; |
| 33 |
bool volumeChanged, setPos; |
| 34 |
int resVol; |
| 35 |
int macroVolMul; |
| 36 |
Channel(): |
| 37 |
SharedChannel<int>(255), |
| 38 |
prevFreq(-1), |
| 39 |
audPos(0), |
| 40 |
sample(-1), |
| 41 |
volumeChanged(false), |
| 42 |
setPos(false), |
| 43 |
resVol(255), |
| 44 |
macroVolMul(64) {} |
| 45 |
}; |
| 46 |
Channel chan[4]; |
| 47 |
DivDispatchOscBuffer* oscBuf[4]; |
| 48 |
bool isMuted[4]; |
| 49 |
struct QueuedWrite { |
| 50 |
unsigned char addr; |
| 51 |
unsigned char val; |
| 52 |
QueuedWrite(): addr(0), val(0) {} |
| 53 |
QueuedWrite(unsigned char a, unsigned char v): |
| 54 |
addr(a), |
| 55 |
val(v) {} |
| 56 |
}; |
| 57 |
FixedQueue<QueuedWrite,256> writes; |
| 58 |
unsigned int* sampleOffGA20; |
| 59 |
bool* sampleLoaded; |
| 60 |
|
| 61 |
int oldOut; |
| 62 |
|
| 63 |
short* ga20Buf[4]; |
| 64 |
size_t ga20BufLen; |
| 65 |
|
| 66 |
unsigned char* sampleMem; |
| 67 |
size_t sampleMemLen; |
| 68 |
iremga20_device ga20; |
| 69 |
DivMemoryComposition memCompo; |
| 70 |
unsigned char regPool[32]; |
| 71 |
friend void putDispatchChip(void*,int); |
| 72 |
friend void putDispatchChan(void*,int,int); |
| 73 |
|
| 74 |
void chWrite(unsigned char ch, unsigned int addr, unsigned char val); |
| 75 |
public: |
| 76 |
virtual u8 read_byte(u32 address) override; |
| 77 |
virtual void acquireDirect(blip_buffer_t** bb, size_t len) override; |
| 78 |
virtual void acquire(short** buf, size_t len) override; |
| 79 |
virtual int dispatch(DivCommand c) override; |
| 80 |
virtual void* getChanState(int chan) override; |
| 81 |
virtual DivMacroInt* getChanMacroInt(int ch) override; |
| 82 |
virtual DivSamplePos getSamplePos(int ch) override; |
| 83 |
virtual DivDispatchOscBuffer* getOscBuffer(int chan) override; |
| 84 |
virtual unsigned char* getRegisterPool() override; |
| 85 |
virtual int getRegisterPoolSize() override; |
| 86 |
virtual void reset() override; |
| 87 |
virtual void forceIns() override; |
| 88 |
virtual void tick(bool sysTick=true) override; |
| 89 |
virtual void muteChannel(int ch, bool mute) override; |
| 90 |
virtual bool hasAcquireDirect() override; |
| 91 |
virtual int getOutputCount() override; |
| 92 |
virtual void notifyInsChange(int ins) override; |
| 93 |
virtual void notifyWaveChange(int wave) override; |
| 94 |
virtual void notifyInsDeletion(void* ins) override; |
| 95 |
virtual void setFlags(const DivConfig& flags) override; |
| 96 |
virtual void poke(unsigned int addr, unsigned short val) override; |
| 97 |
virtual void poke(std::vector<DivRegWrite>& wlist) override; |
| 98 |
virtual const char** getRegisterSheet() override; |
| 99 |
virtual const void* getSampleMem(int index = 0) override; |
| 100 |
virtual size_t getSampleMemCapacity(int index = 0) override; |
| 101 |
virtual size_t getSampleMemUsage(int index = 0) override; |
| 102 |
virtual bool isSampleLoaded(int index, int sample) override; |
| 103 |
virtual const DivMemoryComposition* getMemCompo(int index) override; |
| 104 |
virtual void renderSamples(int chipID) override; |
| 105 |
virtual int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) override; |
| 106 |
virtual void quit() override; |
| 107 |
DivPlatformGA20(); |
| 108 |
~DivPlatformGA20(); |
| 109 |
}; |
| 110 |
|
| 111 |
#endif |