From 0602a2f811f7273e4fcb7eb515e1e162de91f840 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 8 Nov 2025 15:17:56 -0500 Subject: [PATCH] total extinction of legacy sample mode, part 2 remove legacy sample bank completely --- src/engine/platform/ay.cpp | 7 - src/engine/platform/ay.h | 1 - src/engine/platform/ay8930.cpp | 7 - src/engine/platform/ay8930.h | 2 - src/engine/platform/genesis.cpp | 7 - src/engine/platform/genesis.h | 2 - src/engine/platform/genesisext.cpp | 8 - src/engine/platform/mmc5.cpp | 7 - src/engine/platform/mmc5.h | 1 - src/engine/platform/msm6258.cpp | 19 - src/engine/platform/msm6258.h | 2 +- src/engine/platform/msm6295.cpp | 19 - src/engine/platform/msm6295.h | 1 - src/engine/platform/nes.cpp | 7 - src/engine/platform/nes.h | 1 - src/engine/platform/opl.cpp | 11 - src/engine/platform/opl.h | 5 +- src/engine/platform/pce.cpp | 7 - src/engine/platform/pce.h | 2 +- src/engine/platform/saa.cpp | 6 - src/engine/platform/saa.h | 7 - src/engine/platform/segapcm.cpp | 7 - src/engine/platform/segapcm.h | 1 - src/engine/platform/su.cpp | 1 - src/engine/platform/su.h | 2 +- src/engine/platform/swan.cpp | 7 - src/engine/platform/swan.h | 2 +- src/engine/platform/swan_before.cpp | 670 ---------------------------- src/engine/platform/swan_before.h | 90 ---- src/engine/platform/vrc6.cpp | 7 - src/engine/platform/vrc6.h | 1 - src/engine/platform/x1_010.cpp | 7 - src/engine/platform/x1_010.h | 1 - src/engine/platform/ym2203.cpp | 1 - src/engine/platform/ym2203.h | 1 - src/engine/platform/ym2608.cpp | 9 - src/engine/platform/ym2608.h | 4 +- src/engine/platform/ym2610.cpp | 34 +- src/engine/platform/ym2610b.cpp | 34 +- src/engine/platform/ym2610shared.h | 7 +- src/gui/debug.cpp | 11 - 41 files changed, 10 insertions(+), 1016 deletions(-) delete mode 100644 src/engine/platform/swan_before.cpp delete mode 100644 src/engine/platform/swan_before.h diff --git a/src/engine/platform/ay.cpp b/src/engine/platform/ay.cpp index 5506278a0..001989d34 100644 --- a/src/engine/platform/ay.cpp +++ b/src/engine/platform/ay.cpp @@ -928,12 +928,6 @@ int DivPlatformAY8910::dispatch(DivCommand c) { chan[c.chan].curPSGMode.val|=chan[c.chan].nextPSGMode.val&8; } break; - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - break; case DIV_CMD_SAMPLE_POS: chan[c.chan].dac.pos=c.value; chan[c.chan].dac.setPos=true; @@ -1064,7 +1058,6 @@ void DivPlatformAY8910::reset() { pendingWrites[i]=-1; } - sampleBank=0; ayEnvPeriod=0; ayEnvMode=0; ayEnvSlide=0; diff --git a/src/engine/platform/ay.h b/src/engine/platform/ay.h index b488616d5..23f68e8dc 100644 --- a/src/engine/platform/ay.h +++ b/src/engine/platform/ay.h @@ -121,7 +121,6 @@ class DivPlatformAY8910: public DivDispatch { unsigned char regPool[16]; unsigned char lastBusy; - unsigned char sampleBank; unsigned char stereoSep; unsigned char selCore; diff --git a/src/engine/platform/ay8930.cpp b/src/engine/platform/ay8930.cpp index aea1899fa..99f6f4b4e 100644 --- a/src/engine/platform/ay8930.cpp +++ b/src/engine/platform/ay8930.cpp @@ -750,12 +750,6 @@ int DivPlatformAY8930::dispatch(DivCommand c) { chan[c.chan].curPSGMode.val|=chan[c.chan].nextPSGMode.val&8; } break; - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - break; case DIV_CMD_SAMPLE_POS: chan[c.chan].dac.pos=c.value; chan[c.chan].dac.setPos=true; @@ -873,7 +867,6 @@ void DivPlatformAY8930::reset() { pendingWrites[i]=-1; } - sampleBank=0; ayNoiseAnd=2; ayNoiseOr=0; delay=0; diff --git a/src/engine/platform/ay8930.h b/src/engine/platform/ay8930.h index a6ecc546a..230f63f84 100644 --- a/src/engine/platform/ay8930.h +++ b/src/engine/platform/ay8930.h @@ -111,8 +111,6 @@ class DivPlatformAY8930: public DivDispatch { unsigned char stereoSep; bool bank; - unsigned char sampleBank; - int delay; int lastOut[2]; diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index 10994ac0d..276b710e6 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -1283,13 +1283,6 @@ int DivPlatformGenesis::dispatch(DivCommand c) { rWrite(0x2b,c.value<<7); break; } - case DIV_CMD_SAMPLE_BANK: - if (c.chan<5) c.chan=5; - chan[c.chan].sampleBank=c.value; - if (chan[c.chan].sampleBank>(parent->song.sample.size()/12)) { - chan[c.chan].sampleBank=parent->song.sample.size()/12; - } - break; case DIV_CMD_SAMPLE_DIR: { if (c.chan<5) c.chan=5; chan[c.chan].dacDirection=c.value; diff --git a/src/engine/platform/genesis.h b/src/engine/platform/genesis.h index 82495bdef..5293ef4df 100644 --- a/src/engine/platform/genesis.h +++ b/src/engine/platform/genesis.h @@ -46,7 +46,6 @@ class DivPlatformGenesis: public DivPlatformOPN { int dacDelay; bool dacDirection; bool setPos; - unsigned char sampleBank; signed char dacOutput; Channel(): FMChannelStereo(), @@ -59,7 +58,6 @@ class DivPlatformGenesis: public DivPlatformOPN { dacDelay(0), dacDirection(false), setPos(false), - sampleBank(0), dacOutput(0) {} }; Channel chan[10]; diff --git a/src/engine/platform/genesisext.cpp b/src/engine/platform/genesisext.cpp index c7c3e287b..02fa2be79 100644 --- a/src/engine/platform/genesisext.cpp +++ b/src/engine/platform/genesisext.cpp @@ -203,14 +203,6 @@ int DivPlatformGenesisExt::dispatch(DivCommand c) { } break; } - case DIV_CMD_SAMPLE_BANK: - if (!parent->song.ignoreDACModeOutsideIntendedChannel) { - chan[5].sampleBank=c.value; - if (chan[5].sampleBank>(parent->song.sample.size()/12)) { - chan[5].sampleBank=parent->song.sample.size()/12; - } - } - break; case DIV_CMD_LEGATO: { if (opChan[ch].insChanged) { DivInstrument* ins=parent->getIns(opChan[ch].ins,DIV_INS_FM); diff --git a/src/engine/platform/mmc5.cpp b/src/engine/platform/mmc5.cpp index 39fc57655..3b28c2ee7 100644 --- a/src/engine/platform/mmc5.cpp +++ b/src/engine/platform/mmc5.cpp @@ -304,12 +304,6 @@ int DivPlatformMMC5::dispatch(DivCommand c) { chan[c.chan].duty=c.value; rWrite(0x5000+c.chan*4,0x30|(chan[c.chan].active?chan[c.chan].outVol:0)|((chan[c.chan].duty&3)<<6)); break; - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - break; case DIV_CMD_SAMPLE_POS: if (c.chan!=2) break; dacPos=c.value; @@ -403,7 +397,6 @@ void DivPlatformMMC5::reset() { dacPos=0; dacRate=0; dacSample=-1; - sampleBank=0; map_init_MMC5(mmc5); memset(regPool,0,128); diff --git a/src/engine/platform/mmc5.h b/src/engine/platform/mmc5.h index 57e396c06..574f0684c 100644 --- a/src/engine/platform/mmc5.h +++ b/src/engine/platform/mmc5.h @@ -49,7 +49,6 @@ class DivPlatformMMC5: public DivDispatch { int dacPeriod, dacRate; unsigned int dacPos; int dacSample; - unsigned char sampleBank; unsigned char writeOscBuf; struct _mmc5* mmc5; unsigned char regPool[128]; diff --git a/src/engine/platform/msm6258.cpp b/src/engine/platform/msm6258.cpp index b78ce52d5..f54104144 100644 --- a/src/engine/platform/msm6258.cpp +++ b/src/engine/platform/msm6258.cpp @@ -185,18 +185,6 @@ int DivPlatformMSM6258::dispatch(DivCommand c) { } else { break; } - } else { - chan[c.chan].sample=-1; - chan[c.chan].macroInit(NULL); - chan[c.chan].outVol=chan[c.chan].vol; - if ((12*sampleBank+c.value%12)<0 || (12*sampleBank+c.value%12)>=parent->song.sampleLen) { - break; - } - //DivSample* s=parent->getSample(12*sampleBank+c.value%12); - sample=12*sampleBank+c.value%12; - samplePos=0; - chan[c.chan].active=true; - chan[c.chan].keyOn=true; } break; } @@ -238,12 +226,6 @@ int DivPlatformMSM6258::dispatch(DivCommand c) { case DIV_CMD_NOTE_PORTA: { return 2; } - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - break; case DIV_CMD_SAMPLE_FREQ: rateSel=c.value&3; rWrite(12,rateSel); @@ -360,7 +342,6 @@ void DivPlatformMSM6258::reset() { chan[i].outVol=8; } - sampleBank=0; sample=-1; samplePos=0; diff --git a/src/engine/platform/msm6258.h b/src/engine/platform/msm6258.h index de7191919..dde975d72 100644 --- a/src/engine/platform/msm6258.h +++ b/src/engine/platform/msm6258.h @@ -48,7 +48,7 @@ class DivPlatformMSM6258: public DivDispatch { FixedQueue writes; okim6258_device* msm; - unsigned char sampleBank, msmPan, msmDivider, rateSel, msmClock, clockSel; + unsigned char msmPan, msmDivider, rateSel, msmClock, clockSel; signed char msmDividerCount, msmClockCount; bool updateSampleFreq; bool variableRate; diff --git a/src/engine/platform/msm6295.cpp b/src/engine/platform/msm6295.cpp index 67e3390da..c2d4ef70b 100644 --- a/src/engine/platform/msm6295.cpp +++ b/src/engine/platform/msm6295.cpp @@ -186,18 +186,6 @@ int DivPlatformMSM6295::dispatch(DivCommand c) { } else { break; } - } else { - chan[c.chan].sample=-1; - chan[c.chan].macroInit(NULL); - chan[c.chan].outVol=chan[c.chan].vol; - if ((12*sampleBank+c.value%12)<0 || (12*sampleBank+c.value%12)>=parent->song.sampleLen) { - break; - } - //DivSample* s=parent->getSample(12*sampleBank+c.value%12); - chan[c.chan].sample=12*sampleBank+c.value%12; - rWriteDelay(0,(8<(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - break; case DIV_CMD_LEGATO: { break; } @@ -335,7 +317,6 @@ void DivPlatformMSM6295::reset() { chan[i].outVol=8; } - sampleBank=0; rateSel=rateSelInit; rWrite(12,!rateSelInit); if (isBanked) { diff --git a/src/engine/platform/msm6295.h b/src/engine/platform/msm6295.h index 5975e1216..3277a2f15 100644 --- a/src/engine/platform/msm6295.h +++ b/src/engine/platform/msm6295.h @@ -53,7 +53,6 @@ class DivPlatformMSM6295: public DivDispatch, public vgsound_emu_mem_intf { unsigned char* adpcmMem; size_t adpcmMemLen; bool* sampleLoaded; - unsigned char sampleBank; int delay, updateOsc; diff --git a/src/engine/platform/nes.cpp b/src/engine/platform/nes.cpp index d570020fc..bf035e7bc 100644 --- a/src/engine/platform/nes.cpp +++ b/src/engine/platform/nes.cpp @@ -737,12 +737,6 @@ int DivPlatformNES::dispatch(DivCommand c) { } break; } - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - break; case DIV_CMD_SAMPLE_POS: if (c.chan!=4) break; dacPos=c.value; @@ -858,7 +852,6 @@ void DivPlatformNES::reset() { dpcmPos=0; dacRate=0; dacSample=-1; - sampleBank=0; dpcmBank=0; dpcmMode=dpcmModeDefault; goingToLoop=false; diff --git a/src/engine/platform/nes.h b/src/engine/platform/nes.h index 51413d1a4..72ef7aa34 100644 --- a/src/engine/platform/nes.h +++ b/src/engine/platform/nes.h @@ -59,7 +59,6 @@ class DivPlatformNES: public DivDispatch { size_t dpcmMemLen; bool* sampleLoaded; unsigned char dpcmBank; - unsigned char sampleBank; unsigned char writeOscBuf; unsigned char apuType; unsigned char linearCount; diff --git a/src/engine/platform/opl.cpp b/src/engine/platform/opl.cpp index dd879260d..3d01bb1bd 100644 --- a/src/engine/platform/opl.cpp +++ b/src/engine/platform/opl.cpp @@ -2128,14 +2128,6 @@ int DivPlatformOPL::dispatch(DivCommand c) { } break; } - case DIV_CMD_SAMPLE_BANK: - if (adpcmChan<0) break; - sampleBank=c.value; - if (sampleBank>(int)(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - iface.sampleBank=sampleBank; - break; case DIV_CMD_LEGATO: { // TODO: OPL4 PCM if (chan[c.chan].insChanged) { @@ -2908,7 +2900,6 @@ void DivPlatformOPL::reset() { lastBusy=60; lfoValue=8; drumState=0; - sampleBank=0; drumVol[0]=0; drumVol[1]=0; @@ -3471,7 +3462,6 @@ int DivPlatformOPL::init(DivEngine* p, int channels, int sugRate, const DivConfi adpcmBMem=new unsigned char[262144]; adpcmBMemLen=0; iface.adpcmBMem=adpcmBMem; - iface.sampleBank=0; adpcmB=new ymfm::adpcm_b_engine(iface,2); } @@ -3479,7 +3469,6 @@ int DivPlatformOPL::init(DivEngine* p, int channels, int sugRate, const DivConfi pcmMem=new unsigned char[4194304]; pcmMemLen=0; iface.pcmMem=pcmMem; - iface.sampleBank=0; pcmMemory.memory=pcmMem; } diff --git a/src/engine/platform/opl.h b/src/engine/platform/opl.h index 9ba5dd3fe..adf9a6709 100644 --- a/src/engine/platform/opl.h +++ b/src/engine/platform/opl.h @@ -36,10 +36,9 @@ class DivOPLAInterface: public ymfm::ymfm_interface { public: unsigned char* adpcmBMem; unsigned char* pcmMem; - int sampleBank; uint8_t ymfm_external_read(ymfm::access_class type, uint32_t address); void ymfm_external_write(ymfm::access_class type, uint32_t address, uint8_t data); - DivOPLAInterface(): adpcmBMem(NULL), pcmMem(NULL), sampleBank(0) {} + DivOPLAInterface(): adpcmBMem(NULL), pcmMem(NULL) {} }; class DivYMF278MemoryInterface: public MemoryInterface { @@ -134,7 +133,7 @@ class DivPlatformOPL: public DivDispatch { const unsigned short* chanMap; const unsigned char* outChanMap; int chipFreqBase, chipRateBase; - int delay, chipType, oplType, chans, melodicChans, totalChans, adpcmChan=-1, pcmChanOffs=-1, sampleBank, totalOutputs, ramSize; + int delay, chipType, oplType, chans, melodicChans, totalChans, adpcmChan=-1, pcmChanOffs=-1, totalOutputs, ramSize; int fmMixL=7, fmMixR=7, pcmMixL=7, pcmMixR=7; unsigned char lastBusy; unsigned char drumState; diff --git a/src/engine/platform/pce.cpp b/src/engine/platform/pce.cpp index 46f1b9ac7..874e45457 100644 --- a/src/engine/platform/pce.cpp +++ b/src/engine/platform/pce.cpp @@ -466,12 +466,6 @@ int DivPlatformPCE::dispatch(DivCommand c) { case DIV_CMD_SAMPLE_MODE: chan[c.chan].pcm=c.value; break; - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - break; case DIV_CMD_SAMPLE_POS: chan[c.chan].dacPos=c.value; chan[c.chan].setPos=true; @@ -605,7 +599,6 @@ void DivPlatformPCE::reset() { pce->Power(0); lastPan=0xff; curChan=-1; - sampleBank=0; lfoMode=0; lfoSpeed=255; // set global volume diff --git a/src/engine/platform/pce.h b/src/engine/platform/pce.h index 9f97beeca..5edbd371e 100644 --- a/src/engine/platform/pce.h +++ b/src/engine/platform/pce.h @@ -70,7 +70,7 @@ class DivPlatformPCE: public DivDispatch { unsigned char lastPan; int curChan; - unsigned char sampleBank, lfoMode, lfoSpeed; + unsigned char lfoMode, lfoSpeed; PCE_PSG* pce; unsigned char regPool[128]; void updateWave(int ch); diff --git a/src/engine/platform/saa.cpp b/src/engine/platform/saa.cpp index 01e98a882..624bde5bf 100644 --- a/src/engine/platform/saa.cpp +++ b/src/engine/platform/saa.cpp @@ -389,12 +389,6 @@ void DivPlatformSAA1099::reset() { } lastBusy=60; - dacMode=0; - dacPeriod=0; - dacPos=0; - dacRate=0; - dacSample=-1; - sampleBank=0; saaEnv[0]=0; saaEnv[1]=0; saaNoise[0]=0; diff --git a/src/engine/platform/saa.h b/src/engine/platform/saa.h index 7f5c1565c..056e9a278 100644 --- a/src/engine/platform/saa.h +++ b/src/engine/platform/saa.h @@ -52,13 +52,6 @@ class DivPlatformSAA1099: public DivDispatch { CSAASound* saa_saaSound; unsigned char regPool[32]; unsigned char lastBusy; - - bool dacMode; - int dacPeriod; - int dacRate; - int dacPos; - int dacSample; - unsigned char sampleBank; int delay; diff --git a/src/engine/platform/segapcm.cpp b/src/engine/platform/segapcm.cpp index 5522b4b63..984765ea7 100644 --- a/src/engine/platform/segapcm.cpp +++ b/src/engine/platform/segapcm.cpp @@ -330,12 +330,6 @@ int DivPlatformSegaPCM::dispatch(DivCommand c) { chan[c.chan].freqChanged=true; break; } - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - break; case DIV_CMD_SAMPLE_POS: chan[c.chan].pcm.pos=c.value; chan[c.chan].setPos=true; @@ -475,7 +469,6 @@ void DivPlatformSegaPCM::reset() { pcmCycles=0; pcmL=0; pcmR=0; - sampleBank=0; delay=0; pcm.device_start(); diff --git a/src/engine/platform/segapcm.h b/src/engine/platform/segapcm.h index 068644a96..3eb0c8475 100644 --- a/src/engine/platform/segapcm.h +++ b/src/engine/platform/segapcm.h @@ -68,7 +68,6 @@ class DivPlatformSegaPCM: public DivDispatch { int delay; int pcmL, pcmR, pcmCycles; bool oldSlides; - unsigned char sampleBank; unsigned char lastBusy; unsigned char regPool[256]; diff --git a/src/engine/platform/su.cpp b/src/engine/platform/su.cpp index d672995e7..84c84f6d1 100644 --- a/src/engine/platform/su.cpp +++ b/src/engine/platform/su.cpp @@ -612,7 +612,6 @@ void DivPlatformSoundUnit::reset() { lastPan=0xff; cycles=0; curChan=-1; - sampleBank=0; lfoMode=0; lfoSpeed=255; delay=500; diff --git a/src/engine/platform/su.h b/src/engine/platform/su.h index 4e8bcc691..0ccfb4774 100644 --- a/src/engine/platform/su.h +++ b/src/engine/platform/su.h @@ -100,7 +100,7 @@ class DivPlatformSoundUnit: public DivDispatch { int cycles, curChan, delay, sysIDCache; short tempL; short tempR; - unsigned char sampleBank, lfoMode, lfoSpeed; + unsigned char lfoMode, lfoSpeed; SoundUnit* su; unsigned char* sampleMem; size_t sampleMemLen; diff --git a/src/engine/platform/swan.cpp b/src/engine/platform/swan.cpp index 9d434101c..03d285ff5 100644 --- a/src/engine/platform/swan.cpp +++ b/src/engine/platform/swan.cpp @@ -527,12 +527,6 @@ int DivPlatformSwan::dispatch(DivCommand c) { } } break; - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - break; case DIV_CMD_SAMPLE_POS: dacPos=c.value; setPos=true; @@ -665,7 +659,6 @@ void DivPlatformSwan::reset() { dacRate=0; dacPos=0; dacSample=-1; - sampleBank=0; rWrite(0x0f,0x00); // wave table at 0x0000 rWrite(0x11,0x0f); // enable speakers, minimum headphone volume } diff --git a/src/engine/platform/swan.h b/src/engine/platform/swan.h index e3ea745f9..6b8773e94 100644 --- a/src/engine/platform/swan.h +++ b/src/engine/platform/swan.h @@ -42,7 +42,7 @@ class DivPlatformSwan: public DivDispatch { bool stereo; bool useMdfn; bool pcm, sweep, furnaceDac, setPos; - unsigned char sampleBank, noise; + unsigned char noise; int dacPeriod, dacRate; unsigned int dacPos; int dacSample; diff --git a/src/engine/platform/swan_before.cpp b/src/engine/platform/swan_before.cpp deleted file mode 100644 index 79cfbd695..000000000 --- a/src/engine/platform/swan_before.cpp +++ /dev/null @@ -1,670 +0,0 @@ -/** - * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2025 tildearrow and contributors - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "swan_before.h" -#include "../engine.h" -#include "furIcons.h" -#include "IconsFontAwesome4.h" -#include - -#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);}} -#define postWrite(a,v) postDACWrites.push(DivRegWrite(a,v)); - -#define CHIP_DIVIDER 32 - -const char* regCheatSheetWS[]={ - "CH1_Pitch", "00", - "CH2_Pitch", "02", - "CH3_Pitch", "04", - "CH4_Pitch", "06", - "CH1_Vol", "08", - "CH2_Vol", "09", - "CH3_Vol", "0A", - "CH4_Vol", "0B", - "Sweep_Value", "0C", - "Sweep_Time", "0D", - "Noise", "0E", - "Wave_Base", "0F", - "Ctrl", "10", - "Output", "11", - "Random", "12", - "Voice_Ctrl", "14", - "Wave_Mem", "40", - NULL -}; - -const char** DivPlatformSwan::getRegisterSheet() { - return regCheatSheetWS; -} - -void DivPlatformSwan::acquireDirect(blip_buffer_t** bb, size_t len) { - for (int i=0; i<4; i++) { - oscBuf[i]->begin(len); - ws_mdfn->oscBuf[i]=oscBuf[i]; - } - - ws_mdfn->sbuf[0]=bb[0]; - ws_mdfn->sbuf[1]=bb[1]; - - for (size_t h=0; hv30mz_timestamp=h; - // heuristic - int pcmAdvance=1; - if (writes.empty()) { - if (!pcm || dacSample==-1) { - break; - } else { - pcmAdvance=len-h; - if (dacRate>0) { - int remainTime=(rate-dacPeriod+dacRate-1)/dacRate; - if (remainTime=rate) { - DivSample* s=parent->getSample(dacSample); - if (s->samples<=0 || dacPos>=s->samples) { - dacSample=-1; - dacPeriod=0; - break; - } - rWrite(0x09,(unsigned char)s->data8[dacPos++]+0x80); - if (s->isLoopable() && dacPos>=(unsigned int)s->loopEnd) { - dacPos=s->loopStart; - } else if (dacPos>=s->samples) { - dacSample=-1; - } - dacPeriod-=rate; - } - } - - h+=pcmAdvance-1; - - // the rest - while (!writes.empty()) { - QueuedWrite w=writes.front(); - regPool[w.addr]=w.val; - if (w.addr<0x40) { - ws_mdfn->SoundWrite(w.addr|0x80,w.val); - } else { - ws_mdfn->SoundCheckRAMWrite(w.addr&0x3f); - ws_mdfn->RAMWrite(w.addr&0x3f,w.val); - } - writes.pop(); - } - } - - ws_mdfn->v30mz_timestamp=len; - ws_mdfn->SoundUpdate(); - ws_mdfn->SoundFlush(NULL,0); - - for (int i=0; i<4; i++) { - oscBuf[i]->end(len); - } -} - -void DivPlatformSwan::updateWave(int ch) { - unsigned char addr=0x40+ch*16; - for (int i=0; i<16; i++) { - int nibble1=chan[ch].ws.output[i<<1]; - int nibble2=chan[ch].ws.output[1+(i<<1)]; - rWrite(addr+i,nibble1|(nibble2<<4)); - } -} - -void DivPlatformSwan::calcAndWriteOutVol(int ch, int env) { - int vl=chan[ch].vol*((chan[ch].pan>>4)&0x0f)*env/225; - int vr=chan[ch].vol*(chan[ch].pan&0x0f)*env/225; - if (ch==1&&pcm) { - vl=(vl>0)?((vl>7)?3:2):0; - vr=(vr>0)?((vr>7)?3:2):0; - chan[1].outVol=vr|(vl<<2); - } else { - chan[ch].outVol=vr|(vl<<4); - } - writeOutVol(ch); -} - -void DivPlatformSwan::writeOutVol(int ch) { - unsigned char val=isMuted[ch]?0:chan[ch].outVol; - if (ch==1&&pcm) { - rWrite(0x14,val) - } else { - rWrite(0x08+ch,val); - } -} - -void DivPlatformSwan::tick(bool sysTick) { - unsigned char sndCtrl=(pcm?0x20:0)|(sweep?0x40:0)|((noise>0)?0x80:0); - for (int i=0; i<4; i++) { - chan[i].std.next(); - if (chan[i].std.vol.had) { - int env=chan[i].std.vol.val; - if(parent->getIns(chan[i].ins,DIV_INS_SWAN)->type==DIV_INS_AMIGA) { - env=MIN(env/4,15); - } - calcAndWriteOutVol(i,env); - } - if (NEW_ARP_STRAT) { - chan[i].handleArp(); - } else if (chan[i].std.arp.had) { - if (!chan[i].inPorta) { - chan[i].baseFreq=NOTE_PERIODIC(parent->calcArp(chan[i].note,chan[i].std.arp.val)); - } - chan[i].freqChanged=true; - } - if (chan[i].std.wave.had && !(i==1 && pcm)) { - if (chan[i].wave!=chan[i].std.wave.val || chan[i].ws.activeChanged()) { - chan[i].wave=chan[i].std.wave.val; - chan[i].ws.changeWave1(chan[i].wave); - } - } - if (chan[i].std.panL.had) { - chan[i].pan&=0x0f; - chan[i].pan|=(chan[i].std.panL.val&15)<<4; - } - if (chan[i].std.panR.had) { - chan[i].pan&=0xf0; - chan[i].pan|=chan[i].std.panR.val&15; - } - if (chan[i].std.panL.had || chan[i].std.panR.had) { - calcAndWriteOutVol(i,chan[i].std.vol.will?chan[i].std.vol.val:15); - } - if (chan[i].std.pitch.had) { - if (chan[i].std.pitch.mode) { - chan[i].pitch2+=chan[i].std.pitch.val; - CLAMP_VAR(chan[i].pitch2,-32768,32767); - } else { - chan[i].pitch2=chan[i].std.pitch.val; - } - chan[i].freqChanged=true; - } - if (chan[i].active) { - sndCtrl|=(1<calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,true,0,chan[i].pitch2,chipClock,CHIP_DIVIDER); - if (i==1 && pcm && furnaceDac) { - double off=1.0; - if (dacSample>=0 && dacSamplesong.sampleLen) { - DivSample* s=parent->getSample(dacSample); - if (s->centerRate<1) { - off=1.0; - } else { - off=parent->getCenterRate()/(double)s->centerRate; - } - } - dacRate=((double)chipClock/2)/MAX(1,off*chan[i].freq); - if (dumpWrites) postWrite(0xffff0001,dacRate); - } - if (chan[i].freq>2048) chan[i].freq=2048; - if (chan[i].freq<1) chan[i].freq=1; - int rVal=2048-chan[i].freq; - rWrite(i*2,rVal&0xff); - rWrite(i*2+1,rVal>>8); - if (chan[i].keyOn) { - if (!chan[i].std.vol.will) { - calcAndWriteOutVol(i,15); - } - chan[i].keyOn=false; - } - if (chan[i].keyOff) { - chan[i].keyOff=false; - } - chan[i].freqChanged=false; - } - } - if (chan[3].std.duty.had) { - if (noise!=chan[3].std.duty.val) { - noise=chan[3].std.duty.val; - if (noise>0) { - rWrite(0x0e,((noise-1)&0x07)|0x18); - sndCtrl|=0x80; - } else { - sndCtrl&=~0x80; - } - } - } - if (chan[3].std.phaseReset.had) { - if (noise>0) { - rWrite(0x0e,((noise-1)&0x07)|0x18); - sndCtrl|=0x80; - } else { - sndCtrl&=~0x80; - } - } - unsigned char origSndCtrl=sndCtrl; - bool phaseResetHappens=false; - for (int i=0; i<4; i++) { - if (chan[i].std.phaseReset.had) { - phaseResetHappens=true; - sndCtrl&=~(1<getIns(chan[c.chan].ins,DIV_INS_SWAN); - if (c.chan==1) { - if (ins->type==DIV_INS_AMIGA || ins->amiga.useSample) { - pcm=true; - } else if (furnaceDac) { - pcm=false; - chan[c.chan].sampleNote=DIV_NOTE_NULL; - chan[c.chan].sampleNoteDelta=0; - } - if (pcm) { - if (skipRegisterWrites) break; - if (setPos) { - setPos=false; - } else { - dacPos=0; - } - dacPeriod=0; - if (ins->type==DIV_INS_AMIGA || ins->amiga.useSample) { - if (c.value!=DIV_NOTE_NULL) { - dacSample=ins->amiga.getSample(c.value); - chan[c.chan].sampleNote=c.value; - c.value=ins->amiga.getFreq(c.value); - chan[c.chan].sampleNoteDelta=c.value-chan[c.chan].sampleNote; - } else if (chan[c.chan].sampleNote!=DIV_NOTE_NULL) { - dacSample=ins->amiga.getSample(chan[c.chan].sampleNote); - c.value=ins->amiga.getFreq(chan[c.chan].sampleNote); - } - if (dacSample<0 || dacSample>=parent->song.sampleLen) { - dacSample=-1; - if (dumpWrites) postWrite(0xffff0002,0); - break; - } else { - if (dumpWrites) { - postWrite(0xffff0000,dacSample); - } - } - if (c.value!=DIV_NOTE_NULL) { - chan[1].baseFreq=NOTE_PERIODIC(c.value); - chan[1].freqChanged=true; - chan[1].note=c.value; - } - chan[1].active=true; - chan[1].keyOn=true; - chan[1].macroInit(ins); - furnaceDac=true; - } else { - if (c.value!=DIV_NOTE_NULL) { - chan[1].note=c.value; - } - dacSample=12*sampleBank+chan[1].note%12; - if (dacSample>=parent->song.sampleLen) { - dacSample=-1; - if (dumpWrites) postWrite(0xffff0002,0); - break; - } else { - if (dumpWrites) postWrite(0xffff0000,dacSample); - } - dacRate=parent->getSample(dacSample)->rate; - if (dumpWrites) { - postWrite(0xffff0001,dacRate); - } - chan[1].active=true; - chan[1].keyOn=true; - furnaceDac=false; - } - break; - } - } - if (c.value!=DIV_NOTE_NULL) { - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value); - chan[c.chan].freqChanged=true; - chan[c.chan].note=c.value; - } - chan[c.chan].active=true; - chan[c.chan].keyOn=true; - chan[c.chan].macroInit(ins); - if (!parent->song.brokenOutVol && !chan[c.chan].std.vol.will) { - chan[c.chan].outVol=chan[c.chan].vol; - } - if (chan[c.chan].wave<0) { - chan[c.chan].wave=0; - chan[c.chan].ws.changeWave1(chan[c.chan].wave); - } - chan[c.chan].ws.init(ins,32,15,chan[c.chan].insChanged); - chan[c.chan].insChanged=false; - break; - } - case DIV_CMD_NOTE_OFF: - if (c.chan==1&&pcm) { - dacSample=-1; - if (dumpWrites) postWrite(0xffff0002,0); - pcm=false; - chan[c.chan].sampleNote=DIV_NOTE_NULL; - chan[c.chan].sampleNoteDelta=0; - } - chan[c.chan].active=false; - chan[c.chan].keyOff=true; - chan[c.chan].macroInit(NULL); - break; - case DIV_CMD_NOTE_OFF_ENV: - case DIV_CMD_ENV_RELEASE: - chan[c.chan].std.release(); - break; - case DIV_CMD_INSTRUMENT: - if (chan[c.chan].ins!=c.value || c.value2==1) { - chan[c.chan].ins=c.value; - chan[c.chan].insChanged=true; - } - break; - case DIV_CMD_VOLUME: - if (chan[c.chan].vol!=c.value) { - chan[c.chan].vol=c.value; - if (!chan[c.chan].std.vol.has) { - calcAndWriteOutVol(c.chan,15); - } - } - break; - case DIV_CMD_GET_VOLUME: - return chan[c.chan].vol; - break; - case DIV_CMD_PITCH: - chan[c.chan].pitch=c.value; - chan[c.chan].freqChanged=true; - break; - case DIV_CMD_WAVE: - chan[c.chan].wave=c.value; - chan[c.chan].ws.changeWave1(chan[c.chan].wave); - chan[c.chan].keyOn=true; - break; - case DIV_CMD_WS_SWEEP_TIME: - if (c.chan==2) { - if (c.value==0) { - sweep=false; - } else { - sweep=true; - rWrite(0x0d,(c.value-1)&0xff); - } - } - break; - case DIV_CMD_WS_SWEEP_AMOUNT: - if (c.chan==2) { - rWrite(0x0c,c.value&0xff); - } - break; - case DIV_CMD_NOTE_PORTA: { - int destFreq=NOTE_PERIODIC(c.value2+chan[c.chan].sampleNoteDelta); - bool return2=false; - if (destFreq>chan[c.chan].baseFreq) { - chan[c.chan].baseFreq+=c.value; - if (chan[c.chan].baseFreq>=destFreq) { - chan[c.chan].baseFreq=destFreq; - return2=true; - } - } else { - chan[c.chan].baseFreq-=c.value; - if (chan[c.chan].baseFreq<=destFreq) { - chan[c.chan].baseFreq=destFreq; - return2=true; - } - } - chan[c.chan].freqChanged=true; - if (return2) { - chan[c.chan].inPorta=false; - return 2; - } - break; - } - case DIV_CMD_STD_NOISE_MODE: - if (c.chan==3) { - noise=c.value&0xff; - if (noise>0) rWrite(0x0e,((noise-1)&0x07)|0x18); - } - break; - case DIV_CMD_SAMPLE_MODE: - if (c.chan==1) { - pcm=c.value; - if (!pcm) { - chan[c.chan].sampleNote=DIV_NOTE_NULL; - chan[c.chan].sampleNoteDelta=0; - } - } - break; - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - break; - case DIV_CMD_SAMPLE_POS: - dacPos=c.value; - setPos=true; - break; - case DIV_CMD_PANNING: { - chan[c.chan].pan=(c.value&0xf0)|(c.value2>>4); - calcAndWriteOutVol(c.chan,chan[c.chan].std.vol.will?chan[c.chan].std.vol.val:15); - break; - } - case DIV_CMD_LEGATO: - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+chan[c.chan].sampleNoteDelta+((HACKY_LEGATO_MESS)?(chan[c.chan].std.arp.val):(0))); - chan[c.chan].freqChanged=true; - chan[c.chan].note=c.value; - break; - case DIV_CMD_PRE_PORTA: - if (chan[c.chan].active && c.value2) { - if (parent->song.resetMacroOnPorta) chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_SWAN)); - } - if (!chan[c.chan].inPorta && c.value && !parent->song.brokenPortaArp && chan[c.chan].std.arp.will && !NEW_ARP_STRAT) chan[c.chan].baseFreq=NOTE_PERIODIC(chan[c.chan].note); - chan[c.chan].inPorta=c.value; - break; - case DIV_CMD_GET_VOLMAX: - return 15; - break; - case DIV_CMD_MACRO_OFF: - chan[c.chan].std.mask(c.value,true); - break; - case DIV_CMD_MACRO_ON: - chan[c.chan].std.mask(c.value,false); - break; - case DIV_CMD_MACRO_RESTART: - chan[c.chan].std.restart(c.value); - break; - default: - break; - } - return 1; -} - -void DivPlatformSwan::muteChannel(int ch, bool mute) { - isMuted[ch]=mute; - writeOutVol(ch); -} - -void DivPlatformSwan::forceIns() { - noise=0; - for (int i=0; i<4; i++) { - chan[i].insChanged=true; - chan[i].freqChanged=true; - updateWave(i); - writeOutVol(i); - } -} - -void* DivPlatformSwan::getChanState(int ch) { - return &chan[ch]; -} - -DivMacroInt* DivPlatformSwan::getChanMacroInt(int ch) { - return &chan[ch].std; -} - -unsigned short DivPlatformSwan::getPan(int ch) { - return ((chan[ch].pan&0xf0)<<4)|(chan[ch].pan&15); -} - -DivChannelModeHints DivPlatformSwan::getModeHints(int ch) { - DivChannelModeHints ret; - - switch (ch) { - case 1: // PCM - ret.count=1; - ret.hint[0]=ICON_FA_VOLUME_UP; - ret.type[0]=pcm?4:0; - break; - case 2: // sweep - ret.count=1; - ret.hint[0]=ICON_FUR_SAW; - ret.type[0]=sweep?2:0; - break; - case 3: // noise - ret.count=1; - ret.hint[0]=ICON_FUR_NOISE; - ret.type[0]=noise?4:0; - break; - } - - return ret; -} - -DivDispatchOscBuffer* DivPlatformSwan::getOscBuffer(int ch) { - return oscBuf[ch]; -} - -unsigned char* DivPlatformSwan::getRegisterPool() { - // get Random from emulator - regPool[0x12]=ws_mdfn->SoundRead(0x92); - regPool[0x13]=ws_mdfn->SoundRead(0x93); - return regPool; -} - -int DivPlatformSwan::getRegisterPoolSize() { - return 128; -} - -void DivPlatformSwan::reset() { - while (!writes.empty()) writes.pop(); - while (!postDACWrites.empty()) postDACWrites.pop(); - memset(regPool,0,128); - for (int i=0; i<4; i++) { - chan[i]=Channel(); - chan[i].vol=15; - chan[i].pan=0xff; - chan[i].std.setEngine(parent); - chan[i].ws.setEngine(parent); - chan[i].ws.init(NULL,32,15,false); - rWrite(0x08+i,0xff); - } - if (dumpWrites) { - addWrite(0xffffffff,0); - } - ws_mdfn->SoundReset(); - pcm=false; - sweep=false; - furnaceDac=false; - setPos=false; - noise=0; - dacPeriod=0; - dacRate=0; - dacPos=0; - dacSample=-1; - sampleBank=0; - rWrite(0x0f,0x00); // wave table at 0x0000 - rWrite(0x11,0x09); // enable speakers -} - -int DivPlatformSwan::getOutputCount() { - return 2; -} - -bool DivPlatformSwan::hasAcquireDirect() { - return true; -} - -void DivPlatformSwan::notifyWaveChange(int wave) { - for (int i=0; i<4; i++) { - if (chan[i].wave==wave) { - chan[i].ws.changeWave1(wave); - updateWave(i); - } - } -} - -void DivPlatformSwan::notifyInsDeletion(void* ins) { - for (int i=0; i<4; i++) { - chan[i].std.notifyInsDeletion((DivInstrument*)ins); - } -} - -void DivPlatformSwan::poke(unsigned int addr, unsigned short val) { - rWrite(addr,val); -} - -void DivPlatformSwan::poke(std::vector& wlist) { - for (DivRegWrite& i: wlist) rWrite(i.addr,i.val); -} - -void DivPlatformSwan::setFlags(const DivConfig& flags) { - chipClock=3072000; - CHECK_CUSTOM_CLOCK; - rate=chipClock; - for (int i=0; i<4; i++) { - oscBuf[i]->setRate(rate); - } -} - -int DivPlatformSwan::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) { - parent=p; - dumpWrites=false; - skipRegisterWrites=false; - for (int i=0; i<4; i++) { - isMuted[i]=false; - oscBuf[i]=new DivDispatchOscBuffer; - } - ws_mdfn=new WSwan(); - setFlags(flags); - reset(); - return 4; -} - -void DivPlatformSwan::quit() { - for (int i=0; i<4; i++) { - delete oscBuf[i]; - } - delete ws_mdfn; -} - -DivPlatformSwan::~DivPlatformSwan() { -} diff --git a/src/engine/platform/swan_before.h b/src/engine/platform/swan_before.h deleted file mode 100644 index 63508f163..000000000 --- a/src/engine/platform/swan_before.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Furnace Tracker - multi-system chiptune tracker - * Copyright (C) 2021-2025 tildearrow and contributors - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef _SWAN_H -#define _SWAN_H - -#include "../dispatch.h" -#include "../waveSynth.h" -#include "sound/swan_mdfn.h" -#include "../../fixedQueue.h" - -class DivPlatformSwan: public DivDispatch { - struct Channel: public SharedChannel { - unsigned char pan; - int wave; - DivWaveSynth ws; - Channel(): - SharedChannel(15), - pan(255), - wave(-1) {} - }; - Channel chan[4]; - DivDispatchOscBuffer* oscBuf[4]; - bool isMuted[4]; - bool pcm, sweep, furnaceDac, setPos; - unsigned char sampleBank, noise; - int dacPeriod, dacRate; - unsigned int dacPos; - int dacSample; - - unsigned char regPool[0x80]; - struct QueuedWrite { - unsigned char addr; - unsigned char val; - QueuedWrite(): addr(0), val(0) {} - QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} - }; - FixedQueue writes; - FixedQueue postDACWrites; - WSwan* ws_mdfn; - void updateWave(int ch); - friend void putDispatchChip(void*,int); - friend void putDispatchChan(void*,int,int); - public: - void acquireDirect(blip_buffer_t** bb, size_t len); - int dispatch(DivCommand c); - void* getChanState(int chan); - DivMacroInt* getChanMacroInt(int ch); - unsigned short getPan(int chan); - DivChannelModeHints getModeHints(int chan); - DivDispatchOscBuffer* getOscBuffer(int chan); - unsigned char* getRegisterPool(); - int getRegisterPoolSize(); - void reset(); - void forceIns(); - void tick(bool sysTick=true); - void muteChannel(int ch, bool mute); - void setFlags(const DivConfig& flags); - void notifyWaveChange(int wave); - void notifyInsDeletion(void* ins); - int getOutputCount(); - bool hasAcquireDirect(); - void poke(unsigned int addr, unsigned short val); - void poke(std::vector& wlist); - const char** getRegisterSheet(); - int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); - void quit(); - ~DivPlatformSwan(); - private: - void calcAndWriteOutVol(int ch, int env); - void writeOutVol(int ch); -}; - -#endif diff --git a/src/engine/platform/vrc6.cpp b/src/engine/platform/vrc6.cpp index ee6a95b4d..18a7be76a 100644 --- a/src/engine/platform/vrc6.cpp +++ b/src/engine/platform/vrc6.cpp @@ -407,12 +407,6 @@ int DivPlatformVRC6::dispatch(DivCommand c) { } } break; - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - break; case DIV_CMD_SAMPLE_POS: chan[c.chan].dacPos=c.value; chan[c.chan].setPos=true; @@ -510,7 +504,6 @@ void DivPlatformVRC6::reset() { addWrite(0xffffffff,0); } - sampleBank=0; prevSample=0; vrc6.reset(); diff --git a/src/engine/platform/vrc6.h b/src/engine/platform/vrc6.h index 6751e9389..eb4a6eecc 100644 --- a/src/engine/platform/vrc6.h +++ b/src/engine/platform/vrc6.h @@ -54,7 +54,6 @@ class DivPlatformVRC6: public DivDispatch, public vrcvi_intf { QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {} }; FixedQueue writes; - unsigned char sampleBank; vrcvi_core vrc6; int prevSample; unsigned char regPool[13]; diff --git a/src/engine/platform/x1_010.cpp b/src/engine/platform/x1_010.cpp index 00683f56d..36f0d26ee 100644 --- a/src/engine/platform/x1_010.cpp +++ b/src/engine/platform/x1_010.cpp @@ -711,12 +711,6 @@ int DivPlatformX1_010::dispatch(DivCommand c) { chan[c.chan].envChanged=true; } break; - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - break; case DIV_CMD_PANNING: { if (!stereo) break; unsigned char newPan=(c.value&0xf0)|(c.value2>>4); @@ -891,7 +885,6 @@ void DivPlatformX1_010::reset() { chan[i].ws.init(NULL,128,255,false); } x1_010.reset(); - sampleBank=0; // set per-channel initial panning for (int i=0; i<16; i++) { chWrite(i,0,0); diff --git a/src/engine/platform/x1_010.h b/src/engine/platform/x1_010.h index 7800dbc47..e16f51f3f 100644 --- a/src/engine/platform/x1_010.h +++ b/src/engine/platform/x1_010.h @@ -112,7 +112,6 @@ class DivPlatformX1_010: public DivDispatch, public vgsound_emu_mem_intf { bool stereo=false; unsigned char* sampleMem; size_t sampleMemLen; - unsigned char sampleBank; x1_010_core x1_010; bool isBanked=false; diff --git a/src/engine/platform/ym2203.cpp b/src/engine/platform/ym2203.cpp index 1d1f240c2..98fd77a36 100644 --- a/src/engine/platform/ym2203.cpp +++ b/src/engine/platform/ym2203.cpp @@ -1328,7 +1328,6 @@ void DivPlatformYM2203::reset() { } lastBusy=60; - sampleBank=0; delay=0; diff --git a/src/engine/platform/ym2203.h b/src/engine/platform/ym2203.h index 0166d7a85..123c371ba 100644 --- a/src/engine/platform/ym2203.h +++ b/src/engine/platform/ym2203.h @@ -55,7 +55,6 @@ class DivPlatformYM2203: public DivPlatformOPN { bool lastS; DivPlatformAY8910* ay; - unsigned char sampleBank; bool extMode, noExtMacros; unsigned char prescale, nukedMult; diff --git a/src/engine/platform/ym2608.cpp b/src/engine/platform/ym2608.cpp index 71d7d5b71..3897e9cc5 100644 --- a/src/engine/platform/ym2608.cpp +++ b/src/engine/platform/ym2608.cpp @@ -1392,13 +1392,6 @@ int DivPlatformYM2608::dispatch(DivCommand c) { PLEASE_HELP_ME(chan[c.chan],chan[c.chan].state.block); break; } - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - iface.sampleBank=sampleBank; - break; case DIV_CMD_LEGATO: { if (c.chan==csmChan) { chan[c.chan].baseFreq=NOTE_PERIODIC(c.value); @@ -1884,7 +1877,6 @@ void DivPlatformYM2608::reset() { lastBusy=60; lfoValue=8; - sampleBank=0; writeRSSOff=0; writeRSSOn=0; globalRSSVolume=0x3f; @@ -2087,7 +2079,6 @@ int DivPlatformYM2608::init(DivEngine* p, int channels, int sugRate, const DivCo adpcmBMem=new unsigned char[getSampleMemCapacity(0)]; adpcmBMemLen=0; iface.adpcmBMem=adpcmBMem; - iface.sampleBank=0; dumpWrites=false; skipRegisterWrites=false; for (int i=0; i<17; i++) { diff --git a/src/engine/platform/ym2608.h b/src/engine/platform/ym2608.h index 3bc09fa5d..46908e881 100644 --- a/src/engine/platform/ym2608.h +++ b/src/engine/platform/ym2608.h @@ -31,10 +31,9 @@ extern "C" { class DivYM2608Interface: public DivOPNInterface { public: unsigned char* adpcmBMem; - int sampleBank; uint8_t ymfm_external_read(ymfm::access_class type, uint32_t address); void ymfm_external_write(ymfm::access_class type, uint32_t address, uint8_t data); - DivYM2608Interface(): adpcmBMem(NULL), sampleBank(0) {} + DivYM2608Interface(): adpcmBMem(NULL) {} }; class DivPlatformYM2608: public DivPlatformOPN { @@ -71,7 +70,6 @@ class DivPlatformYM2608: public DivPlatformOPN { bool* sampleLoaded; DivPlatformAY8910* ay; - unsigned char sampleBank; unsigned char writeRSSOff, writeRSSOn; int globalRSSVolume; diff --git a/src/engine/platform/ym2610.cpp b/src/engine/platform/ym2610.cpp index fa0b4e3c3..1a050d1ac 100644 --- a/src/engine/platform/ym2610.cpp +++ b/src/engine/platform/ym2610.cpp @@ -1156,31 +1156,7 @@ int DivPlatformYM2610::dispatch(DivCommand c) { break; } } else { - chan[c.chan].sample=-1; - chan[c.chan].macroInit(NULL); - chan[c.chan].outVol=chan[c.chan].vol; - if ((12*sampleBank+c.value%12)>=parent->song.sampleLen) { - break; - } - chan[c.chan].sample=12*sampleBank+c.value%12; - if (chan[c.chan].sample>=0 && chan[c.chan].samplesong.sampleLen) { - DivSample* s=parent->getSample(12*sampleBank+c.value%12); - immWrite(0x110+c.chan-adpcmAChanOffs,(sampleOffA[chan[c.chan].sample]>>8)&0xff); - immWrite(0x118+c.chan-adpcmAChanOffs,sampleOffA[chan[c.chan].sample]>>16); - int end=sampleOffA[chan[c.chan].sample]+s->lengthA-1; - immWrite(0x120+c.chan-adpcmAChanOffs,(end>>8)&0xff); - immWrite(0x128+c.chan-adpcmAChanOffs,end>>16); - immWrite(0x108+c.chan-adpcmAChanOffs,isMuted[c.chan]?0:((chan[c.chan].pan<<6)|chan[c.chan].outVol)); - chan[c.chan].active=true; - chan[c.chan].keyOn=true; - } else { - writeADPCMAOff|=(1<<(c.chan-adpcmAChanOffs)); - immWrite(0x110+c.chan-adpcmAChanOffs,0); - immWrite(0x118+c.chan-adpcmAChanOffs,0); - immWrite(0x120+c.chan-adpcmAChanOffs,0); - immWrite(0x128+c.chan-adpcmAChanOffs,0); - break; - } + assert(false && "LEGACY SAMPLE MODE!!!"); } break; } @@ -1352,13 +1328,6 @@ int DivPlatformYM2610::dispatch(DivCommand c) { PLEASE_HELP_ME(chan[c.chan],chan[c.chan].state.block); break; } - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - iface.sampleBank=sampleBank; - break; case DIV_CMD_LEGATO: { if (c.chan==adpcmBChanOffs && !chan[c.chan].furnacePCM) break; if (c.chan==csmChan) { @@ -1792,7 +1761,6 @@ void DivPlatformYM2610::reset() { lastBusy=60; lfoValue=8; - sampleBank=0; DivPlatformYM2610Base::reset(); delay=0; diff --git a/src/engine/platform/ym2610b.cpp b/src/engine/platform/ym2610b.cpp index 71eb8a100..8fe8b61dc 100644 --- a/src/engine/platform/ym2610b.cpp +++ b/src/engine/platform/ym2610b.cpp @@ -1225,31 +1225,7 @@ int DivPlatformYM2610B::dispatch(DivCommand c) { break; } } else { - chan[c.chan].sample=-1; - chan[c.chan].macroInit(NULL); - chan[c.chan].outVol=chan[c.chan].vol; - if ((12*sampleBank+c.value%12)>=parent->song.sampleLen) { - break; - } - chan[c.chan].sample=12*sampleBank+c.value%12; - if (chan[c.chan].sample>=0 && chan[c.chan].samplesong.sampleLen) { - DivSample* s=parent->getSample(12*sampleBank+c.value%12); - immWrite(0x110+c.chan-adpcmAChanOffs,(sampleOffA[chan[c.chan].sample]>>8)&0xff); - immWrite(0x118+c.chan-adpcmAChanOffs,sampleOffA[chan[c.chan].sample]>>16); - int end=sampleOffA[chan[c.chan].sample]+s->lengthA-1; - immWrite(0x120+c.chan-adpcmAChanOffs,(end>>8)&0xff); - immWrite(0x128+c.chan-adpcmAChanOffs,end>>16); - immWrite(0x108+c.chan-adpcmAChanOffs,isMuted[c.chan]?0:((chan[c.chan].pan<<6)|chan[c.chan].outVol)); - chan[c.chan].active=true; - chan[c.chan].keyOn=true; - } else { - writeADPCMAOff|=(1<<(c.chan-adpcmAChanOffs)); - immWrite(0x110+c.chan-adpcmAChanOffs,0); - immWrite(0x118+c.chan-adpcmAChanOffs,0); - immWrite(0x120+c.chan-adpcmAChanOffs,0); - immWrite(0x128+c.chan-adpcmAChanOffs,0); - break; - } + assert(false && "LEGACY SAMPLE MODE!!!"); } break; } @@ -1421,13 +1397,6 @@ int DivPlatformYM2610B::dispatch(DivCommand c) { PLEASE_HELP_ME(chan[c.chan],chan[c.chan].state.block); break; } - case DIV_CMD_SAMPLE_BANK: - sampleBank=c.value; - if (sampleBank>(parent->song.sample.size()/12)) { - sampleBank=parent->song.sample.size()/12; - } - iface.sampleBank=sampleBank; - break; case DIV_CMD_LEGATO: { if (c.chan==adpcmBChanOffs && !chan[c.chan].furnacePCM) break; if (c.chan==csmChan) { @@ -1861,7 +1830,6 @@ void DivPlatformYM2610B::reset() { lastBusy=60; lfoValue=8; - sampleBank=0; DivPlatformYM2610Base::reset(); delay=0; diff --git a/src/engine/platform/ym2610shared.h b/src/engine/platform/ym2610shared.h index 9db752d6a..d3add1723 100644 --- a/src/engine/platform/ym2610shared.h +++ b/src/engine/platform/ym2610shared.h @@ -38,13 +38,11 @@ class DivYM2610Interface: public DivOPNInterface { public: unsigned char* adpcmAMem; unsigned char* adpcmBMem; - int sampleBank; uint8_t ymfm_external_read(ymfm::access_class type, uint32_t address); void ymfm_external_write(ymfm::access_class type, uint32_t address, uint8_t data); DivYM2610Interface(): adpcmAMem(NULL), - adpcmBMem(NULL), - sampleBank(0) {} + adpcmBMem(NULL) {} }; class DivPlatformYM2610Base: public DivPlatformOPN { @@ -78,8 +76,6 @@ class DivPlatformYM2610Base: public DivPlatformOPN { unsigned int* sampleOffA; unsigned int* sampleOffB; - unsigned char sampleBank; - bool extMode, noExtMacros; bool* sampleLoaded[2]; @@ -343,7 +339,6 @@ class DivPlatformYM2610Base: public DivPlatformOPN { adpcmBMemLen=0; iface.adpcmAMem=adpcmAMem; iface.adpcmBMem=adpcmBMem; - iface.sampleBank=0; fm=new ymfm::ym2610b(iface); fm->set_fidelity(ymfm::OPN_FIDELITY_MED); setFlags(flags); diff --git a/src/gui/debug.cpp b/src/gui/debug.cpp index 9097c2dcf..40cfb5dc1 100644 --- a/src/gui/debug.cpp +++ b/src/gui/debug.cpp @@ -103,7 +103,6 @@ #define OPNB_CHIP_DEBUG \ FM_OPN_CHIP_DEBUG; \ - ImGui::Text("- sampleBank: %d",ch->sampleBank); \ ImGui::Text("- writeADPCMAOff: %d",ch->writeADPCMAOff); \ ImGui::Text("- writeADPCMAOn: %d",ch->writeADPCMAOn); \ ImGui::Text("- globalADPCMAVolume: %d",ch->globalADPCMAVolume); \ @@ -164,7 +163,6 @@ ImGui::Text(" - output: %d",ch->dacOutput); \ ImGui::Text("- pan: %x",ch->pan); \ ImGui::Text("- opMask: %x",ch->opMask); \ - ImGui::Text("- sampleBank: %d",ch->sampleBank); \ COMMON_CHAN_DEBUG_BOOL; \ ImGui::TextColored(ch->furnaceDac?colorOn:colorOff,">> FurnaceDAC"); \ ImGui::TextColored(ch->hardReset?colorOn:colorOff,">> hardReset"); \ @@ -265,7 +263,6 @@ void putDispatchChip(void* data, int type) { DivPlatformYM2203* ch=(DivPlatformYM2203*)data; ImGui::Text("> YM2203"); FM_OPN_CHIP_DEBUG; - ImGui::Text("- sampleBank: %d",ch->sampleBank); ImGui::Text("- prescale: %d",ch->prescale); FM_OPN_CHIP_DEBUG_BOOL; ImGui::TextColored(ch->extMode?colorOn:colorOff,">> ExtMode"); @@ -276,7 +273,6 @@ void putDispatchChip(void* data, int type) { DivPlatformYM2608* ch=(DivPlatformYM2608*)data; ImGui::Text("> YM2608"); FM_OPN_CHIP_DEBUG; - ImGui::Text("- sampleBank: %d",ch->sampleBank); ImGui::Text("- writeRSSOff: %d",ch->writeRSSOff); ImGui::Text("- writeRSSOn: %d",ch->writeRSSOn); ImGui::Text("- globalRSSVolume: %d",ch->globalRSSVolume); @@ -318,7 +314,6 @@ void putDispatchChip(void* data, int type) { COMMON_CHIP_DEBUG; ImGui::Text("- lastPan: %d",ch->lastPan); ImGui::Text("- curChan: %d",ch->curChan); - ImGui::Text("- sampleBank: %d",ch->sampleBank); ImGui::Text("- lfoMode: %d",ch->lfoMode); ImGui::Text("- lfoSpeed: %d",ch->lfoSpeed); COMMON_CHIP_DEBUG_BOOL; @@ -336,7 +331,6 @@ void putDispatchChip(void* data, int type) { ImGui::Text(" - AntiClick: %d",ch->dacAntiClick); ImGui::Text(" - Sample: %d",ch->dacSample); ImGui::Text("- dpcmBank: %d",ch->dpcmBank); - ImGui::Text("- sampleBank: %d",ch->sampleBank); ImGui::Text("- writeOscBuf: %d",ch->writeOscBuf); ImGui::Text("- apuType: %d",ch->apuType); COMMON_CHIP_DEBUG_BOOL; @@ -380,7 +374,6 @@ void putDispatchChip(void* data, int type) { ImGui::Text("- pcmL: %d",ch->pcmL); ImGui::Text("- pcmR: %d",ch->pcmR); ImGui::Text("- pcmCycles: %d",ch->pcmCycles); - ImGui::Text("- sampleBank: %d",ch->sampleBank); COMMON_CHIP_DEBUG_BOOL; break; } @@ -388,7 +381,6 @@ void putDispatchChip(void* data, int type) { DivPlatformAY8910* ch=(DivPlatformAY8910*)data; ImGui::Text("> AY-3-8910"); COMMON_CHIP_DEBUG; - ImGui::Text("- sampleBank: %d",ch->sampleBank); ImGui::Text("- stereoSep: %d",ch->stereoSep); ImGui::Text("- delay: %d",ch->delay); ImGui::Text("- extClock: %d",ch->extClock); @@ -417,7 +409,6 @@ void putDispatchChip(void* data, int type) { ImGui::Text("* noise:"); ImGui::Text(" - and: %d",ch->ayNoiseAnd); ImGui::Text(" - or: %d",ch->ayNoiseOr); - ImGui::Text("- sampleBank: %d",ch->sampleBank); ImGui::Text("- stereoSep: %d",ch->stereoSep); ImGui::Text("- delay: %d",ch->delay); ImGui::Text("- portAVal: %d",ch->portAVal); @@ -445,7 +436,6 @@ void putDispatchChip(void* data, int type) { DivPlatformX1_010* ch=(DivPlatformX1_010*)data; ImGui::Text("> X1-010"); COMMON_CHIP_DEBUG; - ImGui::Text("- sampleBank: %d",ch->sampleBank); ImGui::Text("- bankSlot: [%d,%d,%d,%d,%d,%d,%d,%d]",ch->bankSlot[0],ch->bankSlot[1],ch->bankSlot[2],ch->bankSlot[3],ch->bankSlot[4],ch->bankSlot[5],ch->bankSlot[6],ch->bankSlot[7]); COMMON_CHIP_DEBUG_BOOL; ImGui::TextColored(ch->stereo?colorOn:colorOff,">> Stereo"); @@ -468,7 +458,6 @@ void putDispatchChip(void* data, int type) { DivPlatformVRC6* ch=(DivPlatformVRC6*)data; ImGui::Text("> VRC6"); COMMON_CHIP_DEBUG; - ImGui::Text("- sampleBank: %.2x",ch->sampleBank); COMMON_CHIP_DEBUG_BOOL; break; }