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 "CartDF.hxx" |
19 | #include "PopUpWidget.hxx" |
20 | #include "CartDFWidget.hxx" |
21 | |
22 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
23 | CartridgeDFWidget::CartridgeDFWidget( |
24 | GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, |
25 | int x, int y, int w, int h, CartridgeDF& cart) |
26 | : CartDebugWidget(boss, lfont, nfont, x, y, w, h), |
27 | myCart(cart) |
28 | { |
29 | uInt32 size = 32 * 4096; |
30 | |
31 | ostringstream info; |
32 | info << "EF 2 cartridge, 32 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 = 0xFD0; i < 32; ++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 ($FFC0)" ); |
49 | VarList::push_back(items, " 1 ($FFC1)" ); |
50 | VarList::push_back(items, " 2 ($FFC2)" ); |
51 | VarList::push_back(items, " 3 ($FFC3)" ); |
52 | VarList::push_back(items, " 4 ($FFC4)" ); |
53 | VarList::push_back(items, " 5 ($FFC5)" ); |
54 | VarList::push_back(items, " 6 ($FFC6)" ); |
55 | VarList::push_back(items, " 7 ($FFC7)" ); |
56 | VarList::push_back(items, " 8 ($FFC8)" ); |
57 | VarList::push_back(items, " 9 ($FFC9)" ); |
58 | VarList::push_back(items, "10 ($FFCA)" ); |
59 | VarList::push_back(items, "11 ($FFCB)" ); |
60 | VarList::push_back(items, "12 ($FFCC)" ); |
61 | VarList::push_back(items, "13 ($FFCD)" ); |
62 | VarList::push_back(items, "14 ($FFCE)" ); |
63 | VarList::push_back(items, "15 ($FFCF)" ); |
64 | VarList::push_back(items, "16 ($FFD0)" ); |
65 | VarList::push_back(items, "17 ($FFD1)" ); |
66 | VarList::push_back(items, "18 ($FFD2)" ); |
67 | VarList::push_back(items, "19 ($FFD3)" ); |
68 | VarList::push_back(items, "20 ($FFD4)" ); |
69 | VarList::push_back(items, "21 ($FFD5)" ); |
70 | VarList::push_back(items, "22 ($FFD6)" ); |
71 | VarList::push_back(items, "23 ($FFD7)" ); |
72 | VarList::push_back(items, "24 ($FFD8)" ); |
73 | VarList::push_back(items, "25 ($FFD9)" ); |
74 | VarList::push_back(items, "26 ($FFDA)" ); |
75 | VarList::push_back(items, "27 ($FFDB)" ); |
76 | VarList::push_back(items, "28 ($FFDC)" ); |
77 | VarList::push_back(items, "29 ($FFDD)" ); |
78 | VarList::push_back(items, "30 ($FFDE)" ); |
79 | VarList::push_back(items, "31 ($FFDF)" ); |
80 | |
81 | myBank = |
82 | new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("31 ($FFDF)" ), |
83 | myLineHeight, items, "Set bank " , |
84 | 0, kBankChanged); |
85 | myBank->setTarget(this); |
86 | addFocusWidget(myBank); |
87 | } |
88 | |
89 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
90 | void CartridgeDFWidget::loadConfig() |
91 | { |
92 | Debugger& dbg = instance().debugger(); |
93 | CartDebug& cart = dbg.cartDebug(); |
94 | const CartState& state = static_cast<const CartState&>(cart.getState()); |
95 | const CartState& oldstate = static_cast<const CartState&>(cart.getOldState()); |
96 | |
97 | myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank); |
98 | |
99 | CartDebugWidget::loadConfig(); |
100 | } |
101 | |
102 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
103 | void CartridgeDFWidget::handleCommand(CommandSender* sender, |
104 | int cmd, int data, int id) |
105 | { |
106 | if(cmd == kBankChanged) |
107 | { |
108 | myCart.unlockBank(); |
109 | myCart.bank(myBank->getSelected()); |
110 | myCart.lockBank(); |
111 | invalidate(); |
112 | } |
113 | } |
114 | |
115 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
116 | string CartridgeDFWidget::bankState() |
117 | { |
118 | ostringstream& buf = buffer(); |
119 | |
120 | static const char* const spot[] = { |
121 | "$FFC0" , "$FFC1" , "$FFC2" , "$FFC3" , "$FFC4" , "$FFC5" , "$FFC6" , "$FFC7" , |
122 | "$FFC8" , "$FFC9" , "$FFCA" , "$FFCB" , "$FFCC" , "$FFCD" , "$FFCE" , "$FFCF" , |
123 | "$FFD0" , "$FFD1" , "$FFD2" , "$FFD3" , "$FFD4" , "$FFD5" , "$FFD6" , "$FFD7" , |
124 | "$FFD8" , "$FFD9" , "$FFDA" , "$FFDB" , "$FFDC" , "$FFDD" , "$FFDE" , "$FFDF" |
125 | }; |
126 | buf << "Bank = " << std::dec << myCart.getBank() |
127 | << ", hotspot = " << spot[myCart.getBank()]; |
128 | |
129 | return buf.str(); |
130 | } |
131 | |