aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/avalanche/animation.cpp79
-rw-r--r--engines/avalanche/animation.h34
-rw-r--r--engines/avalanche/avalanche.cpp8
-rw-r--r--engines/avalanche/avalot.cpp63
-rw-r--r--engines/avalanche/avalot.h4
-rw-r--r--engines/avalanche/parser.cpp9
-rw-r--r--engines/avalanche/parser.h4
-rw-r--r--engines/avalanche/timer.cpp6
8 files changed, 123 insertions, 84 deletions
diff --git a/engines/avalanche/animation.cpp b/engines/avalanche/animation.cpp
index 18164c7673..7ddc58945f 100644
--- a/engines/avalanche/animation.cpp
+++ b/engines/avalanche/animation.cpp
@@ -137,14 +137,14 @@ void AnimationType::draw() {
_anim->_vm->_graphics->drawSprite(_info, picnum, _x, _y);
}
-void AnimationType::turn(byte whichway) {
+void AnimationType::turn(Direction whichway) {
if (whichway == 8)
- _facingDir = Animation::kDirUp;
+ _facingDir = kDirUp;
else
_facingDir = whichway;
}
-void AnimationType::appear(int16 wx, int16 wy, byte wf) {
+void AnimationType::appear(int16 wx, int16 wy, Direction wf) {
_x = (wx / 8) * 8;
_y = wy;
_oldX[_anim->_vm->_avalot->_cp] = wx;
@@ -309,14 +309,14 @@ void AnimationType::setSpeed(int8 xx, int8 yy) {
if (_moveX == 0) {
// No horz movement
if (_moveY < 0)
- turn(Animation::kDirUp);
+ turn(kDirUp);
else
- turn(Animation::kDirDown);
+ turn(kDirDown);
} else {
if (_moveX < 0)
- turn(Animation::kDirLeft);
+ turn(kDirLeft);
else
- turn(Animation::kDirRight);
+ turn(kDirRight);
}
}
@@ -942,7 +942,7 @@ void Animation::updateSpeed() {
}
}
-void Animation::changeDirection(byte t, byte dir) {
+void Animation::setMoveSpeed(byte t, Direction dir) {
switch (dir) {
case kDirUp:
_sprites[t].setSpeed(0, -_sprites[t]._speedY);
@@ -975,7 +975,7 @@ void Animation::appearPed(byte sprNum, byte pedNum) {
AnimationType *curSpr = &_sprites[sprNum];
PedType *curPed = &_vm->_avalot->_peds[pedNum];
curSpr->appear(curPed->_x - curSpr->_info._xLength / 2, curPed->_y - curSpr->_info._yLength, curPed->_direction);
- changeDirection(sprNum, curPed->_direction);
+ setMoveSpeed(sprNum, curPed->_direction);
}
void Animation::followAvalotY(byte tripnum) {
@@ -1078,19 +1078,20 @@ void Animation::takeAStep(byte &tripnum) {
}
}
-void Animation::spin(byte whichway, byte &tripnum) {
- if (_sprites[tripnum]._facingDir != whichway) {
- _sprites[tripnum]._facingDir = whichway;
- if (_sprites[tripnum]._id == 2)
- return; // Not for Spludwick
+void Animation::spin(Direction dir, byte &tripnum) {
+ if (_sprites[tripnum]._facingDir == dir)
+ return;
- _vm->_avalot->_geidaSpin += 1;
- _vm->_avalot->_geidaTime = 20;
- if (_vm->_avalot->_geidaSpin == 5) {
- _vm->_dialogs->displayText("Steady on, Avvy, you'll make the poor girl dizzy!");
- _vm->_avalot->_geidaSpin = 0;
- _vm->_avalot->_geidaTime = 0; // knock out records
- }
+ _sprites[tripnum]._facingDir = dir;
+ if (_sprites[tripnum]._id == 2)
+ return; // Not for Spludwick
+
+ _vm->_avalot->_geidaSpin += 1;
+ _vm->_avalot->_geidaTime = 20;
+ if (_vm->_avalot->_geidaSpin == 5) {
+ _vm->_dialogs->displayText("Steady on, Avvy, you'll make the poor girl dizzy!");
+ _vm->_avalot->_geidaSpin = 0;
+ _vm->_avalot->_geidaTime = 0; // knock out records
}
}
@@ -1330,56 +1331,56 @@ void Animation::handleMoveKey(const Common::Event &event) {
case Common::KEYCODE_UP:
if (_direction != kDirUp) {
_direction = kDirUp;
- changeDirection(0, _direction);
+ setMoveSpeed(0, _direction);
} else
stopWalking();
break;
case Common::KEYCODE_DOWN:
if (_direction != kDirDown) {
_direction = kDirDown;
- changeDirection(0, _direction);
+ setMoveSpeed(0, _direction);
} else
stopWalking();
break;
case Common::KEYCODE_LEFT:
if (_direction != kDirLeft) {
_direction = kDirLeft;
- changeDirection(0, _direction);
+ setMoveSpeed(0, _direction);
} else
stopWalking();
break;
case Common::KEYCODE_RIGHT:
if (_direction != kDirRight) {
_direction = kDirRight;
- changeDirection(0, _direction);
+ setMoveSpeed(0, _direction);
} else
stopWalking();
break;
case Common::KEYCODE_PAGEUP:
if (_direction != kDirUpRight) {
_direction = kDirUpRight;
- changeDirection(0, _direction);
+ setMoveSpeed(0, _direction);
} else
stopWalking();
break;
case Common::KEYCODE_PAGEDOWN:
if (_direction != kDirDownRight) {
_direction = kDirDownRight;
- changeDirection(0, _direction);
+ setMoveSpeed(0, _direction);
} else
stopWalking();
break;
case Common::KEYCODE_END:
if (_direction != kDirDownLeft) {
_direction = kDirDownLeft;
- changeDirection(0, _direction);
+ setMoveSpeed(0, _direction);
} else
stopWalking();
break;
case Common::KEYCODE_HOME:
if (_direction != kDirUpLeft) {
_direction = kDirUpLeft;
- changeDirection(0, _direction);
+ setMoveSpeed(0, _direction);
} else
stopWalking();
break;
@@ -1392,4 +1393,24 @@ void Animation::handleMoveKey(const Common::Event &event) {
}
}
+void Animation::setDirection(Direction dir) {
+ _direction = dir;
+}
+
+void Animation::setOldDirection(Direction dir) {
+ _oldDirection = dir;
+}
+
+Direction Animation::getDirection() {
+ return _direction;
+}
+
+Direction Animation::getOldDirection() {
+ return _oldDirection;
+}
+
+void Animation::synchronize(Common::Serializer &sz) {
+ sz.syncAsByte(_direction);
+}
+
} // End of namespace Avalanche.
diff --git a/engines/avalanche/animation.h b/engines/avalanche/animation.h
index 1f13fd1407..a411de7c20 100644
--- a/engines/avalanche/animation.h
+++ b/engines/avalanche/animation.h
@@ -39,6 +39,12 @@ namespace Avalanche {
class AvalancheEngine;
class Animation;
+enum Direction {
+ kDirUp = 0, kDirRight, kDirDown, kDirLeft,
+ kDirUpRight, kDirDownRight, kDirDownLeft, kDirUpLeft,
+ kDirStopped, kDirNone = 177
+};
+
struct StatType {
Common::String _name; // Name of character.
Common::String _comment; // Comment.
@@ -52,7 +58,8 @@ class AnimationType {
public:
SpriteInfo _info;
StatType _stat; // Vital statistics.
- byte _facingDir, _stepNum;
+ Direction _facingDir;
+ byte _stepNum;
int16 _x, _y; // Current xy coords.
int16 _oldX[2], _oldY[2]; // Last xy coords.
int8 _moveX, _moveY; // Amount to move sprite by, each step.
@@ -69,8 +76,8 @@ public:
void init(byte spritenum, bool doCheck, Animation *anim); // Loads & sets up the sprite.
void original(); // Just sets 'quick' to false.
void draw(); // Drops sprite onto screen. Original: andexor().
- void turn(byte whichway); // Turns character round.
- void appear(int16 wx, int16 wy, byte wf); // Switches it on.
+ void turn(Direction whichway); // Turns character round.
+ void appear(int16 wx, int16 wy, Direction wf); // Switches it on.
void bounce(); // Bounces off walls.
void walk(); // Prepares for andexor, etc.
void walkTo(byte pednum); // Home in on a point.
@@ -92,12 +99,6 @@ class Animation {
public:
friend class AnimationType;
- enum Direction {
- kDirUp, kDirRight, kDirDown, kDirLeft,
- kDirUpRight, kDirDownRight, kDirDownLeft, kDirUpLeft,
- kDirStopped
- };
-
static const byte kSpriteNumbMax = 5; // current max no. of sprites
enum Proc {
@@ -113,8 +114,6 @@ public:
AnimationType _sprites[kSpriteNumbMax];
bool _mustExclaim;
uint16 _sayWhat;
- byte _direction; // The direction Avvy is currently facing.
- byte _oldDirection;
Animation(AvalancheEngine *vm);
~Animation();
@@ -125,7 +124,7 @@ public:
void openDoor(byte whither, byte ped, byte magicnum); // Handles slidey-open doors.
void catacombMove(byte ped); // When you enter a new position in the catacombs, this procedure should be called. It changes the 'also' codes so that they may match the picture on the screen.
void stopWalking();
- void changeDirection(byte t, byte dir);
+ void setMoveSpeed(byte t, Direction dir);
void appearPed(byte sprNum, byte pedNum);
void flipRoom(byte room, byte ped);
bool inField(byte which); // Returns true if you're within field "which".
@@ -133,7 +132,16 @@ public:
void updateSpeed();
void handleMoveKey(const Common::Event &event); // To replace tripkey().
+ void setDirection(Direction dir);
+ void setOldDirection(Direction dir);
+ Direction getDirection();
+ Direction getOldDirection();
+
+ void synchronize(Common::Serializer &sz);
private:
+ Direction _direction; // The direction Avvy is currently facing.
+ Direction _oldDirection;
+
AvalancheEngine *_vm;
byte checkFeet(int16 x1, int16 x2, int16 oy, int16 y, byte yl);
@@ -150,7 +158,7 @@ private:
void faceAvvy(byte tripnum);
// Movements for Homing NPCs: Spludwick and Geida.
- void spin(byte whichway, byte &tripnum);
+ void spin(Direction dir, byte &tripnum);
void takeAStep(byte &tripnum);
void geidaProcs(byte tripnum);
diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp
index 110cef74e5..b8f06bf134 100644
--- a/engines/avalanche/avalanche.cpp
+++ b/engines/avalanche/avalanche.cpp
@@ -113,15 +113,15 @@ const char *AvalancheEngine::getCopyrightString() const {
}
void AvalancheEngine::synchronize(Common::Serializer &sz) {
- sz.syncAsByte(_animation->_direction);
+ _animation->synchronize(sz);
+ _parser->synchronize(sz);
+
sz.syncAsByte(_avalot->_carryNum);
for (int i = 0; i < kObjectNum; i++)
sz.syncAsByte(_avalot->_objects[i]);
sz.syncAsSint16LE(_avalot->_dnascore);
sz.syncAsSint32LE(_avalot->_money);
sz.syncAsByte(_avalot->_room);
- sz.syncAsByte(_parser->_wearing);
- sz.syncAsByte(_parser->_sworeNum);
if (sz.isSaving())
_saveNum++;
sz.syncAsByte(_saveNum);
@@ -439,7 +439,7 @@ bool AvalancheEngine::loadGame(const int16 slot) {
AnimationType *avvy = &_animation->_sprites[0];
if (avvy->_quick && avvy->_visible)
- _animation->changeDirection(0, _animation->_direction); // We push Avvy in the right direction is he was moving.
+ _animation->setMoveSpeed(0, _animation->getDirection()); // We push Avvy in the right direction is he was moving.
return true;
}
diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp
index 8feec3f03e..b1c2edd10b 100644
--- a/engines/avalanche/avalot.cpp
+++ b/engines/avalanche/avalot.cpp
@@ -357,7 +357,7 @@ void Avalot::setup() {
drawToolbar();
_vm->_dialogs->setReadyLight(2);
- _vm->_animation->_direction = Animation::kDirStopped;
+ _vm->_animation->setDirection(kDirStopped);
_vm->_animation->loadAnims();
dawn();
@@ -565,7 +565,7 @@ void Avalot::loadAlso(byte num) {
PedType *curPed = &_peds[i];
curPed->_x = file.readSint16LE();
curPed->_y = file.readSint16LE();
- curPed->_direction = file.readByte();
+ curPed->_direction = (Direction)file.readByte();
}
_fieldNum = file.readByte();
@@ -792,7 +792,7 @@ void Avalot::enterRoom(byte room, byte ped) {
spr1->walkTo(4); // Walks up to greet you.
} else {
_vm->_animation->appearPed(1, 4); // Starts where he was before.
- spr1->_facingDir = Animation::kDirLeft;
+ spr1->_facingDir = kDirLeft;
}
spr1->_callEachStepFl = true;
@@ -852,7 +852,7 @@ void Avalot::enterRoom(byte room, byte ped) {
} else {
// You've been here before.
_vm->_animation->appearPed(1, 3); // He's standing in your way straight away...
- spr1->_facingDir = Animation::kDirLeft;
+ spr1->_facingDir = kDirLeft;
}
}
break;
@@ -919,7 +919,7 @@ void Avalot::enterRoom(byte room, byte ped) {
default: // You've answered SOME of his questions.
spr1->init(9, false, _vm->_animation);
_vm->_animation->appearPed(1, 2);
- spr1->_facingDir = Animation::kDirRight;
+ spr1->_facingDir = kDirRight;
_vm->_timer->addTimer(3, Timer::kProcCardiffReturn, Timer::kReasonCardiffsurvey);
}
}
@@ -1047,7 +1047,7 @@ void Avalot::enterRoom(byte room, byte ped) {
spr1->walkTo(3); // Walks up to greet you.
} else {
_vm->_animation->appearPed(1, 3); // Starts where she was before.
- spr1->_facingDir = Animation::kDirLeft;
+ spr1->_facingDir = kDirLeft;
}
spr1->_callEachStepFl = true;
@@ -1230,7 +1230,7 @@ void Avalot::drawToolbar() {
file.close();
CursorMan.showMouse(true);
- _vm->_animation->_oldDirection = 177;
+ _vm->_animation->setOldDirection(kDirNone);
drawDirection();
}
@@ -1279,23 +1279,23 @@ void Avalot::useCompass(const Common::Point &cursorPos) {
switch (color) {
case kColorGreen:
- _vm->_animation->_direction = Animation::kDirUp;
- _vm->_animation->changeDirection(0, Animation::kDirUp);
+ _vm->_animation->setDirection(kDirUp);
+ _vm->_animation->setMoveSpeed(0, kDirUp);
drawDirection();
break;
case kColorBrown:
- _vm->_animation->_direction = Animation::kDirDown;
- _vm->_animation->changeDirection(0, Animation::kDirDown);
+ _vm->_animation->setDirection(kDirDown);
+ _vm->_animation->setMoveSpeed(0, kDirDown);
drawDirection();
break;
case kColorCyan:
- _vm->_animation->_direction = Animation::kDirLeft;
- _vm->_animation->changeDirection(0, Animation::kDirLeft);
+ _vm->_animation->setDirection(kDirLeft);
+ _vm->_animation->setMoveSpeed(0, kDirLeft);
drawDirection();
break;
case kColorLightmagenta:
- _vm->_animation->_direction = Animation::kDirRight;
- _vm->_animation->changeDirection(0, Animation::kDirRight);
+ _vm->_animation->setDirection(kDirRight);
+ _vm->_animation->setMoveSpeed(0, kDirRight);
drawDirection();
break;
case kColorRed:
@@ -1354,28 +1354,28 @@ void Avalot::guideAvvy(Common::Point cursorPos) {
_vm->_animation->stopWalking();
break; // Clicked on Avvy: no movement.
case 1:
- _vm->_animation->changeDirection(0, Animation::kDirLeft);
+ _vm->_animation->setMoveSpeed(0, kDirLeft);
break;
case 2:
- _vm->_animation->changeDirection(0, Animation::kDirRight);
+ _vm->_animation->setMoveSpeed(0, kDirRight);
break;
case 3:
- _vm->_animation->changeDirection(0, Animation::kDirUp);
+ _vm->_animation->setMoveSpeed(0, kDirUp);
break;
case 4:
- _vm->_animation->changeDirection(0, Animation::kDirUpLeft);
+ _vm->_animation->setMoveSpeed(0, kDirUpLeft);
break;
case 5:
- _vm->_animation->changeDirection(0, Animation::kDirUpRight);
+ _vm->_animation->setMoveSpeed(0, kDirUpRight);
break;
case 6:
- _vm->_animation->changeDirection(0, Animation::kDirDown);
+ _vm->_animation->setMoveSpeed(0, kDirDown);
break;
case 7:
- _vm->_animation->changeDirection(0, Animation::kDirDownLeft);
+ _vm->_animation->setMoveSpeed(0, kDirDownLeft);
break;
case 8:
- _vm->_animation->changeDirection(0, Animation::kDirDownRight);
+ _vm->_animation->setMoveSpeed(0, kDirDownRight);
break;
} // No other values are possible.
@@ -1480,13 +1480,13 @@ void Avalot::dawn() {
}
void Avalot::drawDirection() { // It's data is loaded in load_digits().
- if (_vm->_animation->_oldDirection == _vm->_animation->_direction)
+ if (_vm->_animation->getOldDirection() == _vm->_animation->getDirection())
return;
- _vm->_animation->_oldDirection = _vm->_animation->_direction;
+ _vm->_animation->setOldDirection(_vm->_animation->getDirection());
CursorMan.showMouse(false);
- _vm->_graphics->drawPicture(_vm->_graphics->_surface, _directions[_vm->_animation->_direction], 0, 161);
+ _vm->_graphics->drawPicture(_vm->_graphics->_surface, _directions[_vm->_animation->getDirection()], 0, 161);
CursorMan.showMouse(true);
}
@@ -1501,7 +1501,7 @@ void Avalot::gameOver() {
avvy->remove();
avvy->init(12, true, _vm->_animation); // 12 = Avalot falls
avvy->_stepNum = 0;
- avvy->appear(sx, sy, 0);
+ avvy->appear(sx, sy, kDirUp);
_vm->_timer->addTimer(3, Timer::kProcAvalotFalls, Timer::kReasonFallingOver);
_alive = false;
@@ -1548,7 +1548,7 @@ void Avalot::spriteRun() {
void Avalot::fixFlashers() {
_ledStatus = 177;
- _vm->_animation->_oldDirection = 177;
+ _vm->_animation->setOldDirection(kDirNone);
_vm->_dialogs->setReadyLight(2);
drawDirection();
}
@@ -1582,8 +1582,7 @@ void Avalot::drawShadowBox(int16 x1, int16 y1, int16 x2, int16 y2, Common::Strin
}
void Avalot::resetVariables() {
-// Replaces memset(&_dna, 0, sizeof(DnaType));
- _vm->_animation->_direction = 0;
+ _vm->_animation->setDirection(kDirUp);
_carryNum = 0;
for (int i = 0; i < kObjectNum; i++)
_objects[i] = false;
@@ -1683,7 +1682,7 @@ void Avalot::newGame() {
_spareEvening = "answer a questionnaire";
_favouriteDrink = "beer";
_money = 30; // 2/6
- _vm->_animation->_direction = Animation::kDirStopped;
+ _vm->_animation->setDirection(kDirStopped);
_vm->_parser->_wearing = kObjectClothes;
_objects[kObjectMoney - 1] = true;
_objects[kObjectBodkin - 1] = true;
@@ -1696,7 +1695,7 @@ void Avalot::newGame() {
_onToolbar = false;
_seeScroll = false;
- avvy->appear(300, 117, Animation::kDirRight); // Needed to initialize Avalot.
+ avvy->appear(300, 117, kDirRight); // Needed to initialize Avalot.
//for (gd = 0; gd <= 30; gd++) for (gm = 0; gm <= 1; gm++) also[gd][gm] = nil;
// fillchar(previous^,sizeof(previous^),#0); { blank out array }
_him = Parser::kPardon;
diff --git a/engines/avalanche/avalot.h b/engines/avalanche/avalot.h
index 29433ee831..0179d898bb 100644
--- a/engines/avalanche/avalot.h
+++ b/engines/avalanche/avalot.h
@@ -30,6 +30,8 @@
#ifndef AVALANCHE_AVALOT_H
#define AVALANCHE_AVALOT_H
+#include "avalanche/animation.h"
+
#include "common/events.h"
#include "common/system.h"
#include "common/str.h"
@@ -93,7 +95,7 @@ struct MouseHotspotType { // mouse-void
struct PedType {
int16 _x, _y;
- byte _direction;
+ Direction _direction;
};
struct MagicType {
diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp
index 1bfbe93f3a..c54b482052 100644
--- a/engines/avalanche/parser.cpp
+++ b/engines/avalanche/parser.cpp
@@ -1426,7 +1426,7 @@ void Parser::standUp() {
_vm->_animation->_sprites[0]._visible = true;
_vm->_avalot->_userMovesAvvy = true;
_vm->_animation->appearPed(0, 1);
- _vm->_animation->_direction = Animation::kDirLeft;
+ _vm->_animation->setDirection(kDirLeft);
_vm->_background->drawBackgroundSprite(-1, -1, 3); // Picture of empty pillow.
_vm->_avalot->incScore(1);
_vm->_avalot->_avvyInBed = false;
@@ -1867,7 +1867,7 @@ void Parser::doThat() {
int16 y = spr->_y;
spr->remove();
spr->init(i, true, _vm->_animation);
- spr->appear(x, y, Animation::kDirLeft);
+ spr->appear(x, y, kDirLeft);
spr->_visible = false;
}
}
@@ -2362,4 +2362,9 @@ void Parser::verbOpt(byte verb, Common::String &answer, char &ansKey) {
}
}
+void Parser::synchronize(Common::Serializer &sz) {
+ sz.syncAsByte(_wearing);
+ sz.syncAsByte(_sworeNum);
+}
+
} // End of namespace Avalanche
diff --git a/engines/avalanche/parser.h b/engines/avalanche/parser.h
index 13734136a5..8f49a48e74 100644
--- a/engines/avalanche/parser.h
+++ b/engines/avalanche/parser.h
@@ -31,6 +31,8 @@
#include "common/events.h"
#include "common/scummsys.h"
#include "common/str.h"
+#include "common/serializer.h"
+
namespace Avalanche {
class AvalancheEngine;
@@ -102,6 +104,8 @@ public:
void tryDropdown(); // This asks the parsekey proc in Dropdown if it knows it.
int16 getPos(const Common::String &crit, const Common::String &src); // Returns the index of the first appearance of crit in src.
+ void synchronize(Common::Serializer &sz);
+
private:
AvalancheEngine *_vm;
diff --git a/engines/avalanche/timer.cpp b/engines/avalanche/timer.cpp
index 081f7a314b..1fc69a278b 100644
--- a/engines/avalanche/timer.cpp
+++ b/engines/avalanche/timer.cpp
@@ -248,7 +248,7 @@ void Timer::avariciusTalks() {
}
void Timer::urinate() {
- _vm->_animation->_sprites[0].turn(Animation::kDirUp);
+ _vm->_animation->_sprites[0].turn(kDirUp);
_vm->_animation->stopWalking();
_vm->_avalot->drawDirection();
addTimer(14, kProcToilet, kReasonGoToToilet);
@@ -558,7 +558,7 @@ void Timer::meetAvaroid() {
addTimer(1, kProcRiseUpOubliette, kReasonRisingUpOubliette);
AnimationType *avvy = &_vm->_animation->_sprites[0];
- avvy->_facingDir = Animation::kDirLeft;
+ avvy->_facingDir = kDirLeft;
avvy->_x = 151;
avvy->_moveX = -3;
avvy->_moveY = -5;
@@ -586,7 +586,7 @@ void Timer::robinHoodAndGeida() {
AnimationType *spr = &_vm->_animation->_sprites[1];
spr->stopWalk();
- spr->_facingDir = Animation::kDirLeft;
+ spr->_facingDir = kDirLeft;
addTimer(20, kProcRobinHoodAndGeidaTalk, kReasonRobinHoodAndGeida);
_vm->_avalot->_geidaFollows = false;
}