Merge branch 'master' into feature/More-OPL-Patch-Support

This commit is contained in:
James Alan Nguyen 2022-04-16 09:11:45 +10:00
commit 836fb57f14
80 changed files with 130 additions and 106 deletions

View file

@ -245,8 +245,9 @@ class DivDispatch {
/** /**
* ticks this dispatch. * ticks this dispatch.
* @param sysTick whether the engine has ticked (if not then this may be a sub-tick used in low-latency mode).
*/ */
virtual void tick(); virtual void tick(bool sysTick=true);
/** /**
* get the state of a channel. * get the state of a channel.

View file

@ -2237,6 +2237,8 @@ bool DivEngine::initAudioBackend() {
if (metroVol<0.0f) metroVol=0.0f; if (metroVol<0.0f) metroVol=0.0f;
if (metroVol>2.0f) metroVol=2.0f; if (metroVol>2.0f) metroVol=2.0f;
if (lowLatency) logI("using low latency mode.");
switch (audioEngine) { switch (audioEngine) {
case DIV_AUDIO_JACK: case DIV_AUDIO_JACK:
#ifndef HAVE_JACK #ifndef HAVE_JACK

View file

@ -21,14 +21,19 @@
#include "instrument.h" #include "instrument.h"
#include "engine.h" #include "engine.h"
void DivMacroStruct::doMacro(DivInstrumentMacro& source, bool released) { void DivMacroStruct::doMacro(DivInstrumentMacro& source, bool released, bool tick) {
if (!tick) {
had=false;
return;
}
if (finished) { if (finished) {
finished=false; finished=false;
} }
if (had!=has) { if (actualHad!=has) {
finished=true; finished=true;
} }
had=has; actualHad=has;
had=actualHad;
if (has) { if (has) {
val=source.val[pos++]; val=source.val[pos++];
if (source.rel>=0 && pos>source.rel && !released) { if (source.rel>=0 && pos>source.rel && !released) {
@ -52,17 +57,18 @@ void DivMacroInt::next() {
if (ins==NULL) return; if (ins==NULL) return;
// run macros // run macros
// TODO: potentially get rid of list to avoid allocations // TODO: potentially get rid of list to avoid allocations
if (--subTick<=0) { subTick--;
for (size_t i=0; i<macroListLen; i++) {
if (macroList[i]!=NULL && macroSource[i]!=NULL) {
macroList[i]->doMacro(*macroSource[i],released,subTick==0);
}
}
if (subTick<=0) {
if (e==NULL) { if (e==NULL) {
subTick=1; subTick=1;
} else { } else {
subTick=e->tickMult; subTick=e->tickMult;
} }
for (size_t i=0; i<macroListLen; i++) {
if (macroList[i]!=NULL && macroSource[i]!=NULL) {
macroList[i]->doMacro(*macroSource[i],released);
}
}
} }
} }
@ -85,6 +91,7 @@ void DivMacroInt::init(DivInstrument* which) {
if (macroList[i]!=NULL) macroList[i]->init(); if (macroList[i]!=NULL) macroList[i]->init();
} }
macroListLen=0; macroListLen=0;
subTick=1;
released=false; released=false;

View file

@ -27,17 +27,17 @@ class DivEngine;
struct DivMacroStruct { struct DivMacroStruct {
int pos; int pos;
int val; int val;
bool has, had, finished, will; bool has, had, actualHad, finished, will;
unsigned int mode; unsigned int mode;
void doMacro(DivInstrumentMacro& source, bool released); void doMacro(DivInstrumentMacro& source, bool released, bool tick);
void init() { void init() {
pos=mode=0; pos=mode=0;
has=had=will=false; has=had=actualHad=will=false;
// TODO: test whether this breaks anything? // TODO: test whether this breaks anything?
val=0; val=0;
} }
void prepare(DivInstrumentMacro& source) { void prepare(DivInstrumentMacro& source) {
has=had=will=true; has=had=actualHad=will=true;
mode=source.mode; mode=source.mode;
} }
DivMacroStruct(): DivMacroStruct():
@ -45,6 +45,7 @@ struct DivMacroStruct {
val(0), val(0),
has(false), has(false),
had(false), had(false),
actualHad(false),
finished(false), finished(false),
will(false), will(false),
mode(0) {} mode(0) {}
@ -128,7 +129,7 @@ class DivMacroInt {
e(NULL), e(NULL),
ins(NULL), ins(NULL),
macroListLen(0), macroListLen(0),
subTick(0), subTick(1),
released(false), released(false),
vol(), vol(),
arp(), arp(),

View file

@ -22,7 +22,7 @@
void DivDispatch::acquire(short* bufL, short* bufR, size_t start, size_t len) { void DivDispatch::acquire(short* bufL, short* bufR, size_t start, size_t len) {
} }
void DivDispatch::tick() { void DivDispatch::tick(bool sysTick) {
} }
void* DivDispatch::getChanState(int chan) { void* DivDispatch::getChanState(int chan) {

View file

@ -155,7 +155,7 @@ void DivPlatformAmiga::acquire(short* bufL, short* bufR, size_t start, size_t le
} }
} }
void DivPlatformAmiga::tick() { void DivPlatformAmiga::tick(bool sysTick) {
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -88,7 +88,7 @@ class DivPlatformAmiga: public DivDispatch {
void* getChanState(int chan); void* getChanState(int chan);
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool isStereo(); bool isStereo();
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);

View file

@ -219,7 +219,7 @@ inline int hScale(int note) {
return ((note/12)<<4)+(noteMap[note%12]); return ((note/12)<<4)+(noteMap[note%12]);
} }
void DivPlatformArcade::tick() { void DivPlatformArcade::tick(bool sysTick) {
for (int i=0; i<8; i++) { for (int i=0; i<8; i++) {
chan[i].std.next(); chan[i].std.next();

View file

@ -107,7 +107,7 @@ class DivPlatformArcade: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);

View file

@ -172,7 +172,7 @@ void DivPlatformAY8910::updateOutSel(bool immediate) {
} }
} }
void DivPlatformAY8910::tick() { void DivPlatformAY8910::tick(bool sysTick) {
// PSG // PSG
for (int i=0; i<3; i++) { for (int i=0; i<3; i++) {
chan[i].std.next(); chan[i].std.next();

View file

@ -90,7 +90,7 @@ class DivPlatformAY8910: public DivDispatch {
void flushWrites(); void flushWrites();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);
bool isStereo(); bool isStereo();

View file

@ -187,7 +187,7 @@ const unsigned char regMode[3]={
0x0d, 0x14, 0x15 0x0d, 0x14, 0x15
}; };
void DivPlatformAY8930::tick() { void DivPlatformAY8930::tick(bool sysTick) {
// PSG // PSG
for (int i=0; i<3; i++) { for (int i=0; i<3; i++) {
chan[i].std.next(); chan[i].std.next();

View file

@ -78,7 +78,7 @@ class DivPlatformAY8930: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);
bool isStereo(); bool isStereo();

View file

@ -81,7 +81,7 @@ void DivPlatformBubSysWSG::updateWave(int ch) {
} }
} }
void DivPlatformBubSysWSG::tick() { void DivPlatformBubSysWSG::tick(bool sysTick) {
for (int i=0; i<2; i++) { for (int i=0; i<2; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -67,7 +67,7 @@ class DivPlatformBubSysWSG: public DivDispatch {
int getRegisterPoolDepth(); int getRegisterPoolDepth();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool isStereo(); bool isStereo();
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);

View file

@ -122,7 +122,7 @@ void DivPlatformC64::updateFilter() {
rWrite(0x18,(filtControl<<4)|vol); rWrite(0x18,(filtControl<<4)|vol);
} }
void DivPlatformC64::tick() { void DivPlatformC64::tick(bool sysTick) {
for (int i=0; i<3; i++) { for (int i=0; i<3; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {
@ -166,6 +166,7 @@ void DivPlatformC64::tick() {
rWrite(i*7+2,chan[i].duty&0xff); rWrite(i*7+2,chan[i].duty&0xff);
rWrite(i*7+3,chan[i].duty>>8); rWrite(i*7+3,chan[i].duty>>8);
} }
if (sysTick) {
if (chan[i].testWhen>0) { if (chan[i].testWhen>0) {
if (--chan[i].testWhen<1) { if (--chan[i].testWhen<1) {
if (!chan[i].resetMask) { if (!chan[i].resetMask) {
@ -175,6 +176,7 @@ void DivPlatformC64::tick() {
} }
} }
} }
}
if (chan[i].std.wave.had) { if (chan[i].std.wave.had) {
chan[i].wave=chan[i].std.wave.val; chan[i].wave=chan[i].std.wave.val;
rWrite(i*7+4,(chan[i].wave<<4)|(chan[i].ring<<2)|(chan[i].sync<<1)|(int)(chan[i].active)); rWrite(i*7+4,(chan[i].wave<<4)|(chan[i].ring<<2)|(chan[i].sync<<1)|(int)(chan[i].active));

View file

@ -83,7 +83,7 @@ class DivPlatformC64: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);
void notifyInsChange(int ins); void notifyInsChange(int ins);

View file

@ -38,10 +38,12 @@ void DivPlatformDummy::muteChannel(int ch, bool mute) {
isMuted[ch]=mute; isMuted[ch]=mute;
} }
void DivPlatformDummy::tick() { void DivPlatformDummy::tick(bool sysTick) {
for (unsigned char i=0; i<chans; i++) { for (unsigned char i=0; i<chans; i++) {
if (sysTick) {
chan[i].amp-=3; chan[i].amp-=3;
if (chan[i].amp<16) chan[i].amp=16; if (chan[i].amp<16) chan[i].amp=16;
}
if (chan[i].freqChanged) { if (chan[i].freqChanged) {
chan[i].freqChanged=false; chan[i].freqChanged=false;

View file

@ -41,7 +41,7 @@ class DivPlatformDummy: public DivDispatch {
int dispatch(DivCommand c); int dispatch(DivCommand c);
void* getChanState(int chan); void* getChanState(int chan);
void reset(); void reset();
void tick(); void tick(bool sysTick=true);
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags); int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit(); void quit();
~DivPlatformDummy(); ~DivPlatformDummy();

View file

@ -97,7 +97,7 @@ void DivPlatformFDS::updateWave() {
rWrite(0x4089,0); rWrite(0x4089,0);
} }
void DivPlatformFDS::tick() { void DivPlatformFDS::tick(bool sysTick) {
for (int i=0; i<1; i++) { for (int i=0; i<1; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -77,7 +77,7 @@ class DivPlatformFDS: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);

View file

@ -146,7 +146,7 @@ static unsigned char noiseTable[256]={
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}; };
void DivPlatformGB::tick() { void DivPlatformGB::tick(bool sysTick) {
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.arp.had) { if (chan[i].std.arp.had) {

View file

@ -70,7 +70,7 @@ class DivPlatformGB: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool isStereo(); bool isStereo();
void notifyInsChange(int ins); void notifyInsChange(int ins);

View file

@ -220,7 +220,7 @@ void DivPlatformGenesis::acquire(short* bufL, short* bufR, size_t start, size_t
} }
} }
void DivPlatformGenesis::tick() { void DivPlatformGenesis::tick(bool sysTick) {
for (int i=0; i<6; i++) { for (int i=0; i<6; i++) {
if (i==2 && extMode) continue; if (i==2 && extMode) continue;
chan[i].std.next(); chan[i].std.next();

View file

@ -109,7 +109,7 @@ class DivPlatformGenesis: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool isStereo(); bool isStereo();
void setYMFM(bool use); void setYMFM(bool use);

View file

@ -266,7 +266,7 @@ static int opChanOffsH[4]={
0xad, 0xae, 0xac, 0xa6 0xad, 0xae, 0xac, 0xa6
}; };
void DivPlatformGenesisExt::tick() { void DivPlatformGenesisExt::tick(bool sysTick) {
if (extMode) { if (extMode) {
bool writeSomething=false; bool writeSomething=false;
unsigned char writeMask=2; unsigned char writeMask=2;
@ -283,7 +283,7 @@ void DivPlatformGenesisExt::tick() {
} }
} }
DivPlatformGenesis::tick(); DivPlatformGenesis::tick(sysTick);
bool writeNoteOn=false; bool writeNoteOn=false;
unsigned char writeMask=2; unsigned char writeMask=2;

View file

@ -41,7 +41,7 @@ class DivPlatformGenesisExt: public DivPlatformGenesis {
void* getChanState(int chan); void* getChanState(int chan);
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
bool keyOffAffectsPorta(int ch); bool keyOffAffectsPorta(int ch);

View file

@ -145,7 +145,7 @@ void DivPlatformLynx::acquire(short* bufL, short* bufR, size_t start, size_t len
mikey->sampleAudio( bufL + start, bufR + start, len ); mikey->sampleAudio( bufL + start, bufR + start, len );
} }
void DivPlatformLynx::tick() { void DivPlatformLynx::tick(bool sysTick) {
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -80,7 +80,7 @@ class DivPlatformLynx: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool isStereo(); bool isStereo();
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);

View file

@ -95,7 +95,7 @@ void DivPlatformMMC5::acquire(short* bufL, short* bufR, size_t start, size_t len
} }
} }
void DivPlatformMMC5::tick() { void DivPlatformMMC5::tick(bool sysTick) {
for (int i=0; i<2; i++) { for (int i=0; i<2; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -71,7 +71,7 @@ class DivPlatformMMC5: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
float getPostAmp(); float getPostAmp();

View file

@ -214,7 +214,7 @@ void DivPlatformN163::updateWaveCh(int ch) {
} }
} }
void DivPlatformN163::tick() { void DivPlatformN163::tick(bool sysTick) {
for (int i=0; i<=chanMax; i++) { for (int i=0; i<=chanMax; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -93,7 +93,7 @@ class DivPlatformN163: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);
void notifyWaveChange(int wave); void notifyWaveChange(int wave);

View file

@ -140,7 +140,7 @@ static unsigned char noiseTable[253]={
15 15
}; };
void DivPlatformNES::tick() { void DivPlatformNES::tick(bool sysTick) {
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -72,7 +72,7 @@ class DivPlatformNES: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
float getPostAmp(); float getPostAmp();

View file

@ -228,7 +228,7 @@ void DivPlatformOPL::acquire(short* bufL, short* bufR, size_t start, size_t len)
//} //}
} }
void DivPlatformOPL::tick() { void DivPlatformOPL::tick(bool sysTick) {
for (int i=0; i<totalChans; i++) { for (int i=0; i<totalChans; i++) {
int ops=(slots[3][i]!=255 && chan[i].state.ops==4 && oplType==3)?4:2; int ops=(slots[3][i]!=255 && chan[i].state.ops==4 && oplType==3)?4:2;
chan[i].std.next(); chan[i].std.next();

View file

@ -104,7 +104,7 @@ class DivPlatformOPL: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool isStereo(); bool isStereo();
void setYMFM(bool use); void setYMFM(bool use);

View file

@ -111,7 +111,7 @@ void DivPlatformOPLL::acquire(short* bufL, short* bufR, size_t start, size_t len
acquire_nuked(bufL,bufR,start,len); acquire_nuked(bufL,bufR,start,len);
} }
void DivPlatformOPLL::tick() { void DivPlatformOPLL::tick(bool sysTick) {
for (int i=0; i<11; i++) { for (int i=0; i<11; i++) {
chan[i].std.next(); chan[i].std.next();

View file

@ -100,7 +100,7 @@ class DivPlatformOPLL: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void setYMFM(bool use); void setYMFM(bool use);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);

View file

@ -146,7 +146,7 @@ static unsigned char noiseFreq[12]={
4,13,15,18,21,23,25,27,29,31,0,2 4,13,15,18,21,23,25,27,29,31,0,2
}; };
void DivPlatformPCE::tick() { void DivPlatformPCE::tick(bool sysTick) {
for (int i=0; i<6; i++) { for (int i=0; i<6; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -87,7 +87,7 @@ class DivPlatformPCE: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool isStereo(); bool isStereo();
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);

View file

@ -164,7 +164,7 @@ void DivPlatformPCSpeaker::acquire(short* bufL, short* bufR, size_t start, size_
} }
} }
void DivPlatformPCSpeaker::tick() { void DivPlatformPCSpeaker::tick(bool sysTick) {
for (int i=0; i<1; i++) { for (int i=0; i<1; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -77,7 +77,7 @@ class DivPlatformPCSpeaker: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);

View file

@ -85,7 +85,7 @@ void DivPlatformPET::writeOutVol() {
} }
} }
void DivPlatformPET::tick() { void DivPlatformPET::tick(bool sysTick) {
chan.std.next(); chan.std.next();
if (chan.std.vol.had) { if (chan.std.vol.had) {
chan.outVol=chan.std.vol.val&chan.vol; chan.outVol=chan.std.vol.val&chan.vol;

View file

@ -65,7 +65,7 @@ class DivPlatformPET: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void notifyInsDeletion(void* ins); void notifyInsDeletion(void* ins);
bool isStereo(); bool isStereo();

View file

@ -274,7 +274,7 @@ void DivPlatformQSound::acquire(short* bufL, short* bufR, size_t start, size_t l
} }
} }
void DivPlatformQSound::tick() { void DivPlatformQSound::tick(bool sysTick) {
for (int i=0; i<16; i++) { for (int i=0; i<16; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -74,7 +74,7 @@ class DivPlatformQSound: public DivDispatch {
int getRegisterPoolDepth(); int getRegisterPoolDepth();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool isStereo(); bool isStereo();
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);

View file

@ -132,7 +132,7 @@ inline unsigned char applyPan(unsigned char vol, unsigned char pan) {
return ((vol*(pan>>4))/15)|(((vol*(pan&15))/15)<<4); return ((vol*(pan>>4))/15)|(((vol*(pan&15))/15)<<4);
} }
void DivPlatformSAA1099::tick() { void DivPlatformSAA1099::tick(bool sysTick) {
for (int i=0; i<6; i++) { for (int i=0; i<6; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -90,7 +90,7 @@ class DivPlatformSAA1099: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void setCore(DivSAACores core); void setCore(DivSAACores core);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);

View file

@ -76,7 +76,7 @@ void DivPlatformSegaPCM::acquire(short* bufL, short* bufR, size_t start, size_t
} }
} }
void DivPlatformSegaPCM::tick() { void DivPlatformSegaPCM::tick(bool sysTick) {
for (int i=0; i<16; i++) { for (int i=0; i<16; i++) {
chan[i].std.next(); chan[i].std.next();

View file

@ -78,7 +78,7 @@ class DivPlatformSegaPCM: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);

View file

@ -53,7 +53,7 @@ int DivPlatformSMS::acquireOne() {
return v; return v;
} }
void DivPlatformSMS::tick() { void DivPlatformSMS::tick(bool sysTick) {
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -63,7 +63,7 @@ class DivPlatformSMS: public DivDispatch {
void* getChanState(int chan); void* getChanState(int chan);
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
bool keyOffAffectsPorta(int ch); bool keyOffAffectsPorta(int ch);

View file

@ -141,7 +141,7 @@ void DivPlatformSwan::writeOutVol(int ch) {
} }
} }
void DivPlatformSwan::tick() { void DivPlatformSwan::tick(bool sysTick) {
unsigned char sndCtrl=(pcm?0x20:0)|(sweep?0x40:0)|((noise>0)?0x80:0); unsigned char sndCtrl=(pcm?0x20:0)|(sweep?0x40:0)|((noise>0)?0x80:0);
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
chan[i].std.next(); chan[i].std.next();

View file

@ -77,7 +77,7 @@ class DivPlatformSwan: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void notifyWaveChange(int wave); void notifyWaveChange(int wave);
void notifyInsDeletion(void* ins); void notifyInsDeletion(void* ins);

View file

@ -84,7 +84,7 @@ unsigned char DivPlatformTIA::dealWithFreq(unsigned char shape, int base, int pi
return 0; return 0;
} }
void DivPlatformTIA::tick() { void DivPlatformTIA::tick(bool sysTick) {
for (int i=0; i<2; i++) { for (int i=0; i<2; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -51,7 +51,7 @@ class DivPlatformTIA: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);
bool isStereo(); bool isStereo();

View file

@ -183,7 +183,7 @@ inline int hScale(int note) {
return ((note/12)<<4)+(noteMap[note%12]); return ((note/12)<<4)+(noteMap[note%12]);
} }
void DivPlatformTX81Z::tick() { void DivPlatformTX81Z::tick(bool sysTick) {
for (int i=0; i<8; i++) { for (int i=0; i<8; i++) {
chan[i].std.next(); chan[i].std.next();

View file

@ -102,7 +102,7 @@ class DivPlatformTX81Z: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);

View file

@ -156,7 +156,7 @@ int DivPlatformVERA::calcNoteFreq(int ch, int note) {
} }
} }
void DivPlatformVERA::tick() { void DivPlatformVERA::tick(bool sysTick) {
for (int i=0; i<16; i++) { for (int i=0; i<16; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -63,7 +63,7 @@ class DivPlatformVERA: public DivDispatch {
unsigned char* getRegisterPool(); unsigned char* getRegisterPool();
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void notifyInsDeletion(void* ins); void notifyInsDeletion(void* ins);
float getPostAmp(); float getPostAmp();

View file

@ -91,7 +91,7 @@ void DivPlatformVIC20::writeOutVol(int ch) {
} }
} }
void DivPlatformVIC20::tick() { void DivPlatformVIC20::tick(bool sysTick) {
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -66,7 +66,7 @@ class DivPlatformVIC20: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);
void notifyInsDeletion(void* ins); void notifyInsDeletion(void* ins);

View file

@ -135,7 +135,7 @@ void DivPlatformVRC6::acquire(short* bufL, short* bufR, size_t start, size_t len
} }
} }
void DivPlatformVRC6::tick() { void DivPlatformVRC6::tick(bool sysTick) {
for (int i=0; i<3; i++) { for (int i=0; i<3; i++) {
// 16 for pulse; 14 for saw // 16 for pulse; 14 for saw
int CHIP_DIVIDER=(i==2)?14:16; int CHIP_DIVIDER=(i==2)?14:16;

View file

@ -82,7 +82,7 @@ class DivPlatformVRC6: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);

View file

@ -336,7 +336,7 @@ void DivPlatformX1_010::updateEnvelope(int ch) {
} }
} }
void DivPlatformX1_010::tick() { void DivPlatformX1_010::tick(bool sysTick) {
for (int i=0; i<16; i++) { for (int i=0; i<16; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {

View file

@ -126,7 +126,7 @@ class DivPlatformX1_010: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool isStereo(); bool isStereo();
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);

View file

@ -365,9 +365,9 @@ void DivPlatformYM2610::acquire(short* bufL, short* bufR, size_t start, size_t l
} }
} }
void DivPlatformYM2610::tick() { void DivPlatformYM2610::tick(bool sysTick) {
// PSG // PSG
ay->tick(); ay->tick(sysTick);
ay->flushWrites(); ay->flushWrites();
for (DivRegWrite& i: ay->getRegisterWrites()) { for (DivRegWrite& i: ay->getRegisterWrites()) {
immWrite(i.addr&15,i.val); immWrite(i.addr&15,i.val);

View file

@ -116,7 +116,7 @@ class DivPlatformYM2610: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool isStereo(); bool isStereo();
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);

View file

@ -429,9 +429,9 @@ void DivPlatformYM2610B::acquire(short* bufL, short* bufR, size_t start, size_t
} }
} }
void DivPlatformYM2610B::tick() { void DivPlatformYM2610B::tick(bool sysTick) {
// PSG // PSG
ay->tick(); ay->tick(sysTick);
ay->flushWrites(); ay->flushWrites();
for (DivRegWrite& i: ay->getRegisterWrites()) { for (DivRegWrite& i: ay->getRegisterWrites()) {
immWrite(i.addr&15,i.val); immWrite(i.addr&15,i.val);

View file

@ -107,7 +107,7 @@ class DivPlatformYM2610B: public DivDispatch {
int getRegisterPoolSize(); int getRegisterPoolSize();
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool isStereo(); bool isStereo();
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);

View file

@ -212,7 +212,7 @@ static int opChanOffsH[4]={
0xad, 0xae, 0xac, 0xa6 0xad, 0xae, 0xac, 0xa6
}; };
void DivPlatformYM2610BExt::tick() { void DivPlatformYM2610BExt::tick(bool sysTick) {
if (extMode) { if (extMode) {
bool writeSomething=false; bool writeSomething=false;
unsigned char writeMask=2; unsigned char writeMask=2;
@ -229,7 +229,7 @@ void DivPlatformYM2610BExt::tick() {
} }
} }
DivPlatformYM2610B::tick(); DivPlatformYM2610B::tick(sysTick);
bool writeNoteOn=false; bool writeNoteOn=false;
unsigned char writeMask=2; unsigned char writeMask=2;

View file

@ -41,7 +41,7 @@ class DivPlatformYM2610BExt: public DivPlatformYM2610B {
void* getChanState(int chan); void* getChanState(int chan);
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
void notifyInsChange(int ins); void notifyInsChange(int ins);

View file

@ -212,7 +212,7 @@ static int opChanOffsH[4]={
0xad, 0xae, 0xac, 0xa6 0xad, 0xae, 0xac, 0xa6
}; };
void DivPlatformYM2610Ext::tick() { void DivPlatformYM2610Ext::tick(bool sysTick) {
if (extMode) { if (extMode) {
bool writeSomething=false; bool writeSomething=false;
unsigned char writeMask=2; unsigned char writeMask=2;
@ -229,7 +229,7 @@ void DivPlatformYM2610Ext::tick() {
} }
} }
DivPlatformYM2610::tick(); DivPlatformYM2610::tick(sysTick);
bool writeNoteOn=false; bool writeNoteOn=false;
unsigned char writeMask=2; unsigned char writeMask=2;

View file

@ -41,7 +41,7 @@ class DivPlatformYM2610Ext: public DivPlatformYM2610 {
void* getChanState(int chan); void* getChanState(int chan);
void reset(); void reset();
void forceIns(); void forceIns();
void tick(); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
void notifyInsChange(int ins); void notifyInsChange(int ins);

View file

@ -40,7 +40,7 @@ const char* notes[12]={
}; };
// update this when adding new commands. // update this when adding new commands.
const char* cmdName[DIV_CMD_MAX]={ const char* cmdName[]={
"NOTE_ON", "NOTE_ON",
"NOTE_OFF", "NOTE_OFF",
"NOTE_OFF_ENV", "NOTE_OFF_ENV",
@ -144,6 +144,7 @@ const char* cmdName[DIV_CMD_MAX]={
"N163_WAVE_LOAD", "N163_WAVE_LOAD",
"N163_WAVE_LOADPOS", "N163_WAVE_LOADPOS",
"N163_WAVE_LOADLEN", "N163_WAVE_LOADLEN",
"N163_WAVE_LOADMODE",
"N163_CHANNEL_LIMIT", "N163_CHANNEL_LIMIT",
"N163_GLOBAL_WAVE_LOAD", "N163_GLOBAL_WAVE_LOAD",
"N163_GLOBAL_WAVE_LOADPOS", "N163_GLOBAL_WAVE_LOADPOS",
@ -153,6 +154,8 @@ const char* cmdName[DIV_CMD_MAX]={
"ALWAYS_SET_VOLUME" "ALWAYS_SET_VOLUME"
}; };
static_assert((sizeof(cmdName)/sizeof(void*))==DIV_CMD_MAX,"update cmdName!");
const char* formatNote(unsigned char note, unsigned char octave) { const char* formatNote(unsigned char note, unsigned char octave) {
static char ret[4]; static char ret[4];
if (note==100) { if (note==100) {
@ -1638,7 +1641,7 @@ bool DivEngine::nextTick(bool noAccum) {
firstTick=false; firstTick=false;
// system tick // system tick
for (int i=0; i<song.systemLen; i++) disCont[i].dispatch->tick(); for (int i=0; i<song.systemLen; i++) disCont[i].dispatch->tick(subticks==tickMult);
if (!freelance) { if (!freelance) {
if (stepPlay!=1) { if (stepPlay!=1) {
@ -1654,7 +1657,7 @@ bool DivEngine::nextTick(bool noAccum) {
} }
} }
if (consoleMode) fprintf(stderr,"\x1b[2K> %d:%.2d:%.2d.%.2d %.2x/%.2x:%.3d/%.3d %4dcmd/s\x1b[G",totalSeconds/3600,(totalSeconds/60)%60,totalSeconds%60,totalTicks/10000,curOrder,song.ordersLen,curRow,song.patLen,cmdsPerSecond); if (consoleMode && subticks<=1) fprintf(stderr,"\x1b[2K> %d:%.2d:%.2d.%.2d %.2x/%.2x:%.3d/%.3d %4dcmd/s\x1b[G",totalSeconds/3600,(totalSeconds/60)%60,totalSeconds%60,totalTicks/10000,curOrder,song.ordersLen,curRow,song.patLen,cmdsPerSecond);
} }
if (haltOn==DIV_HALT_TICK) halted=true; if (haltOn==DIV_HALT_TICK) halted=true;

View file

@ -587,8 +587,8 @@ bool DivSample::resampleSinc(double r) {
result+=s[j]*t2[7-j]; result+=s[j]*t2[7-j];
result+=s[8+j]*t1[j]; result+=s[8+j]*t1[j];
} }
if (result<-32768) result=-32768; if (result<-128) result=-128;
if (result>32767) result=32767; if (result>127) result=127;
if (i>=8) { if (i>=8) {
data8[i-8]=result; data8[i-8]=result;
} }

View file

@ -30,8 +30,11 @@ bool DivWaveSynth::activeChanged() {
} }
bool DivWaveSynth::tick() { bool DivWaveSynth::tick() {
if (--subDivCounter>0) return false;
bool updated=first; bool updated=first;
first=false; first=false;
subDivCounter=e->tickMult;
if (!state.enabled) return updated; if (!state.enabled) return updated;
if (width<1) return false; if (width<1) return false;
@ -167,6 +170,7 @@ void DivWaveSynth::init(DivInstrument* which, int w, int h, bool insChanged) {
pos=0; pos=0;
stage=0; stage=0;
divCounter=1+state.rateDivider; divCounter=1+state.rateDivider;
subDivCounter=0;
first=true; first=true;
changeWave1(state.wave1); changeWave1(state.wave1);

View file

@ -28,7 +28,7 @@ class DivEngine;
class DivWaveSynth { class DivWaveSynth {
DivEngine* e; DivEngine* e;
DivInstrumentWaveSynth state; DivInstrumentWaveSynth state;
int pos, stage, divCounter, width, height; int pos, stage, divCounter, width, height, subDivCounter;
bool first, activeChangedB; bool first, activeChangedB;
unsigned char wave1[256]; unsigned char wave1[256];
unsigned char wave2[256]; unsigned char wave2[256];
@ -78,6 +78,7 @@ class DivWaveSynth {
divCounter(0), divCounter(0),
width(32), width(32),
height(31), height(31),
subDivCounter(0),
first(false), first(false),
activeChangedB(false) { activeChangedB(false) {
memset(wave1,0,256); memset(wave1,0,256);

View file

@ -239,6 +239,7 @@ void initParams() {
params.push_back(TAParam("W","warranty",false,pWarranty,"","view warranty disclaimer.")); params.push_back(TAParam("W","warranty",false,pWarranty,"","view warranty disclaimer."));
} }
// TODO: CoInitializeEx on Windows?
int main(int argc, char** argv) { int main(int argc, char** argv) {
initLog(); initLog();
#if !(defined(__APPLE__) || defined(_WIN32)) #if !(defined(__APPLE__) || defined(_WIN32))