From d71b33918a020de255757a924dc56fc1b8923b6a Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Mon, 6 Aug 2018 14:18:58 -0230 Subject: [PATCH 01/25] Slight rework of random number generator. - break dependence on OSystem; source for seed could actually be anything (doesn't have to come from OSystem) --- src/emucore/OSystem.cxx | 5 ++--- src/emucore/Random.hxx | 10 +++------- src/emucore/System.cxx | 2 +- src/emucore/System.hxx | 1 + 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 1b8966f46..c7a9cee4e 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -95,7 +95,6 @@ OSystem::OSystem() mySettings = MediaFactory::createSettings(*this); myAudioSettings = AudioSettings(mySettings.get()); - myRandom = make_unique(*this); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -158,8 +157,8 @@ bool OSystem::create() // a real serial port on the system mySerialPort = MediaFactory::createSerialPort(); - // Re-initialize random seed - myRandom->initSeed(); + // Create random number generator + myRandom = make_unique(getTicks()); // Create PNG handler myPNGLib = make_unique(*this); diff --git a/src/emucore/Random.hxx b/src/emucore/Random.hxx index 3d7f910b1..9a2a6e7c9 100644 --- a/src/emucore/Random.hxx +++ b/src/emucore/Random.hxx @@ -19,7 +19,6 @@ #define RANDOM_HXX #include "bspf.hxx" -#include "OSystem.hxx" #include "Serializable.hxx" /** @@ -35,15 +34,15 @@ class Random : public Serializable /** Create a new random number generator */ - Random(const OSystem& osystem) : myOSystem(osystem) { initSeed(); } + Random(uInt32 seed) { initSeed(seed); } /** Re-initialize the random number generator with a new seed, to generate a different set of random numbers. */ - void initSeed() + void initSeed(uInt32 seed) { - myValue = uInt32(myOSystem.getTicks()); + myValue = seed; } /** @@ -110,9 +109,6 @@ class Random : public Serializable string name() const override { return "Random"; } private: - // Set the OSystem we're using - const OSystem& myOSystem; - // Indicates the next random number // We make this mutable, since it's not immediately obvious that // calling next() should change internal state (ie, the *logical* diff --git a/src/emucore/System.cxx b/src/emucore/System.cxx index 5bd3669a1..d143c548e 100644 --- a/src/emucore/System.cxx +++ b/src/emucore/System.cxx @@ -39,7 +39,7 @@ System::System(const OSystem& osystem, M6502& m6502, M6532& m6532, mySystemInAutodetect(false) { // Re-initialize random generator - randGenerator().initSeed(); + randGenerator().initSeed(myOSystem.getTicks()); // Initialize page access table PageAccess access(&myNullDevice, System::PA_READ); diff --git a/src/emucore/System.hxx b/src/emucore/System.hxx index de6e354df..80046e78b 100644 --- a/src/emucore/System.hxx +++ b/src/emucore/System.hxx @@ -27,6 +27,7 @@ class NullDevice; #include "bspf.hxx" #include "Device.hxx" #include "NullDev.hxx" +#include "OSystem.hxx" #include "Random.hxx" #include "Serializable.hxx" From 2406b8ad0f65f92f21106f11ce134c78d25ac26a Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Mon, 6 Aug 2018 14:28:48 -0230 Subject: [PATCH 02/25] Use our own RNG instead of C-style rand() (fixes issue #336). --- src/emucore/PointingDevice.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emucore/PointingDevice.cxx b/src/emucore/PointingDevice.cxx index 9582e220a..c67fc9905 100644 --- a/src/emucore/PointingDevice.cxx +++ b/src/emucore/PointingDevice.cxx @@ -149,7 +149,7 @@ void PointingDevice::updateDirection(int counter, float& counterRemainder, scanCount = INT_MAX; // Define offset factor for first change, move randomly forward by up to 1/8th - firstScanOffset = (((firstScanOffset << 3) + rand() % + firstScanOffset = (((firstScanOffset << 3) + mySystem.randGenerator().next() % (1 << 12)) >> 3) & ((1 << 12) - 1); } } From a424b8b9a7fd76e217f24493f90e5123e6e98546 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Mon, 6 Aug 2018 17:29:22 -0230 Subject: [PATCH 03/25] Fix minor warnings reported by gcc and clang. --- src/debugger/gui/DataGridWidget.cxx | 5 +++-- src/debugger/gui/PromptWidget.cxx | 2 +- src/debugger/gui/RomListWidget.cxx | 2 +- src/debugger/gui/ToggleBitWidget.cxx | 6 ++++-- src/gui/CheckListWidget.cxx | 3 ++- src/gui/EditTextWidget.cxx | 2 +- src/gui/Widget.cxx | 5 +++-- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 43d2a6ffd..f98a408a8 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -635,12 +635,13 @@ void DataGridWidget::drawWidget(bool hilite) { if(_changedList[pos]) { - s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, onTop ? kDbgChangedColor : _bgcolorlo); + s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, + onTop ? uInt32(kDbgChangedColor) : _bgcolorlo); if(_hiliteList[pos]) textColor = kDbgColorHi; else - textColor = onTop ? kDbgChangedTextColor : textColor; + textColor = onTop ? uInt32(kDbgChangedTextColor) : textColor; } else if(_hiliteList[pos]) textColor = kDbgColorHi; diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index 9093c1537..8bc7d17c5 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -96,7 +96,7 @@ void PromptWidget::drawWidget(bool hilite) else fgcolor = c >> 8; - s.drawChar(_font, c & 0x7f, x, y, onTop ? fgcolor : kColor); + s.drawChar(_font, c & 0x7f, x, y, onTop ? fgcolor : uInt32(kColor)); x += _kConsoleCharWidth; } y += _kConsoleLineHeight; diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index cc8cc1e46..481560889 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -514,7 +514,7 @@ void RomListWidget::drawWidget(bool hilite) // Draw labels s.drawString(_font, dlist[pos].label, xpos, ypos, _labelWidth, - dlist[pos].hllabel ? textColor : kColor); + dlist[pos].hllabel ? textColor : uInt32(kColor)); // Bytes are only editable if they represent code, graphics, or accessible data // Otherwise, the disassembly should get all remaining space diff --git a/src/debugger/gui/ToggleBitWidget.cxx b/src/debugger/gui/ToggleBitWidget.cxx index 11fd8bc3e..80d1814eb 100644 --- a/src/debugger/gui/ToggleBitWidget.cxx +++ b/src/debugger/gui/ToggleBitWidget.cxx @@ -115,11 +115,13 @@ void ToggleBitWidget::drawWidget(bool hilite) // Highlight changes if(_changedList[pos]) { - s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, onTop ? kDbgChangedColor : _bgcolorlo); + s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, + onTop ? uInt32(kDbgChangedColor) : _bgcolorlo); s.drawString(_font, buffer, x, y, _colWidth, onTop ? kDbgChangedTextColor : kColor); } else - s.drawString(_font, buffer, x, y, _colWidth, onTop ? textColor : kColor); + s.drawString(_font, buffer, x, y, _colWidth, + onTop ? textColor : uInt32(kColor)); } else { diff --git a/src/gui/CheckListWidget.cxx b/src/gui/CheckListWidget.cxx index 859fc5439..43803a970 100644 --- a/src/gui/CheckListWidget.cxx +++ b/src/gui/CheckListWidget.cxx @@ -137,7 +137,8 @@ void CheckListWidget::drawWidget(bool hilite) TextAlign::Left, -_editScrollOffset, false); } else - s.drawString(_font, _list[pos], _x + r.left, y, r.width(), onTop ? textColor : kColor); + s.drawString(_font, _list[pos], _x + r.left, y, r.width(), + onTop ? textColor : uInt32(kColor)); } // Only draw the caret while editing, and if it's in the current viewport diff --git a/src/gui/EditTextWidget.cxx b/src/gui/EditTextWidget.cxx index acf972349..919aba3e7 100644 --- a/src/gui/EditTextWidget.cxx +++ b/src/gui/EditTextWidget.cxx @@ -96,7 +96,7 @@ void EditTextWidget::drawWidget(bool hilite) s.drawString(_font, editString(), _x + 2, _y + 2, getEditRect().width(), _changed && onTop ? uInt32(kDbgChangedTextColor) - : onTop ? _textcolor : kColor, + : onTop ? _textcolor : uInt32(kColor), TextAlign::Left, -_editScrollOffset, false); // Draw the caret diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 79a53b12b..e6acce094 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -645,8 +645,9 @@ void CheckboxWidget::drawWidget(bool hilite) if(_drawBox) s.frameRect(_x, _y + _boxY, 14, 14, onTop && hilite && isEnabled() && isEditable() ? kWidColorHi : kColor); // Do we draw a square or cross? - s.fillRect(_x + 1, _y + _boxY + 1, 12, 12, _changed ? onTop ? uInt32(kDbgChangedColor) : kDlgColor - : isEnabled() ? onTop ? _bgcolor : kDlgColor : uInt32(kColor)); + s.fillRect(_x + 1, _y + _boxY + 1, 12, 12, + _changed ? onTop ? uInt32(kDbgChangedColor) : uInt32(kDlgColor) : + isEnabled() ? onTop ? _bgcolor : uInt32(kDlgColor) : uInt32(kColor)); if(_state) s.drawBitmap(_img, _x + 2, _y + _boxY + 2, onTop && isEnabled() ? hilite && isEditable() ? kWidColorHi : kCheckColor : kColor, 10); From ac4acdffec0bc2f289e9efed67db0807830c1848 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Mon, 6 Aug 2018 17:30:38 -0230 Subject: [PATCH 04/25] Bump state version # to indicate incompatible changes in state files. --- src/common/StateManager.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/StateManager.cxx b/src/common/StateManager.cxx index 66a62bf29..61af78d22 100644 --- a/src/common/StateManager.cxx +++ b/src/common/StateManager.cxx @@ -27,7 +27,7 @@ #include "StateManager.hxx" -#define STATE_HEADER "05019000state" +#define STATE_HEADER "05099000state" // #define MOVIE_HEADER "03030000movie" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From b68f72dd5035f5cc16465f8d2c4e485f4e7ef6d5 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Mon, 6 Aug 2018 18:02:12 -0230 Subject: [PATCH 05/25] Fix minor warning in Visual Studio. --- src/common/Version.hxx | 2 +- src/emucore/OSystem.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/Version.hxx b/src/common/Version.hxx index bc1d304a5..3748e3197 100644 --- a/src/common/Version.hxx +++ b/src/common/Version.hxx @@ -19,6 +19,6 @@ #define VERSION_HXX #define STELLA_VERSION "6.0_pre1" -#define STELLA_BUILD "4409" +#define STELLA_BUILD "4430" #endif diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index c7a9cee4e..f4ef445bc 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -158,7 +158,7 @@ bool OSystem::create() mySerialPort = MediaFactory::createSerialPort(); // Create random number generator - myRandom = make_unique(getTicks()); + myRandom = make_unique(uInt32(getTicks())); // Create PNG handler myPNGLib = make_unique(*this); From 78cb878c292fd312f9a7c31879fde8f1d4674270 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Mon, 6 Aug 2018 18:12:09 -0230 Subject: [PATCH 06/25] Fixed minor warning in Xcode. Strange that VS only picked up the other instance of this issue, and neither gcc nor clang found either one. --- src/emucore/System.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emucore/System.cxx b/src/emucore/System.cxx index d143c548e..fd8da8fba 100644 --- a/src/emucore/System.cxx +++ b/src/emucore/System.cxx @@ -39,7 +39,7 @@ System::System(const OSystem& osystem, M6502& m6502, M6532& m6532, mySystemInAutodetect(false) { // Re-initialize random generator - randGenerator().initSeed(myOSystem.getTicks()); + randGenerator().initSeed(uInt32(myOSystem.getTicks())); // Initialize page access table PageAccess access(&myNullDevice, System::PA_READ); From 163b5ca99937d8d53fd96085c083c9b6f3423882 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Mon, 6 Aug 2018 23:25:07 +0200 Subject: [PATCH 07/25] Fix a regression in collision handling -> fixes Sky Skipper. --- src/emucore/tia/Ball.cxx | 4 ++-- src/emucore/tia/Missile.cxx | 2 +- src/emucore/tia/Player.cxx | 2 +- src/emucore/tia/TIA.cxx | 11 ++++++++++- src/emucore/tia/TIA.hxx | 12 ++++++++++-- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/emucore/tia/Ball.cxx b/src/emucore/tia/Ball.cxx index 2a492d22b..293369a2f 100644 --- a/src/emucore/tia/Ball.cxx +++ b/src/emucore/tia/Ball.cxx @@ -66,7 +66,7 @@ void Ball::enabl(uInt8 value) updateEnabled(); collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled; - myTIA->updateCollision(); + myTIA->scheduleCollisionUpdate(); } } @@ -245,7 +245,7 @@ void Ball::updateEnabled() myIsEnabled = !myIsSuppressed && (myIsDelaying ? myIsEnabledOld : myIsEnabledNew); collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled; - myTIA->updateCollision(); + myTIA->scheduleCollisionUpdate(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/tia/Missile.cxx b/src/emucore/tia/Missile.cxx index e70579c06..e6f69a489 100644 --- a/src/emucore/tia/Missile.cxx +++ b/src/emucore/tia/Missile.cxx @@ -260,7 +260,7 @@ void Missile::updateEnabled() myIsEnabled = !myIsSuppressed && myEnam && !myResmp; collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled; - myTIA->updateCollision(); + myTIA->scheduleCollisionUpdate(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/tia/Player.cxx b/src/emucore/tia/Player.cxx index bcfa9c4ab..86af0c66e 100644 --- a/src/emucore/tia/Player.cxx +++ b/src/emucore/tia/Player.cxx @@ -385,7 +385,7 @@ void Player::updatePattern() if (myIsRendering && myRenderCounter >= myRenderCounterTripPoint) { collision = (myPattern & (1 << mySampleCounter)) ? myCollisionMaskEnabled : myCollisionMaskDisabled; - myTIA->updateCollision(); + myTIA->scheduleCollisionUpdate(); } } diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 0efbbd65f..c4f27b8ca 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -266,6 +266,7 @@ bool TIA::save(Serializer& out) const out.putInt(myXAtRenderingStart); out.putBool(myCollisionUpdateRequired); + out.putBool(myCollisionUpdateScheduled); out.putInt(myCollisionMask); out.putInt(myMovementClock); @@ -337,6 +338,7 @@ bool TIA::load(Serializer& in) myXAtRenderingStart = in.getInt(); myCollisionUpdateRequired = in.getBool(); + myCollisionUpdateScheduled = in.getBool(); myCollisionMask = in.getInt(); myMovementClock = in.getInt(); @@ -1216,7 +1218,8 @@ void TIA::cycle(uInt32 colorClocks) [this] (uInt8 address, uInt8 value) {delayedWrite(address, value);} ); - myCollisionUpdateRequired = false; + myCollisionUpdateRequired = myCollisionUpdateScheduled; + myCollisionUpdateScheduled = false; if (myLinesSinceChange < 2) { tickMovement(); @@ -1351,6 +1354,12 @@ void TIA::cloneLastLine() memcpy(buffer + y * 160, buffer + (y-1) * 160, 160); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void TIA::scheduleCollisionUpdate() +{ + myCollisionUpdateScheduled = true; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIA::updateCollision() { diff --git a/src/emucore/tia/TIA.hxx b/src/emucore/tia/TIA.hxx index 44859ef48..11067b56b 100644 --- a/src/emucore/tia/TIA.hxx +++ b/src/emucore/tia/TIA.hxx @@ -448,9 +448,9 @@ class TIA : public Device void flushLineCache(); /** - * Update the collision bitfield. + Schedule a collision update */ - void updateCollision(); + void scheduleCollisionUpdate(); /** Create a new delayQueueIterator for the debugger. @@ -543,6 +543,11 @@ class TIA : public Device */ void tickHframe(); + /** + * Update the collision bitfield. + */ + void updateCollision(); + /** * Execute a RSYNC. */ @@ -815,6 +820,9 @@ class TIA : public Device bool myEnableJitter; uInt8 myJitterFactor; + // Force schedule a collision update + bool myCollisionUpdateScheduled; + #ifdef DEBUGGER_SUPPORT // The arrays containing information about every byte of TIA // indicating whether and how (RW) it is used. From 337c13882e356ca9b254d7fc684cb42b0b7b606a Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Mon, 6 Aug 2018 23:45:28 +0200 Subject: [PATCH 08/25] Remove redundant code. --- src/emucore/tia/Ball.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/emucore/tia/Ball.cxx b/src/emucore/tia/Ball.cxx index 293369a2f..c6ff20eed 100644 --- a/src/emucore/tia/Ball.cxx +++ b/src/emucore/tia/Ball.cxx @@ -65,8 +65,6 @@ void Ball::enabl(uInt8 value) myTIA->flushLineCache(); updateEnabled(); - collision = (myIsVisible && myIsEnabled) ? myCollisionMaskEnabled : myCollisionMaskDisabled; - myTIA->scheduleCollisionUpdate(); } } From e2df53bd057caabc1c90cbde03b1284b27a2420e Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Mon, 6 Aug 2018 23:39:41 -0230 Subject: [PATCH 09/25] Final changes for 6.0 pre-release 1. --- src/common/Version.hxx | 2 +- src/macosx/Info-Stella.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/Version.hxx b/src/common/Version.hxx index 3748e3197..19c9014d3 100644 --- a/src/common/Version.hxx +++ b/src/common/Version.hxx @@ -19,6 +19,6 @@ #define VERSION_HXX #define STELLA_VERSION "6.0_pre1" -#define STELLA_BUILD "4430" +#define STELLA_BUILD "4434" #endif diff --git a/src/macosx/Info-Stella.plist b/src/macosx/Info-Stella.plist index 3127800e8..bf43e9acf 100644 --- a/src/macosx/Info-Stella.plist +++ b/src/macosx/Info-Stella.plist @@ -53,7 +53,7 @@ CFBundleSignature StLa CFBundleVersion - 5.1 + 6.0 LSApplicationCategoryType public.app-category.games LSMinimumSystemVersionByArchitecture From 89b0759da59a279bf837f585ee391d0e2d580518 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 7 Aug 2018 09:37:25 +0200 Subject: [PATCH 10/25] fix #338 --- src/emucore/DispatchResult.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emucore/DispatchResult.hxx b/src/emucore/DispatchResult.hxx index 9c86144a8..400f85017 100644 --- a/src/emucore/DispatchResult.hxx +++ b/src/emucore/DispatchResult.hxx @@ -35,7 +35,7 @@ class DispatchResult const string& getMessage() const { assertStatus(Status::debugger); return myMessage; } - uInt16 getAddress() const { assertStatus(Status::debugger); return myAddress; } + int getAddress() const { assertStatus(Status::debugger); return myAddress; } bool wasReadTrap() const { assertStatus(Status::debugger); return myWasReadTrap; } From a1bc2460bbc5bf7f3115d28e335dd945c7a41851 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 7 Aug 2018 17:30:52 +0200 Subject: [PATCH 11/25] some small darkened color touches --- src/debugger/gui/DataGridWidget.cxx | 2 +- src/debugger/gui/DelayQueueWidget.cxx | 5 +++-- src/debugger/gui/PromptWidget.cxx | 3 ++- src/debugger/gui/ToggleBitWidget.cxx | 9 +++++---- src/debugger/gui/TogglePixelWidget.cxx | 3 ++- src/gui/ColorWidget.cxx | 2 +- src/gui/ScrollBarWidget.cxx | 12 ++++++++---- 7 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index f98a408a8..43359e6bc 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -596,7 +596,7 @@ void DataGridWidget::drawWidget(bool hilite) bool onTop = _boss->dialog().isOnTop(); int row, col; - s.fillRect(_x, _y, _w, _h, hilite && isEnabled() && isEditable() ? _bgcolorhi : onTop ? _bgcolor : _bgcolorlo); + s.fillRect(_x, _y, _w, _h, hilite && isEnabled() && isEditable() ? _bgcolorhi : onTop ? _bgcolor : kBGColorHi); // Draw the internal grid and labels int linewidth = _cols * _colWidth; s.frameRect(_x, _y, _w, _h, hilite && isEnabled() && isEditable() ? kWidColorHi : kColor); diff --git a/src/debugger/gui/DelayQueueWidget.cxx b/src/debugger/gui/DelayQueueWidget.cxx index 281947e22..16e58d1ba 100644 --- a/src/debugger/gui/DelayQueueWidget.cxx +++ b/src/debugger/gui/DelayQueueWidget.cxx @@ -90,6 +90,7 @@ void DelayQueueWidget::loadConfig() { void DelayQueueWidget::drawWidget(bool hilite) { FBSurface& surface = _boss->dialog().surface(); + bool onTop = _boss->dialog().isOnTop(); int y = _y, x = _x, @@ -101,14 +102,14 @@ void DelayQueueWidget::drawWidget(bool hilite) y += 1; x += 1; w -= 1; - surface.fillRect(x, y, w - 1, _h - 2, kDlgColor); + surface.fillRect(x, y, w - 1, _h - 2, onTop ? kDlgColor : _bgcolorlo); y += 2; x += 2; w -= 3; for (const auto& line : myLines) { - surface.drawString(_font, line, x, y, w, _textcolor); + surface.drawString(_font, line, x, y, w, onTop ? _textcolor : kColor); y += lineHeight; } } diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index 8bc7d17c5..67662a41b 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -869,6 +869,7 @@ void PromptWidget::drawCaret() { //cerr << "PromptWidget::drawCaret()\n"; FBSurface& s = _boss->dialog().surface(); + bool onTop = _boss->dialog().isOnTop(); int line = _currentPos / _lineWidth; @@ -881,7 +882,7 @@ void PromptWidget::drawCaret() int y = _y + displayLine * _kConsoleLineHeight; char c = buffer(_currentPos); - s.fillRect(x, y, _kConsoleCharWidth, _kConsoleLineHeight, kTextColor); + s.fillRect(x, y, _kConsoleCharWidth, _kConsoleLineHeight, onTop ? kTextColor : kColor); s.drawChar(_font, c, x, y + 2, kBGColor); } diff --git a/src/debugger/gui/ToggleBitWidget.cxx b/src/debugger/gui/ToggleBitWidget.cxx index 80d1814eb..d97432e87 100644 --- a/src/debugger/gui/ToggleBitWidget.cxx +++ b/src/debugger/gui/ToggleBitWidget.cxx @@ -30,6 +30,7 @@ ToggleBitWidget::ToggleBitWidget(GuiObject* boss, const GUI::Font& font, { _rowHeight = font.getLineHeight(); _colWidth = colchars * font.getMaxCharWidth() + 8; + _bgcolorlo = kDlgColor; // Make sure all lists contain some default values int size = _rows * _cols; @@ -116,17 +117,17 @@ void ToggleBitWidget::drawWidget(bool hilite) if(_changedList[pos]) { s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, - onTop ? uInt32(kDbgChangedColor) : _bgcolorlo); + onTop ? kDbgChangedColor : _bgcolorlo); s.drawString(_font, buffer, x, y, _colWidth, onTop ? kDbgChangedTextColor : kColor); } else s.drawString(_font, buffer, x, y, _colWidth, - onTop ? textColor : uInt32(kColor)); + onTop ? textColor : kColor); } else { - s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kBGColorHi); - s.drawString(_font, buffer, x, y, _colWidth, kTextColor); + s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, onTop ? kBGColorHi : kDlgColor); + s.drawString(_font, buffer, x, y, _colWidth, onTop ? kTextColor : kColor); } } } diff --git a/src/debugger/gui/TogglePixelWidget.cxx b/src/debugger/gui/TogglePixelWidget.cxx index 929c43200..c8cba9b84 100644 --- a/src/debugger/gui/TogglePixelWidget.cxx +++ b/src/debugger/gui/TogglePixelWidget.cxx @@ -121,6 +121,7 @@ void TogglePixelWidget::drawWidget(bool hilite) { //cerr << "TogglePixelWidget::drawWidget\n"; FBSurface& s = dialog().surface(); + bool onTop = _boss->dialog().isOnTop(); int row, col; s.frameRect(_x, _y, _w, _h, hilite && isEnabled() && isEditable() ? kWidColorHi : kColor); @@ -148,7 +149,7 @@ void TogglePixelWidget::drawWidget(bool hilite) // Either draw the pixel in given color, or erase (show background) s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, - _stateList[pos] ? _pixelColor : _backgroundColor); + _stateList[pos] ? onTop ? _pixelColor : kColor : onTop ? _backgroundColor : kBGColorLo); if (_changedList[pos]) s.frameRect(x - 3, y - 1, _colWidth - 1, _rowHeight - 1, kDbgChangedColor); } diff --git a/src/gui/ColorWidget.cxx b/src/gui/ColorWidget.cxx index e5a49a939..93cd73359 100644 --- a/src/gui/ColorWidget.cxx +++ b/src/gui/ColorWidget.cxx @@ -52,7 +52,7 @@ void ColorWidget::drawWidget(bool hilite) s.frameRect(_x, _y, _w, _h + 1, kColor); // Show the currently selected color - s.fillRect(_x+1, _y+1, _w-2, _h-1, onTop ? isEnabled() ? _color : kWidColor : kDlgColor); + s.fillRect(_x+1, _y+1, _w-2, _h-1, onTop ? isEnabled() ? _color : kWidColor : kBGColorLo); // Cross out the grid? if(_crossGrid) diff --git a/src/gui/ScrollBarWidget.cxx b/src/gui/ScrollBarWidget.cxx index 3370eac79..3cca35326 100644 --- a/src/gui/ScrollBarWidget.cxx +++ b/src/gui/ScrollBarWidget.cxx @@ -261,14 +261,18 @@ void ScrollBarWidget::drawWidget(bool hilite) // Up arrow if(hilite && _part == kUpArrowPart) s.fillRect(_x + 1, _y + 1, _w - 2, UP_DOWN_BOX_HEIGHT - 2, kScrollColor); - s.drawBitmap(up_arrow, _x+4, _y+5, isSinglePage ? kColor : - (hilite && _part == kUpArrowPart) ? kWidColor : kTextColor, 8); + s.drawBitmap(up_arrow, _x+4, _y+5, + onTop + ? isSinglePage ? kColor : (hilite && _part == kUpArrowPart) ? kWidColor : kTextColor + : kColor, 8); // Down arrow if(hilite && _part == kDownArrowPart) s.fillRect(_x + 1, bottomY - UP_DOWN_BOX_HEIGHT + 1, _w - 2, UP_DOWN_BOX_HEIGHT - 2, kScrollColor); - s.drawBitmap(down_arrow, _x+4, bottomY - UP_DOWN_BOX_HEIGHT + 5, isSinglePage ? kColor : - (hilite && _part == kDownArrowPart) ? kWidColor : kTextColor, 8); + s.drawBitmap(down_arrow, _x+4, bottomY - UP_DOWN_BOX_HEIGHT + 5, + onTop + ? isSinglePage ? kColor : (hilite && _part == kDownArrowPart) ? kWidColor : kTextColor + : kColor, 8); // Slider if(!isSinglePage) From 3869c8770cb0f128ee35b55ec731e193beac4841 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 7 Aug 2018 19:55:11 +0200 Subject: [PATCH 12/25] minor fix for darkened games list --- src/gui/StringListWidget.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/StringListWidget.cxx b/src/gui/StringListWidget.cxx index dc53b427d..3f1b40526 100644 --- a/src/gui/StringListWidget.cxx +++ b/src/gui/StringListWidget.cxx @@ -62,7 +62,7 @@ void StringListWidget::drawWidget(bool hilite) int i, pos, len = int(_list.size()); // Draw a thin frame around the list. - s.frameRect(_x, _y, _w + 1, _h, hilite && _hilite ? kWidColorHi : kColor); + s.frameRect(_x, _y, _w + 1, _h, onTop && hilite && _hilite ? kWidColorHi : kColor); // Draw the list items for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++) @@ -71,7 +71,7 @@ void StringListWidget::drawWidget(bool hilite) uInt32 textColor = onTop ? kTextColor : kShadowColor; // Draw the selected item inverted, on a highlighted background. - if (_selectedItem == pos && _hilite) + if (onTop && _selectedItem == pos && _hilite) { if(_hasFocus && !_editMode) { From f7d09c772d29719994d262c286ba96ea124f3be1 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 8 Aug 2018 09:28:03 +0200 Subject: [PATCH 13/25] Fixes #339 --- src/debugger/TIADebug.cxx | 4 ++-- src/emucore/tia/TIA.cxx | 5 ++++- src/emucore/tia/TIA.hxx | 11 ++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/debugger/TIADebug.cxx b/src/debugger/TIADebug.cxx index 4d9c19c8c..9d9741a65 100644 --- a/src/debugger/TIADebug.cxx +++ b/src/debugger/TIADebug.cxx @@ -54,7 +54,7 @@ const DebuggerState& TIADebug::getState() myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::P0]); myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::P1]); myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::PF]); - myState.fixedCols.push_back(TIA::FixedColor::BK_GREY); + myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::BK]); myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::M0]); myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::M1]); myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::BL]); @@ -1025,7 +1025,7 @@ string TIADebug::debugColors() const << " Playfield\n" << " " << myTIA.myFixedColorNames[TIA::BL] << " " << colorSwatch(myTIA.myFixedColorPalette[mode][TIA::BL]) << " Ball\n" - << " Grey " << colorSwatch(TIA::FixedColor::BK_GREY) + << " Grey " << colorSwatch(myTIA.myFixedColorPalette[mode][TIA::BK]) << " Background\n" << " White " << colorSwatch(TIA::FixedColor::HBLANK_WHITE) << " HMOVE\n"; diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index c4f27b8ca..617de2b85 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -984,7 +984,7 @@ bool TIA::enableFixedColors(bool enable) myPlayer1.setDebugColor(myFixedColorPalette[layout][FixedObject::P1]); myBall.setDebugColor(myFixedColorPalette[layout][FixedObject::BL]); myPlayfield.setDebugColor(myFixedColorPalette[layout][FixedObject::PF]); - myBackground.setDebugColor(FixedColor::BK_GREY); + myBackground.setDebugColor(myFixedColorPalette[layout][FixedObject::BK]); myMissile0.enableDebugColors(enable); myMissile1.enableDebugColors(enable); @@ -1042,6 +1042,9 @@ bool TIA::setFixedColorPalette(const string& colors) break; } } + myFixedColorPalette[0][TIA::BK] = FixedColor::NTSC_GREY; + myFixedColorPalette[1][TIA::BK] = FixedColor::PAL_GREY; + // If already in fixed debug colours mode, update the current palette if(usingFixedColors()) diff --git a/src/emucore/tia/TIA.hxx b/src/emucore/tia/TIA.hxx index 11067b56b..dc78c0477 100644 --- a/src/emucore/tia/TIA.hxx +++ b/src/emucore/tia/TIA.hxx @@ -77,8 +77,9 @@ class TIA : public Device NTSC_ORANGE = 0x38, NTSC_YELLOW = 0x1c, NTSC_GREEN = 0xc4, - NTSC_BLUE = 0x9e, + NTSC_BLUE = 0x9c, NTSC_PURPLE = 0x66, + NTSC_GREY = 0x04, PAL_RED = 0x62, PAL_ORANGE = 0x4a, @@ -86,8 +87,8 @@ class TIA : public Device PAL_GREEN = 0x34, PAL_BLUE = 0xbc, PAL_PURPLE = 0xa6, + PAL_GREY = 0x06, - BK_GREY = 0x0a, HBLANK_WHITE = 0x0e }; @@ -500,9 +501,9 @@ class TIA : public Device /** * Palette and indices for fixed debug colors. */ - enum FixedObject { P0, M0, P1, M1, PF, BL }; - FixedColor myFixedColorPalette[2][6]; - string myFixedColorNames[6]; + enum FixedObject { P0, M0, P1, M1, PF, BL, BK }; + FixedColor myFixedColorPalette[2][7]; + string myFixedColorNames[7]; private: From 8298ad4d26367c130084e99ee91725c7e33ac8b5 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Wed, 8 Aug 2018 13:09:10 -0230 Subject: [PATCH 14/25] Fixed inconsistency in passing color data to parameters. - Now uses 'ColorId' as the datatype; this is currently mapped to uInt32, but can change in the future if required - Eliminates needless and annoying casts in various places; all colors are now 'ColorId' type --- src/common/FBSurfaceSDL2.cxx | 2 +- src/common/FBSurfaceSDL2.hxx | 2 +- src/debugger/gui/DataGridWidget.cxx | 6 +- src/debugger/gui/PromptWidget.cxx | 14 ++--- src/debugger/gui/RomListWidget.cxx | 6 +- src/debugger/gui/TiaZoomWidget.cxx | 2 +- src/debugger/gui/ToggleBitWidget.cxx | 2 +- src/debugger/gui/TogglePixelWidget.hxx | 10 ++-- src/emucore/FBSurface.cxx | 26 ++++---- src/emucore/FBSurface.hxx | 24 ++++---- src/emucore/FrameBuffer.cxx | 7 +-- src/emucore/FrameBuffer.hxx | 4 +- src/emucore/FrameBufferConstants.hxx | 83 ++++++++++++++------------ src/gui/AboutDialog.cxx | 2 +- src/gui/CheckListWidget.cxx | 4 +- src/gui/ColorWidget.cxx | 4 +- src/gui/ColorWidget.hxx | 6 +- src/gui/ContextMenu.hxx | 2 +- src/gui/DeveloperDialog.cxx | 2 +- src/gui/Dialog.hxx | 2 +- src/gui/EditTextWidget.cxx | 4 +- src/gui/PopUpWidget.cxx | 2 +- src/gui/RadioButtonWidget.cxx | 2 +- src/gui/StringListWidget.cxx | 2 +- src/gui/TabWidget.cxx | 2 +- src/gui/TimeLineWidget.cxx | 2 +- src/gui/Widget.cxx | 12 ++-- src/gui/Widget.hxx | 30 +++++----- 28 files changed, 134 insertions(+), 132 deletions(-) diff --git a/src/common/FBSurfaceSDL2.cxx b/src/common/FBSurfaceSDL2.cxx index f0ff4b4da..c64b64556 100644 --- a/src/common/FBSurfaceSDL2.cxx +++ b/src/common/FBSurfaceSDL2.cxx @@ -46,7 +46,7 @@ FBSurfaceSDL2::~FBSurfaceSDL2() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurfaceSDL2::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, uInt32 color) +void FBSurfaceSDL2::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, ColorId color) { // Fill the rectangle SDL_Rect tmp; diff --git a/src/common/FBSurfaceSDL2.hxx b/src/common/FBSurfaceSDL2.hxx index e36dccf99..6e5bd8a2a 100644 --- a/src/common/FBSurfaceSDL2.hxx +++ b/src/common/FBSurfaceSDL2.hxx @@ -38,7 +38,7 @@ class FBSurfaceSDL2 : public FBSurface // Most of the surface drawing primitives are implemented in FBSurface; // the ones implemented here use SDL-specific code for extra performance // - void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, uInt32 color) override; + void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, ColorId color) override; // With hardware surfaces, it's faster to just update the entire surface void setDirty() override { mySurfaceIsDirty = true; } diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 43359e6bc..43a424df5 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -615,7 +615,7 @@ void DataGridWidget::drawWidget(bool hilite) int x = _x + 4 + (col * _colWidth); int y = _y + 2 + (row * _rowHeight); int pos = row*_cols + col; - uInt32 textColor = onTop ? kTextColor : kColor; + ColorId textColor = onTop ? kTextColor : kColor; // Draw the selected item inverted, on a highlighted background. if (_currentRow == row && _currentCol == col && @@ -636,12 +636,12 @@ void DataGridWidget::drawWidget(bool hilite) if(_changedList[pos]) { s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, - onTop ? uInt32(kDbgChangedColor) : _bgcolorlo); + onTop ? kDbgChangedColor : _bgcolorlo); if(_hiliteList[pos]) textColor = kDbgColorHi; else - textColor = onTop ? uInt32(kDbgChangedTextColor) : textColor; + textColor = onTop ? kDbgChangedTextColor : textColor; } else if(_hiliteList[pos]) textColor = kDbgColorHi; diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index 67662a41b..e125de801 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -72,7 +72,7 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font, void PromptWidget::drawWidget(bool hilite) { //cerr << "PromptWidget::drawWidget\n"; - uInt32 fgcolor, bgcolor; + ColorId fgcolor, bgcolor; FBSurface& s = _boss->dialog().surface(); bool onTop = _boss->dialog().isOnTop(); @@ -90,13 +90,13 @@ void PromptWidget::drawWidget(bool hilite) if(c & (1 << 17)) // inverse video flag { fgcolor = _bgcolor; - bgcolor = (c & 0x1ffff) >> 8; + bgcolor = ColorId((c & 0x1ffff) >> 8); s.fillRect(x, y, _kConsoleCharWidth, _kConsoleCharHeight, bgcolor); } else - fgcolor = c >> 8; + fgcolor = ColorId(c >> 8); - s.drawChar(_font, c & 0x7f, x, y, onTop ? fgcolor : uInt32(kColor)); + s.drawChar(_font, c & 0x7f, x, y, onTop ? fgcolor : kColor); x += _kConsoleCharWidth; } y += _kConsoleLineHeight; @@ -833,13 +833,11 @@ void PromptWidget::putcharIntern(int c) nextLine(); else if(c & 0x80) { // set foreground color to TIA color // don't print or advance cursor - // there are only 128 TIA colors, but - // OverlayColor contains 256 of them - _textcolor = (c & 0x7f) << 1; + _textcolor = ColorId((c & 0x7f) << 1); } else if(c && c < 0x1e) { // first actual character is large dash // More colors (the regular GUI ones) - _textcolor = c + 0x100; + _textcolor = ColorId(c + 0x100); } else if(c == 0x7f) { // toggle inverse video (DEL char) _inverse = !_inverse; diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 481560889..a65af0641 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -468,7 +468,7 @@ void RomListWidget::drawWidget(bool hilite) bool onTop = _boss->dialog().isOnTop(); const CartDebug::DisassemblyList& dlist = myDisasm->list; int i, pos, xpos, ypos, len = int(dlist.size()); - uInt32 textColor = onTop ? kTextColor : kColor; + ColorId textColor = onTop ? kTextColor : kColor; const GUI::Rect& r = getEditRect(); const GUI::Rect& l = getLineRect(); @@ -489,7 +489,7 @@ void RomListWidget::drawWidget(bool hilite) xpos = _x + CheckboxWidget::boxSize() + 10; ypos = _y + 2; for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++, ypos += _fontHeight) { - uInt32 bytesColor = textColor; + ColorId bytesColor = textColor; // Draw checkboxes for correct lines (takes scrolling into account) myCheckList[i]->setState(myBPState->isSet(dlist[pos].address)); @@ -514,7 +514,7 @@ void RomListWidget::drawWidget(bool hilite) // Draw labels s.drawString(_font, dlist[pos].label, xpos, ypos, _labelWidth, - dlist[pos].hllabel ? textColor : uInt32(kColor)); + dlist[pos].hllabel ? textColor : kColor); // Bytes are only editable if they represent code, graphics, or accessible data // Otherwise, the disassembly should get all remaining space diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index 96663515d..6da1f061c 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -273,7 +273,7 @@ void TiaZoomWidget::drawWidget(bool hilite) for(x = myXOff, col = 0; x < myNumCols+myXOff; ++x, col += wzoom) { uInt32 idx = y*width + x; - uInt32 color = currentFrame[idx] | (idx > scanoffset ? 1 : 0); + ColorId color = ColorId(currentFrame[idx] | (idx > scanoffset ? 1 : 0)); s.fillRect(_x + col + 1, _y + row + 1, wzoom, hzoom, color); } } diff --git a/src/debugger/gui/ToggleBitWidget.cxx b/src/debugger/gui/ToggleBitWidget.cxx index d97432e87..972990ee7 100644 --- a/src/debugger/gui/ToggleBitWidget.cxx +++ b/src/debugger/gui/ToggleBitWidget.cxx @@ -94,7 +94,7 @@ void ToggleBitWidget::drawWidget(bool hilite) { for (col = 0; col < _cols; col++) { - uInt32 textColor = kTextColor; + ColorId textColor = kTextColor; int x = _x + 4 + (col * _colWidth); int y = _y + 2 + (row * _rowHeight); int pos = row*_cols + col; diff --git a/src/debugger/gui/TogglePixelWidget.hxx b/src/debugger/gui/TogglePixelWidget.hxx index f224c560a..e176bb76a 100644 --- a/src/debugger/gui/TogglePixelWidget.hxx +++ b/src/debugger/gui/TogglePixelWidget.hxx @@ -28,11 +28,11 @@ class TogglePixelWidget : public ToggleWidget int x, int y, int cols, int rows); virtual ~TogglePixelWidget() = default; - void setColor(int color) { - _pixelColor = (color >= 0 && color <= kNumColors) ? color : kDlgColor; + void setColor(ColorId color) { + _pixelColor = color <= kNumColors ? color : kDlgColor; } - void setBackgroundColor(int color) { - _backgroundColor = (color >= 0 && color <= kNumColors) ? color : kDlgColor; + void setBackgroundColor(ColorId color) { + _backgroundColor = color <= kNumColors ? color : kDlgColor; } void setState(const BoolArray& state); @@ -42,7 +42,7 @@ class TogglePixelWidget : public ToggleWidget void setCrossed(bool enable) { _crossBits = enable; } private: - int _pixelColor, _backgroundColor; + ColorId _pixelColor, _backgroundColor; bool _swapBits; bool _crossBits; diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index a1daac66f..9a457de5b 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -60,7 +60,7 @@ void FBSurface::readPixels(uInt8* buffer, uInt32 pitch, const GUI::Rect& rect) c } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurface::pixel(uInt32 x, uInt32 y, uInt32 color) +void FBSurface::pixel(uInt32 x, uInt32 y, ColorId color) { uInt32* buffer = myPixels + y * myPitch + x; @@ -68,7 +68,7 @@ void FBSurface::pixel(uInt32 x, uInt32 y, uInt32 color) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurface::line(uInt32 x, uInt32 y, uInt32 x2, uInt32 y2, uInt32 color) +void FBSurface::line(uInt32 x, uInt32 y, uInt32 x2, uInt32 y2, ColorId color) { // draw line using Bresenham algorithm Int32 dx = (x2 - x); @@ -127,7 +127,7 @@ void FBSurface::line(uInt32 x, uInt32 y, uInt32 x2, uInt32 y2, uInt32 color) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurface::hLine(uInt32 x, uInt32 y, uInt32 x2, uInt32 color) +void FBSurface::hLine(uInt32 x, uInt32 y, uInt32 x2, ColorId color) { uInt32* buffer = myPixels + y * myPitch + x; while(x++ <= x2) @@ -135,7 +135,7 @@ void FBSurface::hLine(uInt32 x, uInt32 y, uInt32 x2, uInt32 color) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurface::vLine(uInt32 x, uInt32 y, uInt32 y2, uInt32 color) +void FBSurface::vLine(uInt32 x, uInt32 y, uInt32 y2, ColorId color) { uInt32* buffer = static_cast(myPixels + y * myPitch + x); while(y++ <= y2) @@ -146,7 +146,7 @@ void FBSurface::vLine(uInt32 x, uInt32 y, uInt32 y2, uInt32 color) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurface::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, uInt32 color) +void FBSurface::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, ColorId color) { while(h--) hLine(x, y+h, x+w-1, color); @@ -154,9 +154,9 @@ void FBSurface::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, uInt32 color) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurface::drawChar(const GUI::Font& font, uInt8 chr, - uInt32 tx, uInt32 ty, uInt32 color, uInt32 shadowColor) + uInt32 tx, uInt32 ty, ColorId color, ColorId shadowColor) { - if(shadowColor != 0) + if(shadowColor != kNone) { drawChar(font, chr, tx + 1, ty + 0, shadowColor); drawChar(font, chr, tx + 0, ty + 1, shadowColor); @@ -208,14 +208,14 @@ void FBSurface::drawChar(const GUI::Font& font, uInt8 chr, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurface::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty, - uInt32 color, uInt32 h) + ColorId color, uInt32 h) { drawBitmap(bitmap, tx, ty, color, h, h); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurface::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty, - uInt32 color, uInt32 w, uInt32 h) + ColorId color, uInt32 w, uInt32 h) { uInt32* buffer = myPixels + ty * myPitch + tx; @@ -241,7 +241,7 @@ void FBSurface::drawPixels(uInt32* data, uInt32 tx, uInt32 ty, uInt32 numpixels) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurface::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - uInt32 colorA, uInt32 colorB) + ColorId colorA, ColorId colorB) { hLine(x + 1, y, x + w - 2, colorA); hLine(x, y + 1, x + w - 1, colorA); @@ -256,7 +256,7 @@ void FBSurface::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurface::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - uInt32 color, FrameStyle style) + ColorId color, FrameStyle style) { switch(style) { @@ -285,8 +285,8 @@ void FBSurface::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurface::drawString(const GUI::Font& font, const string& s, int x, int y, int w, - uInt32 color, TextAlign align, - int deltax, bool useEllipsis, uInt32 shadowColor) + ColorId color, TextAlign align, + int deltax, bool useEllipsis, ColorId shadowColor) { const string ELLIPSIS = "\x1d"; // "..." const int leftX = x, rightX = x + w; diff --git a/src/emucore/FBSurface.hxx b/src/emucore/FBSurface.hxx index 73999cf25..dec80a17a 100644 --- a/src/emucore/FBSurface.hxx +++ b/src/emucore/FBSurface.hxx @@ -79,7 +79,7 @@ class FBSurface @param y The y coordinate @param color The color of the line */ - virtual void pixel(uInt32 x, uInt32 y, uInt32 color); + virtual void pixel(uInt32 x, uInt32 y, ColorId color); /** This method should be called to draw a line. @@ -90,7 +90,7 @@ class FBSurface @param y2 The second y coordinate @param color The color of the line */ - virtual void line(uInt32 x, uInt32 y, uInt32 x2, uInt32 y2, uInt32 color); + virtual void line(uInt32 x, uInt32 y, uInt32 x2, uInt32 y2, ColorId color); /** This method should be called to draw a horizontal line. @@ -100,7 +100,7 @@ class FBSurface @param x2 The second x coordinate @param color The color of the line */ - virtual void hLine(uInt32 x, uInt32 y, uInt32 x2, uInt32 color); + virtual void hLine(uInt32 x, uInt32 y, uInt32 x2, ColorId color); /** This method should be called to draw a vertical line. @@ -110,7 +110,7 @@ class FBSurface @param y2 The second y coordinate @param color The color of the line */ - virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, uInt32 color); + virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, ColorId color); /** This method should be called to draw a filled rectangle. @@ -122,7 +122,7 @@ class FBSurface @param color The fill color of the rectangle */ virtual void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - uInt32 color); + ColorId color); /** This method should be called to draw the specified character. @@ -134,7 +134,7 @@ class FBSurface @param color The color of the character */ virtual void drawChar(const GUI::Font& font, uInt8 c, uInt32 x, uInt32 y, - uInt32 color, uInt32 shadowColor = 0); + ColorId color, ColorId shadowColor = kNone); /** This method should be called to draw the bitmap image. @@ -145,7 +145,7 @@ class FBSurface @param color The color of the bitmap @param h The height of the data image */ - virtual void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, uInt32 color, + virtual void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, ColorId color, uInt32 h = 8); /** @@ -158,7 +158,7 @@ class FBSurface @param w The width of the data image @param h The height of the data image */ - virtual void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, uInt32 color, + virtual void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, ColorId color, uInt32 w, uInt32 h); /** @@ -185,7 +185,7 @@ class FBSurface @param colorB Darker color for inside line. */ virtual void box(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - uInt32 colorA, uInt32 colorB); + ColorId colorA, ColorId colorB); /** This method should be called to draw a framed rectangle with @@ -199,7 +199,7 @@ class FBSurface @param style The 'FrameStyle' to use for the surrounding frame */ virtual void frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - uInt32 color, FrameStyle style = FrameStyle::Solid); + ColorId color, FrameStyle style = FrameStyle::Solid); /** This method should be called to draw the specified string. @@ -216,8 +216,8 @@ class FBSurface */ virtual void drawString( const GUI::Font& font, const string& s, int x, int y, int w, - uInt32 color, TextAlign align = TextAlign::Left, - int deltax = 0, bool useEllipsis = true, uInt32 shadowColor = 0); + ColorId color, TextAlign align = TextAlign::Left, + int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone); ////////////////////////////////////////////////////////////////////////// // Note: The following methods are FBSurface-specific, and must be diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index fe73012ca..bde56ac69 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -138,7 +138,7 @@ bool FrameBuffer::initialize() else if(myOSystem.settings().getString("uipalette") == "light") palID = 2; - for(int i = 0, j = 256; i < kNumColors-256; ++i, ++j) + for(uInt32 i = 0, j = 256; i < kNumColors-256; ++i, ++j) { uInt8 r = (ourGUIColors[palID][i] >> 16) & 0xff; uInt8 g = (ourGUIColors[palID][i] >> 8) & 0xff; @@ -413,7 +413,6 @@ void FrameBuffer::showMessage(const string& message, MessagePosition position, void FrameBuffer::drawFrameStats(float framesPerSecond) { const ConsoleInfo& info = myOSystem.console().about(); - uInt32 color; int xPos = 2, yPos = 0; const int dy = font().getFontHeight() + 2; @@ -422,8 +421,8 @@ void FrameBuffer::drawFrameStats(float framesPerSecond) myStatsMsg.surface->invalidate(); // draw scanlines - color = myOSystem.console().tia().frameBufferScanlinesLastFrame() != myLastScanlines ? - uInt32(kDbgColorRed) : myStatsMsg.color; + ColorId color = myOSystem.console().tia().frameBufferScanlinesLastFrame() != myLastScanlines ? + kDbgColorRed : myStatsMsg.color; ss << myOSystem.console().tia().frameBufferScanlinesLastFrame() diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index a85d0fedf..bd91d890a 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -518,13 +518,13 @@ class FrameBuffer int counter; int x, y, w, h; MessagePosition position; - uInt32 color; + ColorId color; shared_ptr surface; bool enabled; Message() : counter(-1), x(0), y(0), w(0), h(0), position(MessagePosition::BottomCenter), - color(0), enabled(false) { } + color(kNone), enabled(false) { } }; Message myMsg; Message myStatsMsg; diff --git a/src/emucore/FrameBufferConstants.hxx b/src/emucore/FrameBufferConstants.hxx index 081d7cd68..e64a26371 100644 --- a/src/emucore/FrameBufferConstants.hxx +++ b/src/emucore/FrameBufferConstants.hxx @@ -18,6 +18,8 @@ #ifndef FRAMEBUFFER_CONSTANTS_HXX #define FRAMEBUFFER_CONSTANTS_HXX +#include "bspf.hxx" + // Return values for initialization of framebuffer window enum class FBInitStatus { Success, @@ -39,47 +41,50 @@ enum class MessagePosition { BottomRight }; -// TODO - make this 'enum class' // Colors indices to use for the various GUI elements -enum { +// Abstract away what a color actually is, so we can easily change it in +// the future, if necessary +using ColorId = uInt32; +static constexpr ColorId kColor = 256, - kBGColor, - kBGColorLo, - kBGColorHi, - kShadowColor, - kTextColor, - kTextColorHi, - kTextColorEm, - kTextColorInv, - kDlgColor, - kWidColor, - kWidColorHi, - kWidFrameColor, - kBtnColor, - kBtnColorHi, - kBtnBorderColor, - kBtnBorderColorHi, - kBtnTextColor, - kBtnTextColorHi, - kCheckColor, - kScrollColor, - kScrollColorHi, - kSliderColor, - kSliderColorHi, - kSliderBGColor, - kSliderBGColorHi, - kSliderBGColorLo, - kDbgChangedColor, - kDbgChangedTextColor, - kDbgColorHi, - kDbgColorRed, - kColorInfo, - kColorTitleBar, - kColorTitleText, - kColorTitleBarLo, - kColorTitleTextLo, - kNumColors -}; + kBGColor = 257, + kBGColorLo = 258, + kBGColorHi = 259, + kShadowColor = 260, + kTextColor = 261, + kTextColorHi = 262, + kTextColorEm = 263, + kTextColorInv = 264, + kDlgColor = 265, + kWidColor = 266, + kWidColorHi = 267, + kWidFrameColor = 268, + kBtnColor = 269, + kBtnColorHi = 270, + kBtnBorderColor = 271, + kBtnBorderColorHi = 272, + kBtnTextColor = 273, + kBtnTextColorHi = 274, + kCheckColor = 275, + kScrollColor = 276, + kScrollColorHi = 277, + kSliderColor = 278, + kSliderColorHi = 279, + kSliderBGColor = 280, + kSliderBGColorHi = 281, + kSliderBGColorLo = 282, + kDbgChangedColor = 283, + kDbgChangedTextColor = 284, + kDbgColorHi = 285, + kDbgColorRed = 286, + kColorInfo = 287, + kColorTitleBar = 288, + kColorTitleText = 289, + kColorTitleBarLo = 290, + kColorTitleTextLo = 291, + kNumColors = 292, + kNone = 0 // placeholder to represent default/no color +; // Text alignment modes for drawString() enum class TextAlign { diff --git a/src/gui/AboutDialog.cxx b/src/gui/AboutDialog.cxx index 5b9e722e1..85783a5d6 100644 --- a/src/gui/AboutDialog.cxx +++ b/src/gui/AboutDialog.cxx @@ -169,7 +169,7 @@ void AboutDialog::displayInfo() { const char* str = myDescStr[i].c_str(); TextAlign align = TextAlign::Center; - uInt32 color = kTextColor; + ColorId color = kTextColor; while (str[0] == '\\') { diff --git a/src/gui/CheckListWidget.cxx b/src/gui/CheckListWidget.cxx index 43803a970..e2cc6eba5 100644 --- a/src/gui/CheckListWidget.cxx +++ b/src/gui/CheckListWidget.cxx @@ -112,7 +112,7 @@ void CheckListWidget::drawWidget(bool hilite) _checkList[i]->draw(); const int y = _y + 2 + _fontHeight * i + 2; - uInt32 textColor = kTextColor; + ColorId textColor = kTextColor; GUI::Rect r(getEditRect()); @@ -138,7 +138,7 @@ void CheckListWidget::drawWidget(bool hilite) } else s.drawString(_font, _list[pos], _x + r.left, y, r.width(), - onTop ? textColor : uInt32(kColor)); + onTop ? textColor : kColor); } // Only draw the caret while editing, and if it's in the current viewport diff --git a/src/gui/ColorWidget.cxx b/src/gui/ColorWidget.cxx index 93cd73359..b35e804a7 100644 --- a/src/gui/ColorWidget.cxx +++ b/src/gui/ColorWidget.cxx @@ -28,7 +28,7 @@ ColorWidget::ColorWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h, int cmd) : Widget(boss, font, x, y, w, h), CommandSender(boss), - _color(0), + _color(kNone), _cmd(cmd), _crossGrid(false) { @@ -36,7 +36,7 @@ ColorWidget::ColorWidget(GuiObject* boss, const GUI::Font& font, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ColorWidget::setColor(int color) +void ColorWidget::setColor(ColorId color) { _color = color; setDirty(); diff --git a/src/gui/ColorWidget.hxx b/src/gui/ColorWidget.hxx index 97bffd9a4..142b484d0 100644 --- a/src/gui/ColorWidget.hxx +++ b/src/gui/ColorWidget.hxx @@ -39,8 +39,8 @@ class ColorWidget : public Widget, public CommandSender int x, int y, int w, int h, int cmd = 0); virtual ~ColorWidget() = default; - void setColor(int color); - int getColor() const { return _color; } + void setColor(ColorId color); + ColorId getColor() const { return _color; } void setCrossed(bool enable) { _crossGrid = enable; } @@ -48,7 +48,7 @@ class ColorWidget : public Widget, public CommandSender void drawWidget(bool hilite) override; protected: - int _color; + ColorId _color; int _cmd; bool _crossGrid; diff --git a/src/gui/ContextMenu.hxx b/src/gui/ContextMenu.hxx index 9118f56e0..18ac03a0f 100644 --- a/src/gui/ContextMenu.hxx +++ b/src/gui/ContextMenu.hxx @@ -118,7 +118,7 @@ class ContextMenu : public Dialog, public CommandSender int _selectedOffset, _selectedItem; bool _showScroll; bool _isScrolling; - uInt32 _scrollUpColor, _scrollDnColor; + ColorId _scrollUpColor, _scrollDnColor; int _cmd; diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index 50f04ad76..b1dde505d 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -1090,7 +1090,7 @@ void DeveloperDialog::handleDebugColours(int idx, int color) return; } - static constexpr int dbg_color[2][DEBUG_COLORS] = { + static constexpr ColorId dbg_color[2][DEBUG_COLORS] = { { TIA::FixedColor::NTSC_RED, TIA::FixedColor::NTSC_ORANGE, diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index 444848ac1..098cbcb8c 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -55,7 +55,7 @@ class Dialog : public GuiObject void close(); bool isVisible() const override { return _visible; } - bool isOnTop() { return _onTop; } + bool isOnTop() const { return _onTop; } virtual void center(); virtual void drawDialog(); diff --git a/src/gui/EditTextWidget.cxx b/src/gui/EditTextWidget.cxx index 919aba3e7..42d64cd9f 100644 --- a/src/gui/EditTextWidget.cxx +++ b/src/gui/EditTextWidget.cxx @@ -95,8 +95,8 @@ void EditTextWidget::drawWidget(bool hilite) adjustOffset(); s.drawString(_font, editString(), _x + 2, _y + 2, getEditRect().width(), _changed && onTop - ? uInt32(kDbgChangedTextColor) - : onTop ? _textcolor : uInt32(kColor), + ? kDbgChangedTextColor + : onTop ? _textcolor : kColor, TextAlign::Left, -_editScrollOffset, false); // Draw the caret diff --git a/src/gui/PopUpWidget.cxx b/src/gui/PopUpWidget.cxx index 8b2b4b6df..f4aab1194 100644 --- a/src/gui/PopUpWidget.cxx +++ b/src/gui/PopUpWidget.cxx @@ -206,7 +206,7 @@ void PopUpWidget::drawWidget(bool hilite) // Draw the label, if any if(_labelWidth > 0) s.drawString(_font, _label, _x, _y + myTextY, _labelWidth, - isEnabled() && onTop ? _textcolor : uInt32(kColor), TextAlign::Left); + isEnabled() && onTop ? _textcolor : kColor, TextAlign::Left); // Draw a thin frame around us. s.frameRect(x, _y, w, _h, isEnabled() && hilite ? kWidColorHi : kColor); diff --git a/src/gui/RadioButtonWidget.cxx b/src/gui/RadioButtonWidget.cxx index aa129461b..3c38ffbc5 100644 --- a/src/gui/RadioButtonWidget.cxx +++ b/src/gui/RadioButtonWidget.cxx @@ -164,7 +164,7 @@ void RadioButtonWidget::drawWidget(bool hilite) // Draw the inner bounding circle with enabled color s.drawBitmap(radio_img_innercircle, _x + 1, _y + _boxY + 1, isEnabled() - ? _bgcolor : uInt32(kColor), 12, 12); + ? _bgcolor : kColor, 12, 12); // draw state if(_state) diff --git a/src/gui/StringListWidget.cxx b/src/gui/StringListWidget.cxx index 3f1b40526..459ffa6c0 100644 --- a/src/gui/StringListWidget.cxx +++ b/src/gui/StringListWidget.cxx @@ -68,7 +68,7 @@ void StringListWidget::drawWidget(bool hilite) for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++) { const int y = _y + 2 + _fontHeight * i; - uInt32 textColor = onTop ? kTextColor : kShadowColor; + ColorId textColor = onTop ? kTextColor : kShadowColor; // Draw the selected item inverted, on a highlighted background. if (onTop && _selectedItem == pos && _hilite) diff --git a/src/gui/TabWidget.cxx b/src/gui/TabWidget.cxx index 0ac9cc217..c4a9ac6c5 100644 --- a/src/gui/TabWidget.cxx +++ b/src/gui/TabWidget.cxx @@ -268,7 +268,7 @@ void TabWidget::drawWidget(bool hilite) int i, x = _x + kTabLeftOffset; for (i = 0; i < int(_tabs.size()); ++i) { - uInt32 fontcolor = _tabs[i].enabled && onTop? kTextColor : kColor; + ColorId fontcolor = _tabs[i].enabled && onTop? kTextColor : kColor; int yOffset = (i == _activeTab) ? 0 : 1; s.fillRect(x, _y + 1, _tabWidth, _tabHeight - 1, (i == _activeTab) diff --git a/src/gui/TimeLineWidget.cxx b/src/gui/TimeLineWidget.cxx index a3074ab72..4a0d22b65 100644 --- a/src/gui/TimeLineWidget.cxx +++ b/src/gui/TimeLineWidget.cxx @@ -181,7 +181,7 @@ void TimeLineWidget::drawWidget(bool hilite) if(idx > 1) { int xt = x + valueToPos(idx - 1); - uInt32 color; + ColorId color = kNone; if(isEnabled()) { diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index e6acce094..aefff6d83 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -307,7 +307,7 @@ void Widget::setDirtyInChain(Widget* start) StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h, const string& text, TextAlign align, - uInt32 shadowColor) + ColorId shadowColor) : Widget(boss, font, x, y, w, h), _align(align) { @@ -326,7 +326,7 @@ StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font, StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font, int x, int y, const string& text, TextAlign align, - uInt32 shadowColor) + ColorId shadowColor) : StaticTextWidget(boss, font, x, y, font.getStringWidth(text), font.getLineHeight(), text, align, shadowColor) { @@ -356,7 +356,7 @@ void StaticTextWidget::drawWidget(bool hilite) FBSurface& s = _boss->dialog().surface(); bool onTop = _boss->dialog().isOnTop(); s.drawString(_font, _label, _x, _y, _w, - isEnabled() && onTop ? _textcolor : uInt32(kColor), _align, 0, true, _shadowcolor); + isEnabled() && onTop ? _textcolor : kColor, _align, 0, true, _shadowcolor); setDirty(); } @@ -646,8 +646,8 @@ void CheckboxWidget::drawWidget(bool hilite) s.frameRect(_x, _y + _boxY, 14, 14, onTop && hilite && isEnabled() && isEditable() ? kWidColorHi : kColor); // Do we draw a square or cross? s.fillRect(_x + 1, _y + _boxY + 1, 12, 12, - _changed ? onTop ? uInt32(kDbgChangedColor) : uInt32(kDlgColor) : - isEnabled() ? onTop ? _bgcolor : uInt32(kDlgColor) : uInt32(kColor)); + _changed ? onTop ? kDbgChangedColor : kDlgColor : + isEnabled() ? onTop ? _bgcolor : kDlgColor : kColor); if(_state) s.drawBitmap(_img, _x + 2, _y + _boxY + 2, onTop && isEnabled() ? hilite && isEditable() ? kWidColorHi : kCheckColor : kColor, 10); @@ -868,7 +868,7 @@ void SliderWidget::drawWidget(bool hilite) for(int i = 1; i < _numIntervals; ++i) { int xt = x + (_w - _labelWidth - _valueLabelGap - _valueLabelWidth) * i / _numIntervals - 1; - uInt32 color; + ColorId color = kNone; if(isEnabled()) { diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 62cb82404..5abb899f5 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -109,11 +109,11 @@ class Widget : public GuiObject virtual const GUI::Font& font() const { return _font; } - void setTextColor(uInt32 color) { _textcolor = color; setDirty(); } - void setTextColorHi(uInt32 color) { _textcolorhi = color; setDirty(); } - void setBGColor(uInt32 color) { _bgcolor = color; setDirty(); } - void setBGColorHi(uInt32 color) { _bgcolorhi = color; setDirty(); } - void setShadowColor(uInt32 color) { _shadowcolor = color; setDirty(); } + void setTextColor(ColorId color) { _textcolor = color; setDirty(); } + void setTextColorHi(ColorId color) { _textcolorhi = color; setDirty(); } + void setBGColor(ColorId color) { _bgcolor = color; setDirty(); } + void setBGColorHi(ColorId color) { _bgcolorhi = color; setDirty(); } + void setShadowColor(ColorId color) { _shadowcolor = color; setDirty(); } virtual void loadConfig() { } @@ -140,13 +140,13 @@ class Widget : public GuiObject bool _hasFocus; int _fontWidth; int _fontHeight; - uInt32 _bgcolor; - uInt32 _bgcolorhi; - uInt32 _bgcolorlo; - uInt32 _textcolor; - uInt32 _textcolorhi; - uInt32 _textcolorlo; - uInt32 _shadowcolor; + ColorId _bgcolor; + ColorId _bgcolorhi; + ColorId _bgcolorlo; + ColorId _textcolor; + ColorId _textcolorhi; + ColorId _textcolorlo; + ColorId _shadowcolor; public: static Widget* findWidgetInChain(Widget* start, int x, int y); @@ -183,11 +183,11 @@ class StaticTextWidget : public Widget StaticTextWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h, const string& text = "", TextAlign align = TextAlign::Left, - uInt32 shadowColor = 0); + ColorId shadowColor = kNone); StaticTextWidget(GuiObject* boss, const GUI::Font& font, int x, int y, const string& text = "", TextAlign align = TextAlign::Left, - uInt32 shadowColor = 0); + ColorId shadowColor = kNone); void setValue(int value); void setLabel(const string& label); void setAlign(TextAlign align) { _align = align; setDirty(); } @@ -293,7 +293,7 @@ class CheckboxWidget : public ButtonWidget bool _changed; uInt32* _img; - uInt32 _fillColor; + ColorId _fillColor; int _boxY; int _textY; From a4d923cbe664d1c9d8af1ac768e069d2dc70829f Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Wed, 8 Aug 2018 23:09:46 +0200 Subject: [PATCH 15/25] Remove high frequency artifacts from Lanczos resampling. Run the TIA signal through a high pass with 10Hz cutoff. --- src/common/audio/HighPass.cxx | 41 ++++++++++++++++++++++++++ src/common/audio/HighPass.hxx | 42 +++++++++++++++++++++++++++ src/common/audio/LanczosResampler.cxx | 10 +++++-- src/common/audio/LanczosResampler.hxx | 5 ++++ src/common/audio/module.mk | 3 +- 5 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 src/common/audio/HighPass.cxx create mode 100644 src/common/audio/HighPass.hxx diff --git a/src/common/audio/HighPass.cxx b/src/common/audio/HighPass.cxx new file mode 100644 index 000000000..e4846012b --- /dev/null +++ b/src/common/audio/HighPass.cxx @@ -0,0 +1,41 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2018 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#include +#ifndef M_PI + #define M_PI 3.14159265358979323846f +#endif + +#include "HighPass.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +HighPass::HighPass(float cutOffFrequency, float frequency) + : myLastValueIn(0), + myLastValueOut(0), + myAlpha(1.f / (1.f + 2.f*M_PI*cutOffFrequency/frequency)) +{} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +float HighPass::apply(float valueIn) +{ + float valueOut = myAlpha * (myLastValueOut + valueIn - myLastValueIn); + + myLastValueIn = valueIn; + myLastValueOut = valueOut; + + return valueOut; +} diff --git a/src/common/audio/HighPass.hxx b/src/common/audio/HighPass.hxx new file mode 100644 index 000000000..d479ce874 --- /dev/null +++ b/src/common/audio/HighPass.hxx @@ -0,0 +1,42 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2018 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#ifndef HIGH_PASS_HXX +#define HIGH_PASS_HXX + +class HighPass +{ + public: + + HighPass(float cutOffFrequency, float frequency); + + float apply(float value); + + private: + + float myLastValueIn; + + float myLastValueOut; + + float myAlpha; + + private: + + HighPass() = delete; +}; + +#endif // HIGH_PASS_HXX diff --git a/src/common/audio/LanczosResampler.cxx b/src/common/audio/LanczosResampler.cxx index 25ecd82ec..642f37274 100644 --- a/src/common/audio/LanczosResampler.cxx +++ b/src/common/audio/LanczosResampler.cxx @@ -25,6 +25,7 @@ namespace { constexpr float CLIPPING_FACTOR = 0.75; + constexpr float HIGH_PASS_CUT_OFF = 10; uInt32 reducedDenominator(uInt32 n, uInt32 d) { @@ -78,6 +79,9 @@ LanczosResampler::LanczosResampler( myCurrentFragment(nullptr), myFragmentIndex(0), myIsUnderrun(true), + myHighPassL(HIGH_PASS_CUT_OFF, formatFrom.sampleRate), + myHighPassR(HIGH_PASS_CUT_OFF, formatFrom.sampleRate), + myHighPass(HIGH_PASS_CUT_OFF, formatFrom.sampleRate), myTimeIndex(0) { myPrecomputedKernels = make_unique(myPrecomputedKernelCount * myKernelSize); @@ -184,11 +188,11 @@ inline void LanczosResampler::shiftSamples(uInt32 samplesToShift) { while (samplesToShift-- > 0) { if (myFormatFrom.stereo) { - myBufferL->shift(myCurrentFragment[2*myFragmentIndex] / static_cast(0x7fff)); - myBufferR->shift(myCurrentFragment[2*myFragmentIndex + 1] / static_cast(0x7fff)); + myBufferL->shift(myHighPassL.apply(myCurrentFragment[2*myFragmentIndex] / static_cast(0x7fff))); + myBufferR->shift(myHighPassR.apply(myCurrentFragment[2*myFragmentIndex + 1] / static_cast(0x7fff))); } else - myBuffer->shift(myCurrentFragment[myFragmentIndex] / static_cast(0x7fff)); + myBuffer->shift(myHighPass.apply(myCurrentFragment[myFragmentIndex] / static_cast(0x7fff))); myFragmentIndex++; diff --git a/src/common/audio/LanczosResampler.hxx b/src/common/audio/LanczosResampler.hxx index 0f92f48d5..17bcfefaa 100644 --- a/src/common/audio/LanczosResampler.hxx +++ b/src/common/audio/LanczosResampler.hxx @@ -21,6 +21,7 @@ #include "bspf.hxx" #include "Resampler.hxx" #include "ConvolutionBuffer.hxx" +#include "HighPass.hxx" class LanczosResampler : public Resampler { @@ -59,6 +60,10 @@ class LanczosResampler : public Resampler uInt32 myFragmentIndex; bool myIsUnderrun; + HighPass myHighPassL; + HighPass myHighPassR; + HighPass myHighPass; + uInt32 myTimeIndex; }; diff --git a/src/common/audio/module.mk b/src/common/audio/module.mk index 67ae01063..6c51ab2a0 100644 --- a/src/common/audio/module.mk +++ b/src/common/audio/module.mk @@ -3,7 +3,8 @@ MODULE := src/common/audio MODULE_OBJS := \ src/common/audio/SimpleResampler.o \ src/common/audio/ConvolutionBuffer.o \ - src/common/audio/LanczosResampler.o + src/common/audio/LanczosResampler.o \ + src/common/audio/HighPass.o MODULE_DIRS += \ src/emucore/tia From b8591d6549ade84c117d99eefa55c2814023299c Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Wed, 8 Aug 2018 23:29:53 +0200 Subject: [PATCH 16/25] Update XCode project. --- src/macosx/stella.xcodeproj/project.pbxproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/macosx/stella.xcodeproj/project.pbxproj b/src/macosx/stella.xcodeproj/project.pbxproj index f289254c6..8e12c9b3b 100644 --- a/src/macosx/stella.xcodeproj/project.pbxproj +++ b/src/macosx/stella.xcodeproj/project.pbxproj @@ -635,6 +635,8 @@ E034A5EF209FB25D00C89E9E /* EmulationTiming.hxx in Headers */ = {isa = PBXBuildFile; fileRef = E034A5ED209FB25C00C89E9E /* EmulationTiming.hxx */; }; E0406FB61F81A85400A82AE0 /* AbstractFrameManager.cxx in Sources */ = {isa = PBXBuildFile; fileRef = E0DFDD781F81A358000F3505 /* AbstractFrameManager.cxx */; }; E0406FB81F81A85400A82AE0 /* FrameManager.cxx in Sources */ = {isa = PBXBuildFile; fileRef = E0DFDD7B1F81A358000F3505 /* FrameManager.cxx */; }; + E0893AF2211B9842008B170D /* HighPass.cxx in Sources */ = {isa = PBXBuildFile; fileRef = E0893AF0211B9841008B170D /* HighPass.cxx */; }; + E0893AF3211B9842008B170D /* HighPass.hxx in Headers */ = {isa = PBXBuildFile; fileRef = E0893AF1211B9841008B170D /* HighPass.hxx */; }; E09F413B201E901D004A3391 /* AudioQueue.hxx in Headers */ = {isa = PBXBuildFile; fileRef = E09F4139201E901C004A3391 /* AudioQueue.hxx */; }; E09F413C201E901D004A3391 /* AudioQueue.cxx in Sources */ = {isa = PBXBuildFile; fileRef = E09F413A201E901D004A3391 /* AudioQueue.cxx */; }; E09F4141201E9050004A3391 /* Audio.hxx in Headers */ = {isa = PBXBuildFile; fileRef = E09F413D201E904F004A3391 /* Audio.hxx */; }; @@ -1330,6 +1332,8 @@ E0306E0B1F93E916003DDD52 /* JitterEmulation.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = JitterEmulation.hxx; sourceTree = ""; }; E034A5EC209FB25C00C89E9E /* EmulationTiming.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmulationTiming.cxx; sourceTree = ""; }; E034A5ED209FB25C00C89E9E /* EmulationTiming.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EmulationTiming.hxx; sourceTree = ""; }; + E0893AF0211B9841008B170D /* HighPass.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HighPass.cxx; path = audio/HighPass.cxx; sourceTree = ""; }; + E0893AF1211B9841008B170D /* HighPass.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = HighPass.hxx; path = audio/HighPass.hxx; sourceTree = ""; }; E09F4139201E901C004A3391 /* AudioQueue.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AudioQueue.hxx; sourceTree = ""; }; E09F413A201E901D004A3391 /* AudioQueue.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioQueue.cxx; sourceTree = ""; }; E09F413D201E904F004A3391 /* Audio.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Audio.hxx; sourceTree = ""; }; @@ -2076,6 +2080,8 @@ DCC6A4AD20A2620D00863C59 /* audio */ = { isa = PBXGroup; children = ( + E0893AF0211B9841008B170D /* HighPass.cxx */, + E0893AF1211B9841008B170D /* HighPass.hxx */, E0DCD3A620A64E96000B614E /* ConvolutionBuffer.cxx */, E0DCD3A520A64E96000B614E /* ConvolutionBuffer.hxx */, E0DCD3A420A64E95000B614E /* LanczosResampler.cxx */, @@ -2235,6 +2241,7 @@ DCACBAD11C54296300703A9B /* CartCVPlusWidget.hxx in Headers */, DC1B2EC81E50036100F62837 /* TrakBall.hxx in Headers */, 2D9173E709BA90380026E9FF /* M6532.hxx in Headers */, + E0893AF3211B9842008B170D /* HighPass.hxx in Headers */, 2D9173E809BA90380026E9FF /* MD5.hxx in Headers */, 2D9173EA09BA90380026E9FF /* Paddles.hxx in Headers */, 2D9173EB09BA90380026E9FF /* Props.hxx in Headers */, @@ -2797,6 +2804,7 @@ DCF3A6EF1DFC75E3008A8AF3 /* DrawCounterDecodes.cxx in Sources */, DC5AAC2C1FCB24DF00C420A6 /* RadioButtonWidget.cxx in Sources */, DC9EA8870F729A36000452B5 /* KidVid.cxx in Sources */, + E0893AF2211B9842008B170D /* HighPass.cxx in Sources */, DCF467C20F939A1400B25D7A /* CartEF.cxx in Sources */, DCF467C40F939A1400B25D7A /* CartEFSC.cxx in Sources */, DCF7B0DD10A762FC007A2870 /* CartF0.cxx in Sources */, From 2e42f542735dd7d155fa0387585dd1d5ae0a02a2 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 8 Aug 2018 23:59:01 +0200 Subject: [PATCH 17/25] updated VS project file --- src/windows/Stella.vcxproj | 2 ++ src/windows/Stella.vcxproj.filters | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/windows/Stella.vcxproj b/src/windows/Stella.vcxproj index 7df9fa169..86989ac22 100644 --- a/src/windows/Stella.vcxproj +++ b/src/windows/Stella.vcxproj @@ -233,6 +233,7 @@ + @@ -526,6 +527,7 @@ + diff --git a/src/windows/Stella.vcxproj.filters b/src/windows/Stella.vcxproj.filters index 5ca282fa6..67ecd4f4d 100644 --- a/src/windows/Stella.vcxproj.filters +++ b/src/windows/Stella.vcxproj.filters @@ -936,6 +936,9 @@ Source Files + + Source Files\audio + @@ -1913,6 +1916,9 @@ Header Files + + Header Files\audio + From e26602354b2f705efc5eb38c8f2496a47f38d267 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 9 Aug 2018 11:39:36 +0200 Subject: [PATCH 18/25] fixed warnings --- src/common/audio/LanczosResampler.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/audio/LanczosResampler.cxx b/src/common/audio/LanczosResampler.cxx index 642f37274..c0b70fd28 100644 --- a/src/common/audio/LanczosResampler.cxx +++ b/src/common/audio/LanczosResampler.cxx @@ -79,9 +79,9 @@ LanczosResampler::LanczosResampler( myCurrentFragment(nullptr), myFragmentIndex(0), myIsUnderrun(true), - myHighPassL(HIGH_PASS_CUT_OFF, formatFrom.sampleRate), - myHighPassR(HIGH_PASS_CUT_OFF, formatFrom.sampleRate), - myHighPass(HIGH_PASS_CUT_OFF, formatFrom.sampleRate), + myHighPassL(HIGH_PASS_CUT_OFF, (float)formatFrom.sampleRate), + myHighPassR(HIGH_PASS_CUT_OFF, (float)formatFrom.sampleRate), + myHighPass(HIGH_PASS_CUT_OFF, (float)formatFrom.sampleRate), myTimeIndex(0) { myPrecomputedKernels = make_unique(myPrecomputedKernelCount * myKernelSize); From c6086184de47ae4bd48f1c8b46df1d1124ecf4a0 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Thu, 9 Aug 2018 08:55:41 -0230 Subject: [PATCH 19/25] Convert C-style casts into C++ style (otherwise gcc and clang complain). --- src/common/audio/LanczosResampler.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/audio/LanczosResampler.cxx b/src/common/audio/LanczosResampler.cxx index c0b70fd28..f6cd135f9 100644 --- a/src/common/audio/LanczosResampler.cxx +++ b/src/common/audio/LanczosResampler.cxx @@ -79,9 +79,9 @@ LanczosResampler::LanczosResampler( myCurrentFragment(nullptr), myFragmentIndex(0), myIsUnderrun(true), - myHighPassL(HIGH_PASS_CUT_OFF, (float)formatFrom.sampleRate), - myHighPassR(HIGH_PASS_CUT_OFF, (float)formatFrom.sampleRate), - myHighPass(HIGH_PASS_CUT_OFF, (float)formatFrom.sampleRate), + myHighPassL(HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)), + myHighPassR(HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)), + myHighPass(HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)), myTimeIndex(0) { myPrecomputedKernels = make_unique(myPrecomputedKernelCount * myKernelSize); From 1571860dc0df0ff968751a1f12f5fa718571e6b6 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 9 Aug 2018 14:55:46 +0200 Subject: [PATCH 20/25] fix #341 --- src/emucore/Console.cxx | 3 +++ src/emucore/tia/TIA.cxx | 19 ++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 46433abd1..38fd9cbbf 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -491,6 +491,9 @@ void Console::setPalette(const string& type) palettes[paletteNum][0]; myOSystem.frameBuffer().setPalette(palette); + + if(myTIA->usingFixedColors()) + myTIA->enableFixedColors(true); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 617de2b85..5886c25ed 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -973,18 +973,15 @@ bool TIA::toggleCollisions() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool TIA::enableFixedColors(bool enable) { - // This will be called during reset at a point where no frame manager - // instance is available, so we guard aginst this here. - int layout = 0; - if (myFrameManager) layout = myFrameManager->layout() == FrameLayout::pal ? 1 : 0; + int timing = consoleTiming() == ConsoleTiming::pal ? 1 : 0; - myMissile0.setDebugColor(myFixedColorPalette[layout][FixedObject::M0]); - myMissile1.setDebugColor(myFixedColorPalette[layout][FixedObject::M1]); - myPlayer0.setDebugColor(myFixedColorPalette[layout][FixedObject::P0]); - myPlayer1.setDebugColor(myFixedColorPalette[layout][FixedObject::P1]); - myBall.setDebugColor(myFixedColorPalette[layout][FixedObject::BL]); - myPlayfield.setDebugColor(myFixedColorPalette[layout][FixedObject::PF]); - myBackground.setDebugColor(myFixedColorPalette[layout][FixedObject::BK]); + myMissile0.setDebugColor(myFixedColorPalette[timing][FixedObject::M0]); + myMissile1.setDebugColor(myFixedColorPalette[timing][FixedObject::M1]); + myPlayer0.setDebugColor(myFixedColorPalette[timing][FixedObject::P0]); + myPlayer1.setDebugColor(myFixedColorPalette[timing][FixedObject::P1]); + myBall.setDebugColor(myFixedColorPalette[timing][FixedObject::BL]); + myPlayfield.setDebugColor(myFixedColorPalette[timing][FixedObject::PF]); + myBackground.setDebugColor(myFixedColorPalette[timing][FixedObject::BK]); myMissile0.enableDebugColors(enable); myMissile1.enableDebugColors(enable); From ae96406fd4aee419f5e06d46c68df3a2282b971a Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Thu, 9 Aug 2018 10:54:26 -0230 Subject: [PATCH 21/25] Fix #345; color-loss not correctly initialized. --- src/common/RewindManager.cxx | 2 +- src/emucore/CartBUS.cxx | 2 +- src/emucore/CartCDF.cxx | 2 +- src/emucore/CartDPCPlus.cxx | 2 +- src/emucore/tia/TIA.cxx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/RewindManager.cxx b/src/common/RewindManager.cxx index 55ff40959..14fe54c81 100644 --- a/src/common/RewindManager.cxx +++ b/src/common/RewindManager.cxx @@ -38,7 +38,7 @@ void RewindManager::setup() { myLastTimeMachineAdd = false; - string prefix = myOSystem.settings().getBool("dev.settings") ? "dev." : "plr."; + const string& prefix = myOSystem.settings().getBool("dev.settings") ? "dev." : "plr."; mySize = myOSystem.settings().getInt(prefix + "tm.size"); if(mySize != myStateList.capacity()) diff --git a/src/emucore/CartBUS.cxx b/src/emucore/CartBUS.cxx index f3799d67b..4aeb0123a 100644 --- a/src/emucore/CartBUS.cxx +++ b/src/emucore/CartBUS.cxx @@ -64,7 +64,7 @@ CartridgeBUS::CartridgeBUS(const BytePtr& image, uInt32 size, myDisplayImage = myBUSRAM + DSRAM; // Create Thumbulator ARM emulator - string prefix = settings.getBool("dev.settings") ? "plr." : "dev."; + const string& prefix = settings.getBool("dev.settings") ? "plr." : "dev."; myThumbEmulator = make_unique( reinterpret_cast(myImage), reinterpret_cast(myBUSRAM), settings.getBool(prefix + "thumb.trapfatal"), Thumbulator::ConfigureFor::BUS, this diff --git a/src/emucore/CartCDF.cxx b/src/emucore/CartCDF.cxx index 599cc9bc8..41a9aa1f7 100644 --- a/src/emucore/CartCDF.cxx +++ b/src/emucore/CartCDF.cxx @@ -67,7 +67,7 @@ CartridgeCDF::CartridgeCDF(const BytePtr& image, uInt32 size, setVersion(); // Create Thumbulator ARM emulator - string prefix = settings.getBool("dev.settings") ? "plr." : "dev."; + const string& prefix = settings.getBool("dev.settings") ? "plr." : "dev."; myThumbEmulator = make_unique( reinterpret_cast(myImage), reinterpret_cast(myCDFRAM), settings.getBool(prefix + "thumb.trapfatal"), myVersion ? diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index f6a3ab258..e457e1d4f 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -53,7 +53,7 @@ CartridgeDPCPlus::CartridgeDPCPlus(const BytePtr& image, uInt32 size, myFrequencyImage = myDisplayImage + 0x1000; // Create Thumbulator ARM emulator - string prefix = settings.getBool("dev.settings") ? "plr." : "dev."; + const string& prefix = settings.getBool("dev.settings") ? "plr." : "dev."; myThumbEmulator = make_unique (reinterpret_cast(myImage), reinterpret_cast(myDPCRAM), diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 5886c25ed..7529ac0b0 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -200,7 +200,7 @@ void TIA::frameReset() memset(myBackBuffer, 0, 160 * TIAConstants::frameBufferHeight); memset(myFrontBuffer, 0, 160 * TIAConstants::frameBufferHeight); memset(myFramebuffer, 0, 160 * TIAConstants::frameBufferHeight); - enableColorLoss(mySettings.getBool("dev.settings") ? "dev.colorloss" : "plr.colorloss"); + enableColorLoss(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.colorloss" : "plr.colorloss")); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From efb998129be7461356e4ec5180adb9a2e73c818e Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 9 Aug 2018 15:39:54 +0200 Subject: [PATCH 22/25] fixes #342 --- src/debugger/TIADebug.cxx | 36 ++++++++++++++++++--------------- src/emucore/tia/TIA.cxx | 11 ++++++++-- src/emucore/tia/TIA.hxx | 40 ++++++++++++++++++++++--------------- src/gui/DeveloperDialog.cxx | 34 ++++++++++++++++++++----------- 4 files changed, 75 insertions(+), 46 deletions(-) diff --git a/src/debugger/TIADebug.cxx b/src/debugger/TIADebug.cxx index 9d9741a65..f71164753 100644 --- a/src/debugger/TIADebug.cxx +++ b/src/debugger/TIADebug.cxx @@ -49,15 +49,17 @@ const DebuggerState& TIADebug::getState() myState.coluRegs.push_back(coluBK()); // Debug Colors - int mode = myTIA.frameLayout() == FrameLayout::ntsc ? 0 : 1; + int timing = myTIA.consoleTiming() == ConsoleTiming::ntsc ? 0 + : myTIA.consoleTiming() == ConsoleTiming::pal ? 1 : 2; + myState.fixedCols.clear(); - myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::P0]); - myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::P1]); - myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::PF]); - myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::BK]); - myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::M0]); - myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::M1]); - myState.fixedCols.push_back(myTIA.myFixedColorPalette[mode][TIA::BL]); + myState.fixedCols.push_back(myTIA.myFixedColorPalette[timing][TIA::P0]); + myState.fixedCols.push_back(myTIA.myFixedColorPalette[timing][TIA::P1]); + myState.fixedCols.push_back(myTIA.myFixedColorPalette[timing][TIA::PF]); + myState.fixedCols.push_back(myTIA.myFixedColorPalette[timing][TIA::BK]); + myState.fixedCols.push_back(myTIA.myFixedColorPalette[timing][TIA::M0]); + myState.fixedCols.push_back(myTIA.myFixedColorPalette[timing][TIA::M1]); + myState.fixedCols.push_back(myTIA.myFixedColorPalette[timing][TIA::BL]); myState.fixedCols.push_back(TIA::FixedColor::HBLANK_WHITE); // Collisions @@ -1012,20 +1014,22 @@ string TIADebug::debugColors() const { ostringstream buf; - int mode = myTIA.frameLayout() == FrameLayout::ntsc ? 0 : 1; - buf << " " << myTIA.myFixedColorNames[TIA::P0] << " " << colorSwatch(myTIA.myFixedColorPalette[mode][TIA::P0]) + int timing = myTIA.consoleTiming() == ConsoleTiming::ntsc ? 0 + : myTIA.consoleTiming() == ConsoleTiming::pal ? 1 : 2; + + buf << " " << myTIA.myFixedColorNames[TIA::P0] << " " << colorSwatch(myTIA.myFixedColorPalette[timing][TIA::P0]) << " Player 0\n" - << " " << myTIA.myFixedColorNames[TIA::M0] << " " << colorSwatch(myTIA.myFixedColorPalette[mode][TIA::M0]) + << " " << myTIA.myFixedColorNames[TIA::M0] << " " << colorSwatch(myTIA.myFixedColorPalette[timing][TIA::M0]) << " Missile 0\n" - << " " << myTIA.myFixedColorNames[TIA::P1] << " " << colorSwatch(myTIA.myFixedColorPalette[mode][TIA::P1]) + << " " << myTIA.myFixedColorNames[TIA::P1] << " " << colorSwatch(myTIA.myFixedColorPalette[timing][TIA::P1]) << " Player 1\n" - << " " << myTIA.myFixedColorNames[TIA::M1] << " " << colorSwatch(myTIA.myFixedColorPalette[mode][TIA::M1]) + << " " << myTIA.myFixedColorNames[TIA::M1] << " " << colorSwatch(myTIA.myFixedColorPalette[timing][TIA::M1]) << " Missile 1\n" - << " " << myTIA.myFixedColorNames[TIA::PF] << " " << colorSwatch(myTIA.myFixedColorPalette[mode][TIA::PF]) + << " " << myTIA.myFixedColorNames[TIA::PF] << " " << colorSwatch(myTIA.myFixedColorPalette[timing][TIA::PF]) << " Playfield\n" - << " " << myTIA.myFixedColorNames[TIA::BL] << " " << colorSwatch(myTIA.myFixedColorPalette[mode][TIA::BL]) + << " " << myTIA.myFixedColorNames[TIA::BL] << " " << colorSwatch(myTIA.myFixedColorPalette[timing][TIA::BL]) << " Ball\n" - << " Grey " << colorSwatch(myTIA.myFixedColorPalette[mode][TIA::BK]) + << " Grey " << colorSwatch(myTIA.myFixedColorPalette[timing][TIA::BK]) << " Background\n" << " White " << colorSwatch(TIA::FixedColor::HBLANK_WHITE) << " HMOVE\n"; diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 7529ac0b0..651da546b 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -973,7 +973,8 @@ bool TIA::toggleCollisions() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool TIA::enableFixedColors(bool enable) { - int timing = consoleTiming() == ConsoleTiming::pal ? 1 : 0; + int timing = consoleTiming() == ConsoleTiming::ntsc ? 0 + : consoleTiming() == ConsoleTiming::pal ? 1 : 2; myMissile0.setDebugColor(myFixedColorPalette[timing][FixedObject::M0]); myMissile1.setDebugColor(myFixedColorPalette[timing][FixedObject::M1]); @@ -1010,38 +1011,44 @@ bool TIA::setFixedColorPalette(const string& colors) case 'r': myFixedColorPalette[0][i] = FixedColor::NTSC_RED; myFixedColorPalette[1][i] = FixedColor::PAL_RED; + myFixedColorPalette[2][i] = FixedColor::SECAM_RED; myFixedColorNames[i] = "Red "; break; case 'o': myFixedColorPalette[0][i] = FixedColor::NTSC_ORANGE; myFixedColorPalette[1][i] = FixedColor::PAL_ORANGE; + myFixedColorPalette[2][i] = FixedColor::SECAM_ORANGE; myFixedColorNames[i] = "Orange"; break; case 'y': myFixedColorPalette[0][i] = FixedColor::NTSC_YELLOW; myFixedColorPalette[1][i] = FixedColor::PAL_YELLOW; + myFixedColorPalette[2][i] = FixedColor::SECAM_YELLOW; myFixedColorNames[i] = "Yellow"; break; case 'g': myFixedColorPalette[0][i] = FixedColor::NTSC_GREEN; myFixedColorPalette[1][i] = FixedColor::PAL_GREEN; + myFixedColorPalette[2][i] = FixedColor::SECAM_GREEN; myFixedColorNames[i] = "Green "; break; case 'b': myFixedColorPalette[0][i] = FixedColor::NTSC_BLUE; myFixedColorPalette[1][i] = FixedColor::PAL_BLUE; + myFixedColorPalette[2][i] = FixedColor::SECAM_BLUE; myFixedColorNames[i] = "Blue "; break; case 'p': myFixedColorPalette[0][i] = FixedColor::NTSC_PURPLE; myFixedColorPalette[1][i] = FixedColor::PAL_PURPLE; + myFixedColorPalette[2][i] = FixedColor::SECAM_PURPLE; myFixedColorNames[i] = "Purple"; break; } } myFixedColorPalette[0][TIA::BK] = FixedColor::NTSC_GREY; myFixedColorPalette[1][TIA::BK] = FixedColor::PAL_GREY; - + myFixedColorPalette[2][TIA::BK] = FixedColor::SECAM_GREY; // If already in fixed debug colours mode, update the current palette if(usingFixedColors()) diff --git a/src/emucore/tia/TIA.hxx b/src/emucore/tia/TIA.hxx index dc78c0477..41a7191ce 100644 --- a/src/emucore/tia/TIA.hxx +++ b/src/emucore/tia/TIA.hxx @@ -73,23 +73,31 @@ class TIA : public Device * Possible palette entries for objects in "fixed debug color mode". */ enum FixedColor { - NTSC_RED = 0x30, - NTSC_ORANGE = 0x38, - NTSC_YELLOW = 0x1c, - NTSC_GREEN = 0xc4, - NTSC_BLUE = 0x9c, - NTSC_PURPLE = 0x66, - NTSC_GREY = 0x04, + NTSC_RED = 0x30, + NTSC_ORANGE = 0x38, + NTSC_YELLOW = 0x1c, + NTSC_GREEN = 0xc4, + NTSC_BLUE = 0x9c, + NTSC_PURPLE = 0x66, + NTSC_GREY = 0x04, - PAL_RED = 0x62, - PAL_ORANGE = 0x4a, - PAL_YELLOW = 0x2e, - PAL_GREEN = 0x34, - PAL_BLUE = 0xbc, - PAL_PURPLE = 0xa6, - PAL_GREY = 0x06, + PAL_RED = 0x62, + PAL_ORANGE = 0x4a, + PAL_YELLOW = 0x2e, + PAL_GREEN = 0x34, + PAL_BLUE = 0xbc, + PAL_PURPLE = 0xa6, + PAL_GREY = 0x06, - HBLANK_WHITE = 0x0e + SECAM_RED = 0x04, + SECAM_ORANGE = 0x06, // purple + SECAM_YELLOW = 0x0c, + SECAM_GREEN = 0x08, + SECAM_BLUE = 0x02, + SECAM_PURPLE = 0x0a, // cyan + SECAM_GREY = 0x00, + + HBLANK_WHITE = 0x0e }; public: @@ -502,7 +510,7 @@ class TIA : public Device * Palette and indices for fixed debug colors. */ enum FixedObject { P0, M0, P1, M1, PF, BL, BK }; - FixedColor myFixedColorPalette[2][7]; + FixedColor myFixedColorPalette[3][7]; string myFixedColorNames[7]; private: diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index b1dde505d..4b65f37d3 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -1090,7 +1090,7 @@ void DeveloperDialog::handleDebugColours(int idx, int color) return; } - static constexpr ColorId dbg_color[2][DEBUG_COLORS] = { + static constexpr ColorId dbg_color[3][DEBUG_COLORS] = { { TIA::FixedColor::NTSC_RED, TIA::FixedColor::NTSC_ORANGE, @@ -1106,11 +1106,21 @@ void DeveloperDialog::handleDebugColours(int idx, int color) TIA::FixedColor::PAL_GREEN, TIA::FixedColor::PAL_PURPLE, TIA::FixedColor::PAL_BLUE + }, + { + TIA::FixedColor::SECAM_RED, + TIA::FixedColor::SECAM_ORANGE, + TIA::FixedColor::SECAM_YELLOW, + TIA::FixedColor::SECAM_GREEN, + TIA::FixedColor::SECAM_PURPLE, + TIA::FixedColor::SECAM_BLUE } }; - int mode = instance().console().tia().frameLayout() == FrameLayout::ntsc ? 0 : 1; - myDbgColourSwatch[idx]->setColor(dbg_color[mode][color]); + int timing = instance().console().tia().consoleTiming() == ConsoleTiming::ntsc ? 0 + : instance().console().tia().consoleTiming() == ConsoleTiming::pal ? 1 : 2; + + myDbgColourSwatch[idx]->setColor(dbg_color[timing][color]); myDbgColour[idx]->setSelectedIndex(color); // make sure the selected debug colors are all different @@ -1122,7 +1132,7 @@ void DeveloperDialog::handleDebugColours(int idx, int color) usedCol[i] = false; for(int j = 0; j < DEBUG_COLORS; ++j) { - if(myDbgColourSwatch[j]->getColor() == dbg_color[mode][i]) + if(myDbgColourSwatch[j]->getColor() == dbg_color[timing][i]) { usedCol[i] = true; break; @@ -1132,14 +1142,14 @@ void DeveloperDialog::handleDebugColours(int idx, int color) // check if currently changed color was used somewhere else for(int i = 0; i < DEBUG_COLORS; ++i) { - if (i != idx && myDbgColourSwatch[i]->getColor() == dbg_color[mode][color]) + if (i != idx && myDbgColourSwatch[i]->getColor() == dbg_color[timing][color]) { // if already used, change the other color to an unused one for(int j = 0; j < DEBUG_COLORS; ++j) { if(!usedCol[j]) { - myDbgColourSwatch[i]->setColor(dbg_color[mode][j]); + myDbgColourSwatch[i]->setColor(dbg_color[timing][j]); myDbgColour[i]->setSelectedIndex(j); break; } @@ -1155,12 +1165,12 @@ void DeveloperDialog::handleDebugColours(const string& colors) { switch(colors[i]) { - case 'r': handleDebugColours(i, 0); break; - case 'o': handleDebugColours(i, 1); break; - case 'y': handleDebugColours(i, 2); break; - case 'g': handleDebugColours(i, 3); break; - case 'p': handleDebugColours(i, 4); break; - case 'b': handleDebugColours(i, 5); break; + case 'r': handleDebugColours(i, 0); break; + case 'o': handleDebugColours(i, 1); break; + case 'y': handleDebugColours(i, 2); break; + case 'g': handleDebugColours(i, 3); break; + case 'p': handleDebugColours(i, 4); break; + case 'b': handleDebugColours(i, 5); break; default: break; } } From 95867f91cd5bb0b4f764d3fe7cfb1c763ead715f Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Thu, 9 Aug 2018 23:41:15 +0200 Subject: [PATCH 23/25] Switch to SDL_OpenAudioDevice & friends, fix silence with very tight buffer settings. --- src/common/SoundSDL2.cxx | 41 ++++++++++++++++----------------- src/common/SoundSDL2.hxx | 2 ++ src/emucore/EmulationTiming.cxx | 2 ++ 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index 4e9227d26..25ec5c1bb 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -45,6 +45,15 @@ SoundSDL2::SoundSDL2(OSystem& osystem, AudioSettings& audioSettings) { myOSystem.logMessage("SoundSDL2::SoundSDL2 started ...", 2); + if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { + ostringstream buf; + + buf << "WARNING: Failed to initialize SDL audio system! " << endl + << " " << SDL_GetError() << endl; + myOSystem.logMessage(buf.str(), 0); + return; + } + // The sound system is opened only once per program run, to eliminate // issues with opening and closing it multiple times // This fixes a bug most prevalent with ATI video cards in Windows, @@ -57,28 +66,18 @@ SoundSDL2::SoundSDL2(OSystem& osystem, AudioSettings& audioSettings) desired.callback = callback; desired.userdata = static_cast(this); - ostringstream buf; - if(SDL_OpenAudio(&desired, &myHardwareSpec) < 0) + myDevice = SDL_OpenAudioDevice(0, 0, &desired, &myHardwareSpec, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE); + + if(myDevice == 0) { - buf << "WARNING: Couldn't open SDL audio system! " << endl + ostringstream buf; + + buf << "WARNING: Couldn't open SDL audio device! " << endl << " " << SDL_GetError() << endl; myOSystem.logMessage(buf.str(), 0); return; } - // Make sure the sample buffer isn't to big (if it is the sound code - // will not work so we'll need to disable the audio support) - if((float(myHardwareSpec.samples) / float(myHardwareSpec.freq)) >= 0.25) - { - buf << "WARNING: Sound device doesn't support realtime audio! Make " - << "sure a sound" << endl - << " server isn't running. Audio is disabled." << endl; - myOSystem.logMessage(buf.str(), 0); - - SDL_CloseAudio(); - return; - } - myIsInitializedFlag = true; mute(true); @@ -91,7 +90,7 @@ SoundSDL2::~SoundSDL2() { if (!myIsInitializedFlag) return; - SDL_CloseAudio(); + SDL_CloseAudioDevice(myDevice); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -165,7 +164,7 @@ void SoundSDL2::mute(bool state) { if(myIsInitializedFlag) { - SDL_PauseAudio(state ? 1 : 0); + SDL_PauseAudioDevice(myDevice, state ? 1 : 0); } } @@ -182,9 +181,9 @@ void SoundSDL2::setVolume(uInt32 percent) myAudioSettings.setVolume(percent); myVolume = percent; - SDL_LockAudio(); + SDL_LockAudioDevice(myDevice); myVolumeFactor = static_cast(percent) / 100.f; - SDL_UnlockAudio(); + SDL_UnlockAudioDevice(myDevice); } } @@ -241,7 +240,7 @@ void SoundSDL2::initResampler() Int16* nextFragment = nullptr; if (myUnderrun) - nextFragment = myAudioQueue->size() > myEmulationTiming->prebufferFragmentCount() ? + nextFragment = myAudioQueue->size() >= myEmulationTiming->prebufferFragmentCount() ? myAudioQueue->dequeue(myCurrentFragment) : nullptr; else nextFragment = myAudioQueue->dequeue(myCurrentFragment); diff --git a/src/common/SoundSDL2.hxx b/src/common/SoundSDL2.hxx index 5ffdd63ef..9ed0d07c7 100644 --- a/src/common/SoundSDL2.hxx +++ b/src/common/SoundSDL2.hxx @@ -129,6 +129,8 @@ class SoundSDL2 : public Sound // Audio specification structure SDL_AudioSpec myHardwareSpec; + SDL_AudioDeviceID myDevice; + shared_ptr myAudioQueue; EmulationTiming* myEmulationTiming; diff --git a/src/emucore/EmulationTiming.cxx b/src/emucore/EmulationTiming.cxx index 8ea92ca02..e753791a5 100644 --- a/src/emucore/EmulationTiming.cxx +++ b/src/emucore/EmulationTiming.cxx @@ -204,4 +204,6 @@ void EmulationTiming::recalculate() myPrebufferFragmentCount, discreteDivCeil(myMaxCyclesPerTimeslice * myAudioSampleRate, myAudioFragmentSize * myCyclesPerSecond) ) + myAudioQueueExtraFragments; + + (cout << myAudioQueueCapacity << " " << myPrebufferFragmentCount << std::endl).flush(); } From cac27b5260d7910479cdf56186cd39dbef8d709e Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Thu, 9 Aug 2018 23:56:23 +0200 Subject: [PATCH 24/25] Fix headroom / buffer size slider min values. --- src/gui/AudioDialog.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/AudioDialog.cxx b/src/gui/AudioDialog.cxx index e486373cb..15611489d 100644 --- a/src/gui/AudioDialog.cxx +++ b/src/gui/AudioDialog.cxx @@ -126,7 +126,7 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent, int swidth = pwidth+23; myHeadroomSlider = new SliderWidget(this, font, xpos, ypos, swidth, lineHeight, "Headroom ", 0, kHeadroomChanged, 10 * fontWidth); - myHeadroomSlider->setMinValue(1); myHeadroomSlider->setMaxValue(AudioSettings::MAX_HEADROOM); + myHeadroomSlider->setMinValue(0); myHeadroomSlider->setMaxValue(AudioSettings::MAX_HEADROOM); myHeadroomSlider->setTickmarkInterval(3); wid.push_back(myHeadroomSlider); @@ -135,7 +135,7 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent, // Param 2 myBufferSizeSlider = new SliderWidget(this, font, xpos, ypos, swidth, lineHeight, "Buffer size ", 0, kBufferSizeChanged, 10 * fontWidth); - myBufferSizeSlider->setMinValue(1); myBufferSizeSlider->setMaxValue(AudioSettings::MAX_BUFFER_SIZE); + myBufferSizeSlider->setMinValue(0); myBufferSizeSlider->setMaxValue(AudioSettings::MAX_BUFFER_SIZE); myBufferSizeSlider->setTickmarkInterval(3); wid.push_back(myBufferSizeSlider); From f1a384fa83b7c624e818eb41ca95af517a0b9f45 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Fri, 10 Aug 2018 00:11:47 +0200 Subject: [PATCH 25/25] Terminate audio after the SoundSDL2 has been destroyed. --- src/common/SoundSDL2.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index 25ec5c1bb..c9749e843 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -91,6 +91,7 @@ SoundSDL2::~SoundSDL2() if (!myIsInitializedFlag) return; SDL_CloseAudioDevice(myDevice); + SDL_QuitSubSystem(SDL_INIT_AUDIO); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -