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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Kitt
  • Date: 2010-07-12 23:49:36 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100712234936-juawrr3etzhr2qpv
Tags: 3.1.2-1
* New maintainer (closes: #532039).
* New upstream version (closes: #461121):
  - includes launcher (closes: #396058).
* Fix the reference to the X Window System in the description (closes:
  #411815).
* Move to main, DFSG-free ROMs are available (see README.Debian).
* Enhance the package description.
* Drop the libslang2-dev dependency (closes: #560274).
* Remove the Encoding entry from stella.desktop.
* Avoid ignoring errors when cleaning.
* Add ${misc:Depends} to the package dependencies.
* Provide a doc-base file to install the documentation using doc-base.
* Switch to debhelper 7 with a simplified rules file.
* Use autotools-dev to provide updated configuration files.
* Update to Standards-Version 3.9.0:
  - Move to menu section Applications/Emulators.
  - Move the homepage declaration.
* Re-write the manpage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
//  SS  SS   tt   ee      ll   ll  aa  aa
9
9
//   SSSS     ttt  eeeee llll llll  aaaaa
10
10
//
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
12
13
//
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.
15
16
//
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 $
17
18
//
18
19
//   Based on code from ScummVM - Scumm Interpreter
19
20
//   Copyright (C) 2002-2004 The ScummVM project
44
45
  _type = kTiaOutputWidget;
45
46
 
46
47
  // Create context menu for commands
47
 
  myMenu = new ContextMenu(this, font);
48
 
 
49
 
  StringList l;
50
 
  l.push_back("Fill to scanline");
51
 
  l.push_back("Set breakpoint");
52
 
  l.push_back("Set zoom position");
53
 
 
54
 
  myMenu->setList(l);
 
48
  StringMap l;
 
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);
55
53
}
56
54
 
57
55
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
67
65
}
68
66
 
69
67
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
70
 
void TiaOutputWidget::advanceScanline(int lines)
71
 
{
72
 
  while(lines)
73
 
  {
74
 
    instance()->console().mediaSource().updateScanline();
75
 
    --lines;
76
 
  }
77
 
}
78
 
 
79
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
80
 
void TiaOutputWidget::advance(int frames)
81
 
{
82
 
  while(frames)
83
 
  {
84
 
    instance()->console().mediaSource().update();
85
 
    --frames;
86
 
  }
87
 
}
88
 
 
89
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
90
68
void TiaOutputWidget::handleMouseDown(int x, int y, int button, int clickCount)
91
69
{
92
70
  // Grab right mouse button for command context menu
95
73
    myClickX = x;
96
74
    myClickY = y;
97
75
 
98
 
    myMenu->setPos(x + getAbsX(), y + getAbsY());
99
 
    myMenu->show();
 
76
    // Add menu at current x,y mouse location
 
77
    myMenu->show(x + getAbsX(), y + getAbsY());
100
78
  }
101
79
}
102
80
 
103
81
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104
82
void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
105
83
{
106
 
  int ystart = atoi(instance()->console().properties().get(Display_YStart).c_str());
 
84
  int ystart = atoi(instance().console().properties().get(Display_YStart).c_str());
107
85
 
108
86
  switch(cmd)
109
87
  {
110
88
    case kCMenuItemSelectedCmd:
111
 
      switch(myMenu->getSelected())
112
 
      {
113
 
        case 0:
114
 
        {
115
 
          ostringstream command;
116
 
          int lines = myClickY + ystart -
117
 
              instance()->debugger().tiaDebug().scanlines();
118
 
          if(lines > 0)
119
 
          {
120
 
            command << "scanline #" << lines;
121
 
            instance()->debugger().parser().run(command.str());
122
 
          }
123
 
          break;
124
 
        }
125
 
 
126
 
        case 1:
127
 
        {
128
 
          ostringstream command;
129
 
          int scanline = myClickY + ystart;
130
 
          command << "breakif _scan==#" << scanline;
131
 
          instance()->debugger().parser().run(command.str());
132
 
          break;
133
 
        }
134
 
 
135
 
        case 2:
136
 
          if(myZoom)
137
 
            myZoom->setPos(myClickX, myClickY);
138
 
          break;
 
89
    {
 
90
      const string& rmb = myMenu->getSelectedTag();
 
91
 
 
92
      if(rmb == "scanline")
 
93
      {
 
94
        ostringstream command;
 
95
        int lines = myClickY + ystart;
 
96
        if(instance().console().tia().partialFrame())
 
97
          lines -= instance().console().tia().scanlines();
 
98
        if(lines > 0)
 
99
        {
 
100
          command << "scanline #" << lines;
 
101
          instance().debugger().parser().run(command.str());
 
102
        }
 
103
      }
 
104
      else if(rmb == "bp")
 
105
      {
 
106
        ostringstream command;
 
107
        int scanline = myClickY + ystart;
 
108
        command << "breakif _scan==#" << scanline;
 
109
        instance().debugger().parser().run(command.str());
 
110
      }
 
111
      else if(rmb == "zoom")
 
112
      {
 
113
        if(myZoom)
 
114
          myZoom->setPos(myClickX, myClickY);
139
115
      }
140
116
      break;
 
117
    }
141
118
  }
142
119
}
143
120
 
144
121
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
145
122
void TiaOutputWidget::drawWidget(bool hilite)
146
123
{
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();
 
126
 
 
127
  const uInt32 width  = instance().console().tia().width(),
 
128
               height = instance().console().tia().height();
 
129
 
 
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;
 
136
 
 
137
  for(uInt32 y = 0, i = 0; y < height; ++y)
 
138
  {
 
139
    uInt32* line_ptr = myLineBuffer;
 
140
    for(uInt32 x = 0; x < width; ++x, ++i)
 
141
    {
 
142
      uInt8 shift = i > scanoffset ? 1 : 0;
 
143
      uInt32 pixel = instance().frameBuffer().tiaPixel(i, shift);
 
144
      *line_ptr++ = pixel;
 
145
      *line_ptr++ = pixel;
 
146
    }
 
147
    s.drawPixels(myLineBuffer, _x, _y+y, width << 1);
 
148
  }
 
149
 
 
150
  // Show electron beam position
 
151
  if(visible && scanx < width && scany+2u < height)
 
152
  {
 
153
    s.fillRect(_x+(scanx<<1), _y+scany, 3, 3, kBtnTextColor);
 
154
  }
150
155
}