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 "CartBF.hxx" |
19 | #include "PopUpWidget.hxx" |
20 | #include "CartBFWidget.hxx" |
21 | |
22 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
23 | CartridgeBFWidget::CartridgeBFWidget( |
24 | GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, |
25 | int x, int y, int w, int h, CartridgeBF& cart) |
26 | : CartDebugWidget(boss, lfont, nfont, x, y, w, h), |
27 | myCart(cart) |
28 | { |
29 | uInt32 size = 64 * 4096; |
30 | |
31 | ostringstream info; |
32 | info << "BF cartridge, 64 4K banks\n" |
33 | << "Startup bank = " << cart.startBank() << "\n" ; |
34 | |
35 | // Eventually, we should query this from the debugger/disassembler |
36 | for(uInt32 i = 0, offset = 0xFFC, spot = 0xF80; i < 64; ++i, offset += 0x1000) |
37 | { |
38 | uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; |
39 | start -= start % 0x1000; |
40 | info << "Bank " << std::dec << i << " @ $" << Common::Base::HEX4 << start << " - " |
41 | << "$" << (start + 0xFFF) << " (hotspot = $F" << (spot+i) << ")\n" ; |
42 | } |
43 | |
44 | int xpos = 2, |
45 | ypos = addBaseInformation(size, "CPUWIZ" , info.str()) + myLineHeight; |
46 | |
47 | VariantList items; |
48 | VarList::push_back(items, " 0 ($FF80)" ); |
49 | VarList::push_back(items, " 1 ($FF81)" ); |
50 | VarList::push_back(items, " 2 ($FF82)" ); |
51 | VarList::push_back(items, " 3 ($FF83)" ); |
52 | VarList::push_back(items, " 4 ($FF84)" ); |
53 | VarList::push_back(items, " 5 ($FF85)" ); |
54 | VarList::push_back(items, " 6 ($FF86)" ); |
55 | VarList::push_back(items, " 7 ($FF87)" ); |
56 | VarList::push_back(items, " 8 ($FF88)" ); |
57 | VarList::push_back(items, " 9 ($FF89)" ); |
58 | VarList::push_back(items, "10 ($FF8A)" ); |
59 | VarList::push_back(items, "11 ($FF8B)" ); |
60 | VarList::push_back(items, "12 ($FF8C)" ); |
61 | VarList::push_back(items, "13 ($FF8D)" ); |
62 | VarList::push_back(items, "14 ($FF8E)" ); |
63 | VarList::push_back(items, "15 ($FF8F)" ); |
64 | VarList::push_back(items, "16 ($FF90)" ); |
65 | VarList::push_back(items, "17 ($FF91)" ); |
66 | VarList::push_back(items, "18 ($FF92)" ); |
67 | VarList::push_back(items, "19 ($FF93)" ); |
68 | VarList::push_back(items, "20 ($FF94)" ); |
69 | VarList::push_back(items, "21 ($FF95)" ); |
70 | VarList::push_back(items, "22 ($FF96)" ); |
71 | VarList::push_back(items, "23 ($FF97)" ); |
72 | VarList::push_back(items, "24 ($FF98)" ); |
73 | VarList::push_back(items, "25 ($FF99)" ); |
74 | VarList::push_back(items, "26 ($FF9A)" ); |
75 | VarList::push_back(items, "27 ($FF9B)" ); |
76 | VarList::push_back(items, "28 ($FF9C)" ); |
77 | VarList::push_back(items, "29 ($FF9D)" ); |
78 | VarList::push_back(items, "30 ($FF9E)" ); |
79 | VarList::push_back(items, "31 ($FF9F)" ); |
80 | VarList::push_back(items, "32 ($FFA0)" ); |
81 | VarList::push_back(items, "33 ($FFA1)" ); |
82 | VarList::push_back(items, "34 ($FFA2)" ); |
83 | VarList::push_back(items, "35 ($FFA3)" ); |
84 | VarList::push_back(items, "36 ($FFA4)" ); |
85 | VarList::push_back(items, "37 ($FFA5)" ); |
86 | VarList::push_back(items, "38 ($FFA6)" ); |
87 | VarList::push_back(items, "39 ($FFA7)" ); |
88 | VarList::push_back(items, "40 ($FFA8)" ); |
89 | VarList::push_back(items, "41 ($FFA9)" ); |
90 | VarList::push_back(items, "42 ($FFAA)" ); |
91 | VarList::push_back(items, "43 ($FFAB)" ); |
92 | VarList::push_back(items, "44 ($FFAC)" ); |
93 | VarList::push_back(items, "45 ($FFAD)" ); |
94 | VarList::push_back(items, "46 ($FFAE)" ); |
95 | VarList::push_back(items, "47 ($FFAF)" ); |
96 | VarList::push_back(items, "48 ($FFB0)" ); |
97 | VarList::push_back(items, "49 ($FFB1)" ); |
98 | VarList::push_back(items, "50 ($FFB2)" ); |
99 | VarList::push_back(items, "51 ($FFB3)" ); |
100 | VarList::push_back(items, "52 ($FFB4)" ); |
101 | VarList::push_back(items, "53 ($FFB5)" ); |
102 | VarList::push_back(items, "54 ($FFB6)" ); |
103 | VarList::push_back(items, "55 ($FFB7)" ); |
104 | VarList::push_back(items, "56 ($FFB8)" ); |
105 | VarList::push_back(items, "57 ($FFB9)" ); |
106 | VarList::push_back(items, "58 ($FFBA)" ); |
107 | VarList::push_back(items, "59 ($FFBB)" ); |
108 | VarList::push_back(items, "60 ($FFBC)" ); |
109 | VarList::push_back(items, "61 ($FFBD)" ); |
110 | VarList::push_back(items, "62 ($FFBE)" ); |
111 | VarList::push_back(items, "63 ($FFBF)" ); |
112 | |
113 | myBank = |
114 | new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("64 ($FFBF)" ), |
115 | myLineHeight, items, "Set bank " , |
116 | 0, kBankChanged); |
117 | myBank->setTarget(this); |
118 | addFocusWidget(myBank); |
119 | } |
120 | |
121 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
122 | void CartridgeBFWidget::loadConfig() |
123 | { |
124 | Debugger& dbg = instance().debugger(); |
125 | CartDebug& cart = dbg.cartDebug(); |
126 | const CartState& state = static_cast<const CartState&>(cart.getState()); |
127 | const CartState& oldstate = static_cast<const CartState&>(cart.getOldState()); |
128 | |
129 | myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank); |
130 | |
131 | CartDebugWidget::loadConfig(); |
132 | } |
133 | |
134 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
135 | void CartridgeBFWidget::handleCommand(CommandSender* sender, |
136 | int cmd, int data, int id) |
137 | { |
138 | if(cmd == kBankChanged) |
139 | { |
140 | myCart.unlockBank(); |
141 | myCart.bank(myBank->getSelected()); |
142 | myCart.lockBank(); |
143 | invalidate(); |
144 | } |
145 | } |
146 | |
147 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
148 | string CartridgeBFWidget::bankState() |
149 | { |
150 | ostringstream& buf = buffer(); |
151 | |
152 | static const char* const spot[] = { |
153 | "$FF80" , "$FF81" , "$FF82" , "$FF83" , "$FF84" , "$FF85" , "$FF86" , "$FF87" , |
154 | "$FF88" , "$FF89" , "$FF8A" , "$FF8B" , "$FF8C" , "$FF8D" , "$FF8E" , "$FF8F" , |
155 | "$FF90" , "$FF91" , "$FF92" , "$FF93" , "$FF94" , "$FF95" , "$FF96" , "$FF97" , |
156 | "$FF98" , "$FF99" , "$FF9A" , "$FF9B" , "$FF9C" , "$FF9D" , "$FF9E" , "$FF9F" , |
157 | "$FFA0" , "$FFA1" , "$FFA2" , "$FFA3" , "$FFA4" , "$FFA5" , "$FFA6" , "$FFA7" , |
158 | "$FFA8" , "$FFA9" , "$FFAA" , "$FFAB" , "$FFAC" , "$FFAD" , "$FFAE" , "$FFAF" , |
159 | "$FFB0" , "$FFB1" , "$FFB2" , "$FFB3" , "$FFB4" , "$FFB5" , "$FFB6" , "$FFB7" , |
160 | "$FFB8" , "$FFB9" , "$FFBA" , "$FFBB" , "$FFBC" , "$FFBD" , "$FFBE" , "$FFBF" |
161 | }; |
162 | buf << "Bank = " << std::dec << myCart.getBank() |
163 | << ", hotspot = " << spot[myCart.getBank()]; |
164 | |
165 | return buf.str(); |
166 | } |
167 | |