diff --git a/src/engine/platform/arcade.cpp b/src/engine/platform/arcade.cpp index ccab36b8..e5563604 100644 --- a/src/engine/platform/arcade.cpp +++ b/src/engine/platform/arcade.cpp @@ -340,16 +340,12 @@ int DivPlatformArcade::dispatch(DivCommand c) { return 1; } -bool DivPlatformArcade::isStereo() { - return true; -} - -int DivPlatformArcade::init(DivEngine* p, int channels, int sugRate, bool pal) { - parent=p; - rate=447443; +void DivPlatformArcade::reset() { + while (!writes.empty()) writes.pop(); memset(&fm,0,sizeof(opm_t)); OPM_Reset(&fm); for (int i=0; i<13; i++) { + chan[i]=DivPlatformArcade::Channel(); chan[i].vol=0x7f; } @@ -367,6 +363,16 @@ int DivPlatformArcade::init(DivEngine* p, int channels, int sugRate, bool pal) { rWrite(0x19,0xff); extMode=false; +} + +bool DivPlatformArcade::isStereo() { + return true; +} + +int DivPlatformArcade::init(DivEngine* p, int channels, int sugRate, bool pal) { + parent=p; + rate=447443; + reset(); return 13; } diff --git a/src/engine/platform/arcade.h b/src/engine/platform/arcade.h index c0777cd5..85521516 100644 --- a/src/engine/platform/arcade.h +++ b/src/engine/platform/arcade.h @@ -48,6 +48,7 @@ class DivPlatformArcade: public DivDispatch { public: void acquire(short* bufL, short* bufR, size_t start, size_t len); int dispatch(DivCommand c); + void reset(); void tick(); bool isStereo(); int init(DivEngine* parent, int channels, int sugRate, bool pal); diff --git a/src/engine/platform/c64.cpp b/src/engine/platform/c64.cpp index 99e600f4..459d77dd 100644 --- a/src/engine/platform/c64.cpp +++ b/src/engine/platform/c64.cpp @@ -279,6 +279,22 @@ int DivPlatformC64::dispatch(DivCommand c) { return 1; } +void DivPlatformC64::reset() { + for (int i=0; i<3; i++) { + chan[i]=DivPlatformC64::Channel(); + } + + sid.reset(); + + sid.write(0x18,0x0f); + + filtControl=0; + filtRes=0; + filtCut=0; + resetTime=1; + vol=15; +} + void DivPlatformC64::setChipModel(bool is6581) { if (is6581) { sid.set_chip_model(MOS6581); @@ -295,15 +311,7 @@ int DivPlatformC64::init(DivEngine* p, int channels, int sugRate, bool pal) { rate=1022727; } - sid.reset(); - - sid.write(0x18,0x0f); - - filtControl=0; - filtRes=0; - filtCut=0; - resetTime=1; - vol=15; + reset(); return 3; } diff --git a/src/engine/platform/c64.h b/src/engine/platform/c64.h index cd9f17ed..71d77c72 100644 --- a/src/engine/platform/c64.h +++ b/src/engine/platform/c64.h @@ -55,6 +55,7 @@ class DivPlatformC64: public DivDispatch { public: void acquire(short* bufL, short* bufR, size_t start, size_t len); int dispatch(DivCommand c); + void reset(); void tick(); int init(DivEngine* parent, int channels, int sugRate, bool pal); void setChipModel(bool is6581); diff --git a/src/engine/platform/dummy.cpp b/src/engine/platform/dummy.cpp index 0cdaf2f1..ca5b3f5a 100644 --- a/src/engine/platform/dummy.cpp +++ b/src/engine/platform/dummy.cpp @@ -61,12 +61,17 @@ int DivPlatformDummy::dispatch(DivCommand c) { return 1; } +void DivPlatformDummy::reset() { + for (int i=0; imodel=GB_MODEL_DMG_B; GB_apu_init(gb); @@ -286,5 +282,16 @@ int DivPlatformGB::init(DivEngine* p, int channels, int sugRate, bool pal) { GB_apu_write(gb,0x26,0x80); GB_apu_write(gb,0x25,0xff); lastPan=0xff; +} + +bool DivPlatformGB::isStereo() { + return true; +} + +int DivPlatformGB::init(DivEngine* p, int channels, int sugRate, bool pal) { + parent=p; + rate=262144; + gb=new GB_gameboy_t; + reset(); return 4; } diff --git a/src/engine/platform/gb.h b/src/engine/platform/gb.h index a8e3c1da..a1ed4763 100644 --- a/src/engine/platform/gb.h +++ b/src/engine/platform/gb.h @@ -38,6 +38,7 @@ class DivPlatformGB: public DivDispatch { public: void acquire(short* bufL, short* bufR, size_t start, size_t len); int dispatch(DivCommand c); + void reset(); void tick(); bool isStereo(); int init(DivEngine* parent, int channels, int sugRate, bool pal); diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index eb6cff0d..799676ff 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -357,23 +357,11 @@ int DivPlatformGenesis::dispatch(DivCommand c) { return 1; } -bool DivPlatformGenesis::isStereo() { - return true; -} - -bool DivPlatformGenesis::keyOffAffectsArp(int ch) { - return (ch>5); -} - -int DivPlatformGenesis::init(DivEngine* p, int channels, int sugRate, bool pal) { - parent=p; - if (pal) { - rate=211125; - } else { - rate=213068; - } +void DivPlatformGenesis::reset() { + while (!writes.empty()) writes.pop(); OPN2_Reset(&fm); for (int i=0; i<10; i++) { + chan[i]=DivPlatformGenesis::Channel(); chan[i].vol=0x7f; } @@ -398,8 +386,29 @@ int DivPlatformGenesis::init(DivEngine* p, int channels, int sugRate, bool pal) delay=0; // PSG - psg.init(p,4,sugRate,pal); + psg.reset(); psgClocks=0; psgOut=0; +} + +bool DivPlatformGenesis::isStereo() { + return true; +} + +bool DivPlatformGenesis::keyOffAffectsArp(int ch) { + return (ch>5); +} + +int DivPlatformGenesis::init(DivEngine* p, int channels, int sugRate, bool pal) { + parent=p; + if (pal) { + rate=211125; + } else { + rate=213068; + } + // PSG + psg.init(p,4,sugRate,pal); + + reset(); return 10; } diff --git a/src/engine/platform/genesis.h b/src/engine/platform/genesis.h index 7d2b546b..b56fb488 100644 --- a/src/engine/platform/genesis.h +++ b/src/engine/platform/genesis.h @@ -51,6 +51,7 @@ class DivPlatformGenesis: public DivDispatch { public: void acquire(short* bufL, short* bufR, size_t start, size_t len); int dispatch(DivCommand c); + void reset(); void tick(); bool isStereo(); bool keyOffAffectsArp(int ch); diff --git a/src/engine/platform/genesisext.cpp b/src/engine/platform/genesisext.cpp index e5a4a969..5d9e94c0 100644 --- a/src/engine/platform/genesisext.cpp +++ b/src/engine/platform/genesisext.cpp @@ -254,6 +254,19 @@ void DivPlatformGenesisExt::tick() { } } +void DivPlatformGenesisExt::reset() { + DivPlatformGenesis::reset(); + + for (int i=0; i<4; i++) { + opChan[i]=DivPlatformGenesisExt::OpChannel(); + opChan[i].vol=127; + } + + // channel 3 mode + writes.emplace(0x27,0x40); + extMode=true; +} + bool DivPlatformGenesisExt::keyOffAffectsArp(int ch) { return (ch>8); } @@ -261,12 +274,6 @@ bool DivPlatformGenesisExt::keyOffAffectsArp(int ch) { int DivPlatformGenesisExt::init(DivEngine* parent, int channels, int sugRate, bool pal) { DivPlatformGenesis::init(parent,channels,sugRate,pal); - for (int i=0; i<4; i++) { - opChan[i].vol=127; - } - - // channel 3 mode - writes.emplace(0x27,0x40); - extMode=true; + reset(); return 13; } diff --git a/src/engine/platform/genesisext.h b/src/engine/platform/genesisext.h index 538a5c8e..d9c25184 100644 --- a/src/engine/platform/genesisext.h +++ b/src/engine/platform/genesisext.h @@ -16,6 +16,7 @@ class DivPlatformGenesisExt: public DivPlatformGenesis { OpChannel opChan[4]; public: int dispatch(DivCommand c); + void reset(); void tick(); bool keyOffAffectsArp(int ch); int init(DivEngine* parent, int channels, int sugRate, bool pal); diff --git a/src/engine/platform/nes.cpp b/src/engine/platform/nes.cpp index 53df12f2..1b9ea082 100644 --- a/src/engine/platform/nes.cpp +++ b/src/engine/platform/nes.cpp @@ -252,12 +252,6 @@ int DivPlatformNES::dispatch(DivCommand c) { sampleBank=parent->song.sample.size()/12; } break; - case DIV_CMD_PANNING: { - lastPan&=~(0x11<Power(0); lastPan=0xff; tempL=0; tempR=0; @@ -294,5 +283,24 @@ int DivPlatformPCE::init(DivEngine* p, int channels, int sugRate, bool pal) { chWrite(i,0x05,chan[i].pan); } delay=500; +} + +bool DivPlatformPCE::isStereo() { + return true; +} + +bool DivPlatformPCE::keyOffAffectsArp(int ch) { + return true; +} + +int DivPlatformPCE::init(DivEngine* p, int channels, int sugRate, bool pal) { + parent=p; + if (pal) { // technically there is no PAL PC Engine but oh well... + rate=1773448; + } else { + rate=1789773; + } + pce=new PCE_PSG(&tempL,&tempR,PCE_PSG::REVISION_HUC6280); + reset(); return 6; } diff --git a/src/engine/platform/pce.h b/src/engine/platform/pce.h index f3911dd7..a36761a5 100644 --- a/src/engine/platform/pce.h +++ b/src/engine/platform/pce.h @@ -53,6 +53,7 @@ class DivPlatformPCE: public DivDispatch { public: void acquire(short* bufL, short* bufR, size_t start, size_t len); int dispatch(DivCommand c); + void reset(); void tick(); bool isStereo(); bool keyOffAffectsArp(int ch); diff --git a/src/engine/platform/sms.cpp b/src/engine/platform/sms.cpp index 20092bfe..241664e9 100644 --- a/src/engine/platform/sms.cpp +++ b/src/engine/platform/sms.cpp @@ -159,6 +159,15 @@ int DivPlatformSMS::dispatch(DivCommand c) { return 1; } +void DivPlatformSMS::reset() { + for (int i=0; i<4; i++) { + chan[i]=DivPlatformSMS::Channel(); + } + sn->device_start(); + snNoiseMode=3; + updateSNMode=false; +} + bool DivPlatformSMS::keyOffAffectsArp(int ch) { return true; } @@ -171,8 +180,6 @@ int DivPlatformSMS::init(DivEngine* p, int channels, int sugRate, bool pal) { rate=223722; } sn=new sn76496_device(rate); - sn->device_start(); - snNoiseMode=3; - updateSNMode=false; + reset(); return 4; } diff --git a/src/engine/platform/sms.h b/src/engine/platform/sms.h index e468dd07..ce0482fb 100644 --- a/src/engine/platform/sms.h +++ b/src/engine/platform/sms.h @@ -34,6 +34,7 @@ class DivPlatformSMS: public DivDispatch { int acquireOne(); void acquire(short* bufL, short* bufR, size_t start, size_t len); int dispatch(DivCommand c); + void reset(); void tick(); bool keyOffAffectsArp(int ch); int init(DivEngine* parent, int channels, int sugRate, bool pal); diff --git a/src/engine/platform/ym2610.cpp b/src/engine/platform/ym2610.cpp index 9e2606b0..01b0a7a6 100644 --- a/src/engine/platform/ym2610.cpp +++ b/src/engine/platform/ym2610.cpp @@ -472,6 +472,7 @@ int DivPlatformYM2610::dispatch(DivCommand c) { } void DivPlatformYM2610::reset() { + while (!writes.empty()) writes.pop(); fm->reset(); for (int i=0; i<13; i++) { chan[i]=DivPlatformYM2610::Channel();