furnace/src/engine/platform/pce.h

63 lines
1.4 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 {
int freq, baseFreq, pitch;
2021-06-09 04:16:29 +00:00
int dacPeriod, dacRate, dacPos, dacSample;
unsigned char ins, note, pan;
2021-06-09 04:16:29 +00:00
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise, pcm;
signed char vol, outVol, wave;
DivMacroInt std;
Channel():
freq(0),
baseFreq(0),
pitch(0),
2021-12-04 06:19:54 +00:00
dacPeriod(0),
dacRate(0),
dacPos(0),
dacSample(0),
ins(-1),
note(0),
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),
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];
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;
2021-06-07 07:49:43 +00:00
int tempL, tempR, cycles, curChan, delay;
2021-12-09 08:13:37 +00:00
int sampleBank;
PCE_PSG* pce;
2021-06-07 07:49:43 +00:00
void updateWave(int ch);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
int dispatch(DivCommand c);
void tick();
bool isStereo();
2021-12-08 05:33:00 +00:00
bool keyOffAffectsArp(int ch);
int init(DivEngine* parent, int channels, int sugRate, bool pal);
};
#endif