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;
|
2022-01-23 15:55:12 -05:00
|
|
|
int freq, baseFreq, pitch, note;
|
2021-05-16 18:43:10 -04:00
|
|
|
unsigned char ins;
|
2022-01-23 15:55:12 -05:00
|
|
|
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac, inPorta;
|
2022-01-26 18:03:08 -05:00
|
|
|
int vol, outVol;
|
2021-05-16 18:43:10 -04:00
|
|
|
unsigned char pan;
|
2022-01-23 15:55:12 -05:00
|
|
|
Channel():
|
|
|
|
freqH(0),
|
|
|
|
freqL(0),
|
|
|
|
freq(0),
|
|
|
|
baseFreq(0),
|
|
|
|
pitch(0),
|
|
|
|
note(0),
|
|
|
|
ins(-1),
|
|
|
|
active(false),
|
|
|
|
insChanged(true),
|
|
|
|
freqChanged(false),
|
|
|
|
keyOn(false),
|
|
|
|
keyOff(false),
|
|
|
|
portaPause(false),
|
|
|
|
furnaceDac(false),
|
|
|
|
inPorta(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;
|
2022-01-23 15:15:46 -05:00
|
|
|
unsigned char lfoValue;
|
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);
|
2022-01-27 00:29:16 -05:00
|
|
|
|
|
|
|
friend void putDispatchChan(void*,int,int);
|
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);
|
2022-01-27 00:29:16 -05:00
|
|
|
void* getChanState(int chan);
|
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);
|
2022-01-24 01:01:08 -05:00
|
|
|
void toggleRegisterDump(bool enable);
|
2022-01-28 12:59:53 -05:00
|
|
|
void setFlags(unsigned int flags);
|
2022-01-17 23:59:52 -05:00
|
|
|
void notifyInsChange(int ins);
|
2022-01-13 19:36:02 -05:00
|
|
|
void notifyInsDeletion(void* ins);
|
2022-01-30 15:55:31 -05:00
|
|
|
int getPortaFloor(int ch);
|
2022-01-28 12:59:53 -05:00
|
|
|
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
|
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
|