mirror of https://github.com/stella-emu/stella.git
Finally fixed issue #75 (phosphor mode now works with Blargg).
This commit is contained in:
parent
1d293df782
commit
09af9d09a5
|
@ -91,14 +91,14 @@ class AtariNTSC
|
||||||
// Number of input pixels that will fit within given output width.
|
// Number of input pixels that will fit within given output width.
|
||||||
// Might be rounded down slightly; use outWidth() on result to find
|
// Might be rounded down slightly; use outWidth() on result to find
|
||||||
// rounded value.
|
// 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);
|
return (((out_width) / PIXEL_out_chunk - 1) * PIXEL_in_chunk + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Number of output pixels written by blitter for given input width.
|
// Number of output pixels written by blitter for given input width.
|
||||||
// Width might be rounded down slightly; use inWidth() on result to
|
// Width might be rounded down slightly; use inWidth() on result to
|
||||||
// find rounded value. Guaranteed not to round 160 down at all.
|
// 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);
|
return ((((in_width) - 1) / PIXEL_in_chunk + 1)* PIXEL_out_chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ TIASurface::TIASurface(OSystem& system)
|
||||||
// Base TIA surface for use in taking snapshots in 1x mode
|
// Base TIA surface for use in taking snapshots in 1x mode
|
||||||
myBaseTiaSurface = myFB.allocateSurface(kTIAW*2, kTIAH);
|
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);
|
myFilter = Filter(enable ? uInt8(myFilter) | 0x10 : uInt8(myFilter) & 0x01);
|
||||||
|
|
||||||
// Normal vs NTSC mode uses different source widths
|
// 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();
|
FBSurface::Attributes& tia_attr = myTiaSurface->attributes();
|
||||||
tia_attr.smoothing = myOSystem.settings().getBool("tia.inter");
|
tia_attr.smoothing = myOSystem.settings().getBool("tia.inter");
|
||||||
|
@ -275,6 +275,8 @@ void TIASurface::enableNTSC(bool enable)
|
||||||
|
|
||||||
myTiaSurface->setDirty();
|
myTiaSurface->setDirty();
|
||||||
mySLineSurface->setDirty();
|
mySLineSurface->setDirty();
|
||||||
|
|
||||||
|
memset(myRGBFramebuffer, 0, AtariNTSC::outWidth(kTIAW) * kTIAH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -365,8 +367,29 @@ void TIASurface::render()
|
||||||
|
|
||||||
case Filter::BlarggPhosphor:
|
case Filter::BlarggPhosphor:
|
||||||
{
|
{
|
||||||
|
// First do Blargg filtering
|
||||||
myNTSCFilter.blit_single(myTIA->frameBuffer(), width, height,
|
myNTSCFilter.blit_single(myTIA->frameBuffer(), width, height,
|
||||||
out, outPitch << 2);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ class TIASurface
|
||||||
|
|
||||||
enum TIAConstants {
|
enum TIAConstants {
|
||||||
kTIAW = 160,
|
kTIAW = 160,
|
||||||
kTIAH = 320,
|
kTIAH = FrameManager::frameBufferHeight,
|
||||||
kScanH = kTIAH*2
|
kScanH = kTIAH*2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ class TIASurface
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
// Phosphor mode items (aka reduced flicker on 30Hz screens)
|
// Phosphor mode items (aka reduced flicker on 30Hz screens)
|
||||||
// RGB frame buffer
|
// RGB frame buffer
|
||||||
uInt32 myRGBFramebuffer[160 * FrameManager::frameBufferHeight];
|
uInt32 myRGBFramebuffer[AtariNTSC::outWidth(kTIAW) * kTIAH];
|
||||||
|
|
||||||
// Use phosphor effect
|
// Use phosphor effect
|
||||||
bool myUsePhosphor;
|
bool myUsePhosphor;
|
||||||
|
|
Loading…
Reference in New Issue