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 "CartF6SC.hxx" |
21 | #include "PopUpWidget.hxx" |
22 | #include "CartF6SCWidget.hxx" |
23 | |
24 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
25 | CartridgeF6SCWidget::CartridgeF6SCWidget( |
26 | GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, |
27 | int x, int y, int w, int h, CartridgeF6SC& cart) |
28 | : CartDebugWidget(boss, lfont, nfont, x, y, w, h), |
29 | myCart(cart) |
30 | { |
31 | uInt16 size = 4 * 4096; |
32 | |
33 | ostringstream info; |
34 | info << "Standard F6SC cartridge, four 4K banks\n" |
35 | << "128 bytes RAM @ $F000 - $F0FF\n" |
36 | << " $F080 - $F0FF (R), $F000 - $F07F (W)\n" |
37 | << "Startup bank = " << cart.startBank() << " or undetermined\n" ; |
38 | |
39 | // Eventually, we should query this from the debugger/disassembler |
40 | for(uInt32 i = 0, offset = 0xFFC, spot = 0xFF6; i < 4; ++i, offset += 0x1000) |
41 | { |
42 | uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; |
43 | start -= start % 0x1000; |
44 | info << "Bank " << i << " @ $" << Common::Base::HEX4 << (start + 0x100) << " - " |
45 | << "$" << (start + 0xFFF) << " (hotspot = $F" << (spot+i) << ")\n" ; |
46 | } |
47 | |
48 | int xpos = 2, |
49 | ypos = addBaseInformation(size, "Atari" , info.str()) + myLineHeight; |
50 | |
51 | VariantList items; |
52 | VarList::push_back(items, "0 ($FFF6)" ); |
53 | VarList::push_back(items, "1 ($FFF7)" ); |
54 | VarList::push_back(items, "2 ($FFF8)" ); |
55 | VarList::push_back(items, "3 ($FFF9)" ); |
56 | myBank = |
57 | new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("0 ($FFFx)" ), |
58 | myLineHeight, items, "Set bank " , |
59 | 0, kBankChanged); |
60 | myBank->setTarget(this); |
61 | addFocusWidget(myBank); |
62 | } |
63 | |
64 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
65 | void CartridgeF6SCWidget::saveOldState() |
66 | { |
67 | myOldState.internalram.clear(); |
68 | |
69 | for(uInt32 i = 0; i < internalRamSize(); ++i) |
70 | myOldState.internalram.push_back(myCart.myRAM[i]); |
71 | |
72 | myOldState.bank = myCart.getBank(); |
73 | } |
74 | |
75 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
76 | void CartridgeF6SCWidget::loadConfig() |
77 | { |
78 | myBank->setSelectedIndex(myCart.getBank(), myCart.getBank() != myOldState.bank); |
79 | |
80 | CartDebugWidget::loadConfig(); |
81 | } |
82 | |
83 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
84 | void CartridgeF6SCWidget::handleCommand(CommandSender* sender, |
85 | int cmd, int data, int id) |
86 | { |
87 | if(cmd == kBankChanged) |
88 | { |
89 | myCart.unlockBank(); |
90 | myCart.bank(myBank->getSelected()); |
91 | myCart.lockBank(); |
92 | invalidate(); |
93 | } |
94 | } |
95 | |
96 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
97 | string CartridgeF6SCWidget::bankState() |
98 | { |
99 | ostringstream& buf = buffer(); |
100 | |
101 | static const char* const spot[] = { "$FFF6" , "$FFF7" , "$FFF8" , "$FFF9" }; |
102 | buf << "Bank = " << std::dec << myCart.getBank() |
103 | << ", hotspot = " << spot[myCart.getBank()]; |
104 | |
105 | return buf.str(); |
106 | } |
107 | |
108 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
109 | uInt32 CartridgeF6SCWidget::internalRamSize() |
110 | { |
111 | return 128; |
112 | } |
113 | |
114 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
115 | uInt32 CartridgeF6SCWidget::internalRamRPort(int start) |
116 | { |
117 | return 0xF080 + start; |
118 | } |
119 | |
120 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
121 | string CartridgeF6SCWidget::internalRamDescription() |
122 | { |
123 | ostringstream desc; |
124 | desc << "$F000 - $F07F used for Write Access\n" |
125 | << "$F080 - $F0FF used for Read Access" ; |
126 | |
127 | return desc.str(); |
128 | } |
129 | |
130 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
131 | const ByteArray& CartridgeF6SCWidget::internalRamOld(int start, int count) |
132 | { |
133 | myRamOld.clear(); |
134 | for(int i = 0; i < count; i++) |
135 | myRamOld.push_back(myOldState.internalram[start + i]); |
136 | return myRamOld; |
137 | } |
138 | |
139 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
140 | const ByteArray& CartridgeF6SCWidget::internalRamCurrent(int start, int count) |
141 | { |
142 | myRamCurrent.clear(); |
143 | for(int i = 0; i < count; i++) |
144 | myRamCurrent.push_back(myCart.myRAM[start + i]); |
145 | return myRamCurrent; |
146 | } |
147 | |
148 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
149 | void CartridgeF6SCWidget::internalRamSetValue(int addr, uInt8 value) |
150 | { |
151 | myCart.myRAM[addr] = value; |
152 | } |
153 | |
154 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
155 | uInt8 CartridgeF6SCWidget::internalRamGetValue(int addr) |
156 | { |
157 | return myCart.myRAM[addr]; |
158 | } |
159 | |
160 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
161 | string CartridgeF6SCWidget::internalRamLabel(int addr) |
162 | { |
163 | CartDebug& dbg = instance().debugger().cartDebug(); |
164 | return dbg.getLabel(addr + 0xF080, false); |
165 | } |
166 | |