| 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 "CartEF.hxx" |
| 19 | #include "PopUpWidget.hxx" |
| 20 | #include "CartEFWidget.hxx" |
| 21 | |
| 22 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 23 | CartridgeEFWidget::CartridgeEFWidget( |
| 24 | GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, |
| 25 | int x, int y, int w, int h, CartridgeEF& cart) |
| 26 | : CartDebugWidget(boss, lfont, nfont, x, y, w, h), |
| 27 | myCart(cart) |
| 28 | { |
| 29 | uInt32 size = 16 * 4096; |
| 30 | |
| 31 | ostringstream info; |
| 32 | info << "64K H. Runner EF cartridge, 16 4K banks\n" |
| 33 | << "Startup bank = " << cart.startBank() << "\n" ; |
| 34 | |
| 35 | // Eventually, we should query this from the debugger/disassembler |
| 36 | for(uInt32 i = 0, offset = 0xFFC, spot = 0xFE0; i < 16; ++i, offset += 0x1000) |
| 37 | { |
| 38 | uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; |
| 39 | start -= start % 0x1000; |
| 40 | info << "Bank " << std::dec << i << " @ $" << Common::Base::HEX4 << start << " - " |
| 41 | << "$" << (start + 0xFFF) << " (hotspot = $F" << (spot+i) << ")\n" ; |
| 42 | } |
| 43 | |
| 44 | int xpos = 2, |
| 45 | ypos = addBaseInformation(size, "Paul Slocum / Homestar Runner" , |
| 46 | info.str()) + myLineHeight; |
| 47 | |
| 48 | VariantList items; |
| 49 | VarList::push_back(items, " 0 ($FFE0)" ); |
| 50 | VarList::push_back(items, " 1 ($FFE1)" ); |
| 51 | VarList::push_back(items, " 2 ($FFE2)" ); |
| 52 | VarList::push_back(items, " 3 ($FFE3)" ); |
| 53 | VarList::push_back(items, " 4 ($FFE4)" ); |
| 54 | VarList::push_back(items, " 5 ($FFE5)" ); |
| 55 | VarList::push_back(items, " 6 ($FFE6)" ); |
| 56 | VarList::push_back(items, " 7 ($FFE7)" ); |
| 57 | VarList::push_back(items, " 8 ($FFE8)" ); |
| 58 | VarList::push_back(items, " 9 ($FFE9)" ); |
| 59 | VarList::push_back(items, "10 ($FFEA)" ); |
| 60 | VarList::push_back(items, "11 ($FFEB)" ); |
| 61 | VarList::push_back(items, "12 ($FFEC)" ); |
| 62 | VarList::push_back(items, "13 ($FFED)" ); |
| 63 | VarList::push_back(items, "14 ($FFEE)" ); |
| 64 | VarList::push_back(items, "15 ($FFEF)" ); |
| 65 | myBank = |
| 66 | new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("15 ($FFE0)" ), |
| 67 | myLineHeight, items, "Set bank " , |
| 68 | 0, kBankChanged); |
| 69 | myBank->setTarget(this); |
| 70 | addFocusWidget(myBank); |
| 71 | } |
| 72 | |
| 73 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 74 | void CartridgeEFWidget::loadConfig() |
| 75 | { |
| 76 | Debugger& dbg = instance().debugger(); |
| 77 | CartDebug& cart = dbg.cartDebug(); |
| 78 | const CartState& state = static_cast<const CartState&>(cart.getState()); |
| 79 | const CartState& oldstate = static_cast<const CartState&>(cart.getOldState()); |
| 80 | |
| 81 | myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank); |
| 82 | |
| 83 | CartDebugWidget::loadConfig(); |
| 84 | } |
| 85 | |
| 86 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 87 | void CartridgeEFWidget::handleCommand(CommandSender* sender, |
| 88 | int cmd, int data, int id) |
| 89 | { |
| 90 | if(cmd == kBankChanged) |
| 91 | { |
| 92 | myCart.unlockBank(); |
| 93 | myCart.bank(myBank->getSelected()); |
| 94 | myCart.lockBank(); |
| 95 | invalidate(); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 100 | string CartridgeEFWidget::bankState() |
| 101 | { |
| 102 | ostringstream& buf = buffer(); |
| 103 | |
| 104 | static const char* const spot[] = { |
| 105 | "$FFE0" , "$FFE1" , "$FFE2" , "$FFE3" , "$FFE4" , "$FFE5" , "$FFE6" , "$FFE7" , |
| 106 | "$FFE8" , "$FFE9" , "$FFEA" , "$FFEB" , "$FFEC" , "$FFED" , "$FFEE" , "$FFEF" |
| 107 | }; |
| 108 | buf << "Bank = " << std::dec << myCart.getBank() |
| 109 | << ", hotspot = " << spot[myCart.getBank()]; |
| 110 | |
| 111 | return buf.str(); |
| 112 | } |
| 113 | |