furnace/src/engine/platform/pce.h

77 lines
1.7 KiB
C
Raw Normal View History

#ifndef _PCE_H
#define _PCE_H
#include "../dispatch.h"
2021-06-07 03:49:43 -04:00
#include <queue>
#include "../macroInt.h"
#include "sound/pce_psg.h"
class DivPlatformPCE: public DivDispatch {
struct Channel {
2022-01-18 16:55:32 -05:00
int freq, baseFreq, pitch, note;
2021-12-14 12:33:26 -05:00
int dacPeriod, dacRate;
unsigned int dacPos;
int dacSample;
2022-01-18 16:55:32 -05: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 16:55:32 -05:00
note(0),
2021-12-04 01:19:54 -05:00
dacPeriod(0),
dacRate(0),
dacPos(0),
dacSample(-1),
ins(-1),
2021-06-07 03:49:43 -04:00
pan(255),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
noise(false),
2021-06-09 00:16:29 -04:00
pcm(false),
furnaceDac(false),
2021-06-07 03:49:43 -04:00
vol(31),
2021-06-08 17:46:27 -04:00
outVol(31),
wave(-1) {}
};
2021-06-07 03:49:43 -04:00
Channel chan[6];
2021-12-18 03:25:42 -05:00
bool isMuted[6];
2021-06-07 03:49:43 -04: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-12 22:14:20 -05:00
int cycles, curChan, delay;
int tempL[32];
int tempR[32];
2021-12-14 12:33:26 -05:00
unsigned char sampleBank;
PCE_PSG* pce;
2021-06-07 03:49:43 -04:00
void updateWave(int ch);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
int dispatch(DivCommand c);
2021-12-11 13:14:38 -05:00
void reset();
void forceIns();
void tick();
2021-12-18 03:25:42 -05:00
void muteChannel(int ch, bool mute);
bool isStereo();
2021-12-08 00:33:00 -05:00
bool keyOffAffectsArp(int ch);
2021-12-15 17:32:08 -05:00
void setPAL(bool pal);
2022-01-18 00:25:10 -05:00
void notifyWaveChange(int wave);
void notifyInsDeletion(void* ins);
int init(DivEngine* parent, int channels, int sugRate, bool pal);
void quit();
~DivPlatformPCE();
};
#endif