Finally fixed issue #75 (phosphor mode now works with Blargg).

This commit is contained in:
Stephen Anthony 2017-07-05 12:48:39 -02:30
parent 1d293df782
commit 09af9d09a5
3 changed files with 29 additions and 6 deletions

View File

@ -91,14 +91,14 @@ class AtariNTSC
// Number of input pixels that will fit within given output width.
// Might be rounded down slightly; use outWidth() on result to find
// rounded value.
static uInt32 inWidth( uInt32 out_width ) {
static constexpr uInt32 inWidth( uInt32 out_width ) {
return (((out_width) / PIXEL_out_chunk - 1) * PIXEL_in_chunk + 1);
}
// Number of output pixels written by blitter for given input width.
// Width might be rounded down slightly; use inWidth() on result to
// find rounded value. Guaranteed not to round 160 down at all.
static uInt32 outWidth(uInt32 in_width) {
static constexpr uInt32 outWidth(uInt32 in_width) {
return ((((in_width) - 1) / PIXEL_in_chunk + 1)* PIXEL_out_chunk);
}

View File

@ -54,7 +54,7 @@ TIASurface::TIASurface(OSystem& system)
// Base TIA surface for use in taking snapshots in 1x mode
myBaseTiaSurface = myFB.allocateSurface(kTIAW*2, kTIAH);
memset(myRGBFramebuffer, 0, 160 * FrameManager::frameBufferHeight);
memset(myRGBFramebuffer, 0, AtariNTSC::outWidth(kTIAW) * kTIAH);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -260,7 +260,7 @@ void TIASurface::enableNTSC(bool enable)
myFilter = Filter(enable ? uInt8(myFilter) | 0x10 : uInt8(myFilter) & 0x01);
// Normal vs NTSC mode uses different source widths
myTiaSurface->setSrcSize(enable ? AtariNTSC::outWidth(160) : 160, myTIA->height());
myTiaSurface->setSrcSize(enable ? AtariNTSC::outWidth(kTIAW) : kTIAW, myTIA->height());
FBSurface::Attributes& tia_attr = myTiaSurface->attributes();
tia_attr.smoothing = myOSystem.settings().getBool("tia.inter");
@ -275,6 +275,8 @@ void TIASurface::enableNTSC(bool enable)
myTiaSurface->setDirty();
mySLineSurface->setDirty();
memset(myRGBFramebuffer, 0, AtariNTSC::outWidth(kTIAW) * kTIAH);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -365,8 +367,29 @@ void TIASurface::render()
case Filter::BlarggPhosphor:
{
// First do Blargg filtering
myNTSCFilter.blit_single(myTIA->frameBuffer(), width, height,
out, outPitch << 2);
// Then do phosphor mode (blend the resulting frames)
uInt32* rgbIn = myRGBFramebuffer;
uInt32 bufofsY = 0, screenofsY = 0, pos = 0;
for(uInt32 y = 0; y < height; ++y)
{
pos = screenofsY;
for(uInt32 x = 0; x < AtariNTSC::outWidth(kTIAW); ++x)
{
const uInt32 bufofs = bufofsY + x;
const uInt32 retVal = getRGBPhosphor(out[bufofs], rgbIn[bufofs]);
// Store back into displayed frame buffer (for next frame)
rgbIn[bufofs] = retVal;
out[pos++] = retVal;
}
bufofsY += AtariNTSC::outWidth(kTIAW);
screenofsY += outPitch;
}
break;
}
}

View File

@ -167,7 +167,7 @@ class TIASurface
enum TIAConstants {
kTIAW = 160,
kTIAH = 320,
kTIAH = FrameManager::frameBufferHeight,
kScanH = kTIAH*2
};
@ -177,7 +177,7 @@ class TIASurface
/////////////////////////////////////////////////////////////
// Phosphor mode items (aka reduced flicker on 30Hz screens)
// RGB frame buffer
uInt32 myRGBFramebuffer[160 * FrameManager::frameBufferHeight];
uInt32 myRGBFramebuffer[AtariNTSC::outWidth(kTIAW) * kTIAH];
// Use phosphor effect
bool myUsePhosphor;