aboutsummaryrefslogtreecommitdiff
path: root/engines/prince
diff options
context:
space:
mode:
authorlukaslw2014-07-19 18:10:11 +0200
committerlukaslw2014-07-19 18:10:11 +0200
commitf66a285551c2e91037b7e669facc3e2e6a5173bb (patch)
tree1690e4cc3dfd698f8fb5100831e01d99d1937fda /engines/prince
parent5a5211fbbc3e7745f28b8ed405c1ad6cf83be9b0 (diff)
downloadscummvm-rg350-f66a285551c2e91037b7e669facc3e2e6a5173bb.tar.gz
scummvm-rg350-f66a285551c2e91037b7e669facc3e2e6a5173bb.tar.bz2
scummvm-rg350-f66a285551c2e91037b7e669facc3e2e6a5173bb.zip
PRINCE: walkTo(), moveRunHero(), O_RUNHERO, O_MOVEHERO, O_CLEARPATH, O_SETPATH, O_LOADPATH
Diffstat (limited to 'engines/prince')
-rw-r--r--engines/prince/hero.cpp5
-rw-r--r--engines/prince/hero.h1
-rw-r--r--engines/prince/prince.cpp95
-rw-r--r--engines/prince/prince.h2
-rw-r--r--engines/prince/script.cpp16
5 files changed, 85 insertions, 34 deletions
diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp
index fea5a02c25..edfc6916eb 100644
--- a/engines/prince/hero.cpp
+++ b/engines/prince/hero.cpp
@@ -971,6 +971,11 @@ void Hero::freeOldMove() {
_state = Hero::STAY;
}
+//TODO
+void Hero::freeHeroAnim() {
+
+}
+
}
/* vim: set tabstop=4 noexpandtab: */
diff --git a/engines/prince/hero.h b/engines/prince/hero.h
index 918fa6dc16..4dd34e864c 100644
--- a/engines/prince/hero.h
+++ b/engines/prince/hero.h
@@ -135,6 +135,7 @@ public:
void specialAnim();
void getState();
void freeOldMove();
+ void freeHeroAnim();
//private:
PrinceEngine *_vm;
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 6b620eba8d..e08c2ebb1a 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -1997,6 +1997,72 @@ void PrinceEngine::drawInvItems() {
}
}
+void PrinceEngine::walkTo() {
+ if (_mainHero->_visible) {
+ _mainHero->freeHeroAnim();
+ _mainHero->freeOldMove();
+ _interpreter->storeNewPC(_script->_scriptInfo.usdCode);
+ int destX, destY;
+ if (_optionsMob != -1) {
+ destX = _mobList[_optionsMob]._examPosition.x;
+ destY = _mobList[_optionsMob]._examPosition.y;
+ _mainHero->_destDirection = _mobList[_optionsMob]._examDirection;
+ } else {
+ Common::Point mousePos = _system->getEventManager()->getMousePos();
+ destX = mousePos.x;
+ destY = mousePos.y;
+ _mainHero->_destDirection = 0;
+ }
+ _mainHero->_coords = makePath(destX, destY);
+ if (_mainHero->_coords != nullptr) {
+ _mainHero->_currCoords = _mainHero->_coords;
+ _mainHero->_dirTab = _directionTable;
+ _mainHero->_currDirTab = _directionTable;
+ _directionTable = nullptr;
+ _mainHero->_state = _mainHero->MOVE;
+ moveShandria();
+ }
+ }
+}
+
+void PrinceEngine::moveRunHero(int heroId, int x, int y, int dir, bool runHeroFlag) {
+ Hero *hero = nullptr;
+ if (!heroId) {
+ hero = _mainHero;
+ } else if (heroId == 1) {
+ hero = _secondHero;
+ }
+
+ if (hero != nullptr) {
+ if (dir) {
+ hero->_destDirection = dir;
+ }
+ if (x && y) {
+ hero->freeOldMove();
+ hero->_coords = makePath(x, y);
+ if (hero->_coords != nullptr) {
+ hero->_currCoords = _mainHero->_coords;
+ hero->_dirTab = _directionTable;
+ hero->_currDirTab = _directionTable;
+ _directionTable = nullptr;
+ if (runHeroFlag) {
+ hero->_state = _mainHero->RUN;
+ } else {
+ hero->_state = _mainHero->MOVE;
+ }
+ }
+ } else {
+ hero->freeOldMove();
+ hero->_state = Hero::TURN;
+ }
+ hero->freeHeroAnim();
+ hero->_visible = 1;
+ if (heroId == 1 && _mouseFlag) {
+ moveShandria();
+ }
+ }
+}
+
void PrinceEngine::leftMouseButton() {
if (_mouseFlag) {
int option = 0;
@@ -2012,32 +2078,7 @@ void PrinceEngine::leftMouseButton() {
} else {
_optionsMob = _selectedMob;
if (_optionsMob == -1) {
- // @@walkto - TODO
- if (_mainHero->_visible) {
- //freeHeroAnim();
- _mainHero->freeOldMove();
- _interpreter->storeNewPC(_script->_scriptInfo.usdCode);
- int destX, destY;
- if (_optionsMob != -1) {
- destX = _mobList[_optionsMob]._examPosition.x;
- destY = _mobList[_optionsMob]._examPosition.y;
- _mainHero->_destDirection = _mobList[_optionsMob]._examDirection; // second hero?
- } else {
- Common::Point mousePos = _system->getEventManager()->getMousePos();
- destX = mousePos.x;
- destY = mousePos.y;
- _mainHero->_destDirection = 0; // second hero?
- }
- _mainHero->_coords = makePath(destX, destY);
- if (_mainHero->_coords != nullptr) {
- _mainHero->_currCoords = _mainHero->_coords;
- _mainHero->_dirTab = _directionTable;
- _mainHero->_currDirTab = _directionTable;
- _directionTable = nullptr;
- _mainHero->_state = _mainHero->MOVE;
- moveShandria();
- }
- }
+ walkTo();
return;
}
option = 0;
@@ -2051,7 +2092,7 @@ void PrinceEngine::leftMouseButton() {
}
if (optionEvent == -1) {
if (!option) {
- //@@walkto - TODO
+ walkTo();
return;
} else {
optionEvent = _script->getOptionStandardOffset(option);
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index e6542b763d..54c9e65e89 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -496,6 +496,8 @@ public:
void scanDirections();
int scanDirectionsFindNext(byte *coords, int xDiff, int yDiff);
void moveShandria();
+ void walkTo();
+ void moveRunHero(int heroId, int x, int y, int dir, bool runHeroFlag);
void testDrawPath();
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index fdf1b7c8ef..3f76b91fb7 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -950,7 +950,7 @@ void Interpreter::O_MOVEHERO() {
uint16 x = readScriptFlagValue();
uint16 y = readScriptFlagValue();
uint16 dir = readScriptFlagValue();
-
+ _vm->moveRunHero(heroId, x, y, dir, false);
debugInterpreter("O_MOVEHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir);
}
@@ -1271,10 +1271,9 @@ void Interpreter::O_TALKBACKANIM() {
void Interpreter::O_LOADPATH() {
int32 offset = readScript<uint32>();
- debugInterpreter("O_LOADPATH offset %d", offset);
- // _currentInstruction + offset path file name ptr
- // free path bitmap
- // load packet path bitmap and puts in Sala
+ // simplifying, because used only once in Location 20
+ _vm->loadPath("path2");
+ debugInterpreter("O_LOADPATH - path2");
}
void Interpreter::O_GETCHAR() {
@@ -1525,13 +1524,15 @@ void Interpreter::O_BACKANIMRANGE() {
}
void Interpreter::O_CLEARPATH() {
+ for (int i = 0; i < _vm->kPathBitmapLen; i++) {
+ _vm->_roomPathBitmap[i] = 255;
+ }
debugInterpreter("O_CLEARPATH");
- // Fill Sala with 255
}
void Interpreter::O_SETPATH() {
+ _vm->loadPath("path");
debugInterpreter("O_SETPATH");
- // CopyPath
}
void Interpreter::O_GETHEROX() {
@@ -1631,6 +1632,7 @@ void Interpreter::O_RUNHERO() {
uint16 x = readScriptFlagValue();
uint16 y = readScriptFlagValue();
uint16 dir = readScriptFlagValue();
+ _vm->moveRunHero(heroId, x, y, dir, true);
debugInterpreter("O_RUNHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir);
}