~ubuntu-branches/debian/sid/stella/sid

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Stephen Kitt
  • Date: 2013-06-28 09:53:13 UTC
  • mfrom: (1.3.6)
  • Revision ID: package-import@ubuntu.com-20130628095313-j8jkkgxpvx1t18ym
Tags: 3.9-1
New upstream version.

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-2013 by Bradford W. Mott, Stephen Anthony
 
12
// and the Stella Team
 
13
//
 
14
// See the file "License.txt" for information on usage and redistribution of
 
15
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
16
//
 
17
// $Id: CartX07Widget.cxx 2743 2013-05-29 16:27:12Z stephena $
 
18
//============================================================================
 
19
 
 
20
#include "CartX07.hxx"
 
21
#include "PopUpWidget.hxx"
 
22
#include "CartX07Widget.hxx"
 
23
 
 
24
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
25
CartridgeX07Widget::CartridgeX07Widget(
 
26
      GuiObject* boss, const GUI::Font& font,
 
27
      int x, int y, int w, int h, CartridgeX07& cart)
 
28
  : CartDebugWidget(boss, font, x, y, w, h),
 
29
    myCart(cart)
 
30
{
 
31
  uInt32 size = 16 * 4096;
 
32
 
 
33
  ostringstream info;
 
34
  info << "64K X07 cartridge, 16 4K banks\n"
 
35
       << "Startup bank = " << cart.myStartBank << "\n"
 
36
       << "Multiple hotspots, all below $1000\n"
 
37
       << "See documentation for further details\n";
 
38
 
 
39
  // Eventually, we should query this from the debugger/disassembler
 
40
  for(uInt32 i = 0, offset = 0xFFC; i < 16; ++i, offset += 0x1000)
 
41
  {
 
42
    uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
 
43
    start -= start % 0x1000;
 
44
    info << "Bank " << dec << i << " @ $" << HEX4 << start << " - "
 
45
         << "$" << (start + 0xFFF) << "\n";
 
46
  }
 
47
 
 
48
  int xpos = 10,
 
49
      ypos = addBaseInformation(size, "AtariAge / John Payson / Fred Quimby",
 
50
                                info.str()) + myLineHeight;
 
51
 
 
52
  VariantList items;
 
53
  items.push_back("  0");
 
54
  items.push_back("  1");
 
55
  items.push_back("  2");
 
56
  items.push_back("  3");
 
57
  items.push_back("  4");
 
58
  items.push_back("  5");
 
59
  items.push_back("  6");
 
60
  items.push_back("  7");
 
61
  items.push_back("  8");
 
62
  items.push_back("  9");
 
63
  items.push_back(" 10");
 
64
  items.push_back(" 11");
 
65
  items.push_back(" 12");
 
66
  items.push_back(" 13");
 
67
  items.push_back(" 14");
 
68
  items.push_back(" 15");
 
69
  myBank =
 
70
    new PopUpWidget(boss, font, xpos, ypos-2, font.getStringWidth(" 15 "),
 
71
                    myLineHeight, items, "Set bank: ",
 
72
                    font.getStringWidth("Set bank: "), kBankChanged);
 
73
  myBank->setTarget(this);
 
74
  addFocusWidget(myBank);
 
75
}
 
76
 
 
77
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
78
void CartridgeX07Widget::loadConfig()
 
79
{
 
80
  myBank->setSelected(myCart.myCurrentBank);
 
81
 
 
82
  CartDebugWidget::loadConfig();
 
83
}
 
84
 
 
85
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
86
void CartridgeX07Widget::handleCommand(CommandSender* sender,
 
87
                                      int cmd, int data, int id)
 
88
{
 
89
  if(cmd == kBankChanged)
 
90
  {
 
91
    myCart.unlockBank();
 
92
    myCart.bank(myBank->getSelected());
 
93
    myCart.lockBank();
 
94
    invalidate();
 
95
  }
 
96
}
 
97
 
 
98
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
99
string CartridgeX07Widget::bankState()
 
100
{
 
101
  ostringstream& buf = buffer();
 
102
 
 
103
  buf << "Bank = " << myCart.myCurrentBank;
 
104
 
 
105
  return buf.str();
 
106
}