Frame.cpp: Remove redundant, commented out and if 0 code, mostly relating to the old full-screen implementation

This commit is contained in:
tomcw 2017-10-11 19:18:53 +01:00
parent 32ffe0e1ac
commit 670ca20057
3 changed files with 28 additions and 225 deletions

View File

@ -76,11 +76,6 @@ static int g_nMaxViewportScale = kDEFAULT_VIEWPORT_SCALE; // Max scale in Window
#define BUTTONY 0 #define BUTTONY 0
#define BUTTONCX 45 #define BUTTONCX 45
#define BUTTONCY 45 #define BUTTONCY 45
// NB. FSxxx = FullScreen xxx
//#define FSVIEWPORTX (640-BUTTONCX-MAGICX-g_nViewportCX)
//#define FSVIEWPORTY ((480-g_nViewportCY)/2)
//#define FSBUTTONX (640-BUTTONCX)
//#define FSBUTTONY (((480-g_nViewportCY)/2)-1)
#define BUTTONS 8 #define BUTTONS 8
static HBITMAP g_hCapsLockBitmap[2]; static HBITMAP g_hCapsLockBitmap[2];
@ -144,19 +139,6 @@ static BOOL g_bUsingCursor = 0; // 1=AppleWin is using (hiding) the mouse-cu
static int viewportx = VIEWPORTX; // Default to Normal (non-FullScreen) mode static int viewportx = VIEWPORTX; // Default to Normal (non-FullScreen) mode
static int viewporty = VIEWPORTY; // Default to Normal (non-FullScreen) mode static int viewporty = VIEWPORTY; // Default to Normal (non-FullScreen) mode
#if 0 // TC: Redundant
// Direct Draw -- For Full Screen
// LPDIRECTDRAW g_pDD = (LPDIRECTDRAW)0;
// LPDIRECTDRAWSURFACE g_pDDPrimarySurface = (LPDIRECTDRAWSURFACE)0;
#define DIRECTX_PAGE_FLIP 1
#if DIRECTX_PAGE_FLIP
// LPDIRECTDRAWSURFACE g_pDDBackSurface = (LPDIRECTDRAWSURFACE)0;
#endif
// HDC g_hDDdc = 0;
// int g_nDDFullScreenW = 640;
// int g_nDDFullScreenH = 480;
#endif
static bool g_bShowingCursor = true; static bool g_bShowingCursor = true;
static bool g_bLastCursorInAppleViewport = false; static bool g_bLastCursorInAppleViewport = false;
@ -208,26 +190,26 @@ static int g_win_fullscreen_offsety = 0;
UINT GetFrameBufferBorderlessWidth(void) UINT GetFrameBufferBorderlessWidth(void)
{ {
static UINT uFrameBufferBorderlessW = 560; // 560 = Double Hi-Res static const UINT uFrameBufferBorderlessW = 560; // 560 = Double Hi-Res
return uFrameBufferBorderlessW; return uFrameBufferBorderlessW;
} }
UINT GetFrameBufferBorderlessHeight(void) UINT GetFrameBufferBorderlessHeight(void)
{ {
static UINT uFrameBufferBorderlessH = 384; // 384 = Double Scan Line static const UINT uFrameBufferBorderlessH = 384; // 384 = Double Scan Line
return uFrameBufferBorderlessH; return uFrameBufferBorderlessH;
} }
// NB. These border areas are not visible (... and these border areas are unrelated to the 3D border below) // NB. These border areas are not visible (... and these border areas are unrelated to the 3D border below)
UINT GetFrameBufferBorderWidth(void) UINT GetFrameBufferBorderWidth(void)
{ {
static UINT uBorderW = 20; static const UINT uBorderW = 20;
return uBorderW; return uBorderW;
} }
UINT GetFrameBufferBorderHeight(void) UINT GetFrameBufferBorderHeight(void)
{ {
static UINT uBorderH = 18; static const UINT uBorderH = 18;
return uBorderH; return uBorderH;
} }
@ -530,22 +512,6 @@ static void DrawCrosshairs (int x, int y) {
// ERASE THE OLD CROSSHAIRS // ERASE THE OLD CROSSHAIRS
if (lastx && lasty) if (lastx && lasty)
#if 0
if (g_bIsFullScreen) {
int loop = 4;
while (loop--) {
RECT rect = {0,0,5,5};
switch (loop) {
case 0: OffsetRect(&rect,lastx-2,FSVIEWPORTY-5); break;
case 1: OffsetRect(&rect,lastx-2,FSVIEWPORTY+g_nViewportCY); break;
case 2: OffsetRect(&rect,FSVIEWPORTX-5,lasty-2); break;
case 3: OffsetRect(&rect,FSVIEWPORTX+g_nViewportCX,lasty-2); break;
}
FillRect(dc,&rect,(HBRUSH)GetStockObject(BLACK_BRUSH));
}
}
else
#else
if (g_bIsFullScreen) if (g_bIsFullScreen)
{ {
int loop = 4; int loop = 4;
@ -561,7 +527,6 @@ static void DrawCrosshairs (int x, int y) {
} }
} }
else else
#endif
{ {
int loop = 5; int loop = 5;
while (loop--) { while (loop--) {
@ -2220,13 +2185,6 @@ void SetFullScreenMode ()
int top, left; int top, left;
buttonover = -1; buttonover = -1;
#if 0
// FS: 640x480
buttonx = FSBUTTONX;
buttony = FSBUTTONY;
viewportx = FSVIEWPORTX;
viewporty = FSVIEWPORTY;
#endif
g_main_window_saved_style = GetWindowLong(g_hFrameWindow, GWL_STYLE); g_main_window_saved_style = GetWindowLong(g_hFrameWindow, GWL_STYLE);
g_main_window_saved_exstyle = GetWindowLong(g_hFrameWindow, GWL_EXSTYLE); g_main_window_saved_exstyle = GetWindowLong(g_hFrameWindow, GWL_EXSTYLE);
@ -2252,42 +2210,12 @@ void SetFullScreenMode ()
SetWindowPos(g_hFrameWindow, NULL, left, top, (int)width, (int)height, SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); SetWindowPos(g_hFrameWindow, NULL, left, top, (int)width, (int)height, SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
g_bIsFullScreen = true; g_bIsFullScreen = true;
#if 1
// FS: desktop
SetViewportScale(g_win_fullscreen_scale, true); SetViewportScale(g_win_fullscreen_scale, true);
buttonx = GetFullScreenOffsetX() + g_nViewportCX + VIEWPORTX*2; buttonx = GetFullScreenOffsetX() + g_nViewportCX + VIEWPORTX*2;
buttony = GetFullScreenOffsetY(); buttony = GetFullScreenOffsetY();
viewportx = VIEWPORTX; // TC-TODO: Should be zero too? (Since there's no 3D border in full-screen) viewportx = VIEWPORTX; // TC-TODO: Should be zero too? (Since there's no 3D border in full-screen)
viewporty = 0; // GH#464 viewporty = 0; // GH#464
#endif
// GetWindowRect(g_hFrameWindow,&framerect);
// SetWindowLong(g_hFrameWindow,GWL_STYLE,WS_POPUP | WS_SYSMENU | WS_VISIBLE);
//
// DDSURFACEDESC ddsd;
// ddsd.dwSize = sizeof(ddsd);
// ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
// ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
// ddsd.dwBackBufferCount = 1;
//
// DDSCAPS ddscaps;
// ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
//
// if ( 0
// || DD_OK != DirectDrawCreate(NULL,&g_pDD,NULL)
// || DD_OK != g_pDD->SetCooperativeLevel(g_hFrameWindow,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN)
// || DD_OK != g_pDD->SetDisplayMode(g_nDDFullScreenW,g_nDDFullScreenH,32)
// || DD_OK != g_pDD->CreateSurface(&ddsd,&g_pDDPrimarySurface,NULL)
//#if DIRECTX_PAGE_FLIP
// || DD_OK != g_pDDPrimarySurface->GetAttachedSurface( &ddscaps, &g_pDDBackSurface)
//#endif
// )
// {
// g_pDDPrimarySurface = NULL;
// SetNormalMode();
// return;
// }
InvalidateRect(g_hFrameWindow,NULL,1); InvalidateRect(g_hFrameWindow,NULL,1);
@ -2315,25 +2243,6 @@ void SetNormalMode ()
g_main_window_saved_rect.bottom - g_main_window_saved_rect.top, g_main_window_saved_rect.bottom - g_main_window_saved_rect.top,
SWP_SHOWWINDOW); SWP_SHOWWINDOW);
g_bIsFullScreen = false; g_bIsFullScreen = false;
//g_pDD->RestoreDisplayMode();
//g_pDD->SetCooperativeLevel(NULL,DDSCL_NORMAL);
//SetWindowLong(g_hFrameWindow,GWL_STYLE,
// WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
// WS_VISIBLE);
//SetWindowPos(g_hFrameWindow,0,framerect.left,
// framerect.top,
// framerect.right - framerect.left,
// framerect.bottom - framerect.top,
// SWP_NOZORDER | SWP_FRAMECHANGED);
//if (g_pDDPrimarySurface)
//{
// g_pDDPrimarySurface->Release();
// g_pDDPrimarySurface = (LPDIRECTDRAWSURFACE)0;
//}
//g_pDD->Release();
//g_pDD = (LPDIRECTDRAW)0;
} }
//=========================================================================== //===========================================================================
@ -2569,50 +2478,12 @@ HDC FrameGetDC () {
} }
//=========================================================================== //===========================================================================
HDC FrameGetVideoDC (LPBYTE *pAddr_, LONG *pPitch_) void FrameReleaseDC () {
{ if (g_hFrameDC) {
HDC hDC = 0; SetViewportOrgEx(g_hFrameDC,0,0,NULL);
ReleaseDC(g_hFrameWindow,g_hFrameDC);
#if 0 // TC: just wrapping existing "if (false)" code in "#if 0" to make it clear that it's dead code g_hFrameDC = (HDC)0;
// ASSERT( pAddr_ );
// ASSERT( pPitch_ );
if (false) // TODO: ...
//if (g_bIsFullScreen && g_bAppActive && !g_bPaintingWindow)
{
// Reference: http://archive.gamedev.net/archive/reference/articles/article608.html
// NTSC TODO: Are these coordinates correct?? Coordinates don't seem to matter on Win7 fullscreen!?
// g_nViewportCX = FRAMEBUFFER_W * kDEFAULT_VIEWPORT_SCALE;
RECT rect = {
FSVIEWPORTX,
FSVIEWPORTY,
FSVIEWPORTX+g_nViewportCX,
FSVIEWPORTY+g_nViewportCY
};
DDSURFACEDESC surfacedesc;
surfacedesc.dwSize = sizeof(surfacedesc);
// TC: Use DDLOCK_WAIT - see Bug #13425
if (g_pDDPrimarySurface->Lock(&rect,&surfacedesc,DDLOCK_WAIT,NULL) == DDERR_SURFACELOST)
{
g_pDDPrimarySurface->Restore();
g_pDDPrimarySurface->Lock(&rect,&surfacedesc,DDLOCK_WAIT,NULL);
} }
*pAddr_ = (LPBYTE)surfacedesc.lpSurface + (g_nViewportCY-1) * surfacedesc.lPitch;
*pPitch_ = -surfacedesc.lPitch;
if( g_pDDPrimarySurface->GetDC( &hDC ) == DD_OK )
g_hDDdc = hDC; // intentional "null" copy
else
hDC = 0;
}
else
#endif
{
*pAddr_ = g_pFramebufferbits;
*pPitch_ = GetFrameBufferWidth();
hDC = FrameGetDC();
}
return hDC;
} }
//=========================================================================== //===========================================================================
@ -2642,46 +2513,6 @@ void FrameRegisterClass () {
RegisterClassEx(&wndclass); RegisterClassEx(&wndclass);
} }
//===========================================================================
void FrameReleaseDC () {
if (g_hFrameDC) {
SetViewportOrgEx(g_hFrameDC,0,0,NULL);
ReleaseDC(g_hFrameWindow,g_hFrameDC);
g_hFrameDC = (HDC)0;
}
}
//===========================================================================
void FrameReleaseVideoDC ()
{
#if 0 // TC: just wrapping existing "if (false)" code in "#if 0" to make it clear that it's dead code
if (false) // TODO: ...
//if (g_bIsFullScreen && g_bAppActive && !g_bPaintingWindow)
{
// THIS IS CORRECT ACCORDING TO THE DIRECTDRAW DOCS
RECT rect = {
FSVIEWPORTX,
FSVIEWPORTY,
FSVIEWPORTX+g_nViewportCX,
FSVIEWPORTY+g_nViewportCY
};
//g_pDDBackSurface->BltFast( 0, 0, g_pDDPrimarySurface, &rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT);
#if DIRECTX_PAGE_FLIP
g_pDDBackSurface->Flip( g_pDDPrimarySurface, 0 );
#endif
g_pDDPrimarySurface->Unlock(&rect);
// BUT THIS SEEMS TO BE WORKING
g_pDDPrimarySurface->Unlock(NULL);
g_pDDPrimarySurface->ReleaseDC( g_hDDdc ); // NTSC Full Screen
g_hDDdc = 0;
}
#endif
}
//=========================================================================== //===========================================================================
// TODO: FIXME: Util_TestFileExists() // TODO: FIXME: Util_TestFileExists()
static bool FileExists(std::string strFilename) static bool FileExists(std::string strFilename)

View File

@ -27,11 +27,9 @@
void FrameCreateWindow(void); void FrameCreateWindow(void);
HDC FrameGetDC (); HDC FrameGetDC ();
HDC FrameGetVideoDC (LPBYTE *,LONG *); void FrameReleaseDC ();
void FrameRefreshStatus (int, bool bUpdateDiskStatus = true ); void FrameRefreshStatus (int, bool bUpdateDiskStatus = true );
void FrameRegisterClass (); void FrameRegisterClass ();
void FrameReleaseDC ();
void FrameReleaseVideoDC ();
void FrameSetCursorPosByMousePos(); void FrameSetCursorPosByMousePos();
int GetViewportScale(void); int GetViewportScale(void);
int SetViewportScale(int nNewScale, bool bForce = false); int SetViewportScale(int nNewScale, bool bForce = false);

View File

@ -446,14 +446,8 @@ void VideoDisplayLogo ()
if( IsFullScreen() ) if( IsFullScreen() )
{ {
#if 0
// Draw Logo at top of screen so when the Apple display is refreshed it will automagically clear it
nLogoX = 0;
nLogoY = 0;
#else
nLogoX += GetFullScreenOffsetX(); nLogoX += GetFullScreenOffsetX();
nLogoY += GetFullScreenOffsetY(); nLogoY += GetFullScreenOffsetY();
#endif
} }
VideoDrawLogoBitmap( hFrameDC, nLogoX, nLogoY, bm.bmWidth, bm.bmHeight, scale ); VideoDrawLogoBitmap( hFrameDC, nLogoX, nLogoY, bm.bmWidth, bm.bmHeight, scale );
@ -500,8 +494,6 @@ void VideoDisplayLogo ()
#undef DRAWVERSION #undef DRAWVERSION
FrameReleaseVideoDC();
DeleteObject(font); DeleteObject(font);
} }
@ -656,23 +648,9 @@ void VideoRefreshScreen ( uint32_t uRedrawWholeScreenVideoMode /* =0*/, bool bRe
NTSC_VideoRedrawWholeScreen(); NTSC_VideoRedrawWholeScreen();
} }
// NTSC_BEGIN HDC hFrameDC = FrameGetDC();
LPBYTE pDstFrameBufferBits = 0;
LONG pitch = 0;
HDC hFrameDC = FrameGetVideoDC(&pDstFrameBufferBits,&pitch);
#if 1 // Keep Aspect Ratio
// Need to clear full screen logo to black
#define W g_nViewportCX
#define H g_nViewportCY
#else // Stretch
// Stretch - doesn't preserve 1:1 aspect ratio
#define W IsFullScreen() ? g_nDDFullScreenW : g_nViewportCX
#define H IsFullScreen() ? g_nDDFullScreenH : g_nViewportCY
#endif
if (hFrameDC) if (hFrameDC)
{
{ {
int xSrc = GetFrameBufferBorderWidth(); int xSrc = GetFrameBufferBorderWidth();
int ySrc = GetFrameBufferBorderHeight(); int ySrc = GetFrameBufferBorderHeight();
@ -693,12 +671,8 @@ void VideoRefreshScreen ( uint32_t uRedrawWholeScreenVideoMode /* =0*/, bool bRe
GetFrameBufferBorderlessWidth(), GetFrameBufferBorderlessHeight(), GetFrameBufferBorderlessWidth(), GetFrameBufferBorderlessHeight(),
SRCCOPY); SRCCOPY);
} }
}
GdiFlush(); GdiFlush();
FrameReleaseVideoDC();
// NTSC_END
} }
//=========================================================================== //===========================================================================