Skip to content

Commit

Permalink
Made VblankManager::ystart() always return a valid ystart, either
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sa666666 committed Mar 4, 2017
1 parent ff3f4f1 commit b5b058c
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 91 deletions.
4 changes: 2 additions & 2 deletions src/debugger/gui/TiaOutputWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/debugger/gui/TiaZoomWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
54 changes: 0 additions & 54 deletions src/emucore/tia/FrameManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/emucore/tia/FrameManager.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,35 @@ 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(); }

bool vsync() const { return myVsync; }

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).
Expand Down
2 changes: 1 addition & 1 deletion src/emucore/tia/TIA.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/emucore/tia/TIA.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 5 additions & 17 deletions src/emucore/tia/VblankManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -71,12 +71,6 @@ bool VblankManager::nextLine(bool isGarbageFrame)
return transition;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void VblankManager::setVblankLines(uInt32 vblankLines)
{
myVblankLines = vblankLines;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void VblankManager::setYstart(uInt32 ystart)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -210,4 +198,4 @@ bool VblankManager::load(Serializer& in)
}

return false;
}
}
12 changes: 6 additions & 6 deletions src/emucore/tia/VblankManager.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -70,7 +70,7 @@ class VblankManager : public Serializable
private:

uInt32 myVblankLines;
uInt32 myMaxUnderscan;
//uInt32 myMaxUnderscan;
uInt32 myYstart;
bool myVblank;
uInt32 myCurrentLine;
Expand All @@ -92,4 +92,4 @@ class VblankManager : public Serializable

};

#endif // TIA_VBLANK_MANAGER
#endif // TIA_VBLANK_MANAGER

1 comment on commit b5b058c

@sa666666
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that this change has a side-effect of not causing the display to 'jump' to ystart=1 when dynamically changing ystart with the Alt-PgUp/Alt-PgDn keys. Instead, it simply updates ystart from its current value. This is visually nice.

However, if we happen to manually set the ystart back to the same value as auto-detection would have detected and then save the ROM properties, then it will save the actual value instead of resetting to 0 (for auto-detection to happen again). I will fix this soon.

Please sign in to comment.