aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sword2/anims.cpp2
-rw-r--r--sword2/build_display.cpp9
-rw-r--r--sword2/console.cpp3
-rw-r--r--sword2/controls.cpp32
-rw-r--r--sword2/debug.cpp1
-rw-r--r--sword2/driver/_console.cpp1
-rw-r--r--sword2/driver/d_draw.cpp739
-rw-r--r--sword2/driver/d_draw.h1
-rw-r--r--sword2/driver/ddutil.h159
-rw-r--r--sword2/driver/driver96.h12
-rw-r--r--sword2/driver/rdwin.cpp1
-rw-r--r--sword2/driver/render.cpp254
-rw-r--r--sword2/driver/sprite.cpp9
-rw-r--r--sword2/function.cpp1
-rw-r--r--sword2/logic.cpp1
-rw-r--r--sword2/mem_view.cpp1
-rw-r--r--sword2/mouse.cpp2
-rw-r--r--sword2/resman.cpp20
-rw-r--r--sword2/router.cpp1
-rw-r--r--sword2/startup.cpp1
-rw-r--r--sword2/sword2.cpp6
21 files changed, 17 insertions, 1239 deletions
diff --git a/sword2/anims.cpp b/sword2/anims.cpp
index 7850af0af7..9bafb41e17 100644
--- a/sword2/anims.cpp
+++ b/sword2/anims.cpp
@@ -851,7 +851,6 @@ int32 FN_play_sequence(int32 *params) // James(09apr97)
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q during the smacker
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -884,7 +883,6 @@ int32 FN_play_sequence(int32 *params) // James(09apr97)
EraseBackBuffer(); // for hardware rendering
EraseSoftwareScreenBuffer(); // for software rendering
- FlipScreens(); // to get the new blank screen visible
//--------------------------------------------------
// zero the entire palette in case we're about to fade up!
diff --git a/sword2/build_display.cpp b/sword2/build_display.cpp
index 76c6624164..5795ec408d 100644
--- a/sword2/build_display.cpp
+++ b/sword2/build_display.cpp
@@ -254,7 +254,6 @@ void Build_display(void) //Tony21Sept96
// ready - blit to screen
CopyScreenBuffer();
- FlipScreens();
//----------------------------------------------------
// update our fps reading
@@ -304,7 +303,6 @@ void Build_display(void) //Tony21Sept96
ExitWithReport("Driver Error %.8x (drawing console) [%s line %u]", rv, __FILE__, __LINE__);
CopyScreenBuffer();
- FlipScreens();
}
else
{
@@ -349,7 +347,6 @@ void DisplayMsg( uint8 *text, int time ) // Chris 15May97
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -404,7 +401,6 @@ void DisplayMsg( uint8 *text, int time ) // Chris 15May97
SetPalette(0, 256, (uint8 *) pal, RDPAL_FADE);
CopyScreenBuffer();
- FlipScreens();
FadeUp((float)0.75);
@@ -421,7 +417,6 @@ void DisplayMsg( uint8 *text, int time ) // Chris 15May97
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -442,7 +437,6 @@ void DisplayMsg( uint8 *text, int time ) // Chris 15May97
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -458,7 +452,6 @@ void DisplayMsg( uint8 *text, int time ) // Chris 15May97
spriteInfo.y = oldY; // Drivers change the y co-ordinate, don't know why...
spriteInfo.x = oldX;
CopyScreenBuffer();
- FlipScreens();
}
SetPalette(0, 256, (uint8 *) oldPal, RDPAL_FADE);
@@ -483,7 +476,6 @@ void RemoveMsg( void ) // Chris 15May97
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -494,7 +486,6 @@ void RemoveMsg( void ) // Chris 15May97
EraseBackBuffer(); // for hardware rendering
EraseSoftwareScreenBuffer(); // for software rendering
CopyScreenBuffer();
- FlipScreens();
// FadeUp((float)0.75);
// removed by JEL (08oct97) to prevent "eye" smacker corruption when restarting game from CD2
diff --git a/sword2/console.cpp b/sword2/console.cpp
index d6bed2ce34..81cbfb4657 100644
--- a/sword2/console.cpp
+++ b/sword2/console.cpp
@@ -912,7 +912,6 @@ void Con_help(void) //Tony13Aug96
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -1030,7 +1029,6 @@ void Con_fatal_error(const char *format,...) //Tony17Oct96
Close_game(); //should down game services - free's mallocs, etc.
- RestoreDisplay(); //reset the Windows stuff
CloseAppWindow(); //
exit(0);
@@ -1144,7 +1142,6 @@ void Con_list_savegames(void) // (James05feb97) Tony1Apr97
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
diff --git a/sword2/controls.cpp b/sword2/controls.cpp
index 2e9ac6941d..96f99044fe 100644
--- a/sword2/controls.cpp
+++ b/sword2/controls.cpp
@@ -275,7 +275,6 @@ uint32 Restore_control(void) //Tony20Mar97
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q during the smacker
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -417,14 +416,6 @@ uint32 Restore_control(void) //Tony20Mar97
SetFullPalette(CONTROL_PANEL_PALETTE); // see Build_display.cpp (James17jun97)
}
- FlipScreens();
-
-
-
-
-
-
-
//mouse over buttons?
//restore
@@ -972,7 +963,6 @@ void Save_control(void) //Tony1Apr97 not a joke
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q during the smacker
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -1485,9 +1475,6 @@ void Save_control(void) //Tony1Apr97 not a joke
first++;
SetFullPalette(CONTROL_PANEL_PALETTE); // see Build_display.cpp (James17jun97)
}
-
- FlipScreens();
-
} //while
@@ -1513,15 +1500,9 @@ void Quit_control(void) //Tony2Apr97
if (!res)
return; //just return to game
-
-//avoid corruption when windows kicks back in
- EraseBackBuffer();
- FlipScreens();
EraseBackBuffer();
- FlipScreens();
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0);
@@ -1550,8 +1531,6 @@ void Restart_control(void) //Tony4Apr97
Kill_mini_surfaces();
EraseBackBuffer();
//ProcessMenu(); //draw menu
- FlipScreens();
-
//restart the game
//clear all memory and reset the globals
@@ -1656,7 +1635,6 @@ uint32 Generic_mini_control(uint32 text_id) //Tony2Apr97
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -1747,7 +1725,6 @@ uint32 Generic_mini_control(uint32 text_id) //Tony2Apr97
if (breakOut)
break;
- FlipScreens();
if (!first)
{
first++;
@@ -1875,7 +1852,6 @@ void Control_error(char* text) //Tony13May97
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q during the smacker
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -2379,7 +2355,6 @@ void Option_control(void) //Pete6Jun97
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q during the smacker
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -2789,7 +2764,6 @@ void Option_control(void) //Pete6Jun97
first++;
SetFullPalette(CONTROL_PANEL_PALETTE); // see Build_display.cpp (James17jun97)
}
- FlipScreens();
}
@@ -2812,20 +2786,17 @@ void UpdateGraphicsLevel(uint8 oldLevel, uint8 newLevel) // (James13jun97)
break;
case 1:
- RenderSoft();
ClearBltFx();
ClearShadowFx();
CloseBackgroundLayer();
break;
case 2:
- RenderSoft();
ClearBltFx();
CloseBackgroundLayer();
break;
case 3: // same as case 2 until case 2 has edge-blending inactivated
- RenderSoft();
CloseBackgroundLayer();
break;
}
@@ -2838,7 +2809,6 @@ void UpdateGraphicsLevel(uint8 oldLevel, uint8 newLevel) // (James13jun97)
break;
case 0:
- RenderHard();
SetUpBackgroundLayers(); // InitialiseBackgroundLayer for each layer! (see layers.cpp)
break;
@@ -2867,7 +2837,6 @@ void UpdateGraphicsLevel(uint8 oldLevel, uint8 newLevel) // (James13jun97)
break;
case 0:
- RenderHard();
SetUpBackgroundLayers(); // InitialiseBackgroundLayer for each layer! (see layers.cpp)
break;
}
@@ -2889,7 +2858,6 @@ void UpdateGraphicsLevel(uint8 oldLevel, uint8 newLevel) // (James13jun97)
break;
case 0:
- RenderHard();
SetUpBackgroundLayers(); // InitialiseBackgroundLayer for each layer! (see layers.cpp)
break;
}
diff --git a/sword2/debug.cpp b/sword2/debug.cpp
index 3264eafb84..41a0e184ad 100644
--- a/sword2/debug.cpp
+++ b/sword2/debug.cpp
@@ -105,7 +105,6 @@ void ExitWithReport(const char *format,...) // (6dec96 JEL)
while (GetFadeStatus()) // wait for fade to finish before calling RestoreDisplay()
ServiceWindows();
- RestoreDisplay();
ReportFatalError((const uint8 *)buf); // display message box
CloseAppWindow();
while (ServiceWindows() != RDERR_APPCLOSED);
diff --git a/sword2/driver/_console.cpp b/sword2/driver/_console.cpp
index c501efdf6f..022899bd53 100644
--- a/sword2/driver/_console.cpp
+++ b/sword2/driver/_console.cpp
@@ -94,7 +94,6 @@ void DisplayConsole(void)
hr = IDirectDrawSurface_Lock(lpBackBuffer, NULL, &ddDescription, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr != DD_OK)
{
- RestoreSurfaces();
hr = IDirectDrawSurface_Lock(lpBackBuffer, NULL, &ddDescription, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
}
diff --git a/sword2/driver/d_draw.cpp b/sword2/driver/d_draw.cpp
index 0c4891e427..d62697ce62 100644
--- a/sword2/driver/d_draw.cpp
+++ b/sword2/driver/d_draw.cpp
@@ -17,15 +17,7 @@
* $Header$
*/
-#define WIN32_LEAN_AND_MEAN
-
-//#include <windows.h>
-//#include <windowsx.h>
-//#include <mmsystem.h>
#include <stdio.h>
-
-//#include "ddraw.h"
-
#include "stdafx.h"
#include "driver96.h"
#include "rdwin.h"
@@ -33,32 +25,16 @@
#include "d_draw.h"
#include "palette.h"
-//#include "ddutil.h"
-//CDisplay *g_pDisplay = NULL;
-
-
-
-
-
#define SCREENYOFFSET 40
-
#define MILLISECSPERCYCLE 83
-
-// Surface *lpPrimarySurface;
Surface *lpBackBuffer;
/*
-LPDIRECTDRAW7 m_pDD;
-
-
static LPDIRECTDRAW lpDraw; // DirectDraw object
LPDIRECTDRAW2 lpDD2; // DirectDraw2 object
-LPDIRECTDRAWSURFACE lpPrimarySurface; // DirectDraw primary surface
LPDIRECTDRAWSURFACE lpBackBuffer; // DirectDraw back surface
LPDIRECTDRAWPALETTE lpPalette = NULL; // DirectDraw palette
-
-static PALETTEENTRY AppPalette[256]; // Application wide logical palette
*/
@@ -91,37 +67,14 @@ int32 dxHalCaps = 0;
int32 dxHelCaps = 0;
//DDCOLORKEY blackColorKey;
-
-//static int32 platformIsNT = 0;
-
-
-//----------------------------------------------------------------------------------------------------------------
-//----------------------------------------------------------------------------------------------------------------
-
-
-void FatalDirectDrawError(char *str, int32 code, char *filename, int32 line)
-{
-
+void FatalDirectDrawError(char *str, int32 code, char *filename, int32 line) {
char string[256];
- RestoreDisplay();
-
sprintf(string, "FATAL: %s - code 0x%.8x - file %s - line %d", str, code, filename, line);
- //MessageBox(hwnd, string, "DDraw error", MB_OK);
warning("%s", string);
-
}
-
-
-
-//----------------------------------------------------------------------------------------------------------------
-
-
-
-int32 PlotDots(int16 x, int16 y, int16 count)
-
-{
+int32 PlotDots(int16 x, int16 y, int16 count) {
warning("stub PlotDots( %d, %d, %d )", x, y, count);
/*
@@ -136,7 +89,6 @@ int32 PlotDots(int16 x, int16 y, int16 count)
hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddDescription, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr != DD_OK)
{
- RestoreSurfaces();
hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddDescription, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
}
@@ -162,540 +114,31 @@ int32 PlotDots(int16 x, int16 y, int16 count)
return(RD_OK);
}
-//----------------------------------------------------------------------------------------------------------------
-
-
-
-void RestoreSurfaces(void)
-
-{
- warning("stub RestoreSurfaces");
-/*
- IDirectDrawSurface2_Restore(lpPrimarySurface);
- IDirectDrawSurface2_Restore(lpBackBuffer);
-*/
-}
-
-//----------------------------------------------------------------------------------------------------------------
-
-/*
-static PALETTEENTRY *CreateAppPalette(PALETTEENTRY *pe)
-{
-
- HDC screen_dc;
-
-// Fill the palette with system colours
- screen_dc = GetDC(NULL);
- GetSystemPaletteEntries(screen_dc, 0, 256, pe);
- ReleaseDC(NULL, screen_dc);
-
- return pe;
-
-}
-*/
-
-
-//----------------------------------------------------------------------------------------------------------------
-
-int32 RestoreDisplay(void)
-
-{
- warning("stub RestoreDisplay");
-/*
- if( lpDraw != NULL )
- {
- if( lpPrimarySurface != NULL )
- {
- IDirectDrawSurface2_Release(lpPrimarySurface);
- lpPrimarySurface = NULL;
- }
- if( lpPalette != NULL )
- {
- IDirectDrawPalette_Release(lpPalette);
- lpPalette = NULL;
- }
- if (lpDD2 != NULL)
- {
- IDirectDraw2_Release(lpDD2);
- lpDD2 = NULL;
- }
-
- IDirectDraw_Release(lpDraw);
- lpDraw = NULL;
- }
-*/
- return(RD_OK);
-
-}
-
-//----------------------------------------------------------------------------------------------------------------
-//----------------------------------------------------------------------------------------------------------------
-//----------------------------------------------------------------------------------------------------------------
-//----------------------------------------------------------------------------------------------------------------
-
-int32 InitialiseDisplay(int16 width, int16 height, int16 colourDepth, int32 windowType)
-{
+int32 InitialiseDisplay(int16 width, int16 height, int16 colourDepth, int32 windowType) {
screenWide = width;
screenDeep = height;
-// lpPrimarySurface = new Surface(width, height);
lpBackBuffer = new Surface(width, height);
-
-/*
- DDSURFACEDESC ddsd;
- DDSCAPS ddscaps;
- HRESULT hr;
- DDCAPS helCaps;
- long int timerFrequency;
- int32 capsError = 0;
-
-
- OSVERSIONINFO VersionInfo;
- VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-
- if (GetVersionEx(&VersionInfo))
- {
-
- switch (VersionInfo.dwPlatformId)
- {
- case VER_PLATFORM_WIN32s :
- case VER_PLATFORM_WIN32_WINDOWS :
- break;
- case VER_PLATFORM_WIN32_NT :
- platformIsNT = 1;
- break;
- }
- }
-
-
- if (windowType == RD_FULLSCREEN)
- bFullScreen = TRUE;
- else
- bFullScreen = FALSE;
-
- // Colour depths of 8 bits only are currently supported
- if (colourDepth != 8)
- {
- return(RDERR_COLOURDEPTH);
- }
-
- screenWide = width;
- screenDeep = height;
-
- // Create the directDraw object
- hr = DirectDrawCreate(NULL, &lpDraw, NULL);
-// hr=DirectDrawCreateEx( NULL, (VOID**)&m_pDD, IID_IDirectDraw7, NULL );
-
-
- if ( hr != DD_OK )
- {
-// Zdebug(" DirectDrawCreate failed!");
-
- DirectDrawError("DirectDraw unavailable", hr);
- return(hr);
- }
-
-
- // Get exclusive mode
- if (bFullScreen)
- {
-
-// hr = m_pDD->SetCooperativeLevel( hWnd, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN );
- hr = IDirectDraw2_SetCooperativeLevel(lpDraw, hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
- if (hr != DD_OK)
- {
- DirectDrawError("Exclusive mode unavailable", hr);
- return(hr);
- }
-
- // TONY TEMP
-
-
- hr = IDirectDraw2_QueryInterface(lpDraw, &IID_IDirectDraw2, (LPVOID *) &lpDD2);
- if (hr != DD_OK)
- {
- DirectDrawError("DirectDraw2 unavailable", hr);
- return(hr);
- }
-
- // Set up the display mode which has been requested
-// hr = lpDD2->lpVtbl->SetDisplayMode(lpDD2, width, height, colourDepth, 0, 0);
- hr = IDirectDraw2_SetDisplayMode(lpDD2, width, height, colourDepth, 0, 0);
- if (hr != DD_OK)
- {
- DirectDrawError("Unable to set display mode", hr);
- return(hr);
- }
-
- // Set up the primary surface descriptor
- ddsd.dwSize = sizeof(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
- ddsd.dwBackBufferCount = 1;
-
- // Create the primary surface
- hr = IDirectDraw2_CreateSurface(lpDD2, &ddsd, &lpPrimarySurface, NULL);
- if (hr != DD_OK)
- {
- DirectDrawError("Cannot create primary surface", hr);
- return(hr);
- }
-
- // Create the back buffer as a page flipping surface
- ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
- hr = IDirectDrawSurface2_GetAttachedSurface(lpPrimarySurface, &ddscaps, &lpBackBuffer);
- if (hr != DD_OK)
- {
- DirectDrawError("Unable to attach back buffer", hr);
- return(hr);
- }
-
- EraseBackBuffer();
- FlipScreens();
- EraseBackBuffer();
- FlipScreens();
-
- // Create a palette object
- hr = IDirectDraw2_CreatePalette(lpDD2, DDPCAPS_8BIT | DDPCAPS_ALLOW256 | DDPCAPS_INITIALIZE,
- CreateAppPalette(AppPalette), &lpPalette, NULL);
- if (hr != DD_OK )
- {
- DirectDrawError("Cannot create 8-bit palette", hr);
- return(hr);
- }
-
- // Set our palette object active
- hr = IDirectDrawSurface2_SetPalette(lpPrimarySurface, lpPalette);
- if (hr != DD_OK )
- {
- DirectDrawError("Unable to set palette", hr);
- return(hr);
- }
-
- }
- else
- {
- RECT rcWork;
- RECT rc;
- HDC hdc;
- DWORD dwStyle;
- uint32 GameBPP;
-
-
-
- hr = IDirectDraw_SetCooperativeLevel(lpDraw, hwnd, DDSCL_NORMAL);
- if (hr != DD_OK)
- {
- DirectDrawError("Cannot set normal cooperative level", hr);
- return(hr);
- }
-
-
-
- hr = IDirectDraw_QueryInterface(lpDraw, &IID_IDirectDraw2, (LPVOID *) &lpDD2);
- if (hr != DD_OK)
- {
- DirectDrawError("DirectDraw2 unavailable", hr);
- return(hr);
- }
-
- //
- // when in windows we should use the current mode
- //
- hdc = GetDC(NULL);
- GameBPP = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL);
- ReleaseDC(NULL, hdc);
-
- if ((GameBPP != 8) && (GameBPP != 16))
- {
- MessageBox(hwnd, "Cannot execute in high colour mode - going to full screen", "Broken Sword II", MB_OK);
- return(RDERR_GOFULLSCREEN);
- }
- else if (GameBPP != 8)
- {
- if (MessageBox(hwnd, "Your display is not in 256 colour mode. Would you like to go to full screen mode (better performance)", "Broken Sword II", MB_YESNO) == IDYES)
- {
- return(RDERR_GOFULLSCREEN);
- }
- }
-
- //
- // if we are still a WS_POPUP window we should convert to a
- // normal app window so we look like a windows app.
- //
- dwStyle = GetWindowStyle(hwnd);
- dwStyle &= ~WS_POPUP;
- dwStyle |= WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX;
- SetWindowLong(hwnd, GWL_STYLE, dwStyle);
-
-// if (bStretch)
-// SetRect(&rc, 0, 0, GameMode.cx*2, GameMode.cy*2);
-// else
-// SetRect(&rc, 0, 0, GameMode.cx, GameMode.cy);
- SetRect(&rc, 0, 0, 640, 480);
-
- AdjustWindowRectEx(&rc,
- GetWindowStyle(hwnd),
- GetMenu(hwnd) != NULL,
- GetWindowExStyle(hwnd));
-
- SetWindowPos(hwnd, NULL, 0, 0, rc.right-rc.left, rc.bottom-rc.top,
- SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
-
- SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
- SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
-
- //
- // make sure our window does not hang outside of the work area
- // this will make people who have the tray on the top or left
- // happy.
- //
- SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWork, 0);
- GetWindowRect(hwnd, &rc);
- if (rc.left < rcWork.left) rc.left = rcWork.left;
- if (rc.top < rcWork.top) rc.top = rcWork.top;
- SetWindowPos(hwnd, NULL, rc.left, rc.top, 0, 0,
- SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
-
-
-
-
- // Set up the primary surface descriptor
- ddsd.dwSize = sizeof(ddsd);
- ddsd.dwFlags = DDSD_CAPS;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
- // Create the primary surface
- hr = IDirectDraw2_CreateSurface(lpDD2, &ddsd, &lpPrimarySurface, NULL);
- if (hr != DD_OK)
- {
- DirectDrawError("Cannot create primary surface", hr);
- return(hr);
- }
-
- // Create the back buffer as a page flipping surface
- memset( &ddsd, 0, sizeof( ddsd ) );
- ddsd.dwSize = sizeof( ddsd );
- ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT |DDSD_WIDTH;
-
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- ddsd.dwHeight = 480;
- ddsd.dwWidth = 640;
-
- hr = IDirectDraw2_CreateSurface(lpDD2, &ddsd, &lpBackBuffer, NULL );
- if (hr != DD_OK)
- {
- DirectDrawError("Cannot attach back buffer", hr);
- return(hr);
- }
-
- // DDClear();
-
- if (IDirectDrawSurface2_GetDC(lpPrimarySurface, &hdc) == DD_OK)
- {
- char *szMsg = "Broken Sword II is loading.......please wait.";
- SetTextColor(hdc, RGB(255,255,255));
- SetBkMode(hdc, TRANSPARENT);
- TextOut(hdc, rcWindow.left, rcWindow.top, szMsg, lstrlen(szMsg));
- IDirectDrawSurface2_ReleaseDC(lpPrimarySurface, hdc);
- }
-
- // Create a palette object - only if we have a palette!
- if (GameBPP == 8)
- {
- hr = IDirectDraw2_CreatePalette(lpDD2, DDPCAPS_8BIT, CreateAppPalette(AppPalette), &lpPalette, NULL);
- if (hr != DD_OK )
- {
- DirectDrawError("Cannot create 8-bit palette", hr);
- return(hr);
- }
-
- hr = IDirectDrawSurface2_SetPalette(lpPrimarySurface, lpPalette);
- if (hr != DD_OK )
- {
- DirectDrawError("Cannot set palette", hr);
- return(hr);
- }
- }
- }
-
- // Set my capability bits.
- memset(&driverCaps, 0, sizeof(DDCAPS));
- memset(&helCaps, 0, sizeof(DDCAPS));
- driverCaps.dwSize = sizeof(DDCAPS);
- helCaps.dwSize = sizeof(DDCAPS);
- hr = IDirectDraw2_GetCaps(lpDD2, &driverCaps, &helCaps);
- if (hr != DD_OK)
- {
- driverCaps.dwSize = sizeof(DDCAPS_DX3);
- helCaps.dwSize = sizeof(DDCAPS_DX3);
- hr = IDirectDraw2_GetCaps(lpDD2, &driverCaps, &helCaps);
- if (hr != DD_OK)
- {
- MessageBox(hwnd, "Cannot get hardware capabilities. Software emulation only. Re-install DirectX!", "DDraw error", MB_OK);
- capsError = 1;
- }
- }
-
- blackColorKey.dwColorSpaceLowValue = 0;
- blackColorKey.dwColorSpaceHighValue = 0;
-
- if (capsError)
- {
- helCaps.dwCaps = DDCAPS_BLT + DDCAPS_BLTSTRETCH + DDCAPS_COLORKEY;
- helCaps.dwCKeyCaps = DDCKEYCAPS_SRCBLT;
- dxHelCaps += RDCAPS_BLTSTRETCH;
- dxHelCaps += RDCAPS_SRCBLTCKEY;
- renderCaps = RDBLTFX_MOUSEBLT | RDBLTFX_ARITHMETICSTRETCH | RDBLTFX_EDGEBLEND |
- RDBLTFX_SHADOWBLEND | RDBLTFX_FLATALPHA | RDBLTFX_GRADEDALPHA;
- }
- else
- {
- if ((helCaps.dwCaps & DDCAPS_BLT == 0) ||
- (helCaps.dwCaps & DDCAPS_BLTSTRETCH == 0) ||
- (helCaps.dwCaps & DDCAPS_COLORKEY == 0) ||
- (helCaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT == 0))
- {
- RestoreDisplay();
- return(RDERR_NOEMULATION);
- }
-
-// if (driverCaps.dwCaps & DDCAPS_BLTSTRETCH)
-// {
-// if (driverCaps.dwFXCaps & (DDFXCAPS_BLTSHRINKX + DDFXCAPS_BLTSHRINKY + DDFXCAPS_BLTSTRETCHX + DDFXCAPS_BLTSTRETCHY) ==
-// DDFXCAPS_BLTSHRINKX + DDFXCAPS_BLTSHRINKY + DDFXCAPS_BLTSTRETCHX + DDFXCAPS_BLTSTRETCHY)
-// dxHalCaps += RDCAPS_BLTSTRETCH;
-// else if (helCaps.dwCaps & DDCAPS_BLTSTRETCH)
-// dxHelCaps += RDCAPS_BLTSTRETCH;
-// else
-// return RDERR_DDRAWNOEMULATION;
-// }
-// else if (helCaps.dwCaps & DDCAPS_BLTSTRETCH)
-// dxHelCaps += RDCAPS_BLTSTRETCH;
-// else
-// return(RDERR_DDRAWNOEMULATION);
-
- if (helCaps.dwCaps & DDCAPS_BLTSTRETCH)
- dxHelCaps += RDCAPS_BLTSTRETCH;
- else
- return(RDERR_DDRAWNOEMULATION);
-
- if ((driverCaps.dwCaps & DDCAPS_BLT) && (driverCaps.dwCaps & DDCAPS_COLORKEY) && (driverCaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT))
- dxHalCaps += RDCAPS_SRCBLTCKEY;
- else if ((helCaps.dwCaps & DDCAPS_BLT) && (helCaps.dwCaps & DDCAPS_COLORKEY) && (helCaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT))
- dxHelCaps += RDCAPS_SRCBLTCKEY;
- else
- return(RDERR_DDRAWNOEMULATION);
-
-
-
- // Do computer speed testing here to set bits. - this is the path we go through:
- //
- // if (Can everything be done in hardware?)
- // renderCaps = RDBLTFX_ALLHARDWARE;
- // else
- // if (Everything fast enough in software)
- // turn everything on in software
- // else
- // Turn blending off
- // if (can everything but blending be done in hardware?)
- // renderCaps = RDBLTFX_ALLHARDWARE
- // else
- // if (everything but blending fast enough in software)
- // Do everything but blending in software
- // else
- // Turn off sprite effects
- // endif
- // endif
- // endif
- // endif
-
-
-
-
- if ((driverCaps.dwCaps & DDCAPS_BLT) && (driverCaps.dwCaps & DDCAPS_COLORKEY) && (driverCaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT)
- && (driverCaps.dwCaps & DDSCAPS_ALPHA) && (driverCaps.dwAlphaBltConstBitDepths))
- renderCaps = RDBLTFX_ALLHARDWARE | RDBLTFX_GRADEDALPHA | RDBLTFX_FLATALPHA;
- else if ((driverCaps.dwCaps & DDCAPS_BLT) && (driverCaps.dwCaps & DDCAPS_COLORKEY) && (driverCaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT))
- renderCaps = RDBLTFX_ALLHARDWARE;
- else
- renderCaps = RDBLTFX_MOUSEBLT | RDBLTFX_ARITHMETICSTRETCH | RDBLTFX_EDGEBLEND |
- RDBLTFX_SHADOWBLEND | RDBLTFX_FLATALPHA | RDBLTFX_GRADEDALPHA;
-
- if (QueryPerformanceFrequency(&timerFrequency) == TRUE)
- if (timerFrequency.QuadPart > 700000)
- renderCaps = RDBLTFX_MOUSEBLT | RDBLTFX_ARITHMETICSTRETCH | RDBLTFX_EDGEBLEND |
- RDBLTFX_SHADOWBLEND | RDBLTFX_FLATALPHA | RDBLTFX_GRADEDALPHA;
-
- // if ((driverCaps.dwCaps & DDCAPS_BLT) && (driverCaps.dwCaps & DDCAPS_COLORKEY) && (driverCaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT))
- // renderCaps = RDBLTFX_MOUSEBLT | RDBLTFX_ARITHMETICSTRETCH | RDBLTFX_EDGEBLEND |
- // RDBLTFX_SHADOWBLEND | RDBLTFX_FLATALPHA | RDBLTFX_GRADEDALPHA | RDBLTFX_FGPARALLAX;
- // else
- // renderCaps = RDBLTFX_MOUSEBLT | RDBLTFX_ARITHMETICSTRETCH | RDBLTFX_EDGEBLEND |
- // RDBLTFX_SHADOWBLEND | RDBLTFX_FLATALPHA | RDBLTFX_GRADEDALPHA;
-
- // renderCaps = RDBLTFX_MOUSEBLT | RDBLTFX_SHADOWBLEND | RDBLTFX_FLATALPHA | RDBLTFX_ALLHARDWARE;
- }
-*/
- return(RD_OK);
-
-}
-//----------------------------------------------------------------------------------------------------------------
-//----------------------------------------------------------------------------------------------------------------
-//----------------------------------------------------------------------------------------------------------------
-//----------------------------------------------------------------------------------------------------------------
-//----------------------------------------------------------------------------------------------------------------
-
-
-
-int32 RenderHard(void)
-{
- warning("stub RenderHard");
-/*
- if (renderCaps & RDBLTFX_ALLHARDWARE)
- return(RDERR_ALREADYON);
- if ((driverCaps.dwCaps & DDCAPS_BLT) && (driverCaps.dwCaps & DDCAPS_COLORKEY) && (driverCaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT))
- renderCaps = RDBLTFX_ALLHARDWARE;
- else
- return(RDERR_NOHARDWARE);
-
-*/
- return(RD_OK);
-}
-
-int32 RenderSoft(void)
-{
- warning("stub RenderSoft");
-/*
- if (!(renderCaps & RDBLTFX_ALLHARDWARE))
- return(RDERR_ALREADYON);
- renderCaps = RDBLTFX_MOUSEBLT | RDBLTFX_ARITHMETICSTRETCH | RDBLTFX_EDGEBLEND |
- RDBLTFX_SHADOWBLEND | RDBLTFX_FLATALPHA | RDBLTFX_GRADEDALPHA;
-*/
return(RD_OK);
}
-int32 SetBltFx(void)
-{
+int32 SetBltFx(void) {
renderCaps |= RDBLTFX_EDGEBLEND + RDBLTFX_ARITHMETICSTRETCH;
return(RD_OK);
}
-int32 ClearBltFx(void)
-{
+int32 ClearBltFx(void) {
renderCaps &= (0xffffffff - RDBLTFX_EDGEBLEND - RDBLTFX_ARITHMETICSTRETCH);
return(RD_OK);
}
-int32 ClearShadowFx(void)
-{
+int32 ClearShadowFx(void) {
renderCaps &= (0xffffffff - RDBLTFX_SHADOWBLEND);
return(RD_OK);
}
-int32 SetShadowFx(void)
-{
+int32 SetShadowFx(void) {
renderCaps |= RDBLTFX_SHADOWBLEND;
return RD_OK;
}
@@ -720,88 +163,6 @@ int32 GetRenderType(void)
}
}
-int32 FlipScreens(void)
-
-{
- // I think this function can be removed. We render to lpBackBuffer,
- // and the backend acts as the primary buffer.
-
- debug(0, "FlipScreens");
-
-/*
- HRESULT hr;
- BOOL vbl;
- int32 startTime;
-
- DrawMouse();
-
- if (bFullScreen)
- {
- startTime = timeGetTime();
-
- while(TRUE)
- {
- if (!noVbl)
- {
- hr = IDirectDraw2_GetVerticalBlankStatus(lpDD2, &vbl);
- if (hr != DD_OK)
- {
- DirectDrawError("Vertical blank status unavailable", hr);
- }
- }
-
- if (vbl || noVbl)
- {
- hr = IDirectDrawSurface2_Flip(lpPrimarySurface, NULL, 0);
- if (hr == DD_OK)
- {
- break;
- }
-
- if (hr == DDERR_SURFACELOST)
- {
- if (gotTheFocus)
- {
- hr = IDirectDrawSurface2_Restore(lpPrimarySurface);
-
- if(hr != DD_OK)
- {
- if (++failCount == 32)
- return(RDERR_CANNOTFLIP);
- }
- }
-
- }
- else
- failCount = 0;
-
- if(hr != DDERR_WASSTILLDRAWING)
- {
- break;
- }
- }
- if (timeGetTime() - startTime > 20)
- {
- noVbl = 1;
- }
- }
- }
- else
- {
-
- hr = IDirectDrawSurface2_Blt(lpPrimarySurface, &rcWindow, lpBackBuffer, NULL, DDBLT_WAIT, NULL);
- if (hr != DD_OK)
- {
- return(RDERR_UNKNOWN);
- }
- }
-*/
- return(RD_OK);
-
-}
-
-
-
int32 WaitForVbl(void)
{
warning("stub WaitForVbl");
@@ -832,66 +193,10 @@ int32 WaitForVbl(void)
}
-
-
-
-int32 EraseBackBuffer( void )
-{
- debug(0, "EraseBackBuffer");
+int32 EraseBackBuffer( void ) {
+ debug(9, "EraseBackBuffer");
lpBackBuffer->clear();
-
-/*
- DDBLTFX ddbltfx;
- HRESULT hr;
- RECT r = {0, 0, screenWide, screenDeep};
-
-
- // Erase the background
- ddbltfx.dwSize = sizeof(ddbltfx);
- ddbltfx.dwFillColor = 0;
-
- while( 1 )
- {
-
- hr = IDirectDrawSurface2_Blt(lpBackBuffer, &r, NULL, NULL, DDBLT_COLORFILL, &ddbltfx );
-
- if (hr == DDERR_SURFACELOST)
- {
-
- RestoreSurfaces();
-
- hr = IDirectDrawSurface2_Blt(lpBackBuffer, &r, NULL, NULL, DDBLT_COLORFILL, &ddbltfx );
-
- if (hr != DD_OK)
- {
- if (++failCount == 32)
- {
- DirectDrawError("Cannot render back buffer", hr);
- return(hr);
- }
- else
- {
- failCount = 0;
- return(RD_OK);
- }
- }
-
- }
-
- if (hr == DD_OK)
- {
- break;
- }
-
- if (hr != DDERR_WASSTILLDRAWING)
- {
- DirectDrawError("Cannot render back buffer", hr);
- return(hr);
- }
- }
-*/
return(RD_OK);
-
}
@@ -1024,14 +329,7 @@ int32 SaveScreenShot(uint8 *buffer, uint8 *palette)
}
-
-
-
-
-
-int32 GrabScreenShot(void)
-
-{
+int32 GrabScreenShot(void) {
warning("stub GrabScreenShot");
/*
uint8 *screenGrabBuffer;
@@ -1085,8 +383,7 @@ int32 GrabScreenShot(void)
-int32 NextSmackerFrame(void)
-{
+int32 NextSmackerFrame(void) {
warning("stub NextSmackerFrame");
return(RD_OK);
}
@@ -1094,19 +391,16 @@ int32 NextSmackerFrame(void)
uint32 textSurface = 0;
-void OpenTextObject(_movieTextObject *obj)
-{
+void OpenTextObject(_movieTextObject *obj) {
CreateSurface(obj->textSprite, &textSurface);
}
-void CloseTextObject(_movieTextObject *obj)
-{
+void CloseTextObject(_movieTextObject *obj) {
DeleteSurface(textSurface);
textSurface = 0;
}
-void DrawTextObject(_movieTextObject *obj)
-{
+void DrawTextObject(_movieTextObject *obj) {
warning("stub DrawTextObject");
/*
HRESULT hr;
@@ -1223,15 +517,12 @@ void DrawTextObject(_movieTextObject *obj)
extern uint8 musicMuted;
-int32 PlaySmacker(char *filename, _movieTextObject *text[], uint8 *musicOut)
-{
+int32 PlaySmacker(char *filename, _movieTextObject *text[], uint8 *musicOut) {
warning("stub PlaySmacker %s", filename);
return(RD_OK);
}
-
-
void GetDrawStatus(_drvDrawStatus *s)
{
// s->hwnd = hwnd;
diff --git a/sword2/driver/d_draw.h b/sword2/driver/d_draw.h
index 3c6adad86d..50b4afb82a 100644
--- a/sword2/driver/d_draw.h
+++ b/sword2/driver/d_draw.h
@@ -88,7 +88,6 @@ extern int32 dxHalCaps; // Hardware capabilities.
extern int32 dxHelCaps; // Emulation capabilities.
extern void FatalDirectDrawError(char *str, int32 dderr, char *file, int32 line);
-extern void RestoreSurfaces(void); // Restores direct draw surfaces.
#ifdef __cplusplus
}
diff --git a/sword2/driver/ddutil.h b/sword2/driver/ddutil.h
deleted file mode 100644
index f6976eca15..0000000000
--- a/sword2/driver/ddutil.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/* Copyright (C) 1994-2003 Revolution Software Ltd
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Header$
- */
-
-//-----------------------------------------------------------------------------
-// File: ddutil.cpp
-//
-// Desc: Routines for loading bitmap and palettes from resources
-//
-// Copyright (C) 1998-2001 Microsoft Corporation. All Rights Reserved.
-//-----------------------------------------------------------------------------
-#ifndef DDUTIL_H
-#define DDUTIL_H
-
-#include <ddraw.h>
-#include <d3d.h>
-
-
-
-
-//-----------------------------------------------------------------------------
-// Classes defined in this header file
-//-----------------------------------------------------------------------------
-class CDisplay;
-class CSurface;
-
-
-
-
-//-----------------------------------------------------------------------------
-// Flags for the CDisplay and CSurface methods
-//-----------------------------------------------------------------------------
-#define DSURFACELOCK_READ
-#define DSURFACELOCK_WRITE
-
-
-
-
-//-----------------------------------------------------------------------------
-// Name: class CDisplay
-// Desc: Class to handle all DDraw aspects of a display, including creation of
-// front and back buffers, creating offscreen surfaces and palettes,
-// and blitting surface and displaying bitmaps.
-//-----------------------------------------------------------------------------
-class CDisplay
-{
-protected:
- LPDIRECTDRAW7 m_pDD;
- LPDIRECTDRAWSURFACE7 m_pddsFrontBuffer;
- LPDIRECTDRAWSURFACE7 m_pddsBackBuffer;
- LPDIRECTDRAWSURFACE7 m_pddsBackBufferLeft; // For stereo modes
-
- HWND m_hWnd;
- RECT m_rcWindow;
- BOOL m_bWindowed;
- BOOL m_bStereo;
-
-public:
- CDisplay();
- ~CDisplay();
-
- // Access functions
- HWND GetHWnd() { return m_hWnd; }
- LPDIRECTDRAW7 GetDirectDraw() { return m_pDD; }
- LPDIRECTDRAWSURFACE7 GetFrontBuffer() { return m_pddsFrontBuffer; }
- LPDIRECTDRAWSURFACE7 GetBackBuffer() { return m_pddsBackBuffer; }
- LPDIRECTDRAWSURFACE7 GetBackBufferLeft() { return m_pddsBackBufferLeft; }
-
- // Status functions
- BOOL IsWindowed() { return m_bWindowed; }
- BOOL IsStereo() { return m_bStereo; }
-
- // Creation/destruction methods
- HRESULT CreateFullScreenDisplay( HWND hWnd, DWORD dwWidth, DWORD dwHeight,
- DWORD dwBPP );
- HRESULT CreateWindowedDisplay( HWND hWnd, DWORD dwWidth, DWORD dwHeight );
- HRESULT InitClipper();
- HRESULT UpdateBounds();
- virtual HRESULT DestroyObjects();
-
- // Methods to create child objects
- HRESULT CreateSurface( CSurface** ppSurface, DWORD dwWidth,
- DWORD dwHeight );
- HRESULT CreateSurfaceFromBitmap( CSurface** ppSurface, TCHAR* strBMP,
- DWORD dwDesiredWidth,
- DWORD dwDesiredHeight );
- HRESULT CreateSurfaceFromText( CSurface** ppSurface, HFONT hFont,
- TCHAR* strText,
- COLORREF crBackground,
- COLORREF crForeground );
- HRESULT CreatePaletteFromBitmap( LPDIRECTDRAWPALETTE* ppPalette, const TCHAR* strBMP );
-
- // Display methods
- HRESULT Clear( DWORD dwColor = 0L );
- HRESULT ColorKeyBlt( DWORD x, DWORD y, LPDIRECTDRAWSURFACE7 pdds,
- RECT* prc = NULL );
- HRESULT Blt( DWORD x, DWORD y, LPDIRECTDRAWSURFACE7 pdds,
- RECT* prc=NULL, DWORD dwFlags=0 );
- HRESULT Blt( DWORD x, DWORD y, CSurface* pSurface, RECT* prc = NULL );
- HRESULT ShowBitmap( HBITMAP hbm, LPDIRECTDRAWPALETTE pPalette=NULL );
- HRESULT SetPalette( LPDIRECTDRAWPALETTE pPalette );
- HRESULT Present();
-};
-
-
-
-
-//-----------------------------------------------------------------------------
-// Name: class CSurface
-// Desc: Class to handle aspects of a DirectDrawSurface.
-//-----------------------------------------------------------------------------
-class CSurface
-{
- LPDIRECTDRAWSURFACE7 m_pdds;
- DDSURFACEDESC2 m_ddsd;
- BOOL m_bColorKeyed;
-
-public:
- LPDIRECTDRAWSURFACE7 GetDDrawSurface() { return m_pdds; }
- BOOL IsColorKeyed() { return m_bColorKeyed; }
-
- HRESULT DrawBitmap( HBITMAP hBMP, DWORD dwBMPOriginX = 0, DWORD dwBMPOriginY = 0,
- DWORD dwBMPWidth = 0, DWORD dwBMPHeight = 0 );
- HRESULT DrawBitmap( TCHAR* strBMP, DWORD dwDesiredWidth, DWORD dwDesiredHeight );
- HRESULT DrawText( HFONT hFont, TCHAR* strText, DWORD dwOriginX, DWORD dwOriginY,
- COLORREF crBackground, COLORREF crForeground );
-
- HRESULT SetColorKey( DWORD dwColorKey );
- DWORD ConvertGDIColor( COLORREF dwGDIColor );
- static HRESULT GetBitMaskInfo( DWORD dwBitMask, DWORD* pdwShift, DWORD* pdwBits );
-
- HRESULT Create( LPDIRECTDRAW7 pDD, DDSURFACEDESC2* pddsd );
- HRESULT Create( LPDIRECTDRAWSURFACE7 pdds );
- HRESULT Destroy();
-
- CSurface();
- ~CSurface();
-};
-
-
-
-
-#endif // DDUTIL_H
-
diff --git a/sword2/driver/driver96.h b/sword2/driver/driver96.h
index 73e1984d83..f57ddd660e 100644
--- a/sword2/driver/driver96.h
+++ b/sword2/driver/driver96.h
@@ -303,14 +303,6 @@
//
// ---------------------------------------------------------------------------
//
-// int32 FlipScreens(void)
-//
-// Waits for the vertical retrace and then flips the front and back buffers.
-// If a vertical retrace flag is unavailable, it flips immediately. Returns
-// an RD code.
-//
-// ---------------------------------------------------------------------------
-//
// int32 EraseBackBuffer(void)
//
// Fills the back buffer with palette colour zero. Returns an RD code.
@@ -1478,16 +1470,12 @@ typedef struct {
// Display functions - from d_draw.c
//-----------------------------------------------------------------------------
extern int32 InitialiseDisplay(int16 width, int16 height, int16 colourDepth, int32 windowType);
-extern int32 RestoreDisplay(void);
-extern int32 FlipScreens(void);
extern int32 WaitForVbl(void);
extern int32 EraseBackBuffer(void);
extern int32 SetBltFx(void);
extern int32 ClearBltFx(void);
extern int32 ClearShadowFx(void);
extern int32 SetShadowFx(void);
-extern int32 RenderHard(void);
-extern int32 RenderSoft(void);
extern int32 GetRenderType(void);
extern int32 PlaySmacker(char *filename, _movieTextObject *textObjects[], uint8 *musicOut);
extern void GetDrawStatus(_drvDrawStatus *s);
diff --git a/sword2/driver/rdwin.cpp b/sword2/driver/rdwin.cpp
index 2a3205f61b..156a21e3ab 100644
--- a/sword2/driver/rdwin.cpp
+++ b/sword2/driver/rdwin.cpp
@@ -183,7 +183,6 @@ void Sword2State::parseEvents() {
break;
case OSystem::EVENT_QUIT:
Close_game();
- RestoreDisplay();
CloseAppWindow();
break;
default:
diff --git a/sword2/driver/render.cpp b/sword2/driver/render.cpp
index 2c441f88c9..0d21d30b18 100644
--- a/sword2/driver/render.cpp
+++ b/sword2/driver/render.cpp
@@ -366,7 +366,6 @@ int32 RestoreBackgroundLayer(_parallax *p, int16 l)
free(blockSurfaces[l]);
blockSurfaces[l] = NULL;
}
- RestoreSurfaces();
InitialiseBackgroundLayer(p);
layer = oldLayer;
@@ -383,7 +382,6 @@ int32 RestoreBackgroundLayer(_parallax *p, int16 l)
free(blockSurfaces[l]);
blockSurfaces[l] = NULL;
}
- RestoreSurfaces();
InitialiseBackgroundLayer(p);
layer = oldLayer;
*/
@@ -419,7 +417,6 @@ int32 PlotPoint(uint16 x, uint16 y, uint8 colour)
hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr != DD_OK)
{
- RestoreSurfaces();
hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
}
@@ -467,7 +464,6 @@ int32 DrawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour)
hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr != DD_OK)
{
- RestoreSurfaces();
hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
}
if (hr != DD_OK)
@@ -697,7 +693,7 @@ int32 RenderParallax(_parallax *p, int16 l) {
int16 i, j;
ScummVM::Rect r;
- debug(0, "RenderParallax %d", l);
+ debug(9, "RenderParallax %d", l);
if (locationWide == screenWide)
x = 0;
@@ -733,251 +729,7 @@ int32 RenderParallax(_parallax *p, int16 l) {
parallaxScrollx = scrollx - x;
parallaxScrolly = scrolly - y;
-/*
-
-#if PROFILING == 1
-
- long int startTime, endTime;
-
- QueryPerformanceCounter(&startTime);
-
-#endif
-
- if ((renderCaps & RDBLTFX_ALLHARDWARE) || ((renderCaps & RDBLTFX_FGPARALLAX) && (l > 2)))
- {
-
- int16 x, y;
- int16 i, j;
- int16 restoreSurfaces = 0;
- HRESULT hr = 0;
- RECT r, rd;
-
- if (restoreLayer[l])
- {
- RestoreBackgroundLayer(p, l);
- restoreLayer[l] = 0;
- }
-
- if (locationWide == screenWide)
- x = 0;
- else
- x = ((int32) ((p->w - screenWide) * scrollx) / (int32) (locationWide - screenWide));
-
- if (locationDeep == (screenDeep - MENUDEEP*2))
- y = 0;
- else
- y = ((int32) ((p->h - (screenDeep - MENUDEEP*2)) * scrolly) / (int32) (locationDeep - (screenDeep - MENUDEEP*2)));
-
-
- while (TRUE)
- {
- j = 0;
- while (j < yblocks[l])
- {
- i = 0;
- while (i < xblocks[l])
- {
- if (*(blockSurfaces[l] + i + j * xblocks[l]))
- {
- r.left = i * BLOCKWIDTH - x;
- r.right = r.left + BLOCKWIDTH;
- r.top = j * BLOCKHEIGHT - y + 40;
- r.bottom = r.top + BLOCKHEIGHT;
- rd.left = 0;
- rd.right = BLOCKWIDTH;
- rd.top = 0;
- rd.bottom = BLOCKHEIGHT;
-
- if ((r.left < 0) && (r.left > 0 - BLOCKWIDTH))
- {
- rd.left = 0 - r.left;
- r.left = 0;
- }
- if ((r.top < 40) && (r.top > 40 - BLOCKHEIGHT))
- {
- rd.top = 40 - r.top;
- r.top = 40;
- }
- if ((r.right > 640) && (r.right < 640 + BLOCKWIDTH))
- {
- rd.right = BLOCKWIDTH - (r.right - 640);
- r.right = 640;
- }
- if ((r.bottom > 440) && (r.bottom < 440 + BLOCKHEIGHT))
- {
- rd.bottom = BLOCKHEIGHT - (r.bottom - 440);
- r.bottom = 440;
- }
- hr = IDirectDrawSurface2_Blt(lpBackBuffer, &r, *(blockSurfaces[l] + i + j * xblocks[l]), &rd, DDBLT_WAIT | DDBLT_KEYSRC, NULL);
- if (hr == DDERR_INVALIDRECT)
- hr = 0;
- if (hr)
- break;
- }
- i++;
- if (hr)
- break;
- }
- j++;
- if (hr)
- break;
- }
- if (hr)
- {
- if (hr == DDERR_SURFACELOST)
- {
- if (gotTheFocus)
- {
- if (++restoreSurfaces == 4)
- return(RDERR_RESTORELAYERS);
- else
- RestoreBackgroundLayer(p, l);
- }
- else
- return(RD_OK);
- }
- else
- return(hr);
-
- }
- else
- break;
- }
-
- parallaxScrollx = scrollx - x;
- parallaxScrolly = scrolly - y;
- }
- else
- {
- uint8 zeros;
- uint16 count;
- uint16 skip;
- uint16 i, j;
- uint16 x;
- int32 px, py;
- uint8 *data;
- uint8 *dst;
- _parallaxLine *line;
-
- if (locationWide == screenWide)
- px = 0;
- else
- px = ( (int32) ((p->w - screenWide) * scrollx) / (int32) (locationWide - screenWide));
-
- if (locationDeep == (screenDeep - MENUDEEP*2))
- py = 0;
- else
- py = ( (int32) ((p->h - (screenDeep - MENUDEEP*2)) * scrolly) / (int32) (locationDeep - (screenDeep - MENUDEEP*2)));
-
-
- for (i = py; i < py + (screenDeep - MENUDEEP * 2); i++)
- {
- if (p->offset[i] == 0)
- continue;
-
- line = (_parallaxLine *) ((uint8 *) p + p->offset[i]);
- data = (uint8 *) line + sizeof(_parallaxLine);
- x = line->offset;
- if (x > px)
- skip = x - px;
- else
- skip = 0;
-
- dst = myScreenBuffer + (i - py) * RENDERWIDE + skip;
-
-
- zeros = 0;
- if (line->packets == 0)
- {
- data += px;
- memcpy(dst, data, screenWide);
- continue;
- }
-
- for (j=0; j<line->packets; j++)
- {
- if (zeros)
- {
- if (x >= px)
- {
- dst += *data;
- x += *data;
- }
- else
- {
- x += *data;
- if (x > px)
- {
- dst += (x - px);
- }
- }
- data += 1;
- zeros = 0;
- }
- else
- {
- if (*data == 0)
- {
- data ++;
- }
- else if (x >= px)
- {
- if (x + *data <= px + screenWide)
- {
- count = *data++;
- memcpy(dst, data, count);
- data += count;
- dst += count;
- x += count;
- }
- else if (x < px + screenWide)
- {
- data++;
- count = screenWide - (x - px);
- memcpy(dst, data, count);
- j = line->packets;
- }
- }
- else
- {
- count = *data++;
-
- if (x + count > px)
- {
- skip = px - x;
- data += skip;
- count -= skip;
- memcpy(dst, data, count);
- data += count;
- dst += count;
- x += count + skip;
- }
- else
- {
- data += count;
- x += count;
- if (x > px)
- {
- dst += (x - px);
- }
- }
- }
- zeros = 1;
- }
- }
- }
-
- parallaxScrollx = scrollx - px;
- parallaxScrolly = scrolly - py;
- }
-
-#if PROFILING == 1
- QueryPerformanceCounter(&endTime);
- profileRenderLayers += (endTime.LowPart - startTime.LowPart);
-#endif
-*/
return(RD_OK);
-
}
@@ -1120,7 +872,7 @@ int32 SetScrollTarget(int16 sx, int16 sy)
int32 CopyScreenBuffer(void)
{
- debug(0, "CopyScreenBuffer");
+ debug(9, "CopyScreenBuffer");
// FIXME: The backend should keep track of dirty rects, but I have a
// feeling each one may be drawn several times, so we may have do add
@@ -1154,7 +906,6 @@ int32 CopyScreenBuffer(void)
hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddDescription, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr != DD_OK)
{
- RestoreSurfaces();
hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddDescription, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
}
if (hr == DD_OK)
@@ -1340,7 +1091,6 @@ bailout:
if (layer == MAXLAYERS)
{
CloseBackgroundLayer();
- // RestoreSurfaces(); // for the primary and back buffer.
}
diff --git a/sword2/driver/sprite.cpp b/sword2/driver/sprite.cpp
index cfb2fe9097..b4fab6a562 100644
--- a/sword2/driver/sprite.cpp
+++ b/sword2/driver/sprite.cpp
@@ -258,15 +258,7 @@
-#define WIN32_LEAN_AND_MEAN
-
-//#include <windows.h>
-//#include <windowsx.h>
#include <stdio.h>
-//#include <mmsystem.h>
-
-//#include "ddraw.h"
-
#include "stdafx.h"
#include "driver96.h"
#include "d_draw.h"
@@ -1812,7 +1804,6 @@ int32 DrawSprite(_spriteInfo *s)
hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr != DD_OK)
{
- RestoreSurfaces();
hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
}
if (hr == DD_OK)
diff --git a/sword2/function.cpp b/sword2/function.cpp
index aa9720be3b..d0668c57d5 100644
--- a/sword2/function.cpp
+++ b/sword2/function.cpp
@@ -446,7 +446,6 @@ int32 FN_play_credits(int32 *params)
if (rv || DEMO) // if Ctrl-Q pressed during credits, or if this is the playable demo
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); // quit the game
}
diff --git a/sword2/logic.cpp b/sword2/logic.cpp
index 9b8f790557..d2285b7b8a 100644
--- a/sword2/logic.cpp
+++ b/sword2/logic.cpp
@@ -323,7 +323,6 @@ uint32 logic::Examine_run_list(void) //Tony25Oct96
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
diff --git a/sword2/mem_view.cpp b/sword2/mem_view.cpp
index 40c3193989..7930ae6fcd 100644
--- a/sword2/mem_view.cpp
+++ b/sword2/mem_view.cpp
@@ -139,7 +139,6 @@ void Console_mem_display(void) //Tony13Aug96
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
diff --git a/sword2/mouse.cpp b/sword2/mouse.cpp
index 0a107940c8..fb528aa877 100644
--- a/sword2/mouse.cpp
+++ b/sword2/mouse.cpp
@@ -253,7 +253,6 @@ void System_menu(void) //Tony19Mar97
EraseBackBuffer();
ProcessMenu(); // drivers to redraw menu over this blank screen!
- FlipScreens();
ResetRenderEngine();
//------------------------
@@ -295,7 +294,6 @@ void System_menu(void) //Tony19Mar97
EraseBackBuffer();
ProcessMenu(); // drivers to redraw menu over this blank screen!
- FlipScreens();
//------------------------
// reset game palette, but not after a successful restore or restart!
diff --git a/sword2/resman.cpp b/sword2/resman.cpp
index 20350b7325..121dca1ed3 100644
--- a/sword2/resman.cpp
+++ b/sword2/resman.cpp
@@ -862,7 +862,6 @@ void resMan::Kill_all_res(uint8 wantInfo) //Tony29Nov96
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -953,7 +952,6 @@ void resMan::Kill_all_objects(uint8 wantInfo) // James17jan97
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -1054,7 +1052,6 @@ void resMan::CacheNewCluster(uint32 newCluster)
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -1074,7 +1071,6 @@ void resMan::CacheNewCluster(uint32 newCluster)
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -1084,13 +1080,7 @@ void resMan::CacheNewCluster(uint32 newCluster)
}
-//get rid of top menu flash (tony 26Aug97)
EraseBackBuffer();
- FlipScreens();
- EraseBackBuffer();
- FlipScreens();
-
-
Set_mouse(0);
Set_luggage(0); //tw28Aug
@@ -1182,8 +1172,6 @@ void resMan::CacheNewCluster(uint32 newCluster)
textSprite.y = textY;
CopyScreenBuffer();
- FlipScreens();
-
FadeUp((float)0.75);
do
@@ -1194,7 +1182,6 @@ void resMan::CacheNewCluster(uint32 newCluster)
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -1243,8 +1230,6 @@ void resMan::CacheNewCluster(uint32 newCluster)
textSprite.y = textY;
CopyScreenBuffer();
- FlipScreens();
-
fr += 1;
}
else
@@ -1257,7 +1242,6 @@ void resMan::CacheNewCluster(uint32 newCluster)
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -1288,7 +1272,6 @@ void resMan::CacheNewCluster(uint32 newCluster)
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -1297,7 +1280,6 @@ void resMan::CacheNewCluster(uint32 newCluster)
while(GetFadeStatus()==RDFADE_DOWN);
CopyScreenBuffer();
- FlipScreens();
FadeUp((float)0.75);
SVM_SetFileAttributes(resource_files[newCluster], FILE_ATTRIBUTE_NORMAL); // Git rid of read-only status.
@@ -1498,7 +1480,6 @@ void resMan::GetCd(int cd)
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
@@ -1517,7 +1498,6 @@ void resMan::GetCd(int cd)
spriteInfo.y = oldY; // Drivers change the y co-ordinate, don't know why...
spriteInfo.x = oldX;
CopyScreenBuffer();
- FlipScreens();
}
} while (!done);
diff --git a/sword2/router.cpp b/sword2/router.cpp
index 04c0acdd57..6982c3d92f 100644
--- a/sword2/router.cpp
+++ b/sword2/router.cpp
@@ -499,7 +499,6 @@ int32 RouteFinder(Object_mega *ob_mega, Object_walkdata *ob_walkdata, int32 x, i
#else
RenderOffScreenBuffer( scroll_offset_x, scroll_offset_y, SCREEN_WIDTH, SCREEN_DEPTH );
#endif
- FlipScreens();
FlushMouseEvents(); // clear mouse buffer
while (!TestForMouseEvent()); // wait for a button press or release
diff --git a/sword2/startup.cpp b/sword2/startup.cpp
index 8ab80e0225..43056a1f53 100644
--- a/sword2/startup.cpp
+++ b/sword2/startup.cpp
@@ -222,7 +222,6 @@ uint32 Con_print_start_menu(void) //Tony14Oct96
if (ServiceWindows() == RDERR_APPCLOSED) // if we pressed Ctrl-Q
{
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
exit(0); //quit the game
}
diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp
index f3ce0d515d..38784d6c82 100644
--- a/sword2/sword2.cpp
+++ b/sword2/sword2.cpp
@@ -189,11 +189,7 @@ int32 Sword2State::InitialiseGame(void)
void Close_game() //Tony11Oct96
{
Zdebug("Close_game() STARTING:");
-//avoid corruption when windows kicks back in
EraseBackBuffer();
- FlipScreens();
- EraseBackBuffer();
- FlipScreens();
Kill_music(); // Stop music instantly! (James22aug97)
Close_memory_manager(); // free the memory again
@@ -315,7 +311,6 @@ void Sword2State::go()
if (InitialiseGame())
{
Zdebug("RETURNED from InitialiseGame - closing game");
- RestoreDisplay();
CloseAppWindow();
return;
}
@@ -459,7 +454,6 @@ void Sword2State::go()
}
Close_game(); //close engine systems down
- RestoreDisplay();
CloseAppWindow();
return; //quit the game