aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2006-02-21 09:25:39 +0000
committerPaul Gilbert2006-02-21 09:25:39 +0000
commitdd6b20702546a52e871df1eaeb2a752238437e24 (patch)
tree42644fffda56530cd82029207c6446024289a536 /engines
parent4d6b3dd5f31963eb287c46ffd2f92bc774dbfdd9 (diff)
downloadscummvm-rg350-dd6b20702546a52e871df1eaeb2a752238437e24.tar.gz
scummvm-rg350-dd6b20702546a52e871df1eaeb2a752238437e24.tar.bz2
scummvm-rg350-dd6b20702546a52e871df1eaeb2a752238437e24.zip
Improved layering of objects within rooms - for example, Ratpouch now properly shows up on the rack
svn-id: r20804
Diffstat (limited to 'engines')
-rw-r--r--engines/lure/room.cpp68
-rw-r--r--engines/lure/room.h10
2 files changed, 34 insertions, 44 deletions
diff --git a/engines/lure/room.cpp b/engines/lure/room.cpp
index cf0e7e7bbb..f6f5ec233b 100644
--- a/engines/lure/room.cpp
+++ b/engines/lure/room.cpp
@@ -35,10 +35,12 @@ static Room *int_room;
RoomLayer::RoomLayer(uint16 screenId, bool backgroundLayer):
Surface(FULL_SCREEN_WIDTH, FULL_SCREEN_HEIGHT) {
loadScreen(screenId);
- byte cellIndex = 0;
byte *screenData = data().data();
- memset(_cells, 0xff, FULL_HORIZ_RECTS*FULL_VERT_RECTS);
+ // Reset all the cells to false
+ for (int cellY = 0; cellY < FULL_VERT_RECTS; ++cellY)
+ for (int cellX = 0; cellX < FULL_HORIZ_RECTS; ++cellX)
+ _cells[cellY][cellX] = false;
// Loop through each cell of the screen
for (int cellY = 0; cellY < NUM_VERT_RECTS; ++cellY) {
@@ -61,8 +63,7 @@ RoomLayer::RoomLayer(uint16 screenId, bool backgroundLayer):
}
}
- _cells[(cellY + NUM_EDGE_RECTS) * FULL_HORIZ_RECTS + NUM_EDGE_RECTS +
- cellX] = !hasPixels ? 0xff : cellIndex++;
+ _cells[cellY + NUM_EDGE_RECTS][cellX + NUM_EDGE_RECTS] = hasPixels;
}
}
}
@@ -242,7 +243,7 @@ uint8 Room::checkRoomExits() {
void Room::flagCoveredCells(Hotspot &h) {
int16 yStart = (h.y() - MENUBAR_Y_SIZE) / RECT_SIZE;
- int16 yEnd = (h.y() + h.height() - 1 - MENUBAR_Y_SIZE) / RECT_SIZE;
+ int16 yEnd = (h.y() + h.heightCopy() - 1 - MENUBAR_Y_SIZE) / RECT_SIZE;
int16 numY = yEnd - yStart + 1;
int16 xStart = h.x() / RECT_SIZE;
int16 xEnd = (h.x() + h.width() - 1) / RECT_SIZE;
@@ -255,8 +256,7 @@ void Room::flagCoveredCells(Hotspot &h) {
int indexPos = index + xP;
if ((indexPos < 0) || (indexPos >= NUM_HORIZ_RECTS*NUM_VERT_RECTS))
continue;
- _cells[index+xP] |= 0x81;
- _cells2[index+xP] |= 1;
+ _cells[index+xP] = true;
}
index += NUM_HORIZ_RECTS;
}
@@ -286,7 +286,7 @@ void Room::addLayers(Hotspot &h) {
int16 xEnd = (hsX + h.width()) / RECT_SIZE;
int16 numX = xEnd - xStart + 1;
int16 yStart = hsY / RECT_SIZE;
- int16 yEnd = (hsY + h.height() - 1) / RECT_SIZE;
+ int16 yEnd = (hsY + h.heightCopy() - 1) / RECT_SIZE;
int16 numY = yEnd - yStart + 1;
for (int16 xCtr = 0; xCtr < numX; ++xCtr, ++xStart) {
@@ -294,16 +294,9 @@ void Room::addLayers(Hotspot &h) {
if (xs < 0) continue;
// Check foreground layers for an occupied one
-/* DEBUG
- int layerNum = 1;
- while ((layerNum < _numLayers) &&
- !_layers[layerNum]->isOccupied(xStart, yEnd))
- ++layerNum;
- if (layerNum == _numLayers) continue;
-*/
+
int layerNum = _numLayers - 1;
- while ((layerNum > 0) &&
- !_layers[layerNum]->isOccupied(xStart, yEnd))
+ while ((layerNum > 0) && !_layers[layerNum]->isOccupied(xStart, yEnd))
--layerNum;
if (layerNum == 0) continue;
@@ -321,11 +314,7 @@ void Room::addCell(int16 xp, int16 yp, int layerNum) {
while ((layerNum > 0) && !_layers[layerNum]->isOccupied(xp+4, yp+4))
--layerNum;
if (layerNum == 0) return;
-/* DEBUG
- while ((layerNum < _numLayers) && !_layers[layerNum]->isOccupied(xp+4, yp+4))
- ++layerNum;
- if (layerNum == _numLayers) return;
-*/
+
RoomLayer *layer = _layers[layerNum];
int index = ((yp * RECT_SIZE + 8) * FULL_SCREEN_WIDTH) + (xp * RECT_SIZE);
@@ -342,10 +331,6 @@ void Room::addCell(int16 xp, int16 yp, int layerNum) {
srcPos += FULL_SCREEN_WIDTH - RECT_SIZE;
destPos += FULL_SCREEN_WIDTH - RECT_SIZE;
}
-
- // Note: old version of screen layers load compresses loaded layers down to
- // only a set of the non-empty rects. Since modern memory allows me to load
- // all the layers completely, I'm bypassing the need to use cell index values
}
void Room::update() {
@@ -355,12 +340,10 @@ void Room::update() {
HotspotList &hotspots = res.activeHotspots();
HotspotList::iterator i;
- memset(_cells, 0x81, NUM_HORIZ_RECTS*NUM_VERT_RECTS);
- memset(_cells2, 0x81, NUM_HORIZ_RECTS*NUM_VERT_RECTS);
+ memset(_cells, false, NUM_HORIZ_RECTS*NUM_VERT_RECTS);
+ // Copy the background to the temporary srceen surface
_layers[0]->copyTo(&s);
- for (int ctr = 1; ctr < _numLayers; ++ctr)
- _layers[ctr]->transparentCopyTo(&s);
// Handle first layer (layer 3)
for (i = hotspots.begin(); i != hotspots.end(); ++i) {
@@ -380,15 +363,12 @@ void Room::update() {
if ((h->roomNumber() != _roomNumber) || !h->isActiveAnimation()
|| (h->layer() != 1))
continue;
- int16 endY = h->y() + h->height();
+ int16 endY = h->y() + h->heightCopy();
for (iTemp = tempList.begin(); iTemp != tempList.end(); ++iTemp) {
Hotspot *hTemp = iTemp.operator*();
- int16 tempY = hTemp->y() + hTemp->height();
- if (endY < tempY) {
- if (iTemp != tempList.begin()) --iTemp;
- break;
- }
+ int16 tempY = hTemp->y() + hTemp->heightCopy();
+ if (endY < tempY) break;
}
tempList.insert(iTemp, h);
}
@@ -408,7 +388,21 @@ void Room::update() {
}
}
- // Show any active talk dialog and voice
+ // Loop to add in any remaining cells
+ for (int yp = 0; yp < NUM_VERT_RECTS; ++yp) {
+ for (int xp = 0; xp < NUM_HORIZ_RECTS; ++xp) {
+ if (_cells[yp*NUM_HORIZ_RECTS+xp]) continue;
+
+ int layerNum = _numLayers - 1;
+ while ((layerNum > 0) && !_layers[layerNum]->isOccupied(xp+4, yp+4))
+ --layerNum;
+ if (layerNum != 0)
+ // Add in the cell
+ addCell(xp, yp, layerNum);
+ }
+ }
+
+ // Show any active talk dialog
if (_talkDialog) {
_talkDialog->surface().copyTo(&s, _talkDialogX, _talkDialogY);
}
diff --git a/engines/lure/room.h b/engines/lure/room.h
index e1731f8359..3ba9312f8a 100644
--- a/engines/lure/room.h
+++ b/engines/lure/room.h
@@ -43,14 +43,11 @@ namespace Lure {
class RoomLayer: public Surface {
private:
- byte _cells[FULL_HORIZ_RECTS*FULL_VERT_RECTS];
+ bool _cells[FULL_VERT_RECTS][FULL_HORIZ_RECTS];
public:
RoomLayer(uint16 screenId, bool backgroundLayer);
- byte cellVal(byte cellX, byte cellY) {
- return _cells[FULL_HORIZ_RECTS*cellY + cellX];
- }
bool isOccupied(byte cellX, byte cellY) {
- return cellVal(cellX, cellY) != 0xff;
+ return _cells[cellY][cellX];
}
};
@@ -68,8 +65,7 @@ private:
bool _showInfo;
uint8 _numLayers;
RoomLayer *_layers[MAX_NUM_LAYERS];
- byte _cells[NUM_HORIZ_RECTS*NUM_VERT_RECTS];
- byte _cells2[NUM_HORIZ_RECTS*NUM_VERT_RECTS];
+ bool _cells[NUM_HORIZ_RECTS*NUM_VERT_RECTS];
TalkDialog *_talkDialog;
int16 _talkDialogX, _talkDialogY;