MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / DrawStack

Function DrawStack

source/Debugger/Debugger_Display.cpp:2983–3045  ·  view source on GitHub ↗

===========================================================================

Source from the content-addressed store, hash-verified

2981
2982//===========================================================================
2983void DrawStack ( int line)
2984{
2985 if (! ((g_iWindowThis == WINDOW_CODE) || ((g_iWindowThis == WINDOW_DATA))))
2986 return;
2987
2988 unsigned nStackAddress = regs.sp;
2989#if DEBUG_FORCE_DISPLAY // Stack
2990 nStackAddress = _6502_STACK_BEGIN;
2991#endif
2992
2993 int nFontWidth = g_aFontConfig[ FONT_INFO ]._nFontWidthAvg;
2994
2995 // 2.6.0.0 Alpha - Stack was dark cyan BG_DATA_1
2996 DebuggerSetColorBG( DebuggerGetColor( BG_DATA_1 )); // BG_INFO // recessed 3d look
2997
2998 // 2.9.4.3 Normally we would display a maximum of 8 lines ending when we hit the stack end $200 ...
2999 // [ S, min(S+8,$1FF) ], or
3000 // [ S, min(S+8,$200) )
3001 // ... but we need to handle two edge cases:
3002 // S = $1FE Display $1FF, $100 NonInclusiveEnd = $101
3003 // S = $1FF Display $100, $101 NonInclusiveEnd = $102
3004 // DrawStack()
3005 // DrawTargets()
3006/*
3007; Repro
3008 MD1 100
3009 MD2 1FC
3010 100:61 FA
3011 1FD:FD FE FF 00
3012 R PC FBFC
3013 R S FD ; FFFF sans overflow
3014 R S FE ; 6200 with overflow
3015 R S FF ; FA62 with overflow
3016*/
3017 const unsigned nHead = nStackAddress + MAX_DISPLAY_STACK_LINES;
3018 const unsigned nTail = _6502_STACK_END + 1;
3019 const unsigned nEndAddr = (nStackAddress >= (_6502_STACK_END - 1))
3020 ? ((nStackAddress & 1) + 1) | _6502_STACK_BEGIN
3021 : min( nHead, nTail );
3022
3023 int iStack = 0;
3024 while (iStack < MAX_DISPLAY_STACK_LINES)
3025 {
3026 nStackAddress++;
3027 if (nStackAddress == nEndAddr)
3028 break;
3029 nStackAddress &= _6502_STACK_END;
3030 nStackAddress |= _6502_STACK_BEGIN;
3031
3032 RECT rect;
3033 rect.left = DISPLAY_STACK_COLUMN;
3034 rect.top = (iStack+line) * g_nFontHeight;
3035 rect.right = rect.left + (10 * nFontWidth) + 1;
3036 rect.bottom = rect.top + g_nFontHeight;
3037
3038 DebuggerSetColorFG( DebuggerGetColor( FG_INFO_TITLE )); // [COLOR_STATIC
3039 PrintTextCursorX( StrFormat( "%04X: ", nStackAddress ).c_str(), rect );
3040

Callers 1

DrawSubWindow_InfoFunction · 0.85

Calls 6

DebuggerSetColorBGFunction · 0.85
DebuggerGetColorFunction · 0.85
DebuggerSetColorFGFunction · 0.85
PrintTextCursorXFunction · 0.85
StrFormatFunction · 0.85
ReadByteFromMemoryFunction · 0.85

Tested by

no test coverage detected