2021-05-16 18:43:10 -04:00
|
|
|
#ifndef _GENESIS_H
|
|
|
|
#define _GENESIS_H
|
2021-05-12 18:19:18 -04:00
|
|
|
#include "../dispatch.h"
|
|
|
|
#include <queue>
|
|
|
|
#include "../../../extern/Nuked-OPN2/ym3438.h"
|
|
|
|
|
2021-05-15 17:59:57 -04:00
|
|
|
#include "sms.h"
|
|
|
|
|
2021-05-12 18:19:18 -04:00
|
|
|
class DivPlatformGenesis: public DivDispatch {
|
2021-05-16 18:43:10 -04:00
|
|
|
protected:
|
|
|
|
struct Channel {
|
2022-01-22 17:43:57 -05:00
|
|
|
DivInstrumentFM state;
|
2022-01-23 13:19:19 -05:00
|
|
|
DivMacroInt std;
|
2021-05-16 18:43:10 -04:00
|
|
|
unsigned char freqH, freqL;
|
|
|
|
int freq, baseFreq, pitch;
|
|
|
|
unsigned char ins;
|
|
|
|
signed char konCycles;
|
2022-01-20 16:09:05 -05:00
|
|
|
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac;
|
2021-05-17 16:51:12 -04:00
|
|
|
int vol;
|
2021-05-16 18:43:10 -04:00
|
|
|
unsigned char pan;
|
2022-01-20 16:09:05 -05:00
|
|
|
Channel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false), furnaceDac(false), vol(0), pan(3) {}
|
2021-05-16 18:43:10 -04:00
|
|
|
};
|
|
|
|
Channel chan[10];
|
2021-12-18 03:25:42 -05:00
|
|
|
bool isMuted[10];
|
2021-05-16 18:43:10 -04:00
|
|
|
struct QueuedWrite {
|
|
|
|
unsigned short addr;
|
|
|
|
unsigned char val;
|
|
|
|
bool addrOrVal;
|
|
|
|
QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {}
|
|
|
|
};
|
|
|
|
std::queue<QueuedWrite> writes;
|
|
|
|
ym3438_t fm;
|
|
|
|
DivPlatformSMS psg;
|
|
|
|
int psgClocks;
|
|
|
|
int psgOut;
|
|
|
|
int delay;
|
|
|
|
unsigned char lastBusy;
|
|
|
|
|
|
|
|
bool dacMode;
|
|
|
|
int dacPeriod;
|
|
|
|
int dacRate;
|
2021-12-14 12:33:26 -05:00
|
|
|
unsigned int dacPos;
|
2021-05-16 18:43:10 -04:00
|
|
|
int dacSample;
|
2021-12-14 12:33:26 -05:00
|
|
|
unsigned char sampleBank;
|
2021-05-16 21:49:54 -04:00
|
|
|
|
|
|
|
bool extMode;
|
2021-05-16 18:43:10 -04:00
|
|
|
|
|
|
|
short oldWrites[512];
|
|
|
|
short pendingWrites[512];
|
2021-05-18 02:20:38 -04:00
|
|
|
|
|
|
|
int octave(int freq);
|
2021-05-19 15:39:39 -04:00
|
|
|
int toFreq(int freq);
|
2021-05-16 18:43:10 -04:00
|
|
|
|
2021-05-12 18:19:18 -04:00
|
|
|
public:
|
2021-12-06 16:51:18 -05:00
|
|
|
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
2021-05-12 18:19:18 -04:00
|
|
|
int dispatch(DivCommand c);
|
2021-12-11 13:14:38 -05:00
|
|
|
void reset();
|
2021-12-21 01:29:07 -05:00
|
|
|
void forceIns();
|
2021-05-12 18:19:18 -04:00
|
|
|
void tick();
|
2021-12-18 03:25:42 -05:00
|
|
|
void muteChannel(int ch, bool mute);
|
2021-12-06 16:51:18 -05:00
|
|
|
bool isStereo();
|
2021-12-08 00:33:00 -05:00
|
|
|
bool keyOffAffectsArp(int ch);
|
2021-12-29 02:08:50 -05:00
|
|
|
bool keyOffAffectsPorta(int ch);
|
2021-12-15 17:32:08 -05:00
|
|
|
void setPAL(bool pal);
|
2022-01-17 23:59:52 -05:00
|
|
|
void notifyInsChange(int ins);
|
2022-01-13 19:36:02 -05:00
|
|
|
void notifyInsDeletion(void* ins);
|
2021-12-08 01:56:40 -05:00
|
|
|
int init(DivEngine* parent, int channels, int sugRate, bool pal);
|
2021-12-15 00:37:27 -05:00
|
|
|
void quit();
|
|
|
|
~DivPlatformGenesis();
|
2021-05-12 18:19:18 -04:00
|
|
|
};
|
2021-05-16 18:43:10 -04:00
|
|
|
#endif
|