Made VblankManager::ystart() always return a valid ystart, either

autocalculated or fixed.  This fixes selecting a scanline with the
mouse in TIA output widget in the debugger.

Made various methods inline for issue #7.
This commit is contained in:
Stephen Anthony 2017-03-03 21:57:36 -03:30
parent ff3f4f1a39
commit b5b058c615
8 changed files with 25 additions and 91 deletions

View File

@ -99,7 +99,7 @@ void TiaOutputWidget::handleMouseDown(int x, int y, int button, int clickCount)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
{
int ystart = atoi(instance().console().properties().get(Display_YStart).c_str());
uInt32 ystart = instance().console().tia().ystart();
switch(cmd)
{
@ -155,7 +155,7 @@ void TiaOutputWidget::drawWidget(bool hilite)
// Get current scanline position
// This determines where the frame greying should start, and where a
// scanline 'pointer' should be drawn
uInt16 scanx, scany, scanoffset;
uInt32 scanx, scany, scanoffset;
bool visible = instance().console().tia().electronBeamPos(scanx, scany);
scanoffset = width * scany + scanx;

View File

@ -253,7 +253,7 @@ void TiaZoomWidget::drawWidget(bool hilite)
// Get current scanline position
// This determines where the frame greying should start
uInt16 scanx, scany, scanoffset;
uInt32 scanx, scany, scanoffset;
instance().console().tia().electronBeamPos(scanx, scany);
scanoffset = width * scany + scanx;

View File

@ -282,18 +282,6 @@ void FrameManager::updateTvMode(TvMode mode)
myVblankManager.setVblankLines(myVblankLines);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::setYstart(uInt32 ystart)
{
myVblankManager.setYstart(ystart);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 FrameManager::ystart() const
{
return myVblankManager.ystart();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::setVblank(bool vblank)
{
@ -305,54 +293,12 @@ void FrameManager::setVblank(bool vblank)
myVblankManager.setVblank(vblank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FrameManager::isRendering() const
{
return myState == State::frame;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TvMode FrameManager::tvMode() const
{
return myMode;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 FrameManager::height() const
{
return myFixedHeight > 0 ? myFixedHeight : (myKernelLines + Metrics::visibleOverscan);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::setFixedHeight(uInt32 height)
{
myFixedHeight = height;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 FrameManager::scanlines() const
{
return myCurrentFrameTotalLines;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 FrameManager::scanlinesLastFrame() const
{
return myCurrentFrameFinalLines;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::setTvMode(TvMode mode)
{
if (!myAutodetectTvMode) updateTvMode(mode);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::autodetectTvMode(bool toggle)
{
myAutodetectTvMode = toggle;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TODO: implement this once the class is finalized
bool FrameManager::save(Serializer& out) const

View File

@ -49,9 +49,9 @@ class FrameManager : public Serializable
void setVsync(bool vsync);
bool isRendering() const;
bool isRendering() const { return myState == State::frame; }
TvMode tvMode() const;
TvMode tvMode() const { return myMode; }
bool vblank() const { return myVblankManager.vblank(); }
@ -59,25 +59,25 @@ class FrameManager : public Serializable
uInt32 height() const;
void setFixedHeight(uInt32 height);
void setFixedHeight(uInt32 height) { myFixedHeight = height; }
uInt32 getY() const { return myY; }
uInt32 scanlines() const;
uInt32 scanlines() const { return myCurrentFrameTotalLines; }
uInt32 scanlinesLastFrame() const;
uInt32 scanlinesLastFrame() const { return myCurrentFrameFinalLines; }
uInt32 frameCount() const { return myTotalFrames; }
float frameRate() const { return myFrameRate; }
void setYstart(uInt32 ystart);
void setYstart(uInt32 ystart) { myVblankManager.setYstart(ystart); }
uInt32 ystart() const;
uInt32 ystart() const { return myVblankManager.ystart(); }
void autodetectTvMode(bool toggle);
void autodetectTvMode(bool toggle) { myAutodetectTvMode = toggle; }
void setTvMode(TvMode mode);
void setTvMode(TvMode mode) { if (!myAutodetectTvMode) updateTvMode(mode); }
/**
Serializable methods (see that class for more information).

View File

@ -640,7 +640,7 @@ void TIA::enableColorLoss(bool enabled)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TIA::electronBeamPos(uInt16& x, uInt16& y) const
bool TIA::electronBeamPos(uInt32& x, uInt32& y) const
{
x = clocksThisLine();
y = myFrameManager.getY();

View File

@ -227,7 +227,7 @@ class TIA : public Device
@return The x/y coordinates of the scanline electron beam, and whether
it is in the visible/viewable area of the screen
*/
bool electronBeamPos(uInt16& x, uInt16& y) const;
bool electronBeamPos(uInt32& x, uInt32& y) const;
/**
Enables/disable/toggle the specified (or all) TIA bit(s). Note that

View File

@ -20,15 +20,15 @@
#include "VblankManager.hxx"
enum Metrics: uInt32 {
maxUnderscan = 10,
maxVblankViolations = 2,
minStableVblankFrames = 1
maxUnderscan = 10,
maxVblankViolations = 2,
minStableVblankFrames = 1
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VblankManager::VblankManager()
: myVblankLines(0),
myMaxUnderscan(0),
//myMaxUnderscan(0),
myYstart(0),
myMode(VblankMode::floating)
{
@ -71,12 +71,6 @@ bool VblankManager::nextLine(bool isGarbageFrame)
return transition;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void VblankManager::setVblankLines(uInt32 vblankLines)
{
myVblankLines = vblankLines;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void VblankManager::setYstart(uInt32 ystart)
{
@ -87,12 +81,6 @@ void VblankManager::setYstart(uInt32 ystart)
myMode = ystart ? VblankMode::fixed : VblankMode::floating;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void VblankManager::setVblank(bool vblank)
{
myVblank = vblank;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool VblankManager::setVblankDuringVblank(bool vblank, bool isGarbageFrame)
{
@ -210,4 +198,4 @@ bool VblankManager::load(Serializer& in)
}
return false;
}
}

View File

@ -34,19 +34,19 @@ class VblankManager : public Serializable
bool nextLine(bool isGarbageFrame);
void setVblankLines(uInt32 lines);
void setVblankLines(uInt32 lines) { myVblankLines = lines; }
void setYstart(uInt32 ystart);
uInt32 ystart() const { return myYstart; }
uInt32 ystart() const { return myYstart == 0 ? myLastVblankLines : myYstart; }
void setVblank(bool vblank);
void setVblank(bool vblank) { myVblank = vblank; }
bool setVblankDuringVblank(bool vblank, bool isGarbageFrame);
bool vblank() const { return myVblank; }
uInt32 currentLine() const {return myCurrentLine; };
uInt32 currentLine() const { return myCurrentLine; };
/**
Serializable methods (see that class for more information).
@ -70,7 +70,7 @@ class VblankManager : public Serializable
private:
uInt32 myVblankLines;
uInt32 myMaxUnderscan;
//uInt32 myMaxUnderscan;
uInt32 myYstart;
bool myVblank;
uInt32 myCurrentLine;
@ -92,4 +92,4 @@ class VblankManager : public Serializable
};
#endif // TIA_VBLANK_MANAGER
#endif // TIA_VBLANK_MANAGER