aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/access/access.cpp10
-rw-r--r--engines/access/access.h19
-rw-r--r--engines/access/amazon/amazon_room.cpp6
-rw-r--r--engines/access/animation.cpp8
-rw-r--r--engines/access/asurface.cpp12
-rw-r--r--engines/access/asurface.h13
-rw-r--r--engines/access/player.cpp119
-rw-r--r--engines/access/player.h14
-rw-r--r--engines/access/room.cpp2
9 files changed, 152 insertions, 51 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 2ffc479748..ad8405800b 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -51,10 +51,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_mouseMode = 0;
_currentMan = 0;
_currentManOld = -1;
- _man = nullptr;
- _man1 = nullptr;
_inactive = nullptr;
- _manPal1 = nullptr;
_music = nullptr;
_title = nullptr;
_converseMode = 0;
@@ -115,9 +112,7 @@ AccessEngine::~AccessEngine() {
delete _sound;
freeCells();
- delete[] _man1;
delete[] _inactive;
- delete[] _manPal1;
delete[] _music;
delete[] _title;
}
@@ -207,11 +202,6 @@ void AccessEngine::freeInactiveData() {
_inactive = nullptr;
}
-void AccessEngine::freeManData() {
- delete[] _man;
- _man = nullptr;
-}
-
void AccessEngine::establish(int v) {
_establishMode = 0;
_establishGroup = 0;
diff --git a/engines/access/access.h b/engines/access/access.h
index d919ae83f9..1e83c6e97c 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -70,15 +70,6 @@ enum AccessDebugChannels {
struct AccessGameDescription;
-class ImageEntry {
-public:
- int _frameNumber;
- SpriteResource *_spritesPtr;
- int _priority;
- Common::Point _position;
- int _flags;
-};
-
class AccessEngine : public Engine {
private:
/**
@@ -137,17 +128,14 @@ public:
Common::Array<Common::Rect> _newRects;
Common::Array<Common::Rect> _oldRects;
Common::Array<ExtraCell> _extraCells;
- Common::Array<ImageEntry> _images;
+ ImageEntryList _images;
int _pCount;
int _selectCommand;
bool _normalMouse;
int _mouseMode;
int _currentManOld;
- byte *_man;
- byte *_man1;
byte *_inactive;
- byte *_manPal1;
byte *_music;
byte *_title;
int _converseMode;
@@ -222,11 +210,6 @@ public:
*/
void freeInactiveData();
- /**
- * Free animation data
- */
- void freeManData();
-
void establish(int v);
void establishCenter(int v);
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index db163977ca..5cb1dfe59c 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -51,15 +51,15 @@ void AmazonRoom::reloadRoom() {
switch (_vm->_currentMan) {
case 0:
- _vm->_man1 = _vm->_files->loadFile("MAN.LZ");
+ _vm->_player->loadSprites("MAN.LZ");
break;
case 2:
- _vm->_man1 = _vm->_files->loadFile("JMAN.LZ");
+ _vm->_player->loadSprites("JMAN.LZ");
break;
case 3:
- _vm->_man1 = _vm->_files->loadFile("OVERHEAD.LZ");
+ _vm->_player->loadSprites("OVERHEAD.LZ");
_vm->_manScaleOff = 1;
break;
diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index 20772af8f0..4965f41105 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -210,10 +210,6 @@ void Animation::setFrame(AnimationFrame *frame) {
setFrame1(frame);
}
-static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) {
- return ie1._priority < ie2._priority;
-}
-
void Animation::setFrame1(AnimationFrame *frame) {
_vm->_animation->_base.x = frame->_baseX;
_vm->_animation->_base.y = frame->_baseY;
@@ -234,9 +230,7 @@ void Animation::setFrame1(AnimationFrame *frame) {
ie._position = part->_position + _vm->_animation->_base;
ie._priority = part->_priority - ie._position.y;
- assert(_vm->_images.size() < 35);
- _vm->_images.push_back(ie);
- Common::sort(_vm->_images.begin(), _vm->_images.end(), sortImagesY);
+ _vm->_images.addToList(&ie);
}
}
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 5824545af7..ed614df974 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -82,6 +82,18 @@ SpriteFrame::~SpriteFrame() {
/*------------------------------------------------------------------------*/
+static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) {
+ return ie1._priority < ie2._priority;
+}
+
+void ImageEntryList::addToList(ImageEntry *ie) {
+ assert(size() < 35);
+ push_back(*ie);
+ Common::sort(begin(), end(), sortImagesY);
+}
+
+/*------------------------------------------------------------------------*/
+
int ASurface::_leftSkip;
int ASurface::_rightSkip;
int ASurface::_topSkip;
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 4f172ae309..d660ff60b6 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -88,6 +88,19 @@ public:
SpriteFrame *getFrame(int idx) { return _frames[idx]; }
};
+class ImageEntry {
+public:
+ int _frameNumber;
+ SpriteResource *_spritesPtr;
+ int _priority;
+ Common::Point _position;
+ int _flags;
+};
+
+class ImageEntryList : public Common::Array<ImageEntry> {
+public:
+ void addToList(ImageEntry *ie);
+};
} // End of namespace Access
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 6fab689ee0..7c07c69b1a 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -28,13 +28,16 @@
namespace Access {
-Player::Player(AccessEngine *vm): Manager(vm) {
+Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() {
Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0);
Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0);
Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0);
Common::fill(&_walkOffDown[0], &_walkOffDown[PLAYER_DATA_COUNT], 0);
- _field0 = 0;
+ _playerSprites = nullptr;
+ _playerSprites1 = nullptr;
+ _manPal1 = nullptr;
+ _frameNumber = 0;
_monData = nullptr;
_rawTempL = 0;
_rawXTemp = 0;
@@ -53,6 +56,12 @@ Player::Player(AccessEngine *vm): Manager(vm) {
_collideFlag = false;
_move = NONE;
_playerDirection = NONE;
+ _xFlag = _yFlag = 0;
+}
+
+Player::~Player() {
+ delete _playerSprites1;
+ delete[] _manPal1;
}
void Player::load() {
@@ -131,14 +140,28 @@ void Player::load() {
_diagDownWalkMax = 7;
}
- _vm->_man = _vm->_man1;
- if (_vm->_manPal1) {
- Common::copy(_vm->_manPal1 + 0x270, _vm->_manPal1 + 0x270 + 0x60, _vm->_screen->_manPal);
+ _playerSprites = _playerSprites1;
+ if (_manPal1) {
+ Common::copy(_manPal1 + 0x270, _manPal1 + 0x270 + 0x60, _vm->_screen->_manPal);
} else {
Common::fill(_vm->_screen->_manPal, _vm->_screen->_manPal + 0x60, 0);
}
}
+void Player::loadSprites(const Common::String &name) {
+ delete _playerSprites1;
+ _playerSprites = nullptr;
+
+ const byte *data = _vm->_files->loadFile(name);
+ _playerSprites1 = new SpriteResource(_vm, data, _vm->_files->_filesize,
+ DisposeAfterUse::YES);
+}
+
+void Player::freeSprites() {
+ delete _playerSprites;
+ _playerSprites = nullptr;
+}
+
void Player::calcManScale() {
if (!_vm->_manScaleOff) {
_vm->_scale = (((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) *
@@ -534,11 +557,80 @@ void Player::walkDownRight() {
}
void Player::checkMove() {
- error("TODO");
+ if (!_vm->_events->_mouseMove)
+ return;
+
+ if (_xFlag == 0 && _yFlag == 0) {
+ int xp = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x;
+ if (xp < 0)
+ xp = -xp;
+ int yp = _rawPlayer.y - _moveTo.y;
+ if (yp < 0)
+ yp = -yp;
+
+ if (xp < yp)
+ _xFlag = 1;
+ else
+ _yFlag = 1;
+ }
+
+ if (_yFlag == 1) {
+ int yd = _rawPlayer.y - _moveTo.y;
+ if ((yd >= 0 && yd <= _upDelta) || (yd < 0 && -yd <= _upDelta)) {
+ ++_yFlag;
+ if (_xFlag) {
+ _vm->_events->_mouseMove = false;
+ _xFlag = _yFlag = 0;
+ } else {
+ ++_xFlag;
+ }
+ } else {
+ if (yd >= 0)
+ walkUp();
+ else
+ walkDown();
+
+ if (_collideFlag) {
+ _vm->_events->_mouseMove = false;
+ _xFlag = _yFlag = 0;
+ }
+ }
+ } else if (_xFlag == 1) {
+ int xd = _rawPlayer.x - _moveTo.x;
+ if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) {
+ ++_xFlag;
+
+ if (_yFlag) {
+ _vm->_events->_mouseMove = false;
+ _xFlag = _yFlag = 0;
+ }
+ } else {
+ if (xd >= 0)
+ walkLeft();
+ else
+ walkRight();
+
+ if (_collideFlag) {
+ _vm->_events->_mouseMove = false;
+ _xFlag = _yFlag = 0;
+ }
+ }
+ } else if (!_yFlag) {
+ ++_yFlag;
+ } else {
+ _vm->_events->_mouseMove = false;
+ _xFlag = _yFlag = 0;
+ }
+
+ plotCom3();
}
-void Player::plotCom(int v) {
- error("TODO");
+void Player::plotCom(int flags) {
+ _flags &= ~2;
+ _flags &= ~8;
+ _flags |= flags;
+
+ plotCom3();
}
void Player::plotCom1() {
@@ -546,11 +638,18 @@ void Player::plotCom1() {
}
void Player::plotCom2() {
- error("TODO");
+ if (_playerOff != 1)
+ _vm->_images.addToList(this);
}
void Player::plotCom3() {
- error("TODO");
+ // Update the base ImageEntry fields for the player
+ _position = _rawPlayer;
+ _priority = _playerOffset.y;
+ _spritesPtr = _playerSprites;
+ _frameNumber = _frame;
+
+ plotCom2();
}
bool Player::codeWalls() {
diff --git a/engines/access/player.h b/engines/access/player.h
index 28189706de..a0167838a0 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "common/rect.h"
+#include "access/asurface.h"
#include "access/data.h"
namespace Access {
@@ -36,7 +37,7 @@ enum Direction { NONE = 0, UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4,
class AccessEngine;
-class Player: public Manager {
+class Player: public ImageEntry, Manager {
private:
int _leftDelta, _rightDelta;
int _upDelta, _downDelta;
@@ -50,6 +51,11 @@ private:
bool _collideFlag;
Direction _playerDirection;
Direction _move;
+ int _xFlag, _yFlag;
+ Common::Point _moveTo;
+ SpriteResource *_playerSprites;
+ SpriteResource *_playerSprites1;
+ byte *_manPal1;
bool codeWalls();
void checkMove();
@@ -68,7 +74,6 @@ private:
void walkDownRight();
public:
// Fields in original Player structure
- int _field0;
byte *_monData;
int _walkOffRight[PLAYER_DATA_COUNT];
int _walkOffLeft[PLAYER_DATA_COUNT];
@@ -98,9 +103,14 @@ public:
Common::Point _rawPlayer;
public:
Player(AccessEngine *vm);
+ ~Player();
void load();
+ void loadSprites(const Common::String &name);
+
+ void freeSprites();
+
void calcManScale();
void walk();
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 66231e60e1..80bcc0082b 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -150,7 +150,7 @@ void Room::clearRoom() {
_vm->freeCells();
freePlayField();
_vm->freeInactiveData();
- _vm->freeManData();
+ _vm->_player->freeSprites();
}
void Room::loadRoomData(const byte *roomData) {