aboutsummaryrefslogtreecommitdiff
path: root/engines/access/amazon
diff options
context:
space:
mode:
authorPaul Gilbert2014-10-31 23:01:47 -0400
committerPaul Gilbert2014-12-12 22:18:37 -0500
commit3627ff51aaad803f611b2e5f3072914d0170ed9c (patch)
tree2b15b2ad5d1311af105ecd735568a9ba198749ca /engines/access/amazon
parent59c4c93c005896389915c1022634e5dd041e268a (diff)
downloadscummvm-rg350-3627ff51aaad803f611b2e5f3072914d0170ed9c.tar.gz
scummvm-rg350-3627ff51aaad803f611b2e5f3072914d0170ed9c.tar.bz2
scummvm-rg350-3627ff51aaad803f611b2e5f3072914d0170ed9c.zip
ACCESS: Implemented code for cmdChapter
Diffstat (limited to 'engines/access/amazon')
-rw-r--r--engines/access/amazon/amazon_game.cpp158
-rw-r--r--engines/access/amazon/amazon_game.h6
-rw-r--r--engines/access/amazon/amazon_resources.cpp38
-rw-r--r--engines/access/amazon/amazon_resources.h6
-rw-r--r--engines/access/amazon/amazon_scripts.cpp7
-rw-r--r--engines/access/amazon/amazon_scripts.h2
6 files changed, 212 insertions, 5 deletions
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 187b38c497..3af07edaf3 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -55,11 +55,13 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_rawInactiveY = 0;
_inactiveYOff = 0;
_tilePos = Common::Point(0, 0);
+ _hintLevel = 0;
Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
memset(_tileData, 0, sizeof(_tileData));
+
+ _chapterCells.push_back(CellIdent(0, 96, 17));
- _hintLevel = 0;
}
AmazonEngine::~AmazonEngine() {
@@ -380,6 +382,160 @@ void AmazonEngine::drawHelp() {
error("TODO: drawHelp");
}
+void AmazonEngine::startChapter(int chapter) {
+ _chapter = chapter;
+ assert(_chapter <= 14);
+
+ if (chapter != 1) {
+ _room->clearRoom();
+ freeChar();
+
+ _sound->newMusic(32, 0);
+ playVideo(0, Common::Point());
+ if (shouldQuit())
+ return;
+
+ _events->debounceLeft();
+ _events->zeroKeys();
+ playVideo(_chapter, Common::Point(4, 113));
+ if (shouldQuit())
+ return;
+
+ _timers[20]._timer = 500;
+ _timers[20]._initTm = 500;
+ _timers[20]._flag++;
+
+ _sound->_soundTable[0] = _sound->loadSound(115, 0);
+ _sound->_soundPriority[0] = 1;
+ _sound->playSound(0);
+ _sound->freeSounds();
+
+ _sound->_soundTable[0] = _sound->loadSound(115, 1);
+ _sound->_soundPriority[0] = 1;
+ _sound->playSound(0);
+ _sound->freeSounds();
+
+ // Wait loop
+ while (!shouldQuit() && !_events->_leftButton && !_events->_rightButton
+ && _events->_keypresses.size() == 0 && _timers[20]._flag) {
+ _events->pollEvents();
+ g_system->delayMillis(10);
+ }
+ }
+
+ _screen->forceFadeOut();
+ _events->debounceLeft();
+ _events->zeroKeys();
+ _screen->clearScreen();
+
+ _screen->setPanel(3);
+
+ // Set up cells for the chapter display
+ Common::Array<CellIdent> chapterCells;
+ chapterCells.push_back(CellIdent(0, 96, 17));
+ const int *chapCell = &CHAPTER_CELLS[_chapter - 1][0];
+ chapterCells.push_back(CellIdent(chapCell[0], chapCell[1], chapCell[2]));
+ loadCells(chapterCells);
+
+ // Show chapter screen
+ _files->loadScreen(96, 15);
+ _buffer2.copyFrom(*_screen);
+
+ const int *chapImg = &CHAPTER_TABLE[_chapter - 1][0];
+ _screen->plotImage(_objectsTable[0], _chapter - 1,
+ Common::Point(chapImg[1], chapImg[2]));
+ _screen->plotImage(_objectsTable[_chapter - 1], 0,
+ Common::Point(chapImg[3], chapImg[4]));
+ if (chapter == 14)
+ _screen->plotImage(_objectsTable[_chapter - 1], 1, Common::Point(169, 76));
+
+ _sound->newMusic(chapImg[4], 1);
+ _sound->newMusic(33, 0);
+ _screen->forceFadeIn();
+
+ _timers[20]._timer = 950;
+ _timers[20]._initTm = 950;
+ _timers[20]._flag++;
+
+ // Wait loop
+ while (!shouldQuit() && !_events->_leftButton && !_events->_rightButton
+ && _events->_keypresses.size() == 0 && _timers[20]._flag) {
+ _events->pollEvents();
+ g_system->delayMillis(10);
+ }
+ if (shouldQuit())
+ return;
+
+ _screen->forceFadeOut();
+ _events->debounceLeft();
+ _events->zeroKeys();
+
+ _screen->clearBuffer();
+ _files->loadScreen(96, 16);
+ _buffer2.copyFrom(*_screen);
+ _screen->plotImage(_objectsTable[0], chapImg[0], Common::Point(90, 7));
+
+ _sound->newMusic(7, 1);
+ _sound->newMusic(34, 0);
+
+ _screen->forceFadeIn();
+ _buffer2.copyFrom(*_screen);
+
+ _fonts._charSet._lo = 1;
+ _fonts._charSet._hi = 10;
+ _fonts._charFor._lo = 55;
+ _fonts._charFor._hi = 0xFF;
+ _screen->_printOrg = Common::Point(31, 77);
+ _screen->_printStart = Common::Point(31, 77);
+
+ _establishGroup = 1;
+ loadEstablish(0x40 + _chapter);
+ uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (_chapter * 2) + 2);
+ _printEnd = 170;
+
+ _printEnd = 155;
+ Common::String msg((const char *)_eseg->data() + msgOffset);
+
+ if (_txtPages == 0) {
+ printText(_screen, msg);
+ } else {
+ speakText(_screen, msg);
+ }
+ if (shouldQuit())
+ return;
+
+ _screen->forceFadeOut();
+ _screen->clearBuffer();
+ freeCells();
+
+ _sound->newMusic(_chapter * 2, 1);
+
+ if (chapter != 1 && chapter != 14) {
+ _room->init4Quads();
+ }
+
+ if (chapter == 14) {
+ _conversation = 31;
+ _char->loadChar(_conversation);
+ _events->setCursor(CURSOR_ARROW);
+
+ _images.clear();
+ _oldRects.clear();
+ _scripts->_sequence = 0;
+ _scripts->searchForSequence();
+
+ if (_screen->_vesaMode) {
+ _converseMode = 1;
+ }
+ } else if (chapter != 1) {
+ _player->_roomNumber = CHAPTER_JUMP[_chapter - 1];
+ _room->_function = 1;
+ _converseMode = 0;
+
+ _scripts->cmdRetPos();
+ }
+}
+
void AmazonEngine::synchronize(Common::Serializer &s) {
AccessEngine::synchronize(s);
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 0275ceec17..2dc0c058fb 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -70,6 +70,7 @@ private:
// Other fields
Common::Point _tilePos;
byte _tileData[1455];
+ Common::Array<CellIdent> _chapterCells;
/**
* Do the game introduction
@@ -161,6 +162,11 @@ public:
void tileScreen();
void updateSummary(int chap);
+
+ /**
+ * Show the start of a chapter
+ */
+ void startChapter(int chapter);
};
} // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index a51457522e..05af0c116b 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1314,6 +1314,44 @@ const int DEATH_CELLS[12][3] = {
{ 0, 94, 14 }
};
+const int CHAPTER_CELLS[17][3] = {
+ { 1, 96, 18 },
+ { 2, 96, 19 },
+ { 3, 96, 20 },
+ { 4, 96, 21 },
+ { 5, 96, 22 },
+ { 6, 96, 23 },
+ { 7, 96, 24 },
+ { 8, 96, 25 },
+ { 9, 96, 26 },
+ { 10, 96, 27 },
+ { 11, 96, 28 },
+ { 12, 96, 29 },
+ { 13, 96, 30 },
+ { 14, 96, 31 }
+};
+
+const int CHAPTER_TABLE[14][5] = {
+ { 18, 136, 27, 76, 49 },
+ { 16, 134, 27, 53, 74 },
+ { 16, 136, 27, 52, 56 },
+ { 16, 135, 26, 46, 75 },
+ { 16, 135, 27, 54, 66 },
+ { 16, 137, 27, 67, 79 },
+ { 14, 136, 27, 82, 52 },
+ { 15, 136, 26, 65, 73 },
+ { 15, 137, 26, 48, 75 },
+ { 17, 135, 27, 52, 66 },
+ { 15, 135, 27, 62, 65 },
+ { 16, 135, 28, 45, 66 },
+ { 16, 135, 28, 36, 67 },
+ { 15, 135, 27, 34, 63 }
+};
+
+const int CHAPTER_JUMP[14] = {
+ 0, 12, 10, 15, 19, 25, 31, 36, 45, 46, 29, 55, 61, 0
+};
+
} // End of namespace Amazon
} // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 17cca2a0b4..d8d37b5a5f 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -58,6 +58,12 @@ extern const char *const DEATH_TEXT[58];
extern const int DEATH_CELLS[12][3];
+extern const int CHAPTER_CELLS[17][3];
+
+extern const int CHAPTER_TABLE[14][5];
+
+extern const int CHAPTER_JUMP[14];
+
} // End of namespace Amazon
} // End of namespace Access
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index a932dad216..7ad68bd5bc 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -414,7 +414,7 @@ typedef void(AmazonScripts::*AmazonScriptMethodPtr)();
void AmazonScripts::executeCommand(int commandIndex) {
static const AmazonScriptMethodPtr COMMAND_LIST[] = {
&AmazonScripts::cmdHelp, &AmazonScripts::CMDCYCLEBACK,
- &AmazonScripts::CMDCHAPTER, &AmazonScripts::cmdSetHelp,
+ &AmazonScripts::cmdChapter, &AmazonScripts::cmdSetHelp,
&AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel,
&AmazonScripts::CMDRETFLASH
};
@@ -452,8 +452,9 @@ void AmazonScripts::cmdHelp() {
void AmazonScripts::CMDCYCLEBACK() {
error("TODO CMDCYCLEBACK");
}
-void AmazonScripts::CMDCHAPTER() {
- error("TODO CMDCHAPTER");
+void AmazonScripts::cmdChapter() {
+ int chapter = _data->readByte();
+ _game->startChapter(chapter);
}
void AmazonScripts::cmdSetHelp() {
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 50bd2ac9b1..edb8843da3 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -53,7 +53,7 @@ protected:
void cmdHelp();
void CMDCYCLEBACK();
- void CMDCHAPTER();
+ void cmdChapter();
void cmdSetHelp();
void cmdCenterPanel();
void cmdMainPanel();