Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
audetto committed Jan 5, 2022
2 parents c2a2553 + 545c79f commit d0601d1
Show file tree
Hide file tree
Showing 14 changed files with 481 additions and 110 deletions.
36 changes: 35 additions & 1 deletion docs/Debugger_Changelog.txt
@@ -1,5 +1,39 @@
/*

2.9.1.13 Added: CD now detects ".." to change to the previous directory and chops the trailing sub-directory from the current path.
It worked before but would clutter up the current directory with a trailing "..\".
2.9.1.12 Added: New commands HGR0, HGR3, HGR4, HGR5 to see pseudo pages $00, $60, $80, $A0 respectively.
2.9.1.11 Fixed: Right justify signed decimal values.
Example:
U 300
300:A9 80 A9 81 A9 FF A9 00 A9 01 A9 7E A9 7F
Will display as:
LDA #$80 #-128
LDA #$81 #-127
LDA #$FF #-1
LDA #$00
LDA #$01 #+1
LDA #$7E #+126
LDA #$7F #+127
2.9.1.10 Fixed: Immedate #80 was not showing -128 for the signed decimal value.
2.9.1.9 Fixed: Immediate #0 was showing '#' prefix but not showing zero for the signed decimal value. Changed to show the signed decimal value only if non zero.
2.9.1.8 Changed: Disassembly window now lists symbol labels and symbol target address from User2 in orange.
Example:
U 300
SYM @ = 303
300: 20 03 03
2.9.1.7 Added: Extended SYM command to auto-generate symbol names when reverse engineering. NOTE: These symbols will be placed in User2.
Example:
SYM @ = 800 // Alias for: SYM _0800 = 0800
2.9.1.6 Added: Branch instructions now show target address.
2.9.1.5 Added: Disassembly window now shows signed decimal values for immediate values.
2.9.1.4 Changed: Show symbol warnings in Orange, and length of symbols in light blue.
2.9.1.3 Added: DB commanoptionally supports =
DB HGR = 2000:3FFF
2.9.1.2 Fixed: Off by one end address when deleting DisasmData_t
2.9.1.1 Added: X command now supports a range and will chop off the appropiate data sections.
DB 2000:2005
X 2002:2003
Released post 1.30.7.0

2.9.1.0 Added: Bookmarks now have their own indicator (a number with a box around it) and replace the ":" seperator. Updated Debug_Font.bmp

Expand Down
104 changes: 97 additions & 7 deletions source/Debugger/Debug.cpp
Expand Up @@ -51,7 +51,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define ALLOW_INPUT_LOWERCASE 1

// See /docs/Debugger_Changelog.txt for full details
const int DEBUGGER_VERSION = MAKE_VERSION(2,9,1,0);
const int DEBUGGER_VERSION = MAKE_VERSION(2,9,1,13);


// Public _________________________________________________________________________________________
Expand Down Expand Up @@ -3745,7 +3745,10 @@ Update_t CmdConfigGetDebugDir (int nArgs)
return ConsoleUpdate();
}

// "CD"
// Usage:
// CD "<dir>"
// CD ".."
// Note: Subdirectory MUST be quoted with double quotes.
//===========================================================================
Update_t CmdConfigSetDebugDir (int nArgs)
{
Expand Down Expand Up @@ -3780,8 +3783,71 @@ Update_t CmdConfigSetDebugDir (int nArgs)
}
else // Relative
{
// TODO: Support ".." - currently just appends (which still works)
sPath = g_sCurrentDir + g_aArgs[1].sArg; // TODO: debugger dir has no ` CONSOLE_COLOR_ESCAPE_CHAR ?!?!
std::string SAME_DIR( "." ); SAME_DIR += PATH_SEPARATOR;
std::string UP_DIR ( ".."); UP_DIR += PATH_SEPARATOR;
std::string sNewPath( g_aArgs[1].sArg );

// if new path doesn't have a trailing slash, append one
if (*(sNewPath.rbegin()) != PATH_SEPARATOR)
sNewPath += PATH_SEPARATOR;

// Support ".." and various permutations
// cd "..\"
// cd "abc\..\def\"
//
// 1. find next slash in newpath
// 2. subdir = newpath.substr()
// 3. if subdir == "..\"
// reverse find slash in g_sCurrentDir
// g_sCurrentDir = g_sCurrentDir.substr()
// else
// g_sCurrentDir += subdir
size_t iPrevSeparator = 0;
size_t iPathSeparator = 0;

while ((iPathSeparator = sNewPath.find( PATH_SEPARATOR, iPrevSeparator )) != std::string::npos)
{
#if _DEBUG
char zDebug[128];
sprintf( zDebug, "Prev: %d\n", iPrevSeparator ); OutputDebugStringA( zDebug );
sprintf( zDebug, "Next: %d\n", iPathSeparator ); OutputDebugStringA( zDebug );
sprintf( zDebug, "%s\n", sNewPath.c_str() ); OutputDebugStringA( zDebug );
sprintf( zDebug, "%*s%s\n", iPathSeparator, "", "^"); OutputDebugStringA( zDebug );
#endif

std::string sSubDir = sNewPath.substr( iPrevSeparator, iPathSeparator - iPrevSeparator + 1 );
const size_t nSubDirLen = sSubDir.size();

if ((nSubDirLen == 2) && (sSubDir == SAME_DIR)) // Same directory ".\" in the subpath?
{
// Intentional: Nothing to do
}
else
if ((nSubDirLen == 3) && (sSubDir == UP_DIR)) // Up directory "..\" in the subpath?
{
size_t nCurrentLen = g_sCurrentDir.size();
size_t nLastSeperator = g_sCurrentDir.rfind( '\\', nCurrentLen - 2 );

if (nLastSeperator != std::string::npos)
{
#if _DEBUG
sprintf( zDebug, "Last: %d\n", nLastSeperator ); OutputDebugStringA( zDebug );
sprintf( zDebug, "%s\n", g_sCurrentDir.c_str() ); OutputDebugStringA( zDebug );
sprintf( zDebug, "%*s%s\n", nLastSeperator, "", "^"); OutputDebugStringA( zDebug );
#endif
std::string sCurrentDir = g_sCurrentDir.substr( 0, nLastSeperator + 1 ); // Path always has trailing slash so include it
g_sCurrentDir = sCurrentDir;
}
}
else
g_sCurrentDir += sSubDir;

iPathSeparator++; // start next search past path separator
iPrevSeparator = iPathSeparator;
}

// TODO: debugger dir has no ` CONSOLE_COLOR_ESCAPE_CHAR ?!?!
sPath = g_sCurrentDir;
}

if ( SetCurrentImageDir( sPath ) )
Expand Down Expand Up @@ -6470,8 +6536,12 @@ Update_t CmdCyclesReset(int /*nArgs*/)
enum ViewVideoPage_t
{
VIEW_PAGE_X, // current page
VIEW_PAGE_0, // Pseudo
VIEW_PAGE_1,
VIEW_PAGE_2
VIEW_PAGE_2,
VIEW_PAGE_3, // Pseudo
VIEW_PAGE_4, // Pseudo
VIEW_PAGE_5 // Pseudo
};

Update_t _ViewOutput( ViewVideoPage_t iPage, int bVideoModeFlags )
Expand All @@ -6482,8 +6552,12 @@ Update_t _ViewOutput( ViewVideoPage_t iPage, int bVideoModeFlags )
bVideoModeFlags |= !GetVideo().VideoGetSWPAGE2() ? 0 : VF_PAGE2;
bVideoModeFlags |= !GetVideo().VideoGetSWMIXED() ? 0 : VF_MIXED;
break; // Page Current & current MIXED state
case VIEW_PAGE_1: bVideoModeFlags |= 0; break; // Page 1
case VIEW_PAGE_2: bVideoModeFlags |= VF_PAGE2; break; // Page 2
case VIEW_PAGE_0: bVideoModeFlags |= VF_PAGE0; break; // Pseudo Page 0 ($0000)
case VIEW_PAGE_1: bVideoModeFlags |= 0 ; break; // Hardware Page 1 ($2000), NOTE: VF_HIRES will be passed in
case VIEW_PAGE_2: bVideoModeFlags |= VF_PAGE2; break; // Hardware Page 2 ($4000)
case VIEW_PAGE_3: bVideoModeFlags |= VF_PAGE3; break; // Pseudo Page 3 ($6000)
case VIEW_PAGE_4: bVideoModeFlags |= VF_PAGE4; break; // Pseudo Page 4 ($8000)
case VIEW_PAGE_5: bVideoModeFlags |= VF_PAGE5; break; // Pseudo Page 5 ($A000)
default:
_ASSERT(0);
break;
Expand Down Expand Up @@ -6551,6 +6625,10 @@ Update_t _ViewOutput( ViewVideoPage_t iPage, int bVideoModeFlags )
{
return _ViewOutput( VIEW_PAGE_X, VF_HIRES );
}
Update_t CmdViewOutput_HGR0 (int nArgs)
{
return _ViewOutput( VIEW_PAGE_0, VF_HIRES ); // Pseudo page ($0000)
}
Update_t CmdViewOutput_HGR1 (int nArgs)
{
return _ViewOutput( VIEW_PAGE_1, VF_HIRES );
Expand All @@ -6559,6 +6637,18 @@ Update_t _ViewOutput( ViewVideoPage_t iPage, int bVideoModeFlags )
{
return _ViewOutput( VIEW_PAGE_2, VF_HIRES );
}
Update_t CmdViewOutput_HGR3 (int nArgs)
{
return _ViewOutput( VIEW_PAGE_3, VF_HIRES ); // Pseudo page ($6000)
}
Update_t CmdViewOutput_HGR4 (int nArgs)
{
return _ViewOutput( VIEW_PAGE_4, VF_HIRES ); // Pseudo page ($8000)
}
Update_t CmdViewOutput_HGR5 (int nArgs)
{
return _ViewOutput( VIEW_PAGE_5, VF_HIRES ); // Pseudo page ($A000)
}
// Double Hi-Res
Update_t CmdViewOutput_DHGRX (int nArgs)
{
Expand Down
1 change: 1 addition & 0 deletions source/Debugger/Debugger_Color.cpp
Expand Up @@ -95,6 +95,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
G8, // FG_DISASM_SYMBOL
C8, // FG_DISASM_CHAR
G8, // FG_DISASM_BRANCH
COLOR_CUSTOM_01, // FG_DISASM_SINT8

C3, // BG_INFO (C4, C2 too dark)
C3, // BG_INFO_WATCH
Expand Down
1 change: 1 addition & 0 deletions source/Debugger/Debugger_Color.h
Expand Up @@ -89,6 +89,7 @@
/*ZZZ*/ , FG_DISASM_SYMBOL // Green HOME
, FG_DISASM_CHAR // Cyan 'c'
, FG_DISASM_BRANCH // Green ^ = v
, FG_DISASM_SINT8 // Lite Blue

, BG_INFO // Cyan Regs/Stack/BP/Watch/ZP
, BG_INFO_WATCH // Cyan
Expand Down
8 changes: 6 additions & 2 deletions source/Debugger/Debugger_Commands.cpp
Expand Up @@ -262,8 +262,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{TEXT("DGR1") , CmdViewOutput_DGR1 , CMD_VIEW_DGR1 , "View Double lo-res Page 1" },
{TEXT("DGR2") , CmdViewOutput_DGR2 , CMD_VIEW_DGR2 , "View Double lo-res Page 2" },
{TEXT("HGR") , CmdViewOutput_HGRX , CMD_VIEW_HGRX , "View Hi-res (current page)" },
{TEXT("HGR1") , CmdViewOutput_HGR1 , CMD_VIEW_HGR1 , "View Hi-res Page 1" },
{TEXT("HGR2") , CmdViewOutput_HGR2 , CMD_VIEW_HGR2 , "View Hi-res Page 2" },
{TEXT("HGR0") , CmdViewOutput_HGR0 , CMD_VIEW_HGR0 , "View pseudo Hi-res Page 0 ($0000)" },
{TEXT("HGR1") , CmdViewOutput_HGR1 , CMD_VIEW_HGR1 , "View Hi-res Page 1 ($2000)" },
{TEXT("HGR2") , CmdViewOutput_HGR2 , CMD_VIEW_HGR2 , "View Hi-res Page 2 ($4000)" },
{TEXT("HGR3") , CmdViewOutput_HGR3 , CMD_VIEW_HGR3 , "View pseudo Hi-res Page 3 ($6000)" },
{TEXT("HGR4") , CmdViewOutput_HGR4 , CMD_VIEW_HGR4 , "View pseudo Hi-res Page 4 ($8000)" },
{TEXT("HGR5") , CmdViewOutput_HGR5 , CMD_VIEW_HGR5 , "View pseudo Hi-res Page 5 ($A000)" },
{TEXT("DHGR") , CmdViewOutput_DHGRX , CMD_VIEW_DHGRX , "View Double Hi-res (current page)" },
{TEXT("DHGR1") , CmdViewOutput_DHGR1 , CMD_VIEW_DHGR1 , "View Double Hi-res Page 1" },
{TEXT("DHGR2") , CmdViewOutput_DHGR2 , CMD_VIEW_DHGR2 , "View Double Hi-res Page 2" },
Expand Down
4 changes: 2 additions & 2 deletions source/Debugger/Debugger_Console.h
Expand Up @@ -68,12 +68,12 @@
#define CHC_ARG_MAND "`7" // < >
#define CHC_ARG_OPT "`4" // [ ]
#define CHC_ARG_SEP "`9" // | grey
#define CHC_NUM_DEC "`6" // cyan looks better then yellow (_SearchMemoryDisplay), S D000:FFFF A9 00, PROFILE, HELP BP
#define CHC_NUM_DEC "`:" // Lite Blue looks better then yellow (_SearchMemoryDisplay), S D000:FFFF A9 00, PROFILE, HELP BP
#define CHC_NUM_HEX "`3"
#define CHC_SYMBOL "`2" // Symbols
#define CHC_ADDRESS "`8" // Hex Address
#define CHC_ERROR "`1" // Red
#define CHC_WARNING "`5" // Purple
#define CHC_WARNING "`8" // Orange
#define CHC_INFO "`3" // Yellow
#define CHC_STRING "`6" //
#define CHC_EXAMPLE "`:"
Expand Down
74 changes: 39 additions & 35 deletions source/Debugger/Debugger_Disassembler.cpp
Expand Up @@ -243,41 +243,39 @@ int GetDisassemblyLine(WORD nBaseAddress, DisasmLine_t& line_)
bDisasmFormatFlags |= DISASM_FORMAT_BRANCH;

if (nTarget < nBaseAddress)
{
sprintf(line_.sBranch, "%s", g_sConfigBranchIndicatorUp[g_iConfigDisasmBranchType]);
}
else
if (nTarget > nBaseAddress)
{
sprintf(line_.sBranch, "%s", g_sConfigBranchIndicatorDown[g_iConfigDisasmBranchType]);
}
else
{
sprintf(line_.sBranch, "%s", g_sConfigBranchIndicatorEqual[g_iConfigDisasmBranchType]);
}
if (nTarget > nBaseAddress)
sprintf(line_.sBranch, "%s", g_sConfigBranchIndicatorDown[g_iConfigDisasmBranchType]);
else
sprintf(line_.sBranch, "%s", g_sConfigBranchIndicatorEqual[g_iConfigDisasmBranchType]);

bDisasmFormatFlags |= DISASM_FORMAT_TARGET_POINTER;
if (g_iConfigDisasmTargets & DISASM_TARGET_ADDR)
sprintf(line_.sTargetPointer, "%04X", nTarget & 0xFFFF);
}
// intentional re-test AM_R ...

// if ((iOpmode >= AM_A) && (iOpmode <= AM_NA))
if ((iOpmode == AM_A) || // Absolute
(iOpmode == AM_Z) || // Zeropage
(iOpmode == AM_AX) || // Absolute, X
(iOpmode == AM_AY) || // Absolute, Y
(iOpmode == AM_ZX) || // Zeropage, X
(iOpmode == AM_ZY) || // Zeropage, Y
(iOpmode == AM_R) || // Relative
// if ((iOpmode >= AM_A ) && (iOpmode <= AM_NA))
if ((iOpmode == AM_A ) || // Absolute
(iOpmode == AM_Z ) || // Zeropage
(iOpmode == AM_AX ) || // Absolute, X
(iOpmode == AM_AY ) || // Absolute, Y
(iOpmode == AM_ZX ) || // Zeropage, X
(iOpmode == AM_ZY ) || // Zeropage, Y
(iOpmode == AM_R ) || // Relative
(iOpmode == AM_IZX) || // Indexed (Zeropage Indirect, X)
(iOpmode == AM_IAX) || // Indexed (Absolute Indirect, X)
(iOpmode == AM_NZY) || // Indirect (Zeropage) Index, Y
(iOpmode == AM_NZ) || // Indirect (Zeropage)
(iOpmode == AM_NA)) //(Indirect Absolute)
(iOpmode == AM_NZ ) || // Indirect (Zeropage)
(iOpmode == AM_NA )) //(Indirect Absolute)
{
line_.nTarget = nTarget;

const char* pTarget = NULL;
const char* pSymbol = 0;

pSymbol = FindSymbolFromAddress(nTarget);
pSymbol = FindSymbolFromAddress(nTarget, &line_.iTargetTable);

// Data Assembler
if (pData && (!pData->bSymbolLookup))
Expand All @@ -292,7 +290,7 @@ int GetDisassemblyLine(WORD nBaseAddress, DisasmLine_t& line_)

if (!(bDisasmFormatFlags & DISASM_FORMAT_SYMBOL))
{
pSymbol = FindSymbolFromAddress(nTarget - 1);
pSymbol = FindSymbolFromAddress(nTarget - 1, &line_.iTargetTable);
if (pSymbol)
{
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
Expand All @@ -314,7 +312,7 @@ int GetDisassemblyLine(WORD nBaseAddress, DisasmLine_t& line_)
// nSecondTarget = g_bDebugConfig_DisasmMatchSymbolOffsetMinus1First ? nTarget+1 : nTarget-1;
if (!(bDisasmFormatFlags & DISASM_FORMAT_SYMBOL) || pData)
{
pSymbol = FindSymbolFromAddress(nTarget + 1);
pSymbol = FindSymbolFromAddress(nTarget + 1,&line_.iTargetTable);
if (pSymbol)
{
bDisasmFormatFlags |= DISASM_FORMAT_SYMBOL;
Expand Down Expand Up @@ -390,22 +388,28 @@ int GetDisassemblyLine(WORD nBaseAddress, DisasmLine_t& line_)
if (iOpmode == AM_M)
{
// sprintf( sTarget, g_aOpmodes[ iOpmode ]._sFormat, (unsigned)nTarget );
sprintf(line_.sTarget, "%02X", (unsigned)nTarget);
sprintf(line_.sTarget , "%02X", (unsigned)nTarget);

if (iOpmode == AM_M)
{
bDisasmFormatFlags |= DISASM_FORMAT_CHAR;
line_.nImmediate = (BYTE)nTarget;
unsigned _char = FormatCharTxtCtrl(FormatCharTxtHigh(line_.nImmediate, NULL), NULL);
if (nTarget == 0)
line_.sImmediateSignedDec[0] = 0; // nothing
else
if (nTarget < 128)
sprintf(line_.sImmediateSignedDec, "+%d" , nTarget );
else
if (nTarget >= 128)
sprintf(line_.sImmediateSignedDec, "-%d" , (~nTarget + 1) & 0xFF );

sprintf(line_.sImmediate, "%c", _char);
bDisasmFormatFlags |= DISASM_FORMAT_CHAR;
line_.nImmediate = (BYTE)nTarget;
unsigned _char = FormatCharTxtCtrl(FormatCharTxtHigh(line_.nImmediate, NULL), NULL);

sprintf(line_.sImmediate, "%c", _char);
#if OLD_CONSOLE_COLOR
if (ConsoleColorIsEscapeMeta(_char))
sprintf(line_.sImmediate, "%c%c", _char, _char);
else
sprintf(line_.sImmediate, "%c", _char);
if (ConsoleColorIsEscapeMeta(_char))
sprintf(line_.sImmediate, "%c%c", _char, _char);
else
sprintf(line_.sImmediate, "%c", _char);
#endif
}
}
}

Expand Down

0 comments on commit d0601d1

Please sign in to comment.