furnace/src/engine/platform/pce.h

118 lines
3.4 KiB
C
Raw Normal View History

2022-02-15 03:12:20 +00:00
/**
* Furnace Tracker - multi-system chiptune tracker
* Copyright (C) 2021-2022 tildearrow and contributors
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _PCE_H
#define _PCE_H
#include "../dispatch.h"
2021-06-07 07:49:43 +00:00
#include <queue>
#include "../macroInt.h"
#include "../waveSynth.h"
#include "sound/pce_psg.h"
class DivPlatformPCE: public DivDispatch {
struct Channel {
2022-07-30 06:00:51 +00:00
int freq, baseFreq, pitch, pitch2, note, antiClickPeriodCount, antiClickWavePos;
2021-12-14 17:33:26 +00:00
int dacPeriod, dacRate;
unsigned int dacPos;
int dacSample, ins;
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise, pcm, furnaceDac, deferredWaveUpdate;
signed char vol, outVol, wave;
DivMacroInt std;
DivWaveSynth ws;
2022-04-28 06:31:16 +00:00
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
2022-04-28 05:50:09 +00:00
pitch2(0),
2022-01-18 21:55:32 +00:00
note(0),
2022-07-30 06:00:51 +00:00
antiClickPeriodCount(0),
antiClickWavePos(0),
2021-12-04 06:19:54 +00:00
dacPeriod(0),
dacRate(0),
dacPos(0),
dacSample(-1),
ins(-1),
2021-06-07 07:49:43 +00:00
pan(255),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
noise(false),
2021-06-09 04:16:29 +00:00
pcm(false),
furnaceDac(false),
deferredWaveUpdate(false),
2021-06-07 07:49:43 +00:00
vol(31),
2021-06-08 21:46:27 +00:00
outVol(31),
wave(-1) {}
};
2021-06-07 07:49:43 +00:00
Channel chan[6];
DivDispatchOscBuffer* oscBuf[6];
2021-12-18 08:25:42 +00:00
bool isMuted[6];
2022-07-30 06:00:51 +00:00
bool antiClickEnabled;
2021-06-07 07:49:43 +00:00
struct QueuedWrite {
unsigned char addr;
unsigned char val;
QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
};
std::queue<QueuedWrite> writes;
unsigned char lastPan;
2022-01-13 03:14:20 +00:00
int cycles, curChan, delay;
int tempL[32];
int tempR[32];
2022-02-05 21:19:22 +00:00
unsigned char sampleBank, lfoMode, lfoSpeed;
PCE_PSG* pce;
unsigned char regPool[128];
2021-06-07 07:49:43 +00:00
void updateWave(int ch);
2022-01-27 05:29:16 +00:00
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
int dispatch(DivCommand c);
2022-01-27 05:29:16 +00:00
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
DivDispatchOscBuffer* getOscBuffer(int chan);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
2021-12-11 18:14:38 +00:00
void reset();
void forceIns();
void tick(bool sysTick=true);
2021-12-18 08:25:42 +00:00
void muteChannel(int ch, bool mute);
bool isStereo();
2021-12-08 05:33:00 +00:00
bool keyOffAffectsArp(int ch);
2022-01-28 17:59:53 +00:00
void setFlags(unsigned int flags);
2022-01-18 05:25:10 +00:00
void notifyWaveChange(int wave);
void notifyInsDeletion(void* ins);
2022-02-01 23:08:19 +00:00
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
2022-02-03 23:38:57 +00:00
const char** getRegisterSheet();
2022-01-28 17:59:53 +00:00
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit();
~DivPlatformPCE();
};
#endif