2021-06-06 19:02:38 +00:00
|
|
|
#ifndef _PCE_H
|
|
|
|
#define _PCE_H
|
|
|
|
|
|
|
|
#include "../dispatch.h"
|
2021-06-07 07:49:43 +00:00
|
|
|
#include <queue>
|
2021-06-06 19:02:38 +00:00
|
|
|
#include "../macroInt.h"
|
|
|
|
#include "sound/pce_psg.h"
|
|
|
|
|
|
|
|
class DivPlatformPCE: public DivDispatch {
|
|
|
|
struct Channel {
|
|
|
|
int freq, baseFreq, pitch;
|
2021-06-07 07:49:43 +00:00
|
|
|
unsigned char ins, note, duty, pan;
|
|
|
|
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
|
2021-06-06 19:02:38 +00:00
|
|
|
signed char vol, outVol, wave;
|
|
|
|
DivMacroInt std;
|
|
|
|
Channel():
|
|
|
|
freq(0),
|
|
|
|
baseFreq(0),
|
|
|
|
pitch(0),
|
|
|
|
ins(-1),
|
|
|
|
note(0),
|
|
|
|
duty(0),
|
2021-06-07 07:49:43 +00:00
|
|
|
pan(255),
|
2021-06-06 19:02:38 +00:00
|
|
|
active(false),
|
|
|
|
insChanged(true),
|
|
|
|
freqChanged(false),
|
|
|
|
keyOn(false),
|
|
|
|
keyOff(false),
|
|
|
|
inPorta(false),
|
2021-06-07 07:49:43 +00:00
|
|
|
vol(31),
|
2021-06-06 19:02:38 +00:00
|
|
|
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;
|
2021-06-06 19:02:38 +00:00
|
|
|
unsigned char lastPan;
|
|
|
|
|
2021-06-07 07:49:43 +00:00
|
|
|
int tempL, tempR, cycles, curChan, delay;
|
2021-06-06 19:02:38 +00:00
|
|
|
PCE_PSG* pce;
|
2021-06-07 07:49:43 +00:00
|
|
|
void updateWave(int ch);
|
2021-06-06 19:02:38 +00:00
|
|
|
public:
|
|
|
|
void acquire(int& l, int& r);
|
|
|
|
int dispatch(DivCommand c);
|
|
|
|
void tick();
|
|
|
|
int init(DivEngine* parent, int channels, int sugRate);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|