Skip to content

Commit

Permalink
ACCESS: Remainder of Amazon game initialization added
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 6, 2014
1 parent c4fb766 commit f1309a7
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 17 deletions.
16 changes: 13 additions & 3 deletions engines/access/access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_sound = nullptr;

_destIn = nullptr;
_objectsTable = nullptr;
clearCellTable();
_pCount = 0;
_selectCommand = 0;
_normalMouse = true;
_mouseMode = 0;
_currentMan = 0;
_currentManOld = -1;
_man1 = nullptr;
Expand All @@ -57,7 +60,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_startAboutBox = 0;
_startTravelBox = 0;

_startData = 0;
_roomNumber = 0;
_rawPlayerXLow = 0;
_rawPlayerX = 0;
_rawPlayerYLow = 0;
Expand Down Expand Up @@ -112,7 +115,6 @@ AccessEngine::~AccessEngine() {

_buffer1.free();
_buffer2.free();
delete[] _objectsTable;
}

void AccessEngine::setVGA() {
Expand Down Expand Up @@ -164,4 +166,12 @@ int AccessEngine::getRandomNumber(int maxNumber) {
return _randomSource.getRandomNumber(maxNumber);
}

void AccessEngine::clearCellTable() {
Common::fill(&_objectsTable[0], &_objectsTable[100], (byte *)nullptr);
}

void AccessEngine::doRoom() {
// TODO
}

} // End of namespace Access
21 changes: 18 additions & 3 deletions engines/access/access.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "common/util.h"
#include "engines/engine.h"
#include "graphics/surface.h"
#include "access/data.h"
#include "access/debugger.h"
#include "access/events.h"
#include "access/files.h"
Expand Down Expand Up @@ -63,7 +64,6 @@ enum AccessDebugChannels {

struct AccessGameDescription;


class AccessEngine : public Engine {
private:
/**
Expand All @@ -81,6 +81,16 @@ class AccessEngine : public Engine {
const AccessGameDescription *_gameDescription;
Common::RandomSource _randomSource;

/**
* Clear the cell table
*/
void clearCellTable();

/**
* Main handler for showing game rooms
*/
void doRoom();

// Engine APIs
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
Expand All @@ -99,8 +109,13 @@ class AccessEngine : public Engine {
byte *_destIn;
Graphics::Surface _buffer1;
Graphics::Surface _buffer2;
byte *_objectsTable;
byte *_objectsTable[100];
Common::Array<TimerEntry> _timers;
Player _player;
int _pCount;
int _selectCommand;
bool _normalMouse;
int _mouseMode;

int _currentManOld;
byte *_man1;
Expand All @@ -119,7 +134,7 @@ class AccessEngine : public Engine {
int _startTravelBox;

// Fields that are included in savegames
int _startData;
int _roomNumber;
int _rawPlayerXLow;
int _rawPlayerX;
int _rawPlayerYLow;
Expand Down
54 changes: 43 additions & 11 deletions engines/access/amazon/amazon_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#include "access/amazon/amazon_game.h"
#include "access/resources.h"

namespace Access {

Expand Down Expand Up @@ -49,11 +50,30 @@ AmazonEngine::~AmazonEngine() {
}

void AmazonEngine::playGame() {
doIntroduction();
if (shouldQuit())
return;

// Setup the game
setupGame();

_screen->clearScreen();
_screen->setPanel(0);
_screen->forceFadeOut();

_events->showCursor();
doRoom();
}

void AmazonEngine::doIntroduction() {
_screen->setInitialPalettte();
_events->setCursor(CURSOR_0);
_events->showCursor();
_screen->setPanel(0);


// TODO: Worry about implementing full intro sequence later
return;

doTitle();
if (shouldQuit())
return;
Expand All @@ -72,14 +92,6 @@ void AmazonEngine::playGame() {
}

doTitle();
if (shouldQuit())
return;

_screen->clearScreen();
_screen->setPanel(0);
_screen->forceFadeOut();


}

void AmazonEngine::doTitle() {
Expand All @@ -100,7 +112,7 @@ void AmazonEngine::doTitle() {
_screen->forceFadeIn();
_sound->playSound(1);

_objectsTable = _files->loadFile(0, 2);
_objectsTable[0] = _files->loadFile(0, 2);
_sound->playSound(1);

_screen->_loadPalFlag = false;
Expand All @@ -116,7 +128,7 @@ void AmazonEngine::doTitle() {
_buffer2.copyFrom(_buffer1);
int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4);
int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2);
_screen->plotImage(_objectsTable, id, Common::Point(xp, 71));
_screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71));
}
// TODO: More to do
}
Expand All @@ -129,6 +141,26 @@ void AmazonEngine::doTent() {
// TODO
}

void AmazonEngine::setupGame() {
_chapter = 1;
clearCellTable();

// Setup timers
const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 };
for (int i = 0; i < 32; ++i) {
TimerEntry te;
te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1;
te._flag = true;

_timers.push_back(te);
}

// Set miscellaneous fields
_roomNumber = 4;
_player._playerX = _rawPlayerX = TRAVEL_POS[_roomNumber][0];
_player._playerY = _rawPlayerY = TRAVEL_POS[_roomNumber][1];
_selectCommand = -1;
}

} // End of namespace Amazon

Expand Down
10 changes: 10 additions & 0 deletions engines/access/amazon/amazon_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class AmazonEngine : public AccessEngine {
int _inactiveYOff;
int _esTabTable[100];

/**
* Do the game introduction
*/
void doIntroduction();

/**
* Do title sequence
Expand All @@ -63,6 +67,12 @@ class AmazonEngine : public AccessEngine {
* Do tent scene of introduction
*/
void doTent();

/**
* Setup variables for the game
*/
void setupGame();

protected:
/**
* Play the game
Expand Down
46 changes: 46 additions & 0 deletions engines/access/data.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* 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 "access/data.h"
#include "common/algorithm.h"

namespace Access {

Player::Player() {
_field0 = 0;
_monData = nullptr;
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);
_rawTempL = 0;
_rawXTemp = 0;
_rawYTempL = 0;
_rawYTemp = 0;
_playerXLow = 0;
_playerX = 0;
_playerYLow = 0;
_playerY = 0;
_frame = 0;
}

} // End of namespace Access
72 changes: 72 additions & 0 deletions engines/access/data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* 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_DATA_H
#define ACCESS_DATA_H

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

namespace Access {

struct TimerEntry {
int _initTm;
int _timer;
bool _flag;

TimerEntry() {
_initTm = _timer = 0;
_flag = false;
}
};

#define PLAYER_DATA_COUNT 8

class Player {
public:
int _field0;
byte *_monData;
int _walkOffRight[PLAYER_DATA_COUNT];
int _walkOffLeft[PLAYER_DATA_COUNT];
int _walkOffUp[PLAYER_DATA_COUNT];
int _walkOffDown[PLAYER_DATA_COUNT];
Common::Point _walkOffUR[PLAYER_DATA_COUNT];
Common::Point _walkOffDR[PLAYER_DATA_COUNT];
Common::Point _walkOffUL[PLAYER_DATA_COUNT];
Common::Point _walkOffDL[PLAYER_DATA_COUNT];
int _rawTempL;
int _rawXTemp;
int _rawYTempL;
int _rawYTemp;
Common::Point _playerOffset;
int _playerXLow;
int _playerX;
int _playerYLow;
int _playerY;
int _frame;
public:
Player();
};

} // End of namespace Access

#endif /* ACCESS_DATA_H */
1 change: 1 addition & 0 deletions engines/access/module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ MODULE := engines/access
MODULE_OBJS := \
asurface.o \
access.o \
data.o \
debugger.o \
decompress.o \
detection.o \
Expand Down
Loading

0 comments on commit f1309a7

Please sign in to comment.