8
8
// SS SS tt ee ll ll aa aa
9
9
// SSSS ttt eeeee llll llll aaaaa
11
// Copyright (c) 1995-2008 by Bradford W. Mott and the Stella team
11
// Copyright (c) 1995-2010 by Bradford W. Mott, Stephen Anthony
12
// and the Stella Team
13
// See the file "license" for information on usage and redistribution of
14
// See the file "License.txt" for information on usage and redistribution of
14
15
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16
// $Id: TiaOutputWidget.cxx,v 1.15 2008/03/23 17:43:22 stephena Exp $
17
// $Id: TiaOutputWidget.cxx 2001 2010-04-10 21:37:23Z stephena $
18
19
// Based on code from ScummVM - Scumm Interpreter
19
20
// Copyright (C) 2002-2004 The ScummVM project
44
45
_type = kTiaOutputWidget;
46
47
// Create context menu for commands
47
myMenu = new ContextMenu(this, font);
50
l.push_back("Fill to scanline");
51
l.push_back("Set breakpoint");
52
l.push_back("Set zoom position");
49
l.push_back("Fill to scanline", "scanline");
50
l.push_back("Set breakpoint", "bp");
51
l.push_back("Set zoom position", "zoom");
52
myMenu = new ContextMenu(this, font, l);
57
55
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
69
67
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
70
void TiaOutputWidget::advanceScanline(int lines)
74
instance()->console().mediaSource().updateScanline();
79
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
80
void TiaOutputWidget::advance(int frames)
84
instance()->console().mediaSource().update();
89
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
90
68
void TiaOutputWidget::handleMouseDown(int x, int y, int button, int clickCount)
92
70
// Grab right mouse button for command context menu
98
myMenu->setPos(x + getAbsX(), y + getAbsY());
76
// Add menu at current x,y mouse location
77
myMenu->show(x + getAbsX(), y + getAbsY());
103
81
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104
82
void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
106
int ystart = atoi(instance()->console().properties().get(Display_YStart).c_str());
84
int ystart = atoi(instance().console().properties().get(Display_YStart).c_str());
110
88
case kCMenuItemSelectedCmd:
111
switch(myMenu->getSelected())
115
ostringstream command;
116
int lines = myClickY + ystart -
117
instance()->debugger().tiaDebug().scanlines();
120
command << "scanline #" << lines;
121
instance()->debugger().parser().run(command.str());
128
ostringstream command;
129
int scanline = myClickY + ystart;
130
command << "breakif _scan==#" << scanline;
131
instance()->debugger().parser().run(command.str());
137
myZoom->setPos(myClickX, myClickY);
90
const string& rmb = myMenu->getSelectedTag();
94
ostringstream command;
95
int lines = myClickY + ystart;
96
if(instance().console().tia().partialFrame())
97
lines -= instance().console().tia().scanlines();
100
command << "scanline #" << lines;
101
instance().debugger().parser().run(command.str());
106
ostringstream command;
107
int scanline = myClickY + ystart;
108
command << "breakif _scan==#" << scanline;
109
instance().debugger().parser().run(command.str());
111
else if(rmb == "zoom")
114
myZoom->setPos(myClickX, myClickY);
144
121
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
145
122
void TiaOutputWidget::drawWidget(bool hilite)
147
// FIXME - check if we're in 'greyed out mode' and act accordingly
148
instance()->frameBuffer().refresh();
149
instance()->frameBuffer().drawMediaSource();
124
//cerr << "TiaOutputWidget::drawWidget\n";
125
FBSurface& s = dialog().surface();
127
const uInt32 width = instance().console().tia().width(),
128
height = instance().console().tia().height();
130
// Get current scanline position
131
// This determines where the frame greying should start, and where a
132
// scanline 'pointer' should be drawn
133
uInt16 scanx, scany, scanoffset;
134
bool visible = instance().console().tia().scanlinePos(scanx, scany);
135
scanoffset = width * scany + scanx;
137
for(uInt32 y = 0, i = 0; y < height; ++y)
139
uInt32* line_ptr = myLineBuffer;
140
for(uInt32 x = 0; x < width; ++x, ++i)
142
uInt8 shift = i > scanoffset ? 1 : 0;
143
uInt32 pixel = instance().frameBuffer().tiaPixel(i, shift);
147
s.drawPixels(myLineBuffer, _x, _y+y, width << 1);
150
// Show electron beam position
151
if(visible && scanx < width && scany+2u < height)
153
s.fillRect(_x+(scanx<<1), _y+scany, 3, 3, kBtnTextColor);