fix MessageBox height calculation

add first 0.5K RAM to ARM fatal error message
This commit is contained in:
thrust26 2019-12-21 11:59:07 +01:00
parent 99ec454fd4
commit c65b9c6709
4 changed files with 28 additions and 6 deletions

View File

@ -401,8 +401,8 @@ void DebuggerDialog::createFont()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::showFatalMessage(const string& msg)
{
myFatalError = make_unique<GUI::MessageBox>(this, *myLFont, msg, _w/2, _h/2,
kDDExitFatalCmd, "Exit ROM", "Continue", "Fatal error");
myFatalError = make_unique<GUI::MessageBox>(this, *myLFont, msg, _w-20, _h-20,
kDDExitFatalCmd, "Exit ROM", "Continue", "Fatal error");
myFatalError->show();
}

View File

@ -134,6 +134,7 @@ inline int Thumbulator::fatalError(const char* opcode, uInt32 v1, const char* ms
statusMsg << "Thumb ARM emulation fatal error: " << endl
<< opcode << "(" << Base::HEX8 << v1 << "), " << msg << endl;
dump_regs();
dump_ram();
if(trapOnFatal)
throw runtime_error(statusMsg.str());
return 0;
@ -146,6 +147,7 @@ inline int Thumbulator::fatalError(const char* opcode, uInt32 v1, uInt32 v2,
statusMsg << "Thumb ARM emulation fatal error: " << endl
<< opcode << "(" << Base::HEX8 << v1 << "," << v2 << "), " << msg << endl;
dump_regs();
dump_ram();
if(trapOnFatal)
throw runtime_error(statusMsg.str());
return 0;
@ -168,7 +170,8 @@ void Thumbulator::dump_regs()
for (int cnt = 0; cnt < 14; cnt++)
{
statusMsg << "R" << cnt << " = " << Base::HEX8 << reg_norm[cnt-1] << " ";
if(cnt % 4 == 0) statusMsg << endl;
if((cnt + 1) % 4 == 0)
statusMsg << endl;
}
statusMsg << endl
<< "SP = " << Base::HEX8 << reg_norm[13] << " "
@ -176,6 +179,25 @@ void Thumbulator::dump_regs()
<< "PC = " << Base::HEX8 << reg_norm[15] << " "
<< endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Thumbulator::dump_ram()
{
statusMsg << endl << "RAM:" << endl;
// TODO: display more than the first 0.5K
for (int addr = 0; addr < 0x200; addr++)
{
if (addr % 16 == 0)
statusMsg << Base::HEX4 << addr << ": ";
statusMsg << Base::HEX4 << CONV_RAMROM(ram[addr]) << " ";
if ((addr + 1) % 16 == 0)
statusMsg << endl;
else if ((addr + 1) % 8 == 0)
statusMsg << " ";
}
statusMsg << Base::HEX4 << 0x200 << ": ...";
}
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -180,6 +180,7 @@ class Thumbulator
void dump_counters();
void dump_regs();
void dump_ram();
#endif
int execute();
int reset();

View File

@ -56,8 +56,7 @@ MessageBox::MessageBox(GuiObject* boss, const GUI::Font& font,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MessageBox::addText(const GUI::Font& font, const StringList& text)
{
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth(),
const int fontWidth = font.getMaxCharWidth(),
fontHeight = font.getFontHeight();
int xpos, ypos;
@ -66,7 +65,7 @@ void MessageBox::addText(const GUI::Font& font, const StringList& text)
for(const auto& s: text)
str_w = std::max(int(s.length()), str_w);
_w = std::min(str_w * fontWidth + 20, _w);
_h = std::min(uInt32((text.size() + 2) * lineHeight + 20 + _th), uInt32(_h));
_h = std::min(uInt32((text.size() + 2) * fontHeight + 20 + _th), uInt32(_h));
xpos = 10; ypos = 10 + _th;
for(const auto& s: text)