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 "CartE7.hxx" |
19 | #include "CartMNetwork.hxx" |
20 | #include "PopUpWidget.hxx" |
21 | #include "CartMNetworkWidget.hxx" |
22 | |
23 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
24 | CartridgeMNetworkWidget::CartridgeMNetworkWidget( |
25 | GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, |
26 | int x, int y, int w, int h, |
27 | CartridgeMNetwork& cart) |
28 | : CartDebugWidget(boss, lfont, nfont, x, y, w, h), |
29 | myCart(cart), |
30 | myLower2K(nullptr), |
31 | myUpper256B(nullptr) |
32 | { |
33 | } |
34 | |
35 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
36 | void CartridgeMNetworkWidget::initialize(GuiObject* boss, CartridgeMNetwork& cart, ostringstream& info) |
37 | { |
38 | uInt32 size = cart.bankCount() * cart.BANK_SIZE; |
39 | |
40 | int xpos = 2, |
41 | ypos = addBaseInformation(size, "M-Network" , info.str(), 15) + |
42 | myLineHeight; |
43 | |
44 | VariantList items0, items1; |
45 | for(int i = 0; i < cart.bankCount(); ++i) |
46 | VarList::push_back(items0, getSpotLower(i)); |
47 | for(int i = 0; i < 4; ++i) |
48 | VarList::push_back(items1, getSpotUpper(i)); |
49 | |
50 | const int lwidth = _font.getStringWidth("Set slice for upper 256B " ), |
51 | fwidth = _font.getStringWidth("3 - RAM ($FFEB)" ); |
52 | myLower2K = |
53 | new PopUpWidget(boss, _font, xpos, ypos - 2, fwidth, myLineHeight, items0, |
54 | "Set slice for lower 2K " , lwidth, kLowerChanged); |
55 | myLower2K->setTarget(this); |
56 | addFocusWidget(myLower2K); |
57 | ypos += myLower2K->getHeight() + 4; |
58 | |
59 | myUpper256B = |
60 | new PopUpWidget(boss, _font, xpos, ypos - 2, fwidth, myLineHeight, items1, |
61 | "Set slice for upper 256B " , lwidth, kUpperChanged); |
62 | myUpper256B->setTarget(this); |
63 | addFocusWidget(myUpper256B); |
64 | } |
65 | |
66 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
67 | void CartridgeMNetworkWidget::saveOldState() |
68 | { |
69 | myOldState.internalram.clear(); |
70 | |
71 | for(uInt32 i = 0; i < internalRamSize(); ++i) |
72 | myOldState.internalram.push_back(myCart.myRAM[i]); |
73 | |
74 | myOldState.lowerBank = myCart.myCurrentSlice[0]; |
75 | myOldState.upperBank = myCart.myCurrentRAM; |
76 | } |
77 | |
78 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
79 | void CartridgeMNetworkWidget::loadConfig() |
80 | { |
81 | myLower2K->setSelectedIndex(myCart.myCurrentSlice[0], myCart.myCurrentSlice[0] != myOldState.lowerBank); |
82 | myUpper256B->setSelectedIndex(myCart.myCurrentRAM, myCart.myCurrentRAM != myOldState.upperBank); |
83 | |
84 | CartDebugWidget::loadConfig(); |
85 | } |
86 | |
87 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
88 | void CartridgeMNetworkWidget::handleCommand(CommandSender* sender, |
89 | int cmd, int data, int id) |
90 | { |
91 | myCart.unlockBank(); |
92 | |
93 | switch(cmd) |
94 | { |
95 | case kLowerChanged: |
96 | myCart.bank(myLower2K->getSelected()); |
97 | break; |
98 | case kUpperChanged: |
99 | myCart.bankRAM(myUpper256B->getSelected()); |
100 | break; |
101 | } |
102 | |
103 | myCart.lockBank(); |
104 | invalidate(); |
105 | } |
106 | |
107 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
108 | string CartridgeMNetworkWidget::bankState() |
109 | { |
110 | ostringstream& buf = buffer(); |
111 | |
112 | buf << "Slices: " << std::dec |
113 | << getSpotLower(myCart.myCurrentSlice[0]) << " / " |
114 | << getSpotUpper(myCart.myCurrentRAM); |
115 | |
116 | return buf.str(); |
117 | } |
118 | |
119 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
120 | uInt32 CartridgeMNetworkWidget::internalRamSize() |
121 | { |
122 | return 2048; |
123 | } |
124 | |
125 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
126 | uInt32 CartridgeMNetworkWidget::internalRamRPort(int start) |
127 | { |
128 | return 0x0000 + start; |
129 | } |
130 | |
131 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
132 | string CartridgeMNetworkWidget::internalRamDescription() |
133 | { |
134 | ostringstream desc; |
135 | desc << "First 1K accessible via:\n" |
136 | << " $F000 - $F3FF used for Write Access\n" |
137 | << " $F400 - $F7FF used for Read Access\n" |
138 | << "256K of second 1K accessible via:\n" |
139 | << " $F800 - $F8FF used for Write Access\n" |
140 | << " $F900 - $F9FF used for Read Access" ; |
141 | |
142 | return desc.str(); |
143 | } |
144 | |
145 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
146 | const ByteArray& CartridgeMNetworkWidget::internalRamOld(int start, int count) |
147 | { |
148 | myRamOld.clear(); |
149 | for(int i = 0; i < count; i++) |
150 | myRamOld.push_back(myOldState.internalram[start + i]); |
151 | return myRamOld; |
152 | } |
153 | |
154 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
155 | const ByteArray& CartridgeMNetworkWidget::internalRamCurrent(int start, int count) |
156 | { |
157 | myRamCurrent.clear(); |
158 | for(int i = 0; i < count; i++) |
159 | myRamCurrent.push_back(myCart.myRAM[start + i]); |
160 | return myRamCurrent; |
161 | } |
162 | |
163 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
164 | void CartridgeMNetworkWidget::internalRamSetValue(int addr, uInt8 value) |
165 | { |
166 | myCart.myRAM[addr] = value; |
167 | } |
168 | |
169 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
170 | uInt8 CartridgeMNetworkWidget::internalRamGetValue(int addr) |
171 | { |
172 | return myCart.myRAM[addr]; |
173 | } |
174 | |