aboutsummaryrefslogtreecommitdiff
path: root/queen
diff options
context:
space:
mode:
authorDavid Eriksson2003-10-28 14:19:11 +0000
committerDavid Eriksson2003-10-28 14:19:11 +0000
commit1ab811c4ec3bdbc97d56fa648ea66954bff3f467 (patch)
treec0d4e67c117c9da8064393283f7f0c208b5b7690 /queen
parent7418c47b48925b095f7ff9daae9962f92f297cc7 (diff)
downloadscummvm-rg350-1ab811c4ec3bdbc97d56fa648ea66954bff3f467.tar.gz
scummvm-rg350-1ab811c4ec3bdbc97d56fa648ea66954bff3f467.tar.bz2
scummvm-rg350-1ab811c4ec3bdbc97d56fa648ea66954bff3f467.zip
Safer use of dynalum.
svn-id: r10991
Diffstat (limited to 'queen')
-rw-r--r--queen/display.cpp20
-rw-r--r--queen/display.h2
2 files changed, 19 insertions, 3 deletions
diff --git a/queen/display.cpp b/queen/display.cpp
index be4f7a346b..29730132fd 100644
--- a/queen/display.cpp
+++ b/queen/display.cpp
@@ -146,11 +146,15 @@ void Display::dynalumInit(Resource *resource, const char *roomName, uint16 roomN
// FIXME: are these tests really needed ?
if (roomNum < 90 || ((roomNum > 94) && (roomNum < 114))) {
char filename[20];
+
sprintf(filename, "%s.msk", roomName);
- if (resource->exists(filename))
+ _dynalum.haveMsk = resource->exists(filename);
+ if (_dynalum.haveMsk)
resource->loadFile(filename, 0, (uint8*)_dynalum.msk);
+
sprintf(filename, "%s.lum", roomName);
- if (resource->exists(filename))
+ _dynalum.haveLum = resource->exists(filename);
+ if (_dynalum.haveLum)
resource->loadFile(filename, 0, (uint8*)_dynalum.lum);
}
}
@@ -158,13 +162,23 @@ void Display::dynalumInit(Resource *resource, const char *roomName, uint16 roomN
void Display::dynalumUpdate(int x, int y) {
+ if (!_dynalum.haveMsk)
+ return;
+
if (x >= _bdWidth) {
x = _bdWidth;
}
if (y >= ROOM_ZONE_HEIGHT - 1) {
y = ROOM_ZONE_HEIGHT - 1;
}
- uint8 colMask = _dynalum.msk[(y / 4) * 160 + (x / 4)];
+
+ unsigned offset = (y / 4) * 160 + (x / 4);
+ if (offset >= sizeof(_dynalum.msk)) {
+ debug(0, "Graphics::dynalumUpdate(%d, %d) - invalid offset: %08x", x, y, offset);
+ return;
+ }
+
+ uint8 colMask = _dynalum.msk[offset];
debug(9, "Graphics::dynalumUpdate(%d, %d) - colMask = %d", x, y, colMask);
if (colMask != _dynalum.prevColMask) {
diff --git a/queen/display.h b/queen/display.h
index 5c5a2e2f6b..24608b3345 100644
--- a/queen/display.h
+++ b/queen/display.h
@@ -43,6 +43,8 @@ enum JoePalette {
struct Dynalum {
+ bool haveMsk;
+ bool haveLum;
uint8 msk[50 * 160];
int8 lum[8 * 3];
uint8 prevColMask;