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 "CartFE.hxx"
19#include "PopUpWidget.hxx"
20#include "CartFEWidget.hxx"
21
22// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
23CartridgeFEWidget::CartridgeFEWidget(
24 GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
25 int x, int y, int w, int h, CartridgeFE& cart)
26 : CartDebugWidget(boss, lfont, nfont, x, y, w, h),
27 myCart(cart)
28{
29 string info =
30 "FE cartridge, two 4K banks\n"
31 "Monitors access to hotspot $01FE, and uses "
32 "upper 3 bits of databus for bank number:\n"
33 "Bank 0 @ $F000 - $FFFF (DATA = 111, D5 = 1)\n"
34 "Bank 1 @ $D000 - $DFFF (DATA = 110, D5 = 0)\n";
35
36 int xpos = 2,
37 ypos = addBaseInformation(2 * 4096, "Activision", info) + myLineHeight;
38
39 VariantList items;
40 VarList::push_back(items, "0 ($01FE, D5=1)");
41 VarList::push_back(items, "1 ($01FE, D5=0)");
42 myBank =
43 new PopUpWidget(boss, _font, xpos, ypos-2,
44 _font.getStringWidth("0 ($01FE, D5=1)"),
45 myLineHeight, items, "Set bank ",
46 0, kBankChanged);
47 myBank->setTarget(this);
48 addFocusWidget(myBank);
49}
50
51// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
52void CartridgeFEWidget::loadConfig()
53{
54 Debugger& dbg = instance().debugger();
55 CartDebug& cart = dbg.cartDebug();
56 const CartState& state = static_cast<const CartState&>(cart.getState());
57 const CartState& oldstate = static_cast<const CartState&>(cart.getOldState());
58
59 myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank);
60
61 CartDebugWidget::loadConfig();
62}
63
64// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
65void CartridgeFEWidget::handleCommand(CommandSender* sender,
66 int cmd, int data, int id)
67{
68 if(cmd == kBankChanged)
69 {
70 myCart.unlockBank();
71 myCart.bank(myBank->getSelected());
72 myCart.lockBank();
73 invalidate();
74 }
75}
76
77// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
78string CartridgeFEWidget::bankState()
79{
80 ostringstream& buf = buffer();
81
82 static const char* const range[] = { "$F000", "$D000" };
83 buf << "Bank = " << std::dec << myCart.getBank()
84 << ", address range = " << range[myCart.getBank()];
85
86 return buf.str();
87}
88