ACCESS: Implemented code for cmdChapter

This commit is contained in:
Paul Gilbert 2014-10-31 23:01:47 -04:00
parent 59c4c93c00
commit 3627ff51aa
13 changed files with 235 additions and 10 deletions

View file

@ -432,6 +432,17 @@ void AccessEngine::copyBF2Vid() {
} }
} }
void AccessEngine::playVideo(int fileNum, const Common::Point &pt) {
_video->setVideo(_screen, pt, FileIdent(fileNum, 96), 10);
while (!shouldQuit() && !_video->_videoEnd) {
_video->playVideo();
g_system->delayMillis(10);
_events->pollEvents();
}
}
void AccessEngine::doLoadSave() { void AccessEngine::doLoadSave() {
error("TODO: doLoadSave"); error("TODO: doLoadSave");
} }

View file

@ -119,6 +119,11 @@ protected:
*/ */
Common::String AccessEngine::generateSaveName(int slot); Common::String AccessEngine::generateSaveName(int slot);
/**
* Play back an entire video
*/
void playVideo(int fileNum, const Common::Point &pt);
// Engine APIs // Engine APIs
virtual Common::Error run(); virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const; virtual bool hasFeature(EngineFeature f) const;

View file

@ -55,11 +55,13 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_rawInactiveY = 0; _rawInactiveY = 0;
_inactiveYOff = 0; _inactiveYOff = 0;
_tilePos = Common::Point(0, 0); _tilePos = Common::Point(0, 0);
_hintLevel = 0;
Common::fill(&_esTabTable[0], &_esTabTable[100], 0); Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
memset(_tileData, 0, sizeof(_tileData)); memset(_tileData, 0, sizeof(_tileData));
_chapterCells.push_back(CellIdent(0, 96, 17));
_hintLevel = 0;
} }
AmazonEngine::~AmazonEngine() { AmazonEngine::~AmazonEngine() {
@ -380,6 +382,160 @@ void AmazonEngine::drawHelp() {
error("TODO: 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) { void AmazonEngine::synchronize(Common::Serializer &s) {
AccessEngine::synchronize(s); AccessEngine::synchronize(s);

View file

@ -70,6 +70,7 @@ private:
// Other fields // Other fields
Common::Point _tilePos; Common::Point _tilePos;
byte _tileData[1455]; byte _tileData[1455];
Common::Array<CellIdent> _chapterCells;
/** /**
* Do the game introduction * Do the game introduction
@ -161,6 +162,11 @@ public:
void tileScreen(); void tileScreen();
void updateSummary(int chap); void updateSummary(int chap);
/**
* Show the start of a chapter
*/
void startChapter(int chapter);
}; };
} // End of namespace Amazon } // End of namespace Amazon

View file

@ -1314,6 +1314,44 @@ const int DEATH_CELLS[12][3] = {
{ 0, 94, 14 } { 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 Amazon
} // End of namespace Access } // End of namespace Access

View file

@ -58,6 +58,12 @@ extern const char *const DEATH_TEXT[58];
extern const int DEATH_CELLS[12][3]; 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 Amazon
} // End of namespace Access } // End of namespace Access

View file

@ -414,7 +414,7 @@ typedef void(AmazonScripts::*AmazonScriptMethodPtr)();
void AmazonScripts::executeCommand(int commandIndex) { void AmazonScripts::executeCommand(int commandIndex) {
static const AmazonScriptMethodPtr COMMAND_LIST[] = { static const AmazonScriptMethodPtr COMMAND_LIST[] = {
&AmazonScripts::cmdHelp, &AmazonScripts::CMDCYCLEBACK, &AmazonScripts::cmdHelp, &AmazonScripts::CMDCYCLEBACK,
&AmazonScripts::CMDCHAPTER, &AmazonScripts::cmdSetHelp, &AmazonScripts::cmdChapter, &AmazonScripts::cmdSetHelp,
&AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel, &AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel,
&AmazonScripts::CMDRETFLASH &AmazonScripts::CMDRETFLASH
}; };
@ -452,8 +452,9 @@ void AmazonScripts::cmdHelp() {
void AmazonScripts::CMDCYCLEBACK() { void AmazonScripts::CMDCYCLEBACK() {
error("TODO CMDCYCLEBACK"); error("TODO CMDCYCLEBACK");
} }
void AmazonScripts::CMDCHAPTER() { void AmazonScripts::cmdChapter() {
error("TODO CMDCHAPTER"); int chapter = _data->readByte();
_game->startChapter(chapter);
} }
void AmazonScripts::cmdSetHelp() { void AmazonScripts::cmdSetHelp() {

View file

@ -53,7 +53,7 @@ protected:
void cmdHelp(); void cmdHelp();
void CMDCYCLEBACK(); void CMDCYCLEBACK();
void CMDCHAPTER(); void cmdChapter();
void cmdSetHelp(); void cmdSetHelp();
void cmdCenterPanel(); void cmdCenterPanel();
void cmdMainPanel(); void cmdMainPanel();

View file

@ -101,7 +101,7 @@ Resource *FileManager::loadFile(int fileNum, int subfile) {
return res; return res;
} }
Resource *FileManager::loadFile(FileIdent &fileIdent) { Resource *FileManager::loadFile(const FileIdent &fileIdent) {
return loadFile(fileIdent._fileNum, fileIdent._subfile); return loadFile(fileIdent._fileNum, fileIdent._subfile);
} }

View file

@ -38,6 +38,7 @@ struct FileIdent {
int _subfile; int _subfile;
FileIdent(); FileIdent();
FileIdent(int fileNum, int subfile) { _fileNum = fileNum; _subfile = subfile; }
void load(Common::SeekableReadStream &s); void load(Common::SeekableReadStream &s);
}; };
@ -112,7 +113,7 @@ public:
/** /**
* Loads a resource specified by a file identifier * Loads a resource specified by a file identifier
*/ */
Resource *loadFile(FileIdent &fileIdent); Resource *loadFile(const FileIdent &fileIdent);
/** /**
* Load a given file by name * Load a given file by name

View file

@ -66,7 +66,6 @@ protected:
void cmdJumpTalk(); void cmdJumpTalk();
void cmdNull(); void cmdNull();
void cmdPrint(); void cmdPrint();
void cmdRetPos();
void cmdAnim(); void cmdAnim();
void cmdSetFlag(); void cmdSetFlag();
void cmdCheckFlag(); void cmdCheckFlag();
@ -145,7 +144,9 @@ public:
void findNull(); void findNull();
// Script commands that need to be public
void cmdFreeSound(); void cmdFreeSound();
void cmdRetPos();
}; };
} // End of namespace Access } // End of namespace Access

View file

@ -38,7 +38,7 @@ VideoPlayer::~VideoPlayer() {
} }
void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate) { void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, const FileIdent &videoFile, int rate) {
_vidSurface = vidSurface; _vidSurface = vidSurface;
vidSurface->_orgX1 = pt.x; vidSurface->_orgX1 = pt.x;
vidSurface->_orgY1 = pt.y; vidSurface->_orgY1 = pt.y;

View file

@ -62,7 +62,7 @@ public:
/** /**
* Start up a video * Start up a video
*/ */
void setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate); void setVideo(ASurface *vidSurface, const Common::Point &pt, const FileIdent &videoFile, int rate);
/** /**
* Decodes a frame of the video * Decodes a frame of the video