| 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 _K053260_H |
| 21 |
#define _K053260_H |
| 22 |
|
| 23 |
#include "../dispatch.h" |
| 24 |
#include <queue> |
| 25 |
#include "vgsound_emu/src/k053260/k053260.hpp" |
| 26 |
|
| 27 |
class DivPlatformK053260: public DivDispatch, public k053260_intf { |
| 28 |
struct Channel: public SharedChannel<int> { |
| 29 |
unsigned int audPos; |
| 30 |
int sample, wave; |
| 31 |
int panning; |
| 32 |
bool setPos, reverse; |
| 33 |
int macroVolMul; |
| 34 |
Channel(): |
| 35 |
SharedChannel<int>(127), |
| 36 |
audPos(0), |
| 37 |
sample(-1), |
| 38 |
wave(-1), |
| 39 |
panning(4), |
| 40 |
setPos(false), |
| 41 |
reverse(false), |
| 42 |
macroVolMul(64) {} |
| 43 |
}; |
| 44 |
Channel chan[4]; |
| 45 |
DivDispatchOscBuffer* oscBuf[4]; |
| 46 |
bool isMuted[4]; |
| 47 |
int chipType; |
| 48 |
unsigned char curChan; |
| 49 |
unsigned int* sampleOff; |
| 50 |
bool* sampleLoaded; |
| 51 |
|
| 52 |
unsigned char* sampleMem; |
| 53 |
size_t sampleMemLen; |
| 54 |
k053260_core k053260; |
| 55 |
DivMemoryComposition memCompo; |
| 56 |
unsigned char regPool[64]; |
| 57 |
void updatePanning(unsigned char mask); |
| 58 |
|
| 59 |
friend void putDispatchChip(void*,int); |
| 60 |
friend void putDispatchChan(void*,int,int); |
| 61 |
|
| 62 |
public: |
| 63 |
virtual u8 read_sample(u32 address) override; |
| 64 |
virtual void acquire(short** buf, size_t len) override; |
| 65 |
virtual int dispatch(DivCommand c) override; |
| 66 |
virtual void* getChanState(int chan) override; |
| 67 |
virtual DivMacroInt* getChanMacroInt(int ch) override; |
| 68 |
virtual unsigned short getPan(int chan) override; |
| 69 |
virtual DivDispatchOscBuffer* getOscBuffer(int chan) override; |
| 70 |
virtual unsigned char* getRegisterPool() override; |
| 71 |
virtual int getRegisterPoolSize() override; |
| 72 |
virtual void reset() override; |
| 73 |
virtual void forceIns() override; |
| 74 |
virtual void tick(bool sysTick=true) override; |
| 75 |
virtual void muteChannel(int ch, bool mute) override; |
| 76 |
virtual int getOutputCount() override; |
| 77 |
virtual void notifyInsChange(int ins) override; |
| 78 |
virtual void notifyWaveChange(int wave) override; |
| 79 |
virtual void notifyInsDeletion(void* ins) override; |
| 80 |
virtual void setFlags(const DivConfig& flags) override; |
| 81 |
virtual void poke(unsigned int addr, unsigned short val) override; |
| 82 |
virtual void poke(std::vector<DivRegWrite>& wlist) override; |
| 83 |
virtual const char** getRegisterSheet() override; |
| 84 |
virtual const void* getSampleMem(int index = 0) override; |
| 85 |
virtual size_t getSampleMemCapacity(int index = 0) override; |
| 86 |
virtual size_t getSampleMemUsage(int index = 0) override; |
| 87 |
virtual bool isSampleLoaded(int index, int sample) override; |
| 88 |
virtual const DivMemoryComposition* getMemCompo(int index) override; |
| 89 |
virtual void renderSamples(int chipID) override; |
| 90 |
virtual int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) override; |
| 91 |
virtual void quit() override; |
| 92 |
DivPlatformK053260(); |
| 93 |
~DivPlatformK053260(); |
| 94 |
private: |
| 95 |
void chWrite(unsigned char ch, unsigned int addr, unsigned char val); |
| 96 |
}; |
| 97 |
|
| 98 |
#endif |