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 "DelayQueueWidget.hxx"
19#include "DelayQueueIterator.hxx"
20#include "OSystem.hxx"
21#include "Debugger.hxx"
22#include "CartDebug.hxx"
23#include "TIADebug.hxx"
24#include "TIAConstants.hxx"
25#include "FBSurface.hxx"
26#include "Font.hxx"
27#include "Base.hxx"
28#include "TIA.hxx"
29
30// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
31DelayQueueWidget::DelayQueueWidget(
32 GuiObject* boss,
33 const GUI::Font& font,
34 int x, int y
35 ) : Widget(boss, font, x, y, 0, 0)
36{
37 _textcolor = kTextColor;
38
39 _w = 20 * font.getMaxCharWidth() + 6;
40 _h = lineCount * font.getLineHeight() + 6;
41
42 for (auto&& line : myLines) line = "";
43}
44
45// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
46void DelayQueueWidget::loadConfig() {
47 shared_ptr<DelayQueueIterator> delayQueueIterator =
48 instance().debugger().tiaDebug().delayQueueIterator();
49
50 using Common::Base;
51 for (auto&& line : myLines) {
52 if (!delayQueueIterator->isValid()) {
53 line = "";
54 continue;
55 }
56
57 stringstream ss;
58 const auto address = delayQueueIterator->address();
59 const int delay = delayQueueIterator->delay();
60
61 switch (address) {
62 case TIA::DummyRegisters::shuffleP0:
63 ss << delay << " clk, shuffle GRP0";
64 break;
65
66 case TIA::DummyRegisters::shuffleP1:
67 ss << delay << " clk, shuffle GRP1";
68 break;
69
70 case TIA::DummyRegisters::shuffleBL:
71 ss << delay << " clk, shuffle ENABL";
72 break;
73
74 default:
75 if (address < 64) ss
76 << delay
77 << " clk, $"
78 << Base::toString(delayQueueIterator->value(), Base::Format::F_16_2)
79 << " -> "
80 << instance().debugger().cartDebug().getLabel(address, false);
81 break;
82 }
83
84 line = ss.str();
85 delayQueueIterator->next();
86 }
87}
88
89// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
90void DelayQueueWidget::drawWidget(bool hilite)
91{
92 FBSurface& surface = _boss->dialog().surface();
93 bool onTop = _boss->dialog().isOnTop();
94
95 int y = _y,
96 x = _x,
97 w = _w,
98 lineHeight = _font.getLineHeight();
99
100 surface.frameRect(x, y, w, _h, kColor);
101
102 y += 1;
103 x += 1;
104 w -= 1;
105 surface.fillRect(x, y, w - 1, _h - 2, onTop ? kDlgColor : _bgcolorlo);
106
107 y += 2;
108 x += 2;
109 w -= 3;
110
111 for (const auto& line : myLines) {
112 surface.drawString(_font, line, x, y, w, onTop ? _textcolor : kColor);
113 y += lineHeight;
114 }
115}
116