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 "Debugger.hxx" |
19 | #include "CartDebug.hxx" |
20 | #include "CartDFSC.hxx" |
21 | #include "PopUpWidget.hxx" |
22 | #include "CartDFSCWidget.hxx" |
23 | |
24 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
25 | CartridgeDFSCWidget::CartridgeDFSCWidget( |
26 | GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, |
27 | int x, int y, int w, int h, CartridgeDFSC& cart) |
28 | : CartDebugWidget(boss, lfont, nfont, x, y, w, h), |
29 | myCart(cart) |
30 | { |
31 | uInt32 size = 32 * 4096; |
32 | |
33 | ostringstream info; |
34 | info << "128K DFSC + RAM, 32 4K banks\n" |
35 | << "128 bytes RAM @ $F000 - $F0FF\n" |
36 | << " $F080 - $F0FF (R), $F000 - $F07F (W)\n" |
37 | << "Startup bank = " << cart.startBank() << "\n" ; |
38 | |
39 | // Eventually, we should query this from the debugger/disassembler |
40 | for(uInt32 i = 0, offset = 0xFFC, spot = 0xFC0; i < 32; ++i, offset += 0x1000) |
41 | { |
42 | uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; |
43 | start -= start % 0x1000; |
44 | info << "Bank " << std::dec << i << " @ $" << Common::Base::HEX4 << (start + 0x100) |
45 | << " - " << "$" << (start + 0xFFF) << " (hotspot = $F" << (spot+i) << ")\n" ; |
46 | } |
47 | |
48 | int xpos = 2, |
49 | ypos = addBaseInformation(size, "CPUWIZ" , info.str()) + myLineHeight; |
50 | |
51 | VariantList items; |
52 | VarList::push_back(items, " 0 ($FFC0)" ); |
53 | VarList::push_back(items, " 1 ($FFC1)" ); |
54 | VarList::push_back(items, " 2 ($FFC2)" ); |
55 | VarList::push_back(items, " 3 ($FFC3)" ); |
56 | VarList::push_back(items, " 4 ($FFC4)" ); |
57 | VarList::push_back(items, " 5 ($FFC5)" ); |
58 | VarList::push_back(items, " 6 ($FFC6)" ); |
59 | VarList::push_back(items, " 7 ($FFC7)" ); |
60 | VarList::push_back(items, " 8 ($FFC8)" ); |
61 | VarList::push_back(items, " 9 ($FFC9)" ); |
62 | VarList::push_back(items, "10 ($FFCA)" ); |
63 | VarList::push_back(items, "11 ($FFCB)" ); |
64 | VarList::push_back(items, "12 ($FFCC)" ); |
65 | VarList::push_back(items, "13 ($FFCD)" ); |
66 | VarList::push_back(items, "14 ($FFCE)" ); |
67 | VarList::push_back(items, "15 ($FFCF)" ); |
68 | VarList::push_back(items, "16 ($FFD0)" ); |
69 | VarList::push_back(items, "17 ($FFD1)" ); |
70 | VarList::push_back(items, "18 ($FFD2)" ); |
71 | VarList::push_back(items, "19 ($FFD3)" ); |
72 | VarList::push_back(items, "20 ($FFD4)" ); |
73 | VarList::push_back(items, "21 ($FFD5)" ); |
74 | VarList::push_back(items, "22 ($FFD6)" ); |
75 | VarList::push_back(items, "23 ($FFD7)" ); |
76 | VarList::push_back(items, "24 ($FFD8)" ); |
77 | VarList::push_back(items, "25 ($FFD9)" ); |
78 | VarList::push_back(items, "26 ($FFDA)" ); |
79 | VarList::push_back(items, "27 ($FFDB)" ); |
80 | VarList::push_back(items, "28 ($FFDC)" ); |
81 | VarList::push_back(items, "29 ($FFDD)" ); |
82 | VarList::push_back(items, "30 ($FFDE)" ); |
83 | VarList::push_back(items, "31 ($FFDF)" ); |
84 | |
85 | myBank = |
86 | new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("31 ($FFE0)" ), |
87 | myLineHeight, items, "Set bank " , |
88 | 0, kBankChanged); |
89 | myBank->setTarget(this); |
90 | addFocusWidget(myBank); |
91 | } |
92 | |
93 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
94 | void CartridgeDFSCWidget::saveOldState() |
95 | { |
96 | myOldState.internalram.clear(); |
97 | |
98 | for(uInt32 i = 0; i < internalRamSize(); ++i) |
99 | myOldState.internalram.push_back(myCart.myRAM[i]); |
100 | |
101 | myOldState.bank = myCart.getBank(); |
102 | } |
103 | |
104 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
105 | void CartridgeDFSCWidget::loadConfig() |
106 | { |
107 | myBank->setSelectedIndex(myCart.getBank(), myCart.getBank() != myOldState.bank); |
108 | |
109 | CartDebugWidget::loadConfig(); |
110 | } |
111 | |
112 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
113 | void CartridgeDFSCWidget::handleCommand(CommandSender* sender, |
114 | int cmd, int data, int id) |
115 | { |
116 | if(cmd == kBankChanged) |
117 | { |
118 | myCart.unlockBank(); |
119 | myCart.bank(myBank->getSelected()); |
120 | myCart.lockBank(); |
121 | invalidate(); |
122 | } |
123 | } |
124 | |
125 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
126 | string CartridgeDFSCWidget::bankState() |
127 | { |
128 | ostringstream& buf = buffer(); |
129 | |
130 | static const char* const spot[] = { |
131 | "$FFC0" , "$FFC1" , "$FFC2" , "$FFC3" , "$FFC4" , "$FFC5" , "$FFC6" , "$FFC7" , |
132 | "$FFC8" , "$FFC9" , "$FFCA" , "$FFCB" , "$FFCC" , "$FFCD" , "$FFCE" , "$FFCF" , |
133 | "$FFD0" , "$FFD1" , "$FFD2" , "$FFD3" , "$FFD4" , "$FFD5" , "$FFD6" , "$FFE7" , |
134 | "$FFD8" , "$FFD9" , "$FFDA" , "$FFDB" , "$FFDC" , "$FFDD" , "$FFDE" , "$FFDF" |
135 | }; |
136 | buf << "Bank = " << std::dec << myCart.getBank() |
137 | << ", hotspot = " << spot[myCart.getBank()]; |
138 | |
139 | return buf.str(); |
140 | } |
141 | |
142 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
143 | uInt32 CartridgeDFSCWidget::internalRamSize() |
144 | { |
145 | return 128; |
146 | } |
147 | |
148 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
149 | uInt32 CartridgeDFSCWidget::internalRamRPort(int start) |
150 | { |
151 | return 0xF080 + start; |
152 | } |
153 | |
154 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
155 | string CartridgeDFSCWidget::internalRamDescription() |
156 | { |
157 | ostringstream desc; |
158 | desc << "$F000 - $F07F used for Write Access\n" |
159 | << "$F080 - $F0FF used for Read Access" ; |
160 | |
161 | return desc.str(); |
162 | } |
163 | |
164 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
165 | const ByteArray& CartridgeDFSCWidget::internalRamOld(int start, int count) |
166 | { |
167 | myRamOld.clear(); |
168 | for(int i = 0; i < count; i++) |
169 | myRamOld.push_back(myOldState.internalram[start + i]); |
170 | return myRamOld; |
171 | } |
172 | |
173 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
174 | const ByteArray& CartridgeDFSCWidget::internalRamCurrent(int start, int count) |
175 | { |
176 | myRamCurrent.clear(); |
177 | for(int i = 0; i < count; i++) |
178 | myRamCurrent.push_back(myCart.myRAM[start + i]); |
179 | return myRamCurrent; |
180 | } |
181 | |
182 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
183 | void CartridgeDFSCWidget::internalRamSetValue(int addr, uInt8 value) |
184 | { |
185 | myCart.myRAM[addr] = value; |
186 | } |
187 | |
188 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
189 | uInt8 CartridgeDFSCWidget::internalRamGetValue(int addr) |
190 | { |
191 | return myCart.myRAM[addr]; |
192 | } |
193 | |
194 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
195 | string CartridgeDFSCWidget::internalRamLabel(int addr) |
196 | { |
197 | CartDebug& dbg = instance().debugger().cartDebug(); |
198 | return dbg.getLabel(addr + 0xF080, false); |
199 | } |
200 | |