| 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 _PLATFORM_VB_H |
| 21 |
#define _PLATFORM_VB_H |
| 22 |
|
| 23 |
#include "../dispatch.h" |
| 24 |
#include "../../fixedQueue.h" |
| 25 |
#include "../waveSynth.h" |
| 26 |
#include "sound/vsu.h" |
| 27 |
|
| 28 |
class DivPlatformVB: public DivDispatch { |
| 29 |
struct Channel: public SharedChannel<signed char> { |
| 30 |
int antiClickPeriodCount, antiClickWavePos; |
| 31 |
unsigned char pan, envLow, envHigh; |
| 32 |
bool noise, deferredWaveUpdate, intWritten; |
| 33 |
unsigned char hasEnvWarning; |
| 34 |
signed short wave; |
| 35 |
DivWaveSynth ws; |
| 36 |
Channel(): |
| 37 |
SharedChannel<signed char>(15), |
| 38 |
antiClickPeriodCount(0), |
| 39 |
antiClickWavePos(0), |
| 40 |
pan(255), |
| 41 |
envLow(0), |
| 42 |
envHigh(0), |
| 43 |
noise(false), |
| 44 |
deferredWaveUpdate(false), |
| 45 |
intWritten(false), |
| 46 |
hasEnvWarning(0), |
| 47 |
wave(-1) {} |
| 48 |
}; |
| 49 |
Channel chan[6]; |
| 50 |
DivDispatchOscBuffer* oscBuf[6]; |
| 51 |
bool isMuted[6]; |
| 52 |
bool antiClickEnabled, screwThis; |
| 53 |
struct QueuedWrite { |
| 54 |
unsigned short addr; |
| 55 |
unsigned char val; |
| 56 |
QueuedWrite(): addr(0), val(0) {} |
| 57 |
QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {} |
| 58 |
}; |
| 59 |
FixedQueue<QueuedWrite,2048> writes; |
| 60 |
unsigned char lastPan; |
| 61 |
|
| 62 |
int cycles, curChan, delay; |
| 63 |
int tempL; |
| 64 |
int tempR; |
| 65 |
unsigned char modulation; |
| 66 |
bool modType; |
| 67 |
bool romMode; |
| 68 |
signed char modTable[32]; |
| 69 |
int coreQuality; |
| 70 |
VSU* vb; |
| 71 |
unsigned char regPool[0x600]; |
| 72 |
void updateWave(int ch); |
| 73 |
void updateROMWaves(); |
| 74 |
void writeEnv(int ch, bool upperByteToo=false); |
| 75 |
friend void putDispatchChip(void*,int); |
| 76 |
friend void putDispatchChan(void*,int,int); |
| 77 |
public: |
| 78 |
void acquireDirect(blip_buffer_t** bb, size_t len); |
| 79 |
int dispatch(DivCommand c); |
| 80 |
void* getChanState(int chan); |
| 81 |
DivMacroInt* getChanMacroInt(int ch); |
| 82 |
unsigned short getPan(int chan); |
| 83 |
DivChannelModeHints getModeHints(int chan); |
| 84 |
DivDispatchOscBuffer* getOscBuffer(int chan); |
| 85 |
unsigned char* getRegisterPool(); |
| 86 |
int getRegisterPoolSize(); |
| 87 |
int getRegisterPoolDepth(); |
| 88 |
void reset(); |
| 89 |
void forceIns(); |
| 90 |
void tick(bool sysTick=true); |
| 91 |
void muteChannel(int ch, bool mute); |
| 92 |
int getOutputCount(); |
| 93 |
bool keyOffAffectsArp(int ch); |
| 94 |
bool hasAcquireDirect(); |
| 95 |
float getPostAmp(); |
| 96 |
void setFlags(const DivConfig& flags); |
| 97 |
void notifyWaveChange(int wave); |
| 98 |
void notifyInsDeletion(void* ins); |
| 99 |
void poke(unsigned int addr, unsigned short val); |
| 100 |
void poke(std::vector<DivRegWrite>& wlist); |
| 101 |
const char** getRegisterSheet(); |
| 102 |
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); |
| 103 |
void quit(); |
| 104 |
~DivPlatformVB(); |
| 105 |
}; |
| 106 |
|
| 107 |
#endif |