aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorEugene Sandulenko2004-09-05 17:39:54 +0000
committerEugene Sandulenko2004-09-05 17:39:54 +0000
commit96ad0d9cb78ce510ce82072c34740a0ca4a1ec5d (patch)
tree657cb7b25bb1fb95b8f4e589dfaaa76dce024b79 /scumm
parent7916291efc8e556f924a988fd866732740fc4473 (diff)
downloadscummvm-rg350-96ad0d9cb78ce510ce82072c34740a0ca4a1ec5d.tar.gz
scummvm-rg350-96ad0d9cb78ce510ce82072c34740a0ca4a1ec5d.tar.bz2
scummvm-rg350-96ad0d9cb78ce510ce82072c34740a0ca4a1ec5d.zip
Added BMAP support in objects.
Though I didn't test it as I don't know when it is used. Please, tell me when you'll see warning that it is called. Now we have BMAP for all cases in HE 70+ games. svn-id: r14911
Diffstat (limited to 'scumm')
-rw-r--r--scumm/gfx.cpp103
-rw-r--r--scumm/gfx.h4
-rw-r--r--scumm/intern.h1
-rw-r--r--scumm/object.cpp6
-rw-r--r--scumm/script_v72he.cpp45
5 files changed, 102 insertions, 57 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp
index e25151f7cc..d4bff39f31 100644
--- a/scumm/gfx.cpp
+++ b/scumm/gfx.cpp
@@ -557,20 +557,28 @@ void ScummEngine::redrawBGAreas() {
gdi.drawBMAPBg(room, &virtscr[0], _screenStartStrip, _screenWidth);
}
cont = false;
+ } else if (findResource(MKID('SMAP'), room) == NULL) {
+ warning("redrawBGAreas(): Both SMAP and BMAP are missing...");
+ cont = false;
+ }
+
+ if (!cont) {
+ drawRoomObjects(val);
+ _BgNeedsRedraw = false;
+ return;
}
}
// Redraw parts of the background which are marked as dirty.
- if (!_fullRedraw && _BgNeedsRedraw && cont) {
+ if (!_fullRedraw && _BgNeedsRedraw) {
for (i = 0; i != gdi._numStrips; i++) {
if (testGfxUsageBit(_screenStartStrip + i, USAGE_BIT_DIRTY)) {
redrawBGStrip(i, 1);
- cont = false;
}
}
}
- if (_features & GF_NEW_CAMERA && cont) {
+ if (_features & GF_NEW_CAMERA) {
diff = camera._cur.x / 8 - camera._last.x / 8;
if (_fullRedraw == 0 && diff == 1) {
val = 2;
@@ -1288,7 +1296,7 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip, int width)
bmap_ptr = _vm->findResource(MKID('BMAP'), ptr) + 8;
if (bmap_ptr == NULL) {
- error("Room %d has no compressed bitmap?", _vm->_roomResource);
+ error("Gdi::drawBMAPBg: Room %d has no compressed bitmap?", _vm->_roomResource);
return;
}
@@ -1300,7 +1308,7 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip, int width)
decompressBMAPbg((byte *)vs->backBuf, width, vs->w, vs->h, bmap_ptr, decomp_shr, decomp_mask);
}
- copyVirtScreenBuffers(0, 0, vs->w - 1, vs->h - 1);
+ copyVirtScreenBuffers(Common::Rect(0, 0, vs->w - 1, vs->h - 1));
if (_numZBuffer <= 1)
return;
@@ -1336,6 +1344,38 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip, int width)
}
}
+void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h) {
+ const byte *bmap_ptr;
+
+ warning("drawBMAPObject() called");
+
+ bmap_ptr = _vm->findResource(MKID('BMAP'), ptr) + 8;
+ if (bmap_ptr == NULL) {
+ error("Gdi::drawBMAPObject: No image for item %d?", obj);
+ return;
+ }
+
+ byte code = *ptr++;
+ int scrX = _vm->_screenStartStrip * 8;
+
+ if (code == 8 || code == 9) {
+ Common::Rect rScreen(0, 0, vs->w, vs->h);
+ byte *dst = (byte *)_vm->virtscr[0].backBuf + scrX;
+ copyWizImage(dst, ptr, vs->w, vs->h, x - scrX, y, w, h, &rScreen);
+ }
+
+ Common::Rect rect1(x, y, w, h);
+ Common::Rect rect2(scrX, 0, vs->w + scrX, vs->h);
+
+ if (rect1.intersects(rect2) && rect1.top <= rect1.bottom && rect1.left <= rect1.right) {
+ rect1.left -= rect2.left;
+ rect1.right -= rect2.left;
+ rect1.top -= rect2.top;
+ rect1.bottom -= rect2.top;
+ copyVirtScreenBuffers(rect1);
+ }
+}
+
void Gdi::decompressBMAPbg(byte *dst, int screenwidth, int w, int height, const byte *src, int shr, int mask) {
uint32 color, dataBit, data, shift;
int32 iteration;
@@ -1385,6 +1425,47 @@ void Gdi::decompressBMAPbg(byte *dst, int screenwidth, int w, int height, const
}
}
+void Gdi::copyWizImage(uint8 *dst, const uint8 *src, int dst_w, int dst_h, int src_x, int src_y, int src_w, int src_h, Common::Rect *rect) {
+ Common::Rect r1(0, 0, src_w, src_h), r2(src_x, src_y, src_x + src_w, src_y + src_h);
+ Common::Rect r3;
+ int diff;
+
+ if (rect) {
+ r3 = *rect;
+ Common::Rect r4(0, 0, dst_w, dst_h);
+ if (!r3.intersects(r4)) {
+ return;
+ } else {
+ r3.clip(r4);
+ }
+ } else {
+ r3 = Common::Rect(0, 0, dst_w, dst_h);
+ }
+ diff = r2.left - r3.left;
+ if (diff < 0) {
+ r1.left -= diff;
+ r2.left -= diff;
+ }
+ diff = r2.right - r3.right;
+ if (diff > 0) {
+ r1.right -= diff;
+ r2.right -= diff;
+ }
+ diff = r2.top - r3.top;
+ if (diff < 0) {
+ r1.top -= diff;
+ r2.top -= diff;
+ }
+ diff = r2.bottom - r3.bottom;
+ if (diff > 0) {
+ r1.bottom -= diff;
+ r2.bottom -= diff;
+ }
+ if (r1.isValidRect() && r2.isValidRect()) {
+ decompressImageHE(dst, dst_w, &r2, src, &r1);
+ }
+}
+
void Gdi::decompressImageHE(uint8 *dst, int dstWidth, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect) {
const uint8 *dataPtr, *dataPtrNext;
uint8 *dstPtr, *dstPtrNext;
@@ -1489,16 +1570,16 @@ dec_next:
}
}
-void Gdi::copyVirtScreenBuffers(int x1, int y1, int x2, int y2) {
- int rw = x2 - x1 + 1;
- int rh = y2 - y1 + 1;
+void Gdi::copyVirtScreenBuffers(Common::Rect rect) {
+ int rw = rect.right - rect.left + 1;
+ int rh = rect.bottom - rect.top + 1;
byte *src, *dst;
- src = (byte *)_vm->virtscr[0].backBuf + (_vm->_screenStartStrip + y1 * _numStrips) * 8 + x1;
- dst = (byte *)_vm->virtscr[0].pixels + (_vm->_screenStartStrip + y1 * _numStrips) * 8 + x1;
+ src = (byte *)_vm->virtscr[0].backBuf + (_vm->_screenStartStrip + rect.top * _numStrips) * 8 + rect.left;
+ dst = (byte *)_vm->virtscr[0].pixels + (_vm->_screenStartStrip + rect.top * _numStrips) * 8 + rect.left;
copyBufferBox(dst, src, rw, rh);
- _vm->markRectAsDirty(kMainVirtScreen, x1, x2, y1, y2, 0);
+ _vm->markRectAsDirty(kMainVirtScreen, rect.left, rect.right, rect.top, rect.bottom, 0);
}
/**
diff --git a/scumm/gfx.h b/scumm/gfx.h
index e06b1b1be0..06a9fa9f04 100644
--- a/scumm/gfx.h
+++ b/scumm/gfx.h
@@ -274,8 +274,10 @@ public:
int stripnr, int numstrip, StripTable *table);
StripTable *generateStripTable(const byte *src, int width, int height, StripTable *table);
void drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip, int width);
+ void drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h);
+ void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, Common::Rect *pr);
void decompressImageHE(uint8 *dst, int dstWidth, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect);
- void copyVirtScreenBuffers(int x1, int y1, int x2, int y2);
+ void copyVirtScreenBuffers(Common::Rect rect);
void disableZBuffer() { _zbufferDisabled = true; }
void enableZBuffer() { _zbufferDisabled = false; }
diff --git a/scumm/intern.h b/scumm/intern.h
index 199e105abc..06d016b1fa 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -698,7 +698,6 @@ protected:
void drawWizImage(int restype, int resnum, int x1, int y1, int flags);
void flushWizBuffer();
- void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, Common::Rect *pr);
virtual void decodeParseString(int a, int b);
void decodeScriptString(byte *dst, bool scriptString = false);
diff --git a/scumm/object.cpp b/scumm/object.cpp
index 9a2589da2c..0b02463340 100644
--- a/scumm/object.cpp
+++ b/scumm/object.cpp
@@ -484,7 +484,11 @@ void ScummEngine::drawObject(int obj, int arg) {
// the inventory and conversation icons.
if ((_version >= 7 || _gameId == GID_SAMNMAX) && getClass(od.obj_nr, kObjectClassIgnoreBoxes))
flags |= Gdi::dbDrawMaskOnAll;
- gdi.drawBitmap(ptr, &virtscr[0], x, ypos, width * 8, height, x - xpos, numstrip, flags);
+
+ if (_heversion >= 70 && findResource(MKID('SMAP'), ptr) == NULL)
+ gdi.drawBMAPObject(ptr, &virtscr[0], obj, od.x_pos * 8, od.y_pos * 8, od.width * 8, od.height * 8);
+ else
+ gdi.drawBitmap(ptr, &virtscr[0], x, ypos, width * 8, height, x - xpos, numstrip, flags);
}
}
diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp
index e1620d886f..2836ec7e94 100644
--- a/scumm/script_v72he.cpp
+++ b/scumm/script_v72he.cpp
@@ -1295,7 +1295,7 @@ void ScummEngine_v72he::drawWizImage(int restype, int resnum, int x1, int y1, in
if (flags & 2) {
warning("unhandled Wiz image w/ rmap");
} else {
- copyWizImage(dst, wizd, pvs->w, pvs->h, x1, y1, width, height, &rScreen);
+ gdi.copyWizImage(dst, wizd, pvs->w, pvs->h, x1, y1, width, height, &rScreen);
}
Common::Rect rImage(x1, y1, x1 + width, y1 + height);
@@ -1305,7 +1305,7 @@ void ScummEngine_v72he::drawWizImage(int restype, int resnum, int x1, int y1, in
++rImage.bottom;
markRectAsDirty(kMainVirtScreen, rImage);
} else {
- gdi.copyVirtScreenBuffers(rImage.left, rImage.top, rImage.right - 1, rImage.bottom - 1);
+ gdi.copyVirtScreenBuffers(rImage);
}
}
}
@@ -1324,47 +1324,6 @@ void ScummEngine_v72he::flushWizBuffer() {
_wizImagesNum = 0;
}
-void ScummEngine_v72he::copyWizImage(uint8 *dst, const uint8 *src, int dst_w, int dst_h, int src_x, int src_y, int src_w, int src_h, Common::Rect *rect) {
- Common::Rect r1(0, 0, src_w, src_h), r2(src_x, src_y, src_x + src_w, src_y + src_h);
- Common::Rect r3;
- int diff;
-
- if (rect) {
- r3 = *rect;
- Common::Rect r4(0, 0, dst_w, dst_h);
- if (!r3.intersects(r4)) {
- return;
- } else {
- r3.clip(r4);
- }
- } else {
- r3 = Common::Rect(0, 0, dst_w, dst_h);
- }
- diff = r2.left - r3.left;
- if (diff < 0) {
- r1.left -= diff;
- r2.left -= diff;
- }
- diff = r2.right - r3.right;
- if (diff > 0) {
- r1.right -= diff;
- r2.right -= diff;
- }
- diff = r2.top - r3.top;
- if (diff < 0) {
- r1.top -= diff;
- r2.top -= diff;
- }
- diff = r2.bottom - r3.bottom;
- if (diff > 0) {
- r1.bottom -= diff;
- r2.bottom -= diff;
- }
- if (r1.isValidRect() && r2.isValidRect()) {
- gdi.decompressImageHE(dst, dst_w, &r2, src, &r1);
- }
-}
-
void ScummEngine_v72he::o72_drawWizImage() {
int flags = pop();
int y1 = pop();