[Scummvm-cvs-logs] CVS: scummvm/bs2/driver .cvsignore,NONE,1.1 _console.cpp,NONE,1.1 _console.h,NONE,1.1 _mouse.cpp,NONE,1.1 _mouse.h,NONE,1.1 d_draw.cpp,NONE,1.1 d_draw.h,NONE,1.1 d_sound.cpp,NONE,1.1 d_sound.h,NONE,1.1 ddutil.h,NONE,1.1 driver96.h,NONE,1.1 keyboard.cpp,NONE,1.1 keyboard.h,NONE,1.1 language.cpp,NONE,1.1 menu.cpp,NONE,1.1 menu.h,NONE,1.1 misc.cpp,NONE,1.1 palette.cpp,NONE,1.1 palette.h,NONE,1.1 rdwin.cpp,NONE,1.1 rdwin.h,NONE,1.1 render.cpp,NONE,1.1 render.h,NONE,1.1 sprite.cpp,NONE,1.1
Jonathan Gray
khalek at users.sourceforge.net
Sun Jul 27 18:48:11 CEST 2003
Update of /cvsroot/scummvm/scummvm/bs2/driver
In directory sc8-pr-cvs1:/tmp/cvs-serv2590
Added Files:
.cvsignore _console.cpp _console.h _mouse.cpp _mouse.h
d_draw.cpp d_draw.h d_sound.cpp d_sound.h ddutil.h driver96.h
keyboard.cpp keyboard.h language.cpp menu.cpp menu.h misc.cpp
palette.cpp palette.h rdwin.cpp rdwin.h render.cpp render.h
sprite.cpp
Log Message:
bs2 driver
--- NEW FILE: .cvsignore ---
.deps
--- NEW FILE: _console.cpp ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/_console.cpp,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
//=============================================================================
//
// Filename : console.c
// Created : 19th September 1996
// By : P.R.Porter
//
// Summary : This module holds the code which controls and displays
// the console/debugging window.
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 20-Sep-96 PRP Inital console code. Currently draws the
// background of the console window. Tex
//
//
// Functions
// ---------
//
// --------------------------------------------------------------------------
//
// int32 OpenConsole(void)
//
// Displays the console window and directs keyboard input to it.
//
// --------------------------------------------------------------------------
//
// int32 CloseConsole(void)
//
// Removes the console from the display.
//
//=============================================================================
#define WIN32_LEAN_AND_MEAN
//#include <windows.h>
//#include <windowsx.h>
//#include "ddraw.h"
#include "driver96.h"
#include "d_draw.h"
uint8 consoleStatus = 0; // 1 - console display
static uint16 consoley = 0;
static uint32 consoleSize;
static uint8 *consoleSprite = NULL;
// --------------------------------------------------------------------------
// Called before the screens are flipped, so that the console can be drawn
// over the screen if necessary.
// --------------------------------------------------------------------------
void DisplayConsole(void)
{
warning("stub DisplayConsole");
/*
uint8 *src, *dst;
uint8 i;
// DDSURFACEDESC ddDescription;
// HRESULT hr;
if (consoleStatus)
{
ddDescription.dwSize = sizeof(ddDescription);
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);
}
if (hr == DD_OK)
{
dst = (uint8 *) ddDescription.lpSurface + (screenDeep - consoley) * ddDescription.lPitch;
src = (uint8 *) consoleSprite;
for (i=0; i<consoley; i++)
{
memcpy(dst, src, screenWide);
src += screenWide;
dst += ddDescription.lPitch;
}
IDirectDrawSurface_Unlock(lpBackBuffer, ddDescription.lpSurface);
}
}
*/
}
int32 OpenConsole(void)
{
warning("stub OpenConsole");
/*
if (consoleStatus)
return(RDERR_ALREADYOPEN);
if (consoleSprite == NULL)
{
consoley = screenDeep >> 2;
consoleSize = screenWide * consoley;
consoleSprite = (uint8 *) malloc(consoleSize);
}
if (consoleSprite == NULL)
return(RDERR_OUTOFMEMORY);
memset(consoleSprite, 0, consoleSize);
*/
consoleStatus = 1;
return(RD_OK);
}
int32 CloseConsole(void)
{
if (!consoleStatus)
return(RDERR_ALREADYCLOSED);
free(consoleSprite);
consoleSprite = NULL;
consoleStatus = 0;
return(RD_OK);
}
--- NEW FILE: _console.h ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/_console.h,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
//=============================================================================
//
// Filename : console.h
// Created : 19th September 1996
// By : P.R.Porter
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 20-Sep-96 PRP Internal driver interface to the console
// functions and data.
//
//
// Summary : This include file defines links to all data which is
// defined in the console.c module, but can be accessed by
// other parts of the driver96 library.
//
//=============================================================================
#ifndef CONSOLE_H
#define CONSOLE_H
extern void DisplayConsole(void);
#endif
--- NEW FILE: _mouse.cpp ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/_mouse.cpp,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
//=============================================================================
//
// Filename : mouse.c
// Created : 17th September 1996
// By : P.R.Porter
//
// Summary : This module holds the interface to the mouse..
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 18-Sep-96 PRP Initial mouse functions. Simple logging of
// previous 16 mouse events implemented. Mouse
// drawing is currently hard coded, but animations
// will be definable at a later date.
//
// 1.1 03-Oct-96 PRP Changed the mouse position so that mouse y of
// zero is the top left corner of the screen, and
// not the top left corner of the top menubar.
// Also, removed the x and y position from the
// mouse log. And changed the MouseEvent function
// so that it returns a pointer to _mouseEvent
//
// 1.2 04-Oct-96 PRP Put direct path in for ddraw.h
//
// 1.3 31-Oct-96 PRP Added code to draw the proper type of mouse
// sprite, which comprises of the internal
// function DrawMouse and globally available
// AnimateMouse and SetMouseAnim.
//
// 1.4 15-Nov-96 PRP Definition of menubar size is now obtained
// from menu.h
//
// 1.5 18-Nov-96 PRP Changed the direct draw interface to
// IDirectDraw2.
//
// 1.6 25-Nov-96 PRP Added functionality to set the luggage
// sprite.
//
// 1.7 06-Jan-97 PRP Changed the width and height of sprites
// to be signed.
//
// 1.8 14-Jan-97 JEL Reset mouse frame when new animation starts.
//
// 1.9 27-Jan-97 PRP Changed the mouse drawing routines to utilize
// directDraw surfaces and transparency blitting.
//
// 1.10 10-Feb-97 PRP Changed the directDraw error reporting so that
// it works properly. Also, created the mouse
// sprite depending upon whether the hardware can
// blt or not.
//
// 1.11 19-Mar-97 PRP Fixed a bug which was causing the mouse sprite
// to be freed up each frame and therefore
// decompressed and re-loaded each frame.
//
// 1.12 20-Mar-97 PRP Added a function to reset the render code when
// the control panel is entered.
//
// 1.13 09-Apr-97 PRP Made the mouse animation wrap back to the
// seventh frame.
//
// 1.14 10-Apr-97 PRP Added parameter to define whether mouse flashes
// or not.
//
// 1.15 23-Jul-97 JEL Added CheckForMouseEvents() to return no. of events outstanding
//
//
// Functions
// ---------
//
// --------------------------------------------------------------------------
//
// _mouseEvent *MouseEvent(void)
//
// The address of a _mouseEvent pointer is passed in. If there is a mouse
// event in the queue, a the value of the mouse event pointer is set to the
// address of the event, otherwise, the mouse event pointer is set to NULL.
//
// --------------------------------------------------------------------------
//
// int32 SetMouseAnim(uint8 *ma, int32 size)
//
// A pointer to a valid mouse animation is passed in, along with the size of
// the header plus sprite data. Remember to check that the function has
// successfully completed, as memory allocation is required.
// Pass NULL in to clear the mouse sprite.
//
// --------------------------------------------------------------------------
//
// int32 SetLuggageAnim(uint8 *ma, int32 size)
//
// A pointer to a valid luggage animation is passed in, along with the size of
// the header plus sprite data. Remember to check that the function has
// successfully completed, as memory allocation is required.
// Pass NULL in to clear the luggage sprite. Luggage sprites are of the same
// format as mouse sprites.
//
// --------------------------------------------------------------------------
//
// int32 AnimateMouse(void)
//
// This function animates the current mouse pointer. If no pointer is
// currently defined, an error code is returned.
//
//=============================================================================
#define WIN32_LEAN_AND_MEAN
//#include <windows.h>
//#include <windowsx.h>
//#include "ddraw.h"
#include "driver96.h"
#include "d_draw.h"
#include "render.h"
#include "menu.h"
#define MAX_MOUSE_EVENTS 16
#define MOUSEFLASHFRAME 6
typedef struct
{
uint8 runTimeComp; // type of runtime compression used for the frame data
uint8 noAnimFrames; // number of frames in the anim
int8 xHotSpot;
int8 yHotSpot;
uint8 mousew;
uint8 mouseh;
} _mouseAnim;
int16 mousex;
int16 mousey;
static uint8 mouseBacklog = 0;
static uint8 mouseLogPos = 0;
static uint8 mouseFrame;
static uint8 luggageFrame = 0;
static uint8 *mouseSprite = NULL;
static _mouseAnim *mouseAnim = NULL;
static _mouseAnim *luggageAnim = NULL;
static _mouseEvent mouseLog[MAX_MOUSE_EVENTS];
static int32 *mouseOffsets;
static int32 *luggageOffset;
//static LPDIRECTDRAWSURFACE *mouseSurfaces;
//static LPDIRECTDRAWSURFACE luggageSurface = NULL;
void ResetRenderEngine(void)
{
memset(myScreenBuffer, 0, RENDERWIDE * RENDERDEEP);
parallaxScrollx = 0;
parallaxScrolly = 0;
scrollx = 0;
scrolly = 0;
}
// --------------------------------------------------------------------------
// Logs the mouse button event passed in buttons. The button events are
// defined as RD_LEFTBUTTONDOWN, RD_LEFTBUTTONUP, RD_RIGHTBUTTONDOWN and
// RD_RIGHTBUTTONUP.
// --------------------------------------------------------------------------
void LogMouseEvent(uint16 buttons)
{
_mouseEvent *me;
if (mouseBacklog == MAX_MOUSE_EVENTS-1) // We need to leave the one which is
{ // the current event alone!
return;
}
me = &mouseLog[(mouseBacklog + mouseLogPos) % MAX_MOUSE_EVENTS];
me->buttons = buttons;
mouseBacklog += 1;
}
int32 DecompressMouse(uint8 *decomp, uint8 *comp, int32 size)
{
int32 i = 0;
while (i < size)
{
if (*comp > 183)
{
*decomp++ = *comp++;
i += 1;
}
else
{
memset(decomp, 0, *comp);
decomp += *comp;
i += *comp++;
}
}
return(RD_OK);
}
// --------------------------------------------------------------------------
// Draws the mouse sprite to the back buffer.
// --------------------------------------------------------------------------
int32 DrawMouse(void)
{
warning("stub DrawMouse");
/*
uint8 *src, *dst;
int16 i;
int16 xoff=0, yoff=0;
uint8 *decompSprite;
DDSURFACEDESC ddsd;
HRESULT hr;
RECT rs, rd;
if (luggageAnim)
{
if (luggageSurface == NULL)
{
// Create the luggage surface.
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(DDSURFACEDESC);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
if (dxHalCaps & RDCAPS_SRCBLTCKEY)
ddsd.ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY;
else
ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
ddsd.dwWidth = luggageAnim->mousew;
ddsd.dwHeight = luggageAnim->mouseh;
hr = IDirectDraw2_CreateSurface(lpDD2, &ddsd, &luggageSurface, NULL);
if (hr != DD_OK)
{
if (hr == DDERR_OUTOFVIDEOMEMORY)
{
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
hr = IDirectDraw2_CreateSurface(lpDD2, &ddsd, &luggageSurface, NULL);
}
if (hr != DD_OK)
{
DirectDrawError("Cannot create mouse surface", hr);
return(hr);
}
}
// Set the surface blt source colour key
hr = IDirectDrawSurface2_SetColorKey(luggageSurface, DDCKEY_SRCBLT, &blackColorKey);
// Copy the data into the surfaces.
decompSprite = (uint8 *) malloc(luggageAnim->mousew * luggageAnim->mouseh);
if (decompSprite == NULL)
return(RDERR_OUTOFMEMORY);
// DecompressMouse(decompSprite, (uint8 *) luggageAnim + *mouseOffsets, luggageAnim->mousew * luggageAnim->mouseh);
DecompressMouse(decompSprite, (uint8 *) luggageAnim + *luggageOffset, luggageAnim->mousew * luggageAnim->mouseh);
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(DDSURFACEDESC);
hr = IDirectDrawSurface2_Lock(luggageSurface, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr != DD_OK)
{
IDirectDrawSurface2_Restore(luggageSurface);
hr = IDirectDrawSurface2_Lock(luggageSurface, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr != DD_OK)
{
DirectDrawError("Unable to lock luggage surface", hr);
return(hr);
}
}
dst = ddsd.lpSurface;
src = decompSprite;
for (i=0; i<luggageAnim->mouseh; i++)
{
memcpy(dst, src, luggageAnim->mousew);
dst += ddsd.lPitch;
src += luggageAnim->mousew;
}
IDirectDrawSurface2_Unlock(luggageSurface, ddsd.lpSurface);
free(decompSprite);
}
rd.top = mousey + MENUDEEP - luggageAnim->yHotSpot;
rd.bottom = rd.top + luggageAnim->mouseh;
rd.left = mousex - luggageAnim->xHotSpot;
rd.right = rd.left + luggageAnim->mousew;
rs.left = 0;
rs.right = luggageAnim->mousew;
rs.top = 0;
rs.bottom = luggageAnim->mouseh;
if (rd.left < 0)
{
rs.left = 0 - rd.left;
rd.left = 0;
}
if (rd.top < 0)
{
rs.top = 0 - rd.top;
rd.top = 0;
}
if (rd.right > RENDERWIDE)
{
rs.right -= (rd.right - RENDERWIDE);
rd.right = RENDERWIDE;
}
if (rd.bottom > ALIGNRENDERDEEP)
{
rs.bottom -= (rd.bottom - ALIGNRENDERDEEP);
rd.bottom = ALIGNRENDERDEEP;
}
hr = IDirectDrawSurface2_Blt(lpBackBuffer, &rd, luggageSurface, &rs, DDBLT_WAIT | DDBLT_KEYSRC, NULL);
if (hr = DDERR_SURFACELOST)
{
IDirectDrawSurface2_Release(luggageSurface);
luggageSurface = NULL;
}
}
if (mouseAnim == NULL)
{
return(RD_OK);
}
// Decompress the mouse sprite onto the directDraw surface, if it is not
// there already.
if (*(mouseSurfaces + mouseFrame) == NULL)
{
// Create the mouse surface.
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(DDSURFACEDESC);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
if (dxHalCaps & RDCAPS_SRCBLTCKEY)
ddsd.ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY;
else
ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
ddsd.dwWidth = mouseAnim->mousew;
ddsd.dwHeight = mouseAnim->mouseh;
hr = IDirectDraw2_CreateSurface(lpDD2, &ddsd, mouseSurfaces + mouseFrame, NULL);
if (hr != DD_OK)
{
if (hr == DDERR_OUTOFVIDEOMEMORY)
{
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
hr = IDirectDraw2_CreateSurface(lpDD2, &ddsd, mouseSurfaces + mouseFrame, NULL);
}
if (hr != DD_OK)
{
DirectDrawError("Cannot create mouse surface", hr);
return(hr);
}
}
// Set the surface blt source colour key
hr = IDirectDrawSurface2_SetColorKey(*(mouseSurfaces + mouseFrame), DDCKEY_SRCBLT, &blackColorKey);
// Copy the data into the surfaces.
decompSprite = (uint8 *) malloc(mouseAnim->mousew * mouseAnim->mouseh);
if (decompSprite == NULL)
return(RDERR_OUTOFMEMORY);
DecompressMouse(decompSprite, mouseSprite, mouseAnim->mousew * mouseAnim->mouseh);
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(DDSURFACEDESC);
hr = IDirectDrawSurface2_Lock(*(mouseSurfaces + mouseFrame), NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr != DD_OK)
{
IDirectDrawSurface2_Restore(*(mouseSurfaces + mouseFrame));
hr = IDirectDrawSurface2_Lock(*(mouseSurfaces + mouseFrame), NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr != DD_OK)
{
DirectDrawError("Cannot lock mouse surface", hr);
return(hr);
}
}
dst = ddsd.lpSurface;
src = decompSprite;
for (i=0; i<mouseAnim->mouseh; i++)
{
memcpy(dst, src, mouseAnim->mousew);
dst += ddsd.lPitch;
src += mouseAnim->mousew;
}
IDirectDrawSurface2_Unlock(*(mouseSurfaces + mouseFrame), ddsd.lpSurface);
free(decompSprite);
}
rd.top = mousey + MENUDEEP - mouseAnim->yHotSpot;
rd.bottom = rd.top + mouseAnim->mouseh;
rd.left = mousex - mouseAnim->xHotSpot;
rd.right = rd.left + mouseAnim->mousew;
rs.left = 0;
rs.right = mouseAnim->mousew;
rs.top = 0;
rs.bottom = mouseAnim->mouseh;
if (rd.left < 0)
{
rs.left = 0 - rd.left;
rd.left = 0;
}
if (rd.top < 0)
{
rs.top = 0 - rd.top;
rd.top = 0;
}
if (rd.right > RENDERWIDE)
{
rs.right -= (rd.right - RENDERWIDE);
rd.right = RENDERWIDE;
}
if (rd.bottom > ALIGNRENDERDEEP)
{
rs.bottom -= (rd.bottom - ALIGNRENDERDEEP);
rd.bottom = ALIGNRENDERDEEP;
}
hr = IDirectDrawSurface2_Blt(lpBackBuffer, &rd, *(mouseSurfaces + mouseFrame), &rs, DDBLT_WAIT | DDBLT_KEYSRC, NULL);
if (hr == DDERR_SURFACELOST)
{
IDirectDrawSurface2_Release(*(mouseSurfaces + mouseFrame));
*(mouseSurfaces + mouseFrame) = NULL;
}
*/
return(RD_OK);
}
_mouseEvent *MouseEvent(void)
{
_mouseEvent *me;
if (mouseBacklog)
{
me = &mouseLog[mouseLogPos];
if (++mouseLogPos == MAX_MOUSE_EVENTS)
{
mouseLogPos = 0;
}
mouseBacklog -= 1;
return(me);
}
return(NULL);
}
uint8 CheckForMouseEvents(void) // (James23july97)
{
return (mouseBacklog); // return the number of mouse events waiting
}
int32 AnimateMouse(void)
{
if (mouseAnim)
{
if (++mouseFrame == mouseAnim->noAnimFrames)
{
mouseFrame = MOUSEFLASHFRAME;
}
mouseSprite = (uint8 *) mouseAnim + *(mouseOffsets+mouseFrame);
}
else
{
return(RDERR_UNKNOWN);
}
return(RD_OK);
}
int32 SetMouseAnim(uint8 *ma, int32 size, int32 mouseFlash)
{
warning("stub SetMouseAnim( %d, %d )", size, mouseFlash);
/*
int32 i;
if (mouseAnim)
{
for (i=0; i<mouseAnim->noAnimFrames; i++)
{
if (*(mouseSurfaces + i))
{
IDirectDrawSurface2_Release(*(mouseSurfaces + i));
*(mouseSurfaces + i) = NULL;
}
}
free(mouseAnim);
mouseAnim = NULL;
free(mouseSurfaces);
mouseSurfaces = NULL;
}
if (ma)
{
if (mouseFlash == RDMOUSE_FLASH)
mouseFrame = 0;
else
mouseFrame = MOUSEFLASHFRAME;
mouseAnim = malloc(size);
if (mouseAnim == NULL)
{
return(RDERR_OUTOFMEMORY);
}
else
{
memcpy((uint8 *) mouseAnim, ma, size);
mouseOffsets = (int32 *) ((uint8 *) mouseAnim + sizeof(_mouseAnim));
AnimateMouse();
mouseSurfaces = (LPDIRECTDRAWSURFACE *) malloc(mouseAnim->noAnimFrames * sizeof(LPDIRECTDRAWSURFACE));
if (mouseSurfaces == NULL)
return(RDERR_OUTOFMEMORY);
memset(mouseSurfaces, 0, sizeof(LPDIRECTDRAWSURFACE) * mouseAnim->noAnimFrames);
}
}
*/
return(RD_OK);
}
int32 SetLuggageAnim(uint8 *ma, int32 size)
{
warning("stub SetLugggeAnim");
/*
if (luggageAnim)
{
free(luggageAnim);
luggageAnim = NULL;
}
if (ma)
{
luggageAnim = malloc(size);
if (luggageAnim == NULL)
{
return(RDERR_OUTOFMEMORY);
}
else
{
memcpy((uint8 *) luggageAnim, ma, size);
luggageOffset = (int32 *) ((uint8 *) luggageAnim + sizeof(_mouseAnim));
AnimateMouse();
}
}
*/
return(RD_OK);
}
--- NEW FILE: _mouse.h ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/_mouse.h,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
//=============================================================================
//
// Filename : mouse.h
// Created : 18th September 1996
// By : P.R.Porter
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 18-Sep-96 PRP Internal driver interface to the mouse driver
// functions and data.
//
// 1.1 03-Oct-96 PRP Changed the definition of mousex and y so that
// negative values are allowed.
//
//
// Summary : This include file defines links to all data which is
// defined in the mouse.c module, but can be accessed by
// other parts of the driver96 library.
//
//
//=============================================================================
#ifndef MOUSE_H
#define MOUSE_H
extern int16 mousex; // Mouse x coordinate
extern int16 mousey; // Mouse y coordinate
extern void LogMouseEvent(uint16 buttons); // Adds a mouse event to the log
extern int32 DrawMouse(void); // Renders the mouse onto the back buffer.
#endif
--- NEW FILE: d_draw.cpp ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/d_draw.cpp,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
[...1235 lines suppressed...]
// lpBackBuffer = s->lpBackBuffer;
// lpPalette = s->lpPalette;
screenDeep = s->screenDeep;
screenWide = s->screenWide;
scrollx = s->scrollx;
scrolly = s->scrolly;
scrollxTarget = s->scrollxTarget;
scrollyTarget = s->scrollyTarget;
scrollxOld = s->scrollxOld;
scrollyOld = s->scrollyOld;
failCount = s->failCount;
// renderCaps = s->renderCaps;
dxHalCaps = s->dxHalCaps;
dxHelCaps = s->dxHelCaps;
noVbl = s->noVbl;
bFullScreen = s->bFullScreen;
// memcpy(&driverCaps, &s->driverCaps, sizeof(DDCAPS));
// memset(&blackColorKey, 0, sizeof(DDCOLORKEY));
}
--- NEW FILE: d_draw.h ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/d_draw.h,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
//=============================================================================
//
// Filename : d_draw.h
// Created : 22nd August 1996
// By : P.R.Porter
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 16-Sep-96 PRP Interface to the DirectDraw driver functions
// and data.
//
// 1.1 19-Sep-96 PRP Increased scope of directDraw data, such as
// the back buffer object, so that mouse.c can
// have access to the screen.
//
// 1.2 25-Sep-96 PRP Made scrollx and scrolly available to all
// driver code.
//
// 1.3 26-Sep-96 PRP Moved scroll stuff to render.h for clarity.
//
// 1.4 07-Nov-96 PRP Made bFullScreen available to all driver code.
//
// 1.5 18-Nov-96 PRP Added reference to lpDD2 object.
//
// 1.6 24-Jan-97 PRP Added hardware capability bits and defines.
//
// 1.7 06-Mar-97 PRP Changed capability bits, and changed the
// direct draw error reporting call. Added
// function to grab screen shot.
//
// 1.8 16-Jun-97 PSJ Made globall externable to c++.
//
// 1.9 27-Jun-97 PRP Moving the definition of GrabScreenShot to
// driver96.h for external access.
//
//
// Summary : This include file defines links to all data which is
// defined in the d_draw.c module, but can be accessed by
// other parts of the driver96 library.
//
//
//=============================================================================
#ifndef D_DRAW_H
#define D_DRAW_H
#ifdef __cplusplus
extern "C" {
#endif
//#include "ddraw.h"
// Bits defining hardware and emulation capabilities.
#define RDCAPS_BLTSTRETCH 1
#define RDCAPS_SRCBLTCKEY 2
#define DirectDrawError(f, g) FatalDirectDrawError(f, g, __FILE__, __LINE__)
extern uint8 *lpPalette; // palette
extern uint8 *lpBackBuffer; // back surface
extern uint8 *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.
extern void FatalDirectDrawError(char *str, int32 dderr, char *file, int32 line);
extern void RestoreSurfaces(void); // Restores direct draw surfaces.
#ifdef __cplusplus
}
#endif
#endif
--- NEW FILE: d_sound.cpp ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/d_sound.cpp,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
[...3056 lines suppressed...]
memcpy(musStreaming, s->musStreaming, sizeof(int16) * MAXMUS);
memcpy(musicPaused, s->musicPaused, sizeof(int16) * MAXMUS);
memcpy(musCounter, s->musCounter, sizeof(int16) * MAXMUS);
memcpy(musFading, s->musFading, sizeof(int16) * MAXMUS);
memcpy(musLooping, s->musLooping, sizeof(int16) * MAXMUS);
memcpy(musLastSample,s->musLastSample, sizeof(int16) * MAXMUS);
memcpy(streamCursor, s->streamCursor, sizeof(int32) * MAXMUS);
memcpy(musFilePos, s->musFilePos, sizeof(int32) * MAXMUS);
memcpy(musEnd, s->musEnd, sizeof(int32) * MAXMUS);
memcpy(musId, s->musId, sizeof(uint32) * MAXMUS);
memcpy(volMusic, s->volMusic, sizeof(uint32) * 2);
// memcpy(dsbdMus, s->dsbdMus, sizeof(DSBUFFERDESC) * MAXMUS);
// memcpy(lpDsbMus, s->lpDsbMus, sizeof(LPDIRECTSOUNDBUFFER) * MAXMUS);
// memcpy(fpMus, s->fpMus, sizeof(FILE*) * MAXMUS);
// memcpy(wfMus, s->wfMus, sizeof(PCMWAVEFORMAT) * MAXMUS);
for (i = 0; i<MAXMUS; i++)
memcpy(musFilename[i], s->musFilename[i], sizeof(char) * 256);
}
--- NEW FILE: d_sound.h ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/d_sound.h,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
//=============================================================================
//
// Filename : d_sound.h
// Created : 5th December 1996
// By : P.R.Porter
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 05-Dec-96 PRP Interface to the DirectSound driver functions
//
// Summary : This include file defines links to all data which is
// defined in the d_sound.c module, but can be accessed by
// other parts of the driver96 library.
//
//
//=============================================================================
#ifndef D_SOUND_H
#define D_SOUND_H
extern void FxServer(void);
#endif
--- NEW FILE: ddutil.h ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/ddutil.h,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
//-----------------------------------------------------------------------------
// 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
--- NEW FILE: driver96.h ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/driver96.h,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
[...1626 lines suppressed...]
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
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
extern int16 mousey; // Mouse screen y coordinate
extern int32 renderCaps; // Flags which determine how to render the scene.
extern uint8 palCopy[256][4]; // Current palette.
//-----------------------------------------------------------------------------
extern LARGE_INTEGER myTimers[10][2];
#ifdef __cplusplus
}
#endif
#endif
--- NEW FILE: keyboard.cpp ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/keyboard.cpp,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
//=============================================================================
//
// Filename : keyboard.c
// Created : 19th September 1996
// By : P.R.Porter
//
// Summary : This module holds the interface to the keyboard
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 19-Sep-96 PRP Keyboard functions. Simple logging of
// previous 32 keys pressed.
//
// 1.1 19-Sep-96 PRP Fixed bug, ReadKey did not return RD_OK.
//
// 1.2 13-Aug-97 PSJ Added GetKeyStatus
//
// Functions
// ---------
//
// --------------------------------------------------------------------------
//
// BOOL KeyWaiting(void)
//
// This function returns TRUE if there is an unprocessed key waiting in the
// queue, FALSE otherwise.
//
// --------------------------------------------------------------------------
//
// int32 ReadKey(char *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 *s)
//
// Retrieves the status of the keyboard handler.
//
//=============================================================================
#define WIN32_LEAN_AND_MEAN
//#include <windows.h>
//#include <windowsx.h>
#include "driver96.h"
#define MAX_KEY_BUFFER 23
uint8 keyBacklog = 0; // The number of key presses waiting to be processed.
uint8 keyPointer = 0; // Index of the next key to read from the buffer.
char keyBuffer[MAX_KEY_BUFFER]; // The keyboard buffer
void WriteKey(char key)
{
if (keyBuffer && keyBacklog < MAX_KEY_BUFFER)
{
keyBuffer[(keyPointer + keyBacklog) % MAX_KEY_BUFFER] = key;
keyBacklog += 1;
}
}
BOOL KeyWaiting(void)
{
if (keyBacklog)
return(TRUE);
else
return(FALSE);
}
int32 ReadKey(char *key)
{
if (!keyBacklog)
return(RDERR_NOKEYWAITING);
if (key == NULL)
return(RDERR_INVALIDPOINTER);
*key = keyBuffer[keyPointer++];
if (keyPointer == MAX_KEY_BUFFER)
keyPointer = 0;
keyBacklog -= 1;
return(RD_OK);
}
void GetKeyStatus(_drvKeyStatus *s)
{
// Flush key buffer
s->pBacklog = &keyBacklog;
s->pPointer = &keyPointer;
s->pBuffer = keyBuffer;
}
--- NEW FILE: keyboard.h ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/keyboard.h,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
//=============================================================================
//
// Filename : keyboard.h
// Created : 19th September 1996
// By : P.R.Porter
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 19-Sep-96 PRP Internal driver interface to the keyboard driver
// functions and data.
//
//
// Summary : This include file defines links to all data which is
// defined in the keyboard.c module, but can be accessed by
// other parts of the driver96 library.
//
//
//=============================================================================
#ifndef KEYBOARD_H
#define KEYBOARD_H
void WriteKey(char key); // Adds a keypress to the buffer
#endif
--- NEW FILE: language.cpp ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/language.cpp,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
//=============================================================================
//
// Filename : language.c
// Created : 20th August 1996
// By : P.R.Porter
//
// Summary : This module holds the functions which govern which language
// version is current.
//
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 16-Sep-96 PRP Initial language version control functions.
// Many of the functions are currently stubs, and
// this will be addressed shortly.
//
//
// Functions
// ---------
//
// --------------------------------------------------------------------------
//
// int32 GetLanguageVersion(uint8 *version)
//
// This function modifies the 'version' passed in to be the current language.
// The first time this function is called, it gets the language from the
// version.inf file distributed on the game CD. It returns an RD error code
// if this file cannot be opened, or the version cannot be obtained from it.
//
// ---------------------------------------------------------------------------
//
// int32 SetLanguageVersion(uint8 version)
//
// This function is useful for debugging. It sets the version to the one
// passed in.
//
// ---------------------------------------------------------------------------
//
// int32 GetGameName(uint8 *name);
//
// Fills the string pointed to by name with the title of the game, depending
// upon what the current language version is.
//
//=============================================================================
#include "driver96.h"
uint8 languageVersion = ENGLISH;
static uint8 versionFromFile = 0;
int32 GetLanguageVersion(uint8 *version)
{
if (versionFromFile)
{
*version = languageVersion;
}
else
{
versionFromFile = 1;
languageVersion = AMERICAN;
return(RDERR_OPENVERSIONFILE);
}
return(RD_OK);
}
int32 SetLanguageVersion(uint8 version)
{
languageVersion = version;
return(RD_OK);
}
int32 GetGameName(uint8 *name)
{
uint8 version;
int32 rv;
rv = GetLanguageVersion(&version);
switch(version)
{
case ENGLISH:
strcpy((char *)name, "Broken Sword II");
break;
case AMERICAN:
strcpy((char *)name, "Circle of Blood II");
break;
case GERMAN:
strcpy((char *)name, "Baphomet's Fluch II");
break;
default:
strcpy((char *)name, "Some game or other, part 86");
return(RDERR_INVALIDVERSION);
}
return(rv);
}
--- NEW FILE: menu.cpp ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/menu.cpp,v 1.1 2003/07/28 01:47:40 khalek Exp $
*/
//=============================================================================
//
// Filename : menu.c
// Created : 14th November 1996
// By : P.R.Porter
//
// Summary : This module holds the code for the driver96 menu system.
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 15-Nov-96 PRP Initial Menu functions.
//
// 1.1 20-Nov-96 PRP Fixed the displaying of the bottom menu.
//
// 1.2 08-Nov-96 PRP Made the speed of the menubar dependent upon
// the number of icons displayed.
//
// 1.3 24-Jan-97 PRP Changed the creation of menu icon sprite
// surfaces depending upon whether the hardware
// can stretch blit or not. Also, made it so
// that the full size icon sprite is not stretch
// blitted.
//
// 1.4 10-Feb-97 PRP Changed the creation of menu icon sprite
// surfaces as the capability bits for the drivers
// have been changed. Also, changed the error
// reporting code (for directDraw) so that it
// works.
//
// 1.5 04-Mar-97 PRP Tried to fix bug where running out of video
// memory creating menubar icon surfaces.
//
// 1.6 16-Apr-97 PRP Got rid of bug where task switching causes
// failure of icon draw.
//
// 1.7 23-Jul-97 PRP Checked error value of stretched blit.
//
// 1.8 13-Aug-97 PRP Added CloseMenuImmediately.
//
// 1.9 13-Aug-97 PRP Fixed spelling of above
//
//
// Functions
// ---------
//
// --------------------------------------------------------------------------
//
// int32 ProcessMenu(void)
//
// This function should be called regularly to process the menuber system.
// The rate at which this function is called will dictate how smooth the menu
// system is. The menu cannot be drawn at a higher rate than the system
// vbl rate.
//
// --------------------------------------------------------------------------
//
// int32 ShowMenu(uint8 menu)
//
// This function brings the menu in to view. The choice of top or bottom menu
// is defined by the parameter menu being either RDMENU_TOP or RDMENU_BOTTOM.
// An error code is returned if the menu is already shown.
//
// --------------------------------------------------------------------------
//
// int32 HideMenu(uint8 menu)
//
// This function hides the menu defined by the parameter menu. If the menu is
// already hidden, an error code is returned.
//
// --------------------------------------------------------------------------
//
// int32 SetMenuIcon(uint8 menu, uint8 pocket, uint8 *icon)
//
// This function sets a menubar icon to that passed in. If icon is NULL, the
// pocket is cleared, otherwise, that icon is placed into pocket. The menu is
// either RDMENU_TOP or RDMENU_BOTTOM. Valid error codes include
// RDERR_INVALIDPOCKET if the pocket number does not exist. Initially, there
// are 15 pockets.
//
// --------------------------------------------------------------------------
//
// uint8 GetMenuStatus(uint8 menu)
//
// This function returns the status of the menu passed in menu. Return values
// are RDMENU_OPENING, RDMENU_CLOSING, RDMENU_HIDDEN and RDMENU_SHOWN.
//
//=============================================================================
#define WIN32_LEAN_AND_MEAN
//#include <windows.h>
//#include <windowsx.h>
//#include <mmsystem.h>
//#include "ddraw.h"
#include "driver96.h"
#include "menu.h"
#include "d_draw.h"
#include "render.h"
#define MENUDEEP 40
#define MAXMENUANIMS 8
static uint8 menuStatus[2] =
{
RDMENU_HIDDEN, RDMENU_HIDDEN
};
static uint8 *icons[2][RDMENU_MAXPOCKETS] =
{
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
/*
static LPDIRECTDRAWSURFACE lpIconSurface[2][RDMENU_MAXPOCKETS] =
{
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
*/
static uint8 pocketStatus[2][RDMENU_MAXPOCKETS] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
static uint8 menuCounter[2];
static uint8 lastIcon[2];
static uint8 iconCount = 0;
int32 CreateIconSurface(uint8 menu, uint8 pocket)
{
warning("stub CreatIconSurface( %d, %d )", menu, pocket);
/*
HRESULT hr;
DDSURFACEDESC ddsd;
// Set up the direct draw surface for the icon.
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(DDSURFACEDESC);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
if (dxHalCaps & RDCAPS_BLTSTRETCH)
ddsd.ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY;
else
ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
ddsd.dwWidth = RDMENU_ICONWIDE;
ddsd.dwHeight = RDMENU_ICONDEEP;
hr = IDirectDraw2_CreateSurface(lpDD2, &ddsd, &lpIconSurface[menu][pocket], NULL);
if ((dxHalCaps & RDCAPS_BLTSTRETCH) && (hr == DDERR_OUTOFVIDEOMEMORY))
{
ddsd.ddsCaps.dwCaps &= (0xffffffff - DDSCAPS_VIDEOMEMORY);
ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
hr = IDirectDraw2_CreateSurface(lpDD2, &ddsd, &lpIconSurface[menu][pocket], NULL);
}
if (hr != DD_OK)
{
DirectDrawError("Unable to create icon surface", hr);
return(hr);
}
*/
return(RD_OK);
}
int32 LoadIconSurface(int32 menu, int32 pocket)
{
warning("stub LoadIconSurface( %d, %d )");
/*
uint8 *src, *dst;
int32 i;
HRESULT hr;
DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(DDSURFACEDESC);
hr = IDirectDrawSurface2_Lock(lpIconSurface[menu][pocket], NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr != DD_OK)
{
IDirectDrawSurface2_Restore(lpIconSurface[menu][pocket]);
hr = IDirectDrawSurface2_Lock(lpIconSurface[menu][pocket], NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr != DD_OK)
{
DirectDrawError("Unable to lock icon surface", hr);
return(hr);
}
}
src = icons[menu][pocket];
dst = ddsd.lpSurface;
for (i=0; i<RDMENU_ICONDEEP; i++)
{
memcpy(dst, src, RDMENU_ICONWIDE);
src += RDMENU_ICONWIDE;
dst += ddsd.lPitch;
}
IDirectDrawSurface2_Unlock(lpIconSurface[menu][pocket], ddsd.lpSurface);
*/
return(RD_OK);
}
int32 ProcessMenu(void)
{
warning("stub ProcessMenu");
/*
uint8 menu;
uint8 i;
uint8 complete;
uint8 frameCount;
// uint8 *src, *dst;
int32 curx, xoff;
int32 cury, yoff;
HRESULT hr;
RECT r;
int32 delta;
static int32 lastTime = 0;
if (lastTime == 0)
{
lastTime = timeGetTime();
frameCount = 1;
}
else
{
delta = timeGetTime() - lastTime;
if (delta > 250)
{
lastTime += delta;
delta = 250;
frameCount = 1;
}
else
{
frameCount = (uint8) ((iconCount+8) * delta / 750);
lastTime += frameCount * 750 / (iconCount + 8);
}
}
while (frameCount-- > 0)
{
for (menu = RDMENU_TOP; menu <= RDMENU_BOTTOM; menu++)
{
if (menuStatus[menu] == RDMENU_OPENING)
{
// The menu is opening, so process it here
complete = 1;
// Propagate the animation from the first icon.
for (i=RDMENU_MAXPOCKETS-1; i>0; i--)
{
pocketStatus[menu][i] = pocketStatus[menu][i-1];
if (pocketStatus[menu][i] != MAXMENUANIMS)
{
complete = 0;
}
}
if (pocketStatus[menu][i] != MAXMENUANIMS)
complete = 0;
// ... and animate the first icon
if (pocketStatus[menu][0] != MAXMENUANIMS)
pocketStatus[menu][0] += 1;
// Check to see if the menu is fully open
if (complete)
{
menuStatus[menu] = RDMENU_SHOWN;
}
}
else if (menuStatus[menu] == RDMENU_CLOSING)
{
// The menu is closing, so process it here
complete = 1;
// Propagate the animation from the first icon.
for (i=RDMENU_MAXPOCKETS-1; i>0; i--)
{
pocketStatus[menu][i] = pocketStatus[menu][i-1];
if (pocketStatus[menu][i] != 0)
{
complete = 0;
}
}
if (pocketStatus[menu][i] != 0)
complete = 0;
// ... and animate the first icon
if (pocketStatus[menu][0] != 0)
pocketStatus[menu][0] -= 1;
// Check to see if the menu is fully open
if (complete)
{
menuStatus[menu] = RDMENU_HIDDEN;
}
}
}
}
// Does the menu need to be drawn?
for (menu = RDMENU_TOP; menu <= RDMENU_BOTTOM; menu++)
{
if (menuStatus[menu] != RDMENU_HIDDEN)
{
// Draw the menu here.
curx = RDMENU_ICONSTART + RDMENU_ICONWIDE / 2;
cury = (MENUDEEP / 2) + (RENDERDEEP + MENUDEEP) * menu;
for (i=0; i<RDMENU_MAXPOCKETS; i++)
{
if (lpIconSurface[menu][i])
{
if (pocketStatus[menu][i] == MAXMENUANIMS)
{
xoff = (RDMENU_ICONWIDE / 2);
r.left = curx - xoff;
r.right = r.left + RDMENU_ICONWIDE;
yoff = (RDMENU_ICONDEEP / 2);
r.top = cury - yoff;
r.bottom = r.top + RDMENU_ICONDEEP;
}
else
{
xoff = (RDMENU_ICONWIDE / 2) * pocketStatus[menu][i] / MAXMENUANIMS;
r.left = curx - xoff;
r.right = curx + xoff;
yoff = (RDMENU_ICONDEEP / 2) * pocketStatus[menu][i] / MAXMENUANIMS;
r.top = cury - yoff;
r.bottom = cury + yoff;
}
if ((xoff != 0) && (yoff != 0))
{
hr = IDirectDrawSurface2_Blt(lpBackBuffer, &r, lpIconSurface[menu][i], NULL, DDBLT_WAIT, NULL);
if (hr != DD_OK)
{
switch (hr)
{
case DDERR_GENERIC :
hr = 0;
break;
case DDERR_INVALIDCLIPLIST :
hr = 0;
break;
case DDERR_INVALIDOBJECT :
hr = 0;
break;
case DDERR_INVALIDPARAMS :
hr = 0;
break;
case DDERR_INVALIDRECT :
hr = 0;
break;
case DDERR_NOALPHAHW :
hr = 0;
break;
case DDERR_NOBLTHW :
hr = 0;
break;
case DDERR_NOCLIPLIST :
hr = 0;
break;
case DDERR_NODDROPSHW :
hr = 0;
break;
case DDERR_NOMIRRORHW :
hr = 0;
break;
case DDERR_NORASTEROPHW :
hr = 0;
break;
case DDERR_NOROTATIONHW :
hr = 0;
break;
case DDERR_NOSTRETCHHW :
hr = 0;
break;
case DDERR_NOZBUFFERHW :
hr = 0;
break;
case DDERR_SURFACEBUSY :
hr = 0;
break;
case DDERR_SURFACELOST :
hr = 0;
break;
case DDERR_UNSUPPORTED :
hr = 0;
break;
default: //shit
hr = 0;
break;
}
// if (hr == DDERR_INVALIDOBJECT)
// {
CreateIconSurface(menu, i);
LoadIconSurface(menu, i);
hr = IDirectDrawSurface2_Blt(lpBackBuffer, &r, lpIconSurface[menu][i], NULL, DDBLT_WAIT, NULL);
// }
if (hr != DD_OK)
{
if (hr != DDERR_SURFACELOST)
{
DirectDrawError("Unable to blt icon", hr);
return(hr);
}
}
}
}
}
curx += (RDMENU_ICONSPACING + RDMENU_ICONWIDE);
}
}
}
*/
}
int32 ShowMenu(uint8 menu)
{
// Check for invalid menu parameter
if (menu > RDMENU_BOTTOM)
return(RDERR_INVALIDMENU);
// Check that the menu is not currently shown, or in the process of being shown.
if ((menuStatus[menu] == RDMENU_SHOWN) || (menuStatus[menu] == RDMENU_OPENING))
return(RDERR_INVALIDCOMMAND);
menuStatus[menu] = RDMENU_OPENING;
}
int32 HideMenu(uint8 menu)
{
// Check for invalid menu parameter
if (menu > RDMENU_BOTTOM)
return(RDERR_INVALIDMENU);
// Check that the menu is not currently hidden, or in the process of being hidden.
if ((menuStatus[menu] == RDMENU_HIDDEN) || (menuStatus[menu] == RDMENU_CLOSING))
return(RDERR_INVALIDCOMMAND);
menuStatus[menu] = RDMENU_CLOSING;
}
int32 CloseMenuImmediately(void)
{
menuStatus[0] = RDMENU_HIDDEN;
menuStatus[1] = RDMENU_HIDDEN;
memset(pocketStatus, 0, sizeof(uint8) * 2 * RDMENU_MAXPOCKETS);
return (RD_OK);
}
int32 SetMenuIcon(uint8 menu, uint8 pocket, uint8 *icon)
{
warning("stub SetMenuIcon( %d, %d )", menu, pocket);
/*
HRESULT hr;
// Check for invalid menu parameter.
if (menu > RDMENU_BOTTOM)
return(RDERR_INVALIDMENU);
// Check for invalid pocket parameter
if (pocket >= RDMENU_MAXPOCKETS)
return(RDERR_INVALIDPOCKET);
// If there is an icon in the requested menu/pocket, clear it out.
if (icons[menu][pocket])
{
iconCount--;
free(icons[menu][pocket]);
icons[menu][pocket] = NULL;
IDirectDrawSurface2_Release(lpIconSurface[menu][pocket]);
lpIconSurface[menu][pocket] = NULL;
}
// Only put the icon in the pocket if it is not NULL
if (icon != NULL)
{
iconCount++;
icons[menu][pocket] = (uint8 *) malloc(RDMENU_ICONWIDE * RDMENU_ICONDEEP);
if (icons[menu][pocket] == NULL)
return(RDERR_OUTOFMEMORY);
memcpy(icons[menu][pocket], icon, RDMENU_ICONWIDE * RDMENU_ICONDEEP);
hr = CreateIconSurface(menu, pocket);
if (hr != DD_OK)
return(hr);
hr = LoadIconSurface(menu, pocket);
if (hr != RD_OK)
return(hr);
}
*/
}
uint8 GetMenuStatus(uint8 menu)
{
if (menu > RDMENU_BOTTOM)
return(RDMENU_HIDDEN);
return(menuStatus[menu]);
}
--- NEW FILE: menu.h ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/menu.h,v 1.1 2003/07/28 01:47:41 khalek Exp $
*/
//=============================================================================
//
// Filename : menu.h
// Created : 15th November 1996
// By : P.R.Porter
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 15-Nov-96 PRP Internal driver interface to the menu driver
// functions and data.
//
//
// Summary : This include file defines links to all data which is
// defined in the menu.c module, but can be accessed by
// other parts of the driver96 library.
//
//
//=============================================================================
#ifndef MENU_H
#define MENU_H
#define MENUDEEP 40
#endif
--- NEW FILE: misc.cpp ---
/* Copyright (C) 2003 The ScummVM project
*
* 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: /cvsroot/scummvm/scummvm/bs2/driver/misc.cpp,v 1.1 2003/07/28 01:47:41 khalek Exp $
*/
#include "driver96.h"
#include "../sword2.h"
uint32 timeGetTime(void) {
return g_bs2->_syst->get_msecs();
}
void VirtualUnlock(uint8 *free_memman, uint32 total_free_memory) {
warning("stub VirtualUnlock");
}
void GlobalMemoryStatus(MEMORYSTATUS *memo) {
warning("stub GlobalMemoryStatus");
memo->dwTotalPhys = 16000*1024; // hard code 16mb for now
}
void SetFileAttributes(char *file, uint32 atrib) {
warning("stub SetFileAttributes");
}
void DeleteFile(char *file) {
warning("stub DeleteFile");
}
void GetCurrentDirectory(uint32 max, char* path) {
warning("stub GetCurrentDirectory");
}
int32 GetVolumeInformation(char *cdPath, char *sCDName, uint32 maxPath, uint8 *, DWORD *dwMaxCompLength, DWORD *dwFSFlags, uint8 *, uint32 a) {
warning("stub GetVolumeInformation %s", cdPath);
strcpy(sCDName, CD1_LABEL);
return 1;
}
// FIXME wrap different platform specific mkdir calls and actually do something
void _mkdir(const char *pathname) {
warning("stub _mkdir %s", pathname);
}
void GetModuleFileName(void *module, char *destStr, uint32 maxLen) {
warning("stub GetModuleFileName");
}
--- NEW FILE: palette.cpp ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/palette.cpp,v 1.1 2003/07/28 01:47:41 khalek Exp $
*/
//=============================================================================
//
// Filename : palette.c
// Created : 22nd August 1996
// By : P.R.Porter
//
// Summary : This module holds the palette functions and the interface
// to the directDraw palette.
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 16-Sep-96 PRP Currently holds the palette setting code. Will
// be modified so that the calling functions have
// to use the correct palette format, and the
// fading code will be added.
//
// 1.1 17-Sep-96 PRP Removed utypes.h from include list.
//
// 1.2 03-Oct-96 PRP Changed the palette format to RGBA 0-255.
//
// 1.3 04-Oct-96 PRP No changes
//
// 1.4 04-Oct-96 PRP Put direct path in for ddraw.h
//
// 1.5 08-Nov-96 PRP Created a drivers copy of the palette so that
// it can be restored at any time without the
// game engine having to worry about things.
// Currently, there is different code for setting
// the palette in full screen and windowed mode
// until I can get windowed mode working.
//
// 1.6 09-Nov-96 PRP More work to get the palette to work propery
// in windowed mode.
//
// 1.7 22-Nov-96 PRP Made the whole of the palette available to
// the rest of the driver96 code.
//
// 1.8 25-Nov-96 PRP Added a function to create a palette match
// table from the current palette.
//
// 1.9 29-Nov-96 PRP Made the QuickMatch function __inline for
// speed - but didn't work. Added functions
// to fade the palette up and down.
//
// 1.10 05-Dec-96 PRP Added a flag to SetPalette so that the palette
// can be set immediately or later by the fade.
//
// 1.11 06-Dec-96 JEL fadeStatus now initialised to 0
//
// 1.12 09-Dec-96 PRP Function UpdatePaletteMatchTable() changed so
// that the data can be part of another file.
//
// 1.13 10-Feb-97 PRP Changed the direct draw error reporting calls.
//
// 1.14 11-Feb-97 PRP Suspended the fade server if the direct draw
// palette object does not exist.
//
// 1.15 17-Mar-97 PRP Added RDFADE_BLACK as a return value so the
// engine knows the state of the palette when
// there is no fade.
//
// 1.16 17-Mar-97 PRP Fixed driver bug which caused FadeUp to fail
// becuase of the introduction of RDFADE_BLACK.
//
// 1.17 26-Jun-97 PRP Added a function to darken the palette for pausing.
//
// 1.18 26-Jun-97 PRP Forgot to return a value.
//
// 1.19 26-Jun-97 PRP Forgot to set the palette - DOH!
//
// 1.20 26-Jun-97 PRP Fixed undefined symbols bugs.
//
// 1.21 09-Jul-97 JEL Fixed palette dimming - to unsigned rather than signed RGB values!
//
// 1.22 26-Jun-97 JEL SetPalette now always sets colour 0 to black so doesn't need setting to black from game engine
//
// 1.23 10-Jul-97 JEL Nothing changed but new version had to be booked in anyway.
//
// 1.24 10-Jul-97 JEL SetPalette doesn't do that any more (see above)!
//
// Functions
// ---------
//
// --------------------------------------------------------------------------
//
// void SetPalette(int32 startEntry, int32 noEntries, uint8 *colourTable)
//
// Sets the palette from position startEntry for noEntries, to the data
// pointed to by colourTable.
//
// --------------------------------------------------------------------------
//
// void UpdatePaletteMatchTable(uint8 *data)
//
// Uses the current palCopy to create a table of palette indeces which will
// be searched later for a quick palette match, if data is NULL. Otherwise
// it uses the table passed in.
//
// --------------------------------------------------------------------------
//
// uint8 QuickMatch(uint8 r, uint8 g, uint8 b)
//
// Returns the palette index of the closest matching colour in the palette
// to these RGB values.
//
// --------------------------------------------------------------------------
//
// int32 FadeUp(float time)
//
// Fades the palette up from black to the current palette in time.
//
// --------------------------------------------------------------------------
//
// int32 FadeDown(float time)
//
// Fades the palette down to black from the current palette in time.
//
// --------------------------------------------------------------------------
//
// uint8 GetFadeStatus(void)
//
// Returns the fade status which can be one of RDFADE_UP, RDFADE_DOWN or
// RDFADE_NONE.
//
//=============================================================================
#define WIN32_LEAN_AND_MEAN
//#include <windows.h>
//#include <windowsx.h>
#include <stdio.h>
//#include <mmsystem.h>
//#include "ddraw.h"
#include "driver96.h"
#include "d_draw.h"
#define PALTABLESIZE 64*64*64
uint8 palCopy[256][4];
uint8 fadePalette[256][4];
uint8 paletteMatch[PALTABLESIZE];
uint8 fadeStatus=0;
static int32 fadeStartTime;
static int32 fadeTotalTime;
// --------------------------------------------------------------------------
// int32 RestorePalette(void)
//
// This function restores the palette, and should be called whenever the
// screen mode changes, or something like that.
// --------------------------------------------------------------------------
int32 RestorePalette(void)
{
warning("stub RestorePalette");
/*
int32 hr;
if (bFullScreen)
hr = IDirectDrawPalette_SetEntries(lpPalette, 0, 0, 256, (LPPALETTEENTRY) &palCopy[0][0]);
else
hr = IDirectDrawPalette_SetEntries(lpPalette, 0, 10, 236, (LPPALETTEENTRY) &palCopy[10][0]);
if (hr != DD_OK)
{
DirectDrawError("Unable to restore palette", hr);
return(hr);
}
*/
return(RD_OK);
}
uint8 GetMatch(uint8 r, uint8 g, uint8 b)
{
int32 diff;
int32 min;
int16 diffred, diffgreen, diffblue;
int16 i;
uint8 minIndex;
diffred = palCopy[0][0] - r;
diffgreen = palCopy[0][1] - g;
diffblue = palCopy[0][2] - b;
diff = diffred * diffred + diffgreen * diffgreen + diffblue * diffblue;
min = diff;
minIndex = 0;
if (diff > 0)
{
i = 1;
while (i < 256)
{
diffred = palCopy[i][0] - r;
diffgreen = palCopy[i][1] - g;
diffblue = palCopy[i][2] - b;
diff = diffred * diffred + diffgreen * diffgreen + diffblue * diffblue;
if (diff < min)
{
min = diff;
minIndex = (uint8) i;
if (min == 0)
break;
}
i += 1;
}
}
// Here, minIndex is the index of the matchpalette which is closest.
return(minIndex);
}
int32 UpdatePaletteMatchTable(uint8 *data)
{
if (data == NULL)
// Create palette match table
{
FILE *fp;
int16 red, green, blue;
uint8 *p;
p = &paletteMatch[0];
for (red = 0; red < 256; red += 4)
{
for (green = 0; green < 256; green += 4)
{
for (blue = 0; blue < 256; blue += 4)
{
*p++ = GetMatch((uint8) red, (uint8) green, (uint8) blue);
}
}
}
// Write out palette match table
fp = fopen("r11.rgb", "wb");
if (fp == NULL)
return(RDERR_INVALIDFILENAME);
if (fwrite(paletteMatch, 1, 64*64*64, fp) != 64*64*64)
return(RDERR_WRITEERROR);
fclose(fp);
}
else
// Read table from file
{
memcpy(paletteMatch, data, PALTABLESIZE);
/*
FILE *fp;
fp = fopen(filename, "rb");
if (fp == NULL)
return(RDERR_INVALIDFILENAME);
if (fread(paletteMatch, 1, 64*64*64, fp) != 64*64*64)
return(RDERR_READERROR);
fclose(fp);
return(RD_OK);
*/
}
return(RD_OK);
}
__inline uint8 QuickMatch(uint8 r, uint8 g, uint8 b)
{
return(paletteMatch[((int32) (r >> 2) << 12) + ((int32) (g >> 2) << 6) + (b >> 2)]);
}
int32 SetPalette(int16 startEntry, int16 noEntries, uint8 *colourTable, uint8 fadeNow)
{
warning("stub SetPalette( %d, %d, %d )", startEntry, noEntries, fadeNow);
/*
int32 hr;
if (noEntries == 0)
{
RestorePalette();
return(RD_OK);
}
memcpy(&palCopy[startEntry][0], colourTable, noEntries * 4);
if ((lpPalette) && (fadeNow == RDPAL_INSTANT))
{
if (bFullScreen)
hr = IDirectDrawPalette_SetEntries(lpPalette, 0, startEntry, noEntries, (LPPALETTEENTRY) &palCopy[startEntry][0]);
else
hr = IDirectDrawPalette_SetEntries(lpPalette, 0, 10, 236, (LPPALETTEENTRY) &palCopy[10][0]);
if (hr != DD_OK)
{
DirectDrawError("Unable to set palette entries", hr);
return(hr);
}
}
*/
return(RD_OK);
}
int32 DimPalette(void)
{
warning("stub DimpPalette");
/*
uint8 *p;
uint32 i;
p = (uint8*) &palCopy[0][0];
for (i=0; i<256*4; i++)
{
*p++ /= 2;
}
if (lpPalette)
IDirectDrawPalette_SetEntries(lpPalette, 0, 0, 256, (LPPALETTEENTRY) &palCopy[0][0]);
*/
return RD_OK;
}
int32 FadeUp(float time)
{
if ((fadeStatus != RDFADE_BLACK) && (fadeStatus != RDFADE_NONE))
return(RDERR_FADEINCOMPLETE);
fadeTotalTime = (int32) (time * 1000);
fadeStatus = RDFADE_UP;
fadeStartTime = timeGetTime();
}
int32 FadeDown(float time)
{
if ((fadeStatus != RDFADE_BLACK) && (fadeStatus != RDFADE_NONE))
return(RDERR_FADEINCOMPLETE);
fadeTotalTime = (int32) (time * 1000);
fadeStatus = RDFADE_DOWN;
fadeStartTime = timeGetTime();
}
uint8 GetFadeStatus(void)
{
return(fadeStatus);
}
void FadeServer(void)
{
warning("stub FadeServer");
/*
int32 currentTime;
int16 fadeMultiplier;
int16 i;
HRESULT hr;
if (lpPalette == NULL)
return;
if (fadeStatus)
{
if (fadeStatus == RDFADE_UP)
{
currentTime = timeGetTime();
if (currentTime >= fadeStartTime + fadeTotalTime)
{
fadeStatus = RDFADE_NONE;
if (bFullScreen)
hr = IDirectDrawPalette_SetEntries(lpPalette, 0, 0, 256, (LPPALETTEENTRY) &palCopy[0][0]);
else
hr = IDirectDrawPalette_SetEntries(lpPalette, 0, 10, 236, (LPPALETTEENTRY) &palCopy[10][0]);
}
else
{
fadeMultiplier = (int16) (((int32) (currentTime - fadeStartTime) * 256) / fadeTotalTime);
for (i=0; i<256; i++)
{
fadePalette[i][0] = (palCopy[i][0] * fadeMultiplier) >> 8;
fadePalette[i][1] = (palCopy[i][1] * fadeMultiplier) >> 8;
fadePalette[i][2] = (palCopy[i][2] * fadeMultiplier) >> 8;
}
if (bFullScreen)
hr = IDirectDrawPalette_SetEntries(lpPalette, 0, 0, 256, (LPPALETTEENTRY) &fadePalette[0][0]);
else
hr = IDirectDrawPalette_SetEntries(lpPalette, 0, 10, 236, (LPPALETTEENTRY) &fadePalette[10][0]);
}
}
else if (fadeStatus == RDFADE_DOWN)
{
currentTime = timeGetTime();
if (currentTime >= fadeStartTime + fadeTotalTime)
{
for (i=0; i<256; i++)
{
fadePalette[i][0] = 0;
fadePalette[i][1] = 0;
fadePalette[i][2] = 0;
}
fadeStatus = RDFADE_BLACK;
if (bFullScreen)
hr = IDirectDrawPalette_SetEntries(lpPalette, 0, 0, 256, (LPPALETTEENTRY) &fadePalette[0][0]);
else
hr = IDirectDrawPalette_SetEntries(lpPalette, 0, 10, 236, (LPPALETTEENTRY) &fadePalette[10][0]);
}
else
{
fadeMultiplier = (int16) (((int32) (fadeTotalTime - (currentTime - fadeStartTime)) * 256) / fadeTotalTime);
for (i=0; i<256; i++)
{
fadePalette[i][0] = (palCopy[i][0] * fadeMultiplier) >> 8;
fadePalette[i][1] = (palCopy[i][1] * fadeMultiplier) >> 8;
fadePalette[i][2] = (palCopy[i][2] * fadeMultiplier) >> 8;
}
if (bFullScreen)
hr = IDirectDrawPalette_SetEntries(lpPalette, 0, 0, 256, (LPPALETTEENTRY) &fadePalette[0][0]);
else
hr = IDirectDrawPalette_SetEntries(lpPalette, 0, 10, 236, (LPPALETTEENTRY) &fadePalette[10][0]);
}
}
}
*/
}
--- NEW FILE: palette.h ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/palette.h,v 1.1 2003/07/28 01:47:41 khalek Exp $
*/
//=============================================================================
//
// Filename : palette.h
// Created : 8th November 1996
// By : P.R.Porter
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 08-Nov-96 PRP Internal driver interface to the palette
// functions and data.
//
// 1.1 11-Nov-96 PRP Added internal driver reference for
// RestorePalette which should be called by the
// windows message handler whenever the window
// has been minimised/maximised.
//
// 1.2 22-Nov-96 PRP Made the palette available to the rest of the
// driver96 library.
//
// 1.3 29-Nov-96 PRP Made paletteMatch table available to other
// parts of the driver library. Also, made the
// FadeServer available for the windows module
// to have access.
//
// 1.4 11-Apr-97 CJR Moved palCopy to driver96.h for use in the
// game engine.
//
//
// Summary : This include file defines links to all data which is
// defined in the palette.c module, but can be accessed by
// other parts of the driver96 library.
//
//
//=============================================================================
#ifndef PALETTE_H
#define PALETTE_H
extern uint8 paletteMatch[64*64*64];
extern int32 RestorePalette(void);
extern void FadeServer(void);
#endif
--- NEW FILE: rdwin.cpp ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/rdwin.cpp,v 1.1 2003/07/28 01:47:41 khalek Exp $
*/
#define WIN32_LEAN_AND_MEAN
//#include <windows.h>
//#include <windowsx.h>
#include <stdio.h>
#include "common/stdafx.h"
#include "engine.h"
#include "driver96.h"
#include "_mouse.h"
#include "keyboard.h"
#include "rdwin.h"
#include "d_draw.h"
#include "palette.h"
#include "render.h"
#include "menu.h"
#include "d_sound.h"
#include "../sword2.h"
#define MENUDEEP 40 // Temporary, until menu.h is written!
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(char *format,...) {
#ifdef __PALM_OS__
char buf[256]; // 1024 is too big overflow the stack
#else
char buf[1024];
#endif
va_list va;
va_start(va, format);
vsprintf(buf, format, va);
va_end(va);
#ifdef __GP32__ //ph0x FIXME: implement fprint?
printf("ZDEBUG: %s\n", buf);
#else
fprintf(stderr, "ZDEBUG: %s!\n", buf);
#endif
#if defined( USE_WINDBG )
strcat(buf, "\n");
#if defined( _WIN32_WCE )
TCHAR buf_unicode[1024];
MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
OutputDebugString(buf_unicode);
#else
OutputDebugString(buf);
#endif
#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!
//-----------------------------------------------------------------------------
void BS2State::parseEvents() {
OSystem::Event event;
while (_system->poll_event(&event)) {
switch(event.event_code) {
case OSystem::EVENT_KEYDOWN:
Zdebug("key %d", event.kbd.keycode);
if (event.kbd.flags==OSystem::KBD_CTRL) {
if (event.kbd.keycode == 'w')
GrabScreenShot();
}
WriteKey(event.kbd.keycode);
break;
case OSystem::EVENT_MOUSEMOVE:
mousex = event.mouse.x;
mousey = event.mouse.y;
_syst->set_mouse_pos(event.mouse.x, event.mouse.y);
break;
case OSystem::EVENT_LBUTTONDOWN:
LogMouseEvent(RD_LEFTBUTTONDOWN);
break;
case OSystem::EVENT_RBUTTONDOWN:
LogMouseEvent(RD_RIGHTBUTTONDOWN);
break;
case OSystem::EVENT_LBUTTONUP:
LogMouseEvent(RD_LEFTBUTTONUP);
break;
case OSystem::EVENT_RBUTTONUP:
LogMouseEvent(RD_RIGHTBUTTONUP);
break;
case OSystem::EVENT_QUIT:
Close_game();
RestoreDisplay();
CloseAppWindow();
break;
default:
break;
}
}
}
//-----------------------------------------------------------------------------
// 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_SetPalette(lpPrimarySurface, lpPalette);
if (hr == DDERR_SURFACELOST)
{
IDirectDrawSurface_Restore(lpPrimarySurface);
hr= IDirectDrawSurface_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)
{
warning("stub CloseAppWindow");
/*
DestroyWindow(hwnd);
*/
// just quit for now
g_bs2->_syst->quit();
return(RD_OK);
}
int32 ServiceWindows(void)
{
g_bs2->parseEvents();
// 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, uint8 *filename, uint32 line)
{
warning("stub _ReportDriverError 0x%.8x file: %s, line: %d ", error, (char *) filename, line);
/*
char errorText[128];
char name[80];
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(uint8 *error, 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)
{
warning("stub SetWindowName( %s )", windowName);
// SetWindowText(hwnd,windowName);
// strcpy(gameName,windowName);
}
--- NEW FILE: rdwin.h ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/rdwin.h,v 1.1 2003/07/28 01:47:41 khalek Exp $
*/
//=============================================================================
//
// Filename : rdwin.h
// Created : 20th August 1996
// By : P.R.Porter
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 16-Sep-96 PRP Driver interface to the rdwin functions/data
//
// 1.1 07-Nov-96 PRP Added debug windows message handler, and RECT
// defining the size of the current window.
//
// 1.2 04-Apr-97 PRP Oops - no changes
//
//
//
// Summary : This include file defines links to all data which is
// defined in the rdwin.c module, but can be accessed by
// other parts of the driver96 library.
//
//
//=============================================================================
#ifndef RDWIN_H
#define RDWIN_H
/*
extern HWND hwnd; // handle to the current window
extern RECT rcWindow; // size of the current window.
extern void Message(LPSTR fmt, ...);
*/
#endif
--- NEW FILE: render.cpp ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/render.cpp,v 1.1 2003/07/28 01:47:41 khalek Exp $
*/
[...1244 lines suppressed...]
for (i=0; i<xblocks[j] * yblocks[j]; i++)
if (*(blockSurfaces[j]+i))
IDirectDrawSurface2_Release(*(blockSurfaces[j] + i));
free(blockSurfaces[j]);
blockSurfaces[j] = NULL;
}
}
layer = 0;
// }
*/
return(RD_OK);
}
int32 EraseSoftwareScreenBuffer(void)
{
memset(myScreenBuffer, 0, RENDERWIDE * RENDERDEEP);
return(RD_OK);
}
--- NEW FILE: render.h ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/render.h,v 1.1 2003/07/28 01:47:41 khalek Exp $
*/
//=============================================================================
//
// Filename : render.h
// Created : 26th August 1996
// By : P.R.Porter
//
// Version Date By Description
// ------- --------- --- -----------------------------------------------
// 1.0 16-Sep-96 PRP Interface to the current scroll position.
//
// 1.1 23-Oct-96 PRP Added definition of _parallaxLine structure.
//
// 1.2 05-Nov-96 PRP Added definition of myScreenBuffer.
//
// 1.3 06-Nov-96 PRP Fixed definition of myScreenBuffer.
//
// 1.4 15-Nov-96 PRP Definition of menubar size removed, and put
// into menu.h
//
// 1.5 24-Jan-97 PRP Added references to parallaxScrollx and
// parallaxScrolly. These are used by the sprite
// drawing code to link sprites to parallax
// layers.
//
// 1.6 19-Mar-97 PRP Added profiling flag for testing purposes.
//
// 1.7 24-Mar-97 PRP Turned profiling off
//
// 1.8 08-Apr-97 JEL Made locationWide and locationDeep accessible
// to other drivers.
//
//
//
// Summary : This include file defines links to all data which is
// defined in the render.c module, but can be accessed by
// other parts of the driver96 library.
//
//
//=============================================================================
#ifndef RENDER_H
#define RENDER_H
#include "menu.h"
#define RENDERWIDE 640
#define ALIGNRENDERDEEP 480
#define RENDERDEEP (ALIGNRENDERDEEP - (MENUDEEP * 2))
#define PROFILING 0
typedef struct
{
uint16 packets;
uint16 offset;
} _parallaxLine;
extern int16 scrollx; // current x offset into background of display
extern int16 scrolly; // current y offset into background of display
extern int16 parallaxScrollx; // current x offset to link a sprite to the parallax layer
extern int16 parallaxScrolly; // current y offset to link a sprite to the parallax layer
extern int16 locationWide;
extern int16 locationDeep;
extern uint8 myScreenBuffer[RENDERWIDE * RENDERDEEP];
#endif
--- NEW FILE: sprite.cpp ---
/* 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: /cvsroot/scummvm/scummvm/bs2/driver/sprite.cpp,v 1.1 2003/07/28 01:47:41 khalek Exp $
*/
[...3201 lines suppressed...]
More information about the Scummvm-git-logs
mailing list