Direct Draw Palette Debugging

This commit is contained in:
mpohoreski 2009-02-21 04:42:35 +00:00
parent e9f8f5484b
commit 8fcdab3d69

View File

@ -398,15 +398,18 @@ static void DrawCrosshairs (int x, int y) {
}
//===========================================================================
static void DrawFrameWindow () {
static void DrawFrameWindow ()
{
FrameReleaseDC();
PAINTSTRUCT ps;
HDC dc = (g_bPaintingWindow ? BeginPaint(g_hFrameWindow,&ps)
HDC dc = (g_bPaintingWindow
? BeginPaint(g_hFrameWindow,&ps)
: GetDC(g_hFrameWindow));
VideoRealizePalette(dc);
if (!g_bIsFullScreen) {
if (!g_bIsFullScreen)
{
// DRAW THE 3D BORDER AROUND THE EMULATED SCREEN
Draw3dRect(dc,
VIEWPORTX-2,VIEWPORTY-2,
@ -425,17 +428,15 @@ static void DrawFrameWindow () {
VIEWPORTX+VIEWPORTCX+5,VIEWPORTY+VIEWPORTCY+5);
// DRAW THE TOOLBAR BUTTONS
int loop = BUTTONS;
while (loop--)
DrawButton(dc,loop);
int iButton = BUTTONS;
while (iButton--)
{
DrawButton(dc,iButton);
}
}
// DRAW THE STATUS AREA
DrawStatusArea(dc,DRAW_BACKGROUND | DRAW_LEDS);
if (g_bPaintingWindow)
EndPaint(g_hFrameWindow,&ps);
else
ReleaseDC(g_hFrameWindow,dc);
// DRAW THE CONTENTS OF THE EMULATED SCREEN
if (g_nAppMode == MODE_LOGO)
@ -444,6 +445,13 @@ static void DrawFrameWindow () {
DebugDisplay(1);
else
VideoRedrawScreen();
// DD Full-Screen Palette: BUGFIX: needs to come _after_ all drawing...
if (g_bPaintingWindow)
EndPaint(g_hFrameWindow,&ps);
else
ReleaseDC(g_hFrameWindow,dc);
}
//===========================================================================
@ -613,6 +621,10 @@ static void EraseButton (int number) {
rect.right = rect.left+BUTTONCX;
rect.top = buttony+number*BUTTONCY;
rect.bottom = rect.top+BUTTONCY;
// TODO: DD Full-Screen Palette
// if( !g_bIsFullScreen )
InvalidateRect(g_hFrameWindow,&rect,1);
}
@ -916,7 +928,9 @@ LRESULT CALLBACK FrameWndProc (
KeybQueueKeypress((int)wparam,NOT_ASCII);
}
else if (g_nAppMode == MODE_DEBUG)
{
DebuggerProcessKey(wparam);
}
if (wparam == VK_F10)
{
@ -1142,11 +1156,30 @@ LRESULT CALLBACK FrameWndProc (
break;
case WM_PALETTECHANGED:
// To avoid creating an infinite loop, a window that receives this
// message must not realize its palette, unless it determines that
// wParam does not contain its own window handle.
if ((HWND)wparam == window)
{
#if DEBUG_DD_PALETTE
if( g_bIsFullScreen )
OutputDebugString( "WM_PALETTECHANGED: Full Screen\n" );
else
OutputDebugString( "WM_PALETTECHANGED: Windowed\n" );
#endif
break;
// fall through
}
// else fall through
case WM_QUERYNEWPALETTE:
#if DEBUG_DD_PALETTE
if( g_bIsFullScreen )
OutputDebugString( "WM_QUERYNEWPALETTE: Full Screen\n" );
else
OutputDebugString( "WM_QUERYNEWPALETTE: Windowed\n" );
#endif
// TODO: DD Full-Screen Palette
DrawFrameWindow();
break;
@ -1208,6 +1241,14 @@ LRESULT CALLBACK FrameWndProc (
break;
case WM_SYSCOLORCHANGE:
#if DEBUG_DD_PALETTE
if( g_bIsFullScreen )
OutputDebugString( "WM_SYSCOLORCHANGE: Full Screen\n" );
else
OutputDebugString( "WM_SYSCOLORCHANGE: Windowed\n" );
#endif
// TODO: DD Full-Screen Palette
DeleteGdiObjects();
CreateGdiObjects();
break;
@ -1329,10 +1370,16 @@ LRESULT CALLBACK FrameWndProc (
//===========================================================================
void ProcessButtonClick (int button) {
void ProcessButtonClick (int button)
{
SoundCore_SetFade(FADE_OUT);
#if DEBUG_DD_PALETTE
char _text[ 80 ];
sprintf( _text, "Button: F%d Full Screen: %d\n", button+1, g_bIsFullScreen );
OutputDebugString( _text );
#endif
switch (button) {
case BTN_HELP:
@ -1418,6 +1465,10 @@ void ProcessButtonClick (int button) {
{
g_bDebugDelayBreakCheck = true;
ProcessButtonClick(BTN_RUN);
// TODO: DD Full-Screen Palette
// exiting debugger using wrong palette, but this makes problem worse...
//InvalidateRect(g_hFrameWindow,NULL,1);
}
else
{
@ -1625,6 +1676,10 @@ void SetFullScreenMode ()
SetNormalMode();
return;
}
// TODO: DD Full-Screen Palette
// if( !g_bIsFullScreen )
InvalidateRect(g_hFrameWindow,NULL,1);
}
@ -1647,11 +1702,21 @@ void SetNormalMode ()
framerect.right - framerect.left,
framerect.bottom - framerect.top,
SWP_NOZORDER | SWP_FRAMECHANGED);
// DD Full-Screen Palette: BUGFIX: Re-attach new palette on next new surface
// Delete Palette
if (g_pDDPal)
{
g_pDDPal->Release();
g_pDDPal = (LPDIRECTDRAWPALETTE)0;
}
if (g_pDDPrimarySurface)
{
g_pDDPrimarySurface->Release();
g_pDDPrimarySurface = (LPDIRECTDRAWSURFACE)0;
}
g_pDD->Release();
g_pDD = (LPDIRECTDRAW)0;
}
@ -1843,14 +1908,17 @@ void FrameReleaseDC () {
}
//===========================================================================
void FrameReleaseVideoDC () {
if (g_bIsFullScreen && g_bAppActive && !g_bPaintingWindow) {
void FrameReleaseVideoDC ()
{
if (g_bIsFullScreen && g_bAppActive && !g_bPaintingWindow)
{
// THIS IS CORRECT ACCORDING TO THE DIRECTDRAW DOCS
RECT rect = {FSVIEWPORTX,
RECT rect = {
FSVIEWPORTX,
FSVIEWPORTY,
FSVIEWPORTX+VIEWPORTCX,
FSVIEWPORTY+VIEWPORTCY};
FSVIEWPORTY+VIEWPORTCY
};
g_pDDPrimarySurface->Unlock(&rect);
// BUT THIS SEEMS TO BE WORKING