Skip to content

Commit

Permalink
Some changes to phosphor blending:
Browse files Browse the repository at this point in the history
 - 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.
  • Loading branch information
sa666666 committed May 29, 2017
1 parent 47aa5d4 commit 5dbd9fe
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 14 deletions.
12 changes: 12 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,18 @@ <h2><b><a name="Keyboard">5. Keyboard Layout</a></b></h2>
<td>Cmd + p</td>
</tr>

<tr>
<td>Decrease 'phosphor' blend in phosphor mode</td>
<td>Alt + i</td>
<td>Cmd + i</td>
</tr>

<tr>
<td>Increase 'phosphor' blend in phosphor mode</td>
<td>Alt + o</td>
<td>Cmd + o</td>
</tr>

<tr>
<td>Toggle palette</td>
<td>Control + p</td>
Expand Down
41 changes: 41 additions & 0 deletions src/emucore/Console.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
7 changes: 7 additions & 0 deletions src/emucore/Console.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/emucore/DefProps.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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", "", "", "", "", "" },
Expand Down Expand Up @@ -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", "", "", "" },
Expand Down
8 changes: 8 additions & 0 deletions src/emucore/EventHandler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/emucore/Props.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -324,7 +324,7 @@ const char* Properties::ourDefaultProperties[LastPropType] = {
"0", // Display.YStart
"0", // Display.Height
"NO", // Display.Phosphor
"60" // Display.PPBlend
"30" // Display.PPBlend
};

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down
14 changes: 6 additions & 8 deletions src/emucore/TIASurface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,15 @@ 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();
mySLineSurface->setDirty();
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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;

Expand Down Expand Up @@ -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]];

Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/emucore/stella.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14365,6 +14365,7 @@
"Controller.Left" "COMPUMATE"
"Controller.Right" "COMPUMATE"
"Display.Phosphor" "YES"
"Display.PPBlend" "60"
""

"Cartridge.MD5" "b9b4612358a0b2c1b4d66bb146767306"
Expand Down Expand Up @@ -18155,6 +18156,7 @@
"Controller.Left" "COMPUMATE"
"Controller.Right" "COMPUMATE"
"Display.Phosphor" "YES"
"Display.PPBlend" "60"
""

"Cartridge.MD5" "e800e4aec7c6c54c9cf3db0d1d030058"
Expand Down
2 changes: 1 addition & 1 deletion src/gui/GameInfoDialog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/PropSet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ my @prop_defaults = (
"0",
"0",
"NO",
"60"
"30"
);

# Load and parse a properties file into an hash table of property
Expand Down

0 comments on commit 5dbd9fe

Please sign in to comment.