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 "CartCVPlus.hxx" |
21 | #include "PopUpWidget.hxx" |
22 | #include "CartCVPlusWidget.hxx" |
23 | |
24 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
25 | CartridgeCVPlusWidget::CartridgeCVPlusWidget( |
26 | GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, |
27 | int x, int y, int w, int h, CartridgeCVPlus& cart) |
28 | : CartDebugWidget(boss, lfont, nfont, x, y, w, h), |
29 | myCart(cart) |
30 | { |
31 | size_t size = cart.mySize; |
32 | |
33 | ostringstream info; |
34 | info << "LS_Dracon CV+ cartridge, 1K RAM, 2-256 2K ROM\n" |
35 | << "1024 bytes RAM @ $F000 - $F7FF\n" |
36 | << " $F000 - $F3FF (R), $F400 - $F7FF (W)\n" |
37 | << "2048 bytes ROM @ $F800 - $FFFF, by writing to $3D\n" |
38 | << "Startup bank = " << cart.startBank() << "\n" ; |
39 | |
40 | int xpos = 2, |
41 | ypos = addBaseInformation(size, "LS_Dracon / Stephen Anthony" , |
42 | info.str()) + myLineHeight; |
43 | |
44 | VariantList items; |
45 | for(uInt16 i = 0; i < cart.bankCount(); ++i) |
46 | VarList::push_back(items, Variant(i).toString() + " ($3D)" ); |
47 | |
48 | ostringstream label; |
49 | label << "Set bank ($F800 - $FFFF) " ; |
50 | myBank = |
51 | new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("xxx ($3D)" ), |
52 | myLineHeight, items, label.str(), |
53 | _font.getStringWidth(label.str()), kBankChanged); |
54 | myBank->setTarget(this); |
55 | addFocusWidget(myBank); |
56 | } |
57 | |
58 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
59 | void CartridgeCVPlusWidget::loadConfig() |
60 | { |
61 | myBank->setSelectedIndex(myCart.getBank(), myCart.getBank() != myOldState.bank); |
62 | |
63 | CartDebugWidget::loadConfig(); |
64 | } |
65 | |
66 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
67 | void CartridgeCVPlusWidget::handleCommand(CommandSender* sender, |
68 | int cmd, int data, int id) |
69 | { |
70 | if(cmd == kBankChanged) |
71 | { |
72 | myCart.unlockBank(); |
73 | myCart.bank(myBank->getSelected()); |
74 | myCart.lockBank(); |
75 | invalidate(); |
76 | } |
77 | } |
78 | |
79 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
80 | string CartridgeCVPlusWidget::bankState() |
81 | { |
82 | ostringstream& buf = buffer(); |
83 | |
84 | buf << "Bank = " << std::dec << myCart.myCurrentBank << ", hotspot = $3D" ; |
85 | |
86 | return buf.str(); |
87 | } |
88 | |
89 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
90 | void CartridgeCVPlusWidget::saveOldState() |
91 | { |
92 | myOldState.internalram.clear(); |
93 | |
94 | for(uInt32 i = 0; i < internalRamSize(); ++i) |
95 | myOldState.internalram.push_back(myCart.myRAM[i]); |
96 | |
97 | myOldState.bank = myCart.getBank(); |
98 | } |
99 | |
100 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
101 | uInt32 CartridgeCVPlusWidget::internalRamSize() |
102 | { |
103 | return 1024; |
104 | } |
105 | |
106 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
107 | uInt32 CartridgeCVPlusWidget::internalRamRPort(int start) |
108 | { |
109 | return 0xF000 + start; |
110 | } |
111 | |
112 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
113 | string CartridgeCVPlusWidget::internalRamDescription() |
114 | { |
115 | ostringstream desc; |
116 | desc << "$F000 - $F3FF used for Read Access\n" |
117 | << "$F400 - $F7FF used for Write Access" ; |
118 | |
119 | return desc.str(); |
120 | } |
121 | |
122 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
123 | const ByteArray& CartridgeCVPlusWidget::internalRamOld(int start, int count) |
124 | { |
125 | myRamOld.clear(); |
126 | for(int i = 0; i < count; i++) |
127 | myRamOld.push_back(myOldState.internalram[start + i]); |
128 | return myRamOld; |
129 | } |
130 | |
131 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
132 | const ByteArray& CartridgeCVPlusWidget::internalRamCurrent(int start, int count) |
133 | { |
134 | myRamCurrent.clear(); |
135 | for(int i = 0; i < count; i++) |
136 | myRamCurrent.push_back(myCart.myRAM[start + i]); |
137 | return myRamCurrent; |
138 | } |
139 | |
140 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
141 | void CartridgeCVPlusWidget::internalRamSetValue(int addr, uInt8 value) |
142 | { |
143 | myCart.myRAM[addr] = value; |
144 | } |
145 | |
146 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
147 | uInt8 CartridgeCVPlusWidget::internalRamGetValue(int addr) |
148 | { |
149 | return myCart.myRAM[addr]; |
150 | } |
151 | |
152 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
153 | string CartridgeCVPlusWidget::internalRamLabel(int addr) |
154 | { |
155 | CartDebug& dbg = instance().debugger().cartDebug(); |
156 | return dbg.getLabel(addr + 0xF000, false); |
157 | } |
158 | |