From 90b76d20e3396823572646b18fa25a7a142e4f20 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 12 Jul 2023 06:04:37 -0500 Subject: [PATCH 01/13] C64: fix reSIDfp muting --- src/engine/platform/sound/c64_fp/SID.cpp | 6 +++--- src/engine/platform/sound/c64_fp/SID.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/engine/platform/sound/c64_fp/SID.cpp b/src/engine/platform/sound/c64_fp/SID.cpp index a996d223..03c778c9 100644 --- a/src/engine/platform/sound/c64_fp/SID.cpp +++ b/src/engine/platform/sound/c64_fp/SID.cpp @@ -351,7 +351,7 @@ void SID::write(int offset, unsigned char value) break; case 0x04: // Voice #1 control register - voice[0]->writeCONTROL_REG(muted[0] ? 0 : value); + voice[0]->writeCONTROL_REG(value); break; case 0x05: // Voice #1 Attack and Decay length @@ -379,7 +379,7 @@ void SID::write(int offset, unsigned char value) break; case 0x0b: // Voice #2 control register - voice[1]->writeCONTROL_REG(muted[1] ? 0 : value); + voice[1]->writeCONTROL_REG(value); break; case 0x0c: // Voice #2 Attack and Decay length @@ -407,7 +407,7 @@ void SID::write(int offset, unsigned char value) break; case 0x12: // Voice #3 control register - voice[2]->writeCONTROL_REG(muted[2] ? 0 : value); + voice[2]->writeCONTROL_REG(value); break; case 0x13: // Voice #3 Attack and Decay length diff --git a/src/engine/platform/sound/c64_fp/SID.h b/src/engine/platform/sound/c64_fp/SID.h index 85b6a4e4..77d7706d 100644 --- a/src/engine/platform/sound/c64_fp/SID.h +++ b/src/engine/platform/sound/c64_fp/SID.h @@ -320,11 +320,11 @@ int SID::output() const int v2 = voice[1]->output(voice[0]->wave()); const int v3 = voice[2]->output(voice[1]->wave()); - lastChanOut[0]=v1; - lastChanOut[1]=v2; - lastChanOut[2]=v3; + lastChanOut[0]=muted[0]?0:v1; + lastChanOut[1]=muted[1]?0:v2; + lastChanOut[2]=muted[2]?0:v3; - return externalFilter->clock(filter->clock(v1, v2, v3)); + return externalFilter->clock(filter->clock(muted[0]?0:v1, muted[1]?0:v2, muted[2]?0:v3)); } From dbd200c2795a94121106891dafc0b68a1d1deb36 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 12 Jul 2023 19:43:15 -0500 Subject: [PATCH 02/13] prepare to use FixedQueue avoiding allocations in real-time code --- src/engine/fixedQueue.h | 81 +++++++++++++++++++++++++++++++++++++ src/engine/platform/pce.cpp | 2 +- src/engine/platform/pce.h | 5 ++- 3 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 src/engine/fixedQueue.h diff --git a/src/engine/fixedQueue.h b/src/engine/fixedQueue.h new file mode 100644 index 00000000..4b0d8129 --- /dev/null +++ b/src/engine/fixedQueue.h @@ -0,0 +1,81 @@ +/** + * Furnace Tracker - multi-system chiptune tracker + * Copyright (C) 2021-2023 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 _FIXED_QUEUE_H +#define _FIXED_QUEUE_H + +#include +#include "../ta-log.h" + +template struct FixedQueue { + size_t readPos, writePos; + T data[items]; + + T& front(); + bool pop(); + bool push(const T& item); + void clear(); + bool empty(); + size_t size(); + FixedQueue(): + readPos(0), + writePos(0) {} +}; + +template T& FixedQueue::front() { + return data[readPos]; +} + +template bool FixedQueue::pop() { + if (readPos==writePos) return false; + if (++readPos>=items) readPos=0; + return true; +} + +template bool FixedQueue::push(const T& item) { + if (writePos==(readPos-1)) { + logW("queue overflow!"); + return false; + } + if (writePos==0 && readPos==items-1) { + logW("queue overflow!"); + return false; + } + data[writePos]=item; + if (++writePos>=items) writePos=0; + return true; +} + +template void FixedQueue::clear() { + readPos=0; + writePos=0; +} + +template bool FixedQueue::empty() { + return (readPos==writePos); +} + +template size_t FixedQueue::size() { + if (readPos>writePos) { + return items+writePos-readPos; + } + return writePos-readPos; +} + +#endif diff --git a/src/engine/platform/pce.cpp b/src/engine/platform/pce.cpp index 47e5bbcd..8066bff2 100644 --- a/src/engine/platform/pce.cpp +++ b/src/engine/platform/pce.cpp @@ -22,7 +22,7 @@ #include //#define rWrite(a,v) pendingWrites[a]=v; -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define chWrite(c,a,v) \ if (!skipRegisterWrites) { \ if (curChan!=c) { \ diff --git a/src/engine/platform/pce.h b/src/engine/platform/pce.h index 9b8c610c..45279179 100644 --- a/src/engine/platform/pce.h +++ b/src/engine/platform/pce.h @@ -21,7 +21,7 @@ #define _PCE_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "../waveSynth.h" #include "sound/pce_psg.h" @@ -62,9 +62,10 @@ class DivPlatformPCE: public DivDispatch { struct QueuedWrite { unsigned char addr; unsigned char val; + QueuedWrite(): addr(0), val(9) {} QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; + FixedQueue writes; unsigned char lastPan; int cycles, curChan, delay; From 99be9cb337ebca478f8383813320537f743c2edd Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 12 Jul 2023 19:54:37 -0500 Subject: [PATCH 03/13] FixedQueue, part 1 --- src/engine/platform/fmsharedbase.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/platform/fmsharedbase.h b/src/engine/platform/fmsharedbase.h index b59b419d..b08bda9f 100644 --- a/src/engine/platform/fmsharedbase.h +++ b/src/engine/platform/fmsharedbase.h @@ -79,6 +79,7 @@ class DivPlatformFMBase: public DivDispatch { unsigned short addr; unsigned char val; bool addrOrVal; + QueuedWrite(): addr(0), val(0), addrOrVal(false) {} QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {} }; std::deque writes; From 01ba81cbccc6c3158370c28e9b157982017af222 Mon Sep 17 00:00:00 2001 From: MooingLemur Date: Wed, 12 Jul 2023 21:34:59 -0700 Subject: [PATCH 04/13] Add cover song to demos/x16 --- demos/x16/Shades of Blue.fur | Bin 0 -> 4651 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 demos/x16/Shades of Blue.fur diff --git a/demos/x16/Shades of Blue.fur b/demos/x16/Shades of Blue.fur new file mode 100644 index 0000000000000000000000000000000000000000..6d6e5a510de096706b932a2fc897fdf93757b52f GIT binary patch literal 4651 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 literal 0 HcmV?d00001 From 708c363635895e2f085b044188ae143c79ca5467 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 13 Jul 2023 04:09:20 -0500 Subject: [PATCH 05/13] FixedQueue, part 2 --- src/engine/dispatch.h | 2 + src/engine/fixedQueue.h | 61 +++++++++++++++++++++++++++++- src/engine/platform/amiga.h | 1 - src/engine/platform/arcade.cpp | 2 +- src/engine/platform/arcade.h | 1 - src/engine/platform/ay.cpp | 2 +- src/engine/platform/ay.h | 5 ++- src/engine/platform/ay8930.cpp | 2 +- src/engine/platform/ay8930.h | 5 ++- src/engine/platform/bubsyswsg.h | 1 - src/engine/platform/c64.cpp | 2 +- src/engine/platform/c64.h | 5 ++- src/engine/platform/es5506.cpp | 23 +++++------ src/engine/platform/es5506.h | 24 ++++++------ src/engine/platform/fmsharedbase.h | 4 +- src/engine/platform/ga20.cpp | 8 ++-- src/engine/platform/ga20.h | 13 +++---- src/engine/platform/gb.cpp | 4 +- src/engine/platform/gb.h | 11 +++--- src/engine/platform/genesis.cpp | 4 +- src/engine/platform/k007232.cpp | 2 +- src/engine/platform/k007232.h | 5 ++- src/engine/platform/msm5232.cpp | 2 +- src/engine/platform/msm5232.h | 11 +++--- src/engine/platform/msm6258.cpp | 2 +- src/engine/platform/msm6258.h | 5 ++- src/engine/platform/msm6295.cpp | 4 +- src/engine/platform/msm6295.h | 5 ++- src/engine/platform/n163.cpp | 4 +- src/engine/platform/n163.h | 13 ++++--- src/engine/platform/namcowsg.cpp | 2 +- src/engine/platform/namcowsg.h | 11 +++--- src/engine/platform/opl.cpp | 2 +- src/engine/platform/opl.h | 5 ++- src/engine/platform/opll.cpp | 2 +- src/engine/platform/opll.h | 5 ++- src/engine/platform/pce.cpp | 2 +- src/engine/platform/pce.h | 8 ++-- src/engine/platform/pcmdac.h | 1 - src/engine/platform/pcspkr.h | 8 +++- src/engine/platform/pokey.cpp | 2 +- src/engine/platform/pokey.h | 11 +++--- src/engine/platform/pv1000.h | 1 - src/engine/platform/qsound.h | 1 - src/engine/platform/rf5c68.h | 1 - src/engine/platform/saa.cpp | 2 +- src/engine/platform/saa.h | 5 ++- src/engine/platform/scc.h | 1 - src/engine/platform/segapcm.cpp | 2 +- src/engine/platform/segapcm.h | 5 ++- src/engine/platform/sm8521.cpp | 2 +- src/engine/platform/sm8521.h | 11 +++--- src/engine/platform/sms.cpp | 2 +- src/engine/platform/sms.h | 5 ++- src/engine/platform/snes.h | 5 ++- src/engine/platform/su.cpp | 2 +- src/engine/platform/su.h | 11 +++--- src/engine/platform/swan.cpp | 4 +- src/engine/platform/swan.h | 13 ++++--- src/engine/platform/t6w28.cpp | 2 +- src/engine/platform/t6w28.h | 11 +++--- src/engine/platform/tia.h | 1 - src/engine/platform/tx81z.cpp | 2 +- src/engine/platform/tx81z.h | 2 +- src/engine/platform/vb.cpp | 2 +- src/engine/platform/vb.h | 11 +++--- src/engine/platform/vic20.h | 1 - src/engine/platform/vrc6.cpp | 2 +- src/engine/platform/vrc6.h | 11 +++--- src/engine/platform/ym2203.cpp | 2 +- src/engine/platform/ym2608.cpp | 2 +- src/engine/platform/ym2610.cpp | 2 +- src/engine/platform/ym2610b.cpp | 2 +- src/engine/platform/ymz280b.h | 1 - src/engine/platform/zxbeeper.cpp | 1 - src/engine/platform/zxbeeper.h | 7 ---- 76 files changed, 245 insertions(+), 182 deletions(-) diff --git a/src/engine/dispatch.h b/src/engine/dispatch.h index acb7af66..767db912 100644 --- a/src/engine/dispatch.h +++ b/src/engine/dispatch.h @@ -295,6 +295,8 @@ struct DivRegWrite { */ unsigned int addr; unsigned int val; + DivRegWrite(): + addr(0), val(0) {} DivRegWrite(unsigned int a, unsigned int v): addr(a), val(v) {} }; diff --git a/src/engine/fixedQueue.h b/src/engine/fixedQueue.h index 4b0d8129..afcf8afc 100644 --- a/src/engine/fixedQueue.h +++ b/src/engine/fixedQueue.h @@ -28,8 +28,14 @@ template struct FixedQueue { T data[items]; T& front(); + T& back(); bool pop(); bool push(const T& item); + + bool pop_front(); + bool pop_back(); + bool push_front(const T& item); + bool push_back(const T& item); void clear(); bool empty(); size_t size(); @@ -42,6 +48,11 @@ template T& FixedQueue::front() { return data[readPos]; } +template T& FixedQueue::back() { + if (writePos==0) return data[items-1]; + return data[writePos-1]; +} + template bool FixedQueue::pop() { if (readPos==writePos) return false; if (++readPos>=items) readPos=0; @@ -53,7 +64,7 @@ template bool FixedQueue::push(const T& item logW("queue overflow!"); return false; } - if (writePos==0 && readPos==items-1) { + if (writePos==items-1 && readPos==0) { logW("queue overflow!"); return false; } @@ -62,6 +73,54 @@ template bool FixedQueue::push(const T& item return true; } +template bool FixedQueue::pop_front() { + if (readPos==writePos) return false; + if (++readPos>=items) readPos=0; + return true; +} + +template bool FixedQueue::push_back(const T& item) { + if (writePos==(readPos-1)) { + logW("queue overflow!"); + return false; + } + if (writePos==items-1 && readPos==0) { + logW("queue overflow!"); + return false; + } + data[writePos]=item; + if (++writePos>=items) writePos=0; + return true; +} + +template bool FixedQueue::pop_back() { + if (readPos==writePos) return false; + if (writePos>0) { + writePos--; + } else { + writePos=items-1; + } + return true; +} + +template bool FixedQueue::push_front(const T& item) { + if (readPos==(writePos+1)) { + logW("stack overflow!"); + return false; + } + if (readPos==0 && writePos==items-1) { + logW("stack overflow!"); + return false; + } + data[readPos]=item; + if (readPos>0) { + readPos--; + } else { + readPos=items-1; + } + return true; +} + template void FixedQueue::clear() { readPos=0; writePos=0; diff --git a/src/engine/platform/amiga.h b/src/engine/platform/amiga.h index 1c793296..a05a5994 100644 --- a/src/engine/platform/amiga.h +++ b/src/engine/platform/amiga.h @@ -21,7 +21,6 @@ #define _AMIGA_H #include "../dispatch.h" -#include #include "../waveSynth.h" class DivPlatformAmiga: public DivDispatch { diff --git a/src/engine/platform/arcade.cpp b/src/engine/platform/arcade.cpp index 0e38bf96..20110b9d 100644 --- a/src/engine/platform/arcade.cpp +++ b/src/engine/platform/arcade.cpp @@ -878,7 +878,7 @@ void DivPlatformArcade::poke(std::vector& wlist) { } void DivPlatformArcade::reset() { - while (!writes.empty()) writes.pop_front(); + writes.clear(); memset(regPool,0,256); if (useYMFM) { fm_ymfm->reset(); diff --git a/src/engine/platform/arcade.h b/src/engine/platform/arcade.h index edcdd8d1..b5720f19 100644 --- a/src/engine/platform/arcade.h +++ b/src/engine/platform/arcade.h @@ -20,7 +20,6 @@ #ifndef _ARCADE_H #define _ARCADE_H #include "fmshared_OPM.h" -#include #include "../../../extern/opm/opm.h" #include "sound/ymfm/ymfm_opm.h" diff --git a/src/engine/platform/ay.cpp b/src/engine/platform/ay.cpp index c32a4ee2..5d9a5593 100644 --- a/src/engine/platform/ay.cpp +++ b/src/engine/platform/ay.cpp @@ -25,7 +25,7 @@ #include #define rWrite(a,v) if (!skipRegisterWrites) {pendingWrites[a]=v;} -#define immWrite(a,v) if (!skipRegisterWrites) {writes.emplace(regRemap(a),v); if (dumpWrites) {addWrite(regRemap(a),v);} } +#define immWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(regRemap(a),v)); if (dumpWrites) {addWrite(regRemap(a),v);} } #define CHIP_DIVIDER (extMode?extDiv:((sunsoft||clockSel)?16:8)) diff --git a/src/engine/platform/ay.h b/src/engine/platform/ay.h index 04e3aed1..999db1e5 100644 --- a/src/engine/platform/ay.h +++ b/src/engine/platform/ay.h @@ -20,7 +20,7 @@ #ifndef _AY_H #define _AY_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "sound/ay8910.h" class DivPlatformAY8910: public DivDispatch { @@ -89,9 +89,10 @@ class DivPlatformAY8910: public DivDispatch { unsigned short addr; unsigned char val; bool addrOrVal; + QueuedWrite(): addr(0), val(0), addrOrVal(false) {} QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {} }; - std::queue writes; + FixedQueue writes; ay8910_device* ay; DivDispatchOscBuffer* oscBuf[3]; unsigned char regPool[16]; diff --git a/src/engine/platform/ay8930.cpp b/src/engine/platform/ay8930.cpp index 8561548d..10421942 100644 --- a/src/engine/platform/ay8930.cpp +++ b/src/engine/platform/ay8930.cpp @@ -25,7 +25,7 @@ #include #define rWrite(a,v) if (!skipRegisterWrites) {pendingWrites[a]=v;} -#define immWrite2(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define immWrite2(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define CHIP_DIVIDER (clockSel?8:4) diff --git a/src/engine/platform/ay8930.h b/src/engine/platform/ay8930.h index 3b47cf0d..113aed91 100644 --- a/src/engine/platform/ay8930.h +++ b/src/engine/platform/ay8930.h @@ -20,7 +20,7 @@ #ifndef _AY8930_H #define _AY8930_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "sound/ay8910.h" class DivPlatformAY8930: public DivDispatch { @@ -99,9 +99,10 @@ class DivPlatformAY8930: public DivDispatch { unsigned short addr; unsigned char val; bool addrOrVal; + QueuedWrite(): addr(0), val(0), addrOrVal(false) {} QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {} }; - std::queue writes; + FixedQueue writes; ay8930_device* ay; DivDispatchOscBuffer* oscBuf[3]; unsigned char regPool[32]; diff --git a/src/engine/platform/bubsyswsg.h b/src/engine/platform/bubsyswsg.h index 784396bf..c3891bf6 100644 --- a/src/engine/platform/bubsyswsg.h +++ b/src/engine/platform/bubsyswsg.h @@ -21,7 +21,6 @@ #define _K005289_H #include "../dispatch.h" -#include #include "../waveSynth.h" #include "vgsound_emu/src/k005289/k005289.hpp" diff --git a/src/engine/platform/c64.cpp b/src/engine/platform/c64.cpp index 5c1521ab..6ca85ffe 100644 --- a/src/engine/platform/c64.cpp +++ b/src/engine/platform/c64.cpp @@ -23,7 +23,7 @@ #include #include "../../ta-log.h" -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define CHIP_FREQBASE 524288 diff --git a/src/engine/platform/c64.h b/src/engine/platform/c64.h index 5f67b956..0da59fc8 100644 --- a/src/engine/platform/c64.h +++ b/src/engine/platform/c64.h @@ -21,7 +21,7 @@ #define _C64_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "sound/c64/sid.h" #include "sound/c64_fp/SID.h" #include "sound/c64_d/dsid.h" @@ -62,9 +62,10 @@ class DivPlatformC64: public DivDispatch { struct QueuedWrite { unsigned char addr; unsigned char val; + QueuedWrite(): addr(0), val(0) {} QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; + FixedQueue writes; unsigned char filtControl, filtRes, vol; unsigned char writeOscBuf; diff --git a/src/engine/platform/es5506.cpp b/src/engine/platform/es5506.cpp index f388e860..adb342f3 100644 --- a/src/engine/platform/es5506.cpp +++ b/src/engine/platform/es5506.cpp @@ -26,9 +26,8 @@ #define PITCH_OFFSET ((double)(16*2048*(chanMax+1))) #define NOTE_ES5506(c,note) (parent->calcBaseFreq(chipClock,chan[c].pcm.freqOffs,note,false)) -#define rWrite(a,...) {if(!skipRegisterWrites) {hostIntf32.emplace(4,(a),__VA_ARGS__); }} -//#define rRead(a,st,...) {hostIntf32.emplace(st,4,(a),__VA_ARGS__);} -#define immWrite(a,...) {hostIntf32.emplace(4,(a),__VA_ARGS__);} +#define rWrite(a,...) {if(!skipRegisterWrites) {hostIntf32.push_back(QueuedHostIntf(4,(a),__VA_ARGS__)); }} +#define immWrite(a,...) {hostIntf32.push_back(QueuedHostIntf(4,(a),__VA_ARGS__));} #define pageWrite(p,a,...) \ if (!skipRegisterWrites) { \ if (curPage!=(p)) { \ @@ -118,15 +117,15 @@ void DivPlatformES5506::acquire(short** buf, size_t len) { while (!hostIntf32.empty()) { QueuedHostIntf w=hostIntf32.front(); if (w.isRead && (w.read!=NULL)) { - hostIntf8.emplace(w.state,0,w.addr,w.read,w.mask); - hostIntf8.emplace(w.state,1,w.addr,w.read,w.mask); - hostIntf8.emplace(w.state,2,w.addr,w.read,w.mask); - hostIntf8.emplace(w.state,3,w.addr,w.read,w.mask,w.delay); + hostIntf8.push(QueuedHostIntf(w.state,0,w.addr,w.read,w.mask)); + hostIntf8.push(QueuedHostIntf(w.state,1,w.addr,w.read,w.mask)); + hostIntf8.push(QueuedHostIntf(w.state,2,w.addr,w.read,w.mask)); + hostIntf8.push(QueuedHostIntf(w.state,3,w.addr,w.read,w.mask,w.delay)); } else { - hostIntf8.emplace(0,w.addr,w.val,w.mask); - hostIntf8.emplace(1,w.addr,w.val,w.mask); - hostIntf8.emplace(2,w.addr,w.val,w.mask); - hostIntf8.emplace(3,w.addr,w.val,w.mask,w.delay); + hostIntf8.push(QueuedHostIntf(0,w.addr,w.val,w.mask)); + hostIntf8.push(QueuedHostIntf(1,w.addr,w.val,w.mask)); + hostIntf8.push(QueuedHostIntf(2,w.addr,w.val,w.mask)); + hostIntf8.push(QueuedHostIntf(3,w.addr,w.val,w.mask,w.delay)); } hostIntf32.pop(); } @@ -1095,8 +1094,6 @@ DivMacroInt* DivPlatformES5506::getChanMacroInt(int ch) { void DivPlatformES5506::reset() { while (!hostIntf32.empty()) hostIntf32.pop(); while (!hostIntf8.empty()) hostIntf8.pop(); - while (!queuedRead.empty()) queuedRead.pop(); - while (!queuedReadState.empty()) queuedReadState.pop(); for (int i=0; i<32; i++) { chan[i]=DivPlatformES5506::Channel(); chan[i].std.setEngine(parent); diff --git a/src/engine/platform/es5506.h b/src/engine/platform/es5506.h index 1502d03e..b7658c52 100644 --- a/src/engine/platform/es5506.h +++ b/src/engine/platform/es5506.h @@ -22,7 +22,7 @@ #include "../dispatch.h" #include "../engine.h" -#include +#include "../fixedQueue.h" #include "../macroInt.h" #include "../sample.h" #include "vgsound_emu/src/es550x/es5506.hpp" @@ -238,6 +238,15 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf { unsigned int* read; unsigned short delay; bool isRead; + QueuedHostIntf(): + state(0), + step(0), + addr(0), + val(0), + mask(0), + read(NULL), + delay(0), + isRead(false) {} QueuedHostIntf(unsigned char s, unsigned char a, unsigned int v, unsigned int m=(unsigned int)(~0), unsigned short d=0): state(0), step(s), @@ -257,17 +266,8 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf { delay(d), isRead(true) {} }; - struct QueuedReadState { - unsigned int* read; - unsigned char state; - QueuedReadState(unsigned int* r, unsigned char s): - read(r), - state(s) {} - }; - std::queue hostIntf32; - std::queue hostIntf8; - std::queue queuedRead; - std::queue queuedReadState; + FixedQueue hostIntf32; + FixedQueue hostIntf8; int cycle, curPage, volScale; unsigned char maskedVal; unsigned int irqv; diff --git a/src/engine/platform/fmsharedbase.h b/src/engine/platform/fmsharedbase.h index b08bda9f..c0fb7dd2 100644 --- a/src/engine/platform/fmsharedbase.h +++ b/src/engine/platform/fmsharedbase.h @@ -22,7 +22,7 @@ #include "../dispatch.h" #include "../instrument.h" -#include +#include "../fixedQueue.h" #define KVS(x,y) ((chan[x].state.op[y].kvs==2 && isOutput[chan[x].state.alg][y]) || chan[x].state.op[y].kvs==1) @@ -82,7 +82,7 @@ class DivPlatformFMBase: public DivDispatch { QueuedWrite(): addr(0), val(0), addrOrVal(false) {} QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {} }; - std::deque writes; + FixedQueue writes; unsigned char lastBusy; int delay; diff --git a/src/engine/platform/ga20.cpp b/src/engine/platform/ga20.cpp index 7794d61a..901927dd 100644 --- a/src/engine/platform/ga20.cpp +++ b/src/engine/platform/ga20.cpp @@ -22,7 +22,7 @@ #include "../../ta-log.h" #include -#define rWrite(a,v) {if(!skipRegisterWrites) {writes.emplace(a,v); if(dumpWrites) addWrite(a,v);}} +#define rWrite(a,v) {if(!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if(dumpWrites) addWrite(a,v);}} #define CHIP_DIVIDER 64 @@ -68,7 +68,7 @@ void DivPlatformGA20::acquire(short** buf, size_t len) { ga20.write(w.addr,w.val); regPool[w.addr]=w.val; writes.pop(); - delay=w.delay; + delay=1; } } short *buffer[4]={ @@ -361,9 +361,7 @@ DivDispatchOscBuffer* DivPlatformGA20::getOscBuffer(int ch) { } void DivPlatformGA20::reset() { - while (!writes.empty()) { - writes.pop(); - } + writes.clear(); memset(regPool,0,32); ga20.device_reset(); delay=0; diff --git a/src/engine/platform/ga20.h b/src/engine/platform/ga20.h index 1e06378f..691b68f0 100644 --- a/src/engine/platform/ga20.h +++ b/src/engine/platform/ga20.h @@ -21,7 +21,7 @@ #define _GA20_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "../macroInt.h" #include "sound/ga20/iremga20.h" @@ -47,15 +47,14 @@ class DivPlatformGA20: public DivDispatch, public iremga20_intf { DivDispatchOscBuffer* oscBuf[4]; bool isMuted[4]; struct QueuedWrite { - unsigned short addr; + unsigned char addr; unsigned char val; - unsigned short delay; - QueuedWrite(unsigned short a, unsigned char v, unsigned short d=1): + QueuedWrite(): addr(0), val(0) {} + QueuedWrite(unsigned char a, unsigned char v): addr(a), - val(v), - delay(d) {} + val(v) {} }; - std::queue writes; + FixedQueue writes; unsigned int sampleOffGA20[256]; bool sampleLoaded[256]; diff --git a/src/engine/platform/gb.cpp b/src/engine/platform/gb.cpp index a475b7da..8d61b334 100644 --- a/src/engine/platform/gb.cpp +++ b/src/engine/platform/gb.cpp @@ -22,8 +22,8 @@ #include "../../ta-log.h" #include -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); regPool[(a)&0x7f]=v; if (dumpWrites) {addWrite(a,v);} } -#define immWrite(a,v) {writes.emplace(a,v); regPool[(a)&0x7f]=v; if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); regPool[(a)&0x7f]=v; if (dumpWrites) {addWrite(a,v);} } +#define immWrite(a,v) {writes.push(QueuedWrite(a,v)); regPool[(a)&0x7f]=v; if (dumpWrites) {addWrite(a,v);} } #define CHIP_DIVIDER 16 diff --git a/src/engine/platform/gb.h b/src/engine/platform/gb.h index 8ba70a91..e68a94f8 100644 --- a/src/engine/platform/gb.h +++ b/src/engine/platform/gb.h @@ -23,7 +23,7 @@ #include "../dispatch.h" #include "../waveSynth.h" #include "sound/gb/gb.h" -#include +#include "../fixedQueue.h" class DivPlatformGB: public DivDispatch { struct Channel: public SharedChannel { @@ -62,11 +62,12 @@ class DivPlatformGB: public DivDispatch { unsigned char lastPan; DivWaveSynth ws; struct QueuedWrite { - unsigned char addr; - unsigned char val; - QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} + unsigned char addr; + unsigned char val; + QueuedWrite(): addr(0), val(0) {} + QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; + FixedQueue writes; int antiClickPeriodCount, antiClickWavePos; diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index fcd96972..20e87d61 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -284,7 +284,7 @@ void DivPlatformGenesis::acquire(short** buf, size_t len) { } void DivPlatformGenesis::fillStream(std::vector& stream, int sRate, size_t len) { - while (!writes.empty()) writes.pop_front(); + writes.clear(); for (size_t i=0; ireset(); diff --git a/src/engine/platform/k007232.cpp b/src/engine/platform/k007232.cpp index bb0bf7a9..d1037988 100644 --- a/src/engine/platform/k007232.cpp +++ b/src/engine/platform/k007232.cpp @@ -22,7 +22,7 @@ #include "../../ta-log.h" #include -#define rWrite(a,v) {if(!skipRegisterWrites) {writes.emplace(a,v); if(dumpWrites) addWrite(a,v);}} +#define rWrite(a,v) {if(!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if(dumpWrites) addWrite(a,v);}} #define CHIP_DIVIDER 64 diff --git a/src/engine/platform/k007232.h b/src/engine/platform/k007232.h index 842310da..b1025f57 100644 --- a/src/engine/platform/k007232.h +++ b/src/engine/platform/k007232.h @@ -21,7 +21,7 @@ #define _K007232_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "../macroInt.h" #include "vgsound_emu/src/k007232/k007232.hpp" @@ -57,12 +57,13 @@ class DivPlatformK007232: public DivDispatch, public k007232_intf { unsigned short addr; unsigned char val; unsigned short delay; + QueuedWrite(): addr(0), val(0), delay(1) {} QueuedWrite(unsigned short a, unsigned char v, unsigned short d=1): addr(a), val(v), delay(d) {} }; - std::queue writes; + FixedQueue writes; unsigned int sampleOffK007232[256]; bool sampleLoaded[256]; diff --git a/src/engine/platform/msm5232.cpp b/src/engine/platform/msm5232.cpp index 55df6128..4a810728 100644 --- a/src/engine/platform/msm5232.cpp +++ b/src/engine/platform/msm5232.cpp @@ -23,7 +23,7 @@ #include //#define rWrite(a,v) pendingWrites[a]=v; -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define NOTE_LINEAR(x) ((x)<<7) diff --git a/src/engine/platform/msm5232.h b/src/engine/platform/msm5232.h index b1d83cf0..abdb72f0 100644 --- a/src/engine/platform/msm5232.h +++ b/src/engine/platform/msm5232.h @@ -21,7 +21,7 @@ #define _MSM5232_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "sound/oki/msm5232.h" class DivPlatformMSM5232: public DivDispatch { @@ -46,11 +46,12 @@ class DivPlatformMSM5232: public DivDispatch { unsigned char groupAR[2]; unsigned char groupDR[2]; struct QueuedWrite { - unsigned char addr; - unsigned char val; - QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} + unsigned char addr; + unsigned char val; + QueuedWrite(): addr(0), val(0) {} + QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; + FixedQueue writes; int cycles, curChan, delay, detune, clockDriftAccum; unsigned int clockDriftLFOPos, clockDriftLFOSpeed; diff --git a/src/engine/platform/msm6258.cpp b/src/engine/platform/msm6258.cpp index 31002a9c..7f4d2e63 100644 --- a/src/engine/platform/msm6258.cpp +++ b/src/engine/platform/msm6258.cpp @@ -24,7 +24,7 @@ #include #include -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } const char** DivPlatformMSM6258::getRegisterSheet() { return NULL; diff --git a/src/engine/platform/msm6258.h b/src/engine/platform/msm6258.h index 0c19d976..2c18d90c 100644 --- a/src/engine/platform/msm6258.h +++ b/src/engine/platform/msm6258.h @@ -21,7 +21,7 @@ #define _MSM6258_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "sound/oki/okim6258.h" class DivPlatformMSM6258: public DivDispatch { @@ -42,9 +42,10 @@ class DivPlatformMSM6258: public DivDispatch { struct QueuedWrite { unsigned short addr; unsigned char val; + QueuedWrite(): addr(0), val(0) {} QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; + FixedQueue writes; okim6258_device* msm; unsigned char lastBusy; diff --git a/src/engine/platform/msm6295.cpp b/src/engine/platform/msm6295.cpp index 2aff0006..3d823d16 100644 --- a/src/engine/platform/msm6295.cpp +++ b/src/engine/platform/msm6295.cpp @@ -23,8 +23,8 @@ #include #include -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } -#define rWriteDelay(a,v,d) if (!skipRegisterWrites) {writes.emplace(a,v,d); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } +#define rWriteDelay(a,v,d) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v,d)); if (dumpWrites) {addWrite(a,v);} } const char** DivPlatformMSM6295::getRegisterSheet() { return NULL; diff --git a/src/engine/platform/msm6295.h b/src/engine/platform/msm6295.h index df140693..dfa59a0c 100644 --- a/src/engine/platform/msm6295.h +++ b/src/engine/platform/msm6295.h @@ -21,7 +21,7 @@ #define _MSM6295_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "vgsound_emu/src/msm6295/msm6295.hpp" class DivPlatformMSM6295: public DivDispatch, public vgsound_emu_mem_intf { @@ -41,12 +41,13 @@ class DivPlatformMSM6295: public DivDispatch, public vgsound_emu_mem_intf { unsigned short addr; unsigned char val; unsigned short delay; + QueuedWrite(): addr(0), val(0), delay(96) {} QueuedWrite(unsigned short a, unsigned char v, unsigned short d=96): addr(a), val(v), delay(d) {} }; - std::queue writes; + FixedQueue writes; msm6295_core msm; unsigned char lastBusy; diff --git a/src/engine/platform/n163.cpp b/src/engine/platform/n163.cpp index 1063349d..7e10a01e 100644 --- a/src/engine/platform/n163.cpp +++ b/src/engine/platform/n163.cpp @@ -23,8 +23,8 @@ #include #define rRead(a,v) n163.addr_w(a); n163.data_r(v); -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } -#define rWriteMask(a,v,m) if (!skipRegisterWrites) {writes.emplace(a,v,m); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } +#define rWriteMask(a,v,m) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v,m)); if (dumpWrites) {addWrite(a,v);} } #define chWrite(c,a,v) \ if (c<=chanMax) { \ rWrite(0x78-(c<<3)+(a&7),v) \ diff --git a/src/engine/platform/n163.h b/src/engine/platform/n163.h index 49c0ff05..0c5e5913 100644 --- a/src/engine/platform/n163.h +++ b/src/engine/platform/n163.h @@ -21,7 +21,7 @@ #define _N163_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "../waveSynth.h" #include "vgsound_emu/src/n163/n163.hpp" @@ -54,12 +54,13 @@ class DivPlatformN163: public DivDispatch { DivDispatchOscBuffer* oscBuf[8]; bool isMuted[8]; struct QueuedWrite { - unsigned char addr; - unsigned char val; - unsigned char mask; - QueuedWrite(unsigned char a, unsigned char v, unsigned char m=~0): addr(a), val(v), mask(m) {} + unsigned char addr; + unsigned char val; + unsigned char mask; + QueuedWrite(): addr(0), val(0), mask(~0) {} + QueuedWrite(unsigned char a, unsigned char v, unsigned char m=~0): addr(a), val(v), mask(m) {} }; - std::queue writes; + FixedQueue writes; unsigned char initChanMax; unsigned char chanMax; short loadWave, loadPos, loadLen; diff --git a/src/engine/platform/namcowsg.cpp b/src/engine/platform/namcowsg.cpp index 088f1e63..5b804b23 100644 --- a/src/engine/platform/namcowsg.cpp +++ b/src/engine/platform/namcowsg.cpp @@ -22,7 +22,7 @@ #include //#define rWrite(a,v) pendingWrites[a]=v; -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define CHIP_FREQBASE 4194304 diff --git a/src/engine/platform/namcowsg.h b/src/engine/platform/namcowsg.h index 9d418a9d..6aaef095 100644 --- a/src/engine/platform/namcowsg.h +++ b/src/engine/platform/namcowsg.h @@ -21,7 +21,7 @@ #define _NAMCOWSG_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "../waveSynth.h" #include "sound/namco.h" @@ -41,11 +41,12 @@ class DivPlatformNamcoWSG: public DivDispatch { DivDispatchOscBuffer* oscBuf[8]; bool isMuted[8]; struct QueuedWrite { - unsigned short addr; - unsigned char val; - QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {} + unsigned short addr; + unsigned char val; + QueuedWrite(): addr(0), val(0) {} + QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; + FixedQueue writes; namco_audio_device* namco; int devType, chans; diff --git a/src/engine/platform/opl.cpp b/src/engine/platform/opl.cpp index d340aa31..3578dbd9 100644 --- a/src/engine/platform/opl.cpp +++ b/src/engine/platform/opl.cpp @@ -24,7 +24,7 @@ #include #define rWrite(a,v) if (!skipRegisterWrites) {pendingWrites[a]=v;} -#define immWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define immWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define KVSL(x,y) ((chan[x].state.op[orderedOpsL1[ops==4][y]].kvs==2 && isOutputL[ops==4][chan[x].state.alg][y]) || chan[x].state.op[orderedOpsL1[ops==4][y]].kvs==1) diff --git a/src/engine/platform/opl.h b/src/engine/platform/opl.h index aae0e800..f4881c29 100644 --- a/src/engine/platform/opl.h +++ b/src/engine/platform/opl.h @@ -21,7 +21,7 @@ #define _OPL_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "../../../extern/opl/opl3.h" #include "sound/ymfm/ymfm_adpcm.h" @@ -64,9 +64,10 @@ class DivPlatformOPL: public DivDispatch { unsigned short addr; unsigned char val; bool addrOrVal; + QueuedWrite(): addr(0), val(0), addrOrVal(false) {} QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {} }; - std::queue writes; + FixedQueue writes; opl3_chip fm; unsigned char* adpcmBMem; size_t adpcmBMemLen; diff --git a/src/engine/platform/opll.cpp b/src/engine/platform/opll.cpp index 38b892e8..d081fabc 100644 --- a/src/engine/platform/opll.cpp +++ b/src/engine/platform/opll.cpp @@ -24,7 +24,7 @@ #include #define rWrite(a,v) if (!skipRegisterWrites) {pendingWrites[a]=v;} -#define immWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define immWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define CHIP_FREQBASE 1180068 diff --git a/src/engine/platform/opll.h b/src/engine/platform/opll.h index 4e72936d..7333f729 100644 --- a/src/engine/platform/opll.h +++ b/src/engine/platform/opll.h @@ -21,7 +21,7 @@ #define _OPLL_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" extern "C" { #include "../../../extern/Nuked-OPLL/opll.h" @@ -50,9 +50,10 @@ class DivPlatformOPLL: public DivDispatch { unsigned short addr; unsigned char val; bool addrOrVal; + QueuedWrite(): addr(0), val(0), addrOrVal(false) {} QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {} }; - std::queue writes; + FixedQueue writes; opll_t fm; int delay, lastCustomMemory; unsigned char lastBusy; diff --git a/src/engine/platform/pce.cpp b/src/engine/platform/pce.cpp index 8066bff2..b6f43e2d 100644 --- a/src/engine/platform/pce.cpp +++ b/src/engine/platform/pce.cpp @@ -531,7 +531,7 @@ int DivPlatformPCE::getRegisterPoolSize() { } void DivPlatformPCE::reset() { - while (!writes.empty()) writes.pop(); + writes.clear(); memset(regPool,0,128); for (int i=0; i<6; i++) { chan[i]=DivPlatformPCE::Channel(); diff --git a/src/engine/platform/pce.h b/src/engine/platform/pce.h index 45279179..baca7770 100644 --- a/src/engine/platform/pce.h +++ b/src/engine/platform/pce.h @@ -60,10 +60,10 @@ class DivPlatformPCE: public DivDispatch { bool antiClickEnabled; bool updateLFO; struct QueuedWrite { - unsigned char addr; - unsigned char val; - QueuedWrite(): addr(0), val(9) {} - QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} + unsigned char addr; + unsigned char val; + QueuedWrite(): addr(0), val(9) {} + QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} }; FixedQueue writes; unsigned char lastPan; diff --git a/src/engine/platform/pcmdac.h b/src/engine/platform/pcmdac.h index f9435e3e..8ef10149 100644 --- a/src/engine/platform/pcmdac.h +++ b/src/engine/platform/pcmdac.h @@ -21,7 +21,6 @@ #define _PCM_DAC_H #include "../dispatch.h" -#include #include "../waveSynth.h" class DivPlatformPCMDAC: public DivDispatch { diff --git a/src/engine/platform/pcspkr.h b/src/engine/platform/pcspkr.h index 23b3c0b4..0437a90c 100644 --- a/src/engine/platform/pcspkr.h +++ b/src/engine/platform/pcspkr.h @@ -21,7 +21,7 @@ #define _PCSPKR_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include #include #include @@ -40,12 +40,16 @@ class DivPlatformPCSpeaker: public DivDispatch { struct RealQueueVal { int tv_sec, tv_nsec; unsigned short val; + RealQueueVal(): + tv_sec(0), + tv_nsec(0), + val(0) {} RealQueueVal(int sec, int nsec, unsigned short v): tv_sec(sec), tv_nsec(nsec), val(v) {} }; - std::queue realQueue; + FixedQueue realQueue; std::mutex realQueueLock; bool isMuted[1]; bool on, flip, lastOn, realOutEnabled; diff --git a/src/engine/platform/pokey.cpp b/src/engine/platform/pokey.cpp index 790346e1..08b6da9f 100644 --- a/src/engine/platform/pokey.cpp +++ b/src/engine/platform/pokey.cpp @@ -21,7 +21,7 @@ #include "../engine.h" #include "../../ta-log.h" -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define CHIP_DIVIDER 1 diff --git a/src/engine/platform/pokey.h b/src/engine/platform/pokey.h index b5087517..979f6075 100644 --- a/src/engine/platform/pokey.h +++ b/src/engine/platform/pokey.h @@ -21,7 +21,7 @@ #define _POKEY_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" extern "C" { #include "sound/pokey/mzpokeysnd.h" @@ -43,11 +43,12 @@ class DivPlatformPOKEY: public DivDispatch { DivDispatchOscBuffer* oscBuf[4]; bool isMuted[4]; struct QueuedWrite { - unsigned char addr; - unsigned char val; - QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} + unsigned char addr; + unsigned char val; + QueuedWrite(): addr(0), val(0) {} + QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; + FixedQueue writes; unsigned char audctl, skctl; bool audctlChanged, skctlChanged; unsigned char oscBufDelay; diff --git a/src/engine/platform/pv1000.h b/src/engine/platform/pv1000.h index 852bf120..740f16c4 100644 --- a/src/engine/platform/pv1000.h +++ b/src/engine/platform/pv1000.h @@ -22,7 +22,6 @@ #include "../dispatch.h" #include "sound/d65modified.h" -#include class DivPlatformPV1000: public DivDispatch { struct Channel: public SharedChannel { diff --git a/src/engine/platform/qsound.h b/src/engine/platform/qsound.h index 9c090f19..aff53f67 100644 --- a/src/engine/platform/qsound.h +++ b/src/engine/platform/qsound.h @@ -21,7 +21,6 @@ #define _QSOUND_H #include "../dispatch.h" -#include #include "sound/qsound.h" class DivPlatformQSound: public DivDispatch { diff --git a/src/engine/platform/rf5c68.h b/src/engine/platform/rf5c68.h index 94ced515..4ba40318 100644 --- a/src/engine/platform/rf5c68.h +++ b/src/engine/platform/rf5c68.h @@ -21,7 +21,6 @@ #define _RF5C68_H #include "../dispatch.h" -#include #include "sound/rf5c68.h" class DivPlatformRF5C68: public DivDispatch { diff --git a/src/engine/platform/saa.cpp b/src/engine/platform/saa.cpp index 7682d318..803a6cad 100644 --- a/src/engine/platform/saa.cpp +++ b/src/engine/platform/saa.cpp @@ -23,7 +23,7 @@ #include #include -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define CHIP_DIVIDER 2 diff --git a/src/engine/platform/saa.h b/src/engine/platform/saa.h index 43e3cc87..ffd79db7 100644 --- a/src/engine/platform/saa.h +++ b/src/engine/platform/saa.h @@ -21,7 +21,7 @@ #define _SAA_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "../../../extern/SAASound/src/SAASound.h" class DivPlatformSAA1099: public DivDispatch { @@ -44,9 +44,10 @@ class DivPlatformSAA1099: public DivDispatch { unsigned short addr; unsigned char val; bool addrOrVal; + QueuedWrite(): addr(0), val(0), addrOrVal(false) {} QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {} }; - std::queue writes; + FixedQueue writes; CSAASound* saa_saaSound; unsigned char regPool[32]; unsigned char lastBusy; diff --git a/src/engine/platform/scc.h b/src/engine/platform/scc.h index b8b892af..f075753a 100644 --- a/src/engine/platform/scc.h +++ b/src/engine/platform/scc.h @@ -21,7 +21,6 @@ #define _SCC_H #include "../dispatch.h" -#include #include "../waveSynth.h" #include "vgsound_emu/src/scc/scc.hpp" diff --git a/src/engine/platform/segapcm.cpp b/src/engine/platform/segapcm.cpp index 20032a1b..b9af8a91 100644 --- a/src/engine/platform/segapcm.cpp +++ b/src/engine/platform/segapcm.cpp @@ -23,7 +23,7 @@ #include #include -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define chWrite(c,a,v) rWrite(((c)<<3)+(a),v) void DivPlatformSegaPCM::acquire(short** buf, size_t len) { diff --git a/src/engine/platform/segapcm.h b/src/engine/platform/segapcm.h index b818306b..067054fe 100644 --- a/src/engine/platform/segapcm.h +++ b/src/engine/platform/segapcm.h @@ -23,7 +23,7 @@ #include "../dispatch.h" #include "../instrument.h" #include "sound/segapcm.h" -#include +#include "../fixedQueue.h" class DivPlatformSegaPCM: public DivDispatch { protected: @@ -59,9 +59,10 @@ class DivPlatformSegaPCM: public DivDispatch { unsigned short addr; unsigned char val; bool addrOrVal; + QueuedWrite(): addr(0), val(0), addrOrVal(false) {} QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {} }; - std::queue writes; + FixedQueue writes; segapcm_device pcm; int delay; int pcmL, pcmR, pcmCycles; diff --git a/src/engine/platform/sm8521.cpp b/src/engine/platform/sm8521.cpp index e72616bd..52c3442c 100644 --- a/src/engine/platform/sm8521.cpp +++ b/src/engine/platform/sm8521.cpp @@ -22,7 +22,7 @@ #include //#define rWrite(a,v) pendingWrites[a]=v; -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define CHIP_DIVIDER 64 diff --git a/src/engine/platform/sm8521.h b/src/engine/platform/sm8521.h index b0a119fb..02e2f458 100644 --- a/src/engine/platform/sm8521.h +++ b/src/engine/platform/sm8521.h @@ -21,7 +21,7 @@ #define _SM8521_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "../waveSynth.h" #include "sound/sm8521.h" @@ -46,11 +46,12 @@ class DivPlatformSM8521: public DivDispatch { DivDispatchOscBuffer* oscBuf[3]; bool isMuted[3]; struct QueuedWrite { - unsigned short addr; - unsigned char val; - QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {} + unsigned short addr; + unsigned char val; + QueuedWrite(): addr(0), val(0) {} + QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; + FixedQueue writes; bool antiClickEnabled; struct sm8521_t sm8521; diff --git a/src/engine/platform/sms.cpp b/src/engine/platform/sms.cpp index f8858aab..640f364e 100644 --- a/src/engine/platform/sms.cpp +++ b/src/engine/platform/sms.cpp @@ -22,7 +22,7 @@ #include "../../ta-log.h" #include -#define rWrite(a,v) {if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);}}} +#define rWrite(a,v) {if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);}}} const char* regCheatSheetSN[]={ "DATA", "0", diff --git a/src/engine/platform/sms.h b/src/engine/platform/sms.h index efdfff44..692c0a42 100644 --- a/src/engine/platform/sms.h +++ b/src/engine/platform/sms.h @@ -25,7 +25,7 @@ extern "C" { #include "../../../extern/Nuked-PSG/ympsg.h" } -#include +#include "../fixedQueue.h" class DivPlatformSMS: public DivDispatch { struct Channel: public SharedChannel { @@ -59,9 +59,10 @@ class DivPlatformSMS: public DivDispatch { unsigned short addr; unsigned char val; bool addrOrVal; + QueuedWrite(): addr(0), val(0), addrOrVal(false) {} QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {} }; - std::queue writes; + FixedQueue writes; friend void putDispatchChip(void*,int); friend void putDispatchChan(void*,int,int); diff --git a/src/engine/platform/snes.h b/src/engine/platform/snes.h index 68637be8..cec51c0c 100644 --- a/src/engine/platform/snes.h +++ b/src/engine/platform/snes.h @@ -22,7 +22,7 @@ #include "../dispatch.h" #include "../waveSynth.h" -#include +#include "../fixedQueue.h" #include "sound/snes/SPC_DSP.h" class DivPlatformSNES: public DivDispatch { @@ -81,9 +81,10 @@ class DivPlatformSNES: public DivDispatch { struct QueuedWrite { unsigned char addr; unsigned char val; + QueuedWrite(): addr(0), val(0) {} QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; + FixedQueue writes; signed char sampleMem[65536]; signed char copyOfSampleMem[65536]; diff --git a/src/engine/platform/su.cpp b/src/engine/platform/su.cpp index 728d7a91..b38b9f86 100644 --- a/src/engine/platform/su.cpp +++ b/src/engine/platform/su.cpp @@ -23,7 +23,7 @@ #include //#define rWrite(a,v) pendingWrites[a]=v; -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define chWrite(c,a,v) rWrite(((c)<<5)|(a),v); #define CHIP_DIVIDER 2 diff --git a/src/engine/platform/su.h b/src/engine/platform/su.h index de67c2fa..d83ae477 100644 --- a/src/engine/platform/su.h +++ b/src/engine/platform/su.h @@ -21,7 +21,7 @@ #define _SU_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "sound/su.h" class DivPlatformSoundUnit: public DivDispatch { @@ -72,11 +72,12 @@ class DivPlatformSoundUnit: public DivDispatch { DivDispatchOscBuffer* oscBuf[8]; bool isMuted[8]; struct QueuedWrite { - unsigned char addr; - unsigned char val; - QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} + unsigned char addr; + unsigned char val; + QueuedWrite(): addr(0), val(0) {} + QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; + FixedQueue writes; unsigned char lastPan; bool sampleMemSize; unsigned char ilCtrl, ilSize, fil1; diff --git a/src/engine/platform/swan.cpp b/src/engine/platform/swan.cpp index f2fc6d43..04039e6e 100644 --- a/src/engine/platform/swan.cpp +++ b/src/engine/platform/swan.cpp @@ -21,8 +21,8 @@ #include "../engine.h" #include -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);}} -#define postWrite(a,v) postDACWrites.emplace(a,v); +#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 diff --git a/src/engine/platform/swan.h b/src/engine/platform/swan.h index cff6cc62..72ddae39 100644 --- a/src/engine/platform/swan.h +++ b/src/engine/platform/swan.h @@ -23,7 +23,7 @@ #include "../dispatch.h" #include "../waveSynth.h" #include "sound/swan.h" -#include +#include "../fixedQueue.h" class DivPlatformSwan: public DivDispatch { struct Channel: public SharedChannel { @@ -46,12 +46,13 @@ class DivPlatformSwan: public DivDispatch { unsigned char regPool[0x80]; struct QueuedWrite { - unsigned char addr; - unsigned char val; - QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} + unsigned char addr; + unsigned char val; + QueuedWrite(): addr(0), val(0) {} + QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; - std::queue postDACWrites; + FixedQueue writes; + FixedQueue postDACWrites; WSwan* ws; void updateWave(int ch); friend void putDispatchChip(void*,int); diff --git a/src/engine/platform/t6w28.cpp b/src/engine/platform/t6w28.cpp index 5d21e1ad..90140da9 100644 --- a/src/engine/platform/t6w28.cpp +++ b/src/engine/platform/t6w28.cpp @@ -23,7 +23,7 @@ #include //#define rWrite(a,v) pendingWrites[a]=v; -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } const char* regCheatSheetT6W28[]={ "Data0", "0", diff --git a/src/engine/platform/t6w28.h b/src/engine/platform/t6w28.h index d324a09c..33c03a88 100644 --- a/src/engine/platform/t6w28.h +++ b/src/engine/platform/t6w28.h @@ -21,7 +21,7 @@ #define _T6W28_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "sound/t6w28/T6W28_Apu.h" class DivPlatformT6W28: public DivDispatch { @@ -38,11 +38,12 @@ class DivPlatformT6W28: public DivDispatch { bool isMuted[4]; bool easyNoise; struct QueuedWrite { - unsigned char addr; - unsigned char val; - QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} + unsigned char addr; + unsigned char val; + QueuedWrite(): addr(0), val(0) {} + QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; + FixedQueue writes; unsigned char lastPan; int cycles, curChan, delay; diff --git a/src/engine/platform/tia.h b/src/engine/platform/tia.h index 95ae9917..4e7420b7 100644 --- a/src/engine/platform/tia.h +++ b/src/engine/platform/tia.h @@ -21,7 +21,6 @@ #define _TIA_H #include "../dispatch.h" -#include #include "sound/tia/Audio.h" class DivPlatformTIA: public DivDispatch { diff --git a/src/engine/platform/tx81z.cpp b/src/engine/platform/tx81z.cpp index 86128340..6e70895b 100644 --- a/src/engine/platform/tx81z.cpp +++ b/src/engine/platform/tx81z.cpp @@ -986,7 +986,7 @@ void DivPlatformTX81Z::poke(std::vector& wlist) { } void DivPlatformTX81Z::reset() { - while (!writes.empty()) writes.pop_front(); + writes.clear(); memset(regPool,0,330); fm_ymfm->reset(); if (dumpWrites) { diff --git a/src/engine/platform/tx81z.h b/src/engine/platform/tx81z.h index d1ebd543..d0bc759c 100644 --- a/src/engine/platform/tx81z.h +++ b/src/engine/platform/tx81z.h @@ -21,7 +21,7 @@ #define _TX81Z_H #include "fmshared_OPM.h" -#include +#include "../fixedQueue.h" #include "sound/ymfm/ymfm_opz.h" class DivTXInterface: public ymfm::ymfm_interface { diff --git a/src/engine/platform/vb.cpp b/src/engine/platform/vb.cpp index 3701b5aa..9edaf2db 100644 --- a/src/engine/platform/vb.cpp +++ b/src/engine/platform/vb.cpp @@ -22,7 +22,7 @@ #include //#define rWrite(a,v) pendingWrites[a]=v; -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define chWrite(c,a,v) rWrite(0x400+((c)<<6)+((a)<<2),v); #define CHIP_DIVIDER 16 diff --git a/src/engine/platform/vb.h b/src/engine/platform/vb.h index 09193f25..2efcdd1b 100644 --- a/src/engine/platform/vb.h +++ b/src/engine/platform/vb.h @@ -21,7 +21,7 @@ #define _PLATFORM_VB_H #include "../dispatch.h" -#include +#include "../fixedQueue.h" #include "../waveSynth.h" #include "sound/vsu.h" @@ -44,11 +44,12 @@ class DivPlatformVB: public DivDispatch { DivDispatchOscBuffer* oscBuf[6]; bool isMuted[6]; struct QueuedWrite { - unsigned short addr; - unsigned char val; - QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {} + unsigned short addr; + unsigned char val; + QueuedWrite(): addr(0), val(0) {} + QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; + FixedQueue writes; unsigned char lastPan; int cycles, curChan, delay; diff --git a/src/engine/platform/vic20.h b/src/engine/platform/vic20.h index 5125bd96..e233d984 100644 --- a/src/engine/platform/vic20.h +++ b/src/engine/platform/vic20.h @@ -22,7 +22,6 @@ #include "../dispatch.h" #include "sound/vic20sound.h" -#include class DivPlatformVIC20: public DivDispatch { struct Channel: public SharedChannel { diff --git a/src/engine/platform/vrc6.cpp b/src/engine/platform/vrc6.cpp index b52bc106..96088d93 100644 --- a/src/engine/platform/vrc6.cpp +++ b/src/engine/platform/vrc6.cpp @@ -22,7 +22,7 @@ #include #include -#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} } +#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} } #define chWrite(c,a,v) rWrite(0x9000+(c<<12)+(a&3),v) const char* regCheatSheetVRC6[]={ diff --git a/src/engine/platform/vrc6.h b/src/engine/platform/vrc6.h index 5a241610..df0aa92e 100644 --- a/src/engine/platform/vrc6.h +++ b/src/engine/platform/vrc6.h @@ -20,7 +20,7 @@ #ifndef _VRC6_H #define _VRC6_H -#include +#include "../fixedQueue.h" #include "../dispatch.h" #include "vgsound_emu/src/vrcvi/vrcvi.hpp" @@ -47,11 +47,12 @@ class DivPlatformVRC6: public DivDispatch, public vrcvi_intf { DivDispatchOscBuffer* oscBuf[3]; bool isMuted[3]; struct QueuedWrite { - unsigned short addr; - unsigned char val; - QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {} + unsigned short addr; + unsigned char val; + QueuedWrite(): addr(0), val(0) {} + QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {} }; - std::queue writes; + FixedQueue writes; unsigned char sampleBank; unsigned char writeOscBuf; vrcvi_core vrc6; diff --git a/src/engine/platform/ym2203.cpp b/src/engine/platform/ym2203.cpp index 135ad140..68cccca4 100644 --- a/src/engine/platform/ym2203.cpp +++ b/src/engine/platform/ym2203.cpp @@ -974,7 +974,7 @@ void DivPlatformYM2203::poke(std::vector& wlist) { } void DivPlatformYM2203::reset() { - while (!writes.empty()) writes.pop_front(); + writes.clear(); memset(regPool,0,256); if (dumpWrites) { addWrite(0xffffffff,0); diff --git a/src/engine/platform/ym2608.cpp b/src/engine/platform/ym2608.cpp index 589d90d3..02a5ffa0 100644 --- a/src/engine/platform/ym2608.cpp +++ b/src/engine/platform/ym2608.cpp @@ -1481,7 +1481,7 @@ void DivPlatformYM2608::poke(std::vector& wlist) { } void DivPlatformYM2608::reset() { - while (!writes.empty()) writes.pop_front(); + writes.clear(); memset(regPool,0,512); if (dumpWrites) { addWrite(0xffffffff,0); diff --git a/src/engine/platform/ym2610.cpp b/src/engine/platform/ym2610.cpp index 66c2f411..4fbf7859 100644 --- a/src/engine/platform/ym2610.cpp +++ b/src/engine/platform/ym2610.cpp @@ -1441,7 +1441,7 @@ void DivPlatformYM2610::poke(std::vector& wlist) { } void DivPlatformYM2610::reset() { - while (!writes.empty()) writes.pop_front(); + writes.clear(); memset(regPool,0,512); if (dumpWrites) { addWrite(0xffffffff,0); diff --git a/src/engine/platform/ym2610b.cpp b/src/engine/platform/ym2610b.cpp index d38ad525..4fff4727 100644 --- a/src/engine/platform/ym2610b.cpp +++ b/src/engine/platform/ym2610b.cpp @@ -1508,7 +1508,7 @@ void DivPlatformYM2610B::poke(std::vector& wlist) { } void DivPlatformYM2610B::reset() { - while (!writes.empty()) writes.pop_front(); + writes.clear(); memset(regPool,0,512); if (dumpWrites) { addWrite(0xffffffff,0); diff --git a/src/engine/platform/ymz280b.h b/src/engine/platform/ymz280b.h index 3fb4a7dc..14a67dc9 100644 --- a/src/engine/platform/ymz280b.h +++ b/src/engine/platform/ymz280b.h @@ -21,7 +21,6 @@ #define _YMZ280B_H #include "../dispatch.h" -#include #include "sound/ymz280b.h" class DivPlatformYMZ280B: public DivDispatch { diff --git a/src/engine/platform/zxbeeper.cpp b/src/engine/platform/zxbeeper.cpp index 047dc2cb..3592c049 100644 --- a/src/engine/platform/zxbeeper.cpp +++ b/src/engine/platform/zxbeeper.cpp @@ -260,7 +260,6 @@ int DivPlatformZXBeeper::getRegisterPoolSize() { } void DivPlatformZXBeeper::reset() { - while (!writes.empty()) writes.pop(); memset(regPool,0,128); for (int i=0; i<6; i++) { chan[i]=DivPlatformZXBeeper::Channel(); diff --git a/src/engine/platform/zxbeeper.h b/src/engine/platform/zxbeeper.h index 3e120354..9bd3678a 100644 --- a/src/engine/platform/zxbeeper.h +++ b/src/engine/platform/zxbeeper.h @@ -21,7 +21,6 @@ #define _ZXBEEPER_H #include "../dispatch.h" -#include class DivPlatformZXBeeper: public DivDispatch { struct Channel: public SharedChannel { @@ -35,12 +34,6 @@ class DivPlatformZXBeeper: public DivDispatch { Channel chan[6]; DivDispatchOscBuffer* oscBuf[6]; bool isMuted[6]; - struct QueuedWrite { - unsigned char addr; - unsigned char val; - QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} - }; - std::queue writes; unsigned char lastPan, ulaOut; int cycles, curChan, sOffTimer, delay, curSample, curSamplePeriod; From e93f649bfb0110fb29d7cc399133389ec782ba2d Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 13 Jul 2023 04:23:01 -0500 Subject: [PATCH 06/13] FixedQueue, part 3 --- src/engine/fixedQueue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/fixedQueue.h b/src/engine/fixedQueue.h index afcf8afc..ad43f160 100644 --- a/src/engine/fixedQueue.h +++ b/src/engine/fixedQueue.h @@ -112,12 +112,12 @@ template bool FixedQueue::push_front(const T logW("stack overflow!"); return false; } - data[readPos]=item; if (readPos>0) { readPos--; } else { readPos=items-1; } + data[readPos]=item; return true; } From 9c97291e9c0e9bc9cfb98e839668bd7f913fb4c5 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 13 Jul 2023 16:03:47 -0500 Subject: [PATCH 07/13] MSM6258: don't use auto --- src/engine/platform/sound/oki/okim6258.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/platform/sound/oki/okim6258.cpp b/src/engine/platform/sound/oki/okim6258.cpp index 728507df..5bf6714d 100644 --- a/src/engine/platform/sound/oki/okim6258.cpp +++ b/src/engine/platform/sound/oki/okim6258.cpp @@ -137,7 +137,7 @@ void okim6258_device::device_reset() void okim6258_device::sound_stream_update(short** outputs, int len) { - auto &buffer = outputs[0]; + short* buffer = outputs[0]; if (m_status & STATUS_PLAYING) { From ed7265645d457bba9b213d327061e238b7f9c1ba Mon Sep 17 00:00:00 2001 From: Electric Keet Date: Thu, 13 Jul 2023 16:35:55 -0700 Subject: [PATCH 08/13] Document standard instr. noise modes. --- doc/4-instrument/standard.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/4-instrument/standard.md b/doc/4-instrument/standard.md index 2da6e160..11272356 100644 --- a/doc/4-instrument/standard.md +++ b/doc/4-instrument/standard.md @@ -2,9 +2,17 @@ The instrument editor for NES and PSG (SMS, MSX, and such) consists of these macros: -- **Volume**: volume -- **Arpeggio**: pitch in half-steps -- **Duty**: duty cycle and noise mode for NES channels. _Note:_ This has no effect on Sega Master System. -- **Panning**: output for left and right channels -- **Pitch**: fine pitch -- **Phase Reset**: trigger restart of waveform \ No newline at end of file +- **Volume**: volume. +- **Arpeggio**: pitch in half-steps. +- **Duty**: duty cycle and noise mode. + - NES noise modes: + - `0`: long noise. + - `1`: short noise. + - PSG noise modes: + - `0`: short noise, preset frequencies. + - `1`: long noise, preset frequencies. + - `2`: short noise, use channel 3 for frequency. + - `3`: long noise, use channel 3 for frequency. +- **Panning**: output for left and right channels. +- **Pitch**: fine pitch. +- **Phase Reset**: trigger restart of waveform. \ No newline at end of file From 7cfdad6367bdc8b4ebc7ff198e0fbd20d0d71281 Mon Sep 17 00:00:00 2001 From: Electric Keet Date: Thu, 13 Jul 2023 17:19:00 -0700 Subject: [PATCH 09/13] Split NES and PSG instrument docs. --- doc/4-instrument/README.md | 227 +++++++++++++++++++------------------ doc/4-instrument/nes.md | 18 +++ doc/4-instrument/psg.md | 14 +++ 3 files changed, 146 insertions(+), 113 deletions(-) create mode 100644 doc/4-instrument/nes.md create mode 100644 doc/4-instrument/psg.md diff --git a/doc/4-instrument/README.md b/doc/4-instrument/README.md index f33126dd..bd00b6b8 100644 --- a/doc/4-instrument/README.md +++ b/doc/4-instrument/README.md @@ -1,113 +1,114 @@ -# instrument list - -![instrument list](list.png) - -click on an instrument to select it. - -double-click to open the instrument editor. - -# instrument editor - -every instrument can be renamed and have its type changed. - -depending on the instrument type, there are many different types of instrument editor: - -- [FM synthesis](fm.md) - for use with YM2612, YM2151 and FM block portion of YM2610. -- [Standard](standard.md) - for use with NES and Sega Master System's PSG sound source and its derivatives. -- [Game Boy](game-boy.md) - for use with Game Boy APU. -- [PC Engine / TurboGrafx-16](pce.md) - for use with PC Engine's wavetable synthesizer. -- [WonderSwan](wonderswan.md) - for use with WonderSwan's wavetable synthesizer. -- [AY8930](8930.md) - for use with Microchip AY8930 E-PSG sound source. -- [Commodore 64](c64.md) - for use with Commodore 64 SID. -- [SAA1099](saa.md) - for use with Philips SAA1099 PSG sound source. -- [TIA](tia.md) - for use with Atari 2600 chip. -- [AY-3-8910](ay8910.md) - for use with AY-3-8910 PSG sound source and SSG portion in YM2610. -- [Amiga / sample](amiga.md) for controlling Amiga and other sample based synthsizers like YM2612's Channel 6 PCM mode, NES channel 5, Sega PCM, X1-010 and PC Engine's sample playback mode. -- [Atari Lynx](lynx.md) - for use with Atari Lynx handheld console. -- [VERA](vera.md) - for use with Commander X16 VERA. -- [Seta/Allumer X1-010](x1_010.md) - for use with Wavetable portion in Seta/Allumer X1-010. -- [Konami SCC / Bubble System WSG](scc.md) - for use with Konami SCC and Wavetable portion in Bubble System's sound hardware. -- [Namco 163](n163.md) - for use with Namco 163. -- [Konami VRC6](vrc6.md) - for use with VRC6's PSG sound source. -- [SNES](snes.md) - for use with SNES S-APU. -- [Casio PV-1000](pv1000.md) - for use with Casio PV-1000. - - -# macros - -Macros are incredibly versatile tools for automating instrument parameters. - -After creating an instrument, open the Instrument Editor and select the "Macros" tab. There may be multiple macro tabs to control individual FM operators and such. - -![macro view](macroview.png) - -The very first numeric entry sets the visible width of the bars in sequence-type macros. The scrollbar affects the view of all macros at once. There's a matching scrollbar at the bottom underneath all the macros. - -Each macro has two buttons on the left. -- Macro type (explained below). -- Timing editor, which pops up a small dialog: - - Step Length (ticks): Determines how many ticks pass before each change of value. - - Delay: Delays the start of the macro until this many ticks have passed. - -## macro types - -Every macro can be defined though one of three methods, selectable with the leftmost button under the macro type label: - -- ![](macro-button-seq.png) **Sequence:** displayed as a bar graph, this is a sequence of numeric values. -- ![](macro-button-ADSR.png) **ADSR:** this is a traditional ADSR envelope, defined by the rate of increase and decrease of value over time. -- ![](macro-button-LFO.png) **LFO:** the Low Frequency Oscillator generates a repeating wave of values. - -Some macros are "bitmap" style. They represent a number of "bits" that can be toggled individually, and the values listed represent the sum of which bits are turned on. - -### sequence - -![sequence macro editor](macro-seq.png) - -The number between the macro type label and the macro type button is the macro length in steps. The `-` and `+` buttons change the length of the macro. Start out by adding at least a few steps. - -The values of the macro can be drawn in the "bar graph box". Just beneath the box is shorter bar graph. -- Click to set the start point of a loop; the end point is the last value or release point. Right-click to remove the loop. -- Shift-click to set the release point. When played, the macro will hold here until the note is released. Right-click to remove the release point. - -Finally, the sequence of values can be directly edited in the text box at the bottom. -- The loop start is entered as a `|`. -- The release point is entered as a `/`. -- In arpeggio macros, a value starting with a `@` is an absolute note (instead of a relative shift). No matter the note played, `@` values will be played at that exact note. This is especially useful for noise instruments with preset periods. - -### ADSR - -![ADSR macro editor](macro-ADSR.png) - -- **Bottom** and **Top** determine the range of outputs generated by the macro. (Bottom can be larger than Top to invert the envelope!) All outputs will be between these two values. -- Attack, Decay, Sustain, SusDecay, and Release accept inputs between 0 to 255. These are scaled to the distance between Bottom and Top. -- **Attack** is how much the value moves toward Top with each tick. -- **Hold** sets how many ticks to stay at Top before Decay. -- **Decay** is how much the value moves to the Sustain level. -- **Sustain** is how far from Bottom the value stays while the note is held. -- **SusTime** is how many ticks to stay at Sustain until SusDecay. -- **SusDecay** is how much the value moves toward Bottom with each tick while the note is held. -- **Release** is how much the value moves toward Bottom with each tick after the note is released. - -![macro ADSR chart](macro-ADSRchart.png) - -### LFO - -![LFO macro editor](macro-LFO.png) - -- **Bottom** and **Top** determine the range of values generated by the macro. (Bottom can be larger than Top to invert the waveform!) -- **Speed** is how quickly the values change - the frequency of the oscillator. -- **Phase** is which part of the waveform the macro will start at, measured in 1/1024 increments. -- **Shape** is the waveform used. Triangle is the default, and Saw and Square are exactly as they say. - -# samples - -This tab appears for Generic PCM, SNES, Amiga, and other sample-based instruments. - -![](sample-map.png) - -- **Initial Sample**: the sample that the instrument will use. -- **Use wavetable**: instead of samples, use wavetables. this causes the [Wavetables](../5-wave/README.md) tab to appear next to Sample. - - depending on the system and use of the wavetable synthesizer, this may or may not be reproducible on hardware. -- **Use sample map**: assigns a sample to each note. - - samples will be played at their default pitch. - - to set a note's sample, click the list entry in the `#` column then type the number of the sample. +# instrument list + +![instrument list](list.png) + +click on an instrument to select it. + +double-click to open the instrument editor. + +# instrument editor + +every instrument can be renamed and have its type changed. + +depending on the instrument type, there are many different types of instrument editor: + +- [FM synthesis](fm.md) - for use with YM2612, YM2151 and FM block portion of YM2610. +- [PSG](psg.md) - for use with TI SN76489 and derivatives like Sega Master System's PSG. +- [NES](nes.md) - for use with NES. +- [Game Boy](game-boy.md) - for use with Game Boy APU. +- [PC Engine / TurboGrafx-16](pce.md) - for use with PC Engine's wavetable synthesizer. +- [WonderSwan](wonderswan.md) - for use with WonderSwan's wavetable synthesizer. +- [AY8930](8930.md) - for use with Microchip AY8930 E-PSG sound source. +- [Commodore 64](c64.md) - for use with Commodore 64 SID. +- [SAA1099](saa.md) - for use with Philips SAA1099 PSG sound source. +- [TIA](tia.md) - for use with Atari 2600 chip. +- [AY-3-8910](ay8910.md) - for use with AY-3-8910 PSG sound source and SSG portion in YM2610. +- [Amiga / sample](amiga.md) for controlling Amiga and other sample based synthsizers like YM2612's Channel 6 PCM mode, NES channel 5, Sega PCM, X1-010 and PC Engine's sample playback mode. +- [Atari Lynx](lynx.md) - for use with Atari Lynx handheld console. +- [VERA](vera.md) - for use with Commander X16 VERA. +- [Seta/Allumer X1-010](x1_010.md) - for use with Wavetable portion in Seta/Allumer X1-010. +- [Konami SCC / Bubble System WSG](scc.md) - for use with Konami SCC and Wavetable portion in Bubble System's sound hardware. +- [Namco 163](n163.md) - for use with Namco 163. +- [Konami VRC6](vrc6.md) - for use with VRC6's PSG sound source. +- [SNES](snes.md) - for use with SNES S-APU. +- [Casio PV-1000](pv1000.md) - for use with Casio PV-1000. + + +# macros + +Macros are incredibly versatile tools for automating instrument parameters. + +After creating an instrument, open the Instrument Editor and select the "Macros" tab. There may be multiple macro tabs to control individual FM operators and such. + +![macro view](macroview.png) + +The very first numeric entry sets the visible width of the bars in sequence-type macros. The scrollbar affects the view of all macros at once. There's a matching scrollbar at the bottom underneath all the macros. + +Each macro has two buttons on the left. +- Macro type (explained below). +- Timing editor, which pops up a small dialog: + - Step Length (ticks): Determines how many ticks pass before each change of value. + - Delay: Delays the start of the macro until this many ticks have passed. + +## macro types + +Every macro can be defined though one of three methods, selectable with the leftmost button under the macro type label: + +- ![](macro-button-seq.png) **Sequence:** displayed as a bar graph, this is a sequence of numeric values. +- ![](macro-button-ADSR.png) **ADSR:** this is a traditional ADSR envelope, defined by the rate of increase and decrease of value over time. +- ![](macro-button-LFO.png) **LFO:** the Low Frequency Oscillator generates a repeating wave of values. + +Some macros are "bitmap" style. They represent a number of "bits" that can be toggled individually, and the values listed represent the sum of which bits are turned on. + +### sequence + +![sequence macro editor](macro-seq.png) + +The number between the macro type label and the macro type button is the macro length in steps. The `-` and `+` buttons change the length of the macro. Start out by adding at least a few steps. + +The values of the macro can be drawn in the "bar graph box". Just beneath the box is shorter bar graph. +- Click to set the start point of a loop; the end point is the last value or release point. Right-click to remove the loop. +- Shift-click to set the release point. When played, the macro will hold here until the note is released. Right-click to remove the release point. + +Finally, the sequence of values can be directly edited in the text box at the bottom. +- The loop start is entered as a `|`. +- The release point is entered as a `/`. +- In arpeggio macros, a value starting with a `@` is an absolute note (instead of a relative shift). No matter the note played, `@` values will be played at that exact note. This is especially useful for noise instruments with preset periods. + +### ADSR + +![ADSR macro editor](macro-ADSR.png) + +- **Bottom** and **Top** determine the range of outputs generated by the macro. (Bottom can be larger than Top to invert the envelope!) All outputs will be between these two values. +- Attack, Decay, Sustain, SusDecay, and Release accept inputs between 0 to 255. These are scaled to the distance between Bottom and Top. +- **Attack** is how much the value moves toward Top with each tick. +- **Hold** sets how many ticks to stay at Top before Decay. +- **Decay** is how much the value moves to the Sustain level. +- **Sustain** is how far from Bottom the value stays while the note is held. +- **SusTime** is how many ticks to stay at Sustain until SusDecay. +- **SusDecay** is how much the value moves toward Bottom with each tick while the note is held. +- **Release** is how much the value moves toward Bottom with each tick after the note is released. + +![macro ADSR chart](macro-ADSRchart.png) + +### LFO + +![LFO macro editor](macro-LFO.png) + +- **Bottom** and **Top** determine the range of values generated by the macro. (Bottom can be larger than Top to invert the waveform!) +- **Speed** is how quickly the values change - the frequency of the oscillator. +- **Phase** is which part of the waveform the macro will start at, measured in 1/1024 increments. +- **Shape** is the waveform used. Triangle is the default, and Saw and Square are exactly as they say. + +# samples + +This tab appears for Generic PCM, SNES, Amiga, and other sample-based instruments. + +![](sample-map.png) + +- **Initial Sample**: the sample that the instrument will use. +- **Use wavetable**: instead of samples, use wavetables. this causes the [Wavetables](../5-wave/README.md) tab to appear next to Sample. + - depending on the system and use of the wavetable synthesizer, this may or may not be reproducible on hardware. +- **Use sample map**: assigns a sample to each note. + - samples will be played at their default pitch. + - to set a note's sample, click the list entry in the `#` column then type the number of the sample. diff --git a/doc/4-instrument/nes.md b/doc/4-instrument/nes.md new file mode 100644 index 00000000..d8df859a --- /dev/null +++ b/doc/4-instrument/nes.md @@ -0,0 +1,18 @@ +# Standard instrument editor + +The instrument editor for NES consists of these macros: + +- **Volume**: volume. +- **Arpeggio**: pitch in half-steps. +- **Duty**: duty cycle and noise mode. + - pulse duty cycles: + - `0`: 12.5% + - `1`: 25% + - `2`: 50% + - `3`: 75% + - noise modes: + - `0`: long noise. + - `1`: short noise. +- **Panning**: output for left and right channels. +- **Pitch**: fine pitch. +- **Phase Reset**: trigger restart of waveform. \ No newline at end of file diff --git a/doc/4-instrument/psg.md b/doc/4-instrument/psg.md new file mode 100644 index 00000000..2f692af1 --- /dev/null +++ b/doc/4-instrument/psg.md @@ -0,0 +1,14 @@ +# PSG instrument editor + +The instrument editor for PSG (SMS, MSX, and other TI SN76489 derivatives) consists of these macros: + +- **Volume**: volume. +- **Arpeggio**: pitch in half-steps. +- **Duty**: noise mode. + - `0`: short noise, preset frequencies. + - `1`: long noise, preset frequencies. + - `2`: short noise, use channel 3 for frequency. + - `3`: long noise, use channel 3 for frequency. +- **Panning**: output for left and right channels. +- **Pitch**: fine pitch. +- **Phase Reset**: trigger restart of waveform. \ No newline at end of file From 573f8d5b3bef4f2e63e4c7683b845dc1f1dda637 Mon Sep 17 00:00:00 2001 From: Electric Keet Date: Thu, 13 Jul 2023 17:19:56 -0700 Subject: [PATCH 10/13] Deleting old NES.PSG instrument doc. --- doc/4-instrument/standard.md | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 doc/4-instrument/standard.md diff --git a/doc/4-instrument/standard.md b/doc/4-instrument/standard.md deleted file mode 100644 index 11272356..00000000 --- a/doc/4-instrument/standard.md +++ /dev/null @@ -1,18 +0,0 @@ -# Standard instrument editor - -The instrument editor for NES and PSG (SMS, MSX, and such) consists of these macros: - -- **Volume**: volume. -- **Arpeggio**: pitch in half-steps. -- **Duty**: duty cycle and noise mode. - - NES noise modes: - - `0`: long noise. - - `1`: short noise. - - PSG noise modes: - - `0`: short noise, preset frequencies. - - `1`: long noise, preset frequencies. - - `2`: short noise, use channel 3 for frequency. - - `3`: long noise, use channel 3 for frequency. -- **Panning**: output for left and right channels. -- **Pitch**: fine pitch. -- **Phase Reset**: trigger restart of waveform. \ No newline at end of file From d096d5eb3ce6a4a459c6f7f8f836b745ab89a930 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 14 Jul 2023 19:24:57 -0500 Subject: [PATCH 11/13] GUI: fix scrolling when stepping rows --- src/engine/engine.cpp | 2 ++ src/engine/playback.cpp | 12 +++++++++--- src/gui/doAction.cpp | 1 + src/gui/editControls.cpp | 10 +++++----- src/gui/gui.cpp | 2 +- src/gui/gui.h | 3 ++- src/gui/pattern.cpp | 2 +- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index c7b5ac9e..b7ee8ec0 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -2598,6 +2598,8 @@ void DivEngine::stepOne(int row) { } stepPlay=2; ticks=1; + prevOrder=curOrder; + prevRow=curRow; BUSY_END; } diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index 9f8a2f10..aabce5c6 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -1130,8 +1130,10 @@ void DivEngine::nextRow() { } } - prevOrder=curOrder; - prevRow=curRow; + if (!stepPlay) { + prevOrder=curOrder; + prevRow=curRow; + } for (int i=0; istepOne(cursor.y); + pendingStepUpdate=1; break; case GUI_ACTION_OCTAVE_UP: if (++curOctave>7) { diff --git a/src/gui/editControls.cpp b/src/gui/editControls.cpp index e3e84348..099ff7e2 100644 --- a/src/gui/editControls.cpp +++ b/src/gui/editControls.cpp @@ -374,7 +374,7 @@ void FurnaceGUI::drawMobileControls() { if (portrait) ImGui::SameLine(); if (ImGui::Button(ICON_FA_ARROW_DOWN "##StepOne",buttonSize)) { e->stepOne(cursor.y); - pendingStepUpdate=true; + pendingStepUpdate=1; } bool repeatPattern=e->getRepeatPattern(); @@ -730,7 +730,7 @@ void FurnaceGUI::drawEditControls() { ImGui::SameLine(); if (ImGui::Button(ICON_FA_ARROW_DOWN "##StepOne")) { e->stepOne(cursor.y); - pendingStepUpdate=true; + pendingStepUpdate=1; } if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Step one row"); @@ -770,7 +770,7 @@ void FurnaceGUI::drawEditControls() { ImGui::SameLine(); if (ImGui::Button(ICON_FA_ARROW_DOWN "##StepOne")) { e->stepOne(cursor.y); - pendingStepUpdate=true; + pendingStepUpdate=1; } if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Step one row"); @@ -875,7 +875,7 @@ void FurnaceGUI::drawEditControls() { } if (ImGui::Button(ICON_FA_ARROW_DOWN "##StepOne",buttonSize)) { e->stepOne(cursor.y); - pendingStepUpdate=true; + pendingStepUpdate=1; } if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Step one row"); @@ -1009,7 +1009,7 @@ void FurnaceGUI::drawEditControls() { ImGui::SameLine(); if (ImGui::Button(ICON_FA_ARROW_DOWN "##StepOne")) { e->stepOne(cursor.y); - pendingStepUpdate=true; + pendingStepUpdate=1; } if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Step one row"); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 6437ecab..71f4fecd 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -7015,7 +7015,7 @@ FurnaceGUI::FurnaceGUI(): fadeMode(false), randomMode(false), haveHitBounds(false), - pendingStepUpdate(false), + pendingStepUpdate(0), oldOrdersLen(0), sampleZoom(1.0), prevSampleZoom(1.0), diff --git a/src/gui/gui.h b/src/gui/gui.h index 83c5a380..4e564751 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1913,7 +1913,8 @@ class FurnaceGUI { int dummyRows, demandX; int transposeAmount, randomizeMin, randomizeMax, fadeMin, fadeMax, collapseAmount; float scaleMax; - bool fadeMode, randomMode, haveHitBounds, pendingStepUpdate; + bool fadeMode, randomMode, haveHitBounds; + signed char pendingStepUpdate; int oldOrdersLen; DivOrders oldOrders; diff --git a/src/gui/pattern.cpp b/src/gui/pattern.cpp index 72d953b7..1deec9dc 100644 --- a/src/gui/pattern.cpp +++ b/src/gui/pattern.cpp @@ -446,7 +446,7 @@ void FurnaceGUI::drawPattern() { float lineHeight=(ImGui::GetTextLineHeight()+2*dpiScale); int curRow=e->getRow(); if (e->isPlaying() && followPattern && (!e->isStepping() || pendingStepUpdate)) updateScroll(curRow); - pendingStepUpdate=false; + if (--pendingStepUpdate<0) pendingStepUpdate=0; if (nextScroll>-0.5f) { ImGui::SetScrollY(nextScroll); nextScroll=-1.0f; From 99e55136f36dfa7f3336ef5dadf6da8d155609fa Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 15 Jul 2023 02:50:49 -0500 Subject: [PATCH 12/13] GUI: prevent lag when drawing on wave editor --- src/gui/gui.cpp | 8 +++++++- src/gui/gui.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 71f4fecd..d6e68911 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2419,7 +2419,7 @@ void FurnaceGUI::processDrags(int dragX, int dragY) { if (y>waveDragMax) y=waveDragMax; if (ynotifyWaveChange(curWave); + notifyWaveChange=true; MARK_MODIFIED; } } @@ -3746,6 +3746,11 @@ bool FurnaceGUI::loop() { midiLock.unlock(); } + if (notifyWaveChange) { + notifyWaveChange=false; + e->notifyWaveChange(curWave); + } + eventTimeEnd=SDL_GetPerformanceCounter(); if (SDL_GetWindowFlags(sdlWin)&SDL_WINDOW_MINIMIZED) { @@ -6718,6 +6723,7 @@ FurnaceGUI::FurnaceGUI(): preserveChanPos(false), wantScrollList(false), noteInputPoly(true), + notifyWaveChange(false), displayPendingIns(false), pendingInsSingle(false), displayPendingRawSample(false), diff --git a/src/gui/gui.h b/src/gui/gui.h index 4e564751..c87b60a1 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1310,7 +1310,7 @@ class FurnaceGUI { bool vgmExportDirectStream, displayInsTypeList; bool portrait, injectBackUp, mobileMenuOpen, warnColorPushed; bool wantCaptureKeyboard, oldWantCaptureKeyboard, displayMacroMenu; - bool displayNew, fullScreen, preserveChanPos, wantScrollList, noteInputPoly; + bool displayNew, fullScreen, preserveChanPos, wantScrollList, noteInputPoly, notifyWaveChange; bool displayPendingIns, pendingInsSingle, displayPendingRawSample, snesFilterHex, modTableHex, displayEditString; bool mobileEdit; bool killGraphics; From c3d6d9c440d1e799a47530b5faf792c7680baf20 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 15 Jul 2023 02:59:06 -0500 Subject: [PATCH 13/13] don't start engine on autoNoteOff it's unnecessary. issue #1187 --- src/engine/engine.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index b7ee8ec0..c32b5311 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -4322,9 +4322,7 @@ void DivEngine::autoNoteOn(int ch, int ins, int note, int vol) { void DivEngine::autoNoteOff(int ch, int note, int vol) { if (!playing) { - reset(); - freelance=true; - playing=true; + return; } //if (ch<0 || ch>=chans) return; for (int i=0; i