Skip to content

Commit

Permalink
ACCESS: Implemented player loading
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 10, 2014
1 parent f495d39 commit c161317
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 25 deletions.
1 change: 0 additions & 1 deletion engines/access/access.cpp
Expand Up @@ -118,7 +118,6 @@ AccessEngine::~AccessEngine() {
_buffer2.free();

freeCells();
delete[] _man;
delete[] _man1;
delete[] _inactive;
delete[] _manPal1;
Expand Down
9 changes: 0 additions & 9 deletions engines/access/asurface.cpp
Expand Up @@ -30,13 +30,4 @@ void ASurface::clearBuffer() {
Common::fill(pSrc, pSrc + w * h, 0);
}

void ASurface::setScaleTable(int scale) {
int total = 0;
for (int idx = 0; idx < 256; ++idx) {
_scaleTable1[idx] = total >> 8;
_scaleTable2[idx] = total & 0xff;
total += scale;
}
}

} // End of namespace Access
5 changes: 0 additions & 5 deletions engines/access/asurface.h
Expand Up @@ -30,15 +30,10 @@
namespace Access {

class ASurface : public Graphics::Surface {
private:
byte _scaleTable1[256];
byte _scaleTable2[256];
public:
void clearBuffer();

void copyBuffer(Graphics::Surface *src) { copyFrom(*src); }

void setScaleTable(int scale);
};

} // End of namespace Access
Expand Down
103 changes: 95 additions & 8 deletions engines/access/player.cpp
Expand Up @@ -20,19 +20,22 @@
*
*/

#include "access/player.h"
#include "common/algorithm.h"
#include "common/textconsole.h"
#include "access/player.h"
#include "access/access.h"
#include "access/resources.h"

namespace Access {

Player::Player(AccessEngine *vm): _vm(vm) {
_field0 = 0;
_monData = nullptr;
Player::Player(AccessEngine *vm): Manager(vm) {
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;
_monData = nullptr;
_rawTempL = 0;
_rawXTemp = 0;
_rawYTempL = 0;
Expand All @@ -42,18 +45,102 @@ Player::Player(AccessEngine *vm): _vm(vm) {
_playerYLow = 0;
_playerY = 0;
_frame = 0;

_playerOff = false;

_leftDelta = _rightDelta = 0;
_upDelta = _downDelta = 0;
_scrollConst = 0;
_roomNumber = 0;
}

void Player::load() {
// TODO
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 = true;

_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;
}

_vm->_man = _vm->_man1;
Common::copy(_vm->_manPal1 + 0x270, _vm->_manPal1 + 0x270 + 0x60, _vm->_screen->_manPal);
}

void Player::calcManScale() {
// TODO
if (!_vm->_manScaleOff) {
_vm->_scale = (((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) *
_vm->_scaleT1 + (_vm->_scaleH2 << 8)) / _vm->_scaleH1 * _vm->_scaleI) >> 8;
_vm->_screen->setScaleTable(_vm->_scale);

_playerOffset.x = _vm->_screen->_scaleTable1[20];
_playerOffset.y = _vm->_screen->_scaleTable1[67];
}
}

void Player::walk() {
Expand Down
13 changes: 11 additions & 2 deletions engines/access/player.h
Expand Up @@ -25,16 +25,25 @@

#include "common/scummsys.h"
#include "common/rect.h"
#include "access/data.h"

namespace Access {

#define PLAYER_DATA_COUNT 8

class AccessEngine;

class Player {
class Player: public Manager {
private:
AccessEngine *_vm;
int _leftDelta, _rightDelta;
int _upDelta, _downDelta;
int _scrollConst;
int _sideWalkMin, _sideWalkMax;
int _upWalkMin, _upWalkMax;
int _downWalkMin, _downWalkMax;
int _diagUpWalkMin, _diagUpWalkMax;
int _diagDownWalkMin, _diagDownWalkMax;
Common::Point _guard;
public:
// Fields in original Player structure
int _field0;
Expand Down
25 changes: 25 additions & 0 deletions engines/access/resources.cpp
Expand Up @@ -46,4 +46,29 @@ const byte INITIAL_PALETTE[18 * 3] = {
0x00, 0x00, 0x00
};

const int SIDEOFFR[] = { 5, 5, 5, 5, 5, 5, 5, 5, 0 };
const int SIDEOFFL[] = { 5, 5, 5, 5, 5, 5, 5, 5, 0 };
const int SIDEOFFU[] = { 2, 2, 2, 2, 2, 2, 2, 2, 0 };
const int SIDEOFFD[] = { 2, 2, 2, 2, 2, 2, 2, 2, 0 };
const int DIAGOFFURX[] = { 4, 5, 2, 2, 3, 4, 2, 2, 0 };
const int DIAGOFFURY[] = { 2, 3, 2, 2, 2, 3, 1, 1, 0 };
const int DIAGOFFDRX[] = { 4, 5, 4, 3, 5, 4, 5, 1, 0 };
const int DIAGOFFDRY[] = { 3, 2, 1, 2, 2, 1, 2, 1, 0 };
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 };

} // End of namespace Access
25 changes: 25 additions & 0 deletions engines/access/resources.h
Expand Up @@ -29,6 +29,31 @@ namespace Access {

extern const byte INITIAL_PALETTE[18 * 3];

extern const int SIDEOFFR[];
extern const int SIDEOFFL[];
extern const int SIDEOFFU[];
extern const int SIDEOFFD[];
extern const int DIAGOFFURX[];
extern const int DIAGOFFURY[];
extern const int DIAGOFFDRX[];
extern const int DIAGOFFDRY[];
extern const int DIAGOFFULX[];
extern const int DIAGOFFULY[];
extern const int DIAGOFFDLX[];
extern const int DIAGOFFDLY[];
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[];

} // End of namespace Access

#endif /* ACCESS_RESOURCES_H */
12 changes: 12 additions & 0 deletions engines/access/screen.cpp
Expand Up @@ -35,6 +35,9 @@ namespace Access {
Screen::Screen(AccessEngine *vm) : _vm(vm) {
create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);
Common::fill(&_manPal[0], &_manPal[0x60], 0);
Common::fill(&_scaleTable1[0], &_scaleTable1[256], 0);
Common::fill(&_scaleTable2[0], &_scaleTable2[256], 0);
_vesaMode = 0;
_vesaCurrentWin = 0;
_currentPanel = 0;
Expand Down Expand Up @@ -224,4 +227,13 @@ void Screen::setBufferScan() {
// TODO
}

void Screen::setScaleTable(int scale) {
int total = 0;
for (int idx = 0; idx < 256; ++idx) {
_scaleTable1[idx] = total >> 8;
_scaleTable2[idx] = total & 0xff;
total += scale;
}
}

} // End of namespace Access
5 changes: 5 additions & 0 deletions engines/access/screen.h
Expand Up @@ -62,6 +62,9 @@ class Screen: public ASurface {
Common::Point _vWindowSize;
int _scrollX, _scrollY;
int _scrollCol, _scrollRow;
byte _manPal[0x60];
byte _scaleTable1[256];
byte _scaleTable2[256];
public:
Screen(AccessEngine *vm);

Expand Down Expand Up @@ -119,6 +122,8 @@ class Screen: public ASurface {
void copyRects();

void setBufferScan();

void setScaleTable(int scale);
};

} // End of namespace Access
Expand Down

0 comments on commit c161317

Please sign in to comment.