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

« back to all changes in this revision

Viewing changes to src/debugger/gui/CartEFWidget.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: CartEFWidget.cxx 2743 2013-05-29 16:27:12Z stephena $
 
18
//============================================================================
 
19
 
 
20
#include "CartEF.hxx"
 
21
#include "PopUpWidget.hxx"
 
22
#include "CartEFWidget.hxx"
 
23
 
 
24
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
25
CartridgeEFWidget::CartridgeEFWidget(
 
26
      GuiObject* boss, const GUI::Font& font,
 
27
      int x, int y, int w, int h, CartridgeEF& 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 H. Runner EF cartridge, 16 4K banks\n"
 
35
       << "Startup bank = " << cart.myStartBank << "\n";
 
36
 
 
37
  // Eventually, we should query this from the debugger/disassembler
 
38
  for(uInt32 i = 0, offset = 0xFFC, spot = 0xFE0; i < 16; ++i, offset += 0x1000)
 
39
  {
 
40
    uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
 
41
    start -= start % 0x1000;
 
42
    info << "Bank " << dec << i << " @ $" << HEX4 << start << " - "
 
43
         << "$" << (start + 0xFFF) << " (hotspot = $" << (spot+i) << ")\n";
 
44
  }
 
45
 
 
46
  int xpos = 10,
 
47
      ypos = addBaseInformation(size, "Paul Slocum / Homestar Runner",
 
48
                                info.str()) + myLineHeight;
 
49
 
 
50
  VariantList items;
 
51
  items.push_back(" 0 ($FE0)");
 
52
  items.push_back(" 1 ($FE1)");
 
53
  items.push_back(" 2 ($FE2)");
 
54
  items.push_back(" 3 ($FE3)");
 
55
  items.push_back(" 4 ($FE4)");
 
56
  items.push_back(" 5 ($FE5)");
 
57
  items.push_back(" 6 ($FE6)");
 
58
  items.push_back(" 7 ($FE7)");
 
59
  items.push_back(" 8 ($FE8)");
 
60
  items.push_back(" 9 ($FE9)");
 
61
  items.push_back("10 ($FEA)");
 
62
  items.push_back("11 ($FEB)");
 
63
  items.push_back("12 ($FEC)");
 
64
  items.push_back("13 ($FED)");
 
65
  items.push_back("14 ($FEE)");
 
66
  items.push_back("15 ($FEF)");
 
67
  myBank =
 
68
    new PopUpWidget(boss, font, xpos, ypos-2, font.getStringWidth("15 ($FE0) "),
 
69
                    myLineHeight, items, "Set bank: ",
 
70
                    font.getStringWidth("Set bank: "), kBankChanged);
 
71
  myBank->setTarget(this);
 
72
  addFocusWidget(myBank);
 
73
}
 
74
 
 
75
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
76
void CartridgeEFWidget::loadConfig()
 
77
{
 
78
  myBank->setSelected(myCart.myCurrentBank);
 
79
 
 
80
  CartDebugWidget::loadConfig();
 
81
}
 
82
 
 
83
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
84
void CartridgeEFWidget::handleCommand(CommandSender* sender,
 
85
                                      int cmd, int data, int id)
 
86
{
 
87
  if(cmd == kBankChanged)
 
88
  {
 
89
    myCart.unlockBank();
 
90
    myCart.bank(myBank->getSelected());
 
91
    myCart.lockBank();
 
92
    invalidate();
 
93
  }
 
94
}
 
95
 
 
96
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
97
string CartridgeEFWidget::bankState()
 
98
{
 
99
  ostringstream& buf = buffer();
 
100
 
 
101
  static const char* spot[] = {
 
102
    "$FE0", "$FE1", "$FE2", "$FE3", "$FE4", "$FE5", "$FE6", "$FE7",
 
103
    "$FE8", "$FE9", "$FEA", "$FEB", "$FEC", "$FED", "$FEE", "$FEF"
 
104
  };
 
105
  buf << "Bank = " << myCart.myCurrentBank
 
106
      << ", hotspot = " << spot[myCart.myCurrentBank];
 
107
 
 
108
  return buf.str();
 
109
}