From b4ac5c7e6a28169c1c2d30dda242ac28becf0e3d Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 16 Apr 2022 01:39:40 -0500 Subject: [PATCH] implement pitch macro --- src/engine/platform/arcade.cpp | 4 ++++ src/engine/platform/ay.cpp | 3 +++ src/engine/platform/ay8930.cpp | 3 +++ src/engine/platform/bubsyswsg.cpp | 3 +++ src/engine/platform/c64.cpp | 3 +++ src/engine/platform/fds.cpp | 19 ++++++------------- src/engine/platform/gb.cpp | 3 +++ src/engine/platform/genesis.cpp | 4 ++++ src/engine/platform/lynx.cpp | 4 ++++ src/engine/platform/mmc5.cpp | 3 +++ src/engine/platform/n163.cpp | 3 +++ src/engine/platform/nes.cpp | 3 +++ src/engine/platform/opl.cpp | 4 ++++ src/engine/platform/opll.cpp | 4 ++++ src/engine/platform/pce.cpp | 3 +++ src/engine/platform/pcspkr.cpp | 3 +++ src/engine/platform/pet.cpp | 3 +++ src/engine/platform/qsound.cpp | 3 +++ src/engine/platform/saa.cpp | 3 +++ src/engine/platform/segapcm.cpp | 4 ++++ src/engine/platform/sms.cpp | 3 +++ src/engine/platform/swan.cpp | 3 +++ src/engine/platform/tia.cpp | 3 +++ src/engine/platform/tx81z.cpp | 4 ++++ src/engine/platform/vera.cpp | 3 +++ src/engine/platform/vic20.cpp | 3 +++ src/engine/platform/vrc6.cpp | 3 +++ src/engine/platform/x1_010.cpp | 3 +++ src/engine/platform/ym2610.cpp | 4 ++++ src/engine/platform/ym2610b.cpp | 4 ++++ 30 files changed, 102 insertions(+), 13 deletions(-) diff --git a/src/engine/platform/arcade.cpp b/src/engine/platform/arcade.cpp index 0bcb3b99..2935bad0 100644 --- a/src/engine/platform/arcade.cpp +++ b/src/engine/platform/arcade.cpp @@ -264,6 +264,10 @@ void DivPlatformArcade::tick(bool sysTick) { rWrite(0x1b,chan[i].std.wave.val&3); } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } + if (chan[i].std.phaseReset.had) { if (chan[i].std.phaseReset.val==1) { chan[i].keyOn=true; diff --git a/src/engine/platform/ay.cpp b/src/engine/platform/ay.cpp index d3db4ba8..25f49e95 100644 --- a/src/engine/platform/ay.cpp +++ b/src/engine/platform/ay.cpp @@ -215,6 +215,9 @@ void DivPlatformAY8910::tick(bool sysTick) { rWrite(0x08+i,(chan[i].outVol&15)|((chan[i].psgMode&4)<<2)); } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].std.phaseReset.had) { if (chan[i].std.phaseReset.val==1) { oldWrites[0x08+i]=-1; diff --git a/src/engine/platform/ay8930.cpp b/src/engine/platform/ay8930.cpp index 9fa39131..e4fa30dc 100644 --- a/src/engine/platform/ay8930.cpp +++ b/src/engine/platform/ay8930.cpp @@ -226,6 +226,9 @@ void DivPlatformAY8930::tick(bool sysTick) { rWrite(0x08+i,(chan[i].outVol&31)|((chan[i].psgMode&4)<<3)); } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].std.phaseReset.had) { if (chan[i].std.phaseReset.val==1) { oldWrites[0x08+i]=-1; diff --git a/src/engine/platform/bubsyswsg.cpp b/src/engine/platform/bubsyswsg.cpp index 91f50d46..569e82f1 100644 --- a/src/engine/platform/bubsyswsg.cpp +++ b/src/engine/platform/bubsyswsg.cpp @@ -110,6 +110,9 @@ void DivPlatformBubSysWSG::tick(bool sysTick) { if (!chan[i].keyOff) chan[i].keyOn=true; } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].active) { if (chan[i].ws.tick()) { updateWave(i); diff --git a/src/engine/platform/c64.cpp b/src/engine/platform/c64.cpp index 4c3cc32e..12ec3f5f 100644 --- a/src/engine/platform/c64.cpp +++ b/src/engine/platform/c64.cpp @@ -181,6 +181,9 @@ void DivPlatformC64::tick(bool sysTick) { 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)); } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].std.ex1.had) { filtControl=chan[i].std.ex1.val&15; updateFilter(); diff --git a/src/engine/platform/fds.cpp b/src/engine/platform/fds.cpp index 16e24f13..c581c516 100644 --- a/src/engine/platform/fds.cpp +++ b/src/engine/platform/fds.cpp @@ -107,21 +107,11 @@ void DivPlatformFDS::tick(bool sysTick) { rWrite(0x4080,0x80|chan[i].outVol); } if (chan[i].std.arp.had) { - if (i==3) { // noise + if (!chan[i].inPorta) { if (chan[i].std.arp.mode) { - chan[i].baseFreq=chan[i].std.arp.val; + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp.val); } else { - chan[i].baseFreq=chan[i].note+chan[i].std.arp.val; - } - if (chan[i].baseFreq>255) chan[i].baseFreq=255; - if (chan[i].baseFreq<0) chan[i].baseFreq=0; - } else { - if (!chan[i].inPorta) { - if (chan[i].std.arp.mode) { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp.val); - } else { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+chan[i].std.arp.val); - } + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+chan[i].std.arp.val); } } chan[i].freqChanged=true; @@ -155,6 +145,9 @@ void DivPlatformFDS::tick(bool sysTick) { //if (!chan[i].keyOff) chan[i].keyOn=true; } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].active) { if (ws.tick()) { updateWave(); diff --git a/src/engine/platform/gb.cpp b/src/engine/platform/gb.cpp index c28478a3..d3bb28e5 100644 --- a/src/engine/platform/gb.cpp +++ b/src/engine/platform/gb.cpp @@ -192,6 +192,9 @@ void DivPlatformGB::tick(bool sysTick) { if (!chan[i].keyOff) chan[i].keyOn=true; } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].std.phaseReset.had) { if (chan[i].std.phaseReset.val==1) { chan[i].keyOn=true; diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index bcca663e..1385c62c 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -258,6 +258,10 @@ void DivPlatformGenesis::tick(bool sysTick) { } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } + if (chan[i].std.phaseReset.had) { if (chan[i].std.phaseReset.val==1) { chan[i].keyOn=true; diff --git a/src/engine/platform/lynx.cpp b/src/engine/platform/lynx.cpp index a62f0d45..16d3f15e 100644 --- a/src/engine/platform/lynx.cpp +++ b/src/engine/platform/lynx.cpp @@ -171,6 +171,10 @@ void DivPlatformLynx::tick(bool sysTick) { } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } + if (chan[i].freqChanged) { if (chan[i].lfsr >= 0) { WRITE_LFSR(i, (chan[i].lfsr&0xff)); diff --git a/src/engine/platform/mmc5.cpp b/src/engine/platform/mmc5.cpp index 3c7f3dca..696ae6d2 100644 --- a/src/engine/platform/mmc5.cpp +++ b/src/engine/platform/mmc5.cpp @@ -123,6 +123,9 @@ void DivPlatformMMC5::tick(bool sysTick) { chan[i].duty=chan[i].std.duty.val; rWrite(0x5000+i*4,0x30|chan[i].outVol|((chan[i].duty&3)<<6)); } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].std.phaseReset.had) { if (chan[i].std.phaseReset.val==1) { chan[i].freqChanged=true; diff --git a/src/engine/platform/n163.cpp b/src/engine/platform/n163.cpp index 6a1eb60e..a9634fa9 100644 --- a/src/engine/platform/n163.cpp +++ b/src/engine/platform/n163.cpp @@ -261,6 +261,9 @@ void DivPlatformN163::tick(bool sysTick) { } } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].std.ex1.had) { if (chan[i].waveLen!=(chan[i].std.ex1.val&0xfc)) { chan[i].waveLen=chan[i].std.ex1.val&0xfc; diff --git a/src/engine/platform/nes.cpp b/src/engine/platform/nes.cpp index 7e291446..e4bfbca9 100644 --- a/src/engine/platform/nes.cpp +++ b/src/engine/platform/nes.cpp @@ -195,6 +195,9 @@ void DivPlatformNES::tick(bool sysTick) { chan[i].freqChanged=true; } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].sweepChanged) { chan[i].sweepChanged=false; if (i==0) { diff --git a/src/engine/platform/opl.cpp b/src/engine/platform/opl.cpp index e73ca41e..7050e000 100644 --- a/src/engine/platform/opl.cpp +++ b/src/engine/platform/opl.cpp @@ -269,6 +269,10 @@ void DivPlatformOPL::tick(bool sysTick) { } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } + if (chan[i].std.phaseReset.had) { if (chan[i].std.phaseReset.val==1) { chan[i].keyOn=true; diff --git a/src/engine/platform/opll.cpp b/src/engine/platform/opll.cpp index cb6ceba8..d94d1e26 100644 --- a/src/engine/platform/opll.cpp +++ b/src/engine/platform/opll.cpp @@ -145,6 +145,10 @@ void DivPlatformOPLL::tick(bool sysTick) { } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } + if (chan[i].std.phaseReset.had) { if (chan[i].std.phaseReset.val==1) { chan[i].keyOn=true; diff --git a/src/engine/platform/pce.cpp b/src/engine/platform/pce.cpp index cff5e534..2c248db0 100644 --- a/src/engine/platform/pce.cpp +++ b/src/engine/platform/pce.cpp @@ -196,6 +196,9 @@ void DivPlatformPCE::tick(bool sysTick) { if (!chan[i].keyOff) chan[i].keyOn=true; } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].active) { if (chan[i].ws.tick() || (chan[i].std.phaseReset.had && chan[i].std.phaseReset.val==1)) { updateWave(i); diff --git a/src/engine/platform/pcspkr.cpp b/src/engine/platform/pcspkr.cpp index 8e1705f5..e7062d21 100644 --- a/src/engine/platform/pcspkr.cpp +++ b/src/engine/platform/pcspkr.cpp @@ -186,6 +186,9 @@ void DivPlatformPCSpeaker::tick(bool sysTick) { chan[i].freqChanged=true; } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1+chan[i].std.pitch.val; if (chan[i].freq<0) chan[i].freq=0; diff --git a/src/engine/platform/pet.cpp b/src/engine/platform/pet.cpp index 0fe4523d..47bb2e3d 100644 --- a/src/engine/platform/pet.cpp +++ b/src/engine/platform/pet.cpp @@ -112,6 +112,9 @@ void DivPlatformPET::tick(bool sysTick) { rWrite(10,chan.wave); } } + if (chan.std.pitch.had) { + chan.freqChanged=true; + } if (chan.freqChanged || chan.keyOn || chan.keyOff) { chan.freq=parent->calcFreq(chan.baseFreq,chan.pitch,true)+chan.std.pitch.val; if (chan.freq>257) chan.freq=257; diff --git a/src/engine/platform/qsound.cpp b/src/engine/platform/qsound.cpp index 601ea0ea..33887010 100644 --- a/src/engine/platform/qsound.cpp +++ b/src/engine/platform/qsound.cpp @@ -326,6 +326,9 @@ void DivPlatformQSound::tick(bool sysTick) { chan[i].freqChanged=true; } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { //DivInstrument* ins=parent->getIns(chan[i].ins); chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false)+chan[i].std.pitch.val; diff --git a/src/engine/platform/saa.cpp b/src/engine/platform/saa.cpp index ca91800c..0e06c338 100644 --- a/src/engine/platform/saa.cpp +++ b/src/engine/platform/saa.cpp @@ -166,6 +166,9 @@ void DivPlatformSAA1099::tick(bool sysTick) { if (chan[i].std.wave.had) { chan[i].psgMode=chan[i].std.wave.val&3; } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].std.ex1.had) { saaEnv[i/3]=chan[i].std.ex1.val; rWrite(0x18+(i/3),saaEnv[i/3]); diff --git a/src/engine/platform/segapcm.cpp b/src/engine/platform/segapcm.cpp index 97ff900a..79d7179a 100644 --- a/src/engine/platform/segapcm.cpp +++ b/src/engine/platform/segapcm.cpp @@ -99,6 +99,10 @@ void DivPlatformSegaPCM::tick(bool sysTick) { chan[i].freqChanged=true; } } + + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } /*if (chan[i].keyOn || chan[i].keyOff) { chan[i].keyOff=false; }*/ diff --git a/src/engine/platform/sms.cpp b/src/engine/platform/sms.cpp index acd2c072..d755e84f 100644 --- a/src/engine/platform/sms.cpp +++ b/src/engine/platform/sms.cpp @@ -98,6 +98,9 @@ void DivPlatformSMS::tick(bool sysTick) { } } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } } for (int i=0; i<3; i++) { if (chan[i].freqChanged) { diff --git a/src/engine/platform/swan.cpp b/src/engine/platform/swan.cpp index 99d819b1..3b4a955e 100644 --- a/src/engine/platform/swan.cpp +++ b/src/engine/platform/swan.cpp @@ -173,6 +173,9 @@ void DivPlatformSwan::tick(bool sysTick) { chan[i].ws.changeWave1(chan[i].wave); } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].active) { sndCtrl|=(1<calcFreq(chan[i].baseFreq,chan[i].pitch,false,8)+chan[i].std.pitch.val; if (chan[i].freq>65535) chan[i].freq=65535; diff --git a/src/engine/platform/vic20.cpp b/src/engine/platform/vic20.cpp index 7817cd83..44aba967 100644 --- a/src/engine/platform/vic20.cpp +++ b/src/engine/platform/vic20.cpp @@ -119,6 +119,9 @@ void DivPlatformVIC20::tick(bool sysTick) { chan[i].keyOn=true; } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)+chan[i].std.pitch.val; if (i<3) { diff --git a/src/engine/platform/vrc6.cpp b/src/engine/platform/vrc6.cpp index 048b42cd..d8b37d92 100644 --- a/src/engine/platform/vrc6.cpp +++ b/src/engine/platform/vrc6.cpp @@ -178,6 +178,9 @@ void DivPlatformVRC6::tick(bool sysTick) { chWrite(i,0,(chan[i].outVol&0xf)|((chan[i].duty&7)<<4)); } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { if (i==2) { // sawtooth chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1+chan[i].std.pitch.val; diff --git a/src/engine/platform/x1_010.cpp b/src/engine/platform/x1_010.cpp index df6682ad..229d8eab 100644 --- a/src/engine/platform/x1_010.cpp +++ b/src/engine/platform/x1_010.cpp @@ -372,6 +372,9 @@ void DivPlatformX1_010::tick(bool sysTick) { } } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].std.ex1.had) { bool nextEnable=(chan[i].std.ex1.val&1); if (nextEnable!=(chan[i].env.flag.envEnable)) { diff --git a/src/engine/platform/ym2610.cpp b/src/engine/platform/ym2610.cpp index 3d6c8ed2..6f4a1e46 100644 --- a/src/engine/platform/ym2610.cpp +++ b/src/engine/platform/ym2610.cpp @@ -408,6 +408,10 @@ void DivPlatformYM2610::tick(bool sysTick) { } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } + if (chan[i].std.phaseReset.had) { if (chan[i].std.phaseReset.val==1) { chan[i].keyOn=true; diff --git a/src/engine/platform/ym2610b.cpp b/src/engine/platform/ym2610b.cpp index aeadeae4..04bc096a 100644 --- a/src/engine/platform/ym2610b.cpp +++ b/src/engine/platform/ym2610b.cpp @@ -472,6 +472,10 @@ void DivPlatformYM2610B::tick(bool sysTick) { } } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } + if (chan[i].std.phaseReset.had) { if (chan[i].std.phaseReset.val==1) { chan[i].keyOn=true;