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 "CartF4.hxx" |
19 | #include "PopUpWidget.hxx" |
20 | #include "CartF4Widget.hxx" |
21 | |
22 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
23 | CartridgeF4Widget::CartridgeF4Widget( |
24 | GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, |
25 | int x, int y, int w, int h, CartridgeF4& cart) |
26 | : CartDebugWidget(boss, lfont, nfont, x, y, w, h), |
27 | myCart(cart) |
28 | { |
29 | uInt16 size = 8 * 4096; |
30 | |
31 | ostringstream info; |
32 | info << "Standard F4 cartridge, eight 4K banks\n" |
33 | << "Startup bank = " << cart.startBank() << " or undetermined\n" ; |
34 | |
35 | // Eventually, we should query this from the debugger/disassembler |
36 | for(uInt32 i = 0, offset = 0xFFC, spot = 0xFF4; i < 8; ++i, offset += 0x1000) |
37 | { |
38 | uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; |
39 | start -= start % 0x1000; |
40 | info << "Bank " << i << " @ $" << Common::Base::HEX4 << start << " - " |
41 | << "$" << (start + 0xFFF) << " (hotspot = $F" << (spot+i) << ")\n" ; |
42 | } |
43 | |
44 | int xpos = 2, |
45 | ypos = addBaseInformation(size, "Atari" , info.str(), 15) + myLineHeight; |
46 | |
47 | VariantList items; |
48 | VarList::push_back(items, "0 ($FFF4)" ); |
49 | VarList::push_back(items, "1 ($FFF5)" ); |
50 | VarList::push_back(items, "2 ($FFF6)" ); |
51 | VarList::push_back(items, "3 ($FFF7)" ); |
52 | VarList::push_back(items, "4 ($FFF8)" ); |
53 | VarList::push_back(items, "5 ($FFF9)" ); |
54 | VarList::push_back(items, "6 ($FFFA)" ); |
55 | VarList::push_back(items, "7 ($FFFB)" ); |
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 CartridgeF4Widget::loadConfig() |
66 | { |
67 | Debugger& dbg = instance().debugger(); |
68 | CartDebug& cart = dbg.cartDebug(); |
69 | const CartState& state = static_cast<const CartState&>(cart.getState()); |
70 | const CartState& oldstate = static_cast<const CartState&>(cart.getOldState()); |
71 | |
72 | myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank); |
73 | |
74 | CartDebugWidget::loadConfig(); |
75 | } |
76 | |
77 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
78 | void CartridgeF4Widget::handleCommand(CommandSender* sender, |
79 | int cmd, int data, int id) |
80 | { |
81 | if(cmd == kBankChanged) |
82 | { |
83 | myCart.unlockBank(); |
84 | myCart.bank(myBank->getSelected()); |
85 | myCart.lockBank(); |
86 | invalidate(); |
87 | } |
88 | } |
89 | |
90 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
91 | string CartridgeF4Widget::bankState() |
92 | { |
93 | ostringstream& buf = buffer(); |
94 | |
95 | static const char* const spot[] = { |
96 | "$FFF4" , "$FFF5" , "$FFF6" , "$FFF7" , "$FFF8" , "$FFF9" , "$FFFA" , "$FFFB" |
97 | }; |
98 | buf << "Bank = " << std::dec << myCart.getBank() |
99 | << ", hotspot = " << spot[myCart.getBank()]; |
100 | |
101 | return buf.str(); |
102 | } |
103 | |