~ubuntu-branches/debian/squeeze/stella/squeeze

« back to all changes in this revision

Viewing changes to src/debugger/gui/DebuggerDialog.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Mario Iseli
  • Date: 2006-04-08 18:38:25 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20060408183825-vu1jk57rk929derx
* New Maintainer (Closes: #361345)
* New upstream release (Closes: #349725)
* Build-Depend now on libslang2-dev (Closes: #325577)
* Complete rebuild of debian/, upgraded to policy-standards
  3.6.2 and compat-level 5.
* Removed stellarc since stella only reads ~/.stellarc and even
  works without a first config.
* New debian/watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//============================================================================
 
2
//
 
3
//   SSSS    tt          lll  lll       
 
4
//  SS  SS   tt           ll   ll        
 
5
//  SS     tttttt  eeee   ll   ll   aaaa 
 
6
//   SSSS    tt   ee  ee  ll   ll      aa
 
7
//      SS   tt   eeeeee  ll   ll   aaaaa  --  "An Atari 2600 VCS Emulator"
 
8
//  SS  SS   tt   ee      ll   ll  aa  aa
 
9
//   SSSS     ttt  eeeee llll llll  aaaaa
 
10
//
 
11
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
 
12
//
 
13
// See the file "license" for information on usage and redistribution of
 
14
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
15
//
 
16
// $Id: DebuggerDialog.cxx,v 1.13 2006/03/23 16:16:32 stephena Exp $
 
17
//
 
18
//   Based on code from ScummVM - Scumm Interpreter
 
19
//   Copyright (C) 2002-2004 The ScummVM project
 
20
//============================================================================
 
21
 
 
22
#include "Widget.hxx"
 
23
#include "Dialog.hxx"
 
24
#include "TabWidget.hxx"
 
25
#include "TiaInfoWidget.hxx"
 
26
#include "TiaOutputWidget.hxx"
 
27
#include "TiaZoomWidget.hxx"
 
28
#include "AudioWidget.hxx"
 
29
#include "PromptWidget.hxx"
 
30
#include "CpuWidget.hxx"
 
31
#include "RamWidget.hxx"
 
32
#include "RomWidget.hxx"
 
33
#include "TiaWidget.hxx"
 
34
#include "DataGridOpsWidget.hxx"
 
35
#include "EditTextWidget.hxx"
 
36
#include "Rect.hxx"
 
37
#include "Debugger.hxx"
 
38
#include "DebuggerParser.hxx"
 
39
 
 
40
#include "DebuggerDialog.hxx"
 
41
 
 
42
enum {
 
43
  kDDStepCmd  = 'DDst',
 
44
  kDDTraceCmd = 'DDtr',
 
45
  kDDAdvCmd   = 'DDav',
 
46
  kDDSAdvCmd  = 'DDsv',
 
47
  kDDExitCmd  = 'DDex'
 
48
};
 
49
 
 
50
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
51
DebuggerDialog::DebuggerDialog(OSystem* osystem, DialogContainer* parent,
 
52
                               int x, int y, int w, int h)
 
53
  : Dialog(osystem, parent, x, y, w, h),
 
54
    myTab(NULL)
 
55
{
 
56
  addTiaArea();
 
57
  addTabArea();
 
58
  addStatusArea();
 
59
  addRomArea();
 
60
 
 
61
  // Inform the output widget about its associated zoom widget
 
62
  myTiaOutput->setZoomWidget(myTiaZoom);
 
63
}
 
64
 
 
65
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
66
DebuggerDialog::~DebuggerDialog()
 
67
{
 
68
}
 
69
 
 
70
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
71
void DebuggerDialog::loadConfig()
 
72
{
 
73
  myTab->loadConfig();
 
74
  myTiaInfo->loadConfig();
 
75
  myTiaOutput->loadConfig();
 
76
  myTiaZoom->loadConfig();
 
77
  myCpu->loadConfig();
 
78
  myRam->loadConfig();
 
79
  myRom->loadConfig();
 
80
 
 
81
  myMessageBox->setEditString("");
 
82
}
 
83
 
 
84
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
85
void DebuggerDialog::handleKeyDown(int ascii, int keycode, int modifiers)
 
86
{
 
87
  // Doing this means we disallow 'Alt xxx' events to any widget in the tabset
 
88
  if(instance()->eventHandler().kbdAlt(modifiers))
 
89
  {
 
90
    switch(ascii)
 
91
    {
 
92
      case 's':
 
93
        doStep();
 
94
        break;
 
95
      case 't':
 
96
        doTrace();
 
97
        break;
 
98
      case 'f':
 
99
        doAdvance();
 
100
        break;
 
101
      case 'l':
 
102
        doScanlineAdvance();
 
103
        break;
 
104
    }
 
105
  }
 
106
  else
 
107
    Dialog::handleKeyDown(ascii, keycode, modifiers);
 
108
}
 
109
 
 
110
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
111
void DebuggerDialog::handleCommand(CommandSender* sender, int cmd,
 
112
                                   int data, int id)
 
113
{
 
114
  // We reload the tabs in the cases where the actions could possibly
 
115
  // change their contents
 
116
  switch(cmd)
 
117
  {
 
118
    case kDDStepCmd:
 
119
      doStep();
 
120
      break;
 
121
 
 
122
    case kDDTraceCmd:
 
123
      doTrace();
 
124
      break;
 
125
 
 
126
    case kDDAdvCmd:
 
127
      doAdvance();
 
128
      break;
 
129
 
 
130
    case kDDSAdvCmd:
 
131
      doScanlineAdvance();
 
132
      break;
 
133
 
 
134
    case kDDExitCmd:
 
135
      doExit();
 
136
      break;
 
137
 
 
138
    default:
 
139
      Dialog::handleCommand(sender, cmd, data, id);
 
140
  }
 
141
}
 
142
 
 
143
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
144
void DebuggerDialog::addTiaArea()
 
145
{
 
146
  GUI::Rect r = instance()->debugger().getTiaBounds();
 
147
 
 
148
  myTiaOutput = new TiaOutputWidget(this, instance()->consoleFont(),
 
149
                                    r.left, r.top, r.width(), r.height());
 
150
}
 
151
 
 
152
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
153
void DebuggerDialog::addTabArea()
 
154
{
 
155
  GUI::Rect r = instance()->debugger().getTabBounds();
 
156
 
 
157
  const int vBorder = 4;
 
158
 
 
159
  // The tab widget
 
160
  myTab = new TabWidget(this, instance()->consoleFont(), r.left, r.top + vBorder,
 
161
                        r.width(), r.height() - vBorder);
 
162
  addTabWidget(myTab);
 
163
 
 
164
  const int widWidth  = r.width() - vBorder;
 
165
  const int widHeight = r.height() - myTab->getTabHeight() - vBorder - 4;
 
166
  int tabID;
 
167
 
 
168
  // The Prompt/console tab
 
169
  tabID = myTab->addTab("Prompt");
 
170
  myPrompt = new PromptWidget(myTab, instance()->consoleFont(),
 
171
                              2, 2, widWidth, widHeight);
 
172
  myTab->setParentWidget(tabID, myPrompt);
 
173
  addToFocusList(myPrompt->getFocusList(), tabID);
 
174
 
 
175
  // The TIA tab
 
176
  tabID = myTab->addTab("TIA");
 
177
  TiaWidget* tia = new TiaWidget(myTab, instance()->consoleFont(),
 
178
                                 2, 2, widWidth, widHeight);
 
179
  myTab->setParentWidget(tabID, tia);
 
180
  addToFocusList(tia->getFocusList(), tabID);
 
181
 
 
182
  // The Audio tab
 
183
  tabID = myTab->addTab("Audio");
 
184
  AudioWidget* aud = new AudioWidget(myTab, instance()->consoleFont(),
 
185
                                     2, 2, widWidth, widHeight);
 
186
  myTab->setParentWidget(tabID, aud);
 
187
  addToFocusList(aud->getFocusList(), tabID);
 
188
 
 
189
  // The input/output tab (part of RIOT)
 
190
//  tabID = myTab->addTab("I/O");
 
191
 
 
192
  myTab->setActiveTab(0);
 
193
}
 
194
 
 
195
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
196
void DebuggerDialog::addStatusArea()
 
197
{
 
198
  const GUI::Font& font = instance()->consoleFont();
 
199
  GUI::Rect r = instance()->debugger().getStatusBounds();
 
200
  int xpos, ypos;
 
201
 
 
202
  xpos = r.left;  ypos = r.top;
 
203
  myTiaInfo = new TiaInfoWidget(this, instance()->consoleFont(), xpos, ypos);
 
204
 
 
205
  ypos += myTiaInfo->getHeight() + 10;
 
206
  myTiaZoom = new TiaZoomWidget(this, instance()->consoleFont(), xpos+10, ypos);
 
207
  addToFocusList(myTiaZoom->getFocusList());
 
208
 
 
209
  xpos += 10;  ypos += myTiaZoom->getHeight() + 20;
 
210
  myMessageBox = new EditTextWidget(this, instance()->consoleFont(),
 
211
                                    xpos, ypos, myTiaZoom->getWidth(),
 
212
                                    font.getLineHeight(), "");
 
213
  myMessageBox->setEditable(false);
 
214
  myMessageBox->setColor(kTextColorEm);
 
215
}
 
216
 
 
217
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
218
void DebuggerDialog::addRomArea()
 
219
{
 
220
  GUI::Rect r = instance()->debugger().getRomBounds();
 
221
  int xpos, ypos;
 
222
 
 
223
  xpos = r.left + 10;  ypos = 10;
 
224
  myCpu = new CpuWidget(this, instance()->consoleFont(), xpos, ypos);
 
225
  addToFocusList(myCpu->getFocusList());
 
226
 
 
227
  xpos = r.left + 10;  ypos += myCpu->getHeight() + 10;
 
228
  myRam = new RamWidget(this, instance()->consoleFont(), xpos, ypos);
 
229
  addToFocusList(myRam->getFocusList());
 
230
 
 
231
  xpos = r.left + 10 + myCpu->getWidth() + 20;
 
232
  DataGridOpsWidget* ops = new DataGridOpsWidget(this, instance()->consoleFont(),
 
233
                                                 xpos, 20);
 
234
 
 
235
  const int bwidth  = instance()->consoleFont().getStringWidth("Frame +1 "),
 
236
            bheight = instance()->consoleFont().getLineHeight() + 2;
 
237
  int buttonX = r.right - bwidth - 5, buttonY = r.top + 5;
 
238
 
 
239
  new ButtonWidget(this, instance()->consoleFont(), buttonX, buttonY,
 
240
                   bwidth, bheight, "Step", kDDStepCmd);
 
241
  buttonY += bheight + 4;
 
242
  new ButtonWidget(this, instance()->consoleFont(), buttonX, buttonY,
 
243
                   bwidth, bheight, "Trace", kDDTraceCmd);
 
244
  buttonY += bheight + 4;
 
245
  new ButtonWidget(this, instance()->consoleFont(), buttonX, buttonY,
 
246
                   bwidth, bheight, "Scan +1", kDDSAdvCmd);
 
247
  buttonY += bheight + 4;
 
248
  new ButtonWidget(this, instance()->consoleFont(), buttonX, buttonY,
 
249
                   bwidth, bheight, "Frame +1", kDDAdvCmd);
 
250
  buttonY += bheight + 4;
 
251
  new ButtonWidget(this, instance()->consoleFont(), buttonX, buttonY,
 
252
                   bwidth, bheight, "Exit", kDDExitCmd);
 
253
  buttonY += bheight + 4;
 
254
 
 
255
  xpos = r.left + 10;  ypos += myRam->getHeight() + 5;
 
256
  myRom = new RomWidget(this, instance()->consoleFont(), xpos, ypos);
 
257
  addToFocusList(myRom->getFocusList());
 
258
 
 
259
  // Add the DataGridOpsWidget to any widgets which contain a
 
260
  // DataGridWidget which we want controlled
 
261
  myCpu->setOpsWidget(ops);
 
262
  myRam->setOpsWidget(ops);
 
263
}
 
264
 
 
265
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
266
void DebuggerDialog::doStep()
 
267
{
 
268
  instance()->debugger().parser()->run("step");
 
269
}
 
270
 
 
271
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
272
void DebuggerDialog::doTrace()
 
273
{
 
274
  instance()->debugger().parser()->run("trace");
 
275
}
 
276
 
 
277
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
278
void DebuggerDialog::doAdvance()
 
279
{
 
280
  instance()->debugger().parser()->run("frame #1");
 
281
}
 
282
 
 
283
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
284
void DebuggerDialog::doScanlineAdvance()
 
285
{
 
286
  instance()->debugger().parser()->run("scanline #1");
 
287
}
 
288
 
 
289
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
290
void DebuggerDialog::doExit()
 
291
{
 
292
  instance()->debugger().quit();
 
293
}