aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorJohannes Schickel2008-05-03 19:23:45 +0000
committerJohannes Schickel2008-05-03 19:23:45 +0000
commitd5545bd8c5589e8d919350b932eaed76b28e83e9 (patch)
tree8418c5c56c25d97202fb544660bf6cbf88123610 /engines/kyra
parent043f92cb230f6afc83e5635cc1610c5d166e105f (diff)
downloadscummvm-rg350-d5545bd8c5589e8d919350b932eaed76b28e83e9.tar.gz
scummvm-rg350-d5545bd8c5589e8d919350b932eaed76b28e83e9.tar.bz2
scummvm-rg350-d5545bd8c5589e8d919350b932eaed76b28e83e9.zip
- Moved newShape/temporaryScript code to KyraEngine_v2.
- Renamed newShape/temporaryScript code to animationScript. svn-id: r31841
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/animator_mr.cpp6
-rw-r--r--engines/kyra/animator_v2.cpp6
-rw-r--r--engines/kyra/kyra_hof.cpp160
-rw-r--r--engines/kyra/kyra_hof.h51
-rw-r--r--engines/kyra/kyra_mr.cpp26
-rw-r--r--engines/kyra/kyra_mr.h48
-rw-r--r--engines/kyra/kyra_v2.cpp21
-rw-r--r--engines/kyra/kyra_v2.h67
-rw-r--r--engines/kyra/module.mk1
-rw-r--r--engines/kyra/scene_v2.cpp2
-rw-r--r--engines/kyra/script_hof.cpp60
-rw-r--r--engines/kyra/script_mr.cpp40
-rw-r--r--engines/kyra/script_v2.cpp22
-rw-r--r--engines/kyra/sequences_hof.cpp10
-rw-r--r--engines/kyra/sequences_mr.cpp125
-rw-r--r--engines/kyra/sequences_v2.cpp137
-rw-r--r--engines/kyra/staticres.cpp2
-rw-r--r--engines/kyra/text_hof.cpp22
-rw-r--r--engines/kyra/text_mr.cpp12
-rw-r--r--engines/kyra/timer_hof.cpp2
20 files changed, 355 insertions, 465 deletions
diff --git a/engines/kyra/animator_mr.cpp b/engines/kyra/animator_mr.cpp
index c51989ae67..15c4db346c 100644
--- a/engines/kyra/animator_mr.cpp
+++ b/engines/kyra/animator_mr.cpp
@@ -212,8 +212,8 @@ void KyraEngine_MR::updateCharacterAnim(int charId) {
shapeOffsetX = _malcolmShapeXOffset;
shapeOffsetY = _malcolmShapeYOffset;
} else {
- shapeOffsetX = _newShapeXAdd;
- shapeOffsetY = _newShapeYAdd;
+ shapeOffsetX = _animShapeXAdd;
+ shapeOffsetY = _animShapeYAdd;
}
obj->xPos2 = _mainCharacter.x1;
@@ -425,7 +425,7 @@ void KyraEngine_MR::showIdleAnim() {
snprintf(filename, 14, "MI0%s%.02d.EMC", facingTable[_mainCharacter.facing], _characterShapeFile);
if (_res->exists(filename))
- runTemporaryScript(filename, 1, 1, 1, 1);
+ runAnimationScript(filename, 1, 1, 1, 1);
}
_nextIdleType = !_nextIdleType;
diff --git a/engines/kyra/animator_v2.cpp b/engines/kyra/animator_v2.cpp
index 83081ca105..af22056eee 100644
--- a/engines/kyra/animator_v2.cpp
+++ b/engines/kyra/animator_v2.cpp
@@ -163,14 +163,14 @@ void KyraEngine_v2::addItemToAnimList(int item) {
animObj->xPos2 = animObj->xPos1 = _itemList[item].x;
animObj->yPos2 = animObj->yPos1 = _itemList[item].y;
- animObj->shapePtr = getShapePtr(getItemShape(itemId));
+ animObj->shapePtr = getShapePtr(itemId + _desc.itemShapeStart);
animSetupPaletteEntry(animObj);
- animObj->shapeIndex2 = animObj->shapeIndex1 = getItemShape(itemId);
+ animObj->shapeIndex2 = animObj->shapeIndex1 = itemId + _desc.itemShapeStart;
int scaleY, scaleX;
scaleY = scaleX = getScale(animObj->xPos1, animObj->yPos1);
- uint8 *shapePtr = getShapePtr(getItemShape(itemId));
+ uint8 *shapePtr = getShapePtr(itemId + _desc.itemShapeStart);
animObj->xPos3 = (animObj->xPos2 -= (screen_v2()->getShapeScaledWidth(shapePtr, scaleX) >> 1));
animObj->yPos3 = (animObj->yPos2 -= screen_v2()->getShapeScaledHeight(shapePtr, scaleY));
diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp
index 347e5f35a4..6e0961264f 100644
--- a/engines/kyra/kyra_hof.cpp
+++ b/engines/kyra/kyra_hof.cpp
@@ -40,7 +40,19 @@
namespace Kyra {
-KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEngine_v2(system, flags), _updateFunctor(this, &KyraEngine_HoF::update) {
+namespace {
+const KyraEngine_v2::EngineDesc hofEngineDesc = {
+ 64,
+
+ 8,
+
+ 33
+};
+} // end of anonymous namespace
+
+KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEngine_v2(system, flags, hofEngineDesc), _updateFunctor(this, &KyraEngine_HoF::update) {
+ KyraEngine_v2::_characterFrameTable = _characterFrameTable;
+
_mouseSHPBuf = 0;
_debugger = 0;
_screen = 0;
@@ -53,8 +65,6 @@ KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEn
_sequences = 0;
_sequenceSoundList = 0;
- _showCredits = false;
-
_gamePlayBuffer = 0;
_cCodeBuffer = _optionsBuffer = _chapterBuffer = 0;
@@ -74,14 +84,7 @@ KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEn
_unkHandleSceneChangeFlag = false;
_pathfinderFlag = 0;
_mouseX = _mouseY = 0;
- _newShapeCount = 0;
- _newShapeFiledata = 0;
-
- _vocHigh = -1;
- _chatVocHigh = -1;
- _chatVocLow = -1;
- _chatText = 0;
- _chatObject = -1;
+
_lastIdleScript = -1;
_currentTalkSections.STATim = 0;
@@ -128,8 +131,6 @@ KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEn
_mainCharacter.dlgIndex = 0;
setNewDlgIndex(-1);
- _deathHandler = -1;
-
_bookMaxPage = 6;
_bookCurPage = 0;
_bookNewPage = 0;
@@ -171,10 +172,6 @@ KyraEngine_HoF::~KyraEngine_HoF() {
delete [] _conversationState[i];
delete [] _conversationState;
- for (Common::Array<const Opcode*>::iterator i = _opcodesTemporary.begin(); i != _opcodesTemporary.end(); ++i)
- delete *i;
- _opcodesTemporary.clear();
-
for (Common::Array<const TIMOpcode*>::iterator i = _timOpcodes.begin(); i != _timOpcodes.end(); ++i)
delete *i;
_timOpcodes.clear();
@@ -267,7 +264,7 @@ int KyraEngine_HoF::go() {
runLoop();
cleanup();
- if (_showCredits)
+ if (_showOutro)
seq_playSequences(kSequenceFunters, kSequenceFrash);
}
@@ -594,7 +591,7 @@ bool KyraEngine_HoF::handleInputUnkSub(int x, int y) {
if (queryGameFlag(0x1ED)) {
_sound->beginFadeOut();
_screen->fadeToBlack();
- _showCredits = true;
+ _showOutro = true;
_runFlag = false;
}
@@ -835,10 +832,6 @@ void KyraEngine_HoF::cleanup() {
delete [] _screenBuffer; _screenBuffer = 0;
delete [] _unkBuf200kByte; _unkBuf200kByte = 0;
- resetNewShapes(_newShapeCount, _newShapeFiledata);
- _newShapeFiledata = 0;
- _newShapeCount = 0;
-
freeSceneShapePtrs();
if (_optionsBuffer != _cCodeBuffer)
@@ -1171,53 +1164,6 @@ void KyraEngine_HoF::loadNPCScript() {
_emc->load(filename, &_npcScriptData, &_opcodes);
}
-void KyraEngine_HoF::runTemporaryScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload) {
- memset(&_temporaryScriptData, 0, sizeof(_temporaryScriptData));
- memset(&_temporaryScriptState, 0, sizeof(_temporaryScriptState));
-
- if (!_emc->load(filename, &_temporaryScriptData, &_opcodesTemporary))
- error("Couldn't load temporary script '%s'", filename);
-
- _emc->init(&_temporaryScriptState, &_temporaryScriptData);
- _emc->start(&_temporaryScriptState, 0);
-
- _newShapeFlag = -1;
-
- if (_newShapeFiledata && newShapes) {
- resetNewShapes(_newShapeCount, _newShapeFiledata);
- _newShapeFiledata = 0;
- _newShapeCount = 0;
- }
-
- while (_emc->isValid(&_temporaryScriptState))
- _emc->run(&_temporaryScriptState);
-
- uint8 *fileData = 0;
-
- if (newShapes)
- _newShapeFiledata = _res->fileData(_newShapeFilename, 0);
-
- fileData = _newShapeFiledata;
-
- if (!fileData) {
- _emc->unload(&_temporaryScriptData);
- return;
- }
-
- if (newShapes)
- _newShapeCount = initNewShapes(fileData);
-
- processNewShapes(allowSkip, resetChar);
-
- if (shapeUnload) {
- resetNewShapes(_newShapeCount, fileData);
- _newShapeCount = 0;
- _newShapeFiledata = 0;
- }
-
- _emc->unload(&_temporaryScriptData);
-}
-
#pragma mark -
void KyraEngine_HoF::resetScaleTable() {
@@ -1376,7 +1322,7 @@ int KyraEngine_HoF::inputSceneChange(int x, int y, int unk1, int unk2) {
if (queryGameFlag(0x164)) {
_screen->hideMouse();
_timer->disable(5);
- runTemporaryScript("_ZANBURN.EMC", 0, 1, 1, 0);
+ runAnimationScript("_ZANBURN.EMC", 0, 1, 1, 0);
_deathHandler = 7;
snd_playWanderScoreViaMap(0x53, 1);
} else {
@@ -1485,76 +1431,20 @@ bool KyraEngine_HoF::checkCharCollision(int x, int y) {
return false;
}
-int KyraEngine_HoF::initNewShapes(uint8 *filedata) {
- const int lastEntry = MIN(_newShapeLastEntry, 31);
+int KyraEngine_HoF::initAnimationShapes(uint8 *filedata) {
+ const int lastEntry = MIN(_animShapeLastEntry, 31);
for (int i = 0; i < lastEntry; ++i) {
addShapeToPool(filedata, i+33, i);
ShapeDesc *desc = &_shapeDescTable[24+i];
- desc->xAdd = _newShapeXAdd;
- desc->yAdd = _newShapeYAdd;
- desc->width = _newShapeWidth;
- desc->height = _newShapeHeight;
+ desc->xAdd = _animShapeXAdd;
+ desc->yAdd = _animShapeYAdd;
+ desc->width = _animShapeWidth;
+ desc->height = _animShapeHeight;
}
return lastEntry;
}
-void KyraEngine_HoF::processNewShapes(int allowSkip, int resetChar) {
- setCharacterAnimDim(_newShapeWidth, _newShapeHeight);
-
- _emc->init(&_temporaryScriptState, &_temporaryScriptData);
- _emc->start(&_temporaryScriptState, 1);
-
- resetSkipFlag();
-
- while (_emc->isValid(&_temporaryScriptState)) {
- _temporaryScriptExecBit = false;
- while (_emc->isValid(&_temporaryScriptState) && !_temporaryScriptExecBit)
- _emc->run(&_temporaryScriptState);
-
- if (_newShapeAnimFrame < 0)
- continue;
-
- _mainCharacter.animFrame = _newShapeAnimFrame + 33;
- updateCharacterAnim(0);
- if (_chatText)
- updateWithText();
- else
- update();
-
- uint32 delayEnd = _system->getMillis() + _newShapeDelay * _tickLength;
-
- while ((!skipFlag() || !allowSkip) && _system->getMillis() < delayEnd) {
- if (_chatText)
- updateWithText();
- else
- update();
-
- delay(10);
- }
-
- if (skipFlag())
- resetSkipFlag();
- }
-
- if (resetChar) {
- if (_newShapeFlag >= 0) {
- _mainCharacter.animFrame = _newShapeFlag + 33;
- updateCharacterAnim(0);
- if (_chatText)
- updateWithText();
- else
- update();
- }
-
- _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing];
- updateCharacterAnim(0);
- }
-
- _newShapeFlag = -1;
- resetCharacterAnimDim();
-}
-
-void KyraEngine_HoF::resetNewShapes(int count, uint8 *filedata) {
+void KyraEngine_HoF::uninitAnimationShapes(int count, uint8 *filedata) {
for (int i = 0; i < count; ++i)
remShapeFromPool(i+33);
delete [] filedata;
@@ -1616,7 +1506,7 @@ void KyraEngine_HoF::runIdleScript(int script) {
"_IDLBRSH.EMC", "_Z3IDLE.EMC", "_Z4IDLE.EMC", "_Z6IDLE.EMC", "_Z7IDLE.EMC", "_Z8IDLE.EMC"
};
- runTemporaryScript(idleScriptFiles[script], 1, 1, 1, 1);
+ runAnimationScript(idleScriptFiles[script], 1, 1, 1, 1);
}
}
diff --git a/engines/kyra/kyra_hof.h b/engines/kyra/kyra_hof.h
index f05ab77455..baecdc687a 100644
--- a/engines/kyra/kyra_hof.h
+++ b/engines/kyra/kyra_hof.h
@@ -204,9 +204,6 @@ public:
virtual TextDisplayer *text() { return _text; }
int language() const { return _lang; }
protected:
- // KyraEngine_v2 API
- int getFirstSpecialSceneScript() const { return 8; }
-
// intro/outro
void seq_playSequences(int startSeq, int endSeq = -1);
@@ -322,9 +319,6 @@ protected:
void loadItemShapes();
// run
- bool _runFlag;
- bool _showCredits;
-
void update();
void updateWithText();
@@ -369,8 +363,6 @@ protected:
ShapeDesc *_shapeDescTable;
- int getItemShape(int item) const { return 64+item; }
-
void loadCharacterShapes(int shapes);
void loadInventoryShapes();
@@ -385,19 +377,8 @@ protected:
int _layerFlagTable[16]; // seems to indicate layers where items get destroyed when dropped to (TODO: check this!)
- char _newShapeFilename[13];
- int _newShapeLastEntry;
- int _newShapeWidth, _newShapeHeight;
- int _newShapeXAdd, _newShapeYAdd;
- int _newShapeFlag;
- uint8 *_newShapeFiledata;
- int _newShapeCount;
- int _newShapeAnimFrame;
- int _newShapeDelay;
-
- int initNewShapes(uint8 *filedata);
- void processNewShapes(int allowSkip, int resetChar);
- void resetNewShapes(int count, uint8 *filedata);
+ int initAnimationShapes(uint8 *filedata);
+ void uninitAnimationShapes(int count, uint8 *filedata);
// animator
uint8 *_gamePlayBuffer;
@@ -581,7 +562,6 @@ protected:
static const char *_scriptLangExt[];
// character
- int8 _deathHandler;
bool _useCharPal;
int _charPalEntry;
uint8 _charPalTable[16];
@@ -593,7 +573,7 @@ protected:
bool checkCharCollision(int x, int y);
- static const int _characterFrameTable[];
+ static const uint8 _characterFrameTable[];
// text
void showMessageFromCCode(int id, int16 palIndex, int);
@@ -609,16 +589,7 @@ protected:
void fadeMessagePalette();
// chat
- int _vocHigh;
-
- const char *_chatText;
- int _chatObject;
bool _chatIsNote;
- uint32 _chatEndTime;
- int _chatVocHigh, _chatVocLow;
-
- EMCData _chatScriptData;
- EMCState _chatScriptState;
int chatGetType(const char *text);
int chatCalcDuration(const char *text);
@@ -874,13 +845,8 @@ protected:
int o2_demoFinale(EMCState *script);
int o2_dummy(EMCState *script);
- // opcodes temporary
- // TODO: rename it from temporary to something more appropriate
- int o2t_defineNewShapes(EMCState *script);
- int o2t_setCurrentFrame(EMCState *script);
- int o2t_playSoundEffect(EMCState *script);
- int o2t_fadeScenePal(EMCState *script);
- int o2t_setShapeFlag(EMCState *script);
+ // animation opcodes
+ int o2a_setCharacterFrame(EMCState *script);
// script
void runStartScript(int script, int unk1);
@@ -890,13 +856,6 @@ protected:
EMCData _npcScriptData;
- EMCData _temporaryScriptData;
- EMCState _temporaryScriptState;
- bool _temporaryScriptExecBit;
- Common::Array<const Opcode*> _opcodesTemporary;
-
- void runTemporaryScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload);
-
// pathfinder
uint8 *_unkBuf500Bytes;
uint8 *_unkBuf200kByte;
diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp
index 3fe27fe86d..442601575a 100644
--- a/engines/kyra/kyra_mr.cpp
+++ b/engines/kyra/kyra_mr.cpp
@@ -40,7 +40,20 @@
#include "common/config-manager.h"
namespace Kyra {
-KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngine_v2(system, flags) {
+
+namespace {
+const KyraEngine_v2::EngineDesc mrEngineDesc = {
+ 248,
+
+ 9,
+
+ 9
+};
+} // end of anonymous namespace
+
+KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngine_v2(system, flags, mrEngineDesc) {
+ KyraEngine_v2::_characterFrameTable = _characterFrameTable;
+
_soundDigital = 0;
_musicSoundChannel = -1;
_menuAudioFile = "TITLE1.AUD";
@@ -90,8 +103,6 @@ KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngi
_noStartupChat = false;
_pathfinderFlag = 0;
_talkObjectList = 0;
- _chatText = 0;
- _chatObject = -1;
memset(&_chatScriptState, 0, sizeof(_chatScriptState));
memset(&_chatScriptData, 0, sizeof(_chatScriptData));
_voiceSoundChannel = -1;
@@ -101,7 +112,6 @@ KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngi
_curStudioSFX = 283;
_badConscienceShown = false;
_currentChapter = 1;
- _deathHandler = -1;
_unkHandleSceneChangeFlag = false;
memset(_sceneShapeDescs, 0, sizeof(_sceneShapeDescs));
_cnvFile = _dlgBuffer = 0;
@@ -115,8 +125,6 @@ KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngi
_malcolmsMood = 1;
_nextIdleAnim = 0;
_nextIdleType = false;
- _newShapeFlag = -1;
- _newShapeFiledata = 0;
_inventoryScrollSpeed = -1;
_invWsa = 0;
_invWsaFrame = -1;
@@ -130,7 +138,6 @@ KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngi
_goodConscienceShown = false;
_goodConscienceAnim = -1;
_goodConsciencePosition = false;
- _showOutro = false;
}
KyraEngine_MR::~KyraEngine_MR() {
@@ -167,10 +174,6 @@ KyraEngine_MR::~KyraEngine_MR() {
delete [] _sceneStrings;
delete [] _talkObjectList;
- for (Common::Array<const Opcode*>::iterator i = _opcodesTemporary.begin(); i != _opcodesTemporary.end(); ++i)
- delete *i;
- _opcodesTemporary.clear();
-
for (Common::Array<const Opcode*>::iterator i = _opcodesDialog.begin(); i != _opcodesDialog.end(); ++i)
delete *i;
_opcodesDialog.clear();
@@ -178,7 +181,6 @@ KyraEngine_MR::~KyraEngine_MR() {
delete _cnvFile;
delete _dlgBuffer;
delete [] _stringBuffer;
- delete [] _newShapeFiledata;
delete _invWsa;
delete _debugger;
delete [] _mainButtonData;
diff --git a/engines/kyra/kyra_mr.h b/engines/kyra/kyra_mr.h
index 9b330394e6..c1496a5ffa 100644
--- a/engines/kyra/kyra_mr.h
+++ b/engines/kyra/kyra_mr.h
@@ -62,9 +62,6 @@ public:
void playVQA(const char *name);
protected:
- // KyraEngine_v2 API
- int getFirstSpecialSceneScript() const { return 9; }
-
// --
Screen_MR *_screen;
SoundDigital *_soundDigital;
@@ -78,10 +75,6 @@ protected:
void setupOpcodeTable();
// run
- bool _showOutro;
- bool _runFlag;
- int _deathHandler;
-
void runLoop();
void handleInput(int x, int y);
int inputSceneChange(int x, int y, int unk1, int unk2);
@@ -291,8 +284,6 @@ private:
void setMouseCursor(uint16 item);
// shapes
- int getItemShape(int item) const { return 248+item; }
-
void initMouseShapes();
void loadCharacterShapes(int newShapes);
@@ -392,16 +383,6 @@ private:
bool talkObjectsInCurScene();
// chat
- int _vocHigh;
-
- const char *_chatText;
- int _chatObject;
- uint32 _chatEndTime;
- int _chatVocHigh, _chatVocLow;
-
- EMCData _chatScriptData;
- EMCState _chatScriptState;
-
int chatGetType(const char *text);
int chatCalcDuration(const char *text);
@@ -474,36 +455,13 @@ private:
void hideGoodConscience();
// special script code
- bool _temporaryScriptExecBit;
bool _useFrameTable;
- Common::Array<const Opcode *> _opcodesTemporary;
-
- int o3t_defineNewShapes(EMCState *script);
- int o3t_setCurrentFrame(EMCState *script);
- int o3t_setNewShapeFlag(EMCState *script);
-
- EMCData _temporaryScriptData;
- EMCState _temporaryScriptState;
-
- void runTemporaryScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload);
+ int o3a_setCharacterFrame(EMCState *script);
// special shape code
- char _newShapeFilename[13];
- int _newShapeLastEntry;
- int _newShapeWidth, _newShapeHeight;
- int _newShapeXAdd, _newShapeYAdd;
-
- int _newShapeAnimFrame;
- int _newShapeDelay;
-
- int _newShapeFlag;
- uint8 *_newShapeFiledata;
- int _newShapeCount;
-
- int initNewShapes(uint8 *filedata);
- void processNewShapes(int allowSkip, int resetChar);
- void resetNewShapes(int count, uint8 *filedata);
+ int initAnimationShapes(uint8 *filedata);
+ void uninitAnimationShapes(int count, uint8 *filedata);
// unk
uint8 *_costPalBuffer;
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp
index 0f4a78146b..60b3af2b9e 100644
--- a/engines/kyra/kyra_v2.cpp
+++ b/engines/kyra/kyra_v2.cpp
@@ -28,7 +28,7 @@
namespace Kyra {
-KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngine(system, flags) {
+KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags, const EngineDesc &desc) : KyraEngine(system, flags), _desc(desc) {
memset(&_sceneAnims, 0, sizeof(_sceneAnims));
memset(&_sceneAnimMovie, 0, sizeof(_sceneAnimMovie));
@@ -46,6 +46,20 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi
memset(&_sceneScriptData, 0, sizeof(_sceneScriptData));
_animObjects = 0;
+
+ _runFlag = true;
+ _showOutro = false;
+ _deathHandler = -1;
+ _animNeedUpdate = false;
+
+ _animShapeCount = 0;
+ _animShapeFiledata = 0;
+
+ _vocHigh = -1;
+ _chatVocHigh = -1;
+ _chatVocLow = -1;
+ _chatText = 0;
+ _chatObject = -1;
}
KyraEngine_v2::~KyraEngine_v2() {
@@ -60,6 +74,11 @@ KyraEngine_v2::~KyraEngine_v2() {
_emc->unload(&_sceneScriptData);
delete [] _animObjects;
+
+ for (Common::Array<const Opcode*>::iterator i = _opcodesAnimation.begin(); i != _opcodesAnimation.end(); ++i)
+ delete *i;
+ _opcodesAnimation.clear();
+
}
void KyraEngine_v2::updateInput() {
diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h
index 6a426f3761..730366a435 100644
--- a/engines/kyra/kyra_v2.h
+++ b/engines/kyra/kyra_v2.h
@@ -40,12 +40,31 @@ class Screen_v2;
class KyraEngine_v2 : public KyraEngine {
friend class Debugger_v2;
public:
- KyraEngine_v2(OSystem *system, const GameFlags &flags);
+ struct EngineDesc {
+ // Generic shape related
+ const int itemShapeStart;
+
+ // Scene script
+ const int firstAnimSceneScript;
+
+ // Animation script specific
+ const int animScriptFrameAdd;
+ };
+
+ KyraEngine_v2(OSystem *system, const GameFlags &flags, const EngineDesc &desc);
~KyraEngine_v2();
virtual Screen_v2 *screen_v2() const = 0;
+
+ const EngineDesc &engineDesc() const { return _desc; }
protected:
+ EngineDesc _desc;
+
// run
+ bool _runFlag;
+ bool _showOutro;
+ int8 _deathHandler;
+
virtual void update() = 0;
virtual void updateWithText() = 0;
@@ -138,6 +157,8 @@ protected:
virtual int getScale(int x, int y) = 0;
+ const uint8 *_characterFrameTable;
+
// Scene
struct SceneDesc {
char filename1[10];
@@ -197,7 +218,36 @@ protected:
bool _specialSceneScriptRunFlag;
void updateSpecialSceneScripts();
- virtual int getFirstSpecialSceneScript() const = 0;
+
+ // Sequences
+ EMCData _animationScriptData;
+ EMCState _animationScriptState;
+ Common::Array<const Opcode*> _opcodesAnimation;
+
+ void runAnimationScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload);
+
+ int o2a_setAnimationShapes(EMCState *script);
+ int o2a_setResetFrame(EMCState *script);
+
+ char _animShapeFilename[14];
+
+ uint8 *_animShapeFiledata;
+ int _animShapeCount;
+ int _animShapeLastEntry;
+
+ int _animNewFrame;
+ int _animDelayTime;
+
+ int _animResetFrame;
+
+ int _animShapeWidth, _animShapeHeight;
+ int _animShapeXAdd, _animShapeYAdd;
+
+ bool _animNeedUpdate;
+
+ virtual int initAnimationShapes(uint8 *filedata) = 0;
+ void processAnimationScript(int allowSkip, int resetChar);
+ virtual void uninitAnimationShapes(int count, uint8 *filedata) = 0;
// Shapes
typedef Common::HashMap<int, uint8*> ShapeMap;
@@ -208,8 +258,6 @@ protected:
void addShapeToPool(uint8 *shpData, int index);
void remShapeFromPool(int idx);
- virtual int getItemShape(int item) const = 0;
-
int _characterShapeFile;
virtual void loadCharacterShapes(int shapes) = 0;
@@ -289,6 +337,17 @@ protected:
virtual int getCharacterWalkspeed() const = 0;
virtual void updateCharAnimFrame(int num, int *table) = 0;
+ // chat
+ int _vocHigh;
+
+ const char *_chatText;
+ int _chatObject;
+ uint32 _chatEndTime;
+ int _chatVocHigh, _chatVocLow;
+
+ EMCData _chatScriptData;
+ EMCState _chatScriptState;
+
// unknown
int _unk3, _unk4, _unk5;
bool _unkSceneScreenFlag1;
diff --git a/engines/kyra/module.mk b/engines/kyra/module.mk
index 452d747ce4..9c387b27ff 100644
--- a/engines/kyra/module.mk
+++ b/engines/kyra/module.mk
@@ -43,6 +43,7 @@ MODULE_OBJS := \
script_tim.o \
seqplayer.o \
sequences_v1.o \
+ sequences_v2.o \
sequences_hof.o \
sequences_mr.o \
sound_adlib.o \
diff --git a/engines/kyra/scene_v2.cpp b/engines/kyra/scene_v2.cpp
index ac7bcdb257..5d811bcf44 100644
--- a/engines/kyra/scene_v2.cpp
+++ b/engines/kyra/scene_v2.cpp
@@ -57,7 +57,7 @@ void KyraEngine_v2::updateSpecialSceneScripts() {
}
if (!_emc->isValid(&_sceneSpecialScripts[_lastProcessedSceneScript])) {
- _emc->start(&_sceneSpecialScripts[_lastProcessedSceneScript], getFirstSpecialSceneScript()+_lastProcessedSceneScript);
+ _emc->start(&_sceneSpecialScripts[_lastProcessedSceneScript], _desc.firstAnimSceneScript+_lastProcessedSceneScript);
_specialSceneScriptRunFlag = false;
}
diff --git a/engines/kyra/script_hof.cpp b/engines/kyra/script_hof.cpp
index af10106fd3..85536dbaf3 100644
--- a/engines/kyra/script_hof.cpp
+++ b/engines/kyra/script_hof.cpp
@@ -878,7 +878,7 @@ int KyraEngine_HoF::o2_setRunFlag(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2_setRunFlag(%p) (%d)", (const void *)script, stackPos(0));
// this is usually just _runFlag, but since this is just used when the game should play the credits
// we handle it a bit different :-)
- _showCredits = true;
+ _showOutro = true;
_runFlag = false;
return 0;
}
@@ -1013,7 +1013,7 @@ int KyraEngine_HoF::o2_runTemporaryScript(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2_runTemporaryScript(%p) ('%s', %d, %d, %d)", (const void *)script, stackPosString(0), stackPos(1),
stackPos(2), stackPos(3));
- runTemporaryScript(stackPosString(0), stackPos(3), stackPos(2) ? 1 : 0, stackPos(1), stackPos(2));
+ runAnimationScript(stackPosString(0), stackPos(3), stackPos(2) ? 1 : 0, stackPos(1), stackPos(2));
return 0;
}
@@ -1678,45 +1678,11 @@ int KyraEngine_HoF::o2_dummy(EMCState *script) {
#pragma mark -
-int KyraEngine_HoF::o2t_defineNewShapes(EMCState *script) {
- debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2t_defineNewShapes(%p) ('%s', %d, %d, %d, %d, %d, %d)", (const void *)script, stackPosString(0),
- stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6));
-
- strcpy(_newShapeFilename, stackPosString(0));
- _newShapeLastEntry = stackPos(1);
- _newShapeWidth = stackPos(2);
- _newShapeHeight = stackPos(3);
- _newShapeXAdd = stackPos(4);
- _newShapeYAdd = stackPos(5);
- //word_324EB = stackPos(6); <- never used
-
- return 0;
-}
-
-int KyraEngine_HoF::o2t_setCurrentFrame(EMCState *script) {
- debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2t_setCurrentFrame(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
- _newShapeAnimFrame = stackPos(0);
- _newShapeDelay = stackPos(1);
- _temporaryScriptExecBit = true;
- return 0;
-}
-
-int KyraEngine_HoF::o2t_playSoundEffect(EMCState *script) {
- debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2t_playSoundEffect(%p) (%d)", (const void *)script, stackPos(0));
- snd_playSoundEffect(stackPos(0));
- return 0;
-}
-
-int KyraEngine_HoF::o2t_fadeScenePal(EMCState *script) {
- debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2t_fadeScenePal(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
- fadeScenePal(stackPos(0), stackPos(1));
- return 0;
-}
-
-int KyraEngine_HoF::o2t_setShapeFlag(EMCState *script) {
- debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2t_setShapeFlag(%p) (%d)", (const void *)script, stackPos(0));
- if (_flags.isTalkie)
- _newShapeFlag = stackPos(0);
+int KyraEngine_HoF::o2a_setCharacterFrame(EMCState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2a_setCharacterFrame(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
+ _animNewFrame = stackPos(0);
+ _animDelayTime = stackPos(1);
+ _animNeedUpdate = true;
return 0;
}
@@ -1995,15 +1961,15 @@ void KyraEngine_HoF::setupOpcodeTable() {
Opcode(o2_demoFinale);
Opcode(o2_dummy);
- SetOpcodeTable(_opcodesTemporary);
+ SetOpcodeTable(_opcodesAnimation);
// 0x00
- Opcode(o2t_defineNewShapes);
- Opcode(o2t_setCurrentFrame);
- Opcode(o2t_playSoundEffect);
- Opcode(o2t_fadeScenePal);
+ Opcode(o2a_setAnimationShapes);
+ Opcode(o2a_setCharacterFrame);
+ Opcode(o2_playSoundEffect);
+ Opcode(o2_fadeScenePal);
// 0x04
- Opcode(o2t_setShapeFlag);
+ _flags.isTalkie ? Opcode(o2a_setResetFrame) : Opcode(o2_dummy);
Opcode(o2_dummy);
// ---- TIM opcodes
diff --git a/engines/kyra/script_mr.cpp b/engines/kyra/script_mr.cpp
index 5d31979dee..c90765dd84 100644
--- a/engines/kyra/script_mr.cpp
+++ b/engines/kyra/script_mr.cpp
@@ -905,7 +905,7 @@ int KyraEngine_MR::o3_runTemporaryScript(EMCState *script) {
const int newShapes = stackPos(1);
const int unloadShapes = stackPos(2);
const int allowSkip = stackPos(3);
- runTemporaryScript(stackPosString(0), allowSkip, (unloadShapes != 0) ? 1 : 0, newShapes, unloadShapes);
+ runAnimationScript(stackPosString(0), allowSkip, (unloadShapes != 0) ? 1 : 0, newShapes, unloadShapes);
return 0;
}
@@ -1264,36 +1264,18 @@ int KyraEngine_MR::o3_dummy(EMCState *script) {
#pragma mark -
-int KyraEngine_MR::o3t_defineNewShapes(EMCState *script) {
- debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3t_defineNewShapes(%p) ('%s', %d, %d, %d, %d, %d)", (const void *)script,
- stackPosString(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5));
- strcpy(_newShapeFilename, stackPosString(0));
- _newShapeLastEntry = stackPos(1);
- _newShapeWidth = stackPos(2);
- _newShapeHeight = stackPos(3);
- _newShapeXAdd = stackPos(4);
- _newShapeYAdd = stackPos(5);
- return 0;
-}
-
-int KyraEngine_MR::o3t_setCurrentFrame(EMCState *script) {
- debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3t_setCurrentFrame(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
+int KyraEngine_MR::o3a_setCharacterFrame(EMCState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3a_setCharacterFrame(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
static const uint8 frameTable[] = {
0x58, 0xD8, 0xD8, 0x98, 0x78, 0x78, 0xB8, 0xB8
};
- _newShapeAnimFrame = stackPos(0);
+ _animNewFrame = stackPos(0);
if (_useFrameTable)
- _newShapeAnimFrame += frameTable[_mainCharacter.facing];
-
- _newShapeDelay = stackPos(1);
- _temporaryScriptExecBit = true;
- return 0;
-}
+ _animNewFrame += frameTable[_mainCharacter.facing];
-int KyraEngine_MR::o3t_setNewShapeFlag(EMCState *script) {
- debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3t_setNewShapeFlag(%p) (%d)", (const void *)script, stackPos(0));
- _newShapeFlag = stackPos(0);
+ _animDelayTime = stackPos(1);
+ _animNeedUpdate = true;
return 0;
}
@@ -1550,14 +1532,14 @@ void KyraEngine_MR::setupOpcodeTable() {
OpcodeUnImpl();
Opcode(o3_dummy);
- SetOpcodeTable(_opcodesTemporary);
+ SetOpcodeTable(_opcodesAnimation);
// 0x00
- Opcode(o3t_defineNewShapes);
- Opcode(o3t_setCurrentFrame);
+ Opcode(o2a_setAnimationShapes);
+ Opcode(o3a_setCharacterFrame);
Opcode(o3_playSoundEffect);
Opcode(o3_dummy);
// 0x0a
- Opcode(o3t_setNewShapeFlag);
+ Opcode(o2a_setResetFrame);
Opcode(o3_getRand);
Opcode(o3_getMalcolmShapes);
Opcode(o3_dummy);
diff --git a/engines/kyra/script_v2.cpp b/engines/kyra/script_v2.cpp
index dc7a7c8bd0..dd7aca79ee 100644
--- a/engines/kyra/script_v2.cpp
+++ b/engines/kyra/script_v2.cpp
@@ -26,6 +26,8 @@
#include "kyra/kyra_v2.h"
#include "kyra/screen_v2.h"
+#include "common/endian.h"
+
namespace Kyra {
int KyraEngine_v2::o2_getCharacterX(EMCState *script) {
@@ -137,5 +139,25 @@ int KyraEngine_v2::o2_showMouse(EMCState *script) {
return 0;
}
+#pragma mark -
+
+int KyraEngine_v2::o2a_setAnimationShapes(EMCState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v2::o2a_setAnimationShapes(%p) ('%s', %d, %d, %d, %d, %d)", (const void *)script,
+ stackPosString(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5));
+ strcpy(_animShapeFilename, stackPosString(0));
+ _animShapeLastEntry = stackPos(1);
+ _animShapeWidth = stackPos(2);
+ _animShapeHeight = stackPos(3);
+ _animShapeXAdd = stackPos(4);
+ _animShapeYAdd = stackPos(5);
+ return 0;
+}
+
+int KyraEngine_v2::o2a_setResetFrame(EMCState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3t_setResetFrame(%p) (%d)", (const void *)script, stackPos(0));
+ _animResetFrame = stackPos(0);
+ return 0;
+}
+
} // end of namespace Kyra
diff --git a/engines/kyra/sequences_hof.cpp b/engines/kyra/sequences_hof.cpp
index 6a170b1127..1c74f48990 100644
--- a/engines/kyra/sequences_hof.cpp
+++ b/engines/kyra/sequences_hof.cpp
@@ -2626,13 +2626,13 @@ void KyraEngine_HoF::seq_init() {
_demoAnimData = _staticres->loadHofShapeAnimDataV1(k2SeqplayShapeAnimData, _itemAnimDataSize);
uint8 *shp = _res->fileData("icons.shp", 0);
uint32 outsize = READ_LE_UINT16(shp + 4);
- _newShapeFiledata = new uint8[outsize];
- Screen::decodeFrame4(shp + 10, _newShapeFiledata, outsize);
+ _animShapeFiledata = new uint8[outsize];
+ Screen::decodeFrame4(shp + 10, _animShapeFiledata, outsize);
delete [] shp;
do {
numShp++;
- addShapeToPool(_screen->getPtrToShape(_newShapeFiledata, numShp), numShp);
+ addShapeToPool(_screen->getPtrToShape(_animShapeFiledata, numShp), numShp);
} while (getShapePtr(numShp));
} else {
MainMenu::StaticData data = {
@@ -2659,8 +2659,8 @@ void KyraEngine_HoF::seq_uninit() {
delete _seqWsa;
_seqWsa = NULL;
- delete [] _newShapeFiledata;
- _newShapeFiledata = 0;
+ delete [] _animShapeFiledata;
+ _animShapeFiledata = 0;
if (_flags.isDemo && !_flags.isTalkie)
_staticres->unloadId(k2SeqplayShapeAnimData);
diff --git a/engines/kyra/sequences_mr.cpp b/engines/kyra/sequences_mr.cpp
index 4db62f597f..8c826e2048 100644
--- a/engines/kyra/sequences_mr.cpp
+++ b/engines/kyra/sequences_mr.cpp
@@ -183,54 +183,6 @@ void KyraEngine_MR::hideGoodConscience() {
setNextIdleAnimTimer();
}
-void KyraEngine_MR::runTemporaryScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload) {
- debugC(9, kDebugLevelMain, "KyraEngine_MR::runTemporaryScript('%s', %d, %d, %d, %d)", filename, allowSkip, resetChar, newShapes, shapeUnload);
- memset(&_temporaryScriptData, 0, sizeof(_temporaryScriptData));
- memset(&_temporaryScriptState, 0, sizeof(_temporaryScriptState));
-
- if (!_emc->load(filename, &_temporaryScriptData, &_opcodesTemporary))
- error("Couldn't load temporary script '%s'", filename);
-
- _emc->init(&_temporaryScriptState, &_temporaryScriptData);
- _emc->start(&_temporaryScriptState, 0);
-
- _newShapeFlag = -1;
-
- if (_newShapeFiledata && newShapes) {
- resetNewShapes(_newShapeCount, _newShapeFiledata);
- _newShapeFiledata = 0;
- _newShapeCount = 0;
- }
-
- while (_emc->isValid(&_temporaryScriptState))
- _emc->run(&_temporaryScriptState);
-
- uint8 *fileData = 0;
-
- if (newShapes)
- _newShapeFiledata = _res->fileData(_newShapeFilename, 0);
-
- fileData = _newShapeFiledata;
-
- if (!fileData) {
- _emc->unload(&_temporaryScriptData);
- return;
- }
-
- if (newShapes)
- _newShapeCount = initNewShapes(fileData);
-
- processNewShapes(allowSkip, resetChar);
-
- if (shapeUnload) {
- resetNewShapes(_newShapeCount, fileData);
- _newShapeCount = 0;
- _newShapeFiledata = 0;
- }
-
- _emc->unload(&_temporaryScriptData);
-}
-
void KyraEngine_MR::eelScript() {
debugC(9, kDebugLevelMain, "KyraEngine_MR::eelScript()");
if (_chatText)
@@ -252,24 +204,24 @@ void KyraEngine_MR::eelScript() {
switch (_characterShapeFile-1) {
case 0:
- runTemporaryScript("EELS01.EMC", 0, 0, 1, 1);
+ runAnimationScript("EELS01.EMC", 0, 0, 1, 1);
break;
case 1:
- runTemporaryScript("EELS02.EMC", 0, 0, 1, 1);
+ runAnimationScript("EELS02.EMC", 0, 0, 1, 1);
break;
case 2:
- runTemporaryScript("EELS03.EMC", 0, 0, 1, 1);
+ runAnimationScript("EELS03.EMC", 0, 0, 1, 1);
break;
case 3:
- runTemporaryScript("EELS04.EMC", 0, 0, 1, 1);
+ runAnimationScript("EELS04.EMC", 0, 0, 1, 1);
break;
default:
resetGameFlag(0x171);
- runTemporaryScript("EELS00.EMC", 0, 0, 1, 1);
+ runAnimationScript("EELS00.EMC", 0, 0, 1, 1);
break;
}
@@ -277,73 +229,16 @@ void KyraEngine_MR::eelScript() {
_screen->showMouse();
}
-int KyraEngine_MR::initNewShapes(uint8 *filedata) {
- debugC(9, kDebugLevelAnimator, "KyraEngine_MR::initNewShapes(%p)", (const void*)filedata);
- const int lastEntry = MIN(_newShapeLastEntry, 41);
+int KyraEngine_MR::initAnimationShapes(uint8 *filedata) {
+ debugC(9, kDebugLevelAnimator, "KyraEngine_MR::initAnimationShapes(%p)", (const void*)filedata);
+ const int lastEntry = MIN(_animShapeLastEntry, 41);
for (int i = 0; i < lastEntry; ++i)
_gameShapes[9+i] = _screen->getPtrToShape(filedata, i);
return lastEntry;
}
-void KyraEngine_MR::processNewShapes(int allowSkip, int resetChar) {
- debugC(9, kDebugLevelAnimator, "KyraEngine_MR::processNewShapes(%d, %d)", allowSkip, resetChar);
- setCharacterAnimDim(_newShapeWidth, _newShapeHeight);
-
- _emc->init(&_temporaryScriptState, &_temporaryScriptData);
- _emc->start(&_temporaryScriptState, 1);
-
- resetSkipFlag();
-
- while (_emc->isValid(&_temporaryScriptState)) {
- _temporaryScriptExecBit = false;
- while (_emc->isValid(&_temporaryScriptState) && !_temporaryScriptExecBit)
- _emc->run(&_temporaryScriptState);
-
- if (_newShapeAnimFrame < 0)
- continue;
-
- _mainCharacter.animFrame = _newShapeAnimFrame + 9;
- updateCharacterAnim(0);
- if (_chatText)
- updateWithText();
- else
- update();
-
- uint32 delayEnd = _system->getMillis() + _newShapeDelay * _tickLength;
-
- while ((!skipFlag() || !allowSkip) && _system->getMillis() < delayEnd) {
- if (_chatText)
- updateWithText();
- else
- update();
-
- delay(10);
- }
-
- if (skipFlag())
- resetSkipFlag();
- }
-
- if (resetChar) {
- if (_newShapeFlag >= 0) {
- _mainCharacter.animFrame = _newShapeFlag + 9;
- updateCharacterAnim(0);
- if (_chatText)
- updateWithText();
- else
- update();
- }
-
- _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing];
- updateCharacterAnim(0);
- }
-
- _newShapeFlag = -1;
- resetCharacterAnimDim();
-}
-
-void KyraEngine_MR::resetNewShapes(int count, uint8 *filedata) {
- debugC(9, kDebugLevelAnimator, "KyraEngine_MR::resetNewShapes(%d, %p)", count, (const void*)filedata);
+void KyraEngine_MR::uninitAnimationShapes(int count, uint8 *filedata) {
+ debugC(9, kDebugLevelAnimator, "KyraEngine_MR::uninitAnimationShapes(%d, %p)", count, (const void*)filedata);
for (int i = 0; i < count; ++i)
_gameShapes[9+i] = 0;
delete [] filedata;
diff --git a/engines/kyra/sequences_v2.cpp b/engines/kyra/sequences_v2.cpp
new file mode 100644
index 0000000000..1530ddd3f0
--- /dev/null
+++ b/engines/kyra/sequences_v2.cpp
@@ -0,0 +1,137 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "kyra/kyra_v2.h"
+#include "kyra/resource.h"
+
+namespace Kyra {
+
+void KyraEngine_v2::runAnimationScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v2::runAnimationScript('%s', %d, %d, %d, %d)", filename, allowSkip, resetChar, newShapes, shapeUnload);
+ memset(&_animationScriptData, 0, sizeof(_animationScriptData));
+ memset(&_animationScriptState, 0, sizeof(_animationScriptState));
+
+ if (!_emc->load(filename, &_animationScriptData, &_opcodesAnimation))
+ error("Couldn't load temporary script '%s'", filename);
+
+ _emc->init(&_animationScriptState, &_animationScriptData);
+ _emc->start(&_animationScriptState, 0);
+
+ _animResetFrame = -1;
+
+ if (_animShapeFiledata && newShapes) {
+ uninitAnimationShapes(_animShapeCount, _animShapeFiledata);
+ _animShapeFiledata = 0;
+ _animShapeCount = 0;
+ }
+
+ while (_emc->isValid(&_animationScriptState))
+ _emc->run(&_animationScriptState);
+
+ uint8 *fileData = 0;
+
+ if (newShapes)
+ _animShapeFiledata = _res->fileData(_animShapeFilename, 0);
+
+ fileData = _animShapeFiledata;
+
+ if (!fileData) {
+ _emc->unload(&_animationScriptData);
+ return;
+ }
+
+ if (newShapes)
+ _animShapeCount = initAnimationShapes(fileData);
+
+ processAnimationScript(allowSkip, resetChar);
+
+ if (shapeUnload) {
+ uninitAnimationShapes(_animShapeCount, fileData);
+ _animShapeCount = 0;
+ _animShapeFiledata = 0;
+ }
+
+ _emc->unload(&_animationScriptData);
+}
+
+void KyraEngine_v2::processAnimationScript(int allowSkip, int resetChar) {
+ debugC(9, kDebugLevelAnimator, "KyraEngine_v2::processAnimationScript(%d, %d)", allowSkip, resetChar);
+ setCharacterAnimDim(_animShapeWidth, _animShapeHeight);
+
+ _emc->init(&_animationScriptState, &_animationScriptData);
+ _emc->start(&_animationScriptState, 1);
+
+ resetSkipFlag();
+
+ while (_emc->isValid(&_animationScriptState)) {
+ _animNeedUpdate = false;
+ while (_emc->isValid(&_animationScriptState) && !_animNeedUpdate)
+ _emc->run(&_animationScriptState);
+
+ if (_animNewFrame < 0)
+ continue;
+
+ _mainCharacter.animFrame = _animNewFrame + _desc.animScriptFrameAdd;
+ updateCharacterAnim(0);
+ if (_chatText)
+ updateWithText();
+ else
+ update();
+
+ uint32 delayEnd = _system->getMillis() + _animDelayTime * _tickLength;
+
+ while ((!skipFlag() || !allowSkip) && _system->getMillis() < delayEnd) {
+ if (_chatText)
+ updateWithText();
+ else
+ update();
+
+ delay(10);
+ }
+
+ if (skipFlag())
+ resetSkipFlag();
+ }
+
+ if (resetChar) {
+ if (_animResetFrame >= 0) {
+ _mainCharacter.animFrame = _animResetFrame + _desc.animScriptFrameAdd;
+ updateCharacterAnim(0);
+ if (_chatText)
+ updateWithText();
+ else
+ update();
+ }
+
+ _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing];
+ updateCharacterAnim(0);
+ }
+
+ _animResetFrame = -1;
+ resetCharacterAnimDim();
+}
+
+} // end of namespace Kyra
+
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index 9c9ced2387..723b7d334e 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -1540,7 +1540,7 @@ const char *KyraEngine_HoF::_scriptLangExt[] = {
"JMC"
};
-const int KyraEngine_HoF::_characterFrameTable[] = {
+const uint8 KyraEngine_HoF::_characterFrameTable[] = {
0x19, 0x09, 0x09, 0x12, 0x12, 0x12, 0x09, 0x09
};
diff --git a/engines/kyra/text_hof.cpp b/engines/kyra/text_hof.cpp
index 9717b23a6a..8def912926 100644
--- a/engines/kyra/text_hof.cpp
+++ b/engines/kyra/text_hof.cpp
@@ -299,16 +299,16 @@ void KyraEngine_HoF::objectChatProcess(const char *script) {
memset(&_chatScriptData, 0, sizeof(_chatScriptData));
memset(&_chatScriptState, 0, sizeof(_chatScriptState));
- _emc->load(script, &_chatScriptData, &_opcodesTemporary);
+ _emc->load(script, &_chatScriptData, &_opcodesAnimation);
_emc->init(&_chatScriptState, &_chatScriptData);
_emc->start(&_chatScriptState, 0);
while (_emc->isValid(&_chatScriptState))
_emc->run(&_chatScriptState);
- _newShapeFilename[2] = _characterShapeFile + '0';
- uint8 *shapeBuffer = _res->fileData(_newShapeFilename, 0);
+ _animShapeFilename[2] = _characterShapeFile + '0';
+ uint8 *shapeBuffer = _res->fileData(_animShapeFilename, 0);
if (shapeBuffer) {
- int shapeCount = initNewShapes(shapeBuffer);
+ int shapeCount = initAnimationShapes(shapeBuffer);
if (_chatVocHigh >= 0) {
playVoice(_chatVocHigh, _chatVocLow);
@@ -317,9 +317,9 @@ void KyraEngine_HoF::objectChatProcess(const char *script) {
objectChatWaitToFinish();
- resetNewShapes(shapeCount, shapeBuffer);
+ uninitAnimationShapes(shapeCount, shapeBuffer);
} else {
- warning("couldn't load file '%s'", _newShapeFilename);
+ warning("couldn't load file '%s'", _animShapeFilename);
}
_emc->unload(&_chatScriptData);
@@ -327,7 +327,7 @@ void KyraEngine_HoF::objectChatProcess(const char *script) {
void KyraEngine_HoF::objectChatWaitToFinish() {
int charAnimFrame = _mainCharacter.animFrame;
- setCharacterAnimDim(_newShapeWidth, _newShapeHeight);
+ setCharacterAnimDim(_animShapeWidth, _animShapeHeight);
_emc->init(&_chatScriptState, &_chatScriptData);
_emc->start(&_chatScriptState, 1);
@@ -340,12 +340,12 @@ void KyraEngine_HoF::objectChatWaitToFinish() {
if (!_emc->isValid(&_chatScriptState))
_emc->start(&_chatScriptState, 1);
- _temporaryScriptExecBit = false;
- while (!_temporaryScriptExecBit && _emc->isValid(&_chatScriptState))
+ _animNeedUpdate = false;
+ while (!_animNeedUpdate && _emc->isValid(&_chatScriptState))
_emc->run(&_chatScriptState);
- int curFrame = _newShapeAnimFrame;
- uint32 delayTime = _newShapeDelay;
+ int curFrame = _animNewFrame;
+ uint32 delayTime = _animDelayTime;
if (!_chatIsNote)
_mainCharacter.animFrame = 33 + curFrame;
diff --git a/engines/kyra/text_mr.cpp b/engines/kyra/text_mr.cpp
index 3e728cf538..b1c2bc9eec 100644
--- a/engines/kyra/text_mr.cpp
+++ b/engines/kyra/text_mr.cpp
@@ -312,7 +312,7 @@ void KyraEngine_MR::objectChatProcess(const char *script) {
memset(&_chatScriptData, 0, sizeof(_chatScriptData));
memset(&_chatScriptState, 0, sizeof(_chatScriptState));
- _emc->load(script, &_chatScriptData, &_opcodesTemporary);
+ _emc->load(script, &_chatScriptData, &_opcodesAnimation);
_emc->init(&_chatScriptState, &_chatScriptData);
_emc->start(&_chatScriptState, 0);
while (_emc->isValid(&_chatScriptState))
@@ -333,7 +333,7 @@ void KyraEngine_MR::objectChatProcess(const char *script) {
void KyraEngine_MR::objectChatWaitToFinish() {
debugC(9, kDebugLevelMain, "KyraEngine_MR::objectChatWaitToFinish()");
int charAnimFrame = _mainCharacter.animFrame;
- setCharacterAnimDim(_newShapeWidth, _newShapeHeight);
+ setCharacterAnimDim(_animShapeWidth, _animShapeHeight);
_emc->init(&_chatScriptState, &_chatScriptData);
_emc->start(&_chatScriptState, 1);
@@ -346,14 +346,14 @@ void KyraEngine_MR::objectChatWaitToFinish() {
if (!_emc->isValid(&_chatScriptState))
_emc->start(&_chatScriptState, 1);
- _temporaryScriptExecBit = false;
- while (!_temporaryScriptExecBit && _emc->isValid(&_chatScriptState)) {
+ _animNeedUpdate = false;
+ while (!_animNeedUpdate && _emc->isValid(&_chatScriptState)) {
musicUpdate(0);
_emc->run(&_chatScriptState);
}
- int curFrame = _newShapeAnimFrame;
- uint32 delayTime = _newShapeDelay;
+ int curFrame = _animNewFrame;
+ uint32 delayTime = _animDelayTime;
_mainCharacter.animFrame = curFrame;
updateCharacterAnim(0);
diff --git a/engines/kyra/timer_hof.cpp b/engines/kyra/timer_hof.cpp
index a96717bdb3..2643ae9b45 100644
--- a/engines/kyra/timer_hof.cpp
+++ b/engines/kyra/timer_hof.cpp
@@ -91,7 +91,7 @@ void KyraEngine_HoF::timerBurnZanthia(int arg) {
_timer->disable(5);
_screen->hideMouse();
snd_playSoundEffect(0x2D);
- runTemporaryScript("_ZANBURN.EMC", 0, 1, 1, 0);
+ runAnimationScript("_ZANBURN.EMC", 0, 1, 1, 0);
_deathHandler = 7;
snd_playWanderScoreViaMap(0x53, 1);
}