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 "CartAR.hxx" |
19 | #include "PopUpWidget.hxx" |
20 | #include "CartARWidget.hxx" |
21 | |
22 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
23 | CartridgeARWidget::CartridgeARWidget( |
24 | GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, |
25 | int x, int y, int w, int h, CartridgeAR& cart) |
26 | : CartDebugWidget(boss, lfont, nfont, x, y, w, h), |
27 | myCart(cart) |
28 | { |
29 | size_t size = myCart.mySize; |
30 | |
31 | string info = |
32 | "Supercharger cartridge, four 2K slices (3 RAM, 1 ROM)\n" |
33 | "\nTHIS SCHEME IS NOT FULLY IMPLEMENTED OR TESTED\n" ; |
34 | |
35 | int xpos = 2, |
36 | ypos = addBaseInformation(size, "Starpath" , info) + myLineHeight; |
37 | |
38 | VariantList items; |
39 | VarList::push_back(items, " 0" ); |
40 | VarList::push_back(items, " 1" ); |
41 | VarList::push_back(items, " 2" ); |
42 | VarList::push_back(items, " 3" ); |
43 | VarList::push_back(items, " 4" ); |
44 | VarList::push_back(items, " 5" ); |
45 | VarList::push_back(items, " 6" ); |
46 | VarList::push_back(items, " 7" ); |
47 | VarList::push_back(items, " 8" ); |
48 | VarList::push_back(items, " 9" ); |
49 | VarList::push_back(items, " 10" ); |
50 | VarList::push_back(items, " 11" ); |
51 | VarList::push_back(items, " 12" ); |
52 | VarList::push_back(items, " 13" ); |
53 | VarList::push_back(items, " 14" ); |
54 | VarList::push_back(items, " 15" ); |
55 | VarList::push_back(items, " 16" ); |
56 | VarList::push_back(items, " 17" ); |
57 | VarList::push_back(items, " 18" ); |
58 | VarList::push_back(items, " 19" ); |
59 | VarList::push_back(items, " 20" ); |
60 | VarList::push_back(items, " 21" ); |
61 | VarList::push_back(items, " 22" ); |
62 | VarList::push_back(items, " 23" ); |
63 | VarList::push_back(items, " 24" ); |
64 | VarList::push_back(items, " 25" ); |
65 | VarList::push_back(items, " 26" ); |
66 | VarList::push_back(items, " 27" ); |
67 | VarList::push_back(items, " 28" ); |
68 | VarList::push_back(items, " 29" ); |
69 | VarList::push_back(items, " 30" ); |
70 | VarList::push_back(items, " 31" ); |
71 | myBank = |
72 | new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth(" XX" ), |
73 | myLineHeight, items, "Set bank " , |
74 | 0, kBankChanged); |
75 | myBank->setTarget(this); |
76 | addFocusWidget(myBank); |
77 | } |
78 | |
79 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
80 | void CartridgeARWidget::loadConfig() |
81 | { |
82 | Debugger& dbg = instance().debugger(); |
83 | CartDebug& cart = dbg.cartDebug(); |
84 | const CartState& state = static_cast<const CartState&>(cart.getState()); |
85 | const CartState& oldstate = static_cast<const CartState&>(cart.getOldState()); |
86 | |
87 | myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank); |
88 | |
89 | CartDebugWidget::loadConfig(); |
90 | } |
91 | |
92 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
93 | void CartridgeARWidget::handleCommand(CommandSender* sender, |
94 | int cmd, int data, int id) |
95 | { |
96 | if(cmd == kBankChanged) |
97 | { |
98 | myCart.unlockBank(); |
99 | myCart.bank(myBank->getSelected()); |
100 | myCart.lockBank(); |
101 | invalidate(); |
102 | } |
103 | } |
104 | |
105 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
106 | string CartridgeARWidget::bankState() |
107 | { |
108 | ostringstream& buf = buffer(); |
109 | |
110 | buf << "Bank = " << std::dec << myCart.myCurrentBank; |
111 | |
112 | return buf.str(); |
113 | } |
114 | |