From fb22d6c8bb89a398b36496ecdc29fbb80f8ec77c Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Wed, 7 Dec 2016 18:56:26 +0300 Subject: Ooops Fixed wrong generated sound in some cases. DBOPL has own constructors to initialize it's fields. memset no need here --- src/adlmidi.cpp | 3 +-- src/dbopl.cpp | 17 +++++++++++++++++ src/dbopl.h | 2 ++ 3 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp index 6372f55..265208b 100644 --- a/src/adlmidi.cpp +++ b/src/adlmidi.cpp @@ -429,8 +429,7 @@ struct OPL3 { LogarithmicVolumes = false; #ifdef ADLMIDI_USE_DOSBOX_OPL - DBOPL::Handler emptyChip; - memset(&emptyChip, 0, sizeof(DBOPL::Handler)); + DBOPL::Handler emptyChip; //Constructors inside are will initialize necessary fields #else _opl3_chip emptyChip; memset(&emptyChip, 0, sizeof(_opl3_chip)); diff --git a/src/dbopl.cpp b/src/dbopl.cpp index 1f2f397..e534c99 100644 --- a/src/dbopl.cpp +++ b/src/dbopl.cpp @@ -1203,6 +1203,23 @@ namespace DBOPL regBD = 0; reg104 = 0; opl3Active = 0; + //Extra zeros! + vibratoIndex = 0; + tremoloIndex = 0; + vibratoSign = 0; + vibratoShift = 0; + tremoloValue = 0; + vibratoStrength = 0; + tremoloStrength = 0; + waveFormMask = 0; + lfoCounter = 0; + lfoAdd = 0; + noiseCounter = 0; + noiseAdd = 0; + noiseValue = 0; + memset(freqMul, 0, sizeof(Bit32u) * 16); + memset(linearRates, 0, sizeof(Bit32u) * 76); + memset(attackRates, 0, sizeof(Bit32u) * 76); } INLINE Bit32u Chip::ForwardNoise() diff --git a/src/dbopl.h b/src/dbopl.h index 5dfe7fe..bdd439d 100644 --- a/src/dbopl.h +++ b/src/dbopl.h @@ -173,6 +173,7 @@ namespace DBOPL Bits GetWave(Bitu index, Bitu vol); public: Operator(); + char ____padding[5]; }; struct Channel @@ -211,6 +212,7 @@ namespace DBOPL template Channel *BlockTemplate(Chip *chip, Bit32u samples, Bit32s *output); Channel(); + char ____padding[6]; }; struct Chip -- cgit v1.2.3