Delay committing fullscreen until seeing window size change
[lsnes.git] / libgambatte-patches / svn537 / 0004-Fix-sound-DC-levels.patch
blob185c5159bdaec33c7bca0bf4bf76fefa67e0495e
1 From 607d3e252c43d67cea54ec222ef1767a86b3660b Mon Sep 17 00:00:00 2001
2 From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
3 Date: Thu, 5 Dec 2013 08:48:21 +0200
4 Subject: [PATCH 4/9] Fix sound DC levels
6 This was causing popping in Mega Man (I)
7 ---
8 libgambatte/src/sound/channel1.cpp | 6 +++---
9 libgambatte/src/sound/channel2.cpp | 6 +++---
10 libgambatte/src/sound/channel3.cpp | 8 ++++----
11 libgambatte/src/sound/channel4.cpp | 4 ++--
12 4 files changed, 12 insertions(+), 12 deletions(-)
14 diff --git a/libgambatte/src/sound/channel1.cpp b/libgambatte/src/sound/channel1.cpp
15 index c517965..dd83894 100644
16 --- a/libgambatte/src/sound/channel1.cpp
17 +++ b/libgambatte/src/sound/channel1.cpp
18 @@ -218,13 +218,13 @@ void Channel1::loadState(SaveState const &state) {
20 void Channel1::update(uint_least32_t *buf, unsigned const soBaseVol, unsigned cycles) {
21 unsigned const outBase = envelopeUnit_.dacIsOn() ? soBaseVol & soMask_ : 0;
22 - unsigned const outLow = outBase * (0 - 15ul);
23 unsigned const endCycles = cycleCounter_ + cycles;
25 for (;;) {
26 unsigned const outHigh = master_
27 - ? outBase * (envelopeUnit_.getVolume() * 2 - 15ul)
28 - : outLow;
29 + ? outBase * (envelopeUnit_.getVolume())
30 + : 0;
31 + unsigned const outLow = -outHigh;
32 unsigned const nextMajorEvent = std::min(nextEventUnit_->counter(), endCycles);
33 unsigned out = dutyUnit_.isHighState() ? outHigh : outLow;
35 diff --git a/libgambatte/src/sound/channel2.cpp b/libgambatte/src/sound/channel2.cpp
36 index f154249..6024d79 100644
37 --- a/libgambatte/src/sound/channel2.cpp
38 +++ b/libgambatte/src/sound/channel2.cpp
39 @@ -122,13 +122,13 @@ void Channel2::loadState(SaveState const &state) {
41 void Channel2::update(uint_least32_t *buf, unsigned const soBaseVol, unsigned cycles) {
42 unsigned const outBase = envelopeUnit_.dacIsOn() ? soBaseVol & soMask_ : 0;
43 - unsigned const outLow = outBase * (0 - 15ul);
44 unsigned const endCycles = cycleCounter_ + cycles;
46 for (;;) {
47 unsigned const outHigh = master_
48 - ? outBase * (envelopeUnit_.getVolume() * 2 - 15ul)
49 - : outLow;
50 + ? outBase * (envelopeUnit_.getVolume())
51 + : 0;
52 + unsigned const outLow = -outHigh;
53 unsigned const nextMajorEvent = std::min(nextEventUnit->counter(), endCycles);
54 unsigned out = dutyUnit_.isHighState() ? outHigh : outLow;
56 diff --git a/libgambatte/src/sound/channel3.cpp b/libgambatte/src/sound/channel3.cpp
57 index c583949..f25c96d 100644
58 --- a/libgambatte/src/sound/channel3.cpp
59 +++ b/libgambatte/src/sound/channel3.cpp
60 @@ -156,8 +156,8 @@ void Channel3::update(uint_least32_t *buf, unsigned const soBaseVol, unsigned cy
61 unsigned const nextMajorEvent =
62 std::min(lengthCounter_.counter(), endCycles);
63 unsigned out = master_
64 - ? ((sampleBuf_ >> (~wavePos_ << 2 & 4) & 0xF) >> rshift_) * 2 - 15ul
65 - : 0 - 15ul;
66 + ? ((sampleBuf_ >> (~wavePos_ << 2 & 4) & 0xF) >> rshift_) * 2 - (15 >> rshift_)
67 + : 0;
68 out *= outBase;
70 while (waveCounter_ <= nextMajorEvent) {
71 @@ -171,7 +171,7 @@ void Channel3::update(uint_least32_t *buf, unsigned const soBaseVol, unsigned cy
72 ++wavePos_;
73 wavePos_ &= 0x1F;
74 sampleBuf_ = waveRam_[wavePos_ >> 1];
75 - out = ((sampleBuf_ >> (~wavePos_ << 2 & 4) & 0xF) >> rshift_) * 2 - 15ul;
76 + out = ((sampleBuf_ >> (~wavePos_ << 2 & 4) & 0xF) >> rshift_) * 2 - (15 >> rshift_);
77 out *= outBase;
80 @@ -188,7 +188,7 @@ void Channel3::update(uint_least32_t *buf, unsigned const soBaseVol, unsigned cy
81 break;
83 } else {
84 - unsigned const out = outBase * (0 - 15ul);
85 + unsigned const out = 0;
86 *buf += out - prevOut_;
87 prevOut_ = out;
88 cycleCounter_ += cycles;
89 diff --git a/libgambatte/src/sound/channel4.cpp b/libgambatte/src/sound/channel4.cpp
90 index bc0a312..0abd4fb 100644
91 --- a/libgambatte/src/sound/channel4.cpp
92 +++ b/libgambatte/src/sound/channel4.cpp
93 @@ -224,11 +224,11 @@ void Channel4::loadState(SaveState const &state) {
95 void Channel4::update(uint_least32_t *buf, unsigned const soBaseVol, unsigned cycles) {
96 unsigned const outBase = envelopeUnit_.dacIsOn() ? soBaseVol & soMask_ : 0;
97 - unsigned const outLow = outBase * (0 - 15ul);
98 unsigned const endCycles = cycleCounter_ + cycles;
100 for (;;) {
101 - unsigned const outHigh = outBase * (envelopeUnit_.getVolume() * 2 - 15ul);
102 + unsigned const outHigh = outBase * (envelopeUnit_.getVolume());
103 + unsigned const outLow = -outHigh;
104 unsigned const nextMajorEvent = std::min(nextEventUnit_->counter(), endCycles);
105 unsigned out = lfsr_.isHighState() ? outHigh : outLow;
108 2.1.3