SMS: prepare for don't reset phase flag

This commit is contained in:
tildearrow 2022-02-07 18:34:04 -05:00
parent fbb6c4cb4f
commit e6201b8390
2 changed files with 12 additions and 7 deletions

View file

@ -73,18 +73,19 @@ void DivPlatformSMS::tick() {
} }
} }
if (chan[3].freqChanged || updateSNMode) { if (chan[3].freqChanged || updateSNMode) {
updateSNMode=false;
// seems arbitrary huh? // seems arbitrary huh?
chan[3].freq=parent->calcFreq(chan[3].baseFreq,chan[3].pitch-1-(isRealSN?127:0),true); chan[3].freq=parent->calcFreq(chan[3].baseFreq,chan[3].pitch-1-(isRealSN?127:0),true);
if (chan[3].freq>1023) chan[3].freq=1023; if (chan[3].freq>1023) chan[3].freq=1023;
if (chan[3].actualNote>0x5d) chan[3].freq=0x01; if (chan[3].actualNote>0x5d) chan[3].freq=0x01;
chan[3].freqChanged=false; chan[3].freqChanged=false;
if (snNoiseMode&2) { // take period from channel 3 if (snNoiseMode&2) { // take period from channel 3
if (updateSNMode || resetPhase) {
if (snNoiseMode&1) { if (snNoiseMode&1) {
rWrite(0xe7); rWrite(0xe7);
} else { } else {
rWrite(0xe3); rWrite(0xe3);
} }
}
rWrite(0xdf); rWrite(0xdf);
rWrite(0xc0|(chan[3].freq&15)); rWrite(0xc0|(chan[3].freq&15));
rWrite(chan[3].freq>>4); rWrite(chan[3].freq>>4);
@ -104,6 +105,7 @@ void DivPlatformSMS::tick() {
rWrite(0xe0|value|((snNoiseMode&1)<<2)); rWrite(0xe0|value|((snNoiseMode&1)<<2));
} }
} }
updateSNMode=false;
} }
} }
@ -224,7 +226,7 @@ void DivPlatformSMS::reset() {
} }
sn->device_start(); sn->device_start();
snNoiseMode=3; snNoiseMode=3;
updateSNMode=false; updateSNMode=true;
} }
bool DivPlatformSMS::keyOffAffectsArp(int ch) { bool DivPlatformSMS::keyOffAffectsArp(int ch) {
@ -261,8 +263,9 @@ void DivPlatformSMS::setFlags(unsigned int flags) {
} else { } else {
chipClock=COLOR_NTSC; chipClock=COLOR_NTSC;
} }
resetPhase=!(flags&16);
if (sn!=NULL) delete sn; if (sn!=NULL) delete sn;
switch (flags>>2) { switch ((flags>>2)&3) {
case 1: // TI case 1: // TI
sn=new sn76496_base_device(0x4000, 0x4000, 0x01, 0x02, true, 1, false, true); sn=new sn76496_base_device(0x4000, 0x4000, 0x01, 0x02, true, 1, false, true);
isRealSN=true; isRealSN=true;
@ -287,6 +290,7 @@ int DivPlatformSMS::init(DivEngine* p, int channels, int sugRate, unsigned int f
parent=p; parent=p;
dumpWrites=false; dumpWrites=false;
skipRegisterWrites=false; skipRegisterWrites=false;
resetPhase=false;
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
isMuted[i]=false; isMuted[i]=false;
} }

View file

@ -32,6 +32,7 @@ class DivPlatformSMS: public DivDispatch {
bool isMuted[4]; bool isMuted[4];
unsigned char snNoiseMode; unsigned char snNoiseMode;
bool updateSNMode; bool updateSNMode;
bool resetPhase;
bool isRealSN; bool isRealSN;
sn76496_base_device* sn; sn76496_base_device* sn;
friend void putDispatchChan(void*,int,int); friend void putDispatchChan(void*,int,int);