2005-07-14 23:47:17 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2015-01-01 03:49:32 +00:00
|
|
|
// Copyright (c) 1995-2015 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2005-07-14 23:47:17 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2005-07-14 23:47:17 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2005-07-14 23:47:17 +00:00
|
|
|
//============================================================================
|
|
|
|
|
2005-09-15 19:43:36 +00:00
|
|
|
#include <sstream>
|
|
|
|
|
2005-07-14 23:47:17 +00:00
|
|
|
#include "OSystem.hxx"
|
|
|
|
#include "FrameBuffer.hxx"
|
2005-08-30 17:51:26 +00:00
|
|
|
#include "Widget.hxx"
|
2005-07-14 23:47:17 +00:00
|
|
|
#include "GuiObject.hxx"
|
2005-08-31 22:34:43 +00:00
|
|
|
#include "ContextMenu.hxx"
|
|
|
|
#include "TiaZoomWidget.hxx"
|
2005-09-01 16:49:52 +00:00
|
|
|
#include "Debugger.hxx"
|
2005-09-15 19:43:36 +00:00
|
|
|
#include "DebuggerParser.hxx"
|
2005-09-01 16:49:52 +00:00
|
|
|
#include "TIADebug.hxx"
|
2014-05-12 23:34:25 +00:00
|
|
|
#include "TIASurface.hxx"
|
2010-10-18 18:39:57 +00:00
|
|
|
#include "TIA.hxx"
|
2005-08-30 17:51:26 +00:00
|
|
|
|
|
|
|
#include "TiaOutputWidget.hxx"
|
2005-07-14 23:47:17 +00:00
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2006-02-22 17:38:04 +00:00
|
|
|
TiaOutputWidget::TiaOutputWidget(GuiObject* boss, const GUI::Font& font,
|
|
|
|
int x, int y, int w, int h)
|
|
|
|
: Widget(boss, font, x, y, w, h),
|
2005-08-31 22:34:43 +00:00
|
|
|
CommandSender(boss),
|
2014-11-09 03:05:19 +00:00
|
|
|
myZoom(nullptr),
|
2014-10-27 14:41:46 +00:00
|
|
|
myClickX(0),
|
|
|
|
myClickY(0)
|
2005-07-14 23:47:17 +00:00
|
|
|
{
|
2005-08-31 22:34:43 +00:00
|
|
|
// Create context menu for commands
|
2013-05-09 14:22:34 +00:00
|
|
|
VariantList l;
|
2014-11-19 22:29:33 +00:00
|
|
|
VarList::push_back(l, "Fill to scanline", "scanline");
|
|
|
|
VarList::push_back(l, "Set breakpoint", "bp");
|
|
|
|
VarList::push_back(l, "Set zoom position", "zoom");
|
|
|
|
VarList::push_back(l, "Save snapshot", "snap");
|
|
|
|
VarList::push_back(l, "Toggle fixed debug colors (from beam pos)", "fixed");
|
2014-11-09 04:01:31 +00:00
|
|
|
myMenu = make_ptr<ContextMenu>(this, font, l);
|
2005-07-14 23:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-08-30 17:51:26 +00:00
|
|
|
TiaOutputWidget::~TiaOutputWidget()
|
2005-07-14 23:47:17 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-08-01 22:33:16 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-08-30 17:51:26 +00:00
|
|
|
void TiaOutputWidget::loadConfig()
|
2005-08-01 22:33:16 +00:00
|
|
|
{
|
2015-03-21 20:00:00 +00:00
|
|
|
setDirty();
|
2005-08-01 22:33:16 +00:00
|
|
|
}
|
|
|
|
|
2014-06-15 19:25:46 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void TiaOutputWidget::saveSnapshot()
|
|
|
|
{
|
2014-06-30 00:54:30 +00:00
|
|
|
int number = (int)(instance().getTicks() / 1000);
|
2014-06-20 23:01:11 +00:00
|
|
|
ostringstream sspath;
|
|
|
|
sspath << instance().snapshotSaveDir()
|
|
|
|
<< instance().console().properties().get(Cartridge_Name)
|
|
|
|
<< "_dbg_" << hex << setw(8) << setfill('0') << number << ".png";
|
|
|
|
|
|
|
|
const uInt32 width = instance().console().tia().width(),
|
|
|
|
height = instance().console().tia().height();
|
|
|
|
FBSurface& s = dialog().surface();
|
|
|
|
|
|
|
|
GUI::Rect rect(_x, _y, _x + width*2, _y + height);
|
|
|
|
string message = "Snapshot saved";
|
|
|
|
try
|
|
|
|
{
|
|
|
|
instance().png().saveImage(sspath.str(), s, rect);
|
|
|
|
}
|
2015-06-12 20:44:09 +00:00
|
|
|
catch(const runtime_error& e)
|
2014-06-20 23:01:11 +00:00
|
|
|
{
|
2015-06-12 20:44:09 +00:00
|
|
|
message = e.what();
|
2014-06-20 23:01:11 +00:00
|
|
|
}
|
|
|
|
instance().frameBuffer().showMessage(message);
|
2014-06-15 19:25:46 +00:00
|
|
|
}
|
|
|
|
|
2005-07-14 23:47:17 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-08-30 17:51:26 +00:00
|
|
|
void TiaOutputWidget::handleMouseDown(int x, int y, int button, int clickCount)
|
2005-07-14 23:47:17 +00:00
|
|
|
{
|
2005-09-01 16:49:52 +00:00
|
|
|
// Grab right mouse button for command context menu
|
2005-08-31 22:34:43 +00:00
|
|
|
if(button == 2)
|
|
|
|
{
|
2005-09-01 16:49:52 +00:00
|
|
|
myClickX = x;
|
|
|
|
myClickY = y;
|
2005-08-31 22:34:43 +00:00
|
|
|
|
2008-06-19 12:01:31 +00:00
|
|
|
// Add menu at current x,y mouse location
|
2008-12-23 18:54:05 +00:00
|
|
|
myMenu->show(x + getAbsX(), y + getAbsY());
|
2005-08-31 22:34:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
|
|
|
{
|
2008-06-13 13:14:52 +00:00
|
|
|
int ystart = atoi(instance().console().properties().get(Display_YStart).c_str());
|
2005-10-11 19:38:10 +00:00
|
|
|
|
2005-08-31 22:34:43 +00:00
|
|
|
switch(cmd)
|
|
|
|
{
|
2013-05-01 16:56:43 +00:00
|
|
|
case ContextMenu::kItemSelectedCmd:
|
2008-07-25 12:41:41 +00:00
|
|
|
{
|
2013-05-09 14:22:34 +00:00
|
|
|
const string& rmb = myMenu->getSelectedTag().toString();
|
2005-08-31 22:34:43 +00:00
|
|
|
|
2008-07-25 12:41:41 +00:00
|
|
|
if(rmb == "scanline")
|
|
|
|
{
|
|
|
|
ostringstream command;
|
2009-09-01 11:54:59 +00:00
|
|
|
int lines = myClickY + ystart;
|
|
|
|
if(instance().console().tia().partialFrame())
|
|
|
|
lines -= instance().console().tia().scanlines();
|
2008-07-25 12:41:41 +00:00
|
|
|
if(lines > 0)
|
2005-09-23 17:38:27 +00:00
|
|
|
{
|
2008-07-25 12:41:41 +00:00
|
|
|
command << "scanline #" << lines;
|
2008-06-13 13:14:52 +00:00
|
|
|
instance().debugger().parser().run(command.str());
|
2005-09-23 17:38:27 +00:00
|
|
|
}
|
2008-07-25 12:41:41 +00:00
|
|
|
}
|
|
|
|
else if(rmb == "bp")
|
|
|
|
{
|
|
|
|
ostringstream command;
|
|
|
|
int scanline = myClickY + ystart;
|
|
|
|
command << "breakif _scan==#" << scanline;
|
|
|
|
instance().debugger().parser().run(command.str());
|
|
|
|
}
|
|
|
|
else if(rmb == "zoom")
|
|
|
|
{
|
|
|
|
if(myZoom)
|
|
|
|
myZoom->setPos(myClickX, myClickY);
|
2005-08-31 22:34:43 +00:00
|
|
|
}
|
2013-09-12 22:37:01 +00:00
|
|
|
else if(rmb == "snap")
|
|
|
|
{
|
|
|
|
instance().debugger().parser().run("savesnap");
|
|
|
|
}
|
2012-01-29 22:54:23 +00:00
|
|
|
else if(rmb == "fixed")
|
|
|
|
{
|
|
|
|
instance().console().tia().toggleFixedColors();
|
|
|
|
}
|
2005-08-31 22:34:43 +00:00
|
|
|
break;
|
2008-07-25 12:41:41 +00:00
|
|
|
}
|
2005-08-31 22:34:43 +00:00
|
|
|
}
|
2005-08-30 17:51:26 +00:00
|
|
|
}
|
2005-07-14 23:47:17 +00:00
|
|
|
|
2005-08-30 17:51:26 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void TiaOutputWidget::drawWidget(bool hilite)
|
|
|
|
{
|
2009-01-03 22:57:12 +00:00
|
|
|
//cerr << "TiaOutputWidget::drawWidget\n";
|
2009-09-01 11:54:59 +00:00
|
|
|
const uInt32 width = instance().console().tia().width(),
|
2009-01-19 16:52:32 +00:00
|
|
|
height = instance().console().tia().height();
|
2014-06-15 19:25:46 +00:00
|
|
|
FBSurface& s = dialog().surface();
|
2009-09-01 11:54:59 +00:00
|
|
|
|
|
|
|
// Get current scanline position
|
|
|
|
// This determines where the frame greying should start, and where a
|
|
|
|
// scanline 'pointer' should be drawn
|
|
|
|
uInt16 scanx, scany, scanoffset;
|
|
|
|
bool visible = instance().console().tia().scanlinePos(scanx, scany);
|
|
|
|
scanoffset = width * scany + scanx;
|
|
|
|
|
|
|
|
for(uInt32 y = 0, i = 0; y < height; ++y)
|
2009-01-03 22:57:12 +00:00
|
|
|
{
|
2009-01-11 02:23:45 +00:00
|
|
|
uInt32* line_ptr = myLineBuffer;
|
2009-09-01 11:54:59 +00:00
|
|
|
for(uInt32 x = 0; x < width; ++x, ++i)
|
2009-01-03 22:57:12 +00:00
|
|
|
{
|
2009-09-01 11:54:59 +00:00
|
|
|
uInt8 shift = i > scanoffset ? 1 : 0;
|
2014-05-12 23:34:25 +00:00
|
|
|
uInt32 pixel = instance().frameBuffer().tiaSurface().pixel(i, shift);
|
2009-01-03 22:57:12 +00:00
|
|
|
*line_ptr++ = pixel;
|
|
|
|
*line_ptr++ = pixel;
|
|
|
|
}
|
2009-01-11 02:23:45 +00:00
|
|
|
s.drawPixels(myLineBuffer, _x, _y+y, width << 1);
|
2009-01-03 22:57:12 +00:00
|
|
|
}
|
2009-09-01 11:54:59 +00:00
|
|
|
|
|
|
|
// Show electron beam position
|
|
|
|
if(visible && scanx < width && scany+2u < height)
|
|
|
|
{
|
2009-09-02 00:12:29 +00:00
|
|
|
s.fillRect(_x+(scanx<<1), _y+scany, 3, 3, kBtnTextColor);
|
2009-09-01 11:54:59 +00:00
|
|
|
}
|
2005-07-14 23:47:17 +00:00
|
|
|
}
|