aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2008-02-02 09:48:07 +0000
committerNicola Mettifogo2008-02-02 09:48:07 +0000
commit015ad5e4696243a96be383fce5c04350a71cb91f (patch)
tree6e5efa0bb1a364f8eb11aea7d3d6b0d5e210c24c /engines
parent4227c0f7ce0abf6647e1cd9c64615e55d744fb68 (diff)
downloadscummvm-rg350-015ad5e4696243a96be383fce5c04350a71cb91f.tar.gz
scummvm-rg350-015ad5e4696243a96be383fce5c04350a71cb91f.tar.bz2
scummvm-rg350-015ad5e4696243a96be383fce5c04350a71cb91f.zip
Some more integration of background code into BackgroundInfo.
svn-id: r30731
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/callables_ns.cpp12
-rw-r--r--engines/parallaction/exec_ns.cpp2
-rw-r--r--engines/parallaction/graphics.cpp65
-rw-r--r--engines/parallaction/graphics.h22
-rw-r--r--engines/parallaction/parallaction.cpp2
-rw-r--r--engines/parallaction/parser_br.cpp10
6 files changed, 53 insertions, 60 deletions
diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp
index 7ba42c2dba..db011cf892 100644
--- a/engines/parallaction/callables_ns.cpp
+++ b/engines/parallaction/callables_ns.cpp
@@ -330,8 +330,8 @@ void Parallaction_ns::_c_onMouse(void *parm) {
void Parallaction_ns::_c_setMask(void *parm) {
- memset(_gfx->_backgroundInfo->mask.data + 3600, 0, 3600);
- _gfx->_backgroundInfo->layers[1] = 500;
+ memset(_gfx->_backgroundInfo.mask.data + 3600, 0, 3600);
+ _gfx->_backgroundInfo.layers[1] = 500;
return;
}
@@ -584,7 +584,7 @@ void Parallaction_ns::_c_sketch(void *parm) {
newx = _rightHandPositions[2*index];
}
- Graphics::drawLine(oldx, oldy, newx, newy, 0, zeroMask, _gfx->_backgroundInfo);
+ Graphics::drawLine(oldx, oldy, newx, newy, 0, zeroMask, &_gfx->_backgroundInfo);
_rightHandAnim->_left = newx;
_rightHandAnim->_top = newy - 20;
@@ -606,11 +606,11 @@ void Parallaction_ns::_c_shade(void *parm) {
_rightHandAnim->_top
);
- uint16 _di = r.left/4 + r.top * _gfx->_backgroundInfo->mask.internalWidth;
+ uint16 _di = r.left/4 + r.top * _gfx->_backgroundInfo.mask.internalWidth;
for (uint16 _si = r.top; _si < r.bottom; _si++) {
- memset(_gfx->_backgroundInfo->mask.data + _di, 0, r.width()/4+1);
- _di += _gfx->_backgroundInfo->mask.internalWidth;
+ memset(_gfx->_backgroundInfo.mask.data + _di, 0, r.width()/4+1);
+ _di += _gfx->_backgroundInfo.mask.internalWidth;
}
return;
diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp
index 6765da72c1..9a15bbfdf5 100644
--- a/engines/parallaction/exec_ns.cpp
+++ b/engines/parallaction/exec_ns.cpp
@@ -333,7 +333,7 @@ void Parallaction_ns::drawAnimations() {
if (v18->_flags & kFlagsNoMasked)
layer = 3;
else
- layer = _gfx->queryMask(v18->_top + v18->height());
+ layer = _gfx->_backgroundInfo.getLayer(v18->_top + v18->height());
_gfx->showGfxObj(obj, true);
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index ca912e3f23..7b000c911f 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -32,7 +32,6 @@
namespace Parallaction {
-#define BUFFER_FOREGROUND 3
#define LABEL_TRANSPARENT_COLOR 0xFF
#define BALLOON_TRANSPARENT_COLOR 2
@@ -262,7 +261,7 @@ void Gfx::animatePalette() {
PaletteFxRange *range;
for (uint16 i = 0; i < 4; i++) {
- range = &_backgroundInfo->ranges[i];
+ range = &_backgroundInfo.ranges[i];
if ((range->_flags & 1) == 0) continue; // animated palette
range->_timer += range->_step * 2; // update timer
@@ -326,7 +325,7 @@ void Gfx::drawItems() {
Graphics::Surface *surf = g_system->lockScreen();
for (uint i = 0; i < _numItems; i++) {
- blt(_items[i].rect, _items[i].data->getData(_items[i].frame), surf, BUFFER_FOREGROUND, 0);
+ blt(_items[i].rect, _items[i].data->getData(_items[i].frame), surf, LAYER_FOREGROUND, 0);
}
g_system->unlockScreen();
}
@@ -340,14 +339,14 @@ void Gfx::drawBalloons() {
for (uint i = 0; i < _numBalloons; i++) {
Common::Rect r(_balloons[i].surface.w, _balloons[i].surface.h);
r.moveTo(_balloons[i].x, _balloons[i].y);
- blt(r, (byte*)_balloons[i].surface.getBasePtr(0, 0), surf, BUFFER_FOREGROUND, BALLOON_TRANSPARENT_COLOR);
+ blt(r, (byte*)_balloons[i].surface.getBasePtr(0, 0), surf, LAYER_FOREGROUND, BALLOON_TRANSPARENT_COLOR);
}
g_system->unlockScreen();
}
void Gfx::updateScreen() {
- g_system->copyRectToScreen((const byte*)_backgroundInfo->bg.pixels, _backgroundInfo->bg.pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight);
+ g_system->copyRectToScreen((const byte*)_backgroundInfo.bg.pixels, _backgroundInfo.bg.pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight);
Graphics::Surface *surf = g_system->lockScreen();
drawGfxObjects(*surf);
@@ -355,7 +354,7 @@ void Gfx::updateScreen() {
if (_halfbrite) {
// FIXME: the implementation of halfbrite is now largely sub-optimal in that a full screen
// rewrite is needed to apply the effect.
- byte *src = (byte*)_backgroundInfo->bg.pixels;
+ byte *src = (byte*)_backgroundInfo.bg.pixels;
byte *dst = (byte*)surf->pixels;
for (int i = 0; i < surf->w*surf->h; i++) {
*dst++ = *src++ | 0x20;
@@ -384,7 +383,7 @@ void Gfx::updateScreen() {
// graphic primitives
//
void Gfx::clearBackground() {
- memset(_backgroundInfo->bg.pixels, 0, _vm->_screenSize);
+ memset(_backgroundInfo.bg.pixels, 0, _vm->_screenSize);
}
@@ -393,17 +392,17 @@ void Gfx::patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask)
Common::Rect r(surf.w, surf.h);
r.moveTo(x, y);
- uint16 z = (mask) ? queryMask(y) : BUFFER_FOREGROUND;
- blt(r, (byte*)surf.pixels, &_backgroundInfo->bg, z, 0);
+ uint16 z = (mask) ? _backgroundInfo.getLayer(y) : LAYER_FOREGROUND;
+ blt(r, (byte*)surf.pixels, &_backgroundInfo.bg, z, 0);
}
void Gfx::fillBackground(const Common::Rect& r, byte color) {
- _backgroundInfo->bg.fillRect(r, color);
+ _backgroundInfo.bg.fillRect(r, color);
}
void Gfx::invertBackground(const Common::Rect& r) {
- byte *d = (byte*)_backgroundInfo->bg.getBasePtr(r.left, r.top);
+ byte *d = (byte*)_backgroundInfo.bg.getBasePtr(r.left, r.top);
for (int i = 0; i < r.height(); i++) {
for (int j = 0; j < r.width(); j++) {
@@ -411,7 +410,7 @@ void Gfx::invertBackground(const Common::Rect& r) {
d++;
}
- d += (_backgroundInfo->bg.pitch - r.width());
+ d += (_backgroundInfo.bg.pitch - r.width());
}
}
@@ -437,13 +436,13 @@ void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16
uint sPitch = r.width() - q.width();
uint dPitch = surf->w - q.width();
- if (_backgroundInfo->mask.data && (z < BUFFER_FOREGROUND)) {
+ if (_backgroundInfo.mask.data && (z < LAYER_FOREGROUND)) {
for (uint16 i = 0; i < q.height(); i++) {
for (uint16 j = 0; j < q.width(); j++) {
if (*s != transparentColor) {
- byte v = _backgroundInfo->mask.getValue(dp.x + j, dp.y + i);
+ byte v = _backgroundInfo.mask.getValue(dp.x + j, dp.y + i);
if (z >= v) *d = *s;
}
@@ -627,14 +626,14 @@ void Gfx::drawLabels() {
if (_labels[i]->_visible) {
Common::Rect r(_labels[i]->_cnv.w, _labels[i]->_cnv.h);
r.moveTo(_labels[i]->_pos);
- blt(r, (byte*)_labels[i]->_cnv.getBasePtr(0, 0), surf, BUFFER_FOREGROUND, LABEL_TRANSPARENT_COLOR);
+ blt(r, (byte*)_labels[i]->_cnv.getBasePtr(0, 0), surf, LAYER_FOREGROUND, LABEL_TRANSPARENT_COLOR);
}
}
if (_floatingLabel) {
Common::Rect r(_floatingLabel->_cnv.w, _floatingLabel->_cnv.h);
r.moveTo(_floatingLabel->_pos);
- blt(r, (byte*)_floatingLabel->_cnv.getBasePtr(0, 0), surf, BUFFER_FOREGROUND, LABEL_TRANSPARENT_COLOR);
+ blt(r, (byte*)_floatingLabel->_cnv.getBasePtr(0, 0), surf, LAYER_FOREGROUND, LABEL_TRANSPARENT_COLOR);
}
g_system->unlockScreen();
@@ -727,19 +726,10 @@ void Gfx::copyRect(const Common::Rect &r, Graphics::Surface &src, Graphics::Surf
}
void Gfx::grabBackground(const Common::Rect& r, Graphics::Surface &dst) {
- copyRect(r, _backgroundInfo->bg, dst);
+ copyRect(r, _backgroundInfo.bg, dst);
}
-uint16 Gfx::queryMask(uint16 v) {
-
- for (uint16 _si = 0; _si < 3; _si++) {
- if (_backgroundInfo->layers[_si+1] > v) return _si;
- }
-
- return BUFFER_FOREGROUND;
-}
-
Gfx::Gfx(Parallaction* vm) :
_vm(vm), _disk(vm->_disk) {
@@ -762,7 +752,6 @@ Gfx::Gfx(Parallaction* vm) :
_hbCircleRadius = 0;
_font = NULL;
- _backgroundInfo = new BackgroundInfo;
return;
}
@@ -770,7 +759,6 @@ Gfx::Gfx(Parallaction* vm) :
Gfx::~Gfx() {
freeBackground();
- delete _backgroundInfo;
return;
}
@@ -826,7 +814,7 @@ int Gfx::createBalloon(int16 w, int16 h, int16 winding, uint16 borderThickness)
winding = (winding == 0 ? 1 : 0);
Common::Rect s(BALLOON_TAIL_WIDTH, BALLOON_TAIL_HEIGHT);
s.moveTo(r.width()/2 - 5, r.bottom - 1);
- blt(s, _resBalloonTail[winding], &balloon->surface, BUFFER_FOREGROUND, BALLOON_TRANSPARENT_COLOR);
+ blt(s, _resBalloonTail[winding], &balloon->surface, LAYER_FOREGROUND, BALLOON_TRANSPARENT_COLOR);
}
_numBalloons++;
@@ -1000,25 +988,18 @@ bool Gfx::drawWrappedText(Graphics::Surface* surf, char *text, byte color, int16
}
void Gfx::freeBackground() {
-
- if (!_backgroundInfo)
- return;
-
- _backgroundInfo->bg.free();
- _backgroundInfo->mask.free();
- _backgroundInfo->path.free();
-
+ _backgroundInfo.free();
}
void Gfx::setBackground(uint type, const char* name, const char* mask, const char* path) {
if (type == kBackgroundLocation) {
- _disk->loadScenery(*_backgroundInfo, name, mask, path);
- setPalette(_backgroundInfo->palette);
- _palette.clone(_backgroundInfo->palette);
+ _disk->loadScenery(_backgroundInfo, name, mask, path);
+ setPalette(_backgroundInfo.palette);
+ _palette.clone(_backgroundInfo.palette);
} else {
- _disk->loadSlide(*_backgroundInfo, name);
- setPalette(_backgroundInfo->palette);
+ _disk->loadSlide(_backgroundInfo, name);
+ setPalette(_backgroundInfo.palette);
}
}
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index 2beab46cf5..8aae823a1a 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -326,6 +326,8 @@ public:
typedef Common::List<GfxObj*> GfxObjList;
+#define LAYER_FOREGROUND 3
+
struct BackgroundInfo {
uint width;
uint height;
@@ -348,6 +350,20 @@ struct BackgroundInfo {
assert(index < 6);
memcpy(&ranges[index], &range, sizeof(PaletteFxRange));
}
+
+ uint16 getLayer(uint16 z) {
+ for (uint16 i = 0; i < 3; i++) {
+ if (layers[i+1] > z) return i;
+ }
+ return LAYER_FOREGROUND;
+ }
+
+ void free() {
+ bg.free();
+ mask.free();
+ path.free();
+ }
+
};
@@ -394,7 +410,7 @@ public:
void freeItems();
// background surface
- BackgroundInfo *_backgroundInfo;
+ BackgroundInfo _backgroundInfo;
void setBackground(uint type, const char* name, const char* mask, const char* path);
void clearBackground();
void patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask = false);
@@ -412,10 +428,6 @@ public:
void setHalfbriteMode(bool enable);
void setProjectorPos(int x, int y);
- // misc
- uint16 queryMask(uint16 v);
- void setMask(MaskBuffer *buffer);
-
// init
Gfx(Parallaction* vm);
virtual ~Gfx();
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 8ac5fd6ff6..2de64c8b5d 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -745,7 +745,7 @@ void Parallaction::freeBackground() {
void Parallaction::setBackground(const char* name, const char* mask, const char* path) {
_gfx->setBackground(kBackgroundLocation, name, mask, path);
- _pathBuffer = &_gfx->_backgroundInfo->path;
+ _pathBuffer = &_gfx->_backgroundInfo.path;
return;
}
diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp
index 8d6d5d9ab0..023edc1460 100644
--- a/engines/parallaction/parser_br.cpp
+++ b/engines/parallaction/parser_br.cpp
@@ -132,9 +132,9 @@ DECLARE_LOCATION_PARSER(location) {
// flip();
// }
- _gfx->setBackground(&_backgroundInfo->bg);
- _gfx->_palette.clone(_backgroundInfo->palette);
- _gfx->setPalette(_backgroundInfo->palette);
+ _gfx->setBackground(&_backgroundInfo.bg);
+ _gfx->_palette.clone(_backgroundInfo.palette);
+ _gfx->setPalette(_backgroundInfo.palette);
#endif
if (_tokens[nextToken][0] != '\0') {
@@ -273,7 +273,7 @@ DECLARE_LOCATION_PARSER(mask) {
debugC(7, kDebugParser, "LOCATION_PARSER(mask) ");
#if 0
_disk->loadScenery(*_backgroundInfo, NULL, _tokens[1], NULL);
- _gfx->setMask(&_backgroundInfo->mask);
+ _gfx->setMask(&_backgroundInfo.mask);
_gfx->_bgLayers[0] = atoi(_tokens[2]);
_gfx->_bgLayers[1] = atoi(_tokens[3]);
@@ -286,7 +286,7 @@ DECLARE_LOCATION_PARSER(path) {
debugC(7, kDebugParser, "LOCATION_PARSER(path) ");
#if 0
_disk->loadScenery(*_backgroundInfo, NULL, NULL, _tokens[1]);
- _pathBuffer = &_backgroundInfo->path;
+ _pathBuffer = &_backgroundInfo.path;
#endif
}