[Scummvm-cvs-logs] SF.net SVN: scummvm: [28491] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Wed Aug 8 20:33:56 CEST 2007
Revision: 28491
http://scummvm.svn.sourceforge.net/scummvm/?rev=28491&view=rev
Author: peres001
Date: 2007-08-08 11:33:55 -0700 (Wed, 08 Aug 2007)
Log Message:
-----------
Removed some duplicated code.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/graphics.cpp
scummvm/trunk/engines/parallaction/graphics.h
scummvm/trunk/engines/parallaction/zone.cpp
Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp 2007-08-08 10:53:41 UTC (rev 28490)
+++ scummvm/trunk/engines/parallaction/graphics.cpp 2007-08-08 18:33:55 UTC (rev 28491)
@@ -77,22 +77,10 @@
// draws tail
// TODO: this bitmap tail should only be used for Dos games. Amiga should use a polygon fill.
winding = (winding == 0 ? 1 : 0);
- byte *s = _resBalloonTail[winding];
- byte *d = (byte*)_buffers[kBitFront]->getBasePtr(r.left + (r.width()+5)/2 - 5, r.bottom - 1);
- uint pitch = _vm->_screenWidth - BALLOON_TAIL_WIDTH;
- for (uint16 i = 0; i < BALLOON_TAIL_HEIGHT; i++) {
- for (uint16 j = 0; j < BALLOON_TAIL_WIDTH; j++) {
- if (*s != 2)
- *d = *s;
- d++;
- s++;
- }
+ Common::Rect s(BALLOON_TAIL_WIDTH, BALLOON_TAIL_HEIGHT);
+ s.moveTo(r.left + (r.width()+5)/2 - 5, r.bottom - 1);
+ flatBlit(s, _resBalloonTail[winding], kBitFront, 2);
- d += pitch;
- }
-
-// printf("done\n");
-
return;
}
@@ -332,7 +320,7 @@
}
-void Gfx::flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer) {
+void Gfx::flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer, byte transparentColor) {
Common::Point dp;
Common::Rect q(r);
@@ -347,7 +335,9 @@
for (uint16 i = q.top; i < q.bottom; i++) {
for (uint16 j = q.left; j < q.right; j++) {
- if (*s != 0) *d = *s;
+ if (*s != transparentColor)
+ *d = *s;
+
s++;
d++;
}
@@ -468,14 +458,8 @@
// FIXME: destination offseting is not clear
byte* s = _vm->_char._objs->getFramePtr(getInventoryItemIndex(index));
byte* d = v8 + 7 + MOUSECOMBO_WIDTH * 7;
+ copyRect(INVENTORYITEM_WIDTH, INVENTORYITEM_HEIGHT, d, MOUSECOMBO_WIDTH, s, INVENTORYITEM_PITCH);
- for (uint32 i = 0; i < INVENTORYITEM_HEIGHT; i++) {
- memcpy(d, s, INVENTORYITEM_WIDTH);
-
- s += INVENTORYITEM_PITCH;
- d += MOUSECOMBO_WIDTH;
- }
-
g_system->setMouseCursor(v8, MOUSECOMBO_WIDTH, MOUSECOMBO_HEIGHT, 0, 0, 0);
}
@@ -503,7 +487,7 @@
Common::Rect r(cnv->w, cnv->h);
r.moveTo(x, y);
- flatBlit(r, (byte*)cnv->pixels, buffer);
+ flatBlit(r, (byte*)cnv->pixels, buffer, 0);
return;
}
@@ -517,17 +501,8 @@
}
void Gfx::backupDoorBackground(DoorData *data, int16 x, int16 y) {
-
byte *s = (byte*)_buffers[kBit2]->getBasePtr(x, y);
- byte *d = data->_background;
-
- for (uint16 i = 0; i < data->_cnv->_height ; i++) {
- memcpy(d, s, data->_cnv->_width);
-
- s += _vm->_screenWidth;
- d += data->_cnv->_width;
- }
-
+ copyRect(data->_cnv->_width, data->_cnv->_height, data->_background, data->_cnv->_width, s, _vm->_screenWidth);
return;
}
@@ -557,9 +532,9 @@
//
// restores background according to specified frame
//
-void Gfx::restoreDoorBackground(Graphics::Surface *cnv, const Common::Rect& r, byte* background) {
+void Gfx::restoreDoorBackground(const Common::Rect& r, byte *data, byte* background) {
- byte *t = (byte*)cnv->pixels;
+ byte *t = data;
byte *s = background;
byte *d0 = (byte*)_buffers[kBitBack]->getBasePtr(r.left, r.top);
byte *d1 = (byte*)_buffers[kBit2]->getBasePtr(r.left, r.top);
@@ -593,15 +568,9 @@
//
void Gfx::restoreGetBackground(const Common::Rect& r, byte *data) {
- Graphics::Surface cnv;
+ flatBlit(r, data, kBitBack, 0);
+ flatBlit(r, data, kBit2, 0);
- cnv.w = r.width();
- cnv.h = r.height();
- cnv.pixels = data;
-
- flatBlitCnv(&cnv, r.left, r.top, kBitBack);
- flatBlitCnv(&cnv, r.left, r.top, kBit2);
-
return;
}
@@ -770,35 +739,28 @@
_depthMask = buffer;
}
+void Gfx::copyRect(uint width, uint height, byte *dst, uint dstPitch, byte *src, uint srcPitch) {
+ for (uint16 _si = 0; _si < height; _si++) {
+ memcpy(dst, src, width);
-void Gfx::copyRect(Gfx::Buffers dstbuffer, const Common::Rect& r, byte *src, uint16 pitch) {
-
- byte *d = (byte*)_buffers[dstbuffer]->getBasePtr(r.left, r.top);
- byte *s = src;
-
- for (uint16 _si = 0; _si < r.height(); _si++) {
- memcpy(d, s, r.width());
-
- s += pitch;
- d += _vm->_screenWidth;
+ src += srcPitch;
+ dst += dstPitch;
}
+ return;
+}
+void Gfx::copyRect(Gfx::Buffers dstbuffer, const Common::Rect& r, byte *src, uint16 pitch) {
+ byte *d = (byte*)_buffers[dstbuffer]->getBasePtr(r.left, r.top);
+ copyRect(r.width(), r.height(), d, _vm->_screenWidth, src, pitch);
+ return;
}
void Gfx::grabRect(byte *dst, const Common::Rect& r, Gfx::Buffers srcbuffer, uint16 pitch) {
-
byte *s = (byte*)_buffers[srcbuffer]->getBasePtr(r.left, r.top);
-
- for (uint16 i = 0; i < r.height(); i++) {
- memcpy(dst, s, r.width());
-
- s += _vm->_screenWidth;
- dst += pitch;
- }
-
+ copyRect(r.width(), r.height(), dst, pitch, s, _vm->_screenWidth);
return;
}
Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h 2007-08-08 10:53:41 UTC (rev 28490)
+++ scummvm/trunk/engines/parallaction/graphics.h 2007-08-08 18:33:55 UTC (rev 28491)
@@ -203,7 +203,7 @@
void blitCnv(Graphics::Surface *cnv, int16 x, int16 y, uint16 z, Gfx::Buffers buffer);
void restoreBackground(const Common::Rect& r);
void backupDoorBackground(DoorData *data, int16 x, int16 y);
- void restoreDoorBackground(Graphics::Surface *cnv, const Common::Rect& r, byte* background);
+ void restoreDoorBackground(const Common::Rect& r, byte *data, byte* background);
void backupGetBackground(GetData *data, int16 x, int16 y);
void restoreGetBackground(const Common::Rect& r, byte *data);
@@ -260,7 +260,8 @@
bool _halfbrite;
protected:
- void flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer);
+ void copyRect(uint width, uint height, byte *dst, uint dstPitch, byte *src, uint srcPitch);
+ void flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer, byte transparentColor);
void blit(const Common::Rect& r, uint16 z, byte *data, Gfx::Buffers buffer);
void initMouse(uint16 arg_0);
void screenClip(Common::Rect& r, Common::Point& p);
Modified: scummvm/trunk/engines/parallaction/zone.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/zone.cpp 2007-08-08 10:53:41 UTC (rev 28490)
+++ scummvm/trunk/engines/parallaction/zone.cpp 2007-08-08 18:33:55 UTC (rev 28491)
@@ -420,21 +420,13 @@
Zone *z = (Zone*)parm;
- Graphics::Surface v14;
-
if (z->u.door->_cnv) {
Common::Rect r(z->_left, z->_top, z->_left+z->u.door->_cnv->_width, z->_top+z->u.door->_cnv->_height);
uint16 _ax = (z->_flags & kFlagsClosed ? 1 : 0);
+ _vm->_gfx->restoreDoorBackground(r, z->u.door->_cnv->getFramePtr(_ax), z->u.door->_background);
- v14.w = z->u.door->_cnv->_width;
- v14.h = z->u.door->_cnv->_height;
- v14.pixels = z->u.door->_cnv->getFramePtr(_ax);
-
- _vm->_gfx->restoreDoorBackground(&v14, r, z->u.door->_background);
-
_ax = (z->_flags & kFlagsClosed ? 0 : 1);
-
_vm->_gfx->flatBlitCnv(z->u.door->_cnv, _ax, z->_left, z->_top, Gfx::kBitBack);
_vm->_gfx->flatBlitCnv(z->u.door->_cnv, _ax, z->_left, z->_top, Gfx::kBit2);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list