From 6e9ce1b17ccbcf8239da45624f434ee5bddfcea7 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Tue, 21 Sep 2004 20:21:31 +0000 Subject: fix freddemo intro glitches svn-id: r15225 --- scumm/actor.cpp | 51 ++++++++++++++++++++++---------------------------- scumm/gfx.cpp | 10 ++++------ scumm/script_v72he.cpp | 14 ++++++-------- 3 files changed, 32 insertions(+), 43 deletions(-) diff --git a/scumm/actor.cpp b/scumm/actor.cpp index afe8eb6900..230180be93 100644 --- a/scumm/actor.cpp +++ b/scumm/actor.cpp @@ -1890,39 +1890,32 @@ void ScummEngine::postProcessAuxQueue() { if (ae->actorNum != -1) { Actor *a = derefActor(ae->actorNum, "postProcessAuxQueue"); const uint8 *cost = getResourceAddress(rtCostume, a->costume); - int dy = a->offs_y + a->_pos.y - a->getElevation(); int dx = a->offs_x + a->_pos.x; const uint8 *akax = findResource(MKID('AKAX'), cost); - if (!akax) { - error("No AKAX block for actor %d", ae->actorNum); - } + assert(akax); const uint8 *auxd = findPalInPals(akax, ae->subIndex) - _resourceHeaderSize; - if (!auxd) { - error("No AUXD block for actor %d", ae->actorNum); - } + assert(auxd); const uint8 *axfd = findResourceData(MKID('AXFD'), auxd); - if (!axfd) { - error("No AXFD block for actor %d", ae->actorNum); - } else { - uint16 comp = READ_LE_UINT16(axfd); - if (comp != 0) { - 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, pvs->topline); - uint8 *dst2 = pvs->getBackPixels(0, pvs->topline); - switch (comp) { - case 1: - gdi.copyAuxImage(dst1, dst2, axfd + 10, pvs->w, pvs->h, x, y, w, h, NULL); - break; - default: - warning("unimplemented compression type %d", comp); - break; - } + assert(axfd); + + uint16 comp = READ_LE_UINT16(axfd); + if (comp != 0) { + 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, pvs->topline); + uint8 *dst2 = pvs->getBackPixels(0, pvs->topline); + switch (comp) { + case 1: + gdi.copyAuxImage(dst1, dst2, axfd + 10, pvs->w, pvs->h, x, y, w, h, NULL); + break; + default: + warning("unimplemented compression type %d", comp); + break; } } const uint8 *axur = findResourceData(MKID('AXUR'), auxd); @@ -1932,8 +1925,8 @@ void ScummEngine::postProcessAuxQueue() { 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); + int y2 = (int16)READ_LE_UINT16(axur + 6) + dy; + markRectAsDirty(kMainVirtScreen, x1, x2, y1, y2 + 1); axur += 8; } } diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 4759e9240d..c3d02a48b1 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -1404,21 +1404,21 @@ void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, } 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); + srcRect = Common::Rect(0, 0, src_w - 1, src_h - 1); + dstRect = Common::Rect(src_x, src_y, src_x + src_w - 1, src_y + src_h - 1); Common::Rect r3; int diff; if (rect) { r3 = *rect; - Common::Rect r4(0, 0, dst_w, dst_h); + Common::Rect r4(0, 0, dst_w - 1, dst_h - 1); if (r3.intersects(r4)) { r3.clip(r4); } else { return false; } } else { - r3 = Common::Rect(0, 0, dst_w, dst_h); + r3 = Common::Rect(0, 0, dst_w - 1, dst_h - 1); } diff = dstRect.left - r3.left; if (diff < 0) { @@ -1564,8 +1564,6 @@ void Gdi::copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int 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); } } diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp index 225534755c..24ca02e5d0 100644 --- a/scumm/script_v72he.cpp +++ b/scumm/script_v72he.cpp @@ -1454,7 +1454,7 @@ uint8 *ScummEngine_v72he::drawWizImage(int restype, int resnum, int state, int x cw = pvs->w; ch = pvs->h; } - Common::Rect rScreen(0, 0, cw, ch); + Common::Rect rScreen(0, 0, cw - 1, ch - 1); if (flags & 0x80) { // drawWizImageHelper2(p, wizd, cw, ch, x1, y1, width, height, &rScreen, 0, 2); warning("drawWizImage() unhandled flag 0x80"); @@ -1470,15 +1470,13 @@ uint8 *ScummEngine_v72he::drawWizImage(int restype, int resnum, int state, int x warning("printing Wiz image is unimplemented"); dst = NULL; } else { - Common::Rect rImage(x1, y1, x1 + width, y1 + height); + Common::Rect rImage(x1, y1, x1 + width - 1, y1 + height - 1); if (rImage.intersects(rScreen)) { rImage.clip(rScreen); if (flags & 0x18) { ++rImage.bottom; markRectAsDirty(kMainVirtScreen, rImage); } else { - --rImage.right; - --rImage.bottom; gdi.copyVirtScreenBuffers(rImage); } } @@ -1497,12 +1495,12 @@ struct PolygonDrawData { int16 y2; }; struct ResArea { - int16 off; + uint16 off; int16 x_step; int16 y_step; int16 x_s; int16 y_s; - uint16 w; + int16 w; }; Common::Point pts[4]; ResArea *ra; @@ -1556,7 +1554,7 @@ struct PolygonDrawData { x3 += x_step_2; y3 += y_step; - if (p2->y > p1->y) { + if (p2->y <= p1->y) { --iaidx; } else { ++iaidx; @@ -1663,6 +1661,7 @@ void ScummEngine_v72he::drawWizPolygon(int resnum, int state, int id, int flags) uint16 rw = pra->w; while (rw--) { uint srcWizOff = (y_acc >> 0x10) * wizW + (x_acc >> 0x10); + assert(srcWizOff < wizW * wizH); x_acc += pra->x_step; y_acc += pra->y_step; *dstPtr++ = srcWizBuf[srcWizOff]; @@ -1679,7 +1678,6 @@ void ScummEngine_v72he::drawWizPolygon(int resnum, int state, int id, int flags) free(srcWizBuf); } - } void ScummEngine_v72he::redrawBGAreas() { -- cgit v1.2.3