Skip to content

Commit

Permalink
ACCESS: Refactored Amazon specific player loading into new AmazonPlay…
Browse files Browse the repository at this point in the history
…er class
  • Loading branch information
dreammaster committed Dec 13, 2014
1 parent a8c99d1 commit cc8a8bf
Show file tree
Hide file tree
Showing 11 changed files with 210 additions and 104 deletions.
2 changes: 1 addition & 1 deletion engines/access/access.cpp
Expand Up @@ -165,7 +165,7 @@ void AccessEngine::initialize() {
_events = new EventsManager(this);
_files = new FileManager(this);
_inventory = new InventoryManager(this);
_player = new Player(this);
_player = Player::init(this);
_screen = new Screen(this);
_sound = new SoundManager(this, _mixer);
_video = new VideoPlayer(this);
Expand Down
86 changes: 86 additions & 0 deletions engines/access/amazon/amazon_player.cpp
@@ -0,0 +1,86 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#include "common/scummsys.h"
#include "access/access.h"
#include "access/room.h"
#include "access/amazon/amazon_game.h"
#include "access/amazon/amazon_player.h"
#include "access/amazon/amazon_resources.h"

namespace Access {

namespace Amazon {

AmazonPlayer::AmazonPlayer(AccessEngine *vm) : Player(vm) {
_game = (AmazonEngine *)vm;
}

void AmazonPlayer::load() {
Player::load();

// Special scene setup for the top-down view when on the Slaver ship
if (_vm->_room->_roomFlag == 3) {
_playerOffset.x = _vm->_screen->_scaleTable1[8];
_playerOffset.y = _vm->_screen->_scaleTable1[11];
_leftDelta = 0;
_rightDelta = 8;
_upDelta = 2;
_downDelta = -2;
_scrollConst = 2;

for (int i = 0; i < PLAYER_DATA_COUNT; ++i) {
_walkOffRight[i] = OVEROFFR[i];
_walkOffLeft[i] = OVEROFFL[i];
_walkOffUp[i] = OVEROFFU[i];
_walkOffDown[i] = OVEROFFD[i];
_walkOffUR[i].x = OVEROFFURX[i];
_walkOffUR[i].y = OVEROFFURY[i];
_walkOffDR[i].x = OVEROFFDRX[i];
_walkOffDR[i].y = OVEROFFDRY[i];
_walkOffUL[i].x = OVEROFFULX[i];
_walkOffUL[i].y = OVEROFFULY[i];
_walkOffDL[i].x = OVEROFFDLX[i];
_walkOffDL[i].y = OVEROFFDLY[i];
}

_vm->_timers[8]._initTm = 7;
_vm->_timers[8]._timer = 7;
++_vm->_timers[8]._flag;

_sideWalkMin = 0;
_sideWalkMax = 5;
_upWalkMin = 12;
_upWalkMax = 17;
_downWalkMin = 6;
_downWalkMax = 11;
_diagUpWalkMin = 0;
_diagUpWalkMax = 5;
_diagDownWalkMin = 0;
_diagDownWalkMax = 5;
_game->_guard._position = Common::Point(56, 190);
}
}

} // End of namespace Amazon

} // End of namespace Access
48 changes: 48 additions & 0 deletions engines/access/amazon/amazon_player.h
@@ -0,0 +1,48 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#ifndef ACCESS_AMAZON_PLAYER_H
#define ACCESS_AMAZON_PLAYER_H

#include "common/scummsys.h"
#include "access/player.h"

namespace Access {

namespace Amazon {

class AmazonEngine;

class AmazonPlayer: public Player {
private:
AmazonEngine *_game;
public:
AmazonPlayer(AccessEngine *vm);

virtual void load();
};

} // End of namespace Amazon

} // End of namespace Access

#endif /* ACCESS_AMAZON_PLAYER_H */
13 changes: 13 additions & 0 deletions engines/access/amazon/amazon_resources.cpp
Expand Up @@ -245,6 +245,19 @@ const int TRAVEL_POS[][2] = {
{ 0, 0 }
};

const int OVEROFFR[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 };
const int OVEROFFL[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 };
const int OVEROFFU[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 };
const int OVEROFFD[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 };
const int OVEROFFURX[] = { 3, 1, 1, 2, 2, 1, 0, 0, 0 };
const int OVEROFFURY[] = { 1, 0, 0, 1, 1, 0, 0, 0, 0 };
const int OVEROFFDRX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 };
const int OVEROFFDRY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 };
const int OVEROFFULX[] = { 2, 1, 1, 1, 2, 1, 0, 0, 0 };
const int OVEROFFULY[] = { 1, 0, 0, 2, 1, 0, 0, 0, 0 };
const int OVEROFFDLX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 };
const int OVEROFFDLY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 };

const byte CREDITS[] = {
0x2, 0xFF, 0xFF, 0x61, 0x0, 0x3, 0x0, 0x30, 0x22, 0x30, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0xFF, 0xFF,
Expand Down
13 changes: 13 additions & 0 deletions engines/access/amazon/amazon_resources.h
Expand Up @@ -44,6 +44,19 @@ extern const byte *CURSORS[10];

extern const int TRAVEL_POS[][2];

extern const int OVEROFFR[];
extern const int OVEROFFL[];
extern const int OVEROFFU[];
extern const int OVEROFFD[];
extern const int OVEROFFURX[];
extern const int OVEROFFURY[];
extern const int OVEROFFDRX[];
extern const int OVEROFFDRY[];
extern const int OVEROFFULX[];
extern const int OVEROFFULY[];
extern const int OVEROFFDLX[];
extern const int OVEROFFDLY[];

extern const byte *ROOM_TABLE[];
extern const char *ROOM_DESCR[];
extern const int ROOM_NUMB;
Expand Down
4 changes: 2 additions & 2 deletions engines/access/animation.cpp
Expand Up @@ -222,9 +222,9 @@ void Animation::setFrame1(AnimationFrame *frame) {
ImageEntry ie;

// Set the flags
ie._flags = part->_flags & 0xF7;
ie._flags = part->_flags & ~IMGFLAG_UNSCALED;
if (_vm->_animation->_frameScale == -1)
ie._flags |= 8;
ie._flags |= IMGFLAG_UNSCALED;

// Set the other fields
ie._spritesPtr = _vm->_objectsTable[part->_spritesIndex];
Expand Down
1 change: 1 addition & 0 deletions engines/access/module.mk
Expand Up @@ -22,6 +22,7 @@ MODULE_OBJS := \
sound.o \
video.o \
amazon/amazon_game.o \
amazon/amazon_player.o \
amazon/amazon_resources.o \
amazon/amazon_room.o \
amazon/amazon_scripts.o \
Expand Down
115 changes: 42 additions & 73 deletions engines/access/player.cpp
Expand Up @@ -25,9 +25,19 @@
#include "access/player.h"
#include "access/access.h"
#include "access/resources.h"
#include "access/amazon/amazon_player.h"

namespace Access {

Player *Player::init(AccessEngine *vm) {
switch (vm->getGameID()) {
case GType_Amazon:
return new Amazon::AmazonPlayer(vm);
default:
return new Player(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);
Expand Down Expand Up @@ -71,81 +81,40 @@ Player::~Player() {
}

void Player::load() {
if (_vm->_room->_roomFlag == 3) {
_playerOffset.x = _vm->_screen->_scaleTable1[8];
_playerOffset.y = _vm->_screen->_scaleTable1[11];
_leftDelta = 0;
_rightDelta = 8;
_upDelta = 2;
_downDelta = -2;
_scrollConst = 2;

for (int i = 0; i < PLAYER_DATA_COUNT; ++i) {
_walkOffRight[i] = OVEROFFR[i];
_walkOffLeft[i] = OVEROFFL[i];
_walkOffUp[i] = OVEROFFU[i];
_walkOffDown[i] = OVEROFFD[i];
_walkOffUR[i].x = OVEROFFURX[i];
_walkOffUR[i].y = OVEROFFURY[i];
_walkOffDR[i].x = OVEROFFDRX[i];
_walkOffDR[i].y = OVEROFFDRY[i];
_walkOffUL[i].x = OVEROFFULX[i];
_walkOffUL[i].y = OVEROFFULY[i];
_walkOffDL[i].x = OVEROFFDLX[i];
_walkOffDL[i].y = OVEROFFDLY[i];
}

_vm->_timers[8]._initTm = 7;
_vm->_timers[8]._timer = 7;
++_vm->_timers[8]._flag;

_sideWalkMin = 0;
_sideWalkMax = 5;
_upWalkMin = 12;
_upWalkMax = 17;
_downWalkMin = 6;
_downWalkMax = 11;
_diagUpWalkMin = 0;
_diagUpWalkMax = 5;
_diagDownWalkMin = 0;
_diagDownWalkMax = 5;
_guard = Common::Point(56, 190);
} else {
_playerOffset.x = _vm->_screen->_scaleTable1[25];
_playerOffset.y = _vm->_screen->_scaleTable1[67];
_leftDelta = -3;
_rightDelta = 33;
_upDelta = 5;
_downDelta = -10;
_scrollConst = 5;

for (int i = 0; i < PLAYER_DATA_COUNT; ++i) {
_walkOffRight[i] = SIDEOFFR[i];
_walkOffLeft[i] = SIDEOFFL[i];
_walkOffUp[i] = SIDEOFFU[i];
_walkOffDown[i] = SIDEOFFD[i];
_walkOffUR[i].x = DIAGOFFURX[i];
_walkOffUR[i].y = DIAGOFFURY[i];
_walkOffDR[i].x = DIAGOFFDRX[i];
_walkOffDR[i].y = DIAGOFFDRY[i];
_walkOffUL[i].x = DIAGOFFULX[i];
_walkOffUL[i].y = DIAGOFFULY[i];
_walkOffDL[i].x = DIAGOFFDLX[i];
_walkOffDL[i].y = DIAGOFFDLY[i];
}

_sideWalkMin = 0;
_sideWalkMax = 7;
_upWalkMin = 16;
_upWalkMax = 23;
_downWalkMin = 8;
_downWalkMax = 15;
_diagUpWalkMin = 0;
_diagUpWalkMax = 7;
_diagDownWalkMin = 0;
_diagDownWalkMax = 7;
_playerOffset.x = _vm->_screen->_scaleTable1[25];
_playerOffset.y = _vm->_screen->_scaleTable1[67];
_leftDelta = -3;
_rightDelta = 33;
_upDelta = 5;
_downDelta = -10;
_scrollConst = 5;

for (int i = 0; i < PLAYER_DATA_COUNT; ++i) {
_walkOffRight[i] = SIDEOFFR[i];
_walkOffLeft[i] = SIDEOFFL[i];
_walkOffUp[i] = SIDEOFFU[i];
_walkOffDown[i] = SIDEOFFD[i];
_walkOffUR[i].x = DIAGOFFURX[i];
_walkOffUR[i].y = DIAGOFFURY[i];
_walkOffDR[i].x = DIAGOFFDRX[i];
_walkOffDR[i].y = DIAGOFFDRY[i];
_walkOffUL[i].x = DIAGOFFULX[i];
_walkOffUL[i].y = DIAGOFFULY[i];
_walkOffDL[i].x = DIAGOFFDLX[i];
_walkOffDL[i].y = DIAGOFFDLY[i];
}

_sideWalkMin = 0;
_sideWalkMax = 7;
_upWalkMin = 16;
_upWalkMax = 23;
_downWalkMin = 8;
_downWalkMax = 15;
_diagUpWalkMin = 0;
_diagUpWalkMax = 7;
_diagDownWalkMin = 0;
_diagDownWalkMax = 7;

_playerSprites = _playerSprites1;
if (_manPal1) {
Common::copy(_manPal1 + 0x270, _manPal1 + 0x270 + 0x60, _vm->_screen->_manPal);
Expand Down
8 changes: 4 additions & 4 deletions engines/access/player.h
Expand Up @@ -38,8 +38,8 @@ enum Direction { NONE = 0, UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4,

class AccessEngine;

class Player: public ImageEntry, Manager {
private:
class Player: public ImageEntry, public Manager {
protected:
int _leftDelta, _rightDelta;
int _upDelta, _downDelta;
int _scrollConst;
Expand All @@ -48,7 +48,6 @@ class Player: public ImageEntry, Manager {
int _downWalkMin, _downWalkMax;
int _diagUpWalkMin, _diagUpWalkMax;
int _diagDownWalkMin, _diagDownWalkMax;
Common::Point _guard;
SpriteResource *_playerSprites1;
byte *_manPal1;
int _scrollEnd;
Expand Down Expand Up @@ -113,8 +112,9 @@ class Player: public ImageEntry, Manager {
public:
Player(AccessEngine *vm);
~Player();
static Player *init(AccessEngine *vm);

void load();
virtual void load();

void loadSprites(const Common::String &name);

Expand Down
12 changes: 0 additions & 12 deletions engines/access/resources.cpp
Expand Up @@ -58,18 +58,6 @@ const int DIAGOFFULX[] = { 4, 5, 4, 3, 3, 2, 2, 2, 0 };
const int DIAGOFFULY[] = { 3, 3, 1, 2, 2, 1, 1, 1, 0 };
const int DIAGOFFDLX[] = { 4, 5, 3, 3, 5, 4, 6, 1, 0 };
const int DIAGOFFDLY[] = { 2, 2, 1, 2, 3, 1, 2, 1, 0 };
const int OVEROFFR[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 };
const int OVEROFFL[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 };
const int OVEROFFU[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 };
const int OVEROFFD[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 };
const int OVEROFFURX[] = { 3, 1, 1, 2, 2, 1, 0, 0, 0 };
const int OVEROFFURY[] = { 1, 0, 0, 1, 1, 0, 0, 0, 0 };
const int OVEROFFDRX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 };
const int OVEROFFDRY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 };
const int OVEROFFULX[] = { 2, 1, 1, 1, 2, 1, 0, 0, 0 };
const int OVEROFFULY[] = { 1, 0, 0, 2, 1, 0, 0, 0, 0 };
const int OVEROFFDLX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 };
const int OVEROFFDLY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 };

const int RMOUSE[10][2] = {
{ 0, 35 }, { 0, 0 }, { 36, 70 }, { 71, 106 }, { 107, 141 },
Expand Down

0 comments on commit cc8a8bf

Please sign in to comment.