| 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 "Base.hxx" |
| 19 | #include "Font.hxx" |
| 20 | #include "OSystem.hxx" |
| 21 | #include "Debugger.hxx" |
| 22 | #include "TIADebug.hxx" |
| 23 | #include "Widget.hxx" |
| 24 | #include "EditTextWidget.hxx" |
| 25 | #include "GuiObject.hxx" |
| 26 | |
| 27 | #include "TiaInfoWidget.hxx" |
| 28 | |
| 29 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 30 | TiaInfoWidget::TiaInfoWidget(GuiObject* boss, const GUI::Font& lfont, |
| 31 | const GUI::Font& nfont, |
| 32 | int x, int y, int max_w) |
| 33 | : Widget(boss, lfont, x, y, 16, 16), |
| 34 | CommandSender(boss) |
| 35 | { |
| 36 | bool longstr = 34 * lfont.getMaxCharWidth() <= max_w; |
| 37 | |
| 38 | x += 5; |
| 39 | const int lineHeight = lfont.getLineHeight(); |
| 40 | int xpos = x, ypos = y + 10; |
| 41 | int lwidth = lfont.getStringWidth(longstr ? "Frame Cycle " : "F. Cycle " ); |
| 42 | int fwidth = 5 * lfont.getMaxCharWidth() + 4; |
| 43 | |
| 44 | // Add frame info |
| 45 | new StaticTextWidget(boss, lfont, xpos, ypos, lwidth, lineHeight, |
| 46 | longstr ? "Frame Count " : "Frame " , |
| 47 | TextAlign::Left); |
| 48 | xpos += lwidth; |
| 49 | myFrameCount = new EditTextWidget(boss, nfont, xpos, ypos-1, fwidth, lineHeight, "" ); |
| 50 | myFrameCount->setEditable(false, true); |
| 51 | |
| 52 | xpos = x; ypos += lineHeight + 5; |
| 53 | new StaticTextWidget(boss, lfont, xpos, ypos, lwidth, lineHeight, |
| 54 | longstr ? "Frame Cycle " : "F. Cycle " , |
| 55 | TextAlign::Left); |
| 56 | xpos += lwidth; |
| 57 | myFrameCycles = new EditTextWidget(boss, nfont, xpos, ypos-1, fwidth, lineHeight, "" ); |
| 58 | myFrameCycles->setEditable(false, true); |
| 59 | |
| 60 | xpos = x + 20; ypos += lineHeight + 8; |
| 61 | myVSync = new CheckboxWidget(boss, lfont, xpos, ypos-3, "VSync" , 0); |
| 62 | myVSync->setEditable(false); |
| 63 | |
| 64 | xpos = x + 20; ypos += lineHeight + 5; |
| 65 | myVBlank = new CheckboxWidget(boss, lfont, xpos, ypos-3, "VBlank" , 0); |
| 66 | myVBlank->setEditable(false); |
| 67 | |
| 68 | xpos = x + lwidth + myFrameCycles->getWidth() + 8; ypos = y + 10; |
| 69 | lwidth = lfont.getStringWidth(longstr ? "Color Clock " : "Pixel Pos " ); |
| 70 | fwidth = 3 * lfont.getMaxCharWidth() + 4; |
| 71 | |
| 72 | new StaticTextWidget(boss, lfont, xpos, ypos, |
| 73 | lfont.getStringWidth(longstr ? "Scanline" : "Scn Ln" ), lineHeight, |
| 74 | longstr ? "Scanline" : "Scn Ln" , TextAlign::Left); |
| 75 | |
| 76 | myScanlineCountLast = new EditTextWidget(boss, nfont, xpos+lwidth, ypos-1, fwidth, |
| 77 | lineHeight, "" ); |
| 78 | myScanlineCountLast->setEditable(false, true); |
| 79 | |
| 80 | myScanlineCount = new EditTextWidget(boss, nfont, |
| 81 | xpos+lwidth - myScanlineCountLast->getWidth() - 2, ypos-1, fwidth, |
| 82 | lineHeight, "" ); |
| 83 | myScanlineCount->setEditable(false, true); |
| 84 | |
| 85 | ypos += lineHeight + 5; |
| 86 | new StaticTextWidget(boss, lfont, xpos, ypos, lwidth, lineHeight, |
| 87 | longstr ? "Scan Cycle " : "Scn Cycle" , TextAlign::Left); |
| 88 | |
| 89 | myScanlineCycles = new EditTextWidget(boss, nfont, xpos+lwidth, ypos-1, fwidth, |
| 90 | lineHeight, "" ); |
| 91 | myScanlineCycles->setEditable(false, true); |
| 92 | |
| 93 | ypos += lineHeight + 5; |
| 94 | new StaticTextWidget(boss, lfont, xpos, ypos, lwidth, lineHeight, |
| 95 | "Pixel Pos " , TextAlign::Left); |
| 96 | |
| 97 | myPixelPosition = new EditTextWidget(boss, nfont, xpos+lwidth, ypos-1, fwidth, |
| 98 | lineHeight, "" ); |
| 99 | myPixelPosition->setEditable(false, true); |
| 100 | |
| 101 | ypos += lineHeight + 5; |
| 102 | new StaticTextWidget(boss, lfont, xpos, ypos, lwidth, lineHeight, |
| 103 | longstr ? "Color Clock " : "Color Clk " , TextAlign::Left); |
| 104 | |
| 105 | myColorClocks = new EditTextWidget(boss, nfont, xpos+lwidth, ypos-1, fwidth, |
| 106 | lineHeight, "" ); |
| 107 | myColorClocks->setEditable(false, true); |
| 108 | |
| 109 | // Calculate actual dimensions |
| 110 | _w = myColorClocks->getAbsX() + myColorClocks->getWidth() - x; |
| 111 | _h = ypos + lineHeight; |
| 112 | } |
| 113 | |
| 114 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 115 | void TiaInfoWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) |
| 116 | { |
| 117 | //cerr << "TiaInfoWidget button press: x = " << x << ", y = " << y << endl; |
| 118 | } |
| 119 | |
| 120 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 121 | void TiaInfoWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) |
| 122 | { |
| 123 | } |
| 124 | |
| 125 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 126 | void TiaInfoWidget::loadConfig() |
| 127 | { |
| 128 | Debugger& dbg = instance().debugger(); |
| 129 | TIADebug& tia = dbg.tiaDebug(); |
| 130 | const TiaState& oldTia = static_cast<const TiaState&>(tia.getOldState()); |
| 131 | |
| 132 | myFrameCount->setText(Common::Base::toString(tia.frameCount(), Common::Base::F_10_5), |
| 133 | tia.frameCount() != oldTia.info[0]); |
| 134 | myFrameCycles->setText(Common::Base::toString(tia.frameCycles(), Common::Base::F_10_5), |
| 135 | tia.frameCycles() != oldTia.info[1]); |
| 136 | |
| 137 | myVSync->setState(tia.vsync(), tia.vsyncAsInt() != oldTia.info[2]); |
| 138 | myVBlank->setState(tia.vblank(), tia.vblankAsInt() != oldTia.info[3]); |
| 139 | |
| 140 | int clk = tia.clocksThisLine(); |
| 141 | myScanlineCount->setText(Common::Base::toString(tia.scanlines(), Common::Base::F_10_3), |
| 142 | tia.scanlines() != oldTia.info[4]); |
| 143 | myScanlineCountLast->setText( |
| 144 | Common::Base::toString(tia.scanlinesLastFrame(), Common::Base::F_10_3), |
| 145 | tia.scanlinesLastFrame() != oldTia.info[5]); |
| 146 | myScanlineCycles->setText(Common::Base::toString(clk/3, Common::Base::F_10), |
| 147 | clk != oldTia.info[6]); |
| 148 | myPixelPosition->setText(Common::Base::toString(clk-68, Common::Base::F_10), |
| 149 | clk != oldTia.info[6]); |
| 150 | myColorClocks->setText(Common::Base::toString(clk, Common::Base::F_10), |
| 151 | clk != oldTia.info[6]); |
| 152 | } |
| 153 | |