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