Skip to content

Commit

Permalink
ACCESS: Refactor opening scenes logic into Opening class
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Dec 13, 2014
1 parent c42666f commit a8e111f
Show file tree
Hide file tree
Showing 9 changed files with 343 additions and 349 deletions.
1 change: 0 additions & 1 deletion engines/access/access.cpp
Expand Up @@ -50,7 +50,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)

_destIn = nullptr;
_current = nullptr;
_pCount = 0;
_mouseMode = 0;
_currentMan = 0;
_currentManOld = -1;
Expand Down
1 change: 0 additions & 1 deletion engines/access/access.h
Expand Up @@ -173,7 +173,6 @@ class AccessEngine : public Engine {
Common::Array<Common::Rect> _oldRects;
Common::Array<ExtraCell> _extraCells;
ImageEntryList _images;
int _pCount;
int _mouseMode;

int _currentManOld;
Expand Down
311 changes: 1 addition & 310 deletions engines/access/amazon/amazon_game.cpp
Expand Up @@ -40,7 +40,6 @@ AccessEngine(syst, gameDesc),
_ant(this), _cast(this), _guard(this), _jungle(this), _opening(this),
_plane(this), _river(this) {

_skipStart = false;
_charSegSwitch = false;

_oldTitleChapter = _chapter = 0;
Expand Down Expand Up @@ -92,7 +91,7 @@ void AmazonEngine::playGame() {

if (_loadSaveSlot == -1) {
// Do introduction
doIntroduction();
_opening.doIntroduction();
if (shouldQuit())
return;
}
Expand All @@ -112,314 +111,6 @@ void AmazonEngine::playGame() {
_room->doRoom();
}

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

_events->setCursor(CURSOR_ARROW);
_events->showCursor();
_screen->setPanel(3);
doTitle();

if (shouldQuit() || _skipStart)
return;

_screen->setPanel(3);
_opening.mWhileDoOpen();

if (shouldQuit() || _skipStart)
return;

doTent();
}

void AmazonEngine::doCredit() {
if (_pCount < 15)
return;

if (_pCount <= 75)
_buffer2.plotImage(_objectsTable[0], 0, Common::Point(90, 35));
else if (_pCount <= 210)
_buffer2.plotImage(_objectsTable[0], 1, Common::Point(65, 35));
else if (_pCount <= 272)
_buffer2.plotImage(_objectsTable[0], 2, Common::Point(96, 45));
else if (_pCount <= 334)
_buffer2.plotImage(_objectsTable[0], 3, Common::Point(68, 54));
else if (_pCount <= 396)
_buffer2.plotImage(_objectsTable[0], 4, Common::Point(103, 54));
else if (_pCount <= 458) {
_buffer2.plotImage(_objectsTable[0], 5, Common::Point(8, 5));
_buffer2.plotImage(_objectsTable[0], 12, Common::Point(88, 55));
_buffer2.plotImage(_objectsTable[0], 6, Common::Point(194, 98));
} else if (_pCount <= 520) {
_buffer2.plotImage(_objectsTable[0], 7, Common::Point(32, 13));
_buffer2.plotImage(_objectsTable[0], 8, Common::Point(162, 80));
} else if (_pCount <= 580) {
_buffer2.plotImage(_objectsTable[0], 9, Common::Point(18, 15));
_buffer2.plotImage(_objectsTable[0], 10, Common::Point(164, 81));
} else
_buffer2.plotImage(_objectsTable[0], 11, Common::Point(106, 55));
}

void AmazonEngine::scrollTitle() {
copyBF1BF2();
_newRects.clear();
doCredit();
copyRects();
copyBF2Vid();
}

void AmazonEngine::doTitle() {
_screen->setDisplayScan();
_destIn = &_buffer2;

_screen->forceFadeOut();
_events->hideCursor();

_sound->queueSound(0, 98, 30);
_sound->queueSound(1, 98, 8);

_files->_setPaletteFlag = false;
_files->loadScreen(0, 3);

_buffer2.copyFrom(*_screen);
_buffer1.copyFrom(*_screen);
_screen->forceFadeIn();
_sound->playSound(1);

// HACK: This delay has been added so that the very first screen is visible.
// The original was using disk loading time to display it, and it's too fast
// nowadays to be visible.
_events->_vbCount = 70;
while (!shouldQuit() && _events->_vbCount > 0) {
_events->pollEvents();
g_system->delayMillis(10);
}

Resource *spriteData = _files->loadFile(0, 2);
_objectsTable[0] = new SpriteResource(this, spriteData);
delete spriteData;

_sound->playSound(1);

_files->_setPaletteFlag = false;
_files->loadScreen(0, 4);
_sound->playSound(1);

_buffer2.copyFrom(*_screen);
_buffer1.copyFrom(*_screen);
_sound->playSound(1);

const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 };
for (_pCount = 0; _pCount < 3; ++_pCount) {
_buffer2.copyFrom(_buffer1);
int id = COUNTDOWN[_pCount * 2];
int xp = COUNTDOWN[_pCount * 2 + 1];
_buffer2.plotImage(_objectsTable[0], id, Common::Point(xp, 71));
_screen->copyFrom(_buffer2);

_events->_vbCount = 70;
while (!shouldQuit() && _events->_vbCount > 0) {
_events->pollEvents();
g_system->delayMillis(10);
}
}

_sound->playSound(0);
_screen->forceFadeOut();
_events->_vbCount = 100;
while (!shouldQuit() && _events->_vbCount > 0) {
_events->pollEvents();
g_system->delayMillis(10);
}

_sound->freeSounds();
delete _objectsTable[0];
_objectsTable[0] = nullptr;

_files->_setPaletteFlag = false;
_files->loadScreen(0, 5);
_buffer2.copyFrom(*_screen);
_buffer1.copyFrom(*_screen);
_screen->forceFadeIn();
_sound->newMusic(1, 0);
_events->_vbCount = 700;
while (!shouldQuit() && (_events->_vbCount > 0) && !_events->isKeyMousePressed()) {
_events->pollEvents();
g_system->delayMillis(10);
}

if (_events->_rightButton) {
_skipStart = true;
_room->clearRoom();
_events->showCursor();
return;
}

_sound->newMusic(1, 1);
_sound->_musicRepeat = false;
_events->zeroKeys();
_room->loadRoom(0);
_screen->clearScreen();
_screen->setBufferScan();
_screen->_scrollRow = _screen->_scrollCol = 0;
_screen->_scrollX = _screen->_scrollY = 0;
_player->_rawPlayer = Common::Point(0, 0);
_screen->forceFadeOut();
_screen->_scrollX = 0;
_room->buildScreen();
copyBF2Vid();
_screen->forceFadeIn();
_oldRects.clear();
_newRects.clear();
// KEYFLG = 0;
_player->_scrollAmount = 1;
_pCount = 0;

while (!shouldQuit()) {
if (!_events->isKeyMousePressed()) {
if (_events->_rightButton)
_skipStart = true;
_room->clearRoom();
_events->showCursor();
return;
}

_events->_vbCount = 4;
if (_screen->_scrollCol + _screen->_vWindowWidth != _room->_playFieldWidth) {
_screen->_scrollX += _player->_scrollAmount;

while (_screen->_scrollX >= TILE_WIDTH) {
_screen->_scrollX -= TILE_WIDTH;
++_screen->_scrollCol;

_buffer1.moveBufferLeft();
_room->buildColumn(_screen->_scrollCol + _screen->_vWindowWidth, _screen->_vWindowBytesWide);
}
scrollTitle();
++_pCount;

while (!shouldQuit() && (_events->_vbCount > 0)) {
_events->pollEvents();
g_system->delayMillis(10);
}
continue;
}

_events->_vbCount = 120;
while (!shouldQuit() && (_events->_vbCount > 0)) {
_events->pollEvents();
g_system->delayMillis(10);
}

while (!shouldQuit()) {
_pCount = 0;
_events->_vbCount = 3;
if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) {
_room->clearRoom();
_events->showCursor();
return;
}

_screen->_scrollY = _screen->_scrollY + _player->_scrollAmount;

while (_screen->_scrollY >= TILE_HEIGHT && !shouldQuit()) {
_screen->_scrollY -= TILE_HEIGHT;
++_screen->_scrollRow;
_buffer1.moveBufferUp();

// WORKAROUND: the original was using _screen->_vWindowBytesWide * _screen->_vWindowLinesTall
_room->buildRow(_screen->_scrollRow + _screen->_vWindowHeight, _screen->_vWindowLinesTall);

if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) {
_room->clearRoom();
_events->showCursor();
return;
}
}
scrollTitle();
while (!shouldQuit() && (_events->_vbCount > 0)) {
_events->pollEvents();
g_system->delayMillis(10);
}
}
}
}

void AmazonEngine::doTent() {
int step = 0;
_screen->setDisplayScan();
_screen->forceFadeOut();
_events->hideCursor();
_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 39), 1));
_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 14), 1));
_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 15), 1));
_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 16), 1));
_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 31), 2));
_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 52), 2));
_sound->playSound(0);

_files->_setPaletteFlag = false;
_files->loadScreen(2, 0);
_buffer2.copyFrom(*_screen);
_buffer1.copyFrom(*_screen);
_screen->forceFadeIn();

_video->setVideo(_screen, Common::Point(126, 73), FileIdent(2, 1), 10);
while (!shouldQuit() && !_video->_videoEnd) {
_video->playVideo();
if ((_video->_videoFrame == 32) || (_video->_videoFrame == 34))
_sound->playSound(4);
else if (_video->_videoFrame == 36) {
if (step != 2) {
_sound->playSound(2);
step = 2;
}
} else if (_video->_videoFrame == 18) {
if (step != 1) {
_sound->newMusic(73, 1);
_sound->newMusic(11, 0);
step = 1;
_sound->playSound(1);
}
}

g_system->delayMillis(10);
_events->pollEvents();
}

_sound->playSound(5);
_video->setVideo(_screen, Common::Point(43, 11), FileIdent(2, 2), 10);
while (!shouldQuit() && !_video->_videoEnd) {
_video->playVideo();
if (_video->_videoFrame == 26) {
_sound->playSound(5);
} else if (_video->_videoFrame == 15) {
if (step !=3) {
_sound->playSound(3);
step = 3;
}
}

g_system->delayMillis(10);
_events->pollEvents();
}

_events->_vbCount = 200;
while (!shouldQuit() && _events->_vbCount > 0) {
_events->pollEvents();
g_system->delayMillis(10);
}
_events->showCursor();
_sound->newMusic(11, 1);
_sound->_soundTable.clear();

establishCenter(0, 4);
}

void AmazonEngine::setupGame() {
// Setup timers
const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 };
Expand Down
18 changes: 0 additions & 18 deletions engines/access/amazon/amazon_game.h
Expand Up @@ -38,21 +38,6 @@ class AmazonEngine : public AccessEngine {
byte _tileData[1455];
Common::Array<CellIdent> _chapterCells;

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

/**
* Do title sequence
*/
void doTitle();

/**
* Do tent scene of introduction
*/
void doTent();

/**
* Setup variables for the game
*/
Expand All @@ -67,8 +52,6 @@ class AmazonEngine : public AccessEngine {
void calcIQ();
void helpTitle();
void drawHelpText(const Common::String &msg);
void doCredit();
void scrollTitle();
void loadEstablish(int estabIndex);
void doEstablish(int screenId, int estabIndex);

Expand All @@ -85,7 +68,6 @@ class AmazonEngine : public AccessEngine {
public:
InactivePlayer _inactive;
bool _charSegSwitch;
bool _skipStart;
byte _help1[366];
byte _help2[366];
byte _help3[366];
Expand Down

0 comments on commit a8e111f

Please sign in to comment.