From 95a59bd049928dd4eddda8476920e3155e6c2c1d Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 23 Sep 2003 16:38:38 +0000 Subject: Must ... make ... space ... for ... FotAQ ... svn-id: r10383 --- sword2/debug.cpp | 7 +- sword2/driver/d_draw.cpp | 9 +- sword2/driver/d_draw.h | 6 - sword2/driver/driver96.h | 81 +------- sword2/driver/rdwin.cpp | 475 +---------------------------------------------- sword2/sword2.cpp | 15 -- 6 files changed, 6 insertions(+), 587 deletions(-) (limited to 'sword2') diff --git a/sword2/debug.cpp b/sword2/debug.cpp index 8e4f370ab8..1973c14268 100644 --- a/sword2/debug.cpp +++ b/sword2/debug.cpp @@ -105,12 +105,7 @@ void ExitWithReport(const char *format,...) // (6dec96 JEL) // wait for fade to finish before calling RestoreDisplay() WaitForFade(); - ReportFatalError((const uint8 *)buf); // display message box - CloseAppWindow(); - // This looks like a bad idea, since our ServiceWindows() never - // returns RDERR_APPCLOSED. - // while (ServiceWindows() != RDERR_APPCLOSED); - exit(0); + error(buf); } #ifdef _SWORD2_DEBUG // all other functions only for _SWORD2_DEBUG version diff --git a/sword2/driver/d_draw.cpp b/sword2/driver/d_draw.cpp index a56e764114..6e69f322c8 100644 --- a/sword2/driver/d_draw.cpp +++ b/sword2/driver/d_draw.cpp @@ -31,18 +31,15 @@ #include "palette.h" #include "render.h" -#define SCREENYOFFSET 40 -#define MILLISECSPERCYCLE 83 - byte *lpBackBuffer; // Game screen metrics -int16 screenDeep; -int16 screenWide; +int16 screenDeep; +int16 screenWide; // Set to 1 if vertical blank status cannot be checked. -BOOL bFullScreen = 0; +// BOOL bFullScreen = 0; diff --git a/sword2/driver/d_draw.h b/sword2/driver/d_draw.h index 4cc1fe927e..b3f4d04a04 100644 --- a/sword2/driver/d_draw.h +++ b/sword2/driver/d_draw.h @@ -68,7 +68,6 @@ extern "C" { #endif -//#include "ddraw.h" #include "driver96.h" // Bits defining hardware and emulation capabilities. @@ -79,11 +78,6 @@ extern "C" { extern uint8 *lpPalette; // palette extern byte *lpBackBuffer; // back surface -// extern Surface *lpPrimarySurface; // DirectDraw front buffer. -extern uint8 *lpDD2; // DirectDraw2 object -extern BOOL bFullScreen; // Defines whether the app is running in full screen mode or not. -//extern DDCOLORKEY blackColorKey; // transparent pixel for color key blitting. -extern uint8 blackColorKey; // transparent pixel for color key blitting. extern int32 dxHalCaps; // Hardware capabilities. extern int32 dxHelCaps; // Emulation capabilities. diff --git a/sword2/driver/driver96.h b/sword2/driver/driver96.h index 315d0d8fd3..a0a3d15e5c 100644 --- a/sword2/driver/driver96.h +++ b/sword2/driver/driver96.h @@ -354,28 +354,9 @@ // // Plays the smacker file, filename. // -// --------------------------------------------------------------------------- -// -// void GetDrawStatus(_drvStatus *s) -// -// Retrieves the value of the driver's drawing globals and stores them in s. -// -// --------------------------------------------------------------------------- -// -// void SetDrawStatus(_drvStatus *s) -// -// Set the value of the driver's drawing globals from s. -// // --------------------------- rdwin.c --------------------------------------- // --------------------------------------------------------------------------- // -// int32 InitialiseWindow(HWND hWnd) -// -// Creates a window! This must be the first operation in creating the -// Windows 95 version. -// -// --------------------------------------------------------------------------- -// // int32 ServiceWindows(void) // // This function should be called at a high rate ( > 20 per second) to service @@ -389,20 +370,6 @@ // // --------------------------------------------------------------------------- // -// int32 ReportDriverError(int32 error) -// -// Creates a message box and displays the error code passed to it, as well as -// the filename and line that the function was called from -// -// --------------------------------------------------------------------------- -// -// int32 ReportFatalError(const uint8 *error) -// -// Creates a message box and displays the error string passed in, as well as -// the filename and line that the function was called from -// -// --------------------------------------------------------------------------- -// // void SetWindowName(const char *windowName) // // Set the window name to windowName and stores this name in gameName for future @@ -530,19 +497,13 @@ // // -------------------------------------------------------------------------- // -// int32 ReadKey(char *key) +// int32 ReadKey(_keyboardEvent *key) // // Sets the value of key passed in to the current waiting key. If there is // no key waiting, an error code is returned. // // // -------------------------------------------------------------------------- -// -// void GetKeyStatus(_drvKeyStatus *) -// -// Retrieves the address of the keyboard buffer bits. -// -// -------------------------------------------------------------------------- // ------------------------------- sprite.c --------------------------------- // -------------------------------------------------------------------------- // @@ -888,18 +849,6 @@ // // --------------------------------------------------------------------------- // -// void GetSoundStatus(_drvStatus *s) -// -// Retrieves the value of the driver's audio globals and stores them in s. -// -// --------------------------------------------------------------------------- -// -// void SetSoundStatus(_drvStatus *s) -// -// Set the value of the driver's audio globals from s. -// -// --------------------------------------------------------------------------- -// // void SetMusicVolume(uint8 vol) // // Set the volume of any future as well as playing (but not fading) music to @@ -1328,12 +1277,8 @@ extern int32 PlaySmacker(char *filename, _movieTextObject *textObjects[], uint8 //----------------------------------------------------------------------------- // Windows OS functions - from rdwin.c //----------------------------------------------------------------------------- -//extern int32 InitialiseWindow(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow, char *gameName); extern int32 CloseAppWindow(void); extern int32 ServiceWindows(void); -extern int32 _ReportDriverError(int32 error, const uint8 *filename, uint32 line); -extern int32 _ReportFatalError(const uint8 *error, const uint8 *filename, uint32 line); -extern int32 DisableQuitKey(void); extern void SetWindowName(const char *windowName); //----------------------------------------------------------------------------- @@ -1425,33 +1370,9 @@ extern int32 SVM_GetVolumeInformation(char *cdPath, char *sCDName, uint32 maxPat extern void scumm_mkdir(const char *pathname); extern void SVM_GetModuleFileName(void *module, char *destStr, uint32 maxLen); -//----------------------------------------------------------------------------- -//Macro for calling error handler with source filename and line. -//----------------------------------------------------------------------------- -#define ReportDriverError(f) _ReportDriverError(f, (const uint8 *) __FILE__, (uint32) __LINE__) -#define ReportFatalError(f) _ReportFatalError(f, (const uint8 *) __FILE__, (uint32) __LINE__) -//----------------------------------------------------------------------------- - - - -//----------------------------------------------------------------------------- -// Macro for reporting a non-fatal driver error -//----------------------------------------------------------------------------- -#ifdef _SWORD2_DEBUG -static int32 rderror; -#define Driver(f) \ - if (rderror = f) \ - ReportDriverError(rderror) -#else -#define Driver(f) f -#endif -//----------------------------------------------------------------------------- - - //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -extern BOOL gotTheFocus; // set if the game is currently displayed extern int16 screenWide; // Width of the screen display extern int16 screenDeep; // Height of the screen display extern int16 mousex; // Mouse screen x coordinate diff --git a/sword2/driver/rdwin.cpp b/sword2/driver/rdwin.cpp index 55f87608d6..2450ee8144 100644 --- a/sword2/driver/rdwin.cpp +++ b/sword2/driver/rdwin.cpp @@ -38,23 +38,6 @@ -//static BOOL bMouseVisible = FALSE; -//static BOOL controlKey = FALSE; -//static BOOL altKey = FALSE; -//static BOOL wasScreenSaverActive = FALSE; -//static BOOL myAppClosed = FALSE; -static BOOL controlQDisabled = FALSE; -//static uint8 gameName[80]; - - -//BOOL gotTheFocus = FALSE; -//assume we always have focus for the time being - khalek -BOOL gotTheFocus = TRUE; -//HWND hwnd; -//RECT rcWindow; - - - //----------------------------------------------------------------------------- void Zdebug(const char *format,...) { @@ -86,61 +69,6 @@ void Zdebug(const char *format,...) { #endif } -/* -void Zdebug(char *format,...) //Tony's special debug logging file March96 -{ - warning("stub Zdebug"); -// Write a printf type string to a debug file - - va_list arg_ptr; // Variable argument pointer - FILE * debug_filep=0; // Debug file pointer - static int first_debug = 1; // Flag for first time this is used - - va_start(arg_ptr,format); - - if (first_debug) //First time round delete any previous debug file - { - unlink("debug.txt"); - first_debug = 0; - } - - debug_filep = fopen("debug.txt","a+t"); - - if (debug_filep != NULL) // if it could be opened - { - vfprintf(debug_filep, format, arg_ptr); - fprintf(debug_filep,"\n"); - - fclose(debug_filep); - } -} -*/ -//----------------------------------------------------------------------------- - -/* -void Message(LPSTR fmt, ...) -{ - char buff[256]; - va_list va; - - - va_start(va, fmt); - - // - // format message with header - // - lstrcpy( buff, "DRIVER96:" ); - wvsprintf( &buff[lstrlen(buff)], fmt, va ); - lstrcat( buff, "\r\n" ); - - // - // To the debugger - // - OutputDebugString( buff ); - -} -*/ - //----------------------------------------------------------------------------- // OSystem Event Handler. Full of cross platform goodness and 99% fat free! //----------------------------------------------------------------------------- @@ -180,340 +108,6 @@ void Sword2State::parseEvents() { } -//----------------------------------------------------------------------------- -// Windows Message Handler. All keyboard and mouse input is handled here. -//----------------------------------------------------------------------------- -/* -long FAR PASCAL WindowsMessageHandler(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) -{ - - switch( message ) - { - - - case WM_TIMER: - switch (wParam) - { - case 25: - FadeServer(); - return(0); - case 1: - FxServer(); - return(0); - } - break; - - - case WM_CLOSE: - Zdebug("WM_CLOSE"); - break; - - case WM_SIZE: - case WM_MOVE: - if (IsIconic(hwnd)) - { - Message("minimising"); -// PauseGame(); - } - - if (bFullScreen) - { - SetRect(&rcWindow, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); - } - else - { - GetClientRect(hwnd, &rcWindow); - ClientToScreen(hwnd, (LPPOINT)&rcWindow); - ClientToScreen(hwnd, (LPPOINT)&rcWindow+1); - } - Message("WINDOW RECT: [%d,%d,%d,%d]", rcWindow.left, rcWindow.top, rcWindow.right, rcWindow.bottom); - if (bFullScreen) - { - SetCapture(hwnd); - } - else - { - ReleaseCapture(); - } -// SetCursor(NULL); -// ShowCursor(FALSE); - break; - - - - case WM_ACTIVATEAPP: - gotTheFocus = wParam; - if (gotTheFocus) - { - Message("Got the focus"); - bMouseVisible = FALSE; - Message("Mouse invisible"); - ShowCursor(FALSE); - } - else - { - if (bMouseVisible == FALSE) - ShowCursor(TRUE); - Message("Lost the focus"); - bMouseVisible = TRUE; - Message("Mouse visible"); - } - break; - - - case WM_SYSKEYUP: - switch( wParam ) - { - -// int32 rv; - - // handle ALT+ENTER (fullscreen) - case VK_RETURN: - break; - } - break; - - - case WM_DISPLAYCHANGE: - break; - - case WM_CREATE: - SystemParametersInfo(SPI_GETSCREENSAVEACTIVE , 0 , &wasScreenSaverActive , 0); - if (wasScreenSaverActive) - { - SystemParametersInfo(SPI_SETSCREENSAVEACTIVE , FALSE , 0 , 0 ); - } - break; - - - case WM_QUERYNEWPALETTE: - // - // we are getting the palette focus, select our palette - // - if (!bFullScreen && lpPalette && lpPrimarySurface) - { - int32 hr; - - hr = IDirectDrawSurface_BS2_SetPalette(lpPrimarySurface, lpPalette); - if (hr == DDERR_SURFACELOST) - { - IDirectDrawSurface_Restore(lpPrimarySurface); - - hr= IDirectDrawSurface_BS2_SetPalette(lpPrimarySurface, lpPalette); - if(hr == DDERR_SURFACELOST) - { - Message("Failed to restore palette after second try"); - } - } - - // - // Restore normal title if palette is ours - // - if(hr == DD_OK) - { - SetWindowText(hwnd, gameName); - } - } - break; - - case WM_PALETTECHANGED: - // - // if another app changed the palette we dont have full control - // of the palette. NOTE this only applies for FoxBear in a window - // when we are fullscreen we get all the palette all of the time. - // - if ((HWND)wParam != hwnd) - { - if( !bFullScreen ) - { - Message("Lost palette but continuing"); - } - } - break; - - -// case WM_SETCURSOR: -// if (bMouseVisible) -// SetCursor(LoadCursor(NULL, IDC_ARROW)); -// else -// SetCursor(NULL); -// return TRUE; -// break; - - case WM_CHAR: - if (lParam & (1 << 30)) - return(0); - WriteKey((char) (wParam & 0xff)); - return(0); - - case WM_KEYDOWN: - - Zdebug("key %d", wParam); - - switch( wParam ) - { - case VK_CONTROL: - controlKey = TRUE; - break; - -// case VK_ALT: -// altKey = TRUE; -// break; - - case 'W': - if (controlKey) - GrabScreenShot(); - return 0; - - case 'Q': - if (controlKey && !controlQDisabled) - DestroyWindow( hWnd ); - return 0; - - case 'F4': - DestroyWindow( hWnd ); - return 0; - - } - break; - - - case WM_KEYUP: - switch(wParam) - { - case VK_CONTROL: - controlKey = FALSE; - break; - -// case VK_ALT: -// altKey = FALSE; -// break; - - } - break; - - - case WM_DESTROY: - Zdebug("*destroy*"); - - if (wasScreenSaverActive) - SystemParametersInfo(SPI_SETSCREENSAVEACTIVE , TRUE , 0 , 0 ); - PostQuitMessage( 0 ); - break; - - - case WM_MOUSEMOVE: - mousex = lParam & 0xffff; - - if (bFullScreen) - { - mousey = (uint16) (lParam >> 16) - MENUDEEP; - } - else - { - mousey = (uint16) (lParam >> 16) - MENUDEEP; - - if (mousex < 0) - mousex = 0; - if (mousex >= RENDERWIDE) - mousex = RENDERWIDE-1; - } - - if (mousey < -MENUDEEP) - mousey = -MENUDEEP; - if (mousey >= RENDERDEEP + MENUDEEP) - mousey = RENDERDEEP + MENUDEEP - 1; - - return(0); - - case WM_LBUTTONDOWN: - LogMouseEvent(RD_LEFTBUTTONDOWN); - return(0); - - case WM_LBUTTONUP: - LogMouseEvent(RD_LEFTBUTTONUP); - return(0); - - case WM_RBUTTONDOWN: - LogMouseEvent(RD_RIGHTBUTTONDOWN); - return(0); - - case WM_RBUTTONUP: - LogMouseEvent(RD_RIGHTBUTTONUP); - return(0); - - case WM_LBUTTONDBLCLK: - LogMouseEvent(RD_LEFTBUTTONDOWN); - return(0); - - case WM_RBUTTONDBLCLK: - LogMouseEvent(RD_RIGHTBUTTONDOWN); - - - case WM_SYSCOMMAND: - if (gotTheFocus) - return(0); - - - - - } - - return DefWindowProc(hWnd, message, wParam, lParam); - -} -*/ - - -/* -int32 InitialiseWindow(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow, char *gameName) - -{ - - WNDCLASS wc; -// uint32 err; - - -// hPrevInstance = hPrevInstance; - wc.style = CS_DBLCLKS; - wc.lpfnWndProc = WindowsMessageHandler; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon( hInstance, "resourc1"); //IDI_APPLICATION ); - wc.hCursor = LoadCursor( NULL, IDC_ARROW ); - wc.hbrBackground = GetStockObject(BLACK_BRUSH); - - wc.lpszMenuName = gameName; - wc.lpszClassName = gameName; - - RegisterClass( &wc ); - - // Create a window - hwnd = CreateWindowEx(WS_EX_APPWINDOW, gameName, gameName, WS_VISIBLE | WS_SYSMENU | WS_POPUP, 0, 0, - GetSystemMetrics( SM_CXSCREEN ), GetSystemMetrics( SM_CYSCREEN ), - NULL, NULL, hInstance, NULL ); - - if(!hwnd) - { - MessageBox(hwnd, "Failed to create window", gameName, MB_OK ); - DestroyWindow(hwnd); - return(RDERR_CREATEWINDOW); - } - -// ShowWindow(hwnd, nCmdShow); - UpdateWindow(hwnd); - SetFocus(hwnd); - - SetTimer(hwnd, 25, 1000 / 25, NULL); - SetTimer(hwnd, 1, 100, NULL); - - return(RD_OK); - -} -*/ - - int32 CloseAppWindow(void) { @@ -551,75 +145,8 @@ int32 ServiceWindows(void) // We still need to update because of fades, menu animations, etc. g_system->update_screen(); -// warning("stub ServiceWindows"); // too noisy -/* - MSG msg; - - if (myAppClosed) - return(RDERR_APPCLOSED); - - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) - { - if (!GetMessage(&msg, NULL, 0, 0)) - { - myAppClosed = TRUE; - return(RDERR_APPCLOSED); - } - - TranslateMessage(&msg); - DispatchMessage(&msg); - } -*/ - return(RD_OK); - -} - - - - -int32 _ReportDriverError(int32 error, const uint8 *filename, uint32 line) - -{ - warning("stub _ReportDriverError 0x%.8x file: %s, line: %d ", error, (const char *) filename, line); -/* - - char errorText[128]; - char name[80]; + return RD_OK; - - GetGameName(name); - sprintf(errorText, "Fatal error in %s, line %u! Code 0x%.8x", filename, line, error); - MessageBox(hwnd, errorText, name, MB_SYSTEMMODAL | MB_ICONHAND | MB_ABORTRETRYIGNORE); -*/ - return(RD_OK); - -} - - - -int32 _ReportFatalError(const uint8 *error, const uint8 *filename, uint32 line) - -{ - - warning("stub _ReportFatalError"); - char errorText[500]; - char name[80]; - - - GetGameName((uint8 *)name); - sprintf(errorText, "FATAL ERROR - GAME TERMINATED\n%s", error); - //MessageBox(hwnd, errorText, name, MB_SYSTEMMODAL | MB_ICONHAND | MB_ABORTRETRYIGNORE); - warning("%s", errorText); - - return(RD_OK); - -} - - -int32 DisableQuitKey(void) -{ - controlQDisabled = TRUE; - return(RD_OK); } void SetWindowName(const char *windowName) diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index e18193fe9e..0366434042 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -263,11 +263,6 @@ void Sword2State::go() { // Zdebug("[%s]", lpCmdLine); -#ifndef _SWORD2_DEBUG - // so cannot use Ctrl-Q from the release versions (full game or demo) - DisableQuitKey(); -#endif - // Call the application "Revolution" until the resource manager is // ready to dig the name out of a text file. See InitialiseGame() // which calls InitialiseFontResourceFlags() in maketext.cpp @@ -276,16 +271,6 @@ void Sword2State::go() { // manager until a window has been created as any errors are displayed // via a window, thus time becomes a loop. - // Zdebug("CALLING: InitialiseWindow"); - // rv = InitialiseWindow(hInstance, hPrevInstance, lpCmdLine, nCmdShow, "Revolution"); - rv = RD_OK; - // Zdebug("RETURNED with rv = %.8x", rv); - - if (rv != RD_OK) { - // ReportDriverError(rv); - return; - } - // Override global scaler with any game-specific define if (g_config->get("gfx_mode")) { prop.gfx_mode = _detector->parseGraphicsMode(g_config->get("gfx_mode")); -- cgit v1.2.3