added shading to TIA surface when emulation paused or dialog on top

This commit is contained in:
thrust26 2020-12-01 22:21:23 +01:00
parent bff8d4141a
commit 48e3f85a9f
3 changed files with 28 additions and 11 deletions

View File

@ -346,10 +346,10 @@ void FrameBuffer::update(UpdateMode mode)
{
myPausedCount = uInt32(7 * myOSystem.frameRate());
showTextMessage("Paused", MessagePosition::MiddleCenter);
myTIASurface->render();
myTIASurface->render(true);
}
if(rerender)
myTIASurface->render();
myTIASurface->render(true);
break; // EventHandlerState::PAUSE
}
@ -361,13 +361,13 @@ void FrameBuffer::update(UpdateMode mode)
if(redraw)
{
clear();
myTIASurface->render();
myTIASurface->render(true);
myOSystem.menu().draw(forceRedraw);
}
else if(rerender)
{
clear();
myTIASurface->render();
myTIASurface->render(true);
myOSystem.menu().render();
}
break; // EventHandlerState::OPTIONSMENU
@ -380,7 +380,7 @@ void FrameBuffer::update(UpdateMode mode)
if(redraw)
{
clear();
myTIASurface->render();
myTIASurface->render(true);
myOSystem.commandMenu().draw(forceRedraw);
}
break; // EventHandlerState::CMDMENU
@ -393,13 +393,13 @@ void FrameBuffer::update(UpdateMode mode)
if(redraw)
{
clear();
myTIASurface->render();
myTIASurface->render(true);
myOSystem.highscoresMenu().draw(forceRedraw);
}
else if(rerender)
{
clear();
myTIASurface->render();
myTIASurface->render(true);
myOSystem.highscoresMenu().render();
}
break; // EventHandlerState::HIGHSCORESMENU
@ -412,7 +412,7 @@ void FrameBuffer::update(UpdateMode mode)
if(redraw)
{
clear();
myTIASurface->render();
myTIASurface->render(true);
myOSystem.messageMenu().draw(forceRedraw);
}
break; // EventHandlerState::MESSAGEMENU

View File

@ -75,6 +75,17 @@ TIASurface::TIASurface(OSystem& system)
myBaseTiaSurface = myFB.allocateSurface(TIAConstants::frameBufferWidth*2,
TIAConstants::frameBufferHeight);
// Create shading surface
uInt32 data = 0xff000000;
myShadeSurface = myFB.allocateSurface(1, 1, ScalingInterpolation::sharp, &data);
FBSurface::Attributes& attr = myShadeSurface->attributes();
attr.blending = true;
attr.blendalpha = 35; // darken stopped emulation by 35%
myShadeSurface->applyAttributes();
myRGBFramebuffer.fill(0);
// Enable/disable threading in the NTSC TV effects renderer
@ -361,7 +372,7 @@ inline uInt32 TIASurface::averageBuffers(uInt32 bufOfs)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIASurface::render()
void TIASurface::render(bool shade)
{
uInt32 width = myTIA->width(), height = myTIA->height();
@ -438,6 +449,12 @@ void TIASurface::render()
if(myScanlinesEnabled)
mySLineSurface->render();
if(shade)
{
myShadeSurface->setDstRect(myTiaSurface->dstRect());
myShadeSurface->render();
}
if(mySaveSnapFlag)
{
mySaveSnapFlag = false;

View File

@ -164,7 +164,7 @@ class TIASurface
/**
This method should be called to draw the TIA image(s) to the screen.
*/
void render();
void render(bool shade = false);
/**
This method prepares the current frame for taking a snapshot.
@ -208,7 +208,7 @@ class TIASurface
FrameBuffer& myFB;
TIA* myTIA{nullptr};
shared_ptr<FBSurface> myTiaSurface, mySLineSurface, myBaseTiaSurface;
shared_ptr<FBSurface> myTiaSurface, mySLineSurface, myBaseTiaSurface, myShadeSurface;
// NTSC object to use in TIA rendering mode
NTSCFilter myNTSCFilter;