KYRA: move HOF sequence player into its own class

(also cleaning up and fixing things while doing that)
This commit is contained in:
athrxx 2012-08-09 18:13:15 +02:00
parent e016e7dfc2
commit 9840744acc
18 changed files with 3045 additions and 2787 deletions

View File

@ -52,13 +52,6 @@ KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEn
_screen = 0;
_text = 0;
_seqProcessedString = 0;
_activeWSA = 0;
_activeText = 0;
_seqWsa = 0;
_sequences = 0;
_sequenceSoundList = 0;
_gamePlayBuffer = 0;
_cCodeBuffer = _optionsBuffer = _chapterBuffer = 0;
@ -89,7 +82,6 @@ KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEn
memset(&_invWsa, 0, sizeof(_invWsa));
_itemAnimDefinition = 0;
_demoAnimData = 0;
_nextAnimItem = 0;
for (int i = 0; i < 15; i++)
@ -136,7 +128,6 @@ KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEn
memset(_cauldronStateTables, 0, sizeof(_cauldronStateTables));
_menuDirectlyToLoad = false;
_menu = 0;
_chatIsNote = false;
memset(&_npcScriptData, 0, sizeof(_npcScriptData));
@ -148,7 +139,6 @@ KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEn
KyraEngine_HoF::~KyraEngine_HoF() {
cleanup();
seq_uninit();
delete _screen;
delete _text;
@ -157,15 +147,6 @@ KyraEngine_HoF::~KyraEngine_HoF() {
_text = 0;
delete _invWsa.wsa;
if (_sequenceSoundList) {
for (int i = 0; i < _sequenceSoundListSize; i++) {
if (_sequenceSoundList[i])
delete[] _sequenceSoundList[i];
}
delete[] _sequenceSoundList;
_sequenceSoundList = NULL;
}
delete[] _dlgBuffer;
for (int i = 0; i < 19; i++)
delete[] _conversationState[i];
@ -179,41 +160,13 @@ KyraEngine_HoF::~KyraEngine_HoF() {
void KyraEngine_HoF::pauseEngineIntern(bool pause) {
KyraEngine_v2::pauseEngineIntern(pause);
seq_pausePlayer(pause);
if (!pause) {
uint32 pausedTime = _system->getMillis() - _pauseStart;
_pauseStart = 0;
// sequence player
//
// Timers in KyraEngine_HoF::seq_cmpFadeFrame() and KyraEngine_HoF::seq_animatedSubFrame()
// have been left out for now. I think we don't need them here.
_seqStartTime += pausedTime;
_seqSubFrameStartTime += pausedTime;
_seqEndTime += pausedTime;
_seqSubFrameEndTimeInternal += pausedTime;
_seqWsaChatTimeout += pausedTime;
_seqWsaChatFrameTimeout += pausedTime;
if (_activeText) {
for (int x = 0; x < 10; x++) {
if (_activeText[x].duration != -1)
_activeText[x].startTime += pausedTime;
}
}
if (_activeWSA) {
for (int x = 0; x < 8; x++) {
if (_activeWSA[x].flags != -1)
_activeWSA[x].nextFrame += pausedTime;
}
}
_nextIdleAnim += pausedTime;
for (int x = 0; x < _itemAnimDefinitionSize; x++)
_activeItemAnim[x].nextFrameTime += pausedTime;
_tim->refreshTimersAfterPause(pausedTime);
}
}
@ -254,13 +207,6 @@ Common::Error KyraEngine_HoF::init() {
if (!_sound->init())
error("Couldn't init sound");
_abortIntroFlag = false;
if (_sequenceStrings) {
for (int i = 0; i < MIN(33, _sequenceStringsSize); i++)
_sequenceStringsDuration[i] = (int) strlen(_sequenceStrings[i]) * 8;
}
// No mouse display in demo
if (_flags.isDemo && !_flags.isTalkie)
return Common::kNoError;
@ -279,28 +225,24 @@ Common::Error KyraEngine_HoF::init() {
}
Common::Error KyraEngine_HoF::go() {
int menuChoice = 0;
if (_gameToLoad == -1) {
if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)
seq_showStarcraftLogo();
if (_flags.isDemo && !_flags.isTalkie) {
#ifdef ENABLE_LOL
if (_flags.gameID == GI_LOL)
seq_playSequences(kSequenceLoLDemoScene1, kSequenceLoLDemoScene6);
else
#endif // ENABLE_LOL
seq_playSequences(kSequenceDemoVirgin, kSequenceDemoFisher);
_menuChoice = 4;
menuChoice = seq_playDemo();
} else {
seq_playSequences(kSequenceVirgin, kSequenceZanfaun);
menuChoice = seq_playIntro();
}
} else {
_menuChoice = 1;
menuChoice = 1;
}
_res->unloadAllPakFiles();
if (_menuChoice != 4) {
if (menuChoice != 4) {
// load just the pak files needed for ingame
_staticres->loadStaticResourceFile();
@ -317,17 +259,17 @@ Common::Error KyraEngine_HoF::go() {
}
}
_menuDirectlyToLoad = (_menuChoice == 3) ? true : false;
_menuDirectlyToLoad = (menuChoice == 3) ? true : false;
_menuDirectlyToLoad &= saveFileLoadable(0);
if (_menuChoice & 1) {
if (menuChoice & 1) {
startup();
if (!shouldQuit())
runLoop();
cleanup();
if (_showOutro)
seq_playSequences(kSequenceFunters, kSequenceFrash);
seq_playOutro();
}
return Common::kNoError;

View File

@ -35,158 +35,13 @@
namespace Kyra {
enum Sequences {
kSequenceVirgin = 0,
kSequenceWestwood,
kSequenceTitle,
kSequenceOverview,
kSequenceLibrary,
kSequenceHand,
kSequencePoint,
kSequenceZanfaun,
kSequenceFunters,
kSequenceFerb,
kSequenceFish,
kSequenceFheep,
kSequenceFarmer,
kSequenceFuards,
kSequenceFirates,
kSequenceFrash,
kSequenceArraySize
};
enum NestedSequences {
kSequenceFiggle = 0,
kSequenceOver1,
kSequenceOver2,
kSequenceForest,
kSequenceDragon,
kSequenceDarm,
kSequenceLibrary2,
kSequenceLibrary3,
kSequenceMarco,
kSequenceHand1a,
kSequenceHand1b,
kSequenceHand1c,
kSequenceHand2,
kSequenceHand3,
kSequenceHand4
};
enum SequencesDemo {
kSequenceDemoVirgin = 0,
kSequenceDemoWestwood,
kSequenceDemoTitle,
kSequenceDemoHill,
kSequenceDemoOuthome,
kSequenceDemoWharf,
kSequenceDemoDinob,
kSequenceDemoFisher
};
enum NestedSequencesDemo {
kSequenceDemoWharf2 = 0,
kSequenceDemoDinob2,
kSequenceDemoWater,
kSequenceDemoBail,
kSequenceDemoDig
};
#ifdef ENABLE_LOL
enum SequencesLoLDemo {
kSequenceLoLDemoScene1 = 0,
kSequenceLoLDemoText1,
kSequenceLoLDemoScene2,
kSequenceLoLDemoText2,
kSequenceLoLDemoScene3,
kSequenceLoLDemoText3,
kSequenceLoLDemoScene4,
kSequenceLoLDemoText4,
kSequenceLoLDemoScene5,
kSequenceLoLDemoText5,
kSequenceLoLDemoScene6
};
#endif // ENABLE_LOL
class WSAMovie_v2;
class KyraEngine_HoF;
//class WSAMovie_v2;
//class KyraEngine_HoF;
class TextDisplayer_HoF;
class SeqPlayer_HOF;
struct TIM;
typedef int (KyraEngine_HoF::*SeqProc)(WSAMovie_v2 *, int, int, int);
struct ActiveWSA {
SeqProc callback;
WSAMovie_v2 *movie;
const FrameControl *control;
int16 flags;
uint16 startFrame;
uint16 endFrame;
uint16 frameDelay;
uint32 nextFrame;
uint16 currentFrame;
uint16 lastFrame;
uint16 x;
uint16 y;
uint16 startupCommand;
uint16 finalCommand;
};
struct ActiveText {
uint16 strIndex;
uint16 x;
uint16 y;
uint16 width;
int32 duration;
uint32 startTime;
int16 textcolor;
};
struct Sequence {
const char *wsaFile;
const char *cpsFile;
uint16 flags;
uint8 startupCommand;
uint8 finalCommand;
int16 stringIndex1;
int16 stringIndex2;
uint16 startFrame;
uint16 numFrames;
uint16 frameDelay;
uint16 xPos;
uint16 yPos;
uint16 duration;
};
struct NestedSequence {
const char *wsaFile;
const FrameControl *wsaControl;
uint16 flags;
uint16 startframe;
uint16 endFrame;
uint16 frameDelay;
uint16 x;
uint16 y;
uint16 startupCommand;
uint16 finalCommand;
};
struct HofSeqData {
const Sequence *seq;
int numSeq;
const NestedSequence *seqn;
int numSeqn;
};
struct ItemAnimData_v1 {
int16 itemIndex;
uint16 y;
const uint16 *frames;
};
class KyraEngine_HoF : public KyraEngine_v2 {
friend class Debugger_HoF;
friend class TextDisplayer_HoF;
@ -202,98 +57,19 @@ public:
GUI *gui() const { return _gui; }
virtual TextDisplayer *text() { return _text; }
int language() const { return _lang; }
const AudioDataStruct *soundData(int index) { return &_soundData[index]; }
protected:
static const EngineDesc _hofEngineDesc;
// intro/outro
void seq_playSequences(int startSeq, int endSeq = -1);
int seq_introWestwood(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introTitle(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introOverview(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introLibrary(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introHand(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introPoint(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introZanfaun(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introOver1(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introOver2(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introForest(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introDragon(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introDarm(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introLibrary2(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introMarco(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introHand1a(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introHand1b(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introHand1c(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introHand2(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_introHand3(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_finaleFunters(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_finaleFerb(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_finaleFish(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_finaleFheep(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_finaleFarmer(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_finaleFuards(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_finaleFirates(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_finaleFrash(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_finaleFiggle(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_demoVirgin(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_demoWestwood(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_demoTitle(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_demoHill(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_demoOuthome(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_demoWharf(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_demoDinob(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_demoFisher(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_demoWharf2(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_demoDinob2(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_demoWater(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_demoBail(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_demoDig(WSAMovie_v2 *wsaObj, int x, int y, int frm);
#ifdef ENABLE_LOL
int seq_lolDemoScene1(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_lolDemoScene2(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_lolDemoScene3(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_lolDemoScene4(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_lolDemoScene5(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_lolDemoText5(WSAMovie_v2 *wsaObj, int x, int y, int frm);
int seq_lolDemoScene6(WSAMovie_v2 *wsaObj, int x, int y, int frm);
#endif // ENABLE_LOL
void seq_sequenceCommand(int command);
void seq_loadNestedSequence(int wsaNum, int seqNum);
void seq_nestedSequenceFrame(int command, int wsaNum);
void seq_animatedSubFrame(int srcPage, int dstPage, int delaytime,
int steps, int x, int y, int w, int h, int openClose, int directionFlags);
bool seq_processNextSubFrame(int wsaNum);
void seq_resetActiveWSA(int wsaNum);
void seq_unloadWSA(int wsaNum);
void seq_processWSAs();
void seq_cmpFadeFrame(const char *cmpFile);
void seq_playTalkText(uint8 chatNum);
void seq_resetAllTextEntries();
uint32 seq_activeTextsTimeLeft();
void seq_waitForTextsTimeout();
int seq_setTextEntry(uint16 strIndex, uint16 posX, uint16 posY, int duration, uint16 width);
void seq_processText();
char *seq_preprocessString(const char *str, int width);
void seq_printCreditsString(uint16 strIndex, int x, int y, const uint8 *colorMap, uint8 textcolor);
void seq_playWsaSyncDialogue(uint16 strIndex, uint16 vocIndex, int textColor, int x, int y, int width,
WSAMovie_v2 * wsa, int firstframe, int lastframe, int wsaXpos, int wsaYpos);
void seq_finaleActorScreen();
void seq_displayScrollText(uint8 *data, const ScreenDim *d, int tempPage1, int tempPage2, int speed, int step, Screen::FontId fid1, Screen::FontId fid2, const uint8 *shapeData = 0, const char *const *specialData = 0);
void seq_scrollPage(int bottom, int top);
void seq_showStarcraftLogo();
MainMenu *_menu;
int seq_playIntro();
int seq_playOutro();
int seq_playDemo();
void seq_init();
void seq_uninit();
void seq_pausePlayer(bool toggle);
Common::Error init();
Common::Error go();
@ -312,6 +88,7 @@ protected:
static const int _pcSpkSfxMapSize;
AudioDataStruct _soundData[3];
protected:
// game initialization
void startup();
@ -841,11 +618,11 @@ protected:
bool _chatAltFlag;
// sequence player
ActiveWSA *_activeWSA;
/* ActiveWSA *_activeWSA;
ActiveText *_activeText;
const char * const *_sequencePakList;
int _sequencePakListSize;
*/
/*const char * const *_sequencePakList;
int _sequencePakListSize;*/
const char * const *_ingamePakList;
int _ingamePakListSize;
@ -861,34 +638,33 @@ protected:
int _cdaTrackTableIngameSize;
const uint8 *_cdaTrackTableFinale;
int _cdaTrackTableFinaleSize;
const char * const *_sequenceSoundList;
int _sequenceSoundListSize;
const char * const *_ingameSoundList;
int _ingameSoundListSize;
const uint16 *_ingameSoundIndex;
int _ingameSoundIndexSize;
const char * const *_sequenceStrings;
int _sequenceStringsSize;
const uint16 *_ingameTalkObjIndex;
int _ingameTalkObjIndexSize;
const char * const *_ingameTimJpStr;
int _ingameTimJpStrSize;
const HofSeqData *_sequences;
const ItemAnimDefinition *_itemAnimDefinition;
int _itemAnimDefinitionSize;
/*const HofSeqData *_sequences;
const ItemAnimData_v1 *_demoAnimData;
int _demoAnimSize;
int _sequenceStringsDuration[33];
int _sequenceStringsDuration[33];*/
static const uint8 _seqTextColorPresets[];
/* static const uint8 _seqTextColorPresets[];
char *_seqProcessedString;
WSAMovie_v2 *_seqWsa;
bool _abortIntroFlag;
int _menuChoice;
int _menuChoice;*/
uint32 _seqFrameDelay;
/*uint32 _seqFrameDelay;
uint32 _seqStartTime;
uint32 _seqSubFrameStartTime;
uint32 _seqEndTime;
@ -902,10 +678,7 @@ protected:
bool _seqSpecialFlag;
bool _seqSubframePlaying;
uint8 _seqTextColor[2];
uint8 _seqTextColorMap[16];
const SeqProc *_callbackS;
const SeqProc *_callbackN;
uint8 _seqTextColorMap[16];*/
static const uint8 _rainbowRoomData[];

View File

@ -134,6 +134,8 @@ public:
const uint8 * const *palTable1() { return &_specialPalettes[0]; }
const uint8 * const *palTable2() { return &_specialPalettes[29]; }
const AudioDataStruct *soundData(int index) { return &_soundData[index]; }
protected:
virtual Common::Error go();
virtual Common::Error init();

View File

@ -172,19 +172,6 @@ Common::Error KyraEngine_v1::init() {
assert(_res);
_res->reset();
if (_flags.isDemo) {
// HACK: check whether this is the HOF demo or the LOL demo.
// The LOL demo needs to be detected and run as KyraEngine_HoF,
// but the static resource loader and the sequence player will
// need correct IDs.
if (_res->exists("scene1.cps"))
#ifdef ENABLE_LOL
_flags.gameID = GI_LOL;
#else
error("Lands of Lore demo is not supported in this build");
#endif // !ENABLE_LOL
}
_staticres = new StaticResource(this);
assert(_staticres);
if (!_staticres->init())

View File

@ -242,6 +242,8 @@ public:
virtual bool snd_voiceIsPlaying();
virtual void snd_stopVoice();
virtual const AudioDataStruct *soundData(int index) { return 0; }
// delay functionallity
virtual void delayUntil(uint32 timestamp, bool updateGameTimers = false, bool update = false, bool isMainLoop = false);
virtual void delay(uint32 millis, bool update = false, bool isMainLoop = false);

View File

@ -499,6 +499,11 @@ void LoLEngine::initKeymap() {
#endif
}
void LoLEngine::pauseEngineIntern(bool pause) {
KyraEngine_v1::pauseEngineIntern(pause);
pauseDemoPlayer(pause);
}
Common::Error LoLEngine::go() {
int action = -1;
@ -2361,7 +2366,7 @@ int LoLEngine::processMagicIce(int charNum, int spellLevel) {
playSpellAnimation(0, 0, 0, 2, 0, 0, 0, s.getData(), tpal.getData(), 40, false);
_screen->fadePaletteStep(s.getData(), tpal.getData(), _system->getMillis(), _tickLength);
_screen->timedPaletteFadeStep(s.getData(), tpal.getData(), _system->getMillis(), _tickLength);
if (mov->opened()) {
int r = true;
if (spellLevel > 2) {
@ -2430,7 +2435,7 @@ int LoLEngine::processMagicIce(int charNum, int spellLevel) {
playSpellAnimation(0, 0, 0, 2, 0, 0, 0, tpal.getData(), swampCol.getData(), 40, 0);
_screen->fadePaletteStep(tpal.getData(), swampCol.getData(), _system->getMillis(), _tickLength);
_screen->timedPaletteFadeStep(tpal.getData(), swampCol.getData(), _system->getMillis(), _tickLength);
if (breakWall)
breakIceWall(tpal.getData(), swampCol.getData());
@ -2886,7 +2891,7 @@ int LoLEngine::processMagicVaelansCube() {
uint32 endTime = _system->getMillis() + 70 * _tickLength;
while (_system->getMillis() < endTime) {
_screen->fadePaletteStep(tmpPal1, tmpPal2, _system->getMillis() - ctime, 70 * _tickLength);
_screen->timedPaletteFadeStep(tmpPal1, tmpPal2, _system->getMillis() - ctime, 70 * _tickLength);
updateInput();
}
@ -2915,7 +2920,7 @@ int LoLEngine::processMagicVaelansCube() {
endTime = _system->getMillis() + 70 * _tickLength;
while (_system->getMillis() < endTime) {
_screen->fadePaletteStep(tmpPal2, tmpPal1, _system->getMillis() - ctime, 70 * _tickLength);
_screen->timedPaletteFadeStep(tmpPal2, tmpPal1, _system->getMillis() - ctime, 70 * _tickLength);
updateInput();
}
@ -3244,7 +3249,7 @@ void LoLEngine::playSpellAnimation(WSAMovie_v2 *mov, int firstFrame, int lastFra
continue;
}
if (!_screen->fadePaletteStep(pal1, pal2, _system->getMillis() - startTime, _tickLength * fadeDelay) && !mov)
if (!_screen->timedPaletteFadeStep(pal1, pal2, _system->getMillis() - startTime, _tickLength * fadeDelay) && !mov)
return;
if (del) {

View File

@ -270,9 +270,13 @@ public:
virtual void initKeymap();
void pauseEngineIntern(bool pause);
Screen *screen();
GUI *gui() const;
const AudioDataStruct *soundData(int index) { return &_soundData[index]; }
private:
Screen_LoL *_screen;
GUI_LoL *_gui;
@ -400,6 +404,10 @@ private:
static const int _outroMonsterScaleTableX[];
static const int _outroMonsterScaleTableY[];
// Non-interactive demo
int playDemo();
void pauseDemoPlayer(bool toggle);
// timers
void setupTimers();

View File

@ -742,6 +742,8 @@ enum KyraResources {
struct Shape;
struct Room;
struct AmigaSfxTable;
struct HoFSeqData;
struct HoFSeqItemAnimData;
class StaticResource {
public:
@ -760,8 +762,8 @@ public:
const Shape *loadShapeTable(int id, int &entries);
const AmigaSfxTable *loadAmigaSfxTable(int id, int &entries);
const Room *loadRoomTable(int id, int &entries);
const HofSeqData *loadHofSequenceData(int id, int &entries);
const ItemAnimData_v1 *loadShapeAnimData_v1(int id, int &entries);
const HoFSeqData *loadHoFSequenceData(int id, int &entries);
const HoFSeqItemAnimData *loadHoFSeqItemAnimData(int id, int &entries);
const ItemAnimDefinition *loadItemAnimDefinition(int id, int &entries);
#if defined(ENABLE_EOB) || defined(ENABLE_LOL)
const uint16 *loadRawDataBe16(int id, int &entries);
@ -803,8 +805,8 @@ private:
bool loadShapeTable(Common::SeekableReadStream &stream, void *&ptr, int &size);
bool loadAmigaSfxTable(Common::SeekableReadStream &stream, void *&ptr, int &size);
bool loadRoomTable(Common::SeekableReadStream &stream, void *&ptr, int &size);
bool loadHofSequenceData(Common::SeekableReadStream &stream, void *&ptr, int &size);
bool loadShapeAnimData_v1(Common::SeekableReadStream &stream, void *&ptr, int &size);
bool loadHoFSequenceData(Common::SeekableReadStream &stream, void *&ptr, int &size);
bool loadHoFSeqItemAnimData(Common::SeekableReadStream &stream, void *&ptr, int &size);
bool loadItemAnimDefinition(Common::SeekableReadStream &stream, void *&ptr, int &size);
#if defined(ENABLE_EOB) || defined(ENABLE_LOL)
bool loadRawDataBe16(Common::SeekableReadStream &stream, void *&ptr, int &size);
@ -829,8 +831,8 @@ private:
void freeShapeTable(void *&ptr, int &size);
void freeAmigaSfxTable(void *&ptr, int &size);
void freeRoomTable(void *&ptr, int &size);
void freeHofSequenceData(void *&ptr, int &size);
void freeHofShapeAnimDataV1(void *&ptr, int &size);
void freeHoFSequenceData(void *&ptr, int &size);
void freeHoFSeqItemAnimData(void *&ptr, int &size);
void freeItemAnimDefinition(void *&ptr, int &size);
#if defined(ENABLE_EOB) || defined(ENABLE_LOL)
void freeRawDataBe16(void *&ptr, int &size);
@ -857,7 +859,7 @@ private:
kAmigaSfxTable = 4,
k2SeqData = 5,
k2ShpAnimDataV1 = 6,
k2SeqItemAnimData = 6,
k2ItemAnimDefinition = 7,
kLoLCharData = 8,

View File

@ -1183,11 +1183,11 @@ void LoLEngine::processGasExplosion(int soundId) {
p2[i * 3] = 0x3f;
uint32 ctime = _system->getMillis();
while (_screen->fadePaletteStep(_screen->getPalette(0).getData(), p2, _system->getMillis() - ctime, 10))
while (_screen->timedPaletteFadeStep(_screen->getPalette(0).getData(), p2, _system->getMillis() - ctime, 10))
updateInput();
ctime = _system->getMillis();
while (_screen->fadePaletteStep(p2, _screen->getPalette(0).getData(), _system->getMillis() - ctime, 50))
while (_screen->timedPaletteFadeStep(p2, _screen->getPalette(0).getData(), _system->getMillis() - ctime, 50))
updateInput();
}

View File

@ -93,12 +93,6 @@ void Screen_HoF::cmpFadeFrameStep(int srcPage, int srcW, int srcH, int srcX, int
}
}
void Screen_HoF::copyPageMemory(int srcPage, int srcPos, int dstPage, int dstPos, int numBytes) {
const uint8 *src = getPagePtr(srcPage) + srcPos;
uint8 *dst = getPagePtr(dstPage) + dstPos;
memcpy(dst, src, numBytes);
}
void Screen_HoF::copyRegionEx(int srcPage, int srcW, int srcH, int dstPage, int dstX, int dstY, int dstW, int dstH, const ScreenDim *dim, bool flag) {
int x0 = dim->sx << 3;
int y0 = dim->sy;

View File

@ -37,7 +37,7 @@ public:
// sequence player
void generateGrayOverlay(const Palette &pal, uint8 *grayOverlay, int factor, int addR, int addG, int addB, int lastColor, bool flag);
void cmpFadeFrameStep(int srcPage, int srcW, int srcH, int srcX, int srcY, int dstPage, int dstW, int dstH, int dstX, int dstY, int cmpW, int cmpH, int cmpPage);
void copyPageMemory(int srcPage, int srcPos, int dstPage, int dstPos, int numBytes);
void copyRegionEx(int srcPage, int srcW, int srcH, int dstPage, int dstX,int dstY, int dstW, int dstH, const ScreenDim *d, bool flag = false);
private:
KyraEngine_HoF *_vm;

View File

@ -808,34 +808,6 @@ bool Screen_LoL::fadeColor(int dstColorIndex, int srcColorIndex, uint32 elapsedT
return res;
}
bool Screen_LoL::fadePaletteStep(uint8 *pal1, uint8 *pal2, uint32 elapsedTime, uint32 targetTime) {
Palette &p1 = getPalette(1);
bool res = false;
for (int i = 0; i < p1.getNumColors() * 3; i++) {
uint8 out = 0;
if (elapsedTime < targetTime) {
int32 d = ((pal2[i] & 0x3f) - (pal1[i] & 0x3f));
if (d)
res = true;
int32 val = ((((d << 8) / (int32)targetTime) * (int32)elapsedTime) >> 8);
out = ((pal1[i] & 0x3f) + (int8)val);
} else {
out = p1[i] = (pal2[i] & 0x3f);
res = false;
}
(*_internFadePalette)[i] = out;
}
setScreenPalette(*_internFadePalette);
updateScreen();
return res;
}
Palette **Screen_LoL::generateFadeTable(Palette **dst, Palette *src1, Palette *src2, int numTabs) {
int len = _use16ColorMode ? 48 : 768;
if (!src1)

View File

@ -65,7 +65,6 @@ public:
void loadSpecialColors(Palette &dst);
void copyColor(int dstColorIndex, int srcColorIndex);
bool fadeColor(int dstColorIndex, int srcColorIndex, uint32 elapsedTicks, uint32 totalTicks);
bool fadePaletteStep(uint8 *pal1, uint8 *pal2, uint32 elapsedTime, uint32 targetTime);
Palette **generateFadeTable(Palette **dst, Palette *src1, Palette *src2, int numTabs);
void generateGrayOverlay(const Palette &Pal, uint8 *grayOverlay, int factor, int addR, int addG, int addB, int lastColor, bool skipSpecialColors);

View File

@ -162,6 +162,34 @@ void Screen_v2::getFadeParams(const Palette &pal, int delay, int &delayInc, int
}
}
bool Screen_v2::timedPaletteFadeStep(uint8 *pal1, uint8 *pal2, uint32 elapsedTime, uint32 totalTime) {
Palette &p1 = getPalette(1);
bool res = false;
for (int i = 0; i < p1.getNumColors() * 3; i++) {
uint8 out = 0;
if (elapsedTime < totalTime) {
int32 d = ((pal2[i] & 0x3f) - (pal1[i] & 0x3f));
if (d)
res = true;
int32 val = ((((d << 8) / (int32)totalTime) * (int32)elapsedTime) >> 8);
out = ((pal1[i] & 0x3f) + (int8)val);
} else {
out = p1[i] = (pal2[i] & 0x3f);
res = false;
}
(*_internFadePalette)[i] = out;
}
setScreenPalette(*_internFadePalette);
updateScreen();
return res;
}
const uint8 *Screen_v2::getPtrToShape(const uint8 *shpFile, int shape) {
uint16 shapes = READ_LE_UINT16(shpFile);
@ -322,6 +350,12 @@ void Screen_v2::wsaFrameAnimationStep(int x1, int y1, int x2, int y2,
addDirtyRect(x2, y2, w2, h2);
}
void Screen_v2::copyPageMemory(int srcPage, int srcPos, int dstPage, int dstPos, int numBytes) {
const uint8 *src = getPagePtr(srcPage) + srcPos;
uint8 *dst = getPagePtr(dstPage) + dstPos;
memcpy(dst, src, numBytes);
}
bool Screen_v2::calcBounds(int w0, int h0, int &x1, int &y1, int &w1, int &h1, int &x2, int &y2, int &w2) {
x2 = 0;
y2 = 0;

View File

@ -43,6 +43,8 @@ public:
virtual void getFadeParams(const Palette &pal, int delay, int &delayInc, int &diff);
bool timedPaletteFadeStep(uint8 *pal1, uint8 *pal2, uint32 elapsedTime, uint32 totalTime);
// shape handling
uint8 *getPtrToShape(uint8 *shpFile, int shape);
const uint8 *getPtrToShape(const uint8 *shpFile, int shape);
@ -66,6 +68,9 @@ public:
// special WSA handling
void wsaFrameAnimationStep(int x1, int y1, int x2, int y2, int w1, int h1, int w2, int h2, int srcPage, int dstPage, int dim);
// used in non-interactive HoF/LoL demos
void copyPageMemory(int srcPage, int srcPos, int dstPage, int dstPos, int numBytes);
protected:
uint8 *_wsaFrameAnimBuffer;
};

File diff suppressed because it is too large Load Diff

View File

@ -36,10 +36,15 @@ namespace Kyra {
#pragma mark - Intro
int LoLEngine::processPrologue() {
setupPrologueData(true);
if (!saveFileLoadable(0) || _flags.isDemo)
showIntro();
// There are two non-interactive demos (one which plays the intro and another one) which plays a number of specific scenes.
// We try to identify the latter one by looking for a specific file.
if (_flags.isDemo && _res->exists("scene1.cps")) {
return playDemo();
} else {
setupPrologueData(true);
if (!saveFileLoadable(0) || _flags.isDemo)
showIntro();
}
if (_flags.isDemo) {
_screen->fadePalette(_screen->getPalette(1), 30, 0);

View File

@ -31,6 +31,7 @@
#include "kyra/gui_lok.h"
#include "kyra/gui_hof.h"
#include "kyra/gui_mr.h"
#include "kyra/sequences_hof.h"
#include "kyra/sound_intern.h"
#include "common/endian.h"
@ -245,8 +246,8 @@ bool StaticResource::init() {
{ kAmigaSfxTable, proc(loadAmigaSfxTable), proc(freeAmigaSfxTable) },
{ kRawData, proc(loadRawData), proc(freeRawData) },
{ k2SeqData, proc(loadHofSequenceData), proc(freeHofSequenceData) },
{ k2ShpAnimDataV1, proc(loadShapeAnimData_v1), proc(freeHofShapeAnimDataV1) },
{ k2SeqData, proc(loadHoFSequenceData), proc(freeHoFSequenceData) },
{ k2SeqItemAnimData, proc(loadHoFSeqItemAnimData), proc(freeHoFSeqItemAnimData) },
{ k2ItemAnimDefinition, proc(loadItemAnimDefinition), proc(freeItemAnimDefinition) },
#ifdef ENABLE_LOL
@ -308,12 +309,12 @@ const Room *StaticResource::loadRoomTable(int id, int &entries) {
return (const Room *)getData(id, StaticResource::kRoomList, entries);
}
const HofSeqData *StaticResource::loadHofSequenceData(int id, int &entries) {
return (const HofSeqData *)getData(id, k2SeqData, entries);
const HoFSeqData *StaticResource::loadHoFSequenceData(int id, int &entries) {
return (const HoFSeqData *)getData(id, k2SeqData, entries);
}
const ItemAnimData_v1 *StaticResource::loadShapeAnimData_v1(int id, int &entries) {
return (const ItemAnimData_v1 *)getData(id, k2ShpAnimDataV1, entries);
const HoFSeqItemAnimData *StaticResource::loadHoFSeqItemAnimData(int id, int &entries) {
return (const HoFSeqItemAnimData *)getData(id, k2SeqItemAnimData, entries);
}
const ItemAnimDefinition *StaticResource::loadItemAnimDefinition(int id, int &entries) {
@ -513,12 +514,12 @@ bool StaticResource::loadRoomTable(Common::SeekableReadStream &stream, void *&pt
return true;
}
bool StaticResource::loadHofSequenceData(Common::SeekableReadStream &stream, void *&ptr, int &size) {
bool StaticResource::loadHoFSequenceData(Common::SeekableReadStream &stream, void *&ptr, int &size) {
int numSeq = stream.readUint16BE();
uint32 offset = 2;
Sequence *tmp_s = new Sequence[numSeq];
HoFSequence *tmp_s = new HoFSequence[numSeq];
size = sizeof(HofSeqData) + numSeq * (sizeof(Sequence) + 28);
size = sizeof(HoFSeqData) + numSeq * (sizeof(HoFSequence) + 28);
for (int i = 0; i < numSeq; i++) {
stream.seek(offset, SEEK_SET); offset += 2;
@ -529,22 +530,22 @@ bool StaticResource::loadHofSequenceData(Common::SeekableReadStream &stream, voi
stream.read(const_cast<char *>(tmp_s[i].wsaFile), 14);
tmp_s[i].cpsFile = new char[14];
stream.read(const_cast<char *>(tmp_s[i].cpsFile), 14);
tmp_s[i].startupCommand = stream.readByte();
tmp_s[i].finalCommand = stream.readByte();
tmp_s[i].fadeInTransitionType = stream.readByte();
tmp_s[i].fadeOutTransitionType = stream.readByte();
tmp_s[i].stringIndex1 = stream.readUint16BE();
tmp_s[i].stringIndex2 = stream.readUint16BE();
tmp_s[i].startFrame = stream.readUint16BE();
tmp_s[i].numFrames = stream.readUint16BE();
tmp_s[i].frameDelay = stream.readUint16BE();
tmp_s[i].duration = stream.readUint16BE();
tmp_s[i].xPos = stream.readUint16BE();
tmp_s[i].yPos = stream.readUint16BE();
tmp_s[i].duration = stream.readUint16BE();
tmp_s[i].timeout = stream.readUint16BE();
}
stream.seek(offset, SEEK_SET); offset += 2;
int numSeqN = stream.readUint16BE();
NestedSequence *tmp_n = new NestedSequence[numSeqN];
size += (numSeqN * (sizeof(NestedSequence) + 14));
HoFNestedSequence *tmp_n = new HoFNestedSequence[numSeqN];
size += (numSeqN * (sizeof(HoFNestedSequence) + 14));
for (int i = 0; i < numSeqN; i++) {
stream.seek(offset, SEEK_SET); offset += 2;
@ -559,8 +560,8 @@ bool StaticResource::loadHofSequenceData(Common::SeekableReadStream &stream, voi
tmp_n[i].x = stream.readUint16BE();
tmp_n[i].y = stream.readUint16BE();
uint16 ctrlOffs = stream.readUint16BE();
tmp_n[i].startupCommand = stream.readUint16BE();
tmp_n[i].finalCommand = stream.readUint16BE();
tmp_n[i].fadeInTransitionType = stream.readUint16BE();
tmp_n[i].fadeOutTransitionType = stream.readUint16BE();
if (ctrlOffs) {
stream.seek(ctrlOffs, SEEK_SET);
@ -580,21 +581,21 @@ bool StaticResource::loadHofSequenceData(Common::SeekableReadStream &stream, voi
}
}
HofSeqData *loadTo = new HofSeqData;
HoFSeqData *loadTo = new HoFSeqData;
assert(loadTo);
loadTo->seq = tmp_s;
loadTo->seqn = tmp_n;
loadTo->nestedSeq = tmp_n;
loadTo->numSeq = numSeq;
loadTo->numSeqn = numSeqN;
loadTo->numNestedSeq = numSeqN;
ptr = loadTo;
return true;
}
bool StaticResource::loadShapeAnimData_v1(Common::SeekableReadStream &stream, void *&ptr, int &size) {
bool StaticResource::loadHoFSeqItemAnimData(Common::SeekableReadStream &stream, void *&ptr, int &size) {
size = stream.readByte();
ItemAnimData_v1 *loadTo = new ItemAnimData_v1[size];
HoFSeqItemAnimData *loadTo = new HoFSeqItemAnimData[size];
assert(loadTo);
for (int i = 0; i < size; i++) {
@ -670,8 +671,8 @@ void StaticResource::freeRoomTable(void *&ptr, int &size) {
size = 0;
}
void StaticResource::freeHofSequenceData(void *&ptr, int &size) {
HofSeqData *h = (HofSeqData *)ptr;
void StaticResource::freeHoFSequenceData(void *&ptr, int &size) {
HoFSeqData *h = (HoFSeqData *)ptr;
for (int i = 0; i < h->numSeq; i++) {
delete[] h->seq[i].wsaFile;
@ -679,19 +680,19 @@ void StaticResource::freeHofSequenceData(void *&ptr, int &size) {
}
delete[] h->seq;
for (int i = 0; i < h->numSeqn; i++) {
delete[] h->seqn[i].wsaFile;
delete[] h->seqn[i].wsaControl;
for (int i = 0; i < h->numNestedSeq; i++) {
delete[] h->nestedSeq[i].wsaFile;
delete[] h->nestedSeq[i].wsaControl;
}
delete[] h->seqn;
delete[] h->nestedSeq;
delete h;
ptr = 0;
size = 0;
}
void StaticResource::freeHofShapeAnimDataV1(void *&ptr, int &size) {
ItemAnimData_v1 *d = (ItemAnimData_v1 *)ptr;
void StaticResource::freeHoFSeqItemAnimData(void *&ptr, int &size) {
HoFSeqItemAnimData *d = (HoFSeqItemAnimData *)ptr;
for (int i = 0; i < size; i++)
delete[] d[i].frames;
delete[] d;
@ -994,9 +995,7 @@ void KyraEngine_LoK::loadMainScreen(int page) {
void KyraEngine_HoF::initStaticResource() {
int tmpSize = 0;
_sequencePakList = _staticres->loadStrings(k2SeqplayPakFiles, _sequencePakListSize);
_ingamePakList = _staticres->loadStrings(k2IngamePakFiles, _ingamePakListSize);
_sequenceStrings = _staticres->loadStrings(k2SeqplayStrings, _sequenceStringsSize);
_ingameSoundList = _staticres->loadStrings(k2IngameSfxFiles, _ingameSoundListSize);
_ingameSoundIndex = (const uint16 *)_staticres->loadRawData(k2IngameSfxIndex, _ingameSoundIndexSize);
_musicFileListIntro = _staticres->loadStrings(k2SeqplayIntroTracks, _musicFileListIntroSize);
@ -1009,33 +1008,6 @@ void KyraEngine_HoF::initStaticResource() {
_ingameTimJpStr = _staticres->loadStrings(k2IngameTimJpStrings, _ingameTimJpStrSize);
_itemAnimDefinition = _staticres->loadItemAnimDefinition(k2IngameShapeAnimData, _itemAnimDefinitionSize);
// replace sequence talkie files with localized versions
const char *const *seqSoundList = _staticres->loadStrings(k2SeqplaySfxFiles, _sequenceSoundListSize);
const char *const *tlkfiles = _staticres->loadStrings(k2SeqplayTlkFiles, tmpSize);
char **tmpSndLst = new char *[_sequenceSoundListSize];
for (int i = 0; i < _sequenceSoundListSize; i++) {
const int len = strlen(seqSoundList[i]);
tmpSndLst[i] = new char[len + 1];
tmpSndLst[i][0] = 0;
if (tlkfiles && len > 1) {
for (int ii = 0; ii < tmpSize; ii++) {
if (strlen(tlkfiles[ii]) > 1 && !scumm_stricmp(&seqSoundList[i][1], &tlkfiles[ii][1]))
strcpy(tmpSndLst[i], tlkfiles[ii]);
}
}
if (tmpSndLst[i][0] == 0)
strcpy(tmpSndLst[i], seqSoundList[i]);
}
tlkfiles = seqSoundList = 0;
_staticres->unloadId(k2SeqplayTlkFiles);
_staticres->unloadId(k2SeqplaySfxFiles);
_sequenceSoundList = tmpSndLst;
// assign music data
static const char *const fmtMusicFileListIntro[] = { "intro%d.twn" };
static const char *const fmtMusicFileListFinale[] = { "finale%d.twn" };
@ -1074,66 +1046,6 @@ void KyraEngine_HoF::initStaticResource() {
_soundData[2].fileList = pc98MusicFileListFinale;
_soundData[2].fileListLen = 1;
}
// setup sequence data
_sequences = _staticres->loadHofSequenceData(k2SeqplaySeqData, tmpSize);
static const SeqProc hofSequenceCallbacks[] = {
0, &KyraEngine_HoF::seq_introWestwood,
&KyraEngine_HoF::seq_introTitle, &KyraEngine_HoF::seq_introOverview,
&KyraEngine_HoF::seq_introLibrary, &KyraEngine_HoF::seq_introHand,
&KyraEngine_HoF::seq_introPoint, &KyraEngine_HoF::seq_introZanfaun,
&KyraEngine_HoF::seq_finaleFunters, &KyraEngine_HoF::seq_finaleFerb,
&KyraEngine_HoF::seq_finaleFish, &KyraEngine_HoF::seq_finaleFheep,
&KyraEngine_HoF::seq_finaleFarmer, &KyraEngine_HoF::seq_finaleFuards,
&KyraEngine_HoF::seq_finaleFirates, &KyraEngine_HoF::seq_finaleFrash
};
static const SeqProc hofNestedSequenceCallbacks[] = {
&KyraEngine_HoF::seq_finaleFiggle, &KyraEngine_HoF::seq_introOver1,
&KyraEngine_HoF::seq_introOver2, &KyraEngine_HoF::seq_introForest,
&KyraEngine_HoF::seq_introDragon, &KyraEngine_HoF::seq_introDarm,
&KyraEngine_HoF::seq_introLibrary2, &KyraEngine_HoF::seq_introLibrary2,
&KyraEngine_HoF::seq_introMarco, &KyraEngine_HoF::seq_introHand1a,
&KyraEngine_HoF::seq_introHand1b, &KyraEngine_HoF::seq_introHand1c,
&KyraEngine_HoF::seq_introHand2, &KyraEngine_HoF::seq_introHand3, 0
};
static const SeqProc hofDemoSequenceCallbacks[] = {
&KyraEngine_HoF::seq_demoVirgin, &KyraEngine_HoF::seq_demoWestwood,
&KyraEngine_HoF::seq_demoTitle, &KyraEngine_HoF::seq_demoHill,
&KyraEngine_HoF::seq_demoOuthome, &KyraEngine_HoF::seq_demoWharf,
&KyraEngine_HoF::seq_demoDinob, &KyraEngine_HoF::seq_demoFisher, 0
};
static const SeqProc hofDemoNestedSequenceCallbacks[] = {
&KyraEngine_HoF::seq_demoWharf2, &KyraEngine_HoF::seq_demoDinob2,
&KyraEngine_HoF::seq_demoWater, &KyraEngine_HoF::seq_demoBail,
&KyraEngine_HoF::seq_demoDig, 0
};
#ifdef ENABLE_LOL
static const SeqProc kLoLDemoSequenceCallbacks[] = {
&KyraEngine_HoF::seq_lolDemoScene1, 0, &KyraEngine_HoF::seq_lolDemoScene2, 0,
&KyraEngine_HoF::seq_lolDemoScene3, 0, &KyraEngine_HoF::seq_lolDemoScene4, 0,
&KyraEngine_HoF::seq_lolDemoScene5, &KyraEngine_HoF::seq_lolDemoText5,
&KyraEngine_HoF::seq_lolDemoScene6, 0
};
static const SeqProc kLoLDemoNestedSequenceCallbacks[] = { 0 };
#endif // ENABLE_LOL
_callbackS =
#ifdef ENABLE_LOL
_flags.gameID == GI_LOL ? kLoLDemoSequenceCallbacks :
#endif // ENABLE_LOL
((_flags.isDemo && !_flags.isTalkie) ? hofDemoSequenceCallbacks : hofSequenceCallbacks);
_callbackN =
#ifdef ENABLE_LOL
_flags.gameID == GI_LOL ? kLoLDemoNestedSequenceCallbacks :
#endif // ENABLE_LOL
((_flags.isDemo && !_flags.isTalkie) ? hofDemoNestedSequenceCallbacks : hofNestedSequenceCallbacks);
}
void KyraEngine_MR::initStaticResource() {
@ -1412,8 +1324,6 @@ const int GUI_v2::_sliderBarsPosition[] = {
// kyra 2 static res
const uint8 KyraEngine_HoF::_seqTextColorPresets[] = { 0x01, 0x01, 0x00, 0x3f, 0x3f, 0x3f };
const char *const KyraEngine_HoF::_languageExtension[] = {
"ENG",
"FRE",