aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2009-03-23 00:56:05 +0000
committerNicola Mettifogo2009-03-23 00:56:05 +0000
commit71f42a954988bfe490d9c76e16edfa06873fe1b8 (patch)
treee641a159bd307189d96dc6afca2efbec56f9316e /engines
parente3f9acc3e6c66ab42e6e992536c933069771c99e (diff)
downloadscummvm-rg350-71f42a954988bfe490d9c76e16edfa06873fe1b8.tar.gz
scummvm-rg350-71f42a954988bfe490d9c76e16edfa06873fe1b8.tar.bz2
scummvm-rg350-71f42a954988bfe490d9c76e16edfa06873fe1b8.zip
Fully implemented scrolling.
svn-id: r39622
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/exec_br.cpp4
-rw-r--r--engines/parallaction/gfxbase.cpp25
-rw-r--r--engines/parallaction/graphics.cpp71
-rw-r--r--engines/parallaction/graphics.h18
-rw-r--r--engines/parallaction/input.cpp5
-rw-r--r--engines/parallaction/parallaction.cpp26
-rw-r--r--engines/parallaction/parallaction_br.cpp17
-rw-r--r--engines/parallaction/walk.cpp29
8 files changed, 105 insertions, 90 deletions
diff --git a/engines/parallaction/exec_br.cpp b/engines/parallaction/exec_br.cpp
index 04969fcad4..a3eb919354 100644
--- a/engines/parallaction/exec_br.cpp
+++ b/engines/parallaction/exec_br.cpp
@@ -264,7 +264,9 @@ DECLARE_COMMAND_OPCODE(zeta) {
DECLARE_COMMAND_OPCODE(scroll) {
- warning("Parallaction_br::cmdOp_scroll not yet implemented");
+ Common::Point p;
+ _vm->_gfx->getScrollPos(p);
+ _vm->_gfx->initiateScroll(ctxt._cmd->u._counterValue - p.x, 0);
}
diff --git a/engines/parallaction/gfxbase.cpp b/engines/parallaction/gfxbase.cpp
index 47bf0000db..ec72b14c15 100644
--- a/engines/parallaction/gfxbase.cpp
+++ b/engines/parallaction/gfxbase.cpp
@@ -227,7 +227,7 @@ void Gfx::drawGfxObject(GfxObj *obj, Graphics::Surface &surf) {
int x = obj->x;
if (_overlayMode) {
- x += _scrollPos;
+ x += _scrollPosX;
}
rect.translate(x, obj->y);
data = obj->getData(obj->frame);
@@ -248,29 +248,6 @@ void Gfx::drawText(Font *font, Graphics::Surface* surf, uint16 x, uint16 y, cons
}
-#if 0
-void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, byte transparentColor) {
-
- byte *d = _unpackedBitmap;
-
- while (size > 0) {
-
- uint8 p = *data++;
- size--;
- uint8 color = p & 0xF;
- uint8 repeat = (p & 0xF0) >> 4;
- if (repeat == 0) {
- repeat = *data++;
- size--;
- }
-
- memset(d, color, repeat);
- d += repeat;
- }
-
- blt(r, _unpackedBitmap, surf, z, transparentColor);
-}
-#endif
void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor) {
byte *d = _unpackedBitmap;
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index fdeba0b089..15ac36fc65 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -317,7 +317,7 @@ void Gfx::drawList(Graphics::Surface &surface, GfxObjArray &list) {
void Gfx::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
if (_doubleBuffering) {
if (_overlayMode)
- x += _scrollPos;
+ x += _scrollPosX;
byte *dst = (byte*)_backBuffer.getBasePtr(x, y);
for (int i = 0; i < h; i++) {
@@ -357,23 +357,60 @@ void Gfx::unlockScreen() {
void Gfx::updateScreenIntern() {
if (_doubleBuffering) {
- byte *data = (byte*)_backBuffer.getBasePtr(_scrollPos, 0);
+ byte *data = (byte*)_backBuffer.getBasePtr(_scrollPosX, 0);
_vm->_system->copyRectToScreen(data, _backBuffer.pitch, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
}
_vm->_system->updateScreen();
}
-int Gfx::getScrollPos() {
- return _scrollPos;
+void Gfx::getScrollPos(Common::Point &p) {
+ p.x = _scrollPosX;
+ p.y = _scrollPosY;
}
-void Gfx::setScrollPos(int scrollX) {
- _scrollPos = CLIP(scrollX, _minScroll, _maxScroll);
+void Gfx::setScrollPosX(int scrollX) {
+ _scrollPosX = CLIP(scrollX, _minScrollX, _maxScrollX);
+}
+
+void Gfx::setScrollPosY(int scrollY) {
+ _scrollPosY = CLIP(scrollY, _minScrollY, _maxScrollY);
+}
+
+void Gfx::initiateScroll(int deltaX, int deltaY) {
+ if (deltaX != 0) {
+ _requestedHScrollDir = deltaX > 0 ? 1 : -1;
+ deltaX *= _requestedHScrollDir;
+ _requestedHScrollSteps = ((deltaX+31)/32) / _requestedHScrollDir;
+ }
+
+ if (deltaY != 0) {
+ _requestedVScrollDir = deltaY > 0 ? 1 : -1;
+ deltaY *= _requestedVScrollDir;
+ _requestedVScrollSteps = ((deltaY+7)/8) / _requestedVScrollDir;
+ }
+}
+
+void Gfx::scroll() {
+ int32 x = _scrollPosX, y = _scrollPosY;
+
+ if (_requestedHScrollSteps) {
+ x += 32*_requestedHScrollDir; // scroll 32 pixels at a time
+ _requestedHScrollSteps--;
+ }
+
+ if (_requestedVScrollSteps) {
+ y += 8*_requestedVScrollDir; // scroll 8 pixel at a time
+ _requestedVScrollSteps--;
+ }
+
+ setScrollPosX(x);
+ setScrollPosY(y);
}
void Gfx::beginFrame() {
resetSceneDrawList();
+ scroll();
}
void Gfx::updateScreen() {
@@ -392,20 +429,7 @@ void Gfx::updateScreen() {
uint16 backgroundPitch = _backgroundInfo->bg.pitch;
copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo->_x, _backgroundInfo->_y, w, h);
}
-/*
- if (_varDrawPathZones == 1) {
- Graphics::Surface *surf = lockScreen();
- ZoneList::iterator b = _vm->_location._zones.begin();
- ZoneList::iterator e = _vm->_location._zones.end();
- for (; b != e; b++) {
- ZonePtr z = *b;
- if (z->_type & kZonePath) {
- surf->frameRect(Common::Rect(z->getX(), z->getY(), z->getX() + z->width(), z->getY() + z->height()), 2);
- }
- }
- unlockScreen();
- }
-*/
+
sortScene();
Graphics::Surface *surf = lockScreen();
// draws animations frames and other game items
@@ -691,7 +715,8 @@ void Gfx::grabBackground(const Common::Rect& r, Graphics::Surface &dst) {
Gfx::Gfx(Parallaction* vm) :
- _vm(vm), _disk(vm->_disk), _backgroundInfo(0), _scrollPos(0), _minScroll(0), _maxScroll(0) {
+ _vm(vm), _disk(vm->_disk), _backgroundInfo(0), _scrollPosX(0), _minScrollX(0), _maxScrollX(0),
+ _minScrollY(0), _maxScrollY(0), _requestedHScrollSteps(0), _requestedVScrollSteps(0) {
_gameType = _vm->getGameType();
_doubleBuffering = _gameType != GType_Nippon;
@@ -827,8 +852,8 @@ void Gfx::setBackground(uint type, BackgroundInfo *info) {
}
}
- _minScroll = 0;
- _maxScroll = MAX<int>(0, _backgroundInfo->width - _vm->_screenWidth);
+ _minScrollX = 0;
+ _maxScrollX = MAX<int>(0, _backgroundInfo->width - _vm->_screenWidth);
}
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index 2816729eb6..e7e7c7fb41 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -478,8 +478,13 @@ public:
void setProjectorProgram(int16 *data);
int16 *_nextProjectorPos;
- int getScrollPos();
- void setScrollPos(int scrollX);
+ // start programmatic relative scroll
+ void initiateScroll(int deltaX, int deltaY);
+ // immediate and absolute x,y scroll
+ void setScrollPosX(int scrollX);
+ void setScrollPosY(int scrollY);
+ // return current scroll position
+ void getScrollPos(Common::Point &p);
// init
Gfx(Parallaction* vm);
@@ -512,9 +517,14 @@ protected:
Graphics::Surface _backBuffer;
void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
- int _scrollPos;
- int _minScroll, _maxScroll;
+ int _scrollPosX, _scrollPosY;
+ int _minScrollX, _maxScrollX, _minScrollY, _maxScrollY;
+ uint32 _requestedHScrollSteps;
+ uint32 _requestedVScrollSteps;
+ int32 _requestedHScrollDir;
+ int32 _requestedVScrollDir;
+ void scroll();
#define NO_FLOATING_LABEL 1000
GfxObjArray _labels;
diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp
index c36288fe40..3fbd65d196 100644
--- a/engines/parallaction/input.cpp
+++ b/engines/parallaction/input.cpp
@@ -442,8 +442,9 @@ bool Input::isMouseEnabled() {
}
void Input::getAbsoluteCursorPos(Common::Point& p) const {
- p = _mousePos;
- p.x += _vm->_gfx->getScrollPos();
+ _vm->_gfx->getScrollPos(p);
+ p.x += _mousePos.x;
+ p.y += _mousePos.y;
}
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 23da65cee7..7b6f3b464e 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -160,32 +160,6 @@ void Parallaction::updateView() {
return;
}
- #define SCROLL_BAND_WIDTH 120
-
- int scrollX = 0;
- if (canScroll()) {
- scrollX = _gfx->getScrollPos();
-
- if (_char._ani->gfxobj) {
- Common::Point foot;
- _char._ani->getFoot(foot);
-
- foot.x -= scrollX;
- //foot.y -= ...
-
- int min = SCROLL_BAND_WIDTH;
- int max = _screenWidth - SCROLL_BAND_WIDTH;
-
- if (foot.x < min) {
- scrollX -= (min - foot.x);
- } else
- if (foot.x > max) {
- scrollX += (foot.x - max);
- }
- }
- }
- _gfx->setScrollPos(scrollX);
-
_gfx->animatePalette();
_gfx->updateScreen();
_system->delayMillis(30);
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index 54b91896d3..6fcf009a21 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -293,6 +293,19 @@ void Parallaction_br::changeLocation() {
_location._followerStartPosition.x = -1000;
_location._followerStartPosition.y = -1000;
+ _gfx->setScrollPosX(0);
+ _gfx->setScrollPosY(0);
+ if (_char._ani->gfxobj) {
+ Common::Point foot;
+ _char._ani->getFoot(foot);
+
+ if (foot.x > 550)
+ _gfx->setScrollPosX(320);
+
+ if (foot.y > 350)
+ _gfx->setScrollPosY(foot.y - 350);
+ }
+
// kFlagsRemove is cleared because the character is visible by default.
// Commands can hide the character, anyway.
_char._ani->_flags &= ~kFlagsRemove;
@@ -301,8 +314,8 @@ void Parallaction_br::changeLocation() {
doLocationEnterTransition();
_cmdExec->run(_location._aCommands);
-
- // NOTE: music should not started here!
+
+ // NOTE: music should not started here!
// TODO: implement the music commands which control music execution
_soundMan->execute(SC_PLAYMUSIC);
diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp
index e00a9fa8b4..ec435fddec 100644
--- a/engines/parallaction/walk.cpp
+++ b/engines/parallaction/walk.cpp
@@ -529,14 +529,6 @@ void PathWalker_BR::finalizeWalk(State &s) {
s._a->setF(s._dirFrame); // temporary solution
-#if 0
- // TODO: support scrolling ;)
- if (foot.x > _gfx->hscroll + 600) _gfx->scrollRight(78);
- if (foot.x < _gfx->hscroll + 40) _gfx->scrollLeft(78);
- if (foot.y > 350) _gfx->scrollDown(100);
- if (foot.y < 80) _gfx->scrollUp(100);
-#endif
-
s._active = false;
}
@@ -550,6 +542,27 @@ void PathWalker_BR::walk() {
doWalk(_character);
doWalk(_follower);
+ Common::Point pos, foot;
+ _vm->_gfx->getScrollPos(pos);
+ _character._a->getFoot(foot);
+
+ int32 dx = 0, dy = 0;
+ if (foot.x > pos.x + 600) {
+ dx = 78*4;
+ } else
+ if (foot.x < pos.x + 40) {
+ dx = -78*4;
+ }
+
+ if (foot.y > pos.y + 350) {
+ dy = 100;
+ } else
+ if (foot.y < pos.y + 80) {
+ dy = -100;
+ }
+
+ _vm->_gfx->initiateScroll(dx, dy);
+
debugC(3, kDebugWalk, "PathWalker_BR::walk() -> done");
}