[Scummvm-cvs-logs] CVS: scummvm/bs2/driver driver96.h,1.54,1.55 language.cpp,1.8,1.9 palette.cpp,1.20,1.21 rdwin.cpp,1.31,1.32 render.cpp,1.34,1.35

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Tue Oct 7 00:08:06 CEST 2003


Update of /cvsroot/scummvm/scummvm/bs2/driver
In directory sc8-pr-cvs1:/tmp/cvs-serv2418/driver

Modified Files:
	driver96.h language.cpp palette.cpp rdwin.cpp render.cpp 
Log Message:
Some cleanup, some code removal and some unstubbing. Nothing important.


Index: driver96.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/driver/driver96.h,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- driver96.h	5 Oct 2003 15:28:15 -0000	1.54
+++ driver96.h	7 Oct 2003 07:07:47 -0000	1.55
@@ -303,7 +303,6 @@
 //-----------------------------------------------------------------------------
 extern int32 GetLanguageVersion(uint8 *version);
 extern int32 SetLanguageVersion(uint8 version);
-extern int32 GetGameName(uint8 *name);
 //-----------------------------------------------------------------------------
 
 //-----------------------------------------------------------------------------

Index: language.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/driver/language.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- language.cpp	4 Oct 2003 08:31:20 -0000	1.8
+++ language.cpp	7 Oct 2003 07:07:47 -0000	1.9
@@ -66,34 +66,4 @@
 	return RD_OK;
 }
 
-/**
- * Fills the string pointed to by 'name' with the title of the game, depending
- * upon what the current language version is.
- * @param name buffer to store the title of the game in
- */
-
-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;
-}
-
 } // End of namespace Sword2

Index: palette.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/driver/palette.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- palette.cpp	4 Oct 2003 08:07:03 -0000	1.20
+++ palette.cpp	7 Oct 2003 07:07:47 -0000	1.21
@@ -29,11 +29,10 @@
 #define PALTABLESIZE 64 * 64 * 64
 
 uint8 palCopy[256][4];
-uint8 fadePalette[256][4];
-
-uint8 paletteMatch[PALTABLESIZE];
 
-uint8 fadeStatus = RDFADE_NONE;
+static uint8 fadePalette[256][4];
+static uint8 paletteMatch[PALTABLESIZE];
+static uint8 fadeStatus = RDFADE_NONE;
 
 static int32 fadeStartTime;
 static int32 fadeTotalTime;
@@ -65,8 +64,7 @@
 	min = diff;
 	minIndex = 0;
 	if (diff > 0) {
-		i = 1;
-		while (i < 256)	{
+		for (i = 1; i < 256; i++) {
 			diffred = palCopy[i][0] - r;
 			diffgreen = palCopy[i][1] - g;
 			diffblue = palCopy[i][2] - b;
@@ -78,7 +76,6 @@
 				if (min == 0)
 					break;
 			}
-			i++;
 		}
 	}
 
@@ -111,7 +108,7 @@
 			}
 		}
 	} else {
-		// The provided data is th new palette match table
+		// The provided data is the new palette match table
 		memcpy(paletteMatch, data, PALTABLESIZE);
 	}
 
@@ -155,10 +152,10 @@
 
 int32 DimPalette(void) {
 	byte *p = (byte *) palCopy;
-	uint32 i;
 
-	for (i = 0; i < 256 * 4; i++)
+	for (int i = 0; i < 256 * 4; i++)
 		p[i] /= 2;
+
 	g_system->set_palette(p, 0, 256);
 	return RD_OK;
 }

Index: rdwin.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/driver/rdwin.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- rdwin.cpp	4 Oct 2003 08:07:03 -0000	1.31
+++ rdwin.cpp	7 Oct 2003 07:07:47 -0000	1.32
@@ -18,8 +18,7 @@
  */
 
 #include "common/stdafx.h"
-#include "base/engine.h"
-#include "common/timer.h"
+#include "bs2/sword2.h"
 #include "bs2/driver/driver96.h"
 #include "bs2/driver/_mouse.h"
 #include "bs2/driver/keyboard.h"
@@ -29,12 +28,9 @@
 #include "bs2/driver/render.h"
 #include "bs2/driver/menu.h"
 #include "bs2/driver/d_sound.h"
-#include "bs2/sword2.h"
 
 namespace Sword2 {
 
-#define MENUDEEP 40		// Temporary, until menu.h is written!
-
 // ---------------------------------------------------------------------------
 // OSystem Event Handler. Full of cross platform goodness and 99% fat free!
 // ---------------------------------------------------------------------------
@@ -117,14 +113,14 @@
 }
 
 /**
- * Set the window name to windowName and stores this name in gameName for
- * future use.
+ * Set the window title
  */
 
 void SetWindowName(const char *windowName) {
-	warning("stub SetWindowName( %s )", windowName);
-	// SetWindowText(hwnd, windowName);
-	// strcpy(gameName, windowName);
+	OSystem::Property prop;
+
+	prop.caption = windowName;
+	g_system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
 }
 
 } // End of namespace Sword2

Index: render.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/driver/render.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- render.cpp	5 Oct 2003 15:28:15 -0000	1.34
+++ render.cpp	7 Oct 2003 07:07:47 -0000	1.35
@@ -49,14 +49,14 @@
 
 #define RENDERAVERAGETOTAL 4
 
-int32 renderCountIndex = 0;
-int32 renderTimeLog[RENDERAVERAGETOTAL] = { 60, 60, 60, 60 };
-int32 initialTime;
-int32 startTime;
-int32 totalTime;
-int32 renderAverageTime = 60;
-int32 framesPerGameCycle;
-int32 renderTooSlow;
+static int32 renderCountIndex = 0;
+static int32 renderTimeLog[RENDERAVERAGETOTAL] = { 60, 60, 60, 60 };
+static int32 initialTime;
+static int32 startTime;
+static int32 totalTime;
+static int32 renderAverageTime = 60;
+static int32 framesPerGameCycle;
+static int32 renderTooSlow;
 
 #define BLOCKWIDTH 64
 #define BLOCKHEIGHT 64
@@ -64,8 +64,8 @@
 #define BLOCKHBITS 6
 #define MAXLAYERS 5
 
-uint8 xblocks[MAXLAYERS];
-uint8 yblocks[MAXLAYERS];
+static uint8 xblocks[MAXLAYERS];
+static uint8 yblocks[MAXLAYERS];
 
 // blockSurfaces stores an array of sub-blocks for each of the parallax layers.
 
@@ -74,7 +74,7 @@
 	bool transparent;
 } BlockSurface;
 
-BlockSurface **blockSurfaces[MAXLAYERS] = { 0, 0, 0, 0, 0 };
+static BlockSurface **blockSurfaces[MAXLAYERS] = { 0, 0, 0, 0, 0 };
 
 void UploadRect(Common::Rect *r) {
 	g_system->copy_rect(lpBackBuffer + r->top * screenWide + r->left,
@@ -403,41 +403,16 @@
  */
 
 int32 PlotPoint(uint16 x, uint16 y, uint8 colour) {
-	warning("stub PlotPoint( %d, %d, %d )", x, y, colour);
-/*
+	uint8 *buf = lpBackBuffer + 40 * RENDERWIDE;
 	int16 newx, newy;
 	
 	newx = x - scrollx;
 	newy = y - scrolly;
 
-	if ((newx < 0) || (newx > RENDERWIDE) || (newy < 0) || (newy > RENDERDEEP))
-	{
-		return(RD_OK);
-	}
-	if (renderCaps & RDBLTFX_ALLHARDWARE)
-	{
-		DDSURFACEDESC ddsd;
-		HRESULT hr;
-
-		ddsd.dwSize = sizeof(DDSURFACEDESC);
-		hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
-		if (hr != DD_OK)
-		{
-			hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
-		}
-
-		if (hr == DD_OK)
-		{
-
-			*((uint8 *) ddsd.lpSurface + (newy + 40) * ddsd.lPitch + newx) = colour;
-			IDirectDrawSurface2_Unlock(lpBackBuffer, ddsd.lpSurface);
-		}
-	}
-	else
-		myScreenBuffer[newy * RENDERWIDE + newx] = colour;
-*/	
-	return(RD_OK);
+	if (newx >= 0 && newx < RENDERWIDE && newy >= 0 && newy < RENDERDEEP)
+		buf[newy * RENDERWIDE + newx] = colour;
 
+	return RD_OK;
 }
 
 /**
@@ -451,46 +426,24 @@
 
 // Uses Bressnham's incremental algorithm!
 int32 DrawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour) {
-	warning("stub DrawLine( %d, %d, %d, %d, %d )", x0, y0, x1, y1, colour);
-/*
+	uint8 *buf = lpBackBuffer + 40 * RENDERWIDE;
 	int dx, dy;
 	int dxmod, dymod;
 	int ince, incne;
-	int	d;
+	int d;
 	int x, y;
 	int addTo;
-	DDSURFACEDESC ddsd;
-	HRESULT hr;
 
 	x1 -= scrollx;
 	y1 -= scrolly;
 	x0 -= scrollx;
 	y0 -= scrolly;
 
-
 	// Lock the surface if we're rendering to the back buffer.
 
-	if (renderCaps & RDBLTFX_ALLHARDWARE)
-	{
-		ddsd.dwSize = sizeof(DDSURFACEDESC);
-		hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
-		if (hr != DD_OK)
-		{
-			hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
-		}
-		if (hr != DD_OK)
-			return(RD_OK);
-
-		(uint8 *) ddsd.lpSurface += (40 * ddsd.lPitch);
-
-	}
-
-
-
-
 	//Make sure we're going from left to right
-	if (x1 < x0)
-	{
+
+	if (x1 < x0) {
 		x = x1;
 		x1 = x0;
 		x0 = x;
@@ -498,6 +451,7 @@
 		y1 = y0;
 		y0 = y;
 	}
+
 	dx = x1 - x0;
 	dy = y1 - y0;
 	
@@ -511,42 +465,29 @@
 	else
 		dymod = dy;
 
-	if (dxmod >= dymod)
-	{
-		if (dy > 0)
-		{
+	if (dxmod >= dymod) {
+		if (dy > 0) {
 			d = 2 * dy - dx;
 			ince = 2 * dy;
 			incne = 2 * (dy - dx);
 			x = x0;
 			y = y0;
-			if ((x >= 0) && (x < RENDERWIDE) && (y >= 0) && (y < RENDERDEEP))
-				if (renderCaps & RDBLTFX_ALLHARDWARE)
-					*((uint8 *) ddsd.lpSurface + y * ddsd.lPitch + x) = colour;
-				else
-					myScreenBuffer[y * RENDERWIDE + x] = colour;
-			while (x < x1)
-			{
-				if (d <= 0)
-				{
+			if (x >= 0 && x < RENDERWIDE && y >= 0 && y < RENDERDEEP)
+				buf[y * RENDERWIDE + x] = colour;
+
+			while (x < x1) {
+				if (d <= 0) {
 					d += ince;
-					x += 1;
-				}
-				else
-				{
+					x++;
+				} else {
 					d += incne;
-					x += 1;
-					y += 1;
+					x++;
+					y++;
 				}
-				if ((x >= 0) && (x < RENDERWIDE) && (y >= 0) && (y < RENDERDEEP))
-					if (renderCaps & RDBLTFX_ALLHARDWARE)
-						*((uint8 *) ddsd.lpSurface + y * ddsd.lPitch + x) = colour;
-					else
-						myScreenBuffer[y * RENDERWIDE + x] = colour;
+				if (x >= 0 && x < RENDERWIDE && y >= 0 && y < RENDERDEEP)
+					buf[y * RENDERWIDE + x] = colour;
 			}
-		}
-		else
-		{
+		} else {
 			addTo = y0;
 			y0 = 0;
 			y1 -= addTo;
@@ -558,39 +499,26 @@
 			incne = 2 * (dy - dx);
 			x = x0;
 			y = y0;
-			if ((x >= 0) && (x < RENDERWIDE) && (addTo - y >= 0) && (addTo - y < RENDERDEEP))
-				if (renderCaps & RDBLTFX_ALLHARDWARE)
-					*((uint8 *) ddsd.lpSurface + (addTo - y) * ddsd.lPitch + x) = colour;
-				else
-					myScreenBuffer[(addTo - y) * RENDERWIDE + x] = colour;
-			while (x < x1)
-			{
-				if (d <= 0)
-				{
+			if (x >= 0 && x < RENDERWIDE && addTo - y >= 0 && addTo - y < RENDERDEEP)
+				buf[(addTo - y) * RENDERWIDE + x] = colour;
+
+			while (x < x1) {
+				if (d <= 0) {
 					d += ince;
-					x += 1;
-				}
-				else
-				{
+					x++;
+				} else {
 					d += incne;
-					x += 1;
-					y += 1;
+					x++;
+					y++;
 				}
-				if ((x >= 0) && (x < RENDERWIDE) && (addTo - y >= 0) && (addTo - y < RENDERDEEP))
-					if (renderCaps & RDBLTFX_ALLHARDWARE)
-						*((uint8 *) ddsd.lpSurface + (addTo - y) * ddsd.lPitch + x) = colour;
-					else
-						myScreenBuffer[(addTo - y) * RENDERWIDE + x] = colour;
+				if (x >= 0 && x < RENDERWIDE && addTo - y >= 0 && addTo - y < RENDERDEEP)
+					buf[(addTo - y) * RENDERWIDE + x] = colour;
 			}
-
 		}
-	}
-	else
-	{
+	} else {
 		//OK, y is now going to be the single increment.
 		//	Ensure the line is going top to bottom
-		if (y1 < y0)
-		{
+		if (y1 < y0) {
 			x = x1;
 			x1 = x0;
 			x0 = x;
@@ -601,40 +529,28 @@
 		dx = x1 - x0;
 		dy = y1 - y0;
 
-		if (dx > 0)
-		{
+		if (dx > 0) {
 			d = 2 * dx - dy;
 			ince = 2 * dx;
 			incne = 2 * (dx - dy);
 			x = x0;
 			y = y0;
-			if ((x >= 0) && (x < RENDERWIDE) && (y >= 0) && (y < RENDERDEEP))
-				if (renderCaps & RDBLTFX_ALLHARDWARE)
-					*((uint8 *) ddsd.lpSurface + y * ddsd.lPitch + x) = colour;
-				else
-					myScreenBuffer[y * RENDERWIDE + x] = colour;
-			while (y < y1)
-			{
-				if (d <= 0)
-				{
+			if (x >= 0 && x < RENDERWIDE && y >= 0 && y < RENDERDEEP)
+				buf[y * RENDERWIDE + x] = colour;
+
+			while (y < y1) {
+				if (d <= 0) {
 					d += ince;
-					y += 1;
-				}
-				else
-				{
+					y++;
+				} else {
 					d += incne;
-					x += 1;
-					y += 1;
+					x++;
+					y++;
 				}
-				if ((x >= 0) && (x < RENDERWIDE) && (y >= 0) && (y < RENDERDEEP))
-					if (renderCaps & RDBLTFX_ALLHARDWARE)
-						*((uint8 *) ddsd.lpSurface + y * ddsd.lPitch + x) = colour;
-					else
-						myScreenBuffer[y * RENDERWIDE + x] = colour;
+				if (x >= 0 && x < RENDERWIDE && y >= 0 && y < RENDERDEEP)
+					buf[y * RENDERWIDE + x] = colour;
 			}
-		}
-		else
-		{
+		} else {
 			addTo = x0;
 			x0 = 0;
 			x1 -= addTo;
@@ -646,41 +562,24 @@
 			incne = 2 * (dx - dy);
 			x = x0;
 			y = y0;
-			if ((addTo - x >= 0) && (addTo - x < RENDERWIDE) && (y >= 0) && (y < RENDERDEEP))
-				if (renderCaps & RDBLTFX_ALLHARDWARE)
-					*((uint8 *) ddsd.lpSurface + y * ddsd.lPitch + addTo - x) = colour;
-				else
-					myScreenBuffer[y * RENDERWIDE + addTo - x] = colour;
-			while (y < y1)
-			{
-				if (d <= 0)
-				{
+			if (addTo - x >= 0 && addTo - x < RENDERWIDE && y >= 0 && y < RENDERDEEP)
+				buf[y * RENDERWIDE + addTo - x] = colour;
+
+			while (y < y1) {
+				if (d <= 0) {
 					d += ince;
-					y += 1;
-				}
-				else
-				{
+					y++;
+				} else {
 					d += incne;
-					x += 1;
-					y += 1;
+					x++;
+					y++;
 				}
-				if ((addTo - x >= 0) && (addTo - x < RENDERWIDE) && (y >= 0) && (y < RENDERDEEP))
-					if (renderCaps & RDBLTFX_ALLHARDWARE)
-						*((uint8 *) ddsd.lpSurface + y * ddsd.lPitch + addTo - x) = colour;
-					else
-						myScreenBuffer[y * RENDERWIDE + addTo - x] = colour;
+				if (addTo - x >= 0 && addTo - x < RENDERWIDE && y >= 0 && y < RENDERDEEP)
+					buf[y * RENDERWIDE + addTo - x] = colour;
 			}
-
 		}
-
 	}
 
-	if (renderCaps & RDBLTFX_ALLHARDWARE)
-	{
-		(uint8 *) ddsd.lpSurface -= (40 * ddsd.lPitch);
-		IDirectDrawSurface2_Unlock(lpBackBuffer, ddsd.lpSurface);
-	}
-*/
 	return RD_OK;
 }
 
@@ -796,7 +695,7 @@
 	startTime = time;
 	renderAverageTime = (renderTimeLog[0] + renderTimeLog[1] + renderTimeLog[2] + renderTimeLog[3]) >> 2;
 
-	framesPerGameCycle += 1;
+	framesPerGameCycle++;
 
 	if (++renderCountIndex == RENDERAVERAGETOTAL)
 		renderCountIndex = 0;
@@ -869,8 +768,6 @@
 
 	// This function is called to re-initialise the layers if they have
 	// been lost. We know this if the layers have already been assigned.
-
-	// TODO: Can layers still be lost, or is that a DirectDraw-ism?
 
 	if (layer == MAXLAYERS)
 		CloseBackgroundLayer();





More information about the Scummvm-git-logs mailing list