diff options
author | Gregory Montoir | 2004-09-20 18:27:13 +0000 |
---|---|---|
committer | Gregory Montoir | 2004-09-20 18:27:13 +0000 |
commit | 0fad7a95387eb27e10c5776c1ccd8a069d2e8364 (patch) | |
tree | a143b2264d247d3c620469c455ced1812b580d9b /scumm | |
parent | 046017aba6953cfc2c6ef67c5c564530d13eff7f (diff) | |
download | scummvm-rg350-0fad7a95387eb27e10c5776c1ccd8a069d2e8364.tar.gz scummvm-rg350-0fad7a95387eb27e10c5776c1ccd8a069d2e8364.tar.bz2 scummvm-rg350-0fad7a95387eb27e10c5776c1ccd8a069d2e8364.zip |
cleanup / code re-use
svn-id: r15203
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/actor.cpp | 24 | ||||
-rw-r--r-- | scumm/akos.cpp | 2 | ||||
-rw-r--r-- | scumm/gfx.cpp | 132 | ||||
-rw-r--r-- | scumm/gfx.h | 8 | ||||
-rw-r--r-- | scumm/vars.cpp | 6 |
5 files changed, 73 insertions, 99 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp index 4a2cab1258..e2a3f3fa05 100644 --- a/scumm/actor.cpp +++ b/scumm/actor.cpp @@ -1918,16 +1918,16 @@ void ScummEngine::postProcessAuxQueue() { } else { uint16 comp = READ_LE_UINT16(axfd); if (comp != 0) { - int x1 = (int16)READ_LE_UINT16(axfd + 2) + dx; - int y1 = (int16)READ_LE_UINT16(axfd + 4) + dy; - int x2 = (int16)READ_LE_UINT16(axfd + 6); - int y2 = (int16)READ_LE_UINT16(axfd + 8); + int x = (int16)READ_LE_UINT16(axfd + 2) + dx; + int y = (int16)READ_LE_UINT16(axfd + 4) + dy; + int w = (int16)READ_LE_UINT16(axfd + 6); + int h = (int16)READ_LE_UINT16(axfd + 8); VirtScreen *pvs = &virtscr[kMainVirtScreen]; - uint8 *dst1 = pvs->getPixels(0, 0); - uint8 *dst2 = pvs->getBackPixels(0, 0); + uint8 *dst1 = pvs->getPixels(0, pvs->topline); + uint8 *dst2 = pvs->getBackPixels(0, pvs->topline); switch (comp) { case 1: - gdi.copyAuxImage(dst1, dst2, axfd + 10, pvs->w, pvs->h, x1, y1, x2, y2, 0); + gdi.copyAuxImage(dst1, dst2, axfd + 10, pvs->w, pvs->h, x, y, w, h, NULL); break; default: warning("unimplemented compression type %d", comp); @@ -1939,11 +1939,11 @@ void ScummEngine::postProcessAuxQueue() { if (axur) { uint16 n = READ_LE_UINT16(axur); axur += 2; while (n--) { - int x = (int16)READ_LE_UINT16(axur + 0) + dx; - int y = (int16)READ_LE_UINT16(axur + 2) + dy; - int w = (int16)READ_LE_UINT16(axur + 4) + dx; - int h = (int16)READ_LE_UINT16(axur + 6) + dy; - markRectAsDirty(kMainVirtScreen, x, w, y, h); + int x1 = (int16)READ_LE_UINT16(axur + 0) + dx; + int y1 = (int16)READ_LE_UINT16(axur + 2) + dy; + int x2 = (int16)READ_LE_UINT16(axur + 4) + dx; + int y2 = (int16)READ_LE_UINT16(axur + 6) + dy; + markRectAsDirty(kMainVirtScreen, x1, x2, y1, y2); axur += 8; } } diff --git a/scumm/akos.cpp b/scumm/akos.cpp index 7fa2012582..3dd0c35fcd 100644 --- a/scumm/akos.cpp +++ b/scumm/akos.cpp @@ -1239,7 +1239,7 @@ byte AkosRenderer::codec32(int xmoveCur, int ymoveCur) { if (_draw_bottom < dst.bottom) _draw_bottom = dst.bottom; - _vm->gdi.decompressWizImage(_outptr, _outwidth, &dst, _srcptr, &src); + _vm->gdi.decompressWizImage(_outptr, _outwidth, dst, _srcptr, src); return 0; } diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index ce3d9e76d8..e2a82af20a 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -1401,53 +1401,61 @@ void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, } } -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); +static bool calcClipRects(int dst_w, int dst_h, int src_x, int src_y, int src_w, int src_h, const Common::Rect *rect, Common::Rect &srcRect, Common::Rect &dstRect) { + srcRect = Common::Rect(0, 0, src_w, src_h); + dstRect = Common::Rect(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 { + if (r3.intersects(r4)) { r3.clip(r4); + } else { + return false; } } else { r3 = Common::Rect(0, 0, dst_w, dst_h); } - diff = r2.left - r3.left; + diff = dstRect.left - r3.left; if (diff < 0) { - r1.left -= diff; - r2.left -= diff; + srcRect.left -= diff; + dstRect.left -= diff; } - diff = r2.right - r3.right; + diff = dstRect.right - r3.right; if (diff > 0) { - r1.right -= diff; - r2.right -= diff; + srcRect.right -= diff; + dstRect.right -= diff; } - diff = r2.top - r3.top; + diff = dstRect.top - r3.top; if (diff < 0) { - r1.top -= diff; - r2.top -= diff; + srcRect.top -= diff; + dstRect.top -= diff; } - diff = r2.bottom - r3.bottom; + diff = dstRect.bottom - r3.bottom; if (diff > 0) { - r1.bottom -= diff; - r2.bottom -= diff; + srcRect.bottom -= diff; + dstRect.bottom -= diff; } - // TODO/FIXME: At this point, unless I am mistaken, r1 == r2.moveTo(0, 0) - // As such the code above could be simplified (i.e. r1 could be removed, + // TODO/FIXME: At this point, unless I am mistaken, srcRect == dstRect.moveTo(0, 0) + // As such the code above could be simplified (i.e. srcRect could be removed, // and then the uses of the diff variables can be folded in). // In fact it looks to me as if the code above just does some simple clipping... // Since I don't have the HE games in questions, I can't test this, though. - if (r1.isValidRect() && r2.isValidRect()) { - decompressWizImage(dst, dst_w, &r2, src, &r1); + return true; +} + +void Gdi::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect) { + Common::Rect r1, r2; + if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) { + if (r1.isValidRect() && r2.isValidRect()) { + decompressWizImage(dst, dstw, r2, src, r1); + } } } -void Gdi::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect) { +void Gdi::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect) { const uint8 *dataPtr, *dataPtrNext; uint8 *dstPtr, *dstPtrNext; uint32 code; @@ -1455,25 +1463,25 @@ void Gdi::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect *dstRe int h, w, xoff; uint16 off; - dstPtr = dst + dstRect->left + dstRect->top * dstPitch; + dstPtr = dst + dstRect.left + dstRect.top * dstPitch; dataPtr = src; // Skip over the first 'srcRect->top' lines in the data - h = srcRect->top; + h = srcRect.top; while (h--) { dataPtr += READ_LE_UINT16(dataPtr) + 2; } - h = srcRect->bottom - srcRect->top + 1; + h = srcRect.bottom - srcRect.top + 1; if (h <= 0) return; - w = srcRect->right - srcRect->left + 1; + w = srcRect.right - srcRect.left + 1; if (w <= 0) return; while (h--) { - xoff = srcRect->left; + xoff = srcRect.left; off = READ_LE_UINT16(dataPtr); - w = srcRect->right - srcRect->left + 1; + w = srcRect.right - srcRect.left + 1; dstPtrNext = dstPitch + dstPtr; dataPtrNext = off + 2 + dataPtr; dataPtr += 2; @@ -1550,78 +1558,44 @@ dec_next: } } -void Gdi::copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, Common::Rect *rect) { - Common::Rect r1(0, 0, srcw - 1, srch - 1); - Common::Rect r2(srcx, srcy, srcx + srcw - 1, srcy + srch - 1); - Common::Rect r3; - int diff; - - if (rect) { - r3 = *rect; - Common::Rect r4(0, 0, dstw - 1, dsth - 1); - if (!r3.intersects(r4)) { - return; +void Gdi::copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect) { + Common::Rect r1, r2; + if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) { + if (r1.isValidRect() && r2.isValidRect()) { + --r1.right; + --r1.bottom; + decompressAuxImage(dst1, dst2, dstw, r2, src, r1); } - } else { - r3 = Common::Rect(0, 0, dstw - 1, dsth - 1); - } - 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; - } - // TODO/FIXME: At this point, unless I am mistaken, r1 == r2.moveTo(0, 0) - // As such the code above could be simplified (i.e. r1 could be removed, - // and then the uses of the diff variables can be folded in). - // In fact it looks to me as if the code above just does some simple clipping... - // Since I don't have the HE games in questions, I can't test this, though. - if (r1.isValidRect() && r2.isValidRect()) { - decompressAuxImage(dst1, dst2, dstw, &r2, src, &r1); } } -void Gdi::decompressAuxImage(uint8 *dst1, uint8 *dst2, int dstPitch, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect) { +void Gdi::decompressAuxImage(uint8 *dst1, uint8 *dst2, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect) { const uint8 *dataPtr, *dataPtrNext; uint8 *dst1Ptr, *dst2Ptr, *dst1PtrNext, *dst2PtrNext; int h, w, xoff; uint16 off; uint8 code; - - dst1Ptr = dst1 + dstRect->left + dstRect->top * dstPitch; - dst2Ptr = dst2 + dstRect->left + dstRect->top * dstPitch; + + dst1Ptr = dst1 + dstRect.left + dstRect.top * dstPitch; + dst2Ptr = dst2 + dstRect.left + dstRect.top * dstPitch; dataPtr = src; - + // Skip over the first 'srcRect->top' lines in the data - h = srcRect->top; + h = srcRect.top; while (h--) { dataPtr += READ_LE_UINT16(dataPtr) + 2; } - h = srcRect->bottom - srcRect->top + 1; + h = srcRect.bottom - srcRect.top + 1; if (h <= 0) return; - w = srcRect->right - srcRect->left + 1; + w = srcRect.right - srcRect.left + 1; if (w <= 0) return; while (h--) { - xoff = srcRect->left; + xoff = srcRect.left; off = READ_LE_UINT16(dataPtr); - w = srcRect->right - srcRect->left + 1; + w = srcRect.right - srcRect.left + 1; dst1PtrNext = dstPitch + dst1Ptr; dst2PtrNext = dstPitch + dst2Ptr; dataPtrNext = off + 2 + dataPtr; diff --git a/scumm/gfx.h b/scumm/gfx.h index def9977a58..4a974a147e 100644 --- a/scumm/gfx.h +++ b/scumm/gfx.h @@ -277,10 +277,10 @@ public: 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 *rect); - void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect); - void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, Common::Rect *rect); - void decompressAuxImage(uint8 *dst1, uint8 *dst2, int dstPitch, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect); + void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect); + void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect); + void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect); + void decompressAuxImage(uint8 *dst1, uint8 *dst2, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect); void copyVirtScreenBuffers(const Common::Rect &rect); void disableZBuffer() { _zbufferDisabled = true; } diff --git a/scumm/vars.cpp b/scumm/vars.cpp index 7eca4d4153..abfc905cfb 100644 --- a/scumm/vars.cpp +++ b/scumm/vars.cpp @@ -259,12 +259,12 @@ void ScummEngine_v72he::setupScummVars() { VAR_NUM_GLOBAL_OBJS = 74; VAR_POLYGONS_ONLY = 76; - if (_heversion >= 80) { + if (_heversion >= 80) VAR_WINDOWS_VERSION = 79; + if (_heversion >= 90) { + VAR_NUM_SPRITES = 106; VAR_WIZ_TCOLOR = 117; } - if (_heversion >= 90) - VAR_NUM_SPRITES = 106; } void ScummEngine_v7::setupScummVars() { |