2 // memory1browser.cpp - Jaguar memory window 1 browser
6 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
9 // --- ---------- -----------------------------------------------------------
10 // JPM 08/07/2017 Created this file
16 #include "memory1browser.h"
18 #include "debugger/DBGManager.h"
22 Memory1BrowserWindow::Memory1BrowserWindow(QWidget
* parent
/*= 0*/): QWidget(parent
, Qt::Dialog
),
23 // layout(new QVBoxLayout), text(new QTextBrowser),
24 layout(new QVBoxLayout
), text(new QLabel
),
25 refresh(new QPushButton(tr("Refresh"))),
26 address(new QLineEdit
),
27 go(new QPushButton(tr("Go"))),
28 memBase(0), memOrigin(0), NumWinOrigin(0)
30 //setWindowTitle(tr("Memory 1 Browser"));
32 //address->setInputMask("hhhhhh");
33 address
->setPlaceholderText("0x<value>, decimal value or symbol name");
35 QHBoxLayout
* hbox1
= new QHBoxLayout
;
36 hbox1
->addWidget(refresh
);
37 hbox1
->addWidget(address
);
40 // Need to set the size as well...
43 QFont
fixedFont("Lucida Console", 8, QFont::Normal
);
44 // QFont fixedFont("", 8, QFont::Normal);
45 fixedFont
.setStyleHint(QFont::TypeWriter
);
46 text
->setFont(fixedFont
);
47 //// layout->setSizeConstraint(QLayout::SetFixedSize);
50 layout
->addWidget(text
);
51 //layout->addWidget(refresh);
52 layout
->addLayout(hbox1
);
54 connect(refresh
, SIGNAL(clicked()), this, SLOT(RefreshContentsWindow()));
55 connect(go
, SIGNAL(clicked()), this, SLOT(GoToAddress()));
59 // Refresh / Display the window contents
60 void Memory1BrowserWindow::RefreshContents(size_t NumWin
)
66 sprintf(string
, "Memory %i - %06X", (unsigned int)((NumWinOrigin
= NumWin
) + 1), (unsigned int)memOrigin
);
67 setWindowTitle(tr(string
));
69 RefreshContentsWindow();
74 // Refresh / Display the window contents
75 void Memory1BrowserWindow::RefreshContentsWindow(void)
77 char string
[1024], buf
[64];
82 for (i
= 0; i
< 480; i
+= 16)
84 sprintf(string
, "%s%06X: ", (i
? "<br>" : ""), (unsigned int)(memBase
+ i
));
86 for (j
= 0; j
< 16; j
++)
88 sprintf(buf
, "%02X ", jaguarMainRAM
[memBase
+ i
+ j
]);
95 for (j
= 0; j
< 16; j
++)
97 c
= jaguarMainRAM
[memBase
+ i
+ j
];
98 sprintf(buf
, "&#%i;", c
);
101 sprintf(buf
, " ");
103 if ((c
< 0x20) || (c
> 0x7E))
109 memDump
+= QString(string
);
113 text
->setText(memDump
);
118 void Memory1BrowserWindow::keyPressEvent(QKeyEvent
* e
)
120 if (e
->key() == Qt::Key_Escape
)
126 if (e
->key() == Qt::Key_PageUp
)
133 RefreshContentsWindow();
137 if (e
->key() == Qt::Key_PageDown
)
141 if (memBase
> (0x200000 - 480))
142 memBase
= 0x200000 - 480;
144 RefreshContentsWindow();
148 if (e
->key() == Qt::Key_Up
|| e
->key() == Qt::Key_Minus
)
155 RefreshContentsWindow();
159 if (e
->key() == Qt::Key_Down
|| e
->key() == Qt::Key_Equal
)
163 if (memBase
> (0x200000 - 480))
164 memBase
= 0x200000 - 480;
166 RefreshContentsWindow();
170 if (e
->key() == Qt::Key_Return
)
182 // Go to the requested address
183 // Address can be an hexa, decimal or a symbol name
184 void Memory1BrowserWindow::GoToAddress(void)
189 newAddress
= address
->text();
191 if (( newAddress
.at(0) == QChar('0')) && (newAddress
.at(1) == QChar('x')))
193 memBase
= newAddress
.toUInt(&ok
, 16);
197 if (!(memBase
= DBGManager_GetAdrFromSymbolName(newAddress
.toLatin1().data())))
199 memBase
= newAddress
.toUInt(&ok
, 10);
204 RefreshContents(NumWinOrigin
);