| 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 _MSM6295_H |
| 21 |
#define _MSM6295_H |
| 22 |
|
| 23 |
#include "../dispatch.h" |
| 24 |
#include "../../fixedQueue.h" |
| 25 |
#include "vgsound_emu/src/msm6295/msm6295.hpp" |
| 26 |
|
| 27 |
class DivPlatformMSM6295: public DivDispatch, public vgsound_emu_mem_intf { |
| 28 |
protected: |
| 29 |
struct Channel: public SharedChannel<int> { |
| 30 |
bool furnacePCM; |
| 31 |
int sample; |
| 32 |
Channel(): |
| 33 |
SharedChannel<int>(8), |
| 34 |
furnacePCM(false), |
| 35 |
sample(-1) {} |
| 36 |
}; |
| 37 |
Channel chan[4]; |
| 38 |
DivDispatchOscBuffer* oscBuf[4]; |
| 39 |
bool isMuted[4]; |
| 40 |
struct QueuedWrite { |
| 41 |
unsigned short addr; |
| 42 |
unsigned char val; |
| 43 |
unsigned short delay; |
| 44 |
QueuedWrite(): addr(0), val(0), delay(96) {} |
| 45 |
QueuedWrite(unsigned short a, unsigned char v, unsigned short d=96): |
| 46 |
addr(a), |
| 47 |
val(v), |
| 48 |
delay(d) {} |
| 49 |
}; |
| 50 |
FixedQueue<QueuedWrite,256> writes; |
| 51 |
msm6295_core msm; |
| 52 |
|
| 53 |
unsigned char* adpcmMem; |
| 54 |
size_t adpcmMemLen; |
| 55 |
bool* sampleLoaded; |
| 56 |
unsigned char sampleBank; |
| 57 |
|
| 58 |
int delay, updateOsc; |
| 59 |
|
| 60 |
bool rateSel=false, rateSelInit=false, isBanked=false; |
| 61 |
|
| 62 |
unsigned int bank[4]; |
| 63 |
struct BankedPhrase { |
| 64 |
unsigned char bank=0; |
| 65 |
unsigned char phrase=0; |
| 66 |
unsigned int length=0; |
| 67 |
BankedPhrase(): |
| 68 |
bank(0), |
| 69 |
phrase(0), |
| 70 |
length(0) {} |
| 71 |
}* bankedPhrase; |
| 72 |
|
| 73 |
DivMemoryComposition memCompo; |
| 74 |
|
| 75 |
friend void putDispatchChip(void*,int); |
| 76 |
friend void putDispatchChan(void*,int,int); |
| 77 |
|
| 78 |
public: |
| 79 |
virtual u8 read_byte(u32 address) override; |
| 80 |
virtual void acquire(short** buf, size_t len) override; |
| 81 |
virtual int dispatch(DivCommand c) override; |
| 82 |
virtual void* getChanState(int chan) override; |
| 83 |
virtual DivMacroInt* getChanMacroInt(int ch) override; |
| 84 |
virtual DivDispatchOscBuffer* getOscBuffer(int chan) override; |
| 85 |
virtual unsigned char* getRegisterPool() override; |
| 86 |
virtual int getRegisterPoolSize() override; |
| 87 |
virtual void reset() override; |
| 88 |
virtual void forceIns() override; |
| 89 |
virtual void tick(bool sysTick=true) override; |
| 90 |
virtual void muteChannel(int ch, bool mute) override; |
| 91 |
virtual bool keyOffAffectsArp(int ch) override; |
| 92 |
virtual bool getLegacyAlwaysSetVolume() override; |
| 93 |
virtual float getPostAmp() override; |
| 94 |
virtual void notifyInsChange(int ins) override; |
| 95 |
virtual void notifyInsDeletion(void* ins) override; |
| 96 |
virtual void poke(unsigned int addr, unsigned short val) override; |
| 97 |
virtual void poke(std::vector<DivRegWrite>& wlist) override; |
| 98 |
virtual void setFlags(const DivConfig& flags) override; |
| 99 |
virtual const char** getRegisterSheet() override; |
| 100 |
virtual const void* getSampleMem(int index) override; |
| 101 |
virtual size_t getSampleMemCapacity(int index) override; |
| 102 |
virtual size_t getSampleMemUsage(int index) override; |
| 103 |
virtual bool isSampleLoaded(int index, int sample) override; |
| 104 |
virtual const DivMemoryComposition* getMemCompo(int index) override; |
| 105 |
virtual void renderSamples(int chipID) override; |
| 106 |
|
| 107 |
virtual int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) override; |
| 108 |
virtual void quit() override; |
| 109 |
DivPlatformMSM6295(); |
| 110 |
~DivPlatformMSM6295(); |
| 111 |
}; |
| 112 |
#endif |