Safer use of dynalum.

svn-id: r10991
This commit is contained in:
David Eriksson 2003-10-28 14:19:11 +00:00
parent 7418c47b48
commit 1ab811c4ec
2 changed files with 19 additions and 3 deletions

View File

@ -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) {

View File

@ -43,6 +43,8 @@ enum JoePalette {
struct Dynalum {
bool haveMsk;
bool haveLum;
uint8 msk[50 * 160];
int8 lum[8 * 3];
uint8 prevColMask;