Debugger - Fix #345: wrap and protect debugger's video mode
This commit is contained in:
parent
c146587b8e
commit
1bb60026a5
6 changed files with 91 additions and 25 deletions
|
@ -311,7 +311,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
bool g_bTraceHeader = false; // semaphore, flag header to be printed
|
bool g_bTraceHeader = false; // semaphore, flag header to be printed
|
||||||
|
|
||||||
DWORD extbench = 0;
|
DWORD extbench = 0;
|
||||||
int g_bDebuggerViewingAppleOutput = false; // NOTE: alias for bVideoModeFlags!
|
|
||||||
|
|
||||||
bool g_bIgnoreNextKey = false;
|
bool g_bIgnoreNextKey = false;
|
||||||
|
|
||||||
|
@ -380,6 +379,67 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
WORD DisasmCalcAddressFromLines( WORD iAddress, int nLines );
|
WORD DisasmCalcAddressFromLines( WORD iAddress, int nLines );
|
||||||
|
|
||||||
|
|
||||||
|
// DebugVideoMode _____________________________________________________________
|
||||||
|
|
||||||
|
// Fix for GH#345
|
||||||
|
// Wrap & protect the debugger's video mode in its own class:
|
||||||
|
// . This may seem like overkill but it stops the video mode being (erroneously) additionally used as a flag.
|
||||||
|
// . VideoMode is a bitmap of video flags and a VideoMode value of zero is a valid video mode (GR,PAGE1,non-mixed).
|
||||||
|
class DebugVideoMode // NB. Implemented as a singleton
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
DebugVideoMode()
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
~DebugVideoMode(){}
|
||||||
|
|
||||||
|
static DebugVideoMode& Instance()
|
||||||
|
{
|
||||||
|
return m_Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reset(void)
|
||||||
|
{
|
||||||
|
m_bIsVideoModeValid = false;
|
||||||
|
m_uVideoMode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsSet(void)
|
||||||
|
{
|
||||||
|
return m_bIsVideoModeValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Get(UINT* pVideoMode)
|
||||||
|
{
|
||||||
|
if (pVideoMode)
|
||||||
|
*pVideoMode = m_bIsVideoModeValid ? m_uVideoMode : 0;
|
||||||
|
return m_bIsVideoModeValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set(UINT videoMode)
|
||||||
|
{
|
||||||
|
m_bIsVideoModeValid = true;
|
||||||
|
m_uVideoMode = videoMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_bIsVideoModeValid;
|
||||||
|
UINT m_uVideoMode;
|
||||||
|
|
||||||
|
static DebugVideoMode m_Instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
DebugVideoMode DebugVideoMode::m_Instance;
|
||||||
|
|
||||||
|
bool DebugGetVideoMode(UINT* pVideoMode)
|
||||||
|
{
|
||||||
|
return DebugVideoMode::Instance().Get(pVideoMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// File _______________________________________________________________________
|
// File _______________________________________________________________________
|
||||||
|
|
||||||
int _GetFileSize( FILE *hFile )
|
int _GetFileSize( FILE *hFile )
|
||||||
|
@ -6728,11 +6788,8 @@ Update_t _ViewOutput( ViewVideoPage_t iPage, int bVideoModeFlags )
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if _DEBUG
|
|
||||||
if (bVideoModeFlags == 0)
|
DebugVideoMode::Instance().Set(bVideoModeFlags);
|
||||||
MessageBoxA( NULL, "bVideoModeFlags = ZERO !?", "Information", MB_OK );
|
|
||||||
#endif
|
|
||||||
g_bDebuggerViewingAppleOutput = bVideoModeFlags;
|
|
||||||
VideoRefreshScreen( bVideoModeFlags, true );
|
VideoRefreshScreen( bVideoModeFlags, true );
|
||||||
return UPDATE_NOTHING; // intentional
|
return UPDATE_NOTHING; // intentional
|
||||||
}
|
}
|
||||||
|
@ -6766,11 +6823,11 @@ Update_t _ViewOutput( ViewVideoPage_t iPage, int bVideoModeFlags )
|
||||||
// Lo-Res
|
// Lo-Res
|
||||||
Update_t CmdViewOutput_GRX (int nArgs)
|
Update_t CmdViewOutput_GRX (int nArgs)
|
||||||
{
|
{
|
||||||
return _ViewOutput( VIEW_PAGE_X, VF_80STORE ); // NTSC VideoRefresh() Hack: flags != 0
|
return _ViewOutput( VIEW_PAGE_X, 0 );
|
||||||
}
|
}
|
||||||
Update_t CmdViewOutput_GR1 (int nArgs)
|
Update_t CmdViewOutput_GR1 (int nArgs)
|
||||||
{
|
{
|
||||||
return _ViewOutput( VIEW_PAGE_1, VF_80STORE ); // NTSC VideoRefresh() Hack: flags != 0
|
return _ViewOutput( VIEW_PAGE_1, 0 );
|
||||||
}
|
}
|
||||||
Update_t CmdViewOutput_GR2 (int nArgs)
|
Update_t CmdViewOutput_GR2 (int nArgs)
|
||||||
{
|
{
|
||||||
|
@ -7286,7 +7343,8 @@ Update_t CmdWindowViewData (int nArgs)
|
||||||
Update_t CmdWindowViewOutput (int nArgs)
|
Update_t CmdWindowViewOutput (int nArgs)
|
||||||
{
|
{
|
||||||
VideoRedrawScreen();
|
VideoRedrawScreen();
|
||||||
g_bDebuggerViewingAppleOutput = true;
|
|
||||||
|
DebugVideoMode::Instance().Set(g_uVideoMode);
|
||||||
|
|
||||||
return UPDATE_NOTHING; // intentional
|
return UPDATE_NOTHING; // intentional
|
||||||
}
|
}
|
||||||
|
@ -8421,7 +8479,7 @@ void DebugBegin ()
|
||||||
g_nDisasmCurAddress = regs.pc;
|
g_nDisasmCurAddress = regs.pc;
|
||||||
DisasmCalcTopBotAddress();
|
DisasmCalcTopBotAddress();
|
||||||
|
|
||||||
g_bDebuggerViewingAppleOutput = false;
|
DebugVideoMode::Instance().Reset();
|
||||||
|
|
||||||
UpdateDisplay( UPDATE_ALL );
|
UpdateDisplay( UPDATE_ALL );
|
||||||
|
|
||||||
|
@ -9106,7 +9164,7 @@ void DebuggerProcessKey( int keycode )
|
||||||
if (g_nAppMode != MODE_DEBUG)
|
if (g_nAppMode != MODE_DEBUG)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_bDebuggerViewingAppleOutput)
|
if (DebugVideoMode::Instance().IsSet())
|
||||||
{
|
{
|
||||||
if ((VK_SHIFT == keycode) || (VK_CONTROL == keycode) || (VK_MENU == keycode))
|
if ((VK_SHIFT == keycode) || (VK_CONTROL == keycode) || (VK_MENU == keycode))
|
||||||
{
|
{
|
||||||
|
@ -9116,7 +9174,7 @@ void DebuggerProcessKey( int keycode )
|
||||||
// Normally any key press takes us out of "Viewing Apple Output" g_nAppMode
|
// Normally any key press takes us out of "Viewing Apple Output" g_nAppMode
|
||||||
// VK_F# are already processed, so we can't use them to cycle next video g_nAppMode
|
// VK_F# are already processed, so we can't use them to cycle next video g_nAppMode
|
||||||
// if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG))
|
// if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG))
|
||||||
g_bDebuggerViewingAppleOutput = false;
|
DebugVideoMode::Instance().Reset();
|
||||||
UpdateDisplay( UPDATE_ALL ); // 1
|
UpdateDisplay( UPDATE_ALL ); // 1
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -9475,7 +9533,7 @@ void DebuggerProcessKey( int keycode )
|
||||||
} // switch
|
} // switch
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bUpdateDisplay && !g_bDebuggerViewingAppleOutput) // & UPDATE_BACKGROUND)
|
if (bUpdateDisplay && !DebugVideoMode::Instance().IsSet()) // & UPDATE_BACKGROUND)
|
||||||
UpdateDisplay( bUpdateDisplay );
|
UpdateDisplay( bUpdateDisplay );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9509,7 +9567,7 @@ void DebuggerCursorUpdate()
|
||||||
static DWORD nBeg = GetTickCount(); // timeGetTime();
|
static DWORD nBeg = GetTickCount(); // timeGetTime();
|
||||||
DWORD nNow = GetTickCount(); // timeGetTime();
|
DWORD nNow = GetTickCount(); // timeGetTime();
|
||||||
|
|
||||||
if (((nNow - nBeg) >= nUpdateInternal_ms) && !g_bDebuggerViewingAppleOutput)
|
if (((nNow - nBeg) >= nUpdateInternal_ms) && !DebugVideoMode::Instance().IsSet())
|
||||||
{
|
{
|
||||||
nBeg = nNow;
|
nBeg = nNow;
|
||||||
|
|
||||||
|
|
|
@ -104,9 +104,6 @@
|
||||||
// Disassembly
|
// Disassembly
|
||||||
extern int g_aDisasmTargets[ MAX_DISPLAY_LINES ];
|
extern int g_aDisasmTargets[ MAX_DISPLAY_LINES ];
|
||||||
|
|
||||||
// Display
|
|
||||||
extern int g_bDebuggerViewingAppleOutput;
|
|
||||||
|
|
||||||
// Font
|
// Font
|
||||||
extern int g_nFontHeight;
|
extern int g_nFontHeight;
|
||||||
extern int g_iFontSpacing;
|
extern int g_iFontSpacing;
|
||||||
|
@ -238,6 +235,8 @@
|
||||||
DEBUG_TOGGLE_KEY = VK_F1 + BTN_DEBUG
|
DEBUG_TOGGLE_KEY = VK_F1 + BTN_DEBUG
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool DebugGetVideoMode(UINT* pVideoMode);
|
||||||
|
|
||||||
void DebugBegin ();
|
void DebugBegin ();
|
||||||
void DebugContinueStepping ();
|
void DebugContinueStepping ();
|
||||||
void DebugDestroy ();
|
void DebugDestroy ();
|
||||||
|
|
|
@ -789,7 +789,7 @@ void DebuggerPrintColor( int x, int y, const conchar_t * pText )
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
bool CanDrawDebugger()
|
bool CanDrawDebugger()
|
||||||
{
|
{
|
||||||
if (g_bDebuggerViewingAppleOutput)
|
if (DebugGetVideoMode(NULL))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((g_nAppMode == MODE_DEBUG) || (g_nAppMode == MODE_STEPPING))
|
if ((g_nAppMode == MODE_DEBUG) || (g_nAppMode == MODE_STEPPING))
|
||||||
|
|
|
@ -1177,7 +1177,7 @@ LRESULT CALLBACK FrameWndProc (
|
||||||
size_t nSize = 0;
|
size_t nSize = 0;
|
||||||
|
|
||||||
// if viewing the debugger, get the last virtual debugger screen
|
// if viewing the debugger, get the last virtual debugger screen
|
||||||
if ((g_nAppMode == MODE_DEBUG) && !g_bDebuggerViewingAppleOutput)
|
if ((g_nAppMode == MODE_DEBUG) && !DebugGetVideoMode(NULL))
|
||||||
nSize = Util_GetDebuggerText( pText );
|
nSize = Util_GetDebuggerText( pText );
|
||||||
else
|
else
|
||||||
nSize = Util_GetTextScreen( pText );
|
nSize = Util_GetTextScreen( pText );
|
||||||
|
@ -1244,7 +1244,16 @@ LRESULT CALLBACK FrameWndProc (
|
||||||
VideoReinitialize();
|
VideoReinitialize();
|
||||||
if (g_nAppMode != MODE_LOGO)
|
if (g_nAppMode != MODE_LOGO)
|
||||||
{
|
{
|
||||||
VideoRefreshScreen( g_nAppMode == MODE_DEBUG ? g_bDebuggerViewingAppleOutput : 0);
|
if (g_nAppMode == MODE_DEBUG)
|
||||||
|
{
|
||||||
|
UINT debugVideoMode;
|
||||||
|
bool bIsVideoModeValid = DebugGetVideoMode(&debugVideoMode);
|
||||||
|
VideoRefreshScreen( bIsVideoModeValid ? debugVideoMode : 0, bIsVideoModeValid );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VideoRefreshScreen(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Config_Save_Video();
|
Config_Save_Video();
|
||||||
|
|
|
@ -1129,7 +1129,7 @@ void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame)
|
||||||
|
|
||||||
void VideoRedrawScreen (void)
|
void VideoRedrawScreen (void)
|
||||||
{
|
{
|
||||||
// NB. Can't rely on g_uVideoMode being non-zero (ie. so it can double up as a flag) since 'non-mixed GR' mode == 0x00.
|
// NB. Can't rely on g_uVideoMode being non-zero (ie. so it can double up as a flag) since 'GR,PAGE1,non-mixed' mode == 0x00.
|
||||||
VideoRefreshScreen( g_uVideoMode, true );
|
VideoRefreshScreen( g_uVideoMode, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1193,7 +1193,7 @@ static void VideoFrameBufferAdjust(int& xSrc, int& ySrc, bool bInvertY=false)
|
||||||
ySrc += dy;
|
ySrc += dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoRefreshScreen ( int bVideoModeFlags, bool bRedrawWholeScreen /* =false*/ )
|
void VideoRefreshScreen ( int uRedrawWholeScreenVideoMode /* =0*/, bool bRedrawWholeScreen /* =false*/ )
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) && defined(DEBUG_REFRESH_TIMINGS)
|
#if defined(_DEBUG) && defined(DEBUG_REFRESH_TIMINGS)
|
||||||
DebugRefresh(0);
|
DebugRefresh(0);
|
||||||
|
@ -1201,11 +1201,11 @@ void VideoRefreshScreen ( int bVideoModeFlags, bool bRedrawWholeScreen /* =false
|
||||||
|
|
||||||
if (bRedrawWholeScreen || g_nAppMode == MODE_PAUSED)
|
if (bRedrawWholeScreen || g_nAppMode == MODE_PAUSED)
|
||||||
{
|
{
|
||||||
// bVideoModeFlags set if:
|
// uVideoModeForWholeScreen set if:
|
||||||
// . MODE_DEBUG : always
|
// . MODE_DEBUG : always
|
||||||
// . MODE_RUNNING : called from VideoRedrawScreen(), eg. during full-speed
|
// . MODE_RUNNING : called from VideoRedrawScreen(), eg. during full-speed
|
||||||
if (bRedrawWholeScreen)
|
if (bRedrawWholeScreen)
|
||||||
NTSC_SetVideoMode( bVideoModeFlags );
|
NTSC_SetVideoMode( uRedrawWholeScreenVideoMode );
|
||||||
NTSC_VideoRedrawWholeScreen();
|
NTSC_VideoRedrawWholeScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ void VideoRealizePalette (HDC);
|
||||||
void VideoRedrawScreenDuringFullSpeed(DWORD dwCyclesThisFrame, bool bInit = false);
|
void VideoRedrawScreenDuringFullSpeed(DWORD dwCyclesThisFrame, bool bInit = false);
|
||||||
void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame);
|
void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame);
|
||||||
void VideoRedrawScreen (void);
|
void VideoRedrawScreen (void);
|
||||||
void VideoRefreshScreen (int bVideoFlags, bool bRedrawWholeScreen = false);
|
void VideoRefreshScreen (int uRedrawWholeScreenVideoMode = 0, bool bRedrawWholeScreen = false);
|
||||||
void VideoReinitialize ();
|
void VideoReinitialize ();
|
||||||
void VideoResetState ();
|
void VideoResetState ();
|
||||||
WORD VideoGetScannerAddress(bool* pbVblBar_OUT, const DWORD uExecutedCycles);
|
WORD VideoGetScannerAddress(bool* pbVblBar_OUT, const DWORD uExecutedCycles);
|
||||||
|
|
Loading…
Add table
Reference in a new issue