reverse and limit vcenter

This commit is contained in:
thrust26 2020-01-11 20:28:55 +01:00
parent a530bdcfb7
commit 4580484835
7 changed files with 34 additions and 16 deletions

View File

@ -426,8 +426,8 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultCommo
{Event::VidmodeDecrease, KBDK_MINUS, MOD3},
{Event::VidmodeIncrease, KBDK_EQUALS, MOD3},
{Event::VCenterDecrease, KBDK_PAGEDOWN, MOD3},
{Event::VCenterIncrease, KBDK_PAGEUP, MOD3},
{Event::VCenterDecrease, KBDK_PAGEUP, MOD3},
{Event::VCenterIncrease, KBDK_PAGEDOWN, MOD3},
{Event::ScanlineAdjustDecrease, KBDK_PAGEDOWN, KBDM_SHIFT | MOD3},
{Event::ScanlineAdjustIncrease, KBDK_PAGEUP, KBDM_SHIFT | MOD3},
{Event::VolumeDecrease, KBDK_LEFTBRACKET, MOD3},

View File

@ -642,22 +642,20 @@ void Console::changeVerticalCenter(int direction)
if(direction == +1) // increase vcenter
{
if(vcenter >= TIAConstants::maxVcenter)
{
myOSystem.frameBuffer().showMessage("V-Center at minimum");
return;
}
++vcenter;
}
else if(direction == -1) // decrease vcenter
{
if (vcenter <= TIAConstants::minVcenter)
if(vcenter >= myTIA->maxVcenter())
{
myOSystem.frameBuffer().showMessage("V-Center at maximum");
return;
}
++vcenter;
}
else if(direction == -1) // decrease vcenter
{
if (vcenter <= myTIA->minVcenter())
{
myOSystem.frameBuffer().showMessage("V-Center at minimum");
return;
}
--vcenter;
}
else

View File

@ -252,6 +252,8 @@ class TIA : public Device
uInt32 width() const { return TIAConstants::H_PIXEL; }
uInt32 height() const { return myFrameManager->height(); }
Int32 vcenter() const { return myFrameManager->vcenter(); }
Int32 minVcenter() const { return myFrameManager->minVcenter(); }
Int32 maxVcenter() const { return myFrameManager->maxVcenter(); }
uInt32 startLine() const { return myFrameManager->startLine(); }
/**

View File

@ -24,8 +24,8 @@ namespace TIAConstants {
static constexpr uInt32 frameBufferWidth = 160;
static constexpr uInt32 frameBufferHeight = 320;
static constexpr Int32 maxVcenter = 20; // limit to reasonable values
static constexpr Int32 minVcenter = -20; // limit to reasonable values
static constexpr Int32 maxVcenter = 20; // limit to reasonable values
static constexpr uInt32 viewableWidth = 320;
static constexpr uInt32 viewableHeight = 240;
static constexpr uInt32 initialGarbageFrames = 10;

View File

@ -170,6 +170,17 @@ class AbstractFrameManager : public Serializable
*/
virtual Int32 vcenter() const { return 0; }
/**
* The calculated minimal vcenter value.
*/
virtual Int32 minVcenter() const { return 0; }
/**
* The calculated maximal vcenter value.
*/
virtual Int32 maxVcenter() const { return 0; }
virtual void setAdjustScanlines(Int32 adjustScanlines) {}
virtual Int32 adjustScanlines() const { return 0; }

View File

@ -244,7 +244,9 @@ void FrameManager::recalculateMetrics() {
}
myHeight = BSPF::clamp<uInt32>(baseHeight + myAdjustScanlines * 2, 0, myFrameLines);
myYStart = BSPF::clamp<uInt32>(ystartBase + (baseHeight - static_cast<Int32>(myHeight)) / 2 + myVcenter, 0, myFrameLines);
myYStart = BSPF::clamp<uInt32>(ystartBase + (baseHeight - static_cast<Int32>(myHeight)) / 2 - myVcenter, 0, myFrameLines);
// TODO: why "- 1" here: ???
myMaxVcenter = BSPF::clamp<Int32>(ystartBase + (baseHeight - static_cast<Int32>(myHeight)) / 2 - 1, 0, TIAConstants::maxVcenter);
myJitterEmulation.setYStart(myYStart);
}

View File

@ -48,6 +48,10 @@ class FrameManager: public AbstractFrameManager {
Int32 vcenter() const override { return myVcenter; }
Int32 minVcenter() const override { return TIAConstants::minVcenter; }
Int32 maxVcenter() const override { return myMaxVcenter; }
void setAdjustScanlines(Int32 adjustScanlines) override;
Int32 adjustScanlines() const override { return myAdjustScanlines; }
@ -97,6 +101,7 @@ class FrameManager: public AbstractFrameManager {
uInt32 myHeight{0};
uInt32 myYStart{0};
Int32 myVcenter{0};
Int32 myMaxVcenter{0};
Int32 myAdjustScanlines{0};
bool myJitterEnabled{false};