New debugger font on by default now

Color console support
(still have a bug with MA1 xxxx, if xxxx has 0x60)
Main Message loop is more 'game' like for debugger cursor timing
This commit is contained in:
mpohoreski 2006-07-05 21:23:13 +00:00
parent 3714f6b392
commit e362633013
12 changed files with 1286 additions and 672 deletions

View File

@ -323,7 +323,12 @@ void EnterMessageLoop ()
{
MSG message;
while (GetMessage(&message,0,0,0))
PeekMessage( &message, NULL, 0, 0, PM_NOREMOVE);
while (message.message!=WM_QUIT)
{
// while (GetMessage(&message,0,0,0))
if (PeekMessage( &message, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&message);
DispatchMessage(&message);
@ -348,9 +353,17 @@ void EnterMessageLoop ()
}
}
}
else
{
if (g_nAppMode == MODE_DEBUG)
{
DebuggerUpdate();
}
}
}
while (PeekMessage(&message,0,0,0,PM_REMOVE))
; // intentional null statement
// while (PeekMessage(&message,0,0,0,PM_REMOVE))
// ; // intentional null statement
}
//===========================================================================

View File

@ -53,7 +53,7 @@ enum AppMode_e
#define MAXIMAGES 16
// TODO: Move to StringTable.h
#define TITLE_APPLE_2 TEXT("Apple ][ Emulator")
#define TITLE_APPLE_2_ORG TEXT("Apple ][ Emulator")
#define TITLE_APPLE_2_PLUS TEXT("Apple ][+ Emulator")
#define TITLE_APPLE_2_E TEXT("Apple //e Emulator")
// #define TITLE TITLE_APPLE_2_E

View File

@ -37,14 +37,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// #define DEBUG_COMMAND_HELP 1
// #define DEBUG_ASM_HASH 1
#define ALLOW_INPUT_LOWERCASE 1
#define CONSOLE_FULL_WIDTH 0
// TODO: COLOR RESET
// TODO: COLOR SAVE ["filename"]
// TODO: COLOR LOAD ["filename"]
// See Debugger_Changelong.txt for full details
const int DEBUGGER_VERSION = MAKE_VERSION(2,5,6,42);
const int DEBUGGER_VERSION = MAKE_VERSION(2,5,7,1);
// Public _________________________________________________________________________________________
@ -513,7 +512,25 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
COLORREF DebuggerGetColor ( int iColor );
// Cursor _____________________________________________________________________
// Cursor (Console Input) _____________________________________________________
// char g_aInputCursor[] = "\|/-";
enum InputCursor
{
CURSOR_INSERT,
CURSOR_OVERSTRIKE,
NUM_INPUT_CURSORS
};
const char g_aInputCursor[] = "_\x7F"; // insert over-write
bool g_bInputCursor = false;
int g_iInputCursor = CURSOR_OVERSTRIKE; // which cursor to use
const int g_nInputCursor = sizeof( g_aInputCursor );
void DebuggerCursorUpdate();
char DebuggerCursorGet();
// Cursor (Disasm) ____________________________________________________________
WORD g_nDisasmTopAddress = 0;
WORD g_nDisasmBotAddress = 0;
@ -521,7 +538,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
bool g_bDisasmCurBad = false;
int g_nDisasmCurLine = 0; // Aligned to Top or Center
int g_iDisasmCurState = CURSOR_NORMAL;
int g_iDisasmCurState = CURSOR_NORMAL;
int g_nDisasmWinHeight = 0;
@ -545,12 +562,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
int g_nFontHeight = 15; // 13 -> 12 Lucida Console is readable
#endif
const int MIN_DISPLAY_CONSOLE_LINES = 4; // doesn't include ConsoleInput
const int MIN_DISPLAY_CONSOLE_LINES = 5; // doesn't include ConsoleInput
int g_nTotalLines = 0; // DISPLAY_HEIGHT / g_nFontHeight;
int MAX_DISPLAY_DISASM_LINES = 0; // g_nTotalLines - MIN_DISPLAY_CONSOLE_LINES; // 19;
int MAX_DISPLAY_CONSOLE_LINES = 0; // MAX_DISPLAY_DISASM_LINES + MIN_DISPLAY_CONSOLE_LINES; // 23
int g_nDisasmDisplayLines = 0;
// Config _____________________________________________________________________
@ -823,7 +837,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
static Update_t ExecuteCommand ( int nArgs );
// Breakpoints
void _ListBreakWatchZero( Breakpoint_t * aBreakWatchZero, int iBWZ, bool bZeroBased = true );
void _BWZ_List( const Breakpoint_t * aBreakWatchZero, const int iBWZ ); // bool bZeroBased = true );
void _BWZ_ListAll( const Breakpoint_t * aBreakWatchZero, const int nMax );
// bool CheckBreakpoint (WORD address, BOOL memory);
bool CheckBreakpointsIO ();
@ -1240,15 +1255,7 @@ Update_t CmdBookmarkList (int nArgs)
}
else
{
int iBookmark = 0;
while (iBookmark < MAX_BOOKMARKS)
{
if (g_aBookmarks[ iBookmark ].bSet)
{
_ListBreakWatchZero( g_aBookmarks, iBookmark, false );
}
iBookmark++;
}
_BWZ_ListAll( g_aBookmarks, MAX_BOOKMARKS );
}
return ConsoleUpdate();
}
@ -2055,35 +2062,33 @@ Update_t CmdBreakpointAddMem (int nArgs)
//===========================================================================
void _BreakWatchZero_Clear( Breakpoint_t * aBreakWatchZero, int iSlot )
void _BWZ_Clear( Breakpoint_t * aBreakWatchZero, int iSlot )
{
aBreakWatchZero[ iSlot ].bSet = false;
aBreakWatchZero[ iSlot ].bEnabled = false;
aBreakWatchZero[ iSlot ].nLength = 0;
}
void _BreakWatchZero_RemoveOne( Breakpoint_t *aBreakWatchZero, const int iSlot, int & nTotal )
void _BWZ_RemoveOne( Breakpoint_t *aBreakWatchZero, const int iSlot, int & nTotal )
{
if (aBreakWatchZero[iSlot].bSet)
{
_BreakWatchZero_Clear( aBreakWatchZero, iSlot );
_BWZ_Clear( aBreakWatchZero, iSlot );
nTotal--;
}
}
void _BreakWatchZero_RemoveAll( Breakpoint_t *aBreakWatchZero, const int nMax, int & nTotal )
void _BWZ_RemoveAll( Breakpoint_t *aBreakWatchZero, const int nMax, int & nTotal )
{
int iSlot = nMax;
while (iSlot--)
for( int iSlot = 0; iSlot < nMax; iSlot++ )
{
_BreakWatchZero_RemoveOne( aBreakWatchZero, iSlot, nTotal );
_BWZ_RemoveOne( aBreakWatchZero, iSlot, nTotal );
}
}
// called by BreakpointsClear, WatchesClear, ZeroPagePointersClear
//===========================================================================
void _ClearViaArgs( int nArgs, Breakpoint_t * aBreakWatchZero, const int nMax, int & nTotal )
void _BWZ_ClearViaArgs( int nArgs, Breakpoint_t * aBreakWatchZero, const int nMax, int & nTotal )
{
int iSlot = 0;
@ -2094,13 +2099,13 @@ void _ClearViaArgs( int nArgs, Breakpoint_t * aBreakWatchZero, const int nMax, i
if (! _tcscmp(g_aArgs[nArgs].sArg, g_aParameters[ PARAM_WILDSTAR ].m_sName))
{
_BreakWatchZero_RemoveAll( aBreakWatchZero, nMax, nTotal );
_BWZ_RemoveAll( aBreakWatchZero, nMax, nTotal );
break;
}
else
if ((iSlot >= 1) && (iSlot <= nMax))
if ((iSlot >= 0) && (iSlot < nMax))
{
_BreakWatchZero_RemoveOne( aBreakWatchZero, iSlot - 1, nTotal );
_BWZ_RemoveOne( aBreakWatchZero, iSlot, nTotal );
}
nArgs--;
@ -2109,7 +2114,7 @@ void _ClearViaArgs( int nArgs, Breakpoint_t * aBreakWatchZero, const int nMax, i
// called by BreakpointsEnable, WatchesEnable, ZeroPagePointersEnable
// called by BreakpointsDisable, WatchesDisable, ZeroPagePointersDisable
void _EnableDisableViaArgs( int nArgs, Breakpoint_t * aBreakWatchZero, const int nMax, const bool bEnabled )
void _BWZ_EnableDisableViaArgs( int nArgs, Breakpoint_t * aBreakWatchZero, const int nMax, const bool bEnabled )
{
int iSlot = 0;
@ -2120,17 +2125,15 @@ void _EnableDisableViaArgs( int nArgs, Breakpoint_t * aBreakWatchZero, const int
if (! _tcscmp(g_aArgs[nArgs].sArg, g_aParameters[ PARAM_WILDSTAR ].m_sName))
{
iSlot = nMax;
while (iSlot--)
for( ; iSlot < nMax; iSlot++ )
{
aBreakWatchZero[ iSlot ].bEnabled = bEnabled;
}
break;
}
else
if ((iSlot >= 1) && (iSlot <= nMax))
if ((iSlot >= 0) && (iSlot < nMax))
{
aBreakWatchZero[iSlot-1].bEnabled = bEnabled;
aBreakWatchZero[ iSlot ].bEnabled = bEnabled;
}
nArgs--;
@ -2145,11 +2148,11 @@ Update_t CmdBreakpointClear (int nArgs)
if (!nArgs)
{
_BreakWatchZero_RemoveAll( g_aBreakpoints, MAX_BREAKPOINTS, g_nBreakpoints );
_BWZ_RemoveAll( g_aBreakpoints, MAX_BREAKPOINTS, g_nBreakpoints );
}
else
{
_ClearViaArgs( nArgs, g_aBreakpoints, MAX_BREAKPOINTS, g_nBreakpoints );
_BWZ_ClearViaArgs( nArgs, g_aBreakpoints, MAX_BREAKPOINTS, g_nBreakpoints );
}
return UPDATE_DISASM | UPDATE_BREAKPOINTS | UPDATE_CONSOLE_DISPLAY;
@ -2164,7 +2167,7 @@ Update_t CmdBreakpointDisable (int nArgs)
if (! nArgs)
return Help_Arg_1( CMD_BREAKPOINT_DISABLE );
_EnableDisableViaArgs( nArgs, g_aBreakpoints, MAX_BREAKPOINTS, false );
_BWZ_EnableDisableViaArgs( nArgs, g_aBreakpoints, MAX_BREAKPOINTS, false );
return UPDATE_BREAKPOINTS;
}
@ -2185,13 +2188,13 @@ Update_t CmdBreakpointEnable (int nArgs) {
if (! nArgs)
return Help_Arg_1( CMD_BREAKPOINT_ENABLE );
_EnableDisableViaArgs( nArgs, g_aBreakpoints, MAX_BREAKPOINTS, true );
_BWZ_EnableDisableViaArgs( nArgs, g_aBreakpoints, MAX_BREAKPOINTS, true );
return UPDATE_BREAKPOINTS;
}
void _ListBreakWatchZero( Breakpoint_t * aBreakWatchZero, int iBWZ, bool bZeroBased )
void _BWZ_List( const Breakpoint_t * aBreakWatchZero, const int iBWZ ) //, bool bZeroBased )
{
static TCHAR sText[ CONSOLE_WIDTH ];
static const TCHAR sFlags[] = "-*";
@ -2206,7 +2209,8 @@ void _ListBreakWatchZero( Breakpoint_t * aBreakWatchZero, int iBWZ, bool bZeroBa
}
wsprintf( sText, " #%d %c %04X %s",
(bZeroBased ? iBWZ + 1 : iBWZ),
// (bZeroBased ? iBWZ + 1 : iBWZ),
iBWZ,
sFlags[ (int) aBreakWatchZero[ iBWZ ].bEnabled ],
aBreakWatchZero[ iBWZ ].nAddress,
pSymbol
@ -2214,6 +2218,18 @@ void _ListBreakWatchZero( Breakpoint_t * aBreakWatchZero, int iBWZ, bool bZeroBa
ConsoleBufferPush( sText );
}
void _BWZ_ListAll( const Breakpoint_t * aBreakWatchZero, const int nMax )
{
int iBWZ = 0;
while (iBWZ < MAX_BOOKMARKS)
{
if (aBreakWatchZero[ iBWZ ].bSet)
{
_BWZ_List( aBreakWatchZero, iBWZ );
}
iBWZ++;
}
}
//===========================================================================
Update_t CmdBreakpointList (int nArgs)
@ -2239,15 +2255,7 @@ Update_t CmdBreakpointList (int nArgs)
}
else
{
int iBreakpoint = 0;
while (iBreakpoint < MAX_BREAKPOINTS)
{
if (g_aBreakpoints[ iBreakpoint ].bSet)
{
_ListBreakWatchZero( g_aBreakpoints, iBreakpoint );
}
iBreakpoint++;
}
_BWZ_ListAll( g_aBreakpoints, MAX_BREAKPOINTS );
}
return ConsoleUpdate();
}
@ -3179,7 +3187,7 @@ Update_t CmdConfigFont (int nArgs)
{
TCHAR sText[ CONSOLE_WIDTH ];
wsprintf( sText, "Lines: %d Font Px: %d Line Px: %d"
, g_nTotalLines
, g_nDisasmDisplayLines
, g_aFontConfig[ FONT_DISASM_DEFAULT ]._nFontHeight
, g_aFontConfig[ FONT_DISASM_DEFAULT ]._nLineHeight );
ConsoleBufferPush( sText );
@ -3228,46 +3236,33 @@ void _UpdateWindowFontHeights( int nFontHeight )
{
if (nFontHeight)
{
// The screen layout defaults to a "virtal" font height of 16 pixels.
// The disassmebler has 19 lines.
// Total: 19 * 16 pixels
//
// Figure out how many lines we can display, given our new font height.
// Given: Total_Pixels = Lines * Pixels_Line
// Calc: Lines = Total_Pixels / Pixels_Line
int nConsoleTopY = 19 * 16;
int nConsoleTopY = GetConsoleTopPixels( g_nConsoleDisplayLines );
int nHeight = 0;
if (g_iFontSpacing == FONT_SPACING_CLASSIC)
{
nHeight = nFontHeight + 1;
g_nTotalLines = nConsoleTopY / nHeight;
g_nDisasmDisplayLines = nConsoleTopY / nHeight;
}
else
if (g_iFontSpacing == FONT_SPACING_CLEAN)
{
nHeight = nFontHeight;
g_nTotalLines = nConsoleTopY / nHeight;
g_nDisasmDisplayLines = nConsoleTopY / nHeight;
}
else
if (g_iFontSpacing == FONT_SPACING_COMPRESSED)
{
nHeight = nFontHeight - 1;
g_nTotalLines = (nConsoleTopY + nHeight) / nHeight; // Ceil()
g_nDisasmDisplayLines = (nConsoleTopY + nHeight) / nHeight; // Ceil()
}
g_aFontConfig[ FONT_DISASM_DEFAULT ]._nLineHeight = nHeight;
// int nHeightOptimal = (nHeight0 + nHeight1) / 2;
// int nLinesOptimal = nConsoleTopY / nHeightOptimal;
// g_nTotalLines = nLinesOptimal;
MAX_DISPLAY_DISASM_LINES = g_nTotalLines;
// TODO/FIXME: Needs to take into account the console height
MAX_DISPLAY_CONSOLE_LINES = MAX_DISPLAY_DISASM_LINES + MIN_DISPLAY_CONSOLE_LINES; // 23
// if (MAX_DISPLAY_CONSOLE_LINES > 23)
// MAX_DISPLAY_CONSOLE_LINES = 23;
// g_nDisasmDisplayLines = nLinesOptimal;
WindowUpdateSizes();
}
@ -3821,9 +3816,9 @@ Update_t CmdCursorLineUp (int nArgs)
aTopCandidates.reserve( MAX_LOOK_AHEAD );
aTopCandidates.erase( aTopCandidates.begin(), aTopCandidates.end() );
int nTop = g_nDisasmTopAddress;
int iTop = 0;
int nCur = 0;
WORD nTop = g_nDisasmTopAddress;
WORD iTop = 0;
WORD nCur = 0;
do
{
@ -3831,6 +3826,7 @@ Update_t CmdCursorLineUp (int nArgs)
nCur = nTop;
iTop = (g_nDisasmTopAddress - nTop);
for (int iLine = 0; iLine < MAX_LOOK_AHEAD; iLine++ )
{
iOpcode = _6502_GetOpmodeOpbytes( nCur, iOpmode, nOpbytes );
@ -6657,7 +6653,7 @@ Update_t CmdWatchAdd (int nArgs)
if (iWatch == NO_6502_TARGET)
{
iWatch = 0;
while ((iWatch < MAX_ZEROPAGE_POINTERS) && (g_aZeroPagePointers[iWatch].bSet))
while ((iWatch < MAX_ZEROPAGE_POINTERS) && (g_aWatches[iWatch].bSet))
{
iWatch++;
}
@ -6700,7 +6696,7 @@ Update_t CmdWatchClear (int nArgs)
if (!nArgs)
return Help_Arg_1( CMD_WATCH_CLEAR );
_ClearViaArgs( nArgs, g_aWatches, MAX_WATCHES, g_nWatches );
_BWZ_ClearViaArgs( nArgs, g_aWatches, MAX_WATCHES, g_nWatches );
// if (! g_nWatches)
// {
@ -6720,7 +6716,7 @@ Update_t CmdWatchDisable (int nArgs)
if (!nArgs)
return Help_Arg_1( CMD_WATCH_DISABLE );
_EnableDisableViaArgs( nArgs, g_aWatches, MAX_WATCHES, false );
_BWZ_EnableDisableViaArgs( nArgs, g_aWatches, MAX_WATCHES, false );
return UPDATE_WATCH;
}
@ -6734,7 +6730,7 @@ Update_t CmdWatchEnable (int nArgs)
if (!nArgs)
return Help_Arg_1( CMD_WATCH_ENABLE );
_EnableDisableViaArgs( nArgs, g_aWatches, MAX_WATCHES, true );
_BWZ_EnableDisableViaArgs( nArgs, g_aWatches, MAX_WATCHES, true );
return UPDATE_WATCH;
}
@ -6750,15 +6746,7 @@ Update_t CmdWatchList (int nArgs)
}
else
{
int iWatch = 0;
while (iWatch < MAX_WATCHES)
{
if (g_aWatches[ iWatch ].bSet)
{
_ListBreakWatchZero( g_aWatches, iWatch, true );
}
iWatch++;
}
_BWZ_List( g_aWatches, MAX_WATCHES );
}
return ConsoleUpdate();
}
@ -6847,19 +6835,19 @@ Update_t _CmdWindowViewFull ( int iNewWindow )
//===========================================================================
void WindowUpdateConsoleDisplayedSize()
{
g_nConsoleDisplayHeight = MIN_DISPLAY_CONSOLE_LINES;
#if CONSOLE_FULL_WIDTH
g_nConsoleDisplayLines = MIN_DISPLAY_CONSOLE_LINES;
#if USE_APPLE_FONT
g_bConsoleFullWidth = true;
g_nConsoleDisplayWidth = CONSOLE_WIDTH - 1;
if (g_iWindowThis == WINDOW_CONSOLE)
{
g_nConsoleDisplayHeight = MAX_DISPLAY_CONSOLE_LINES;
g_nConsoleDisplayLines = MAX_DISPLAY_LINES;
g_nConsoleDisplayWidth = CONSOLE_WIDTH - 1;
g_bConsoleFullWidth = true;
}
#else
g_nConsoleDisplayWidth = (CONSOLE_WIDTH / 2) + 8;
g_nConsoleDisplayWidth = (CONSOLE_WIDTH / 2) + 10;
g_bConsoleFullWidth = false;
// g_bConsoleFullWidth = false;
@ -6867,7 +6855,7 @@ void WindowUpdateConsoleDisplayedSize()
if (g_iWindowThis == WINDOW_CONSOLE)
{
g_nConsoleDisplayHeight = MAX_DISPLAY_CONSOLE_LINES;
g_nConsoleDisplayLines = MAX_DISPLAY_LINES;
g_nConsoleDisplayWidth = CONSOLE_WIDTH - 1;
g_bConsoleFullWidth = true;
}
@ -6886,11 +6874,11 @@ void WindowUpdateDisasmSize()
{
if (g_aWindowConfig[ g_iWindowThis ].bSplit)
{
g_nDisasmWinHeight = (MAX_DISPLAY_DISASM_LINES) / 2;
g_nDisasmWinHeight = (MAX_DISPLAY_LINES - g_nConsoleDisplayLines) / 2;
}
else
{
g_nDisasmWinHeight = MAX_DISPLAY_DISASM_LINES;
g_nDisasmWinHeight = MAX_DISPLAY_LINES - g_nConsoleDisplayLines;
}
g_nDisasmCurLine = MAX(0, (g_nDisasmWinHeight - 1) / 2);
#if _DEBUG
@ -7232,7 +7220,7 @@ Update_t CmdZeroPageClear (int nArgs)
if (!nArgs)
return Help_Arg_1( CMD_ZEROPAGE_POINTER_CLEAR );
_ClearViaArgs( nArgs, g_aZeroPagePointers, MAX_ZEROPAGE_POINTERS, g_nZeroPagePointers );
_BWZ_ClearViaArgs( nArgs, g_aZeroPagePointers, MAX_ZEROPAGE_POINTERS, g_nZeroPagePointers );
if (! g_nZeroPagePointers)
{
@ -7251,7 +7239,7 @@ Update_t CmdZeroPageDisable (int nArgs)
if (! g_nZeroPagePointers)
return ConsoleDisplayError(TEXT("There are no (ZP) pointers defined."));
_EnableDisableViaArgs( nArgs, g_aZeroPagePointers, MAX_ZEROPAGE_POINTERS, false );
_BWZ_EnableDisableViaArgs( nArgs, g_aZeroPagePointers, MAX_ZEROPAGE_POINTERS, false );
return UPDATE_ZERO_PAGE;
}
@ -7265,7 +7253,7 @@ Update_t CmdZeroPageEnable (int nArgs)
if (!nArgs)
return Help_Arg_1( CMD_ZEROPAGE_POINTER_ENABLE );
_EnableDisableViaArgs( nArgs, g_aZeroPagePointers, MAX_ZEROPAGE_POINTERS, true );
_BWZ_EnableDisableViaArgs( nArgs, g_aZeroPagePointers, MAX_ZEROPAGE_POINTERS, true );
return UPDATE_ZERO_PAGE;
}
@ -7281,15 +7269,7 @@ Update_t CmdZeroPageList (int nArgs)
}
else
{
int iZP = 0;
while (iZP < MAX_ZEROPAGE_POINTERS)
{
if (g_aZeroPagePointers[ iZP ].bEnabled)
{
_ListBreakWatchZero( g_aZeroPagePointers, iZP );
}
iZP++;
}
_BWZ_ListAll( g_aZeroPagePointers, MAX_ZEROPAGE_POINTERS );
}
return ConsoleUpdate();
}
@ -7686,8 +7666,8 @@ bool InternalSingleStep ()
void OutputTraceLine ()
{
// HACK: MAGIC #: 50 -> 64 chars for disassembly
TCHAR sDisassembly[ 64 ] ; DrawDisassemblyLine((HDC)0,0,regs.pc, sDisassembly); // Get Disasm String
TCHAR sFlags[ _6502_NUM_FLAGS+1]; DrawFlags( (HDC)0, 0, regs.ps, sFlags); // Get Flags String
TCHAR sDisassembly[ 64 ] ; DrawDisassemblyLine( 0,regs.pc, sDisassembly); // Get Disasm String
TCHAR sFlags[ _6502_NUM_FLAGS+1]; DrawFlags( 0, regs.ps, sFlags ); // Get Flags String
_ftprintf(g_hTraceFile,
TEXT("a=%02x x=%02x y=%02x sp=%03x ps=%s %s\n"),
@ -8182,7 +8162,7 @@ void DebugDestroy ()
_CmdSymbolsClear( (Symbols_e) iTable );
}
SelectObject( g_hDstDC, GetStockObject(NULL_BRUSH) );
SelectObject( g_hFrameDC, GetStockObject(NULL_BRUSH) );
DeleteObject( g_hConsoleBrushFG );
DeleteObject( g_hConsoleBrushBG );
@ -8190,7 +8170,7 @@ void DebugDestroy ()
DeleteDC( g_hConsoleFontDC );
DeleteObject( g_hConsoleFontBitmap );
ReleaseDC( g_hFrameWindow, g_hDstDC );
// ReleaseDC( g_hFrameWindow, g_hFrameDC );
}
@ -8303,19 +8283,19 @@ void DebugInitialize ()
DWORD nError = 0;
#endif
g_hDstDC = GetDC( g_hFrameWindow );
// g_hDstDC = g_hFrameDC; //GetDC( g_hFrameWindow );
#if _DEBUG
nError = GetLastError();
#endif
// Must select a bitmap into the temp DC !
HDC hTmpDC = CreateCompatibleDC( g_hDstDC );
HDC hTmpDC = CreateCompatibleDC( g_hFrameDC );
#if _DEBUG
nError = GetLastError();
#endif
g_hConsoleFontDC = CreateCompatibleDC( g_hDstDC );
g_hConsoleFontDC = CreateCompatibleDC( g_hFrameDC );
#if _DEBUG
nError = GetLastError();
#endif
@ -8371,7 +8351,7 @@ void DebugInitialize ()
DeleteObject( hTmpDC );
#endif
DeleteDC( g_hDstDC ); g_hDstDC = NULL;
// DeleteDC( g_hFrameDC ); g_hDstDC = NULL;
ZeroMemory( g_aConsoleDisplay, sizeof( g_aConsoleDisplay ) ); // CONSOLE_WIDTH * CONSOLE_HEIGHT );
ConsoleInputReset();
@ -8426,12 +8406,13 @@ void DebugInitialize ()
_CmdConfigFont( FONT_DISASM_DEFAULT, g_sFontNameDisasm , FIXED_PITCH | FF_MODERN , g_nFontHeight ); // OEM_CHARSET
_CmdConfigFont( FONT_DISASM_BRANCH , g_sFontNameBranch , DEFAULT_PITCH | FF_DECORATIVE, g_nFontHeight+3); // DEFAULT_CHARSET
//#endif
// _UpdateWindowFontHeights( nFontHeight );
int iColor;
iColor = FG_CONSOLE_OUTPUT;
COLORREF nColor = gaColorPalette[ g_aColorIndex[ iColor ] ];
g_anConsoleColor[ CONSOLE_COLOR_PREV ] = nColor;
g_anConsoleColor[ CONSOLE_COLOR_x ] = nColor;
/*
g_hFontDebugger = CreateFont(
@ -8467,6 +8448,7 @@ void DebugInitialize ()
, g_sFontNameBranch );
*/
// if (g_hFontWebDings)
#if !USE_APPLE_FONT
if (g_aFontConfig[ FONT_DISASM_BRANCH ]._hFont)
{
g_iConfigDisasmBranchType = DISASM_BRANCH_FANCY;
@ -8475,7 +8457,7 @@ void DebugInitialize ()
{
g_iConfigDisasmBranchType = DISASM_BRANCH_PLAIN;
}
#endif
// ConsoleInputReset(); already called in DebugInitialize()
TCHAR sText[ CONSOLE_WIDTH ];
@ -8542,6 +8524,12 @@ void DebuggerInputConsoleChar( TCHAR ch )
return;
}
if (ch == CONSOLE_COLOR_ESCAPE_CHAR)
return;
if (g_nConsoleInputSkip == ch)
return;
if (ch == CHAR_SPACE)
{
// If don't have console input, don't pass space to the input line
@ -8553,12 +8541,6 @@ void DebuggerInputConsoleChar( TCHAR ch )
if (g_nConsoleInputChars > (g_nConsoleDisplayWidth-1))
return;
if (g_bConsoleInputSkip)
{
g_bConsoleInputSkip = false;
return;
}
if ((ch >= CHAR_SPACE) && (ch <= 126)) // HACK MAGIC # 32 -> ' ', # 126
{
if ((ch == TCHAR_QUOTE_DOUBLE) || (ch == TCHAR_QUOTE_SINGLE))
@ -8574,8 +8556,10 @@ void DebuggerInputConsoleChar( TCHAR ch )
}
ConsoleInputChar( ch );
HDC dc = FrameGetDC();
DrawConsoleInput( dc );
DebuggerCursorNext();
FrameGetDC();
DrawConsoleInput();
FrameReleaseDC();
}
else
@ -8675,7 +8659,7 @@ Update_t DebuggerProcessCommand( const bool bEchoConsoleInput )
}
}
ConsoleInputReset();
bUpdateDisplay |= UPDATE_CONSOLE_DISPLAY;
bUpdateDisplay |= UPDATE_CONSOLE_DISPLAY | UPDATE_CONSOLE_INPUT;
ConsoleUpdate(); // udpate console, don't pause
}
else
@ -8728,7 +8712,7 @@ void DebuggerProcessKey( int keycode )
{
if ((VK_SPACE == keycode) || (VK_RETURN == keycode) || (VK_TAB == keycode) || (VK_ESCAPE == keycode))
{
int nLines = MIN( g_nConsoleBuffer, g_nConsoleDisplayHeight - 1 ); // was -2
int nLines = MIN( g_nConsoleBuffer, g_nConsoleDisplayLines - 1 ); // was -2
if (VK_ESCAPE == keycode) // user doesn't want to read all this stu
{
nLines = g_nConsoleBuffer;
@ -8739,23 +8723,24 @@ void DebuggerProcessKey( int keycode )
keycode = 0; // don't single-step
}
bUpdateDisplay |= UPDATE_CONSOLE_DISPLAY;
bUpdateDisplay |= UPDATE_CONSOLE_DISPLAY | UPDATE_CONSOLE_INPUT;
ConsoleDisplayPause();
}
else
// If have console input, don't invoke cursor movement
// If have console input, don't invoke curmovement
// TODO: Probably should disable all "movement" keys to map them to line editing g_nAppMode
if ((keycode == VK_SPACE) && g_nConsoleInputChars)
return;
else if (keycode == VK_ESCAPE)
{
g_bConsoleInputQuoted = false;
ConsoleInputClear();
ConsoleInputReset();
bUpdateDisplay |= UPDATE_CONSOLE_INPUT;
}
else if (keycode == VK_BACK)
{
// Note: Checks prev char if QUTOE - SINGLE or DOUBLE
// ConsoleUpdateCursor( CHAR_SPACE );
if (! ConsoleInputBackSpace())
{
// CmdBeep();
@ -8764,22 +8749,32 @@ void DebuggerProcessKey( int keycode )
}
else if (keycode == VK_RETURN)
{
// ConsoleUpdateCursor( 0 );
ConsoleScrollEnd();
bUpdateDisplay |= DebuggerProcessCommand( true ); // copy console input to console output
bUpdateDisplay |= UPDATE_CONSOLE_DISPLAY;
}
else if (keycode == VK_OEM_3) // Tilde ~
{
// Switch to Console Window
if (g_iWindowThis != WINDOW_CONSOLE)
if (KeybGetCtrlStatus())
{
CmdWindowViewConsole( 0 );
// Switch to Console Window
if (g_iWindowThis != WINDOW_CONSOLE)
{
CmdWindowViewConsole( 0 );
}
else // switch back to last window
{
CmdWindowLast( 0 );
}
bUpdateDisplay |= UPDATE_ALL;
}
else // switch back to last window
else
{
CmdWindowLast( 0 );
g_nConsoleInputSkip = 0; // VK_OEM_3; // don't pass to DebugProcessChar()
DebuggerInputConsoleChar( '~' );
}
bUpdateDisplay |= UPDATE_ALL;
g_bConsoleInputSkip = true; // don't pass to DebugProcessChar()
g_nConsoleInputSkip = '~'; // VK_OEM_3; // don't pass to DebugProcessChar()
}
else
{
@ -9063,3 +9058,99 @@ void DebugDisplay( BOOL bDrawBackground )
UpdateDisplay( bUpdateFlags );
}
//===========================================================================
void DebuggerUpdate()
{
DebuggerCursorUpdate();
}
//===========================================================================
void DebuggerCursorUpdate()
{
if (g_nAppMode != MODE_DEBUG)
return;
const nUpdatesPerSecond = 4;
const DWORD nHz = 1000 / nUpdatesPerSecond;
static DWORD nBeg = GetTickCount(); // timeGetTime();
DWORD nNow = GetTickCount(); // timeGetTime();
if (((nNow - nBeg)) >= nHz)
{
nBeg = nNow;
DebuggerCursorNext();
FrameGetDC();
DrawConsoleCursor();
FrameReleaseDC();
}
}
//===========================================================================
void DebuggerCursorNext()
{
g_bInputCursor ^= true;
if (g_bInputCursor)
{
ConsoleUpdateCursor( g_aInputCursor[ g_iInputCursor ] );
}
else
ConsoleUpdateCursor( 0 ); // show char under cursor
}
//===========================================================================
//char DebuggerCursorGet()
//{
// return g_aInputCursor[ g_iInputCursor ];
//}
//===========================================================================
void DebuggerMouseClick( int x, int y )
{
int nFontWidth = g_aFontConfig[ FONT_DISASM_DEFAULT ]._nFontWidthAvg;
int nFontHeight = g_aFontConfig[ FONT_DISASM_DEFAULT ]._nLineHeight ;
// do picking
FrameGetDC();
int cx = (x - VIEWPORTX) / nFontWidth;
int cy = (y - VIEWPORTY) / nFontHeight;
#if _DEBUG
char sText[ CONSOLE_WIDTH ];
sprintf( sText, "x:%d y:%d cx:%d cy:%d", x, y, cx, cy );
ConsoleDisplayPush( sText );
DebugDisplay( UPDATE_CONSOLE_DISPLAY );
#endif
if (g_iWindowThis == WINDOW_CODE)
{
// Display_AssemblyLine -- need Tabs
if (cx == 4)
{
g_bConfigDisasmAddressColon ^= true;
DebugDisplay( UPDATE_DISASM );
}
else
if ((cx > 4) & (cx <= 13))
{
g_bConfigDisasmOpcodesView ^= true;
DebugDisplay( UPDATE_DISASM );
}
else
if ((cx >= 51) && (cx <= 60) && (cy == 3))
{
CmdCursorJumpPC( CURSOR_ALIGN_CENTER );
DebugDisplay( UPDATE_DISASM );
}
}
FrameReleaseDC();
}

View File

@ -68,6 +68,9 @@ using namespace std;
// Config - Info
extern bool g_bConfigInfoTargetPointer ;
// Disassembly
extern int g_aDisasmTargets[ MAX_DISPLAY_LINES ];
// Display
extern bool g_bDebuggerViewingAppleOutput;
@ -164,3 +167,9 @@ using namespace std;
void DebuggerInputConsoleChar( TCHAR ch );
// void DebugProcessCommand (int);
void DebuggerProcessKey( int keycode );
void DebuggerUpdate();
void DebuggerCursorNext();
void DebuggerMouseClick( int x, int y );

View File

@ -49,34 +49,39 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// Buffer
bool g_bConsoleBufferPaused = false; // buffered output is waiting for user to continue
int g_nConsoleBuffer = 0;
TCHAR g_aConsoleBuffer[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH ]; // TODO: stl::vector< line_t >
conchar_t g_aConsoleBuffer[ CONSOLE_BUFFER_HEIGHT ][ CONSOLE_WIDTH*2 ]; // TODO: stl::vector< line_t >
// Display
TCHAR g_aConsolePrompt[] = TEXT(">!"); // input, assembler // NUM_PROMPTS
TCHAR g_sConsolePrompt[] = TEXT(">"); // No, NOT Integer Basic! The nostalgic '*' "Monitor" doesn't look as good, IMHO. :-(
conchar_t g_aConsolePrompt[] = TEXT(">!"); // input, assembler // NUM_PROMPTS
conchar_t g_sConsolePrompt[] = TEXT(">"); // No, NOT Integer Basic! The nostalgic '*' "Monitor" doesn't look as good, IMHO. :-(
int g_nConsolePromptLen = 1;
bool g_bConsoleFullWidth = true; // false
int g_iConsoleDisplayStart = 0; // to allow scrolling
int g_nConsoleDisplayTotal = 0; // number of lines added to console
int g_nConsoleDisplayHeight = 0;
int g_nConsoleDisplayLines = 0;
int g_nConsoleDisplayWidth = 0;
TCHAR g_aConsoleDisplay[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH ];
conchar_t g_aConsoleDisplay[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH*2 ];
// Input History
int g_nHistoryLinesStart = 0;
int g_nHistoryLinesTotal = 0; // number of commands entered
TCHAR g_aHistoryLines[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH ] = {TEXT("")};
TCHAR g_aHistoryLines[ HISTORY_HEIGHT ][ HISTORY_WIDTH ] = {TEXT("")};
// Input Line
conchar_t g_sConsoleCursor[] = "_";
// Raw input Line (has prompt)
TCHAR * const g_aConsoleInput = g_aConsoleDisplay[0];
conchar_t * const g_aConsoleInput = g_aConsoleDisplay[0];
// Cooked input line (no prompt)
int g_nConsoleInputChars = 0;
TCHAR * g_pConsoleInput = 0; // points to past prompt
const TCHAR * g_pConsoleFirstArg = 0; // points to first arg
conchar_t * g_pConsoleInput = 0; // points to past prompt
const conchar_t * g_pConsoleFirstArg = 0; // points to first arg
bool g_bConsoleInputQuoted = false; // Allows lower-case to be entered
bool g_bConsoleInputSkip = false;
char g_nConsoleInputSkip = '~';
// Prototypes _______________________________________________________________
@ -89,21 +94,64 @@ LPCSTR ConsoleBufferPeek()
}
//===========================================================================
bool ConsolePrint( const char * pText )
{
// TODO: Must convert color string to native console color text
const int nMaxWidth = (CONSOLE_WIDTH * 2) - 1; // g_nConsoleDisplayWidth;
int nLen = _tcslen( pText );
// push multiple lines
while ((nLen > 0) && (g_nConsoleBuffer < CONSOLE_BUFFER_HEIGHT))
{
_tcsncpy( g_aConsoleBuffer[ g_nConsoleBuffer ], pText, nMaxWidth );
pText += nMaxWidth;
g_nConsoleBuffer++;
nLen -= nMaxWidth;
}
return true;
}
// Add string to buffered output
// Shifts the buffered console output lines "Up"
//===========================================================================
bool ConsoleBufferPush( const TCHAR * pString ) // LPCSTR
{
if (g_nConsoleBuffer < CONSOLE_HEIGHT)
{
const int nMaxWidth = CONSOLE_WIDTH-1; // g_nConsoleDisplayWidth;
int nLen = _tcslen( pString );
int nLen = _tcslen( pString );
if (nLen <= nMaxWidth)
#if USE_APPLE_FONT
// TODO/FIXME: Must convert console over to CHAR16 type, since colored strings are of varying length
const int nMaxWidth = CONSOLE_WIDTH; // + (CONSOLE_WIDTH / 2); // g_nConsoleDisplayWidth;
#else
const int nMaxWidth = CONSOLE_WIDTH-1; // g_nConsoleDisplayWidth;
#endif
int x = 0;
while ((nLen > 0) && (g_nConsoleBuffer < CONSOLE_HEIGHT))
{
x = min( nLen, nMaxWidth );
_tcsncpy( g_aConsoleBuffer[ g_nConsoleBuffer ], pString, x );
nLen -= x;
conchar_t *pLine = & g_aConsoleBuffer[ g_nConsoleBuffer ][ x ];
/*
for ( ; x < nMaxWidth; x++ )
{
_tcscpy( g_aConsoleBuffer[ g_nConsoleBuffer ], pString );
g_nConsoleBuffer++;
return true;
*pLine++ = CHAR_SPACE;
}
*/
*pLine = 0;
g_nConsoleBuffer++;
}
return true;
// return true;
/*
}
else
{
@ -123,10 +171,10 @@ bool ConsoleBufferPush( const TCHAR * pString ) // LPCSTR
}
return true;
}
}
*/
// TODO: Warning: Too much output.
return false;
// return false;
}
// Shifts the buffered console output "down"
@ -168,14 +216,21 @@ void ConsoleDisplayPush( LPCSTR pText )
int nLen = MIN( g_nConsoleDisplayTotal, CONSOLE_HEIGHT - 1 - CONSOLE_FIRST_LINE);
while (nLen--)
{
_tcsncpy(
g_aConsoleDisplay[(nLen + 1 + CONSOLE_FIRST_LINE )],
g_aConsoleDisplay[nLen + CONSOLE_FIRST_LINE],
CONSOLE_WIDTH );
// _tcsncpy(
_tcscpy(
g_aConsoleDisplay[(nLen + 1 + CONSOLE_FIRST_LINE )]
, g_aConsoleDisplay[nLen + CONSOLE_FIRST_LINE]
);
// , CONSOLE_WIDTH );
}
if (pText)
_tcsncpy( g_aConsoleDisplay[ CONSOLE_FIRST_LINE ], pText, CONSOLE_WIDTH );
// _tcsncpy(
_tcscpy(
g_aConsoleDisplay[ CONSOLE_FIRST_LINE ]
, pText
);
// , CONSOLE_WIDTH );
g_nConsoleDisplayTotal++;
if (g_nConsoleDisplayTotal > (CONSOLE_HEIGHT - CONSOLE_FIRST_LINE))
@ -189,7 +244,9 @@ void ConsoleDisplayPause()
{
if (g_nConsoleBuffer)
{
_tcscpy( g_pConsoleInput, TEXT("...press SPACE continue, ESC skip..." ) );
strcpy( g_aConsoleInput, "...press SPACE continue, ESC skip..." );
g_nConsolePromptLen = strlen( g_pConsoleInput ) + 1;
g_nConsoleInputChars = 0;
g_bConsoleBufferPaused = true;
}
else
@ -203,24 +260,32 @@ bool ConsoleInputBackSpace()
{
if (g_nConsoleInputChars)
{
g_pConsoleInput[ g_nConsoleInputChars ] = CHAR_SPACE;
g_nConsoleInputChars--;
if ((g_pConsoleInput[ g_nConsoleInputChars ] == TCHAR_QUOTE_DOUBLE) ||
(g_pConsoleInput[ g_nConsoleInputChars ] == TCHAR_QUOTE_SINGLE))
g_bConsoleInputQuoted = ! g_bConsoleInputQuoted;
g_pConsoleInput[ g_nConsoleInputChars ] = 0;
g_pConsoleInput[ g_nConsoleInputChars ] = CHAR_SPACE;
return true;
}
return false;
}
// Clears prompt too
//===========================================================================
bool ConsoleInputClear()
{
ZeroMemory( g_aConsoleInput, CONSOLE_WIDTH );
// Note: Alternate console, with no NULL end of line terminator
// for( int x = 0; x < CONSOLE_WIDTH; x++ )
// g_aConsoleInput[ x ] = CHAR_SPACE;
if (g_nConsoleInputChars)
{
ZeroMemory( g_pConsoleInput, g_nConsoleDisplayWidth );
// ZeroMemory( g_pConsoleInput, g_nConsoleDisplayWidth );
g_nConsoleInputChars = 0;
return true;
}
@ -239,6 +304,23 @@ bool ConsoleInputChar( TCHAR ch )
return false;
}
//===========================================================================
void ConsoleUpdateCursor( char ch )
{
if (ch)
g_sConsoleCursor[0] = ch;
else
{
ch = g_aConsoleInput[ g_nConsoleInputChars + g_nConsolePromptLen ];
if (! ch)
{
ch = CHAR_SPACE;
}
g_sConsoleCursor[0] = ch;
}
}
//===========================================================================
LPCSTR ConsoleInputPeek()
{
@ -252,12 +334,16 @@ void ConsoleInputReset ()
// Even if we add console scrolling, we don't need any special logic to draw the input line.
g_bConsoleInputQuoted = false;
ZeroMemory( g_aConsoleInput, CONSOLE_WIDTH );
_tcscpy( g_aConsoleInput, g_sConsolePrompt ); // Assembler can change prompt
_tcscat( g_aConsoleInput, TEXT(" " ) );
ConsoleInputClear();
// _tcscpy( g_aConsoleInput, g_sConsolePrompt ); // Assembler can change prompt
g_aConsoleInput[0] = g_sConsolePrompt[0];
g_nConsolePromptLen = 1;
// _tcscat( g_aConsoleInput, TEXT(" " ) );
int nLen = _tcslen( g_aConsoleInput );
g_pConsoleInput = &g_aConsoleInput[nLen];
g_pConsoleInput = &g_aConsoleInput[ g_nConsolePromptLen ]; // nLen];
g_nConsoleInputChars = 0;
}
@ -312,7 +398,7 @@ Update_t ConsoleScrollDn ( int nLines )
//===========================================================================
Update_t ConsoleScrollPageUp ()
{
ConsoleScrollUp( g_nConsoleDisplayHeight - CONSOLE_FIRST_LINE );
ConsoleScrollUp( g_nConsoleDisplayLines - CONSOLE_FIRST_LINE );
return UPDATE_CONSOLE_DISPLAY;
}
@ -320,13 +406,13 @@ Update_t ConsoleScrollPageUp ()
//===========================================================================
Update_t ConsoleScrollPageDn()
{
ConsoleScrollDn( g_nConsoleDisplayHeight - CONSOLE_FIRST_LINE );
ConsoleScrollDn( g_nConsoleDisplayLines - CONSOLE_FIRST_LINE );
return UPDATE_CONSOLE_DISPLAY;
}
//===========================================================================
void ConsoleBufferTryUnpause (int nLines)
Update_t ConsoleBufferTryUnpause (int nLines)
{
for( int y = 0; y < nLines; y++ )
{
@ -338,7 +424,10 @@ void ConsoleBufferTryUnpause (int nLines)
{
g_bConsoleBufferPaused = true;
ConsoleDisplayPause();
return UPDATE_CONSOLE_INPUT | UPDATE_CONSOLE_DISPLAY;
}
return UPDATE_CONSOLE_DISPLAY;
}
//===========================================================================
@ -346,8 +435,8 @@ Update_t ConsoleUpdate()
{
if (! g_bConsoleBufferPaused)
{
int nLines = MIN( g_nConsoleBuffer, g_nConsoleDisplayHeight - 1);
ConsoleBufferTryUnpause( nLines );
int nLines = MIN( g_nConsoleBuffer, g_nConsoleDisplayLines - 1);
return ConsoleBufferTryUnpause( nLines );
}
return UPDATE_CONSOLE_DISPLAY;

View File

@ -8,31 +8,44 @@
CONSOLE_HEIGHT = 384, // Lines, was 128, but need ~ 256+16 for PROFILE LIST
CONSOLE_WIDTH = 80,
CONSOLE_BUFFER_HEIGHT = 128,
HISTORY_HEIGHT = 128,
HISTORY_WIDTH = 128,
CONSOLE_FIRST_LINE = 1, // where ConsoleDisplay is pushed up from
};
// Globals __________________________________________________________________
typedef TCHAR conchar_t;
// Buffer
extern bool g_bConsoleBufferPaused;// = false; // buffered output is waiting for user to continue
extern int g_nConsoleBuffer; //= 0;
extern TCHAR g_aConsoleBuffer[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH ]; // TODO: stl::vector< line_t >
extern TCHAR g_aConsoleBuffer[ CONSOLE_BUFFER_HEIGHT ][ CONSOLE_WIDTH*2 ]; // TODO: stl::vector< line_t >
// Cursor
extern char g_sConsoleCursor[];
// Display
extern TCHAR g_aConsolePrompt[];// = TEXT(">!"); // input, assembler // NUM_PROMPTS
extern TCHAR g_sConsolePrompt[];// = TEXT(">"); // No, NOT Integer Basic! The nostalgic '*' "Monitor" doesn't look as good, IMHO. :-(
extern int g_nConsolePromptLen;
extern bool g_bConsoleFullWidth;// = false;
extern int g_iConsoleDisplayStart ;// = 0; // to allow scrolling
extern int g_nConsoleDisplayTotal ;//= 0; // number of lines added to console
extern int g_nConsoleDisplayHeight ;//= 0;
extern int g_nConsoleDisplayWidth ;//= 0;
extern TCHAR g_aConsoleDisplay[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH ];
extern int g_iConsoleDisplayStart ; // to allow scrolling
extern int g_nConsoleDisplayTotal ; // number of lines added to console
extern int g_nConsoleDisplayLines ;
extern int g_nConsoleDisplayWidth ;
extern TCHAR g_aConsoleDisplay[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH*2 ];
// Input History
extern int g_nHistoryLinesStart;// = 0;
extern int g_nHistoryLinesTotal;// = 0; // number of commands entered
extern TCHAR g_aHistoryLines[ CONSOLE_HEIGHT ][ CONSOLE_WIDTH ];// = {TEXT("")};
extern TCHAR g_aHistoryLines[ HISTORY_HEIGHT ][ HISTORY_WIDTH ];// = {TEXT("")};
// Input Line
// Raw input Line (has prompt)
@ -43,7 +56,7 @@
extern TCHAR * g_pConsoleInput ;//= 0; // points to past prompt
extern const TCHAR * g_pConsoleFirstArg ;//= 0; // points to first arg
extern bool g_bConsoleInputQuoted ;//= false; // Allows lower-case to be entered
extern bool g_bConsoleInputSkip ;//= false;
extern char g_nConsoleInputSkip ;//= false;
// Prototypes _______________________________________________________________
@ -51,6 +64,7 @@
// Console
// Buffered
bool ConsolePrint( const char * pText );
void ConsoleBufferToDisplay ();
LPCSTR ConsoleBufferPeek ();
void ConsoleBufferPop ();
@ -71,7 +85,9 @@
void ConsoleInputReset ();
int ConsoleInputTabCompletion ();
void ConsoleBufferTryUnpause (int nLines);
void ConsoleUpdateCursor( char ch );
Update_t ConsoleBufferTryUnpause (int nLines);
// Scrolling
Update_t ConsoleScrollHome ();

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,11 @@
#ifndef DEBUGGER_DISPLAY_H
#define DEBUGGER_DISPLAY_H
// use the new Debugger Font (Apple Font)
#define USE_APPLE_FONT 1
// Test Colors & Glyphs
#define DEBUG_APPLE_FONT 0
// Re-route all debugger text to new font
#define USE_APPLE_FONT 0
// Win32 Debugger Font
// 1 = Use Debugger_Font_7x8.BMP
@ -40,7 +41,7 @@
#endif
};
extern HDC g_hDstDC ;
// extern HDC g_hDstDC ;
extern HBRUSH g_hConsoleBrushFG;
extern HBRUSH g_hConsoleBrushBG;
@ -51,7 +52,7 @@
enum ConsoleColors_e
{
CONSOLE_COLOR_K,
CONSOLE_COLOR_PREV = 0,
CONSOLE_COLOR_x = 0, // default console foreground
CONSOLE_COLOR_R,
CONSOLE_COLOR_G,
CONSOLE_COLOR_Y,
@ -62,11 +63,47 @@
MAX_CONSOLE_COLORS
};
extern COLORREF g_anConsoleColor[ MAX_CONSOLE_COLORS ];
extern char *g_asConsoleColor[ MAX_CONSOLE_COLORS ];
extern COLORREF g_anConsoleColor[ MAX_CONSOLE_COLORS ];
// extern const char *g_asConsoleColor[ MAX_CONSOLE_COLORS ];
// ` ~ should always display ~
// Note: THe ` ~ key should always display ~ to prevent rendering errors
#define CONSOLE_COLOR_ESCAPE_CHAR '`'
// Help Colors
/*
Types
Plain White
Header Yellow i.e. Usage
Operator Yellow
Command Green
Key Red
ArgMandatory Magenta < >
ArgOptional Blue [ ]
ArgSeperator White |
#define CON_COLOR_DEFAULT g_asConsoleColor[ CONSOLE_COLOR_x ]
#define CON_COLOR_DEFAULT "`0"
*/
#if USE_APPLE_FONT
#define CON_COLOR_DEFAULT "`0"
#define CON_COLOR_USAGE "`3"
#define CON_COLOR_PARAM "`2"
#define CON_COLOR_KEY "`1"
#define CON_COLOR_ARG_MAND "`5"
#define CON_COLOR_ARG_OPT "`4"
#define CON_COLOR_ARG_SEP "`3"
#define CON_COLOR_NUM "`2"
#else
#define CON_COLOR_DEFAULT ""
#define CON_COLOR_USAGE ""
#define CON_COLOR_PARAM ""
#define CON_COLOR_KEY ""
#define CON_COLOR_ARG_MAND ""
#define CON_COLOR_ARG_OPT ""
#define CON_COLOR_ARG_SEP ""
#endif
inline bool ConsoleColorIsEscapeMeta( char c )
{
if (CONSOLE_COLOR_ESCAPE_CHAR == c)
@ -98,7 +135,13 @@
#endif
}
extern const int DISPLAY_HEIGHT;
enum
{
DISPLAY_HEIGHT = 384,
MAX_DISPLAY_LINES = DISPLAY_HEIGHT / CONSOLE_FONT_HEIGHT,
};
int GetConsoleTopPixels( int y );
extern FontConfig_t g_aFontConfig[ NUM_FONTS ];
@ -114,16 +157,18 @@
void DrawWindow_Source (Update_t bUpdate);
void DrawBreakpoints (HDC dc, int line);
void DrawConsoleInput (HDC dc);
void DrawBreakpoints ( int line);
void DrawConsoleInput ();
void DrawConsoleLine (LPCSTR pText, int y);
WORD DrawDisassemblyLine (HDC dc, int line, WORD offset, LPTSTR text);
void DrawFlags (HDC dc, int line, WORD nRegFlags, LPTSTR pFlagNames_);
void DrawMemory (HDC dc, int line, int iMem );
void DrawRegister (HDC dc, int line, LPCTSTR name, int bytes, WORD value, int iSource = 0 );
void DrawStack (HDC dc, int line);
void DrawTargets (HDC dc, int line);
void DrawWatches (HDC dc, int line);
void DrawZeroPagePointers (HDC dc, int line);
void DrawConsoleCursor ();
WORD DrawDisassemblyLine ( int line, WORD offset, LPTSTR text);
void DrawFlags ( int line, WORD nRegFlags, LPTSTR pFlagNames_);
void DrawMemory ( int line, int iMem );
void DrawRegister ( int line, LPCTSTR name, int bytes, WORD value, int iSource = 0 );
void DrawStack ( int line);
void DrawTargets ( int line);
void DrawWatches ( int line);
void DrawZeroPagePointers ( int line);
#endif

View File

@ -86,7 +86,7 @@ bool TryStringCat ( TCHAR * pDst, LPCSTR pSrc, const int nDstSize )
// cats string as much as possible
// returns true if pSrc safely fits into pDst, else false (pSrc would of overflowed pDst)
//===========================================================================
bool StringCat ( TCHAR * pDst, LPCSTR pSrc, const int nDstSize )
int StringCat ( TCHAR * pDst, LPCSTR pSrc, const int nDstSize )
{
int nLenDst = _tcslen( pDst );
int nLenSrc = _tcslen( pSrc );
@ -97,9 +97,9 @@ bool StringCat ( TCHAR * pDst, LPCSTR pSrc, const int nDstSize )
bool bOverflow = (nSpcDst < nLenSrc);
if (bOverflow)
return false;
return 0;
return true;
return nChars;
}
@ -126,6 +126,70 @@ Update_t Help_Arg_1( int iCommandHelp )
}
//===========================================================================
void Help_Categories()
{
const int nBuf = CONSOLE_WIDTH * 2;
char sText[ nBuf ] = "";
int nLen = 0;
nLen += StringCat( sText, CON_COLOR_USAGE , nBuf );
nLen += StringCat( sText, "Usage", nBuf );
nLen += StringCat( sText, CON_COLOR_DEFAULT, nBuf );
nLen += StringCat( sText, ": " , nBuf );
nLen += StringCat( sText, CON_COLOR_ARG_OPT, nBuf );
nLen += StringCat( sText, "[ ", nBuf );
nLen += StringCat( sText, CON_COLOR_ARG_MAND, nBuf );
nLen += StringCat( sText, "< ", nBuf );
for (int iCategory = _PARAM_HELPCATEGORIES_BEGIN ; iCategory < _PARAM_HELPCATEGORIES_END; iCategory++)
{
TCHAR *pName = g_aParameters[ iCategory ].m_sName;
if (nLen + _tcslen( pName ) >= (CONSOLE_WIDTH - 4))
{
ConsolePrint( sText );
sText[ 0 ] = 0;
nLen = StringCat( sText, " ", nBuf );
}
StringCat( sText, CON_COLOR_PARAM, nBuf );
nLen += StringCat( sText, pName, nBuf );
if (iCategory < (_PARAM_HELPCATEGORIES_END - 1))
{
StringCat( sText, CON_COLOR_ARG_SEP, nBuf );
nLen += StringCat( sText, " | " , nBuf );
}
}
StringCat( sText, CON_COLOR_ARG_MAND, nBuf );
StringCat( sText, TEXT(" >"), nBuf);
StringCat( sText, CON_COLOR_ARG_OPT, nBuf );
StringCat( sText, TEXT(" ]"), nBuf);
// ConsoleBufferPush( sText );
ConsolePrint( sText ); // Transcode colored text to native console color text
wsprintf( sText, "%sNotes%s: %s<>%s = mandatory, %s[]%s = optional, %s|%s argument option"
, CON_COLOR_USAGE
, CON_COLOR_DEFAULT
, CON_COLOR_ARG_MAND
, CON_COLOR_DEFAULT
, CON_COLOR_ARG_OPT
, CON_COLOR_DEFAULT
, CON_COLOR_ARG_SEP
, CON_COLOR_DEFAULT
);
ConsolePrint( sText ); // Transcode colored text to native console color text
// ConsoleBufferPush( sText );
}
//===========================================================================
void Help_Range()
{
@ -137,33 +201,41 @@ void Help_Range()
//===========================================================================
void Help_Operators()
{
ConsoleBufferPush( TEXT(" Operators: (Math)" ) );
ConsoleBufferPush( TEXT(" + Addition" ) );
ConsoleBufferPush( TEXT(" - Subtraction" ) );
ConsoleBufferPush( TEXT(" * Multiplication" ) );
ConsoleBufferPush( TEXT(" / Division" ) );
ConsoleBufferPush( TEXT(" % Modulas or Remainder" ) );
ConsoleBufferPush( TEXT(" Operators: (Bit Wise)" ) );
ConsoleBufferPush( TEXT(" & Bit-wise and (AND)" ) );
ConsoleBufferPush( TEXT(" | Bit-wise or (OR )" ) );
ConsoleBufferPush( TEXT(" ^ Bit-wise exclusive-or (EOR/XOR)" ) );
ConsoleBufferPush( TEXT(" ! Bit-wise negation (NOT)" ) );
ConsoleBufferPush( TEXT(" Operators: (Input)" ) );
ConsoleBufferPush( TEXT(" @ next number refers to search results" ) );
ConsoleBufferPush( TEXT(" \" Designate string in ASCII format" ) );
ConsoleBufferPush( TEXT(" \' Desginate string in High-Bit apple format" ) );
ConsoleBufferPush( TEXT(" $ Designate number/symbol" ) );
ConsoleBufferPush( TEXT(" # Designate number in hex" ) );
ConsoleBufferPush( TEXT(" Operators: (Range)" ) );
ConsoleBufferPush( TEXT(" , range seperator (2nd address is relative)" ) );
ConsoleBufferPush( TEXT(" : range seperator (2nd address is absolute)" ) );
ConsoleBufferPush( TEXT(" Operators: (Misc)" ) );
ConsoleBufferPush( TEXT(" // comment until end of line" ) );
ConsoleBufferPush( TEXT(" Operators: (Breakpoint)" ) );
TCHAR sText[ CONSOLE_WIDTH ];
char sText[ CONSOLE_WIDTH ];
// sprintf( sText," %sOperators%s:" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
// sprintf( sText," Operators: (Math)" );
sprintf( sText," Operators: (%sMath%s)" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s+%s Addition" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s-%s Subtraction" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s*%s Multiplication" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s/%s Division" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s%%%s Modulas or Remainder" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
//ConsoleBufferPush( " Operators: (Bit Wise)" );
sprintf( sText," Operators: (%sBit Wise%s)" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s&%s Bit-wise and (AND)" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s|%s Bit-wise or (OR )" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s^%s Bit-wise exclusive-or (EOR/XOR)" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s!%s Bit-wise negation (NOT)" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
//ConsoleBufferPush( " Operators: (Input)" );
sprintf( sText," Operators: (%sInput%s)" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s@%s next number refers to search results", CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s\"%s Designate string in ASCII format" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s\'%s Desginate string in High-Bit apple format", CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s$%s Designate number/symbol" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s#%s Designate number in hex" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
//ConsoleBufferPush( " Operators: (Range)" );
sprintf( sText," Operators: (%sRange%s)" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s,%s range seperator (2nd address is relative)", CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s:%s range seperator (2nd address is absolute)", CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
// sprintf( sText," Operators: (Misc)" );
sprintf( sText," Operators: (%sMisc%s)" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
sprintf( sText," %s//%s comment until end of line" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
//ConsoleBufferPush( " Operators: (Breakpoint)" );
sprintf( sText," Operators: (%sBreakpoint%s)" , CON_COLOR_USAGE, CON_COLOR_DEFAULT ); ConsolePrint( sText );
_tcscpy( sText, " " );
_tcscat( sText, CON_COLOR_USAGE );
int iBreakOp = 0;
for( iBreakOp = 0; iBreakOp < NUM_BREAKPOINT_OPERATORS; iBreakOp++ )
{
@ -174,6 +246,7 @@ void Help_Operators()
_tcscat( sText, " " );
}
}
_tcscat( sText, CON_COLOR_DEFAULT );
ConsoleBufferPush( sText );
}
@ -202,10 +275,16 @@ Update_t CmdMOTD( int nArgs )
ConsoleBufferPush( TEXT(" Apple ][ ][+ //e Emulator for Windows") );
CmdVersion(0);
CmdSymbols(0);
wsprintf( sText, " '~' console, '%s' (specific), '%s' (all)"
wsprintf( sText, " '%sCtrl ~%s' console, '%s%s%s' (specific), '%s%s%s' (all)"
, CON_COLOR_KEY
, CON_COLOR_DEFAULT
, CON_COLOR_PARAM
, g_aCommands[ CMD_HELP_SPECIFIC ].m_sName
, CON_COLOR_DEFAULT
// , g_aCommands[ CMD_HELP_SPECIFIC ].pHelpSummary
, CON_COLOR_PARAM
, g_aCommands[ CMD_HELP_LIST ].m_sName
, CON_COLOR_DEFAULT
// , g_aCommands[ CMD_HELP_LIST ].pHelpSummary
);
ConsoleBufferPush( sText );
@ -221,41 +300,13 @@ Update_t CmdMOTD( int nArgs )
Update_t CmdHelpSpecific (int nArgs)
{
int iArg;
TCHAR sText[ CONSOLE_WIDTH ];
TCHAR sText[ CONSOLE_WIDTH * 2 ];
ZeroMemory( sText, CONSOLE_WIDTH );
if (! nArgs)
{
// ConsoleBufferPush( TEXT(" [] = optional, {} = mandatory. Categories are: ") );
_tcscpy( sText, TEXT("Usage: [< ") );
for (int iCategory = _PARAM_HELPCATEGORIES_BEGIN ; iCategory < _PARAM_HELPCATEGORIES_END; iCategory++)
{
#if _DEBUG
// if (iCategory == (PARAM_CAT_ZEROPAGE - 1))
// {
// int nLen = _tcslen( sText );
// bool bStop = true;
// }
#endif
TCHAR *pName = g_aParameters[ iCategory ].m_sName;
if (! TestStringCat( sText, pName, CONSOLE_WIDTH - 4 )) // CONSOLE_WIDTH // g_nConsoleDisplayWidth - 3
{
ConsoleBufferPush( sText );
_tcscpy( sText, TEXT(" ") );
}
StringCat( sText, pName, CONSOLE_WIDTH );
if (iCategory < (_PARAM_HELPCATEGORIES_END - 1))
{
StringCat( sText, TEXT(" | "), CONSOLE_WIDTH - 1 );
}
}
StringCat( sText, TEXT(" >]"), CONSOLE_WIDTH - 3 );
ConsoleBufferPush( sText );
wsprintf( sText, TEXT("Note: [] = optional, <> = mandatory"), CONSOLE_WIDTH );
ConsoleBufferPush( sText );
Help_Categories();
return ConsoleUpdate();
}
CmdFuncPtr_t pFunction = NULL;
@ -1068,12 +1119,12 @@ Update_t CmdVersion (int nArgs)
// wsprintf( sText, "Version" ); ConsoleBufferPush( sText );
wsprintf( sText, " Emulator: %s%s%s Debugger: %s%d.%d.%d.%d%s"
, g_asConsoleColor[ CONSOLE_COLOR_G ]
, CON_COLOR_NUM
, VERSIONSTRING
, g_asConsoleColor[ CONSOLE_COLOR_PREV ]
, g_asConsoleColor[ CONSOLE_COLOR_G ]
, CON_COLOR_DEFAULT
, CON_COLOR_NUM
, nMajor, nMinor, nFixMajor, nFixMinor
, g_asConsoleColor[ CONSOLE_COLOR_PREV ]
, CON_COLOR_DEFAULT
);
ConsoleBufferPush( sText );

View File

@ -152,7 +152,7 @@
enum
{
MAX_BREAKPOINTS = 15
MAX_BREAKPOINTS = 16
};
/*
@ -1383,7 +1383,7 @@
enum
{
MAX_WATCHES = 8
MAX_WATCHES = 16
};

View File

@ -32,8 +32,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define ENABLE_MENU 0
#define VIEWPORTX 5
#define VIEWPORTY 5
#define VIEWPORTCX 560
#if ENABLE_MENU
#define VIEWPORTCY 400
@ -68,7 +66,7 @@ static int buttonover = -1;
static int buttonx = BUTTONX;
static int buttony = BUTTONY;
static HRGN clipregion = (HRGN)0;
static HDC g_hFrameDC = (HDC)0;
HDC g_hFrameDC = (HDC)0;
static RECT framerect = {0,0,0,0};
HWND g_hFrameWindow = (HWND)0;
BOOL fullscreen = 0;
@ -142,19 +140,21 @@ void DeleteGdiObjects () {
DeleteObject(smallfont);
}
// Draws an 3D box around the main apple screen
//===========================================================================
void Draw3dRect (HDC dc, int x1, int y1, int x2, int y2, BOOL out) {
SelectObject(dc,GetStockObject(NULL_BRUSH));
SelectObject(dc,out ? btnshadowpen : btnhighlightpen);
POINT pt[3];
pt[0].x = x1; pt[0].y = y2-1;
pt[1].x = x2-1; pt[1].y = y2-1;
pt[2].x = x2-1; pt[2].y = y1;
Polyline(dc,(LPPOINT)&pt,3);
SelectObject(dc,(out == 1) ? btnhighlightpen : btnshadowpen);
pt[1].x = x1; pt[1].y = y1;
pt[2].x = x2; pt[2].y = y1;
Polyline(dc,(LPPOINT)&pt,3);
void Draw3dRect (HDC dc, int x1, int y1, int x2, int y2, BOOL out)
{
SelectObject(dc,GetStockObject(NULL_BRUSH));
SelectObject(dc,out ? btnshadowpen : btnhighlightpen);
POINT pt[3];
pt[0].x = x1; pt[0].y = y2-1;
pt[1].x = x2-1; pt[1].y = y2-1;
pt[2].x = x2-1; pt[2].y = y1;
Polyline(dc,(LPPOINT)&pt,3);
SelectObject(dc,(out == 1) ? btnhighlightpen : btnshadowpen);
pt[1].x = x1; pt[1].y = y1;
pt[2].x = x2; pt[2].y = y1;
Polyline(dc,(LPPOINT)&pt,3);
}
//===========================================================================
@ -397,10 +397,10 @@ void DrawStatusArea (HDC passdc, int drawflags)
{
TCHAR title[40];
_tcscpy(title,g_bApple2e
? TITLE_APPLE_2
? TITLE_APPLE_2_E
: (g_bApple2plus
? TITLE_APPLE_2_PLUS
: TITLE_APPLE_2 ));
: TITLE_APPLE_2_ORG ));
switch (g_nAppMode)
{
@ -681,6 +681,7 @@ LRESULT CALLBACK FrameWndProc (
else if ((x < buttonx) && JoyUsingMouse() &&
((g_nAppMode == MODE_RUNNING) || (g_nAppMode == MODE_STEPPING)))
SetUsingCursor(1);
DebuggerMouseClick( x, y );
}
RelayEvent(WM_LBUTTONDOWN,wparam,lparam);
break;
@ -1187,7 +1188,7 @@ void FrameCreateWindow ()
if (g_bApple2plus)
g_pAppTitle = TITLE_APPLE_2_PLUS;
else
g_pAppTitle = TITLE_APPLE_2;
g_pAppTitle = TITLE_APPLE_2_ORG;
}
g_hFrameWindow = CreateWindow(

View File

@ -2,8 +2,13 @@
enum {NOT_ASCII=0, ASCII};
// 3D Border
#define VIEWPORTX 5
#define VIEWPORTY 5
// Win32
extern HWND g_hFrameWindow;
extern HDC g_hFrameDC;
extern BOOL fullscreen;