bind SMS platform to Genesis one
This commit is contained in:
parent
3172fd37ed
commit
f2c70df4a8
|
@ -6,7 +6,7 @@
|
|||
// TODO fix all the writes.
|
||||
// i think there is no wait for data writes, just for ON/OFF writes
|
||||
void DivPlatformGenesis::acquire(short& l, short& r) {
|
||||
short o[2];
|
||||
static short o[2];
|
||||
|
||||
if (dacMode && dacSample!=-1) {
|
||||
if (--dacPeriod<1) {
|
||||
|
@ -38,8 +38,16 @@ void DivPlatformGenesis::acquire(short& l, short& r) {
|
|||
}
|
||||
OPN2_Clock(&fm,o);
|
||||
//OPN2_Write(&fm,0,0);
|
||||
l=o[0]<<7;
|
||||
r=o[1]<<7;
|
||||
|
||||
psgClocks+=223722;
|
||||
if (psgClocks>=rate) {
|
||||
psg.acquire(psgOut,psgOut);
|
||||
psgClocks-=rate;
|
||||
psgOut>>=2;
|
||||
}
|
||||
|
||||
l=(o[0]<<7)+psgOut;
|
||||
r=(o[1]<<7)+psgOut;
|
||||
}
|
||||
|
||||
static unsigned short chanOffs[6]={
|
||||
|
@ -122,12 +130,17 @@ void DivPlatformGenesis::tick() {
|
|||
chan[i].keyOn=false;
|
||||
}
|
||||
}
|
||||
|
||||
psg.tick();
|
||||
}
|
||||
|
||||
#define rWrite(a,v) pendingWrites[a]=v;
|
||||
|
||||
int DivPlatformGenesis::dispatch(DivCommand c) {
|
||||
if (c.chan>5) return 0;
|
||||
if (c.chan>5) {
|
||||
c.chan-=6;
|
||||
return psg.dispatch(c);
|
||||
}
|
||||
switch (c.cmd) {
|
||||
case DIV_CMD_NOTE_ON: {
|
||||
if (c.chan==5 && dacMode) {
|
||||
|
@ -313,5 +326,10 @@ int DivPlatformGenesis::init(DivEngine* p, int channels, int sugRate) {
|
|||
writes.emplace(0x22,0x08);
|
||||
|
||||
delay=0;
|
||||
|
||||
// PSG
|
||||
psg.init(p,4,sugRate);
|
||||
psgClocks=0;
|
||||
psgOut=0;
|
||||
return 10;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include <queue>
|
||||
#include "../../../extern/Nuked-OPN2/ym3438.h"
|
||||
|
||||
#include "sms.h"
|
||||
|
||||
class DivPlatformGenesis: public DivDispatch {
|
||||
struct Channel {
|
||||
unsigned char freqH, freqL;
|
||||
|
@ -22,6 +24,9 @@ class DivPlatformGenesis: public DivDispatch {
|
|||
};
|
||||
std::queue<QueuedWrite> writes;
|
||||
ym3438_t fm;
|
||||
DivPlatformSMS psg;
|
||||
int psgClocks;
|
||||
short psgOut;
|
||||
int delay;
|
||||
unsigned char lastBusy;
|
||||
|
||||
|
|
|
@ -56,6 +56,8 @@ int DivPlatformSMS::dispatch(DivCommand c) {
|
|||
break;
|
||||
case DIV_CMD_NOTE_OFF:
|
||||
chan[c.chan].active=false;
|
||||
sn->write(0x9f|c.chan<<5);
|
||||
chan[c.chan].std.init(NULL);
|
||||
break;
|
||||
case DIV_CMD_INSTRUMENT:
|
||||
chan[c.chan].ins=c.value;
|
||||
|
@ -84,7 +86,7 @@ int DivPlatformSMS::init(DivEngine* p, int channels, int sugRate) {
|
|||
rate=223722;
|
||||
sn=new sn76496_device("sn",223722);
|
||||
sn->device_start();
|
||||
snNoiseMode=0;
|
||||
snNoiseMode=3;
|
||||
updateSNMode=false;
|
||||
return 4;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef _SMS_H
|
||||
#define _SMS_H
|
||||
|
||||
#include "../dispatch.h"
|
||||
#include "../macroInt.h"
|
||||
#include "sound/sn76496.h"
|
||||
|
@ -21,3 +24,5 @@ class DivPlatformSMS: public DivDispatch {
|
|||
void tick();
|
||||
int init(DivEngine* parent, int channels, int sugRate);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue