furnace/src/engine/platform/pce.h

79 lines
1.8 KiB
C
Raw Normal View History

#ifndef _PCE_H
#define _PCE_H
#include "../dispatch.h"
2021-06-07 07:49:43 +00:00
#include <queue>
#include "../macroInt.h"
#include "sound/pce_psg.h"
class DivPlatformPCE: public DivDispatch {
struct Channel {
2022-01-18 21:55:32 +00:00
int freq, baseFreq, pitch, note;
2021-12-14 17:33:26 +00:00
int dacPeriod, dacRate;
unsigned int dacPos;
int dacSample;
2022-01-18 21:55:32 +00:00
unsigned char ins, pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise, pcm, furnaceDac;
signed char vol, outVol, wave;
DivMacroInt std;
Channel():
freq(0),
baseFreq(0),
pitch(0),
2022-01-18 21:55:32 +00:00
note(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),
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];
2021-12-18 08:25:42 +00:00
bool isMuted[6];
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];
2021-12-14 17:33:26 +00:00
unsigned char sampleBank;
PCE_PSG* pce;
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);
2021-12-11 18:14:38 +00:00
void reset();
void forceIns();
void tick();
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-01-28 17:59:53 +00:00
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit();
~DivPlatformPCE();
};
#endif