| 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 _FDS_H |
| 21 |
#define _FDS_H |
| 22 |
|
| 23 |
#include "../dispatch.h" |
| 24 |
#include "../waveSynth.h" |
| 25 |
|
| 26 |
#include "sound/nes_nsfplay/nes_fds.h" |
| 27 |
|
| 28 |
class DivPlatformFDS: public DivDispatch { |
| 29 |
struct Channel: public SharedChannel<signed char> { |
| 30 |
int prevFreq, modFreq; |
| 31 |
unsigned char duty, sweep, modDepth, modPos; |
| 32 |
unsigned char autoModNum, autoModDen; |
| 33 |
bool sweepChanged, modOn; |
| 34 |
signed short wave; |
| 35 |
signed char modTable[32]; |
| 36 |
Channel(): |
| 37 |
SharedChannel<signed char>(32), |
| 38 |
prevFreq(65535), |
| 39 |
modFreq(0), |
| 40 |
duty(0), |
| 41 |
sweep(8), |
| 42 |
modDepth(0), |
| 43 |
modPos(0), |
| 44 |
autoModNum(0), |
| 45 |
autoModDen(0), |
| 46 |
sweepChanged(false), |
| 47 |
modOn(false), |
| 48 |
wave(-1) { |
| 49 |
memset(modTable,0,32); |
| 50 |
} |
| 51 |
}; |
| 52 |
Channel chan[1]; |
| 53 |
DivDispatchOscBuffer* oscBuf; |
| 54 |
bool isMuted[1]; |
| 55 |
DivWaveSynth ws; |
| 56 |
unsigned char writeOscBuf; |
| 57 |
bool useNP; |
| 58 |
struct _fds* fds; |
| 59 |
xgm::NES_FDS* fds_NP; |
| 60 |
unsigned char regPool[128]; |
| 61 |
|
| 62 |
void updateWave(); |
| 63 |
|
| 64 |
friend void putDispatchChip(void*,int); |
| 65 |
friend void putDispatchChan(void*,int,int); |
| 66 |
|
| 67 |
void doWrite(unsigned short addr, unsigned char data); |
| 68 |
void acquire_puNES(short* buf, size_t len); |
| 69 |
void acquire_NSFPlay(short* buf, size_t len); |
| 70 |
|
| 71 |
public: |
| 72 |
void acquire(short** buf, size_t len); |
| 73 |
int dispatch(DivCommand c); |
| 74 |
void* getChanState(int chan); |
| 75 |
DivMacroInt* getChanMacroInt(int ch); |
| 76 |
DivDispatchOscBuffer* getOscBuffer(int chan); |
| 77 |
unsigned char* getRegisterPool(); |
| 78 |
int getRegisterPoolSize(); |
| 79 |
void reset(); |
| 80 |
void forceIns(); |
| 81 |
void tick(bool sysTick=true); |
| 82 |
void muteChannel(int ch, bool mute); |
| 83 |
bool keyOffAffectsArp(int ch); |
| 84 |
void setNSFPlay(bool use); |
| 85 |
void setFlags(const DivConfig& flags); |
| 86 |
void notifyInsDeletion(void* ins); |
| 87 |
float getPostAmp(); |
| 88 |
void poke(unsigned int addr, unsigned short val); |
| 89 |
void poke(std::vector<DivRegWrite>& wlist); |
| 90 |
const char** getRegisterSheet(); |
| 91 |
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); |
| 92 |
void quit(); |
| 93 |
~DivPlatformFDS(); |
| 94 |
}; |
| 95 |
|
| 96 |
#endif |