[Scummvm-cvs-logs] SF.net SVN: scummvm:[43406] scummvm/trunk/engines/cruise
dreammaster at users.sourceforge.net
dreammaster at users.sourceforge.net
Sat Aug 15 13:50:59 CEST 2009
Revision: 43406
http://scummvm.svn.sourceforge.net/scummvm/?rev=43406&view=rev
Author: dreammaster
Date: 2009-08-15 11:50:59 +0000 (Sat, 15 Aug 2009)
Log Message:
-----------
Added Dirty Rect handling functionality
Modified Paths:
--------------
scummvm/trunk/engines/cruise/background.cpp
scummvm/trunk/engines/cruise/background.h
scummvm/trunk/engines/cruise/backgroundIncrust.cpp
scummvm/trunk/engines/cruise/cell.cpp
scummvm/trunk/engines/cruise/detection.cpp
scummvm/trunk/engines/cruise/function.cpp
scummvm/trunk/engines/cruise/gfxModule.cpp
scummvm/trunk/engines/cruise/gfxModule.h
scummvm/trunk/engines/cruise/mainDraw.cpp
Modified: scummvm/trunk/engines/cruise/background.cpp
===================================================================
--- scummvm/trunk/engines/cruise/background.cpp 2009-08-15 10:45:51 UTC (rev 43405)
+++ scummvm/trunk/engines/cruise/background.cpp 2009-08-15 11:50:59 UTC (rev 43406)
@@ -30,6 +30,7 @@
uint8 colorMode = 0;
uint8 *backgroundScreens[8] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; // wasn't initialized in original, but it's probably better
+bool backgroundChanged[8] = { false, false, false, false, false, false, false, false };
backgroundTableStruct backgroundTable[8];
char hwPage[64000];
@@ -101,6 +102,8 @@
return (-2);
}
+ backgroundChanged[idx] = true;
+
ptrToFree = gfxModuleData.pPage10;
if (loadFileSub1(&ptrToFree, name, NULL) < 0) {
if (ptrToFree != gfxModuleData.pPage10)
Modified: scummvm/trunk/engines/cruise/background.h
===================================================================
--- scummvm/trunk/engines/cruise/background.h 2009-08-15 10:45:51 UTC (rev 43405)
+++ scummvm/trunk/engines/cruise/background.h 2009-08-15 11:50:59 UTC (rev 43406)
@@ -36,6 +36,7 @@
extern short int cvtPalette[0x20];
extern int CVTLoaded;
extern uint8 *backgroundScreens[8];
+extern bool backgroundChanged[8];
extern backgroundTableStruct backgroundTable[8];
int loadBackground(const char *name, int idx);
Modified: scummvm/trunk/engines/cruise/backgroundIncrust.cpp
===================================================================
--- scummvm/trunk/engines/cruise/backgroundIncrust.cpp 2009-08-15 10:45:51 UTC (rev 43405)
+++ scummvm/trunk/engines/cruise/backgroundIncrust.cpp 2009-08-15 11:50:59 UTC (rev 43406)
@@ -71,6 +71,8 @@
if (pBackground == NULL)
return;
+ backgroundChanged[pIncrust->backgroundIdx] = true;
+
int X = pIncrust->savedX;
int Y = pIncrust->savedY;
int width = pIncrust->saveWidth;
@@ -108,6 +110,8 @@
backgroundPtr = backgroundScreens[backgroundIdx];
+ backgroundChanged[backgroundIdx] = true;
+
assert(backgroundPtr != NULL);
currentHead = pHead;
@@ -218,6 +222,8 @@
// Poly
addBackgroundIncrustSub1(frame, pl->X, pl->Y, NULL, pl->scale, (char*)backgroundScreens[pl->backgroundIdx], (char *)filesDatabase[frame].subData.ptr);
}
+
+ backgroundChanged[pl->backgroundIdx] = true;
}
pl = pl2;
Modified: scummvm/trunk/engines/cruise/cell.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cell.cpp 2009-08-15 10:45:51 UTC (rev 43405)
+++ scummvm/trunk/engines/cruise/cell.cpp 2009-08-15 11:50:59 UTC (rev 43406)
@@ -176,6 +176,11 @@
if (ax) {
pNewElement->gfxPtr = renderText(width, ax);
}
+
+ // WORKAROUND: This is needed for the new dirty rect handling so as to properly refresh the screen
+ // when the copy protection screen is being shown
+ if ((messageIdx == 0) && !strcmp(overlayTable[overlayIdx].overlayName, "XX2"))
+ backgroundChanged[0] = true;
}
void removeCell(cellStruct *objPtr, int ovlNumber, int objectIdx, int objType, int backgroundPlane) {
Modified: scummvm/trunk/engines/cruise/detection.cpp
===================================================================
--- scummvm/trunk/engines/cruise/detection.cpp 2009-08-15 10:45:51 UTC (rev 43405)
+++ scummvm/trunk/engines/cruise/detection.cpp 2009-08-15 11:50:59 UTC (rev 43406)
@@ -26,7 +26,7 @@
#include "base/plugins.h"
-
+#include "common/savefile.h"
#include "engines/advancedDetector.h"
#include "cruise/cruise.h"
Modified: scummvm/trunk/engines/cruise/function.cpp
===================================================================
--- scummvm/trunk/engines/cruise/function.cpp 2009-08-15 10:45:51 UTC (rev 43405)
+++ scummvm/trunk/engines/cruise/function.cpp 2009-08-15 11:50:59 UTC (rev 43406)
@@ -510,6 +510,8 @@
gfxModuleData_gfxWaitVSync();
result = loadBackground(bgName, bgIdx);
+
+ gfxModuleData_addDirtyRect(Common::Rect(0, 0, 320, 200));
}
changeCursor(CURSOR_NORMAL);
@@ -788,6 +790,7 @@
if ((bgIdx >= 0) && (bgIdx < NBSCREENS) && (backgroundScreens[bgIdx])) {
memset(backgroundScreens[bgIdx], 0, 320 * 200);
+ backgroundChanged[bgIdx] = true;
strcpy(backgroundTable[0].name, "");
}
@@ -922,6 +925,7 @@
if (newPlane >= 0 && newPlane < NBSCREENS) {
if (backgroundScreens[newPlane]) {
masterScreen = newPlane;
+ backgroundChanged[newPlane] = true;
switchPal = 1;
}
}
@@ -936,8 +940,10 @@
if (backgroundScreens[backgroundIdx])
free(backgroundScreens[backgroundIdx]);
- if (masterScreen == backgroundIdx)
+ if (masterScreen == backgroundIdx) {
masterScreen = 0;
+ backgroundChanged[0] = true;
+ }
strcpy(backgroundTable[backgroundIdx].name, "");
} else {
Modified: scummvm/trunk/engines/cruise/gfxModule.cpp
===================================================================
--- scummvm/trunk/engines/cruise/gfxModule.cpp 2009-08-15 10:45:51 UTC (rev 43405)
+++ scummvm/trunk/engines/cruise/gfxModule.cpp 2009-08-15 11:50:59 UTC (rev 43406)
@@ -26,6 +26,8 @@
#include "common/system.h"
#include "common/endian.h"
+#include "common/list.h"
+#include "common/rect.h"
#include "cruise/cruise.h"
#include "cruise/cruise_main.h"
@@ -41,6 +43,12 @@
int palDirtyMin = 256;
int palDirtyMax = -1;
+typedef Common::List<Common::Rect> RectList;
+RectList _dirtyRects;
+RectList _priorFrameRects;
+
+bool _dirtyRectScreen = false;
+
gfxModuleDataStruct gfxModuleData = {
0, // use Tandy
0, // use EGA
@@ -229,7 +237,47 @@
flip();
}
+void gfxModuleData_addDirtyRect(const Common::Rect &r) {
+ _dirtyRects.push_back(Common::Rect( MAX(r.left, (int16)0), MAX(r.top, (int16)0),
+ MIN(r.right, (int16)320), MIN(r.bottom, (int16)200)));
+}
+
+/**
+ * Creates the union of two rectangles.
+ */
+static bool unionRectangle(Common::Rect &pDest, const Common::Rect &pSrc1, const Common::Rect &pSrc2) {
+ pDest.left = MIN(pSrc1.left, pSrc2.left);
+ pDest.top = MIN(pSrc1.top, pSrc2.top);
+ pDest.right = MAX(pSrc1.right, pSrc2.right);
+ pDest.bottom = MAX(pSrc1.bottom, pSrc2.bottom);
+
+ return !pDest.isEmpty();
+}
+
+static void mergeClipRects() {
+ RectList::iterator rOuter, rInner;
+
+ for (rOuter = _dirtyRects.begin(); rOuter != _dirtyRects.end(); ++rOuter) {
+ rInner = rOuter;
+ while (++rInner != _dirtyRects.end()) {
+
+ if ((*rOuter).intersects(*rInner)) {
+ // these two rectangles overlap, so translate it to a bigger rectangle
+ // that contains both of them
+ unionRectangle(*rOuter, *rOuter, *rInner);
+
+ // remove the inner rect from the list
+ _dirtyRects.erase(rInner);
+
+ // move back to beginning of list
+ rInner = rOuter;
+ }
+ }
+ }
+}
+
void flip() {
+ RectList::iterator dr;
int i;
byte paletteRGBA[256 * 4];
@@ -245,7 +293,29 @@
palDirtyMax = -1;
}
- g_system->copyRectToScreen(globalScreen, 320, 0, 0, 320, 200);
+ // Make a copy of the prior frame's dirty rects, and then backup the current frame's rects
+ RectList tempList = _priorFrameRects;
+ _priorFrameRects = _dirtyRects;
+
+ // Merge the prior frame's dirty rects into the current frame's list
+ for (dr = tempList.begin(); dr != tempList.end(); ++dr) {
+ Common::Rect &r = *dr;
+ _dirtyRects.push_back(Common::Rect(r.left, r.top, r.right, r.bottom));
+ }
+
+ // Merge any overlapping rects to simplify the drawing process
+ mergeClipRects();
+
+ // Copy any modified areas
+ for (dr = _dirtyRects.begin(); dr != _dirtyRects.end(); ++dr) {
+ Common::Rect &r = *dr;
+ g_system->copyRectToScreen(globalScreen + 320 * r.top + r.left, 320,
+ r.left, r.top, r.width(), r.height());
+ }
+
+ _dirtyRects.clear();
+
+ // Allow the screen to update
g_system->updateScreen();
}
Modified: scummvm/trunk/engines/cruise/gfxModule.h
===================================================================
--- scummvm/trunk/engines/cruise/gfxModule.h 2009-08-15 10:45:51 UTC (rev 43405)
+++ scummvm/trunk/engines/cruise/gfxModule.h 2009-08-15 11:50:59 UTC (rev 43406)
@@ -62,6 +62,7 @@
void gfxModuleData_convertOldPalColor(uint16 oldColor, uint8 *pOutput);
void gfxModuleData_setPalEntries(const byte *ptr, int start, int num);
void gfxModuleData_setPal256(const byte *ptr);
+void gfxModuleData_addDirtyRect(const Common::Rect &r);
void flip(void);
void drawSolidBox(int32 x1, int32 y1, int32 x2, int32 y2, uint8 colour);
void resetBitmap(uint8 *dataPtr, int32 dataSize);
Modified: scummvm/trunk/engines/cruise/mainDraw.cpp
===================================================================
--- scummvm/trunk/engines/cruise/mainDraw.cpp 2009-08-15 10:45:51 UTC (rev 43405)
+++ scummvm/trunk/engines/cruise/mainDraw.cpp 2009-08-15 11:50:59 UTC (rev 43406)
@@ -1121,6 +1121,8 @@
if (spriteY1 == spriteY2)
return;
+ gfxModuleData_addDirtyRect(Common::Rect(spriteX2, spriteY2, spriteX1, spriteY1));
+
var_8 = 0;
memset(polygonMask, 0xFF, (320*200) / 8);
@@ -1177,6 +1179,8 @@
globalY = 198 - pGfxPtr->height;
}
+ gfxModuleData_addDirtyRect(Common::Rect(globalX, globalY, globalX + width, globalY + height));
+
initialOuput = ouputPtr + (globalY * 320) + globalX;
for (yp = 0; yp < height; yp++) {
@@ -1206,6 +1210,9 @@
int x = 0;
int y = 0;
+ // Flag the given area as having been changed
+ gfxModuleData_addDirtyRect(Common::Rect(xs, ys, xs + width - 1, ys + height - 1));
+
cellStruct* plWork = currentObjPtr;
int workBufferSize = height * (width / 8);
@@ -1406,6 +1413,10 @@
if (bgPtr) {
gfxModuleData_gfxCopyScreen(bgPtr, gfxModuleData.pPage10);
+ if (backgroundChanged[masterScreen]) {
+ backgroundChanged[masterScreen] = false;
+ gfxModuleData_addDirtyRect(Common::Rect(0, 0, 320, 200));
+ }
}
autoCellHead.next = NULL;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list