[Scummvm-cvs-logs] SF.net SVN: scummvm:[39622] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Mon Mar 23 01:56:05 CET 2009
Revision: 39622
http://scummvm.svn.sourceforge.net/scummvm/?rev=39622&view=rev
Author: peres001
Date: 2009-03-23 00:56:05 +0000 (Mon, 23 Mar 2009)
Log Message:
-----------
Fully implemented scrolling.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/exec_br.cpp
scummvm/trunk/engines/parallaction/gfxbase.cpp
scummvm/trunk/engines/parallaction/graphics.cpp
scummvm/trunk/engines/parallaction/graphics.h
scummvm/trunk/engines/parallaction/input.cpp
scummvm/trunk/engines/parallaction/parallaction.cpp
scummvm/trunk/engines/parallaction/parallaction_br.cpp
scummvm/trunk/engines/parallaction/walk.cpp
Modified: scummvm/trunk/engines/parallaction/exec_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_br.cpp 2009-03-22 23:11:43 UTC (rev 39621)
+++ scummvm/trunk/engines/parallaction/exec_br.cpp 2009-03-23 00:56:05 UTC (rev 39622)
@@ -264,7 +264,9 @@
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);
}
Modified: scummvm/trunk/engines/parallaction/gfxbase.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gfxbase.cpp 2009-03-22 23:11:43 UTC (rev 39621)
+++ scummvm/trunk/engines/parallaction/gfxbase.cpp 2009-03-23 00:56:05 UTC (rev 39622)
@@ -227,7 +227,7 @@
int x = obj->x;
if (_overlayMode) {
- x += _scrollPos;
+ x += _scrollPosX;
}
rect.translate(x, obj->y);
data = obj->getData(obj->frame);
@@ -248,29 +248,6 @@
}
-#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;
Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp 2009-03-22 23:11:43 UTC (rev 39621)
+++ scummvm/trunk/engines/parallaction/graphics.cpp 2009-03-23 00:56:05 UTC (rev 39622)
@@ -317,7 +317,7 @@
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::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 @@
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 @@
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 @@
}
}
- _minScroll = 0;
- _maxScroll = MAX<int>(0, _backgroundInfo->width - _vm->_screenWidth);
+ _minScrollX = 0;
+ _maxScrollX = MAX<int>(0, _backgroundInfo->width - _vm->_screenWidth);
}
Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h 2009-03-22 23:11:43 UTC (rev 39621)
+++ scummvm/trunk/engines/parallaction/graphics.h 2009-03-23 00:56:05 UTC (rev 39622)
@@ -478,8 +478,13 @@
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 @@
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;
Modified: scummvm/trunk/engines/parallaction/input.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/input.cpp 2009-03-22 23:11:43 UTC (rev 39621)
+++ scummvm/trunk/engines/parallaction/input.cpp 2009-03-23 00:56:05 UTC (rev 39622)
@@ -442,8 +442,9 @@
}
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;
}
Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp 2009-03-22 23:11:43 UTC (rev 39621)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp 2009-03-23 00:56:05 UTC (rev 39622)
@@ -160,32 +160,6 @@
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);
Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp 2009-03-22 23:11:43 UTC (rev 39621)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp 2009-03-23 00:56:05 UTC (rev 39622)
@@ -293,6 +293,19 @@
_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 @@
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);
Modified: scummvm/trunk/engines/parallaction/walk.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/walk.cpp 2009-03-22 23:11:43 UTC (rev 39621)
+++ scummvm/trunk/engines/parallaction/walk.cpp 2009-03-23 00:56:05 UTC (rev 39622)
@@ -529,14 +529,6 @@
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 @@
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");
}
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