Debugger: replace sprintf() part 4 - Debugger_Display

- Change ColorizeSpecialChar() to return std::string
This commit is contained in:
Kelvin Lee 2022-04-17 21:52:42 +10:00
parent 08c730c647
commit 6a342c27ce

View File

@ -180,11 +180,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
VideoScannerDisplayInfo g_videoScannerDisplayInfo; VideoScannerDisplayInfo g_videoScannerDisplayInfo;
static char ColorizeSpecialChar( char * sText, BYTE nData, const MemoryView_e iView,
const int iTxtBackground = BG_INFO , const int iTxtForeground = FG_DISASM_CHAR,
const int iHighBackground = BG_INFO_CHAR, const int iHighForeground = FG_INFO_CHAR_HI,
const int iLowBackground = BG_INFO_CHAR, const int iLowForeground = FG_INFO_CHAR_LO );
char FormatCharTxtAsci ( const BYTE b, bool * pWasAsci_ ); char FormatCharTxtAsci ( const BYTE b, bool * pWasAsci_ );
void DrawSubWindow_Code ( int iWindow ); void DrawSubWindow_Code ( int iWindow );
@ -945,15 +940,15 @@ void SetupColorsHiLoBits ( bool bHighBit, bool bCtrlBit,
// To flush out color bugs... swap: iAsciBackground & iHighBackground // To flush out color bugs... swap: iAsciBackground & iHighBackground
//=========================================================================== //===========================================================================
char ColorizeSpecialChar( char * sText, BYTE nData, const MemoryView_e iView, static std::string ColorizeSpecialChar( BYTE nData, const MemoryView_e iView,
const int iAsciBackground /*= 0 */, const int iTextForeground /*= FG_DISASM_CHAR */, const int iTextBackground = BG_INFO, const int iTextForeground = FG_DISASM_CHAR,
const int iHighBackground /*= BG_INFO_CHAR*/, const int iHighForeground /*= FG_INFO_CHAR_HI*/, const int iHighBackground = BG_INFO_CHAR, const int iHighForeground = FG_INFO_CHAR_HI,
const int iCtrlBackground /*= BG_INFO_CHAR*/, const int iCtrlForeground /*= FG_INFO_CHAR_LO*/ ) const int iCtrlBackground = BG_INFO_CHAR, const int iCtrlForeground = FG_INFO_CHAR_LO )
{ {
bool bHighBit = false; bool bHighBit = false;
bool bCtrlBit = false; bool bCtrlBit = false;
int iTextBG = iAsciBackground; int iTextBG = iTextBackground;
int iHighBG = iHighBackground; int iHighBG = iHighBackground;
int iCtrlBG = iCtrlBackground; int iCtrlBG = iCtrlBackground;
int iTextFG = iTextForeground; int iTextFG = iTextForeground;
@ -989,19 +984,6 @@ char ColorizeSpecialChar( char * sText, BYTE nData, const MemoryView_e iView,
default: break; default: break;
} }
if (sText)
sprintf( sText, "%c", nChar );
#if OLD_CONSOLE_COLOR
if (sText)
{
if (ConsoleColor_IsEscapeMeta( nChar ))
sprintf( sText, "%c%c", nChar, nChar );
else
sprintf( sText, "%c", nChar );
}
#endif
// if (hDC) // if (hDC)
{ {
SetupColorsHiLoBits( bHighBit, bCtrlBit SetupColorsHiLoBits( bHighBit, bCtrlBit
@ -1010,7 +992,13 @@ char ColorizeSpecialChar( char * sText, BYTE nData, const MemoryView_e iView,
, iCtrlBG, iCtrlFG // FG_DISASM_OPCODE , iCtrlBG, iCtrlFG // FG_DISASM_OPCODE
); );
} }
return nChar;
#if OLD_CONSOLE_COLOR
if (ConsoleColorIsEscapeMeta( nChar ))
return std::string( 2, nChar );
#endif
return std::string( 1, nChar );
} }
void ColorizeFlags( bool bSet, int bg_default = BG_INFO, int fg_default = FG_INFO_TITLE ) void ColorizeFlags( bool bSet, int bg_default = BG_INFO, int fg_default = FG_INFO_TITLE )
@ -1043,12 +1031,10 @@ void DrawBreakpoints ( int line )
rect.right = DISPLAY_WIDTH; rect.right = DISPLAY_WIDTH;
rect.bottom = rect.top + g_nFontHeight; rect.bottom = rect.top + g_nFontHeight;
char sText[16] = "Breakpoints"; // TODO: Move to BP1
#if DISPLAY_BREAKPOINT_TITLE #if DISPLAY_BREAKPOINT_TITLE
DebuggerSetColorBG( DebuggerGetColor( BG_INFO )); // COLOR_BG_DATA DebuggerSetColorBG( DebuggerGetColor( BG_INFO )); // COLOR_BG_DATA
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE )); //COLOR_STATIC DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE )); //COLOR_STATIC
PrintText( sText, rect ); PrintText("Breakpoints", rect );
rect.top += g_nFontHeight; rect.top += g_nFontHeight;
rect.bottom += g_nFontHeight; rect.bottom += g_nFontHeight;
#endif #endif
@ -1088,17 +1074,14 @@ void DrawBreakpoints ( int line )
DebuggerSetColorBG( DebuggerGetColor( BG_INFO )); DebuggerSetColorBG( DebuggerGetColor( BG_INFO ));
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE ) ); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE ) );
sprintf( sText, "B" ); PrintTextCursorX( "B", rect2 );
PrintTextCursorX( sText, rect2 );
DebuggerSetColorBG( DebuggerGetColor( BG_INFO )); DebuggerSetColorBG( DebuggerGetColor( BG_INFO ));
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_BULLET ) ); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_BULLET ) );
sprintf( sText, "%X ", iBreakpoint ); PrintTextCursorX( StrFormat("%X ", iBreakpoint).c_str(), rect2);
PrintTextCursorX( sText, rect2 );
// DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR ) ); // DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR ) );
// strcpy( sText, "." ); // PrintTextCursorX( ".", rect2 );
// PrintTextCursorX( sText, rect2 );
#if DEBUG_FORCE_DISPLAY #if DEBUG_FORCE_DISPLAY
pBP->eSource = (BreakpointSource_t) iBreakpoint; pBP->eSource = (BreakpointSource_t) iBreakpoint;
@ -1157,8 +1140,7 @@ void DrawBreakpoints ( int line )
DebuggerSetColorFG( nColor ); DebuggerSetColorFG( nColor );
#endif #endif
sprintf( sText, "%04X", nAddress1 ); PrintTextCursorX( WordToHexStr( nAddress1 ).c_str(), rect2);
PrintTextCursorX( sText, rect2 );
if (nLength == 1) if (nLength == 1)
{ {
@ -1198,8 +1180,7 @@ void DrawBreakpoints ( int line )
} }
DebuggerSetColorFG( nColor ); DebuggerSetColorFG( nColor );
#endif #endif
sprintf( sText, "%04X", nAddress2 ); PrintTextCursorX( WordToHexStr( nAddress2 ).c_str(), rect2);
PrintTextCursorX( sText, rect2 );
if (pBP->eSource == BP_SRC_MEM_READ_ONLY) if (pBP->eSource == BP_SRC_MEM_READ_ONLY)
PrintTextCursorX("R", rect2); PrintTextCursorX("R", rect2);
@ -1825,7 +1806,7 @@ WORD DrawDisassemblyLine ( int iLine, const WORD nBaseAddress )
if (! bCursorLine) if (! bCursorLine)
{ {
ColorizeSpecialChar( NULL, line.nImmediate, MEM_VIEW_ASCII, iBackground ); ColorizeSpecialChar( line.nImmediate, MEM_VIEW_ASCII, iBackground );
} }
PrintTextCursorX( line.sImmediate, linerect ); PrintTextCursorX( line.sImmediate, linerect );
@ -1869,7 +1850,6 @@ static void DrawFlags ( int line, WORD nRegFlags )
if (! ((g_iWindowThis == WINDOW_CODE) || ((g_iWindowThis == WINDOW_DATA)))) if (! ((g_iWindowThis == WINDOW_CODE) || ((g_iWindowThis == WINDOW_DATA))))
return; return;
char sText[4] = "?";
RECT rect; RECT rect;
int nFontWidth = g_aFontConfig[ FONT_INFO ]._nFontWidthAvg; int nFontWidth = g_aFontConfig[ FONT_INFO ]._nFontWidthAvg;
@ -1901,15 +1881,12 @@ static void DrawFlags ( int line, WORD nRegFlags )
rect.top += g_nFontHeight; rect.top += g_nFontHeight;
rect.bottom += g_nFontHeight; rect.bottom += g_nFontHeight;
sprintf( sText, "%02X", nRegFlags );
DebuggerSetColorBG( DebuggerGetColor( BG_INFO )); DebuggerSetColorBG( DebuggerGetColor( BG_INFO ));
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE ));
PrintText( sText, rect ); PrintText( ByteToHexStr( nRegFlags ).c_str(), rect);
rect.top -= g_nFontHeight; rect.top -= g_nFontHeight;
rect.bottom -= g_nFontHeight; rect.bottom -= g_nFontHeight;
sText[1] = 0;
rect.left += ((2 + _6502_NUM_FLAGS) * nSpacerWidth); rect.left += ((2 + _6502_NUM_FLAGS) * nSpacerWidth);
rect.right = rect.left + nFontWidth; rect.right = rect.left + nFontWidth;
@ -1924,7 +1901,6 @@ static void DrawFlags ( int line, WORD nRegFlags )
bool bSet = (nRegFlags & 1); bool bSet = (nRegFlags & 1);
sText[0] = g_aBreakpointSource[ BP_SRC_FLAG_C + iFlag ][0];
if (bSet) if (bSet)
{ {
@ -1939,7 +1915,8 @@ static void DrawFlags ( int line, WORD nRegFlags )
rect.left -= nSpacerWidth; rect.left -= nSpacerWidth;
rect.right -= nSpacerWidth; rect.right -= nSpacerWidth;
PrintText( sText, rect ); const char szBpSrc[2] = { g_aBreakpointSource[ BP_SRC_FLAG_C + iFlag ][0], '\0' };
PrintText( szBpSrc, rect );
// Print Binary value // Print Binary value
rect.top += g_nFontHeight; rect.top += g_nFontHeight;
@ -1947,8 +1924,8 @@ static void DrawFlags ( int line, WORD nRegFlags )
DebuggerSetColorBG( DebuggerGetColor( BG_INFO )); DebuggerSetColorBG( DebuggerGetColor( BG_INFO ));
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE ));
sText[0] = '0' + static_cast<int>(bSet); const char szSet[2] = { '0' + static_cast<int>(bSet), '\0' };
PrintText( sText, rect ); PrintText( szSet, rect );
rect.top -= g_nFontHeight; rect.top -= g_nFontHeight;
rect.bottom -= g_nFontHeight; rect.bottom -= g_nFontHeight;
@ -1979,20 +1956,18 @@ void DrawMemory ( int line, int iMemDump )
if ((eDevice == DEV_SY6522) || (eDevice == DEV_AY8910)) if ((eDevice == DEV_SY6522) || (eDevice == DEV_AY8910))
MB_GetSnapshot_v1(&SS_MB, 4+(nAddr>>1)); // Slot4 or Slot5 MB_GetSnapshot_v1(&SS_MB, 4+(nAddr>>1)); // Slot4 or Slot5
RECT rect; RECT rect = { 0 };
rect.left = DISPLAY_MINIMEM_COLUMN; rect.left = DISPLAY_MINIMEM_COLUMN;
rect.top = (line * g_nFontHeight); rect.top = (line * g_nFontHeight);
rect.right = DISPLAY_WIDTH; rect.right = DISPLAY_WIDTH;
rect.bottom = rect.top + g_nFontHeight; rect.bottom = rect.top + g_nFontHeight;
RECT rect2; RECT rect2 = rect;
rect2 = rect;
const int MAX_MEM_VIEW_TXT = 16; const int MAX_MEM_VIEW_TXT = 16;
char sText[ MAX_MEM_VIEW_TXT * 2 ];
char sType [ 6 ] = "Mem"; const char* pType = "Mem";
char sAddress[ 8 ] = ""; std::string sAddress;
int iForeground = FG_INFO_OPCODE; int iForeground = FG_INFO_OPCODE;
int iBackground = BG_INFO; int iBackground = BG_INFO;
@ -2000,37 +1975,37 @@ void DrawMemory ( int line, int iMemDump )
#if DISPLAY_MEMORY_TITLE #if DISPLAY_MEMORY_TITLE
if (eDevice == DEV_SY6522) if (eDevice == DEV_SY6522)
{ {
// sprintf(sData,"Mem at SY#%d", nAddr); // sData = StrFormat("Mem at SY#%d", nAddr);
sprintf( sAddress,"SY#%d", nAddr ); sAddress = StrFormat( "SY#%d", nAddr );
} }
else if (eDevice == DEV_AY8910) else if (eDevice == DEV_AY8910)
{ {
// sprintf(sData,"Mem at AY#%d", nAddr); // sData = StrFormat("Mem at AY#%d", nAddr);
sprintf( sAddress,"AY#%d", nAddr ); sAddress = StrFormat( "AY#%d", nAddr );
} }
else else
{ {
sprintf( sAddress,"%04X",(unsigned)nAddr); sAddress = WordToHexStr( nAddr );
if (iView == MEM_VIEW_HEX) if (iView == MEM_VIEW_HEX)
sprintf( sType, "HEX" ); pType = "HEX";
else else
if (iView == MEM_VIEW_ASCII) if (iView == MEM_VIEW_ASCII)
sprintf( sType, "ASCII" ); pType = "ASCII";
else else
sprintf( sType, "TEXT" ); pType = "TEXT";
} }
rect2 = rect; rect2 = rect;
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE ));
DebuggerSetColorBG( DebuggerGetColor( BG_INFO )); DebuggerSetColorBG( DebuggerGetColor( BG_INFO ));
PrintTextCursorX( sType, rect2 ); PrintTextCursorX( pType, rect2 );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR ));
PrintTextCursorX( " at ", rect2 ); PrintTextCursorX( " at ", rect2 );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_ADDRESS )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_ADDRESS ));
PrintTextCursorY( sAddress, rect2 ); PrintTextCursorY( sAddress.c_str(), rect2);
#endif #endif
rect.top = rect2.top; rect.top = rect2.top;
@ -2062,9 +2037,8 @@ void DrawMemory ( int line, int iMemDump )
if (iView == MEM_VIEW_HEX) if (iView == MEM_VIEW_HEX)
{ {
sprintf( sText, "%04X", iAddress );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_ADDRESS )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_ADDRESS ));
PrintTextCursorX( sText, rect2 ); PrintTextCursorX( WordToHexStr( iAddress ).c_str(), rect2);
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR ));
PrintTextCursorX( ":", rect2 ); PrintTextCursorX( ":", rect2 );
@ -2075,15 +2049,17 @@ void DrawMemory ( int line, int iMemDump )
DebuggerSetColorBG( DebuggerGetColor( iBackground )); DebuggerSetColorBG( DebuggerGetColor( iBackground ));
DebuggerSetColorFG( DebuggerGetColor( iForeground )); DebuggerSetColorFG( DebuggerGetColor( iForeground ));
std::string sText;
// .12 Bugfix: DrawMemory() should draw memory byte for IO address: ML1 C000 // .12 Bugfix: DrawMemory() should draw memory byte for IO address: ML1 C000
// if ((iAddress >= _6502_IO_BEGIN) && (iAddress <= _6502_IO_END)) // if ((iAddress >= _6502_IO_BEGIN) && (iAddress <= _6502_IO_END))
// { // {
// sprintf( sText, "IO " ); // sText = "IO ";
// } // }
// else // else
if (eDevice == DEV_SY6522) if (eDevice == DEV_SY6522)
{ {
sprintf( sText, "%02X ", (unsigned) ((BYTE*)&SS_MB.Unit[nAddr & 1].RegsSY6522)[iAddress] ); sText = StrFormat( "%02X ", (unsigned)((BYTE*)&SS_MB.Unit[nAddr & 1].RegsSY6522)[iAddress] );
if (SS_MB.Unit[nAddr & 1].bTimer1Active && (iAddress == 4 || iAddress == 5)) // T1C if (SS_MB.Unit[nAddr & 1].bTimer1Active && (iAddress == 4 || iAddress == 5)) // T1C
{ {
DebuggerSetColorFG(DebuggerGetColor(FG_INFO_TITLE)); // if timer1 active then draw in white DebuggerSetColorFG(DebuggerGetColor(FG_INFO_TITLE)); // if timer1 active then draw in white
@ -2103,7 +2079,7 @@ void DrawMemory ( int line, int iMemDump )
else else
if (eDevice == DEV_AY8910) if (eDevice == DEV_AY8910)
{ {
sprintf( sText, "%02X ", (unsigned)SS_MB.Unit[nAddr & 1].RegsAY8910[iAddress] ); sText = StrFormat( "%02X ", (unsigned)SS_MB.Unit[nAddr & 1].RegsAY8910[iAddress] );
if (iCol & 1) if (iCol & 1)
DebuggerSetColorFG( DebuggerGetColor( iForeground )); DebuggerSetColorFG( DebuggerGetColor( iForeground ));
else else
@ -2112,7 +2088,6 @@ void DrawMemory ( int line, int iMemDump )
else else
{ {
BYTE nData = (unsigned)*(LPBYTE)(mem+iAddress); BYTE nData = (unsigned)*(LPBYTE)(mem+iAddress);
sText[0] = 0;
if (iView == MEM_VIEW_HEX) if (iView == MEM_VIEW_HEX)
{ {
@ -2121,7 +2096,7 @@ void DrawMemory ( int line, int iMemDump )
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_IO_BYTE )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_IO_BYTE ));
} }
sprintf(sText, "%02X ", nData ); sText = StrFormat( "%02X ", nData );
} }
else else
{ {
@ -2129,10 +2104,10 @@ void DrawMemory ( int line, int iMemDump )
if ((iAddress >= _6502_IO_BEGIN) && (iAddress <= _6502_IO_END)) if ((iAddress >= _6502_IO_BEGIN) && (iAddress <= _6502_IO_END))
iBackground = BG_INFO_IO_BYTE; iBackground = BG_INFO_IO_BYTE;
ColorizeSpecialChar( sText, nData, iView, iBackground ); sText = ColorizeSpecialChar( nData, iView, iBackground );
} }
} }
PrintTextCursorX( sText, rect2 ); // PrintTextCursorX() PrintTextCursorX( sText.c_str(), rect2); // PrintTextCursorX()
iAddress++; iAddress++;
} }
// Windows HACK: Bugfix: Rest of line is still background color // Windows HACK: Bugfix: Rest of line is still background color
@ -2182,23 +2157,22 @@ void DrawRegister ( int line, LPCTSTR name, const int nBytes, const WORD nValue,
unsigned int nData = nValue; unsigned int nData = nValue;
int nOffset = 6; int nOffset = 6;
char sValue[8];
if (PARAM_REG_SP == iSource) if (PARAM_REG_SP == iSource)
{ {
WORD nStackDepth = _6502_STACK_END - nValue; WORD nStackDepth = _6502_STACK_END - nValue;
sprintf( sValue, "%02X", nStackDepth );
int nFontWidth = g_aFontConfig[ FONT_INFO ]._nFontWidthAvg; int nFontWidth = g_aFontConfig[ FONT_INFO ]._nFontWidthAvg;
rect.left += (2 * nFontWidth) + (nFontWidth >> 1); // 2.5 looks a tad nicer then 2 rect.left += (2 * nFontWidth) + (nFontWidth >> 1); // 2.5 looks a tad nicer then 2
// ## = Stack Depth (in bytes) // ## = Stack Depth (in bytes)
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR )); // FG_INFO_OPCODE, FG_INFO_TITLE DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR )); // FG_INFO_OPCODE, FG_INFO_TITLE
PrintText( sValue, rect ); PrintText( ByteToHexStr( nStackDepth ).c_str(), rect );
} }
std::string sValue;
if (nBytes == 2) if (nBytes == 2)
{ {
sprintf(sValue,"%04X", nData); sValue = WordToHexStr( nData );
} }
else else
{ {
@ -2208,15 +2182,15 @@ void DrawRegister ( int line, LPCTSTR name, const int nBytes, const WORD nValue,
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR ));
PrintTextCursorX( "'", rect ); // PrintTextCursorX PrintTextCursorX( "'", rect ); // PrintTextCursorX
ColorizeSpecialChar( sValue, nData, MEM_VIEW_ASCII ); // MEM_VIEW_APPLE for inverse background little hard on the eyes sValue = ColorizeSpecialChar( nData, MEM_VIEW_ASCII ); // MEM_VIEW_APPLE for inverse background little hard on the eyes
DebuggerSetColorBG( DebuggerGetColor( iBackground )); DebuggerSetColorBG( DebuggerGetColor( iBackground ));
PrintTextCursorX( sValue, rect ); // PrintTextCursorX() PrintTextCursorX( sValue.c_str(), rect); // PrintTextCursorX()
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR ));
PrintTextCursorX( "'", rect ); // PrintTextCursorX() PrintTextCursorX( "'", rect ); // PrintTextCursorX()
sprintf(sValue," %02X", nData ); sValue = StrFormat( " %02X", nData );
} }
// Needs to be far enough over, since 4 chars of ZeroPage symbol also calls us // Needs to be far enough over, since 4 chars of ZeroPage symbol also calls us
@ -2230,7 +2204,7 @@ void DrawRegister ( int line, LPCTSTR name, const int nBytes, const WORD nValue,
{ {
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE )); // FG_DISASM_OPCODE DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE )); // FG_DISASM_OPCODE
} }
PrintText( sValue, rect ); PrintText( sValue.c_str(), rect );
} }
//=========================================================================== //===========================================================================
@ -2270,12 +2244,9 @@ void _DrawSoftSwitchHighlight( RECT & temp, bool bSet, const char *sOn, const ch
//=========================================================================== //===========================================================================
void _DrawSoftSwitchAddress( RECT & rect, int nAddress, int bg_default = BG_INFO ) void _DrawSoftSwitchAddress( RECT & rect, int nAddress, int bg_default = BG_INFO )
{ {
char sText[ 4 ] = "";
DebuggerSetColorBG( DebuggerGetColor( bg_default )); DebuggerSetColorBG( DebuggerGetColor( bg_default ));
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_TARGET )); DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_TARGET ));
sprintf( sText, "%02X", (nAddress & 0xFF) ); PrintTextCursorX( ByteToHexStr( nAddress & 0xFF ).c_str(), rect );
PrintTextCursorX( sText, rect );
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_OPERATOR ) ); DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_OPERATOR ) );
PrintTextCursorX( ":", rect ); PrintTextCursorX( ":", rect );
@ -2438,18 +2409,18 @@ void _DrawSoftSwitchLanguageCardBank( RECT & rect, const int iBankDisplay, int b
rect.right += 4*w; rect.right += 4*w;
int iActiveBank = -1; int iActiveBank = -1;
char sText[ 4 ] = "?"; // Default to RAMWORKS char chMemType = '?'; // Default to RAMWORKS
if (GetCurrentExpansionMemType() == CT_RamWorksIII) { sText[0] = 'r'; iActiveBank = GetRamWorksActiveBank(); } if (GetCurrentExpansionMemType() == CT_RamWorksIII) { chMemType = 'r'; iActiveBank = GetRamWorksActiveBank(); }
if (GetCurrentExpansionMemType() == CT_Saturn128K) { sText[0] = 's'; iActiveBank = GetCardMgr().GetLanguageCard()->GetActiveBank(); } if (GetCurrentExpansionMemType() == CT_Saturn128K) { chMemType = 's'; iActiveBank = GetCardMgr().GetLanguageCard()->GetActiveBank(); }
if (iActiveBank >= 0) if (iActiveBank >= 0)
{ {
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_REG )); // light blue DebuggerSetColorFG( DebuggerGetColor( FG_INFO_REG )); // light blue
PrintTextCursorX( sText, rect ); const char szMemType[2] = { chMemType, '\0' };
PrintTextCursorX( szMemType, rect );
sprintf( sText, "%02X", (iActiveBank & 0x7F) );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_ADDRESS )); // orange DebuggerSetColorFG( DebuggerGetColor( FG_INFO_ADDRESS )); // orange
PrintTextCursorX( sText, rect ); PrintTextCursorX( ByteToHexStr( iActiveBank & 0x7F ).c_str(), rect );
} }
else else
{ {
@ -2538,39 +2509,32 @@ void DrawSoftSwitches( int iSoftSwitch )
// GR / TEXT // GR / TEXT
// GRAPH/TEXT // GRAPH/TEXT
// TEXT ON/OFF // TEXT ON/OFF
sprintf( sText, !VideoGetSWTEXT() ? "GR / ----" : "-- / TEXT" ); PrintTextCursorY( !VideoGetSWTEXT() ? "GR / ----" : "-- / TEXT", rect );
PrintTextCursorY( sText, rect );
// $C052 / $C053 = MIXEDOFF/MIXEDON = SW.MIXCLR/SW.MIXSET // $C052 / $C053 = MIXEDOFF/MIXEDON = SW.MIXCLR/SW.MIXSET
// FULL/MIXED // FULL/MIXED
// MIX OFF/ON // MIX OFF/ON
sprintf( sText, !VideoGetSWMIXED() ? "FULL/-----" : "----/MIXED" ); PrintTextCursorY( !VideoGetSWMIXED() ? "FULL/-----" : "----/MIXED", rect );
PrintTextCursorY( sText, rect );
// $C054 / $C055 = PAGE1/PAGE2 = PAGE2OFF/PAGE2ON = SW.LOWSCR/SW.HISCR // $C054 / $C055 = PAGE1/PAGE2 = PAGE2OFF/PAGE2ON = SW.LOWSCR/SW.HISCR
// PAGE 1 / 2 // PAGE 1 / 2
sprintf( sText, !VideoGetSWPAGE2() ? "PAGE 1 / -" : "PAGE - / 2" ); PrintTextCursorY( !VideoGetSWPAGE2() ? "PAGE 1 / -" : "PAGE - / 2", rect );
PrintTextCursorY( sText, rect );
// $C056 / $C057 LORES/HIRES = HIRESOFF/HIRESON = SW.LORES/SW.HIRES // $C056 / $C057 LORES/HIRES = HIRESOFF/HIRESON = SW.LORES/SW.HIRES
// LO / HIRES // LO / HIRES
// LO / ----- // LO / -----
// -- / HIRES // -- / HIRES
sprintf( sText, !VideoGetSWHIRES() ? "LO /-- RES" : "---/HI RES" ); PrintTextCursorY( !VideoGetSWHIRES() ? "LO /-- RES" : "---/HI RES", rect );
PrintTextCursorY( sText, rect );
PrintTextCursorY( "", rect ); PrintTextCursorY( "", rect );
// Extended soft switches // Extended soft switches
sprintf( sText, !VideoGetSW80COL() ? "40 / -- COL" : "-- / 80 COL" ); PrintTextCursorY( !VideoGetSW80COL() ? "40 / -- COL" : "-- / 80 COL", rect );
PrintTextCursorY( sText, rect );
sprintf(sText, VideoGetSWAltCharSet() ? "ASCII/-----" : "-----/MOUSE" ); PrintTextCursorY( VideoGetSWAltCharSet() ? "ASCII/-----" : "-----/MOUSE", rect );
PrintTextCursorY( sText, rect );
// 280/560 HGR // 280/560 HGR
sprintf(sText, !VideoGetSWDHIRES() ? "HGR / ----" : "--- / DHGR" ); PrintTextCursorY( !VideoGetSWDHIRES() ? "HGR / ----" : "--- / DHGR", rect );
PrintTextCursorY( sText, rect );
#else //SOFTSWITCH_OLD #else //SOFTSWITCH_OLD
// See: VideoSetMode() // See: VideoSetMode()
@ -2705,18 +2669,15 @@ void DrawStack ( int line)
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE )); // [COLOR_STATIC DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE )); // [COLOR_STATIC
char sText[8] = "";
if (nAddress <= _6502_STACK_END) if (nAddress <= _6502_STACK_END)
{ {
sprintf( sText,"%04X: ", nAddress ); PrintTextCursorX( StrFormat( "%04X: ", nAddress ).c_str(), rect );
PrintTextCursorX( sText, rect );
} }
if (nAddress <= _6502_STACK_END) if (nAddress <= _6502_STACK_END)
{ {
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE )); // COLOR_FG_DATA_TEXT DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE )); // COLOR_FG_DATA_TEXT
sprintf(sText, " %02X",(unsigned)*(LPBYTE)(mem+nAddress)); PrintTextCursorX( StrFormat( " %02X", (unsigned)*(LPBYTE)(mem+nAddress) ).c_str(), rect );
PrintTextCursorX( sText, rect );
} }
iStack++; iStack++;
} }
@ -2745,8 +2706,8 @@ void DrawTargets ( int line)
// if ((aTarget[iAddress] >= _6502_IO_BEGIN) && (aTarget[iAddress] <= _6502_IO_END)) // if ((aTarget[iAddress] >= _6502_IO_BEGIN) && (aTarget[iAddress] <= _6502_IO_END))
// aTarget[iAddress] = NO_6502_TARGET; // aTarget[iAddress] = NO_6502_TARGET;
char sAddress[8] = "-none-"; std::string sAddress = "-none-";
char sData[8] = ""; std::string sData;
#if DEBUG_FORCE_DISPLAY // Targets #if DEBUG_FORCE_DISPLAY // Targets
if (aTarget[iAddress] == NO_6502_TARGET) if (aTarget[iAddress] == NO_6502_TARGET)
@ -2754,11 +2715,11 @@ void DrawTargets ( int line)
#endif #endif
if (aTarget[iAddress] != NO_6502_TARGET) if (aTarget[iAddress] != NO_6502_TARGET)
{ {
sprintf(sAddress,"%04X",aTarget[iAddress]); sAddress = WordToHexStr(aTarget[iAddress]);
if (iAddress) if (iAddress)
sprintf(sData,"%02X",*(LPBYTE)(mem+aTarget[iAddress])); sData = ByteToHexStr(*(LPBYTE)(mem+aTarget[iAddress]));
else else
sprintf(sData,"%04X",*(LPWORD)(mem+aTarget[iAddress])); sData = WordToHexStr(*(LPWORD)(mem+aTarget[iAddress]));
} }
rect.left = DISPLAY_TARGETS_COLUMN; rect.left = DISPLAY_TARGETS_COLUMN;
@ -2773,7 +2734,7 @@ void DrawTargets ( int line)
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_ADDRESS )); // Target Address DebuggerSetColorFG( DebuggerGetColor( FG_INFO_ADDRESS )); // Target Address
DebuggerSetColorBG( DebuggerGetColor( BG_INFO )); DebuggerSetColorBG( DebuggerGetColor( BG_INFO ));
PrintText( sAddress, rect ); PrintText( sAddress.c_str(), rect );
rect.left = nColumn; rect.left = nColumn;
rect.right = rect.left + (10 * nFontWidth); // SCREENSPLIT2 rect.right = rect.left + (10 * nFontWidth); // SCREENSPLIT2
@ -2783,7 +2744,7 @@ void DrawTargets ( int line)
else else
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE )); // Target Bytes DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE )); // Target Bytes
PrintText( sData, rect ); PrintText( sData.c_str(), rect );
} }
} }
@ -2799,13 +2760,11 @@ void DrawWatches (int line)
rect.right = DISPLAY_WIDTH; rect.right = DISPLAY_WIDTH;
rect.bottom = rect.top + g_nFontHeight; rect.bottom = rect.top + g_nFontHeight;
char sText[16] = "Watches";
DebuggerSetColorBG(DebuggerGetColor( BG_INFO_WATCH )); DebuggerSetColorBG(DebuggerGetColor( BG_INFO_WATCH ));
#if DISPLAY_WATCH_TITLE #if DISPLAY_WATCH_TITLE
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE ));
PrintTextCursorY( sText, rect ); PrintTextCursorY("Watches", rect );
#endif #endif
int iWatch; int iWatch;
@ -2823,16 +2782,14 @@ void DrawWatches (int line)
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE ) ); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE ) );
PrintTextCursorX( "W", rect2 ); PrintTextCursorX( "W", rect2 );
sprintf( sText, "%X ",iWatch );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_BULLET )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_BULLET ));
PrintTextCursorX( sText, rect2 ); PrintTextCursorX( StrFormat( "%X ", iWatch ).c_str(), rect2 );
// DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR )); // DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR ));
// PrintTextCursorX( ".", rect2 ); // PrintTextCursorX( ".", rect2 );
sprintf( sText,"%04X", g_aWatches[iWatch].nAddress );
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_ADDRESS )); DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_ADDRESS ));
PrintTextCursorX( sText, rect2 ); PrintTextCursorX( WordToHexStr( g_aWatches[iWatch].nAddress ).c_str(), rect2 );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR ));
PrintTextCursorX( ":", rect2 ); PrintTextCursorX( ":", rect2 );
@ -2840,32 +2797,27 @@ void DrawWatches (int line)
BYTE nTarget8 = 0; BYTE nTarget8 = 0;
nTarget8 = (unsigned)*(LPBYTE)(mem+g_aWatches[iWatch].nAddress); nTarget8 = (unsigned)*(LPBYTE)(mem+g_aWatches[iWatch].nAddress);
sprintf(sText,"%02X", nTarget8 );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE ));
PrintTextCursorX( sText, rect2 ); PrintTextCursorX( ByteToHexStr( nTarget8 ).c_str(), rect2 );
nTarget8 = (unsigned)*(LPBYTE)(mem+g_aWatches[iWatch].nAddress + 1); nTarget8 = (unsigned)*(LPBYTE)(mem+g_aWatches[iWatch].nAddress + 1);
sprintf(sText,"%02X", nTarget8 );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE ));
PrintTextCursorX( sText, rect2 ); PrintTextCursorX( ByteToHexStr( nTarget8 ).c_str(), rect2 );
sprintf( sText,"(" );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR ));
PrintTextCursorX( sText, rect2 ); PrintTextCursorX( "(", rect2 );
WORD nTarget16 = (unsigned)*(LPWORD)(mem+g_aWatches[iWatch].nAddress); WORD nTarget16 = (unsigned)*(LPWORD)(mem+g_aWatches[iWatch].nAddress);
sprintf( sText,"%04X", nTarget16 );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_ADDRESS )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_ADDRESS ));
PrintTextCursorX( sText, rect2 ); PrintTextCursorX( WordToHexStr( nTarget16 ).c_str(), rect2 );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR ));
// PrintTextCursorX( ":", rect2 ); // PrintTextCursorX( ":", rect2 );
PrintTextCursorX( ")", rect2 ); PrintTextCursorX( ")", rect2 );
// BYTE nValue8 = (unsigned)*(LPBYTE)(mem + nTarget16); // BYTE nValue8 = *(LPBYTE)(mem + nTarget16);
// sprintf(sText,"%02X", nValue8 );
// DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE )); // DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE ));
// PrintTextCursorX( sText, rect2 ); // PrintTextCursorX( ByteToHexStr( nValue8 ).c_str(), rect2 );
rect.top += g_nFontHeight; rect.top += g_nFontHeight;
rect.bottom += g_nFontHeight; rect.bottom += g_nFontHeight;
@ -2887,8 +2839,7 @@ void DrawWatches (int line)
DebuggerSetColorBG( DebuggerGetColor( BG_DATA_2 )); DebuggerSetColorBG( DebuggerGetColor( BG_DATA_2 ));
BYTE nValue8 = mem[ (nTarget16 + iByte) & 0xffff ]; BYTE nValue8 = mem[ (nTarget16 + iByte) & 0xffff ];
sprintf(sText,"%02X", nValue8 ); PrintTextCursorX( ByteToHexStr( nValue8 ).c_str(), rect2 );
PrintTextCursorX( sText, rect2 );
} }
} }
rect.top += g_nFontHeight; rect.top += g_nFontHeight;
@ -2914,7 +2865,6 @@ void DrawZeroPagePointers ( int line )
DebuggerSetColorBG( DebuggerGetColor( BG_INFO_ZEROPAGE )); DebuggerSetColorBG( DebuggerGetColor( BG_INFO_ZEROPAGE ));
const int nMaxSymbolLen = 7; const int nMaxSymbolLen = 7;
char sText[nMaxSymbolLen+1] = "";
for (int iZP = 0; iZP < MAX_ZEROPAGE_POINTERS; iZP++) for (int iZP = 0; iZP < MAX_ZEROPAGE_POINTERS; iZP++)
{ {
@ -2931,9 +2881,8 @@ void DrawZeroPagePointers ( int line )
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE ) ); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE ) );
PrintTextCursorX( "Z", rect2 ); PrintTextCursorX( "Z", rect2 );
sprintf( sText, "%X ", iZP );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_BULLET )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_BULLET ));
PrintTextCursorX( sText, rect2 ); PrintTextCursorX( StrFormat( "%X ", iZP ).c_str(), rect2 );
// DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR )); // DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR ));
// PrintTextCursorX( " ", rect2 ); // PrintTextCursorX( " ", rect2 );
@ -2946,63 +2895,57 @@ void DrawZeroPagePointers ( int line )
std::string const& sSymbol1 = GetSymbol(nZPAddr1, 2, sAddressBuf1); // 2:8-bit value (if symbol not found) std::string const& sSymbol1 = GetSymbol(nZPAddr1, 2, sAddressBuf1); // 2:8-bit value (if symbol not found)
std::string const& sSymbol2 = GetSymbol(nZPAddr2, 2, sAddressBuf2); // 2:8-bit value (if symbol not found) std::string const& sSymbol2 = GetSymbol(nZPAddr2, 2, sAddressBuf2); // 2:8-bit value (if symbol not found)
std::string sText;
// if ((sSymbol1.length() == 1) && (sSymbol2.length() == 1)) // if ((sSymbol1.length() == 1) && (sSymbol2.length() == 1))
// sprintf( sText, "%s%s", sSymbol1.c_str(), sSymbol2.c_str()); // sText = sSymbol1 + sSymbol2;
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_ADDRESS )); DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_ADDRESS ));
for ( int x = 0; x < nMaxSymbolLen; x++ )
{
sText[ x ] = CHAR_SPACE;
}
sText[nMaxSymbolLen] = 0;
if (!sSymbol1.empty() && sSymbol1[0] == '$') if (!sSymbol1.empty() && sSymbol1[0] == '$')
{ {
// sprintf( sText, "%s%s", sSymbol1 ); // sText = pSymbol1;
// sprintf( sText, "%04X", nZPAddr1 ); // sZPAddr = WordToHexStr( nZPAddr1 );
} }
else else
if (!sSymbol2.empty() && sSymbol2[0] == '$') if (!sSymbol2.empty() && sSymbol2[0] == '$')
{ {
// sprintf( sText, "%s%s", sSymbol2 ); // sText = pSymbol2;
// sprintf( sText, "%04X", nZPAddr2 ); // sZPAddr = WordToHexStr( nZPAddr2 );
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_ADDRESS )); DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_ADDRESS ));
} }
else else
{ {
int nMin = MIN( sSymbol1.length(), nMaxSymbolLen ); size_t nMin = MIN( sSymbol1.length(), size_t(nMaxSymbolLen) );
memcpy(sText, sSymbol1.c_str(), nMin); sText.assign(sSymbol1.c_str(), nMin);
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_SYMBOL ) ); DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_SYMBOL ) );
} }
// DrawRegister( line+iZP, szZP, 2, nTarget16); // DrawRegister( line+iZP, szZP, 2, nTarget16);
// PrintText( szZP, rect2 ); // PrintText( szZP, rect2 );
PrintText( sText, rect2); if (sText.length() < nMaxSymbolLen)
sText.resize(nMaxSymbolLen, CHAR_SPACE);
PrintText( sText.c_str(), rect2);
rect2.left = rect.left; rect2.left = rect.left;
rect2.top += g_nFontHeight; rect2.top += g_nFontHeight;
rect2.bottom += g_nFontHeight; rect2.bottom += g_nFontHeight;
sprintf( sText, "%02X", nZPAddr1 );
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_ADDRESS )); DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_ADDRESS ));
PrintTextCursorX( sText, rect2 ); PrintTextCursorX( ByteToHexStr( nZPAddr1 ).c_str(), rect2 );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR ));
PrintTextCursorX( ":", rect2 ); PrintTextCursorX( ":", rect2 );
WORD nTarget16 = (WORD)mem[ nZPAddr1 ] | ((WORD)mem[ nZPAddr2 ]<< 8); WORD nTarget16 = (WORD)mem[ nZPAddr1 ] | ((WORD)mem[ nZPAddr2 ]<< 8);
sprintf( sText, "%04X", nTarget16 );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_ADDRESS )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_ADDRESS ));
PrintTextCursorX( sText, rect2 ); PrintTextCursorX( WordToHexStr( nTarget16 ).c_str(), rect2 );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPERATOR ));
PrintTextCursorX( ":", rect2 ); PrintTextCursorX( ":", rect2 );
BYTE nValue8 = (unsigned)*(LPBYTE)(mem + nTarget16); BYTE nValue8 = (unsigned)*(LPBYTE)(mem + nTarget16);
sprintf(sText, "%02X", nValue8 );
DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE )); DebuggerSetColorFG( DebuggerGetColor( FG_INFO_OPCODE ));
PrintTextCursorX( sText, rect2 ); PrintTextCursorX( ByteToHexStr( nValue8 ).c_str(), rect2 );
} }
rect.top += (g_nFontHeight * 2); rect.top += (g_nFontHeight * 2);
rect.bottom += (g_nFontHeight * 2); rect.bottom += (g_nFontHeight * 2);
@ -3061,16 +3004,12 @@ void DrawSubWindow_Data (Update_t bUpdate)
int iBackground; int iBackground;
const int nMaxOpcodes = WINDOW_DATA_BYTES_PER_LINE; const int nMaxOpcodes = WINDOW_DATA_BYTES_PER_LINE;
char sAddress[ 5 ];
_ASSERT( CONSOLE_WIDTH > WINDOW_DATA_BYTES_PER_LINE ); _ASSERT( CONSOLE_WIDTH > (WINDOW_DATA_BYTES_PER_LINE * 3));
char sOpcodes [ CONSOLE_WIDTH ] = ""; const int nDefaultFontWidth = 7; // g_aFontConfig[FONT_DISASM_DEFAULT]._nFontWidth or g_nFontWidthAvg
char sImmediate[ 4 ]; // 'c' const int X_OPCODE = 6 * nDefaultFontWidth;
const int X_CHAR = (6 + (nMaxOpcodes*3)) * nDefaultFontWidth;
const int nDefaultFontWidth = 7; // g_aFontConfig[FONT_DISASM_DEFAULT]._nFontWidth or g_nFontWidthAvg
int X_OPCODE = 6 * nDefaultFontWidth;
int X_CHAR = (6 + (nMaxOpcodes*3)) * nDefaultFontWidth;
int iMemDump = 0; int iMemDump = 0;
@ -3083,8 +3022,8 @@ void DrawSubWindow_Data (Update_t bUpdate)
// int iWindows = g_iThisWindow; // int iWindows = g_iThisWindow;
// WindowSplit_t * pWindow = &g_aWindowConfig[ iWindow ]; // WindowSplit_t * pWindow = &g_aWindowConfig[ iWindow ];
RECT rect; RECT rect = { 0 };
rect.top = 0 + 0; rect.top = 0;
WORD iAddress = nAddress; WORD iAddress = nAddress;
@ -3095,15 +3034,15 @@ void DrawSubWindow_Data (Update_t bUpdate)
iAddress = nAddress; iAddress = nAddress;
// Format // Format
sprintf( sAddress, "%04X", iAddress ); std::string sAddress = WordToHexStr( iAddress );
sOpcodes[0] = 0; std::string sOpcodes;
for ( int iByte = 0; iByte < nMaxOpcodes; iByte++ ) const BYTE* mp = mem + iAddress;
for ( int iByte = 0; iByte < nMaxOpcodes; ++iByte, ++mp )
{ {
BYTE nData = (unsigned)*(LPBYTE)(mem + iAddress + iByte); StrAppendByteAsHex(sOpcodes, *mp);
sprintf( &sOpcodes[ iByte * 3 ], "%02X ", nData ); sOpcodes += ' ';
} }
sOpcodes[ nMaxOpcodes * 3 ] = 0;
int nFontHeight = g_aFontConfig[ FONT_DISASM_DEFAULT ]._nLineHeight; int nFontHeight = g_aFontConfig[ FONT_DISASM_DEFAULT ]._nLineHeight;
@ -3112,18 +3051,12 @@ void DrawSubWindow_Data (Update_t bUpdate)
rect.right = DISPLAY_DISASM_RIGHT; rect.right = DISPLAY_DISASM_RIGHT;
rect.bottom = rect.top + nFontHeight; rect.bottom = rect.top + nFontHeight;
if (iLine & 1) iBackground = !!(iLine & 1) ? BG_DATA_1 : BG_DATA_2;
{
iBackground = BG_DATA_1;
}
else
{
iBackground = BG_DATA_2;
}
DebuggerSetColorBG( DebuggerGetColor( iBackground ) ); DebuggerSetColorBG( DebuggerGetColor( iBackground ) );
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_ADDRESS ) ); DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_ADDRESS ) );
PrintTextCursorX( (LPCTSTR) sAddress, rect ); PrintTextCursorX( sAddress.c_str(), rect);
DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_OPERATOR ) ); DebuggerSetColorFG( DebuggerGetColor( FG_DISASM_OPERATOR ) );
if (g_bConfigDisasmAddressColon) if (g_bConfigDisasmAddressColon)
@ -3132,7 +3065,7 @@ void DrawSubWindow_Data (Update_t bUpdate)
rect.left = X_OPCODE; rect.left = X_OPCODE;
DebuggerSetColorFG( DebuggerGetColor( FG_DATA_BYTE ) ); DebuggerSetColorFG( DebuggerGetColor( FG_DATA_BYTE ) );
PrintTextCursorX( (LPCTSTR) sOpcodes, rect ); PrintTextCursorX( sOpcodes.c_str(), rect);
rect.left = X_CHAR; rect.left = X_CHAR;
@ -3158,8 +3091,8 @@ void DrawSubWindow_Data (Update_t bUpdate)
iTextBackground = BG_INFO_IO_BYTE; iTextBackground = BG_INFO_IO_BYTE;
} }
*/ */
ColorizeSpecialChar( sImmediate, (BYTE) nImmediate, eView, iBackground ); std::string sImmediate = ColorizeSpecialChar( nImmediate, eView, iBackground );
PrintTextCursorX( (LPCSTR) sImmediate, rect ); PrintTextCursorX( sImmediate.c_str(), rect);
iAddress++; iAddress++;
} }
@ -3174,8 +3107,8 @@ void DrawSubWindow_Data (Update_t bUpdate)
if ((iAddress >= _6502_IO_BEGIN) && (iAddress <= _6502_IO_END)) if ((iAddress >= _6502_IO_BEGIN) && (iAddress <= _6502_IO_END))
iTextBackground = BG_INFO_IO_BYTE; iTextBackground = BG_INFO_IO_BYTE;
ColorizeSpecialChar( hDC, sImmediate, (BYTE) nImmediate, MEM_VIEW_APPLE, iBackground ); std::string sImmediate = ColorizeSpecialChar( nImmediate, MEM_VIEW_APPLE, iBackground );
PrintTextCursorX( (LPCSTR) sImmediate, rect ); PrintTextCursorX( sImmediate.c_str(), rect );
iAddress++; iAddress++;
} }
@ -3422,7 +3355,7 @@ void DrawSubWindow_Source2 (Update_t bUpdate)
if (g_aWindowConfig[ g_iWindowThis ].bSplit) // HACK: Split Window Height is odd, so bottom window gets +1 height if (g_aWindowConfig[ g_iWindowThis ].bSplit) // HACK: Split Window Height is odd, so bottom window gets +1 height
nHeight++; nHeight++;
RECT rect; RECT rect = { 0 };
rect.top = (y * g_nFontHeight); rect.top = (y * g_nFontHeight);
rect.bottom = rect.top + (nHeight * g_nFontHeight); rect.bottom = rect.top + (nHeight * g_nFontHeight);
rect.left = 0; rect.left = 0;