aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2007-11-14 11:46:55 +0000
committerPaul Gilbert2007-11-14 11:46:55 +0000
commit2a24ecaf9b95b7282eb2aa0f2ee73c4a84f2a07b (patch)
tree589af816e76bfe0d8c0f1fab2e15c3f55e7a5099 /engines
parentfdafe925e9ee07cdef4f27a472b4afb908485bb6 (diff)
downloadscummvm-rg350-2a24ecaf9b95b7282eb2aa0f2ee73c4a84f2a07b.tar.gz
scummvm-rg350-2a24ecaf9b95b7282eb2aa0f2ee73c4a84f2a07b.tar.bz2
scummvm-rg350-2a24ecaf9b95b7282eb2aa0f2ee73c4a84f2a07b.zip
Fixed clipping issues that were still occurring in some rooms
svn-id: r29500
Diffstat (limited to 'engines')
-rw-r--r--engines/lure/room.cpp48
-rw-r--r--engines/lure/room.h9
2 files changed, 52 insertions, 5 deletions
diff --git a/engines/lure/room.cpp b/engines/lure/room.cpp
index 12e58a1be6..b5afe377bd 100644
--- a/engines/lure/room.cpp
+++ b/engines/lure/room.cpp
@@ -39,9 +39,10 @@ RoomLayer::RoomLayer(uint16 screenId, bool backgroundLayer):
loadScreen(screenId);
byte *screenData = data().data();
int cellY;
+ int cellIndex = 0;
// Reset all the cells to unused
- Common::set_to((bool *) _cells, (bool *) _cells + GRID_SIZE, false);
+ Common::set_to((uint8 *) _cells, (uint8 *) _cells + GRID_SIZE, 0xff);
// Loop through each cell of the screen
for (cellY = 0; cellY < NUM_VERT_RECTS; ++cellY) {
@@ -64,7 +65,8 @@ RoomLayer::RoomLayer(uint16 screenId, bool backgroundLayer):
}
}
- _cells[cellY + NUM_EDGE_RECTS][cellX + NUM_EDGE_RECTS] = hasPixels;
+ _cells[cellY + NUM_EDGE_RECTS][cellX + NUM_EDGE_RECTS] =
+ hasPixels ? cellIndex++ : 0xff;
}
}
}
@@ -302,7 +304,7 @@ void Room::addLayers(Hotspot &h) {
int layerNum = 1;
while ((layerNum < 4) && (_layers[layerNum] != NULL) &&
- !_layers[layerNum]->isOccupied(xStart, yEnd))
+ (_layers[layerNum]->getCell(xStart, yEnd) == 0xff))
++layerNum;
if ((layerNum == 4) || (_layers[layerNum] == NULL)) continue;
@@ -318,7 +320,7 @@ void Room::addCell(int16 xp, int16 yp, int layerNum) {
Surface &s = _screen.screen();
while ((layerNum < 4) && (_layers[layerNum] != NULL) &&
- !_layers[layerNum]->isOccupied(xp + NUM_EDGE_RECTS, yp + NUM_EDGE_RECTS))
+ (_layers[layerNum]->getCell(xp + NUM_EDGE_RECTS, yp + NUM_EDGE_RECTS) >= 0xfe))
++layerNum;
if ((layerNum == 4) || (_layers[layerNum] == NULL)) return;
@@ -370,6 +372,43 @@ void Room::blockMerge() {
}
}
+void Room::layersPostProcess() {
+ for (int layerNum = 1; layerNum < 4; ++layerNum) {
+ if (_layers[layerNum] == NULL)
+ continue;
+
+ // Layer optimisation
+ for (int xp = NUM_EDGE_RECTS; xp < NUM_HORIZ_RECTS + NUM_EDGE_RECTS; ++xp) {
+ bool priorFlag = false, nextFlag = false;
+
+ for (int yp = NUM_EDGE_RECTS; yp < NUM_VERT_RECTS + NUM_EDGE_RECTS; ++yp) {
+ if (_layers[layerNum]->getCell(xp, yp) == 0xff) {
+ priorFlag = false;
+ nextFlag = false;
+ continue;
+ }
+
+ if (priorFlag && (_layers[layerNum]->getCell(xp - 1, yp) == 0xff))
+ _layers[layerNum]->setCell(xp - 1, yp, 0xfe);
+ if (nextFlag && (_layers[layerNum]->getCell(xp + 1, yp) == 0xff))
+ _layers[layerNum]->setCell(xp + 1, yp, 0xfe);
+
+ priorFlag = _layers[layerNum]->getCell(xp - 1, yp) != 0xff;
+ nextFlag = _layers[layerNum]->getCell(xp + 1, yp) != 0xff;
+ }
+ }
+
+ // Layer extension of final row to off-screen edge rows below
+
+ for (int xp = NUM_EDGE_RECTS + NUM_HORIZ_RECTS - 1; xp >= NUM_EDGE_RECTS; --xp) {
+ if (_layers[layerNum]->getCell(xp, NUM_EDGE_RECTS + NUM_VERT_RECTS - 1) != 0xff) {
+ for (int yp = NUM_VERT_RECTS + NUM_EDGE_RECTS; yp < FULL_VERT_RECTS; ++yp)
+ _layers[layerNum]->setCell(xp, yp, 0xfe);
+ }
+ }
+ }
+}
+
void Room::update() {
Surface &s = _screen.screen();
Resources &res = Resources::getReference();
@@ -519,6 +558,7 @@ void Room::setRoomNumber(uint16 newRoomNumber, bool showOverlay) {
layerNum == 0);
blockMerge();
+ layersPostProcess();
// Generate the palette for the room that will be faded in
//Palette p(MAIN_PALETTE_SIZE, NULL, RGB64);
diff --git a/engines/lure/room.h b/engines/lure/room.h
index 2c3fbf83cf..32cd0f4280 100644
--- a/engines/lure/room.h
+++ b/engines/lure/room.h
@@ -47,12 +47,18 @@ namespace Lure {
class RoomLayer: public Surface {
private:
- bool _cells[FULL_VERT_RECTS][FULL_HORIZ_RECTS];
+ byte _cells[FULL_VERT_RECTS][FULL_HORIZ_RECTS];
public:
RoomLayer(uint16 screenId, bool backgroundLayer);
bool isOccupied(byte cellX, byte cellY) {
+ return _cells[cellY][cellX] < 0xfe;
+ }
+ uint8 getCell(byte cellX, byte cellY) {
return _cells[cellY][cellX];
}
+ void setCell(byte cellX, byte cellY, byte value) {
+ _cells[cellY][cellX] = value;
+ }
};
enum CursorState {CS_NONE, CS_ACTION, CS_SEQUENCE, CS_TALKING, CS_BUMPED};
@@ -84,6 +90,7 @@ private:
void addLayers(Hotspot &h);
void addCell(int16 xp, int16 yp, int layerNum);
void blockMerge();
+ void layersPostProcess();
public:
RoomPathsDecompressedData tempLayer;
Room();