From 5dbd9fee5103aa31b1a1ff2db958bc567e3a3765 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Mon, 29 May 2017 10:49:50 -0230 Subject: [PATCH] Some changes to phosphor blending: - Updated default phosphor blend to '30'. - Added shortcut keys Alt-i and Alt-o to decrease/increase phosphor blend mode dynamically, while a ROM is running. - Made range of blending 0 - 100. --- docs/index.html | 12 +++++++++++ src/emucore/Console.cxx | 41 ++++++++++++++++++++++++++++++++++++ src/emucore/Console.hxx | 7 ++++++ src/emucore/DefProps.hxx | 4 ++-- src/emucore/EventHandler.cxx | 8 +++++++ src/emucore/Props.cxx | 4 ++-- src/emucore/TIASurface.cxx | 14 ++++++------ src/emucore/stella.pro | 2 ++ src/gui/GameInfoDialog.cxx | 2 +- src/tools/PropSet.pm | 2 +- 10 files changed, 82 insertions(+), 14 deletions(-) diff --git a/docs/index.html b/docs/index.html index ec67c54ec..4cc8c0c9c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1550,6 +1550,18 @@

5. Keyboard Layout

Cmd + p + + Decrease 'phosphor' blend in phosphor mode + Alt + i + Cmd + i + + + + Increase 'phosphor' blend in phosphor mode + Alt + o + Cmd + o + + Toggle palette Control + p diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 156594f22..ac44b9f1d 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -440,6 +440,47 @@ void Console::togglePhosphor() myOSystem.frameBuffer().tiaSurface().enablePhosphor(enable, blend); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Console::changePhosphor(int direction) +{ + bool enable = myProperties.get(Display_Phosphor) == "YES"; + int blend = atoi(myProperties.get(Display_PPBlend).c_str()); + + if(enable) + { + if(direction == +1) // increase blend + { + if(blend >= 100) + { + myOSystem.frameBuffer().showMessage("Phosphor blend at maximum"); + return; + } + else + blend = std::min(blend+2, 100); + } + else if(direction == -1) // decrease blend + { + if(blend <= 0) + { + myOSystem.frameBuffer().showMessage("Phosphor blend at minimum"); + return; + } + else + blend = std::max(blend-2, 0); + } + else + return; + + ostringstream val; + val << blend; + myProperties.set(Display_PPBlend, val.str()); + myOSystem.frameBuffer().showMessage("Phosphor blend " + val.str()); + myOSystem.frameBuffer().tiaSurface().enablePhosphor(enable, blend); + } + else + myOSystem.frameBuffer().showMessage("Phosphor effect disabled"); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Console::setProperties(const Properties& props) { diff --git a/src/emucore/Console.hxx b/src/emucore/Console.hxx index 92fc2d06b..65855e682 100644 --- a/src/emucore/Console.hxx +++ b/src/emucore/Console.hxx @@ -210,6 +210,13 @@ class Console : public Serializable */ void togglePhosphor(); + /** + Change the "Display.PPBlend" variable. + + @param direction +1 indicates increase, -1 indicates decrease. + */ + void changePhosphor(int direction); + /** Toggles the PAL color-loss effect. */ diff --git a/src/emucore/DefProps.hxx b/src/emucore/DefProps.hxx index 9cde5b22b..796cd29a8 100644 --- a/src/emucore/DefProps.hxx +++ b/src/emucore/DefProps.hxx @@ -2368,7 +2368,7 @@ static const char* DefProps[DEF_PROPS_SIZE][21] = { { "b9336ed6d94a5cc81a16483b0a946a73", "Atari, Jerome Domurat, Michael Sierchio", "CX2667, CX2667P", "RealSports Soccer (1983) (Atari) (PAL)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "" }, { "b958d5fd9574c5cf9ece4b9421c28ecd", "Piero Cavina", "", "Multi-Sprite Game V1.0 (Piero Cavina) (PD)", "", "New Release", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "b95a6274ca0e0c773bfdc06b4c3daa42", "Paul Slocum", "", "3-D Corridor (29-03-2003) (Paul Slocum)", "", "Homebrew", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, - { "b98cc2c6f7a0f05176f74f0f62c45488", "Spectravideo", "SV-010", "CompuMate (1983) (Spectravideo)", "", "", "", "CM", "", "", "", "", "COMPUMATE", "COMPUMATE", "", "", "", "", "", "YES", "" }, + { "b98cc2c6f7a0f05176f74f0f62c45488", "Spectravideo", "SV-010", "CompuMate (1983) (Spectravideo)", "", "", "", "CM", "", "", "", "", "COMPUMATE", "COMPUMATE", "", "", "", "", "", "YES", "60" }, { "b9b4612358a0b2c1b4d66bb146767306", "Commavid, Ben Burch", "CM-010", "Rush Hour (1983) (Commavid) (Prototype)", "", "Prototype", "", "", "", "", "", "", "", "", "", "", "", "23", "245", "", "" }, { "b9d1e3be30b131324482345959aed5e5", "Activision, Rex Bradford", "", "Kabobber (07-25-1983) (Activision) (Prototype)", "", "Prototype", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "b9f6fa399b8cd386c235983ec45e4355", "Parker Brothers, John Emerson", "931511", "Action Force (1983) (Parker Bros) (PAL)", "AKA G.I. Joe - Cobra Strike", "", "", "", "", "", "", "", "PADDLES", "", "", "01 55", "", "", "", "", "" }, @@ -2985,7 +2985,7 @@ static const char* DefProps[DEF_PROPS_SIZE][21] = { { "e7864caaf9ec49ed67b1904ce8602690", "", "", "Donkey Kong 2K3 Pic (PD)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "e7a758bb0b43d0f7004e92b9abf4bc83", "", "", "Troll's Adventure (Hack)", "Hack of Adventure", "Hack", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "e7dd8c2e6c100044002c1086d02b366e", "Activision, Steve Cartwright - Ariola", "EAX-013, PAX-013, 711 013-720", "Barnstorming (1982) (Activision) (PAL)", "AKA Die tollkeuhnen Flieger", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, - { "e7f005ddb6902c648de098511f6ae2e5", "Spectravideo - Universum", "SV-010", "CompuMate (1983) (Spectravideo) (PAL)", "", "", "", "CM", "", "", "", "", "COMPUMATE", "COMPUMATE", "", "", "", "", "", "YES", "" }, + { "e7f005ddb6902c648de098511f6ae2e5", "Spectravideo - Universum", "SV-010", "CompuMate (1983) (Spectravideo) (PAL)", "", "", "", "CM", "", "", "", "", "COMPUMATE", "COMPUMATE", "", "", "", "", "", "YES", "60" }, { "e800e4aec7c6c54c9cf3db0d1d030058", "", "", "Qb (2.06) (Retroactive) (Stella)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "" }, { "e80a4026d29777c3c7993fbfaee8920f", "", "", "Frisco (Unknown)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "e823b13751e4388f1f2a375d3560a8d7", "Arcadia Corporation, Stephen Harland Landrum", "AR-4105", "Official Frogger (Preview) (1983) (Arcadia) [a]", "", "", "", "", "", "", "", "", "", "", "", "", "", "32", "", "", "" }, diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 6744ec29f..a83bcb49f 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -404,6 +404,14 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state) myOSystem.console().toggleBits(); break; + case KBDK_I: // Alt-i decreases phosphor blend + myOSystem.console().changePhosphor(-1); + break; + + case KBDK_O: // Alt-o increases phosphor blend + myOSystem.console().changePhosphor(+1); + break; + case KBDK_P: // Alt-p toggles phosphor effect myOSystem.console().togglePhosphor(); break; diff --git a/src/emucore/Props.cxx b/src/emucore/Props.cxx index 2e4c1fe8c..52406aadd 100644 --- a/src/emucore/Props.cxx +++ b/src/emucore/Props.cxx @@ -66,7 +66,7 @@ void Properties::set(PropertyType key, const string& value) case Display_PPBlend: { int blend = atoi(myProperties[key].c_str()); - if(blend < 50 || blend > 100) blend = 77; + if(blend < 0 || blend > 100) blend = 30; ostringstream buf; buf << blend; myProperties[key] = buf.str(); @@ -324,7 +324,7 @@ const char* Properties::ourDefaultProperties[LastPropType] = { "0", // Display.YStart "0", // Display.Height "NO", // Display.Phosphor - "60" // Display.PPBlend + "30" // Display.PPBlend }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index 6ae164580..be95c9d2a 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -223,7 +223,7 @@ void TIASurface::enableScanlineInterpolation(bool enable) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIASurface::enablePhosphor(bool enable, int blend) { - myUsePhosphor = enable; + myUsePhosphor = enable; myPhosphorPercent = blend / 100.0; myFilterType = FilterType(enable ? myFilterType | 0x01 : myFilterType & 0x10); myTiaSurface->setDirty(); @@ -231,7 +231,7 @@ void TIASurface::enablePhosphor(bool enable, int blend) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 TIASurface::getRGBPhosphor(uInt32 c, uInt32 p, uInt8 shift) const +inline uInt32 TIASurface::getRGBPhosphor(uInt32 c, uInt32 p, uInt8 shift) const { uInt8 rc, gc, bc, rp, gp, bp; @@ -320,11 +320,10 @@ void TIASurface::render() { case kNormal: { - uInt32 bufofsY = 0; - uInt32 screenofsY = 0; + uInt32 bufofsY = 0, screenofsY = 0, pos = 0; for(uInt32 y = 0; y < height; ++y) { - uInt32 pos = screenofsY; + pos = screenofsY; for(uInt32 x = 0; x < width; ++x) buffer[pos++] = myPalette[tiaFrame[bufofsY + x]]; @@ -335,11 +334,10 @@ void TIASurface::render() } case kPhosphor: { - uInt32 bufofsY = 0; - uInt32 screenofsY = 0; + uInt32 bufofsY = 0, screenofsY = 0, pos = 0; for(uInt32 y = 0; y < height; ++y) { - uInt32 pos = screenofsY; + pos = screenofsY; for(uInt32 x = 0; x < width; ++x) { const uInt32 bufofs = bufofsY + x; diff --git a/src/emucore/stella.pro b/src/emucore/stella.pro index 3d1be8792..97b196327 100644 --- a/src/emucore/stella.pro +++ b/src/emucore/stella.pro @@ -14365,6 +14365,7 @@ "Controller.Left" "COMPUMATE" "Controller.Right" "COMPUMATE" "Display.Phosphor" "YES" +"Display.PPBlend" "60" "" "Cartridge.MD5" "b9b4612358a0b2c1b4d66bb146767306" @@ -18155,6 +18156,7 @@ "Controller.Left" "COMPUMATE" "Controller.Right" "COMPUMATE" "Display.Phosphor" "YES" +"Display.PPBlend" "60" "" "Cartridge.MD5" "e800e4aec7c6c54c9cf3db0d1d030058" diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index 48c9cb73a..f1fb922bf 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -355,7 +355,7 @@ GameInfoDialog::GameInfoDialog( ypos, 8*fontWidth, lineHeight, "Blend ", font.getStringWidth("Blend "), kPPBlendChanged); - myPPBlend->setMinValue(50); myPPBlend->setMaxValue(100); + myPPBlend->setMinValue(0); myPPBlend->setMaxValue(100); wid.push_back(myPPBlend); myPPBlendLabel = new StaticTextWidget(myTab, font, diff --git a/src/tools/PropSet.pm b/src/tools/PropSet.pm index 1e381a730..51a0fdefe 100755 --- a/src/tools/PropSet.pm +++ b/src/tools/PropSet.pm @@ -70,7 +70,7 @@ my @prop_defaults = ( "0", "0", "NO", - "60" + "30" ); # Load and parse a properties file into an hash table of property