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-2019 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
18#include "CartX07.hxx"
19#include "PopUpWidget.hxx"
20#include "CartX07Widget.hxx"
21
22// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
23CartridgeX07Widget::CartridgeX07Widget(
24 GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
25 int x, int y, int w, int h, CartridgeX07& cart)
26 : CartDebugWidget(boss, lfont, nfont, x, y, w, h),
27 myCart(cart)
28{
29 uInt32 size = 16 * 4096;
30
31 ostringstream info;
32 info << "64K X07 cartridge, 16 4K banks\n"
33 << "Startup bank = " << cart.startBank() << "\n"
34 << "Multiple hotspots, all below $1000\n"
35 << "See documentation for further details\n";
36
37 // Eventually, we should query this from the debugger/disassembler
38 for(uInt32 i = 0, offset = 0xFFC; i < 16; ++i, offset += 0x1000)
39 {
40 uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
41 start -= start % 0x1000;
42 info << "Bank " << std::dec << i << " @ $" << Common::Base::HEX4 << start
43 << " - " << "$" << (start + 0xFFF) << "\n";
44 }
45
46 int xpos = 2,
47 ypos = addBaseInformation(size, "AtariAge / John Payson / Fred Quimby",
48 info.str()) + myLineHeight;
49
50 VariantList items;
51 VarList::push_back(items, " 0");
52 VarList::push_back(items, " 1");
53 VarList::push_back(items, " 2");
54 VarList::push_back(items, " 3");
55 VarList::push_back(items, " 4");
56 VarList::push_back(items, " 5");
57 VarList::push_back(items, " 6");
58 VarList::push_back(items, " 7");
59 VarList::push_back(items, " 8");
60 VarList::push_back(items, " 9");
61 VarList::push_back(items, " 10");
62 VarList::push_back(items, " 11");
63 VarList::push_back(items, " 12");
64 VarList::push_back(items, " 13");
65 VarList::push_back(items, " 14");
66 VarList::push_back(items, " 15");
67 myBank =
68 new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth(" 15"),
69 myLineHeight, items, "Set bank ",
70 0, kBankChanged);
71 myBank->setTarget(this);
72 addFocusWidget(myBank);
73}
74
75// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
76void CartridgeX07Widget::loadConfig()
77{
78 Debugger& dbg = instance().debugger();
79 CartDebug& cart = dbg.cartDebug();
80 const CartState& state = static_cast<const CartState&>(cart.getState());
81 const CartState& oldstate = static_cast<const CartState&>(cart.getOldState());
82
83 myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank);
84
85 CartDebugWidget::loadConfig();
86}
87
88// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
89void CartridgeX07Widget::handleCommand(CommandSender* sender,
90 int cmd, int data, int id)
91{
92 if(cmd == kBankChanged)
93 {
94 myCart.unlockBank();
95 myCart.bank(myBank->getSelected());
96 myCart.lockBank();
97 invalidate();
98 }
99}
100
101// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
102string CartridgeX07Widget::bankState()
103{
104 ostringstream& buf = buffer();
105
106 buf << "Bank = " << std::dec << myCart.myCurrentBank;
107
108 return buf.str();
109}
110