Committed patch "KYRA: HoF missing talkie credits and demo support".

svn-id: r30845
This commit is contained in:
Johannes Schickel 2008-02-10 18:34:48 +00:00
parent cb6fb6200d
commit b407420ebb
8 changed files with 617 additions and 81 deletions

@ -52,7 +52,7 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi
_seqWsa = 0;
_sequences = 0;
_nSequences = 0;
_demoShapeDefs = 0;
_gamePlayBuffer = 0;
_cCodeBuffer = _optionsBuffer = _chapterBuffer = 0;
@ -129,10 +129,15 @@ int KyraEngine_v2::init() {
_text = new TextDisplayer_v2(this, _screen);
assert(_text);
_screen->loadFont(_screen->FID_6_FNT, "6.FNT");
_screen->loadFont(_screen->FID_8_FNT, "8FAT.FNT");
if (_flags.isDemo && !_flags.isTalkie) {
_screen->loadFont(_screen->FID_8_FNT, "FONT9P.FNT");
} else {
_screen->loadFont(_screen->FID_6_FNT, "6.FNT");
_screen->loadFont(_screen->FID_8_FNT, "8FAT.FNT");
_screen->loadFont(_screen->FID_BOOKFONT_FNT, "BOOKFONT.FNT");
}
_screen->loadFont(_screen->FID_GOLDFONT_FNT, "GOLDFONT.FNT");
_screen->loadFont(_screen->FID_BOOKFONT_FNT, "BOOKFONT.FNT");
_screen->setAnimBlockPtr(3504);
_screen->setScreenDim(0);
@ -141,8 +146,10 @@ int KyraEngine_v2::init() {
_abortIntroFlag = false;
for (int i = 0; i < 33; i++)
_sequenceStringsDuration[i] = (int) strlen(_sequenceStrings[i]) * 8;
if (_sequenceStrings) {
for (int i = 0; i < 33; i++)
_sequenceStringsDuration[i] = (int) strlen(_sequenceStrings[i]) * 8;
}
// No mouse display in demo
if (_flags.isDemo)
@ -164,8 +171,13 @@ int KyraEngine_v2::go() {
if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)
seq_showStarcraftLogo();
seq_playSequences(kSequenceVirgin, kSequenceZanfaun);
//seq_playSequences(kSequenceFunters, kSequenceFrash);
if (_flags.isDemo && !_flags.isTalkie) {
seq_playSequences(kSequenceDemoVirgin, kSequenceDemoFisher);
_menuChoice = 4;
} else {
seq_playSequences(kSequenceVirgin, kSequenceZanfaun);
//seq_playSequences(kSequenceFunters, kSequenceFrash);
}
_res->unloadAllPakFiles();
@ -178,13 +190,12 @@ int KyraEngine_v2::go() {
_res->loadFileList(_ingamePakList, _ingamePakListSize);
}
if (_menuChoice == 1) {
//_menuDirectlyToLoad = (_menuChoice == 3) ? true : false;
if (_menuChoice & 1) {
startup();
runLoop();
cleanup();
} else if (_menuChoice == 3) {
// TODO: Load Game
}
return 0;

@ -78,7 +78,6 @@ enum kSequencesDemo {
kSequenceDemoVirgin = 0,
kSequenceDemoWestwood,
kSequenceDemoTitle,
kSequenceDemoTitle2,
kSequenceDemoHill,
kSequenceDemoOuthome,
kSequenceDemoWharf,
@ -223,9 +222,23 @@ protected:
int seq_finaleFirates(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_finaleFrash(WSAMovieV2 *wsaObj, int x, int y, int frm);
void seq_finaleActorScreen();
int seq_finaleFiggle(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_demoVirgin(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_demoWestwood(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_demoTitle(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_demoHill(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_demoOuthome(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_demoWharf(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_demoDinob(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_demoFisher(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_demoWharf2(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_demoDinob2(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_demoWater(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_demoBail(WSAMovieV2 *wsaObj, int x, int y, int frm);
int seq_demoDig(WSAMovieV2 *wsaObj, int x, int y, int frm);
void seq_sequenceCommand(int command);
void seq_loadNestedSequence(int wsaNum, int seqNum);
void seq_nestedSequenceFrame(int command, int wsaNum);
@ -236,7 +249,6 @@ protected:
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();
@ -244,9 +256,12 @@ protected:
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, uint8 * colorMap, uint8 textcolor);
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,
WSAMovieV2 * 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();
void seq_showStarcraftLogo();
void seq_init();
@ -264,7 +279,7 @@ protected:
static const int8 _dosTrackMap[];
static const int _dosTrackMapSize;
const AudioDataStruct * _soundData;
const AudioDataStruct *_soundData;
protected:
// game initialization
@ -697,7 +712,7 @@ protected:
uint16 unk_2;
uint16 unk_4;
uint16 unk_8;
uint16* unk_20;
uint16 *unk_20;
};
struct TIMBuffers {
@ -715,7 +730,7 @@ protected:
TalkSections _currentTalkSections;
bool _objectChatFinished;
byte* loadTIMFile(const char *filename, byte *buffer, int32 bufferSize);
byte *loadTIMFile(const char *filename, byte *buffer, int32 bufferSize);
void freeTIM(byte *buffer);
// ingame static sequence handling
@ -881,6 +896,7 @@ protected:
int _ingameSoundIndexSize;
const char *const *_sequenceStrings;
int _sequenceStringsSize;
uint8 *_demoShapeDefs;
int _sequenceStringsDuration[33];
static const uint8 _seqTextColorPresets[];
@ -891,16 +907,18 @@ protected:
int _menuChoice;
uint32 _seqFrameDelay;
uint32 _seqStartTime;
uint32 _seqEndTime;
int _seqFrameCounter;
int _seqScrollTextCounter;
int _seqWsaCurrentFrame;
bool _seqSpecialFlag;
bool _seqSubframePlaying;
uint8 _seqTextColor[2];
uint8 _seqTextColorMap[16];
Sequence * _sequences;
NestedSequence * _nSequences;
Sequence *_sequences;
NestedSequence *_nSequences;
};
} // end of namespace Kyra

@ -202,6 +202,7 @@ enum kKyraResources {
k2SeqplayPakFiles,
k2SeqplayCredits,
k2SeqplayCreditsSpecial,
k2SeqplayStrings,
k2SeqplaySfxFiles,
k2SeqplayTlkFiles,
@ -210,6 +211,7 @@ enum kKyraResources {
k2SeqplayFinaleTracks,
k2SeqplayIntroCDA,
k2SeqplayFinaleCDA,
k2SeqplayShapeDefs,
k2IngamePakFiles,
k2IngameSfxFiles,

@ -43,10 +43,7 @@ Screen::~Screen() {
for (int i = 0; i < SCREEN_OVLS_NUM; ++i)
delete [] _sjisOverlayPtrs[i];
for (int pageNum = 0; pageNum < SCREEN_PAGE_NUM; pageNum += 2) {
delete [] _pagePtrs[pageNum];
_pagePtrs[pageNum] = _pagePtrs[pageNum + 1] = 0;
}
delete [] _pagePtrs[0];
for (int f = 0; f < ARRAYSIZE(_fonts); ++f) {
delete[] _fonts[f].fontData;
@ -98,12 +95,10 @@ bool Screen::init() {
setResolution();
_curPage = 0;
for (int pageNum = 0; pageNum < SCREEN_PAGE_NUM; pageNum += 2) {
uint8 *pagePtr = new uint8[SCREEN_PAGE_SIZE];
assert(pagePtr);
memset(pagePtr, 0, SCREEN_PAGE_SIZE);
_pagePtrs[pageNum] = _pagePtrs[pageNum + 1] = pagePtr;
}
uint8 *pagePtr = new uint8[SCREEN_PAGE_SIZE * 8];
for (int pageNum = 0; pageNum < SCREEN_PAGE_NUM; pageNum += 2)
_pagePtrs[pageNum] = _pagePtrs[pageNum + 1] = pagePtr + (pageNum >> 1) * SCREEN_PAGE_SIZE;
memset(_shapePages, 0, sizeof(_shapePages));
memset(_palettes, 0, sizeof(_palettes));

@ -129,8 +129,8 @@ void Screen_v2::wsaFrameAnimationStep(int x1, int y1, int x2, int y2,
if (!calcBounds(cdm.w, cdm.h, x2, y2, w2, h2, na, nb, nc))
return;
uint8 * src = getPagePtr(srcPage) + y1 * 320;
uint8 * dst = getPagePtr(dstPage) + (y2 + cdm.sy) * 320;
const uint8 *src = getPagePtr(srcPage) + y1 * 320;
uint8 *dst = getPagePtr(dstPage) + (y2 + cdm.sy) * 320;
int u = -1;
@ -138,8 +138,8 @@ void Screen_v2::wsaFrameAnimationStep(int x1, int y1, int x2, int y2,
int t = (nb * h1) / h2;
if (t != u) {
u = t;
uint8 * s = src + (x1 + t) * 320;
uint8 * dt = (uint8*) _wsaFrameAnimBuffer;
const uint8 *s = src + (x1 + t) * 320;
uint8 *dt = (uint8*) _wsaFrameAnimBuffer;
t = w2 - w1;
if (!t) {
@ -208,13 +208,13 @@ void Screen_v2::cmpFadeFrameStep(int srcPage, int srcW, int srcH, int srcX, int
if (!calcBounds(dstW, dstH, X2, Y2, W2, H2, r4, r5, r6))
return;
uint8 * src = getPagePtr(srcPage) + srcW * (Y1 + r5);
uint8 * dst = getPagePtr(dstPage) + dstW * (Y2 + r2);
uint8 * cmp = getPagePtr(cmpPage);
const uint8 *src = getPagePtr(srcPage) + srcW * (Y1 + r5);
uint8 *dst = getPagePtr(dstPage) + dstW * (Y2 + r2);
const uint8 *cmp = getPagePtr(cmpPage);
while (H2--) {
uint8 * s = src + r4 + X1;
uint8 * d = dst + r1 + X2;
const uint8 *s = src + r4 + X1;
uint8 *d = dst + r1 + X2;
for (int i = 0; i < W2; i++) {
int ix = (*s++ << 8) + *d;
@ -226,6 +226,49 @@ void Screen_v2::cmpFadeFrameStep(int srcPage, int srcW, int srcH, int srcX, int
}
}
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);
}
void Screen_v2::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;
int w0 = dim->w << 3;
int h0 = dim->h;
int x1 = dstX;
int y1 = dstY;
int w1 = dstW;
int h1 = dstH;
int x2, y2, w2;
calcBounds(w0, h0, x1, y1, w1, h1, x2, y2, w2);
const uint8 *src = getPagePtr(srcPage) + (320 * srcH) + srcW;
uint8 *dst = getPagePtr(dstPage) + 320 * (y0 + y1);
for (int y = 0; y < h1; y++) {
const uint8 *s = src + x2;
uint8 *d = dst + x0 + x1;
if (flag)
d += (h1 >> 1);
for (int x = 0; x < w1; x++) {
if (*s)
*d = *s;
s++;
d++;
}
dst += 320;
src += 320;
}
}
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;

@ -46,10 +46,10 @@ public:
void applyGrayOverlay(int x, int y, int w, int h, int pageNum, const uint8 *grayOverlay);
int findLeastDifferentColor(const uint8 *paletteEntry, const uint8 *palette, uint16 numColors);
bool calcBounds(int w0, int h0, int &x1, int &y1, int &w1, int &h1, int &x2, int &y2, int &w2);
void wsaFrameAnimationStep(int x1, int y1, int x2, int y2,
int w1, int h1, int w2, int h2, int srcPage, int dstPage, int dim);
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 wsaFrameAnimationStep(int x1, int y1, int x2, int y2, int w1, int h1, int w2, int h2, int srcPage, int dstPage, int dim);
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);
// screen page handling
void copyWsaRect(int x, int y, int w, int h, int dimState, int plotFunc, const uint8 *src,

@ -46,7 +46,6 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
assert(startSeq >= 0 && endSeq < kSequenceArraySize && startSeq <= endSeq);
// TODO: verfiy this is also correct for the demo
_sound->setSoundList(&_soundData[(startSeq > kSequenceZanfaun) ? kMusicFinale : kMusicIntro]);
_sound->loadSoundFile(0);
@ -80,23 +79,26 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
_screen->clearPage(8);
memcpy(_screen->getPalette(1), _screen->getPalette(0), 0x300);
_seqFrameCounter = 0;
_seqStartTime = _system->getMillis();
allowSkip = (seqNum == 2) ? false : true;
if (_sequences[seqNum].flags & 2) {
_screen->loadBitmap(_sequences[seqNum].cpsFile, 2, 2, _screen->getPalette(0));
_screen->setScreenPalette(_screen->getPalette(0));
} else {
_screen->setCurPage(2);
_screen->clearPage(2);
_screen->loadPalette("goldfont.col", _screen->getPalette(0));
}
if (_sequences[seqNum].callback)
if (_sequences[seqNum].callback && !(_flags.isDemo && !_flags.isTalkie))
(this->*_sequences[seqNum].callback)(0, 0, 0, -1);
if (_sequences[seqNum].flags & 1) {
_seqWsa->close();
_seqWsa->open(_sequences[seqNum].wsaFile, 0, _screen->getPalette(0));
_screen->setScreenPalette(_screen->getPalette(0));
_seqWsa->setX(_sequences[seqNum].xPos);
_seqWsa->setY(_sequences[seqNum].yPos);
_seqWsa->setDrawPage(2);
@ -123,8 +125,6 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
_screen->copyPage(2, 10);
_screen->copyPage(12, 2);
_screen->copyPage(2, 6);
seq_sequenceCommand(_sequences[seqNum].startupCommand);
if (!((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
@ -187,7 +187,6 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
if ((_seqWsa || !_sequences[seqNum].callback) && !((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
_screen->copyPage(2, 0);
_screen->copyPage(2, 6);
_screen->updateScreen();
}
@ -197,7 +196,6 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
seq_processText();
if (!((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
_screen->copyPage(2, 0);
_screen->copyPage(2, 6);
_screen->updateScreen();
}
@ -236,7 +234,6 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
seq_processText();
_screen->copyPage(2, 6);
_screen->copyPage(2, 0);
_screen->updateScreen();
_screen->copyPage(12, 2);
@ -252,7 +249,7 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
}
}
if (_sequences[seqNum].callback)
if (_sequences[seqNum].callback && !(_flags.isDemo && !_flags.isTalkie))
(this->*_sequences[seqNum].callback)(0, 0, 0, -2);
uint32 ct = seq_activeTextsTimeLeft();
@ -265,7 +262,6 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
uint32 starttime = _system->getMillis();
seq_processWSAs();
_screen->copyPage(2, 6);
_screen->copyPage(2, 0);
_screen->updateScreen();
_screen->copyPage(12, 2);
@ -284,7 +280,10 @@ void KyraEngine_v2::seq_playSequences(int startSeq, int endSeq) {
seq_sequenceCommand(_sequences[seqNum].finalCommand);
seq_resetAllTextEntries();
if ((seqNum != kSequenceTitle && seqNum < kSequenceZanfaun &&
if (_flags.isDemo && seqNum == kSequenceDemoFisher) {
_abortIntroFlag = _skipFlag = false;
seqNum = kSequenceDemoVirgin;
} else if ((seqNum != kSequenceTitle && seqNum < kSequenceZanfaun &&
(_abortIntroFlag || _skipFlag)) || seqNum == kSequenceZanfaun) {
_abortIntroFlag = _skipFlag = false;
seqNum = kSequenceWestwood;
@ -351,7 +350,7 @@ int KyraEngine_v2::seq_introTitle(WSAMovieV2 *wsaObj, int x, int y, int frm) {
int KyraEngine_v2::seq_introOverview(WSAMovieV2 *wsaObj, int x, int y, int frm) {
debugC(9, kDebugLevelMain, "KyraEngine_v2::seq_introOverview(%p, %i, %i, %i)", (const void*)wsaObj, x, y, frm);
uint8 * tmpPal = &(_screen->getPalette(3)[0x101]);
uint8 *tmpPal = &(_screen->getPalette(3)[0x101]);
memset(tmpPal, 0, 256);
uint32 endtime = 0, now = 0;
@ -746,13 +745,11 @@ int KyraEngine_v2::seq_introOver2(WSAMovieV2 *wsaObj, int x, int y, int frm) {
}
int KyraEngine_v2::seq_introForest(WSAMovieV2 *wsaObj, int x, int y, int frm) {
if (frm == 11) {
if (frm == 11)
seq_waitForTextsTimeout();
} else if (frm == 12) {
//if (_flags.lang == Common::FR_FRA)
//XXX
else if (frm == 12)
seq_playTalkText(2);
}
return frm;
}
@ -1413,8 +1410,8 @@ int KyraEngine_v2::seq_finaleFrash(WSAMovieV2 *wsaObj, int x, int y, int frm) {
break;
case -1:
// if (_flags.isTalkie)
// seq_finaleActorScreen();
if (_flags.isTalkie)
seq_finaleActorScreen();
_seqSpecialFlag = _flags.isTalkie;
break;
@ -1493,21 +1490,35 @@ int KyraEngine_v2::seq_finaleFrash(WSAMovieV2 *wsaObj, int x, int y, int frm) {
}
void KyraEngine_v2::seq_finaleActorScreen() {
static const uint8 colormap[] = {0, 0, 102, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
static const ScreenDim d = { 0x00, 0x0C, 0x28, 0xB4, 0xFF, 0x00, 0x00, 0x00 };
_screen->loadBitmap("finale.cps", 3, 3, _screen->_currentPalette);
_screen->setFont(Screen::FID_GOLDFONT_FNT);
//int talkieCreditsSize;
//const uint8 *talkieCredits = _staticres->loadRawData(k2SeqplayCredits, talkieCreditsSize);
int talkieCreditsSize, talkieCreditsSpecialSize;
const uint8 *talkieCredits = _staticres->loadRawData(k2SeqplayCredits, talkieCreditsSize);
const char *const *talkieCreditsSpecial = _staticres->loadStrings(k2SeqplayCreditsSpecial, talkieCreditsSpecialSize);
_sound->setSoundList(&_soundData[kMusicIngame]);
_sound->loadSoundFile(3);
_sound->playTrack(3);
static const uint8 colormap[] = {0, 0, 102, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
_screen->setTextColorMap(colormap);
_screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0);
_screen->updateScreen();
_screen->fadeFromBlack();
//XXX
_screen->_charWidth = -2;
uint8 *dataPtr = new uint8[0xafd];
memcpy(dataPtr, talkieCredits, talkieCreditsSize);
_staticres->unloadId(k2SeqplayCredits);
seq_displayScrollText(dataPtr, &d, 2, 6, 5, 1, Screen::FID_GOLDFONT_FNT, Screen::FID_GOLDFONT_FNT, 0, talkieCreditsSpecial);
delay(120);
delete [] dataPtr;
_staticres->unloadId(k2SeqplayCreditsSpecial);
_sound->setSoundList(&_soundData[kMusicFinale]);
_sound->loadSoundFile(0);
}
@ -1522,6 +1533,244 @@ int KyraEngine_v2::seq_finaleFiggle(WSAMovieV2 *wsaObj, int x, int y, int frm) {
return frm;
}
int KyraEngine_v2::seq_demoVirgin(WSAMovieV2 *wsaObj, int x, int y, int frm) {
if (!frm)
delay(50 * _tickLength);
return 0;
}
int KyraEngine_v2::seq_demoWestwood(WSAMovieV2 *wsaObj, int x, int y, int frm) {
if (!frm)
_sound->playTrack(2);
return 0;
}
int KyraEngine_v2::seq_demoTitle(WSAMovieV2 *wsaObj, int x, int y, int frm) {
if (!frm) {
_sound->playTrack(3);
} else if (frm == 25) {
delay(60 * _tickLength);
_seqEndTime = 0;
seq_sequenceCommand(0);
}
return 0;
}
int KyraEngine_v2::seq_demoHill(WSAMovieV2 *wsaObj, int x, int y, int frm) {
if (!frm) {
_sound->playTrack(4);
} else if (frm == 25) {
seq_loadNestedSequence(0, kSequenceDemoWater);
_seqFrameDelay--;
} else if (frm > 25 && frm < 50) {
if (_seqFrameDelay > 3)
_seqFrameDelay--;
} else if (frm == 95) {
_seqFrameDelay = 70;
} else if (frm == 96) {
_seqFrameDelay = 7;
} else if (frm == 129) {
seq_resetActiveWSA(0);
}
return 0;
}
int KyraEngine_v2::seq_demoOuthome(WSAMovieV2 *wsaObj, int x, int y, int frm) {
switch (frm) {
case 12:
seq_playTalkText(4);
break;
case 32:
seq_playTalkText(7);
break;
case 36:
seq_playTalkText(10);
break;
case 57:
seq_playTalkText(9);
break;
case 80:
case 96:
case 149:
_seqFrameDelay = 70;
break;
case 81:
case 97:
_seqFrameDelay = 5;
break;
case 110:
seq_playTalkText(5);
break;
case 137:
seq_playTalkText(6);
break;
}
return 0;
}
int KyraEngine_v2::seq_demoWharf(WSAMovieV2 *wsaObj, int x, int y, int frm) {
if (!_seqFrameCounter)
seq_loadNestedSequence(0, kSequenceDemoWharf2);
switch (frm) {
case 0:
seq_playTalkText(11);
break;
case 5:
if ((_seqFrameCounter / 8) <= 2 || _activeWSA[0].flags != -1)
_seqWsaCurrentFrame = 0;
else
seq_resetActiveWSA(0);
break;
case 6:
seq_resetActiveWSA(0);
break;
case 8:
case 10:
seq_playTalkText(2);
break;
case 13:
seq_playTalkText(7);
break;
case 16:
seq_playTalkText(12);
break;
default:
break;
}
_seqFrameCounter++;
return 0;
}
int KyraEngine_v2::seq_demoDinob(WSAMovieV2 *wsaObj, int x, int y, int frm) {
if (frm == 0) {
if (!(_seqFrameCounter/8)) {
seq_loadNestedSequence(0, kSequenceDemoDinob2);
_seqWsaCurrentFrame = 0;
}
} else if (frm == 3) {
if (_activeWSA[0].flags != -1) {
_seqWsaCurrentFrame = 0;
} else {
seq_resetActiveWSA(0);
_screen->copyPage(2, 12);
}
} else if (frm == 4) {
seq_resetActiveWSA(0);
}
_seqFrameCounter++;
return 0;
}
int KyraEngine_v2::seq_demoFisher(WSAMovieV2 *wsaObj, int x, int y, int frm) {
if (((_system->getMillis() - _seqStartTime) / (5 * _tickLength)) > 0) {
_seqStartTime = _system->getMillis();
if (!_seqFrameCounter) {
seq_loadNestedSequence(0, kSequenceDemoBail);
seq_loadNestedSequence(1, kSequenceDemoDig);
}
if (_seqScrollTextCounter >= 0x18f && !_seqFrameCounter)
return 0;
if (!_seqFrameCounter) {
_screen->loadBitmap("adtext.cps", 4, 4, 0);
_screen->loadBitmap("adtext2.cps", 6, 6, 0);
_screen->copyPageMemory(6, 0, 4, 64000, 1024);
_screen->copyPageMemory(6, 1023, 6, 0, 64000);
_seqScrollTextCounter = 0;
}
seq_scrollPage();;
_seqFrameCounter++;
if (_seqFrameCounter < 0x256 || _seqFrameCounter > 0x31c) {
if (_seqFrameCounter < 0x174 || _seqFrameCounter > 0x1d7) {
if (_seqFrameCounter < 0x84 || _seqFrameCounter > 0xe7) {
_seqScrollTextCounter++;
}
}
}
if (_seqFrameCounter > 0x31e) {
seq_resetActiveWSA(0);
seq_resetActiveWSA(1);
_seqEndTime = 0;
_screen->copyPage(2, 12);
}
} else {
seq_scrollPage();;
}
return 0;
}
int KyraEngine_v2::seq_demoWharf2(WSAMovieV2 *wsaObj, int x, int y, int frm) {
if (frm == 69)
_seqWsaCurrentFrame = 8;
return frm;
}
int KyraEngine_v2::seq_demoDinob2(WSAMovieV2 *wsaObj, int x, int y, int frm) {
switch (frm) {
case 19:
seq_playTalkText(13);
break;
case 54:
seq_playTalkText(15);
break;
case 61:
seq_playTalkText(16);
break;
case 69:
seq_playTalkText(14);
break;
case 77:
seq_playTalkText(13);
break;
case 79:
_seqWsaCurrentFrame = 4;
break;
}
return frm;
}
int KyraEngine_v2::seq_demoWater(WSAMovieV2 *wsaObj, int x, int y, int frm) {
if (frm == 1)
seq_playTalkText(11);
return frm;
}
int KyraEngine_v2::seq_demoBail(WSAMovieV2 *wsaObj, int x, int y, int frm) {
return frm;
}
int KyraEngine_v2::seq_demoDig(WSAMovieV2 *wsaObj, int x, int y, int frm) {
return frm;
}
uint32 KyraEngine_v2::seq_activeTextsTimeLeft() {
uint32 res = 0;
@ -1688,7 +1937,7 @@ void KyraEngine_v2::seq_sequenceCommand(int command) {
}
}
void KyraEngine_v2::seq_cmpFadeFrame(const char * cmpFile) {
void KyraEngine_v2::seq_cmpFadeFrame(const char *cmpFile) {
_screen->copyPage(10, 2);
_screen->copyPage(4, 10);
_screen->clearPage(6);
@ -1715,7 +1964,7 @@ void KyraEngine_v2::seq_playTalkText(uint8 chatNum) {
assert(chatNum < _sequenceSoundListSize);
if (chatNum < 12)
if (chatNum < 12 && !_flags.isDemo)
seq_setTextEntry(chatNum, 160, 168, _sequenceStringsDuration[chatNum], 160);
_sound->voicePlay(_sequenceSoundList[chatNum]);
@ -2010,7 +2259,7 @@ bool KyraEngine_v2::seq_processNextSubFrame(int wsaNum) {
return res;
}
void KyraEngine_v2::seq_printCreditsString(uint16 strIndex, int x, int y, uint8 * colorMap, uint8 textcolor) {
void KyraEngine_v2::seq_printCreditsString(uint16 strIndex, int x, int y, const uint8 *colorMap, uint8 textcolor) {
uint8 colormap[16];
memset(&_screen->getPalette(0)[0x2fa], 0x3f, 6);
@ -2027,7 +2276,6 @@ void KyraEngine_v2::seq_printCreditsString(uint16 strIndex, int x, int y, uint8
seq_resetAllTextEntries();
seq_setTextEntry(strIndex, x, y, 0x80, 0x78);
seq_processText();
_screen->copyPage(2, 6);
_screen->copyPage(2, 0);
_screen->updateScreen();
_screen->getPalette(0)[0x2f7] = _screen->getPalette(0)[textcolor * 3];
@ -2040,7 +2288,6 @@ void KyraEngine_v2::seq_printCreditsString(uint16 strIndex, int x, int y, uint8
seq_resetAllTextEntries();
seq_setTextEntry(strIndex, x, y, 0x80, 0x78);
seq_processText();
_screen->copyPage(2, 6);
_screen->copyPage(2, 0);
_screen->updateScreen();
_screen->getPalette(0)[0x2f7] = _screen->getPalette(0)[0x2f8] = _screen->getPalette(0)[0x2f9] = 0;
@ -2051,7 +2298,7 @@ void KyraEngine_v2::seq_printCreditsString(uint16 strIndex, int x, int y, uint8
_seqTextColor[0] = seqTextColor0;
}
void KyraEngine_v2::seq_playWsaSyncDialogue(uint16 strIndex, uint16 vocIndex, int textColor, int x, int y, int width, WSAMovieV2 * wsa, int firstframe, int lastframe, int wsaXpos, int wsaYpos) {
void KyraEngine_v2::seq_playWsaSyncDialogue(uint16 strIndex, uint16 vocIndex, int textColor, int x, int y, int width, WSAMovieV2 *wsa, int firstframe, int lastframe, int wsaXpos, int wsaYpos) {
int dur = int(strlen(_sequenceStrings[strIndex])) * (_flags.isTalkie ? 7 : 15);
int entry = seq_setTextEntry(strIndex, x, y, dur, width);
_activeText[entry].textcolor = textColor;
@ -2087,7 +2334,6 @@ void KyraEngine_v2::seq_playWsaSyncDialogue(uint16 strIndex, uint16 vocIndex, in
if (frameTimeout > tm && chatTimeout > tm)
delay(MIN(frameTimeout - tm, chatTimeout - tm));
_screen->copyPage(2, 6);
_screen->copyPage(2, 0);
_screen->updateScreen();
curframe++;
@ -2105,8 +2351,197 @@ void KyraEngine_v2::seq_playWsaSyncDialogue(uint16 strIndex, uint16 vocIndex, in
_seqWsaCurrentFrame = curframe;
}
void KyraEngine_v2::seq_displayScrollText(uint8 *data, const ScreenDim *d, int tempPage1, int tempPage2, int speed,
int step, Screen::FontId fid1, Screen::FontId fid2, const uint8 *shapeData, const char *const *specialData) {
if (!data)
return;
static const char mark[] = { 5, 13, 0};
/*uint _creditsNumChars = d->unkC / (_screen->getFontWidth() + _screen->_charWidth);
uint _creditsMaxNumLines = (d->h - _screen->_charOffset) / (_screen->getFontHeight() + _screen->_charOffset);
uint _creditsMaxNumChars = (d->w << 3) / (_screen->getFontWidth() + _screen->_charWidth); */
_screen->clearPage(tempPage1);
_screen->clearPage(tempPage2);
_screen->copyRegion(d->sx << 3, d->sy, d->sx << 3, d->sy, d->w << 3, d->h, 0, tempPage1);
uint8 *tmp = new uint8[397];
memset(tmp, 0, 397);
uint8 **tmpStringTable = new uint8*[35];
uint8 *ptr = data;
int strTblIndex = 0;
bool loop = true;
int cnt = 0;
while (loop) {
uint32 endTime = _system->getMillis() + speed * _tickLength;
while (cnt < 35 && *ptr) {
int m = cnt * 11;
uint16 cH = cnt ? READ_LE_UINT16(&tmp[m + 2]) + tmp[m + 9] + (tmp[m + 9] >> 3) : d->h;
const char *str = (const char*)ptr;
ptr = (uint8*)strpbrk((const char*)str, mark);
if (!ptr)
ptr = (uint8*)strchr((const char*)str, 0);
tmp[m + 19] = *ptr;
*ptr = 0;
if (tmp[m + 19])
ptr++;
tmp[m + 21] = (*str == 3 || *str == 4) ? tmp[m + 21] = *str++ : 0;
_screen->setFont(fid1);
if (*str == 1) {
_screen->setFont(fid2);
str++;
} else if (*str == 2) {
str++;
}
tmp[m + 20] = _screen->getFontHeight();
WRITE_LE_UINT16(&tmp[m + 11], (tmp[m + 21] == 3) ? 157 - _screen->getTextWidth(str) :
((tmp[m + 21] == 4) ? 161 : (((d->w << 3) - _screen->getTextWidth(str)) >> 1) + 1));
if (tmp[m + 8] == 5)
cH -= (tmp[m + 9] + (tmp[m + 9] >> 3));
WRITE_LE_UINT16(&tmp[m + 13], cH);
WRITE_LE_UINT32(&tmp[m + 15], strTblIndex);
tmpStringTable[strTblIndex] = (uint8*) str;
strTblIndex = (strTblIndex + 1) % 35;
cnt++;
}
_screen->copyRegion(d->sx << 3, d->sy, d->sx << 3, d->sy, d->w << 3, d->h, tempPage1, tempPage2);
int cnt2 = 0;
bool palCycle = 0;
while (cnt2 < cnt) {
int m = cnt2 * 11;
const char *str = (const char*)tmpStringTable[READ_LE_UINT32(&tmp[m + 15])];
const char *str2 = str;
uint16 cW = READ_LE_UINT16(&tmp[m + 11]) - 10;
uint16 cH = READ_LE_UINT16(&tmp[m + 13]);
int x = (d->sx << 3) + cW;
int y = d->sy + cH;
int col1 = 255;
if (cH < d->h) {
_screen->setCurPage(tempPage2);
_screen->setFont(fid1);
if (tmp[m + 20] != _screen->getFontHeight())
_screen->setFont(fid2);
if (specialData) {
if (!strcmp(str, specialData[0])) {
col1 = 112;
char cChar[2] = " ";
while (*str2) {
cChar[0] = *str2;
_screen->printText(cChar, x, y, col1++, 0);
x += _screen->getCharWidth(*str2++);
}
palCycle = true;
} else if (!strcmp(str, specialData[1])) {
col1 = 133;
char cChar[2] = " ";
while (*str2) {
cChar[0] = *str2;
_screen->printText(cChar, x, y, col1--, 0);
x += _screen->getCharWidth(*str2++);
}
palCycle = true;
} else {
_screen->printText(str, x, y, col1, 0);
}
} else {
_screen->printText(str, x, y, col1, 0);
}
_screen->setCurPage(0);
}
WRITE_LE_UINT16(&tmp[m + 13], READ_LE_UINT16(&tmp[m + 13]) - step);
cnt2++;
}
_screen->copyRegion(d->sx << 3, d->sy, d->sx << 3, d->sy, d->w << 3, d->h, tempPage2, 0);
_screen->updateScreen();
if ((int16)READ_LE_UINT16(&tmp[13]) < -10) {
tmpStringTable[tmp[15]] += strlen((char*)tmpStringTable[tmp[15]]);
tmpStringTable[tmp[15]][0] = tmp[19];
cnt--;
memcpy(&tmp[11], &tmp[22], cnt * 11);
}
if (palCycle) {
for (int col = 133; col > 112; col--)
memcpy(_screen->_currentPalette + (col * 3), _screen->_currentPalette + ((col - 1) * 3), 3);
memcpy(_screen->_currentPalette + 336, _screen->_currentPalette + 399, 3);
_screen->setScreenPalette(_screen->_currentPalette);
}
delayUntil(endTime);
if ((cnt < 36) && ((d->sy + d->h) > (READ_LE_UINT16(&tmp[cnt * 11 + 2]) + tmp[cnt * 11 + 9])) && !_skipFlag) {
_skipFlag=_skipFlag;
delay(_tickLength * 500);
cnt = 0;
}
if (!cnt || _skipFlag)
loop = false;
}
_sound->beginFadeOut();
_screen->fadeToBlack();
delete [] tmp;
delete [] tmpStringTable;
}
void KyraEngine_v2::seq_scrollPage() {
int dstY, dstH, srcH;
static const ScreenDim d = { 0x00, 0x00, 0x28, 0x320, 0xFF, 0xFE, 0x00, 0x00 };
if (_seqScrollTextCounter - 143 < 0) {
dstY = 144 - _seqScrollTextCounter;;
dstH = _seqScrollTextCounter;;
srcH = 0;
} else {
dstY = 0;
srcH = _seqScrollTextCounter - 144;
dstH = (400 - srcH <= 144) ? 400 - srcH : 144;
}
if (dstH > 0) {
for (int i = 0; i < 4; i++) {
int p = _screen->setCurPage(4);
uint8 *def = _demoShapeDefs + 46 * i;
_screen->drawBox(12, READ_LE_UINT16(def + 2) - 8, 28, READ_LE_UINT16(def + 2) + 8, 0);
_screen->setCurPage(p);
_screen->drawShape(4, _defaultShapeTable[READ_LE_UINT16(def) + READ_LE_UINT16(def + 6 + (READ_LE_UINT16(def + 4) << 1))], 12, READ_LE_UINT16(def + 2) - 8, 0, 0);
if(_seqFrameCounter % 2 == 0){
uint16 frame = READ_LE_UINT16(def + 4);
WRITE_LE_UINT16(def + 4, ++frame % 20);
}
}
_screen->copyRegionEx(4, 0, srcH, 2, 2, dstY + 24, 320, dstH, &d);
}
}
void KyraEngine_v2::seq_showStarcraftLogo() {
WSAMovieV2 * ci = new WSAMovieV2(this);
WSAMovieV2 *ci = new WSAMovieV2(this);
assert(ci);
_screen->clearPage(2);
_res->loadPakFile("INTROGEN.PAK");
@ -2155,6 +2590,26 @@ void KyraEngine_v2::seq_init() {
_res->unloadAllPakFiles();
_res->loadPakFile(StaticResource::staticDataFilename());
_res->loadFileList(_sequencePakList, _sequencePakListSize);
int numShp = -1;
if (_flags.isDemo) {
int size;
const uint8 *tmp = _staticres->loadRawData(k2SeqplayShapeDefs, size);
_demoShapeDefs = new uint8[size];
memcpy(_demoShapeDefs, tmp, size);
_staticres->unloadId(k2SeqplayShapeDefs);
uint8 *shp = _res->fileData("icons.shp", 0);
uint32 outsize = READ_LE_UINT16(shp + 4);
_newShapeFiledata = new uint8[outsize];
Screen::decodeFrame4(shp + 10, _newShapeFiledata, outsize);
delete [] shp;
do {
numShp++;
_defaultShapeTable[numShp] = _screen->getPtrToShape(_newShapeFiledata, numShp);
} while (_defaultShapeTable[numShp]);
}
}
void KyraEngine_v2::seq_uninit() {
@ -2169,6 +2624,11 @@ void KyraEngine_v2::seq_uninit() {
delete _seqWsa;
_seqWsa = NULL;
if (_demoShapeDefs) {
delete [] _demoShapeDefs;
_demoShapeDefs = 0;
}
}
#pragma mark -

@ -35,7 +35,7 @@
namespace Kyra {
#define RESFILE_VERSION 19
#define RESFILE_VERSION 20
bool StaticResource::checkKyraDat() {
Common::File kyraDat;
@ -228,6 +228,7 @@ bool StaticResource::init() {
// Sequence Player
{ k2SeqplayPakFiles, kStringList, "S_PAKFILES.TXT" },
{ k2SeqplayCredits, kRawData, "S_CREDITS.TXT" },
{ k2SeqplayCreditsSpecial, kStringList, "S_CREDITS2.TXT" },
{ k2SeqplayStrings, kLanguageList, "S_STRINGS." },
{ k2SeqplaySfxFiles, kStringList, "S_SFXFILES.TXT" },
{ k2SeqplayTlkFiles, kLanguageList, "S_TLKFILES." },
@ -236,6 +237,7 @@ bool StaticResource::init() {
{ k2SeqplayFinaleTracks, kStringList, "S_FINALE.TRA" },
{ k2SeqplayIntroCDA, kRawData, "S_INTRO.CDA" },
{ k2SeqplayFinaleCDA, kRawData, "S_FINALE.CDA" },
{ k2SeqplayShapeDefs, kRawData, "S_DEMO.SHP" },
// Ingame
{ k2IngamePakFiles, kStringList, "I_PAKFILES.TXT" },
@ -990,20 +992,25 @@ void KyraEngine_v2::initStaticResource() {
&KyraEngine_v2::seq_introHand2, &KyraEngine_v2::seq_introHand3, 0
};
/*static const Seqproc hofDemoSequenceCallbacks[] = {
0 // XXX
static const Seqproc hofDemoSequenceCallbacks[] = {
&KyraEngine_v2::seq_demoVirgin, &KyraEngine_v2::seq_demoWestwood,
&KyraEngine_v2::seq_demoTitle, &KyraEngine_v2::seq_demoHill,
&KyraEngine_v2::seq_demoOuthome, &KyraEngine_v2::seq_demoWharf,
&KyraEngine_v2::seq_demoDinob, &KyraEngine_v2::seq_demoFisher, 0
};
static const Seqproc hofDemoNestedSequenceCallbacks[] = {
0 // XXX
};*/
&KyraEngine_v2::seq_demoWharf2, &KyraEngine_v2::seq_demoDinob2,
&KyraEngine_v2::seq_demoWater, &KyraEngine_v2::seq_demoBail,
&KyraEngine_v2::seq_demoDig, 0
};
const uint16 *hdr = (const uint16 *) seqData;
uint16 numSeq = READ_LE_UINT16(hdr++);
uint16 hdrSize = READ_LE_UINT16(hdr) - 1;
const Seqproc *cb = hofSequenceCallbacks;
const Seqproc *ncb = hofNestedSequenceCallbacks;
const Seqproc *cb = (_flags.isDemo && !_flags.isTalkie) ? hofDemoSequenceCallbacks : hofSequenceCallbacks;
const Seqproc *ncb = (_flags.isDemo && !_flags.isTalkie) ? hofDemoNestedSequenceCallbacks : hofNestedSequenceCallbacks;
_sequences = new Sequence[numSeq];
for (int i = 0; i < numSeq; i++) {