aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/chargen.cpp48
-rw-r--r--engines/kyra/darkmoon.cpp13
-rw-r--r--engines/kyra/darkmoon.h18
-rw-r--r--engines/kyra/debugger.cpp53
-rw-r--r--engines/kyra/debugger.h1
-rw-r--r--engines/kyra/detection.cpp2
-rw-r--r--engines/kyra/detection_tables.h41
-rw-r--r--engines/kyra/eob.cpp12
-rw-r--r--engines/kyra/eob.h5
-rw-r--r--engines/kyra/eobcommon.cpp56
-rw-r--r--engines/kyra/eobcommon.h25
-rw-r--r--engines/kyra/gui_eob.cpp150
-rw-r--r--engines/kyra/gui_eob.h2
-rw-r--r--engines/kyra/gui_hof.cpp2
-rw-r--r--engines/kyra/gui_lol.cpp132
-rw-r--r--engines/kyra/gui_lol.h18
-rw-r--r--engines/kyra/gui_mr.cpp2
-rw-r--r--engines/kyra/gui_rpg.cpp6
-rw-r--r--engines/kyra/items_eob.cpp10
-rw-r--r--engines/kyra/items_hof.cpp14
-rw-r--r--engines/kyra/items_lok.cpp6
-rw-r--r--engines/kyra/items_lol.cpp21
-rw-r--r--engines/kyra/kyra_hof.cpp86
-rw-r--r--engines/kyra/kyra_hof.h284
-rw-r--r--engines/kyra/kyra_lok.cpp8
-rw-r--r--engines/kyra/kyra_lok.h78
-rw-r--r--engines/kyra/kyra_mr.cpp6
-rw-r--r--engines/kyra/kyra_mr.h6
-rw-r--r--engines/kyra/kyra_rpg.cpp25
-rw-r--r--engines/kyra/kyra_rpg.h9
-rw-r--r--engines/kyra/kyra_v1.cpp141
-rw-r--r--engines/kyra/kyra_v1.h15
-rw-r--r--engines/kyra/lol.cpp253
-rw-r--r--engines/kyra/lol.h42
-rw-r--r--engines/kyra/magic_eob.cpp22
-rw-r--r--engines/kyra/resource.cpp2
-rw-r--r--engines/kyra/resource.h27
-rw-r--r--engines/kyra/resource_intern.cpp36
-rw-r--r--engines/kyra/resource_intern.h2
-rw-r--r--engines/kyra/saveload.cpp4
-rw-r--r--engines/kyra/saveload_eob.cpp368
-rw-r--r--engines/kyra/saveload_lok.cpp2
-rw-r--r--engines/kyra/saveload_lol.cpp6
-rw-r--r--engines/kyra/scene_eob.cpp98
-rw-r--r--engines/kyra/scene_lol.cpp64
-rw-r--r--engines/kyra/scene_mr.cpp2
-rw-r--r--engines/kyra/scene_rpg.cpp94
-rw-r--r--engines/kyra/screen.cpp179
-rw-r--r--engines/kyra/screen.h31
-rw-r--r--engines/kyra/screen_eob.cpp418
-rw-r--r--engines/kyra/screen_eob.h17
-rw-r--r--engines/kyra/screen_hof.cpp60
-rw-r--r--engines/kyra/screen_hof.h3
-rw-r--r--engines/kyra/screen_lol.cpp84
-rw-r--r--engines/kyra/screen_lol.h1
-rw-r--r--engines/kyra/screen_v2.cpp90
-rw-r--r--engines/kyra/screen_v2.h6
-rw-r--r--engines/kyra/script_eob.cpp44
-rw-r--r--engines/kyra/script_eob.h4
-rw-r--r--engines/kyra/script_hof.cpp44
-rw-r--r--engines/kyra/script_lok.cpp20
-rw-r--r--engines/kyra/script_lol.cpp88
-rw-r--r--engines/kyra/script_mr.cpp28
-rw-r--r--engines/kyra/script_tim.cpp30
-rw-r--r--engines/kyra/sequences_darkmoon.cpp9
-rw-r--r--engines/kyra/sequences_eob.cpp4
-rw-r--r--engines/kyra/sequences_hof.cpp4145
-rw-r--r--engines/kyra/sequences_hof.h74
-rw-r--r--engines/kyra/sequences_lok.cpp2
-rw-r--r--engines/kyra/sequences_lol.cpp51
-rw-r--r--engines/kyra/sound.cpp50
-rw-r--r--engines/kyra/sound.h156
-rw-r--r--engines/kyra/sound_adlib.cpp37
-rw-r--r--engines/kyra/sound_adlib.h9
-rw-r--r--engines/kyra/sound_amiga.cpp18
-rw-r--r--engines/kyra/sound_digital.cpp8
-rw-r--r--engines/kyra/sound_digital.h119
-rw-r--r--engines/kyra/sound_intern.h154
-rw-r--r--engines/kyra/sound_lol.cpp32
-rw-r--r--engines/kyra/sound_midi.cpp29
-rw-r--r--engines/kyra/sound_towns.cpp148
-rw-r--r--engines/kyra/sprites_eob.cpp25
-rw-r--r--engines/kyra/sprites_lol.cpp108
-rw-r--r--engines/kyra/sprites_rpg.cpp4
-rw-r--r--engines/kyra/staticres.cpp289
-rw-r--r--engines/kyra/staticres_eob.cpp66
-rw-r--r--engines/kyra/staticres_lol.cpp151
-rw-r--r--engines/kyra/text_hof.cpp4
-rw-r--r--engines/kyra/text_lol.cpp25
-rw-r--r--engines/kyra/text_rpg.cpp289
-rw-r--r--engines/kyra/text_rpg.h2
-rw-r--r--engines/kyra/timer_eob.cpp15
-rw-r--r--engines/kyra/timer_lol.cpp12
-rw-r--r--engines/kyra/vqa.cpp8
94 files changed, 5166 insertions, 4341 deletions
diff --git a/engines/kyra/chargen.cpp b/engines/kyra/chargen.cpp
index 54e1abcc2c..80a95da047 100644
--- a/engines/kyra/chargen.cpp
+++ b/engines/kyra/chargen.cpp
@@ -193,7 +193,7 @@ bool CharacterGenerator::start(EoBCharacter *characters, uint8 ***faceShapes) {
}
if (inputFlag & 0x8000) {
- inputFlag = (inputFlag & 0x0f) - 1;
+ inputFlag = (inputFlag & 0x0F) - 1;
if (inputFlag == 4) {
loop = false;
} else {
@@ -402,7 +402,7 @@ int CharacterGenerator::viewDeleteCharacter() {
}
if (inputFlag & 0x8000) {
- inputFlag = (inputFlag & 0x0f) - 1;
+ inputFlag = (inputFlag & 0x0F) - 1;
if (inputFlag == 4) {
res = 1;
loop = false;
@@ -524,7 +524,7 @@ int CharacterGenerator::classMenu(int raceSex) {
while (res == -1 && !_vm->shouldQuit()) {
updateMagicShapes();
- int in = getInput(0) & 0xff;
+ int in = getInput(0) & 0xFF;
Common::Point mp = _vm->getMousePos();
if (in == _vm->_keyMap[Common::KEYCODE_ESCAPE] || _vm->_gui->_menuLastInFlags == _vm->_keyMap[Common::KEYCODE_ESCAPE] || _vm->_gui->_menuLastInFlags == _vm->_keyMap[Common::KEYCODE_b]) {
@@ -572,7 +572,7 @@ int CharacterGenerator::alignmentMenu(int cClass) {
while (res == -1 && !_vm->shouldQuit()) {
updateMagicShapes();
- int in = getInput(0) & 0xff;
+ int in = getInput(0) & 0xFF;
Common::Point mp = _vm->getMousePos();
if (in == _vm->_keyMap[Common::KEYCODE_ESCAPE] || _vm->_gui->_menuLastInFlags == _vm->_keyMap[Common::KEYCODE_ESCAPE] || _vm->_gui->_menuLastInFlags == _vm->_keyMap[Common::KEYCODE_b]) {
@@ -658,14 +658,14 @@ void CharacterGenerator::generateStats(int index) {
sv[i] = _chargenMaxStats[i];
}
- c->strengthCur = c->strengthMax = sv[0] & 0xff;
+ c->strengthCur = c->strengthMax = sv[0] & 0xFF;
c->strengthExtCur = c->strengthExtMax = sv[0] >> 8;
- c->intelligenceCur = c->intelligenceMax = sv[1] & 0xff;
- c->wisdomCur = c->wisdomMax = sv[2] & 0xff;
- c->dexterityCur = c->dexterityMax = sv[3] & 0xff;
- c->constitutionCur = c->constitutionMax = sv[4] & 0xff;
- c->charismaCur = c->charismaMax = sv[5] & 0xff;
- c->armorClass = 10 + _vm->getDexterityArmorClassModifier(sv[3] & 0xff);
+ c->intelligenceCur = c->intelligenceMax = sv[1] & 0xFF;
+ c->wisdomCur = c->wisdomMax = sv[2] & 0xFF;
+ c->dexterityCur = c->dexterityMax = sv[3] & 0xFF;
+ c->constitutionCur = c->constitutionMax = sv[4] & 0xFF;
+ c->charismaCur = c->charismaMax = sv[5] & 0xFF;
+ c->armorClass = 10 + _vm->getDexterityArmorClassModifier(sv[3] & 0xFF);
c->hitPointsCur = 0;
for (int l = 0; l < 3; l++) {
@@ -817,7 +817,7 @@ void CharacterGenerator::faceSelectMenu() {
} else if (in == _vm->_keyMap[Common::KEYCODE_RETURN] || in == _vm->_keyMap[Common::KEYCODE_KP5]) {
in = 3;
} else if (in & 0x8000) {
- in &= 0xff;
+ in &= 0xFF;
} else {
in = 0;
}
@@ -1017,7 +1017,7 @@ int CharacterGenerator::modifyStat(int index, int8 *stat1, int8 *stat2) {
ci = -2;
} else if (inputFlag & 0x8000) {
- inputFlag = (inputFlag & 0x0f) - 1;
+ inputFlag = (inputFlag & 0x0F) - 1;
if (index != inputFlag) {
ci = inputFlag;
loop = false;
@@ -1037,7 +1037,7 @@ int CharacterGenerator::modifyStat(int index, int8 *stat1, int8 *stat2) {
v2--;
}
- v1 = CLIP<uint8>(v1, _chargenMinStats[index], _chargenMaxStats[index] & 0xff);
+ v1 = CLIP<uint8>(v1, _chargenMinStats[index], _chargenMaxStats[index] & 0xFF);
v2 = (v1 == 18 && _chargenMaxStats[index] >= 19) ? CLIP<uint8>(v2, 0, 100) : 0;
if (s2)
*s2 = v2;
@@ -1206,7 +1206,7 @@ void CharacterGenerator::finish() {
static const int8 itemList1[] = { 1, 2, 0, 17, -1, 0, 0 };
static const int8 itemList2[] = { 2, 56, 1, 17, 31, 0, 1, 23, 1, 17, 31, 0, 1 };
static const int8 itemList3[] = { 2, 1, 1, 17, 31, 1, 1, 1, 0, 17, 31, 2, 1 };
- static const int8 *itemList[] = { itemList0, itemList1, itemList2, itemList3 };
+ static const int8 *const itemList[] = { itemList0, itemList1, itemList2, itemList3 };
for (int i = 0; i < 4; i++) {
EoBCharacter *c = &_characters[i];
@@ -1496,7 +1496,7 @@ TransferPartyWiz::~TransferPartyWiz() {
}
bool TransferPartyWiz::start() {
- _screen->copyPage(0, _vm->_useHiResDithering ? 1 : 12);
+ _screen->copyPage(0, 12);
if (!selectAndLoadTransferFile())
return false;
@@ -1536,7 +1536,7 @@ bool TransferPartyWiz::start() {
bool TransferPartyWiz::selectAndLoadTransferFile() {
do {
- _screen->copyPage(_vm->_useHiResDithering ? 1 : 12, 0);
+ _screen->copyPage(12, 0);
if (transferFileDialogue(_vm->_savegameFilename))
break;
} while (_vm->_gui->confirmDialogue2(15, 68, 1));
@@ -1566,7 +1566,7 @@ bool TransferPartyWiz::selectAndLoadTransferFile() {
return false;
Common::String target = _vm->_gui->transferTargetMenu(eobTargets);
- _screen->copyPage(_vm->_useHiResDithering ? 1 : 12, 0);
+ _screen->copyPage(12, 0);
if (target.empty())
return true;
@@ -1579,10 +1579,10 @@ bool TransferPartyWiz::selectAndLoadTransferFile() {
return true;
}
- _screen->copyPage(_vm->_useHiResDithering ? 1 : 12, 0);
+ _screen->copyPage(12, 0);
bool result = _vm->_gui->transferFileMenu(target, dest);
- _screen->copyPage(_vm->_useHiResDithering ? 1 : 12, 0);
+ _screen->copyPage(12, 0);
return result;
}
@@ -1614,7 +1614,7 @@ int TransferPartyWiz::selectCharactersMenu() {
bool update = false;
for (bool loop = true; loop && (!_vm->shouldQuit());) {
- int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff;
+ int inputFlag = _vm->checkInput(0, false, 0) & 0x8FF;
_vm->removeInputTop();
if (inputFlag) {
@@ -1827,7 +1827,7 @@ Item TransferPartyWiz::convertItem(Item eob1Item) {
itm2->flags = itm1->flags | 0x40;
itm2->icon = itm1->icon;
itm2->type = itm1->type;
- itm2->level = 0xff;
+ itm2->level = 0xFF;
switch (itm2->type) {
case 35:
@@ -1850,7 +1850,7 @@ Item TransferPartyWiz::convertItem(Item eob1Item) {
return 0;
}
itm2->value = itm1->value;
- itm2->flags = ((itm1->flags & 0x3f) + 3) | 0x40;
+ itm2->flags = ((itm1->flags & 0x3F) + 3) | 0x40;
break;
case 18:
itm2->icon = 19;
@@ -1860,7 +1860,7 @@ Item TransferPartyWiz::convertItem(Item eob1Item) {
break;
}
- switch ((_vm->_itemTypes[itm2->type].extraProperties & 0x7f) - 1) {
+ switch ((_vm->_itemTypes[itm2->type].extraProperties & 0x7F) - 1) {
case 0:
case 1:
case 2:
diff --git a/engines/kyra/darkmoon.cpp b/engines/kyra/darkmoon.cpp
index 16bd3dad58..130fb10df3 100644
--- a/engines/kyra/darkmoon.cpp
+++ b/engines/kyra/darkmoon.cpp
@@ -136,7 +136,7 @@ void DarkMoonEngine::updateUsedCharacterHandItem(int charIndex, int slot) {
if (itm->type == 48 || itm->type == 62) {
if (itm->value == 5)
return;
- int charges = itm->flags & 0x3f;
+ int charges = itm->flags & 0x3F;
if (--charges)
--itm->flags;
else
@@ -158,10 +158,7 @@ void DarkMoonEngine::generateMonsterPalettes(const char *file, int16 monsterInde
int colx = 302 + 3 * i;
for (int ii = 0; ii < 16; ii++) {
- // Don't use getPagePixel() here, since in EGA mode it will try to
- // undither the pixel (although the shape bitmap is undithered already)
- uint8 col = _screen->getCPagePtr(_screen->_curPage | 1)[(184 + ii) * Screen::SCREEN_W + colx];
-
+ uint8 col = _screen->getPagePixel(_screen->_curPage, colx, 184 + ii);
int iii = 0;
for (; iii < 16; iii++) {
if (tmpPal[iii] == col) {
@@ -178,9 +175,7 @@ void DarkMoonEngine::generateMonsterPalettes(const char *file, int16 monsterInde
memcpy(tmpPal, _monsterShapes[dci] + 4, 16);
for (int iii = 0; iii < 16; iii++) {
- // Don't use getPagePixel() here, since in EGA mode it will try to
- // undither the pixel (although the shape bitmap is undithered already)
- uint8 col = _screen->getCPagePtr(_screen->_curPage | 1)[(184 + iii) * Screen::SCREEN_W + colx + ii];
+ uint8 col = _screen->getPagePixel(_screen->_curPage, colx + ii, 184 + iii);
if (newPal[iii])
tmpPal[newPal[iii]] = col;
}
@@ -455,7 +450,7 @@ void DarkMoonEngine::characterLevelGain(int charIndex) {
int s = _numLevelsPerClass[c->cClass];
for (int i = 0; i < s; i++) {
uint32 er = getRequiredExperience(c->cClass, i, c->level[i] + 1);
- if (er == 0xffffffff)
+ if (er == 0xFFFFFFFF)
continue;
increaseCharacterExperience(charIndex, er - c->experience[i] + 1);
diff --git a/engines/kyra/darkmoon.h b/engines/kyra/darkmoon.h
index f6e7b3ed2c..f0057ddd66 100644
--- a/engines/kyra/darkmoon.h
+++ b/engines/kyra/darkmoon.h
@@ -72,21 +72,21 @@ private:
void seq_playFinale();
void seq_playCredits(DarkmoonSequenceHelper *sq, const uint8 *data, int sd, int backupPage, int tempPage, int speed);
- const char * const *_introStrings;
- const char * const *_cpsFilesIntro;
+ const char *const *_introStrings;
+ const char *const *_cpsFilesIntro;
const DarkMoonAnimCommand **_animIntro;
const DarkMoonShapeDef **_shapesIntro;
- const char * const *_finaleStrings;
+ const char *const *_finaleStrings;
const uint8 *_creditsData;
- const char * const *_cpsFilesFinale;
+ const char *const *_cpsFilesFinale;
const DarkMoonAnimCommand **_animFinale;
const DarkMoonShapeDef **_shapesFinale;
- static const char *_palFilesIntroVGA[];
- static const char *_palFilesIntroEGA[];
- static const char *_palFilesFinaleVGA[];
- static const char *_palFilesFinaleEGA[];
+ static const char *const _palFilesIntroVGA[];
+ static const char *const _palFilesIntroEGA[];
+ static const char *const _palFilesFinaleVGA[];
+ static const char *const _palFilesFinaleEGA[];
// Ingame sequence
void seq_nightmare();
@@ -140,7 +140,7 @@ private:
static const uint8 _egaDefaultPalette[];
};
-} // End of namespace Kyra
+} // End of namespace Kyra
#endif
diff --git a/engines/kyra/debugger.cpp b/engines/kyra/debugger.cpp
index c0a91ac098..75981958d6 100644
--- a/engines/kyra/debugger.cpp
+++ b/engines/kyra/debugger.cpp
@@ -483,11 +483,12 @@ Debugger_EoB::Debugger_EoB(EoBCoreEngine *vm) : Debugger(vm), _vm(vm) {
void Debugger_EoB::initialize() {
DCmd_Register("import_savefile", WRAP_METHOD(Debugger_EoB, cmd_importSaveFile));
+ DCmd_Register("save_original", WRAP_METHOD(Debugger_EoB, cmd_saveOriginal));
}
bool Debugger_EoB::cmd_importSaveFile(int argc, const char **argv) {
if (!_vm->_allowImport) {
- DebugPrintf("This command may only be used from the main menu.\n");
+ DebugPrintf("This command only works from the main menu.\n");
return true;
}
@@ -507,6 +508,56 @@ bool Debugger_EoB::cmd_importSaveFile(int argc, const char **argv) {
return true;
}
+bool Debugger_EoB::cmd_saveOriginal(int argc, const char **argv) {
+ if (!_vm->_runFlag) {
+ DebugPrintf("This command doesn't work during intro or outro sequences,\nfrom the main menu or from the character generation.\n");
+ return true;
+ }
+
+ Common::String dir = ConfMan.get("savepath");
+ if (dir == "None")
+ dir.clear();
+
+ Common::FSNode nd(dir);
+ if (!nd.isDirectory())
+ return false;
+
+ if (_vm->game() == GI_EOB1) {
+ if (argc == 1) {
+ if (_vm->saveAsOriginalSaveFile()) {
+ Common::FSNode nf = nd.getChild(Common::String::format("EOBDATA.SAV"));
+ if (nf.isReadable())
+ DebugPrintf("Saved to file: %s\n\n", nf.getPath().c_str());
+ else
+ DebugPrintf("Failure.\n");
+ } else {
+ DebugPrintf("Failure.\n");
+ }
+ } else {
+ DebugPrintf("Syntax: save_original\n (Saves game in original file format to a file which can be used with the orginal game executable.)\n\n");
+ }
+ return true;
+
+ } else if (argc == 2) {
+ int slot = atoi(argv[1]);
+ if (slot < 0 || slot > 5) {
+ DebugPrintf("Slot must be between (including) 0 and 5.\n");
+ } else if (_vm->saveAsOriginalSaveFile(slot)) {
+ Common::FSNode nf = nd.getChild(Common::String::format("EOBDATA%d.SAV", slot));
+ if (nf.isReadable())
+ DebugPrintf("Saved to file: %s\n\n", nf.getPath().c_str());
+ else
+ DebugPrintf("Failure.\n");
+ } else {
+ DebugPrintf("Failure.\n");
+ }
+ return true;
+ }
+
+ DebugPrintf("Syntax: save_original <slot>\n (Saves game in original file format to a file which can be used with the orginal game executable.\n A save slot between 0 and 5 must be specified.)\n\n");
+ return true;
+}
+
#endif // ENABLE_EOB
} // End of namespace Kyra
diff --git a/engines/kyra/debugger.h b/engines/kyra/debugger.h
index 2b1dcbe505..e4ab39102a 100644
--- a/engines/kyra/debugger.h
+++ b/engines/kyra/debugger.h
@@ -120,6 +120,7 @@ protected:
EoBCoreEngine *_vm;
bool cmd_importSaveFile(int argc, const char **argv);
+ bool cmd_saveOriginal(int argc, const char **argv);
};
#endif // ENABLE_EOB
diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp
index e422f3ea19..95c4accd29 100644
--- a/engines/kyra/detection.cpp
+++ b/engines/kyra/detection.cpp
@@ -298,7 +298,7 @@ SaveStateDescriptor KyraMetaEngine::querySaveMetaInfos(const char *target, int s
if (in) {
Kyra::KyraEngine_v1::SaveHeader header;
- Kyra::KyraEngine_v1::kReadSaveHeaderError error;
+ Kyra::KyraEngine_v1::ReadSaveHeaderError error;
error = Kyra::KyraEngine_v1::readSaveHeader(in, true, header);
delete in;
diff --git a/engines/kyra/detection_tables.h b/engines/kyra/detection_tables.h
index e2162f20e2..5c2b8fe1e8 100644
--- a/engines/kyra/detection_tables.h
+++ b/engines/kyra/detection_tables.h
@@ -53,7 +53,8 @@ namespace {
#define LOL_FLOPPY_FLAGS FLAGS(false, false, false, false, false, false, false, false, Kyra::GI_LOL)
#define LOL_FLOPPY_FAN_FLAGS(x, y) FLAGS_FAN(x, y, false, false, false, false, false, false, false, false, Kyra::GI_LOL)
#define LOL_FLOPPY_CMP_FLAGS FLAGS(false, false, false, false, false, false, false, true, Kyra::GI_LOL)
-#define LOL_PC98_SJIS_FLAGS FLAGS(false, false, false, false, true, true, false, false, Kyra::GI_LOL)
+#define LOL_PC9801_FLAGS FLAGS(false, false, false, false, true, true, false, false, Kyra::GI_LOL)
+#define LOL_FMTOWNS_FLAGS FLAGS(false, false, false, false, true, false, false, false, Kyra::GI_LOL)
#define LOL_DEMO_FLAGS FLAGS(true, true, false, false, false, false, false, false, Kyra::GI_LOL)
#define LOL_KYRA2_DEMO_FLAGS FLAGS(true, false, false, false, false, false, false, false, Kyra::GI_KYRA2)
@@ -1413,6 +1414,23 @@ const KYRAGameDescription adGameDescs[] = {
LOL_FLOPPY_FLAGS
},
+ { // French floppy version 1.20, bug #3608967 "Lands of Lore - french version 1.20 MD5"
+ {
+ "lol",
+ "Extracted",
+ {
+ {"GENERAL.PAK", 0, "a9e22c450c4f1de6a600261183430394", -1 },
+ {"CHAPTER7.PAK", 0, "fb5294f7445318876741c8db39ba0b1a", -1 },
+ { 0, 0, 0, 0 }
+ },
+ Common::FR_FRA,
+ Common::kPlatformPC,
+ ADGF_NO_FLAGS,
+ GUIO8(GUIO_NOSPEECH, GUIO_MIDIADLIB, GUIO_MIDIMT32, GUIO_MIDIGM, GUIO_MIDIPCSPK, GUIO_RENDERVGA, GAMEOPTION_LOL_SCROLLING, GAMEOPTION_LOL_CURSORS)
+ },
+ LOL_FLOPPY_FLAGS
+ },
+
{ // French floppy version 1.23, bug #3552534 "KYRA: LOL Floppy FR version unknown"
{
"lol",
@@ -1462,7 +1480,24 @@ const KYRAGameDescription adGameDescs[] = {
ADGF_NO_FLAGS,
GUIO5(GUIO_NOSPEECH, GUIO_MIDIPC98, GUIO_RENDERPC9801, GAMEOPTION_LOL_SCROLLING, GAMEOPTION_LOL_CURSORS)
},
- LOL_PC98_SJIS_FLAGS
+ LOL_PC9801_FLAGS
+ },
+
+ {
+ {
+ "lol",
+ 0,
+ {
+ { "GENERAL.PAK", 0, "2e4d4ce54bac9162e11fcba6907b576e", -1 },
+ { "TMUS.PAK", 0, "5543dae575164e51856f5a49cfd6b368", -1 },
+ { 0, 0, 0, 0 }
+ },
+ Common::JA_JPN,
+ Common::kPlatformFMTowns,
+ ADGF_NO_FLAGS,
+ GUIO5(GUIO_NOSPEECH, GUIO_MIDITOWNS, GUIO_RENDERFMTOWNS, GAMEOPTION_LOL_SCROLLING, GAMEOPTION_LOL_CURSORS)
+ },
+ LOL_FMTOWNS_FLAGS
},
{
@@ -1495,7 +1530,7 @@ const KYRAGameDescription adGameDescs[] = {
ADGF_DEMO,
GUIO5(GUIO_MIDIADLIB, GUIO_MIDIMT32, GUIO_MIDIGM, GUIO_MIDIPCSPK, GUIO_RENDERVGA)
},
- LOL_KYRA2_DEMO_FLAGS
+ LOL_DEMO_FLAGS
},
#endif // ENABLE_LOL
#ifdef ENABLE_EOB
diff --git a/engines/kyra/eob.cpp b/engines/kyra/eob.cpp
index a7bde9f1ee..1fb4d0a790 100644
--- a/engines/kyra/eob.cpp
+++ b/engines/kyra/eob.cpp
@@ -316,7 +316,7 @@ void EoBEngine::runNpcDialogue(int npcIndex) {
void EoBEngine::updateUsedCharacterHandItem(int charIndex, int slot) {
EoBItem *itm = &_items[_characters[charIndex].inventory[slot]];
if (itm->type == 48) {
- int charges = itm->flags & 0x3f;
+ int charges = itm->flags & 0x3F;
if (--charges)
--itm->flags;
else
@@ -359,7 +359,7 @@ void EoBEngine::loadDoorShapes(int doorType1, int shapeId1, int doorType2, int s
_screen->loadShapeSetBitmap("DOOR", 5, 3);
_screen->_curPage = 2;
- if (doorType1 != 0xff) {
+ if (doorType1 != 0xFF) {
for (int i = 0; i < 3; i++) {
const uint8 *enc = &_doorShapeEncodeDefs[(doorType1 * 3 + i) << 2];
_doorShapes[shapeId1 + i] = _screen->encodeShape(enc[0], enc[1], enc[2], enc[3], false, (_flags.gameID == GI_EOB1) ? _cgaMappingLevel[_cgaLevelMappingIndex[_currentLevel - 1]] : 0);
@@ -370,7 +370,7 @@ void EoBEngine::loadDoorShapes(int doorType1, int shapeId1, int doorType2, int s
}
}
- if (doorType2 != 0xff) {
+ if (doorType2 != 0xFF) {
for (int i = 0; i < 3; i++) {
const uint8 *enc = &_doorShapeEncodeDefs[(doorType2 * 3 + i) << 2];
_doorShapes[shapeId2 + i] = _screen->encodeShape(enc[0], enc[1], enc[2], enc[3], false, (_flags.gameID == GI_EOB1) ? _cgaMappingLevel[_cgaLevelMappingIndex[_currentLevel - 1]] : 0);
@@ -387,6 +387,8 @@ void EoBEngine::loadDoorShapes(int doorType1, int shapeId1, int doorType2, int s
void EoBEngine::drawDoorIntern(int type, int index, int x, int y, int w, int wall, int mDim, int16 y1, int16 y2) {
int shapeIndex = type + 2 - mDim;
uint8 *shp = _doorShapes[shapeIndex];
+ if (!shp)
+ return;
int d1 = 0;
int d2 = 0;
@@ -460,7 +462,7 @@ void EoBEngine::turnUndeadAuto() {
int oc = _openBookChar;
for (int i = 0; i < 6; i++) {
- if (!testCharacter(i, 0x0d))
+ if (!testCharacter(i, 0x0D))
continue;
EoBCharacter *c = &_characters[i];
@@ -505,7 +507,7 @@ bool EoBEngine::checkPartyStatusExtra() {
_txt->printMessage(_menuStringsDefeat[0]);
while (!shouldQuit()) {
removeInputTop();
- if (checkInput(0, false, 0) & 0xff)
+ if (checkInput(0, false, 0) & 0xFF)
break;
}
_screen->copyPage(10, 0);
diff --git a/engines/kyra/eob.h b/engines/kyra/eob.h
index 37ce483702..bf5440b942 100644
--- a/engines/kyra/eob.h
+++ b/engines/kyra/eob.h
@@ -99,7 +99,7 @@ private:
void turnUndeadAuto();
void turnUndeadAutoHit();
- const char * const *_turnUndeadString;
+ const char *const *_turnUndeadString;
// Misc
bool checkPartyStatusExtra();
@@ -113,8 +113,7 @@ private:
static const uint8 _egaDefaultPalette[];
};
-
-} // End of namespace Kyra
+} // End of namespace Kyra
#endif
diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp
index fadb1066e0..d477209e5b 100644
--- a/engines/kyra/eobcommon.cpp
+++ b/engines/kyra/eobcommon.cpp
@@ -57,7 +57,7 @@ EoBCoreEngine::EoBCoreEngine(OSystem *system, const GameFlags &flags)
_configMouse = true;
_loading = false;
- _useHiResDithering = false;
+ _enableHiResDithering = false;
_envAudioTimer = 0;
_flashShapeTimer = 0;
@@ -364,14 +364,14 @@ void EoBCoreEngine::initKeymap() {
}
Common::Error EoBCoreEngine::init() {
- // In EOB the timer proc is directly invoked via interrupt 0x1c, 18.2 times per second.
+ // In EOB the timer proc is directly invoked via interrupt 0x1C, 18.2 times per second.
// This makes a tick length of 54.94.
_tickLength = 55;
if (ConfMan.hasKey("render_mode"))
_configRenderMode = Common::parseRenderMode(ConfMan.get("render_mode"));
- _useHiResDithering = (_configRenderMode == Common::kRenderEGA && _flags.useHiRes);
+ _enableHiResDithering = (_configRenderMode == Common::kRenderEGA && _flags.useHiRes);
_screen = new Screen_EoB(this, _system);
assert(_screen);
@@ -417,12 +417,6 @@ Common::Error EoBCoreEngine::init() {
_screen->loadFont(Screen::FID_6_FNT, "FONT6.FNT");
_screen->loadFont(Screen::FID_8_FNT, "FONT8.FNT");
- if (_useHiResDithering) {
- _vcnBlockWidth <<= 1;
- _vcnBlockHeight <<= 1;
- SWAP(_vcnFlip0, _vcnFlip1);
- }
-
Common::Error err = KyraRpgEngine::init();
if (err.getCode() != Common::kNoError)
return err;
@@ -494,8 +488,8 @@ Common::Error EoBCoreEngine::init() {
_monsterFlashOverlay = new uint8[16];
_monsterStoneOverlay = new uint8[16];
- memset(_monsterFlashOverlay, (_configRenderMode == Common::kRenderCGA) ? 0xff : 0x0f, 16 * sizeof(uint8));
- memset(_monsterStoneOverlay, 0x0d, 16 * sizeof(uint8));
+ memset(_monsterFlashOverlay, (_configRenderMode == Common::kRenderCGA) ? 0xFF : 0x0F, 16 * sizeof(uint8));
+ memset(_monsterStoneOverlay, 0x0D, 16 * sizeof(uint8));
_monsterFlashOverlay[0] = _monsterStoneOverlay[0] = 0;
// Prevent autosave on game startup
@@ -991,7 +985,7 @@ void EoBCoreEngine::recalcArmorClass(int index) {
int tp = _items[itm].type;
- if (!(_itemTypes[tp].allowedClasses & _classModifierFlags[c->cClass]) || (_itemTypes[tp].extraProperties & 0x7f) || (i >= 1 && i <= 2 && tp != 27 && !(_flags.gameID == GI_EOB2 && tp == 57)))
+ if (!(_itemTypes[tp].allowedClasses & _classModifierFlags[c->cClass]) || (_itemTypes[tp].extraProperties & 0x7F) || (i >= 1 && i <= 2 && tp != 27 && !(_flags.gameID == GI_EOB2 && tp == 57)))
continue;
c->armorClass += _itemTypes[tp].armorClass;
@@ -1003,12 +997,12 @@ void EoBCoreEngine::recalcArmorClass(int index) {
int8 m2 = 0;
if (c->inventory[25]) {
- if (!(_itemTypes[_items[c->inventory[25]].type].extraProperties & 0x7f))
+ if (!(_itemTypes[_items[c->inventory[25]].type].extraProperties & 0x7F))
m1 = _items[c->inventory[25]].value;
}
if (c->inventory[26]) {
- if (!(_itemTypes[_items[c->inventory[26]].type].extraProperties & 0x7f))
+ if (!(_itemTypes[_items[c->inventory[26]].type].extraProperties & 0x7F))
m2 = _items[c->inventory[26]].value;
}
@@ -1060,7 +1054,7 @@ int EoBCoreEngine::validateWeaponSlotItem(int index, int slot) {
if (!itm2)
return 1;
- int f = (_itemTypes[tp2].extraProperties & 0x7f);
+ int f = (_itemTypes[tp2].extraProperties & 0x7F);
if (f <= 0 || f > 3)
return r;
@@ -1275,12 +1269,12 @@ void EoBCoreEngine::removeCharacterFromParty(int charIndex) {
if (i == 16 || !c->inventory[i])
continue;
- setItemPosition((Item *)&_levelBlockProperties[_currentBlock & 0x3ff].drawObjects, _currentBlock, c->inventory[i], _dropItemDirIndex[(_currentDirection << 2) + rollDice(1, 2, -1)]);
+ setItemPosition((Item *)&_levelBlockProperties[_currentBlock & 0x3FF].drawObjects, _currentBlock, c->inventory[i], _dropItemDirIndex[(_currentDirection << 2) + rollDice(1, 2, -1)]);
c->inventory[i] = 0;
}
while (c->inventory[16])
- setItemPosition((Item *)&_levelBlockProperties[_currentBlock & 0x3ff].drawObjects, _currentBlock, getQueuedItem(&c->inventory[16], 0, -1), _dropItemDirIndex[(_currentDirection << 2) + rollDice(1, 2, -1)]);
+ setItemPosition((Item *)&_levelBlockProperties[_currentBlock & 0x3FF].drawObjects, _currentBlock, getQueuedItem(&c->inventory[16], 0, -1), _dropItemDirIndex[(_currentDirection << 2) + rollDice(1, 2, -1)]);
c->inventory[16] = 0;
@@ -1326,7 +1320,7 @@ void EoBCoreEngine::increaseCharacterExperience(int charIndex, int32 points) {
_characters[charIndex].experience[i] += points;
uint32 er = getRequiredExperience(cl, i, _characters[charIndex].level[i] + 1);
- if (er == 0xffffffff)
+ if (er == 0xFFFFFFFF)
continue;
if (_characters[charIndex].experience[i] >= er)
@@ -1337,7 +1331,7 @@ void EoBCoreEngine::increaseCharacterExperience(int charIndex, int32 points) {
uint32 EoBCoreEngine::getRequiredExperience(int cClass, int levelIndex, int level) {
cClass = getCharacterClassType(cClass, levelIndex);
if (cClass == -1)
- return 0xffffffff;
+ return 0xFFFFFFFF;
const uint32 *tbl = _expRequirementTables[cClass];
return tbl[level - 1];
@@ -1625,7 +1619,7 @@ void EoBCoreEngine::displayParchment(int id) {
removeInputTop();
while (!shouldQuit()) {
delay(_tickLength);
- if (checkInput(0, false, 0) & 0xff)
+ if (checkInput(0, false, 0) & 0xFF)
break;
removeInputTop();
}
@@ -1658,7 +1652,7 @@ int EoBCoreEngine::countResurrectionCandidates() {
if (!inv)
continue;
- if ((_flags.gameID == GI_EOB1 && ((_itemTypes[_items[inv].type].extraProperties & 0x7f) != 8)) || (_flags.gameID == GI_EOB2 && _items[inv].type != 33))
+ if ((_flags.gameID == GI_EOB1 && ((_itemTypes[_items[inv].type].extraProperties & 0x7F) != 8)) || (_flags.gameID == GI_EOB2 && _items[inv].type != 33))
continue;
_rrNames[_rrCount] = _npcPreset[_items[inv].value - 1].name;
@@ -1667,7 +1661,7 @@ int EoBCoreEngine::countResurrectionCandidates() {
}
if (_itemInHand > 0) {
- if ((_flags.gameID == GI_EOB1 && ((_itemTypes[_items[_itemInHand].type].extraProperties & 0x7f) == 8)) || (_flags.gameID == GI_EOB2 && _items[_itemInHand].type == 33)) {
+ if ((_flags.gameID == GI_EOB1 && ((_itemTypes[_items[_itemInHand].type].extraProperties & 0x7F) == 8)) || (_flags.gameID == GI_EOB2 && _items[_itemInHand].type == 33)) {
_rrNames[_rrCount] = _npcPreset[_items[_itemInHand].value - 1].name;
_rrId[_rrCount++] = -_items[_itemInHand].value;
}
@@ -1748,7 +1742,7 @@ void EoBCoreEngine::seq_portal() {
bool EoBCoreEngine::checkPassword() {
char answ[20];
Screen::FontId of = _screen->setFont(Screen::FID_8_FNT);
- _screen->copyPage(0, _useHiResDithering ? 4 : 10);
+ _screen->copyPage(0, 10);
_screen->setScreenDim(13);
gui_drawBox(_screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, guiSettings()->colors.frame1, guiSettings()->colors.frame2, -1);
@@ -1775,7 +1769,7 @@ bool EoBCoreEngine::checkPassword() {
_screen->modifyScreenDim(13, _screen->_curDim->sx - 1, _screen->_curDim->sy - 2, _screen->_curDim->w + 2, _screen->_curDim->h + 16);
_screen->setFont(of);
- _screen->copyPage(_useHiResDithering ? 4 : 10, 0);
+ _screen->copyPage(10, 0);
return true;
}
@@ -1786,7 +1780,7 @@ void EoBCoreEngine::useSlotWeapon(int charIndex, int slotIndex, Item item) {
if (c->effectFlags & 0x40)
removeCharacterEffect(10, charIndex, 1); // remove invisibility effect
- int ep = _itemTypes[tp].extraProperties & 0x7f;
+ int ep = _itemTypes[tp].extraProperties & 0x7F;
int8 inflict = 0;
if (ep == 1) {
@@ -1829,14 +1823,14 @@ int EoBCoreEngine::closeDistanceAttack(int charIndex, Item item) {
if (r == -1) {
uint8 w = _specialWallTypes[_levelBlockProperties[d].walls[_sceneDrawVarDown]];
- if (w == 0xff) {
+ if (w == 0xFF) {
if (_flags.gameID == GI_EOB1) {
_levelBlockProperties[d].walls[_sceneDrawVarDown]++;
_levelBlockProperties[d].walls[_sceneDrawVarDown ^ 2]++;
} else {
for (int i = 0; i < 4; i++) {
- if (_specialWallTypes[_levelBlockProperties[d].walls[i]] == 0xff)
+ if (_specialWallTypes[_levelBlockProperties[d].walls[i]] == 0xFF)
_levelBlockProperties[d].walls[i]++;
}
}
@@ -1927,7 +1921,7 @@ int EoBCoreEngine::projectileWeaponAttack(int charIndex, Item item) {
void EoBCoreEngine::inflictMonsterDamage(EoBMonsterInPlay *m, int damage, bool giveExperience) {
m->hitPointsCur -= damage;
- m->flags = (m->flags & 0xf7) | 1;
+ m->flags = (m->flags & 0xF7) | 1;
if (_monsterProps[m->type].capsFlags & 0x2000) {
explodeMonster(m);
@@ -2033,7 +2027,7 @@ bool EoBCoreEngine::characterAttackHitTest(int charIndex, int monsterIndex, int
if (charIndex < 0)
return true;
- int p = item ? (_flags.gameID == GI_EOB1 ? _items[item].type : (_itemTypes[_items[item].type].extraProperties & 0x7f)) : 0;
+ int p = item ? (_flags.gameID == GI_EOB1 ? _items[item].type : (_itemTypes[_items[item].type].extraProperties & 0x7F)) : 0;
if (_monsters[monsterIndex].flags & 0x20)
return true;// EOB 2 only ?
@@ -2212,7 +2206,7 @@ void EoBCoreEngine::statusAttack(int charIndex, int attackStatusFlags, const cha
c->flags |= attackStatusFlags;
}
- if ((attackStatusFlags & 0x0c) && (_openBookChar == charIndex) && _updateFlags) {
+ if ((attackStatusFlags & 0x0C) && (_openBookChar == charIndex) && _updateFlags) {
Button b;
clickedSpellbookAbort(&b);
}
@@ -2318,7 +2312,7 @@ int EoBCoreEngine::getSaveThrowModifier(int hpModifier, int level, int type) {
}
bool EoBCoreEngine::calcDamageCheckItemType(int itemType) {
- itemType = _itemTypes[itemType].extraProperties & 0x7f;
+ itemType = _itemTypes[itemType].extraProperties & 0x7F;
return (itemType == 2 || itemType == 3) ? true : false;
}
diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h
index f60e755dd7..1a74321364 100644
--- a/engines/kyra/eobcommon.h
+++ b/engines/kyra/eobcommon.h
@@ -722,21 +722,21 @@ protected:
void gui_processWeaponSlotClickRight(int charIndex, int slotIndex);
void gui_processInventorySlotClick(int slot);
- static const int16 _buttonList1[];
+ static const uint8 _buttonList1[];
int _buttonList1Size;
- static const int16 _buttonList2[];
+ static const uint8 _buttonList2[];
int _buttonList2Size;
- static const int16 _buttonList3[];
+ static const uint8 _buttonList3[];
int _buttonList3Size;
- static const int16 _buttonList4[];
+ static const uint8 _buttonList4[];
int _buttonList4Size;
- static const int16 _buttonList5[];
+ static const uint8 _buttonList5[];
int _buttonList5Size;
- static const int16 _buttonList6[];
+ static const uint8 _buttonList6[];
int _buttonList6Size;
- static const int16 _buttonList7[];
+ static const uint8 _buttonList7[];
int _buttonList7Size;
- static const int16 _buttonList8[];
+ static const uint8 _buttonList8[];
int _buttonList8Size;
const EoBGuiButtonDef *_buttonDefs;
@@ -845,11 +845,12 @@ protected:
const uint8 *_cgaMappingLevel[5];
const uint8 *_cgaLevelMappingIndex;
- bool _useHiResDithering;
+ bool _enableHiResDithering;
// Default parameters will import all present original save files and push them to the top of the save dialog.
bool importOriginalSaveFile(int destSlot, const char *sourceFile = 0);
Common::String readOriginalSaveFile(Common::String &file);
+ bool saveAsOriginalSaveFile(int slot = -1);
void *generateMonsterTempData(LevelTempData *tmp);
void restoreMonsterTempData(LevelTempData *tmp);
@@ -858,11 +859,11 @@ protected:
void restoreWallOfForceTempData(LevelTempData *tmp);
void releaseWallOfForceTempData(LevelTempData *tmp);
- const char * const *_saveLoadStrings;
+ const char *const *_saveLoadStrings;
const uint8 *_mnDef;
- const char * const *_mnWord;
- const char * const *_mnPrompt;
+ const char *const *_mnWord;
+ const char *const *_mnPrompt;
int _mnNumWord;
int _rrCount;
diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp
index e3c0743e5c..9b4c09d7f4 100644
--- a/engines/kyra/gui_eob.cpp
+++ b/engines/kyra/gui_eob.cpp
@@ -86,7 +86,7 @@ void EoBCoreEngine::gui_drawCharPortraitWithStats(int index) {
int txtCol1 = 12;
int txtCol2 = 15;
- if ((_flags.gameID == GI_EOB1 && c->flags & 6) || (_flags.gameID == GI_EOB2 && c->flags & 0x0e)) {
+ if ((_flags.gameID == GI_EOB1 && c->flags & 6) || (_flags.gameID == GI_EOB2 && c->flags & 0x0E)) {
txtCol1 = 8;
txtCol2 = 6;
}
@@ -285,7 +285,7 @@ void EoBCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) {
else
_screen->drawShape(_screen->_curPage, _itemIconShapes[85 + slot], x + 8, y, 0);
- if ((_characters[charIndex].disabledSlots & (1 << slot)) || !validateWeaponSlotItem(charIndex, slot) || (_characters[charIndex].hitPointsCur <= 0) || (_characters[charIndex].flags & 0x0c))
+ if ((_characters[charIndex].disabledSlots & (1 << slot)) || !validateWeaponSlotItem(charIndex, slot) || (_characters[charIndex].hitPointsCur <= 0) || (_characters[charIndex].flags & 0x0C))
_screen->drawShape(_screen->_curPage, _weaponSlotGrid, x, y, 0);
}
@@ -321,7 +321,7 @@ void EoBCoreEngine::gui_drawWeaponSlotStatus(int x, int y, int status) {
break;
}
- int textColor= (_configRenderMode == Common::kRenderCGA) ? 2 : 15;
+ int textColor = (_configRenderMode == Common::kRenderCGA) ? 2 : 15;
if (!tmpStr2.empty()) {
_screen->printText(tmpStr.c_str(), x + (16 - tmpStr.size() * 3), y + 2, textColor, 0);
@@ -485,7 +485,7 @@ void EoBCoreEngine::gui_drawInventoryItem(int slot, int special, int pageNum) {
uint8 col1 = guiSettings()->colors.frame1;
uint8 col2 = guiSettings()->colors.frame2;
- if (_configRenderMode == Common::kRenderCGA ) {
+ if (_configRenderMode == Common::kRenderCGA) {
col1 = 1;
col2 = 3;
}
@@ -777,11 +777,11 @@ int EoBCoreEngine::clickedCamp(Button *button) {
}
_screen->copyPage(0, 7);
- _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, _useHiResDithering ? 1 : 12, Screen::CR_NO_P_CHECK);
+ _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 12, Screen::CR_NO_P_CHECK);
_gui->runCampMenu();
- _screen->copyRegion(0, 0, 0, 120, 176, 24, _useHiResDithering ? 1 : 12, 2, Screen::CR_NO_P_CHECK);
+ _screen->copyRegion(0, 0, 0, 120, 176, 24, 12, 2, Screen::CR_NO_P_CHECK);
_screen->setScreenDim(cd);
drawScene(0);
@@ -808,13 +808,13 @@ int EoBCoreEngine::clickedSceneDropPickupItem(Button *button) {
if (button->arg > 1) {
block = calcNewBlockPosition(_currentBlock, _currentDirection);
int f = _wllWallFlags[_levelBlockProperties[block].walls[_sceneDrawVarDown]];
- if (!(f & 0x0b))
+ if (!(f & 0x0B))
return 1;
}
int d = _dropItemDirIndex[(_currentDirection << 2) + button->arg];
if (_itemInHand) {
- setItemPosition((Item *)&_levelBlockProperties[block & 0x3ff].drawObjects, block, _itemInHand, d);
+ setItemPosition((Item *)&_levelBlockProperties[block & 0x3FF].drawObjects, block, _itemInHand, d);
setHandItem(0);
runLevelScript(block, 4);
} else {
@@ -856,7 +856,7 @@ int EoBCoreEngine::clickedWeaponSlot(Button *button) {
static const uint8 sY[] = { 27, 27, 79, 79, 131, 131 };
int slot = sY[button->arg] > _mouseY ? 0 : 1;
- if ((_gui->_flagsMouseLeft & 0x7f) == 1)
+ if ((_gui->_flagsMouseLeft & 0x7F) == 1)
gui_processWeaponSlotClickLeft(button->arg, slot);
else
gui_processWeaponSlotClickRight(button->arg, slot);
@@ -1031,9 +1031,9 @@ int EoBCoreEngine::clickedSpellbookList(Button *button) {
}
int EoBCoreEngine::clickedCastSpellOnCharacter(Button *button) {
- _activeSpellCharId = button->arg & 0xff;
+ _activeSpellCharId = button->arg & 0xFF;
- if (_activeSpellCharId == 0xff) {
+ if (_activeSpellCharId == 0xFF) {
printWarning(_magicStrings3[_flags.gameID == GI_EOB1 ? 2 : 1]);
if (_castScrollSlot) {
gui_updateSlotAfterScrollUse();
@@ -1170,7 +1170,7 @@ int EoBCoreEngine::clickedSceneSpecial(Button *button) {
int EoBCoreEngine::clickedSpellbookAbort(Button *button) {
_updateFlags = 0;
- _screen->copyRegion(0, 0, 64, 121, 112, 56, _useHiResDithering ? 4 : 10, 0, Screen::CR_NO_P_CHECK);
+ _screen->copyRegion(0, 0, 64, 121, 112, 56, 10, 0, Screen::CR_NO_P_CHECK);
_screen->updateScreen();
gui_drawCompass(true);
gui_toggleButtons();
@@ -1215,7 +1215,7 @@ void EoBCoreEngine::gui_processWeaponSlotClickLeft(int charIndex, int slotIndex)
int ih = _itemInHand;
int t = _items[ih].type;
- uint16 v = (ih) ? _itemTypes[t].invFlags : 0xffff;
+ uint16 v = (ih) ? _itemTypes[t].invFlags : 0xFFFF;
if (v & _slotValidationFlags[slotIndex]) {
setHandItem(itm);
@@ -1227,7 +1227,7 @@ void EoBCoreEngine::gui_processWeaponSlotClickLeft(int charIndex, int slotIndex)
}
void EoBCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex) {
- if (!testCharacter(charIndex, 0x0d))
+ if (!testCharacter(charIndex, 0x0D))
return;
Item itm = _characters[charIndex].inventory[slotIndex];
@@ -1244,7 +1244,7 @@ void EoBCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex
int8 tp = _items[itm].type;
int8 vl = _items[itm].value;
- uint8 ep = _itemTypes[tp].extraProperties & 0x7f;
+ uint8 ep = _itemTypes[tp].extraProperties & 0x7F;
switch (ep) {
case 0:
@@ -1300,24 +1300,24 @@ void EoBCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex
case 14:
// Potion
- usePotion(charIndex, wslot);
+ usePotion(charIndex, slotIndex);
break;
case 18:
- useWand(charIndex, wslot);
+ useWand(charIndex, slotIndex);
break;
case 19:
// eob2 horn
- useHorn(charIndex, wslot);
+ useHorn(charIndex, slotIndex);
break;
case 20:
if (vl == 1)
inflictCharacterDamage(charIndex, 200);
else
- useMagicScroll(charIndex, 55, wslot);
- deleteInventoryItem(charIndex, wslot);
+ useMagicScroll(charIndex, 55, slotIndex);
+ deleteInventoryItem(charIndex, slotIndex);
break;
default:
@@ -1376,7 +1376,7 @@ GUI_EoB::GUI_EoB(EoBCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) {
_backupButtonList = 0;
_progress = 0;
_prcButtonUnk3 = 1;
- _cflag = 0xffff;
+ _cflag = 0xFFFF;
_menuLineSpacing = 0;
_menuLastInFlags = 0;
@@ -1385,8 +1385,8 @@ GUI_EoB::GUI_EoB(EoBCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) {
_numPages = (_vm->game() == GI_EOB2) ? 8 : 5;
_numVisPages = (_vm->game() == GI_EOB2) ? 6 : 5;
- _clericSpellAvltyFlags = (_vm->game() == GI_EOB2) ? 0xf7ffffff : 0x7bffff;
- _paladinSpellAvltyFlags = (_vm->game() == GI_EOB2) ? 0xa9bbd1d : 0x800ff2;
+ _clericSpellAvltyFlags = (_vm->game() == GI_EOB2) ? 0xF7FFFFFF : 0x7BFFFF;
+ _paladinSpellAvltyFlags = (_vm->game() == GI_EOB2) ? 0xA9BBD1D : 0x800FF2;
_numAssignedSpellsOfType = new int8[72];
memset(_numAssignedSpellsOfType, 0, 72);
@@ -1524,7 +1524,7 @@ void GUI_EoB::processButton(Button *button) {
int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 mouseWheel) {
_progress = 0;
- uint16 in = inputFlags & 0xff;
+ uint16 in = inputFlags & 0xFF;
uint16 buttonReleaseFlag = 0;
bool clickEvt = false;
//_vm->_processingButtons = true;
@@ -1543,13 +1543,13 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
////////////////////////////
if (!buttonList && !(inputFlags & 0x800))
- return inputFlags & 0xff;
+ return inputFlags & 0xFF;
////////////////////////////
inputFlags = 0;
clickEvt = true;
} else if (inputFlags & 0x8000) {
- inputFlags &= 0xff;
+ inputFlags &= 0xFF;
}
uint16 result = 0;
@@ -1568,8 +1568,8 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
// UNUSED
//if (buttonList->flags2 & 0x20) {
- //if (_processButtonListExtraCallback)
- // this->*_processButtonListExtraCallback(buttonList);
+ // if (_processButtonListExtraCallback)
+ // this->*_processButtonListExtraCallback(buttonList);
//}
if (buttonList->nextButton)
@@ -1582,7 +1582,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
_specialProcessButton = 0;
_prcButtonUnk3 = 1;
- _cflag = 0xffff;
+ _cflag = 0xFFFF;
}
int sd = 0;
@@ -1616,12 +1616,12 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
if (flgs2 & 1)
flgs2 |= 8;
else
- flgs2 &= 0xfff7;
+ flgs2 &= 0xFFF7;
if (flgs2 & 4)
flgs2 |= 0x10;
else
- flgs2 &= 0xffef;
+ flgs2 &= 0xFFEF;
uint16 vL = 0;
uint16 vR = 0;
@@ -1640,8 +1640,8 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
v6 = 1;
}
} else if (_flagsModifier || clickEvt) {
- vL = flgs & 0xf00;
- vR = flgs & 0xf000;
+ vL = flgs & 0xF00;
+ vR = flgs & 0xF000;
if (_prcButtonUnk3) {
if (sd != buttonList->dimTableIndex) {
@@ -1675,7 +1675,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
flgs2 |= 4;
vc = 1;
} else {
- flgs2 &= 0xfffb;
+ flgs2 &= 0xFFFB;
}
if (flgs & 0x100) {
@@ -1702,7 +1702,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
flgs2 |= 4;
vc = 1;
} else {
- flgs2 &= 0xfffb;
+ flgs2 &= 0xFFFB;
}
if (!(flgs & 0x200))
@@ -1730,12 +1730,12 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
}
if ((flgs & 2) && (flgs2 & 1))
- flgs2 &= 0xfffe;
+ flgs2 &= 0xFFFE;
break;
case 3:
if ((flgs & 4) || (!buttonList->data2Val1))
- flgs2 &= 0xfffb;
+ flgs2 &= 0xFFFB;
else
flgs2 |= 4;
@@ -1745,7 +1745,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
}
if ((flgs & 2) && (flgs2 & 1))
- flgs2 &= 0xfffe;
+ flgs2 &= 0xFFFE;
break;
default:
@@ -1761,7 +1761,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
if ((flgs & 4) && buttonList->data2Val1)
flgs2 |= 4;
else
- flgs2 &= 0xfffb;
+ flgs2 &= 0xFFFB;
if (flgs & 0x1000) {
v6 = 1;
@@ -1786,7 +1786,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
if ((flgs & 4) && buttonList->data2Val1)
flgs2 |= 4;
else
- flgs2 &= 0xfffb;
+ flgs2 &= 0xFFFB;
if (!(flgs & 0x2000))
break;
@@ -1812,12 +1812,12 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
}
if ((flgs & 2) && (flgs2 & 1))
- flgs2 &= 0xfffe;
+ flgs2 &= 0xFFFE;
break;
case 3:
if ((flgs & 4) || (!buttonList->data2Val1))
- flgs2 &= 0xfffb;
+ flgs2 &= 0xFFFB;
else
flgs2 |= 4;
@@ -1827,7 +1827,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
}
if ((flgs & 2) && (flgs2 & 1))
- flgs2 &= 0xfffe;
+ flgs2 &= 0xFFFE;
break;
default:
@@ -1835,7 +1835,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
}
}
} else { // if (_vm->_mouseX >= x2 && _vm->_mouseX <= (x2 + buttonList->width)....)
- flgs2 &= 0xfff9;
+ flgs2 &= 0xFFF9;
if ((flgs & 0x40) && (!(flgs & 0x80)) && _specialProcessButton && !v8) {
static const uint16 flagsTable[] = { 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000 };
@@ -1859,7 +1859,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
}
if ((flgs & 2) && (flgs2 & 1))
- flgs2 &= 0xfffe;
+ flgs2 &= 0xFFFE;
} // end if (_vm->_mouseX >= x2 && _vm->_mouseX <= (x2 + buttonList->width)....)
} // end if (_prcButtonUnk3)
} // end if (_flagsModifier || clickEvt)
@@ -1896,7 +1896,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
};
if ((_flagsMouseLeft == 1 || _flagsMouseRight == 1) && !v18)
- _cflag = 0xffff;
+ _cflag = 0xFFFF;
if (!result)
result = inputFlags;
@@ -1938,7 +1938,7 @@ int GUI_EoB::simpleMenu_process(int sd, const char *const *strings, void *b, int
int x = (_screen->_curDim->sx + dm->sx) << 3;
int y = _screen->_curDim->sy + dm->sy;
- int inFlag = _vm->checkInput(0, false, 0) & 0x8ff;
+ int inFlag = _vm->checkInput(0, false, 0) & 0x8FF;
_vm->removeInputTop();
Common::Point mousePos = _vm->getMousePos();
@@ -2051,16 +2051,15 @@ void GUI_EoB::runCampMenu() {
newMenu = -1;
}
- int inputFlag = _vm->checkInput(buttonList, false, 0) & 0x80ff;
+ int inputFlag = _vm->checkInput(buttonList, false, 0) & 0x80FF;
_vm->removeInputTop();
if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE])
inputFlag = 0x8007;
- else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP5] || inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) {
+ else if (prevHighlightButton && (inputFlag == _vm->_keyMap[Common::KEYCODE_KP5] || inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]))
inputFlag = 0x8000 + prevHighlightButton->index;
- }
- Button *clickedButton = _vm->gui_getButton(buttonList, inputFlag & 0x7fff);
+ Button *clickedButton = _vm->gui_getButton(buttonList, inputFlag & 0x7FFF);
if (clickedButton) {
drawMenuButton(prevHighlightButton, false, false, true);
@@ -2140,8 +2139,8 @@ void GUI_EoB::runCampMenu() {
displayTextBox(44);
// fall through
- case 0x800c:
- case 0x800f:
+ case 0x800C:
+ case 0x800F:
if (lastMenu == 1 || lastMenu == 2)
newMenu = 0;
else if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE])
@@ -2163,7 +2162,7 @@ void GUI_EoB::runCampMenu() {
newMenu = 1;
break;
- case 0x800a:
+ case 0x800A:
for (; i < 6; i++) {
if (_vm->testCharacter(i, 1))
cnt++;
@@ -2172,7 +2171,7 @@ void GUI_EoB::runCampMenu() {
if (cnt > 4) {
_vm->dropCharacter(selectCharacterDialogue(53));
_vm->gui_drawPlayField(false);
- _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, _vm->_useHiResDithering ? 1 : 12, Screen::CR_NO_P_CHECK);
+ _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 12, Screen::CR_NO_P_CHECK);
_screen->setFont(Screen::FID_6_FNT);
_vm->gui_drawAllCharPortraitsWithStats();
_screen->setFont(Screen::FID_8_FNT);
@@ -2183,19 +2182,19 @@ void GUI_EoB::runCampMenu() {
newMenu = 0;
break;
- case 0x800b:
+ case 0x800B:
if (confirmDialogue(46))
_vm->quitGame();
newMenu = 0;
break;
- case 0x800d:
+ case 0x800D:
_vm->_configSounds ^= true;
_vm->_configMusic = _vm->_configSounds ? 1 : 0;
newMenu = 2;
break;
- case 0x800e:
+ case 0x800E:
_vm->_configHpBarGraphs ^= true;
newMenu = 2;
redrawPortraits = true;
@@ -2290,7 +2289,7 @@ bool GUI_EoB::confirmDialogue2(int dim, int id, int deflt) {
else if (_vm->posWithinRect(p.x, p.y, x[1], y, x[1] + 32, y + 14))
newHighlight = 1;
- int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff;
+ int inputFlag = _vm->checkInput(0, false, 0) & 0x8FF;
_vm->removeInputTop();
if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) {
@@ -2351,7 +2350,7 @@ void GUI_EoB::messageDialogue(int dim, int id, int buttonTextCol) {
_screen->updateScreen();
for (bool runLoop = true; runLoop && !_vm->shouldQuit();) {
- int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff;
+ int inputFlag = _vm->checkInput(0, false, 0) & 0x8FF;
_vm->removeInputTop();
if (inputFlag == 199 || inputFlag == 201) {
@@ -2392,7 +2391,7 @@ void GUI_EoB::messageDialogue2(int dim, int id, int buttonTextCol) {
_screen->updateScreen();
for (bool runLoop = true; runLoop && !_vm->shouldQuit();) {
- int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff;
+ int inputFlag = _vm->checkInput(0, false, 0) & 0x8FF;
_vm->removeInputTop();
if (inputFlag == 199 || inputFlag == 201) {
@@ -2607,7 +2606,7 @@ Common::String GUI_EoB::transferTargetMenu(Common::Array<Common::String> &target
break;
} while (_saveSlotIdTemp[slot] == -1);
- _screen->copyRegion(72, 14, 72, 14, 176, 144, _vm->_useHiResDithering ? 7 : 12, 0, Screen::CR_NO_P_CHECK);
+ _screen->copyRegion(72, 14, 72, 14, 176, 144, 12, 0, Screen::CR_NO_P_CHECK);
_screen->modifyScreenDim(11, xo, yo, dm->w, dm->h);
return (slot < 6) ? _savegameList[_savegameOffset + slot] : Common::String();
@@ -2650,7 +2649,7 @@ void GUI_EoB::createScreenThumbnail(Graphics::Surface &dst) {
_screen->getRealPalette(0, screenPal);
uint16 width = Screen::SCREEN_W;
uint16 height = Screen::SCREEN_H;
- if (_vm->_useHiResDithering) {
+ if (_vm->gameFlags().useHiRes) {
width <<= 1;
height <<= 1;
}
@@ -2705,11 +2704,20 @@ bool GUI_EoB::runSaveMenu(int x, int y) {
for (int in = -1; in == -1 && !_vm->shouldQuit();) {
_screen->fillRect(fx - 2, fy, fx + 160, fy + 8, _vm->guiSettings()->colors.fill);
in = getTextInput(_saveSlotStringsTemp[slot], x + 1, fy, 19, 2, 0, 8);
+ if (in == -1) {
+ useSlot = false;
+ break;
+ }
+
if (!strlen(_saveSlotStringsTemp[slot])) {
messageDialogue(11, 54, 6);
in = -1;
}
- };
+ }
+
+ if (!useSlot) {
+ continue;
+ }
_screen->fillRect(fx - 2, fy, fx + 160, fy + 8, _vm->guiSettings()->colors.fill);
_screen->printShadedText(_saveSlotStringsTemp[slot], (x + 1) << 3, fy, 15, 0);
@@ -2755,7 +2763,7 @@ int GUI_EoB::selectSaveSlotDialogue(int x, int y, int id) {
int slot = -1;
for (bool runLoop = true; runLoop && !_vm->shouldQuit();) {
- int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff;
+ int inputFlag = _vm->checkInput(0, false, 0) & 0x8FF;
_vm->removeInputTop();
if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) {
@@ -2999,11 +3007,11 @@ void GUI_EoB::runMemorizePrayMenu(int charIndex, int spellType) {
lastHighLightText = newHighLightText;
}
- int inputFlag = _vm->checkInput(buttonList, false, 0) & 0x80ff;
+ int inputFlag = _vm->checkInput(buttonList, false, 0) & 0x80FF;
_vm->removeInputTop();
if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP6] || inputFlag == _vm->_keyMap[Common::KEYCODE_RIGHT]) {
- inputFlag = 0x801a + ((lastHighLightButton + 1) % _numVisPages);
+ inputFlag = 0x801A + ((lastHighLightButton + 1) % _numVisPages);
} else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP4] || inputFlag == _vm->_keyMap[Common::KEYCODE_LEFT]) {
inputFlag = lastHighLightButton ? 0x8019 + lastHighLightButton : 0x8019 + _numVisPages;
} else if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE]) {
@@ -3018,7 +3026,7 @@ void GUI_EoB::runMemorizePrayMenu(int charIndex, int spellType) {
}
if (inputFlag & 0x8000) {
- b = _vm->gui_getButton(buttonList, inputFlag & 0x7fff);
+ b = _vm->gui_getButton(buttonList, inputFlag & 0x7FFF);
drawMenuButton(b, true, true, true);
_screen->updateScreen();
_vm->_system->delayMillis(80);
@@ -3065,9 +3073,9 @@ void GUI_EoB::runMemorizePrayMenu(int charIndex, int spellType) {
runLoop = false;
} else if (inputFlag & 0x8000) {
- newHighLightButton = inputFlag - 0x801a;
+ newHighLightButton = inputFlag - 0x801A;
if (newHighLightButton == lastHighLightButton)
- drawMenuButton(_vm->gui_getButton(buttonList, inputFlag & 0x7fff), false, true, true);
+ drawMenuButton(_vm->gui_getButton(buttonList, inputFlag & 0x7FFF), false, true, true);
}
}
@@ -3544,7 +3552,7 @@ bool GUI_EoB::confirmDialogue(int id) {
lastHighlight = newHighlight;
}
- int inputFlag = _vm->checkInput(buttonList, false, 0) & 0x80ff;
+ int inputFlag = _vm->checkInput(buttonList, false, 0) & 0x80FF;
_vm->removeInputTop();
if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP5] || inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) {
diff --git a/engines/kyra/gui_eob.h b/engines/kyra/gui_eob.h
index f6be18ffbb..1b7bdf3482 100644
--- a/engines/kyra/gui_eob.h
+++ b/engines/kyra/gui_eob.h
@@ -156,7 +156,7 @@ private:
static const uint8 _highlightColorTableEGA[];
};
-} // End of namespace Kyra
+} // End of namespace Kyra
#endif // ENABLE_EOB
diff --git a/engines/kyra/gui_hof.cpp b/engines/kyra/gui_hof.cpp
index 36fbb0b40a..3a2c07beff 100644
--- a/engines/kyra/gui_hof.cpp
+++ b/engines/kyra/gui_hof.cpp
@@ -521,7 +521,7 @@ void KyraEngine_HoF::bookPrintText(int dstPage, const uint8 *str, int x, int y,
Screen::FontId oldFont = _screen->setFont(_flags.lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_BOOKFONT_FNT);
_screen->_charWidth = -2;
- _screen->printText((const char *)str, x, y, color, (_flags.lang == Common::JA_JPN) ? 0xf6 : 0);
+ _screen->printText((const char *)str, x, y, color, (_flags.lang == Common::JA_JPN) ? 0xF6 : 0);
_screen->_charWidth = 0;
_screen->setFont(oldFont);
diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp
index a79da0681e..b73eddbaf3 100644
--- a/engines/kyra/gui_lol.cpp
+++ b/engines/kyra/gui_lol.cpp
@@ -120,7 +120,7 @@ void LoLEngine::gui_drawScroll() {
if (h) {
_screen->copyRegion(201, 1, 17, 15, 6, h, 2, 2, Screen::CR_NO_P_CHECK);
_screen->copyRegion(208, 1, 89, 15, 6, h, 2, 2, Screen::CR_NO_P_CHECK);
- _screen->fillRect(21, 15, 89, h + 15, _flags.use16ColorMode ? 0xbb : 206);
+ _screen->fillRect(21, 15, 89, h + 15, _flags.use16ColorMode ? 0xBB : 206);
}
_screen->copyRegion(112, 16, 12, h + 15, 87, 14, 2, 2, Screen::CR_NO_P_CHECK);
@@ -172,7 +172,7 @@ void LoLEngine::gui_displayCharInventory(int charNum) {
gui_drawAllCharPortraitsWithStats();
if (_flags.use16ColorMode)
- _screen->fprintString("%s", 156, 8, 0xe1, 0, 1, l->name);
+ _screen->fprintString("%s", 156, 8, 0xE1, 0, 1, l->name);
else
_screen->fprintString("%s", 157, 9, 254, 0, 5, l->name);
@@ -182,7 +182,7 @@ void LoLEngine::gui_displayCharInventory(int charNum) {
gui_drawCharInventoryItem(i);
Screen::FontId of = _screen->setFont(Screen::FID_9_FNT);
- _screen->fprintString("%s", 182, 103, _flags.use16ColorMode ? 0xbb : 172, 0, 5, getLangString(0x4033));
+ _screen->fprintString("%s", 182, 103, _flags.use16ColorMode ? 0xBB : 172, 0, 5, getLangString(0x4033));
_screen->setFont(of);
static const uint16 statusFlags[] = { 0x0080, 0x0000, 0x1000, 0x0002, 0x100, 0x0001, 0x0000, 0x0000 };
@@ -206,7 +206,7 @@ void LoLEngine::gui_displayCharInventory(int charNum) {
int32 b = l->experiencePts[i] - _expRequirements[l->skillLevels[i] - 1];
int32 e = _expRequirements[l->skillLevels[i]] - _expRequirements[l->skillLevels[i] - 1];
- while (e & 0xffff8000) {
+ while (e & 0xFFFF8000) {
e >>= 1;
c = b;
b >>= 1;
@@ -245,7 +245,7 @@ void LoLEngine::gui_printCharacterStats(int index, int redraw, int value) {
// protection
if (_flags.use16ColorMode) {
y = (index + 2) << 3;
- col = 0xa1;
+ col = 0xA1;
if (redraw)
_screen->fprintString("%s", offs + 108, y, col, 0, 0, getLangString(0x4014 + index));
} else {
@@ -260,7 +260,7 @@ void LoLEngine::gui_printCharacterStats(int index, int redraw, int value) {
y = s * 10 + 62;
if (_flags.use16ColorMode) {
y = (s + 8) << 3;
- col = _characters[_selectedCharacter].flags & (0x200 << s) ? 0xe1 : 0x81;
+ col = _characters[_selectedCharacter].flags & (0x200 << s) ? 0xE1 : 0x81;
if (redraw)
_screen->fprintString("%s", offs + 108, y, col, 0, 0, getLangString(0x4014 + index));
} else {
@@ -274,7 +274,7 @@ void LoLEngine::gui_printCharacterStats(int index, int redraw, int value) {
if (offs)
_screen->copyRegion(294, y, 182 + offs, y, 18, 8, 6, _screen->_curPage, Screen::CR_NO_P_CHECK);
- Screen::FontId of = _flags.use16ColorMode ? _screen->setFont(Screen::FID_SJIS_FNT) : _screen->_currentFont;
+ Screen::FontId of = (_flags.lang == Common::JA_JPN && _flags.use16ColorMode) ? _screen->setFont(Screen::FID_SJIS_FNT) : _screen->_currentFont;
_screen->fprintString("%d", 200 + offs, y, col, 0, _flags.use16ColorMode ? 2 : 6, value);
_screen->setFont(of);
}
@@ -322,12 +322,12 @@ void LoLEngine::gui_changeCharacterStats(int charNum) {
void LoLEngine::gui_drawCharInventoryItem(int itemIndex) {
static const uint8 slotShapes[] = { 0x30, 0x34, 0x30, 0x34, 0x2E, 0x2F, 0x32, 0x33, 0x31, 0x35, 0x35 };
-
+ //2Eh, 32h, 2Eh, 32h, 2Ch, 2Dh, 30h, 31h, 2Fh, 33h, 33h
const uint8 *coords = &_charInvDefs[_charInvIndex[_characters[_selectedCharacter].raceClassSex] * 22 + itemIndex * 2];
uint8 x = *coords++;
uint8 y = *coords;
- if (y == 0xff)
+ if (y == 0xFF)
return;
if (!_screen->_curPage)
@@ -366,7 +366,7 @@ void LoLEngine::gui_drawCharPortraitWithStats(int charNum) {
gui_drawCharFaceShape(charNum, 0, 1, _screen->_curPage);
if (_flags.use16ColorMode) {
- gui_drawLiveMagicBar(33, 32, _characters[charNum].magicPointsCur, 0, _characters[charNum].magicPointsMax, 5, 32, 0xaa, 0x44, 0);
+ gui_drawLiveMagicBar(33, 32, _characters[charNum].magicPointsCur, 0, _characters[charNum].magicPointsMax, 5, 32, 0xAA, 0x44, 0);
gui_drawLiveMagicBar(39, 32, _characters[charNum].hitPointsCur, 0, _characters[charNum].hitPointsMax, 5, 32, 0x66, 0x44, 1);
_screen->printText(getLangString(0x4253), 33, 1, 0x99, 0);
_screen->printText(getLangString(0x4254), 39, 1, 0x55, 0);
@@ -493,7 +493,7 @@ void LoLEngine::gui_drawLiveMagicBar(int x, int y, int curPoints, int unk, int m
if (flag) {
t = maxPoints >> 1;
if (t > curPoints)
- col1 = _flags.use16ColorMode ? 0xbb : 144;
+ col1 = _flags.use16ColorMode ? 0xBB : 144;
t = maxPoints >> 2;
if (t > curPoints)
col1 = _flags.use16ColorMode ? 0x88 : 132;
@@ -525,9 +525,9 @@ void LoLEngine::calcCharPortraitXpos() {
}
void LoLEngine::gui_drawMoneyBox(int pageNum) {
- static const uint16 moneyX256[] = { 0x128, 0x134, 0x12b, 0x131, 0x12e};
+ static const uint16 moneyX256[] = { 0x128, 0x134, 0x12B, 0x131, 0x12E};
static const uint16 moneyY256[] = { 0x73, 0x73, 0x74, 0x74, 0x75};
- static const uint16 moneyX16[] = { 0x127, 0x133, 0x12a, 0x130, 0x12d};
+ static const uint16 moneyX16[] = { 0x127, 0x133, 0x12A, 0x130, 0x12D};
static const uint16 moneyY16[] = { 0x74, 0x74, 0x75, 0x75, 0x76};
int backupPage = _screen->_curPage;
@@ -551,11 +551,11 @@ void LoLEngine::gui_drawMoneyBox(int pageNum) {
continue;
uint8 h = _moneyColumnHeight[i] - 1;
- _screen->drawClippedLine(moneyX[i], moneyY[i], moneyX[i], moneyY[i] - h, _flags.use16ColorMode ? 1 : 0xd2);
- _screen->drawClippedLine(moneyX[i] + 1, moneyY[i], moneyX[i] + 1, moneyY[i] - h, _flags.use16ColorMode ? 2 : 0xd1);
- _screen->drawClippedLine(moneyX[i] + 2, moneyY[i], moneyX[i] + 2, moneyY[i] - h, _flags.use16ColorMode ? 3 : 0xd0);
- _screen->drawClippedLine(moneyX[i] + 3, moneyY[i], moneyX[i] + 3, moneyY[i] - h, _flags.use16ColorMode ? 2 : 0xd1);
- _screen->drawClippedLine(moneyX[i] + 4, moneyY[i], moneyX[i] + 4, moneyY[i] - h, _flags.use16ColorMode ? 1 : 0xd2);
+ _screen->drawClippedLine(moneyX[i], moneyY[i], moneyX[i], moneyY[i] - h, _flags.use16ColorMode ? 1 : 0xD2);
+ _screen->drawClippedLine(moneyX[i] + 1, moneyY[i], moneyX[i] + 1, moneyY[i] - h, _flags.use16ColorMode ? 2 : 0xD1);
+ _screen->drawClippedLine(moneyX[i] + 2, moneyY[i], moneyX[i] + 2, moneyY[i] - h, _flags.use16ColorMode ? 3 : 0xD0);
+ _screen->drawClippedLine(moneyX[i] + 3, moneyY[i], moneyX[i] + 3, moneyY[i] - h, _flags.use16ColorMode ? 2 : 0xD1);
+ _screen->drawClippedLine(moneyX[i] + 4, moneyY[i], moneyX[i] + 4, moneyY[i] - h, _flags.use16ColorMode ? 1 : 0xD2);
}
Screen::FontId backupFont = _screen->setFont(Screen::FID_6_FNT);
@@ -584,7 +584,7 @@ void LoLEngine::gui_drawCompass() {
_compassDirection = _currentDirection << 6;
}
- int t = ((_compassDirection + 4) >> 3) & 0x1f;
+ int t = ((_compassDirection + 4) >> 3) & 0x1F;
if (t == _compassDirectionIndex)
return;
@@ -697,7 +697,7 @@ void LoLEngine::gui_toggleButtonDisplayMode(int shapeIndex, int mode) {
t = _system->getMillis();
if (_buttonPressTimer > t)
delay(_buttonPressTimer - t);
-
+ // fall through
case 2:
mode = 0;
_lastButtonShape = 0;
@@ -744,13 +744,13 @@ void LoLEngine::gui_toggleFightButtons(bool disable) {
if (disable)
_characters[i].flags |= 0x2000;
else
- _characters[i].flags &= 0xdfff;
+ _characters[i].flags &= 0xDFFF;
if (disable && !textEnabled()) {
int u = _selectedCharacter;
_selectedCharacter = 99;
int f = _updateFlags;
- _updateFlags &= 0xfffd;
+ _updateFlags &= 0xFFFD;
gui_drawCharPortraitWithStats(i);
@@ -774,7 +774,7 @@ void LoLEngine::gui_updateInput() {
if (inputFlag && _activeMagicMenu != -1 && !(inputFlag & 0x8800)) {
gui_enableDefaultPlayfieldButtons();
- _characters[_activeMagicMenu].flags &= 0xffef;
+ _characters[_activeMagicMenu].flags &= 0xFFEF;
gui_drawCharPortraitWithStats(_activeMagicMenu);
gui_triggerEvent(inputFlag);
_preserveEvents = false;
@@ -875,7 +875,7 @@ void LoLEngine::gui_initCharInventorySpecialButtons(int charNum) {
const uint8 *s = &_charInvDefs[_charInvIndex[_characters[charNum].raceClassSex] * 22];
for (int i = 0; i < 11; i++) {
- if (*s != 0xff)
+ if (*s != 0xFF)
gui_initButton(33 + i, s[0], s[1], i);
s += 2;
}
@@ -916,7 +916,7 @@ void LoLEngine::gui_initButton(int index, int x, int y, int val) {
*b = Button();
b->nextButton = 0;
- b->data0Val2 = b->data1Val2 = b->data2Val2 = 0xfe;
+ b->data0Val2 = b->data1Val2 = b->data2Val2 = 0xFE;
b->data0Val3 = b->data1Val3 = b->data2Val3 = 0x01;
b->index = cnt;
@@ -925,7 +925,7 @@ void LoLEngine::gui_initButton(int index, int x, int y, int val) {
b->dimTableIndex = _buttonData[index].screenDim;
b->flags = _buttonData[index].buttonflags;
- b->arg = (val != -1) ? (uint8)(val & 0xff) : _buttonData[index].index;
+ b->arg = (val != -1) ? (uint8)(val & 0xFF) : _buttonData[index].index;
if (index == 15) {
// magic sub menu
@@ -1100,17 +1100,17 @@ int LoLEngine::clickedMagicSubmenu(Button *button) {
gui_enableDefaultPlayfieldButtons();
if (checkMagic(c, _availableSpells[_selectedSpell], spellLevel)) {
- _characters[c].flags &= 0xffef;
+ _characters[c].flags &= 0xFFEF;
gui_drawCharPortraitWithStats(c);
} else {
_characters[c].flags |= 4;
- _characters[c].flags &= 0xffef;
+ _characters[c].flags &= 0xFFEF;
if (castSpell(c, _availableSpells[_selectedSpell], spellLevel)) {
setCharacterUpdateEvent(c, 1, 8, 1);
increaseExperience(c, 2, spellLevel * spellLevel);
} else {
- _characters[c].flags &= 0xfffb;
+ _characters[c].flags &= 0xFFFB;
gui_drawCharPortraitWithStats(c);
}
}
@@ -1120,7 +1120,7 @@ int LoLEngine::clickedMagicSubmenu(Button *button) {
}
int LoLEngine::clickedScreen(Button *button) {
- _characters[_activeMagicMenu].flags &= 0xffef;
+ _characters[_activeMagicMenu].flags &= 0xFFEF;
gui_drawCharPortraitWithStats(_activeMagicMenu);
_activeMagicMenu = -1;
@@ -1178,12 +1178,12 @@ int LoLEngine::clickedPortraitEtcRight(Button *button) {
runItemScript(c, _itemInHand, 0x400, 0, 0);
runLevelScriptCustom(_currentBlock, 0x400, c, _itemInHand, 0, 0);
} else {
- _txt->printMessage(2, getLangString(0x402c), _characters[c].name);
+ _txt->printMessage(2, getLangString(0x402C), _characters[c].name);
}
return 1;
}
- _txt->printMessage(2, "%s", getLangString((flg & 8) ? 0x4029 : ((flg & 0x10) ? 0x402a : 0x402b)));
+ _txt->printMessage(2, "%s", getLangString((flg & 8) ? 0x4029 : ((flg & 0x10) ? 0x402A : 0x402B)));
return 1;
}
@@ -1235,13 +1235,13 @@ int LoLEngine::clickedCharInventorySlot(Button *button) {
}
int LoLEngine::clickedExitCharInventory(Button *button) {
- _updateFlags &= 0xfff3;
+ _updateFlags &= 0xFFF3;
gui_enableDefaultPlayfieldButtons();
_weaponsDisabled = false;
for (int i = 0; i < 4; i++) {
if (_charInventoryUnk & (1 << i))
- _characters[i].flags &= 0xf1ff;
+ _characters[i].flags &= 0xF1FF;
}
_screen->copyBlockToPage(2, 0, 0, 320, 200, _pageBuffer1);
@@ -1315,7 +1315,7 @@ int LoLEngine::clickedScenePickupItem(Button *button) {
uint16 block = (p <= 128) ? calcNewBlockPosition(_currentBlock, _currentDirection) : _currentBlock;
- int found = checkSceneForItems(&_levelBlockProperties[block].drawObjects, p & 0x7f);
+ int found = checkSceneForItems(&_levelBlockProperties[block].drawObjects, p & 0x7F);
if (found != -1) {
removeLevelItem(found, block);
@@ -1465,7 +1465,7 @@ int LoLEngine::clickedSpellTargetCharacter(Button *button) {
int t = button->arg;
_txt->printMessage(0, "%s.\r", _characters[t].name);
- if ((_spellProperties[_activeSpell.spell].flags & 0xff) == 1) {
+ if ((_spellProperties[_activeSpell.spell].flags & 0xFF) == 1) {
_activeSpell.target = t;
castHealOnSingleCharacter(&_activeSpell);
}
@@ -1504,7 +1504,7 @@ int LoLEngine::clickedSceneThrowItem(Button *button) {
uint16 y = 0;
calcCoordinates(x, y, _currentBlock, 0x80, 0x80);
- if (launchObject(0, _itemInHand, x, y, 12, _currentDirection << 1, 6, _selectedCharacter, 0x3f)) {
+ if (launchObject(0, _itemInHand, x, y, 12, _currentDirection << 1, 6, _selectedCharacter, 0x3F)) {
snd_playSoundEffect(18, -1);
setHandItem(0);
}
@@ -1520,7 +1520,7 @@ int LoLEngine::clickedOptions(Button *button) {
_updateFlags |= 4;
Button b;
- b.data0Val2 = b.data1Val2 = b.data2Val2 = 0xfe;
+ b.data0Val2 = b.data1Val2 = b.data2Val2 = 0xFE;
b.data0Val3 = b.data1Val3 = b.data2Val3 = 0x01;
if (_weaponsDisabled)
@@ -1540,7 +1540,7 @@ int LoLEngine::clickedOptions(Button *button) {
_gui->runMenu(_gui->_mainMenu);
- _updateFlags &= 0xfffb;
+ _updateFlags &= 0xFFFB;
setMouseCursorToItemInHand();
resetLampStatus();
gui_enableDefaultPlayfieldButtons();
@@ -1564,7 +1564,7 @@ int LoLEngine::clickedRestParty(Button *button) {
gui_toggleButtonDisplayMode(_flags.isTalkie ? 77 : 75, 1);
Button b;
- b.data0Val2 = b.data1Val2 = b.data2Val2 = 0xfe;
+ b.data0Val2 = b.data1Val2 = b.data2Val2 = 0xFE;
b.data0Val3 = b.data1Val3 = b.data2Val3 = 0x01;
if (_weaponsDisabled)
@@ -1710,7 +1710,7 @@ int LoLEngine::clickedRestParty(Button *button) {
bool setframe = true;
if (_characters[i].flags & 0x1000) {
- _characters[i].flags &= 0xefff;
+ _characters[i].flags &= 0xEFFF;
if (_partyAwake) {
if (_characters[i].damageSuffered) {
@@ -1733,7 +1733,7 @@ int LoLEngine::clickedRestParty(Button *button) {
setTemporaryFaceFrame(i, frm, upd, 1);
}
- _updateFlags &= 0xfffe;
+ _updateFlags &= 0xFFFE;
_partyAwake = true;
updateDrawPage2();
gui_drawScene(0);
@@ -1742,7 +1742,7 @@ int LoLEngine::clickedRestParty(Button *button) {
} else {
for (int i = 0; i < 4; i++)
- _characters[i].flags &= 0xefff;
+ _characters[i].flags &= 0xEFFF;
if (needPoisoningFlags) {
setTemporaryFaceFrameForAllCharacters(0, 0, 0);
@@ -1750,7 +1750,7 @@ int LoLEngine::clickedRestParty(Button *button) {
if (needPoisoningFlags & (1 << i))
setTemporaryFaceFrame(i, 3, 8, 0);
}
- _txt->printMessage(0x8000, "%s", getLangString(0x405a));
+ _txt->printMessage(0x8000, "%s", getLangString(0x405A));
gui_drawAllCharPortraitsWithStats();
} else {
@@ -1773,10 +1773,10 @@ int LoLEngine::clickedCompass(Button *button) {
return 0;
if (_compassBroken) {
- if (characterSays(0x425b, -1, true))
- _txt->printMessage(4, "%s", getLangString(0x425b));
+ if (characterSays(0x425B, -1, true))
+ _txt->printMessage(4, "%s", getLangString(0x425B));
} else {
- _txt->printMessage(0, "%s", getLangString(0x402f + _currentDirection));
+ _txt->printMessage(0, "%s", getLangString(0x402F + _currentDirection));
}
return 1;
@@ -1813,8 +1813,8 @@ int LoLEngine::clickedLamp(Button *button) {
_lampOilStatus += 100;
} else {
- uint16 s = (_lampOilStatus >= 100) ? 0x4060 : ((!_lampOilStatus) ? 0x405c : (_lampOilStatus / 33) + 0x405d);
- _txt->printMessage(0, getLangString(0x405b), getLangString(s));
+ uint16 s = (_lampOilStatus >= 100) ? 0x4060 : ((!_lampOilStatus) ? 0x405C : (_lampOilStatus / 33) + 0x405D);
+ _txt->printMessage(0, getLangString(0x405B), getLangString(s));
}
if (_brightness)
@@ -1836,7 +1836,7 @@ int LoLEngine::clickedStatusIcon(Button *button) {
if (str == 0 || str > 3)
return 1;
- _txt->printMessage(0x8002, "%s", getLangString(str == 1 ? 0x424c : (str == 2 ? 0x424e : 0x424d)));
+ _txt->printMessage(0x8002, "%s", getLangString(str == 1 ? 0x424C : (str == 2 ? 0x424E : 0x424D)));
return 1;
}
@@ -2239,7 +2239,7 @@ int GUI_LoL::runMenu(Menu &menu) {
if (_currentMenu == &_gameOptions) {
char *s = (char *)_vm->_tempBuffer5120;
- Common::strlcpy(s, _vm->getLangString(0x406f + _vm->_monsterDifficulty), 30);
+ Common::strlcpy(s, _vm->getLangString(0x406F + _vm->_monsterDifficulty), 30);
_currentMenu->item[_vm->gameFlags().isTalkie ? 0 : 2].itemString = s;
s += (strlen(s) + 1);
@@ -2252,7 +2252,7 @@ int GUI_LoL::runMenu(Menu &menu) {
s += (strlen(s) + 1);
if (_vm->gameFlags().isTalkie) {
- Common::strlcpy(s, _vm->getLangString(0x42d6 + _vm->_lang), 30);
+ Common::strlcpy(s, _vm->getLangString(0x42D6 + _vm->_lang), 30);
_currentMenu->item[3].itemString = s;
s += (strlen(s) + 1);
@@ -2315,7 +2315,7 @@ int GUI_LoL::runMenu(Menu &menu) {
for (int ii = 0; ii < 3; ++ii) {
Button *b = getButtonListData() + 1 + (i - 1) * 3 + ii;
b->nextButton = 0;
- b->data0Val2 = b->data1Val2 = b->data2Val2 = 0xfe;
+ b->data0Val2 = b->data1Val2 = b->data2Val2 = 0xFE;
b->data0Val3 = b->data1Val3 = b->data2Val3 = 0x01;
b->index = ii;
@@ -2367,9 +2367,9 @@ int GUI_LoL::runMenu(Menu &menu) {
int mw = (d->w << 3) + 1;
int mh = d->h + 1;
if (_vm->gameFlags().use16ColorMode) {
- _screen->drawShadedBox(mx, my, mx + mw + 1, my + mh + 1, 0xdd, 0xff);
- _screen->drawLine(true, mx + mw + 1, my, mh + 1, 0xcc);
- _screen->drawLine(false, mx, my + mh + 1, mw + 2, 0xcc);
+ _screen->drawShadedBox(mx, my, mx + mw + 1, my + mh + 1, 0xDD, 0xFF);
+ _screen->drawLine(true, mx + mw + 1, my, mh + 1, 0xCC);
+ _screen->drawLine(false, mx, my + mh + 1, mw + 2, 0xCC);
} else {
_screen->drawShadedBox(mx, my, mx + mw, my + mh, 227, 223);
}
@@ -2622,7 +2622,7 @@ int GUI_LoL::clickedMainMenu(Button *button) {
_newMenu = &_audioOptions;
break;
case 0x4006:
- _choiceMenu.menuNameId = 0x400a;
+ _choiceMenu.menuNameId = 0x400A;
_newMenu = &_choiceMenu;
break;
case 0x4005:
@@ -2677,7 +2677,7 @@ int GUI_LoL::clickedDeleteMenu(Button *button) {
return 1;
}
- _choiceMenu.menuNameId = 0x400b;
+ _choiceMenu.menuNameId = 0x400B;
_newMenu = &_choiceMenu;
int16 s = (int16)button->arg;
_menuResult = _deleteMenu.item[-s - 2].saveSlot + 1;
@@ -2689,7 +2689,7 @@ int GUI_LoL::clickedOptionsMenu(Button *button) {
updateMenuButton(button);
switch (button->arg) {
- case 0xfff9:
+ case 0xFFF9:
_vm->_configMusic ^= 1;
_vm->sound()->enableMusic(_vm->_configMusic);
@@ -2698,23 +2698,23 @@ int GUI_LoL::clickedOptionsMenu(Button *button) {
else
_vm->_sound->beginFadeOut();
break;
- case 0xfff8:
+ case 0xFFF8:
_vm->_configSounds ^= true;
_vm->sound()->enableSFX(_vm->_configSounds);
break;
- case 0xfff7:
+ case 0xFFF7:
_vm->_monsterDifficulty = (_vm->_monsterDifficulty + 1) % 3;
break;
- case 0xfff6:
+ case 0xFFF6:
_vm->_smoothScrollingEnabled ^= true;
break;
- case 0xfff5:
+ case 0xFFF5:
_vm->_floatingCursorsEnabled ^= true;
break;
- case 0xfff4:
+ case 0xFFF4:
_vm->_lang = (_vm->_lang + 1) % 3;
break;
- case 0xfff3:
+ case 0xFFF3:
_vm->_configVoice ^= 3;
break;
case 0x4072: {
@@ -2793,7 +2793,7 @@ int GUI_LoL::clickedAudioMenu(Button *button) {
} while (1);
} else if (button->arg == 5) {
_vm->_lastSpeechId = -1;
- _vm->snd_playCharacterSpeech(0x42e0, 0, 0);
+ _vm->snd_playCharacterSpeech(0x42E0, 0, 0);
}
}
diff --git a/engines/kyra/gui_lol.h b/engines/kyra/gui_lol.h
index dbf54e41f0..79d4b6b4c9 100644
--- a/engines/kyra/gui_lol.h
+++ b/engines/kyra/gui_lol.h
@@ -36,9 +36,9 @@ namespace Kyra {
menu.width = (dim->w << 3); \
menu.height = (dim->h); \
if (_vm->gameFlags().use16ColorMode) { \
- menu.bkgdColor = 0xcc; \
- menu.color1 = 0xff; \
- menu.color2 = 0xdd; \
+ menu.bkgdColor = 0xCC; \
+ menu.color1 = 0xFF; \
+ menu.color2 = 0xDD; \
} else { \
menu.bkgdColor = 225; \
menu.color1 = 223; \
@@ -49,7 +49,7 @@ namespace Kyra {
menu.numberOfItems = d; \
menu.titleX = (dim->sx << 3) + (dim->w << 2); \
menu.titleY = 6; \
- menu.textColor = _vm->gameFlags().use16ColorMode ? 0xe1 : 254; \
+ menu.textColor = _vm->gameFlags().use16ColorMode ? 0xE1 : 254; \
menu.scrollUpButtonX = e; \
menu.scrollUpButtonY = f; \
menu.scrollDownButtonX = g; \
@@ -65,13 +65,13 @@ namespace Kyra {
item.y = c; \
item.width = d; \
item.height = e; \
- item.textColor = _vm->gameFlags().use16ColorMode ? 0xc1 : 204; \
- item.highlightColor = _vm->gameFlags().use16ColorMode ? 0xe1 : 254; \
+ item.textColor = _vm->gameFlags().use16ColorMode ? 0xC1 : 204; \
+ item.highlightColor = _vm->gameFlags().use16ColorMode ? 0xE1 : 254; \
item.titleX = -1; \
if (_vm->gameFlags().use16ColorMode) { \
- item.bkgdColor = 0xcc; \
- item.color1 = 0xff; \
- item.color2 = 0xdd; \
+ item.bkgdColor = 0xCC; \
+ item.color1 = 0xFF; \
+ item.color2 = 0xDD; \
} else { \
item.bkgdColor = 225; \
item.color1 = 223; \
diff --git a/engines/kyra/gui_mr.cpp b/engines/kyra/gui_mr.cpp
index 37526f9a5f..bcbfe27b69 100644
--- a/engines/kyra/gui_mr.cpp
+++ b/engines/kyra/gui_mr.cpp
@@ -25,7 +25,7 @@
#include "kyra/text_mr.h"
#include "kyra/resource.h"
#include "kyra/timer.h"
-#include "kyra/sound.h"
+#include "kyra/sound_digital.h"
#include "common/system.h"
diff --git a/engines/kyra/gui_rpg.cpp b/engines/kyra/gui_rpg.cpp
index be40050bb1..ab25f95df8 100644
--- a/engines/kyra/gui_rpg.cpp
+++ b/engines/kyra/gui_rpg.cpp
@@ -76,8 +76,8 @@ void KyraRpgEngine::gui_drawHorizontalBarGraph(int x, int y, int w, int h, int32
screen()->fillRect(x + t, y, x + w - 1, y + h, col2);
}
-void KyraRpgEngine::gui_initButtonsFromList(const int16 *list) {
- while (*list != -1)
+void KyraRpgEngine::gui_initButtonsFromList(const uint8 *list) {
+ while (*list != 0xFF)
gui_initButton(*list++);
}
@@ -107,7 +107,7 @@ bool KyraRpgEngine::clickedShape(int shapeIndex) {
uint16 s = _levelDecorationProperties[shapeIndex].shapeIndex[1];
- if (s == 0xffff)
+ if (s == 0xFFFF)
continue;
int w = _flags.gameID == GI_LOL ? _levelDecorationShapes[s][3] : (_levelDecorationShapes[s][2] << 3);
diff --git a/engines/kyra/items_eob.cpp b/engines/kyra/items_eob.cpp
index 0994e12e4f..6c7ccf14dc 100644
--- a/engines/kyra/items_eob.cpp
+++ b/engines/kyra/items_eob.cpp
@@ -118,7 +118,7 @@ void EoBCoreEngine::setItemPosition(Item *itemQueue, int block, Item item, int p
EoBItem *itm = &_items[item];
itm->pos = pos;
itm->block = block;
- itm->level = block < 0 ? 0xff : _currentLevel;
+ itm->level = block < 0 ? 0xFF : _currentLevel;
if (!*itemQueue) {
*itemQueue = itm->next = itm->prev = item;
@@ -141,7 +141,7 @@ void EoBCoreEngine::createInventoryItem(EoBCharacter *c, Item itemIndex, int16 i
if (itemValue != -1)
_items[itemIndex].value = itemValue;
- if (itemValue && ((_itemTypes[_items[itemIndex].type].extraProperties & 0x7f) < 4))
+ if (itemValue && ((_itemTypes[_items[itemIndex].type].extraProperties & 0x7F) < 4))
_items[itemIndex].flags |= 0x80;
if (c->inventory[preferedInventorySlot]) {
@@ -208,7 +208,7 @@ int EoBCoreEngine::validateInventorySlotForItem(Item item, int charIndex, int sl
}
int itm = _characters[charIndex].inventory[slot];
- int ex = _itemTypes[_items[itm].type].extraProperties & 0x7f;
+ int ex = _itemTypes[_items[itm].type].extraProperties & 0x7F;
if (_items[itm].flags & 0x20 && (_flags.gameID == GI_EOB1 || slot < 2)) {
if (_flags.gameID == GI_EOB2 && ex > 0 && ex < 4)
@@ -216,7 +216,7 @@ int EoBCoreEngine::validateInventorySlotForItem(Item item, int charIndex, int sl
return 0;
}
- uint16 v = item ? _itemTypes[_items[item].type].invFlags : 0xffff;
+ uint16 v = item ? _itemTypes[_items[item].type].invFlags : 0xFFFF;
if (v & _slotValidationFlags[slot])
return 1;
@@ -359,7 +359,7 @@ void EoBCoreEngine::printFullItemName(Item item) {
EoBItem *itm = &_items[item];
const char *nameUnid = _itemNames[itm->nameUnid];
const char *nameId = _itemNames[itm->nameId];
- uint8 f = _itemTypes[itm->type].extraProperties & 0x7f;
+ uint8 f = _itemTypes[itm->type].extraProperties & 0x7F;
int8 v = itm->value;
const char *tstr2 = 0;
diff --git a/engines/kyra/items_hof.cpp b/engines/kyra/items_hof.cpp
index ef2c50c0c5..e1d3c659de 100644
--- a/engines/kyra/items_hof.cpp
+++ b/engines/kyra/items_hof.cpp
@@ -84,7 +84,7 @@ bool KyraEngine_HoF::dropItem(int unk1, Item item, int x, int y, int unk2) {
bool success = processItemDrop(_mainCharacter.sceneId, item, x, y, unk1, unk2);
if (!success) {
- snd_playSoundEffect(0x0d);
+ snd_playSoundEffect(0x0D);
if (countAllItems() >= 30)
showMessageFromCCode(5, 0x84, 0);
}
@@ -205,7 +205,7 @@ void KyraEngine_HoF::itemDropDown(int startX, int startY, int dstX, int dstY, in
if (startX == dstX && startY == dstY) {
if (_layerFlagTable[_screen->getLayer(dstX, dstY)] && item != 13) {
updateCharFacing();
- snd_playSoundEffect(0x2d);
+ snd_playSoundEffect(0x2D);
removeHandItem();
objectChat(getTableString(0xFF, _cCodeBuffer, 1), 0, 0x83, 0xFF);
} else {
@@ -213,7 +213,7 @@ void KyraEngine_HoF::itemDropDown(int startX, int startY, int dstX, int dstY, in
_itemList[itemSlot].y = dstY;
_itemList[itemSlot].id = item;
_itemList[itemSlot].sceneId = _mainCharacter.sceneId;
- snd_playSoundEffect(0x0c);
+ snd_playSoundEffect(0x0C);
addItemToAnimList(itemSlot);
}
} else {
@@ -283,7 +283,7 @@ void KyraEngine_HoF::itemDropDown(int startX, int startY, int dstX, int dstY, in
if (_layerFlagTable[_screen->getLayer(dstX, dstY)] && item != 13) {
updateCharFacing();
- snd_playSoundEffect(0x2d);
+ snd_playSoundEffect(0x2D);
removeHandItem();
_screen->showMouse();
objectChat(getTableString(0xFF, _cCodeBuffer, 1), 0, 0x83, 0xFF);
@@ -292,7 +292,7 @@ void KyraEngine_HoF::itemDropDown(int startX, int startY, int dstX, int dstY, in
_itemList[itemSlot].y = dstY;
_itemList[itemSlot].id = item;
_itemList[itemSlot].sceneId = _mainCharacter.sceneId;
- snd_playSoundEffect(0x0c);
+ snd_playSoundEffect(0x0C);
addItemToAnimList(itemSlot);
_screen->showMouse();
}
@@ -307,7 +307,7 @@ void KyraEngine_HoF::exchangeMouseItem(int itemPos) {
_itemInHand = itemId;
addItemToAnimList(itemPos);
- snd_playSoundEffect(0x0b);
+ snd_playSoundEffect(0x0B);
setMouseCursor(_itemInHand);
int str2 = 7;
@@ -331,7 +331,7 @@ bool KyraEngine_HoF::pickUpItem(int x, int y) {
deleteItemAnimEntry(itemPos);
int itemId = _itemList[itemPos].id;
_itemList[itemPos].id = kItemNone;
- snd_playSoundEffect(0x0b);
+ snd_playSoundEffect(0x0B);
setMouseCursor(itemId);
int str2 = 7;
diff --git a/engines/kyra/items_lok.cpp b/engines/kyra/items_lok.cpp
index b92cd616c1..8ee07e8271 100644
--- a/engines/kyra/items_lok.cpp
+++ b/engines/kyra/items_lok.cpp
@@ -29,9 +29,9 @@ namespace Kyra {
int KyraEngine_LoK::findDuplicateItemShape(int shape) {
static const uint8 dupTable[] = {
- 0x48, 0x46, 0x49, 0x47, 0x4a, 0x46, 0x4b, 0x47,
- 0x4c, 0x46, 0x4d, 0x47, 0x5b, 0x5a, 0x5c, 0x5a,
- 0x5d, 0x5a, 0x5e, 0x5a, 0xFF, 0xFF
+ 0x48, 0x46, 0x49, 0x47, 0x4A, 0x46, 0x4B, 0x47,
+ 0x4C, 0x46, 0x4D, 0x47, 0x5B, 0x5A, 0x5C, 0x5A,
+ 0x5D, 0x5A, 0x5E, 0x5A, 0xFF, 0xFF
};
int i = 0;
diff --git a/engines/kyra/items_lol.cpp b/engines/kyra/items_lol.cpp
index 409b53f6f0..f4024471d2 100644
--- a/engines/kyra/items_lol.cpp
+++ b/engines/kyra/items_lol.cpp
@@ -29,7 +29,7 @@ namespace Kyra {
LoLObject *LoLEngine::findObject(uint16 index) {
if (index & 0x8000)
- return &_monsters[index & 0x7fff];
+ return &_monsters[index & 0x7FFF];
else
return &_itemsInPlay[index];
}
@@ -221,7 +221,7 @@ Item LoLEngine::makeItem(int itemType, int curFrame, int flags) {
memset(&_itemsInPlay[slot], 0, sizeof(LoLItem));
_itemsInPlay[slot].itemPropertyIndex = itemType;
- _itemsInPlay[slot].shpCurFrame_flg = (curFrame & 0x1fff) | flags;
+ _itemsInPlay[slot].shpCurFrame_flg = (curFrame & 0x1FFF) | flags;
_itemsInPlay[slot].level = -1;
return slot;
@@ -265,6 +265,7 @@ bool LoLEngine::addItemToInventory(Item itemIndex) {
gui_drawInventory();
}
+ assert(pos > 0 && pos < 48);
_inventory[pos] = itemIndex;
gui_drawInventory();
@@ -292,7 +293,7 @@ void LoLEngine::runItemScript(int charNum, Item item, int flags, int next, int r
memset(&scriptState, 0, sizeof(EMCState));
uint8 func = item ? _itemProperties[_itemsInPlay[item].itemPropertyIndex].itemScriptFunc : 3;
- if (func == 0xff)
+ if (func == 0xFF)
return;
_emc->init(&scriptState, &_itemScript);
@@ -351,8 +352,8 @@ bool LoLEngine::itemEquipped(int charNum, uint16 itemType) {
void LoLEngine::setItemPosition(Item item, uint16 x, uint16 y, int flyingHeight, int moveable) {
if (!flyingHeight) {
- x = (x & 0xffc0) | 0x40;
- y = (y & 0xffc0) | 0x40;
+ x = (x & 0xFFC0) | 0x40;
+ y = (y & 0xFFC0) | 0x40;
}
uint16 block = calcBlockIndex(x, y);
@@ -364,7 +365,7 @@ void LoLEngine::setItemPosition(Item item, uint16 x, uint16 y, int flyingHeight,
if (moveable)
_itemsInPlay[item].shpCurFrame_flg |= 0x4000;
else
- _itemsInPlay[item].shpCurFrame_flg &= 0xbfff;
+ _itemsInPlay[item].shpCurFrame_flg &= 0xBFFF;
assignItemToBlock(&_levelBlockProperties[block].assignedObjects, item);
@@ -429,9 +430,9 @@ bool LoLEngine::launchObject(int objectType, Item item, int startX, int startY,
if (attackerId != -1) {
if (attackerId & 0x8000) {
- t->flags &= 0xfd;
+ t->flags &= 0xFD;
} else {
- t->flags &= 0xfb;
+ t->flags &= 0xFB;
increaseExperience(attackerId, 1, 2);
}
}
@@ -455,8 +456,8 @@ void LoLEngine::endObjectFlight(FlyingObject *t, int x, int y, int collisionType
if (t->objectType == 0 || t->objectType == 1) {
objectFlightProcessHits(t, cx, cy, collisionType);
- t->x = (cx & 0xffc0) | 0x40;
- t->y = (cy & 0xffc0) | 0x40;
+ t->x = (cx & 0xFFC0) | 0x40;
+ t->y = (cy & 0xFFC0) | 0x40;
t->flyingHeight = 0;
updateObjectFlightPosition(t);
}
diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp
index 7fbecb7f53..b180285ffc 100644
--- a/engines/kyra/kyra_hof.cpp
+++ b/engines/kyra/kyra_hof.cpp
@@ -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);
}
}
@@ -244,8 +197,6 @@ Common::Error KyraEngine_HoF::init() {
_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->setFont(_flags.lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : _screen->FID_8_FNT);
_screen->setAnimBlockPtr(3504);
@@ -254,13 +205,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 +223,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,24 +257,24 @@ 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;
}
void KyraEngine_HoF::startup() {
- _sound->setSoundList(&_soundData[kMusicIngame]);
+ _sound->selectAudioResourceSet(kMusicIngame);
// The track map is exactly the same
// for FM-TOWNS and DOS
_trackMap = _dosTrackMap;
@@ -1508,7 +1448,7 @@ void KyraEngine_HoF::snd_playSoundEffect(int track, int volume) {
int16 vocIndex = (int16)READ_LE_UINT16(&_ingameSoundIndex[track * 2]);
if (vocIndex != -1) {
- _sound->voicePlay(_ingameSoundList[vocIndex], 0, 255, true);
+ _sound->voicePlay(_ingameSoundList[vocIndex], 0, 255, 255, true);
} else if (_flags.platform == Common::kPlatformPC) {
if (_sound->getSfxType() == Sound::kMidiMT32)
track = track < _mt32SfxMapSize ? _mt32SfxMap[track] - 1 : -1;
diff --git a/engines/kyra/kyra_hof.h b/engines/kyra/kyra_hof.h
index 182854cdf1..1b84e5b56f 100644
--- a/engines/kyra/kyra_hof.h
+++ b/engines/kyra/kyra_hof.h
@@ -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,18 @@ public:
GUI *gui() const { return _gui; }
virtual TextDisplayer *text() { return _text; }
int language() const { return _lang; }
+
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();
@@ -311,7 +86,6 @@ protected:
static const int8 _pcSpkSfxMap[];
static const int _pcSpkSfxMapSize;
- AudioDataStruct _soundData[3];
protected:
// game initialization
void startup();
@@ -841,19 +615,19 @@ protected:
bool _chatAltFlag;
// sequence player
- ActiveWSA *_activeWSA;
+/* ActiveWSA *_activeWSA;
ActiveText *_activeText;
-
- const char * const *_sequencePakList;
- int _sequencePakListSize;
- const char * const *_ingamePakList;
+ */
+ /*const char *const *_sequencePakList;
+ int _sequencePakListSize;*/
+ const char *const *_ingamePakList;
int _ingamePakListSize;
- const char * const *_musicFileListIntro;
+ const char *const *_musicFileListIntro;
int _musicFileListIntroSize;
- const char * const *_musicFileListFinale;
+ const char *const *_musicFileListFinale;
int _musicFileListFinaleSize;
- const char * const *_musicFileListIngame;
+ const char *const *_musicFileListIngame;
int _musicFileListIngameSize;
const uint8 *_cdaTrackTableIntro;
int _cdaTrackTableIntroSize;
@@ -861,34 +635,33 @@ protected:
int _cdaTrackTableIngameSize;
const uint8 *_cdaTrackTableFinale;
int _cdaTrackTableFinaleSize;
- const char * const *_sequenceSoundList;
- int _sequenceSoundListSize;
- const char * const *_ingameSoundList;
+ 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;
+ 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 +675,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[];
diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp
index 27bc2ad22a..7d4e35092f 100644
--- a/engines/kyra/kyra_lok.cpp
+++ b/engines/kyra/kyra_lok.cpp
@@ -98,8 +98,6 @@ KyraEngine_LoK::KyraEngine_LoK(OSystem *system, const GameFlags &flags)
_malcolmFrame = 0;
_malcolmTimer1 = _malcolmTimer2 = 0;
-
- _soundFiles = 0;
}
KyraEngine_LoK::~KyraEngine_LoK() {
@@ -123,8 +121,6 @@ KyraEngine_LoK::~KyraEngine_LoK() {
delete _animator;
delete _seq;
- delete[] _soundFiles;
-
delete[] _characterList;
delete[] _roomTable;
@@ -194,7 +190,7 @@ Common::Error KyraEngine_LoK::init() {
initStaticResource();
- _sound->setSoundList(&_soundData[kMusicIntro]);
+ _sound->selectAudioResourceSet(kMusicIntro);
if (_flags.platform == Common::kPlatformAmiga) {
_trackMap = _amigaTrackMap;
@@ -349,7 +345,7 @@ void KyraEngine_LoK::startup() {
static const uint8 colorMap[] = { 0, 0, 0, 0, 12, 12, 12, 0, 0, 0, 0, 0 };
_screen->setTextColorMap(colorMap);
- _sound->setSoundList(&_soundData[kMusicIngame]);
+ _sound->selectAudioResourceSet(kMusicIngame);
if (_flags.platform == Common::kPlatformPC98)
_sound->loadSoundFile("SE.DAT");
else
diff --git a/engines/kyra/kyra_lok.h b/engines/kyra/kyra_lok.h
index e5fb3cddca..def5cbcf6f 100644
--- a/engines/kyra/kyra_lok.h
+++ b/engines/kyra/kyra_lok.h
@@ -126,13 +126,13 @@ public:
typedef bool (KyraEngine_LoK::*IntroProc)();
// static data access
- const char * const *seqWSATable() { return _seq_WSATable; }
- const char * const *seqCPSTable() { return _seq_CPSTable; }
- const char * const *seqCOLTable() { return _seq_COLTable; }
- const char * const *seqTextsTable() { return _seq_textsTable; }
+ const char *const *seqWSATable() { return _seq_WSATable; }
+ const char *const *seqCPSTable() { return _seq_CPSTable; }
+ const char *const *seqCOLTable() { return _seq_COLTable; }
+ const char *const *seqTextsTable() { return _seq_textsTable; }
- const uint8 * const *palTable1() { return &_specialPalettes[0]; }
- const uint8 * const *palTable2() { return &_specialPalettes[29]; }
+ const uint8 *const *palTable1() { return &_specialPalettes[0]; }
+ const uint8 *const *palTable2() { return &_specialPalettes[29]; }
protected:
virtual Common::Error go();
@@ -538,12 +538,12 @@ protected:
const uint8 *_seq_Demo4;
const uint8 *_seq_Reunion;
- const char * const *_seq_WSATable;
- const char * const *_seq_CPSTable;
- const char * const *_seq_COLTable;
- const char * const *_seq_textsTable;
+ const char *const *_seq_WSATable;
+ const char *const *_seq_CPSTable;
+ const char *const *_seq_COLTable;
+ const char *const *_seq_textsTable;
- const char * const *_storyStrings;
+ const char *const *_storyStrings;
int _seq_WSATable_Size;
int _seq_CPSTable_Size;
@@ -552,25 +552,25 @@ protected:
int _storyStringsSize;
- const char * const *_itemList;
- const char * const *_takenList;
- const char * const *_placedList;
- const char * const *_droppedList;
- const char * const *_noDropList;
- const char * const *_putDownFirst;
- const char * const *_waitForAmulet;
- const char * const *_blackJewel;
- const char * const *_poisonGone;
- const char * const *_healingTip;
- const char * const *_thePoison;
- const char * const *_fluteString;
- const char * const *_wispJewelStrings;
- const char * const *_magicJewelString;
- const char * const *_flaskFull;
- const char * const *_fullFlask;
- const char * const *_veryClever;
- const char * const *_homeString;
- const char * const *_newGameString;
+ const char *const *_itemList;
+ const char *const *_takenList;
+ const char *const *_placedList;
+ const char *const *_droppedList;
+ const char *const *_noDropList;
+ const char *const *_putDownFirst;
+ const char *const *_waitForAmulet;
+ const char *const *_blackJewel;
+ const char *const *_poisonGone;
+ const char *const *_healingTip;
+ const char *const *_thePoison;
+ const char *const *_fluteString;
+ const char *const *_wispJewelStrings;
+ const char *const *_magicJewelString;
+ const char *const *_flaskFull;
+ const char *const *_fullFlask;
+ const char *const *_veryClever;
+ const char *const *_homeString;
+ const char *const *_newGameString;
int _itemList_Size;
int _takenList_Size;
@@ -592,13 +592,13 @@ protected:
int _homeString_Size;
int _newGameString_Size;
- const char * const *_characterImageTable;
+ const char *const *_characterImageTable;
int _characterImageTableSize;
- const char * const *_guiStrings;
+ const char *const *_guiStrings;
int _guiStringsSize;
- const char * const *_configStrings;
+ const char *const *_configStrings;
int _configStringsSize;
Shape *_defaultShapeTable;
@@ -636,20 +636,12 @@ protected:
Room *_roomTable;
int _roomTableSize;
- const char * const *_roomFilenameTable;
+ const char *const *_roomFilenameTable;
int _roomFilenameTableSize;
const uint8 *_amuleteAnim;
- const uint8 * const *_specialPalettes;
-
- const char * const *_soundFiles;
- int _soundFilesSize;
- const char * const *_soundFilesIntro;
- int _soundFilesIntroSize;
- const int32 *_cdaTrackTable;
- int _cdaTrackTableSize;
- AudioDataStruct _soundData[3];
+ const uint8 *const *_specialPalettes;
// positions of the inventory
static const uint16 _itemPosX[];
diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp
index 448e4ef70d..48ba96ec8b 100644
--- a/engines/kyra/kyra_mr.cpp
+++ b/engines/kyra/kyra_mr.cpp
@@ -28,7 +28,7 @@
#include "kyra/debugger.h"
#include "kyra/gui_mr.h"
#include "kyra/resource.h"
-#include "kyra/sound.h"
+#include "kyra/sound_digital.h"
#include "common/system.h"
#include "common/config-manager.h"
@@ -213,8 +213,6 @@ Common::Error KyraEngine_MR::init() {
_soundDigital = new SoundDigital(this, _mixer);
assert(_soundDigital);
- if (!_soundDigital->init())
- error("_soundDigital->init() failed");
KyraEngine_v1::_text = _text = new TextDisplayer_MR(this, _screen);
assert(_text);
_gui = new GUI_MR(this);
@@ -724,7 +722,7 @@ void KyraEngine_MR::loadCharacterShapes(int newShapes) {
static const uint8 numberOffset[] = { 3, 3, 4, 4, 3, 3 };
static const uint8 startShape[] = { 0x32, 0x58, 0x78, 0x98, 0xB8, 0xD8 };
static const uint8 endShape[] = { 0x57, 0x77, 0x97, 0xB7, 0xD7, 0xF7 };
- static const char * const filenames[] = {
+ static const char *const filenames[] = {
"MSW##.SHP",
"MTA##.SHP",
"MTFL##.SHP",
diff --git a/engines/kyra/kyra_mr.h b/engines/kyra/kyra_mr.h
index 004236ca04..d194fedd4d 100644
--- a/engines/kyra/kyra_mr.h
+++ b/engines/kyra/kyra_mr.h
@@ -182,11 +182,11 @@ private:
private:
// main menu
- const char * const *_mainMenuStrings;
+ const char *const *_mainMenuStrings;
int _mainMenuStringsSize;
- static const char * const _mainMenuSpanishFan[];
- static const char * const _mainMenuItalianFan[];
+ static const char *const _mainMenuSpanishFan[];
+ static const char *const _mainMenuItalianFan[];
// animator
uint8 *_gamePlayBuffer;
diff --git a/engines/kyra/kyra_rpg.cpp b/engines/kyra/kyra_rpg.cpp
index f1d9550e8f..f8eb7d00cd 100644
--- a/engines/kyra/kyra_rpg.cpp
+++ b/engines/kyra/kyra_rpg.cpp
@@ -46,12 +46,7 @@ KyraRpgEngine::KyraRpgEngine(OSystem *system, const GameFlags &flags) : KyraEngi
_vcnTransitionMask = 0;
_vcnShift = 0;
_vcnColTable = 0;
- _vcnBlockWidth = 4;
- _vcnBlockHeight = 8;
- _vcnFlip0 = 0;
- _vcnFlip1 = 1;
_vmpPtr = 0;
- _vmpSize = 0;
_blockBrightness = _wllVcnOffset = 0;
_blockDrawingBuffer = 0;
_sceneWindowBuffer = 0;
@@ -173,9 +168,8 @@ Common::Error KyraRpgEngine::init() {
_blockDrawingBuffer = new uint16[1320];
memset(_blockDrawingBuffer, 0, 1320 * sizeof(uint16));
- uint32 swbSize = 22 * _vcnBlockWidth * 2 * 15 * _vcnBlockHeight;
- _sceneWindowBuffer = new uint8[swbSize];
- memset(_sceneWindowBuffer, 0, swbSize);
+ _sceneWindowBuffer = new uint8[21120];
+ memset(_sceneWindowBuffer, 0, 21120);
_lvlShapeTop = new int16[18];
memset(_lvlShapeTop, 0, 18 * sizeof(int16));
@@ -186,7 +180,7 @@ Common::Error KyraRpgEngine::init() {
_vcnColTable = new uint8[128];
for (int i = 0; i < 128; i++)
- _vcnColTable[i] = i & 0x0f;
+ _vcnColTable[i] = i & 0x0F;
_doorShapes = new uint8*[6];
memset(_doorShapes, 0, 6 * sizeof(uint8 *));
@@ -210,18 +204,19 @@ bool KyraRpgEngine::posWithinRect(int posX, int posY, int x1, int y1, int x2, in
void KyraRpgEngine::drawDialogueButtons() {
int cp = screen()->setCurPage(0);
- Screen::FontId of = screen()->setFont(gameFlags().use16ColorMode ? Screen::FID_SJIS_FNT : Screen::FID_6_FNT);
+ Screen::FontId of = screen()->setFont(_flags.lang == Common::JA_JPN && _flags.use16ColorMode ? Screen::FID_SJIS_FNT : Screen::FID_6_FNT);
for (int i = 0; i < _dialogueNumButtons; i++) {
int x = _dialogueButtonPosX[i];
- if (gameFlags().use16ColorMode) {
- gui_drawBox(x, ((_dialogueButtonYoffs + _dialogueButtonPosY[i]) & ~7) - 1, 74, 10, 0xee, 0xcc, -1);
+ if (_flags.lang == Common::JA_JPN && _flags.use16ColorMode) {
+ gui_drawBox(x, ((_dialogueButtonYoffs + _dialogueButtonPosY[i]) & ~7) - 1, 74, 10, 0xEE, 0xCC, -1);
screen()->printText(_dialogueButtonString[i], (x + 37 - (screen()->getTextWidth(_dialogueButtonString[i])) / 2) & ~3,
- ((_dialogueButtonYoffs + _dialogueButtonPosY[i]) + 2) & ~7, _dialogueHighlightedButton == i ? 0xc1 : 0xe1, 0);
+ ((_dialogueButtonYoffs + _dialogueButtonPosY[i]) + 2) & ~7, _dialogueHighlightedButton == i ? 0xC1 : 0xE1, 0);
} else {
+ int sjisYOffset = (_flags.lang == Common::JA_JPN && _dialogueButtonString[i][0] < 0) ? 2 : 0;
gui_drawBox(x, (_dialogueButtonYoffs + _dialogueButtonPosY[i]), _dialogueButtonWidth, guiSettings()->buttons.height, guiSettings()->colors.frame1, guiSettings()->colors.frame2, guiSettings()->colors.fill);
screen()->printText(_dialogueButtonString[i], x + (_dialogueButtonWidth >> 1) - (screen()->getTextWidth(_dialogueButtonString[i])) / 2,
- (_dialogueButtonYoffs + _dialogueButtonPosY[i]) + 2, _dialogueHighlightedButton == i ? _dialogueButtonLabelColor1 : _dialogueButtonLabelColor2, 0);
+ (_dialogueButtonYoffs + _dialogueButtonPosY[i]) + 2 - sjisYOffset, _dialogueHighlightedButton == i ? _dialogueButtonLabelColor1 : _dialogueButtonLabelColor2, 0);
}
}
screen()->setFont(of);
@@ -234,7 +229,7 @@ uint16 KyraRpgEngine::processDialogue() {
for (int i = 0; i < _dialogueNumButtons; i++) {
int x = _dialogueButtonPosX[i];
- int y = (gameFlags().use16ColorMode ? ((_dialogueButtonYoffs + _dialogueButtonPosY[i]) & ~7) - 1 : (_dialogueButtonYoffs + _dialogueButtonPosY[i]));
+ int y = ((_flags.lang == Common::JA_JPN && _flags.use16ColorMode) ? ((_dialogueButtonYoffs + _dialogueButtonPosY[i]) & ~7) - 1 : (_dialogueButtonYoffs + _dialogueButtonPosY[i]));
Common::Point p = getMousePos();
if (posWithinRect(p.x, p.y, x, y, x + _dialogueButtonWidth, y + guiSettings()->buttons.height)) {
_dialogueHighlightedButton = i;
diff --git a/engines/kyra/kyra_rpg.h b/engines/kyra/kyra_rpg.h
index 50a4c9bdc1..cd36d2a5cd 100644
--- a/engines/kyra/kyra_rpg.h
+++ b/engines/kyra/kyra_rpg.h
@@ -222,7 +222,6 @@ protected:
uint16 _decorationCount;
int16 _mappedDecorationsCount;
uint16 *_vmpPtr;
- uint16 _vmpSize;
uint8 *_vcnBlocks;
uint8 *_vcfBlocks;
uint8 *_vcnTransitionMask;
@@ -232,10 +231,6 @@ protected:
uint8 *_sceneWindowBuffer;
uint8 _blockBrightness;
uint8 _wllVcnOffset;
- uint8 _vcnBlockWidth;
- uint8 _vcnBlockHeight;
- uint8 _vcnFlip0;
- uint8 _vcnFlip1;
uint8 **_doorShapes;
@@ -288,7 +283,7 @@ protected:
void removeInputTop();
void gui_drawBox(int x, int y, int w, int h, int frameColor1, int frameColor2, int fillColor);
virtual void gui_drawHorizontalBarGraph(int x, int y, int w, int h, int32 curVal, int32 maxVal, int col1, int col2);
- void gui_initButtonsFromList(const int16 *list);
+ void gui_initButtonsFromList(const uint8 *list);
virtual void gui_initButton(int index, int x = -1, int y = -1, int val = -1) = 0;
void gui_resetButtonList();
void gui_notifyButtonListChanged();
@@ -385,7 +380,7 @@ protected:
bool lineIsPassable(int, int) { return false; }
};
-} // End of namespace Kyra
+} // End of namespace Kyra
#endif // ENABLE_EOB || ENABLE_LOL
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp
index 2672618c67..9194b64155 100644
--- a/engines/kyra/kyra_v1.cpp
+++ b/engines/kyra/kyra_v1.cpp
@@ -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())
@@ -366,84 +353,88 @@ void KyraEngine_v1::setupKeyMap() {
Common::KeyCode kcScummVM;
int16 kcDOS;
int16 kcPC98;
+ int16 kcFMTowns;
};
+#define UNKNOWN_KEYCODE -1
#define KC(x) Common::KEYCODE_##x
static const KeyCodeMapEntry keys[] = {
- { KC(SPACE), 61, 53 },
- { KC(RETURN), 43, 29 },
- { KC(UP), 96, 68 },
- { KC(KP8), 96, 68 },
- { KC(RIGHT), 102, 73 },
- { KC(KP6), 102, 73 },
- { KC(DOWN), 98, 76 },
- { KC(KP2), 98, 76 },
- { KC(KP5), 97, 72 },
- { KC(LEFT), 92, 71 },
- { KC(KP4), 92, 71 },
- { KC(HOME), 91, 67 },
- { KC(KP7), 91, 67 },
- { KC(PAGEUP), 101, 69 },
- { KC(KP9), 101, 69 },
- { KC(END), 93, 0/*unknown*/ },
- { KC(KP1), 93, 0/*unknown*/ },
- { KC(PAGEDOWN), 103, 0/*unknown*/ },
- { KC(KP3), 103, 0/*unknown*/ },
- { KC(F1), 112, 99 },
- { KC(F2), 113, 100 },
- { KC(F3), 114, 101 },
- { KC(F4), 115, 102 },
- { KC(F5), 116, 103 },
- { KC(F6), 117, 104 },
- { KC(a), 31, 31 },
- { KC(b), 50, 50 },
- { KC(c), 48, 48 },
- { KC(d), 33, 33 },
- { KC(e), 19, 19 },
- { KC(f), 34, 34 },
- { KC(i), 24, 24 },
- { KC(k), 38, 38 },
- { KC(m), 52, 52 },
- { KC(n), 51, 51 },
- { KC(o), 25, 25 },
- { KC(p), 26, 26 },
- { KC(r), 20, 20 },
- { KC(s), 32, 32 },
- { KC(w), 18, 18 },
- { KC(y), 22, 22 },
- { KC(z), 46, 46 },
- { KC(1), 2, 0/*unknown*/ },
- { KC(2), 3, 0/*unknown*/ },
- { KC(3), 4, 0/*unknown*/ },
- { KC(4), 5, 0/*unknown*/ },
- { KC(5), 6, 0/*unknown*/ },
- { KC(6), 7, 0/*unknown*/ },
- { KC(7), 8, 0/*unknown*/ },
- { KC(SLASH), 55, 55 },
- { KC(ESCAPE), 110, 1 },
- { KC(MINUS), 12, 0/*unknown*/ },
- { KC(KP_MINUS), 105, 0/*unknown*/ },
- { KC(PLUS), 13, 0/*unknown*/ },
- { KC(KP_PLUS), 106, 0/*unknown*/ },
+ { KC(SPACE), 61, 53, 32 },
+ { KC(RETURN), 43, 29, 13 },
+ { KC(UP), 96, 68, 30 },
+ { KC(KP8), 96, 68, 30 },
+ { KC(RIGHT), 102, 73, 28 },
+ { KC(KP6), 102, 73, 28 },
+ { KC(DOWN), 98, 76, 31 },
+ { KC(KP2), 98, 76, 31 },
+ { KC(KP5), 97, 72, UNKNOWN_KEYCODE },
+ { KC(LEFT), 92, 71, 29 },
+ { KC(KP4), 92, 71, 29 },
+ { KC(HOME), 91, 67, 127 },
+ { KC(KP7), 91, 67, 127 },
+ { KC(PAGEUP), 101, 69, 18 },
+ { KC(KP9), 101, 69, 18 },
+ { KC(END), 93, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE },
+ { KC(KP1), 93, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE },
+ { KC(PAGEDOWN), 103, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE },
+ { KC(KP3), 103, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE },
+ { KC(F1), 112, 99, UNKNOWN_KEYCODE },
+ { KC(F2), 113, 100, UNKNOWN_KEYCODE },
+ { KC(F3), 114, 101, UNKNOWN_KEYCODE },
+ { KC(F4), 115, 102, UNKNOWN_KEYCODE },
+ { KC(F5), 116, 103, UNKNOWN_KEYCODE },
+ { KC(F6), 117, 104, UNKNOWN_KEYCODE },
+ { KC(a), 31, 31, UNKNOWN_KEYCODE },
+ { KC(b), 50, 50, UNKNOWN_KEYCODE },
+ { KC(c), 48, 48, 67 },
+ { KC(d), 33, 33, UNKNOWN_KEYCODE },
+ { KC(e), 19, 19, UNKNOWN_KEYCODE },
+ { KC(f), 34, 34, UNKNOWN_KEYCODE },
+ { KC(i), 24, 24, UNKNOWN_KEYCODE },
+ { KC(k), 38, 38, UNKNOWN_KEYCODE },
+ { KC(m), 52, 52, UNKNOWN_KEYCODE },
+ { KC(n), 51, 51, UNKNOWN_KEYCODE },
+ { KC(o), 25, 25, 79 },
+ { KC(p), 26, 26, 80 },
+ { KC(r), 20, 20, 82 },
+ { KC(s), 32, 32, UNKNOWN_KEYCODE },
+ { KC(w), 18, 18, UNKNOWN_KEYCODE },
+ { KC(y), 22, 22, UNKNOWN_KEYCODE },
+ { KC(z), 46, 46, UNKNOWN_KEYCODE },
+ { KC(0), UNKNOWN_KEYCODE, UNKNOWN_KEYCODE, 48 },
+ { KC(1), 2, UNKNOWN_KEYCODE, 49 },
+ { KC(2), 3, UNKNOWN_KEYCODE, 50 },
+ { KC(3), 4, UNKNOWN_KEYCODE, 51 },
+ { KC(4), 5, UNKNOWN_KEYCODE, 52 },
+ { KC(5), 6, UNKNOWN_KEYCODE, 53 },
+ { KC(6), 7, UNKNOWN_KEYCODE, 54 },
+ { KC(7), 8, UNKNOWN_KEYCODE, 55 },
+ { KC(SLASH), 55, 55, 47 },
+ { KC(ESCAPE), 110, 1, 27 },
+ { KC(MINUS), 12, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE },
+ { KC(KP_MINUS), 105, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE },
+ { KC(PLUS), 13, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE },
+ { KC(KP_PLUS), 106, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE },
// Multiple mappings for the keys to the right of the 'M' key,
// since these are different for QWERTZ, QWERTY and AZERTY keyboards.
// QWERTZ
- { KC(COMMA), 53, 0/*unknown*/ },
- { KC(PERIOD), 54, 0/*unknown*/ },
+ { KC(COMMA), 53, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE },
+ { KC(PERIOD), 54, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE },
// AZERTY
- { KC(SEMICOLON), 53, 0/*unknown*/ },
- { KC(COLON), 54, 0/*unknown*/ },
+ { KC(SEMICOLON), 53, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE },
+ { KC(COLON), 54, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE },
// QWERTY
- { KC(LESS), 53, 0/*unknown*/ },
- { KC(GREATER), 54, 0/*unknown*/ }
+ { KC(LESS), 53, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE },
+ { KC(GREATER), 54, UNKNOWN_KEYCODE, UNKNOWN_KEYCODE }
};
#undef KC
+#undef UNKNOWN_KEYCODE
_keyMap.clear();
for (int i = 0; i < ARRAYSIZE(keys); i++)
- _keyMap[keys[i].kcScummVM] = (_flags.platform == Common::kPlatformPC98) ? keys[i].kcPC98 : keys[i].kcDOS;
+ _keyMap[keys[i].kcScummVM] = (_flags.platform == Common::kPlatformPC98) ? keys[i].kcPC98 : ((_flags.platform == Common::kPlatformFMTowns) ? keys[i].kcFMTowns : keys[i].kcDOS);
}
void KyraEngine_v1::updateInput() {
diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h
index 0033969047..cd048563ca 100644
--- a/engines/kyra/kyra_v1.h
+++ b/engines/kyra/kyra_v1.h
@@ -140,14 +140,6 @@ enum {
GI_EOB2 = 6
};
-struct AudioDataStruct {
- const char *const *fileList;
- int fileListLen;
- const void *cdaTracks;
- int cdaNumTracks;
- int extraOffset;
-};
-
// TODO: this is just the start of makeing the debug output of the kyra engine a bit more useable
// in the future we maybe merge some flags and/or create new ones
enum DebugLevels {
@@ -164,7 +156,7 @@ enum DebugLevels {
kDebugLevelTimer = 1 << 10 ///< debug level for "TimerManager" functions
};
-enum MusicDataID {
+enum AudioResourceSet {
kMusicIntro = 0,
kMusicIngame,
kMusicFinale
@@ -188,6 +180,7 @@ friend class GUI;
friend class GUI_v1;
friend class GUI_EoB;
friend class SoundMidiPC; // For _eventMan
+friend class SeqPlayer_HOF; // For skipFlag()
friend class TransferPartyWiz; // For save state API
public:
KyraEngine_v1(OSystem *system, const GameFlags &flags);
@@ -415,14 +408,14 @@ protected:
Graphics::Surface *thumbnail;
};
- enum kReadSaveHeaderError {
+ enum ReadSaveHeaderError {
kRSHENoError = 0,
kRSHEInvalidType = 1,
kRSHEInvalidVersion = 2,
kRSHEIoError = 3
};
- static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *file, bool loadThumbnail, SaveHeader &header);
+ static ReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *file, bool loadThumbnail, SaveHeader &header);
void loadGameStateCheck(int slot);
virtual Common::Error loadGameState(int slot) = 0;
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp
index d3028c5e2d..3af65d9b7a 100644
--- a/engines/kyra/lol.cpp
+++ b/engines/kyra/lol.cpp
@@ -114,7 +114,7 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraRpgEngine(sy
_selectedSpell = 0;
_updateCharNum = _portraitSpeechAnimMode = _textColorFlag = 0;
_palUpdateTimer = _updatePortraitNext = 0;
- _lampStatusTimer = 0xffffffff;
+ _lampStatusTimer = 0xFFFFFFFF;
_weaponsDisabled = false;
_charInventoryUnk = 0;
@@ -381,10 +381,10 @@ Common::Error LoLEngine::init() {
_screen->setAnimBlockPtr(10000);
_screen->setScreenDim(0);
- _pageBuffer1 = new uint8[0xfa00];
- memset(_pageBuffer1, 0, 0xfa00);
- _pageBuffer2 = new uint8[0xfa00];
- memset(_pageBuffer2, 0, 0xfa00);
+ _pageBuffer1 = new uint8[0xFA00];
+ memset(_pageBuffer1, 0, 0xFA00);
+ _pageBuffer2 = new uint8[0xFA00];
+ memset(_pageBuffer2, 0, 0xFA00);
_itemsInPlay = new LoLItem[400];
memset(_itemsInPlay, 0, sizeof(LoLItem) * 400);
@@ -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;
@@ -519,7 +524,7 @@ Common::Error LoLEngine::go() {
// the prologue code we need to setup them manually here.
if (_gameToLoad != -1 && action != 3) {
preInit();
- _screen->setFont(_flags.use16ColorMode ? Screen::FID_SJIS_FNT : Screen::FID_9_FNT);
+ _screen->setFont((_flags.lang == Common::JA_JPN && _flags.use16ColorMode) ? Screen::FID_SJIS_FNT : Screen::FID_9_FNT);
}
// We have three sound.dat files, one for the intro, one for the
@@ -529,7 +534,7 @@ Common::Error LoLEngine::go() {
if (_flags.platform == Common::kPlatformPC98)
_sound->loadSoundFile("sound.dat");
- _sound->setSoundList(&_soundData[kMusicIngame]);
+ _sound->selectAudioResourceSet(kMusicIngame);
if (_flags.platform != Common::kPlatformPC)
_sound->loadSoundFile(0);
@@ -669,7 +674,7 @@ void LoLEngine::checkFloatingPointerRegions() {
uint8 *LoLEngine::getItemIconShapePtr(int index) {
int ix = _itemProperties[_itemsInPlay[index].itemPropertyIndex].shpIndex;
if (_itemProperties[_itemsInPlay[index].itemPropertyIndex].flags & 0x200)
- ix += (_itemsInPlay[index].shpCurFrame_flg & 0x1fff) - 1;
+ ix += (_itemsInPlay[index].shpCurFrame_flg & 0x1FFF) - 1;
return _itemIconShapes[ix];
}
@@ -678,14 +683,14 @@ int LoLEngine::mainMenu() {
bool hasSave = saveFileLoadable(0);
MainMenu::StaticData data[] = {
- // 256 color mode
+ // 256 color ASCII mode
{
{ 0, 0, 0, 0, 0 },
{ 0x01, 0x04, 0x0C, 0x04, 0x00, 0x3D, 0x9F },
{ 0x2C, 0x19, 0x48, 0x2C },
Screen::FID_9_FNT, 1
},
- // 16 color mode
+ // 16 color SJIS mode
{
{ 0, 0, 0, 0, 0 },
{ 0x01, 0x04, 0x0C, 0x04, 0x00, 0xC1, 0xE1 },
@@ -928,7 +933,7 @@ void LoLEngine::writeSettings() {
case 0:
default:
- if (_flags.platform == Common::kPlatformPC98)
+ if (_flags.platform == Common::kPlatformPC98 || _flags.platform == Common::kPlatformFMTowns)
_flags.lang = Common::JA_JPN;
else
_flags.lang = Common::EN_ANY;
@@ -1024,7 +1029,7 @@ void LoLEngine::decodeSjis(const char *src, char *dst) {
uint8 cmd = 0;
while ((cmd = *src++) != 0) {
if (cmd == 27) {
- cmd = *src++ & 0x7f;
+ cmd = *src++ & 0x7F;
memcpy(dst, src, cmd * 2);
dst += cmd * 2;
src += cmd * 2;
@@ -1336,7 +1341,7 @@ int LoLEngine::calculateProtection(int index) {
int c = 0;
if (index & 0x8000) {
// Monster
- index &= 0x7fff;
+ index &= 0x7FFF;
c = (_monsters[index].properties->itemProtection * _monsters[index].properties->fightingStats[2]) >> 8;
} else {
// Character
@@ -1358,7 +1363,7 @@ void LoLEngine::setCharacterMagicOrHitPoints(int charNum, int type, int points,
{ 0x21, 0xAA, 0x99, 0x00, 0x4253 }
};
- if (charNum > 3)
+ if (charNum > 2)
return;
LoLCharacter *c = &_characters[charNum];
@@ -1485,7 +1490,7 @@ void LoLEngine::increaseCharacterHitpoints(int charNum, int points, bool ignoreD
points = 1;
_characters[charNum].hitPointsCur = CLIP<int16>(_characters[charNum].hitPointsCur + points, 1, _characters[charNum].hitPointsMax);
- _characters[charNum].flags &= 0xfff7;
+ _characters[charNum].flags &= 0xFFF7;
}
void LoLEngine::setupScreenDims() {
@@ -1556,10 +1561,10 @@ void LoLEngine::gui_specialSceneSuspendControls(int controlMode) {
void LoLEngine::gui_specialSceneRestoreControls(int restoreLamp) {
if (restoreLamp) {
- _updateFlags &= 0xfffa;
+ _updateFlags &= 0xFFFA;
resetLampStatus();
}
- _updateFlags &= 0xfffe;
+ _updateFlags &= 0xFFFE;
_specialSceneFlag = 0;
checkFloatingPointerRegions();
}
@@ -1567,7 +1572,7 @@ void LoLEngine::gui_specialSceneRestoreControls(int restoreLamp) {
void LoLEngine::restoreAfterSceneWindowDialogue(int redraw) {
gui_enableControls();
_txt->setupField(false);
- _updateFlags &= 0xffdf;
+ _updateFlags &= 0xFFDF;
setDefaultButtonState();
@@ -1596,8 +1601,8 @@ void LoLEngine::initDialogueSequence(int controlMode, int pageNum) {
if (_flags.use16ColorMode) {
_screen->fillRect(0, 128, 319, 199, 0x44);
- gui_drawBox(0, 129, 320, 71, 0xee, 0xcc, -1);
- gui_drawBox(1, 130, 318, 69, 0xee, 0xcc, 0x11);
+ gui_drawBox(0, 129, 320, 71, 0xEE, 0xCC, -1);
+ gui_drawBox(1, 130, 318, 69, 0xEE, 0xCC, 0x11);
} else {
_screen->fillRect(0, 128, 319, 199, 1);
gui_drawBox(0, 129, 320, 71, 136, 251, -1);
@@ -1646,7 +1651,7 @@ void LoLEngine::restoreAfterDialogueSequence(int controlMode) {
if (_currentControlMode) {
_screen->modifyScreenDim(4, 11, 124, 28, 45);
_screen->modifyScreenDim(5, 85, 123, 233, 54);
- _updateFlags &= 0xfffd;
+ _updateFlags &= 0xFFFD;
} else {
const ScreenDim *d = _screen->getScreenDim(5);
_screen->fillRect(d->sx, d->sy, d->sx + d->w - (_flags.use16ColorMode ? 3 : 2), d->sy + d->h - 2, d->unkA);
@@ -1709,14 +1714,14 @@ void LoLEngine::generateBrightnessPalette(const Palette &src, Palette &dst, int
brightness = (8 - brightness) << 5;
if (modifier >= 0 && modifier < 8 && (_flagsTable[31] & 0x08)) {
- brightness = 256 - ((((modifier & 0xfffe) << 5) * (256 - brightness)) >> 8);
+ brightness = 256 - ((((modifier & 0xFFFE) << 5) * (256 - brightness)) >> 8);
if (brightness < 0)
brightness = 0;
}
for (int i = 0; i < 384; i++) {
uint16 c = (dst[i] * brightness) >> 8;
- dst[i] = c & 0xff;
+ dst[i] = c & 0xFF;
}
}
}
@@ -1726,9 +1731,9 @@ void LoLEngine::generateFlashPalette(const Palette &src, Palette &dst, int color
for (int i = 2; i < 128; i++) {
for (int ii = 0; ii < 3; ii++) {
- uint8 t = src[i * 3 + ii] & 0x3f;
+ uint8 t = src[i * 3 + ii] & 0x3F;
if (colorFlags & (1 << ii))
- t += ((0x3f - t) >> 1);
+ t += ((0x3F - t) >> 1);
else
t -= (t >> 1);
dst[i * 3 + ii] = t;
@@ -1750,7 +1755,7 @@ void LoLEngine::createTransparencyTables() {
0x88, 0x00, 0x99, 0x00, 0xAA, 0x00, 0xBB, 0x00, 0xCC, 0x00, 0xDD, 0x00, 0xEE, 0x00, 0xFF, 0x00
};
- memset(tpal, 0xff, 768);
+ memset(tpal, 0xFF, 768);
_res->loadFileToBuf("LOL.NOL", tpal, 48);
for (int i = 15; i > -1; i--) {
@@ -1758,7 +1763,7 @@ void LoLEngine::createTransparencyTables() {
tpal[s] = tpal[i * 3];
tpal[s + 1] = tpal[i * 3 + 1];
tpal[s + 2] = tpal[i * 3 + 2];
- tpal[i * 3 + 2] = tpal[i * 3 + 1] = tpal[i * 3] = 0xff;
+ tpal[i * 3 + 2] = tpal[i * 3 + 1] = tpal[i * 3] = 0xFF;
}
_screen->createTransparencyTablesIntern(colTbl, 16, tpal, tpal, _transparencyTable1, _transparencyTable2, 80);
@@ -1846,7 +1851,7 @@ int LoLEngine::playCharacterScriptChat(int charId, int mode, int restorePortrait
} else if (charId > 0) {
int i = 0;
- for (; i < 4; i++) {
+ for (; i < 3; i++) {
if (_characters[i].id != charId || !(_characters[i].flags & 1))
continue;
if (charId == ch)
@@ -1948,15 +1953,15 @@ void LoLEngine::giveItemToMonster(LoLMonster *monster, Item item) {
}
const uint16 *LoLEngine::getCharacterOrMonsterStats(int id) {
- return (id & 0x8000) ? (const uint16 *)_monsters[id & 0x7fff].properties->fightingStats : _characters[id].defaultModifiers;
+ return (id & 0x8000) ? (const uint16 *)_monsters[id & 0x7FFF].properties->fightingStats : _characters[id].defaultModifiers;
}
uint16 *LoLEngine::getCharacterOrMonsterItemsMight(int id) {
- return (id & 0x8000) ? _monsters[id & 0x7fff].properties->itemsMight : _characters[id].itemsMight;
+ return (id & 0x8000) ? _monsters[id & 0x7FFF].properties->itemsMight : _characters[id].itemsMight;
}
uint16 *LoLEngine::getCharacterOrMonsterProtectionAgainstItems(int id) {
- return (id & 0x8000) ? _monsters[id & 0x7fff].properties->protectionAgainstItems : _characters[id].protectionAgainstItems;
+ return (id & 0x8000) ? _monsters[id & 0x7FFF].properties->protectionAgainstItems : _characters[id].protectionAgainstItems;
}
void LoLEngine::delay(uint32 millis, bool doUpdate, bool) {
@@ -2093,7 +2098,7 @@ int LoLEngine::processMagicSpark(int charNum, int spellLevel) {
uint16 target = getNearestMonsterFromCharacterForBlock(targetBlock, charNum);
static const uint8 dmg[] = { 7, 15, 25, 60 };
- if (target != 0xffff) {
+ if (target != 0xFFFF) {
inflictMagicalDamage(target, charNum, dmg[spellLevel], 5, 0);
updateDrawPage2();
gui_drawScene(0);
@@ -2111,8 +2116,8 @@ int LoLEngine::processMagicSpark(int charNum, int spellLevel) {
const uint16 height = mov->height();
for (int i = 0; i < 6; i++) {
- wX[i] = (_rnd.getRandomNumber(0x7fff) % 64) + ((176 - width) >> 1) + 80;
- wY[i] = (_rnd.getRandomNumber(0x7fff) % 32) + ((120 - height) >> 1) - 16;
+ wX[i] = (_rnd.getRandomNumber(0x7FFF) % 64) + ((176 - width) >> 1) + 80;
+ wY[i] = (_rnd.getRandomNumber(0x7FFF) % 32) + ((120 - height) >> 1) - 16;
wFrames[i] = i << 1;
}
@@ -2162,7 +2167,7 @@ int LoLEngine::processMagicHeal(int charNum, int spellLevel) {
tpal.copy(_screen->getPalette(1));
if (_flags.use16ColorMode) {
- tpal.fill(16, 240, 0xff);
+ tpal.fill(16, 240, 0xFF);
uint8 *dst = tpal.getData();
for (int i = 1; i < 16; i++) {
int s = ((i << 4) | i) * 3;
@@ -2245,7 +2250,7 @@ int LoLEngine::processMagicHeal(int charNum, int spellLevel) {
_screen->copyRegion(charNum * 77, 32, pX[charNum], pY, 77, 44, 2, 2, Screen::CR_NO_P_CHECK);
- pts[charNum] &= 0xff;
+ pts[charNum] &= 0xFF;
pts[charNum] += ((diff[charNum] << 8) / 16);
increaseCharacterHitpoints(charNum, pts[charNum] / 256, true);
gui_drawCharPortraitWithStats(charNum);
@@ -2328,8 +2333,8 @@ int LoLEngine::processMagicIce(int charNum, int spellLevel) {
tpal[i * 3 + 1] = v;
tpal[i * 3 + 2] = v << 1;
- if (tpal[i * 3 + 2] > 0x3f)
- tpal[i * 3 + 2] = 0x3f;
+ if (tpal[i * 3 + 2] > 0x3F)
+ tpal[i * 3 + 2] = 0x3F;
}
}
@@ -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) {
@@ -2390,7 +2395,7 @@ int LoLEngine::processMagicIce(int charNum, int spellLevel) {
int might = rollDice(iceDamageMin[spellLevel], iceDamageMax[spellLevel]) + iceDamageAdd[spellLevel];
int dmg = calcInflictableDamagePerItem(charNum, 0, might, 3, 2);
- LoLMonster *m = &_monsters[o & 0x7fff];
+ LoLMonster *m = &_monsters[o & 0x7FFF];
if (m->hitPoints <= dmg) {
increaseExperience(charNum, 2, m->hitPoints);
o = m->nextAssignedObject;
@@ -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());
@@ -2469,7 +2474,7 @@ int LoLEngine::processMagicFireball(int charNum, int spellLevel) {
while (o & 0x8000) {
static const uint8 fireballDamage[] = { 20, 40, 80, 100 };
int dmg = calcInflictableDamagePerItem(charNum, o, fireballDamage[spellLevel], 4, 1);
- LoLMonster *m = &_monsters[o & 0x7fff];
+ LoLMonster *m = &_monsters[o & 0x7FFF];
o = m->nextAssignedObject;
_envSfxUseQueue = true;
inflictDamage(m->id | 0x8000, dmg, charNum, 2, 4);
@@ -2519,8 +2524,8 @@ int LoLEngine::processMagicFireball(int charNum, int spellLevel) {
static const int8 finShpIndex2[] = { -1, 1, 2, 3, 4, -1 };
uint8 *shp = fb->finalize ? _fireballShapes[finShpIndex1[fb->finProgress]] : _fireballShapes[0];
- int fX = (((fb->progress * _fireBallCoords[fb->tblIndex & 0xff]) >> 16) + fb->destX) - ((fb->progress / 8 + shp[3] + fireBallWH) >> 1);
- int fY = (((fb->progress * _fireBallCoords[(fb->tblIndex + 64) & 0xff]) >> 16) + fb->destY) - ((fb->progress / 8 + shp[2] + fireBallWH) >> 1);
+ int fX = (((fb->progress * _fireBallCoords[fb->tblIndex & 0xFF]) >> 16) + fb->destX) - ((fb->progress / 8 + shp[3] + fireBallWH) >> 1);
+ int fY = (((fb->progress * _fireBallCoords[(fb->tblIndex + 64) & 0xFF]) >> 16) + fb->destY) - ((fb->progress / 8 + shp[2] + fireBallWH) >> 1);
int sW = ((fb->progress / 8 + shp[3] + fireBallWH) << 8) / shp[3];
int sH = ((fb->progress / 8 + shp[2] + fireBallWH) << 8) / shp[2];
@@ -2532,8 +2537,8 @@ int LoLEngine::processMagicFireball(int charNum, int spellLevel) {
if (finShpIndex2[fb->finProgress] != -1) {
shp = _fireballShapes[finShpIndex2[fb->finProgress]];
- fX = (((fb->progress * _fireBallCoords[fb->tblIndex & 0xff]) >> 16) + fb->destX) - ((fb->progress / 8 + shp[3] + fireBallWH) >> 1);
- fY = (((fb->progress * _fireBallCoords[(fb->tblIndex + 64) & 0xff]) >> 16) + fb->destY) - ((fb->progress / 8 + shp[2] + fireBallWH) >> 1);
+ fX = (((fb->progress * _fireBallCoords[fb->tblIndex & 0xFF]) >> 16) + fb->destX) - ((fb->progress / 8 + shp[3] + fireBallWH) >> 1);
+ fY = (((fb->progress * _fireBallCoords[(fb->tblIndex + 64) & 0xFF]) >> 16) + fb->destY) - ((fb->progress / 8 + shp[2] + fireBallWH) >> 1);
sW = ((fb->progress / 8 + shp[3] + fireBallWH) << 8) / shp[3];
sH = ((fb->progress / 8 + shp[2] + fireBallWH) << 8) / shp[2];
_screen->drawShape(_screen->_curPage, shp, fX, fY, 0, 4, sW, sH);
@@ -2634,7 +2639,7 @@ int LoLEngine::processMagicHandOfFate(int spellLevel) {
uint16 o = _levelBlockProperties[b1].assignedObjects;
while (o & 0x8000) {
uint16 o2 = o;
- LoLMonster *m = &_monsters[o & 0x7fff];
+ LoLMonster *m = &_monsters[o & 0x7FFF];
o = findObject(o)->nextAssignedObject;
int nX = 0;
int nY = 0;
@@ -2662,7 +2667,7 @@ int LoLEngine::processMagicHandOfFate(int spellLevel) {
// This might be a bug in the original code, but using
// the hand of fate spell won't give any experience points
int dmg = calcInflictableDamagePerItem(-1, t, damage[spellLevel - 2], 0x80, 1);
- inflictDamage(t, dmg, 0xffff, 3, 0x80);
+ inflictDamage(t, dmg, 0xFFFF, 3, 0x80);
}
}
@@ -2778,7 +2783,7 @@ int LoLEngine::processMagicFog() {
uint16 o = _levelBlockProperties[calcNewBlockPosition(_currentBlock, _currentDirection)].assignedObjects;
while (o & 0x8000) {
inflictMagicalDamage(o, -1, 15, 6, 0);
- o = _monsters[o & 0x7fff].nextAssignedObject;
+ o = _monsters[o & 0x7FFF].nextAssignedObject;
}
gui_drawScene(0);
@@ -2803,7 +2808,7 @@ int LoLEngine::processMagicSwarm(int charNum, int damage) {
int t = 0;
uint16 o = _levelBlockProperties[calcNewBlockPosition(_currentBlock, _currentDirection)].assignedObjects;
while (o & 0x8000) {
- o &= 0x7fff;
+ o &= 0x7FFF;
if (_monsters[o].mode != 13) {
destIds[t++] = o;
@@ -2811,7 +2816,7 @@ int LoLEngine::processMagicSwarm(int charNum, int damage) {
_envSfxUseQueue = true;
inflictMagicalDamage(o | 0x8000, charNum, damage, 0, 0);
_envSfxUseQueue = false;
- _monsters[o].flags &= 0xffef;
+ _monsters[o].flags &= 0xFFEF;
}
}
o = _monsters[o].nextAssignedObject;
@@ -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();
}
@@ -2903,9 +2908,9 @@ int LoLEngine::processMagicVaelansCube() {
uint16 o = _levelBlockProperties[bl].assignedObjects;
while (o & 0x8000) {
- LoLMonster *m = &_monsters[o & 0x7fff];
+ LoLMonster *m = &_monsters[o & 0x7FFF];
if (m->properties->flags & 0x1000) {
- inflictDamage(o, 100, 0xffff, 0, 0x80);
+ inflictDamage(o, 100, 0xFFFF, 0, 0x80);
res = 1;
}
o = m->nextAssignedObject;
@@ -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();
}
@@ -3031,7 +3036,7 @@ void LoLEngine::drinkBezelCup(int numUses, int charNum) {
uint16 step = 0;
do {
- step = (step & 0xff) + (hpDiff * 256) / (bezelAnimData[numUses * 3 + 1]);
+ step = (step & 0xFF) + (hpDiff * 256) / (bezelAnimData[numUses * 3 + 1]);
increaseCharacterHitpoints(charNum, step / 256, true);
gui_drawCharPortraitWithStats(charNum);
@@ -3068,7 +3073,7 @@ void LoLEngine::addSpellToScroll(int spell, int charNum) {
}
if (_availableSpells[i] == spell) {
- _txt->printMessage(2, "%s", getLangString(0x42d0));
+ _txt->printMessage(2, "%s", getLangString(0x42D0));
return;
}
}
@@ -3096,7 +3101,7 @@ void LoLEngine::transferSpellToScollAnimation(int charNum, int spell, int slot)
_screen->copyRegion(201, 1, 17, 15, 6, h, 2, 2, Screen::CR_NO_P_CHECK);
_screen->copyRegion(208, 1, 89, 15, 6, h, 2, 2, Screen::CR_NO_P_CHECK);
int cp = _screen->setCurPage(2);
- _screen->fillRect(21, 15, 89, h + 15, _flags.use16ColorMode ? 0xbb : 206);
+ _screen->fillRect(21, 15, 89, h + 15, _flags.use16ColorMode ? 0xBB : 206);
_screen->copyRegion(112, 16, 12, h + 15, 87, 14, 2, 2, Screen::CR_NO_P_CHECK);
int y = 15;
@@ -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) {
@@ -3284,7 +3289,7 @@ int LoLEngine::checkMagic(int charNum, int spellNum, int spellLevel) {
}
int LoLEngine::getSpellTargetBlock(int currentBlock, int direction, int maxDistance, uint16 &targetBlock) {
- targetBlock = 0xffff;
+ targetBlock = 0xFFFF;
uint16 c = calcNewBlockPosition(currentBlock, direction);
int i = 0;
@@ -3316,9 +3321,9 @@ void LoLEngine::inflictMagicalDamageForBlock(int block, int attacker, int damage
uint16 o = _levelBlockProperties[block].assignedObjects;
while (o & 0x8000) {
inflictDamage(o, calcInflictableDamagePerItem(attacker, o, damage, index, 2), attacker, 2, index);
- if ((_monsters[o & 0x7fff].flags & 0x20) && (_currentLevel != 22))
+ if ((_monsters[o & 0x7FFF].flags & 0x20) && (_currentLevel != 22))
break;
- o = _monsters[o & 0x7fff].nextAssignedObject;
+ o = _monsters[o & 0x7FFF].nextAssignedObject;
}
}
@@ -3331,7 +3336,7 @@ int LoLEngine::battleHitSkillTest(int16 attacker, int16 target, int skill) {
return 1;
if (target & 0x8000) {
- if (_monsters[target & 0x7fff].mode >= 13)
+ if (_monsters[target & 0x7FFF].mode >= 13)
return 0;
}
@@ -3340,8 +3345,8 @@ int LoLEngine::battleHitSkillTest(int16 attacker, int16 target, int skill) {
int sk = 0;
if (attacker & 0x8000) {
- hitChanceModifier = _monsters[target & 0x7fff].properties->fightingStats[0];
- sk = 100 - _monsters[target & 0x7fff].properties->skillLevel;
+ hitChanceModifier = _monsters[target & 0x7FFF].properties->fightingStats[0];
+ sk = 100 - _monsters[target & 0x7FFF].properties->skillLevel;
} else {
hitChanceModifier = _characters[attacker].defaultModifiers[0];
int8 m = _characters[attacker].skillModifiers[skill];
@@ -3351,8 +3356,10 @@ int LoLEngine::battleHitSkillTest(int16 attacker, int16 target, int skill) {
}
if (target & 0x8000) {
- evadeChanceModifier = (_monsterModifiers[9 + _monsterDifficulty] * _monsters[target & 0x7fff].properties->fightingStats[3]) >> 8;
- _monsters[target & 0x7fff].flags |= 0x10;
+ evadeChanceModifier = _monsters[target & 0x7FFF].properties->fightingStats[3];
+ if (_monsterModifiers4)
+ evadeChanceModifier = (evadeChanceModifier * _monsterModifiers4[_monsterDifficulty]) >> 8;
+ _monsters[target & 0x7FFF].flags |= 0x10;
} else {
evadeChanceModifier = _characters[target].defaultModifiers[3];
}
@@ -3387,7 +3394,7 @@ int LoLEngine::inflictDamage(uint16 target, int damage, uint16 attacker, int ski
LoLCharacter *c = 0;
if (target & 0x8000) {
- m = &_monsters[target & 0x7fff];
+ m = &_monsters[target & 0x7FFF];
if (m->mode >= 13)
return 0;
@@ -3477,7 +3484,7 @@ void LoLEngine::removeCharacterEffects(LoLCharacter *c, int first, int last) {
for (int i = first; i <= last; i++) {
switch (i - 1) {
case 0:
- c->flags &= 0xfffb;
+ c->flags &= 0xFFFB;
c->weaponHit = 0;
break;
@@ -3486,19 +3493,19 @@ void LoLEngine::removeCharacterEffects(LoLCharacter *c, int first, int last) {
break;
case 2:
- c->flags &= 0xffbf;
+ c->flags &= 0xFFBF;
break;
case 3:
- c->flags &= 0xff7f;
+ c->flags &= 0xFF7F;
break;
case 4:
- c->flags &= 0xfeff;
+ c->flags &= 0xFEFF;
break;
case 6:
- c->flags &= 0xefff;
+ c->flags &= 0xEFFF;
break;
default:
@@ -3552,7 +3559,7 @@ int LoLEngine::calcInflictableDamagePerItem(int16 attacker, int16 target, uint16
void LoLEngine::checkForPartyDeath() {
Button b;
- b.data0Val2 = b.data1Val2 = b.data2Val2 = 0xfe;
+ b.data0Val2 = b.data1Val2 = b.data2Val2 = 0xFE;
b.data0Val3 = b.data1Val3 = b.data2Val3 = 0x01;
for (int i = 0; i < 4; i++) {
@@ -3591,7 +3598,7 @@ void LoLEngine::checkForPartyDeath() {
_gui->runMenu(_gui->_deathMenu);
setMouseCursorToItemInHand();
- _updateFlags &= 0xfffb;
+ _updateFlags &= 0xFFFB;
resetLampStatus();
gui_enableDefaultPlayfieldButtons();
@@ -3608,7 +3615,7 @@ void LoLEngine::applyMonsterAttackSkill(LoLMonster *monster, int16 target, int16
switch (monster->properties->attackSkillType - 1) {
case 0:
- t = removeCharacterItem(target, 0x7ff);
+ t = removeCharacterItem(target, 0x7FF);
if (t) {
giveItemToMonster(monster, t);
if (characterSays(0x4019, _characters[target].id, true))
@@ -3625,16 +3632,16 @@ void LoLEngine::applyMonsterAttackSkill(LoLMonster *monster, int16 target, int16
t = removeCharacterItem(target, 0x20);
if (t) {
deleteItem(t);
- if (characterSays(0x401b, _characters[target].id, true))
- _txt->printMessage(6, "%s", getLangString(0x401b));
+ if (characterSays(0x401B, _characters[target].id, true))
+ _txt->printMessage(6, "%s", getLangString(0x401B));
}
break;
case 3:
- t = removeCharacterItem(target, 0x0f);
+ t = removeCharacterItem(target, 0x0F);
if (t) {
- if (characterSays(0x401e, _characters[target].id, true))
- _txt->printMessage(6, getLangString(0x401e), _characters[target].name);
+ if (characterSays(0x401E, _characters[target].id, true))
+ _txt->printMessage(6, getLangString(0x401E), _characters[target].name);
setItemPosition(t, monster->x, monster->y, 0, 1);
}
break;
@@ -3679,27 +3686,27 @@ void LoLEngine::applyMonsterDefenseSkill(LoLMonster *monster, int16 attacker, in
switch (monster->properties->defenseSkillType - 1) {
case 0:
case 1:
- if ((flags & 0x3f) == 2 || skill)
+ if ((flags & 0x3F) == 2 || skill)
return;
for (int i = 0; i < 3; i++) {
itm = _characters[attacker].items[i];
if (!itm)
continue;
- if ((_itemProperties[_itemsInPlay[itm].itemPropertyIndex].protection & 0x3f) != flags)
+ if ((_itemProperties[_itemsInPlay[itm].itemPropertyIndex].protection & 0x3F) != flags)
continue;
- removeCharacterItem(attacker, 0x7fff);
+ removeCharacterItem(attacker, 0x7FFF);
if (monster->properties->defenseSkillType == 1) {
giveItemToMonster(monster, itm);
- if (characterSays(0x401c, _characters[attacker].id, true))
- _txt->printMessage(6, "%s", getLangString(0x401c));
+ if (characterSays(0x401C, _characters[attacker].id, true))
+ _txt->printMessage(6, "%s", getLangString(0x401C));
} else {
deleteItem(itm);
- if (characterSays(0x401d, _characters[attacker].id, true))
- _txt->printMessage(6, "%s", getLangString(0x401d));
+ if (characterSays(0x401D, _characters[attacker].id, true))
+ _txt->printMessage(6, "%s", getLangString(0x401D));
}
}
break;
@@ -3890,7 +3897,7 @@ void LoLEngine::launchMagicViper() {
void LoLEngine::breakIceWall(uint8 *pal1, uint8 *pal2) {
_screen->hideMouse();
uint16 bl = calcNewBlockPosition(_currentBlock, _currentDirection);
- _levelBlockProperties[bl].flags &= 0xef;
+ _levelBlockProperties[bl].flags &= 0xEF;
_screen->copyPage(0, 2);
gui_drawScene(2);
_screen->copyPage(2, 10);
@@ -3918,10 +3925,10 @@ uint16 LoLEngine::getNearestMonsterFromCharacterForBlock(uint16 block, int charN
uint16 cX = 0;
uint16 cY = 0;
- uint16 id = 0xffff;
- int minDist = 0x7fff;
+ uint16 id = 0xFFFF;
+ int minDist = 0x7FFF;
- if (block == 0xffff)
+ if (block == 0xFFFF)
return id;
calcCoordinatesForSingleCharacter(charNum, cX, cY);
@@ -3929,7 +3936,7 @@ uint16 LoLEngine::getNearestMonsterFromCharacterForBlock(uint16 block, int charN
int o = _levelBlockProperties[block].assignedObjects;
while (o & 0x8000) {
- LoLMonster *m = &_monsters[o & 0x7fff];
+ LoLMonster *m = &_monsters[o & 0x7FFF];
if (m->mode >= 13) {
o = m->nextAssignedObject;
continue;
@@ -3948,8 +3955,8 @@ uint16 LoLEngine::getNearestMonsterFromCharacterForBlock(uint16 block, int charN
}
uint16 LoLEngine::getNearestMonsterFromPos(int x, int y) {
- uint16 id = 0xffff;
- int minDist = 0x7fff;
+ uint16 id = 0xFFFF;
+ int minDist = 0x7FFF;
for (int i = 0; i < 30; i++) {
if (_monsters[i].mode > 13)
@@ -3966,8 +3973,8 @@ uint16 LoLEngine::getNearestMonsterFromPos(int x, int y) {
}
uint16 LoLEngine::getNearestPartyMemberFromPos(int x, int y) {
- uint16 id = 0xffff;
- int minDist = 0x7fff;
+ uint16 id = 0xFFFF;
+ int minDist = 0x7FFF;
for (int i = 0; i < 4; i++) {
if (!(_characters[i].flags & 1) || _characters[i].hitPointsCur <= 0)
@@ -4049,7 +4056,7 @@ void LoLEngine::displayAutomap() {
delayTimer = _system->getMillis() + 8 * _tickLength;
}
- int f = checkInput(0) & 0xff;
+ int f = checkInput(0) & 0xFF;
removeInputTop();
if (f) {
@@ -4057,7 +4064,7 @@ void LoLEngine::displayAutomap() {
gui_notifyButtonListChanged();
}
- if (f == 0x30) {
+ if (f == _keyMap[Common::KEYCODE_c]) {
for (int i = 0; i < 1024; i++)
_levelBlockProperties[i].flags |= 7;
_mapUpdateNeeded = true;
@@ -4089,7 +4096,7 @@ void LoLEngine::updateAutoMap(uint16 block) {
return;
_levelBlockProperties[block].flags |= 7;
- uint16 x = block & 0x1f;
+ uint16 x = block & 0x1F;
uint16 y = block >> 5;
updateAutoMapIntern(block, x, y, -1, -1);
@@ -4107,7 +4114,7 @@ bool LoLEngine::updateAutoMapIntern(uint16 block, uint16 x, uint16 y, int16 xOff
x += xOffs;
y += yOffs;
- if ((x & 0xffe0) || (y & 0xffe0))
+ if ((x & 0xFFE0) || (y & 0xFFE0))
return false;
xOffs++;
@@ -4117,7 +4124,7 @@ bool LoLEngine::updateAutoMapIntern(uint16 block, uint16 x, uint16 y, int16 xOff
uint16 b = block + blockPosTable[6 + xOffs];
if (fx != -1) {
- if (_wllAutomapData[_levelBlockProperties[b].walls[fx]] & 0xc0)
+ if (_wllAutomapData[_levelBlockProperties[b].walls[fx]] & 0xC0)
return false;
}
@@ -4125,13 +4132,13 @@ bool LoLEngine::updateAutoMapIntern(uint16 block, uint16 x, uint16 y, int16 xOff
b = block + blockPosTable[9 + yOffs];
if (fy != -1) {
- if (_wllAutomapData[_levelBlockProperties[b].walls[fy]] & 0xc0)
+ if (_wllAutomapData[_levelBlockProperties[b].walls[fy]] & 0xC0)
return false;
}
b = block + blockPosTable[6 + xOffs] + blockPosTable[9 + yOffs];
- if ((fx != -1) && (fy != -1) && (_wllAutomapData[_levelBlockProperties[b].walls[fx]] & 0xc0) && (_wllAutomapData[_levelBlockProperties[b].walls[fy]] & 0xc0))
+ if ((fx != -1) && (fy != -1) && (_wllAutomapData[_levelBlockProperties[b].walls[fx]] & 0xC0) && (_wllAutomapData[_levelBlockProperties[b].walls[fy]] & 0xC0))
return false;
_levelBlockProperties[b].flags |= 7;
@@ -4142,8 +4149,8 @@ bool LoLEngine::updateAutoMapIntern(uint16 block, uint16 x, uint16 y, int16 xOff
void LoLEngine::loadMapLegendData(int level) {
uint16 *legendData = (uint16 *)_tempBuffer5120;
for (int i = 0; i < 32; i++) {
- legendData[i * 6] = 0xffff;
- legendData[i * 6 + 5] = 0xffff;
+ legendData[i * 6] = 0xFFFF;
+ legendData[i * 6 + 5] = 0xFFFF;
}
Common::String file = Common::String::format("level%d.xxx", level);
@@ -4184,7 +4191,7 @@ void LoLEngine::drawMapPage(int pageNum) {
_screen->copyRegion(236, 16, 236 + xOffset, 16, -xOffset, 1, pageNum, pageNum, Screen::CR_NO_P_CHECK);
int cp = _screen->setCurPage(pageNum);
- Screen::FontId of = _screen->setFont(_flags.use16ColorMode ? Screen::FID_SJIS_FNT : Screen::FID_9_FNT);
+ Screen::FontId of = _screen->setFont((_flags.lang == Common::JA_JPN && _flags.use16ColorMode) ? Screen::FID_SJIS_FNT : Screen::FID_9_FNT);
_screen->printText(getLangString(_autoMapStrings[_currentMapLevel]), 236 + xOffset, 8, 1, 0);
uint16 blX = mapGetStartPosX();
uint16 bl = (mapGetStartPosY() << 5) + blX;
@@ -4194,7 +4201,7 @@ void LoLEngine::drawMapPage(int pageNum) {
for (; bl < 1024; bl++) {
uint8 *w = _levelBlockProperties[bl].walls;
- if ((_levelBlockProperties[bl].flags & 7) == 7 && (!(_wllAutomapData[w[0]] & 0xc0)) && (!(_wllAutomapData[w[2]] & 0xc0)) && (!(_wllAutomapData[w[1]] & 0xc0)) && (!(_wllAutomapData[w[3]] & 0xc0))) {
+ if ((_levelBlockProperties[bl].flags & 7) == 7 && (!(_wllAutomapData[w[0]] & 0xC0)) && (!(_wllAutomapData[w[2]] & 0xC0)) && (!(_wllAutomapData[w[1]] & 0xC0)) && (!(_wllAutomapData[w[3]] & 0xC0))) {
uint16 b0 = calcNewBlockPosition(bl, 0);
uint16 b2 = calcNewBlockPosition(bl, 2);
uint16 b1 = calcNewBlockPosition(bl, 1);
@@ -4211,25 +4218,25 @@ void LoLEngine::drawMapPage(int pageNum) {
// draw north wall
drawMapBlockWall(b3, w31, sx, sy, 3);
drawMapShape(w31, sx, sy, 3);
- if (_wllAutomapData[w31] & 0xc0)
+ if (_wllAutomapData[w31] & 0xC0)
_screen->copyBlockAndApplyOverlay(_screen->_curPage, sx, sy, _screen->_curPage, sx, sy, 1, 6, 0, _mapOverlay);
// draw west wall
drawMapBlockWall(b1, w13, sx, sy, 1);
drawMapShape(w13, sx, sy, 1);
- if (_wllAutomapData[w13] & 0xc0)
+ if (_wllAutomapData[w13] & 0xC0)
_screen->copyBlockAndApplyOverlay(_screen->_curPage, sx + 6, sy, _screen->_curPage, sx + 6, sy, 1, 6, 0, _mapOverlay);
// draw east wall
drawMapBlockWall(b0, w02, sx, sy, 0);
drawMapShape(w02, sx, sy, 0);
- if (_wllAutomapData[w02] & 0xc0)
+ if (_wllAutomapData[w02] & 0xC0)
_screen->copyBlockAndApplyOverlay(_screen->_curPage, sx, sy, _screen->_curPage, sx, sy, 7, 1, 0, _mapOverlay);
//draw south wall
drawMapBlockWall(b2, w20, sx, sy, 2);
drawMapShape(w20, sx, sy, 2);
- if (_wllAutomapData[w20] & 0xc0)
+ if (_wllAutomapData[w20] & 0xC0)
_screen->copyBlockAndApplyOverlay(_screen->_curPage, sx, sy + 5, _screen->_curPage, sx, sy + 5, 7, 1, 0, _mapOverlay);
}
@@ -4244,7 +4251,7 @@ void LoLEngine::drawMapPage(int pageNum) {
_screen->setFont(of);
_screen->setCurPage(cp);
- of = _screen->setFont(_flags.use16ColorMode ? Screen::FID_SJIS_FNT : Screen::FID_6_FNT);
+ of = _screen->setFont((_flags.lang == Common::JA_JPN && _flags.use16ColorMode) ? Screen::FID_SJIS_FNT : Screen::FID_6_FNT);
int tY = 0;
sx = mapGetStartPosX();
@@ -4255,19 +4262,19 @@ void LoLEngine::drawMapPage(int pageNum) {
for (int ii = 0; ii < 32; ii++) {
uint16 *l = &legendData[ii * 6];
- if (l[0] == 0xffff)
+ if (l[0] == 0xFFFF)
break;
uint16 cbl = l[0] + (l[1] << 5);
if ((_levelBlockProperties[cbl].flags & 7) != 7)
continue;
- if (l[2] == 0xffff)
+ if (l[2] == 0xFFFF)
continue;
printMapText(l[2], 244 + xOffset, (tY << 3) + 22 + yOffset);
- if (l[5] == 0xffff) {
+ if (l[5] == 0xFFFF) {
tY++;
continue;
}
@@ -4338,7 +4345,7 @@ bool LoLEngine::automapProcessButtons(int inputFlag) {
void LoLEngine::automapForwardButton() {
int i = _currentMapLevel + 1;
while (!(_hasTempDataFlags & (1 << (i - 1))))
- i = (i + 1) & 0x1f;
+ i = (i + 1) & 0x1F;
if (i == _currentMapLevel)
return;
@@ -4355,7 +4362,7 @@ void LoLEngine::automapForwardButton() {
void LoLEngine::automapBackButton() {
int i = _currentMapLevel - 1;
while (!(_hasTempDataFlags & (1 << (i - 1))))
- i = (i - 1) & 0x1f;
+ i = (i - 1) & 0x1F;
if (i == _currentMapLevel)
return;
@@ -4396,7 +4403,7 @@ void LoLEngine::redrawMapCursor() {
}
void LoLEngine::drawMapBlockWall(uint16 block, uint8 wall, int x, int y, int direction) {
- if (((1 << direction) & _levelBlockProperties[block].flags) || ((_wllAutomapData[wall] & 0x1f) != 13))
+ if (((1 << direction) & _levelBlockProperties[block].flags) || ((_wllAutomapData[wall] & 0x1F) != 13))
return;
int cp = _screen->_curPage;
@@ -4406,8 +4413,8 @@ void LoLEngine::drawMapBlockWall(uint16 block, uint8 wall, int x, int y, int dir
}
void LoLEngine::drawMapShape(uint8 wall, int x, int y, int direction) {
- int l = _wllAutomapData[wall] & 0x1f;
- if (l == 0x1f)
+ int l = _wllAutomapData[wall] & 0x1F;
+ if (l == 0x1F)
return;
_screen->drawShape(_screen->_curPage, _automapShapes[(l << 2) + direction], x + _mapCoords[10][direction] - 2, y + _mapCoords[11][direction] - 2, 0, 0);
@@ -4473,7 +4480,7 @@ int LoLEngine::mapGetStartPosY() {
}
void LoLEngine::mapIncludeLegendData(int type) {
- type &= 0x7f;
+ type &= 0x7F;
for (int i = 0; i < 11; i++) {
if (_defaultLegendData[i].shapeIndex != type)
continue;
@@ -4494,7 +4501,7 @@ void LoLEngine::printMapText(uint16 stringId, int x, int y) {
void LoLEngine::printMapExitButtonText() {
int cp = _screen->setCurPage(2);
Screen::FontId of = _screen->setFont(Screen::FID_9_FNT);
- _screen->fprintString("%s", 295, 182, _flags.use16ColorMode ? 0xbb : 172, 0, 5, getLangString(0x4033));
+ _screen->fprintString("%s", 295, 182, _flags.use16ColorMode ? 0xBB : 172, 0, 5, getLangString(0x4033));
_screen->setFont(of);
_screen->setCurPage(cp);
}
diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h
index dcd13804b3..4002346d31 100644
--- a/engines/kyra/lol.h
+++ b/engines/kyra/lol.h
@@ -270,6 +270,8 @@ public:
virtual void initKeymap();
+ void pauseEngineIntern(bool pause);
+
Screen *screen();
GUI *gui() const;
@@ -334,9 +336,9 @@ private:
static const char *const _charPreviewNamesDefault[];
static const char *const _charPreviewNamesRussianFloppy[];
- // PC98 specific data
+ // PC98/FM-TOWNS specific data
static const uint16 _charPosXPC98[];
- static const uint8 _charNamesPC98[][11];
+ static const char *const _charNamesJapanese[];
WSAMovie_v2 *_chargenWSA;
static const uint8 _chargenFrameTableTalkie[];
@@ -389,7 +391,7 @@ private:
uint8 _outroShapeTable[256];
// TODO: Consider moving these tables to kyra.dat
- static const char * const _outroShapeFileTable[];
+ static const char *const _outroShapeFileTable[];
static const uint8 _outroFrameTable[];
static const int16 _outroRightMonsterPos[];
@@ -400,6 +402,10 @@ private:
static const int _outroMonsterScaleTableX[];
static const int _outroMonsterScaleTableY[];
+ // Non-interactive demo
+ int playDemo();
+ void pauseDemoPlayer(bool toggle);
+
// timers
void setupTimers();
@@ -464,8 +470,6 @@ private:
const uint8 *_ingamePCSpeakerSoundIndex;
int _ingamePCSpeakerSoundIndexSize;
- AudioDataStruct _soundData[3];
-
// gui
void gui_drawPlayField();
void gui_drawScene(int pageNum);
@@ -554,14 +558,14 @@ private:
int clickedStatusIcon(Button *button);
const LoLButtonDef *_buttonData;
- const int16 *_buttonList1;
- const int16 *_buttonList2;
- const int16 *_buttonList3;
- const int16 *_buttonList4;
- const int16 *_buttonList5;
- const int16 *_buttonList6;
- const int16 *_buttonList7;
- const int16 *_buttonList8;
+ const uint8 *_buttonList1;
+ const uint8 *_buttonList2;
+ const uint8 *_buttonList3;
+ const uint8 *_buttonList4;
+ const uint8 *_buttonList5;
+ const uint8 *_buttonList6;
+ const uint8 *_buttonList7;
+ const uint8 *_buttonList8;
// text
int characterSays(int track, int charId, bool redraw);
@@ -810,7 +814,7 @@ private:
void decodeSjis(const char *src, char *dst);
int decodeCyrillic(const char *src, char *dst);
- static const char * const _languageExt[];
+ static const char *const _languageExt[];
// graphics
void setupScreenDims();
@@ -1009,8 +1013,8 @@ private:
uint8 *_tempBuffer5120;
- const char * const *_levelDatList;
- const char * const *_levelShpList;
+ const char *const *_levelDatList;
+ const char *const *_levelShpList;
const int8 *_dscWalls;
@@ -1133,7 +1137,11 @@ private:
uint16 _monsterCurBlock;
int _objectLastDirection;
- const uint16 *_monsterModifiers;
+ const uint16 *_monsterModifiers1;
+ const uint16 *_monsterModifiers2;
+ const uint16 *_monsterModifiers3;
+ const uint16 *_monsterModifiers4;
+
const int8 *_monsterShiftOffs;
const uint8 *_monsterDirFlags;
const uint8 *_monsterScaleX;
diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp
index 985286854b..2180c5359d 100644
--- a/engines/kyra/magic_eob.cpp
+++ b/engines/kyra/magic_eob.cpp
@@ -60,7 +60,7 @@ void EoBCoreEngine::useMagicBookOrSymbol(int charIndex, int type) {
}
if (!_updateFlags)
- _screen->copyRegion(64, 121, 0, 0, 112, 56, 0, _useHiResDithering ? 4 : 10, Screen::CR_NO_P_CHECK);
+ _screen->copyRegion(64, 121, 0, 0, 112, 56, 0, 10, Screen::CR_NO_P_CHECK);
_updateFlags = 1;
gui_setPlayFieldButtons();
gui_drawSpellbook();
@@ -179,7 +179,7 @@ void EoBCoreEngine::castSpell(int spell, int weaponSlot) {
if ((s->flags & 0x100) && (c->effectFlags & 0x40))
// remove invisibility effect
- removeCharacterEffect(10, _openBookChar, 1);
+ removeCharacterEffect(_flags.gameID == GI_EOB1 ? 8 : 10, _openBookChar, 1);
int ci = _openBookChar;
if (ci > 3)
@@ -308,7 +308,7 @@ void EoBCoreEngine::startSpell(int spell) {
EoBCharacter *c = &_characters[_activeSpellCharId];
snd_playSoundEffect(s->sound);
- if (s->flags & 0xa0)
+ if (s->flags & 0xA0)
sparkEffectDefensive(_activeSpellCharId);
else if (s->flags & 0x40)
sparkEffectDefensive(-1);
@@ -623,7 +623,7 @@ bool EoBCoreEngine::turnUndeadHit(EoBMonsterInPlay *m, int hitChance, int caster
assert(_monsterProps[m->type].tuResist > 0);
uint8 e = _turnUndeadEffect[_monsterProps[m->type].tuResist * 14 + MIN(casterLevel, 14)];
- if (e == 0xff) {
+ if (e == 0xFF) {
calcAndInflictMonsterDamage(m, 0, 0, 500, 0x200, 5, 3);
} else if (hitChance < e) {
return false;
@@ -711,7 +711,7 @@ Item EoBCoreEngine::createMagicWeaponItem(int flags, int icon, int value, int ty
void EoBCoreEngine::removeMagicWeaponItem(Item item) {
_itemTypes[_items[item].type].armorClass = -30;
_items[item].block = -2;
- _items[item].level = 0xff;
+ _items[item].level = 0xFF;
}
void EoBCoreEngine::updateWallOfForceTimers() {
@@ -841,7 +841,7 @@ bool EoBCoreEngine::spellCallback_end_magicMissile(void *obj) {
}
void EoBCoreEngine::spellCallback_start_shockingGrasp() {
- int t = createMagicWeaponType(0, 0, 0, 0x0f, 1, 8, getMageLevel(_openBookChar), 1);
+ int t = createMagicWeaponType(0, 0, 0, 0x0F, 1, 8, getMageLevel(_openBookChar), 1);
Item i = (t != -1) ? createMagicWeaponItem(0x10, 82, 0, t) : -1;
if (t == -1 || i == -1) {
if (_flags.gameID == GI_EOB2)
@@ -948,7 +948,7 @@ bool EoBCoreEngine::spellCallback_end_lightningBolt(void *obj) {
}
void EoBCoreEngine::spellCallback_start_vampiricTouch() {
- int t = createMagicWeaponType(0, 0, 0, 0x0f, getMageLevel(_openBookChar) >> 1, 6, 0, 1);
+ int t = createMagicWeaponType(0, 0, 0, 0x0F, getMageLevel(_openBookChar) >> 1, 6, 0, 1);
Item i = (t != -1) ? createMagicWeaponItem(0x18, 83, 0, t) : -1;
if (t == -1 || i == -1) {
if (_flags.gameID == GI_EOB2)
@@ -989,7 +989,7 @@ bool EoBCoreEngine::spellCallback_end_iceStorm(void *obj) {
if (res) {
for (int i = 0; i < 4; i++) {
uint16 bl = fo->curBlock;
- fo->curBlock = (fo->curBlock + blockAdv[i]) & 0x3ff;
+ fo->curBlock = (fo->curBlock + blockAdv[i]) & 0x3FF;
magicObjectDamageHit(fo, 1, 6, 0, getMageLevel(fo->attackerId));
fo->curBlock = bl;
}
@@ -1027,7 +1027,7 @@ void EoBCoreEngine::spellCallback_start_coneOfCold() {
_preventMonsterFlash = true;
for (int i = 0; i < 7; i++) {
- for (const int16 *m = findBlockMonsters((_currentBlock + tbl[i]) & 0x3ff, 4, _currentDirection, 1, 1); *m != -1; m++)
+ for (const int16 *m = findBlockMonsters((_currentBlock + tbl[i]) & 0x3FF, 4, _currentDirection, 1, 1); *m != -1; m++)
calcAndInflictMonsterDamage(&_monsters[*m], cl, 4, cl, 0x41, 5, 0);
}
@@ -1054,7 +1054,7 @@ void EoBCoreEngine::spellCallback_start_wallOfForce() {
return;
}
- uint32 dur = 0xffffffff;
+ uint32 dur = 0xFFFFFFFF;
int s = 0;
int i = 0;
@@ -1158,7 +1158,7 @@ bool EoBCoreEngine::spellCallback_end_aid(void *obj) {
}
void EoBCoreEngine::spellCallback_start_flameBlade() {
- int t = createMagicWeaponType(0, 0, 0, 0x0f, 1, 4, 4, 1);
+ int t = createMagicWeaponType(0, 0, 0, 0x0F, 1, 4, 4, 1);
Item i = (t != -1) ? createMagicWeaponItem(0, 84, 0, t) : -1;
if (t == -1 || i == -1) {
if (_flags.gameID == GI_EOB2)
diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp
index adb3063344..c350c81742 100644
--- a/engines/kyra/resource.cpp
+++ b/engines/kyra/resource.cpp
@@ -185,7 +185,7 @@ bool Resource::loadFileList(const Common::String &filedata) {
// the demo version supplied with Kyra3 does not
// contain all pak files listed in filedata.fdt
// so we don't do anything here if they are non
- // existant.
+ // existent.
} else if (!loadPakFile(filename)) {
delete f;
error("couldn't load file '%s'", filename.c_str());
diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h
index f2bc4e8146..5c179a7864 100644
--- a/engines/kyra/resource.h
+++ b/engines/kyra/resource.h
@@ -62,7 +62,7 @@ public:
bool isInCacheList(Common::String name);
bool loadFileList(const Common::String &filedata);
- bool loadFileList(const char * const *filelist, uint32 numFiles);
+ bool loadFileList(const char *const *filelist, uint32 numFiles);
// This unloads *all* pakfiles, even kyra.dat and protected ones.
// It does not remove files from cache though!
@@ -87,7 +87,7 @@ protected:
Common::Archive *loadArchive(const Common::String &name, Common::ArchiveMemberPtr member);
Common::Archive *loadInstallerArchive(const Common::String &file, const Common::String &ext, const uint8 offset);
- bool loadProtectedFiles(const char * const * list);
+ bool loadProtectedFiles(const char *const * list);
void initializeLoaders();
@@ -679,7 +679,10 @@ enum KyraResources {
kLoLCharDefsKieran,
kLoLCharDefsAkshel,
kLoLExpRequirements,
- kLoLMonsterModifiers,
+ kLoLMonsterModifiers1,
+ kLoLMonsterModifiers2,
+ kLoLMonsterModifiers3,
+ kLoLMonsterModifiers4,
kLoLMonsterShiftOffsets,
kLoLMonsterDirFlags,
kLoLMonsterScaleY,
@@ -742,6 +745,8 @@ enum KyraResources {
struct Shape;
struct Room;
struct AmigaSfxTable;
+struct HoFSeqData;
+struct HoFSeqItemAnimData;
class StaticResource {
public:
@@ -755,13 +760,13 @@ public:
bool init();
void deinit();
- const char * const *loadStrings(int id, int &strings);
+ const char *const *loadStrings(int id, int &strings);
const uint8 *loadRawData(int id, int &size);
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 +808,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 +834,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 +862,7 @@ private:
kAmigaSfxTable = 4,
k2SeqData = 5,
- k2ShpAnimDataV1 = 6,
+ k2SeqItemAnimData = 6,
k2ItemAnimDefinition = 7,
kLoLCharData = 8,
diff --git a/engines/kyra/resource_intern.cpp b/engines/kyra/resource_intern.cpp
index 6f7591ccf1..4c413487ff 100644
--- a/engines/kyra/resource_intern.cpp
+++ b/engines/kyra/resource_intern.cpp
@@ -496,7 +496,7 @@ public:
void advSrcBitsBy1();
void advSrcBitsByIndex(uint8 newIndex);
- uint8 getKeyLower() const { return _key & 0xff; }
+ uint8 getKeyLower() const { return _key & 0xFF; }
void setIndex(uint8 index) { _index = index; }
uint16 getKeyMasked(uint8 newIndex);
uint16 keyMaskedAlign(uint16 val);
@@ -515,7 +515,7 @@ void FileExpanderSource::advSrcBitsBy1() {
_key >>= 1;
if (!--_bitsLeft) {
if (_dataPtr < _endofBuffer)
- _key = ((*_dataPtr++) << 8) | (_key & 0xff);
+ _key = ((*_dataPtr++) << 8) | (_key & 0xFF);
_bitsLeft = 8;
}
}
@@ -528,7 +528,7 @@ void FileExpanderSource::advSrcBitsByIndex(uint8 newIndex) {
_index = -_bitsLeft;
_bitsLeft = 8 - _index;
if (_dataPtr < _endofBuffer)
- _key = (*_dataPtr++ << 8) | (_key & 0xff);
+ _key = (*_dataPtr++ << 8) | (_key & 0xFF);
}
_key >>= _index;
}
@@ -540,13 +540,13 @@ uint16 FileExpanderSource::getKeyMasked(uint8 newIndex) {
if (_index > 8) {
newIndex = _index - 8;
- res = (_key & 0xff) & mskTable[8];
+ res = (_key & 0xFF) & mskTable[8];
advSrcBitsByIndex(8);
_index = newIndex;
- res |= (((_key & 0xff) & mskTable[_index]) << 8);
+ res |= (((_key & 0xFF) & mskTable[_index]) << 8);
advSrcBitsByIndex(_index);
} else {
- res = (_key & 0xff) & mskTable[_index];
+ res = (_key & 0xFF) & mskTable[_index];
advSrcBitsByIndex(_index);
}
@@ -568,10 +568,10 @@ void FileExpanderSource::copyBytes(uint8 *& dst) {
uint16 FileExpanderSource::keyMaskedAlign(uint16 val) {
val -= 0x101;
- _index = (val & 0xff) >> 2;
+ _index = (val & 0xFF) >> 2;
int16 b = ((_bitsLeft << 8) | _index) - 1;
_bitsLeft = b >> 8;
- _index = b & 0xff;
+ _index = b & 0xFF;
uint16 res = (((val & 3) + 4) << _index) + 0x101;
return res + getKeyMasked(_index);
}
@@ -727,20 +727,20 @@ bool FileExpander::process(uint8 *dst, const uint8 *src, uint32 outsize, uint32
cmd = ((int16 *)_tables[2])[_src->getKeyLower()];
_src->advSrcBitsByIndex(cmd < 0 ? calcCmdAndIndex(_tables[3], cmd) : _tables[0][cmd]);
- if (cmd == 0x11d) {
+ if (cmd == 0x11D) {
cmd = 0x200;
} else if (cmd > 0x108) {
cmd = _src->keyMaskedAlign(cmd);
}
if (!(cmd >> 8)) {
- *d++ = cmd & 0xff;
+ *d++ = cmd & 0xFF;
} else if (cmd != 0x100) {
- cmd -= 0xfe;
+ cmd -= 0xFE;
int16 offset = ((int16 *)_tables[4])[_src->getKeyLower()];
_src->advSrcBitsByIndex(offset < 0 ? calcCmdAndIndex(_tables[5], offset) : _tables[1][offset]);
- if ((offset & 0xff) >= 4) {
- uint8 newIndex = ((offset & 0xff) >> 1) - 1;
+ if ((offset & 0xFF) >= 4) {
+ uint8 newIndex = ((offset & 0xFF) >> 1) - 1;
offset = (((offset & 1) + 2) << newIndex);
offset += _src->getKeyMasked(newIndex);
}
@@ -775,7 +775,7 @@ bool FileExpander::process(uint8 *dst, const uint8 *src, uint32 outsize, uint32
void FileExpander::generateTables(uint8 srcIndex, uint8 dstIndex, uint8 dstIndex2, int cnt) {
uint8 *tbl1 = _tables[srcIndex];
uint8 *tbl2 = _tables[dstIndex];
- uint8 *tbl3 = dstIndex2 == 0xff ? 0 : _tables[dstIndex2];
+ uint8 *tbl3 = dstIndex2 == 0xFF ? 0 : _tables[dstIndex2];
if (!cnt)
return;
@@ -859,7 +859,7 @@ void FileExpander::generateTables(uint8 srcIndex, uint8 dstIndex, uint8 dstIndex
do {
s2[o] = cnt;
o += inc;
- } while (!(o & 0xf00));
+ } while (!(o & 0xF00));
} else if (t > 8) {
if (!bt)
@@ -868,7 +868,7 @@ void FileExpander::generateTables(uint8 srcIndex, uint8 dstIndex, uint8 dstIndex
t -= 8;
uint8 shiftCnt = 1;
uint8 v = (*d) >> 8;
- s2 = &((uint16 *)tbl2)[*d & 0xff];
+ s2 = &((uint16 *)tbl2)[*d & 0xFF];
do {
if (!*s2) {
@@ -897,7 +897,7 @@ uint8 FileExpander::calcCmdAndIndex(const uint8 *tbl, int16 &para) {
do {
newIndex++;
- para = t[((~para) & 0xfffe) | (v & 1)];
+ para = t[((~para) & 0xFFFE) | (v & 1)];
v >>= 1;
} while (para < 0);
@@ -1020,7 +1020,7 @@ Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &fi
pos = 0;
- const uint32 kExecSize = 0x0bba;
+ const uint32 kExecSize = 0x0BBA;
const uint32 kHeaderSize = 30;
const uint32 kHeaderSize2 = 46;
diff --git a/engines/kyra/resource_intern.h b/engines/kyra/resource_intern.h
index 9d9574d823..e63eab7d6a 100644
--- a/engines/kyra/resource_intern.h
+++ b/engines/kyra/resource_intern.h
@@ -75,7 +75,7 @@ private:
const uint32 *findFile(const Common::String &name) const;
const uint16 _entryCount;
- const uint32 * const _fileEntries;
+ const uint32 *const _fileEntries;
};
class CachedArchive : public Common::Archive {
diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp
index 41ba1e5e50..bacfb62c16 100644
--- a/engines/kyra/saveload.cpp
+++ b/engines/kyra/saveload.cpp
@@ -37,7 +37,7 @@
namespace Kyra {
-KyraEngine_v1::kReadSaveHeaderError KyraEngine_v1::readSaveHeader(Common::SeekableReadStream *in, bool loadThumbnail, SaveHeader &header) {
+KyraEngine_v1::ReadSaveHeaderError KyraEngine_v1::readSaveHeader(Common::SeekableReadStream *in, bool loadThumbnail, SaveHeader &header) {
uint32 type = in->readUint32BE();
header.originalSave = false;
header.oldHeader = false;
@@ -140,7 +140,7 @@ Common::SeekableReadStream *KyraEngine_v1::openSaveForReading(const char *filena
if (!(in = _saveFileMan->openForLoading(filename)))
return 0;
- kReadSaveHeaderError errorCode = KyraEngine_v1::readSaveHeader(in, false, header);
+ ReadSaveHeaderError errorCode = KyraEngine_v1::readSaveHeader(in, false, header);
if (errorCode != kRSHENoError) {
if (errorCode == kRSHEInvalidType)
warning("No ScummVM Kyra engine savefile header");
diff --git a/engines/kyra/saveload_eob.cpp b/engines/kyra/saveload_eob.cpp
index f7d7d95b57..1e5b40af83 100644
--- a/engines/kyra/saveload_eob.cpp
+++ b/engines/kyra/saveload_eob.cpp
@@ -298,7 +298,7 @@ Common::Error EoBCoreEngine::loadGameState(int slot) {
useMagicBookOrSymbol(_openBookChar, _openBookType);
}
- _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, _useHiResDithering ? 1 : 12, Screen::CR_NO_P_CHECK);
+ _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 12, Screen::CR_NO_P_CHECK);
gui_toggleButtons();
setHandItem(_itemInHand);
@@ -453,7 +453,7 @@ Common::Error EoBCoreEngine::saveGameStateIntern(int slot, const char *saveName,
out->write(l->wallsXorData, 4096);
for (int ii = 0; ii < 1024; ii++)
- out->writeByte(l->flags[ii] & 0xff);
+ out->writeByte(l->flags[ii] & 0xFF);
EoBMonsterInPlay *lm = (EoBMonsterInPlay *)_lvlTempData[i]->monsters;
EoBFlyingObject *lf = (EoBFlyingObject *)_lvlTempData[i]->flyingObjects;
@@ -680,7 +680,7 @@ Common::String EoBCoreEngine::readOriginalSaveFile(Common::String &file) {
in.skip(4);
delete[] c->faceShape;
c->faceShape = 0;
- in.read(c->mageSpells, (_flags.gameID == GI_EOB1) ? 30 :80);
+ in.read(c->mageSpells, (_flags.gameID == GI_EOB1) ? 30 : 80);
in.read(c->clericSpells, (_flags.gameID == GI_EOB1) ? 30 : 80);
c->mageSpellsAvailableFlags = in.readUint32();
for (int ii = 0; ii < 27; ii++)
@@ -695,6 +695,8 @@ Common::String EoBCoreEngine::readOriginalSaveFile(Common::String &file) {
in.read(c->effectsRemainder, 4);
c->effectFlags = in.readUint32();
if (c->effectFlags && _flags.gameID == GI_EOB1) {
+ // Spell effect flags are completely different in EOB I. We only use EOB II style flags in ScummVM.
+ // Doesn't matter much, since these are the temporary spell effects only anyway.
warning("EoBCoreEngine::readOriginalSaveFile(): Unhandled character effect flags encountered in original EOB1 save file '%s' ('%s')", file.c_str(), desc.c_str());
c->effectFlags = 0;
}
@@ -713,6 +715,8 @@ Common::String EoBCoreEngine::readOriginalSaveFile(Common::String &file) {
_hasTempDataFlags = (_flags.gameID == GI_EOB1) ? in.readUint16() : in.readUint32();
_partyEffectFlags = (_flags.gameID == GI_EOB1) ? in.readUint16() : in.readUint32();
if (_partyEffectFlags && _flags.gameID == GI_EOB1) {
+ // Spell effect flags are completely different in EOB I. We only use EOB II style flags in ScummVM.
+ // Doesn't matter much, since these are the temporary spell effects only anyway.
warning("EoBCoreEngine::readOriginalSaveFile(): Unhandled party effect flags encountered in original EOB1 save file '%s' ('%s')", file.c_str(), desc.c_str());
_partyEffectFlags = 0;
}
@@ -737,7 +741,7 @@ Common::String EoBCoreEngine::readOriginalSaveFile(Common::String &file) {
t->value = in.readSByte();
}
- int numParts = (_flags.gameID == GI_EOB1) ? 13 : 18;
+ int numParts = (_flags.gameID == GI_EOB1) ? 12 : 17;
int partSize = (_flags.gameID == GI_EOB1) ? 2040 : 2130;
uint32 nextPart = in.pos();
uint8 *cmpData = new uint8[1200];
@@ -831,7 +835,7 @@ Common::String EoBCoreEngine::readOriginalSaveFile(Common::String &file) {
for (int ii = 0; ii < 5; ii++) {
WallOfForce *w = &lw[ii];
w->block = in.readUint16();
- w->duration = in.readUint32();
+ w->duration = in.readUint32() * _tickLength;
}
}
@@ -845,10 +849,7 @@ Common::String EoBCoreEngine::readOriginalSaveFile(Common::String &file) {
_itemTypes = new EoBItemType[65];
memset(_itemTypes, 0, sizeof(EoBItemType) * 65);
- if (_flags.gameID == GI_EOB1)
- return desc;
-
- for (int i = 51; i < 65; i++) {
+ for (int i = 51; i < 57; i++) {
EoBItemType *t = &_itemTypes[i];
t->invFlags = in.readUint16();
t->handFlags = in.readUint16();
@@ -868,6 +869,355 @@ Common::String EoBCoreEngine::readOriginalSaveFile(Common::String &file) {
return in.err() ? Common::String() : desc;
}
+static uint32 encodeFrame4(const uint8 *src, uint8 *dst, uint32 insize) {
+ const uint8 *end = src + insize;
+
+ bool updateCounter = true;
+ const uint8 *in = src;
+
+ uint8 *out = dst;
+ uint8 *cntPtr = dst;
+
+ *dst++ = 0x81;
+ *dst++ = *src++;
+
+ while (src < end) {
+ const uint8 *src2 = in;
+ const uint8 *src3 = 0;
+ uint16 len = 1;
+
+ for (bool loop = true; loop; ) {
+ uint16 count = 0;
+ uint16 scansize = end - src - 1;
+ if (scansize > 64) {
+ if (src[0] == src[64]) {
+ for (uint16 i = 0; i < scansize && src[0] == src[i]; ++i)
+ count++;
+ if (count > 64) {
+ updateCounter = false;
+ *dst++ = 0xFE;
+ WRITE_LE_UINT16(dst, count);
+ dst += 2;
+ *dst++ = src[0];
+ src += count;
+ loop = true;
+ continue;
+ }
+ }
+ }
+
+ const uint8 *tmp = src2;
+
+ do {
+ count = src - tmp;
+ loop = false;
+ if (count == 0)
+ break;
+
+ while (count--) {
+ if (*src == *tmp++) {
+ loop = true;
+ break;
+ }
+ }
+ if (!loop)
+ break;
+ } while (*(src + len - 1) != *(tmp + len - 2));
+
+ if (!loop)
+ break;
+
+ src2 = tmp--;
+ const uint8 *tsrc = src;
+ count = end - src;
+ bool nmatch = false;
+
+ while (count--) {
+ if (*tsrc++ != *tmp++) {
+ nmatch = true;
+ break;
+ }
+ }
+ if (!nmatch)
+ tmp++;
+
+ count = tmp - src2;
+ if (count >= len) {
+ len = count;
+ src3 = src2 - 1;
+ }
+ }
+
+ if (len <= 2) {
+ for (bool forceLoop = !updateCounter; forceLoop || *cntPtr == 0xBF; forceLoop = false) {
+ cntPtr = dst;
+ *dst++ = 0x80;
+ }
+ (*cntPtr)++;
+ *dst++ = *src++;
+ updateCounter = true;
+ continue;
+
+ } else if (len > 10 || (src - src3) > 4095) {
+ if (len <= 64) {
+ *dst++ = (len - 3) | 0xC0;
+ } else {
+ *dst++ = 0xFF;
+ WRITE_LE_UINT16(dst, len);
+ dst += 2;
+ }
+ WRITE_LE_UINT16(dst, src3 - in);
+ } else {
+ WRITE_BE_UINT16(dst, (src - src3) + ((len - 3) << 12));
+ }
+
+ dst += 2;
+ src += len;
+ updateCounter = false;
+ }
+
+ *dst++ = 0x80;
+
+ return dst - out;
+}
+
+bool EoBCoreEngine::saveAsOriginalSaveFile(int slot) {
+ if (_flags.gameID == GI_EOB2 && (slot < 0 || slot > 5))
+ return false;
+
+ Common::String dir = ConfMan.get("savepath");
+ if (dir == "None")
+ dir.clear();
+
+ Common::FSNode nd(dir);
+ if (!nd.isDirectory())
+ return false;
+
+ Common::FSNode nf = nd.getChild(_flags.gameID == GI_EOB1 ? "EOBDATA.SAV" : Common::String::format("EOBDATA%d.SAV", slot));
+ Common::WriteStream *out = nf.createWriteStream();
+
+ if (_flags.gameID == GI_EOB2) {
+ static const char tempStr[20] = "SCUMMVM EXPORT ";
+ out->write(tempStr, 20);
+ }
+
+ completeDoorOperations();
+ generateTempData();
+ advanceTimers(_restPartyElapsedTime);
+ _restPartyElapsedTime = 0;
+
+ for (int i = 0; i < 6; i++)
+ timerSpecialCharacterUpdate(0x30 + i);
+
+ for (int i = 0; i < 6; i++) {
+ EoBCharacter *c = &_characters[i];
+ out->writeByte(c->id);
+ out->writeByte(c->flags);
+ out->write(c->name, 11);
+ out->writeSByte(c->strengthCur);
+ out->writeSByte(c->strengthMax);
+ out->writeSByte(c->strengthExtCur);
+ out->writeSByte(c->strengthExtMax);
+ out->writeSByte(c->intelligenceCur);
+ out->writeSByte(c->intelligenceMax);
+ out->writeSByte(c->wisdomCur);
+ out->writeSByte(c->wisdomMax);
+ out->writeSByte(c->dexterityCur);
+ out->writeSByte(c->dexterityMax);
+ out->writeSByte(c->constitutionCur);
+ out->writeSByte(c->constitutionMax);
+ out->writeSByte(c->charismaCur);
+ out->writeSByte(c->charismaMax);
+ if (_flags.gameID == GI_EOB1) {
+ out->writeSByte(c->hitPointsCur);
+ out->writeSByte(c->hitPointsMax);
+ } else {
+ out->writeSint16LE(c->hitPointsCur);
+ out->writeSint16LE(c->hitPointsMax);
+ }
+ out->writeSByte(c->armorClass);
+ out->writeByte(c->disabledSlots);
+ out->writeByte(c->raceSex);
+ out->writeByte(c->cClass);
+ out->writeByte(c->alignment);
+ out->writeSByte(c->portrait);
+ out->writeByte(c->food);
+ out->write(c->level, 3);
+ for (int ii = 0; ii < 3; ii++)
+ out->writeUint32LE(c->experience[ii]);
+ out->writeUint32LE(0);
+ out->write(c->mageSpells, (_flags.gameID == GI_EOB1) ? 30 : 80);
+ out->write(c->clericSpells, (_flags.gameID == GI_EOB1) ? 30 : 80);
+ out->writeUint32LE(c->mageSpellsAvailableFlags);
+ for (int ii = 0; ii < 27; ii++)
+ out->writeSint16LE(c->inventory[ii]);
+ uint32 ct = _system->getMillis();
+ for (int ii = 0; ii < 10; ii++)
+ out->writeUint32LE((c->timers[ii] && c->timers[ii] > ct) ? (c->timers[ii] - ct) / _tickLength : 0);
+ out->write(c->events, 10);
+ out->write(c->effectsRemainder, 4);
+
+ if (c->effectFlags && _flags.gameID == GI_EOB1) {
+ // Spell effect flags are completely different in original EOB I. We only use EOB II style flags in ScummVM.
+ // This doesn't matter much here, since these flags only apply to the temporary spell effects (things like prayer, haste, etc.) anyway.
+ warning("EoBCoreEngine::saveAsOriginalFile(): Character effect flags lost while exporting original EOB1 save file");
+ out->writeUint32LE(0);
+ } else {
+ out->writeUint32LE(c->effectFlags);
+ }
+ out->writeByte(c->damageTaken);
+ out->write(c->slotStatus, 5);
+ for (int ii = 0; ii < 6; ii++)
+ out->writeByte(0);
+ }
+
+ out->writeUint16LE(_currentLevel);
+ if (_flags.gameID == GI_EOB2)
+ out->writeSint16LE(_currentSub);
+ out->writeUint16LE(_currentBlock);
+ out->writeUint16LE(_currentDirection);
+ out->writeSint16LE(_itemInHand);
+ if (_flags.gameID == GI_EOB1) {
+ out->writeUint16LE(_hasTempDataFlags);
+ out->writeUint16LE(0);
+ if (_partyEffectFlags)
+ // Spell effect flags are completely different in original EOB I. We only use EOB II style flags in ScummVM.
+ // This doesn't matter much here, since these flags only apply to the temporary spell effects (things like prayer, haste, etc.) anyway.
+ warning("EoBCoreEngine::saveAsOriginalFile(): Party effect flags lost while exporting original EOB1 save file");
+ } else {
+ out->writeUint32LE(_hasTempDataFlags);
+ out->writeUint32LE(_partyEffectFlags);
+ }
+ if (_flags.gameID == GI_EOB2)
+ out->writeByte(0);
+ _inf->saveState(out, true);
+
+ int numItems = (_flags.gameID == GI_EOB1) ? 500 : 600;
+ for (int i = 0; i < numItems; i++) {
+ EoBItem *t = &_items[i];
+ out->writeByte(t->nameUnid);
+ out->writeByte(t->nameId);
+ out->writeByte(t->flags);
+ out->writeSByte(t->icon);
+ out->writeSByte(t->type);
+ out->writeSByte(t->pos);
+ out->writeSint16LE(t->block);
+ out->writeSint16LE(t->next);
+ out->writeSint16LE(t->prev);
+ out->writeByte(t->level);
+ out->writeSByte(t->value);
+ }
+
+ int numParts = (_flags.gameID == GI_EOB1) ? 12 : 17;
+ int partSize = (_flags.gameID == GI_EOB1) ? 2040 : 2130;
+ uint8 *tempData = new uint8[4096];
+ uint8 *cmpData = new uint8[1200];
+
+ for (int i = 0; i < numParts; i++) {
+ LevelTempData *l = _lvlTempData[i];
+ memset(tempData, 0, 4096);
+ memset(cmpData, 0, 1200);
+
+ if (!l || !(_hasTempDataFlags & (1 << i))) {
+ out->write(tempData, partSize);
+ continue;
+ }
+
+ _curBlockFile = getBlockFileName(i + 1, 0);
+ const uint8 *p = getBlockFileData();
+ uint16 len = READ_LE_UINT16(p + 4);
+ p += 6;
+
+ uint8 *d = tempData;
+ for (int ii = 0; ii < 1024; ii++) {
+ for (int iii = 0; iii < 4; iii++)
+ *d++ = l->wallsXorData[ii * len + iii] ^ p[ii * len + iii];
+ }
+
+ uint32 outsize = encodeFrame4(tempData, cmpData, 4096);
+ if (outsize > 1200)
+ error("Map compression failure: size of map = %d", outsize);
+
+ out->write(cmpData, 1200);
+
+ for (int ii = 0; ii < 30; ii++) {
+ EoBMonsterInPlay *m = &((EoBMonsterInPlay*)l->monsters)[ii];
+ out->writeByte(m->type);
+ out->writeByte(m->unit);
+ out->writeUint16LE(m->block);
+ out->writeByte(m->pos);
+ out->writeSByte(m->dir);
+ out->writeByte(m->animStep);
+ out->writeByte(m->shpIndex);
+ out->writeSByte(m->mode);
+ out->writeSByte(m->f_9);
+ out->writeSByte(m->curAttackFrame);
+ out->writeSByte(m->spellStatusLeft);
+ out->writeSint16LE(m->hitPointsMax);
+ out->writeSint16LE(m->hitPointsCur);
+ out->writeUint16LE(m->dest);
+ out->writeUint16LE(m->randItem);
+ out->writeUint16LE(m->fixedItem);
+ out->writeByte(m->flags);
+ out->writeByte(m->idleAnimState);
+
+ if (_flags.gameID == GI_EOB1)
+ out->writeByte(m->stepsTillRemoteAttack);
+ else
+ out->writeByte(m->curRemoteWeapon);
+
+ out->writeByte(m->numRemoteAttacks);
+ out->writeSByte(m->palette);
+
+ if (_flags.gameID == GI_EOB1) {
+ out->writeByte(0);
+ } else {
+ out->writeByte(m->directionChanged);
+ out->writeByte(m->stepsTillRemoteAttack);
+ out->writeByte(m->sub);
+ }
+ }
+
+ if (_flags.gameID == GI_EOB1)
+ continue;
+
+ for (int ii = 0; ii < 5; ii++) {
+ WallOfForce *w= &((WallOfForce*)l->wallsOfForce)[ii];
+ out->writeUint16LE(w->block);
+ out->writeUint32LE(w->duration / _tickLength);
+ }
+ }
+
+ delete[] cmpData;
+ delete[] tempData;
+
+ out->writeByte(_configMusic ? 1 : 0);
+ out->writeByte(_configMusic ? 1 : 0);
+ out->writeByte(_configHpBarGraphs ? 1 : 0);
+
+ for (int i = 51; i < 57; i++) {
+ EoBItemType *t = &_itemTypes[i];
+ out->writeUint16LE(t->invFlags);
+ out->writeUint16LE(t->handFlags);
+ out->writeSByte(t->armorClass);
+ out->writeSByte(t->allowedClasses);
+ out->writeSByte(t->requiredHands);
+ out->writeSByte(t->dmgNumDiceS);
+ out->writeSByte(t->dmgNumPipsS);
+ out->writeSByte(t->dmgIncS);
+ out->writeSByte(t->dmgNumDiceL);
+ out->writeSByte(t->dmgNumPipsL);
+ out->writeSByte(t->dmgIncL);
+ out->writeByte(t->unk1);
+ out->writeUint16LE(t->extraProperties);
+ }
+
+ out->finalize();
+ delete out;
+
+ return true;
+}
+
void *EoBCoreEngine::generateMonsterTempData(LevelTempData *tmp) {
EoBMonsterInPlay *m = new EoBMonsterInPlay[30];
memcpy(m, _monsters, sizeof(EoBMonsterInPlay) * 30);
diff --git a/engines/kyra/saveload_lok.cpp b/engines/kyra/saveload_lok.cpp
index b76d1da52a..f8cca1ab7b 100644
--- a/engines/kyra/saveload_lok.cpp
+++ b/engines/kyra/saveload_lok.cpp
@@ -150,7 +150,7 @@ Common::Error KyraEngine_LoK::loadGameState(int slot) {
// it wasn't made sure that _curSfxFile was initialized
// so if it's out of bounds we just set it to 0.
if (_flags.platform == Common::kPlatformFMTowns) {
- if (_curSfxFile >= _soundData->fileListLen || _curSfxFile < 0)
+ if (!_sound->hasSoundFile(_curSfxFile))
_curSfxFile = 0;
_sound->loadSoundFile(_curSfxFile);
}
diff --git a/engines/kyra/saveload_lol.cpp b/engines/kyra/saveload_lol.cpp
index b6840663e9..6c83ebd51b 100644
--- a/engines/kyra/saveload_lol.cpp
+++ b/engines/kyra/saveload_lol.cpp
@@ -41,7 +41,7 @@ Common::Error LoLEngine::loadGameState(int slot) {
SaveHeader header;
Common::InSaveFile *saveFile = openSaveForReading(fileName, header);
if (!saveFile) {
- _txt->printMessage(2, "%s", getLangString(0x425d));
+ _txt->printMessage(2, "%s", getLangString(0x425D));
return Common::kNoError;
}
@@ -437,7 +437,7 @@ Common::Error LoLEngine::saveGameStateIntern(int slot, const char *saveName, con
out->write(l->wallsXorData, 4096);
for (int ii = 0; ii < 1024; ii++)
- out->writeByte(l->flags[ii] & 0xff);
+ out->writeByte(l->flags[ii] & 0xFF);
LoLMonster *lm = (LoLMonster *)_lvlTempData[i]->monsters;
FlyingObject *lf = (FlyingObject *)_lvlTempData[i]->flyingObjects;
@@ -547,7 +547,7 @@ void LoLEngine::restoreTempDataAdjustMonsterStrength(int index) {
if (_lvlTempData[index]->monsterDifficulty == _monsterDifficulty)
return;
- uint16 d = (_monsterModifiers[_lvlTempData[index]->monsterDifficulty] << 8) / _monsterModifiers[_monsterDifficulty];
+ uint16 d = (_monsterModifiers1[_lvlTempData[index]->monsterDifficulty] << 8) / _monsterModifiers1[_monsterDifficulty];
for (int i = 0; i < 30; i++) {
if (_monsters[i].mode >= 14 || _monsters[i].block == 0 || _monsters[i].hitPoints <= 0)
diff --git a/engines/kyra/scene_eob.cpp b/engines/kyra/scene_eob.cpp
index 3db055db90..45de232cb6 100644
--- a/engines/kyra/scene_eob.cpp
+++ b/engines/kyra/scene_eob.cpp
@@ -100,7 +100,7 @@ void EoBCoreEngine::loadLevel(int level, int sub) {
void EoBCoreEngine::readLevelFileData(int level) {
Common::String file;
Common::SeekableReadStream *s = 0;
- static const char *suffix[] = { "INF", "DRO", "ELO", 0 };
+ static const char *const suffix[] = { "INF", "DRO", "ELO", 0 };
for (const char *const *sf = suffix; *sf && !s; sf++) {
file = Common::String::format("LEVEL%d.%s", level, *sf);
@@ -144,10 +144,10 @@ Common::String EoBCoreEngine::initLevelData(int sub) {
const char *vmpPattern = (_flags.gameID == GI_EOB1 && (_configRenderMode == Common::kRenderEGA || _configRenderMode == Common::kRenderCGA)) ? "%s.EMP" : "%s.VMP";
Common::SeekableReadStream *s = _res->createReadStream(Common::String::format(vmpPattern, (const char *)pos));
- _vmpSize = s->readUint16LE();
+ uint16 size = s->readUint16LE();
delete[] _vmpPtr;
- _vmpPtr = new uint16[_vmpSize];
- for (int i = 0; i < _vmpSize; i++)
+ _vmpPtr = new uint16[size];
+ for (int i = 0; i < size; i++)
_vmpPtr[i] = s->readUint16LE();
delete s;
@@ -157,7 +157,7 @@ Common::String EoBCoreEngine::initLevelData(int sub) {
_curGfxFile = (const char *)pos;
pos += slen;
- if (*pos++ != 0xff && _flags.gameID == GI_EOB2) {
+ if (*pos++ != 0xFF && _flags.gameID == GI_EOB2) {
tmpStr = Common::String::format(paletteFilePattern, (const char *)pos);
pos += 13;
}
@@ -174,7 +174,7 @@ Common::String EoBCoreEngine::initLevelData(int sub) {
if (_configRenderMode != Common::kRenderCGA) {
Palette backupPal(256);
backupPal.copy(_screen->getPalette(0), 224, 32, 224);
- _screen->getPalette(0).fill(224, 32, 0x3f);
+ _screen->getPalette(0).fill(224, 32, 0x3F);
uint8 *src = _screen->getPalette(0).getData();
_screen->createFadeTable(src, _screen->getFadeTable(0), 4, 75); // green
@@ -259,7 +259,7 @@ Common::String EoBCoreEngine::initLevelData(int sub) {
}
if (_flags.gameID == GI_EOB2)
- pos = initScriptTimers(pos);
+ initScriptTimers(pos);
return _curGfxFile;
}
@@ -271,7 +271,7 @@ void EoBCoreEngine::addLevelItems() {
for (int i = 0; i < 600; i++) {
if (_items[i].level != _currentLevel || _items[i].block <= 0)
continue;
- setItemPosition((Item *)&_levelBlockProperties[_items[i].block & 0x3ff].drawObjects, _items[i].block, i, _items[i].pos);
+ setItemPosition((Item *)&_levelBlockProperties[_items[i].block & 0x3FF].drawObjects, _items[i].block, i, _items[i].pos);
}
}
@@ -283,7 +283,7 @@ void EoBCoreEngine::loadVcnData(const char *file, const uint8 *cgaMapping) {
_screen->loadBitmap(Common::String::format(filePattern, _lastBlockDataFile).c_str(), 3, 3, 0);
const uint8 *pos = _screen->getCPagePtr(3);
- uint32 vcnSize = READ_LE_UINT16(pos) * _vcnBlockWidth * _vcnBlockHeight;
+ uint32 vcnSize = READ_LE_UINT16(pos) << 5;
pos += 2;
const uint8 *colMap = pos;
@@ -292,78 +292,28 @@ void EoBCoreEngine::loadVcnData(const char *file, const uint8 *cgaMapping) {
delete[] _vcnBlocks;
_vcnBlocks = new uint8[vcnSize];
- if (_flags.gameID == GI_EOB2 && _configRenderMode == Common::kRenderEGA) {
- const uint8 *egaTable = _screen->getEGADitheringTable();
- assert(_vmpPtr);
- assert(egaTable);
-
- delete[] _vcnTransitionMask;
- _vcnTransitionMask = new uint8[vcnSize];
-
- for (int i = 0; i < _vmpSize; i++) {
- uint16 vcnOffs = _vmpPtr[i] & 0x3FFF;
- const uint8 *src = &pos[vcnOffs << 5];
- uint8 *dst1 = &_vcnBlocks[vcnOffs << 7];
- uint8 *dst3 = &_vcnTransitionMask[vcnOffs << 7];
- int palOffset = (i < 330) ? 0 : _wllVcnOffset;
-
- for (int y = 0; y < 8; y++) {
- uint8 *dst2 = dst1 + 8;
- uint8 *dst4 = dst3 + 8;
-
- for (int x = 0; x < 4; x++) {
- uint8 in = *src++;
-
- dst1[0] = dst2[0] = egaTable[colMap[(in >> 4) + palOffset]];
- dst1[1] = dst2[1] = egaTable[colMap[(in & 0x0f) + palOffset]];
- dst3[0] = dst4[0] = (in & 0xf0) ? 0 : 0xff;
- dst3[1] = dst4[1] = (in & 0x0f) ? 0 : 0xff;
-
- dst1 += 2;
- dst2 += 2;
- dst3 += 2;
- dst4 += 2;
- }
-
- dst1 += 8;
- dst3 += 8;
- }
- }
- } else if (_configRenderMode == Common::kRenderCGA) {
+ if (_configRenderMode == Common::kRenderCGA) {
uint8 *tmp = _screen->encodeShape(0, 0, 1, 8, false, cgaMapping);
delete[] tmp;
delete[] _vcnTransitionMask;
_vcnTransitionMask = new uint8[vcnSize];
- uint8 tblSwitch = 0;
+ uint8 tblSwitch = 1;
uint8 *dst = _vcnBlocks;
uint8 *dst2 = _vcnTransitionMask;
while (dst < _vcnBlocks + vcnSize) {
const uint16 *table = _screen->getCGADitheringTable((tblSwitch++) & 1);
for (int ii = 0; ii < 2; ii++) {
- *dst++ = ((table[pos[0]] & 0x000f) << 4) | ((table[pos[0]] & 0x0f00) >> 8);
- *dst++= ((table[pos[1]] & 0x000f) << 4) | ((table[pos[1]] & 0x0f00) >> 8);
-
- uint8 msk = 0;
- if (pos[0] & 0xf0)
- msk |= 0x30;
- if (pos[0] & 0x0f)
- msk |= 0x03;
- *dst2++ = msk ^ 0x33;
-
- msk = 0;
- if (pos[1] & 0xf0)
- msk |= 0x30;
- if (pos[1] & 0x0f)
- msk |= 0x03;
- *dst2++ = msk ^ 0x33;
-
+ *dst++ = (table[pos[0]] & 0x000F) | ((table[pos[0]] & 0x0F00) >> 4);
+ *dst++ = (table[pos[1]] & 0x000F) | ((table[pos[1]] & 0x0F00) >> 4);
+ *dst2++ = ((pos[0] & 0xF0 ? 0x30 : 0) | (pos[0] & 0x0F ? 0x03 : 0)) ^ 0x33;
+ *dst2++ = ((pos[1] & 0xF0 ? 0x30 : 0) | (pos[1] & 0x0F ? 0x03 : 0)) ^ 0x33;
pos += 2;
}
}
} else {
- if (_configRenderMode != Common::kRenderEGA)
+ if (!(_flags.gameID == GI_EOB1 && _configRenderMode == Common::kRenderEGA))
memcpy(_vcnColTable, colMap, 32);
memcpy(_vcnBlocks, pos, vcnSize);
}
@@ -429,8 +379,8 @@ void EoBCoreEngine::loadDecorations(const char *cpsFile, const char *decFile) {
LevelDecorationProperty *l = &_levelDecorationData[i];
for (int ii = 0; ii < 10; ii++) {
l->shapeIndex[ii] = s->readByte();
- if (l->shapeIndex[ii] == 0xff)
- l->shapeIndex[ii] = 0xffff;
+ if (l->shapeIndex[ii] == 0xFF)
+ l->shapeIndex[ii] = 0xFFFF;
}
l->next = s->readByte();
l->flags = s->readByte();
@@ -477,7 +427,7 @@ void EoBCoreEngine::assignWallsAndDecorations(int wallIndex, int vmpIndex, int d
for (int i = 0; i < 10; i++) {
uint16 t = _levelDecorationProperties[_mappedDecorationsCount].shapeIndex[i];
- if (t == 0xffff)
+ if (t == 0xFFFF)
continue;
if (_levelDecorationShapes[t])
@@ -529,7 +479,7 @@ void EoBCoreEngine::toggleWallState(int wall, int toggle) {
if (toggle)
_wllWallFlags[wall + i] |= 2;
else
- _wllWallFlags[wall + i] &= 0xfd;
+ _wllWallFlags[wall + i] &= 0xFD;
}
}
@@ -643,7 +593,7 @@ void EoBCoreEngine::drawDecorations(int index) {
if ((i == 0) && (flg & 1 || ((flg & 2) && _wllProcessFlag)))
ix = -ix;
- if (_levelDecorationProperties[l].shapeIndex[shpIx] == 0xffff) {
+ if (_levelDecorationProperties[l].shapeIndex[shpIx] == 0xFFFF) {
l = _levelDecorationProperties[l].next;
continue;
}
@@ -758,7 +708,7 @@ int EoBCoreEngine::clickedNiche(uint16 block, uint16 direction) {
if (_dscItemShapeMap[_items[_itemInHand].icon] <= 14) {
_txt->printMessage(_pryDoorStrings[5]);
} else {
- setItemPosition((Item *)&_levelBlockProperties[block & 0x3ff].drawObjects, block, _itemInHand, 8);
+ setItemPosition((Item *)&_levelBlockProperties[block & 0x3FF].drawObjects, block, _itemInHand, 8);
runLevelScript(block, 4);
setHandItem(0);
_sceneUpdateRequired = true;
@@ -781,7 +731,7 @@ int EoBCoreEngine::clickedDoorPry(uint16 block, uint16 direction) {
int d = -1;
for (int i = 0; i < 6; i++) {
- if (!testCharacter(i, 0x0d))
+ if (!testCharacter(i, 0x0D))
continue;
if (d >= 0) {
int s1 = _characters[i].strengthCur + _characters[i].strengthExtCur;
@@ -826,7 +776,7 @@ int EoBCoreEngine::clickedDoorNoPry(uint16 block, uint16 direction) {
int EoBCoreEngine::specialWallAction(int block, int direction) {
direction ^= 2;
uint8 type = _specialWallTypes[_levelBlockProperties[block].walls[direction]];
- if (!type || !(_clickedSpecialFlag & (((_levelBlockProperties[block].flags & 0xf8) >> 3) | 0xe0)))
+ if (!type || !(_clickedSpecialFlag & (((_levelBlockProperties[block].flags & 0xF8) >> 3) | 0xE0)))
return 0;
int res = 0;
diff --git a/engines/kyra/scene_lol.cpp b/engines/kyra/scene_lol.cpp
index 628654f127..154606d46f 100644
--- a/engines/kyra/scene_lol.cpp
+++ b/engines/kyra/scene_lol.cpp
@@ -193,7 +193,7 @@ int LoLEngine::assignLevelDecorationShapes(int index) {
for (int i = 0; i < 10; i++) {
uint16 t = _levelDecorationProperties[o].shapeIndex[i];
- if (t == 0xffff)
+ if (t == 0xFFFF)
continue;
uint16 pv = p1[t];
@@ -254,7 +254,7 @@ void LoLEngine::loadBlockProperties(const char *cmzFile) {
_levelBlockProperties[i].direction = 5;
if (_wllAutomapData[_levelBlockProperties[i].walls[0]] == 17) {
- _levelBlockProperties[i].flags &= 0xef;
+ _levelBlockProperties[i].flags &= 0xEF;
_levelBlockProperties[i].flags |= 0x20;
}
}
@@ -315,9 +315,9 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight
if (_lastSpecialColor == 1)
_lastSpecialColor = 0x44;
else if (_lastSpecialColor == 0x66)
- _lastSpecialColor = scumm_stricmp(file, "YVEL2") ? 0xcc : 0x44;
- else if (_lastSpecialColor == 0x6b)
- _lastSpecialColor = 0xcc;
+ _lastSpecialColor = scumm_stricmp(_lastBlockDataFile, "YVEL2") ? 0xCC : 0x44;
+ else if (_lastSpecialColor == 0x6B)
+ _lastSpecialColor = 0xCC;
else
_lastSpecialColor = 0x44;
}
@@ -431,17 +431,17 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight
}
for (int ii = l; ii < 256; ii++)
- levelOverlay[ii] = ii & 0xff;
+ levelOverlay[ii] = ii & 0xFF;
}
uint8 *levelOverlay = _screen->getLevelOverlay(7);
for (int i = 0; i < 256; i++)
- levelOverlay[i] = i & 0xff;
+ levelOverlay[i] = i & 0xFF;
if (_flags.use16ColorMode) {
- _screen->getLevelOverlay(6)[0xee] = 0xee;
+ _screen->getLevelOverlay(6)[0xEE] = 0xEE;
if (_lastSpecialColor == 0x44)
- _screen->getLevelOverlay(5)[0xee] = 0xee;
+ _screen->getLevelOverlay(5)[0xEE] = 0xEE;
for (int i = 0; i < 7; i++)
memcpy(_screen->getLevelOverlay(i), _screen->getLevelOverlay(i + 1), 256);
@@ -505,14 +505,14 @@ void LoLEngine::resetBlockProperties() {
for (int i = 0; i < 1024; i++) {
LevelBlockProperty *l = &_levelBlockProperties[i];
if (l->flags & 0x10) {
- l->flags &= 0xef;
+ l->flags &= 0xEF;
if (testWallInvisibility(i, 0) && testWallInvisibility(i, 1))
l->flags |= 0x40;
} else {
if (l->flags & 0x40)
- l->flags &= 0xbf;
+ l->flags &= 0xBF;
else if (l->flags & 0x80)
- l->flags &= 0x7f;
+ l->flags &= 0x7F;
}
}
}
@@ -574,7 +574,7 @@ void LoLEngine::updateLampStatus() {
setPaletteBrightness(_screen->getPalette(0), _brightness, newLampEffect);
_lampStatusTimer = _system->getMillis() + (10 + rollDice(1, 30)) * _tickLength;
} else {
- if ((_lampEffect & 0xfe) == (newLampEffect & 0xfe)) {
+ if ((_lampEffect & 0xFE) == (newLampEffect & 0xFE)) {
if (_system->getMillis() <= _lampStatusTimer) {
newLampEffect = _lampEffect;
} else {
@@ -702,7 +702,7 @@ void LoLEngine::moveParty(uint16 direction, int unk1, int unk2, int buttonShape)
runLevelScript(opos, 8);
runLevelScript(npos, 2);
- if (_levelBlockProperties[npos].walls[0] == 0x1a)
+ if (_levelBlockProperties[npos].walls[0] == 0x1A)
memset(_levelBlockProperties[npos].walls, 0, 4);
}
}
@@ -711,12 +711,12 @@ void LoLEngine::moveParty(uint16 direction, int unk1, int unk2, int buttonShape)
}
uint16 LoLEngine::calcBlockIndex(uint16 x, uint16 y) {
- return (((y & 0xff00) >> 3) | (x >> 8)) & 0x3ff;
+ return (((y & 0xFF00) >> 3) | (x >> 8)) & 0x3FF;
}
void LoLEngine::calcCoordinates(uint16 &x, uint16 &y, int block, uint16 xOffs, uint16 yOffs) {
- x = (block & 0x1f) << 8 | xOffs;
- y = ((block & 0xffe0) << 3) | yOffs;
+ x = (block & 0x1F) << 8 | xOffs;
+ y = ((block & 0xFFE0) << 3) | yOffs;
}
void LoLEngine::calcCoordinatesForSingleCharacter(int charNum, uint16 &x, uint16 &y) {
@@ -732,8 +732,8 @@ void LoLEngine::calcCoordinatesForSingleCharacter(int charNum, uint16 &x, uint16
calcCoordinatesAddDirectionOffset(x, y, _currentDirection);
- x |= (_partyPosX & 0xff00);
- y |= (_partyPosY & 0xff00);
+ x |= (_partyPosX & 0xFF00);
+ y |= (_partyPosY & 0xFF00);
}
void LoLEngine::calcCoordinatesAddDirectionOffset(uint16 &x, uint16 &y, int direction) {
@@ -777,7 +777,7 @@ void LoLEngine::notifyBlockNotPassable(int scrollFlag) {
movePartySmoothScrollBlocked(2);
snd_stopSpeech(true);
- _txt->printMessage(0x8002, "%s", getLangString(0x403f));
+ _txt->printMessage(0x8002, "%s", getLangString(0x403F));
snd_playSoundEffect(19, -1);
}
@@ -804,7 +804,7 @@ int LoLEngine::clickedNiche(uint16 block, uint16 direction) {
return 0;
uint16 x = 0x80;
- uint16 y = 0xff;
+ uint16 y = 0xFF;
calcCoordinatesAddDirectionOffset(x, y, _currentDirection);
calcCoordinates(x, y, block, x, y);
setItemPosition(_itemInHand, x, y, 8, 1);
@@ -1180,14 +1180,14 @@ void LoLEngine::processGasExplosion(int soundId) {
memcpy(p2, p1, 768);
for (int i = 1; i < 128; i++)
- p2[i * 3] = 0x3f;
+ 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();
}
@@ -1244,10 +1244,10 @@ void LoLEngine::setWallType(int block, int wall, int val) {
for (int i = 0; i < 4; i++)
_levelBlockProperties[block].walls[i] = val;
if (_wllAutomapData[val] == 17) {
- _levelBlockProperties[block].flags &= 0xef;
+ _levelBlockProperties[block].flags &= 0xEF;
_levelBlockProperties[block].flags |= 0x20;
} else {
- _levelBlockProperties[block].flags &= 0xdf;
+ _levelBlockProperties[block].flags &= 0xDF;
}
} else {
_levelBlockProperties[block].walls[wall] = val;
@@ -1491,7 +1491,7 @@ void LoLEngine::drawDecorations(int index) {
ov = 0;
}
ovl = _screen->getLevelOverlay(ov);
- } else if (_levelDecorationProperties[l].shapeIndex[shpIx] != 0xffff) {
+ } else if (_levelDecorationProperties[l].shapeIndex[shpIx] != 0xFFFF) {
scaleW = scaleH = 0x100;
int ov = 7;
if (_flags.use16ColorMode) {
@@ -1504,7 +1504,7 @@ void LoLEngine::drawDecorations(int index) {
ovl = _screen->getLevelOverlay(ov);
}
- if (_levelDecorationProperties[l].shapeIndex[shpIx] != 0xffff) {
+ if (_levelDecorationProperties[l].shapeIndex[shpIx] != 0xFFFF) {
shapeData = _levelDecorationShapes[_levelDecorationProperties[l].shapeIndex[shpIx]];
if (shapeData) {
if (ix < 0) {
@@ -1538,10 +1538,10 @@ void LoLEngine::drawDecorations(int index) {
}
void LoLEngine::drawBlockEffects(int index, int type) {
- static const uint16 yOffs[] = { 0xff, 0xff, 0x80, 0x80 };
+ static const uint16 yOffs[] = { 0xFF, 0xFF, 0x80, 0x80 };
uint8 flg = _visibleBlocks[index]->flags;
// flags: 0x10 = ice wall, 0x20 = teleporter, 0x40 = blue slime spot, 0x80 = blood spot
- if (!(flg & 0xf0))
+ if (!(flg & 0xF0))
return;
type = (type == 0) ? 2 : 0;
@@ -1562,8 +1562,8 @@ void LoLEngine::drawBlockEffects(int index, int type) {
calcCoordinatesAddDirectionOffset(x, y, _currentDirection);
- x |= ((_visibleBlockIndex[index] & 0x1f) << 8);
- y |= ((_visibleBlockIndex[index] & 0xffe0) << 3);
+ x |= ((_visibleBlockIndex[index] & 0x1F) << 8);
+ y |= ((_visibleBlockIndex[index] & 0xFFE0) << 3);
drawItemOrMonster(_effectShapes[type], ovl, x, y, 0, (type == 1) ? -20 : 0, drawFlag, -1, false);
}
diff --git a/engines/kyra/scene_mr.cpp b/engines/kyra/scene_mr.cpp
index d6df523f82..c9486d9c45 100644
--- a/engines/kyra/scene_mr.cpp
+++ b/engines/kyra/scene_mr.cpp
@@ -22,7 +22,7 @@
#include "kyra/kyra_mr.h"
#include "kyra/screen_mr.h"
-#include "kyra/sound.h"
+#include "kyra/sound_digital.h"
#include "kyra/resource.h"
#include "common/system.h"
diff --git a/engines/kyra/scene_rpg.cpp b/engines/kyra/scene_rpg.cpp
index 3a694e05fe..6d724efed0 100644
--- a/engines/kyra/scene_rpg.cpp
+++ b/engines/kyra/scene_rpg.cpp
@@ -151,7 +151,7 @@ void KyraRpgEngine::generateBlockDrawingBuffer() {
memset(_blockDrawingBuffer, 0, 660 * sizeof(uint16));
- _wllProcessFlag = ((_currentBlock >> 5) + (_currentBlock & 0x1f) + _currentDirection) & 1;
+ _wllProcessFlag = ((_currentBlock >> 5) + (_currentBlock & 0x1F) + _currentDirection) & 1;
if (_wllProcessFlag) // floor and ceiling
generateVmpTileDataFlipped(0, 15, 1, -330, 22, 15);
@@ -318,7 +318,7 @@ bool KyraRpgEngine::hasWall(int index) {
void KyraRpgEngine::assignVisibleBlocks(int block, int direction) {
for (int i = 0; i < 18; i++) {
- uint16 t = (block + _dscBlockIndex[direction * 18 + i]) & 0x3ff;
+ uint16 t = (block + _dscBlockIndex[direction * 18 + i]) & 0x3FF;
_visibleBlockIndex[i] = t;
_visibleBlocks[i] = &_levelBlockProperties[t];
@@ -348,9 +348,6 @@ bool KyraRpgEngine::checkSceneUpdateNeed(int block) {
void KyraRpgEngine::drawVcnBlocks() {
uint8 *d = _sceneWindowBuffer;
uint16 *bdb = _blockDrawingBuffer;
- uint16 pitch = 22 * _vcnBlockWidth * 2;
- uint8 pxl[2];
- pxl[0] = pxl[1] = 0;
for (int y = 0; y < 15; y++) {
for (int x = 0; x < 22; x++) {
@@ -369,96 +366,95 @@ void KyraRpgEngine::drawVcnBlocks() {
if (vcnOffset & 0x4000) {
horizontalFlip = true;
- vcnOffset &= 0x3fff;
+ vcnOffset &= 0x3FFF;
}
uint8 *src = 0;
if (vcnOffset) {
- src = &_vcnBlocks[vcnOffset * _vcnBlockWidth * _vcnBlockHeight];
+ src = &_vcnBlocks[vcnOffset << 5];
wllVcnOffset = _wllVcnOffset;
} else {
// floor/ceiling blocks
vcnOffset = bdb[329];
if (vcnOffset & 0x4000) {
horizontalFlip = true;
- vcnOffset &= 0x3fff;
+ vcnOffset &= 0x3FFF;
}
- src = (_vcfBlocks ? _vcfBlocks : _vcnBlocks) + (vcnOffset * _vcnBlockWidth * _vcnBlockHeight);
+ src = (_vcfBlocks ? _vcfBlocks : _vcnBlocks) + (vcnOffset << 5);
}
uint8 shift = _vcnShift ? _vcnShift[vcnOffset] : _blockBrightness;
if (horizontalFlip) {
- for (int blockY = 0; blockY < _vcnBlockHeight; blockY++) {
- src += (_vcnBlockWidth - 1);
- for (int blockX = 0; blockX < _vcnBlockWidth; blockX++) {
+ for (int blockY = 0; blockY < 8; blockY++) {
+ src += 3;
+ for (int blockX = 0; blockX < 4; blockX++) {
uint8 bl = *src--;
- d[_vcnFlip0] = _vcnColTable[((bl & 0x0f) + wllVcnOffset) | shift];
- d[_vcnFlip1] = _vcnColTable[((bl >> 4) + wllVcnOffset) | shift];
- d += 2;
+ *d++ = _vcnColTable[((bl & 0x0F) + wllVcnOffset) | shift];
+ *d++ = _vcnColTable[((bl >> 4) + wllVcnOffset) | shift];
}
- src += (_vcnBlockWidth + 1);
- d += (pitch - 2 * _vcnBlockWidth);
+ src += 5;
+ d += 168;
}
} else {
- for (int blockY = 0; blockY < _vcnBlockHeight; blockY++) {
- for (int blockX = 0; blockX < _vcnBlockWidth; blockX++) {
+ for (int blockY = 0; blockY < 8; blockY++) {
+ for (int blockX = 0; blockX < 4; blockX++) {
uint8 bl = *src++;
*d++ = _vcnColTable[((bl >> 4) + wllVcnOffset) | shift];
- *d++ = _vcnColTable[((bl & 0x0f) + wllVcnOffset) | shift];
+ *d++ = _vcnColTable[((bl & 0x0F) + wllVcnOffset) | shift];
}
- d += (pitch - 2 * _vcnBlockWidth);
+ d += 168;
}
}
- d -= (pitch * _vcnBlockHeight - 2 * _vcnBlockWidth);
+ d -= 1400;
if (vcnExtraOffsetWll) {
- d -= (2 * _vcnBlockWidth);
+ d -= 8;
horizontalFlip = false;
if (vcnExtraOffsetWll & 0x4000) {
- vcnExtraOffsetWll &= 0x3fff;
+ vcnExtraOffsetWll &= 0x3FFF;
horizontalFlip = true;
}
shift = _vcnShift ? _vcnShift[vcnExtraOffsetWll] : _blockBrightness;
- src = &_vcnBlocks[vcnExtraOffsetWll * _vcnBlockWidth * _vcnBlockHeight];
- uint8 *maskTable = _vcnTransitionMask ? &_vcnTransitionMask[vcnExtraOffsetWll * _vcnBlockWidth * _vcnBlockHeight] : 0;
+ src = &_vcnBlocks[vcnExtraOffsetWll << 5];
+ uint8 *maskTable = _vcnTransitionMask ? &_vcnTransitionMask[vcnExtraOffsetWll << 5] : 0;
if (horizontalFlip) {
- for (int blockY = 0; blockY < _vcnBlockHeight; blockY++) {
- src += (_vcnBlockWidth - 1);
- maskTable += (_vcnBlockWidth - 1);
- for (int blockX = 0; blockX < _vcnBlockWidth; blockX++) {
+ for (int blockY = 0; blockY < 8; blockY++) {
+ src += 3;
+ maskTable += 3;
+ for (int blockX = 0; blockX < 4; blockX++) {
uint8 bl = *src--;
uint8 mask = _vcnTransitionMask ? *maskTable-- : 0;
- pxl[_vcnFlip0] = _vcnColTable[((bl & 0x0f) + wllVcnRmdOffset) | shift];
- pxl[_vcnFlip1] = _vcnColTable[((bl >> 4) + wllVcnRmdOffset) | shift];
+ uint8 h = _vcnColTable[((bl & 0x0F) + wllVcnRmdOffset) | shift];
+ uint8 l = _vcnColTable[((bl >> 4) + wllVcnRmdOffset) | shift];
if (_vcnTransitionMask)
- *d = (*d & (mask & 0x0f)) | pxl[0];
- else if (pxl[0])
- *d = pxl[0];
+ *d = (*d & (mask & 0x0F)) | h;
+ else if (h)
+ *d = h;
d++;
if (_vcnTransitionMask)
- *d = (*d & (mask >> 4)) | pxl[1];
- else if (pxl[1])
- *d = pxl[1];
+ *d = (*d & (mask >> 4)) | l;
+ else if (l)
+ *d = l;
d++;
}
- src += (_vcnBlockWidth + 1);
- maskTable += (_vcnBlockWidth + 1);
- d += (pitch - 2 * _vcnBlockWidth);
+ src += 5;
+ maskTable += 5;
+ d += 168;
}
} else {
- for (int blockY = 0; blockY < _vcnBlockHeight; blockY++) {
- for (int blockX = 0; blockX < _vcnBlockWidth; blockX++) {
+ for (int blockY = 0; blockY < 8; blockY++) {
+ for (int blockX = 0; blockX < 4; blockX++) {
uint8 bl = *src++;
uint8 mask = _vcnTransitionMask ? *maskTable++ : 0;
uint8 h = _vcnColTable[((bl >> 4) + wllVcnRmdOffset) | shift];
- uint8 l = _vcnColTable[((bl & 0x0f) + wllVcnRmdOffset) | shift];
+ uint8 l = _vcnColTable[((bl & 0x0F) + wllVcnRmdOffset) | shift];
if (_vcnTransitionMask)
*d = (*d & (mask >> 4)) | h;
@@ -467,18 +463,18 @@ void KyraRpgEngine::drawVcnBlocks() {
d++;
if (_vcnTransitionMask)
- *d = (*d & (mask & 0x0f)) | l;
+ *d = (*d & (mask & 0x0F)) | l;
else if (l)
*d = l;
d++;
}
- d += (pitch - 2 * _vcnBlockWidth);
+ d += 168;
}
}
- d -= (pitch * _vcnBlockHeight - 2 * _vcnBlockWidth);
+ d -= 1400;
}
}
- d += (pitch * (_vcnBlockHeight - 1));
+ d += 1232;
}
screen()->copyBlockToPage(_sceneDrawPage1, _sceneXoffset, 0, 176, 120, _sceneWindowBuffer);
@@ -486,7 +482,7 @@ void KyraRpgEngine::drawVcnBlocks() {
uint16 KyraRpgEngine::calcNewBlockPosition(uint16 curBlock, uint16 direction) {
static const int16 blockPosTable[] = { -32, 1, 32, -1 };
- return (curBlock + blockPosTable[direction]) & 0x3ff;
+ return (curBlock + blockPosTable[direction]) & 0x3FF;
}
int KyraRpgEngine::clickedWallShape(uint16 block, uint16 direction) {
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index 04d805737f..419b630714 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -51,13 +51,12 @@ Screen::Screen(KyraEngine_v1 *vm, OSystem *system, const ScreenDim *dimTable, co
memset(_fonts, 0, sizeof(_fonts));
memset(_pagePtrs, 0, sizeof(_pagePtrs));
- // Set scale factor to 1 (no scaling) for all pages
- memset(_pageScaleFactor, 1, sizeof(_pageScaleFactor));
// In VGA mode the odd and even page pointers point to the same buffers.
for (int i = 0; i < SCREEN_PAGE_NUM; i++)
_pageMapping[i] = i & ~1;
_renderMode = Common::kRenderDefault;
+ _sjisMixedFontMode = false;
_currentFont = FID_8_FNT;
_paletteChanged = true;
@@ -114,7 +113,7 @@ bool Screen::init() {
}
// CGA and EGA modes use additional pages to do the CGA/EGA specific graphics conversions.
- if (_renderMode == Common::kRenderCGA || _renderMode == Common::kRenderEGA) {
+ if (_vm->game() == GI_EOB1 && (_renderMode == Common::kRenderCGA || _renderMode == Common::kRenderEGA)) {
for (int i = 0; i < 8; i++)
_pageMapping[i] = i;
}
@@ -126,6 +125,7 @@ bool Screen::init() {
if (_useOverlays) {
_useSJIS = (_vm->gameFlags().lang == Common::JA_JPN);
_sjisInvisibleColor = (_vm->game() == GI_KYRA1) ? 0x80 : 0xF6;
+ _sjisMixedFontMode = !_use16ColorMode;
for (int i = 0; i < SCREEN_OVLS_NUM; ++i) {
if (!_sjisOverlayPtrs[i]) {
@@ -141,7 +141,7 @@ bool Screen::init() {
if (!font)
error("Could not load any SJIS font, neither the original nor ScummVM's 'SJIS.FNT'");
- _fonts[FID_SJIS_FNT] = new SJISFont(font, _sjisInvisibleColor, _use16ColorMode, !_use16ColorMode);
+ _fonts[FID_SJIS_FNT] = new SJISFont(font, _sjisInvisibleColor, _use16ColorMode, !_use16ColorMode && _vm->game() != GI_LOL, _vm->game() == GI_LOL ? 1 : 0);
}
}
@@ -154,9 +154,7 @@ bool Screen::init() {
}
int numPages = realPages.size();
- uint32 bufferSize = 0;
- for (int i = 0; i < numPages; i++)
- bufferSize += (SCREEN_PAGE_SIZE * _pageScaleFactor[realPages[i]] * _pageScaleFactor[realPages[i]]);
+ uint32 bufferSize = numPages * SCREEN_PAGE_SIZE;
uint8 *pagePtr = new uint8[bufferSize];
memset(pagePtr, 0, bufferSize);
@@ -167,7 +165,7 @@ bool Screen::init() {
_pagePtrs[i] = _pagePtrs[_pageMapping[i]];
} else {
_pagePtrs[i] = pagePtr;
- pagePtr += (SCREEN_PAGE_SIZE * _pageScaleFactor[i] * _pageScaleFactor[i]);
+ pagePtr += SCREEN_PAGE_SIZE;
}
}
@@ -292,7 +290,7 @@ void Screen::updateScreen() {
needRealUpdate = true;
if (!_useOverlays)
- _system->copyRectToScreen(getPagePtr(2), SCREEN_W, 320, 0, SCREEN_W * _pageScaleFactor[2], SCREEN_H * _pageScaleFactor[2]);
+ _system->copyRectToScreen(getPagePtr(2), SCREEN_W, 320, 0, SCREEN_W, SCREEN_H);
else
_system->copyRectToScreen(getPagePtr(2), SCREEN_W, 640, 0, SCREEN_W, SCREEN_H);
}
@@ -303,12 +301,12 @@ void Screen::updateScreen() {
void Screen::updateDirtyRects() {
if (_forceFullUpdate) {
- _system->copyRectToScreen(getCPagePtr(0), SCREEN_W * _pageScaleFactor[0], 0, 0, SCREEN_W * _pageScaleFactor[0], SCREEN_H * _pageScaleFactor[0]);
+ _system->copyRectToScreen(getCPagePtr(0), SCREEN_W, 0, 0, SCREEN_W, SCREEN_H);
} else {
const byte *page0 = getCPagePtr(0);
Common::List<Common::Rect>::iterator it;
for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
- _system->copyRectToScreen(page0 + it->top * SCREEN_W * _pageScaleFactor[0] + it->left, SCREEN_W * _pageScaleFactor[0], it->left, it->top, it->width(), it->height());
+ _system->copyRectToScreen(page0 + it->top * SCREEN_W + it->left, SCREEN_W, it->left, it->top, it->width(), it->height());
}
}
_forceFullUpdate = false;
@@ -493,7 +491,7 @@ void Screen::clearPage(int pageNum) {
assert(pageNum < SCREEN_PAGE_NUM);
if (pageNum == 0 || pageNum == 1)
_forceFullUpdate = true;
- memset(getPagePtr(pageNum), 0, SCREEN_PAGE_SIZE * _pageScaleFactor[_curPage] * _pageScaleFactor[_curPage]);
+ memset(getPagePtr(pageNum), 0, SCREEN_PAGE_SIZE);
clearOverlayPage(pageNum);
}
@@ -507,7 +505,7 @@ int Screen::setCurPage(int pageNum) {
void Screen::clearCurPage() {
if (_curPage == 0 || _curPage == 1)
_forceFullUpdate = true;
- memset(getPagePtr(_curPage), 0, SCREEN_PAGE_SIZE * _pageScaleFactor[_curPage] * _pageScaleFactor[_curPage]);
+ memset(getPagePtr(_curPage), 0, SCREEN_PAGE_SIZE);
clearOverlayPage(_curPage);
}
@@ -672,7 +670,7 @@ void Screen::setPagePixel(int pageNum, int x, int y, uint8 color) {
color |= (color << 4);
} else if (_renderMode == Common::kRenderCGA) {
color &= 0x03;
- } else if (_renderMode == Common::kRenderEGA) {
+ } else if (_renderMode == Common::kRenderEGA && !_useHiResEGADithering) {
color &= 0x0F;
}
@@ -881,26 +879,16 @@ void Screen::copyToPage0(int y, int h, uint8 page, uint8 *seqBuf) {
}
void Screen::copyRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPage, int dstPage, int flags) {
- // Since we don't (need to) do any actual scaling, we check for compatible pages here
- assert(_pageScaleFactor[srcPage] == _pageScaleFactor[dstPage]);
-
- x1 *= _pageScaleFactor[srcPage];
- y1 *= _pageScaleFactor[srcPage];
- x2 *= _pageScaleFactor[dstPage];
- y2 *= _pageScaleFactor[dstPage];
- w *= _pageScaleFactor[srcPage];
- h *= _pageScaleFactor[srcPage];
-
if (x2 < 0) {
if (x2 <= -w)
return;
w += x2;
x1 -= x2;
x2 = 0;
- } else if (x2 + w >= SCREEN_W * _pageScaleFactor[dstPage]) {
- if (x2 > SCREEN_W * _pageScaleFactor[dstPage])
+ } else if (x2 + w >= SCREEN_W) {
+ if (x2 > SCREEN_W)
return;
- w = SCREEN_W * _pageScaleFactor[srcPage] - x2;
+ w = SCREEN_W - x2;
}
if (y2 < 0) {
@@ -909,14 +897,14 @@ void Screen::copyRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPag
h += y2;
y1 -= y2;
y2 = 0;
- } else if (y2 + h >= SCREEN_H * _pageScaleFactor[dstPage]) {
- if (y2 > SCREEN_H * _pageScaleFactor[dstPage])
+ } else if (y2 + h >= SCREEN_H) {
+ if (y2 > SCREEN_H)
return;
- h = SCREEN_H * _pageScaleFactor[srcPage] - y2;
+ h = SCREEN_H - y2;
}
- const uint8 *src = getPagePtr(srcPage) + y1 * SCREEN_W * _pageScaleFactor[srcPage] + x1;
- uint8 *dst = getPagePtr(dstPage) + y2 * SCREEN_W * _pageScaleFactor[dstPage] + x2;
+ const uint8 *src = getPagePtr(srcPage) + y1 * SCREEN_W + x1;
+ uint8 *dst = getPagePtr(dstPage) + y2 * SCREEN_W + x2;
if (src == dst)
return;
@@ -929,8 +917,8 @@ void Screen::copyRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPag
if (flags & CR_NO_P_CHECK) {
while (h--) {
memmove(dst, src, w);
- src += SCREEN_W * _pageScaleFactor[srcPage];
- dst += SCREEN_W * _pageScaleFactor[dstPage];
+ src += SCREEN_W;
+ dst += SCREEN_W;
}
} else {
while (h--) {
@@ -938,24 +926,19 @@ void Screen::copyRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPag
if (src[i])
dst[i] = src[i];
}
- src += SCREEN_W * _pageScaleFactor[srcPage];
- dst += SCREEN_W * _pageScaleFactor[dstPage];
+ src += SCREEN_W;
+ dst += SCREEN_W;
}
}
}
void Screen::copyRegionToBuffer(int pageNum, int x, int y, int w, int h, uint8 *dest) {
- x *= _pageScaleFactor[pageNum];
- y *= _pageScaleFactor[pageNum];
- w *= _pageScaleFactor[pageNum];
- h *= _pageScaleFactor[pageNum];
-
if (y < 0) {
dest += (-y) * w;
h += y;
y = 0;
} else if (y + h > SCREEN_H) {
- h = SCREEN_H * _pageScaleFactor[pageNum] - y;
+ h = SCREEN_H - y;
}
if (x < 0) {
@@ -963,7 +946,7 @@ void Screen::copyRegionToBuffer(int pageNum, int x, int y, int w, int h, uint8 *
w += x;
x = 0;
} else if (x + w > SCREEN_W) {
- w = SCREEN_W * _pageScaleFactor[pageNum] - x;
+ w = SCREEN_W - x;
}
if (w < 0 || h < 0)
@@ -972,17 +955,14 @@ void Screen::copyRegionToBuffer(int pageNum, int x, int y, int w, int h, uint8 *
uint8 *pagePtr = getPagePtr(pageNum);
for (int i = y; i < y + h; ++i)
- memcpy(dest + (i - y) * w, pagePtr + i * SCREEN_W * _pageScaleFactor[pageNum] + x, w);
+ memcpy(dest + (i - y) * w, pagePtr + i * SCREEN_W + x, w);
}
void Screen::copyPage(uint8 srcPage, uint8 dstPage) {
- // Since we don't (need to) do any actual scaling, we check for compatible pages here
- assert(_pageScaleFactor[srcPage] == _pageScaleFactor[dstPage]);
-
uint8 *src = getPagePtr(srcPage);
uint8 *dst = getPagePtr(dstPage);
if (src != dst)
- memcpy(dst, src, SCREEN_W * _pageScaleFactor[srcPage] * SCREEN_H * _pageScaleFactor[srcPage]);
+ memcpy(dst, src, SCREEN_W * SCREEN_H);
copyOverlayRegion(0, 0, 0, 0, SCREEN_W, SCREEN_H, srcPage, dstPage);
if (dstPage == 0 || dstPage == 1)
@@ -1009,12 +989,7 @@ void Screen::copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint
if (w < 0 || h < 0)
return;
- x *= _pageScaleFactor[pageNum];
- y *= _pageScaleFactor[pageNum];
- w *= _pageScaleFactor[pageNum];
- h *= _pageScaleFactor[pageNum];
-
- uint8 *dst = getPagePtr(pageNum) + y * SCREEN_W * _pageScaleFactor[pageNum] + x;
+ uint8 *dst = getPagePtr(pageNum) + y * SCREEN_W + x;
if (pageNum == 0 || pageNum == 1)
addDirtyRect(x, y, w, h);
@@ -1023,7 +998,7 @@ void Screen::copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint
while (h--) {
memcpy(dst, src, w);
- dst += SCREEN_W * _pageScaleFactor[pageNum];
+ dst += SCREEN_W;
src += w;
}
}
@@ -1101,7 +1076,7 @@ void Screen::fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum,
color |= (color << 4);
} else if (_renderMode == Common::kRenderCGA) {
color &= 0x03;
- } else if (_renderMode == Common::kRenderEGA) {
+ } else if (_renderMode == Common::kRenderEGA && !_useHiResEGADithering) {
color &= 0x0F;
}
@@ -1178,7 +1153,7 @@ void Screen::drawLine(bool vertical, int x, int y, int length, int color) {
color |= (color << 4);
} else if (_renderMode == Common::kRenderCGA) {
color &= 0x03;
- } else if (_renderMode == Common::kRenderEGA) {
+ } else if (_renderMode == Common::kRenderEGA && !_useHiResEGADithering) {
color &= 0x0F;
}
@@ -1187,7 +1162,7 @@ void Screen::drawLine(bool vertical, int x, int y, int length, int color) {
int currLine = 0;
while (currLine < length) {
*ptr = color;
- ptr += SCREEN_W * _pageScaleFactor[_curPage];
+ ptr += SCREEN_W;
currLine++;
}
} else {
@@ -1233,7 +1208,8 @@ bool Screen::loadFont(FontId fontId, const char *filename) {
fnt = new AMIGAFont();
#ifdef ENABLE_EOB
else if (_vm->game() == GI_EOB1 || _vm->game() == GI_EOB2)
- fnt = new OldDOSFont(_renderMode, _vm->gameFlags().useHiRes);
+ // We use normal VGA rendering in EOB II, since we do the complete EGA dithering in updateScreen().
+ fnt = new OldDOSFont(_useHiResEGADithering ? Common::kRenderVGA : _renderMode);
#endif // ENABLE_EOB
else
fnt = new DOSFont();
@@ -1272,11 +1248,16 @@ int Screen::getCharWidth(uint16 c) const {
return width + ((_currentFont != FID_SJIS_FNT) ? _charWidth : 0);
}
-int Screen::getTextWidth(const char *str) const {
+int Screen::getTextWidth(const char *str) {
int curLineLen = 0;
int maxLineLen = 0;
+ FontId curFont = _currentFont;
+
while (1) {
+ if (_sjisMixedFontMode)
+ setFont(*str < 0 ? FID_SJIS_FNT : curFont);
+
uint c = fetchChar(str);
if (c == 0) {
@@ -1300,7 +1281,7 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2
cmap[1] = color1;
setTextColor(cmap, 0, 1);
- const uint8 charHeightFnt = getFontHeight();
+ FontId curFont = _currentFont;
if (x < 0)
x = 0;
@@ -1314,6 +1295,11 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2
return;
while (1) {
+ if (_sjisMixedFontMode)
+ setFont(*str < 0 ? FID_SJIS_FNT : curFont);
+
+ uint8 charHeightFnt = getFontHeight();
+
uint c = fetchChar(str);
if (c == 0) {
@@ -1362,9 +1348,6 @@ void Screen::drawChar(uint16 c, int x, int y) {
if (x + charWidth > SCREEN_W || y + charHeight > SCREEN_H)
return;
- x *= _pageScaleFactor[_curPage];
- y *= _pageScaleFactor[_curPage];
-
if (useOverlay) {
uint8 *destPage = getOverlayPtr(_curPage);
if (!destPage) {
@@ -1376,11 +1359,11 @@ void Screen::drawChar(uint16 c, int x, int y) {
fnt->drawChar(c, destPage, 640);
} else {
- fnt->drawChar(c, getPagePtr(_curPage) + y * SCREEN_W * _pageScaleFactor[_curPage] + x, SCREEN_W * _pageScaleFactor[_curPage]);
+ fnt->drawChar(c, getPagePtr(_curPage) + y * SCREEN_W + x, SCREEN_W);
}
if (_curPage == 0 || _curPage == 1)
- addDirtyRect(x, y, charWidth * _pageScaleFactor[_curPage], charHeight * _pageScaleFactor[_curPage]);
+ addDirtyRect(x, y, charWidth, charHeight);
}
void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int sd, int flags, ...) {
@@ -1519,7 +1502,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int
int scaleCounterV = 0;
- const int drawFunc = flags & 0x0f;
+ const int drawFunc = flags & 0x0F;
_dsProcessMargin = dsMarginFunc[drawFunc];
_dsScaleSkip = dsSkipFunc[drawFunc];
_dsProcessLine = dsLineFunc[drawFunc];
@@ -1776,7 +1759,7 @@ int Screen::drawShapeMarginScaleUpwind(uint8 *&dst, const uint8 *&src, int &cnt)
_dsTmpWidth += cnt;
int i = (_dsOffscreenLeft - cnt) * _dsScaleW;
- int res = i & 0xff;
+ int res = i & 0xFF;
i >>= 8;
i -= _dsOffscreenScaleVal2;
dst += i;
@@ -1802,7 +1785,7 @@ int Screen::drawShapeMarginScaleDownwind(uint8 *&dst, const uint8 *&src, int &cn
_dsTmpWidth += cnt;
int i = (_dsOffscreenLeft - cnt) * _dsScaleW;
- int res = i & 0xff;
+ int res = i & 0xFF;
i >>= 8;
i -= _dsOffscreenScaleVal2;
dst -= i;
@@ -1891,7 +1874,7 @@ void Screen::drawShapeProcessLineScaleUpwind(uint8 *&dst, const uint8 *&src, int
int r = c * _dsScaleW + scaleState;
dst += (r >> 8);
cnt -= (r >> 8);
- scaleState = r & 0xff;
+ scaleState = r & 0xFF;
}
} else if (scaleState) {
(this->*_dsPlot)(dst++, c);
@@ -1919,7 +1902,7 @@ void Screen::drawShapeProcessLineScaleDownwind(uint8 *&dst, const uint8 *&src, i
int r = c * _dsScaleW + scaleState;
dst -= (r >> 8);
cnt -= (r >> 8);
- scaleState = r & 0xff;
+ scaleState = r & 0xFF;
}
} else {
(this->*_dsPlot)(dst--, c);
@@ -1967,9 +1950,9 @@ void Screen::drawShapePlotType5(uint8 *dst, uint8 cmd) {
void Screen::drawShapePlotType6(uint8 *dst, uint8 cmd) {
int t = _drawShapeVar4 + _drawShapeVar5;
- if (t & 0xff00) {
+ if (t & 0xFF00) {
cmd = dst[_drawShapeVar3];
- t &= 0xff;
+ t &= 0xFF;
} else {
cmd = _dsTable2[cmd];
}
@@ -1980,7 +1963,7 @@ void Screen::drawShapePlotType6(uint8 *dst, uint8 cmd) {
void Screen::drawShapePlotType8(uint8 *dst, uint8 cmd) {
uint32 relOffs = dst - _dsDstPage;
- int t = (_shapePages[0][relOffs] & 0x7f) & 0x87;
+ int t = (_shapePages[0][relOffs] & 0x7F) & 0x87;
if (_dsDrawLayer < t)
cmd = _shapePages[1][relOffs];
@@ -1989,7 +1972,7 @@ void Screen::drawShapePlotType8(uint8 *dst, uint8 cmd) {
void Screen::drawShapePlotType9(uint8 *dst, uint8 cmd) {
uint32 relOffs = dst - _dsDstPage;
- int t = (_shapePages[0][relOffs] & 0x7f) & 0x87;
+ int t = (_shapePages[0][relOffs] & 0x7F) & 0x87;
if (_dsDrawLayer < t) {
cmd = _shapePages[1][relOffs];
} else {
@@ -2003,7 +1986,7 @@ void Screen::drawShapePlotType9(uint8 *dst, uint8 cmd) {
void Screen::drawShapePlotType11_15(uint8 *dst, uint8 cmd) {
uint32 relOffs = dst - _dsDstPage;
- int t = (_shapePages[0][relOffs] & 0x7f) & 0x87;
+ int t = (_shapePages[0][relOffs] & 0x7F) & 0x87;
if (_dsDrawLayer < t) {
cmd = _shapePages[1][relOffs];
@@ -2019,7 +2002,7 @@ void Screen::drawShapePlotType11_15(uint8 *dst, uint8 cmd) {
void Screen::drawShapePlotType12(uint8 *dst, uint8 cmd) {
uint32 relOffs = dst - _dsDstPage;
- int t = (_shapePages[0][relOffs] & 0x7f) & 0x87;
+ int t = (_shapePages[0][relOffs] & 0x7F) & 0x87;
if (_dsDrawLayer < t) {
cmd = _shapePages[1][relOffs];
} else {
@@ -2031,7 +2014,7 @@ void Screen::drawShapePlotType12(uint8 *dst, uint8 cmd) {
void Screen::drawShapePlotType13(uint8 *dst, uint8 cmd) {
uint32 relOffs = dst - _dsDstPage;
- int t = (_shapePages[0][relOffs] & 0x7f) & 0x87;
+ int t = (_shapePages[0][relOffs] & 0x7F) & 0x87;
if (_dsDrawLayer < t) {
cmd = _shapePages[1][relOffs];
} else {
@@ -2046,14 +2029,14 @@ void Screen::drawShapePlotType13(uint8 *dst, uint8 cmd) {
void Screen::drawShapePlotType14(uint8 *dst, uint8 cmd) {
uint32 relOffs = dst - _dsDstPage;
- int t = (_shapePages[0][relOffs] & 0x7f) & 0x87;
+ int t = (_shapePages[0][relOffs] & 0x7F) & 0x87;
if (_dsDrawLayer < t) {
cmd = _shapePages[1][relOffs];
} else {
t = _drawShapeVar4 + _drawShapeVar5;
- if (t & 0xff00) {
+ if (t & 0xFF00) {
cmd = dst[_drawShapeVar3];
- t &= 0xff;
+ t &= 0xFF;
} else {
cmd = _dsTable2[cmd];
}
@@ -2147,7 +2130,7 @@ void Screen::decodeFrame1(const uint8 *src, uint8 *dst, uint32 size) {
uint8 nib = 0;
uint16 code = decodeEGAGetCode(src, nib);
- uint8 last = code & 0xff;
+ uint8 last = code & 0xFF;
uint8 *dstPrev = dst;
uint16 count = 1;
@@ -2160,7 +2143,7 @@ void Screen::decodeFrame1(const uint8 *src, uint8 *dst, uint32 size) {
uint8 cmd = code >> 8;
if (cmd--) {
- code = (cmd << 8) | (code & 0xff);
+ code = (cmd << 8) | (code & 0xFF);
uint8 *tmpDst = dst;
if (code < numPatterns) {
@@ -2188,7 +2171,7 @@ void Screen::decodeFrame1(const uint8 *src, uint8 *dst, uint32 size) {
count = countPrev;
} else {
- *dst++ = last = (code & 0xff);
+ *dst++ = last = (code & 0xFF);
if (numPatterns < 3840) {
patterns[numPatterns].pos = dstPrev;
@@ -2209,7 +2192,7 @@ uint16 Screen::decodeEGAGetCode(const uint8 *&pos, uint8 &nib) {
res >>= 4;
} else {
pos++;
- res &= 0xfff;
+ res &= 0xFFF;
}
return res;
}
@@ -2891,8 +2874,6 @@ void Screen::setShapePages(int page1, int page2, int minY, int maxY) {
void Screen::setMouseCursor(int x, int y, const byte *shape) {
if (!shape)
return;
- // if mouseDisabled
- // return _mouseShape
if (_vm->gameFlags().useAltShapeHeader)
shape += 2;
@@ -3215,7 +3196,7 @@ void Screen::addDirtyRect(int x, int y, int w, int h) {
Common::Rect r(x, y, x + w, y + h);
// Clip rectangle
- r.clip(SCREEN_W * _pageScaleFactor[0], SCREEN_H * _pageScaleFactor[0]);
+ r.clip(SCREEN_W, SCREEN_H);
// If it is empty after clipping, we are done
if (r.isEmpty())
@@ -3322,8 +3303,6 @@ void Screen::crossFadeRegion(int x1, int y1, int x2, int y2, int w, int h, int s
if (srcPage > 13 || dstPage > 13)
error("Screen::crossFadeRegion(): attempting to use temp page as source or dest page.");
- assert(_pageScaleFactor[srcPage] == _pageScaleFactor[dstPage]);
-
hideMouse();
uint16 *wB = (uint16 *)_pagePtrs[14];
@@ -3341,6 +3320,9 @@ void Screen::crossFadeRegion(int x1, int y1, int x2, int y2, int w, int h, int s
for (int i = 0; i < h; i++)
SWAP(hB[_vm->_rnd.getRandomNumberRng(0, h - 1)], hB[i]);
+ uint8 *s = _pagePtrs[srcPage];
+ uint8 *d = _pagePtrs[dstPage];
+
for (int i = 0; i < h; i++) {
int iH = i;
uint32 end = _system->getMillis() + 3;
@@ -3353,7 +3335,8 @@ void Screen::crossFadeRegion(int x1, int y1, int x2, int y2, int w, int h, int s
if (++iH >= h)
iH = 0;
- setPagePixel(dstPage, dX, dY, getPagePixel(srcPage, sX, sY));
+ d[dY * 320 + dX] = s[sY * 320 + sX];
+ addDirtyRect(dX, dY, 1, 1);
}
// This tries to speed things up, to get similiar speeds as in DOSBox etc.
@@ -3595,11 +3578,11 @@ void AMIGAFont::unload() {
memset(_chars, 0, sizeof(_chars));
}
-SJISFont::SJISFont(Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color, bool outlineSize)
- : _colorMap(0), _font(font), _invisColor(invisColor), _is16Color(is16Color) {
+SJISFont::SJISFont(Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color, bool drawOutline, int extraSpacing)
+ : _colorMap(0), _font(font), _invisColor(invisColor), _is16Color(is16Color), _drawOutline(drawOutline), _sjisWidthOffset(extraSpacing) {
assert(_font);
- _font->setDrawingMode(outlineSize ? Graphics::FontSJIS::kOutlineMode : Graphics::FontSJIS::kDefaultMode);
+ _font->setDrawingMode(_drawOutline ? Graphics::FontSJIS::kOutlineMode : Graphics::FontSJIS::kDefaultMode);
_sjisWidth = _font->getMaxFontWidth() >> 1;
_fontHeight = _font->getFontHeight() >> 1;
@@ -3616,14 +3599,14 @@ int SJISFont::getHeight() const {
}
int SJISFont::getWidth() const {
- return _sjisWidth;
+ return _sjisWidth + _sjisWidthOffset;
}
int SJISFont::getCharWidth(uint16 c) const {
if (c <= 0x7F || (c >= 0xA1 && c <= 0xDF))
return _asciiWidth;
else
- return _sjisWidth;
+ return _sjisWidth + _sjisWidthOffset;
}
void SJISFont::setColorMap(const uint8 *src) {
@@ -3633,7 +3616,7 @@ void SJISFont::setColorMap(const uint8 *src) {
if (_colorMap[0] == _invisColor)
_font->setDrawingMode(Graphics::FontSJIS::kDefaultMode);
else
- _font->setDrawingMode(Graphics::FontSJIS::kOutlineMode);
+ _font->setDrawingMode(_drawOutline ? Graphics::FontSJIS::kOutlineMode : Graphics::FontSJIS::kDefaultMode);
}
}
@@ -3672,7 +3655,7 @@ void Palette::loadVGAPalette(Common::ReadStream &stream, int startIndex, int col
uint8 *pos = _palData + startIndex * 3;
for (int i = 0 ; i < colors * 3; i++)
- *pos++ = stream.readByte() & 0x3f;
+ *pos++ = stream.readByte() & 0x3F;
}
void Palette::loadEGAPalette(Common::ReadStream &stream, int startIndex, int colors) {
diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h
index 60bfeb3241..156b5b9a7c 100644
--- a/engines/kyra/screen.h
+++ b/engines/kyra/screen.h
@@ -146,7 +146,7 @@ private:
*/
class OldDOSFont : public Font {
public:
- OldDOSFont(Common::RenderMode mode, bool useHiResEGADithering);
+ OldDOSFont(Common::RenderMode mode);
~OldDOSFont();
bool load(Common::SeekableReadStream &file);
@@ -168,8 +168,6 @@ private:
int _numGlyphs;
Common::RenderMode _renderMode;
- bool _useHiResEGADithering;
- bool _useLoResEGA;
static uint16 *_cgaDitheringTable;
static int _numRef;
@@ -213,7 +211,7 @@ private:
*/
class SJISFont : public Font {
public:
- SJISFont(Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color, bool outlineSize);
+ SJISFont(Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color, bool drawOutline, int extraSpacing);
~SJISFont() { unload(); }
bool usesOverlay() const { return true; }
@@ -232,6 +230,12 @@ private:
Graphics::FontSJIS *_font;
const uint8 _invisColor;
const bool _is16Color;
+ const bool _drawOutline;
+ // We use this for cases where the font width returned by getWidth() or getCharWidth() does not match the original.
+ // The original Japanese game versions use hard coded sjis font widths of 8 or 9. However, this does not necessarily
+ // depend on whether an outline is used or not (neither LOL/PC-9801 nor LOL/FM-TOWNS use an outline, but the first
+ // version uses a font width of 8 where the latter uses a font width of 9).
+ const int _sjisWidthOffset;
int _sjisWidth, _asciiWidth;
int _fontHeight;
@@ -426,12 +430,12 @@ public:
void copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint8 *src);
void shuffleScreen(int sx, int sy, int w, int h, int srcPage, int dstPage, int ticks, bool transparent);
- virtual void fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum = -1, bool xored = false);
+ void fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum = -1, bool xored = false);
void clearPage(int pageNum);
- virtual uint8 getPagePixel(int pageNum, int x, int y);
- virtual void setPagePixel(int pageNum, int x, int y, uint8 color);
+ uint8 getPagePixel(int pageNum, int x, int y);
+ void setPagePixel(int pageNum, int x, int y, uint8 color);
const uint8 *getCPagePtr(int pageNum) const;
uint8 *getPageRect(int pageNum, int x, int y, int w, int h);
@@ -457,7 +461,7 @@ public:
void copyPalette(const int dst, const int src);
// gui specific (processing on _curPage)
- virtual void drawLine(bool vertical, int x, int y, int length, int color);
+ void drawLine(bool vertical, int x, int y, int length, int color);
void drawClippedLine(int x1, int y1, int x2, int y2, int color);
virtual void drawShadedBox(int x1, int y1, int x2, int y2, int color1, int color2);
void drawBox(int x1, int y1, int x2, int y2, int color);
@@ -470,9 +474,9 @@ public:
int getFontWidth() const;
int getCharWidth(uint16 c) const;
- int getTextWidth(const char *str) const;
+ int getTextWidth(const char *str);
- virtual void printText(const char *str, int x, int y, uint8 color1, uint8 color2);
+ void printText(const char *str, int x, int y, uint8 color1, uint8 color2);
virtual void setTextColorMap(const uint8 *cmap) = 0;
void setTextColor(const uint8 *cmap, int a, int b);
@@ -549,7 +553,7 @@ public:
protected:
uint8 *getPagePtr(int pageNum);
- void updateDirtyRects();
+ virtual void updateDirtyRects();
void updateDirtyRectsAmiga();
void updateDirtyRectsOvl();
@@ -573,18 +577,17 @@ protected:
uint8 *_pagePtrs[16];
uint8 *_sjisOverlayPtrs[SCREEN_OVLS_NUM];
- uint8 _pageScaleFactor[SCREEN_PAGE_NUM];
uint8 _pageMapping[SCREEN_PAGE_NUM];
bool _useOverlays;
bool _useSJIS;
bool _use16ColorMode;
bool _useHiResEGADithering;
- bool _useLoResEGA;
bool _isAmiga;
Common::RenderMode _renderMode;
uint8 _sjisInvisibleColor;
+ bool _sjisMixedFontMode;
Palette *_screenPalette;
Common::Array<Palette *> _palettes;
@@ -600,7 +603,7 @@ protected:
int _animBlockSize;
// dimension handling
- const ScreenDim * const _dimTable;
+ const ScreenDim *const _dimTable;
ScreenDim **_customDimTable;
const int _dimTableCount;
int _curDimIndex;
diff --git a/engines/kyra/screen_eob.cpp b/engines/kyra/screen_eob.cpp
index ae75c111b4..ae62e522e7 100644
--- a/engines/kyra/screen_eob.cpp
+++ b/engines/kyra/screen_eob.cpp
@@ -52,10 +52,10 @@ Screen_EoB::Screen_EoB(EoBCoreEngine *vm, OSystem *system) : Screen(vm, system,
_cgaScaleTable = 0;
_gfxMaxY = 0;
_egaDitheringTable = 0;
- _egaPixelValueTable = 0;
+ _egaDitheringTempPage = 0;
_cgaMappingDefault = 0;
_cgaDitheringTables[0] = _cgaDitheringTables[1] = 0;
- _useLoResEGA = _useHiResEGADithering = false;
+ _useHiResEGADithering = false;
}
Screen_EoB::~Screen_EoB() {
@@ -63,18 +63,12 @@ Screen_EoB::~Screen_EoB() {
delete[] _dsTempPage;
delete[] _cgaScaleTable;
delete[] _egaDitheringTable;
- delete[] _egaPixelValueTable;
+ delete[] _egaDitheringTempPage;
delete[] _cgaDitheringTables[0];
delete[] _cgaDitheringTables[1];
}
bool Screen_EoB::init() {
- // Define hi-res pages for EGA mode in EOB II
- if (_vm->gameFlags().useHiRes) {
- for (int i = 0; i < 8; i++)
- _pageScaleFactor[i] = 2;
- }
-
if (Screen::init()) {
int temp;
_gfxMaxY = _vm->staticres()->loadRawData(kEoBBaseExpObjectY, temp);
@@ -98,13 +92,9 @@ bool Screen_EoB::init() {
if (_vm->gameFlags().useHiRes && _renderMode == Common::kRenderEGA) {
_useHiResEGADithering = true;
_egaDitheringTable = new uint8[256];
- _egaPixelValueTable = new uint8[256];
- for (int i = 0; i < 256; i++) {
- _egaDitheringTable[i] = i & 0x0f;
- _egaPixelValueTable[i] = i & 0x0f;
- }
- } else if (_renderMode == Common::kRenderEGA) {
- _useLoResEGA = true;
+ _egaDitheringTempPage = new uint8[SCREEN_W * 2 * SCREEN_H * 2];
+ for (int i = 0; i < 256; i++)
+ _egaDitheringTable[i] = i & 0x0F;
} else if (_renderMode == Common::kRenderCGA) {
_cgaMappingDefault = _vm->staticres()->loadRawData(kEoB1CgaMappingDefault, temp);
_cgaDitheringTables[0] = new uint16[256];
@@ -115,7 +105,7 @@ bool Screen_EoB::init() {
_cgaScaleTable = new uint8[256];
memset(_cgaScaleTable, 0, 256 * sizeof(uint8));
for (int i = 0; i < 256; i++)
- _cgaScaleTable[i] = ((i & 0xf0) >> 2) | (i & 0x03);
+ _cgaScaleTable[i] = ((i & 0xF0) >> 2) | (i & 0x03);
}
return true;
@@ -144,14 +134,20 @@ void Screen_EoB::setMouseCursor(int x, int y, const byte *shape, const uint8 *ov
int mouseH = (shape[3]);
int colorKey = (_renderMode == Common::kRenderCGA) ? 0 : _cursorColorKey;
- uint8 *cursor = new uint8[mouseW * _pageScaleFactor[6] * mouseH * _pageScaleFactor[6]];
+ int scaleFactor = _useHiResEGADithering ? 2 : 1;
+
+ uint8 *cursor = new uint8[mouseW * scaleFactor * mouseH * scaleFactor];
// We use memset and copyBlockToPage instead of fillRect to make sure that the
// color key 0xFF doesn't get converted into EGA color
- memset(cursor, colorKey, mouseW * _pageScaleFactor[6] * mouseH * _pageScaleFactor[6]);
- copyBlockToPage(6, 0, 0, mouseW, mouseH, cursor);
+ memset(cursor, colorKey, mouseW * scaleFactor * mouseH * scaleFactor);
+ copyBlockToPage(6, 0, 0, mouseW * scaleFactor, mouseH * scaleFactor, cursor);
drawShape(6, shape, 0, 0, 0, 2, ovl);
CursorMan.showMouse(false);
- copyRegionToBuffer(6, 0, 0, mouseW, mouseH, cursor);
+
+ if (_useHiResEGADithering)
+ ditherRect(getCPagePtr(6), cursor, mouseW * scaleFactor, mouseW, mouseH, colorKey);
+ else
+ copyRegionToBuffer(6, 0, 0, mouseW, mouseH, cursor);
// Mouse cursor post processing for CGA mode. Unlike the original (which uses drawShape for the mouse cursor)
// the cursor manager cannot know whether a pixel value of 0 is supposed to be black or transparent. Thus, we
@@ -176,7 +172,7 @@ void Screen_EoB::setMouseCursor(int x, int y, const byte *shape, const uint8 *ov
}
}
- CursorMan.replaceCursor(cursor, mouseW * _pageScaleFactor[6], mouseH * _pageScaleFactor[6], x, y, colorKey);
+ CursorMan.replaceCursor(cursor, mouseW * scaleFactor, mouseH * scaleFactor, x, y, colorKey);
if (isMouseVisible())
CursorMan.showMouse(true);
delete[] cursor;
@@ -192,19 +188,6 @@ void Screen_EoB::loadFileDataToPage(Common::SeekableReadStream *s, int pageNum,
s->read(_pagePtrs[pageNum], size);
}
-void Screen_EoB::printText(const char *str, int x, int y, uint8 color1, uint8 color2) {
- if (_useHiResEGADithering) {
- // This is sort of an abuse of the text color map. But since EOB doesn't use it anyway
- // and the font drawing code needs access to both the original color values and the
- // EGA dithering colors we pass them on like this.
- uint8 cmap[2];
- cmap[0] = _egaDitheringTable[color2];
- cmap[1] = _egaDitheringTable[color1];
- setTextColor(cmap, 2, 3);
- }
- Screen::printText(str, x, y, color1, color2);
-}
-
void Screen_EoB::printShadedText(const char *string, int x, int y, int col1, int col2) {
printText(string, x - 1, y, 12, col2);
printText(string, x, y + 1, 12, 0);
@@ -272,32 +255,19 @@ void Screen_EoB::convertPage(int srcPage, int dstPage, const uint8 *cgaMapping)
if (cgaMapping)
generateCGADitheringTables(cgaMapping);
- uint16 *d = (uint16*)dst;
+ uint16 *d = (uint16 *)dst;
uint8 tblSwitch = 0;
for (int height = SCREEN_H; height; height--) {
const uint16 *table = _cgaDitheringTables[(tblSwitch++) & 1];
for (int width = SCREEN_W / 2; width; width--) {
- WRITE_LE_UINT16(d++, table[((src[1] & 0x0f) << 4) | (src[0] & 0x0f)]);
+ WRITE_LE_UINT16(d++, table[((src[1] & 0x0F) << 4) | (src[0] & 0x0F)]);
src += 2;
}
}
-
- } else if (_useHiResEGADithering) {
- for (int height = SCREEN_H; height; height--) {
- uint8 *dst2 = dst + SCREEN_W * 2;
- for (int width = SCREEN_W; width; width--) {
- uint8 in = _egaDitheringTable[*src++];
- *dst++ = *dst2++ = in >> 4;
- *dst++ = *dst2++ = in & 0x0f;
- }
- dst += (SCREEN_W * 2);
- }
-
- } else if (_renderMode == Common::kRenderEGA) {
+ } else if (_renderMode == Common::kRenderEGA && !_useHiResEGADithering) {
uint32 len = SCREEN_W * SCREEN_H;
while (len--)
- *dst++ = *src++ & 0x0f;
-
+ *dst++ = *src++ & 0x0F;
} else {
copyPage(srcPage, dstPage);
}
@@ -306,111 +276,6 @@ void Screen_EoB::convertPage(int srcPage, int dstPage, const uint8 *cgaMapping)
_forceFullUpdate = true;
}
-void Screen_EoB::fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum, bool xored) {
- if (!_useHiResEGADithering) {
- Screen::fillRect(x1, y1, x2, y2, color, pageNum, xored);
- return;
- }
-
- assert(x2 < SCREEN_W && y2 < SCREEN_H);
- if (pageNum == -1)
- pageNum = _curPage;
-
- uint16 pitch = (SCREEN_W - (x2 - x1 + 1)) * _pageScaleFactor[pageNum];
- uint8 col1 = (_egaDitheringTable[color] >> 4);
- uint8 col2 = (_egaDitheringTable[color] & 0x0f);
-
- x1 *= _pageScaleFactor[pageNum];
- y1 *= _pageScaleFactor[pageNum];
- x2 *= _pageScaleFactor[pageNum];
- y2 *= _pageScaleFactor[pageNum];
- uint16 w = x2 - x1 + _pageScaleFactor[pageNum];
- uint16 h = y2 - y1 + _pageScaleFactor[pageNum];
-
- uint8 *dst = getPagePtr(pageNum) + y1 * SCREEN_W * _pageScaleFactor[pageNum] + x1;
- if (pageNum == 0 || pageNum == 1)
- addDirtyRect(x1, y1, w, h);
-
- while (h--) {
- for (uint16 w1 = w; w1; w1 -= 2) {
- *dst++ = col1;
- *dst++ = col2;
- }
- dst += pitch;
- }
-}
-
-void Screen_EoB::drawLine(bool vertical, int x, int y, int length, int color) {
- if (!_useHiResEGADithering) {
- Screen::drawLine(vertical, x, y, length, color);
- return;
- }
-
- uint16 pitch = (SCREEN_W - 1) * _pageScaleFactor[_curPage];
- uint8 col1 = (_egaDitheringTable[color] >> 4);
- uint8 col2 = (_egaDitheringTable[color] & 0x0f);
-
- x *= _pageScaleFactor[_curPage];
- y *= _pageScaleFactor[_curPage];
- length *= _pageScaleFactor[_curPage];
- uint8 *ptr = getPagePtr(_curPage) + y * SCREEN_W * _pageScaleFactor[_curPage] + x;
- uint8 *ptr2 = ptr + SCREEN_W * _pageScaleFactor[_curPage];
-
- if (vertical) {
- assert((y + length) <= SCREEN_H * _pageScaleFactor[_curPage]);
- int currLine = 0;
- while (currLine < length) {
- *ptr++ = col1;
- *ptr++ = col2;
- ptr += pitch;
- currLine++;
- }
- } else {
- assert((x + length) <= SCREEN_W * _pageScaleFactor[_curPage]);
- int currLine = 0;
- while (currLine < length) {
- *ptr++ = *ptr2++ = col1;
- *ptr++ = *ptr2++ = col2;
- currLine += 2;
- }
- }
-
- if (_curPage == 0 || _curPage == 1)
- addDirtyRect(x, y, (vertical) ? _pageScaleFactor[_curPage] : length, (vertical) ? length : _pageScaleFactor[_curPage]);
-}
-
-uint8 Screen_EoB::getPagePixel(int pageNum, int x, int y) {
- if (!_useHiResEGADithering)
- return Screen::getPagePixel(pageNum, x, y);
-
- x *= _pageScaleFactor[_curPage];
- y *= _pageScaleFactor[_curPage];
- uint8 *pos = &_pagePtrs[pageNum][y * SCREEN_W * _pageScaleFactor[_curPage] + x];
-
- return _egaPixelValueTable[(pos[0] << 4) | (pos[1] & 0x0f)];
-}
-
-void Screen_EoB::setPagePixel(int pageNum, int x, int y, uint8 color) {
- if (!_useHiResEGADithering) {
- Screen::setPagePixel(pageNum, x, y, color);
- return;
- }
-
- assert(pageNum < SCREEN_PAGE_NUM);
- assert(x >= 0 && x < SCREEN_W && y >= 0 && y < SCREEN_H);
-
- x *= _pageScaleFactor[_curPage];
- y *= _pageScaleFactor[_curPage];
-
- if (pageNum == 0 || pageNum == 1)
- addDirtyRect(x, y, _pageScaleFactor[pageNum], _pageScaleFactor[pageNum]);
-
- uint8 *pos = &_pagePtrs[pageNum][y * SCREEN_W * _pageScaleFactor[_curPage] + x];
- uint8 *pos2 = pos + SCREEN_W * _pageScaleFactor[_curPage];
- pos[0] = pos2[0] = _egaDitheringTable[color] >> 4;
- pos[1] = pos2[1] = _egaDitheringTable[color] & 0x0f;
-}
-
void Screen_EoB::setScreenPalette(const Palette &pal) {
if (_useHiResEGADithering && pal.getNumColors() != 16) {
generateEGADitheringTable(pal);
@@ -444,7 +309,7 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco
uint8 *srcLineStart = getPagePtr(_curPage | 1) + y * 320 + (x << 3);
uint8 *src = srcLineStart;
- if (_useLoResEGA)
+ if (_renderMode == Common::kRenderEGA && !_useHiResEGADithering)
encode8bit = false;
if (_renderMode == Common::kRenderCGA) {
@@ -456,9 +321,9 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco
uint8 *dst = shp;
*dst++ = 4;
- *dst++ = (h & 0xff);
- *dst++ = (w & 0xff);
- *dst++ = (h & 0xff);
+ *dst++ = (h & 0xFF);
+ *dst++ = (w & 0xFF);
+ *dst++ = (h & 0xFF);
uint8 *dst2 = dst + (h * (w << 1));
@@ -469,8 +334,8 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco
const uint16 *table = _cgaDitheringTables[(tblSwitch++) & 1];
while (w1--) {
- uint16 p0 = table[((src[1] & 0x0f) << 4) | (src[0] & 0x0f)];
- uint16 p1 = table[((src[3] & 0x0f) << 4) | (src[2] & 0x0f)];
+ uint16 p0 = table[((src[1] & 0x0F) << 4) | (src[0] & 0x0F)];
+ uint16 p1 = table[((src[3] & 0x0F) << 4) | (src[2] & 0x0F)];
*dst++ = ((p0 & 0x0003) << 6) | ((p0 & 0x0300) >> 4) | ((p1 & 0x0003) << 2) | ((p1 & 0x0300) >> 8);
@@ -515,9 +380,9 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco
uint8 *dst = shp;
*dst++ = 8;
- *dst++ = (h & 0xff);
- *dst++ = (w & 0xff);
- *dst++ = (h & 0xff);
+ *dst++ = (h & 0xFF);
+ *dst++ = (w & 0xFF);
+ *dst++ = (h & 0xFF);
srcLineStart = getPagePtr(_curPage | 1) + y * 320 + (x << 3);
src = srcLineStart;
@@ -540,7 +405,7 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco
*dst++ = 0;
numZero -= 255;
}
- val = numZero & 0xff;
+ val = numZero & 0xFF;
}
*dst++ = val;
} while (src != lineEnd);
@@ -555,7 +420,7 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco
if (_renderMode != Common::kRenderEGA || _useHiResEGADithering) {
colorMap = new uint8[0x100];
- memset(colorMap, 0xff, 0x100);
+ memset(colorMap, 0xFF, 0x100);
}
shapesize = h * (w << 2) + 20;
@@ -564,15 +429,15 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco
uint8 *dst = shp;
*dst++ = 2;
- *dst++ = (h & 0xff);
- *dst++ = (w & 0xff);
- *dst++ = (h & 0xff);
+ *dst++ = (h & 0xFF);
+ *dst++ = (w & 0xFF);
+ *dst++ = (h & 0xFF);
- if (_useLoResEGA) {
+ if (_renderMode != Common::kRenderEGA || _useHiResEGADithering) {
+ memset(dst, 0xFF, 0x10);
+ } else {
for (int i = 0; i < 16; i++)
dst[i] = i;
- } else {
- memset(dst, 0xff, 0x10);
}
uint8 *pal = dst;
@@ -584,15 +449,13 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco
uint16 w1 = w << 3;
while (w1--) {
uint8 s = *src++;
- uint8 c = s & 0x0f;
+ uint8 c = s & 0x0F;
if (colorMap) {
c = colorMap[s];
- if (c == 0xff) {
+ if (c == 0xFF) {
if (col < 0x10) {
*pal++ = s;
c = colorMap[s] = col++;
- if (!col)
- c = 0;
} else {
c = 0;
}
@@ -632,7 +495,7 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y,
y += _dsY1;
}
- dst += (_dsX1 << 3) * _pageScaleFactor[pageNum];
+ dst += (_dsX1 << 3);
int16 dX = x - (_dsX1 << 3);
int16 dY = y;
int16 dW = _dsX2 - _dsX1;
@@ -704,11 +567,11 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y,
marginRight = w2 - marginLeft - width;
}
- dst += (dY * SCREEN_W * _pageScaleFactor[pageNum] * _pageScaleFactor[pageNum] + dX * _pageScaleFactor[pageNum]);
+ dst += (dY * SCREEN_W + dX);
uint8 *dstL = dst;
if (pageNum == 0 || pageNum == 1)
- addDirtyRect(rX * _pageScaleFactor[pageNum], rY * _pageScaleFactor[pageNum], rW * _pageScaleFactor[pageNum], rH * _pageScaleFactor[pageNum]);
+ addDirtyRect(rX, rY, rW, rH);
while (dH--) {
int16 xpos = (int16) marginLeft;
@@ -743,7 +606,7 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y,
} while (xpos > 0);
}
- dst -= (xpos * _pageScaleFactor[pageNum]);
+ dst -= xpos;
xpos += width;
while (xpos > 0) {
@@ -752,12 +615,12 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y,
src += pixelStep;
if (m) {
- drawShapeSetPixel(dst, c, SCREEN_W * _pageScaleFactor[pageNum]);
- dst += _pageScaleFactor[pageNum];
+ drawShapeSetPixel(dst, c);
+ dst++;
xpos--;
} else {
uint8 len = (flags & 1) ? src[1] : src[0];
- dst += (len * _pageScaleFactor[pageNum]);
+ dst += len;
xpos -= len;
src += pixelStep;
}
@@ -783,7 +646,7 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y,
} while (xpos > 0);
}
- dstL += SCREEN_W * _pageScaleFactor[pageNum] * _pageScaleFactor[pageNum];
+ dstL += SCREEN_W;
dst = dstL;
if (flags & 1)
src = src2 + 1;
@@ -797,7 +660,7 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y,
pal = ovl ? ovl : src;
src += 16;
} else {
- static const uint8 cgaDefOvl[] = { 0x00, 0x55, 0xaa, 0xff };
+ static const uint8 cgaDefOvl[] = { 0x00, 0x55, 0xAA, 0xFF };
pal = ovl ? ovl : cgaDefOvl;
for (int i = 0; i < 4; i++)
cgaPal[i] = pal[i] & 3;
@@ -851,12 +714,12 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y,
if (d < width)
width = d;
- dst += (dY * _pageScaleFactor[pageNum] * SCREEN_W * _pageScaleFactor[pageNum] + dX * _pageScaleFactor[pageNum]);
+ dst += (dY * SCREEN_W + dX);
if (pageNum == 0 || pageNum == 1)
- addDirtyRect(rX * _pageScaleFactor[pageNum], rY * _pageScaleFactor[pageNum], rW * _pageScaleFactor[pageNum], rH * _pageScaleFactor[pageNum]);
+ addDirtyRect(rX, rY, rW, rH);
- int pitch = SCREEN_W * _pageScaleFactor[pageNum] * _pageScaleFactor[pageNum] - width * _pageScaleFactor[pageNum];
+ int pitch = SCREEN_W - width;
int16 lineSrcStep = (w2 - width) / pixelsPerByte;
uint8 lineSrcStepRemainder = (w2 - width) % pixelsPerByte;
@@ -899,8 +762,8 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y,
}
uint8 col = (pixelsPerByte == 2) ? pal[(in >> shift) & pixelPackingMask] : (*dst & ((trans >> shift) & (pixelPackingMask))) | pal[(in >> shift) & pixelPackingMask];
if (col || pixelsPerByte == 4)
- drawShapeSetPixel(dst, col, SCREEN_W * _pageScaleFactor[pageNum]);
- dst += _pageScaleFactor[pageNum];
+ drawShapeSetPixel(dst, col);
+ dst++;
shift = ((shift - (pixelStep * pixelPacking)) & 7);
}
src += lineSrcStep;
@@ -922,7 +785,7 @@ const uint8 *Screen_EoB::scaleShapeStep(const uint8 *shp) {
uint8 *dst = (shp != _dsTempPage) ? _dsTempPage : _dsTempPage + 6000;
uint8 *d = dst;
uint8 pixelsPerByte = *d++ = *shp++;
- assert (pixelsPerByte > 1);
+ assert(pixelsPerByte > 1);
uint16 h = shp[0] + 1;
d[0] = d[2] = (h << 1) / 3;
@@ -952,7 +815,7 @@ const uint8 *Screen_EoB::scaleShapeStep(const uint8 *shp) {
else
i = -i;
- _dsScaleTrans = (i << 4) | (i & 0x0f);
+ _dsScaleTrans = (i << 4) | (i & 0x0F);
for (int ii = 0; ii < 16; ii++)
*d++ = *shp++;
}
@@ -976,7 +839,7 @@ const uint8 *Screen_EoB::scaleShapeStep(const uint8 *shp) {
shp += w2;
}
- return (const uint8*)dst;
+ return (const uint8 *)dst;
}
const uint8 *Screen_EoB::generateShapeOverlay(const uint8 *shp, int paletteOverlayIndex) {
@@ -1328,14 +1191,14 @@ void Screen_EoB::createFadeTable(uint8 *palData, uint8 *dst, uint8 rootColor, ui
for (uint8 i = 1; i; i++) {
uint16 tmp = (uint16)((*src - r) * weight) << 1;
- tr = *src++ - ((tmp >> 8) & 0xff);
+ tr = *src++ - ((tmp >> 8) & 0xFF);
tmp = (uint16)((*src - g) * weight) << 1;
- tg = *src++ - ((tmp >> 8) & 0xff);
+ tg = *src++ - ((tmp >> 8) & 0xFF);
tmp = (uint16)((*src - b) * weight) << 1;
- tb = *src++ - ((tmp >> 8) & 0xff);
+ tb = *src++ - ((tmp >> 8) & 0xFF);
uint8 *d = palData + 3;
- uint16 v = 0xffff;
+ uint16 v = 0xFFFF;
uint8 col = rootColor;
for (uint8 ii = 1; ii; ii++) {
@@ -1367,15 +1230,55 @@ const uint8 *Screen_EoB::getEGADitheringTable() {
return _egaDitheringTable;
}
-void Screen_EoB::drawShapeSetPixel(uint8 *dst, uint8 col, uint16 pitch) {
+void Screen_EoB::updateDirtyRects() {
+ if (!_useHiResEGADithering) {
+ Screen::updateDirtyRects();
+ return;
+ }
+
+ if (_forceFullUpdate) {
+ ditherRect(getCPagePtr(0), _egaDitheringTempPage, SCREEN_W * 2, SCREEN_W, SCREEN_H);
+ _system->copyRectToScreen(_egaDitheringTempPage, SCREEN_W * 2, 0, 0, SCREEN_W * 2, SCREEN_H * 2);
+ } else {
+ const byte *page0 = getCPagePtr(0);
+ Common::List<Common::Rect>::iterator it;
+ for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
+ ditherRect(page0 + it->top * SCREEN_W + it->left, _egaDitheringTempPage, SCREEN_W * 2, it->width(), it->height());
+ _system->copyRectToScreen(_egaDitheringTempPage, SCREEN_W * 2, it->left * 2, it->top * 2, it->width() * 2, it->height() * 2);
+ }
+ }
+ _forceFullUpdate = false;
+ _dirtyRects.clear();
+}
+
+void Screen_EoB::ditherRect(const uint8 *src, uint8 *dst, int dstPitch, int srcW, int srcH, int colorKey) {
+ while (srcH--) {
+ uint8 *dst2 = dst + dstPitch;
+ for (int i = 0; i < srcW; i++) {
+ int in = *src++;
+ if (in != colorKey) {
+ in = _egaDitheringTable[in];
+ *dst++ = *dst2++ = in >> 4;
+ *dst++ = *dst2++ = in & 0x0F;
+ } else {
+ dst[0] = dst[1] = dst2[0] = dst2[1] = colorKey;
+ dst += 2;
+ dst2 += 2;
+ }
+ }
+ src += (SCREEN_W - srcW);
+ dst += ((dstPitch - srcW) * 2);
+ }
+}
+
+void Screen_EoB::drawShapeSetPixel(uint8 *dst, uint8 col) {
if ((_renderMode != Common::kRenderCGA && _renderMode != Common::kRenderEGA) || _useHiResEGADithering) {
if (_shapeFadeMode[0]) {
if (_shapeFadeMode[1]) {
- col = _useHiResEGADithering ? _egaPixelValueTable[(dst[0] << 4) | (dst[1] & 0x0f)] : *dst;
+ col = *dst;
} else {
_shapeFadeInternal &= 7;
- col = _useHiResEGADithering ? _egaPixelValueTable[(dst[_shapeFadeInternal] << 4) | (dst[_shapeFadeInternal + 1] & 0x0f)] : dst[_shapeFadeInternal];
- _shapeFadeInternal++;
+ col = *(dst + _shapeFadeInternal++);
}
}
@@ -1386,21 +1289,15 @@ void Screen_EoB::drawShapeSetPixel(uint8 *dst, uint8 col, uint16 pitch) {
}
}
- if (_useHiResEGADithering) {
- col = _egaDitheringTable[col];
- dst[0] = dst[pitch] = col >> 4;
- dst[1] = dst[pitch + 1] = col & 0x0f;
- } else {
- *dst = col;
- }
+ *dst = col;
}
void Screen_EoB::scaleShapeProcessLine2Bit(uint8 *&shpDst, const uint8 *&shpSrc, uint32 transOffsetDst, uint32 transOffsetSrc) {
for (int i = 0; i < _dsDiv; i++) {
shpDst[0] = (_cgaScaleTable[shpSrc[0]] << 2) | (shpSrc[1] >> 6);
- shpDst[1] = ((shpSrc[1] & 0x0f) << 4) | ((shpSrc[2] >> 2) & 0x0f);
+ shpDst[1] = ((shpSrc[1] & 0x0F) << 4) | ((shpSrc[2] >> 2) & 0x0F);
shpDst[transOffsetDst] = (_cgaScaleTable[shpSrc[transOffsetSrc]] << 2) | (shpSrc[transOffsetSrc + 1] >> 6);
- shpDst[transOffsetDst + 1] = ((shpSrc[transOffsetSrc + 1] & 0x0f) << 4) | ((shpSrc[transOffsetSrc + 2] >> 2) & 0x0f);
+ shpDst[transOffsetDst + 1] = ((shpSrc[transOffsetSrc + 1] & 0x0F) << 4) | ((shpSrc[transOffsetSrc + 2] >> 2) & 0x0F);
shpSrc += 3;
shpDst += 2;
}
@@ -1409,15 +1306,15 @@ void Screen_EoB::scaleShapeProcessLine2Bit(uint8 *&shpDst, const uint8 *&shpSrc,
shpDst[0] = _cgaScaleTable[shpSrc[0]] << 2;
shpDst[1] = 0;
shpDst[transOffsetDst] = (_cgaScaleTable[shpSrc[transOffsetSrc]] << 2) | 3;
- shpDst[transOffsetDst + 1] = 0xff;
+ shpDst[transOffsetDst + 1] = 0xFF;
shpSrc++;
shpDst += 2;
} else if (_dsRem == 2) {
shpDst[0] = (_cgaScaleTable[shpSrc[0]] << 2) | (shpSrc[1] >> 6);
- shpDst[1] = (shpSrc[1] & 0x3f) << 2;
+ shpDst[1] = (shpSrc[1] & 0x3F) << 2;
shpDst[transOffsetDst] = (_cgaScaleTable[shpSrc[transOffsetSrc]] << 2) | (shpSrc[transOffsetSrc + 1] >> 6);
- shpDst[transOffsetDst + 1] = ((shpSrc[transOffsetSrc + 1] & 0x3f) << 2) | 3;
+ shpDst[transOffsetDst + 1] = ((shpSrc[transOffsetSrc + 1] & 0x3F) << 2) | 3;
shpSrc += 2;
shpDst += 2;
}
@@ -1426,7 +1323,7 @@ void Screen_EoB::scaleShapeProcessLine2Bit(uint8 *&shpDst, const uint8 *&shpSrc,
void Screen_EoB::scaleShapeProcessLine4Bit(uint8 *&dst, const uint8 *&src) {
for (int i = 0; i < _dsDiv; i++) {
*dst++ = *src++;
- *dst++ = (READ_BE_UINT16(src) >> 4) & 0xff;
+ *dst++ = (READ_BE_UINT16(src) >> 4) & 0xFF;
src += 2;
}
@@ -1434,7 +1331,7 @@ void Screen_EoB::scaleShapeProcessLine4Bit(uint8 *&dst, const uint8 *&src) {
*dst++ = *src++;
*dst++ = _dsScaleTrans;
} else if (_dsRem == 2) {
- *dst++ = (src[0] & 0xf0) | (src[1] >> 4);
+ *dst++ = (src[0] & 0xF0) | (src[1] >> 4);
src += 2;
*dst++ = _dsScaleTrans;
*dst++ = _dsScaleTrans;
@@ -1463,7 +1360,7 @@ void Screen_EoB::generateEGADitheringTable(const Palette &pal) {
for (int ii = 256; ii; ii--) {
const uint8 *palEntry = _egaMatchTable + (ii - 1) * 3;
- if (*palEntry == 0xff)
+ if (*palEntry == 0xFF)
continue;
int e_r = palEntry[0] - r;
@@ -1479,16 +1376,12 @@ void Screen_EoB::generateEGADitheringTable(const Palette &pal) {
}
*dst++ = col;
}
-
- memset(_egaPixelValueTable, 0, 256);
- for (int i = 0; i < 256; i++)
- _egaPixelValueTable[_egaDitheringTable[i]] = i;
}
void Screen_EoB::generateCGADitheringTables(const uint8 *mappingData) {
for (int i = 0; i < 256; i++) {
- _cgaDitheringTables[0][i] = (mappingData[(i >> 4) + 16] << 8) | mappingData[i & 0x0f];
- _cgaDitheringTables[1][i] = (mappingData[i >> 4] << 8) | mappingData[(i & 0x0f) + 16];
+ _cgaDitheringTables[0][i] = (mappingData[(i >> 4) + 16] << 8) | mappingData[i & 0x0F];
+ _cgaDitheringTables[1][i] = (mappingData[i >> 4] << 8) | mappingData[(i & 0x0F) + 16];
}
}
@@ -1546,11 +1439,10 @@ const uint8 Screen_EoB::_egaMatchTable[] = {
uint16 *OldDOSFont::_cgaDitheringTable = 0;
int OldDOSFont::_numRef = 0;
-OldDOSFont::OldDOSFont(Common::RenderMode mode, bool useHiResEGADithering) : _renderMode(mode), _useHiResEGADithering(useHiResEGADithering) {
+OldDOSFont::OldDOSFont(Common::RenderMode mode) : _renderMode(mode) {
_data = 0;
_width = _height = _numGlyphs = 0;
_bitmapOffsets = 0;
- _useLoResEGA = (_renderMode == Common::kRenderEGA && !_useHiResEGADithering);
_numRef++;
if (!_cgaDitheringTable && _numRef == 1) {
@@ -1615,42 +1507,42 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch) const {
if (_width == 6) {
switch (c) {
case 0x81:
- case 0x9a:
- c = 0x5d;
+ case 0x9A:
+ c = 0x5D;
break;
case 0x84:
- case 0x8e:
- c = 0x5b;
+ case 0x8E:
+ c = 0x5B;
break;
case 0x94:
case 0x99:
c = 0x40;
- case 0xe1:
+ case 0xE1:
// TODO: recheck this: no conversion for 'ß' ?
break;
}
} else if (_width == 8) {
switch (c) {
case 0x81:
- case 0x9a:
- case 0x5d:
- c = 0x1d;
+ case 0x9A:
+ case 0x5D:
+ c = 0x1D;
break;
case 0x84:
- case 0x5b:
- c = 0x1e;
+ case 0x5B:
+ c = 0x1E;
break;
case 0x94:
case 0x40:
- c = 0x1f;
+ c = 0x1F;
break;
- case 0x8e:
- c = 0x1b;
+ case 0x8E:
+ c = 0x1B;
break;
case 0x99:
- c = 0x1c;
+ c = 0x1C;
break;
- case 0xe1:
+ case 0xE1:
c = 0x19;
break;
}
@@ -1662,24 +1554,16 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch) const {
int w = (_width - 1) >> 3;
pitch -= _width;
- if (_useHiResEGADithering)
- pitch *= 2;
-
uint8 color1 = _colorMap[1];
uint8 color2 = _colorMap[0];
- uint8 colEGA11 = _colorMap[3] >> 4;
- uint8 colEGA12 = _colorMap[3] & 0x0f;
- uint8 colEGA21 = _colorMap[2] >> 4;
- uint8 colEGA22 = _colorMap[2] & 0x0f;
-
static const uint16 cgaColorMask[] = { 0, 0x5555, 0xAAAA, 0xFFFF };
uint16 cgaMask1 = cgaColorMask[color1 & 3];
uint16 cgaMask2 = cgaColorMask[color2 & 3];
- if (_renderMode == Common::kRenderCGA || _useLoResEGA) {
- color1 &= 0x0f;
- color2 &= 0x0f;
+ if (_renderMode == Common::kRenderCGA || _renderMode == Common::kRenderEGA) {
+ color1 &= 0x0F;
+ color2 &= 0x0F;
}
int cH = _height;
@@ -1710,7 +1594,7 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch) const {
uint8 sh = 6;
for (int i = 0; i < _width; i++) {
cDst |= ((dst[i] & 3) << sh);
- sh = (sh - 2) & 0x0f;
+ sh = (sh - 2) & 0x0F;
}
uint16 out = (~(cmp1 | cmp2) & cDst) | (cmp1 & cgaMask1) | (cmp2 & cgaMask2);
@@ -1718,7 +1602,7 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch) const {
sh = 6;
for (int i = 0; i < _width; i++) {
*dst++ = (out >> sh) & 3;
- sh = (sh - 2) & 0x0f;
+ sh = (sh - 2) & 0x0F;
}
last = s;
@@ -1734,27 +1618,13 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch) const {
break;
}
- if (_useHiResEGADithering) {
- if (s & i) {
- if (color1) {
- dst[0] = dst2[0] = colEGA11;
- dst[1] = dst2[1] = colEGA12;
- }
- } else if (color2) {
- dst[0] = dst2[0] = colEGA21;
- dst[1] = dst2[1] = colEGA22;
- }
- dst += 2;
- dst2 += 2;
- } else {
- if (s & i) {
- if (color1)
- *dst = color1;
- } else if (color2) {
- *dst = color2;
- }
- dst++;
+ if (s & i) {
+ if (color1)
+ *dst = color1;
+ } else if (color2) {
+ *dst = color2;
}
+ dst++;
}
if (cW)
diff --git a/engines/kyra/screen_eob.h b/engines/kyra/screen_eob.h
index fc40cfe903..934483d146 100644
--- a/engines/kyra/screen_eob.h
+++ b/engines/kyra/screen_eob.h
@@ -45,7 +45,6 @@ public:
void loadFileDataToPage(Common::SeekableReadStream *s, int pageNum, uint32 size);
- void printText(const char *str, int x, int y, uint8 color1, uint8 color2);
void printShadedText(const char *string, int x, int y, int col1, int col2);
void loadEoBBitmap(const char *file, const uint8 *cgaMapping, int tempPage, int destPage, int convertToPage);
@@ -53,11 +52,6 @@ public:
void convertPage(int srcPage, int dstPage, const uint8 *cgaMapping);
- void fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum = -1, bool xored = false);
- void drawLine(bool vertical, int x, int y, int length, int color);
- uint8 getPagePixel(int pageNum, int x, int y);
- void setPagePixel(int pageNum, int x, int y, uint8 color);
-
void setScreenPalette(const Palette &pal);
void getRealPalette(int num, uint8 *dst);
@@ -68,7 +62,7 @@ public:
const uint8 *generateShapeOverlay(const uint8 *shp, int paletteOverlayIndex);
void setShapeFrame(int x1, int y1, int x2, int y2);
- void setShapeFadeMode (uint8 i, bool b);
+ void setShapeFadeMode(uint8 i, bool b);
void setGfxParameters(int x, int y, int col);
void drawExplosion(int scale, int radius, int numElements, int stepSize, int aspectRatio, const uint8 *colorTable, int colorTableSize);
@@ -88,7 +82,10 @@ public:
const uint8 *getEGADitheringTable();
private:
- void drawShapeSetPixel(uint8 *dst, uint8 col, uint16 pitch);
+ void updateDirtyRects();
+ void ditherRect(const uint8 *src, uint8 *dst, int dstPitch, int srcW, int srcH, int colorKey = -1);
+
+ void drawShapeSetPixel(uint8 *dst, uint8 col);
void scaleShapeProcessLine2Bit(uint8 *&shpDst, const uint8 *&shpSrc, uint32 transOffsetDst, uint32 transOffsetSrc);
void scaleShapeProcessLine4Bit(uint8 *&dst, const uint8 *&src);
bool posWithinRect(int posX, int posY, int x1, int y1, int x2, int y2);
@@ -115,14 +112,14 @@ private:
const uint8 *_cgaMappingDefault;
uint8 *_egaDitheringTable;
- uint8 *_egaPixelValueTable;
+ uint8 *_egaDitheringTempPage;
static const uint8 _egaMatchTable[];
static const ScreenDim _screenDimTable[];
static const int _screenDimTableCount;
};
-} // End of namespace Kyra
+} // End of namespace Kyra
#endif // ENABLE_EOB
diff --git a/engines/kyra/screen_hof.cpp b/engines/kyra/screen_hof.cpp
index ac6ee5eb77..b7de7988b8 100644
--- a/engines/kyra/screen_hof.cpp
+++ b/engines/kyra/screen_hof.cpp
@@ -34,16 +34,16 @@ void Screen_HoF::generateGrayOverlay(const Palette &srcPal, uint8 *grayOverlay,
for (int i = 0; i != lastColor; i++) {
if (flag) {
- int v = ((((srcPal[3 * i] & 0x3f) + (srcPal[3 * i + 1] & 0x3f)
- + (srcPal[3 * i + 2] & 0x3f)) / 3) * factor) / 0x40;
- tmpPal[3 * i] = tmpPal[3 * i + 1] = tmpPal[3 * i + 2] = v & 0xff;
+ int v = ((((srcPal[3 * i] & 0x3F) + (srcPal[3 * i + 1] & 0x3F)
+ + (srcPal[3 * i + 2] & 0x3F)) / 3) * factor) / 0x40;
+ tmpPal[3 * i] = tmpPal[3 * i + 1] = tmpPal[3 * i + 2] = v & 0xFF;
} else {
- int v = (((srcPal[3 * i] & 0x3f) * factor) / 0x40) + addR;
- tmpPal[3 * i] = (v > 0x3f) ? 0x3f : v & 0xff;
- v = (((srcPal[3 * i + 1] & 0x3f) * factor) / 0x40) + addG;
- tmpPal[3 * i + 1] = (v > 0x3f) ? 0x3f : v & 0xff;
- v = (((srcPal[3 * i + 2] & 0x3f) * factor) / 0x40) + addB;
- tmpPal[3 * i + 2] = (v > 0x3f) ? 0x3f : v & 0xff;
+ int v = (((srcPal[3 * i] & 0x3F) * factor) / 0x40) + addR;
+ tmpPal[3 * i] = (v > 0x3F) ? 0x3F : v & 0xFF;
+ v = (((srcPal[3 * i + 1] & 0x3F) * factor) / 0x40) + addG;
+ tmpPal[3 * i + 1] = (v > 0x3F) ? 0x3F : v & 0xFF;
+ v = (((srcPal[3 * i + 2] & 0x3F) * factor) / 0x40) + addB;
+ tmpPal[3 * i + 2] = (v > 0x3F) ? 0x3F : v & 0xFF;
}
}
@@ -93,46 +93,4 @@ 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;
- 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;
- }
-}
-
} // End of namespace Kyra
diff --git a/engines/kyra/screen_hof.h b/engines/kyra/screen_hof.h
index 51c6a001fa..95f461677d 100644
--- a/engines/kyra/screen_hof.h
+++ b/engines/kyra/screen_hof.h
@@ -37,8 +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;
diff --git a/engines/kyra/screen_lol.cpp b/engines/kyra/screen_lol.cpp
index 3726b1f4b9..16a77c8fcb 100644
--- a/engines/kyra/screen_lol.cpp
+++ b/engines/kyra/screen_lol.cpp
@@ -133,12 +133,12 @@ void Screen_LoL::generateGrayOverlay(const Palette &srcPal, uint8 *grayOverlay,
Palette tmpPal(lastColor);
for (int i = 0; i != lastColor; i++) {
- int v = (((srcPal[3 * i] & 0x3f) * factor) / 0x40) + addR;
- tmpPal[3 * i] = (v > 0x3f) ? 0x3f : v & 0xff;
- v = (((srcPal[3 * i + 1] & 0x3f) * factor) / 0x40) + addG;
- tmpPal[3 * i + 1] = (v > 0x3f) ? 0x3f : v & 0xff;
- v = (((srcPal[3 * i + 2] & 0x3f) * factor) / 0x40) + addB;
- tmpPal[3 * i + 2] = (v > 0x3f) ? 0x3f : v & 0xff;
+ int v = (((srcPal[3 * i] & 0x3F) * factor) / 0x40) + addR;
+ tmpPal[3 * i] = (v > 0x3F) ? 0x3F : v & 0xFF;
+ v = (((srcPal[3 * i + 1] & 0x3F) * factor) / 0x40) + addG;
+ tmpPal[3 * i + 1] = (v > 0x3F) ? 0x3F : v & 0xFF;
+ v = (((srcPal[3 * i + 2] & 0x3F) * factor) / 0x40) + addB;
+ tmpPal[3 * i + 2] = (v > 0x3F) ? 0x3F : v & 0xFF;
}
for (int i = 0; i < lastColor; i++)
@@ -149,7 +149,7 @@ void Screen_LoL::createTransparencyTablesIntern(const uint8 *ovl, int a, const u
Palette screenPal(256);
screenPal.copy(fxPal2, 0, 256);
- memset(outTable1, 0xff, 256);
+ memset(outTable1, 0xFF, 256);
for (int i = 0; i < a; i++)
outTable1[ovl[i]] = i;
@@ -233,8 +233,6 @@ void Screen_LoL::drawGridBox(int x, int y, int w, int h, int col) {
*(p + tmp) = col;
p += 2;
}
- } else {
- w = 1;
}
if (s == 1) {
@@ -270,7 +268,7 @@ void Screen_LoL::fadeClearSceneWindow(int delay) {
void Screen_LoL::backupSceneWindow(int srcPageNum, int dstPageNum) {
uint8 *src = getPagePtr(srcPageNum) + 112;
- uint8 *dst = getPagePtr(dstPageNum) + 0xa500;
+ uint8 *dst = getPagePtr(dstPageNum) + 0xA500;
for (int h = 0; h < 120; h++) {
for (int w = 0; w < 176; w++)
@@ -280,7 +278,7 @@ void Screen_LoL::backupSceneWindow(int srcPageNum, int dstPageNum) {
}
void Screen_LoL::restoreSceneWindow(int srcPageNum, int dstPageNum) {
- uint8 *src = getPagePtr(srcPageNum) + 0xa500;
+ uint8 *src = getPagePtr(srcPageNum) + 0xA500;
uint8 *dst = getPagePtr(dstPageNum) + 112;
for (int h = 0; h < 120; h++) {
@@ -294,7 +292,7 @@ void Screen_LoL::restoreSceneWindow(int srcPageNum, int dstPageNum) {
}
void Screen_LoL::clearGuiShapeMemory(int pageNum) {
- uint8 *dst = getPagePtr(pageNum) + 0x79b0;
+ uint8 *dst = getPagePtr(pageNum) + 0x79B0;
for (int i = 0; i < 23; i++) {
memset(dst, 0, 176);
dst += 320;
@@ -302,7 +300,7 @@ void Screen_LoL::clearGuiShapeMemory(int pageNum) {
}
void Screen_LoL::copyGuiShapeFromSceneBackupBuffer(int srcPageNum, int dstPageNum) {
- uint8 *src = getPagePtr(srcPageNum) + 0x79c3;
+ uint8 *src = getPagePtr(srcPageNum) + 0x79C3;
uint8 *dst = getPagePtr(dstPageNum);
for (int i = 0; i < 23; i++) {
@@ -325,7 +323,7 @@ void Screen_LoL::copyGuiShapeFromSceneBackupBuffer(int srcPageNum, int dstPageN
void Screen_LoL::copyGuiShapeToSurface(int srcPageNum, int dstPageNum) {
uint8 *src = getPagePtr(srcPageNum);
- uint8 *dst = getPagePtr(dstPageNum) + 0xe7c3;
+ uint8 *dst = getPagePtr(dstPageNum) + 0xE7C3;
for (int i = 0; i < 23; i++) {
uint8 v = *src++;
@@ -344,8 +342,8 @@ void Screen_LoL::copyGuiShapeToSurface(int srcPageNum, int dstPageNum) {
}
void Screen_LoL::smoothScrollZoomStepTop(int srcPageNum, int dstPageNum, int x, int y) {
- uint8 *src = getPagePtr(srcPageNum) + 0xa500 + y * 176 + x;
- uint8 *dst = getPagePtr(dstPageNum) + 0xa500;
+ uint8 *src = getPagePtr(srcPageNum) + 0xA500 + y * 176 + x;
+ uint8 *dst = getPagePtr(dstPageNum) + 0xA500;
x <<= 1;
uint16 width = 176 - x;
@@ -365,7 +363,7 @@ void Screen_LoL::smoothScrollZoomStepTop(int srcPageNum, int dstPageNum, int x,
do {
scaleXc += scaleX;
int numbytes = cntW + (scaleXc >> 16);
- scaleXc &= 0xffff;
+ scaleXc &= 0xFFFF;
memset(dst, *src++, numbytes);
dst += numbytes;
} while (--widthCnt);
@@ -387,8 +385,8 @@ void Screen_LoL::smoothScrollZoomStepTop(int srcPageNum, int dstPageNum, int x,
}
void Screen_LoL::smoothScrollZoomStepBottom(int srcPageNum, int dstPageNum, int x, int y) {
- uint8 *src = getPagePtr(srcPageNum) + 0xc4a0 + x;
- uint8 *dst = getPagePtr(dstPageNum) + 0xc4a0;
+ uint8 *src = getPagePtr(srcPageNum) + 0xC4A0 + x;
+ uint8 *dst = getPagePtr(dstPageNum) + 0xC4A0;
x <<= 1;
uint16 width = 176 - x;
@@ -408,7 +406,7 @@ void Screen_LoL::smoothScrollZoomStepBottom(int srcPageNum, int dstPageNum, int
do {
scaleXc += scaleX;
int numbytes = cntW + (scaleXc >> 16);
- scaleXc &= 0xffff;
+ scaleXc &= 0xFFFF;
memset(dst, *src++, numbytes);
dst += numbytes;
} while (--widthCnt);
@@ -455,7 +453,7 @@ void Screen_LoL::smoothScrollHorizontalStep(int pageNum, int srcX, int dstX, int
void Screen_LoL::smoothScrollTurnStep1(int srcPage1Num, int srcPage2Num, int dstPageNum) {
uint8 *s = getPagePtr(srcPage1Num) + 273;
- uint8 *d = getPagePtr(dstPageNum) + 0xa500;
+ uint8 *d = getPagePtr(dstPageNum) + 0xA500;
for (int i = 0; i < 120; i++) {
uint8 a = *s++;
@@ -474,7 +472,7 @@ void Screen_LoL::smoothScrollTurnStep1(int srcPage1Num, int srcPage2Num, int dst
}
s = getPagePtr(srcPage2Num) + 112;
- d = getPagePtr(dstPageNum) + 0xa52c;
+ d = getPagePtr(dstPageNum) + 0xA52C;
for (int i = 0; i < 120; i++) {
for (int ii = 0; ii < 33; ii++) {
@@ -492,7 +490,7 @@ void Screen_LoL::smoothScrollTurnStep1(int srcPage1Num, int srcPage2Num, int dst
void Screen_LoL::smoothScrollTurnStep2(int srcPage1Num, int srcPage2Num, int dstPageNum) {
uint8 *s = getPagePtr(srcPage1Num) + 244;
- uint8 *d = getPagePtr(dstPageNum) + 0xa500;
+ uint8 *d = getPagePtr(dstPageNum) + 0xA500;
for (int k = 0; k < 2; k++) {
for (int i = 0; i < 120; i++) {
@@ -507,13 +505,13 @@ void Screen_LoL::smoothScrollTurnStep2(int srcPage1Num, int srcPage2Num, int dst
}
s = getPagePtr(srcPage2Num) + 112;
- d = getPagePtr(dstPageNum) + 0xa558;
+ d = getPagePtr(dstPageNum) + 0xA558;
}
}
void Screen_LoL::smoothScrollTurnStep3(int srcPage1Num, int srcPage2Num, int dstPageNum) {
uint8 *s = getPagePtr(srcPage1Num) + 189;
- uint8 *d = getPagePtr(dstPageNum) + 0xa500;
+ uint8 *d = getPagePtr(dstPageNum) + 0xA500;
for (int i = 0; i < 120; i++) {
for (int ii = 0; ii < 33; ii++) {
@@ -529,7 +527,7 @@ void Screen_LoL::smoothScrollTurnStep3(int srcPage1Num, int srcPage2Num, int dst
}
s = getPagePtr(srcPage2Num) + 112;
- d = getPagePtr(dstPageNum) + 0xa584;
+ d = getPagePtr(dstPageNum) + 0xA584;
for (int i = 0; i < 120; i++) {
for (int ii = 0; ii < 14; ii++) {
@@ -783,8 +781,8 @@ bool Screen_LoL::fadeColor(int dstColorIndex, int srcColorIndex, uint32 elapsedT
for (int i = 0; i < 3; i++) {
if (elapsedTicks < totalTicks) {
- srcV = *src & 0x3f;
- dstV = *dst & 0x3f;
+ srcV = *src & 0x3F;
+ dstV = *dst & 0x3F;
outV = srcV - dstV;
if (outV)
@@ -796,7 +794,7 @@ bool Screen_LoL::fadeColor(int dstColorIndex, int srcColorIndex, uint32 elapsedT
res = false;
}
- tmpPalEntry[i] = outV & 0xff;
+ tmpPalEntry[i] = outV & 0xFF;
src++;
dst++;
p++;
@@ -810,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)
diff --git a/engines/kyra/screen_lol.h b/engines/kyra/screen_lol.h
index 09496705bb..8ceb8431bc 100644
--- a/engines/kyra/screen_lol.h
+++ b/engines/kyra/screen_lol.h
@@ -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);
diff --git a/engines/kyra/screen_v2.cpp b/engines/kyra/screen_v2.cpp
index 7d4b064e2a..cc7d526ffe 100644
--- a/engines/kyra/screen_v2.cpp
+++ b/engines/kyra/screen_v2.cpp
@@ -117,11 +117,11 @@ void Screen_v2::applyOverlay(int x, int y, int w, int h, int pageNum, const uint
}
int Screen_v2::findLeastDifferentColor(const uint8 *paletteEntry, const Palette &pal, uint8 firstColor, uint16 numColors, bool skipSpecialColors) {
- int m = 0x7fff;
+ int m = 0x7FFF;
int r = 0x101;
for (int i = 0; i < numColors; i++) {
- if (skipSpecialColors && i >= 0xc0 && i <= 0xc3)
+ if (skipSpecialColors && i >= 0xC0 && i <= 0xC3)
continue;
int v = paletteEntry[0] - pal[(i + firstColor) * 3 + 0];
@@ -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);
@@ -283,13 +311,13 @@ void Screen_v2::wsaFrameAnimationStep(int x1, int y1, int x2, int y2,
if (w1 == 1) {
memset(dt, *s, w2);
} else {
- t = ((((((w2 - w1 + 1) & 0xffff) << 8) / w1) + 0x100) & 0xffff) << 8;
+ t = ((((((w2 - w1 + 1) & 0xFFFF) << 8) / w1) + 0x100) & 0xFFFF) << 8;
int bp = 0;
for (int i = 0; i < w1; i++) {
int cnt = (t >> 16);
- bp += (t & 0xffff);
- if (bp > 0xffff) {
- bp -= 0xffff;
+ bp += (t & 0xFFFF);
+ if (bp > 0xFFFF) {
+ bp -= 0xFFFF;
cnt++;
}
memset(dt, *s++, cnt);
@@ -300,13 +328,13 @@ void Screen_v2::wsaFrameAnimationStep(int x1, int y1, int x2, int y2,
if (w2 == 1) {
*dt = *s;
} else {
- t = (((((w1 - w2) & 0xffff) << 8) / w2) & 0xffff) << 8;
+ t = (((((w1 - w2) & 0xFFFF) << 8) / w2) & 0xFFFF) << 8;
int bp = 0;
for (int i = 0; i < w2; i++) {
*dt++ = *s++;
- bp += (t & 0xffff);
- if (bp > 0xffff) {
- bp -= 0xffff;
+ bp += (t & 0xFFFF);
+ if (bp > 0xFFFF) {
+ bp -= 0xFFFF;
s++;
}
s += (t >> 16);
@@ -322,6 +350,48 @@ 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);
+}
+
+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;
diff --git a/engines/kyra/screen_v2.h b/engines/kyra/screen_v2.h
index f84c923128..6f4d67136a 100644
--- a/engines/kyra/screen_v2.h
+++ b/engines/kyra/screen_v2.h
@@ -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,10 @@ 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);
+ void copyRegionEx(int srcPage, int srcW, int srcH, int dstPage, int dstX,int dstY, int dstW, int dstH, const ScreenDim *d, bool flag = false);
protected:
uint8 *_wsaFrameAnimBuffer;
};
diff --git a/engines/kyra/script_eob.cpp b/engines/kyra/script_eob.cpp
index c07c41f706..de4d01b254 100644
--- a/engines/kyra/script_eob.cpp
+++ b/engines/kyra/script_eob.cpp
@@ -175,7 +175,7 @@ void EoBInfProcessor::run(int func, int flags) {
uint16 f = _vm->_levelBlockProperties[func].flags;
- uint16 subFlags = ((f & 0xfff8) >> 3) | 0xe0;
+ uint16 subFlags = ((f & 0xFFF8) >> 3) | 0xE0;
if (!(flags & subFlags))
return;
@@ -221,10 +221,16 @@ void EoBInfProcessor::loadState(Common::SeekableSubReadStreamEndian &in, bool or
_flagTable[i] = in.readUint32();
}
-void EoBInfProcessor::saveState(Common::OutSaveFile *out) {
- out->writeByte(_preventRest);
- for (int i = 0; i < 18; i++)
- out->writeUint32BE(_flagTable[i]);
+void EoBInfProcessor::saveState(Common::OutSaveFile *out, bool origFile) {
+ if (_vm->game() == GI_EOB2 || !origFile)
+ out->writeByte(_preventRest);
+ int numFlags = (_vm->game() == GI_EOB1 && origFile) ? 13 : 18;
+ for (int i = 0; i < numFlags; i++) {
+ if (origFile)
+ out->writeUint32LE(_flagTable[i]);
+ else
+ out->writeUint32BE(_flagTable[i]);
+ }
}
void EoBInfProcessor::reset() {
@@ -233,7 +239,7 @@ void EoBInfProcessor::reset() {
}
const char *EoBInfProcessor::getString(uint16 index) {
- if (index == 0xffff)
+ if (index == 0xFFFF)
return 0;
int8 *res = _scriptData + READ_LE_UINT16(_scriptData);
@@ -348,7 +354,7 @@ int EoBInfProcessor::oeob_movePartyOrObject(int8 *data) {
int8 *pos = data;
int8 a = *pos++;
- uint16 b = 0xffff;
+ uint16 b = 0xFFFF;
uint16 c = 0;
uint16 d = 0;
@@ -972,7 +978,7 @@ int EoBInfProcessor::oeob_eval_v2(int8 *data) {
case 9:
switch (*pos++) {
case -36:
- _stack[_stackIndex++] = _vm->_itemTypes[_vm->_items[_vm->_lastUsedItem].type].extraProperties & 0x7f;
+ _stack[_stackIndex++] = _vm->_itemTypes[_vm->_items[_vm->_lastUsedItem].type].extraProperties & 0x7F;
break;
case -31:
_stack[_stackIndex++] = _vm->_items[_vm->_lastUsedItem].type;
@@ -1097,7 +1103,7 @@ int EoBInfProcessor::oeob_eval_v2(int8 *data) {
case 26:
a = 0;
for (i = 0; i < 6; i++) {
- if (_vm->testCharacter(i, 0x0f))
+ if (_vm->testCharacter(i, 0x0F))
a++;
}
_stack[_stackIndex++] = a;
@@ -1260,7 +1266,7 @@ int EoBInfProcessor::oeob_loadNewLevelOrMonsters(int8 *data) {
pos += 2;
uint8 dir = (uint8)*pos++;
- if (dir != 0xff)
+ if (dir != 0xFF)
_vm->_currentDirection = dir;
for (int i = 0; i < 30; i++)
@@ -1328,11 +1334,11 @@ int EoBInfProcessor::oeob_createItem_v1(int8 *data) {
uint8 itmPos = *pos++;
if (itm) {
- if (block == 0xffff && !_vm->_itemInHand) {
+ if (block == 0xFFFF && !_vm->_itemInHand) {
_vm->setHandItem(itm);
debugC(5, kDebugLevelScript, " - create hand item '%d'", itm);
- } else if (block != 0xffff) {
- _vm->setItemPosition((Item *)&_vm->_levelBlockProperties[block & 0x3ff].drawObjects, block, itm, itmPos);
+ } else if (block != 0xFFFF) {
+ _vm->setItemPosition((Item *)&_vm->_levelBlockProperties[block & 0x3FF].drawObjects, block, itm, itmPos);
debugC(5, kDebugLevelScript, " - create item '%d' on block '0x%.04X', position '%d'", itm, block, itmPos);
}
}
@@ -1363,19 +1369,19 @@ int EoBInfProcessor::oeob_createItem_v2(int8 *data) {
if (!itm)
return pos - data;
- if (block == 0xffff) {
+ if (block == 0xFFFF) {
if (!_vm->_itemInHand) {
_vm->setHandItem(itm);
debugC(5, kDebugLevelScript, " - create hand item '%d' (value '%d', flags '0x%X', icon number '%d')", itm, _vm->_items[itm].value, _vm->_items[itm].flags, _vm->_items[itm].icon);
} else {
- _vm->setItemPosition((Item *)&_vm->_levelBlockProperties[_vm->_currentBlock & 0x3ff].drawObjects, _vm->_currentBlock, itm, _itemPos[_vm->rollDice(1, 2, -1)]);
+ _vm->setItemPosition((Item *)&_vm->_levelBlockProperties[_vm->_currentBlock & 0x3FF].drawObjects, _vm->_currentBlock, itm, _itemPos[_vm->rollDice(1, 2, -1)]);
debugC(5, kDebugLevelScript, " - create item '%d' (value '%d', flags '0x%X', icon number '%d') on current block", itm, _vm->_items[itm].value, _vm->_items[itm].flags, _vm->_items[itm].icon);
}
- } else if (block == 0xfffe) {
- _vm->setItemPosition((Item *)&_vm->_levelBlockProperties[_vm->_currentBlock & 0x3ff].drawObjects, _vm->_currentBlock, itm, _itemPos[(_vm->_currentDirection << 2) + _vm->rollDice(1, 2, -1)]);
+ } else if (block == 0xFFFE) {
+ _vm->setItemPosition((Item *)&_vm->_levelBlockProperties[_vm->_currentBlock & 0x3FF].drawObjects, _vm->_currentBlock, itm, _itemPos[(_vm->_currentDirection << 2) + _vm->rollDice(1, 2, -1)]);
debugC(5, kDebugLevelScript, " - create item '%d' (value '%d', flags '0x%X', icon number '%d') on current block", itm, _vm->_items[itm].value, _vm->_items[itm].flags, _vm->_items[itm].icon);
} else {
- _vm->setItemPosition((Item *)&_vm->_levelBlockProperties[block & 0x3ff].drawObjects, block, itm, itmPos);
+ _vm->setItemPosition((Item *)&_vm->_levelBlockProperties[block & 0x3FF].drawObjects, block, itm, itmPos);
debugC(5, kDebugLevelScript, " - create item '%d' (value '%d', flags '0x%X', icon number '%d') on block '0x%.04X', position '%d'", itm, _vm->_items[itm].value, _vm->_items[itm].flags, _vm->_items[itm].icon, block, itmPos);
}
@@ -1530,7 +1536,7 @@ int EoBInfProcessor::oeob_dialogue(int8 *data) {
break;
case -40:
- _dlgResult = _vm->runDialogue(READ_LE_UINT16(pos), READ_LE_UINT16(pos + 6) == 0xffff ? 2 : 3, getString(READ_LE_UINT16(pos + 2)), getString(READ_LE_UINT16(pos + 4)), getString(READ_LE_UINT16(pos + 6)));
+ _dlgResult = _vm->runDialogue(READ_LE_UINT16(pos), READ_LE_UINT16(pos + 6) == 0xFFFF ? 2 : 3, getString(READ_LE_UINT16(pos + 2)), getString(READ_LE_UINT16(pos + 4)), getString(READ_LE_UINT16(pos + 6)));
pos += 8;
break;
diff --git a/engines/kyra/script_eob.h b/engines/kyra/script_eob.h
index fc8b4cfc31..8e2dbd8423 100644
--- a/engines/kyra/script_eob.h
+++ b/engines/kyra/script_eob.h
@@ -48,7 +48,7 @@ public:
bool preventRest() const;
void loadState(Common::SeekableSubReadStreamEndian &in, bool origFile = false);
- void saveState(Common::OutSaveFile *out);
+ void saveState(Common::OutSaveFile *out, bool origFile = false);
void reset();
private:
@@ -91,7 +91,7 @@ private:
EoBCoreEngine *_vm;
Screen_EoB *_screen;
- typedef Common::Functor1Mem<int8*, int, EoBInfProcessor> InfProc;
+ typedef Common::Functor1Mem<int8 *, int, EoBInfProcessor> InfProc;
struct InfOpcode : private Common::NonCopyable {
InfOpcode(InfProc *p, const char *d) : proc(p), desc(d) {}
~InfOpcode() { delete proc; }
diff --git a/engines/kyra/script_hof.cpp b/engines/kyra/script_hof.cpp
index fca83ae632..5bf8f6e78d 100644
--- a/engines/kyra/script_hof.cpp
+++ b/engines/kyra/script_hof.cpp
@@ -253,7 +253,7 @@ int KyraEngine_HoF::o2_displayWsaSequentialFrames(EMCState *script) {
uint16 currentFrame = stackPos(3);
uint16 lastFrame = stackPos(4);
uint16 index = stackPos(5);
- uint16 copyParam = stackPos(6) | 0xc000;
+ uint16 copyParam = stackPos(6) | 0xC000;
_screen->hideMouse();
@@ -278,7 +278,7 @@ int KyraEngine_HoF::o2_displayWsaSequence(EMCState *script) {
const int frameDelay = stackPos(2) * _tickLength;
const int index = stackPos(3);
const bool doUpdate = (stackPos(4) != 0);
- const uint16 copyParam = stackPos(5) | 0xc000;
+ const uint16 copyParam = stackPos(5) | 0xC000;
_screen->hideMouse();
@@ -319,8 +319,8 @@ int KyraEngine_HoF::o2_drawShape(EMCState *script) {
uint8 *shp = getShapePtr(stackPos(0) + 64);
int x = stackPos(1);
int y = stackPos(2);
- uint8 dsFlag = stackPos(3) & 0xff;
- uint8 modeFlag = stackPos(4) & 0xff;
+ uint8 dsFlag = stackPos(3) & 0xFF;
+ uint8 modeFlag = stackPos(4) & 0xFF;
if (modeFlag) {
_screen->drawShape(2, shp, x, y, 2, dsFlag ? 1 : 0);
@@ -918,7 +918,7 @@ int KyraEngine_HoF::o2_useItemOnMainChar(EMCState *script) {
tmpScript.regs[0] = _mainCharacter.sceneId;
int oldVocH = _vocHigh;
- _vocHigh = 0x5a;
+ _vocHigh = 0x5A;
while (_emc->isValid(&tmpScript))
_emc->run(&tmpScript);
@@ -955,7 +955,7 @@ int KyraEngine_HoF::o2_pressColorKey(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2_pressColorKey(%p) (%d)", (const void *)script, stackPos(0));
for (int i = 6; i; i--)
_inputColorCode[i] = _inputColorCode[i - 1];
- _inputColorCode[0] = stackPos(0) & 0xff;
+ _inputColorCode[0] = stackPos(0) & 0xFF;
for (int i = 0; i < 7; i++) {
if (_presetColorCode[i] != _inputColorCode[6 - i])
return _dbgPass;
@@ -1023,8 +1023,8 @@ int KyraEngine_HoF::o2_getColorCodeValue(EMCState *script) {
int KyraEngine_HoF::o2_setColorCodeValue(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2_setColorCodeValue(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
- _presetColorCode[stackPos(0)] = stackPos(1) & 0xff;
- return stackPos(1) & 0xff;
+ _presetColorCode[stackPos(0)] = stackPos(1) & 0xFF;
+ return stackPos(1) & 0xFF;
}
int KyraEngine_HoF::o2_countItemInstances(EMCState *script) {
@@ -1495,7 +1495,7 @@ void KyraEngine_HoF::setupOpcodeTable() {
OpcodeUnImpl();
OpcodeUnImpl();
Opcode(o2_setCharacterAnimFrame);
- // 0x0c
+ // 0x0C
Opcode(o2_setCharacterFacingOverwrite);
Opcode(o2_trySceneChange);
Opcode(o2_moveCharacter);
@@ -1515,7 +1515,7 @@ void KyraEngine_HoF::setupOpcodeTable() {
Opcode(o2_wsaOpen);
Opcode(o2_displayWsaSequentialFrames);
Opcode(o2_displayWsaSequence);
- // 0x1c
+ // 0x1C
Opcode(o2_addItemToInventory);
Opcode(o2_drawShape);
Opcode(o2_addItemToCurScene);
@@ -1536,7 +1536,7 @@ void KyraEngine_HoF::setupOpcodeTable() {
Opcode(o1_setGameFlag);
Opcode(o1_setHandItem);
Opcode(o1_removeHandItem);
- // 0x2c
+ // 0x2C
Opcode(o1_getMouseState);
Opcode(o1_hideMouse);
Opcode(o2_addSpecialExit);
@@ -1556,7 +1556,7 @@ void KyraEngine_HoF::setupOpcodeTable() {
Opcode(o2_setTimerDelay);
Opcode(o2_setScaleTableItem);
Opcode(o2_setDrawLayerTableItem);
- // 0x3c
+ // 0x3C
Opcode(o2_setCharPalEntry);
Opcode(o2_loadZShapes);
Opcode(o2_drawSceneShape);
@@ -1576,7 +1576,7 @@ void KyraEngine_HoF::setupOpcodeTable() {
Opcode(o2_restoreInventoryGfx);
Opcode(o2_setSceneAnimPos2);
Opcode(o2_update);
- // 0x4c
+ // 0x4C
OpcodeUnImpl();
Opcode(o2_fadeScenePal);
Opcode(o2_dummy);
@@ -1596,7 +1596,7 @@ void KyraEngine_HoF::setupOpcodeTable() {
Opcode(o1_playSoundEffect);
Opcode(o2_setSceneAnimPos);
Opcode(o1_blockInWalkableRegion);
- // 0x5c
+ // 0x5C
Opcode(o1_blockOutWalkableRegion);
OpcodeUnImpl();
Opcode(o2_setCauldronState);
@@ -1616,7 +1616,7 @@ void KyraEngine_HoF::setupOpcodeTable() {
OpcodeUnImpl();
Opcode(o2_playFireflyScore);
Opcode(o2_waitForConfirmationClick);
- // 0x6c
+ // 0x6C
Opcode(o2_encodeShape);
Opcode(o2_defineRoomEntrance);
Opcode(o2_runAnimationScript);
@@ -1636,7 +1636,7 @@ void KyraEngine_HoF::setupOpcodeTable() {
Opcode(o2_defineScene);
Opcode(o2_addCauldronStateTableEntry);
Opcode(o2_setCountDown);
- // 0x7c
+ // 0x7C
Opcode(o2_getCountDown);
Opcode(o2_dummy);
Opcode(o2_dummy);
@@ -1656,7 +1656,7 @@ void KyraEngine_HoF::setupOpcodeTable() {
Opcode(o2_removeItemFromScene);
Opcode(o2_initObject);
Opcode(o2_npcChat);
- // 0x8c
+ // 0x8C
Opcode(o2_deinitObject);
Opcode(o2_playTimSequence);
Opcode(o2_makeBookOrCauldronAppear);
@@ -1676,27 +1676,27 @@ void KyraEngine_HoF::setupOpcodeTable() {
Opcode(o2_customChatFinish);
Opcode(o2_setupSceneAnimation);
Opcode(o2_stopSceneAnimation);
- // 0x9c
+ // 0x9C
Opcode(o2_disableTimer);
Opcode(o2_enableTimer);
Opcode(o2_setTimerCountdown);
Opcode(o2_processPaletteIndex);
- // 0xa0
+ // 0xA0
Opcode(o2_updateTwoSceneAnims);
Opcode(o2_getRainbowRoomData);
Opcode(o2_drawSceneShapeEx);
Opcode(o2_midiSoundFadeout);
- // 0xa4
+ // 0xA4
Opcode(o2_getSfxDriver);
Opcode(o2_getVocSupport);
Opcode(o2_getMusicDriver);
Opcode(o2_setVocHigh);
- // 0xa8
+ // 0xA8
Opcode(o2_getVocHigh);
Opcode(o2_zanthiaChat);
Opcode(o2_isVoiceEnabled);
Opcode(o2_isVoicePlaying);
- // 0xac
+ // 0xAC
Opcode(o2_stopVoicePlaying);
Opcode(o2_getGameLanguage);
Opcode(o2_demoFinale);
diff --git a/engines/kyra/script_lok.cpp b/engines/kyra/script_lok.cpp
index db9e01cabb..22d5e9fd7c 100644
--- a/engines/kyra/script_lok.cpp
+++ b/engines/kyra/script_lok.cpp
@@ -1774,7 +1774,7 @@ void KyraEngine_LoK::setupOpcodeTable() {
Opcode(o1_blockInWalkableRegion);
Opcode(o1_blockOutWalkableRegion);
Opcode(o1_walkPlayerToPoint);
- // 0x0c
+ // 0x0C
Opcode(o1_dropItemInScene);
Opcode(o1_drawAnimShapeIntoScene);
Opcode(o1_setHandItem);
@@ -1794,7 +1794,7 @@ void KyraEngine_LoK::setupOpcodeTable() {
Opcode(o1_phaseInSameScene);
Opcode(o1_setScenePhasingFlag);
Opcode(o1_resetScenePhasingFlag);
- // 0x1c
+ // 0x1C
Opcode(o1_queryScenePhasingFlag);
Opcode(o1_sceneToDirection);
Opcode(o1_setBirthstoneGem);
@@ -1814,7 +1814,7 @@ void KyraEngine_LoK::setupOpcodeTable() {
Opcode(o1_openWSAFile);
Opcode(o1_closeWSAFile);
Opcode(o1_runWSAFromBeginningToEnd);
- // 0x2c
+ // 0x2C
Opcode(o1_displayWSAFrame);
Opcode(o1_enterNewScene);
Opcode(o1_setSpecialEnterXAndY);
@@ -1834,7 +1834,7 @@ void KyraEngine_LoK::setupOpcodeTable() {
Opcode(o1_getCharacterY);
Opcode(o1_setCharacterFacing);
Opcode(o1_copyWSARegion);
- // 0x3c
+ // 0x3C
Opcode(o1_printText);
Opcode(o1_getRand);
Opcode(o1_loadSoundFile);
@@ -1854,7 +1854,7 @@ void KyraEngine_LoK::setupOpcodeTable() {
Opcode(o1_placeCharacterInOtherScene);
Opcode(o1_getKey);
Opcode(o1_specificItemInInventory);
- // 0x4c
+ // 0x4C
Opcode(o1_popMobileNPCIntoScene);
Opcode(o1_mobileCharacterInScene);
Opcode(o1_hideMobileCharacter);
@@ -1874,7 +1874,7 @@ void KyraEngine_LoK::setupOpcodeTable() {
Opcode(o1_setCharacterMovementDelay);
Opcode(o1_getCharacterFacing);
Opcode(o1_bkgdScrollSceneAndMasksRight);
- // 0x5c
+ // 0x5C
Opcode(o1_dispelMagicAnimation);
Opcode(o1_findBrightestFireberry);
Opcode(o1_setFireberryGlowPalette);
@@ -1894,7 +1894,7 @@ void KyraEngine_LoK::setupOpcodeTable() {
Opcode(o1_addItemToInventory);
Opcode(o1_intPrint);
Opcode(o1_shakeScreen);
- // 0x6c
+ // 0x6C
Opcode(o1_createAmuletJewel);
Opcode(o1_setSceneAnimCurrXY);
Opcode(o1_poisonBrandonAndRemaps);
@@ -1914,7 +1914,7 @@ void KyraEngine_LoK::setupOpcodeTable() {
Opcode(o1_setMousePos);
Opcode(o1_getMouseState);
Opcode(o1_setEntranceMouseCursorTrack);
- // 0x7c
+ // 0x7C
Opcode(o1_itemAppearsOnGround);
Opcode(o1_setNoDrawShapesFlag);
Opcode(o1_fadeEntirePalette);
@@ -1934,7 +1934,7 @@ void KyraEngine_LoK::setupOpcodeTable() {
Opcode(o1_getScaleDepthTableValue);
Opcode(o1_setScaleDepthTableValue);
Opcode(o1_message);
- // 0x8c
+ // 0x8C
Opcode(o1_checkClickOnNPC);
Opcode(o1_getFoyerItem);
Opcode(o1_setFoyerItem);
@@ -1954,7 +1954,7 @@ void KyraEngine_LoK::setupOpcodeTable() {
Opcode(o1_fillRect);
Opcode(o1_vocUnload);
Opcode(o1_vocLoad);
- // 0x9c
+ // 0x9C
Opcode(o1_dummy);
}
#undef Opcode
diff --git a/engines/kyra/script_lol.cpp b/engines/kyra/script_lol.cpp
index 9c0fe21ad4..0bbe66f530 100644
--- a/engines/kyra/script_lol.cpp
+++ b/engines/kyra/script_lol.cpp
@@ -126,7 +126,7 @@ int LoLEngine::olol_moveParty(EMCState *script) {
mode = (mode - 6 - _currentDirection) & 3;
Button b;
- b.data0Val2 = b.data1Val2 = b.data2Val2 = 0xfe;
+ b.data0Val2 = b.data1Val2 = b.data2Val2 = 0xFE;
b.data0Val3 = b.data1Val3 = b.data2Val3 = 0x01;
switch (mode) {
@@ -268,7 +268,7 @@ int LoLEngine::olol_makeItem(EMCState *script) {
int LoLEngine::olol_placeMoveLevelItem(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_placeMoveLevelItem(%p) (%d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5));
- placeMoveLevelItem(stackPos(0), stackPos(1), stackPos(2), stackPos(3) & 0xff, stackPos(4) & 0xff, stackPos(5));
+ placeMoveLevelItem(stackPos(0), stackPos(1), stackPos(2), stackPos(3) & 0xFF, stackPos(4) & 0xFF, stackPos(5));
return 1;
}
@@ -321,7 +321,7 @@ int LoLEngine::olol_getItemPara(EMCState *script) {
case 14:
return p->unkB;
case 15:
- return i->shpCurFrame_flg & 0x1fff;
+ return i->shpCurFrame_flg & 0x1FFF;
case 16:
return p->flags;
case 17:
@@ -397,7 +397,7 @@ int LoLEngine::olol_setCharacterStat(EMCState *script) {
break;
case 1:
- c->raceClassSex = e & 0x0f;
+ c->raceClassSex = e & 0x0F;
break;
case 5:
@@ -478,19 +478,19 @@ int LoLEngine::olol_loadDoorShapes(EMCState *script) {
_wllWallFlags[i + 3] |= 7;
int t = i % 5;
if (t == 4)
- _wllWallFlags[i + 3] &= 0xf8;
+ _wllWallFlags[i + 3] &= 0xF8;
if (t == 3)
- _wllWallFlags[i + 3] &= 0xfd;
+ _wllWallFlags[i + 3] &= 0xFD;
}
if (stackPos(3)) {
for (int i = 3; i < 13; i++)
- _wllWallFlags[i] &= 0xfd;
+ _wllWallFlags[i] &= 0xFD;
}
if (stackPos(4)) {
for (int i = 13; i < 23; i++)
- _wllWallFlags[i] &= 0xfd;
+ _wllWallFlags[i] &= 0xFD;
}
return 1;
@@ -683,7 +683,7 @@ int LoLEngine::olol_setGlobalVar(EMCState *script) {
break;
case 2:
- _currentLevel = b & 0xff;
+ _currentLevel = b & 0xFF;
break;
case 3:
@@ -691,7 +691,7 @@ int LoLEngine::olol_setGlobalVar(EMCState *script) {
break;
case 4:
- _brightness = b & 0xff;
+ _brightness = b & 0xFF;
break;
case 5:
@@ -717,20 +717,20 @@ int LoLEngine::olol_setGlobalVar(EMCState *script) {
break;
case 9:
- _lampOilStatus = b & 0xff;
+ _lampOilStatus = b & 0xFF;
break;
case 10:
- _sceneDefaultUpdate = b & 0xff;
+ _sceneDefaultUpdate = b & 0xFF;
gui_toggleButtonDisplayMode(0, 0);
break;
case 11:
- _compassBroken = a & 0xff;
+ _compassBroken = a & 0xFF;
break;
case 12:
- _drainMagic = a & 0xff;
+ _drainMagic = a & 0xFF;
break;
default:
@@ -763,9 +763,9 @@ int LoLEngine::olol_checkEquippedItemScriptFlags(EMCState *script) {
int LoLEngine::olol_setDoorState(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_setDoorState(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
if (stackPos(1))
- _levelBlockProperties[stackPos(0)].flags = (_levelBlockProperties[stackPos(0)].flags & 0xef) | 0x20;
+ _levelBlockProperties[stackPos(0)].flags = (_levelBlockProperties[stackPos(0)].flags & 0xEF) | 0x20;
else
- _levelBlockProperties[stackPos(0)].flags &= 0xdf;
+ _levelBlockProperties[stackPos(0)].flags &= 0xDF;
return 1;
}
@@ -784,7 +784,7 @@ int LoLEngine::olol_assignLevelDecorationShape(EMCState *script) {
int LoLEngine::olol_resetBlockShapeAssignment(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_resetBlockShapeAssignment(%p) (%d)", (const void *)script, stackPos(0));
- uint8 v = stackPos(0) & 0xff;
+ uint8 v = stackPos(0) & 0xFF;
memset(_wllShapeMap + 3, v, 5);
memset(_wllShapeMap + 13, v, 5);
return 1;
@@ -823,7 +823,7 @@ int LoLEngine::olol_initMonster(EMCState *script) {
l->type = stackPos(4);
l->properties = &_monsterProperties[l->type];
l->direction = l->facing << 1;
- l->hitPoints = (l->properties->hitPoints * _monsterModifiers[_monsterDifficulty]) >> 8;
+ l->hitPoints = (l->properties->hitPoints * _monsterModifiers1[_monsterDifficulty]) >> 8;
if (_currentLevel != 12 || l->type != 2)
l->hitPoints = (l->hitPoints * (rollDice(1, 128) + 192)) >> 8;
@@ -842,7 +842,7 @@ int LoLEngine::olol_initMonster(EMCState *script) {
l->destDirection = l->direction;
for (int ii = 0; ii < 4; ii++)
- l->equipmentShapes[ii] = stackPos(7 + ii) & 0xff;
+ l->equipmentShapes[ii] = stackPos(7 + ii) & 0xFF;
checkSceneUpdateNeed(l->block);
return i;
@@ -927,7 +927,7 @@ int LoLEngine::olol_loadMonsterProperties(EMCState *script) {
stackPos(35), stackPos(36), stackPos(37), stackPos(38), stackPos(39), stackPos(40), stackPos(41));
LoLMonsterProperty *l = &_monsterProperties[stackPos(0)];
- l->shapeIndex = stackPos(1) & 0xff;
+ l->shapeIndex = stackPos(1) & 0xFF;
int shpWidthMax = 0;
@@ -1079,7 +1079,7 @@ int LoLEngine::olol_addRemoveCharacter(EMCState *script) {
if (!(_characters[i].flags & 1) || _characters[i].id != id)
continue;
- _characters[i].flags &= 0xfffe;
+ _characters[i].flags &= 0xFFFE;
calcCharPortraitXpos();
if (_selectedCharacter == i)
@@ -1192,7 +1192,7 @@ int LoLEngine::olol_changeMonsterStat(EMCState *script) {
if (stackPos(0) == -1)
return 1;
- LoLMonster *m = &_monsters[stackPos(0) & 0x7fff];
+ LoLMonster *m = &_monsters[stackPos(0) & 0x7FFF];
int16 d = stackPos(2);
uint16 x = 0;
@@ -1208,7 +1208,7 @@ int LoLEngine::olol_changeMonsterStat(EMCState *script) {
break;
case 2:
- calcCoordinates(x, y, d, m->x & 0xff, m->y & 0xff);
+ calcCoordinates(x, y, d, m->x & 0xFF, m->y & 0xFF);
if (!walkMonsterCheckDest(x, y, m, 7))
placeMonster(m, x, y);
break;
@@ -1233,7 +1233,7 @@ int LoLEngine::olol_getMonsterStat(EMCState *script) {
if (stackPos(0) == -1)
return 0;
- LoLMonster *m = &_monsters[stackPos(0) & 0x7fff];
+ LoLMonster *m = &_monsters[stackPos(0) & 0x7FFF];
int d = stackPos(1);
switch (d) {
@@ -1318,8 +1318,8 @@ int LoLEngine::olol_drawExitButton(EMCState *script) {
int w = _screen->getTextWidth(str);
if (_flags.use16ColorMode) {
- gui_drawBox(x - offs - w, y - 9, w + offs, 9, 0xee, 0xcc, 0x11);
- _screen->printText(str, x - (offs >> 1) - w, y - 7, 0xbb, 0);
+ gui_drawBox(x - offs - w, y - 9, w + offs, 9, 0xEE, 0xCC, 0x11);
+ _screen->printText(str, x - (offs >> 1) - w, y - 7, 0xBB, 0);
} else {
gui_drawBox(x - offs - w, y - 9, w + offs, 9, 136, 251, 252);
_screen->printText(str, x - (offs >> 1) - w, y - 7, 144, 0);
@@ -1497,7 +1497,7 @@ int LoLEngine::olol_distanceAttack(EMCState *script) {
uint16 y = 0;
calcCoordinates(x, y, stackPos(2), fX, fY);
- if (launchObject(stackPos(0), stackPos(1), x, y, stackPos(5), stackPos(6) << 1, stackPos(7), stackPos(8), 0x3f))
+ if (launchObject(stackPos(0), stackPos(1), x, y, stackPos(5), stackPos(6) << 1, stackPos(7), stackPos(8), 0x3F))
return 1;
deleteItem(stackPos(1));
@@ -1532,7 +1532,7 @@ int LoLEngine::olol_moveBlockObjects(EMCState *script) {
// WORKAROUND for script bug
// Items would vanish when thrown towards the stairs
// in white tower level 3.
- if (_currentLevel == 21 && level == 21 && destBlock == 0x3e0) {
+ if (_currentLevel == 21 && level == 21 && destBlock == 0x3E0) {
level = 20;
destBlock = 0x0247;
}
@@ -1544,7 +1544,7 @@ int LoLEngine::olol_moveBlockObjects(EMCState *script) {
if (!includeMonsters)
continue;
- l &= 0x7fff;
+ l &= 0x7FFF;
LoLMonster *m = &_monsters[l];
@@ -1558,7 +1558,7 @@ int LoLEngine::olol_moveBlockObjects(EMCState *script) {
if (!(_itemsInPlay[l].shpCurFrame_flg & 0x4000) || !includeItems)
continue;
- placeMoveLevelItem(l, level, destBlock, _itemsInPlay[l].x & 0xff, _itemsInPlay[l].y & 0xff, _itemsInPlay[l].flyingHeight);
+ placeMoveLevelItem(l, level, destBlock, _itemsInPlay[l].x & 0xFF, _itemsInPlay[l].y & 0xFF, _itemsInPlay[l].flyingHeight);
res = 1;
if (!runScript || level != _currentLevel)
@@ -1617,7 +1617,7 @@ int LoLEngine::olol_dummy1(EMCState *script) {
int LoLEngine::olol_suspendMonster(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_suspendMonster(%p) (%d)", (const void *)script, stackPos(0));
- LoLMonster *m = &_monsters[stackPos(0) & 0x7fff];
+ LoLMonster *m = &_monsters[stackPos(0) & 0x7FFF];
setMonsterMode(m, 14);
checkSceneUpdateNeed(m->block);
placeMonster(m, 0, 0);
@@ -1732,11 +1732,11 @@ int LoLEngine::olol_getItemOnPos(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_getItemOnPos(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3));
int pX = stackPos(1);
if (pX != -1)
- pX &= 0xff;
+ pX &= 0xFF;
int pY = stackPos(2);
if (pY != -1)
- pY &= 0xff;
+ pY &= 0xFF;
int o = (stackPos(3) || _emcLastItem == -1) ? stackPos(0) : _emcLastItem;
@@ -1744,19 +1744,19 @@ int LoLEngine::olol_getItemOnPos(EMCState *script) {
while (_emcLastItem) {
if (_emcLastItem & 0x8000) {
- o = _emcLastItem & 0x7fff;
+ o = _emcLastItem & 0x7FFF;
_emcLastItem = _levelBlockProperties[o].assignedObjects;
continue;
}
- if (pX != -1 && (_itemsInPlay[_emcLastItem].x & 0xff) != pX) {
- o = _emcLastItem & 0x7fff;
+ if (pX != -1 && (_itemsInPlay[_emcLastItem].x & 0xFF) != pX) {
+ o = _emcLastItem & 0x7FFF;
_emcLastItem = _levelBlockProperties[o].assignedObjects;
continue;
}
- if (pY != -1 && (_itemsInPlay[_emcLastItem].y & 0xff) != pY) {
- o = _emcLastItem & 0x7fff;
+ if (pY != -1 && (_itemsInPlay[_emcLastItem].y & 0xFF) != pY) {
+ o = _emcLastItem & 0x7FFF;
_emcLastItem = _levelBlockProperties[o].assignedObjects;
continue;
}
@@ -1835,7 +1835,7 @@ int LoLEngine::olol_assignCustomSfx(EMCState *script) {
return 0;
uint16 t = READ_LE_UINT16(&_ingameSoundIndex[i << 1]);
- if (t == 0xffff)
+ if (t == 0xFFFF)
return 0;
strcpy(_ingameSoundList[t], c);
@@ -1848,7 +1848,7 @@ int LoLEngine::olol_findAssignedMonster(EMCState *script) {
uint16 o = stackPos(1) == -1 ? _levelBlockProperties[stackPos(0)].assignedObjects : findObject(stackPos(1))->nextAssignedObject;
while (o) {
if (o & 0x8000)
- return o & 0x7fff;
+ return o & 0x7FFF;
o = findObject(o)->nextAssignedObject;
}
return -1;
@@ -1861,8 +1861,8 @@ int LoLEngine::olol_checkBlockForMonster(EMCState *script) {
uint16 o = _levelBlockProperties[block].assignedObjects;
while (o & 0x8000) {
- if (id == 0xffff || id == o)
- return o & 0x7fff;
+ if (id == 0xFFFF || id == o)
+ return o & 0x7FFF;
o = findObject(o)->nextAssignedObject;
}
return -1;
@@ -2040,7 +2040,7 @@ int LoLEngine::olol_changeItemTypeOrFlag(EMCState *script) {
if (stackPos(1) == 4)
i->itemPropertyIndex = val;
else if (stackPos(1) == 15)
- i->shpCurFrame_flg = (i->shpCurFrame_flg & 0xe000) | (val & 0x1fff);
+ i->shpCurFrame_flg = (i->shpCurFrame_flg & 0xE000) | (val & 0x1FFF);
else
val = -1;
@@ -2129,7 +2129,7 @@ int LoLEngine::olol_paletteFlash(EMCState *script) {
uint8 *d = p2.getData();
for (int i = 0; i < 16; i++)
- d[i * 3] = 0x3f;
+ d[i * 3] = 0x3F;
_screen->setScreenPalette(p2);
_screen->updateScreen();
diff --git a/engines/kyra/script_mr.cpp b/engines/kyra/script_mr.cpp
index 22d0bc4e95..f656b162fd 100644
--- a/engines/kyra/script_mr.cpp
+++ b/engines/kyra/script_mr.cpp
@@ -1144,7 +1144,7 @@ void KyraEngine_MR::setupOpcodeTable() {
Opcode(o3_dummy);
Opcode(o3_dummy);
Opcode(o3_getCharacterFrameFromFacing);
- // 0x0c
+ // 0x0C
Opcode(o2_setCharacterFacingOverwrite);
Opcode(o2_trySceneChange);
Opcode(o2_moveCharacter);
@@ -1164,7 +1164,7 @@ void KyraEngine_MR::setupOpcodeTable() {
Opcode(o3_showAlbum);
Opcode(o3_setInventorySlot);
Opcode(o3_getInventorySlot);
- // 0x1c
+ // 0x1C
Opcode(o3_addItemToInventory);
OpcodeUnImpl();
Opcode(o3_addItemToCurScene);
@@ -1184,7 +1184,7 @@ void KyraEngine_MR::setupOpcodeTable() {
Opcode(o1_setGameFlag);
Opcode(o1_setHandItem);
Opcode(o1_removeHandItem);
- // 0x2c
+ // 0x2C
Opcode(o1_getMouseState);
Opcode(o1_hideMouse);
Opcode(o2_addSpecialExit);
@@ -1204,7 +1204,7 @@ void KyraEngine_MR::setupOpcodeTable() {
Opcode(o3_makeSecondChanceSave);
Opcode(o3_setSceneFilename);
OpcodeUnImpl();
- // 0x3c
+ // 0x3C
Opcode(o3_removeItemsFromScene);
Opcode(o3_disguiseMalcolm);
Opcode(o3_drawSceneShape);
@@ -1224,7 +1224,7 @@ void KyraEngine_MR::setupOpcodeTable() {
Opcode(o3_dummy);
Opcode(o3_setSceneAnimPosAndFrame);
Opcode(o2_update);
- // 0x4c
+ // 0x4C
Opcode(o3_removeItemInstances);
Opcode(o3_dummy);
Opcode(o3_disableInventory);
@@ -1244,7 +1244,7 @@ void KyraEngine_MR::setupOpcodeTable() {
Opcode(o3_playSoundEffect);
Opcode(o3_getScore);
Opcode(o3_daggerWarning);
- // 0x5c
+ // 0x5C
Opcode(o3_blockOutWalkableRegion);
Opcode(o3_dummy);
Opcode(o3_showSceneStringsMessage);
@@ -1264,7 +1264,7 @@ void KyraEngine_MR::setupOpcodeTable() {
Opcode(o3_dummy);
Opcode(o3_dummy);
Opcode(o2_waitForConfirmationClick);
- // 0x6c
+ // 0x6C
Opcode(o3_dummy);
Opcode(o2_defineRoomEntrance);
Opcode(o2_runAnimationScript);
@@ -1284,7 +1284,7 @@ void KyraEngine_MR::setupOpcodeTable() {
Opcode(o2_defineScene);
Opcode(o3_setConversationState);
OpcodeUnImpl();
- // 0x7c
+ // 0x7C
OpcodeUnImpl();
Opcode(o3_getConversationState);
Opcode(o3_dummy);
@@ -1304,7 +1304,7 @@ void KyraEngine_MR::setupOpcodeTable() {
Opcode(o3_dummy);
Opcode(o3_dialogStartScript);
Opcode(o3_dummy);
- // 0x8c
+ // 0x8C
Opcode(o3_dialogEndScript);
Opcode(o3_dummy);
Opcode(o3_dummy);
@@ -1324,27 +1324,27 @@ void KyraEngine_MR::setupOpcodeTable() {
Opcode(o3_customChatFinish);
Opcode(o3_setupSceneAnimObject);
Opcode(o3_removeSceneAnimObject);
- // 0x9c
+ // 0x9C
Opcode(o2_disableTimer);
Opcode(o2_enableTimer);
Opcode(o2_setTimerCountdown);
OpcodeUnImpl();
- // 0xa0
+ // 0xA0
Opcode(o3_dummy);
Opcode(o3_dummy);
Opcode(o3_dummy);
Opcode(o3_dummy);
- // 0xa4
+ // 0xA4
OpcodeUnImpl();
OpcodeUnImpl();
OpcodeUnImpl();
Opcode(o2_setVocHigh);
- // 0xa8
+ // 0xA8
Opcode(o2_getVocHigh);
OpcodeUnImpl();
OpcodeUnImpl();
OpcodeUnImpl();
- // 0xac
+ // 0xAC
OpcodeUnImpl();
Opcode(o3_dummy);
OpcodeUnImpl();
diff --git a/engines/kyra/script_tim.cpp b/engines/kyra/script_tim.cpp
index 177d7993a0..ba0f62a2b4 100644
--- a/engines/kyra/script_tim.cpp
+++ b/engines/kyra/script_tim.cpp
@@ -297,20 +297,20 @@ void TIMInterpreter::displayText(uint16 textId, int16 flags) {
memcpy(filename, text+1, end-1-text);
}
- const bool isPC98 = (_vm->gameFlags().platform == Common::kPlatformPC98);
+ const bool sjisMode = (_vm->gameFlags().lang == Common::JA_JPN && _vm->gameFlags().use16ColorMode);
if (filename[0] && (_vm->speechEnabled() || !_vm->gameFlags().isTalkie))
- _vm->sound()->voicePlay(filename);
+ _vm->sound()->voicePlay(filename, 0, 255, 255, !_vm->gameFlags().isTalkie);
if (text[0] == '$')
text = strchr(text + 1, '$') + 1;
- if (!isPC98)
+ if (!_vm->gameFlags().use16ColorMode)
setupTextPalette((flags < 0) ? 1 : flags, 0);
if (flags < 0) {
static const uint8 colorMap[] = { 0x00, 0xF0, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- _screen->setFont(isPC98 ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT);
+ _screen->setFont(sjisMode ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT);
_screen->setTextColorMap(colorMap);
_screen->_charWidth = -2;
}
@@ -335,7 +335,7 @@ void TIMInterpreter::displayText(uint16 textId, int16 flags) {
int width = _screen->getTextWidth(str);
if (flags >= 0) {
- if (isPC98) {
+ if (_vm->gameFlags().use16ColorMode) {
static const uint8 colorMap[] = { 0xE1, 0xE1, 0xC1, 0xA1, 0x81, 0x61 };
_screen->printText(str, (320 - width) >> 1, 160 + heightAdd, colorMap[flags], 0x00);
} else {
@@ -359,7 +359,7 @@ void TIMInterpreter::displayText(uint16 textId, int16 flags) {
if (flags < 0) {
static const uint8 colorMap[] = { 0x00, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0x00, 0x00, 0x00, 0x00 };
- _screen->setFont(isPC98 ? Screen::FID_SJIS_FNT : Screen::FID_INTRO_FNT);
+ _screen->setFont(sjisMode ? Screen::FID_SJIS_FNT : Screen::FID_INTRO_FNT);
_screen->setTextColorMap(colorMap);
_screen->_charWidth = 0;
}
@@ -377,7 +377,7 @@ void TIMInterpreter::displayText(uint16 textId, int16 flags, uint8 color) {
if (flags == 255)
return;
- _screen->setFont(_vm->gameFlags().use16ColorMode ? Screen::FID_SJIS_FNT : Screen::FID_INTRO_FNT);
+ _screen->setFont((_vm->gameFlags().lang == Common::JA_JPN && _vm->gameFlags().use16ColorMode) ? Screen::FID_SJIS_FNT : Screen::FID_INTRO_FNT);
static const uint8 colorMap[] = { 0x00, 0xA0, 0xA1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
_screen->setTextColorMap(colorMap);
@@ -393,14 +393,14 @@ void TIMInterpreter::displayText(uint16 textId, int16 flags, uint8 color) {
int y = 0;
if (_vm->gameFlags().use16ColorMode) {
- if (color == 0xda)
- color = 0xa1;
- else if (color == 0xf2)
- color = 0xe1;
+ if (color == 0xDA)
+ color = 0xA1;
+ else if (color == 0xF2)
+ color = 0xE1;
else if (flags < 0)
- color = 0xe1;
+ color = 0xE1;
else
- color = 0xc1;
+ color = 0xC1;
}
while (str[0]) {
@@ -736,7 +736,7 @@ int TIMInterpreter::cmd_playVocFile(const uint16 *param) {
const int volume = (param[1] * 255) / 100;
if (index < ARRAYSIZE(_vocFiles) && !_vocFiles[index].empty())
- _vm->sound()->voicePlay(_vocFiles[index].c_str(), 0, volume, true);
+ _vm->sound()->voicePlay(_vocFiles[index].c_str(), 0, volume, 255, true);
else if (index == 7 && !_vm->gameFlags().isTalkie)
_vm->sound()->playTrack(index);
else
@@ -1083,7 +1083,7 @@ int TIMInterpreter_LoL::cmd_dialogueBox(const uint16 *param) {
int cnt = 0;
for (int i = 1; i < 4; i++) {
- if (param[i] != 0xffff) {
+ if (param[i] != 0xFFFF) {
tmpStr[i-1] = getTableString(param[i]);
cnt++;
} else {
diff --git a/engines/kyra/sequences_darkmoon.cpp b/engines/kyra/sequences_darkmoon.cpp
index d4f5c847fd..03b15d6950 100644
--- a/engines/kyra/sequences_darkmoon.cpp
+++ b/engines/kyra/sequences_darkmoon.cpp
@@ -142,7 +142,6 @@ int DarkMoonEngine::mainMenu() {
case 3:
// transfer party
- //seq_playFinale();
menuChoice = -3;
break;
@@ -867,7 +866,7 @@ void DarkMoonEngine::seq_playCredits(DarkmoonSequenceHelper *sq, const uint8 *da
int16 nextY = i ? items[i].y + items[i].size + (items[i].size >> 2) : dm->h;
const char *posOld = pos;
- pos = strchr(pos, 0x0d);
+ pos = strchr(pos, 0x0D);
if (!pos)
pos = strchr(posOld, 0x00);
@@ -893,7 +892,7 @@ void DarkMoonEngine::seq_playCredits(DarkmoonSequenceHelper *sq, const uint8 *da
items[i + 1].dataType = 0;
int l = pos - posOld;
- if (items[i + 1].crlf != 0x0d)
+ if (items[i + 1].crlf != 0x0D)
l++;
delete[] items[i + 1].str;
@@ -1071,7 +1070,7 @@ void DarkmoonSequenceHelper::animCommand(int index, int del) {
uint32 end = 0;
- for (const DarkMoonAnimCommand *s = _config->animData[index]; s->command != 0xff && !_vm->skipFlag() && !_vm->shouldQuit(); s++) {
+ for (const DarkMoonAnimCommand *s = _config->animData[index]; s->command != 0xFF && !_vm->skipFlag() && !_vm->shouldQuit(); s++) {
int palIndex = _config->mode == kFinale ? (s->pal + 1) : s->pal;
int x = s->x1;
int y = s->y1;
@@ -1187,7 +1186,7 @@ void DarkmoonSequenceHelper::animCommand(int index, int del) {
case 6:
// play sound effect
- if (s->obj != 0xff)
+ if (s->obj != 0xFF)
_vm->snd_playSoundEffect(s->obj);
break;
diff --git a/engines/kyra/sequences_eob.cpp b/engines/kyra/sequences_eob.cpp
index 4a9f7d8a65..0fec386485 100644
--- a/engines/kyra/sequences_eob.cpp
+++ b/engines/kyra/sequences_eob.cpp
@@ -706,7 +706,7 @@ void EoBIntroPlayer::waterdeepExit() {
_vm->delay(60 * _vm->_tickLength);
for (int i = 0; i < 56 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) {
- uint32 end = _vm->_system->getMillis() +_vm->_tickLength;
+ uint32 end = _vm->_system->getMillis() + _vm->_tickLength;
_screen->copyRegion(0, 136 + i, 80, 16, 160, 56 - i, 2, 0, Screen::CR_NO_P_CHECK);
_screen->copyRegion(160, 0, 80, 72 - i, 160, 96 + i, 2, 0, Screen::CR_NO_P_CHECK);
_screen->updateScreen();
@@ -1061,7 +1061,7 @@ void EoBEngine::seq_playFinale() {
gui_drawBox(0, 0, 176, 175, guiSettings()->colors.frame1, guiSettings()->colors.frame2, guiSettings()->colors.fill);
_txt->printDialogueText(51, _moreStrings[0]);
- if (!checkScriptFlags(0x1ffe)) {
+ if (!checkScriptFlags(0x1FFE)) {
_screen->fadeToBlack();
return;
}
diff --git a/engines/kyra/sequences_hof.cpp b/engines/kyra/sequences_hof.cpp
index f2abfb81dc..306f504b9e 100644
--- a/engines/kyra/sequences_hof.cpp
+++ b/engines/kyra/sequences_hof.cpp
@@ -21,94 +21,661 @@
*/
#include "kyra/kyra_hof.h"
-#include "kyra/timer.h"
+#include "kyra/screen_hof.h"
+#include "kyra/screen_lol.h"
#include "kyra/resource.h"
#include "kyra/sound.h"
+#include "kyra/sequences_hof.h"
+#include "kyra/timer.h"
#include "common/system.h"
namespace Kyra {
-void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) {
- seq_init();
+enum SequenceID {
+ kSequenceNoLooping = -1,
+ kSequenceVirgin = 0,
+ kSequenceWestwood,
+ kSequenceTitle,
+ kSequenceOverview,
+ kSequenceLibrary,
+ kSequenceHand,
+ kSequencePoint,
+ kSequenceZanfaun,
+
+ kSequenceFunters,
+ kSequenceFerb,
+ kSequenceFish,
+ kSequenceFheep,
+ kSequenceFarmer,
+ kSequenceFuards,
+ kSequenceFirates,
+ kSequenceFrash,
+
+ kSequenceHoFDemoVirgin,
+ kSequenceHoFDemoWestwood,
+ kSequenceHoFDemoTitle,
+ kSequenceHoFDemoHill,
+ kSequenceHoFDemoOuthome,
+ kSequenceHoFDemoWharf,
+ kSequenceHoFDemoDinob,
+ kSequenceHoFDemoFisher,
+
+// The following enums remain active even if LoL is disabled
+ kSequenceLoLDemoScene1,
+ kSequenceLoLDemoText1,
+ kSequenceLoLDemoScene2,
+ kSequenceLoLDemoText2,
+ kSequenceLoLDemoScene3,
+ kSequenceLoLDemoText3,
+ kSequenceLoLDemoScene4,
+ kSequenceLoLDemoText4,
+ kSequenceLoLDemoScene5,
+ kSequenceLoLDemoText5,
+ kSequenceLoLDemoScene6,
+
+ kSequenceArraySize
+};
+
+enum NestedSequenceID {
+ kNestedSequenceFiggle = 0,
+
+ kNestedSequenceOver1,
+ kNestedSequenceOver2,
+ kNestedSequenceForest,
+ kNestedSequenceDragon,
+ kNestedSequenceDarm,
+ kNestedSequenceLibrary2,
+ kNestedSequenceLibrary3,
+ kNestedSequenceMarco,
+ kNestedSequenceHand1a,
+ kNestedSequenceHand1b,
+ kNestedSequenceHand1c,
+ kNestedSequenceHand2,
+ kNestedSequenceHand3,
+ kNestedSequenceHand4,
+
+ kNestedSequenceHoFDemoWharf2,
+ kNestedSequenceHoFDemoDinob2,
+ kNestedSequenceHoFDemoWater,
+ kNestedSequenceHoFDemoBail,
+ kNestedSequenceHoFDemoDig,
+
+ kNestedSequenceArraySize
+};
+
+typedef int (SeqPlayer_HOF::*SeqProc)(WSAMovie_v2 *, int, int, int);
+
+struct SeqPlayerConfig {
+ SeqPlayerConfig(const HoFSeqData *data, const SeqProc *callbacks, const SeqProc *nestedCallbacks) : seq(data->seq), seqProc(callbacks), numSeq(data->numSeq), nestedSeq(data->nestedSeq), nestedSeqProc(nestedCallbacks), numNestedSeq(data->numNestedSeq) {}
+ const HoFSequence *seq;
+ const SeqProc *seqProc;
+ int numSeq;
+ const HoFNestedSequence *nestedSeq;
+ const SeqProc *nestedSeqProc;
+ int numNestedSeq;
+};
+
+class SeqPlayer_HOF {
+public:
+ SeqPlayer_HOF(KyraEngine_v1 *vm, Screen_v2 *screen, OSystem *system, bool startupSaveLoadable = false);
+ ~SeqPlayer_HOF();
+
+ int play(SequenceID firstScene, SequenceID loopStartScene);
+ void pause(bool toggle);
+
+ static SeqPlayer_HOF *instance() { return _instance; }
+
+private:
+ // Init
+ void setupCallbacks();
+
+ // Playback loop
+ void runLoop();
+ void playScenes();
+
+ bool checkAbortPlayback();
+ bool checkPlaybackStatus();
+
+ bool _abortRequested;
+ uint32 _pauseStart;
+
+ // Sequence transitions
+ void doTransition(int type);
+ void nestedFrameAnimTransition(int srcPage, int dstPage, int delaytime, int steps, int x, int y, int w, int h, int openClose, int directionFlags);
+ void nestedFrameFadeTransition(const char *cmpFile);
+
+ // Animations
+ void playAnimation(WSAMovie_v2 *wsaObj, int startFrame, int numFrames, int frameRate, int x, int y, const SeqProc callback, Palette *fadePal1, Palette *fadePal2, int fadeRate, bool restoreScreen);
+ void playDialogueAnimation(uint16 strID, uint16 soundID, int textColor, int textPosX, int textPosY, int textWidth, WSAMovie_v2 *wsaObj, int animStartFrame, int animLastFrame, int animPosX, int animPosY);
+
+ void startNestedAnimation(int animSlot, int sequenceID);
+ void closeNestedAnimation(int animSlot);
+ void unloadNestedAnimation(int animSlot);
+ void doNestedFrameTransition(int transitionType, int animSlot);
+ void updateAllNestedAnimations();
+ bool updateNestedAnimation(int animSlot);
+
+ struct AnimSlot {
+ 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 fadeInTransitionType;
+ uint16 fadeOutTransitionType;
+ };
+
+ AnimSlot _animSlots[8];
+
+ bool _updateAnimations;
+ uint32 _animDuration;
+ int _animCurrentFrame;
+ int _callbackCurrentFrame;
+
+ // The only reason to declare these here (instead of just locally) is being able to increase them after pausing the Engine
+ uint32 _specialAnimTimeOutTotal;
+ uint32 _specialAnimFrameTimeOut;
+
+ // Subtitles/Dialogue/Sound
+ void playSoundEffect(uint16 id, int16 vol);
+ void playSoundAndDisplaySubTitle(uint16 id);
+ void printFadingText(uint16 strID, int x, int y, const uint8 *colorMap, uint8 textcolor);
+
+ int displaySubTitle(uint16 strID, uint16 posX, uint16 posY, int duration, uint16 width);
+ void updateSubTitles();
+ char *preprocessString(const char *str, int width);
+ void waitForSubTitlesTimeout();
+ uint32 ticksTillSubTitlesTimeout();
+ void resetAllTextSlots();
+
+ void fadeOutMusic();
+
+ struct TextSlot {
+ uint16 strIndex;
+ uint16 x;
+ uint16 y;
+ uint16 width;
+ int32 duration;
+ uint32 startTime;
+ int16 textcolor;
+ };
- bool allowSkip = (_flags.isDemo && !_flags.isTalkie) || startSeq != kSequenceTitle;
+ TextSlot _textSlots[10];
- if (endSeq == -1)
- endSeq = startSeq;
+ char *_tempString;
- assert(startSeq >= 0 && endSeq < kSequenceArraySize && startSeq <= endSeq);
+ uint8 _textColor[2];
+ uint8 _textColorMap[16];
+ int _textDuration[33];
- _sound->setSoundList(&_soundData[(startSeq > kSequenceZanfaun) ? kMusicFinale : kMusicIntro]);
- _sound->loadSoundFile(0);
+ const char *const *_sequenceStrings;
+ const char *const *_sequenceSoundList;
+ int _sequenceSoundListSize;
- _screen->_charWidth = (_flags.gameID == GI_LOL) ? 0 : -2;
+ static const uint8 _textColorPresets[];
- memset(_activeWSA, 0, sizeof(ActiveWSA) * 8);
- for (int i = 0; i < 8; ++i)
- _activeWSA[i].flags = -1;
+ // HOF credits
+ void playHoFTalkieCredits();
+ void displayHoFTalkieScrollText(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);
+
+ bool _talkieFinaleExtraFlag;
+
+ // HOF+LOL demo specific
+ void updateDemoAdText(int bottom, int top);
+
+ ActiveItemAnim _hofDemoActiveItemAnim[5];
+ const HoFSeqItemAnimData *_hofDemoAnimData;
+
+ uint32 _fisherAnimCurTime;
+ int _scrollProgressCounter;
+
+ uint8 *_hofDemoShapeData;
+ uint8 *_hofDemoItemShapes[20];
+
+ // Misc
+ void delayTicks(uint32 ticks);
+ void delayUntil(uint32 dest);
+ void setCountDown(uint32 ticks);
+ bool countDownRunning();
+
+ uint32 _countDownRemainder;
+ uint32 _countDownLastUpdate;
+
+ enum SeqPlayerTargetInfo {
+ kHoF = 0,
+ kHoFDemo,
+ kLoLDemo
+ };
+
+ SeqPlayerTargetInfo _target;
+ int _firstScene, _loopStartScene, _curScene, _preventSkipBeforeScene, _lastScene;
+ bool _startupSaveLoadable, _isFinale, _preventLooping;
+
+ SeqPlayerConfig *_config;
+
+ MainMenu *_menu;
+ int _result;
+
+ bool _abortPlayback;
+
+ KyraEngine_v1 *_vm;
+ Screen_v2 *_screen;
+ // We might consider getting rid of Screen_HoF, since there are only 2 methods left in that class anyway
+ Screen_HoF *_screenHoF;
+ OSystem *_system;
+
+ static SeqPlayer_HOF *_instance;
+
+private:
+ // Sequence specific callback functions
+ int cbHOF_westwood(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_title(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_overview(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_library(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_hand(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_point(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_zanfaun(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+
+ int cbHOF_over1(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_over2(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_forest(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_dragon(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_darm(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_library2(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_marco(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_hand1a(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_hand1b(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_hand1c(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_hand2(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_hand3(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+
+ int cbHOF_funters(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_ferb(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_fish(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_fheep(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_farmer(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_fuards(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_firates(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOF_frash(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+
+ int cbHOF_figgle(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+
+ int cbHOFDEMO_virgin(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOFDEMO_westwood(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOFDEMO_title(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOFDEMO_hill(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOFDEMO_outhome(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOFDEMO_wharf(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOFDEMO_dinob(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOFDEMO_fisher(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+
+ int cbHOFDEMO_wharf2(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOFDEMO_dinob2(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOFDEMO_water(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOFDEMO_bail(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbHOFDEMO_dig(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+
+#ifdef ENABLE_LOL
+ int cbLOLDEMO_scene1(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbLOLDEMO_scene2(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbLOLDEMO_scene3(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbLOLDEMO_scene4(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbLOLDEMO_scene5(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbLOLDEMO_text5(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+ int cbLOLDEMO_scene6(WSAMovie_v2 *wsaObj, int x, int y, int frm);
+#endif // ENABLE_LOL
+};
+
+SeqPlayer_HOF *SeqPlayer_HOF::_instance = 0;
+
+SeqPlayer_HOF::SeqPlayer_HOF(KyraEngine_v1 *vm, Screen_v2 *screen, OSystem *system, bool startupSaveLoadable) : _vm(vm), _screen(screen), _system(system), _startupSaveLoadable(startupSaveLoadable) {
+ // We use a static pointer for pauseEngine functionality. Since we don't
+ // ever need more than one SeqPlayer_HOF object at the same time we keep
+ // this simple and just add an assert to detect typos, regressions, etc.
+ assert(_instance == 0);
+
+ memset(_animSlots, 0, sizeof(_animSlots));
+ memset(_textSlots, 0, sizeof(_textSlots));
+ memset(_hofDemoActiveItemAnim, 0, sizeof(_hofDemoActiveItemAnim));
+
+ _screenHoF = _vm->game() == GI_KYRA2 ? (Screen_HoF*)screen : 0;
+ _config = 0;
+ _result = 0;
+ _sequenceSoundList = 0;
+ _hofDemoAnimData = 0;
+ _hofDemoShapeData = 0;
+ _isFinale = false;
+ _preventLooping = false;
+ _menu = 0;
+ _abortRequested = false;
+ _pauseStart = 0;
+
+ _updateAnimations = false;
+ _animDuration = 0;
+ _animCurrentFrame = 0;
+ _callbackCurrentFrame = 0;
+
+ _abortPlayback = false;
+ _curScene = 0;
+ _preventSkipBeforeScene = -1;
+ _lastScene = 0;
+
+ _scrollProgressCounter = 0;
+ _fisherAnimCurTime = 0;
+
+ _tempString = new char[200];
+
+ _countDownRemainder = 0;
+ _countDownLastUpdate = 0;
+
+ int tempSize = 0;
+ _vm->resource()->unloadAllPakFiles();
+ _vm->resource()->loadPakFile(StaticResource::staticDataFilename());
+ const char *const *files = _vm->staticres()->loadStrings(k2SeqplayPakFiles, tempSize);
+ _vm->resource()->loadFileList(files, tempSize);
+
+ _sequenceStrings = _vm->staticres()->loadStrings(k2SeqplayStrings, tempSize);
+ uint8 multiplier = (_vm->gameFlags().platform == Common::kPlatformFMTowns || _vm->gameFlags().platform == Common::kPlatformPC98) ? 12 : 8;
+ for (int i = 0; i < MIN(33, tempSize); i++)
+ _textDuration[i] = (int) strlen(_sequenceStrings[i]) * multiplier;
+
+ if (_sequenceSoundList) {
+ for (int i = 0; i < _sequenceSoundListSize; i++) {
+ if (_sequenceSoundList[i])
+ delete[] _sequenceSoundList[i];
+ }
+ delete[] _sequenceSoundList;
+ _sequenceSoundList = 0;
+ }
- memset(_activeText, 0, sizeof(ActiveText) * 10);
- seq_resetAllTextEntries();
+ const char *const *seqSoundList = _vm->staticres()->loadStrings(k2SeqplaySfxFiles, _sequenceSoundListSize);
+ // replace sequence talkie files with localized versions
+ const char *const *tlkfiles = _vm->staticres()->loadStrings(k2SeqplayTlkFiles, tempSize);
+ 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 < tempSize; 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;
+ _vm->staticres()->unloadId(k2SeqplayTlkFiles);
+ _vm->staticres()->unloadId(k2SeqplaySfxFiles);
+ _sequenceSoundList = tmpSndLst;
+
+ if (_vm->gameFlags().platform == Common::kPlatformPC98)
+ _vm->sound()->loadSoundFile("SOUND.DAT");
+
+ _screen->loadFont(_screen->FID_GOLDFONT_FNT, "GOLDFONT.FNT");
+ _screen->setFont(_vm->gameFlags().lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_GOLDFONT_FNT);
+
+ if (_vm->gameFlags().isDemo && !_vm->gameFlags().isTalkie) {
+ if (_vm->game() == GI_KYRA2) {
+ _hofDemoAnimData = _vm->staticres()->loadHoFSeqItemAnimData(k2SeqplayShapeAnimData, tempSize);
+ uint8 *shp = _vm->resource()->fileData("ICONS.SHP", 0);
+ uint32 outsize = READ_LE_UINT16(shp + 4);
+ _hofDemoShapeData = new uint8[outsize];
+ Screen::decodeFrame4(shp + 10, _hofDemoShapeData, outsize);
+ for (int i = 0; i < 20; i++)
+ _hofDemoItemShapes[i] = _screen->getPtrToShape(_hofDemoShapeData, i);
+ delete[] shp;
+ }
+ } else {
+ const MainMenu::StaticData data = {
+ { _sequenceStrings[97], _sequenceStrings[96], _sequenceStrings[95], _sequenceStrings[98], 0 },
+ { 0x01, 0x04, 0x0C, 0x04, 0x00, 0xD7, 0xD6 },
+ { 0xD8, 0xDA, 0xD9, 0xD8 },
+ (_vm->gameFlags().lang == Common::JA_JPN) ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT, 240
+ };
+
+ _menu = new MainMenu(_vm);
+ _menu->init(data, MainMenu::Animation());
+ }
+
+ _instance = this;
+}
+
+SeqPlayer_HOF::~SeqPlayer_HOF() {
+ _instance = 0;
+
+ if (_sequenceSoundList) {
+ for (int i = 0; i < _sequenceSoundListSize; i++) {
+ if (_sequenceSoundList[i])
+ delete[] _sequenceSoundList[i];
+ }
+ delete[] _sequenceSoundList;
+ _sequenceSoundList = NULL;
+ }
+
+ delete[] _tempString;
+ delete[] _hofDemoShapeData;
+ delete _menu;
+
+ if (_vm->game() != GI_LOL)
+ _screen->setFont(_vm->gameFlags().lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT);
+}
+
+int SeqPlayer_HOF::play(SequenceID firstScene, SequenceID loopStartScene) {
+ bool incompatibleData = false;
+ AudioResourceSet soundSet = kMusicIntro;
+ _firstScene = firstScene;
+ _loopStartScene = loopStartScene;
+ _preventLooping = false;
+ _result = 0;
+
+ if (firstScene >= kSequenceArraySize || firstScene < kSequenceVirgin || loopStartScene >= kSequenceArraySize || loopStartScene < kSequenceNoLooping) {
+ return 0;
+ } else if (firstScene >= kSequenceLoLDemoScene1) {
+#ifndef ENABLE_LOL
+ error("SeqPlayer_HOF::play(): The Lands of Lore sub engine (including this non-interactive demo) has been disabled in this build");
+#endif
+ incompatibleData = (_vm->game() != GI_LOL);
+ _firstScene -= kSequenceLoLDemoScene1;
+ if (loopStartScene != kSequenceNoLooping)
+ _loopStartScene -= kSequenceLoLDemoScene1;
+ _lastScene = kSequenceLoLDemoScene6 - kSequenceLoLDemoScene1;
+ _target = kLoLDemo;
+ _screen->_charWidth = 0;
+ } else if (firstScene >= kSequenceHoFDemoVirgin) {
+ incompatibleData = (_vm->game() != GI_KYRA2 || !_vm->gameFlags().isDemo || _vm->gameFlags().isTalkie);
+ _firstScene -= kSequenceHoFDemoVirgin;
+ if (loopStartScene != kSequenceNoLooping)
+ _loopStartScene -= kSequenceHoFDemoVirgin;
+ _lastScene = kSequenceHoFDemoFisher - kSequenceHoFDemoVirgin;
+ _target = kHoFDemo;
+ _screen->_charWidth = -2;
+ } else {
+ _isFinale = _preventLooping = firstScene > kSequenceZanfaun;
+ incompatibleData = (_vm->game() != GI_KYRA2 || (_vm->gameFlags().isDemo && (!_vm->gameFlags().isTalkie || _isFinale)));
+ _target = kHoF;
+ _screen->_charWidth = -2;
+ if (_isFinale) {
+ soundSet = kMusicFinale;
+ _lastScene = kSequenceFrash;
+ } else {
+ _lastScene = kSequenceZanfaun;
+ }
+ }
+
+ if (incompatibleData)
+ error("SeqPlayer_HOF::play(): Specified sequences do not match the available sequence data for this target");
+
+ _vm->sound()->selectAudioResourceSet(soundSet);
+ _vm->sound()->loadSoundFile(0);
+
+ setupCallbacks();
+ runLoop();
+
+ return _result;
+}
+
+void SeqPlayer_HOF::pause(bool toggle) {
+ if (toggle) {
+ _pauseStart = _system->getMillis();
+ } else {
+ uint32 pausedTime = _system->getMillis() - _pauseStart;
+ _pauseStart = 0;
+
+ _countDownLastUpdate += pausedTime;
+ _fisherAnimCurTime += pausedTime;
+ _specialAnimTimeOutTotal += pausedTime;
+ _specialAnimFrameTimeOut += pausedTime;
+
+ for (int i = 0; i < 10; i++) {
+ if (_textSlots[i].duration != -1)
+ _textSlots[i].startTime += pausedTime;
+ }
+
+ for (int i = 0; i < 8; i++) {
+ if (_animSlots[i].flags != -1)
+ _animSlots[i].nextFrame += pausedTime;
+ }
+ }
+}
+
+void SeqPlayer_HOF::setupCallbacks() {
+#define SCB(x) &SeqPlayer_HOF::cbHOF_##x
+ static const SeqProc seqCallbacksHoF[] = { 0, SCB(westwood), SCB(title), SCB(overview), SCB(library), SCB(hand), SCB(point), SCB(zanfaun), SCB(funters), SCB(ferb), SCB(fish), SCB(fheep), SCB(farmer), SCB(fuards), SCB(firates), SCB(frash) };
+ static const SeqProc nestedSeqCallbacksHoF[] = { SCB(figgle), SCB(over1), SCB(over2), SCB(forest), SCB(dragon), SCB(darm), SCB(library2), SCB(library2), SCB(marco), SCB(hand1a), SCB(hand1b), SCB(hand1c), SCB(hand2), SCB(hand3), 0 };
+#undef SCB
+#define SCB(x) &SeqPlayer_HOF::cbHOFDEMO_##x
+ static const SeqProc seqCallbacksHoFDemo[] = { SCB(virgin), SCB(westwood), SCB(title), SCB(hill), SCB(outhome), SCB(wharf), SCB(dinob), SCB(fisher) };
+ static const SeqProc nestedSeqCallbacksHoFDemo[] = { SCB(wharf2), SCB(dinob2), SCB(water), SCB(bail), SCB(dig), 0 };
+#undef SCB
+#ifdef ENABLE_LOL
+#define SCB(x) &SeqPlayer_HOF::cbLOLDEMO_##x
+ static const SeqProc seqCallbacksLoLDemo[] = { SCB(scene1), 0, SCB(scene2), 0, SCB(scene3), 0, SCB(scene4), 0, SCB(scene5), SCB(text5), SCB(scene6), 0 };
+#undef SCB
+#else
+ static const SeqProc seqCallbacksLoLDemo[] = { 0 };
+#endif
+ static const SeqProc nestedSeqCallbacksLoLDemo[] = { 0 };
+
+ static const SeqProc *const seqCallbacks[] = { seqCallbacksHoF, seqCallbacksHoFDemo, seqCallbacksLoLDemo};
+ static const SeqProc *const nestedSeqCallbacks[] = { nestedSeqCallbacksHoF, nestedSeqCallbacksHoFDemo, nestedSeqCallbacksLoLDemo};
+
+ int tmpSize = 0;
+ delete _config;
+ _config = new SeqPlayerConfig(_vm->staticres()->loadHoFSequenceData(k2SeqplaySeqData, tmpSize), seqCallbacks[_target], nestedSeqCallbacks[_target]);
+}
+
+void SeqPlayer_HOF::runLoop() {
+ memset(_animSlots, 0, sizeof(_animSlots));
+ memset(_textSlots, 0, sizeof(_textSlots));
+ memset(_hofDemoActiveItemAnim, 0, sizeof(_hofDemoActiveItemAnim));
+ for (int i = 0; i < 8; ++i)
+ _animSlots[i].flags = -1;
+
+ _screen->clearPage(10);
+ _screen->clearPage(12);
_screen->hideMouse();
int oldPage = _screen->setCurPage(2);
for (int i = 0; i < 4; ++i)
_screen->getPalette(i).clear();
- _screen->clearPage(10);
- _screen->clearPage(12);
+ _updateAnimations = false;
+ _animCurrentFrame = 0;
+ _textColor[0] = _textColor[1] = 0;
+ _curScene = _firstScene;
- _seqSubframePlaying = false;
+ do {
+ playScenes();
+ doTransition(0);
+ resetAllTextSlots();
+ fadeOutMusic();
+ _firstScene = ((!_startupSaveLoadable || _preventLooping) && _curScene >= _loopStartScene) ? kSequenceNoLooping : _loopStartScene;
+ } while (!_vm->shouldQuit() && _firstScene != kSequenceNoLooping);
- _seqWsaCurrentFrame = 0;
- _seqTextColor[0] = _seqTextColor[1] = 0;
- _seqEndTime = 0;
- _menuChoice = 0;
+ checkPlaybackStatus();
- for (int seqNum = startSeq; seqNum <= endSeq && !((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice); seqNum++) {
- _screen->clearPage(0);
- _screen->clearPage(8);
- _screen->copyPalette(1, 0);
- _seqFrameCounter = 0;
- _seqStartTime = _system->getMillis();
+ for (int i = 0; i < 8; i++)
+ unloadNestedAnimation(i);
+
+ if (_vm->gameFlags().isDemo && !_vm->gameFlags().isTalkie)
+ _screen->fadeToBlack();
+ else if (!_isFinale && !_startupSaveLoadable)
+ _result = 1;
- allowSkip = (_flags.isDemo && !_flags.isTalkie) || seqNum != kSequenceTitle;
+ if (!_result)
+ delayTicks(75);
- Sequence cseq = _sequences->seq[seqNum];
- SeqProc cb = _callbackS[seqNum];
+ _screen->setCurPage(oldPage);
+ _screen->_charWidth = 0;
+ _screen->showMouse();
+}
- if (cseq.flags & 2) {
- _screen->loadBitmap(cseq.cpsFile, 2, 2, &_screen->getPalette(0));
+void SeqPlayer_HOF::playScenes() {
+ _vm->sound()->stopAllSoundEffects();
+ _curScene = _firstScene;
+
+ _screen->copyPalette(1, 0);
+ WSAMovie_v2 anim(_vm);
+ _abortRequested = false;
+
+ _scrollProgressCounter = 0;
+
+ while (!_vm->shouldQuit()) {
+ if (checkAbortPlayback())
+ if (checkPlaybackStatus())
+ break;
+
+ _callbackCurrentFrame = 0;
+
+ if (_curScene > _lastScene)
+ break;
+
+ const Kyra::HoFSequence &sq = _config->seq[_curScene];
+
+ if (sq.flags & 2) {
+ _screen->loadBitmap(sq.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));
+ _screen->loadPalette("GOLDFONT.COL", _screen->getPalette(0));
}
- if (cb && !(_flags.isDemo && !_flags.isTalkie))
- (this->*cb)(0, 0, 0, -1);
+ if (_config->seqProc[_curScene] && !(_vm->gameFlags().isDemo && !_vm->gameFlags().isTalkie))
+ (this->*_config->seqProc[_curScene])(0, 0, 0, -1);
- if (cseq.flags & 1) {
- _seqWsa->close();
- _seqWsa->open(cseq.wsaFile, 0, &_screen->getPalette(0));
- _screen->setScreenPalette(_screen->getPalette(0));
- _seqWsa->displayFrame(0, 2, cseq.xPos, cseq.yPos, 0, 0, 0);
+ if (sq.flags & 1) {
+ anim.open(sq.wsaFile, 0, &_screen->getPalette(0));
+ if (!(sq.flags & 2))
+ anim.displayFrame(0, 2, sq.xPos, sq.yPos, 0x4000, 0, 0);
}
- if (cseq.flags & 4) {
+ if (sq.flags & 4) {
int cp = _screen->setCurPage(2);
- Screen::FontId cf = _screen->setFont(_flags.lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_GOLDFONT_FNT);
- if (cseq.stringIndex1 != -1) {
- int sX = (320 - _screen->getTextWidth(_sequenceStrings[cseq.stringIndex1])) / 2;
- _screen->printText(_sequenceStrings[cseq.stringIndex1], sX, 100 - _screen->getFontHeight(), 1, 0);
- }
- if (cseq.stringIndex2 != -1) {
- int sX = (320 - _screen->getTextWidth(_sequenceStrings[cseq.stringIndex2])) / 2;
- _screen->printText(_sequenceStrings[cseq.stringIndex2], sX, 100, 1, 0);
- }
+ Screen::FontId cf = _screen->setFont(_vm->gameFlags().lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_GOLDFONT_FNT);
+
+ if (sq.stringIndex1 != -1)
+ _screen->printText(_sequenceStrings[sq.stringIndex1], (320 - _screen->getTextWidth(_sequenceStrings[sq.stringIndex1])) / 2, 100 - _screen->getFontHeight(), 1, 0);
+
+ if (sq.stringIndex2 != -1)
+ _screen->printText(_sequenceStrings[sq.stringIndex2], (320 - _screen->getTextWidth(_sequenceStrings[sq.stringIndex2])) / 2, 100, 1, 0);
+
_screen->setFont(cf);
_screen->setCurPage(cp);
}
@@ -118,268 +685,1139 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) {
_screen->copyPage(2, 10);
_screen->copyPage(12, 2);
- seq_sequenceCommand(cseq.startupCommand);
+ doTransition(sq.fadeInTransitionType);
- if (!((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ if (!(checkAbortPlayback() || _vm->shouldQuit() || _result)) {
_screen->copyPage(2, 0);
_screen->updateScreen();
}
- if (cseq.flags & 1) {
- int x = cseq.xPos;
- int y = cseq.yPos;
+ if (sq.flags & 1) {
+ playAnimation(&anim, sq.startFrame, sq.numFrames, sq.duration, sq.xPos, sq.yPos, _config->seqProc[_curScene], &_screen->getPalette(1), &_screen->getPalette(0), 30, 0);
+ anim.close();
+ } else {
+ _animDuration = sq.duration;
+ setCountDown(_animDuration);
- _seqFrameDelay = cseq.frameDelay;
+ while (!checkAbortPlayback() && !_vm->shouldQuit() && (countDownRunning() || _updateAnimations)) {
+ uint32 endFrame = (_system->getMillis() + _vm->tickLength()) & ~(_vm->tickLength() - 1);
+ updateAllNestedAnimations();
- if (_seqWsa) {
- if (x < 0) {
- _seqWsa->setWidth(_seqWsa->width() + x);
- x = 0;
- }
+ if (_config->seqProc[_curScene])
+ (this->*_config->seqProc[_curScene])(0, 0, 0, 0);
- if (y < 0) {
- _seqWsa->setHeight(_seqWsa->height() + y);
- y = 0;
- }
+ updateSubTitles();
- if (cseq.xPos + _seqWsa->width() > 319)
- _seqWsa->setWidth(320 - cseq.xPos);
+ _screen->copyPage(2, 0);
+ _screen->updateScreen();
+ _screen->copyPage(12, 2);
- if (cseq.yPos + _seqWsa->height() > 199)
- _seqWsa->setHeight(199 - cseq.yPos);
+ do {
+ if (checkAbortPlayback())
+ if (checkPlaybackStatus())
+ break;
+ } while (_system->getMillis() < endFrame);
}
- uint8 dir = (cseq.startFrame > cseq.numFrames) ? 0 : 1;
- _seqWsaCurrentFrame = cseq.startFrame;
+ }
- bool loop = true;
- while (loop && !((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
- _seqEndTime = _system->getMillis() + _seqFrameDelay * _tickLength;
+ if (_config->seqProc[_curScene] && !(_vm->gameFlags().isDemo && !_vm->gameFlags().isTalkie))
+ (this->*_config->seqProc[_curScene])(0, 0, 0, -2);
- if (_seqWsa || !cb)
- _screen->copyPage(12, 2);
+ uint32 textTimeOut = ticksTillSubTitlesTimeout();
+ setCountDown(sq.timeout < textTimeOut ? textTimeOut : sq.timeout);
- if (cb) {
- int f = _seqWsaCurrentFrame % _seqWsa->frames();
- (this->*cb)(_seqWsa, cseq.xPos, cseq.yPos, f);
- }
+ while (!checkAbortPlayback() && !_vm->shouldQuit() && (countDownRunning() || _updateAnimations)) {
+ updateAllNestedAnimations();
+ _screen->copyPage(2, 0);
+ _screen->updateScreen();
+ _screen->copyPage(12, 2);
+ }
- if (_seqWsa) {
- int f = _seqWsaCurrentFrame % _seqWsa->frames();
- _seqWsa->displayFrame(f, 2, cseq.xPos, cseq.yPos, 0, 0, 0);
- }
+ doTransition(sq.fadeOutTransitionType);
+ _curScene++;
+ }
- _screen->copyPage(2, 12);
+ resetAllTextSlots();
+ _vm->sound()->haltTrack();
+ _vm->sound()->voiceStop();
- seq_processWSAs();
- seq_processText();
+ if ((!checkAbortPlayback() || _vm->shouldQuit()) && _vm->gameFlags().isDemo)
+ _curScene = -1;
+}
- if ((_seqWsa || !cb) && !((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
- _screen->copyPage(2, 0);
- _screen->updateScreen();
- }
+bool SeqPlayer_HOF::checkAbortPlayback() {
+ Common::Event event;
- bool loop2 = true;
- while (loop2 && !((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
- if (_seqWsa) {
- seq_processText();
- if (!((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
- _screen->copyPage(2, 0);
- _screen->updateScreen();
- }
-
- uint32 now = _system->getMillis();
- if (now >= _seqEndTime) {
- loop2 = false;
- } else {
- uint32 tdiff = _seqEndTime - now;
- uint32 dly = tdiff < _tickLength ? tdiff : _tickLength;
- delay(dly);
- }
- } else {
- loop = loop2 = false;
- }
- }
+ if (_vm->skipFlag()) {
+ _abortRequested = true;
+ _vm->resetSkipFlag();
+ }
- if (loop) {
- if (dir == 1) {
- if (++_seqWsaCurrentFrame >= cseq.numFrames)
- loop = false;
- } else {
- if (--_seqWsaCurrentFrame < cseq.numFrames)
- loop = false;
- }
- }
+ if (_abortRequested)
+ return true;
+
+ while (_system->getEventManager()->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ if (event.kbd.keycode == Common::KEYCODE_q && event.kbd.hasFlags(Common::KBD_CTRL)) {
+ _abortRequested = true;
+ _vm->quitGame();
+ return true;
+ } else if (event.kbd.keycode != Common::KEYCODE_ESCAPE && event.kbd.keycode != Common::KEYCODE_RETURN && event.kbd.keycode != Common::KEYCODE_SPACE) {
+ continue;
}
- _seqWsa->close();
- } else {
- _seqFrameDelay = cseq.frameDelay;
- _seqEndTime = _system->getMillis() + _seqFrameDelay * _tickLength;
- while (!((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
- _seqSubFrameStartTime = _system->getMillis();
- seq_processWSAs();
- if (cb)
- (this->*cb)(0, 0, 0, 0);
+ // fall through
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONUP:
+ _abortRequested = true;
+ return true;
+ default:
+ break;
+ }
+ }
- seq_processText();
+ return false;
+}
- _screen->copyPage(2, 0);
- _screen->updateScreen();
- _screen->copyPage(12, 2);
+bool SeqPlayer_HOF::checkPlaybackStatus() {
+ _updateAnimations = false;
- uint32 now = _system->getMillis();
- if (now >= _seqEndTime && !_seqSubframePlaying)
- break;
+ if (_curScene <= _preventSkipBeforeScene || (_curScene == _loopStartScene && !_isFinale)) {
+ _abortRequested = false;
+ return false;
+ }
- uint32 tdiff = _seqEndTime - _seqSubFrameStartTime;
- int32 dly = _tickLength - (now - _seqSubFrameStartTime);
- if (dly > 0)
- delay(MIN<uint32>(dly, tdiff));
- else
- updateInput();
- }
+ if (_loopStartScene == kSequenceNoLooping) {
+ doTransition(0);
+ fadeOutMusic();
+ _abortPlayback = true;
+ }
+
+ return true;
+}
+
+void SeqPlayer_HOF::doTransition(int type) {
+ for (int i = 0; i < 8; i++)
+ closeNestedAnimation(i);
+
+ switch (type) {
+ case 0:
+ _screen->fadeToBlack(36);
+ _screen->getPalette(0).clear();
+ _screen->getPalette(1).clear();
+ break;
+
+ case 1:
+ playSoundAndDisplaySubTitle(_vm->_rnd.getRandomBit());
+
+ _screen->getPalette(0).fill(0, 256, 0x3F);
+ _screen->fadePalette(_screen->getPalette(0), 16);
+
+ _screen->copyPalette(1, 0);
+ break;
+
+ case 3:
+ _screen->copyPage(2, 0);
+ _screen->fadePalette(_screen->getPalette(0), 16);
+ _screen->copyPalette(1, 0);
+ break;
+
+ case 4:
+ _screen->copyPage(2, 0);
+ _screen->fadePalette(_screen->getPalette(0), 36);
+ _screen->copyPalette(1, 0);
+ break;
+
+ case 5:
+ _screen->copyPage(2, 0);
+ break;
+
+ case 6:
+ // UNUSED
+ // seq_loadBLD("library.bld");
+ break;
+
+ case 7:
+ // UNUSED
+ // seq_loadBLD("marco.bld");
+ break;
+
+ case 8:
+ _screen->fadeToBlack(16);
+ _screen->getPalette(0).clear();
+ _screen->getPalette(1).clear();
+
+ delayTicks(120);
+ break;
+
+ case 9: {
+ Palette &pal = _screen->getPalette(0);
+ for (int i = 0; i < 255; i++)
+ pal.fill(i, 1, (pal[3 * i] + pal[3 * i + 1] + pal[3 * i + 2]) / 3);
+ pal.fill(255, 1, 0x3F);
+
+ _screen->fadePalette(pal, 64);
+ _screen->copyPalette(1, 0);
+ } break;
+
+ default:
+ break;
+ }
+}
+
+void SeqPlayer_HOF::nestedFrameAnimTransition(int srcPage, int dstPage, int delaytime, int steps, int x, int y, int w, int h, int openClose, int directionFlags) {
+ if (openClose) {
+ for (int i = 1; i < steps; i++) {
+ uint32 endtime = _system->getMillis() + delaytime * _vm->tickLength();
+
+ int w2 = (((w * 256) / steps) * i) / 256;
+ int h2 = (((h * 256) / steps) * i) / 256;
+
+ int ym = (directionFlags & 2) ? (h - h2) : 0;
+ int xm = (directionFlags & 1) ? (w - w2) : 0;
+
+ _screen->wsaFrameAnimationStep(0, 0, x + xm, y + ym, w, h, w2, h2, srcPage, dstPage, 0);
+
+ _screen->copyPage(dstPage, 6);
+ _screen->copyPage(dstPage, 0);
+ _screen->updateScreen();
+
+ _screen->copyPage(12, dstPage);
+ delayUntil(endtime);
+ }
+
+ _screen->wsaFrameAnimationStep(0, 0, x, y, w, h, w, h, srcPage, dstPage, 0);
+ _screen->copyPage(dstPage, 6);
+ _screen->copyPage(dstPage, 0);
+ _screen->updateScreen();
+ } else {
+ _screen->copyPage(12, dstPage);
+ for (int i = steps; i; i--) {
+ uint32 endtime = _system->getMillis() + delaytime * _vm->tickLength();
+
+ int w2 = (((w * 256) / steps) * i) / 256;
+ int h2 = (((h * 256) / steps) * i) / 256;
+
+ int ym = (directionFlags & 2) ? (h - h2) : 0;
+ int xm = (directionFlags & 1) ? (w - w2) : 0;
+
+ _screen->wsaFrameAnimationStep(0, 0, x + xm, y + ym, w, h, w2, h2, srcPage, dstPage, 0);
+
+ _screen->copyPage(dstPage, 6);
+ _screen->copyPage(dstPage, 0);
+ _screen->updateScreen();
+
+ _screen->copyPage(12, dstPage);
+ delayUntil(endtime);
+ }
+ }
+}
+
+void SeqPlayer_HOF::nestedFrameFadeTransition(const char *cmpFile) {
+ _screen->copyPage(10, 2);
+ _screen->copyPage(4, 10);
+ _screen->clearPage(6);
+ _screen->loadBitmap(cmpFile, 6, 6, 0);
+ _screen->copyPage(12, 4);
+
+ for (int i = 0; i < 3; i++) {
+ uint32 endtime = _system->getMillis() + 4 * _vm->tickLength();
+ assert(_screenHoF);
+ _screenHoF->cmpFadeFrameStep(4, 320, 200, 0, 0, 2, 320, 200, 0, 0, 320, 200, 6);
+ _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0);
+ _screen->updateScreen();
+ delayUntil(endtime);
+ }
+
+ _screen->copyPage(4, 0);
+ _screen->updateScreen();
+ _screen->copyPage(4, 2);
+ _screen->copyPage(4, 6);
+ _screen->copyPage(10, 4);
+}
+
+void SeqPlayer_HOF::playAnimation(WSAMovie_v2 *wsaObj, int startFrame, int lastFrame, int frameRate, int x, int y, const SeqProc callback, Palette *fadePal1, Palette *fadePal2, int fadeRate, bool restoreScreen) {
+ bool finished = false;
+ uint32 startTime = _system->getMillis();
+
+ int origW = wsaObj ? wsaObj->width() : 0;
+ int origH = wsaObj ? wsaObj->height() : 0;
+ int drwX = x;
+ int drwY = y;
+ int drwW = origW;
+ int drwH = origH;
+
+ _animDuration = frameRate;
+
+ if (wsaObj) {
+ if (x < 0) {
+ drwW += x;
+ drwX = 0;
}
- if (cb && !(_flags.isDemo && !_flags.isTalkie))
- (this->*cb)(0, 0, 0, -2);
+ if (y < 0) {
+ drwH += y;
+ drwY = 0;
+ }
+
+ if (x + origW > 319)
+ origW = 320 - x;
+
+ if (y + origH > 199)
+ origW = 200 - y;
+ }
+
+ int8 frameStep = (startFrame > lastFrame) ? -1 : 1;
+ _animCurrentFrame = startFrame;
+
+ while (!_vm->shouldQuit() && !finished) {
+ if (checkAbortPlayback())
+ if (checkPlaybackStatus())
+ break;
+
+ setCountDown(_animDuration);
- uint32 ct = seq_activeTextsTimeLeft();
- uint32 dl = cseq.duration * _tickLength;
- if (dl < ct)
- dl = ct;
- _seqEndTime = _system->getMillis() + dl;
+ if (wsaObj || callback)
+ _screen->copyPage(12, 2);
+
+ int frameIndex = _animCurrentFrame;
+ if (wsaObj)
+ frameIndex %= wsaObj->frames();
+
+ if (callback)
+ (this->*callback)(wsaObj, x, y, frameIndex);
+
+ if (wsaObj)
+ wsaObj->displayFrame(frameIndex, 2, x, y, 0, 0, 0);
+
+ _screen->copyPage(2, 12);
- while (!((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
- _seqSubFrameStartTime = _system->getMillis();
- seq_processWSAs();
+ updateAllNestedAnimations();
+ updateSubTitles();
+ if ((wsaObj || callback) && (!(checkAbortPlayback() || _vm->shouldQuit() || _result))) {
_screen->copyPage(2, 0);
_screen->updateScreen();
+ }
+
+ while (!_vm->shouldQuit()) {
+ if (checkAbortPlayback())
+ if (checkPlaybackStatus())
+ break;
+
+ if (fadePal1 && fadePal2) {
+ if (!_screen->timedPaletteFadeStep(fadePal1->getData(), fadePal2->getData(), _system->getMillis() - startTime, fadeRate * _vm->tickLength()) && !wsaObj)
+ break;
+ }
+
+ if ((wsaObj || callback) && (!(checkAbortPlayback() || _vm->shouldQuit() || _result))) {
+ _screen->copyPage(2, 0);
+ _screen->updateScreen();
+ }
+
+ updateSubTitles();
+
+ if (!countDownRunning())
+ break;
+ }
+
+ if (wsaObj) {
+ _animCurrentFrame += frameStep;
+ if ((frameStep > 0 && _animCurrentFrame >= lastFrame) || (frameStep < 0 && _animCurrentFrame < lastFrame))
+ finished = true;
+ }
+
+ if (restoreScreen && (wsaObj || callback)) {
_screen->copyPage(12, 2);
+ _screen->copyRegion(drwX, drwY, drwX, drwY, drwW, drwH, 2, 0, Screen::CR_NO_P_CHECK);
+ _screen->updateScreen();
+ }
+ }
+}
+
+void SeqPlayer_HOF::playDialogueAnimation(uint16 strID, uint16 soundID, int textColor, int textPosX, int textPosY, int textWidth, WSAMovie_v2 *wsaObj, int animStartFrame, int animLastFrame, int animPosX, int animPosY) {
+ int dur = int(strlen(_sequenceStrings[strID])) * (_vm->gameFlags().isTalkie ? 7 : 15);
+ if (_vm->textEnabled()) {
+ int slot = displaySubTitle(strID, textPosX, textPosY, dur, textWidth);
+ if (slot >= 0)
+ _textSlots[slot].textcolor = textColor;
+ }
+ _specialAnimTimeOutTotal = _system->getMillis() + dur * _vm->tickLength();
+ int curframe = animStartFrame;
+
+ if (soundID && _vm->speechEnabled()) {
+ while (_vm->sound()->voiceIsPlaying() && !_abortPlayback)
+ delayTicks(1);
+ playSoundAndDisplaySubTitle(soundID);
+ }
+
+ while (_system->getMillis() < _specialAnimTimeOutTotal && !_abortPlayback) {
+ if (animLastFrame < 0) {
+ int t = ABS(animLastFrame);
+ if (t < curframe)
+ curframe = t;
+ }
+
+ if (ABS(animLastFrame) < curframe)
+ curframe = animStartFrame;
+
+ _specialAnimFrameTimeOut = _system->getMillis() + _animDuration * _vm->tickLength();
+ setCountDown(_animDuration);
- uint32 now = _system->getMillis();
- if (now >= _seqEndTime && !_seqSubframePlaying) {
+ if (wsaObj)
+ wsaObj->displayFrame(curframe % wsaObj->frames(), 2, animPosX, animPosY, 0, 0, 0);
+
+ _screen->copyPage(2, 12);
+ updateSubTitles();
+ delayUntil(MIN(_specialAnimFrameTimeOut, _specialAnimTimeOutTotal));
+
+ if (_vm->speechEnabled() && !_vm->textEnabled() && !_vm->snd_voiceIsPlaying())
+ break;
+
+ if (checkAbortPlayback())
+ if (checkPlaybackStatus())
break;
- }
- uint32 tdiff = _seqEndTime - _seqSubFrameStartTime;
- int32 dly = _tickLength - (now - _seqSubFrameStartTime);
- if (dly > 0)
- delay(MIN<uint32>(dly, tdiff));
+ _screen->copyPage(2, 0);
+ _screen->updateScreen();
+ curframe++;
+ }
+
+ if (_abortPlayback)
+ _vm->sound()->voiceStop();
+
+ if (ABS(animLastFrame) < curframe)
+ curframe = ABS(animLastFrame);
+
+ if (curframe == animStartFrame)
+ curframe++;
+
+ _animCurrentFrame = curframe;
+}
+
+void SeqPlayer_HOF::startNestedAnimation(int animSlot, int sequenceID) {
+ if (_animSlots[animSlot].flags != -1)
+ return;
+
+ if (_target == kLoLDemo) {
+ return;
+ } else if (_target == kHoFDemo) {
+ assert(sequenceID >= kNestedSequenceHoFDemoWharf2);
+ sequenceID -= kNestedSequenceHoFDemoWharf2;
+ }
+
+ HoFNestedSequence s = _config->nestedSeq[sequenceID];
+
+ if (!_animSlots[animSlot].movie) {
+ _animSlots[animSlot].movie = new WSAMovie_v2(_vm);
+ assert(_animSlots[animSlot].movie);
+ }
+
+ _animSlots[animSlot].movie->close();
+
+ _animSlots[animSlot].movie->open(s.wsaFile, 0, 0);
+
+ if (!_animSlots[animSlot].movie->opened()) {
+ delete _animSlots[animSlot].movie;
+ _animSlots[animSlot].movie = 0;
+ return;
+ }
+
+ _animSlots[animSlot].endFrame = s.endFrame;
+ _animSlots[animSlot].startFrame = _animSlots[animSlot].currentFrame = s.startframe;
+ _animSlots[animSlot].frameDelay = s.frameDelay;
+ _animSlots[animSlot].callback = _config->nestedSeqProc[sequenceID];
+ _animSlots[animSlot].control = s.wsaControl;
+
+ _animSlots[animSlot].flags = s.flags | 1;
+ _animSlots[animSlot].x = s.x;
+ _animSlots[animSlot].y = s.y;
+ _animSlots[animSlot].fadeInTransitionType = s.fadeInTransitionType;
+ _animSlots[animSlot].fadeOutTransitionType = s.fadeOutTransitionType;
+ _animSlots[animSlot].lastFrame = 0xFFFF;
+
+ doNestedFrameTransition(s.fadeInTransitionType, animSlot);
+
+ if (!s.fadeInTransitionType)
+ updateNestedAnimation(animSlot);
+
+ _animSlots[animSlot].nextFrame = _system->getMillis() & ~(_vm->tickLength() - 1);
+}
+
+void SeqPlayer_HOF::closeNestedAnimation(int animSlot) {
+ if (_animSlots[animSlot].flags == -1)
+ return;
+
+ _animSlots[animSlot].flags = -1;
+ doNestedFrameTransition(_animSlots[animSlot].fadeOutTransitionType, animSlot);
+ _animSlots[animSlot].movie->close();
+}
+
+void SeqPlayer_HOF::unloadNestedAnimation(int animSlot) {
+ if (_animSlots[animSlot].movie) {
+ _animSlots[animSlot].movie->close();
+ delete _animSlots[animSlot].movie;
+ _animSlots[animSlot].movie = 0;
+ }
+}
+
+void SeqPlayer_HOF::doNestedFrameTransition(int transitionType, int animSlot) {
+ int xa = 0, ya = 0;
+ transitionType--;
+ if (!_animSlots[animSlot].movie || _abortPlayback || _vm->shouldQuit())
+ return;
+
+ switch (transitionType) {
+ case 0:
+ xa = -_animSlots[animSlot].movie->xAdd();
+ ya = -_animSlots[animSlot].movie->yAdd();
+ _animSlots[animSlot].movie->displayFrame(0, 8, xa, ya, 0, 0, 0);
+ nestedFrameAnimTransition(8, 2, 7, 8, _animSlots[animSlot].movie->xAdd(), _animSlots[animSlot].movie->yAdd(),
+ _animSlots[animSlot].movie->width(), _animSlots[animSlot].movie->height(), 1, 2);
+ break;
+
+ case 1:
+ xa = -_animSlots[animSlot].movie->xAdd();
+ ya = -_animSlots[animSlot].movie->yAdd();
+ _animSlots[animSlot].movie->displayFrame(0, 8, xa, ya, 0, 0, 0);
+ nestedFrameAnimTransition(8, 2, 7, 8, _animSlots[animSlot].movie->xAdd(), _animSlots[animSlot].movie->yAdd(),
+ _animSlots[animSlot].movie->width(), _animSlots[animSlot].movie->height(), 1, 1);
+ break;
+
+ case 2:
+ waitForSubTitlesTimeout();
+ xa = -_animSlots[animSlot].movie->xAdd();
+ ya = -_animSlots[animSlot].movie->yAdd();
+ _animSlots[animSlot].movie->displayFrame(21, 8, xa, ya, 0, 0, 0);
+ nestedFrameAnimTransition(8, 2, 7, 8, _animSlots[animSlot].movie->xAdd(), _animSlots[animSlot].movie->yAdd(),
+ _animSlots[animSlot].movie->width(), _animSlots[animSlot].movie->height(), 0, 2);
+ break;
+
+ case 3:
+ _screen->copyPage(2, 10);
+ _animSlots[animSlot].movie->displayFrame(0, 2, 0, 0, 0, 0, 0);
+ _screen->copyPage(2, 12);
+ nestedFrameFadeTransition("scene2.cmp");
+ break;
+
+ case 4:
+ _screen->copyPage(2, 10);
+ _animSlots[animSlot].movie->displayFrame(0, 2, 0, 0, 0, 0, 0);
+ _screen->copyPage(2, 12);
+ nestedFrameFadeTransition("scene3.cmp");
+ break;
+
+ default:
+ break;
+ }
+}
+
+void SeqPlayer_HOF::updateAllNestedAnimations() {
+ for (int i = 0; i < 8; i++) {
+ if (_animSlots[i].flags != -1) {
+ if (updateNestedAnimation(i))
+ closeNestedAnimation(i);
+ }
+ }
+}
+
+bool SeqPlayer_HOF::updateNestedAnimation(int animSlot) {
+ uint16 currentFrame = _animSlots[animSlot].currentFrame;
+ uint32 curTick = _system->getMillis() & ~(_vm->tickLength() - 1);
+
+ if (_animSlots[animSlot].callback && currentFrame != _animSlots[animSlot].lastFrame) {
+ _animSlots[animSlot].lastFrame = currentFrame;
+ currentFrame = (this->*_animSlots[animSlot].callback)(_animSlots[animSlot].movie, _animSlots[animSlot].x, _animSlots[animSlot].y, currentFrame);
+ }
+
+ if (_animSlots[animSlot].movie) {
+ if (_animSlots[animSlot].flags & 0x20) {
+ _animSlots[animSlot].movie->displayFrame(_animSlots[animSlot].control[currentFrame].index, 2, _animSlots[animSlot].x, _animSlots[animSlot].y, 0x4000, 0, 0);
+ _animSlots[animSlot].frameDelay = _animSlots[animSlot].control[currentFrame].delay;
+ } else {
+ _animSlots[animSlot].movie->displayFrame(currentFrame % _animSlots[animSlot].movie->frames(), 2, _animSlots[animSlot].x, _animSlots[animSlot].y, 0x4000, 0, 0);
+ }
+ }
+
+ if (_animSlots[animSlot].flags & 0x10) {
+ currentFrame = (curTick - _animSlots[animSlot].nextFrame) / (_animSlots[animSlot].frameDelay * _vm->tickLength());
+ } else {
+ int diff = (curTick - _animSlots[animSlot].nextFrame) / (_animSlots[animSlot].frameDelay * _vm->tickLength());
+ if (diff > 0) {
+ currentFrame++;
+ if (_vm->gameFlags().platform == Common::kPlatformFMTowns || _vm->gameFlags().platform == Common::kPlatformPC98)
+ _animSlots[animSlot].nextFrame += ((curTick - _animSlots[animSlot].nextFrame) * 2 / 3);
else
- updateInput();
+ _animSlots[animSlot].nextFrame = curTick;
}
+ }
+
+ bool res = false;
- seq_sequenceCommand(cseq.finalCommand);
- seq_resetAllTextEntries();
+ if (currentFrame >= _animSlots[animSlot].endFrame) {
+ int sw = ((_animSlots[animSlot].flags & 0x1E) - 2);
+ switch (sw) {
+ case 0:
+ res = true;
+ currentFrame = _animSlots[animSlot].endFrame;
+ _screen->copyPage(2, 12);
+ break;
- if (_abortIntroFlag || skipFlag()) {
- _sound->haltTrack();
- _sound->voiceStop();
+ case 6:
+ case 8:
+ currentFrame = _animSlots[animSlot].endFrame - 1;
+ break;
+
+ case 2:
+ case 10:
+ currentFrame = _animSlots[animSlot].startFrame;
+ break;
+
+ default:
+ currentFrame = _animSlots[animSlot].endFrame - 1;
+ res = true;
}
+ }
- if (!_flags.isDemo || _flags.isTalkie) {
- if ((seqNum != kSequenceTitle && seqNum < kSequenceZanfaun &&
- (_abortIntroFlag || skipFlag())) || seqNum == kSequenceZanfaun) {
- _abortIntroFlag = false;
- _eventList.clear();
- seqNum = kSequenceWestwood;
- } else if (seqNum < kSequenceFrash && (_abortIntroFlag || skipFlag())) {
- _abortIntroFlag = false;
- _eventList.clear();
- seqNum = kSequenceFirates;
+ _animSlots[animSlot].currentFrame = currentFrame;
+ return res;
+}
+
+void SeqPlayer_HOF::playSoundEffect(uint16 id, int16 vol) {
+ assert(id < _sequenceSoundListSize);
+ _vm->sound()->voicePlay(_sequenceSoundList[id], 0, vol);
+}
+
+void SeqPlayer_HOF::playSoundAndDisplaySubTitle(uint16 id) {
+ assert(id < _sequenceSoundListSize);
+
+ if (id < 12 && !_vm->gameFlags().isDemo && _vm->textEnabled())
+ displaySubTitle(id, 160, 168, _textDuration[id], 160);
+
+ _vm->sound()->voicePlay(_sequenceSoundList[id], 0);
+}
+
+void SeqPlayer_HOF::printFadingText(uint16 strID, int x, int y, const uint8 *colorMap, uint8 textcolor) {
+ uint8 cmap[16];
+
+ if (checkAbortPlayback())
+ checkPlaybackStatus();
+
+ if (_abortPlayback || _abortRequested || _vm->shouldQuit() || _result)
+ return;
+
+ Screen::FontId of = _screen->setFont(Screen::FID_8_FNT);
+ _screen->getPalette(0).fill(254, 2, 63);
+ _screen->setPaletteIndex(252, 63, 32, 48);
+ cmap[0] = colorMap[0];
+ cmap[1] = 253;
+ memcpy(&cmap[2], &colorMap[2], 14);
+ uint8 col0 = _textColor[0];
+
+ _textColor[0] = 253;
+ _screen->setTextColorMap(cmap);
+ resetAllTextSlots();
+ displaySubTitle(strID, x, y, 128, 120);
+ updateSubTitles();
+ _screen->copyPage(2, 0);
+ _screen->updateScreen();
+ _screen->getPalette(0).copy(_screen->getPalette(0), textcolor, 1, 253);
+ _screen->fadePalette(_screen->getPalette(0), 24);
+
+ _textColor[0] = textcolor;
+ _screen->setTextColorMap(colorMap);
+ resetAllTextSlots();
+ displaySubTitle(strID, x, y, 128, 120);
+ updateSubTitles();
+ _screen->copyPage(2, 0);
+ _screen->updateScreen();
+ _screen->getPalette(0).fill(253, 1, 0);
+ _screen->fadePalette(_screen->getPalette(0), 1);
+
+ _screen->copyPage(2, 12);
+ resetAllTextSlots();
+
+ _textColor[0] = col0;
+
+ _screen->setFont(of);
+}
+
+int SeqPlayer_HOF::displaySubTitle(uint16 strIndex, uint16 posX, uint16 posY, int duration, uint16 width) {
+ for (int i = 0; i < 10; i++) {
+ if (_textSlots[i].duration != -1) {
+ if (i < 9)
+ continue;
+ else
+ return -1;
+ }
+
+ _textSlots[i].strIndex = strIndex;
+ _textSlots[i].x = posX;
+ _textSlots[i].y = posY;
+ _textSlots[i].duration = duration * _vm->tickLength();
+ _textSlots[i].width = width;
+ _textSlots[i].startTime = _system->getMillis();
+ _textSlots[i].textcolor = -1;
+
+ return i;
+ }
+ return -1;
+}
+
+void SeqPlayer_HOF::updateSubTitles() {
+ int curPage = _screen->setCurPage(2);
+ char outputStr[70];
+
+ for (int i = 0; i < 10; i++) {
+ if (_textSlots[i].startTime + _textSlots[i].duration > _system->getMillis() && _textSlots[i].duration != -1) {
+
+ char *srcStr = preprocessString(_sequenceStrings[_textSlots[i].strIndex], _textSlots[i].width);
+ int yPos = _textSlots[i].y;
+
+ while (*srcStr) {
+ uint32 linePos = 0;
+ for (; *srcStr; linePos++) {
+ if (*srcStr == '\r')
+ break;
+ outputStr[linePos] = *srcStr;
+ srcStr++;
+ }
+ outputStr[linePos] = 0;
+ if (*srcStr == '\r')
+ srcStr++;
+
+ uint8 textColor = (_textSlots[i].textcolor >= 0) ? _textSlots[i].textcolor : _textColor[0];
+ _screen->printText(outputStr, _textSlots[i].x - (_screen->getTextWidth(outputStr) / 2), yPos, textColor, 0);
+ yPos += 10;
}
- } else if (seqNum == endSeq && !(_abortIntroFlag || skipFlag())) {
- seqNum = 0;
+ } else {
+ _textSlots[i].duration = -1;
+ }
+ }
+
+ _screen->setCurPage(curPage);
+}
+
+char *SeqPlayer_HOF::preprocessString(const char *srcStr, int width) {
+ char *dstStr = _tempString;
+ int lineStart = 0;
+ int linePos = 0;
+
+ while (*srcStr) {
+ while (*srcStr && *srcStr != ' ')
+ dstStr[lineStart + linePos++] = *srcStr++;
+ dstStr[lineStart + linePos] = 0;
+
+ int len = _screen->getTextWidth(&dstStr[lineStart]);
+ if (width >= len && *srcStr) {
+ dstStr[lineStart + linePos++] = *srcStr++;
+ } else {
+ dstStr[lineStart + linePos] = '\r';
+ lineStart += linePos + 1;
+ linePos = 0;
+ if (*srcStr)
+ srcStr++;
}
+ }
+ dstStr[lineStart + linePos] = 0;
+
+ return strlen(_tempString) ? dstStr : 0;
+}
+
+void SeqPlayer_HOF::waitForSubTitlesTimeout() {
+ uint32 timeOut = _system->getMillis() + ticksTillSubTitlesTimeout() * _vm->tickLength();
- if (_menuChoice) {
- _abortIntroFlag = false;
- _eventList.clear();
+ if (_vm->textEnabled()) {
+ delayUntil(timeOut);
+ } else if (_vm->speechEnabled()) {
+ while (_vm->snd_voiceIsPlaying())
+ delayTicks(1);
+ }
+
+ resetAllTextSlots();
+}
- if (_menuChoice == 2) {
- seqNum = kSequenceTitle;
- _menuChoice = 0;
+uint32 SeqPlayer_HOF::ticksTillSubTitlesTimeout() {
+ uint32 longest = 0;
+
+ for (int i = 0; i < 10; i++) {
+ uint32 timeOut = (_textSlots[i].duration + _textSlots[i].startTime);
+ uint32 curtime = _system->getMillis();
+ if (_textSlots[i].duration != -1 && timeOut > curtime) {
+ timeOut -= curtime;
+ if (longest < timeOut)
+ longest = timeOut;
+ }
+ }
+
+ uint32 tl = _vm->tickLength();
+ return (longest + (tl - 1)) / tl;
+}
+
+void SeqPlayer_HOF::resetAllTextSlots() {
+ for (int i = 0; i < 10; i++)
+ _textSlots[i].duration = -1;
+}
+
+void SeqPlayer_HOF::fadeOutMusic() {
+ _vm->sound()->beginFadeOut();
+ delayTicks(80);
+}
+
+void SeqPlayer_HOF::playHoFTalkieCredits() {
+ 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->getPalette(0));
+ _screen->setFont(Screen::FID_GOLDFONT_FNT);
+
+ int talkieCreditsSize, talkieCreditsSpecialSize;
+ const uint8 *talkieCredits = _vm->staticres()->loadRawData(k2SeqplayCredits, talkieCreditsSize);
+ const char *const *talkieCreditsSpecial = _vm->staticres()->loadStrings(k2SeqplayCreditsSpecial, talkieCreditsSpecialSize);
+
+ _vm->sound()->selectAudioResourceSet(kMusicIngame);
+ _vm->sound()->loadSoundFile(3);
+ _vm->sound()->playTrack(3);
+
+ _screen->setTextColorMap(colormap);
+ _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0);
+ _screen->updateScreen();
+ _screen->fadeFromBlack();
+
+ _screen->_charWidth = -2;
+ uint8 *dataPtr = new uint8[0xAFD];
+ memcpy(dataPtr, talkieCredits, talkieCreditsSize);
+ _vm->staticres()->unloadId(k2SeqplayCredits);
+
+ displayHoFTalkieScrollText(dataPtr, &d, 2, 6, 5, 1, Screen::FID_GOLDFONT_FNT, Screen::FID_GOLDFONT_FNT, 0, talkieCreditsSpecial);
+ delayTicks(8);
+
+ delete[] dataPtr;
+ _vm->staticres()->unloadId(k2SeqplayCreditsSpecial);
+ _vm->sound()->selectAudioResourceSet(kMusicFinale);
+ _vm->sound()->loadSoundFile(0);
+}
+
+void SeqPlayer_HOF::displayHoFTalkieScrollText(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 };
+
+ _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);
+
+ struct ScrollTextData {
+ int16 x;
+ int16 y;
+ uint8 *text;
+ byte unk1;
+ byte height;
+ byte adjust;
+
+ ScrollTextData() {
+ x = 0; // 0 11
+ y = 0; // 2 13
+ text = 0; // 4 15
+ unk1 = 0; // 8 19
+ height = 0; // 9 20
+ adjust = 0; // 10 21
+ }
+ };
+
+ ScrollTextData *textData = new ScrollTextData[36];
+ uint8 *ptr = data;
+
+ bool loop = true;
+ int cnt = 0;
+
+ while (loop) {
+ uint32 loopEnd = _system->getMillis() + speed * _vm->tickLength();
+
+ while (cnt < 35 && *ptr) {
+ uint16 cH;
+
+ if (cnt)
+ cH = textData[cnt].y + textData[cnt].height + (textData[cnt].height >> 3);
+ else
+ cH = d->h;
+
+ char *str = (char *)ptr;
+
+ ptr = (uint8 *)strpbrk(str, mark);
+ if (!ptr)
+ ptr = (uint8 *)strchr(str, 0);
+
+ textData[cnt + 1].unk1 = *ptr;
+ *ptr = 0;
+ if (textData[cnt + 1].unk1)
+ ptr++;
+
+ if (*str == 3 || *str == 4)
+ textData[cnt + 1].adjust = *str++;
+ else
+ textData[cnt + 1].adjust = 0;
+
+ _screen->setFont(fid1);
+
+ if (*str == 1) {
+ _screen->setFont(fid2);
+ str++;
+ } else if (*str == 2) {
+ str++;
+ }
+
+ textData[cnt + 1].height = _screen->getFontHeight();
+
+ switch (textData[cnt + 1].adjust) {
+ case 3:
+ textData[cnt + 1].x = 157 - _screen->getTextWidth(str);
+ break;
+ case 4:
+ textData[cnt + 1].x = 161;
+ break;
+ default:
+ textData[cnt + 1].x = (((d->w << 3) - _screen->getTextWidth(str)) >> 1) + 1;
+ }
+
+ if (textData[cnt].unk1 == 5)
+ cH -= (textData[cnt].height + (textData[cnt].height >> 3));
+
+ textData[cnt + 1].y = cH;
+ textData[cnt + 1].text = (uint8 *)str;
+ 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) {
+ const char *str = (const char *)textData[cnt2 + 1].text;
+ const char *str2 = str;
+ int16 cW = textData[cnt2 + 1].x - 10;
+ int16 cH = textData[cnt2 + 1].y;
+ 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 (textData[cnt2 + 1].height != _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((uint8)*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((uint8)*str2++);
+ }
+ palCycle = true;
+ } else {
+ _screen->printText(str, x, y, col1, 0);
+ }
+ } else {
+ _screen->printText(str, x, y, col1, 0);
+ }
+ _screen->setCurPage(0);
}
+
+ textData[cnt2 + 1].y -= step;
+ cnt2++;
+ }
+
+ _screen->copyRegion(d->sx << 3, d->sy, d->sx << 3, d->sy, d->w << 3, d->h, tempPage2, 0);
+ _screen->updateScreen();
+
+ if (textData[1].y < -10) {
+ textData[1].text += strlen((char *)textData[1].text);
+ textData[1].text[0] = textData[1].unk1;
+ cnt--;
+ memcpy(&textData[1], &textData[2], cnt * sizeof(ScrollTextData));
+ }
+
+ if (palCycle) {
+ for (int col = 133; col > 112; col--)
+ _screen->getPalette(0).copy(_screen->getPalette(0), col - 1, 1, col);
+ _screen->getPalette(0).copy(_screen->getPalette(0), 133, 1, 112);
+ _screen->setScreenPalette(_screen->getPalette(0));
}
+
+ delayUntil(loopEnd);
+
+ if ((cnt < 36) && ((d->sy + d->h) > (textData[cnt].y + textData[cnt].height)) && !_abortPlayback) {
+ delayTicks(500);
+ cnt = 0;
+ }
+
+ if (checkAbortPlayback())
+ if (checkPlaybackStatus())
+ loop = false;
+
+ if (!cnt || _abortPlayback)
+ loop = false;
}
- if (_flags.isDemo && !_flags.isTalkie) {
- _eventList.clear();
- _screen->fadeToBlack();
+ _vm->sound()->beginFadeOut();
+ _screen->fadeToBlack();
+
+ _abortPlayback = _abortRequested = false;
+
+ delete[] textData;
+}
+
+void SeqPlayer_HOF::updateDemoAdText(int bottom, int top) {
+ int dstY, dstH, srcH;
+
+ static const ScreenDim d = { 0x00, 0x00, 0x28, 0x320, 0xFF, 0xFE, 0x00, 0x00 };
+
+ if (_scrollProgressCounter - (top - 1) < 0) {
+ dstY = top - _scrollProgressCounter;
+ dstH = _scrollProgressCounter;
+ srcH = 0;
+ } else {
+ dstY = 0;
+ srcH = _scrollProgressCounter - top;
+ dstH = (400 - srcH <= top) ? 400 - srcH : top;
}
- if (!_menuChoice)
- delay(1200);
+ if (dstH > 0) {
+ if (_hofDemoAnimData) {
+ for (int i = 0; i < 4; i++) {
+ const HoFSeqItemAnimData *def = &_hofDemoAnimData[i];
+ ActiveItemAnim *a = &_hofDemoActiveItemAnim[i];
- _screen->setCurPage(oldPage);
- _screen->showMouse();
+ _screen->fillRect(12, def->y - 8, 28, def->y + 8, 0, 4);
+ _screen->drawShape(4, _hofDemoItemShapes[def->itemIndex + def->frames[a->currentFrame]], 12, def->y - 8, 0, 0);
+ if (_callbackCurrentFrame % 2 == 0)
+ a->currentFrame = (a->currentFrame + 1) % 20;
+ }
+ }
+ _screen->copyRegionEx(4, 0, srcH, 2, 2, dstY + bottom, 320, dstH, &d);
+ }
+}
- for (int i = 0; i < 8; i++)
- seq_unloadWSA(i);
+void SeqPlayer_HOF::delayTicks(uint32 ticks) {
+ uint32 len = ticks * _vm->tickLength();
+ while (len && !_vm->shouldQuit() && !checkAbortPlayback()) {
+ uint32 step = (len >= 10) ? 10 : len;
+ _system->delayMillis(step);
+ len -= step;
+ }
+}
- _seqWsa->close();
+void SeqPlayer_HOF::delayUntil(uint32 dest) {
+ for (uint32 ct = _system->getMillis(); ct < dest && !_vm->shouldQuit() && !checkAbortPlayback(); ) {
+ uint32 step = (dest - ct >= 10) ? 10 : (dest - ct);
+ _system->delayMillis(step);
+ ct = _system->getMillis();
+ }
+}
- _screen->_charWidth = 0;
+void SeqPlayer_HOF::setCountDown(uint32 ticks) {
+ _countDownRemainder = ticks * _vm->tickLength();
+ if (_vm->gameFlags().platform == Common::kPlatformFMTowns || _vm->gameFlags().platform == Common::kPlatformPC98)
+ _countDownRemainder = _countDownRemainder * 2 / 3;
+ _countDownLastUpdate = _system->getMillis() & ~(_vm->tickLength() - 1);
+}
- seq_uninit();
+bool SeqPlayer_HOF::countDownRunning() {
+ uint32 cur = _system->getMillis();
+ uint32 step = cur - _countDownLastUpdate;
+ _countDownLastUpdate = cur;
+ _countDownRemainder = (step <= _countDownRemainder) ? _countDownRemainder - step : 0;
+ return _countDownRemainder;
}
-int KyraEngine_HoF::seq_introWestwood(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+#define CASE_ALT(dosCase, towns98Case)\
+ case dosCase:\
+ case towns98Case:\
+ if (!((_callbackCurrentFrame == towns98Case && (_vm->gameFlags().platform == Common::kPlatformFMTowns || _vm->gameFlags().platform == Common::kPlatformPC98)) || (_callbackCurrentFrame == dosCase && _vm->gameFlags().platform == Common::kPlatformPC)))\
+ break;
+
+int SeqPlayer_HOF::cbHOF_westwood(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == -2) {
- if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)
- delay(300 * _tickLength);
+ if (_vm->gameFlags().platform == Common::kPlatformFMTowns || _vm->gameFlags().platform == Common::kPlatformPC98)
+ delayTicks(300);
} else if (!frm) {
- _sound->playTrack(2);
+ _vm->sound()->playTrack(2);
}
return 0;
}
-int KyraEngine_HoF::seq_introTitle(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOF_title(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == 1) {
- _sound->playTrack(3);
- } else if (frm == 25) {
+ _vm->sound()->playTrack(3);
+ } else if (frm == 25 && _startupSaveLoadable) {
int cp = _screen->setCurPage(0);
_screen->showMouse();
_system->updateScreen();
- _menuChoice = _menu->handle(11) + 1;
- _seqEndTime = 0;
- _seqSubframePlaying = false;
- if (_menuChoice == 4)
- quitGame();
+ _result = _menu->handle(11) + 1;
+ _updateAnimations = false;
+
+ if (_result == 1) {
+ _curScene = _lastScene;
+ _preventLooping = true;
+ }
+
+ if (_result == 2) {
+ _result = 0;
+ } else if (_result == 4) {
+ setCountDown(200);
+ _vm->quitGame();
+ }
_screen->hideMouse();
_screen->setCurPage(cp);
+ } else if (frm == 25) {
+ setCountDown(200);
}
return 0;
}
-int KyraEngine_HoF::seq_introOverview(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOF_overview(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
uint8 *tmpPal = _screen->getPalette(3).getData() + 0x101;
memset(tmpPal, 0, 256);
- _seqSubFrameEndTimeInternal = 0;
- uint32 now = 0;
+ uint32 frameEnd = 0;
- switch (_seqFrameCounter) {
+ switch (_callbackCurrentFrame) {
case 0:
- _seqSubframePlaying = true;
- _sound->playTrack(4);
- _seqSubFrameEndTimeInternal = _system->getMillis() + 60 * _tickLength;
+ _updateAnimations = true;
+ fadeOutMusic();
+ _vm->sound()->playTrack(4);
+ frameEnd = _system->getMillis() + 60 * _vm->tickLength();
- _seqTextColor[1] = _screen->findLeastDifferentColor(_seqTextColorPresets, _screen->getPalette(0), 1, 255) & 0xff;
- memset(_seqTextColorMap, _seqTextColor[1], 16);
- _seqTextColorMap[1] = _seqTextColor[0] = _screen->findLeastDifferentColor(_seqTextColorPresets + 3, _screen->getPalette(0), 1, 255) & 0xff;
+ _textColor[1] = _screen->findLeastDifferentColor(_textColorPresets, _screen->getPalette(0), 1, 255) & 0xFF;
+ memset(_textColorMap, _textColor[1], 16);
+ _textColorMap[1] = _textColor[0] = _screen->findLeastDifferentColor(_textColorPresets + 3, _screen->getPalette(0), 1, 255) & 0xFF;
+ _screen->setTextColorMap(_textColorMap);
- _screen->setTextColorMap(_seqTextColorMap);
-
- now = _system->getMillis();
- if (_seqSubFrameEndTimeInternal > now)
- delay(_seqSubFrameEndTimeInternal - now);
+ delayUntil(frameEnd);
break;
case 1:
- _screen->generateGrayOverlay(_screen->getPalette(0), _screen->getPalette(3).getData(), 0x40, 0, 0, 0, 0x100, true);
+ assert(_screenHoF);
+ _screenHoF->generateGrayOverlay(_screen->getPalette(0), _screen->getPalette(3).getData(), 0x40, 0, 0, 0, 0x100, true);
for (int i = 0; i < 256; i++)
tmpPal[_screen->getPalette(3)[i]] = 1;
@@ -393,19 +1831,19 @@ int KyraEngine_HoF::seq_introOverview(WSAMovie_v2 *wsaObj, int x, int y, int frm
break;
case 40:
- seq_loadNestedSequence(0, kSequenceOver1);
+ startNestedAnimation(0, kNestedSequenceOver1);
break;
case 60:
- seq_loadNestedSequence(1, kSequenceOver2);
+ startNestedAnimation(1, kNestedSequenceOver2);
break;
case 120:
- seq_playTalkText(0);
+ playSoundAndDisplaySubTitle(0);
break;
case 200:
- seq_waitForTextsTimeout();
+ waitForSubTitlesTimeout();
_screen->fadePalette(_screen->getPalette(2), 64);
break;
@@ -417,64 +1855,57 @@ int KyraEngine_HoF::seq_introOverview(WSAMovie_v2 *wsaObj, int x, int y, int frm
_screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0);
_screen->setScreenPalette(_screen->getPalette(0));
_screen->updateScreen();
- seq_resetActiveWSA(0);
- seq_resetActiveWSA(1);
+ closeNestedAnimation(0);
+ closeNestedAnimation(1);
break;
case 282:
- seq_loadNestedSequence(0, kSequenceForest);
- seq_playTalkText(1);
+ startNestedAnimation(0, kNestedSequenceForest);
+ playSoundAndDisplaySubTitle(1);
break;
- case 354:
- case 434:
- if (!((_seqFrameCounter == 354 && (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)) || (_seqFrameCounter == 434 && _flags.platform == Common::kPlatformPC)))
- break;
-
- seq_resetActiveWSA(0);
- seq_loadNestedSequence(0, kSequenceDragon);
+ CASE_ALT(434, 354)
+ closeNestedAnimation(0);
+ startNestedAnimation(0, kNestedSequenceDragon);
break;
- case 400:
- case 540:
- if (!((_seqFrameCounter == 400 && (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)) || (_seqFrameCounter == 540 && _flags.platform == Common::kPlatformPC)))
- break;
-
- seq_waitForTextsTimeout();
- seq_resetActiveWSA(0);
- _seqEndTime = 0;
- _seqSubframePlaying = false;
+ CASE_ALT(540, 400)
+ waitForSubTitlesTimeout();
+ closeNestedAnimation(0);
+ setCountDown(0);
+ _updateAnimations = false;
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-int KyraEngine_HoF::seq_introLibrary(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- switch (_seqFrameCounter) {
+int SeqPlayer_HOF::cbHOF_library(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ switch (_callbackCurrentFrame) {
case 0:
- _seqSubframePlaying = true;
- _sound->playTrack(5);
+ _updateAnimations = true;
+ _vm->sound()->playTrack(5);
- _screen->generateGrayOverlay(_screen->getPalette(0), _screen->getPalette(3).getData(), 0x24, 0, 0, 0, 0x100, false);
- _seqTextColor[1] = _screen->findLeastDifferentColor(_seqTextColorPresets, _screen->getPalette(0), 1, 255) & 0xff;
- memset(_seqTextColorMap, _seqTextColor[1], 16);
- _seqTextColorMap[1] = _seqTextColor[0] = _screen->findLeastDifferentColor(_seqTextColorPresets + 3, _screen->getPalette(0), 1, 255) & 0xff;
+ assert(_screenHoF);
+ _screenHoF->generateGrayOverlay(_screen->getPalette(0), _screen->getPalette(3).getData(), 0x24, 0, 0, 0, 0x100, false);
+ _textColor[1] = _screen->findLeastDifferentColor(_textColorPresets, _screen->getPalette(0), 1, 255) & 0xFF;
+ memset(_textColorMap, _textColor[1], 16);
+ _textColorMap[1] = _textColor[0] = _screen->findLeastDifferentColor(_textColorPresets + 3, _screen->getPalette(0), 1, 255) & 0xFF;
- _screen->setTextColorMap(_seqTextColorMap);
+ _screen->setTextColorMap(_textColorMap);
break;
case 1:
- seq_loadNestedSequence(0, kSequenceLibrary3);
- seq_playTalkText(4);
+ startNestedAnimation(0, kNestedSequenceLibrary3);
+ playSoundAndDisplaySubTitle(4);
break;
case 100:
- seq_waitForTextsTimeout();
+ waitForSubTitlesTimeout();
_screen->copyPage(12, 2);
_screen->applyOverlay(0, 0, 320, 200, 2, _screen->getPalette(3).getData());
@@ -482,585 +1913,560 @@ int KyraEngine_HoF::seq_introLibrary(WSAMovie_v2 *wsaObj, int x, int y, int frm)
_screen->updateScreen();
_screen->copyPage(2, 12);
- seq_resetActiveWSA(0);
- seq_loadNestedSequence(0, kSequenceDarm);
+ closeNestedAnimation(0);
+ startNestedAnimation(0, kNestedSequenceDarm);
break;
case 104:
- seq_playTalkText(5);
+ playSoundAndDisplaySubTitle(5);
break;
case 240:
- seq_waitForTextsTimeout();
- seq_resetActiveWSA(0);
- seq_loadNestedSequence(0, kSequenceLibrary2);
+ waitForSubTitlesTimeout();
+ closeNestedAnimation(0);
+ startNestedAnimation(0, kNestedSequenceLibrary2);
break;
case 340:
- seq_resetActiveWSA(0);
+ closeNestedAnimation(0);
_screen->applyOverlay(0, 0, 320, 200, 2, _screen->getPalette(3).getData());
_screen->copyPage(2, 12);
_screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0);
_screen->updateScreen();
- seq_loadNestedSequence(0, kSequenceMarco);
- seq_playTalkText(6);
+ startNestedAnimation(0, kNestedSequenceMarco);
+ playSoundAndDisplaySubTitle(6);
break;
- case 480:
- case 660:
- if (!((_seqFrameCounter == 480 && (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)) || (_seqFrameCounter == 660 && _flags.platform == Common::kPlatformPC)))
- break;
-
+ CASE_ALT(660, 480)
_screen->copyPage(2, 12);
- seq_waitForTextsTimeout();
- seq_resetActiveWSA(0);
- _seqEndTime = 0;
- _seqSubframePlaying = false;
+ waitForSubTitlesTimeout();
+ closeNestedAnimation(0);
+ setCountDown(0);
+ _updateAnimations = false;
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-
-int KyraEngine_HoF::seq_introHand(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- switch (_seqFrameCounter) {
+int SeqPlayer_HOF::cbHOF_hand(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ switch (_callbackCurrentFrame) {
case 0:
- _seqSubframePlaying = true;
- _sound->playTrack(6);
+ _updateAnimations = true;
+ _vm->sound()->playTrack(6);
- _screen->generateGrayOverlay(_screen->getPalette(0), _screen->getPalette(3).getData(), 0x24, 0, 0, 0, 0x100, false);
- _seqTextColor[1] = _screen->findLeastDifferentColor(_seqTextColorPresets, _screen->getPalette(0), 1, 255) & 0xff;
- memset(_seqTextColorMap, _seqTextColor[1], 16);
- _seqTextColorMap[1] = _seqTextColor[0] = _screen->findLeastDifferentColor(_seqTextColorPresets + 3, _screen->getPalette(0), 1, 255) & 0xff;
+ assert(_screenHoF);
+ _screenHoF->generateGrayOverlay(_screen->getPalette(0), _screen->getPalette(3).getData(), 0x24, 0, 0, 0, 0x100, false);
+ _textColor[1] = _screen->findLeastDifferentColor(_textColorPresets, _screen->getPalette(0), 1, 255) & 0xFF;
+ memset(_textColorMap, _textColor[1], 16);
+ _textColorMap[1] = _textColor[0] = _screen->findLeastDifferentColor(_textColorPresets + 3, _screen->getPalette(0), 1, 255) & 0xFF;
- _screen->setTextColorMap(_seqTextColorMap);
+ _screen->setTextColorMap(_textColorMap);
break;
case 1:
- seq_loadNestedSequence(0, kSequenceHand1a);
- seq_loadNestedSequence(1, kSequenceHand1b);
- seq_loadNestedSequence(2, kSequenceHand1c);
- seq_playTalkText(7);
+ startNestedAnimation(0, kNestedSequenceHand1a);
+ startNestedAnimation(1, kNestedSequenceHand1b);
+ startNestedAnimation(2, kNestedSequenceHand1c);
+ playSoundAndDisplaySubTitle(7);
break;
case 201:
- seq_waitForTextsTimeout();
+ waitForSubTitlesTimeout();
_screen->applyOverlay(0, 0, 320, 200, 2, _screen->getPalette(3).getData());
_screen->copyPage(2, 12);
_screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0);
_screen->updateScreen();
- seq_resetActiveWSA(0);
- seq_resetActiveWSA(1);
- seq_resetActiveWSA(2);
- seq_loadNestedSequence(0, kSequenceHand2);
- seq_playTalkText(8);
+ closeNestedAnimation(0);
+ closeNestedAnimation(1);
+ closeNestedAnimation(2);
+ startNestedAnimation(0, kNestedSequenceHand2);
+ playSoundAndDisplaySubTitle(8);
break;
- case 260:
- case 395:
- if (!((_seqFrameCounter == 260 && (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)) || (_seqFrameCounter == 395 && _flags.platform == Common::kPlatformPC)))
- break;
-
- seq_waitForTextsTimeout();
- seq_resetActiveWSA(0);
- seq_loadNestedSequence(1, kSequenceHand3);
- seq_playTalkText(9);
+ CASE_ALT(395, 260)
+ waitForSubTitlesTimeout();
+ closeNestedAnimation(0);
+ startNestedAnimation(1, kNestedSequenceHand3);
+ playSoundAndDisplaySubTitle(9);
break;
- case 365:
- case 500:
- if (!((_seqFrameCounter == 365 && (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)) || (_seqFrameCounter == 500 && _flags.platform == Common::kPlatformPC)))
- break;
-
- seq_waitForTextsTimeout();
- seq_resetActiveWSA(1);
- seq_loadNestedSequence(0, kSequenceHand4);
+ CASE_ALT(500, 365)
+ waitForSubTitlesTimeout();
+ closeNestedAnimation(1);
+ startNestedAnimation(0, kNestedSequenceHand4);
break;
- case 405:
- case 540:
- if (!((_seqFrameCounter == 405 && (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)) || (_seqFrameCounter == 540 && _flags.platform == Common::kPlatformPC)))
- break;
-
- seq_playTalkText(10);
+ CASE_ALT(540, 405)
+ playSoundAndDisplaySubTitle(10);
break;
- case 484:
- case 630:
- if (!((_seqFrameCounter == 484 && (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)) || (_seqFrameCounter == 630 && _flags.platform == Common::kPlatformPC)))
- break;
-
- seq_waitForTextsTimeout();
- seq_resetActiveWSA(0);
- _seqEndTime = 0;
- _seqSubframePlaying = false;
+ CASE_ALT(630, 484)
+ waitForSubTitlesTimeout();
+ closeNestedAnimation(0);
+ setCountDown(0);
+ _updateAnimations = false;
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-int KyraEngine_HoF::seq_introPoint(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOF_point(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == -2) {
- seq_waitForTextsTimeout();
- _seqEndTime = 0;
+ waitForSubTitlesTimeout();
+ setCountDown(0);
}
- switch (_seqFrameCounter) {
+ switch (_callbackCurrentFrame) {
case -2:
- seq_waitForTextsTimeout();
+ waitForSubTitlesTimeout();
break;
case 0:
- _sound->playTrack(7);
+ _vm->sound()->playTrack(7);
- _seqTextColor[1] = 0xf7;
- memset(_seqTextColorMap, _seqTextColor[1], 16);
- _seqTextColorMap[1] = _seqTextColor[0] = _screen->findLeastDifferentColor(_seqTextColorPresets + 3, _screen->getPalette(0), 1, 255) & 0xff;
- _screen->setTextColorMap(_seqTextColorMap);
- _screen->generateGrayOverlay(_screen->getPalette(0), _screen->getPalette(3).getData(), 0x24, 0, 0, 0, 0x100, false);
+ _textColor[1] = 0xF7;
+ memset(_textColorMap, _textColor[1], 16);
+ _textColorMap[1] = _textColor[0] = _screen->findLeastDifferentColor(_textColorPresets + 3, _screen->getPalette(0), 1, 255) & 0xFF;
+ _screen->setTextColorMap(_textColorMap);
+ assert(_screenHoF);
+ _screenHoF->generateGrayOverlay(_screen->getPalette(0), _screen->getPalette(3).getData(), 0x24, 0, 0, 0, 0x100, false);
break;
case 1:
- seq_playTalkText(11);
+ playSoundAndDisplaySubTitle(11);
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-int KyraEngine_HoF::seq_introZanfaun(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOF_zanfaun(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == -2) {
- seq_waitForTextsTimeout();
- _seqEndTime = 0;
+ waitForSubTitlesTimeout();
+ setCountDown(0);
return 0;
}
- switch (_seqFrameCounter) {
+ switch (_callbackCurrentFrame) {
case 0:
- _sound->playTrack(8);
+ _vm->sound()->playTrack(8);
- _seqTextColor[1] = 0xfd;
- memset(_seqTextColorMap, _seqTextColor[1], 16);
- _seqTextColorMap[1] = _seqTextColor[0] = _screen->findLeastDifferentColor(_seqTextColorPresets + 3, _screen->getPalette(0), 1, 255) & 0xff;
- _screen->setTextColorMap(_seqTextColorMap);
+ _textColor[1] = 0xFD;
+ memset(_textColorMap, _textColor[1], 16);
+ _textColorMap[1] = _textColor[0] = _screen->findLeastDifferentColor(_textColorPresets + 3, _screen->getPalette(0), 1, 255) & 0xFF;
+ _screen->setTextColorMap(_textColorMap);
break;
case 1:
- if (_flags.isTalkie) {
- seq_playWsaSyncDialogue(21, 13, -1, 140, 70, 160, wsaObj, 0, 8, x, y);
+ if (_vm->gameFlags().isTalkie) {
+ playDialogueAnimation(21, 13, -1, 140, 70, 160, wsaObj, 0, 8, x, y);
} else {
- seq_setTextEntry(21, 140, 70, 200, 160);
- _seqFrameDelay = 200;
+ displaySubTitle(21, 140, 70, 200, 160);
+ _animDuration = 200;
}
break;
case 2:
case 11:
case 21:
- if (!_flags.isTalkie)
- _seqFrameDelay = 12;
+ if (!_vm->gameFlags().isTalkie)
+ _animDuration = 12;
break;
case 9:
- if (_flags.isTalkie)
- seq_playWsaSyncDialogue(13, 14, -1, 140, (_flags.lang == Common::FR_FRA
- || _flags.lang == Common::DE_DEU) ? 50 : 70, 160, wsaObj, 9, 15, x, y);
+ if (_vm->gameFlags().isTalkie)
+ playDialogueAnimation(13, 14, -1, 140, (_vm->gameFlags().lang == Common::FR_FRA
+ || _vm->gameFlags().lang == Common::DE_DEU) ? 50 : 70, 160, wsaObj, 9, 15, x, y);
break;
case 10:
- if (!_flags.isTalkie) {
- seq_waitForTextsTimeout();
- seq_setTextEntry(13, 140, 50, _sequenceStringsDuration[13], 160);
- _seqFrameDelay = 300;
+ if (!_vm->gameFlags().isTalkie) {
+ waitForSubTitlesTimeout();
+ displaySubTitle(13, 140, 50, _textDuration[13], 160);
+ _animDuration = 300;
}
break;
case 16:
- if (_flags.isTalkie)
- seq_playWsaSyncDialogue(18, 15, -1, 140, (_flags.lang == Common::FR_FRA) ? 50 :
- (_flags.lang == Common::DE_DEU ? 40 : 70), 160, wsaObj, 10, 16, x, y);
+ if (_vm->gameFlags().isTalkie)
+ playDialogueAnimation(18, 15, -1, 140, (_vm->gameFlags().lang == Common::FR_FRA) ? 50 :
+ (_vm->gameFlags().lang == Common::DE_DEU ? 40 : 70), 160, wsaObj, 10, 16, x, y);
break;
case 17:
- if (_flags.isTalkie)
- _seqFrameDelay = 12;
+ if (_vm->gameFlags().isTalkie)
+ _animDuration = 12;
break;
case 20:
- if (!_flags.isTalkie) {
- seq_waitForTextsTimeout();
- seq_setTextEntry(18, 160, 50, _sequenceStringsDuration[18], 160);
- _seqFrameDelay = 200;
+ if (!_vm->gameFlags().isTalkie) {
+ waitForSubTitlesTimeout();
+ displaySubTitle(18, 160, 50, _textDuration[18], 160);
+ _animDuration = 200;
}
break;
case 26:
- seq_waitForTextsTimeout();
+ waitForSubTitlesTimeout();
break;
case 46:
- if (_flags.isTalkie) {
- seq_playWsaSyncDialogue(16, 16, -1, 200, 50, 120, wsaObj, 46, 46, x, y);
+ if (_vm->gameFlags().isTalkie) {
+ playDialogueAnimation(16, 16, -1, 200, 50, 120, wsaObj, 46, 46, x, y);
} else {
- seq_waitForTextsTimeout();
- seq_setTextEntry(16, 200, 50, _sequenceStringsDuration[16], 120);
+ waitForSubTitlesTimeout();
+ displaySubTitle(16, 200, 50, _textDuration[16], 120);
}
- _seqEndTime = _system->getMillis() + 120 * _tickLength;
+ setCountDown(120);
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-int KyraEngine_HoF::seq_introOver1(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOF_over1(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == 2)
- seq_waitForTextsTimeout();
+ waitForSubTitlesTimeout();
else if (frm == 3)
- seq_playTalkText(12);
+ playSoundAndDisplaySubTitle(12);
return frm;
}
-
-int KyraEngine_HoF::seq_introOver2(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOF_over2(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == 1)
- seq_playTalkText(12);
+ playSoundAndDisplaySubTitle(12);
return frm;
}
-int KyraEngine_HoF::seq_introForest(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOF_forest(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == 11)
- seq_waitForTextsTimeout();
+ waitForSubTitlesTimeout();
else if (frm == 12)
- seq_playTalkText(2);
+ playSoundAndDisplaySubTitle(2);
return frm;
}
-int KyraEngine_HoF::seq_introDragon(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOF_dragon(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == 11)
- seq_waitForTextsTimeout();
+ waitForSubTitlesTimeout();
else if (frm == 3)
- seq_playTalkText(3);
+ playSoundAndDisplaySubTitle(3);
return frm;
}
-int KyraEngine_HoF::seq_introDarm(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- //NULLSUB (at least in FM-TOWNS version)
+int SeqPlayer_HOF::cbHOF_darm(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
return frm;
}
-int KyraEngine_HoF::seq_introLibrary2(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- //NULLSUB (at least in FM-TOWNS version)
+int SeqPlayer_HOF::cbHOF_library2(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
return frm;
}
-int KyraEngine_HoF::seq_introMarco(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOF_marco(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == 36) {
- seq_waitForTextsTimeout();
- _seqEndTime = 0;
+ waitForSubTitlesTimeout();
+ setCountDown(0);
}
return frm;
}
-int KyraEngine_HoF::seq_introHand1a(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- //NULLSUB (at least in FM-TOWNS version)
+int SeqPlayer_HOF::cbHOF_hand1a(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
return frm;
}
-int KyraEngine_HoF::seq_introHand1b(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOF_hand1b(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == 15)
frm = 12;
return frm;
}
-int KyraEngine_HoF::seq_introHand1c(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOF_hand1c(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == 8)
frm = 4;
return frm;
}
-int KyraEngine_HoF::seq_introHand2(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- //NULLSUB (at least in FM-TOWNS version)
+int SeqPlayer_HOF::cbHOF_hand2(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
return frm;
}
-int KyraEngine_HoF::seq_introHand3(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- //NULLSUB (at least in FM-TOWNS version)
+int SeqPlayer_HOF::cbHOF_hand3(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
return frm;
}
-int KyraEngine_HoF::seq_finaleFunters(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- _seqSubFrameEndTimeInternal = 0;
- int chatX = 0;
- int chatY = 0;
- int chatW = 0;
- int chatFirstFrame = 0;
- int chatLastFrame = 0;
+int SeqPlayer_HOF::cbHOF_funters(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ uint32 frameEnd = 0;
+ int subTitleX = 0;
+ int subTitleY = 0;
+ int subTitleW = 0;
+ int subTitleFirstFrame = 0;
+ int subTitleLastFrame = 0;
uint16 voiceIndex = 0;
switch (frm) {
case -2:
- seq_sequenceCommand(9);
+ doTransition(9);
break;
case 0:
- _sound->playTrack(3);
+ _vm->sound()->playTrack(3);
- _seqTextColor[1] = _screen->findLeastDifferentColor(_seqTextColorPresets, _screen->getPalette(0), 1, 255) & 0xff;
- memset(_seqTextColorMap, _seqTextColor[1], 16);
- _seqTextColor[0] = _seqTextColorMap[1] = 0xff;
- _screen->setTextColorMap(_seqTextColorMap);
+ _textColor[1] = _screen->findLeastDifferentColor(_textColorPresets, _screen->getPalette(0), 1, 255) & 0xFF;
+ memset(_textColorMap, _textColor[1], 16);
+ _textColor[0] = _textColorMap[1] = 0xFF;
+ _screen->setTextColorMap(_textColorMap);
- _seqSubFrameEndTimeInternal = _system->getMillis() + 480 * _tickLength;
- seq_printCreditsString(81, 240, 70, _seqTextColorMap, 252);
- seq_printCreditsString(82, 240, 90, _seqTextColorMap, _seqTextColor[0]);
+ frameEnd = _system->getMillis() + 480 * _vm->tickLength();
+ printFadingText(81, 240, 70, _textColorMap, 252);
+ printFadingText(82, 240, 90, _textColorMap, _textColor[0]);
_screen->copyPage(2, 12);
- seq_playTalkText(_flags.isTalkie ? 28 : 24);
- delay(_seqSubFrameEndTimeInternal - _system->getMillis());
- _seqTextColor[0] = 1;
-
- if (_flags.isTalkie) {
- chatY = (_flags.lang == Common::FR_FRA) ? 70 : 78;
- chatFirstFrame = 9;
- chatLastFrame = 15;
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 28 : 24);
+ delayUntil(frameEnd);
+ _textColor[0] = 1;
+
+ if (_vm->gameFlags().isTalkie) {
+ subTitleY = (_vm->gameFlags().lang == Common::FR_FRA) ? 70 : 78;
+ subTitleFirstFrame = 9;
+ subTitleLastFrame = 15;
voiceIndex = 34;
} else {
- chatY = (_flags.lang == Common::FR_FRA) ? 78 : 70;
- chatFirstFrame = 0;
- chatLastFrame = 8;
+ subTitleY = (_vm->gameFlags().lang == Common::FR_FRA) ? 78 : 70;
+ subTitleFirstFrame = 0;
+ subTitleLastFrame = 8;
}
- chatX = (_flags.lang == Common::FR_FRA) ? 84 : 88;
- chatW = 100;
+ subTitleX = (_vm->gameFlags().lang == Common::FR_FRA) ? 84 : 88;
+ subTitleW = 100;
- seq_playWsaSyncDialogue(22, voiceIndex, 187, chatX, chatY, chatW, wsaObj, chatFirstFrame, chatLastFrame, x, y);
+ playDialogueAnimation(22, voiceIndex, 187, subTitleX, subTitleY, subTitleW, wsaObj, subTitleFirstFrame, subTitleLastFrame, x, y);
break;
case 9:
case 16:
- if (!((frm == 9 && !_flags.isTalkie) || (frm == 16 && _flags.isTalkie)))
+ if (!((frm == 9 && !_vm->gameFlags().isTalkie) || (frm == 16 && _vm->gameFlags().isTalkie)))
break;
- _seqFrameDelay = 12;
+ _animDuration = 12;
- if (_flags.lang == Common::FR_FRA) {
- chatX = 80;
- chatW = 112;
+ if (_vm->gameFlags().lang == Common::FR_FRA) {
+ subTitleX = 80;
+ subTitleW = 112;
} else {
- chatX = (_flags.lang == Common::DE_DEU) ? 84 : 96;
- chatW = 100;
+ subTitleX = (_vm->gameFlags().lang == Common::DE_DEU) ? 84 : 96;
+ subTitleW = 100;
}
- if (_flags.isTalkie) {
- chatFirstFrame = 0;
- chatLastFrame = 8;
+ if (_vm->gameFlags().isTalkie) {
+ subTitleFirstFrame = 0;
+ subTitleLastFrame = 8;
voiceIndex = 35;
} else {
- chatFirstFrame = 9;
- chatLastFrame = 15;
+ subTitleFirstFrame = 9;
+ subTitleLastFrame = 15;
}
- chatY = 70;
+ subTitleY = 70;
- seq_playWsaSyncDialogue(23, voiceIndex, 137, chatX, chatY, chatW, wsaObj, chatFirstFrame, chatLastFrame, x, y);
- if (_flags.isTalkie)
- _seqWsaCurrentFrame = 17;
+ playDialogueAnimation(23, voiceIndex, 137, subTitleX, subTitleY, subTitleW, wsaObj, subTitleFirstFrame, subTitleLastFrame, x, y);
+ if (_vm->gameFlags().isTalkie)
+ _animCurrentFrame = 17;
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-int KyraEngine_HoF::seq_finaleFerb(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- _seqSubFrameEndTimeInternal = 0;
- int chatX = 0;
- int chatY = 0;
- int chatW = 0;
- int chatFirstFrame = 0;
- int chatLastFrame = 0;
+int SeqPlayer_HOF::cbHOF_ferb(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ uint32 frameEnd = 0;
+ int subTitleX = 0;
+ int subTitleY = 0;
+ int subTitleW = 0;
+ int subTitleFirstFrame = 0;
+ int subTitleLastFrame = 0;
uint16 voiceIndex = 0;
switch (frm) {
case -2:
- seq_sequenceCommand(9);
- _seqSubFrameEndTimeInternal = _system->getMillis() + 480 * _tickLength;
- seq_printCreditsString(34, 240, _flags.isTalkie ? 60 : 40, _seqTextColorMap, 252);
- seq_printCreditsString(35, 240, _flags.isTalkie ? 70 : 50, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(36, 240, _flags.isTalkie ? 90 : 70, _seqTextColorMap, 252);
- seq_printCreditsString(37, 240, _flags.isTalkie ? 100 : 90, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(38, 240, _flags.isTalkie ? 120 : 110, _seqTextColorMap, 252);
- seq_printCreditsString(39, 240, _flags.isTalkie ? 130 : 120, _seqTextColorMap, _seqTextColor[0]);
- if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)
- seq_printCreditsString(103, 240, 130, _seqTextColorMap, _seqTextColor[0]);
- delay(_seqSubFrameEndTimeInternal - _system->getMillis());
- _seqEndTime = 0;
+ doTransition(9);
+ frameEnd = _system->getMillis() + 480 * _vm->tickLength();
+ printFadingText(34, 240, _vm->gameFlags().isTalkie ? 60 : 40, _textColorMap, 252);
+ printFadingText(35, 240, _vm->gameFlags().isTalkie ? 70 : 50, _textColorMap, _textColor[0]);
+ printFadingText(36, 240, _vm->gameFlags().isTalkie ? 90 : 70, _textColorMap, 252);
+ printFadingText(37, 240, _vm->gameFlags().isTalkie ? 100 : 90, _textColorMap, _textColor[0]);
+ printFadingText(38, 240, _vm->gameFlags().isTalkie ? 120 : 110, _textColorMap, 252);
+ printFadingText(39, 240, _vm->gameFlags().isTalkie ? 130 : 120, _textColorMap, _textColor[0]);
+ if (_vm->gameFlags().platform == Common::kPlatformFMTowns || _vm->gameFlags().platform == Common::kPlatformPC98)
+ printFadingText(103, 240, 130, _textColorMap, _textColor[0]);
+ delayUntil(frameEnd);
+ setCountDown(0);
break;
case 0:
- _seqTextColor[1] = _screen->findLeastDifferentColor(_seqTextColorPresets, _screen->getPalette(0), 1, 255) & 0xff;
- memset(_seqTextColorMap, _seqTextColor[1], 16);
- _seqTextColor[0] = _seqTextColorMap[1] = 255;
- _screen->setTextColorMap(_seqTextColorMap);
+ _textColor[1] = _screen->findLeastDifferentColor(_textColorPresets, _screen->getPalette(0), 1, 255) & 0xFF;
+ memset(_textColorMap, _textColor[1], 16);
+ _textColor[0] = _textColorMap[1] = 255;
+ _screen->setTextColorMap(_textColorMap);
break;
case 5:
- if (!_flags.isTalkie)
- seq_playTalkText(18);
- _seqFrameDelay = 16;
+ if (!_vm->gameFlags().isTalkie)
+ playSoundAndDisplaySubTitle(18);
+ _animDuration = 16;
- if (_flags.isTalkie) {
- chatFirstFrame = 5;
- chatLastFrame = 8;
+ if (_vm->gameFlags().isTalkie) {
+ subTitleFirstFrame = 5;
+ subTitleLastFrame = 8;
voiceIndex = 22;
} else {
- chatLastFrame = 14;
+ subTitleLastFrame = 14;
}
- chatX = 116;
- chatY = 90;
- chatW = 60;
+ subTitleX = 116;
+ subTitleY = 90;
+ subTitleW = 60;
- seq_playWsaSyncDialogue(24, voiceIndex, 149, chatX, chatY, chatW, wsaObj, chatFirstFrame, chatLastFrame, x, y);
+ playDialogueAnimation(24, voiceIndex, 149, subTitleX, subTitleY, subTitleW, wsaObj, subTitleFirstFrame, subTitleLastFrame, x, y);
break;
case 11:
- if (_flags.isTalkie)
- seq_playWsaSyncDialogue(24, 22, 149, 116, 90, 60, wsaObj, 11, 14, x, y);
+ if (_vm->gameFlags().isTalkie)
+ playDialogueAnimation(24, 22, 149, 116, 90, 60, wsaObj, 11, 14, x, y);
break;
case 16:
- seq_playTalkText(_flags.isTalkie ? 23 : 19);
- _seqFrameDelay = _flags.isTalkie ? 20 : 16;
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 23 : 19);
+ _animDuration = _vm->gameFlags().isTalkie ? 20 : 16;
- if (_flags.lang == Common::FR_FRA) {
- chatY = 48;
- chatW = 88;
+ if (_vm->gameFlags().lang == Common::FR_FRA) {
+ subTitleY = 48;
+ subTitleW = 88;
} else {
- chatY = 60;
- chatW = 100;
+ subTitleY = 60;
+ subTitleW = 100;
}
- chatX = 60;
+ subTitleX = 60;
- if (_flags.isTalkie)
+ if (_vm->gameFlags().isTalkie)
voiceIndex = 36;
- seq_playWsaSyncDialogue(25, voiceIndex, 143, chatX, chatY, chatW, wsaObj, 16, 25, x, y);
- _seqFrameDelay = 16;
+ playDialogueAnimation(25, voiceIndex, 143, subTitleX, subTitleY, subTitleW, wsaObj, 16, 25, x, y);
+ _animDuration = 16;
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-int KyraEngine_HoF::seq_finaleFish(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- _seqSubFrameEndTimeInternal = 0;
- int chatX = 0;
- int chatY = 0;
- int chatW = 0;
+int SeqPlayer_HOF::cbHOF_fish(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ uint32 frameEnd = 0;
+ int subTitleX = 0;
+ int subTitleY = 0;
+ int subTitleW = 0;
uint16 voiceIndex = 0;
switch (frm) {
case -2:
- seq_sequenceCommand(9);
- _seqSubFrameEndTimeInternal = _system->getMillis() + 480 * _tickLength;
+ doTransition(9);
+ frameEnd = _system->getMillis() + 480 * _vm->tickLength();
- seq_printCreditsString(40, 240, _flags.isTalkie ? 55 : 40, _seqTextColorMap, 252);
- seq_printCreditsString(41, 240, _flags.isTalkie ? 65 : 50, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(42, 240, _flags.isTalkie ? 75 : 60, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(43, 240, _flags.isTalkie ? 95 : 80, _seqTextColorMap, 252);
- seq_printCreditsString(44, 240, _flags.isTalkie ? 105 : 90, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(93, 240, _flags.isTalkie ? 125 : 110, _seqTextColorMap, 252);
- seq_printCreditsString(94, 240, _flags.isTalkie ? 135 : 120, _seqTextColorMap, _seqTextColor[0]);
- delay(_seqSubFrameEndTimeInternal - _system->getMillis());
- _seqEndTime = 0;
+ printFadingText(40, 240, _vm->gameFlags().isTalkie ? 55 : 40, _textColorMap, 252);
+ printFadingText(41, 240, _vm->gameFlags().isTalkie ? 65 : 50, _textColorMap, _textColor[0]);
+ printFadingText(42, 240, _vm->gameFlags().isTalkie ? 75 : 60, _textColorMap, _textColor[0]);
+ printFadingText(43, 240, _vm->gameFlags().isTalkie ? 95 : 80, _textColorMap, 252);
+ printFadingText(44, 240, _vm->gameFlags().isTalkie ? 105 : 90, _textColorMap, _textColor[0]);
+ printFadingText(93, 240, _vm->gameFlags().isTalkie ? 125 : 110, _textColorMap, 252);
+ printFadingText(94, 240, _vm->gameFlags().isTalkie ? 135 : 120, _textColorMap, _textColor[0]);
+ delayUntil(frameEnd);
+ setCountDown(0);
break;
case 0:
- _seqTextColor[1] = _screen->findLeastDifferentColor(_seqTextColorPresets, _screen->getPalette(0), 1, 255) & 0xff;
- memset(_seqTextColorMap, _seqTextColor[1], 16);
- _seqTextColor[0] = _seqTextColorMap[1] = 0xff;
- _screen->setTextColorMap(_seqTextColorMap);
+ _textColor[1] = _screen->findLeastDifferentColor(_textColorPresets, _screen->getPalette(0), 1, 255) & 0xFF;
+ memset(_textColorMap, _textColor[1], 16);
+ _textColor[0] = _textColorMap[1] = 0xFF;
+ _screen->setTextColorMap(_textColorMap);
break;
case 4:
- chatX = 94;
- chatY = 42;
- chatW = 100;
- if (_flags.isTalkie)
+ subTitleX = 94;
+ subTitleY = 42;
+ subTitleW = 100;
+ if (_vm->gameFlags().isTalkie)
voiceIndex = 37;
- seq_playWsaSyncDialogue(26, voiceIndex, 149, chatX, chatY, chatW, wsaObj, 3, 12, x, y);
+ playDialogueAnimation(26, voiceIndex, 149, subTitleX, subTitleY, subTitleW, wsaObj, 3, 12, x, y);
break;
case 14:
- seq_playTalkText(_flags.isTalkie ? 19 : 15);
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 19 : 15);
break;
case 23:
- seq_playTalkText(_flags.isTalkie ? 20 : 16);
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 20 : 16);
break;
case 29:
- chatX = (_flags.lang == Common::DE_DEU) ? 82 : ((_flags.lang == Common::FR_FRA) ? 92 : 88);
- chatY = 40;
- chatW = 100;
+ subTitleX = (_vm->gameFlags().lang == Common::DE_DEU) ? 82 : ((_vm->gameFlags().lang == Common::FR_FRA) ? 92 : 88);
+ subTitleY = 40;
+ subTitleW = 100;
- if (_flags.isTalkie) {
- if (_flags.lang == Common::DE_DEU)
- chatY = 35;
+ if (_vm->gameFlags().isTalkie) {
+ if (_vm->gameFlags().lang == Common::DE_DEU)
+ subTitleY = 35;
voiceIndex = 38;
}
- seq_playWsaSyncDialogue(27, voiceIndex, 187, chatX, chatY, chatW, wsaObj, 28, 34, x, y);
+ playDialogueAnimation(27, voiceIndex, 187, subTitleX, subTitleY, subTitleW, wsaObj, 28, 34, x, y);
break;
case 45:
- seq_playTalkText(_flags.isTalkie ? 21 : 17);
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 21 : 17);
break;
case 50:
- seq_playTalkText(_flags.isTalkie ? 29 : 25);
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 29 : 25);
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-int KyraEngine_HoF::seq_finaleFheep(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- _seqSubFrameEndTimeInternal = 0;
- int chatX = 0;
- int chatY = 0;
- int chatW = 0;
- int chatFirstFrame = 0;
- int chatLastFrame = 0;
+int SeqPlayer_HOF::cbHOF_fheep(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ uint32 frameEnd = 0;
+ int subTitleX = 0;
+ int subTitleY = 0;
+ int subTitleW = 0;
+ int subTitleFirstFrame = 0;
+ int subTitleLastFrame = 0;
uint16 voiceIndex = 0;
switch (frm) {
@@ -1068,79 +2474,79 @@ int KyraEngine_HoF::seq_finaleFheep(WSAMovie_v2 *wsaObj, int x, int y, int frm)
_screen->copyPage(12, 2);
_screen->copyPage(2, 0);
_screen->updateScreen();
- seq_sequenceCommand(9);
- _seqSubFrameEndTimeInternal = _system->getMillis() + 480 * _tickLength;
- seq_printCreditsString(49, 240, 20, _seqTextColorMap, 252);
- seq_printCreditsString(50, 240, 30, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(51, 240, 40, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(52, 240, 50, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(53, 240, 60, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(54, 240, 70, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(55, 240, 80, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(56, 240, 90, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(57, 240, 100, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(58, 240, 110, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(60, 240, 120, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(61, 240, 130, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(62, 240, 140, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(63, 240, 150, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(64, 240, 160, _seqTextColorMap, _seqTextColor[0]);
-
- delay(_seqSubFrameEndTimeInternal - _system->getMillis());
- _seqEndTime = 0;
+ doTransition(9);
+ frameEnd = _system->getMillis() + 480 * _vm->tickLength();
+ printFadingText(49, 240, 20, _textColorMap, 252);
+ printFadingText(50, 240, 30, _textColorMap, _textColor[0]);
+ printFadingText(51, 240, 40, _textColorMap, _textColor[0]);
+ printFadingText(52, 240, 50, _textColorMap, _textColor[0]);
+ printFadingText(53, 240, 60, _textColorMap, _textColor[0]);
+ printFadingText(54, 240, 70, _textColorMap, _textColor[0]);
+ printFadingText(55, 240, 80, _textColorMap, _textColor[0]);
+ printFadingText(56, 240, 90, _textColorMap, _textColor[0]);
+ printFadingText(57, 240, 100, _textColorMap, _textColor[0]);
+ printFadingText(58, 240, 110, _textColorMap, _textColor[0]);
+ printFadingText(60, 240, 120, _textColorMap, _textColor[0]);
+ printFadingText(61, 240, 130, _textColorMap, _textColor[0]);
+ printFadingText(62, 240, 140, _textColorMap, _textColor[0]);
+ printFadingText(63, 240, 150, _textColorMap, _textColor[0]);
+ printFadingText(64, 240, 160, _textColorMap, _textColor[0]);
+
+ delayUntil(frameEnd);
+ setCountDown(0);
break;
case 0:
- _seqTextColor[1] = _screen->findLeastDifferentColor(_seqTextColorPresets, _screen->getPalette(0), 1, 255) & 0xff;
- memset(_seqTextColorMap, _seqTextColor[1], 16);
- _seqTextColor[0] = _seqTextColorMap[1] = 0xff;
- _screen->setTextColorMap(_seqTextColorMap);
+ _textColor[1] = _screen->findLeastDifferentColor(_textColorPresets, _screen->getPalette(0), 1, 255) & 0xFF;
+ memset(_textColorMap, _textColor[1], 16);
+ _textColor[0] = _textColorMap[1] = 0xFF;
+ _screen->setTextColorMap(_textColorMap);
break;
case 2:
- seq_playTalkText(_flags.isTalkie ? 25 : 21);
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 25 : 21);
- if (_flags.lang == Common::FR_FRA) {
- chatX = 92;
- chatY = 72;
+ if (_vm->gameFlags().lang == Common::FR_FRA) {
+ subTitleX = 92;
+ subTitleY = 72;
} else {
- chatX = (_flags.lang == Common::DE_DEU) ? 90 : 98;
- chatY = 84;
+ subTitleX = (_vm->gameFlags().lang == Common::DE_DEU) ? 90 : 98;
+ subTitleY = 84;
}
- if (_flags.isTalkie) {
- chatFirstFrame = 8;
- chatLastFrame = 9;
+ if (_vm->gameFlags().isTalkie) {
+ subTitleFirstFrame = 8;
+ subTitleLastFrame = 9;
voiceIndex = 39;
} else {
- chatFirstFrame = 2;
- chatLastFrame = -8;
+ subTitleFirstFrame = 2;
+ subTitleLastFrame = -8;
}
- chatW = 100;
+ subTitleW = 100;
- seq_playWsaSyncDialogue(28, voiceIndex, -1, chatX, chatY, chatW, wsaObj, chatFirstFrame, chatLastFrame, x, y);
- if (_flags.isTalkie)
- _seqWsaCurrentFrame = 4;
+ playDialogueAnimation(28, voiceIndex, -1, subTitleX, subTitleY, subTitleW, wsaObj, subTitleFirstFrame, subTitleLastFrame, x, y);
+ if (_vm->gameFlags().isTalkie)
+ _animCurrentFrame = 4;
break;
case 9:
- seq_playTalkText(_flags.isTalkie ? 24 : 20);
- _seqFrameDelay = 100;
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 24 : 20);
+ _animDuration = 100;
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-int KyraEngine_HoF::seq_finaleFarmer(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- _seqSubFrameEndTimeInternal = 0;
- int chatX = 0;
- int chatY = 0;
- int chatW = 0;
+int SeqPlayer_HOF::cbHOF_farmer(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ uint32 frameEnd = 0;
+ int subTitleX = 0;
+ int subTitleY = 0;
+ int subTitleW = 0;
uint16 voiceIndex = 0;
switch (frm) {
@@ -1148,169 +2554,164 @@ int KyraEngine_HoF::seq_finaleFarmer(WSAMovie_v2 *wsaObj, int x, int y, int frm)
_screen->copyPage(12, 2);
_screen->copyPage(2, 0);
_screen->updateScreen();
- seq_sequenceCommand(9);
- _seqSubFrameEndTimeInternal = _system->getMillis() + 480 * _tickLength;
- seq_printCreditsString(45, 240, 40, _seqTextColorMap, 252);
- seq_printCreditsString(46, 240, 50, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(47, 240, 60, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(83, 240, 80, _seqTextColorMap, 252);
- seq_printCreditsString(48, 240, 90, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(65, 240, 110, _seqTextColorMap, 252);
- seq_printCreditsString(66, 240, 120, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(67, 240, 130, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(68, 240, 140, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(69, 240, 150, _seqTextColorMap, _seqTextColor[0]);
- if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)
- seq_printCreditsString(104, 240, 160, _seqTextColorMap, _seqTextColor[0]);
- delay(_seqSubFrameEndTimeInternal - _system->getMillis());
- _seqEndTime = 0;
+ doTransition(9);
+ frameEnd = _system->getMillis() + 480 * _vm->tickLength();
+ printFadingText(45, 240, 40, _textColorMap, 252);
+ printFadingText(46, 240, 50, _textColorMap, _textColor[0]);
+ printFadingText(47, 240, 60, _textColorMap, _textColor[0]);
+ printFadingText(83, 240, 80, _textColorMap, 252);
+ printFadingText(48, 240, 90, _textColorMap, _textColor[0]);
+ printFadingText(65, 240, 110, _textColorMap, 252);
+ printFadingText(66, 240, 120, _textColorMap, _textColor[0]);
+ printFadingText(67, 240, 130, _textColorMap, _textColor[0]);
+ printFadingText(68, 240, 140, _textColorMap, _textColor[0]);
+ printFadingText(69, 240, 150, _textColorMap, _textColor[0]);
+ if (_vm->gameFlags().platform == Common::kPlatformFMTowns || _vm->gameFlags().platform == Common::kPlatformPC98)
+ printFadingText(104, 240, 160, _textColorMap, _textColor[0]);
+ delayUntil(frameEnd);
+ setCountDown(0);
break;
case 0:
- _seqTextColor[1] = 1 + (_screen->findLeastDifferentColor(_seqTextColorPresets, _screen->getPalette(0), 1, 254) & 0xff);
- memset(_seqTextColorMap, _seqTextColor[1], 16);
- _seqTextColorMap[1] = _seqTextColor[0] = 1 + (_screen->findLeastDifferentColor(_seqTextColorPresets + 3, _screen->getPalette(0), 1, 254) & 0xff);
- _screen->setTextColorMap(_seqTextColorMap);
- seq_playTalkText(_flags.isTalkie ? 30 : 26);
+ _textColor[1] = 1 + (_screen->findLeastDifferentColor(_textColorPresets, _screen->getPalette(0), 1, 254) & 0xFF);
+ memset(_textColorMap, _textColor[1], 16);
+ _textColorMap[1] = _textColor[0] = 1 + (_screen->findLeastDifferentColor(_textColorPresets + 3, _screen->getPalette(0), 1, 254) & 0xFF);
+ _screen->setTextColorMap(_textColorMap);
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 30 : 26);
break;
case 6:
- if (_flags.isTalkie)
- seq_playTalkText(18);
+ if (_vm->gameFlags().isTalkie)
+ playSoundAndDisplaySubTitle(18);
break;
case 12:
- if (!_flags.isTalkie)
- seq_playTalkText(14);
+ if (!_vm->gameFlags().isTalkie)
+ playSoundAndDisplaySubTitle(14);
- chatX = 90;
- chatY = 30;
- chatW = 100;
+ subTitleX = 90;
+ subTitleY = 30;
+ subTitleW = 100;
- if (_flags.isTalkie) {
- if (_flags.lang == Common::FR_FRA || _flags.lang == Common::DE_DEU) {
- chatX = 75;
- chatY = 25;
+ if (_vm->gameFlags().isTalkie) {
+ if (_vm->gameFlags().lang == Common::FR_FRA || _vm->gameFlags().lang == Common::DE_DEU) {
+ subTitleX = 75;
+ subTitleY = 25;
}
voiceIndex = 40;
}
- seq_playWsaSyncDialogue(29, voiceIndex, 150, chatX, chatY, chatW, wsaObj, 12, -21, x, y);
+ playDialogueAnimation(29, voiceIndex, 150, subTitleX, subTitleY, subTitleW, wsaObj, 12, -21, x, y);
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-int KyraEngine_HoF::seq_finaleFuards(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- _seqSubFrameEndTimeInternal = 0;
- int chatX = 0;
- int chatY = 0;
- int chatW = 0;
- int chatFirstFrame = 0;
- int chatLastFrame = 0;
- //int textCol = 0;
+int SeqPlayer_HOF::cbHOF_fuards(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ uint32 frameEnd = 0;
+ int subTitleX = 0;
+ int subTitleY = 0;
+ int subTitleW = 0;
+ int subTitleFirstFrame = 0;
+ int subTitleLastFrame = 0;
uint16 voiceIndex = 0;
switch (frm) {
case -2:
- seq_sequenceCommand(9);
- _seqSubFrameEndTimeInternal = _system->getMillis() + 480 * _tickLength;
- seq_printCreditsString(70, 240, 20, _seqTextColorMap, 252);
- seq_printCreditsString(71, 240, 30, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(72, 240, 40, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(73, 240, 50, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(74, 240, 60, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(75, 240, 70, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(101, 240, 80, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(102, 240, 90, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(87, 240, 100, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(88, 240, 110, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(89, 240, 120, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(90, 240, 130, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(91, 240, 140, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(92, 240, 150, _seqTextColorMap, _seqTextColor[0]);
- delay(_seqSubFrameEndTimeInternal - _system->getMillis());
- _seqEndTime = 0;
+ doTransition(9);
+ frameEnd = _system->getMillis() + 480 * _vm->tickLength();
+ printFadingText(70, 240, 20, _textColorMap, 252);
+ printFadingText(71, 240, 30, _textColorMap, _textColor[0]);
+ printFadingText(72, 240, 40, _textColorMap, _textColor[0]);
+ printFadingText(73, 240, 50, _textColorMap, _textColor[0]);
+ printFadingText(74, 240, 60, _textColorMap, _textColor[0]);
+ printFadingText(75, 240, 70, _textColorMap, _textColor[0]);
+ printFadingText(101, 240, 80, _textColorMap, _textColor[0]);
+ printFadingText(102, 240, 90, _textColorMap, _textColor[0]);
+ printFadingText(87, 240, 100, _textColorMap, _textColor[0]);
+ printFadingText(88, 240, 110, _textColorMap, _textColor[0]);
+ printFadingText(89, 240, 120, _textColorMap, _textColor[0]);
+ printFadingText(90, 240, 130, _textColorMap, _textColor[0]);
+ printFadingText(91, 240, 140, _textColorMap, _textColor[0]);
+ printFadingText(92, 240, 150, _textColorMap, _textColor[0]);
+ delayUntil(frameEnd);
+ setCountDown(0);
break;
case 0:
for (int i = 0; i < 0x300; i++)
- _screen->getPalette(0)[i] &= 0x3f;
- _seqTextColor[1] = 0xCf;
- memset(_seqTextColorMap, _seqTextColor[1], 16);
- _seqTextColor[0] = _seqTextColorMap[1] = 0xfe;
+ _screen->getPalette(0)[i] &= 0x3F;
+ _textColor[1] = 0xCf;
+ memset(_textColorMap, _textColor[1], 16);
+ _textColor[0] = _textColorMap[1] = 0xFE;
- _screen->setTextColorMap(_seqTextColorMap);
+ _screen->setTextColorMap(_textColorMap);
break;
case 6:
- _seqFrameDelay = 20;
+ _animDuration = 20;
- if (_flags.isTalkie) {
- chatX = 82;
- //textCol = 143;
- chatFirstFrame = 16;
- chatLastFrame = 21;
+ if (_vm->gameFlags().isTalkie) {
+ subTitleX = 82;
+ subTitleFirstFrame = 16;
+ subTitleLastFrame = 21;
voiceIndex = 41;
} else {
- chatX = 62;
- //textCol = 137;
- chatFirstFrame = 9;
- chatLastFrame = 13;
+ subTitleX = 62;
+ subTitleFirstFrame = 9;
+ subTitleLastFrame = 13;
}
- chatY = (_flags.lang == Common::FR_FRA || _flags.lang == Common::DE_DEU) ? 88 :100;
- chatW = 80;
+ subTitleY = (_vm->gameFlags().lang == Common::FR_FRA || _vm->gameFlags().lang == Common::DE_DEU) ? 88 :100;
+ subTitleW = 80;
- seq_playWsaSyncDialogue(30, voiceIndex, 137, chatX, chatY, chatW, wsaObj, chatFirstFrame, chatLastFrame, x, y);
- if (_flags.isTalkie)
- _seqWsaCurrentFrame = 8;
+ playDialogueAnimation(30, voiceIndex, 137, subTitleX, subTitleY, subTitleW, wsaObj, subTitleFirstFrame, subTitleLastFrame, x, y);
+ if (_vm->gameFlags().isTalkie)
+ _animCurrentFrame = 8;
break;
case 9:
case 16:
- if (_flags.isTalkie) {
+ if (_vm->gameFlags().isTalkie) {
if (frm == 16)
break;
- chatX = 64;
- //textCol = 137;
- chatFirstFrame = 9;
- chatLastFrame = 13;
+ subTitleX = 64;
+ subTitleFirstFrame = 9;
+ subTitleLastFrame = 13;
voiceIndex = 42;
} else {
if (frm == 9)
break;
- chatX = 80;
- //textCol = 143;
- chatFirstFrame = 16;
- chatLastFrame = 21;
+ subTitleX = 80;
+ subTitleFirstFrame = 16;
+ subTitleLastFrame = 21;
}
- chatY = 100;
- chatW = 100;
+ subTitleY = 100;
+ subTitleW = 100;
- seq_playWsaSyncDialogue(31, voiceIndex, 143, chatX, chatY, chatW, wsaObj, chatFirstFrame, chatLastFrame, x, y);
- if (_flags.isTalkie)
- _seqWsaCurrentFrame = 21;
+ playDialogueAnimation(31, voiceIndex, 143, subTitleX, subTitleY, subTitleW, wsaObj, subTitleFirstFrame, subTitleLastFrame, x, y);
+ if (_vm->gameFlags().isTalkie)
+ _animCurrentFrame = 21;
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-int KyraEngine_HoF::seq_finaleFirates(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- _seqSubFrameEndTimeInternal = 0;
- int chatX = 0;
- int chatY = 0;
- int chatW = 0;
+int SeqPlayer_HOF::cbHOF_firates(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ uint32 frameEnd = 0;
+ int subTitleX = 0;
+ int subTitleY = 0;
+ int subTitleW = 0;
uint16 voiceIndex = 0;
switch (frm) {
@@ -1318,87 +2719,87 @@ int KyraEngine_HoF::seq_finaleFirates(WSAMovie_v2 *wsaObj, int x, int y, int frm
_screen->copyPage(12, 2);
_screen->copyPage(2, 0);
_screen->updateScreen();
- seq_sequenceCommand(9);
- _seqSubFrameEndTimeInternal = _system->getMillis() + 480 * _tickLength;
- seq_printCreditsString(76, 240, 40, _seqTextColorMap, 252);
- seq_printCreditsString(77, 240, 50, _seqTextColorMap, 252);
- seq_printCreditsString(78, 240, 60, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(79, 240, 70, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(80, 240, 80, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(84, 240, 100, _seqTextColorMap, 252);
- seq_printCreditsString(85, 240, 110, _seqTextColorMap, _seqTextColor[0]);
- seq_printCreditsString(99, 240, 130, _seqTextColorMap, 252);
- seq_printCreditsString(100, 240, 140, _seqTextColorMap, _seqTextColor[0]);
- delay(_seqSubFrameEndTimeInternal - _system->getMillis());
- _seqEndTime = 0;
+ doTransition(9);
+ frameEnd = _system->getMillis() + 480 * _vm->tickLength();
+ printFadingText(76, 240, 40, _textColorMap, 252);
+ printFadingText(77, 240, 50, _textColorMap, 252);
+ printFadingText(78, 240, 60, _textColorMap, _textColor[0]);
+ printFadingText(79, 240, 70, _textColorMap, _textColor[0]);
+ printFadingText(80, 240, 80, _textColorMap, _textColor[0]);
+ printFadingText(84, 240, 100, _textColorMap, 252);
+ printFadingText(85, 240, 110, _textColorMap, _textColor[0]);
+ printFadingText(99, 240, 130, _textColorMap, 252);
+ printFadingText(100, 240, 140, _textColorMap, _textColor[0]);
+ delayUntil(frameEnd);
+ setCountDown(0);
break;
case 0:
- _seqTextColor[1] = _screen->findLeastDifferentColor(_seqTextColorPresets, _screen->getPalette(0), 1, 255) & 0xff;
- memset(_seqTextColorMap, _seqTextColor[1], 16);
- _seqTextColor[0] = _seqTextColorMap[1] = 0xff;
- _screen->setTextColorMap(_seqTextColorMap);
+ _textColor[1] = _screen->findLeastDifferentColor(_textColorPresets, _screen->getPalette(0), 1, 255) & 0xFF;
+ memset(_textColorMap, _textColor[1], 16);
+ _textColor[0] = _textColorMap[1] = 0xFF;
+ _screen->setTextColorMap(_textColorMap);
break;
case 6:
- seq_playTalkText(_flags.isTalkie ? 31 : 27);
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 31 : 27);
break;
case 14:
case 15:
- if (!((frm == 15 && !_flags.isTalkie) || (frm == 14 && _flags.isTalkie)))
+ if (!((frm == 15 && !_vm->gameFlags().isTalkie) || (frm == 14 && _vm->gameFlags().isTalkie)))
break;
- seq_playTalkText(_flags.isTalkie ? 31 : 27);
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 31 : 27);
- if (_flags.lang == Common::DE_DEU) {
- chatX = 82;
- chatY = 84;
- chatW = 140;
+ if (_vm->gameFlags().lang == Common::DE_DEU) {
+ subTitleX = 82;
+ subTitleY = 84;
+ subTitleW = 140;
} else {
- chatX = 74;
- chatY = (_flags.lang == Common::FR_FRA) ? 96: 108;
- chatW = 80;
+ subTitleX = 74;
+ subTitleY = (_vm->gameFlags().lang == Common::FR_FRA) ? 96: 108;
+ subTitleW = 80;
}
- if (_flags.isTalkie)
+ if (_vm->gameFlags().isTalkie)
voiceIndex = 43;
- seq_playWsaSyncDialogue(32, voiceIndex, 137, chatX, chatY, chatW, wsaObj, 14, 16, x, y);
+ playDialogueAnimation(32, voiceIndex, 137, subTitleX, subTitleY, subTitleW, wsaObj, 14, 16, x, y);
break;
case 28:
- seq_playTalkText(_flags.isTalkie ? 32 : 28);
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 32 : 28);
break;
case 29:
- seq_playTalkText(_flags.isTalkie ? 33 : 29);
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 33 : 29);
break;
case 31:
- if (_flags.isTalkie)
+ if (_vm->gameFlags().isTalkie)
voiceIndex = 44;
- chatX = 90;
- chatY = (_flags.lang == Common::DE_DEU) ? 60 : 76;
- chatW = 80;
+ subTitleX = 90;
+ subTitleY = (_vm->gameFlags().lang == Common::DE_DEU) ? 60 : 76;
+ subTitleW = 80;
- seq_playWsaSyncDialogue(33, voiceIndex, 143, chatX, chatY, chatW, wsaObj, 31, 34, x, y);
+ playDialogueAnimation(33, voiceIndex, 143, subTitleX, subTitleY, subTitleW, wsaObj, 31, 34, x, y);
break;
case 35:
- _seqFrameDelay = 300;
+ _animDuration = 300;
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-int KyraEngine_HoF::seq_finaleFrash(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOF_frash(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
int tmp = 0;
switch (frm) {
@@ -1408,473 +2809,440 @@ int KyraEngine_HoF::seq_finaleFrash(WSAMovie_v2 *wsaObj, int x, int y, int frm)
_screen->copyPage(2, 12);
_screen->copyPage(2, 0);
_screen->updateScreen();
- _seqFrameCounter = 0;
- seq_loadNestedSequence(0, kSequenceFiggle);
+ _callbackCurrentFrame = 0;
+ startNestedAnimation(0, kNestedSequenceFiggle);
break;
case -1:
- if (_flags.isTalkie)
- seq_finaleActorScreen();
- _seqSpecialFlag = _flags.isTalkie;
+ if (_vm->gameFlags().isTalkie)
+ playHoFTalkieCredits();
+ _talkieFinaleExtraFlag = _vm->gameFlags().isTalkie;
break;
case 0:
- if (_seqFrameCounter == 1) {
- _sound->playTrack(4);
- _seqTextColor[1] = _screen->findLeastDifferentColor(_seqTextColorPresets, _screen->getPalette(0), 1, 255) & 0xff;
- memset(_seqTextColorMap, _seqTextColor[1], 16);
- _seqTextColor[0] = _seqTextColorMap[1] = 0xff;
- _screen->setTextColorMap(_seqTextColorMap);
+ if (_callbackCurrentFrame == 1) {
+ _vm->sound()->playTrack(4);
+ _textColor[1] = _screen->findLeastDifferentColor(_textColorPresets, _screen->getPalette(0), 1, 255) & 0xFF;
+ memset(_textColorMap, _textColor[1], 16);
+ _textColor[0] = _textColorMap[1] = 0xFF;
+ _screen->setTextColorMap(_textColorMap);
}
- _seqFrameDelay = 10;
+ _animDuration = 10;
break;
case 1:
- if (_seqFrameCounter < 20 && _seqSpecialFlag) {
- _seqWsaCurrentFrame = 0;
+ if (_callbackCurrentFrame < 20 && _talkieFinaleExtraFlag) {
+ _animCurrentFrame = 0;
} else {
- _seqFrameDelay = _flags.isTalkie ? 500 : (300 + _rnd.getRandomNumberRng(1, 300));
- seq_playTalkText(_flags.isTalkie ? 26 : 22);
- if (_seqSpecialFlag) {
- _seqFrameCounter = 3;
- _seqSpecialFlag = false;
+ _animDuration = _vm->gameFlags().isTalkie ? 500 : (300 + _vm->_rnd.getRandomNumberRng(1, 300));
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 26 : 22);
+ if (_talkieFinaleExtraFlag) {
+ _callbackCurrentFrame = 3;
+ _talkieFinaleExtraFlag = false;
}
}
break;
case 2:
- _seqFrameDelay = 20;
+ _animDuration = 20;
break;
case 3:
- seq_playTalkText(_flags.isTalkie ? 27 : 23);
- _seqFrameDelay = _flags.isTalkie ? 500 : (300 + _rnd.getRandomNumberRng(1, 300));
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 27 : 23);
+ _animDuration = _vm->gameFlags().isTalkie ? 500 : (300 + _vm->_rnd.getRandomNumberRng(1, 300));
break;
case 4:
- _seqFrameDelay = 10;
+ _animDuration = 10;
break;
case 5:
- seq_playTalkText(_flags.isTalkie ? 27 : 23);
- tmp = _seqFrameCounter / 6;
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 27 : 23);
+ tmp = _callbackCurrentFrame / 6;
if (tmp == 2)
- _seqFrameDelay = _flags.isTalkie ? 7 : (1 + _rnd.getRandomNumberRng(1, 10));
+ _animDuration = _vm->gameFlags().isTalkie ? 7 : (1 + _vm->_rnd.getRandomNumberRng(1, 10));
else if (tmp < 2)
- _seqFrameDelay = _flags.isTalkie ? 500 : (300 + _rnd.getRandomNumberRng(1, 300));
+ _animDuration = _vm->gameFlags().isTalkie ? 500 : (300 + _vm->_rnd.getRandomNumberRng(1, 300));
break;
case 6:
- _seqFrameDelay = 10;
- tmp = _seqFrameCounter / 6;
+ _animDuration = 10;
+ tmp = _callbackCurrentFrame / 6;
if (tmp == 2)
- _seqWsaCurrentFrame = 4;
+ _animCurrentFrame = 4;
else if (tmp < 2)
- _seqWsaCurrentFrame = 0;
+ _animCurrentFrame = 0;
break;
case 7:
- _seqFrameCounter = 0;
- _seqFrameDelay = 5;
- seq_playTalkText(_flags.isTalkie ? 26 : 22);
+ _callbackCurrentFrame = 0;
+ _animDuration = 5;
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 26 : 22);
break;
case 11:
- if (_seqFrameCounter < 8)
- _seqWsaCurrentFrame = 8;
+ if (_callbackCurrentFrame < 8)
+ _animCurrentFrame = 8;
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-void KyraEngine_HoF::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->getPalette(0));
- _screen->setFont(Screen::FID_GOLDFONT_FNT);
-
- 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);
-
- _screen->setTextColorMap(colormap);
- _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0);
- _screen->updateScreen();
- _screen->fadeFromBlack();
-
- _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);
-}
-
-int KyraEngine_HoF::seq_finaleFiggle(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- if (_seqFrameCounter == 10)
- _seqEndTime = 0;
- if (_seqFrameCounter == 10 || _seqFrameCounter == 5 || _seqFrameCounter == 7)
- seq_playTalkText(_flags.isTalkie ? 45 : 30);
+int SeqPlayer_HOF::cbHOF_figgle(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ if (_callbackCurrentFrame == 10)
+ setCountDown(0);
+ if (_callbackCurrentFrame == 10 || _callbackCurrentFrame == 5 || _callbackCurrentFrame == 7)
+ playSoundAndDisplaySubTitle(_vm->gameFlags().isTalkie ? 45 : 30);
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return frm;
}
-int KyraEngine_HoF::seq_demoVirgin(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOFDEMO_virgin(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (!frm)
- delay(50 * _tickLength);
+ delayTicks(50);
return 0;
}
-int KyraEngine_HoF::seq_demoWestwood(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOFDEMO_westwood(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (!frm)
- _sound->playTrack(2);
+ _vm->sound()->playTrack(2);
return 0;
}
-int KyraEngine_HoF::seq_demoTitle(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+
+int SeqPlayer_HOF::cbHOFDEMO_title(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (!frm) {
- _sound->playTrack(3);
+ _vm->sound()->playTrack(3);
} else if (frm == 25) {
- delay(60 * _tickLength);
- _seqEndTime = 0;
- seq_sequenceCommand(0);
+ delayTicks(60);
+ setCountDown(0);
+ doTransition(0);
}
return 0;
}
-int KyraEngine_HoF::seq_demoHill(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOFDEMO_hill(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (!frm) {
- _sound->playTrack(4);
+ _vm->sound()->playTrack(4);
} else if (frm == 25) {
- seq_loadNestedSequence(0, kSequenceDemoWater);
- _seqFrameDelay--;
+ startNestedAnimation(0, kNestedSequenceHoFDemoWater);
+ _animDuration--;
} else if (frm > 25 && frm < 50) {
- if (_seqFrameDelay > 3)
- _seqFrameDelay--;
+ if (_animDuration > 3)
+ _animDuration--;
} else if (frm == 95) {
- _seqFrameDelay = 70;
+ _animDuration = 70;
} else if (frm == 96) {
- _seqFrameDelay = 7;
+ _animDuration = 7;
} else if (frm == 129) {
- seq_resetActiveWSA(0);
+ closeNestedAnimation(0);
}
return 0;
}
-int KyraEngine_HoF::seq_demoOuthome(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOFDEMO_outhome(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
switch (frm) {
case 12:
- seq_playTalkText(4);
+ playSoundAndDisplaySubTitle(4);
break;
case 32:
- seq_playTalkText(7);
+ playSoundAndDisplaySubTitle(7);
break;
case 36:
- seq_playTalkText(10);
+ playSoundAndDisplaySubTitle(10);
break;
case 57:
- seq_playTalkText(9);
+ playSoundAndDisplaySubTitle(9);
break;
case 80:
case 96:
case 149:
- _seqFrameDelay = 70;
+ _animDuration = 70;
break;
case 81:
case 97:
- _seqFrameDelay = 5;
+ _animDuration = 5;
break;
case 110:
- seq_playTalkText(5);
+ playSoundAndDisplaySubTitle(5);
break;
case 137:
- seq_playTalkText(6);
+ playSoundAndDisplaySubTitle(6);
break;
}
return 0;
}
-int KyraEngine_HoF::seq_demoWharf(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- if (!_seqFrameCounter)
- seq_loadNestedSequence(0, kSequenceDemoWharf2);
+int SeqPlayer_HOF::cbHOFDEMO_wharf(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ if (!_callbackCurrentFrame)
+ startNestedAnimation(0, kNestedSequenceHoFDemoWharf2);
switch (frm) {
case 0:
- seq_playTalkText(11);
+ playSoundAndDisplaySubTitle(11);
break;
case 5:
- if ((_seqFrameCounter / 8) <= 2 || _activeWSA[0].flags != -1)
- _seqWsaCurrentFrame = 0;
+ if ((_callbackCurrentFrame / 8) <= 2 || _animSlots[0].flags != -1)
+ _animCurrentFrame = 0;
else
- seq_resetActiveWSA(0);
+ closeNestedAnimation(0);
break;
case 6:
- seq_resetActiveWSA(0);
+ closeNestedAnimation(0);
break;
case 8:
case 10:
- seq_playTalkText(2);
+ playSoundAndDisplaySubTitle(2);
break;
case 13:
- seq_playTalkText(7);
+ playSoundAndDisplaySubTitle(7);
break;
case 16:
- seq_playTalkText(12);
+ playSoundAndDisplaySubTitle(12);
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-int KyraEngine_HoF::seq_demoDinob(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOFDEMO_dinob(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == 0) {
- if (!(_seqFrameCounter/8)) {
- seq_loadNestedSequence(0, kSequenceDemoDinob2);
- _seqWsaCurrentFrame = 0;
+ if (!(_callbackCurrentFrame/8)) {
+ startNestedAnimation(0, kNestedSequenceHoFDemoDinob2);
+ _animCurrentFrame = 0;
}
} else if (frm == 3) {
- if (_activeWSA[0].flags != -1) {
- _seqWsaCurrentFrame = 0;
+ if (_animSlots[0].flags != -1) {
+ _animCurrentFrame = 0;
} else {
- seq_resetActiveWSA(0);
+ closeNestedAnimation(0);
_screen->copyPage(2, 12);
}
} else if (frm == 4) {
- seq_resetActiveWSA(0);
+ closeNestedAnimation(0);
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return 0;
}
-int KyraEngine_HoF::seq_demoFisher(WSAMovie_v2 *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);
+int SeqPlayer_HOF::cbHOFDEMO_fisher(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ if (((_system->getMillis() - _fisherAnimCurTime) / (5 * _vm->tickLength())) > 0) {
+ _fisherAnimCurTime = _system->getMillis();
+ if (!_callbackCurrentFrame) {
+ startNestedAnimation(0, kNestedSequenceHoFDemoBail);
+ startNestedAnimation(1, kNestedSequenceHoFDemoDig);
}
- if (_seqScrollTextCounter >= 0x18f && !_seqFrameCounter)
+ if (_scrollProgressCounter >= 0x18F && !_callbackCurrentFrame)
return 0;
- if (!_seqFrameCounter) {
+ if (!_callbackCurrentFrame) {
_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;
+ _scrollProgressCounter = 0;
}
- seq_scrollPage(24, 144);
- _seqFrameCounter++;
- if (_seqFrameCounter < 0x256 || _seqFrameCounter > 0x31c) {
- if (_seqFrameCounter < 0x174 || _seqFrameCounter > 0x1d7) {
- if (_seqFrameCounter < 0x84 || _seqFrameCounter > 0xe7) {
- _seqScrollTextCounter++;
+ updateDemoAdText(24, 144);
+ _callbackCurrentFrame++;
+ if (_callbackCurrentFrame < 0x256 || _callbackCurrentFrame > 0x31C) {
+ if (_callbackCurrentFrame < 0x174 || _callbackCurrentFrame > 0x1D7) {
+ if (_callbackCurrentFrame < 0x84 || _callbackCurrentFrame > 0xE7) {
+ _scrollProgressCounter++;
}
}
}
- if (_seqFrameCounter > 0x31e) {
- seq_resetActiveWSA(0);
- seq_resetActiveWSA(1);
- _seqEndTime = 0;
+ if (_callbackCurrentFrame > 0x31E) {
+ closeNestedAnimation(0);
+ closeNestedAnimation(1);
+ setCountDown(0);
_screen->copyPage(2, 12);
}
} else {
- seq_scrollPage(24, 144);
+ updateDemoAdText(24, 144);
}
return 0;
}
-int KyraEngine_HoF::seq_demoWharf2(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOFDEMO_wharf2(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == 69)
- _seqWsaCurrentFrame = 8;
+ _animCurrentFrame = 8;
return frm;
}
-int KyraEngine_HoF::seq_demoDinob2(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOFDEMO_dinob2(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
switch (frm) {
case 19:
- seq_playTalkText(13);
+ playSoundAndDisplaySubTitle(13);
break;
case 54:
- seq_playTalkText(15);
+ playSoundAndDisplaySubTitle(15);
break;
case 61:
- seq_playTalkText(16);
+ playSoundAndDisplaySubTitle(16);
break;
case 69:
- seq_playTalkText(14);
+ playSoundAndDisplaySubTitle(14);
break;
case 77:
- seq_playTalkText(13);
+ playSoundAndDisplaySubTitle(13);
break;
case 79:
- _seqWsaCurrentFrame = 4;
+ _animCurrentFrame = 4;
break;
}
return frm;
}
-int KyraEngine_HoF::seq_demoWater(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOFDEMO_water(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
if (frm == 1)
- seq_playTalkText(11);
+ playSoundAndDisplaySubTitle(11);
return frm;
}
-int KyraEngine_HoF::seq_demoBail(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOFDEMO_bail(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
return frm;
}
-int KyraEngine_HoF::seq_demoDig(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbHOFDEMO_dig(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
return frm;
}
#ifdef ENABLE_LOL
-int KyraEngine_HoF::seq_lolDemoScene1(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+int SeqPlayer_HOF::cbLOLDEMO_scene1(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
Palette &tmpPal = _screen->getPalette(2);
- if (!(_seqFrameCounter % 100)) {
- if (_seqFrameCounter == 0) {
- _sound->haltTrack();
- _sound->playTrack(6);
+ if (!(_callbackCurrentFrame % 100)) {
+ if (_callbackCurrentFrame == 0) {
+ _vm->sound()->haltTrack();
+ _vm->sound()->playTrack(6);
}
tmpPal.copy(_screen->getPalette(0));
- for (int i = 3; i < 0x300; i++) {
+ for (int i = 3; i < 768; i++) {
tmpPal[i] = ((int)tmpPal[i] * 120) / 64;
- if (tmpPal[i] > 0x3f)
- tmpPal[i] = 0x3f;
+ if (tmpPal[i] > 0x3F)
+ tmpPal[i] = 0x3F;
}
- seq_playTalkText(_rnd.getRandomBit());
+ playSoundAndDisplaySubTitle(_vm->_rnd.getRandomBit());
_screen->setScreenPalette(tmpPal);
_screen->updateScreen();
- delay(8);
+ _vm->delay(8);
} else {
_screen->setScreenPalette(_screen->getPalette(0));
_screen->updateScreen();
- if (_seqFrameCounter == 40)
- seq_playTalkText(3);
+ if (_callbackCurrentFrame == 40)
+ playSoundAndDisplaySubTitle(3);
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return frm;
}
-int KyraEngine_HoF::seq_lolDemoScene2(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- switch (_seqFrameCounter - 17) {
+int SeqPlayer_HOF::cbLOLDEMO_scene2(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ switch (frm - 17) {
case 0:
- _seqFrameDelay = 8;
+ _animDuration = 8;
break;
case 3:
case 6:
case 9:
- seq_playTalkText(8);
+ playSoundEffect(8, 255 - ((26 - frm) << 3));
break;
case 15:
- seq_playTalkText(9);
+ playSoundAndDisplaySubTitle(9);
break;
case 18:
- seq_playTalkText(2);
+ playSoundAndDisplaySubTitle(2);
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return frm;
}
-int KyraEngine_HoF::seq_lolDemoScene3(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- if (_seqFrameCounter == 1)
- seq_playTalkText(6);
- else if (frm == 26)
- seq_playTalkText(7);
+int SeqPlayer_HOF::cbLOLDEMO_scene3(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ if (frm == 1)
+ playSoundAndDisplaySubTitle(6);
+ else if (frm == 24)
+ playSoundAndDisplaySubTitle(7);
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return frm;
}
-int KyraEngine_HoF::seq_lolDemoScene4(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- switch (_seqFrameCounter) {
+int SeqPlayer_HOF::cbLOLDEMO_scene4(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ switch (frm) {
case 11:
case 14:
case 17:
case 20:
- seq_playTalkText(8);
+ playSoundEffect(8, 255 - ((22 - frm) << 3));
break;
case 22:
- seq_playTalkText(11);
+ playSoundAndDisplaySubTitle(11);
break;
case 24:
- seq_playTalkText(8);
+ playSoundAndDisplaySubTitle(8);
break;
case 30:
- seq_playTalkText(15);
+ playSoundAndDisplaySubTitle(15);
break;
case 34:
- seq_playTalkText(14);
+ playSoundAndDisplaySubTitle(14);
break;
case 38:
- seq_playTalkText(13);
+ playSoundAndDisplaySubTitle(13);
break;
case 42:
- seq_playTalkText(12);
+ playSoundAndDisplaySubTitle(12);
break;
default:
break;
}
- _seqFrameCounter++;
+ _callbackCurrentFrame++;
return frm;
}
-int KyraEngine_HoF::seq_lolDemoScene5(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- switch (_seqFrameCounter++) {
+int SeqPlayer_HOF::cbLOLDEMO_scene5(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ switch (_callbackCurrentFrame++) {
case 0:
case 4:
case 6:
@@ -1889,13 +3257,13 @@ int KyraEngine_HoF::seq_lolDemoScene5(WSAMovie_v2 *wsaObj, int x, int y, int frm
case 26:
case 28:
case 30:
- seq_playTalkText(15);
+ playSoundEffect(15, 255 - ((31 - frm) << 3));
break;
case 32:
- seq_playTalkText(16);
+ playSoundAndDisplaySubTitle(16);
break;
case 42:
- seq_playTalkText(6);
+ playSoundAndDisplaySubTitle(6);
break;
default:
break;
@@ -1903,24 +3271,24 @@ int KyraEngine_HoF::seq_lolDemoScene5(WSAMovie_v2 *wsaObj, int x, int y, int frm
return frm;
}
-int KyraEngine_HoF::seq_lolDemoText5(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- if (_seqFrameCounter++ == 100)
- seq_playTalkText(5);
+int SeqPlayer_HOF::cbLOLDEMO_text5(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ if (_callbackCurrentFrame++ == 100)
+ playSoundAndDisplaySubTitle(5);
return frm;
}
-int KyraEngine_HoF::seq_lolDemoScene6(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
- while (_seqScrollTextCounter < 0x122) {
- _seqEndTime = _system->getMillis() + 6 * _tickLength;
- if (!_seqFrameCounter) {
+int SeqPlayer_HOF::cbLOLDEMO_scene6(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
+ while (_scrollProgressCounter < 290) {
+ setCountDown(6);
+ if (!_callbackCurrentFrame) {
_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;
+ _scrollProgressCounter = 0;
}
- if (_seqFrameCounter % 175) {
+ if (_callbackCurrentFrame % 175) {
_screen->setScreenPalette(_screen->getPalette(0));
} else {
Palette &tmpPal = _screen->getPalette(2);
@@ -1928,27 +3296,29 @@ int KyraEngine_HoF::seq_lolDemoScene6(WSAMovie_v2 *wsaObj, int x, int y, int frm
for (int i = 3; i < 0x300; i++) {
tmpPal[i] = ((int)tmpPal[i] * 120) / 64;
- if (tmpPal[i] > 0x3f)
- tmpPal[i] = 0x3f;
+ if (tmpPal[i] > 0x3F)
+ tmpPal[i] = 0x3F;
}
- seq_playTalkText(_rnd.getRandomBit());
+ playSoundAndDisplaySubTitle(_vm->_rnd.getRandomBit());
_screen->setScreenPalette(tmpPal);
_screen->updateScreen();
- delay(8);
+ _vm->delay(8);
}
- if (_seqFrameCounter == 40 || _seqFrameCounter == 80 || _seqFrameCounter == 150 || _seqFrameCounter == 300)
- seq_playTalkText(3);
+ if (_callbackCurrentFrame == 40 || _callbackCurrentFrame == 80 || _callbackCurrentFrame == 150 || _callbackCurrentFrame == 300)
+ playSoundAndDisplaySubTitle(3);
_screen->copyPage(12, 2);
- seq_scrollPage(70, 130);
+ updateDemoAdText(70, 130);
_screen->copyPage(2, 0);
_screen->updateScreen();
- _seqFrameCounter++;
- if (_seqFrameCounter < 128 || _seqFrameCounter > 207)
- _seqScrollTextCounter++;
- delayUntil(_seqEndTime);
+ _callbackCurrentFrame++;
+ if (_callbackCurrentFrame < 128 || _callbackCurrentFrame > 207)
+ _scrollProgressCounter++;
+
+ while (countDownRunning())
+ delayTicks(1);
}
_screen->copyPage(2, 12);
@@ -1956,776 +3326,16 @@ int KyraEngine_HoF::seq_lolDemoScene6(WSAMovie_v2 *wsaObj, int x, int y, int frm
}
#endif // ENABLE_LOL
-uint32 KyraEngine_HoF::seq_activeTextsTimeLeft() {
- uint32 res = 0;
-
- for (int i = 0; i < 10; i++) {
- uint32 chatend = (_activeText[i].duration + _activeText[i].startTime);
- uint32 curtime = _system->getMillis();
- if (_activeText[i].duration != -1 && chatend > curtime) {
- chatend -= curtime;
- if (res < chatend)
- res = chatend;
- }
- }
-
- return res;
-}
-
-void KyraEngine_HoF::seq_processWSAs() {
- for (int i = 0; i < 8; i++) {
- if (_activeWSA[i].flags != -1) {
- if (seq_processNextSubFrame(i))
- seq_resetActiveWSA(i);
- }
- }
-}
-
-void KyraEngine_HoF::seq_processText() {
- int curPage = _screen->setCurPage(2);
- char outputStr[70];
-
- for (int i = 0; i < 10; i++) {
- if (_activeText[i].startTime + _activeText[i].duration > _system->getMillis() && _activeText[i].duration != -1) {
-
- char *srcStr = seq_preprocessString(_sequenceStrings[_activeText[i].strIndex], _activeText[i].width);
- int yPos = _activeText[i].y;
-
- while (*srcStr) {
- uint32 linePos = 0;
- for (; *srcStr; linePos++) {
- if (*srcStr == 0x0d) // Carriage return
- break;
- outputStr[linePos] = *srcStr;
- srcStr++;
- }
- outputStr[linePos] = 0;
- if (*srcStr == 0x0d)
- srcStr++;
-
- uint8 textColor = (_activeText[i].textcolor >= 0) ? _activeText[i].textcolor : _seqTextColor[0];
- _screen->printText(outputStr, _activeText[i].x - (_screen->getTextWidth(outputStr) / 2), yPos, textColor, 0);
- yPos += 10;
- }
- } else {
- _activeText[i].duration = -1;
- }
- }
-
- _screen->setCurPage(curPage);
-}
-
-char *KyraEngine_HoF::seq_preprocessString(const char *srcStr, int width) {
- char *dstStr = _seqProcessedString;
- int lineStart = 0;
- int linePos = 0;
-
- while (*srcStr) {
- while (*srcStr && *srcStr != 0x20) // Space
- dstStr[lineStart + linePos++] = *srcStr++;
- dstStr[lineStart + linePos] = 0;
-
- int len = _screen->getTextWidth(&dstStr[lineStart]);
- if (width >= len && *srcStr) {
- dstStr[lineStart + linePos++] = *srcStr++;
- } else {
- dstStr[lineStart + linePos] = 0x0d; // Carriage return
- lineStart += linePos + 1;
- linePos = 0;
- if (*srcStr)
- srcStr++;
- }
- }
- dstStr[lineStart + linePos] = 0;
-
- return strlen(_seqProcessedString) ? dstStr : 0;
-}
-
-void KyraEngine_HoF::seq_sequenceCommand(int command) {
- for (int i = 0; i < 8; i++)
- seq_resetActiveWSA(i);
-
- switch (command) {
- case 0:
- _screen->fadeToBlack(36);
- _screen->getPalette(0).clear();
- _screen->getPalette(1).clear();
- break;
-
- case 1:
- seq_playTalkText(_rnd.getRandomBit());
-
- _screen->getPalette(0).fill(0, 256, 0x3F);
- _screen->fadePalette(_screen->getPalette(0), 16);
-
- _screen->copyPalette(1, 0);
- break;
-
- case 3:
- _screen->copyPage(2, 0);
- _screen->fadePalette(_screen->getPalette(0), 16);
- _screen->copyPalette(1, 0);
- break;
-
- case 4:
- _screen->copyPage(2, 0);
- _screen->fadePalette(_screen->getPalette(0), 36);
- _screen->copyPalette(1, 0);
- break;
-
- case 5:
- _screen->copyPage(2, 0);
- break;
-
- case 6:
- // UNUSED
- // seq_loadBLD("library.bld");
- break;
-
- case 7:
- // UNUSED
- // seq_loadBLD("marco.bld");
- break;
-
- case 8:
- _screen->fadeToBlack(16);
- _screen->getPalette(0).clear();
- _screen->getPalette(1).clear();
-
- delay(120 * _tickLength);
- break;
-
- case 9: {
- Palette &pal = _screen->getPalette(0);
- for (int i = 0; i < 256; i++) {
- int pv = (pal[3 * i] + pal[3 * i + 1] + pal[3 * i + 2]) / 3;
- pal[3 * i] = pal[3 * i + 1] = pal[3 * i + 2] = pv & 0xff;
- }
-
- //int a = 0x100;
- //int d = (0x800 << 5) - 0x100;
- //pal[3 * i] = pal[3 * i + 1] = pal[3 * i + 2] = 0x3f;
-
- _screen->fadePalette(pal, 64);
- _screen->copyPalette(1, 0);
- } break;
-
- default:
- break;
- }
-}
-
-void KyraEngine_HoF::seq_cmpFadeFrame(const char *cmpFile) {
- _screen->copyPage(10, 2);
- _screen->copyPage(4, 10);
- _screen->clearPage(6);
- _screen->loadBitmap(cmpFile, 6, 6, 0);
- _screen->copyPage(12, 4);
-
- for (int i = 0; i < 3; i++) {
- uint32 endtime = _system->getMillis() + 4 * _tickLength;
- _screen->cmpFadeFrameStep(4, 320, 200, 0, 0, 2, 320, 200, 0, 0, 320, 200, 6);
- _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0);
- _screen->updateScreen();
- delayUntil(endtime);
- }
-
- _screen->copyPage(4, 0);
- _screen->updateScreen();
- _screen->copyPage(4, 2);
- _screen->copyPage(4, 6);
- _screen->copyPage(10, 4);
-}
-
-void KyraEngine_HoF::seq_playTalkText(uint8 chatNum) {
- assert(chatNum < _sequenceSoundListSize);
-
- if (chatNum < 12 && !_flags.isDemo && textEnabled())
- seq_setTextEntry(chatNum, 160, 168, _sequenceStringsDuration[chatNum], 160);
-
- _sound->voicePlay(_sequenceSoundList[chatNum], &_speechHandle);
-}
-
-void KyraEngine_HoF::seq_waitForTextsTimeout() {
- uint32 longest = seq_activeTextsTimeLeft() + _system->getMillis();
- uint32 now = _system->getMillis();
-
- if (textEnabled()) {
- if (longest > now)
- delay(longest - now);
- } else if (speechEnabled()) {
- while (snd_voiceIsPlaying())
- delay(_tickLength);
- }
-
- seq_resetAllTextEntries();
-}
-
-void KyraEngine_HoF::seq_resetAllTextEntries() {
- for (int i = 0; i < 10; i++)
- _activeText[i].duration = -1;
-}
-
-int KyraEngine_HoF::seq_setTextEntry(uint16 strIndex, uint16 posX, uint16 posY, int duration, uint16 width) {
- for (int i = 0; i < 10; i++) {
- if (_activeText[i].duration != -1) {
- if (i < 9)
- continue;
- else
- return -1;
- }
-
- _activeText[i].strIndex = strIndex;
- _activeText[i].x = posX;
- _activeText[i].y = posY;
- _activeText[i].duration = duration * _tickLength;
- _activeText[i].width = width;
- _activeText[i].startTime = _system->getMillis();
- _activeText[i].textcolor = -1;
-
- return i;
- }
- return -1;
-}
-
-void KyraEngine_HoF::seq_loadNestedSequence(int wsaNum, int seqNum) {
- if (_activeWSA[wsaNum].flags != -1)
- return;
-
- NestedSequence s = _sequences->seqn[seqNum];
-
- if (!_activeWSA[wsaNum].movie) {
- _activeWSA[wsaNum].movie = new WSAMovie_v2(this);
- assert(_activeWSA[wsaNum].movie);
- }
-
- _activeWSA[wsaNum].movie->close();
-
- _activeWSA[wsaNum].movie->open(s.wsaFile, 0, 0);
-
- if (!_activeWSA[wsaNum].movie->opened()) {
- delete _activeWSA[wsaNum].movie;
- _activeWSA[wsaNum].movie = 0;
- return;
- }
-
- _activeWSA[wsaNum].endFrame = s.endFrame;
- _activeWSA[wsaNum].startFrame = _activeWSA[wsaNum].currentFrame = s.startframe;
- _activeWSA[wsaNum].frameDelay = s.frameDelay;
- _activeWSA[wsaNum].callback = _callbackN[seqNum];
- _activeWSA[wsaNum].control = s.wsaControl;
-
- _activeWSA[wsaNum].flags = s.flags | 1;
- _activeWSA[wsaNum].x = s.x;
- _activeWSA[wsaNum].y = s.y;
- _activeWSA[wsaNum].startupCommand = s.startupCommand;
- _activeWSA[wsaNum].finalCommand = s.finalCommand;
- _activeWSA[wsaNum].lastFrame = 0xffff;
-
- seq_nestedSequenceFrame(s.startupCommand, wsaNum);
-
- if (!s.startupCommand)
- seq_processNextSubFrame(wsaNum);
-
- _activeWSA[wsaNum].nextFrame = _system->getMillis();
-}
-
-void KyraEngine_HoF::seq_nestedSequenceFrame(int command, int wsaNum) {
- int xa = 0, ya = 0;
- command--;
- if (!_activeWSA[wsaNum].movie || skipFlag() || shouldQuit() || _abortIntroFlag)
- return;
-
- switch (command) {
- case 0:
- xa = -_activeWSA[wsaNum].movie->xAdd();
- ya = -_activeWSA[wsaNum].movie->yAdd();
- _activeWSA[wsaNum].movie->displayFrame(0, 8, xa, ya, 0, 0, 0);
- seq_animatedSubFrame(8, 2, 7, 8, _activeWSA[wsaNum].movie->xAdd(), _activeWSA[wsaNum].movie->yAdd(),
- _activeWSA[wsaNum].movie->width(), _activeWSA[wsaNum].movie->height(), 1, 2);
- break;
-
- case 1:
- xa = -_activeWSA[wsaNum].movie->xAdd();
- ya = -_activeWSA[wsaNum].movie->yAdd();
- _activeWSA[wsaNum].movie->displayFrame(0, 8, xa, ya, 0, 0, 0);
- seq_animatedSubFrame(8, 2, 7, 8, _activeWSA[wsaNum].movie->xAdd(), _activeWSA[wsaNum].movie->yAdd(),
- _activeWSA[wsaNum].movie->width(), _activeWSA[wsaNum].movie->height(), 1, 1);
- break;
-
- case 2:
- seq_waitForTextsTimeout();
- xa = -_activeWSA[wsaNum].movie->xAdd();
- ya = -_activeWSA[wsaNum].movie->yAdd();
- _activeWSA[wsaNum].movie->displayFrame(0x15, 8, xa, ya, 0, 0, 0);
- seq_animatedSubFrame(8, 2, 7, 8, _activeWSA[wsaNum].movie->xAdd(), _activeWSA[wsaNum].movie->yAdd(),
- _activeWSA[wsaNum].movie->width(), _activeWSA[wsaNum].movie->height(), 0, 2);
- break;
-
- case 3:
- _screen->copyPage(2, 10);
- _activeWSA[wsaNum].movie->displayFrame(0, 2, 0, 0, 0, 0, 0);
- _screen->copyPage(2, 12);
- seq_cmpFadeFrame("scene2.cmp");
- break;
-
- case 4:
- _screen->copyPage(2, 10);
- _activeWSA[wsaNum].movie->displayFrame(0, 2, 0, 0, 0, 0, 0);
- _screen->copyPage(2, 12);
- seq_cmpFadeFrame("scene3.cmp");
- break;
-
- default:
- break;
- }
-}
-
-void KyraEngine_HoF::seq_animatedSubFrame(int srcPage, int dstPage, int delaytime, int steps,
- int x, int y, int w, int h, int openClose, int directionFlags) {
- if (openClose) {
- for (int i = 1; i < steps; i++) {
- uint32 endtime = _system->getMillis() + delaytime * _tickLength;
-
- int w2 = (((w * 256) / steps) * i) / 256;
- int h2 = (((h * 256) / steps) * i) / 256;
-
- int ym = (directionFlags & 2) ? (h - h2) : 0;
- int xm = (directionFlags & 1) ? (w - w2) : 0;
-
- _screen->wsaFrameAnimationStep(0, 0, x + xm, y + ym, w, h, w2, h2, srcPage, dstPage, 0);
-
- _screen->copyPage(dstPage, 6);
- _screen->copyPage(dstPage, 0);
- _screen->updateScreen();
-
- _screen->copyPage(12, dstPage);
- delayUntil(endtime);
- }
-
- _screen->wsaFrameAnimationStep(0, 0, x, y, w, h, w, h, srcPage, dstPage, 0);
- _screen->copyPage(dstPage, 6);
- _screen->copyPage(dstPage, 0);
- _screen->updateScreen();
- } else {
- _screen->copyPage(12, dstPage);
- for (int i = steps; i; i--) {
- uint32 endtime = _system->getMillis() + delaytime * _tickLength;
-
- int w2 = (((w * 256) / steps) * i) / 256;
- int h2 = (((h * 256) / steps) * i) / 256;
+#undef CASE_ALT
- int ym = (directionFlags & 2) ? (h - h2) : 0;
- int xm = (directionFlags & 1) ? (w - w2) : 0;
-
- _screen->wsaFrameAnimationStep(0, 0, x + xm, y + ym, w, h, w2, h2, srcPage, dstPage, 0);
-
- _screen->copyPage(dstPage, 6);
- _screen->copyPage(dstPage, 0);
- _screen->updateScreen();
-
- _screen->copyPage(12, dstPage);
- delayUntil(endtime);
- }
- }
-}
-
-void KyraEngine_HoF::seq_resetActiveWSA(int wsaNum) {
- if (_activeWSA[wsaNum].flags == -1)
- return;
-
- _activeWSA[wsaNum].flags = -1;
- seq_nestedSequenceFrame(_activeWSA[wsaNum].finalCommand, wsaNum);
- _activeWSA[wsaNum].movie->close();
-}
-
-void KyraEngine_HoF::seq_unloadWSA(int wsaNum) {
- if (_activeWSA[wsaNum].movie) {
- _activeWSA[wsaNum].movie->close();
- delete _activeWSA[wsaNum].movie;
- _activeWSA[wsaNum].movie = 0;
- }
-}
-
-bool KyraEngine_HoF::seq_processNextSubFrame(int wsaNum) {
- uint32 currentFrame = _activeWSA[wsaNum].currentFrame;
- uint32 currentTime = _system->getMillis();
-
- if (_activeWSA[wsaNum].callback && currentFrame != _activeWSA[wsaNum].lastFrame) {
- _activeWSA[wsaNum].lastFrame = currentFrame;
- currentFrame = (this->*_activeWSA[wsaNum].callback)(_activeWSA[wsaNum].movie, _activeWSA[wsaNum].x, _activeWSA[wsaNum].y, currentFrame);
- }
-
- if (_activeWSA[wsaNum].movie) {
- if (_activeWSA[wsaNum].flags & 0x20) {
- _activeWSA[wsaNum].movie->displayFrame(_activeWSA[wsaNum].control[currentFrame].index, 2, _activeWSA[wsaNum].x, _activeWSA[wsaNum].y, 0x4000, 0, 0);
- _activeWSA[wsaNum].frameDelay = _activeWSA[wsaNum].control[currentFrame].delay;
- } else {
- _activeWSA[wsaNum].movie->displayFrame(currentFrame % _activeWSA[wsaNum].movie->frames(), 2, _activeWSA[wsaNum].x, _activeWSA[wsaNum].y, 0x4000, 0, 0);
- }
- }
-
- if (_activeWSA[wsaNum].flags & 0x10) {
- currentFrame = (currentTime - _activeWSA[wsaNum].nextFrame) / (_activeWSA[wsaNum].frameDelay * _tickLength);
- } else {
- if (((int32)(currentTime - _activeWSA[wsaNum].nextFrame) / (int32)(_activeWSA[wsaNum].frameDelay * _tickLength)) > 0) {
- currentFrame++;
- _activeWSA[wsaNum].nextFrame = currentTime;
- }
- }
-
- bool res = false;
-
- if (currentFrame >= _activeWSA[wsaNum].endFrame) {
- int sw = ((_activeWSA[wsaNum].flags & 0x1e) - 2);
- switch (sw) {
- case 0:
- res = true;
- currentFrame = _activeWSA[wsaNum].endFrame;
- _screen->copyPage(2, 12);
- break;
-
- case 6:
- case 8:
- currentFrame = _activeWSA[wsaNum].endFrame - 1;
- break;
-
- case 2:
- case 10:
- currentFrame = _activeWSA[wsaNum].startFrame;
- break;
-
- default:
- currentFrame = _activeWSA[wsaNum].endFrame - 1;
- res = true;
- }
- }
-
- _activeWSA[wsaNum].currentFrame = currentFrame & 0xffff;
- return res;
-}
-
-void KyraEngine_HoF::seq_printCreditsString(uint16 strIndex, int x, int y, const uint8 *colorMap, uint8 textcolor) {
- uint8 colormap[16];
- if (skipFlag() || shouldQuit() || _abortIntroFlag || _menuChoice)
- return;
-
- Screen::FontId of = _screen->setFont(Screen::FID_8_FNT);
-
- memset(&_screen->getPalette(0)[0x2fa], 0x3f, 6);
- _screen->getPalette(0)[0x2f6] = 0x3f;
- _screen->getPalette(0)[0x2f5] = 0x20;
- _screen->getPalette(0)[0x2f4] = 0x30;
- colormap[0] = colorMap[0];
- colormap[1] = 0xfd;
- memcpy(&colormap[2], &colorMap[2], 14);
- uint8 seqTextColor0 = _seqTextColor[0];
-
- _seqTextColor[0] = 0xfd;
- _screen->setTextColorMap(colormap);
- seq_resetAllTextEntries();
- seq_setTextEntry(strIndex, x, y, 0x80, 0x78);
- seq_processText();
- _screen->copyPage(2, 0);
- _screen->updateScreen();
- _screen->getPalette(0)[0x2f7] = _screen->getPalette(0)[textcolor * 3];
- _screen->getPalette(0)[0x2f8] = _screen->getPalette(0)[textcolor * 3 + 1];
- _screen->getPalette(0)[0x2f9] = _screen->getPalette(0)[textcolor * 3 + 2];
- _screen->fadePalette(_screen->getPalette(0), 0x18);
-
- _seqTextColor[0] = textcolor;
- _screen->setTextColorMap(colorMap);
- seq_resetAllTextEntries();
- seq_setTextEntry(strIndex, x, y, 0x80, 0x78);
- seq_processText();
- _screen->copyPage(2, 0);
- _screen->updateScreen();
- _screen->getPalette(0)[0x2f7] = _screen->getPalette(0)[0x2f8] = _screen->getPalette(0)[0x2f9] = 0;
- _screen->fadePalette(_screen->getPalette(0), 1);
- _screen->copyPage(2, 12);
- seq_resetAllTextEntries();
-
- _seqTextColor[0] = seqTextColor0;
-
- _screen->setFont(of);
-}
-
-void KyraEngine_HoF::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) {
- int dur = int(strlen(_sequenceStrings[strIndex])) * (_flags.isTalkie ? 7 : 15);
- if (textEnabled()) {
- int entry = seq_setTextEntry(strIndex, x, y, dur, width);
- _activeText[entry].textcolor = textColor;
- }
- _seqWsaChatTimeout = _system->getMillis() + dur * _tickLength;
- int curframe = firstframe;
-
- if (vocIndex && speechEnabled()) {
- while (_sound->voiceIsPlaying() && !skipFlag())
- delay(4);
- seq_playTalkText(vocIndex);
- }
-
- while (_system->getMillis() < _seqWsaChatTimeout && !(_abortIntroFlag || skipFlag())) {
- if (lastframe < 0) {
- int t = ABS(lastframe);
- if (t < curframe)
- curframe = t;
- }
-
- if (ABS(lastframe) < curframe)
- curframe = firstframe;
-
- _seqWsaChatFrameTimeout = _seqEndTime = _system->getMillis() + _seqFrameDelay * _tickLength;
- if (wsa)
- wsa->displayFrame(curframe % wsa->frames(), 2, wsaXpos, wsaYpos, 0, 0, 0);
-
- _screen->copyPage(2, 12);
-
- seq_processText();
-
- uint32 tm = _system->getMillis();
- if (_seqWsaChatFrameTimeout > tm && _seqWsaChatTimeout > tm)
- delay(MIN(_seqWsaChatFrameTimeout - tm, _seqWsaChatTimeout - tm));
-
- if (speechEnabled() && !textEnabled() && !snd_voiceIsPlaying())
- break;
-
- _screen->copyPage(2, 0);
- _screen->updateScreen();
- curframe++;
- }
-
- if (_abortIntroFlag || skipFlag())
- _sound->voiceStop();
-
- if (ABS(lastframe) < curframe)
- curframe = ABS(lastframe);
-
- if (curframe == firstframe)
- curframe++;
-
- _seqWsaCurrentFrame = curframe;
-}
-
-void KyraEngine_HoF::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 };
-
- _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);
-
- struct ScrollTextData {
- int16 x;
- int16 y;
- uint8 *text;
- byte unk1;
- byte height;
- byte adjust;
-
- ScrollTextData() {
- x = 0; // 0 11
- y = 0; // 2 13
- text = 0; // 4 15
- unk1 = 0; // 8 19
- height = 0; // 9 20
- adjust = 0; // 10 21
- }
- };
-
- ScrollTextData *textData = new ScrollTextData[36];
- uint8 *ptr = data;
-
- bool loop = true;
- int cnt = 0;
-
- while (loop) {
- _seqSubFrameEndTimeInternal = _system->getMillis() + speed * _tickLength;
-
- while (cnt < 35 && *ptr) {
- uint16 cH;
-
- if (cnt)
- cH = textData[cnt].y + textData[cnt].height + (textData[cnt].height >> 3);
- else
- cH = d->h;
-
- char *str = (char *)ptr;
-
- ptr = (uint8 *)strpbrk(str, mark);
- if (!ptr)
- ptr = (uint8 *)strchr(str, 0);
-
- textData[cnt + 1].unk1 = *ptr;
- *ptr = 0;
- if (textData[cnt + 1].unk1)
- ptr++;
-
- if (*str == 3 || *str == 4)
- textData[cnt + 1].adjust = *str++;
- else
- textData[cnt + 1].adjust = 0;
-
- _screen->setFont(fid1);
-
- if (*str == 1) {
- _screen->setFont(fid2);
- str++;
- } else if (*str == 2) {
- str++;
- }
-
- textData[cnt + 1].height = _screen->getFontHeight();
-
- switch (textData[cnt + 1].adjust) {
- case 3:
- textData[cnt + 1].x = 157 - _screen->getTextWidth(str);
- break;
- case 4:
- textData[cnt + 1].x = 161;
- break;
- default:
- textData[cnt + 1].x = (((d->w << 3) - _screen->getTextWidth(str)) >> 1) + 1;
- }
-
- if (textData[cnt].unk1 == 5)
- cH -= (textData[cnt].height + (textData[cnt].height >> 3));
-
- textData[cnt + 1].y = cH;
- textData[cnt + 1].text = (uint8 *)str;
- 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) {
- const char *str = (const char *)textData[cnt2 + 1].text;
- const char *str2 = str;
- int16 cW = textData[cnt2 + 1].x - 10;
- int16 cH = textData[cnt2 + 1].y;
- 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 (textData[cnt2 + 1].height != _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((uint8)*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((uint8)*str2++);
- }
- palCycle = true;
- } else {
- _screen->printText(str, x, y, col1, 0);
- }
- } else {
- _screen->printText(str, x, y, col1, 0);
- }
- _screen->setCurPage(0);
- }
-
- textData[cnt2 + 1].y -= step;
- cnt2++;
- }
-
- _screen->copyRegion(d->sx << 3, d->sy, d->sx << 3, d->sy, d->w << 3, d->h, tempPage2, 0);
- _screen->updateScreen();
-
- if (textData[1].y < -10) {
- textData[1].text += strlen((char *)textData[1].text);
- textData[1].text[0] = textData[1].unk1;
- cnt--;
- memcpy(&textData[1], &textData[2], cnt * sizeof(ScrollTextData));
- }
-
- if (palCycle) {
- for (int col = 133; col > 112; col--)
- _screen->getPalette(0).copy(_screen->getPalette(0), col - 1, 1, col);
- _screen->getPalette(0).copy(_screen->getPalette(0), 133, 1, 112);
- _screen->setScreenPalette(_screen->getPalette(0));
- }
-
- delayUntil(_seqSubFrameEndTimeInternal);
-
- if ((cnt < 36) && ((d->sy + d->h) > (textData[cnt].y + textData[cnt].height)) && !skipFlag()) {
- resetSkipFlag();
- delay(_tickLength * 500);
- cnt = 0;
- }
-
- if (!cnt || skipFlag())
- loop = false;
- }
-
- _sound->beginFadeOut();
- _screen->fadeToBlack();
-
- _abortIntroFlag= false;
- resetSkipFlag();
-
- delete[] textData;
-}
-
-void KyraEngine_HoF::seq_scrollPage(int bottom, int top) {
- int dstY, dstH, srcH;
-
- static const ScreenDim d = { 0x00, 0x00, 0x28, 0x320, 0xFF, 0xFE, 0x00, 0x00 };
-
- if (_seqScrollTextCounter - (top - 1) < 0) {
- dstY = top - _seqScrollTextCounter;
- dstH = _seqScrollTextCounter;
- srcH = 0;
- } else {
- dstY = 0;
- srcH = _seqScrollTextCounter - top;
- dstH = (400 - srcH <= top) ? 400 - srcH : top;
- }
-
- if (dstH > 0) {
- if (_demoAnimData) {
- for (int i = 0; i < 4; i++) {
- const ItemAnimData_v1 *def = &_demoAnimData[i];
- ActiveItemAnim *a = &_activeItemAnim[i];
-
- _screen->fillRect(12, def->y - 8, 28, def->y + 8, 0, 4);
- _screen->drawShape(4, getShapePtr(def->itemIndex + def->frames[a->currentFrame]), 12, def->y - 8, 0, 0);
- if (_seqFrameCounter % 2 == 0)
- a->currentFrame = (a->currentFrame + 1) % 20;
- }
- }
- _screen->copyRegionEx(4, 0, srcH, 2, 2, dstY + bottom, 320, dstH, &d);
- }
-}
+const uint8 SeqPlayer_HOF::_textColorPresets[] = { 0x01, 0x01, 0x00, 0x3F, 0x3F, 0x3F };
void KyraEngine_HoF::seq_showStarcraftLogo() {
WSAMovie_v2 *ci = new WSAMovie_v2(this);
assert(ci);
_screen->clearPage(2);
_res->loadPakFile("INTROGEN.PAK");
- int endframe = ci->open("ci.wsa", 0, &_screen->getPalette(0));
+ int endframe = ci->open("CI.WSA", 0, &_screen->getPalette(0));
_res->unloadPakFile("INTROGEN.PAK");
if (!ci->opened()) {
delete ci;
@@ -2736,20 +3346,28 @@ void KyraEngine_HoF::seq_showStarcraftLogo() {
_screen->copyPage(2, 0);
_screen->fadeFromBlack();
for (int i = 1; i < endframe; i++) {
- _seqEndTime = _system->getMillis() + 50;
+ uint32 end = _system->getMillis() + 50;
if (skipFlag())
break;
ci->displayFrame(i, 2, 0, 0, 0, 0, 0);
_screen->copyPage(2, 0);
_screen->updateScreen();
- delay(_seqEndTime - _system->getMillis());
+ uint32 cur = _system->getMillis();
+ if (end > cur)
+ delay(end - cur);
+ else
+ updateInput();
}
if (!skipFlag()) {
- _seqEndTime = _system->getMillis() + 50;
+ uint32 end = _system->getMillis() + 50;
ci->displayFrame(0, 2, 0, 0, 0, 0, 0);
_screen->copyPage(2, 0);
_screen->updateScreen();
- delay(_seqEndTime - _system->getMillis());
+ uint32 cur = _system->getMillis();
+ if (end > cur)
+ delay(end - cur);
+ else
+ updateInput();
}
_screen->fadeToBlack();
_screen->showMouse();
@@ -2758,67 +3376,38 @@ void KyraEngine_HoF::seq_showStarcraftLogo() {
delete ci;
}
-void KyraEngine_HoF::seq_init() {
- _seqProcessedString = new char[200];
- _seqWsa = new WSAMovie_v2(this);
- _activeWSA = new ActiveWSA[8];
- _activeText = new ActiveText[10];
-
- _res->unloadAllPakFiles();
- _res->loadPakFile(StaticResource::staticDataFilename());
- _res->loadFileList(_sequencePakList, _sequencePakListSize);
-
- if (_flags.platform == Common::kPlatformPC98)
- _sound->loadSoundFile("SOUND.DAT");
-
- _screen->setFont(_flags.lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_GOLDFONT_FNT);
-
- if (_flags.gameID == GI_LOL)
- return;
-
- if (_flags.isDemo && !_flags.isTalkie) {
- _demoAnimData = _staticres->loadShapeAnimData_v1(k2SeqplayShapeAnimData, _itemAnimDefinitionSize);
- uint8 *shp = _res->fileData("icons.shp", 0);
- uint32 outsize = READ_LE_UINT16(shp + 4);
- _animShapeFiledata = new uint8[outsize];
- Screen::decodeFrame4(shp + 10, _animShapeFiledata, outsize);
- delete[] shp;
-
- for (int i = 0; i < 20; i++)
- addShapeToPool(_screen->getPtrToShape(_animShapeFiledata, i), i);
- } else {
- const MainMenu::StaticData data = {
- { _sequenceStrings[97], _sequenceStrings[96], _sequenceStrings[95], _sequenceStrings[98], 0 },
- { 0x01, 0x04, 0x0C, 0x04, 0x00, 0xd7, 0xd6 },
- { 0xd8, 0xda, 0xd9, 0xd8 },
- (_flags.lang == Common::JA_JPN) ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT, 240
- };
-
- _menu = new MainMenu(this);
- _menu->init(data, MainMenu::Animation());
- }
+int KyraEngine_HoF::seq_playIntro() {
+ bool startupSaveLoadable = saveFileLoadable(0);
+ return SeqPlayer_HOF(this, _screen, _system, startupSaveLoadable).play(kSequenceVirgin, startupSaveLoadable? kSequenceTitle : kSequenceNoLooping);
}
-void KyraEngine_HoF::seq_uninit() {
- delete[] _seqProcessedString;
- _seqProcessedString = NULL;
-
- delete[] _activeWSA;
- _activeWSA = NULL;
+int KyraEngine_HoF::seq_playOutro() {
+ return SeqPlayer_HOF(this, _screen, _system).play(kSequenceFunters, kSequenceFrash);
+}
- delete[] _activeText;
- _activeText = NULL;
+int KyraEngine_HoF::seq_playDemo() {
+ SeqPlayer_HOF(this, _screen, _system).play(kSequenceHoFDemoVirgin, kSequenceHoFDemoVirgin);
+ return 4;
+}
- delete _seqWsa;
- _seqWsa = NULL;
+void KyraEngine_HoF::seq_pausePlayer(bool toggle) {
+ SeqPlayer_HOF *activePlayer = SeqPlayer_HOF::instance();
+ if (activePlayer)
+ activePlayer->pause(toggle);
+}
- delete[] _animShapeFiledata;
- _animShapeFiledata = 0;
+#ifdef ENABLE_LOL
+int LoLEngine::playDemo() {
+ SeqPlayer_HOF(this, _screen, _system).play(kSequenceLoLDemoScene1, kSequenceLoLDemoScene1);
+ return -1;
+}
- delete _menu;
- _menu = 0;
- _screen->setFont(_flags.lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT);
+void LoLEngine::pauseDemoPlayer(bool toggle) {
+ SeqPlayer_HOF *activePlayer = SeqPlayer_HOF::instance();
+ if (activePlayer)
+ activePlayer->pause(toggle);
}
+#endif // ENABLE_LOL
#pragma mark -
#pragma mark - Ingame sequences
diff --git a/engines/kyra/sequences_hof.h b/engines/kyra/sequences_hof.h
new file mode 100644
index 0000000000..2558a68a6a
--- /dev/null
+++ b/engines/kyra/sequences_hof.h
@@ -0,0 +1,74 @@
+/* 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.
+ *
+ */
+
+#ifndef KYRA_SEQUENCES_HOF_H
+#define KYRA_SEQUENCES_HOF_H
+
+#include "kyra/kyra_v2.h"
+
+namespace Kyra {
+
+struct HoFSequence {
+ const char *wsaFile;
+ const char *cpsFile;
+ uint16 flags;
+ uint8 fadeInTransitionType;
+ uint8 fadeOutTransitionType;
+ int16 stringIndex1;
+ int16 stringIndex2;
+ uint16 startFrame;
+ uint16 numFrames;
+ uint16 duration;
+ uint16 xPos;
+ uint16 yPos;
+ uint16 timeout;
+};
+
+struct HoFNestedSequence {
+ const char *wsaFile;
+ const FrameControl *wsaControl;
+ uint16 flags;
+ uint16 startframe;
+ uint16 endFrame;
+ uint16 frameDelay;
+ uint16 x;
+ uint16 y;
+ uint16 fadeInTransitionType;
+ uint16 fadeOutTransitionType;
+};
+
+struct HoFSeqData {
+ const HoFSequence *seq;
+ int numSeq;
+ const HoFNestedSequence *nestedSeq;
+ int numNestedSeq;
+};
+
+struct HoFSeqItemAnimData {
+ int16 itemIndex;
+ uint16 y;
+ const uint16 *frames;
+};
+
+} // End of namespace Kyra
+
+#endif
diff --git a/engines/kyra/sequences_lok.cpp b/engines/kyra/sequences_lok.cpp
index e63d0a7d8f..994bd2ba9b 100644
--- a/engines/kyra/sequences_lok.cpp
+++ b/engines/kyra/sequences_lok.cpp
@@ -1207,7 +1207,7 @@ struct CreditsLine {
void KyraEngine_LoK::seq_playCredits() {
static const uint8 colorMap[] = { 0, 0, 0xC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- static const char stringTerms[] = { 0x5, 0xd, 0x0};
+ static const char stringTerms[] = { 0x5, 0xD, 0x0};
typedef Common::List<CreditsLine> CreditsLineList;
CreditsLineList lines;
diff --git a/engines/kyra/sequences_lol.cpp b/engines/kyra/sequences_lol.cpp
index a06f2077ba..c8f97eb770 100644
--- a/engines/kyra/sequences_lol.cpp
+++ b/engines/kyra/sequences_lol.cpp
@@ -36,10 +36,16 @@ 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.
+ _res->loadPakFile("GENERAL.PAK");
+ 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);
@@ -66,7 +72,7 @@ int LoLEngine::processPrologue() {
// Original version: (260|193) "V CD1.02 D"
const int width = _screen->getTextWidth(versionString.c_str());
_screen->fprintString("%s", 320 - width, 193, 0x67, 0x00, 0x04, versionString.c_str());
- _screen->setFont(_flags.lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_9_FNT);
+ _screen->setFont((_flags.lang == Common::JA_JPN && _flags.use16ColorMode) ? Screen::FID_SJIS_FNT : Screen::FID_9_FNT);
_screen->fadePalette(_screen->getPalette(0), 0x1E);
_screen->updateScreen();
@@ -139,7 +145,12 @@ void LoLEngine::setupPrologueData(bool load) {
static const char *const fileListFloppy[] = {
"INTRO.PAK", "INTROVOC.PAK", 0
};
- const char *const *fileList = _flags.isTalkie ? fileListCD : fileListFloppy;
+
+ static const char *const fileListTowns[] = {
+ "INTRO.PAK", "TINTROVO.PAK", 0
+ };
+
+ const char *const *fileList = _flags.isTalkie ? fileListCD : (_flags.platform == Common::kPlatformFMTowns ? fileListTowns : fileListFloppy);
char filename[32];
for (uint i = 0; fileList[i]; ++i) {
@@ -176,7 +187,7 @@ void LoLEngine::setupPrologueData(bool load) {
memset(_selectionAnimTimers, 0, sizeof(_selectionAnimTimers));
_screen->getPalette(1).clear();
- _sound->setSoundList(&_soundData[kMusicIntro]);
+ _sound->selectAudioResourceSet(kMusicIntro);
// We have three sound.dat files, one for the intro, one for the
// end sequence and one for ingame, each contained in a different
@@ -197,7 +208,7 @@ void LoLEngine::setupPrologueData(bool load) {
return;
_eventList.clear();
- _sound->setSoundList(0);
+ _sound->selectAudioResourceSet(kMusicIntro);
}
}
@@ -219,7 +230,7 @@ void LoLEngine::showIntro() {
_screen->loadFont(Screen::FID_8_FNT, "NEW8P.FNT");
_screen->loadFont(Screen::FID_INTRO_FNT, "INTRO.FNT");
- _screen->setFont(_flags.lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT);
+ _screen->setFont((_flags.lang == Common::JA_JPN && _flags.use16ColorMode) ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT);
_tim->resetFinishedFlag();
_tim->setLangData("LOLINTRO.DIP");
@@ -289,10 +300,10 @@ int LoLEngine::chooseCharacter() {
_chargenWSA->displayFrame(0, 2, 113, 0, 0, 0, 0);
- _screen->setFont(_flags.lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_9_FNT);
+ _screen->setFont((_flags.lang == Common::JA_JPN && _flags.use16ColorMode) ? Screen::FID_SJIS_FNT : Screen::FID_9_FNT);
_screen->_curPage = 2;
- if (_flags.platform == Common::kPlatformPC98) {
+ if (_flags.platform == Common::kPlatformPC98 && _flags.use16ColorMode) {
_screen->fillRect(17, 29, 94, 97, 17);
_screen->fillRect(68, 167, 310, 199, 17);
_screen->drawClippedLine(68, 166, 311, 166, 238);
@@ -304,7 +315,7 @@ int LoLEngine::chooseCharacter() {
_screen->_curPage = 2;
for (int i = 0; i < 4; ++i) {
- _screen->printText((const char *)_charNamesPC98[i], _charPosXPC98[i], 168, 0xC1, 0x00);
+ _screen->printText(_charNamesJapanese[i], _charPosXPC98[i], 168, 0xC1, 0x00);
Screen::FontId old = _screen->setFont(Screen::FID_SJIS_FNT);
for (int j = 0; j < 3; ++j) {
@@ -318,7 +329,7 @@ int LoLEngine::chooseCharacter() {
_screen->printText(_tim->getCTableEntry(53), 72, 184, 0x81, 0x00);
_screen->printText(_tim->getCTableEntry(55), 72, 192, 0x81, 0x00);
} else {
- const char *const *previewNames = (_flags.lang == Common::RU_RUS && !_flags.isTalkie) ? _charPreviewNamesRussianFloppy : _charPreviewNamesDefault;
+ const char *const *previewNames = (_flags.lang == Common::RU_RUS && !_flags.isTalkie) ? _charPreviewNamesRussianFloppy : (_flags.lang == Common::JA_JPN ? _charNamesJapanese : _charPreviewNamesDefault);
for (int i = 0; i < 4; ++i) {
_screen->fprintStringIntro("%s", _charPreviews[i].x + 16, _charPreviews[i].y + 36, 0xC0, 0x00, 0x9C, 0x120, previewNames[i]);
_screen->fprintStringIntro("%d", _charPreviews[i].x + 21, _charPreviews[i].y + 48, 0x98, 0x00, 0x9C, 0x220, _charPreviews[i].attrib[0]);
@@ -710,7 +721,7 @@ void LoLEngine::showStarcraftLogo() {
_screen->fadeFromBlack();
int inputFlag = 0;
for (int i = 0; i < endframe; i++) {
- inputFlag = checkInput(0) & 0xff;
+ inputFlag = checkInput(0) & 0xFF;
if (shouldQuit() || inputFlag)
break;
ci->displayFrame(i, 2, 32, 80, 0, 0, 0);
@@ -722,7 +733,7 @@ void LoLEngine::showStarcraftLogo() {
if (!(shouldQuit() || inputFlag)) {
_sound->voicePlay("star2", &_speechHandle);
while (_sound->voiceIsPlaying(&_speechHandle) && !(shouldQuit() || inputFlag)) {
- inputFlag = checkInput(0) & 0xff;
+ inputFlag = checkInput(0) & 0xFF;
delay(_tickLength);
}
}
@@ -1009,7 +1020,11 @@ void LoLEngine::setupEpilogueData(bool load) {
"GENERAL.PAK", "INTRO.PAK", "FINALE1.PAK", "FINALE2.PAK", 0
};
- const char *const *fileList = _flags.isTalkie ? fileListCD : fileListFloppy;
+ static const char *const fileListTowns[] = {
+ "GENERAL.PAK", "INTRO.PAK", "FINALE1.PAK", "TFINALE2.PAK", 0
+ };
+
+ const char *const *fileList = _flags.isTalkie ? fileListCD : (_flags.platform == Common::kPlatformFMTowns ? fileListTowns : fileListFloppy);
assert(fileList);
char filename[32];
@@ -1035,7 +1050,7 @@ void LoLEngine::setupEpilogueData(bool load) {
_screen->clearPage(3);
if (load) {
- _sound->setSoundList(&_soundData[kMusicFinale]);
+ _sound->selectAudioResourceSet(kMusicFinale);
// We have three sound.dat files, one for the intro, one for the
// end sequence and one for ingame, each contained in a different
@@ -1051,7 +1066,7 @@ void LoLEngine::setupEpilogueData(bool load) {
return;
_eventList.clear();
- _sound->setSoundList(0);
+ _sound->selectAudioResourceSet(kMusicIntro);
}
}
diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp
index 73c20ee6df..32d175bdb0 100644
--- a/engines/kyra/sound.cpp
+++ b/engines/kyra/sound.cpp
@@ -37,7 +37,7 @@ namespace Kyra {
Sound::Sound(KyraEngine_v1 *vm, Audio::Mixer *mixer)
: _vm(vm), _mixer(mixer), _soundChannels(), _musicEnabled(1),
- _sfxEnabled(true), _soundDataList(0) {
+ _sfxEnabled(true) {
}
Sound::~Sound() {
@@ -47,14 +47,6 @@ Sound::kType Sound::getSfxType() const {
return getMusicType();
}
-void Sound::setSoundList(const AudioDataStruct *list) {
- _soundDataList = list;
-}
-
-bool Sound::hasSoundFile(uint file) const {
- return (fileListEntry(file) != 0);
-}
-
bool Sound::isPlaying() const {
return false;
}
@@ -73,7 +65,7 @@ bool Sound::isVoicePresent(const char *file) const {
return false;
}
-int32 Sound::voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume, bool isSfx) {
+int32 Sound::voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume, uint8 priority, bool isSfx) {
Audio::SeekableAudioStream *audioStream = getVoiceStream(file);
if (!audioStream) {
@@ -81,7 +73,7 @@ int32 Sound::voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volum
}
int playTime = audioStream->getLength().msecs();
- playVoiceStream(audioStream, handle, volume, isSfx);
+ playVoiceStream(audioStream, handle, volume, priority, isSfx);
return playTime;
}
@@ -109,12 +101,20 @@ Audio::SeekableAudioStream *Sound::getVoiceStream(const char *file) const {
}
}
-bool Sound::playVoiceStream(Audio::AudioStream *stream, Audio::SoundHandle *handle, uint8 volume, bool isSfx) {
+bool Sound::playVoiceStream(Audio::AudioStream *stream, Audio::SoundHandle *handle, uint8 volume, uint8 priority, bool isSfx) {
int h = 0;
- while (h < kNumChannelHandles && _mixer->isSoundHandleActive(_soundChannels[h]))
+ while (h < kNumChannelHandles && _mixer->isSoundHandleActive(_soundChannels[h].handle))
++h;
if (h >= kNumChannelHandles) {
+ h = 0;
+ while (h < kNumChannelHandles && _soundChannels[h].priority > priority)
+ ++h;
+ if (h < kNumChannelHandles)
+ voiceStop(&_soundChannels[h].handle);
+ }
+
+ if (h >= kNumChannelHandles) {
// When we run out of handles we need to destroy the stream object,
// this is to avoid memory leaks in some scenes where too many sfx
// are started.
@@ -123,9 +123,10 @@ bool Sound::playVoiceStream(Audio::AudioStream *stream, Audio::SoundHandle *hand
return false;
}
- _mixer->playStream(isSfx ? Audio::Mixer::kSFXSoundType : Audio::Mixer::kSpeechSoundType, &_soundChannels[h], stream, -1, volume);
+ _mixer->playStream(isSfx ? Audio::Mixer::kSFXSoundType : Audio::Mixer::kSpeechSoundType, &_soundChannels[h].handle, stream, -1, volume);
+ _soundChannels[h].priority = priority;
if (handle)
- *handle = _soundChannels[h];
+ *handle = _soundChannels[h].handle;
return true;
}
@@ -133,8 +134,8 @@ bool Sound::playVoiceStream(Audio::AudioStream *stream, Audio::SoundHandle *hand
void Sound::voiceStop(const Audio::SoundHandle *handle) {
if (!handle) {
for (int h = 0; h < kNumChannelHandles; ++h) {
- if (_mixer->isSoundHandleActive(_soundChannels[h]))
- _mixer->stopHandle(_soundChannels[h]);
+ if (_mixer->isSoundHandleActive(_soundChannels[h].handle))
+ _mixer->stopHandle(_soundChannels[h].handle);
}
} else {
_mixer->stopHandle(*handle);
@@ -144,7 +145,7 @@ void Sound::voiceStop(const Audio::SoundHandle *handle) {
bool Sound::voiceIsPlaying(const Audio::SoundHandle *handle) const {
if (!handle) {
for (int h = 0; h < kNumChannelHandles; ++h) {
- if (_mixer->isSoundHandleActive(_soundChannels[h]))
+ if (_mixer->isSoundHandleActive(_soundChannels[h].handle))
return true;
}
} else {
@@ -156,7 +157,7 @@ bool Sound::voiceIsPlaying(const Audio::SoundHandle *handle) const {
bool Sound::allVoiceChannelsPlaying() const {
for (int i = 0; i < kNumChannelHandles; ++i)
- if (!_mixer->isSoundHandleActive(_soundChannels[i]))
+ if (!_mixer->isSoundHandleActive(_soundChannels[i].handle))
return false;
return true;
}
@@ -194,9 +195,14 @@ void MixedSoundDriver::updateVolumeSettings() {
_sfx->updateVolumeSettings();
}
-void MixedSoundDriver::setSoundList(const AudioDataStruct *list) {
- _music->setSoundList(list);
- _sfx->setSoundList(list);
+void MixedSoundDriver::initAudioResourceInfo(int set, void *info) {
+ _music->initAudioResourceInfo(set, info);
+ _sfx->initAudioResourceInfo(set, info);
+}
+
+void MixedSoundDriver::selectAudioResourceSet(int set) {
+ _music->selectAudioResourceSet(set);
+ _sfx->selectAudioResourceSet(set);
}
bool MixedSoundDriver::hasSoundFile(uint file) const {
diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h
index 63cec48d00..2f5a0b6121 100644
--- a/engines/kyra/sound.h
+++ b/engines/kyra/sound.h
@@ -37,6 +37,35 @@ class SeekableAudioStream;
namespace Kyra {
+// Helper structs to format the data passed to the various initAudioResourceInfo() implementations
+struct SoundResourceInfo_PC {
+ SoundResourceInfo_PC(const char *const *files, int numFiles) : fileList(files), fileListSize(numFiles) {}
+ const char *const *fileList;
+ uint fileListSize;
+};
+
+struct SoundResourceInfo_Towns {
+ SoundResourceInfo_Towns(const char *const *files, int numFiles, const int32 *cdaTbl, int cdaTblSize) : fileList(files), fileListSize(numFiles), cdaTable(cdaTbl), cdaTableSize(cdaTblSize) {}
+ const char *const *fileList;
+ uint fileListSize;
+ const int32 *cdaTable;
+ uint cdaTableSize;
+};
+
+struct SoundResourceInfo_PC98 {
+ SoundResourceInfo_PC98(const char *fileNamePattern) : pattern(fileNamePattern) {}
+ const char *pattern;
+};
+
+struct SoundResourceInfo_TownsPC98V2 {
+ SoundResourceInfo_TownsPC98V2(const char *const *files, int numFiles, const char *fileNamePattern, const uint16 *cdaTbl, int cdaTblSize) : fileList(files), fileListSize(numFiles), pattern(fileNamePattern), cdaTable(cdaTbl), cdaTableSize(cdaTblSize) {}
+ const char *const *fileList;
+ uint fileListSize;
+ const char *pattern;
+ const uint16 *cdaTable;
+ uint cdaTableSize;
+};
+
/**
* Analog audio output device API for Kyrandia games.
* It contains functionality to play music tracks,
@@ -78,12 +107,20 @@ public:
virtual void updateVolumeSettings() {}
/**
- * Sets the soundfiles the output device will use
- * when playing a track and/or sound effect.
+ * Assigns static resource data with information on how to load
+ * audio resources to
*
- * @param list soundfile list
+ * @param set value defined in AudioResourceSet enum
+ * info various types of resource info data (file list, file name pattern, struct, etc. - depending on the inheriting driver type)
*/
- virtual void setSoundList(const AudioDataStruct *list);
+ virtual void initAudioResourceInfo(int set, void *info) = 0;
+
+ /**
+ * Select audio resource set.
+ *
+ * @param set value defined in AudioResourceSet enum
+ */
+ virtual void selectAudioResourceSet(int set) = 0;
/**
* Checks if a given sound file is present.
@@ -91,7 +128,7 @@ public:
* @param track track number
* @return true if available, false otherwise
*/
- virtual bool hasSoundFile(uint file) const;
+ virtual bool hasSoundFile(uint file) const = 0;
/**
* Load a specifc sound file for use of
@@ -128,7 +165,7 @@ public:
*
* @param track sound effect id
*/
- virtual void playSoundEffect(uint8 track, uint8 volume = 0xff) = 0;
+ virtual void playSoundEffect(uint8 track, uint8 volume = 0xFF) = 0;
/**
* Stop playback of all sfx tracks.
@@ -184,11 +221,11 @@ public:
* @param handle store a copy of the sound handle
* @return playtime of the voice file (-1 marks unknown playtime)
*/
- virtual int32 voicePlay(const char *file, Audio::SoundHandle *handle = 0, uint8 volume = 255, bool isSfx = false);
+ virtual int32 voicePlay(const char *file, Audio::SoundHandle *handle = 0, uint8 volume = 255, uint8 priority = 255, bool isSfx = false);
Audio::SeekableAudioStream *getVoiceStream(const char *file) const;
- bool playVoiceStream(Audio::AudioStream *stream, Audio::SoundHandle *handle = 0, uint8 volume = 255, bool isSfx = false);
+ bool playVoiceStream(Audio::AudioStream *stream, Audio::SoundHandle *handle = 0, uint8 volume = 255, uint8 priority = 255, bool isSfx = false);
/**
* Checks if a voice is being played.
@@ -228,17 +265,17 @@ public:
*/
virtual void resetTrigger() {}
protected:
- const char *fileListEntry(int file) const { return (_soundDataList != 0 && file >= 0 && file < _soundDataList->fileListLen) ? _soundDataList->fileList[file] : ""; }
- int fileListLen() const { return _soundDataList->fileListLen; }
- const void *cdaData() const { return _soundDataList != 0 ? _soundDataList->cdaTracks : 0; }
- int cdaTrackNum() const { return _soundDataList != 0 ? _soundDataList->cdaNumTracks : 0; }
- int extraOffset() const { return _soundDataList != 0 ? _soundDataList->extraOffset : 0; }
-
enum {
kNumChannelHandles = 4
};
- Audio::SoundHandle _soundChannels[kNumChannelHandles];
+ struct SoundChannel {
+ SoundChannel() : handle(), priority(0) {}
+ Audio::SoundHandle handle;
+ int priority;
+ };
+
+ SoundChannel _soundChannels[kNumChannelHandles];
int _musicEnabled;
bool _sfxEnabled;
@@ -247,8 +284,6 @@ protected:
Audio::Mixer *_mixer;
private:
- const AudioDataStruct *_soundDataList;
-
struct SpeechCodecs {
const char *fileext;
Audio::SeekableAudioStream *(*streamFunc)(
@@ -272,7 +307,8 @@ public:
virtual void updateVolumeSettings();
- virtual void setSoundList(const AudioDataStruct *list);
+ virtual void initAudioResourceInfo(int set, void *info);
+ virtual void selectAudioResourceSet(int set);
virtual bool hasSoundFile(uint file) const;
virtual void loadSoundFile(uint file);
virtual void loadSoundFile(Common::String file);
@@ -283,7 +319,7 @@ public:
virtual void haltTrack();
virtual bool isPlaying() const;
- virtual void playSoundEffect(uint8 track, uint8 volume = 0xff);
+ virtual void playSoundEffect(uint8 track, uint8 volume = 0xFF);
virtual void stopAllSoundEffects();
@@ -293,88 +329,6 @@ private:
Sound *_music, *_sfx;
};
-// Digital Audio
-class AUDStream;
-class KyraAudioStream;
-class KyraEngine_MR;
-
-/**
- * Digital audio output device.
- *
- * This is just used for Kyrandia 3.
- */
-class SoundDigital {
-public:
- SoundDigital(KyraEngine_MR *vm, Audio::Mixer *mixer);
- ~SoundDigital();
-
- bool init() { return true; }
-
- /**
- * Plays a sound.
- *
- * @param filename file to be played
- * @param priority priority of the sound
- * @param type type
- * @param volume channel volume
- * @param loop true if the sound should loop (endlessly)
- * @param channel tell the sound player to use a specific channel for playback
- *
- * @return channel playing the sound
- */
- int playSound(const char *filename, uint8 priority, Audio::Mixer::SoundType type, int volume = 255, bool loop = false, int channel = -1);
-
- /**
- * Checks if a given channel is playing a sound.
- *
- * @param channel channel number to check
- * @return true if playing, else false
- */
- bool isPlaying(int channel);
-
- /**
- * Stop the playback of a sound in the given
- * channel.
- *
- * @param channel channel number
- */
- void stopSound(int channel);
-
- /**
- * Stops playback of all sounds.
- */
- void stopAllSounds();
-
- /**
- * Makes the sound in a given channel
- * fading out.
- *
- * @param channel channel number
- * @param ticks fadeout time
- */
- void beginFadeOut(int channel, int ticks);
-private:
- KyraEngine_MR *_vm;
- Audio::Mixer *_mixer;
-
- struct Sound {
- Audio::SoundHandle handle;
-
- char filename[16];
- uint8 priority;
- KyraAudioStream *stream;
- } _sounds[4];
-
- struct AudioCodecs {
- const char *fileext;
- Audio::SeekableAudioStream *(*streamFunc)(
- Common::SeekableReadStream *stream,
- DisposeAfterUse::Flag disposeAfterUse);
- };
-
- static const AudioCodecs _supportedCodecs[];
-};
-
} // End of namespace Kyra
#endif
diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp
index 668e662413..1d665709e5 100644
--- a/engines/kyra/sound_adlib.cpp
+++ b/engines/kyra/sound_adlib.cpp
@@ -683,14 +683,14 @@ void AdLibDriver::adjustSfxData(uint8 *ptr, int volume) {
_sfxVelocity = ptr[3];
// Adjust the values.
- if (volume != 0xff) {
+ if (volume != 0xFF) {
if (_version >= 3) {
int newVal = ((((ptr[3]) + 63) * volume) >> 8) & 0xFF;
ptr[3] = -newVal + 63;
ptr[1] = ((ptr[1] * volume) >> 8) & 0xFF;
} else {
- int newVal = ((_sfxVelocity << 2) ^ 0xff) * volume;
- ptr[3] = (newVal >> 10) ^ 0x3f;
+ int newVal = ((_sfxVelocity << 2) ^ 0xFF) * volume;
+ ptr[3] = (newVal >> 10) ^ 0x3F;
ptr[1] = newVal >> 11;
}
}
@@ -2292,6 +2292,8 @@ SoundAdLibPC::SoundAdLibPC(KyraEngine_v1 *vm, Audio::Mixer *mixer)
_numSoundTriggers = 0;
_sfxPlayingSound = -1;
_soundFileLoaded.clear();
+ _currentResourceSet = 0;
+ memset(&_resInfo, 0, sizeof(_resInfo));
switch (vm->game()) {
case GI_LOL:
@@ -2322,6 +2324,8 @@ SoundAdLibPC::SoundAdLibPC(KyraEngine_v1 *vm, Audio::Mixer *mixer)
SoundAdLibPC::~SoundAdLibPC() {
delete _driver;
delete[] _soundDataPtr;
+ for (int i = 0; i < 3; i++)
+ initAudioResourceInfo(i, 0);
}
bool SoundAdLibPC::init() {
@@ -2371,7 +2375,7 @@ void SoundAdLibPC::playTrack(uint8 track) {
_driver->setSyncJumpMask(0x000F);
else
_driver->setSyncJumpMask(0);
- play(track, 0xff);
+ play(track, 0xFF);
}
}
@@ -2405,7 +2409,7 @@ void SoundAdLibPC::play(uint8 track, uint8 volume) {
}
void SoundAdLibPC::beginFadeOut() {
- play(_version > 2 ? 1 : 15, 0xff);
+ play(_version > 2 ? 1 : 15, 0xFF);
}
int SoundAdLibPC::checkTrigger() {
@@ -2416,8 +2420,29 @@ void SoundAdLibPC::resetTrigger() {
_driver->resetSoundTrigger();
}
+void SoundAdLibPC::initAudioResourceInfo(int set, void *info) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ delete _resInfo[set];
+ _resInfo[set] = info ? new SoundResourceInfo_PC(*(SoundResourceInfo_PC*)info) : 0;
+ }
+}
+
+void SoundAdLibPC::selectAudioResourceSet(int set) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ if (_resInfo[set])
+ _currentResourceSet = set;
+ }
+}
+
+bool SoundAdLibPC::hasSoundFile(uint file) const {
+ if (file < res()->fileListSize)
+ return (res()->fileList[file] != 0);
+ return false;
+}
+
void SoundAdLibPC::loadSoundFile(uint file) {
- internalLoadFile(fileListEntry(file));
+ if (file < res()->fileListSize)
+ internalLoadFile(res()->fileList[file]);
}
void SoundAdLibPC::loadSoundFile(Common::String file) {
diff --git a/engines/kyra/sound_adlib.h b/engines/kyra/sound_adlib.h
index 8492f3b99a..f8486499ab 100644
--- a/engines/kyra/sound_adlib.h
+++ b/engines/kyra/sound_adlib.h
@@ -69,6 +69,9 @@ public:
virtual void updateVolumeSettings();
+ virtual void initAudioResourceInfo(int set, void *info);
+ virtual void selectAudioResourceSet(int set);
+ virtual bool hasSoundFile(uint file) const;
virtual void loadSoundFile(uint file);
virtual void loadSoundFile(Common::String file);
@@ -76,7 +79,7 @@ public:
virtual void haltTrack();
virtual bool isPlaying() const;
- virtual void playSoundEffect(uint8 track, uint8 volume = 0xff);
+ virtual void playSoundEffect(uint8 track, uint8 volume = 0xFF);
virtual void beginFadeOut();
@@ -87,6 +90,10 @@ private:
void play(uint8 track, uint8 volume);
+ const SoundResourceInfo_PC *res() const {return _resInfo[_currentResourceSet]; }
+ SoundResourceInfo_PC *_resInfo[3];
+ int _currentResourceSet;
+
AdLibDriver *_driver;
int _version;
diff --git a/engines/kyra/sound_amiga.cpp b/engines/kyra/sound_amiga.cpp
index ec2748dd38..7292541594 100644
--- a/engines/kyra/sound_amiga.cpp
+++ b/engines/kyra/sound_amiga.cpp
@@ -53,10 +53,26 @@ bool SoundAmiga::init() {
return _driver != 0 && _tableSfxIntro && _tableSfxGame;
}
+void SoundAmiga::initAudioResourceInfo(int set, void *info) {
+ // See comment below
+}
+
+void SoundAmiga::selectAudioResourceSet(int set) {
+ // It seems that loadSoundFile() is doing what would normally be done in here.
+ // As long as this driver is only required for one single target (Kyra 1 Amiga)
+ // this doesn't matter much.
+}
+
+bool SoundAmiga::hasSoundFile(uint file) const {
+ if (file < 3)
+ return true;
+ return false;
+}
+
void SoundAmiga::loadSoundFile(uint file) {
debugC(5, kDebugLevelSound, "SoundAmiga::loadSoundFile(%d)", file);
- static const char * const tableFilenames[3][2] = {
+ static const char *const tableFilenames[3][2] = {
{ "introscr.mx", "introinst.mx" },
{ "kyramusic.mx", 0 },
{ "finalescr.mx", "introinst.mx" }
diff --git a/engines/kyra/sound_digital.cpp b/engines/kyra/sound_digital.cpp
index fe0f1fb9bc..518805c43e 100644
--- a/engines/kyra/sound_digital.cpp
+++ b/engines/kyra/sound_digital.cpp
@@ -20,7 +20,7 @@
*
*/
-#include "kyra/sound.h"
+#include "kyra/sound_digital.h"
#include "kyra/resource.h"
#include "kyra/kyra_mr.h"
@@ -271,8 +271,8 @@ int AUDStream::readChunk(int16 *buffer, const int maxSamples) {
while (outSize > 0) {
input = _inBuffer[i++] << 2;
- code = (input >> 8) & 0xff;
- count = (input & 0xff) >> 2;
+ code = (input >> 8) & 0xFF;
+ count = (input & 0xFF) >> 2;
switch (code) {
case 2:
@@ -294,7 +294,7 @@ int AUDStream::readChunk(int16 *buffer, const int maxSamples) {
for (; count >= 0; count--) {
code = _inBuffer[i++];
- curSample += WSTable4Bit[code & 0x0f];
+ curSample += WSTable4Bit[code & 0x0F];
curSample = clip8BitSample(curSample);
_outBuffer[j++] = curSample;
diff --git a/engines/kyra/sound_digital.h b/engines/kyra/sound_digital.h
new file mode 100644
index 0000000000..271dde6a21
--- /dev/null
+++ b/engines/kyra/sound_digital.h
@@ -0,0 +1,119 @@
+/* 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.
+ *
+ */
+
+#ifndef KYRA_SOUND_DIGITAL_H
+#define KYRA_SOUND_DIGITAL_H
+
+#include "audio/mixer.h"
+
+namespace Common {
+class SeekableReadStream;
+} // End of namespace Common
+
+namespace Audio {
+class SeekableAudioStream;
+} // End of namespace Audio
+
+namespace Kyra {
+
+// Digital Audio
+class KyraAudioStream;
+class KyraEngine_MR;
+
+/**
+ * Digital audio output device.
+ *
+ * This is just used for Kyrandia 3.
+ */
+class SoundDigital {
+public:
+ SoundDigital(KyraEngine_MR *vm, Audio::Mixer *mixer);
+ ~SoundDigital();
+
+ /**
+ * Plays a sound.
+ *
+ * @param filename file to be played
+ * @param priority priority of the sound
+ * @param type type
+ * @param volume channel volume
+ * @param loop true if the sound should loop (endlessly)
+ * @param channel tell the sound player to use a specific channel for playback
+ *
+ * @return channel playing the sound
+ */
+ int playSound(const char *filename, uint8 priority, Audio::Mixer::SoundType type, int volume = 255, bool loop = false, int channel = -1);
+
+ /**
+ * Checks if a given channel is playing a sound.
+ *
+ * @param channel channel number to check
+ * @return true if playing, else false
+ */
+ bool isPlaying(int channel);
+
+ /**
+ * Stop the playback of a sound in the given
+ * channel.
+ *
+ * @param channel channel number
+ */
+ void stopSound(int channel);
+
+ /**
+ * Stops playback of all sounds.
+ */
+ void stopAllSounds();
+
+ /**
+ * Makes the sound in a given channel
+ * fading out.
+ *
+ * @param channel channel number
+ * @param ticks fadeout time
+ */
+ void beginFadeOut(int channel, int ticks);
+private:
+ KyraEngine_MR *_vm;
+ Audio::Mixer *_mixer;
+
+ struct Sound {
+ Audio::SoundHandle handle;
+
+ char filename[16];
+ uint8 priority;
+ KyraAudioStream *stream;
+ } _sounds[4];
+
+ struct AudioCodecs {
+ const char *fileext;
+ Audio::SeekableAudioStream *(*streamFunc)(
+ Common::SeekableReadStream *stream,
+ DisposeAfterUse::Flag disposeAfterUse);
+ };
+
+ static const AudioCodecs _supportedCodecs[];
+};
+
+} // End of namespace Kyra
+
+#endif
diff --git a/engines/kyra/sound_intern.h b/engines/kyra/sound_intern.h
index 827a487685..007ca3d3f5 100644
--- a/engines/kyra/sound_intern.h
+++ b/engines/kyra/sound_intern.h
@@ -23,6 +23,8 @@
#ifndef KYRA_SOUND_INTERN_H
#define KYRA_SOUND_INTERN_H
+
+
#include "kyra/sound.h"
#include "kyra/sound_adlib.h"
@@ -40,6 +42,7 @@ class MaxTrax;
} // End of namespace Audio
namespace Kyra {
+
class MidiOutput;
/**
@@ -51,28 +54,31 @@ class MidiOutput;
class SoundMidiPC : public Sound {
public:
SoundMidiPC(KyraEngine_v1 *vm, Audio::Mixer *mixer, MidiDriver *driver, kType type);
- ~SoundMidiPC();
+ virtual ~SoundMidiPC();
- kType getMusicType() const { return _type; }
+ virtual kType getMusicType() const { return _type; }
- bool init();
+ virtual bool init();
- void updateVolumeSettings();
+ virtual void updateVolumeSettings();
- void loadSoundFile(uint file);
- void loadSoundFile(Common::String file);
- void loadSfxFile(Common::String file);
+ virtual void initAudioResourceInfo(int set, void *info);
+ virtual void selectAudioResourceSet(int set);
+ virtual bool hasSoundFile(uint file) const;
+ virtual void loadSoundFile(uint file);
+ virtual void loadSoundFile(Common::String file);
+ virtual void loadSfxFile(Common::String file);
- void playTrack(uint8 track);
- void haltTrack();
- bool isPlaying() const;
+ virtual void playTrack(uint8 track);
+ virtual void haltTrack();
+ virtual bool isPlaying() const;
- void playSoundEffect(uint8 track, uint8 volume = 0xff);
- void stopAllSoundEffects();
+ virtual void playSoundEffect(uint8 track, uint8 volume = 0xFF);
+ virtual void stopAllSoundEffects();
- void beginFadeOut();
+ virtual void beginFadeOut();
- void pause(bool paused);
+ virtual void pause(bool paused);
private:
static void onTimer(void *data);
@@ -89,6 +95,10 @@ private:
MidiParser *_music;
MidiParser *_sfx[3];
+ const SoundResourceInfo_PC *res() const {return _resInfo[_currentResourceSet]; }
+ SoundResourceInfo_PC *_resInfo[3];
+ int _currentResourceSet;
+
// misc
kType _type;
Common::String getFileName(const Common::String &str);
@@ -103,25 +113,28 @@ private:
class SoundTowns : public Sound {
public:
SoundTowns(KyraEngine_v1 *vm, Audio::Mixer *mixer);
- ~SoundTowns();
+ virtual ~SoundTowns();
- kType getMusicType() const { return kTowns; }
+ virtual kType getMusicType() const { return kTowns; }
- bool init();
- void process();
+ virtual bool init();
+ virtual void process();
- void loadSoundFile(uint file);
- void loadSoundFile(Common::String) {}
+ virtual void initAudioResourceInfo(int set, void *info);
+ virtual void selectAudioResourceSet(int set);
+ virtual bool hasSoundFile(uint file) const;
+ virtual void loadSoundFile(uint file);
+ virtual void loadSoundFile(Common::String) {}
- void playTrack(uint8 track);
- void haltTrack();
+ virtual void playTrack(uint8 track);
+ virtual void haltTrack();
- void playSoundEffect(uint8 track, uint8 volume = 0xff);
- void stopAllSoundEffects();
+ virtual void playSoundEffect(uint8 track, uint8 volume = 0xFF);
+ virtual void stopAllSoundEffects();
- void beginFadeOut();
+ virtual void beginFadeOut();
- void updateVolumeSettings();
+ virtual void updateVolumeSettings();
private:
bool loadInstruments();
@@ -142,6 +155,10 @@ private:
bool _cdaPlaying;
+ const SoundResourceInfo_Towns *res() const {return _resInfo[_currentResourceSet]; }
+ SoundResourceInfo_Towns *_resInfo[3];
+ int _currentResourceSet;
+
const uint8 *_musicFadeTable;
const uint8 *_sfxBTTable;
const uint8 *_sfxWDTable;
@@ -150,55 +167,64 @@ private:
class SoundPC98 : public Sound {
public:
SoundPC98(KyraEngine_v1 *vm, Audio::Mixer *mixer);
- ~SoundPC98();
+ virtual ~SoundPC98();
virtual kType getMusicType() const { return kPC98; }
- bool init();
+ virtual bool init();
- void process() {}
- void loadSoundFile(uint file);
- void loadSoundFile(Common::String file);
+ virtual void initAudioResourceInfo(int set, void *info);
+ virtual void selectAudioResourceSet(int set);
+ virtual bool hasSoundFile(uint file) const;
+ virtual void loadSoundFile(uint file);
+ virtual void loadSoundFile(Common::String file);
- void playTrack(uint8 track);
- void haltTrack();
- void beginFadeOut();
+ virtual void playTrack(uint8 track);
+ virtual void haltTrack();
+ virtual void beginFadeOut();
- int32 voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume, bool isSfx) { return -1; }
- void playSoundEffect(uint8 track, uint8 volume = 0xff);
+ virtual int32 voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume, uint8 priority, bool isSfx) override { return -1; }
+ virtual void playSoundEffect(uint8 track, uint8 volume = 0xFF);
- void updateVolumeSettings();
+ virtual void updateVolumeSettings();
-protected:
+private:
int _lastTrack;
uint8 *_musicTrackData;
uint8 *_sfxTrackData;
TownsPC98_AudioDriver *_driver;
+
+ const char *resPattern() {return _resInfo[_currentResourceSet]->c_str(); }
+ Common::String *_resInfo[3];
+ int _currentResourceSet;
};
class SoundTownsPC98_v2 : public Sound {
public:
SoundTownsPC98_v2(KyraEngine_v1 *vm, Audio::Mixer *mixer);
- ~SoundTownsPC98_v2();
+ virtual ~SoundTownsPC98_v2();
- kType getMusicType() const { return _vm->gameFlags().platform == Common::kPlatformFMTowns ? kTowns : kPC98; }
+ virtual kType getMusicType() const { return _vm->gameFlags().platform == Common::kPlatformFMTowns ? kTowns : kPC98; }
- bool init();
- void process();
+ virtual bool init();
+ virtual void process();
- void loadSoundFile(uint file) {}
- void loadSoundFile(Common::String file);
+ virtual void initAudioResourceInfo(int set, void *info);
+ virtual void selectAudioResourceSet(int set);
+ virtual bool hasSoundFile(uint file) const;
+ virtual void loadSoundFile(uint file) {}
+ virtual void loadSoundFile(Common::String file);
- void playTrack(uint8 track);
- void haltTrack();
- void beginFadeOut();
+ virtual void playTrack(uint8 track);
+ virtual void haltTrack();
+ virtual void beginFadeOut();
- int32 voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume, bool isSfx);
- void playSoundEffect(uint8 track, uint8 volume = 0xff);
+ virtual int32 voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume = 255, uint8 priority = 255, bool isSfx = true) override;
+ virtual void playSoundEffect(uint8 track, uint8 volume = 0xFF);
- void updateVolumeSettings();
+ virtual void updateVolumeSettings();
-protected:
+private:
Audio::AudioStream *_currentSFX;
int _lastTrack;
bool _useFmSfx;
@@ -206,6 +232,10 @@ protected:
uint8 *_musicTrackData;
uint8 *_sfxTrackData;
TownsPC98_AudioDriver *_driver;
+
+ const SoundResourceInfo_TownsPC98V2 *res() const {return _resInfo[_currentResourceSet]; }
+ SoundResourceInfo_TownsPC98V2 *_resInfo[3];
+ int _currentResourceSet;
};
// PC Speaker MIDI driver
@@ -288,22 +318,24 @@ struct AmigaSfxTable {
class SoundAmiga : public Sound {
public:
SoundAmiga(KyraEngine_v1 *vm, Audio::Mixer *mixer);
- ~SoundAmiga();
+ virtual ~SoundAmiga();
virtual kType getMusicType() const { return kAmiga; } //FIXME
- bool init();
+ virtual bool init();
- void process() {}
- void loadSoundFile(uint file);
- void loadSoundFile(Common::String) {}
+ virtual void initAudioResourceInfo(int set, void *info);
+ virtual void selectAudioResourceSet(int set);
+ virtual bool hasSoundFile(uint file) const;
+ virtual void loadSoundFile(uint file);
+ virtual void loadSoundFile(Common::String) {}
- void playTrack(uint8 track);
- void haltTrack();
- void beginFadeOut();
+ virtual void playTrack(uint8 track);
+ virtual void haltTrack();
+ virtual void beginFadeOut();
- int32 voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume, bool isSfx) { return -1; }
- void playSoundEffect(uint8 track, uint8 volume = 0xff);
+ virtual int32 voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume, uint8 priority, bool isSfx) override { return -1; }
+ virtual void playSoundEffect(uint8 track, uint8 volume = 0xFF);
protected:
Audio::MaxTrax *_driver;
diff --git a/engines/kyra/sound_lol.cpp b/engines/kyra/sound_lol.cpp
index cb9be43b07..48230d025c 100644
--- a/engines/kyra/sound_lol.cpp
+++ b/engines/kyra/sound_lol.cpp
@@ -60,7 +60,7 @@ bool LoLEngine::snd_playCharacterSpeech(int id, int8 speaker, int) {
Common::String pattern2 = Common::String::format("%02d", id & 0x4000 ? 0 : _curTlkFile);
if (id & 0x4000) {
- pattern1 = Common::String::format("%03X", id & 0x3fff);
+ pattern1 = Common::String::format("%03X", id & 0x3FFF);
} else if (id < 1000) {
pattern1 = Common::String::format("%03d", id);
} else {
@@ -164,11 +164,19 @@ void LoLEngine::snd_playSoundEffect(int track, int volume) {
if (track == -1 || track >= _ingameSoundListSize)
return;
- volume &= 0xff;
- int16 volIndex = (int16)READ_LE_UINT16(&_ingameSoundIndex[track * 2 + 1]);
+ volume &= 0xFF;
+ int16 prIndex = (int16)READ_LE_UINT16(&_ingameSoundIndex[track * 2 + 1]);
+ uint16 priority = (prIndex > 0) ? (prIndex * volume) >> 8 : -prIndex;
- uint16 vocLevel = (volIndex > 0) ? (volIndex * volume) >> 8 : -volIndex;
- vocLevel = CLIP(volume >> 4, 2, 13) * 7 + 164;
+ static const uint8 volTable1[] = { 223, 159, 95, 47, 15, 0 };
+ static const uint8 volTable2[] = { 255, 191, 127, 63, 30, 0 };
+
+ for (int i = 0; i < 6; i++) {
+ if (volTable1[i] < volume) {
+ volume = volTable2[i];
+ break;
+ }
+ }
int16 vocIndex = (int16)READ_LE_UINT16(&_ingameSoundIndex[track * 2]);
@@ -180,7 +188,7 @@ void LoLEngine::snd_playSoundEffect(int track, int volume) {
if (hasVocFile) {
if (_sound->isVoicePresent(_ingameSoundList[vocIndex]))
- _sound->voicePlay(_ingameSoundList[vocIndex], 0, vocLevel & 0xff, true);
+ _sound->voicePlay(_ingameSoundList[vocIndex], 0, volume, priority, true);
} else if (_flags.platform == Common::kPlatformPC) {
if (_sound->getSfxType() == Sound::kMidiMT32)
track = (track < _ingameMT32SoundIndexSize) ? (_ingameMT32SoundIndex[track] - 1) : -1;
@@ -206,8 +214,8 @@ bool LoLEngine::snd_processEnvironmentalSoundEffect(int soundId, int block) {
uint16 cbl = _currentBlock;
for (int i = 3; i > 0; i--) {
- int dir = calcMonsterDirection(cbl & 0x1f, cbl >> 5, block & 0x1f, block >> 5);
- cbl = (cbl + blockShiftTable[dir]) & 0x3ff;
+ int dir = calcMonsterDirection(cbl & 0x1F, cbl >> 5, block & 0x1F, block >> 5);
+ cbl = (cbl + blockShiftTable[dir]) & 0x3FF;
if (cbl != block) {
if (testWallFlag(cbl, 0, 1))
_environmentSfxVol >>= 1;
@@ -239,7 +247,7 @@ void LoLEngine::snd_playQueuedEffects() {
void LoLEngine::snd_loadSoundFile(int track) {
if (_sound->musicEnabled()) {
- if (_flags.platform != Common::kPlatformPC98) {
+ if (_flags.platform == Common::kPlatformPC) {
int t = (track - 250) * 3;
if (_curMusicFileIndex != _musicTrackMap[t] || _curMusicFileExt != (char)_musicTrackMap[t + 1]) {
snd_stopMusic();
@@ -261,12 +269,12 @@ int LoLEngine::snd_playTrack(int track) {
_lastMusicTrack = track;
if (_sound->musicEnabled()) {
- if (_flags.platform == Common::kPlatformPC98) {
- _sound->playTrack(track - 249);
- } else {
+ if (_flags.platform == Common::kPlatformPC) {
snd_loadSoundFile(track);
int t = (track - 250) * 3;
_sound->playTrack(_musicTrackMap[t + 2]);
+ } else {
+ _sound->playTrack(track - 249);
}
}
diff --git a/engines/kyra/sound_midi.cpp b/engines/kyra/sound_midi.cpp
index 70cc304192..b93b42fa9c 100644
--- a/engines/kyra/sound_midi.cpp
+++ b/engines/kyra/sound_midi.cpp
@@ -442,6 +442,8 @@ SoundMidiPC::SoundMidiPC(KyraEngine_v1 *vm, Audio::Mixer *mixer, MidiDriver *dri
_output = 0;
_musicFile = _sfxFile = 0;
+ _currentResourceSet = 0;
+ memset(&_resInfo, 0, sizeof(_resInfo));
_music = MidiParser::createParser_XMIDI();
assert(_music);
@@ -495,6 +497,9 @@ SoundMidiPC::~SoundMidiPC() {
delete[] _sfxFile;
delete[] _musicFile;
+
+ for (int i = 0; i < 3; i++)
+ initAudioResourceInfo(i, 0);
}
bool SoundMidiPC::init() {
@@ -586,8 +591,29 @@ void SoundMidiPC::updateVolumeSettings() {
_output->setSourceVolume(i, _sfxVolume, false);
}
+void SoundMidiPC::initAudioResourceInfo(int set, void *info) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ delete _resInfo[set];
+ _resInfo[set] = info ? new SoundResourceInfo_PC(*(SoundResourceInfo_PC*)info) : 0;
+ }
+}
+
+void SoundMidiPC::selectAudioResourceSet(int set) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ if (_resInfo[set])
+ _currentResourceSet = set;
+ }
+}
+
+bool SoundMidiPC::hasSoundFile(uint file) const {
+ if (file < res()->fileListSize)
+ return (res()->fileList[file] != 0);
+ return false;
+}
+
void SoundMidiPC::loadSoundFile(uint file) {
- loadSoundFile(fileListEntry(file));
+ if (file < res()->fileListSize)
+ loadSoundFile(res()->fileList[file]);
}
void SoundMidiPC::loadSoundFile(Common::String file) {
@@ -757,7 +783,6 @@ void SoundMidiPC::onTimer(void *data) {
midi->_sfx[i]->stopPlaying();
}
- midi->_output->setSourceVolume(0, midi->_musicVolume, true);
midi->_fadeMusicOut = false;
}
}
diff --git a/engines/kyra/sound_towns.cpp b/engines/kyra/sound_towns.cpp
index 4b25db33f2..af741a1ebe 100644
--- a/engines/kyra/sound_towns.cpp
+++ b/engines/kyra/sound_towns.cpp
@@ -35,8 +35,8 @@ namespace Kyra {
SoundTowns::SoundTowns(KyraEngine_v1 *vm, Audio::Mixer *mixer)
: Sound(vm, mixer), _lastTrack(-1), _musicTrackData(0), _sfxFileData(0), _cdaPlaying(0),
- _sfxFileIndex((uint)-1), _musicFadeTable(0), _sfxWDTable(0), _sfxBTTable(0), _sfxChannel(0x46) {
-
+ _sfxFileIndex((uint)-1), _musicFadeTable(0), _sfxWDTable(0), _sfxBTTable(0), _sfxChannel(0x46), _currentResourceSet(0) {
+ memset(&_resInfo, 0, sizeof(_resInfo));
_driver = new TownsEuphonyDriver(_mixer);
}
@@ -46,6 +46,8 @@ SoundTowns::~SoundTowns() {
delete _driver;
delete[] _musicTrackData;
delete[] _sfxFileData;
+ for (int i = 0; i < 3; i++)
+ initAudioResourceInfo(i, 0);
}
bool SoundTowns::init() {
@@ -78,11 +80,12 @@ void SoundTowns::playTrack(uint8 track) {
return;
track -= 2;
- const int32 *const tTable = (const int32 *)cdaData();
- int tTableIndex = 3 * track;
+ uint tTableIndex = 3 * track;
+
+ assert(tTableIndex + 2 < res()->cdaTableSize);
- int trackNum = (int)READ_LE_UINT32(&tTable[tTableIndex + 2]);
- int32 loop = (int32)READ_LE_UINT32(&tTable[tTableIndex + 1]);
+ int trackNum = (int)READ_LE_UINT32(&res()->cdaTable[tTableIndex + 2]);
+ int32 loop = (int32)READ_LE_UINT32(&res()->cdaTable[tTableIndex + 1]);
if (track == _lastTrack && _musicEnabled)
return;
@@ -95,7 +98,7 @@ void SoundTowns::playTrack(uint8 track) {
g_system->getAudioCDManager()->updateCD();
_cdaPlaying = true;
} else if (_musicEnabled) {
- playEuphonyTrack(READ_LE_UINT32(&tTable[tTableIndex]), loop);
+ playEuphonyTrack(READ_LE_UINT32(&res()->cdaTable[tTableIndex]), loop);
_cdaPlaying = false;
}
@@ -117,12 +120,32 @@ void SoundTowns::haltTrack() {
_driver->stopParser();
}
+void SoundTowns::initAudioResourceInfo(int set, void *info) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ delete _resInfo[set];
+ _resInfo[set] = info ? new SoundResourceInfo_Towns(*(SoundResourceInfo_Towns*)info) : 0;
+ }
+}
+
+void SoundTowns::selectAudioResourceSet(int set) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ if (_resInfo[set])
+ _currentResourceSet = set;
+ }
+}
+
+bool SoundTowns::hasSoundFile(uint file) const {
+ if (file < res()->fileListSize)
+ return (res()->fileList[file] != 0);
+ return false;
+}
+
void SoundTowns::loadSoundFile(uint file) {
- if (_sfxFileIndex == file)
+ if (_sfxFileIndex == file || file >= res()->fileListSize)
return;
_sfxFileIndex = file;
delete[] _sfxFileData;
- _sfxFileData = _vm->resource()->fileData(fileListEntry(file), 0);
+ _sfxFileData = _vm->resource()->fileData(res()->fileList[file], 0);
}
void SoundTowns::playSoundEffect(uint8 track, uint8) {
@@ -151,8 +174,8 @@ void SoundTowns::playSoundEffect(uint8 track, uint8) {
}
}
- uint8 *fileBody = _sfxFileData + 0x01b8;
- int32 offset = (int32)READ_LE_UINT32(_sfxFileData + (track - 0x0b) * 4);
+ uint8 *fileBody = _sfxFileData + 0x01B8;
+ int32 offset = (int32)READ_LE_UINT32(_sfxFileData + (track - 0x0B) * 4);
if (offset == -1)
return;
@@ -191,10 +214,10 @@ void SoundTowns::playSoundEffect(uint8 track, uint8) {
sfx_WdTable_Number = READ_LE_UINT16(_sfxWDTable + sfx_WdTable_Offset);
sfx_BtTable_Offset += (int16)READ_LE_UINT16(_sfxWDTable + sfx_WdTable_Offset + 2);
- *tgt++ = _sfxBTTable[((sfx_BtTable_Offset >> 2) & 0xff)];
+ *tgt++ = _sfxBTTable[((sfx_BtTable_Offset >> 2) & 0xFF)];
sfx_BtTable_Offset += (int16)READ_LE_UINT16(_sfxWDTable + sfx_WdTable_Offset + 4);
- *tgt++ = _sfxBTTable[((sfx_BtTable_Offset >> 2) & 0xff)];
+ *tgt++ = _sfxBTTable[((sfx_BtTable_Offset >> 2) & 0xFF)];
}
}
@@ -270,7 +293,7 @@ void SoundTowns::beginFadeOut() {
for (int ii = 0; ii < 6; ii++)
_driver->chanVolume(ii, fadeVolCur[ii]);
for (int ii = 0x40; ii < 0x46; ii++)
- _driver->chanVolume(ii, fadeVolCur[ii - 0x3a]);
+ _driver->chanVolume(ii, fadeVolCur[ii - 0x3A]);
for (int ii = 0; ii < 6; ii++) {
fadeVolCur[ii] -= fadeVolStep[ii];
@@ -367,13 +390,16 @@ void SoundTowns::fadeOutSoundEffects() {
}
SoundPC98::SoundPC98(KyraEngine_v1 *vm, Audio::Mixer *mixer) :
- Sound(vm, mixer), _musicTrackData(0), _sfxTrackData(0), _lastTrack(-1), _driver(0) {
+ Sound(vm, mixer), _musicTrackData(0), _sfxTrackData(0), _lastTrack(-1), _driver(0), _currentResourceSet(0) {
+ memset(&_resInfo, 0, sizeof(_resInfo));
}
SoundPC98::~SoundPC98() {
delete[] _musicTrackData;
delete[] _sfxTrackData;
delete _driver;
+ for (int i = 0; i < 3; i++)
+ initAudioResourceInfo(i, 0);
}
bool SoundPC98::init() {
@@ -383,8 +409,26 @@ bool SoundPC98::init() {
return reslt;
}
-void SoundPC98::loadSoundFile(uint file) {
- if (!scumm_strnicmp(fileListEntry(0), "INTRO", 5)) {
+void SoundPC98::initAudioResourceInfo(int set, void *info) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ delete _resInfo[set];
+ _resInfo[set] = info ? new Common::String(((SoundResourceInfo_PC98*)info)->pattern) : 0;
+ }
+}
+
+void SoundPC98::selectAudioResourceSet(int set) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ if (_resInfo[set])
+ _currentResourceSet = set;
+ }
+}
+
+bool SoundPC98::hasSoundFile(uint file) const {
+ return true;
+}
+
+void SoundPC98::loadSoundFile(uint) {
+ if (_currentResourceSet == kMusicIntro) {
delete[] _sfxTrackData;
_sfxTrackData = 0;
@@ -407,14 +451,14 @@ void SoundPC98::loadSoundFile(Common::String file) {
}
void SoundPC98::playTrack(uint8 track) {
- track += extraOffset();
+ track -= 1;
if (track == _lastTrack && _musicEnabled)
return;
beginFadeOut();
- Common::String musicFile = fileListLen() == 1 ? Common::String::format(fileListEntry(0), track) : fileListEntry(track);
+ Common::String musicFile = Common::String::format(resPattern(), track);
delete[] _musicTrackData;
_musicTrackData = _vm->resource()->fileData(musicFile.c_str(), 0);
if (_musicEnabled)
@@ -464,13 +508,16 @@ void SoundPC98::updateVolumeSettings() {
// KYRA 2
SoundTownsPC98_v2::SoundTownsPC98_v2(KyraEngine_v1 *vm, Audio::Mixer *mixer) :
- Sound(vm, mixer), _currentSFX(0), _musicTrackData(0), _sfxTrackData(0), _lastTrack(-1), _driver(0), _useFmSfx(false) {
+ Sound(vm, mixer), _currentSFX(0), _musicTrackData(0), _sfxTrackData(0), _lastTrack(-1), _driver(0), _useFmSfx(false), _currentResourceSet(0) {
+ memset(&_resInfo, 0, sizeof(_resInfo));
}
SoundTownsPC98_v2::~SoundTownsPC98_v2() {
delete[] _musicTrackData;
delete[] _sfxTrackData;
delete _driver;
+ for (int i = 0; i < 3; i++)
+ initAudioResourceInfo(i, 0);
}
bool SoundTownsPC98_v2::init() {
@@ -478,7 +525,9 @@ bool SoundTownsPC98_v2::init() {
TownsPC98_AudioDriver::kType86 : TownsPC98_AudioDriver::kTypeTowns);
if (_vm->gameFlags().platform == Common::kPlatformFMTowns) {
- _vm->checkCD();
+ if (_resInfo[_currentResourceSet])
+ if (_resInfo[_currentResourceSet]->cdaTableSize)
+ _vm->checkCD();
// FIXME: While checking for 'track1.XXX(X)' looks like
// a good idea, we should definitely not be doing this
// here. Basically our filenaming scheme could change
@@ -486,9 +535,9 @@ bool SoundTownsPC98_v2::init() {
// this misses the possibility that we play the tracks
// right off CD. So we should find another way to
// check if we have access to CD audio.
- Resource *res = _vm->resource();
+ Resource *r = _vm->resource();
if (_musicEnabled &&
- (res->exists("track1.mp3") || res->exists("track1.ogg") || res->exists("track1.flac") || res->exists("track1.fla")))
+ (r->exists("track1.mp3") || r->exists("track1.ogg") || r->exists("track1.flac") || r->exists("track1.fla")))
_musicEnabled = 2;
else
_musicEnabled = 1;
@@ -503,6 +552,26 @@ bool SoundTownsPC98_v2::init() {
return reslt;
}
+void SoundTownsPC98_v2::initAudioResourceInfo(int set, void *info) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ delete _resInfo[set];
+ _resInfo[set] = info ? new SoundResourceInfo_TownsPC98V2(*(SoundResourceInfo_TownsPC98V2*)info) : 0;
+ }
+}
+
+void SoundTownsPC98_v2::selectAudioResourceSet(int set) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ if (_resInfo[set])
+ _currentResourceSet = set;
+ }
+}
+
+bool SoundTownsPC98_v2::hasSoundFile(uint file) const {
+ if (file < res()->fileListSize)
+ return (res()->fileList[file] != 0);
+ return false;
+}
+
void SoundTownsPC98_v2::loadSoundFile(Common::String file) {
delete[] _sfxTrackData;
_sfxTrackData = _vm->resource()->fileData(file.c_str(), 0);
@@ -513,18 +582,14 @@ void SoundTownsPC98_v2::process() {
}
void SoundTownsPC98_v2::playTrack(uint8 track) {
- track += extraOffset();
-
if (track == _lastTrack && _musicEnabled)
return;
- const uint16 *const cdaTracks = (const uint16 *)cdaData();
-
int trackNum = -1;
if (_vm->gameFlags().platform == Common::kPlatformFMTowns) {
- for (int i = 0; i < cdaTrackNum(); i++) {
- if (track == (uint8) READ_LE_UINT16(&cdaTracks[i * 2])) {
- trackNum = (int) READ_LE_UINT16(&cdaTracks[i * 2 + 1]) - 1;
+ for (uint i = 0; i < res()->cdaTableSize; i++) {
+ if (track == (uint8) READ_LE_UINT16(&res()->cdaTable[i * 2])) {
+ trackNum = (int) READ_LE_UINT16(&res()->cdaTable[i * 2 + 1]) - 1;
break;
}
}
@@ -532,9 +597,10 @@ void SoundTownsPC98_v2::playTrack(uint8 track) {
beginFadeOut();
- Common::String musicFile = fileListLen() == 1 ? Common::String::format(fileListEntry(0), track) : fileListEntry(track);
+ Common::String musicFile = res()->pattern ? Common::String::format(res()->pattern, track) : (res()->fileList ? res()->fileList[track] : 0);
if (musicFile.empty())
return;
+
delete[] _musicTrackData;
_musicTrackData = _vm->resource()->fileData(musicFile.c_str(), 0);
@@ -569,15 +635,24 @@ void SoundTownsPC98_v2::beginFadeOut() {
haltTrack();
}
-int32 SoundTownsPC98_v2::voicePlay(const char *file, Audio::SoundHandle *handle, uint8, bool) {
+int32 SoundTownsPC98_v2::voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume, uint8 priority, bool) {
static const uint16 rates[] = { 0x10E1, 0x0CA9, 0x0870, 0x0654, 0x0438, 0x032A, 0x021C, 0x0194 };
static const char patternHOF[] = "%s.PCM";
static const char patternLOL[] = "%s.VOC";
int h = 0;
if (_currentSFX) {
- while (h < kNumChannelHandles && _mixer->isSoundHandleActive(_soundChannels[h]))
+ while (h < kNumChannelHandles && _mixer->isSoundHandleActive(_soundChannels[h].handle))
h++;
+
+ if (h >= kNumChannelHandles) {
+ h = 0;
+ while (h < kNumChannelHandles && _soundChannels[h].priority > priority)
+ ++h;
+ if (h < kNumChannelHandles)
+ voiceStop(&_soundChannels[h].handle);
+ }
+
if (h >= kNumChannelHandles)
return 0;
}
@@ -621,7 +696,7 @@ int32 SoundTownsPC98_v2::voicePlay(const char *file, Audio::SoundHandle *handle,
cmd = ~cmd;
} else {
cmd |= 0x80;
- if (cmd == 0xff)
+ if (cmd == 0xFF)
cmd--;
}
if (cmd < 0x80)
@@ -630,9 +705,10 @@ int32 SoundTownsPC98_v2::voicePlay(const char *file, Audio::SoundHandle *handle,
}
_currentSFX = Audio::makeRawStream(sfx, outsize, sfxRate * 10, Audio::FLAG_UNSIGNED | Audio::FLAG_LITTLE_ENDIAN);
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundChannels[h], _currentSFX);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundChannels[h].handle, _currentSFX, -1, volume);
+ _soundChannels[h].priority = priority;
if (handle)
- *handle = _soundChannels[h];
+ *handle = _soundChannels[h].handle;
delete[] data;
return 1;
diff --git a/engines/kyra/sprites_eob.cpp b/engines/kyra/sprites_eob.cpp
index 5c679f5cb4..1d4c143185 100644
--- a/engines/kyra/sprites_eob.cpp
+++ b/engines/kyra/sprites_eob.cpp
@@ -58,7 +58,7 @@ void EoBCoreEngine::releaseMonsterShapes(int first, int num) {
const uint8 *EoBCoreEngine::loadMonsterProperties(const uint8 *data) {
uint8 cmd = *data++;
- while (cmd != 0xff) {
+ while (cmd != 0xFF) {
EoBMonsterProperty *d = &_monsterProps[cmd];
d->armorClass = (int8)*data++;
d->hitChance = (int8)*data++;
@@ -90,7 +90,7 @@ const uint8 *EoBCoreEngine::loadMonsterProperties(const uint8 *data) {
d->sound2 = (int8)*data++;
d->numRemoteAttacks = *data++;
- if (*data++ != 0xff) {
+ if (*data++ != 0xFF) {
d->remoteWeaponChangeMode = *data++;
d->numRemoteWeapons = *data++;
@@ -113,7 +113,7 @@ const uint8 *EoBCoreEngine::loadMonsterProperties(const uint8 *data) {
}
const uint8 *EoBCoreEngine::loadActiveMonsterData(const uint8 *data, int level) {
- for (uint8 p = *data++; p != 0xff; p = *data++) {
+ for (uint8 p = *data++; p != 0xFF; p = *data++) {
uint8 v = *data++;
_timer->setCountdown(0x20 + (p << 1), v);
_timer->setCountdown(0x21 + (p << 1), v);
@@ -132,7 +132,7 @@ const uint8 *EoBCoreEngine::loadActiveMonsterData(const uint8 *data, int level)
memset(_monsters, 0, 30 * sizeof(EoBMonsterInPlay));
for (int i = 0; i < 30; i++, data += 14) {
- if (*data == 0xff)
+ if (*data == 0xFF)
continue;
initMonster(data[0], data[1], READ_LE_UINT16(&data[2]), data[4], (int8)data[5], data[6], data[7], data[8], data[9], READ_LE_UINT16(&data[10]), READ_LE_UINT16(&data[12]));
@@ -174,7 +174,7 @@ void EoBCoreEngine::initMonster(int index, int unit, uint16 block, int pos, int
}
void EoBCoreEngine::placeMonster(EoBMonsterInPlay *m, uint16 block, int dir) {
- if (block != 0xffff) {
+ if (block != 0xFFFF) {
checkSceneUpdateNeed(m->block);
if (_levelBlockProperties[m->block].flags & 7) {
_levelBlockProperties[m->block].flags--;
@@ -201,11 +201,11 @@ void EoBCoreEngine::killMonster(EoBMonsterInPlay *m, bool giveExperience) {
if (m->randItem) {
if (rollDice(1, 10, 0) == 1)
- setItemPosition((Item *)&_levelBlockProperties[m->block & 0x3ff].drawObjects, m->block, duplicateItem(m->randItem), pos);
+ setItemPosition((Item *)&_levelBlockProperties[m->block & 0x3FF].drawObjects, m->block, duplicateItem(m->randItem), pos);
}
if (m->fixedItem)
- setItemPosition((Item *)&_levelBlockProperties[m->block & 0x3ff].drawObjects, m->block, duplicateItem(m->fixedItem), pos);
+ setItemPosition((Item *)&_levelBlockProperties[m->block & 0x3FF].drawObjects, m->block, duplicateItem(m->fixedItem), pos);
if (giveExperience)
increasePartyExperience(_monsterProps[m->type].experience);
@@ -247,6 +247,9 @@ void EoBCoreEngine::updateAttackingMonsterFlags() {
m2 = m;
}
+ if (!m2)
+ return;
+
if (m2->type == 7)
setScriptFlags(4);
@@ -357,7 +360,7 @@ void EoBCoreEngine::flashMonsterShape(EoBMonsterInPlay *m) {
disableSysTimer(2);
_flashShapeTimer = 0;
drawScene(1);
- m->flags &= 0xfd;
+ m->flags &= 0xFD;
_flashShapeTimer = _system->getMillis() + _tickLength;
enableSysTimer(2);
@@ -536,7 +539,7 @@ void EoBCoreEngine::drawMonsters(int index) {
int h = shp[1];
x = x - (w >> 1) + (d->idleAnimState >> 4);
- y = y - h + (d->idleAnimState & 0x0f);
+ y = y - h + (d->idleAnimState & 0x0F);
drawMonsterShape(shp, x, y, f >= 0 ? 0 : 1, d->flags, palIndex);
@@ -551,8 +554,6 @@ void EoBCoreEngine::drawMonsters(int index) {
SpriteDecoration *dcr = &_monsterDecorations[(p->decorations[ii] - 1) * 6 + subFrame + shpIndex - 1];
- if (!dcr)
- continue;
if (!dcr->shp)
continue;
@@ -652,6 +653,8 @@ void EoBCoreEngine::drawFlyingObjects(int index) {
}
}
+ assert(shp);
+
shp = _screen->scaleShape(shp, sclValue);
if (rstFade) {
diff --git a/engines/kyra/sprites_lol.cpp b/engines/kyra/sprites_lol.cpp
index f4bae113c5..4d4d596bac 100644
--- a/engines/kyra/sprites_lol.cpp
+++ b/engines/kyra/sprites_lol.cpp
@@ -66,7 +66,7 @@ void LoLEngine::loadMonsterShapes(const char *file, int monsterIndex, int animTy
of[2] = _screen->makeShapeCopy(p, s + 2);
}
}
- _monsterAnimType[monsterIndex] = animType & 0xff;
+ _monsterAnimType[monsterIndex] = animType & 0xFF;
uint8 *palShape = _screen->makeShapeCopy(p, 16);
@@ -90,7 +90,7 @@ void LoLEngine::loadMonsterShapes(const char *file, int monsterIndex, int animTy
uint16 sz = MIN(_screen->getShapeSize(_monsterShapes[pos]) - 10, 256);
memset(tmpPal2, 0, 256);
memcpy(tmpPal2, _monsterShapes[pos] + 10, sz);
- memset(tmpPal3, 0xff, 256 * sizeof(uint16));
+ memset(tmpPal3, 0xFF, 256 * sizeof(uint16));
uint8 numCol = *tmpPal2;
for (int ii = 0; ii < numCol; ii++) {
@@ -104,7 +104,7 @@ void LoLEngine::loadMonsterShapes(const char *file, int monsterIndex, int animTy
memset(tmpPal2, 0, 256);
memcpy(tmpPal2, _monsterShapes[pos] + 10, sz);
for (int iii = 0; iii < numCol; iii++) {
- if (tmpPal3[iii] == 0xffff)
+ if (tmpPal3[iii] == 0xFFFF)
continue;
if (p[tmpPal3[iii] * 320 + ii + 1])
tmpPal2[1 + iii] = p[tmpPal3[iii] * 320 + ii + 1];
@@ -159,7 +159,7 @@ int LoLEngine::deleteMonstersFromBlock(int block) {
continue;
}
- LoLMonster *m = &_monsters[i & 0x7fff];
+ LoLMonster *m = &_monsters[i & 0x7FFF];
cnt++;
setMonsterMode(m, 14);
@@ -215,8 +215,8 @@ bool LoLEngine::updateMonsterAdjustBlocks(LoLMonster *monster) {
if (monster->properties->flags & 8)
return true;
- uint16 x1 = (monster->x & 0xff00) | 0x80;
- uint16 y1 = (monster->y & 0xff00) | 0x80;
+ uint16 x1 = (monster->x & 0xFF00) | 0x80;
+ uint16 y1 = (monster->y & 0xFF00) | 0x80;
int x2 = _partyPosX;
int y2 = _partyPosY;
@@ -242,7 +242,7 @@ bool LoLEngine::updateMonsterAdjustBlocks(LoLMonster *monster) {
return false;
for (int i = 0; i < 18; i++)
- _visibleBlocks[i] = &_levelBlockProperties[(monster->block + _dscBlockIndex[dir + i]) & 0x3ff];
+ _visibleBlocks[i] = &_levelBlockProperties[(monster->block + _dscBlockIndex[dir + i]) & 0x3FF];
int16 fx1 = 0;
int16 fx2 = 0;
@@ -277,8 +277,8 @@ void LoLEngine::placeMonster(LoLMonster *monster, uint16 x, uint16 y) {
_levelBlockProperties[monster->block].direction = 5;
checkSceneUpdateNeed(monster->block);
- // WORKAROUND: Some monsters in the white tower have sound id's of 0xff. This is definitely a bug, since the
- // last valid track number is 249 and there is no specific handling for 0xff. Nonetheless this wouldn't
+ // WORKAROUND: Some monsters in the white tower have sound id's of 0xFF. This is definitely a bug, since the
+ // last valid track number is 249 and there is no specific handling for 0xFF. Nonetheless this wouldn't
// cause problems in the original code, because it just so happens that the invalid memory address points
// to an entry in _ingameGMSoundIndex which just so happens to have a value of -1
if (monster->properties->sounds[0] == 0 || monster->properties->sounds[0] == 255 || cont == false)
@@ -364,7 +364,7 @@ int LoLEngine::checkBlockBeforeObjectPlacement(uint16 x, uint16 y, uint16 object
return 4;
if (x & 0x80) {
- if (((x & 0xff) + objectWidth) & 0xff00) {
+ if (((x & 0xFF) + objectWidth) & 0xFF00) {
xOffs = 1;
_objectLastDirection = 2;
x2 = x + objectWidth;
@@ -380,7 +380,7 @@ int LoLEngine::checkBlockBeforeObjectPlacement(uint16 x, uint16 y, uint16 object
flag = 1;
}
} else {
- if (((x & 0xff) - objectWidth) & 0xff00) {
+ if (((x & 0xFF) - objectWidth) & 0xFF00) {
xOffs = -1;
_objectLastDirection = 6;
x2 = x - objectWidth;
@@ -398,7 +398,7 @@ int LoLEngine::checkBlockBeforeObjectPlacement(uint16 x, uint16 y, uint16 object
}
if (y & 0x80) {
- if (((y & 0xff) + objectWidth) & 0xff00) {
+ if (((y & 0xFF) + objectWidth) & 0xFF00) {
yOffs = 1;
_objectLastDirection = 4;
y2 = y + objectWidth;
@@ -415,7 +415,7 @@ int LoLEngine::checkBlockBeforeObjectPlacement(uint16 x, uint16 y, uint16 object
flag = 0;
}
} else {
- if (((y & 0xff) - objectWidth) & 0xff00) {
+ if (((y & 0xFF) - objectWidth) & 0xFF00) {
yOffs = -1;
_objectLastDirection = 0;
y2 = y - objectWidth;
@@ -449,7 +449,7 @@ int LoLEngine::checkBlockBeforeObjectPlacement(uint16 x, uint16 y, uint16 object
int LoLEngine::testBlockPassability(int block, int x, int y, int objectWidth, int testFlag, int wallFlag) {
if (block == _currentBlock)
- testFlag &= 0xfffe;
+ testFlag &= 0xFFFE;
if (testFlag & 1) {
_monsterCurBlock = block;
@@ -463,7 +463,7 @@ int LoLEngine::testBlockPassability(int block, int x, int y, int objectWidth, in
uint16 obj = _levelBlockProperties[block].assignedObjects;
while (obj & 0x8000) {
- LoLMonster *monster = &_monsters[obj & 0x7fff];
+ LoLMonster *monster = &_monsters[obj & 0x7FFF];
if (monster->mode < 13) {
int r = checkDrawObjectSpace(x, y, monster->x, monster->y);
@@ -481,19 +481,8 @@ int LoLEngine::calcMonsterSkillLevel(int id, int a) {
const uint16 *c = getCharacterOrMonsterStats(id);
int r = (a << 8) / c[4];
- /*
- if (!(id & 0x8000))
- r = (r * _monsterModifiers[3 + _monsterDifficulty]) >> 8;
-
- id &= 0x7fff;
-
- if (_characters[id].skillLevels[1] <= 3)
- return r;
- else if (_characters[id].skillLevels[1] <= 7)
- return (r- (r >> 2));*/
-
if (id & 0x8000) {
- r = (r * _monsterModifiers[3 + _monsterDifficulty]) >> 8;
+ r = (r * _monsterModifiers2[3 + _monsterDifficulty]) >> 8;
} else {
if (_characters[id].skillLevels[1] > 7)
r = (r - (r >> 1));
@@ -514,7 +503,6 @@ int LoLEngine::checkBlockOccupiedByParty(int x, int y, int testFlag) {
void LoLEngine::drawBlockObjects(int blockArrayIndex) {
LevelBlockProperty *l = _visibleBlocks[blockArrayIndex];
uint16 s = l->assignedObjects;
- LoLObject *obj = findObject(s);
if (l->direction != _currentDirection) {
l->drawObjects = 0;
@@ -522,15 +510,14 @@ void LoLEngine::drawBlockObjects(int blockArrayIndex) {
while (s) {
reassignDrawObjects(_currentDirection, s, l, true);
- obj = findObject(s);
- s = obj->nextAssignedObject;
+ s = findObject(s)->nextAssignedObject;
}
}
s = l->drawObjects;
while (s) {
if (s & 0x8000) {
- s &= 0x7fff;
+ s &= 0x7FFF;
if (blockArrayIndex < 15)
drawMonster(s);
s = _monsters[s].nextDrawObject;
@@ -578,6 +565,7 @@ void LoLEngine::drawBlockObjects(int blockArrayIndex) {
case 2:
case 6:
flg |= 0x10;
+ // fall through
case 0:
case 4:
shpIndex = _flyingItemShapes[shpIndex].shapeLeft;
@@ -607,7 +595,7 @@ void LoLEngine::drawBlockObjects(int blockArrayIndex) {
void LoLEngine::drawMonster(uint16 id) {
LoLMonster *m = &_monsters[id];
int16 flg = _monsterDirFlags[(_currentDirection << 2) + m->facing];
- int curFrm = getMonsterCurFrame(m, flg & 0xffef);
+ int curFrm = getMonsterCurFrame(m, flg & 0xFFEF);
uint8 *shp = 0;
if (curFrm == -1) {
@@ -622,7 +610,7 @@ void LoLEngine::drawMonster(uint16 id) {
if (m->properties->flags & 0x800)
flg |= 0x20;
- uint8 *monsterPalette = d ? _monsterPalettes[(m->properties->shapeIndex << 4) + (curFrm & 0x0f)] + (shp[10] * (d - 1)) : 0;
+ uint8 *monsterPalette = d ? _monsterPalettes[(m->properties->shapeIndex << 4) + (curFrm & 0x0F)] + (shp[10] * (d - 1)) : 0;
uint8 *brightnessOverlay = drawItemOrMonster(shp, monsterPalette, m->x + _monsterShiftOffs[m->shiftStep << 1], m->y + _monsterShiftOffs[(m->shiftStep << 1) + 1], 0, 0, flg | 1, -1, flip);
for (int i = 0; i < 4; i++) {
@@ -644,16 +632,16 @@ void LoLEngine::drawMonster(uint16 id) {
int dW = _screen->getShapeScaledWidth(shp, _dmScaleW) >> 1;
int dH = _screen->getShapeScaledHeight(shp, _dmScaleH) >> 1;
- int bloodAmount = (m->mode == 13) ? (m->fightCurTick << 1) : (m->properties->hitPoints / (m->damageReceived & 0x7fff));
+ int bloodAmount = (m->mode == 13) ? (m->fightCurTick << 1) : (m->properties->hitPoints / (m->damageReceived & 0x7FFF));
shp = _gameShapes[6];
- int bloodType = m->properties->flags & 0xc000;
+ int bloodType = m->properties->flags & 0xC000;
if (bloodType == 0x4000)
- bloodType = _flags.use16ColorMode ? 0xbb : 63;
+ bloodType = _flags.use16ColorMode ? 0xBB : 63;
else if (bloodType == 0x8000)
bloodType = _flags.use16ColorMode ? 0x55 : 15;
- else if (bloodType == 0xc000)
+ else if (bloodType == 0xC000)
bloodType = _flags.use16ColorMode ? 0x33 : 74;
else
bloodType = 0;
@@ -708,7 +696,9 @@ int LoLEngine::getMonsterCurFrame(LoLMonster *m, uint16 dirFlags) {
break;
case 1:
// monsters whose outward appearance reflects the damage they have taken
- tmp = (m->properties->hitPoints * _monsterModifiers[_monsterDifficulty]) >> 8;
+ tmp = m->properties->hitPoints;
+ if (_flags.isTalkie)
+ tmp = (tmp * _monsterModifiers1[_monsterDifficulty]) >> 8;
if (m->hitPoints > (tmp >> 1))
tmp = 0;
else if (m->hitPoints > (tmp >> 2))
@@ -796,7 +786,7 @@ void LoLEngine::redrawSceneItem() {
int t = (i << 7) + 1;
while (s) {
if (s & 0x8000) {
- s = _monsters[s & 0x7fff].nextDrawObject;
+ s = _monsters[s & 0x7FFF].nextDrawObject;
} else {
LoLItem *item = &_itemsInPlay[s];
@@ -934,7 +924,7 @@ uint8 *LoLEngine::drawItemOrMonster(uint8 *shape, uint8 *monsterPalette, int x,
uint8 tmpOvl[16];
if (flags & 0x80) {
- flags &= 0xff7f;
+ flags &= 0xFF7F;
ovl2 = monsterPalette;
monsterPalette = 0;
} else {
@@ -969,7 +959,7 @@ uint8 *LoLEngine::drawItemOrMonster(uint8 *shape, uint8 *monsterPalette, int x,
if (_flags.use16ColorMode) {
if (_currentLevel != 22)
- flg &= 0xdfff;
+ flg &= 0xDFFF;
} else {
if (_currentLevel == 22) {
@@ -1059,7 +1049,7 @@ void LoLEngine::updateMonster(LoLMonster *monster) {
if ((monster->mode != 11) && (monster->mode != 14)) {
if (!(_rnd.getRandomNumber(255) & 3)) {
- monster->shiftStep = (monster->shiftStep + 1) & 0x0f;
+ monster->shiftStep = (monster->shiftStep + 1) & 0x0F;
checkSceneUpdateNeed(monster->block);
}
}
@@ -1127,7 +1117,7 @@ void LoLEngine::updateMonster(LoLMonster *monster) {
// first recovery phase after delivering an attack
if (++monster->fightCurTick > 2) {
setMonsterMode(monster, 5);
- monster->fightCurTick = (int8)((((8 << 8) / monster->properties->fightingStats[4]) * _monsterModifiers[6 + _monsterDifficulty]) >> 8);
+ monster->fightCurTick = (int8)((((8 << 8) / monster->properties->fightingStats[4]) * _monsterModifiers3[_monsterDifficulty]) >> 8);
}
checkSceneUpdateNeed(monster->block);
break;
@@ -1137,7 +1127,7 @@ void LoLEngine::updateMonster(LoLMonster *monster) {
chasePartyWithCloseAttacks(monster);
} else {
setMonsterMode(monster, 7);
- monster->flags &= 0xfff7;
+ monster->flags &= 0xFFF7;
}
break;
@@ -1164,13 +1154,13 @@ void LoLEngine::updateMonster(LoLMonster *monster) {
if (monster->damageReceived) {
if (monster->damageReceived & 0x8000)
- monster->damageReceived &= 0x7fff;
+ monster->damageReceived &= 0x7FFF;
else
monster->damageReceived = 0;
checkSceneUpdateNeed(monster->block);
}
- monster->flags &= 0xffef;
+ monster->flags &= 0xFFEF;
}
void LoLEngine::moveMonster(LoLMonster *monster) {
@@ -1239,13 +1229,13 @@ bool LoLEngine::chasePartyWithDistanceAttacks(LoLMonster *monster) {
int flyingObject = monster->properties->distWeapons[s];
- if (flyingObject & 0xc000) {
+ if (flyingObject & 0xC000) {
if (getBlockDistance(monster->block, _currentBlock) > 1) {
int type = flyingObject & 0x4000 ? 0 : 1;
- flyingObject = makeItem(flyingObject & 0x3fff, 0, 0);
+ flyingObject = makeItem(flyingObject & 0x3FFF, 0, 0);
if (flyingObject) {
- if (!launchObject(type, flyingObject, monster->x, monster->y, 12, dir << 1, -1, monster->id | 0x8000, 0x3f))
+ if (!launchObject(type, flyingObject, monster->x, monster->y, 12, dir << 1, -1, monster->id | 0x8000, 0x3F))
deleteItem(flyingObject);
}
}
@@ -1274,7 +1264,7 @@ bool LoLEngine::chasePartyWithDistanceAttacks(LoLMonster *monster) {
if (getBlockDistance(monster->block, _monsters[i].block) < 7)
setMonsterMode(monster, 7);
}
- _txt->printMessage(2, "%s", getLangString(0x401a));
+ _txt->printMessage(2, "%s", getLangString(0x401A));
} else if (flyingObject == 4) {
launchMagicViper();
@@ -1294,7 +1284,7 @@ bool LoLEngine::chasePartyWithDistanceAttacks(LoLMonster *monster) {
void LoLEngine::chasePartyWithCloseAttacks(LoLMonster *monster) {
if (!(monster->flags & 8)) {
- int dir = calcMonsterDirection(monster->x & 0xff00, monster->y & 0xff00, _partyPosX & 0xff00, _partyPosY & 0xff00);
+ int dir = calcMonsterDirection(monster->x & 0xFF00, monster->y & 0xFF00, _partyPosX & 0xFF00, _partyPosY & 0xFF00);
int x1 = _partyPosX;
int y1 = _partyPosY;
@@ -1396,11 +1386,11 @@ int LoLEngine::checkForPossibleDistanceAttack(uint16 monsterBlock, int direction
if (mdist > distance)
return 5;
- int dir = calcMonsterDirection(monsterBlock & 0x1f, monsterBlock >> 5, curBlock & 0x1f, curBlock >> 5);
+ int dir = calcMonsterDirection(monsterBlock & 0x1F, monsterBlock >> 5, curBlock & 0x1F, curBlock >> 5);
if ((dir & 1) || (dir != (direction << 1)))
return 5;
- if (((monsterBlock & 0x1f) != (curBlock & 0x1f)) && ((monsterBlock & 0xffe0) != (curBlock & 0xffe0)))
+ if (((monsterBlock & 0x1F) != (curBlock & 0x1F)) && ((monsterBlock & 0xFFE0) != (curBlock & 0xFFE0)))
return 5;
if (distance < 0)
@@ -1438,8 +1428,8 @@ void LoLEngine::getNextStepCoords(int16 srcX, int16 srcY, int &newX, int &newY,
static const int8 stepAdjustX[] = { 0, 32, 32, 32, 0, -32, -32, -32 };
static const int8 stepAdjustY[] = { -32, -32, 0, 32, 32, 32, 0, -32 };
- newX = (srcX + stepAdjustX[direction]) & 0x1fff;
- newY = (srcY + stepAdjustY[direction]) & 0x1fff;
+ newX = (srcX + stepAdjustX[direction]) & 0x1FFF;
+ newY = (srcY + stepAdjustY[direction]) & 0x1FFF;
}
void LoLEngine::alignMonsterToParty(LoLMonster *monster) {
@@ -1447,7 +1437,7 @@ void LoLEngine::alignMonsterToParty(LoLMonster *monster) {
uint16 mx = monster->x;
uint16 my = monster->y;
uint16 *pos = (mdir & 1) ? &my : &mx;
- bool centered = (*pos & 0x7f) == 0;
+ bool centered = (*pos & 0x7F) == 0;
bool posFlag = true;
if (monster->properties->maxWidth <= 63) {
@@ -1458,7 +1448,7 @@ void LoLEngine::alignMonsterToParty(LoLMonster *monster) {
r = true;
} else {
uint16 id = _levelBlockProperties[monster->block].assignedObjects;
- id = (id & 0x8000) ? (id & 0x7fff) : 0xffff;
+ id = (id & 0x8000) ? (id & 0x7FFF) : 0xFFFF;
if (id != monster->id) {
r = true;
@@ -1466,8 +1456,8 @@ void LoLEngine::alignMonsterToParty(LoLMonster *monster) {
for (int i = 0; i < 3; i++) {
mdir = (mdir + 1) & 3;
id = _levelBlockProperties[calcNewBlockPosition(monster->block, mdir)].assignedObjects;
- id = (id & 0x8000) ? (id & 0x7fff) : 0xffff;
- if (id != 0xffff) {
+ id = (id & 0x8000) ? (id & 0x7FFF) : 0xFFFF;
+ if (id != 0xFFFF) {
r = true;
break;
}
diff --git a/engines/kyra/sprites_rpg.cpp b/engines/kyra/sprites_rpg.cpp
index 0c4fcb09ab..9c08bc8dd6 100644
--- a/engines/kyra/sprites_rpg.cpp
+++ b/engines/kyra/sprites_rpg.cpp
@@ -27,9 +27,9 @@
namespace Kyra {
int KyraRpgEngine::getBlockDistance(uint16 block1, uint16 block2) {
- int b1x = block1 & 0x1f;
+ int b1x = block1 & 0x1F;
int b1y = block1 >> 5;
- int b2x = block2 & 0x1f;
+ int b2x = block2 & 0x1F;
int b2y = block2 >> 5;
uint8 dy = ABS(b2y - b1y);
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index 00dc4f9e13..bac31f0a3e 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -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"
@@ -38,7 +39,7 @@
namespace Kyra {
-#define RESFILE_VERSION 83
+#define RESFILE_VERSION 84
namespace {
bool checkKyraDat(Common::SeekableReadStream *file) {
@@ -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
@@ -289,7 +290,7 @@ void StaticResource::deinit() {
}
const char *const *StaticResource::loadStrings(int id, int &strings) {
- return (const char * const *)getData(id, kStringList, strings);
+ return (const char *const *)getData(id, kStringList, strings);
}
const uint8 *StaticResource::loadRawData(int id, int &size) {
@@ -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;
@@ -777,22 +778,6 @@ void KyraEngine_LoK::initStaticResource() {
_storyStrings = _staticres->loadStrings(k1PC98StoryStrings, _storyStringsSize);
- int size1, size2;
- const char *const *soundfiles1 = _staticres->loadStrings(k1AudioTracks, size1);
- const char *const *soundfiles2 = _staticres->loadStrings(k1AudioTracks2, size2);
- _soundFilesSize = size1 + size2;
- if (_soundFilesSize) {
- delete[] _soundFiles;
- const char **soundfiles = new const char*[_soundFilesSize];
- for (int i = 0; i < _soundFilesSize; i++)
- soundfiles[i] = (i < size1) ? soundfiles1[i] : soundfiles2[i - size1];
- _soundFiles = soundfiles;
- }
- _soundFilesIntro = _staticres->loadStrings(k1AudioTracksIntro, _soundFilesIntroSize);
- _cdaTrackTable = (const int32 *)_staticres->loadRawData(k1TownsCDATable, _cdaTrackTableSize);
-
- // copied static res
-
// room list
const Room *tempRoomList = _staticres->loadRoomTable(k1RoomList, _roomTableSize);
@@ -819,34 +804,40 @@ void KyraEngine_LoK::initStaticResource() {
_staticres->unloadId(k1DefaultShapes);
}
- // audio data tables
- static const char *const tIntro98[] = { "INTRO%d.DAT" };
- static const char *const tIngame98[] = { "KYRAM%d.DAT" };
+ // audio resource assignment
+ int size1, size2;
+ const char *const *soundfiles1 = _staticres->loadStrings(k1AudioTracks, size1);
+ const char *const *soundfiles2 = _staticres->loadStrings(k1AudioTracks2, size2);
+ int soundFilesSize = size1 + size2;
+ int soundFilesIntroSize = 0;
+ int cdaTableSize = 0;
+ const char **soundFiles = 0;
+
+ if (soundFilesSize) {
+ soundFiles = new const char*[soundFilesSize];
+ for (int i = 0; i < soundFilesSize; i++)
+ soundFiles[i] = (i < size1) ? soundfiles1[i] : soundfiles2[i - size1];
+ }
+ const char *const *soundFilesIntro = _staticres->loadStrings(k1AudioTracksIntro, temp);
+ const int32 *cdaTable = (const int32 *)_staticres->loadRawData(k1TownsCDATable, cdaTableSize);
// FIXME: It seems Kyra1 MAC CD includes AdLib and MIDI music and sfx, thus we enable
// support for those for now. (Based on patch #2767489 "Support for Mac Kyrandia 1 CD" by satz).
- memset(_soundData, 0, sizeof(_soundData));
if (_flags.platform == Common::kPlatformPC || _flags.platform == Common::kPlatformMacintosh) {
- _soundData[0].fileList = _soundFilesIntro;
- _soundData[0].fileListLen = _soundFilesIntroSize;
- _soundData[1].fileList = _soundFiles;
- _soundData[1].fileListLen = _soundFilesSize;
+ SoundResourceInfo_PC resInfoIntro(soundFilesIntro, soundFilesIntroSize);
+ SoundResourceInfo_PC resInfoIngame(soundFiles, soundFilesSize);
+ _sound->initAudioResourceInfo(kMusicIntro, &resInfoIntro);
+ _sound->initAudioResourceInfo(kMusicIngame, &resInfoIngame);
} else if (_flags.platform == Common::kPlatformFMTowns) {
- _soundData[0].fileList = _soundFiles;
- _soundData[0].fileListLen = _soundFilesSize;
- _soundData[0].cdaTracks = _cdaTrackTable;
- _soundData[0].cdaNumTracks = _cdaTrackTableSize;
- _soundData[1].fileList = _soundFiles;
- _soundData[1].fileListLen = _soundFilesSize;
- _soundData[1].cdaTracks = _cdaTrackTable;
- _soundData[1].cdaNumTracks = _cdaTrackTableSize;
+ SoundResourceInfo_Towns resInfoIntro(soundFiles, soundFilesSize, cdaTable, cdaTableSize);
+ SoundResourceInfo_Towns resInfoIngame(soundFiles, soundFilesSize, cdaTable, cdaTableSize);
+ _sound->initAudioResourceInfo(kMusicIntro, &resInfoIntro);
+ _sound->initAudioResourceInfo(kMusicIngame, &resInfoIngame);
} else if (_flags.platform == Common::kPlatformPC98) {
- _soundData[0].fileList = tIntro98;
- _soundData[0].fileListLen = 1;
- _soundData[0].extraOffset = -1;
- _soundData[1].fileList = tIngame98;
- _soundData[1].fileListLen = 1;
- _soundData[1].extraOffset = -1;
+ SoundResourceInfo_PC98 resInfoIntro("INTRO%d.DAT");
+ SoundResourceInfo_PC98 resInfoIngame("KYRAM%d.DAT");
+ _sound->initAudioResourceInfo(kMusicIntro, &resInfoIntro);
+ _sound->initAudioResourceInfo(kMusicIngame, &resInfoIngame);
}
}
@@ -992,11 +983,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,131 +996,29 @@ 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" };
- static const char *const fmtMusicFileListIngame[] = { "km%02d.twn" };
-
- static const char *const pc98MusicFileListIntro[] = { "intro%d.86" };
- static const char *const pc98MusicFileListFinale[] = { "finale%d.86" };
- static const char *const pc98MusicFileListIngame[] = { "km%02d.86" };
-
- memset(_soundData, 0, sizeof(_soundData));
if (_flags.platform == Common::kPlatformPC) {
- _soundData[0].fileList = _musicFileListIntro;
- _soundData[0].fileListLen = _musicFileListIntroSize;
- _soundData[1].fileList = _musicFileListIngame;
- _soundData[1].fileListLen = _musicFileListIngameSize;
- _soundData[2].fileList = _musicFileListFinale;
- _soundData[2].fileListLen = _musicFileListIntroSize;
+ SoundResourceInfo_PC resInfoIntro(_musicFileListIntro, _musicFileListIntroSize);
+ SoundResourceInfo_PC resInfoIngame(_musicFileListIngame, _musicFileListIngameSize);
+ SoundResourceInfo_PC resInfoFinale(_musicFileListFinale, _musicFileListFinaleSize);
+ _sound->initAudioResourceInfo(kMusicIntro, &resInfoIntro);
+ _sound->initAudioResourceInfo(kMusicIngame, &resInfoIngame);
+ _sound->initAudioResourceInfo(kMusicFinale, &resInfoFinale);
} else if (_flags.platform == Common::kPlatformFMTowns) {
- _soundData[0].fileList = fmtMusicFileListIntro;
- _soundData[0].fileListLen = 1;
- _soundData[0].cdaTracks = _cdaTrackTableIntro;
- _soundData[0].cdaNumTracks = _cdaTrackTableIntroSize >> 1;
- _soundData[1].fileList = fmtMusicFileListIngame;
- _soundData[1].fileListLen = 1;
- _soundData[1].cdaTracks = _cdaTrackTableIngame;
- _soundData[1].cdaNumTracks = _cdaTrackTableIngameSize >> 1;
- _soundData[2].fileList = fmtMusicFileListFinale;
- _soundData[2].fileListLen = 1;
- _soundData[2].cdaTracks = _cdaTrackTableFinale;
- _soundData[2].cdaNumTracks = _cdaTrackTableFinaleSize >> 1;
+ SoundResourceInfo_TownsPC98V2 resInfoIntro(0, 0, "intro%d.twn", (const uint16*)_cdaTrackTableIntro, _cdaTrackTableIntroSize >> 1);
+ SoundResourceInfo_TownsPC98V2 resInfoIngame(0, 0, "km%02d.twn", (const uint16*)_cdaTrackTableIngame, _cdaTrackTableIngameSize >> 1);
+ SoundResourceInfo_TownsPC98V2 resInfoFinale(0, 0, "finale%d.twn", (const uint16*)_cdaTrackTableFinale, _cdaTrackTableFinaleSize >> 1);
+ _sound->initAudioResourceInfo(kMusicIntro, &resInfoIntro);
+ _sound->initAudioResourceInfo(kMusicIngame, &resInfoIngame);
+ _sound->initAudioResourceInfo(kMusicFinale, &resInfoFinale);
} else if (_flags.platform == Common::kPlatformPC98) {
- _soundData[0].fileList = pc98MusicFileListIntro;
- _soundData[0].fileListLen = 1;
- _soundData[1].fileList = pc98MusicFileListIngame;
- _soundData[1].fileListLen = 1;
- _soundData[2].fileList = pc98MusicFileListFinale;
- _soundData[2].fileListLen = 1;
+ SoundResourceInfo_TownsPC98V2 resInfoIntro(0, 0, "intro%d.86", 0, 0);
+ SoundResourceInfo_TownsPC98V2 resInfoIngame(0, 0, "km%02d.86", 0, 0);
+ SoundResourceInfo_TownsPC98V2 resInfoFinale(0, 0, "finale%d.86", 0, 0);
+ _sound->initAudioResourceInfo(kMusicIntro, &resInfoIntro);
+ _sound->initAudioResourceInfo(kMusicIngame, &resInfoIngame);
+ _sound->initAudioResourceInfo(kMusicFinale, &resInfoFinale);
}
-
- // 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() {
@@ -1224,13 +1109,13 @@ const uint8 KyraEngine_LoK::_itemPosY[] = {
};
void GUI_LoK::initStaticResource() {
- GUI_V1_BUTTON(_scrollUpButton, 0x12, 1, 1, 1, 0x483, 0, 0, 0, 0x18, 0x0f, 0);
- GUI_V1_BUTTON(_scrollDownButton, 0x13, 1, 1, 1, 0x483, 0, 0, 0, 0x18, 0x0f, 0);
+ GUI_V1_BUTTON(_scrollUpButton, 0x12, 1, 1, 1, 0x483, 0, 0, 0, 0x18, 0x0F, 0);
+ GUI_V1_BUTTON(_scrollDownButton, 0x13, 1, 1, 1, 0x483, 0, 0, 0, 0x18, 0x0F, 0);
- GUI_V1_BUTTON(_menuButtonData[0], 0x0c, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
- GUI_V1_BUTTON(_menuButtonData[1], 0x0d, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
- GUI_V1_BUTTON(_menuButtonData[2], 0x0e, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
- GUI_V1_BUTTON(_menuButtonData[3], 0x0f, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
+ GUI_V1_BUTTON(_menuButtonData[0], 0x0C, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
+ GUI_V1_BUTTON(_menuButtonData[1], 0x0D, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
+ GUI_V1_BUTTON(_menuButtonData[2], 0x0E, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
+ GUI_V1_BUTTON(_menuButtonData[3], 0x0F, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
GUI_V1_BUTTON(_menuButtonData[4], 0x10, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
GUI_V1_BUTTON(_menuButtonData[5], 0x11, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
@@ -1412,8 +1297,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",
@@ -1631,7 +1514,7 @@ void KyraEngine_HoF::initInventoryButtonList() {
_inventoryButtons[i].buttonCallback = inventoryCallback;
_buttonList = &_inventoryButtons[0];
- for (size_t i = 1; i < 15; ++i)
+ for (int i = 1; i < 15; ++i)
_buttonList = _gui->addButtonToList(_buttonList, &_inventoryButtons[i]);
}
diff --git a/engines/kyra/staticres_eob.cpp b/engines/kyra/staticres_eob.cpp
index 7a5012f117..e0a2862dea 100644
--- a/engines/kyra/staticres_eob.cpp
+++ b/engines/kyra/staticres_eob.cpp
@@ -220,44 +220,44 @@ const uint8 EoBCoreEngine::_wallOfForceShapeDefs[] = {
0x0C, 0x00, 0x05, 0x10
};
-const int16 EoBCoreEngine::_buttonList1[] = {
+const uint8 EoBCoreEngine::_buttonList1[] = {
58, 0, 1, 2, 3, 90, 91, 4, 5, 6, 7, 8, 9, 10, 11, 12, 78, 79, 13, 14, 15, 16,
- 80, 81, 17, 18, 19, 20, 82, 83, 49, 50, 51, 52, 53, 54, 56, 57, -1
+ 80, 81, 17, 18, 19, 20, 82, 83, 49, 50, 51, 52, 53, 54, 56, 57, 255
};
-const int16 EoBCoreEngine::_buttonList2[] = {
+const uint8 EoBCoreEngine::_buttonList2[] = {
58, 61, 62, 63, 64, 65, 93, 94, 66, 67, 68, 69, 70, 71, 76, 77, 88, 0, 1, 2, 3,
90, 91, 4, 5, 6, 7, 8, 9, 10, 11, 12, 78, 79, 13, 14, 15, 16, 80, 81, 17, 18,
- 19, 20, 82, 83, 49, 50, 51, 52, 53, 54, 56, 57, -1
+ 19, 20, 82, 83, 49, 50, 51, 52, 53, 54, 56, 57, 255
};
-const int16 EoBCoreEngine::_buttonList3[] = {
+const uint8 EoBCoreEngine::_buttonList3[] = {
58, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 84, 85, 46, 47, 48, 60, 59, 92, 4, 5, 6, 7, 8, 49, 50,
- 51, 52, 53, 54, 56, 57, -1
+ 51, 52, 53, 54, 56, 57, 255
};
-const int16 EoBCoreEngine::_buttonList4[] = {
- 58, 47, 48, 60, 59, 92, 4, 5, 6, 7, 8, 49, 50, 51, 52, 53, 54, 56, 57, -1
+const uint8 EoBCoreEngine::_buttonList4[] = {
+ 58, 47, 48, 60, 59, 92, 4, 5, 6, 7, 8, 49, 50, 51, 52, 53, 54, 56, 57, 255
};
-const int16 EoBCoreEngine::_buttonList5[] = {
+const uint8 EoBCoreEngine::_buttonList5[] = {
58, 61, 62, 63, 64, 65, 93, 66, 67, 68, 69, 70, 71, 88, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 84,
- 85, 46, 47, 48, 60, 59, 92, 4, 5, 6, 7, 8, 49, 50, 51, 52, 53, 54, 56, 57, -1
+ 85, 46, 47, 48, 60, 59, 92, 4, 5, 6, 7, 8, 49, 50, 51, 52, 53, 54, 56, 57, 255
};
-const int16 EoBCoreEngine::_buttonList6[] = {
+const uint8 EoBCoreEngine::_buttonList6[] = {
58, 61, 62, 63, 64, 65, 93, 66, 67, 68, 69, 70, 71, 88, 46, 47, 48, 60, 59, 92,
- 4, 5, 6, 7, 8, 49, 50, 51, 52, 53, 54, 56, 57, -1
+ 4, 5, 6, 7, 8, 49, 50, 51, 52, 53, 54, 56, 57, 255
};
-const int16 EoBCoreEngine::_buttonList7[] = {
- 17, 18, 19, 20, 82, 83, 55, -1
+const uint8 EoBCoreEngine::_buttonList7[] = {
+ 17, 18, 19, 20, 82, 83, 55, 255
};
-const int16 EoBCoreEngine::_buttonList8[] = {
- 72, 73, 74, 75, 86, 87, 89, -1
+const uint8 EoBCoreEngine::_buttonList8[] = {
+ 72, 73, 74, 75, 86, 87, 89, 255
};
const uint8 EoBCoreEngine::_clock2Timers[] = {
@@ -465,13 +465,13 @@ void EoBCoreEngine::initStaticResource() {
// EOB I doesn't have load and save menus, because there is only one single
// save slot. Instead of emulating this we provide a menu similiar to EOB II.
- static const char *saveLoadStrings[3][4] = {
+ static const char *const saveLoadStrings[3][4] = {
{ "Cancel", "Empty Slot", "Save Game", "Load Game" },
{ "Abbr.", "Leerer Slot", "Speichern", " Laden" },
{ 0, 0, 0, 0 }
};
- static const char *errorSlotEmptyString[3] = {
+ static const char *const errorSlotEmptyString[3] = {
"There is no game\rsaved in that slot!",
"Hier ist noch kein\rSpiel gespeichert!",
0
@@ -1096,7 +1096,7 @@ void EoBEngine::initStaticResource() {
p->dmgModifierEvade = *ps++;
}
- static const char *errorSlotNoNameString[3] = {
+ static const char *const errorSlotNoNameString[3] = {
" You must specify\r a name for your\r save game!",
" Spielstaende mues-\r sen einen Namen\r haben!",
0
@@ -1118,10 +1118,10 @@ void EoBEngine::initSpells() {
{ 0x0000, 0x000000, 0x00 }, // dummy
{ 0x0033, 0x000001, 0x00 }, // armor
{ 0x0100, 0x000000, 0x21 }, // burning hands
- { 0x004c, 0x000002, 0x00 }, // detect magic
+ { 0x004C, 0x000002, 0x00 }, // detect magic
{ 0x0100, 0x000000, 0x01 }, // magic missile
{ 0x0000, 0x000000, 0x00 }, // dummy
- { 0x008b, 0x000008, 0x00 }, // shield
+ { 0x008B, 0x000008, 0x00 }, // shield
{ 0x0488, 0x000000, 0x03 }, // shocking grasp
{ 0x0021, 0x000040, 0x00 }, // invisibility
{ 0x0000, 0x000000, 0x00 }, // dummy
@@ -1141,10 +1141,10 @@ void EoBEngine::initSpells() {
{ 0x0000, 0x000000, 0x00 }, // CLOUD KILL
{ 0x0100, 0x000000, 0x41 }, // cone of cold
{ 0x0100, 0x000000, 0x00 }, // hold monster
- { 0x005c, 0x000400, 0x00 }, // bless
+ { 0x005C, 0x000400, 0x00 }, // bless
{ 0x0020, 0x000000, 0x00 }, // cure light wounds
{ 0x0100, 0x000000, 0x01 }, // cause light wounds
- { 0x004c, 0x000002, 0x00 }, // detect magic
+ { 0x004C, 0x000002, 0x00 }, // detect magic
{ 0x0029, 0x000800, 0x00 }, // prot from evil
{ 0x0039, 0x000000, 0x00 }, // aid
{ 0x2408, 0x000000, 0x21 }, // flame blade
@@ -1153,7 +1153,7 @@ void EoBEngine::initSpells() {
{ 0x0040, 0x000000, 0x00 }, // create food
{ 0x1000, 0x000000, 0x00 }, // dispel magic
{ 0x0099, 0x004000, 0x00 }, // magical vestment
- { 0x004c, 0x008000, 0x00 }, // prayer
+ { 0x004C, 0x008000, 0x00 }, // prayer
{ 0x0040, 0x000000, 0x00 }, // remove paralysis
{ 0x0020, 0x000000, 0x00 }, // cure serious
{ 0x0100, 0x000000, 0x01 }, // cause serious
@@ -1187,7 +1187,7 @@ void EoBEngine::initSpells() {
const KyraRpgGUISettings EoBEngine::_guiSettingsVGA = {
{ 9, 15, 95, 9, 7, { 285, 139 }, { 189, 162 }, { 31, 31 } },
- { 135, 130, 132, 133, 133, 17, 23, 20, 184, 177, 180, 184, 177, 180 }
+ { 135, 130, 132, 133, 133, 17, 23, 20, 184, 177, 180, 184, 177, 180 }
};
const KyraRpgGUISettings EoBEngine::_guiSettingsEGA = {
@@ -1210,7 +1210,7 @@ void DarkMoonEngine::initStaticResource() {
_animIntro[i] = _staticres->loadEoB2SeqData(kEob2IntroAnimData00 + i, temp);
_shapesIntro = new const DarkMoonShapeDef*[13];
- memset(_shapesIntro, 0, sizeof(DarkMoonShapeDef*) * 13);
+ memset(_shapesIntro, 0, sizeof(DarkMoonShapeDef *) * 13);
_shapesIntro[0] = _staticres->loadEoB2ShapeData(kEoB2IntroShapes00, temp);
_shapesIntro[1] = _staticres->loadEoB2ShapeData(kEoB2IntroShapes01, temp);
_shapesIntro[4] = _staticres->loadEoB2ShapeData(kEoB2IntroShapes04, temp);
@@ -1225,7 +1225,7 @@ void DarkMoonEngine::initStaticResource() {
_animFinale[i] = _staticres->loadEoB2SeqData(kEob2FinaleAnimData00 + i, temp);
_shapesFinale = new const DarkMoonShapeDef*[13];
- memset(_shapesFinale, 0, sizeof(DarkMoonShapeDef*) * 13);
+ memset(_shapesFinale, 0, sizeof(DarkMoonShapeDef *) * 13);
_shapesFinale[0] = _staticres->loadEoB2ShapeData(kEoB2FinaleShapes00, temp);
_shapesFinale[3] = _staticres->loadEoB2ShapeData(kEoB2FinaleShapes03, temp);
_shapesFinale[7] = _staticres->loadEoB2ShapeData(kEoB2FinaleShapes07, temp);
@@ -1249,7 +1249,7 @@ void DarkMoonEngine::initStaticResource() {
_wallOfForceDsNumH = _staticres->loadRawData(kEoB2WallOfForceNumH, temp);
_wallOfForceShpId = _staticres->loadRawData(kEoB2WallOfForceShpId, temp);
- static const char *errorSlotNoNameString[3] = {
+ static const char *const errorSlotNoNameString[3] = {
" You must specify\r a name for your\r save game!",
" Spielst[nde m]ssen\r einen Namen haben!",
0
@@ -1258,7 +1258,7 @@ void DarkMoonEngine::initStaticResource() {
_errorSlotNoNameString = errorSlotNoNameString[(_flags.lang == Common::EN_ANY) ? 0 : ((_flags.lang == Common::DE_DEU) ? 1 : 2)];
// ScummVM specific
- static const char *transferStringsScummVM[3][5] = {
+ static const char *const transferStringsScummVM[3][5] = {
{
"\r We cannot find any EOB save game\r file. Please make sure that the\r save game file with the party\r you wish to transfer is located\r in your ScummVM save game\r directory. If you have set up\r multiple save directories you\r have to copy the EOB save file\r into your EOB II save directory.\r Do you wish to try again?",
"Game ID",
@@ -1300,7 +1300,7 @@ void DarkMoonEngine::initSpells() {
}
}
-const char *DarkMoonEngine::_palFilesIntroVGA[] = {
+const char *const DarkMoonEngine::_palFilesIntroVGA[] = {
"PALETTE1.PAL",
"PALETTE3.PAL",
"PALETTE2.PAL",
@@ -1308,7 +1308,7 @@ const char *DarkMoonEngine::_palFilesIntroVGA[] = {
0
};
-const char *DarkMoonEngine::_palFilesIntroEGA[] = {
+const char *const DarkMoonEngine::_palFilesIntroEGA[] = {
"PALETTE0.PAL",
"PALETTE3.PAL",
"PALETTE2.PAL",
@@ -1316,7 +1316,7 @@ const char *DarkMoonEngine::_palFilesIntroEGA[] = {
0
};
-const char *DarkMoonEngine::_palFilesFinaleVGA[] = {
+const char *const DarkMoonEngine::_palFilesFinaleVGA[] = {
"FINALE_0.PAL",
"FINALE_0.PAL",
"FINALE_1.PAL",
@@ -1329,7 +1329,7 @@ const char *DarkMoonEngine::_palFilesFinaleVGA[] = {
0
};
-const char *DarkMoonEngine::_palFilesFinaleEGA[] = {
+const char *const DarkMoonEngine::_palFilesFinaleEGA[] = {
"FINALE_0.PAL",
"FINALE_0.PAL",
"FINALE_1.PAL",
diff --git a/engines/kyra/staticres_lol.cpp b/engines/kyra/staticres_lol.cpp
index 63bc7fa99b..a1c5ff340c 100644
--- a/engines/kyra/staticres_lol.cpp
+++ b/engines/kyra/staticres_lol.cpp
@@ -24,6 +24,7 @@
#include "kyra/lol.h"
#include "kyra/screen_lol.h"
#include "kyra/gui_lol.h"
+#include "kyra/sound_intern.h"
#ifdef ENABLE_LOL
@@ -213,30 +214,39 @@ void StaticResource::freeButtonDefs(void *&ptr, int &size) {
}
void LoLEngine::initStaticResource() {
- // assign music data
- static const char *const pcMusicFileListIntro[] = { "LOREINTR" };
- static const char *const pcMusicFileListFinale[] = { "LOREFINL" };
- static const char *const pcMusicFileListIngame[] = { "LORE%02d%c" };
-
- static const char *const pc98MusicFileListIntro[] = { 0, "lore84.86", "lore82.86", 0, 0, 0, "lore83.86", "lore81.86" };
- static const char *const pc98MusicFileListFinale[] = { 0, 0, "lore85.86", "lore86.86", "lore87.86" };
- static const char *const pc98MusicFileListIngame[] = { "lore%02d.86" };
-
- memset(_soundData, 0, sizeof(_soundData));
+ // assign music resource data.
if (_flags.platform == Common::kPlatformPC) {
- _soundData[0].fileList = pcMusicFileListIntro;
- _soundData[0].fileListLen = ARRAYSIZE(pcMusicFileListIntro);
- _soundData[1].fileList = pcMusicFileListIngame;
- _soundData[1].fileListLen = ARRAYSIZE(pcMusicFileListIngame);
- _soundData[2].fileList = pcMusicFileListFinale;
- _soundData[2].fileListLen = ARRAYSIZE(pcMusicFileListFinale);
+ if (_flags.isDemo) {
+ static const char *const file[] = { "LOREDEMO" };
+ SoundResourceInfo_PC resInfoDemo(file, ARRAYSIZE(file));
+ _sound->initAudioResourceInfo(kMusicIntro, &resInfoDemo);
+ } else {
+ static const char *const intro[] = { "LOREINTR" };
+ static const char *const finale[] = { "LOREFINL" };
+ SoundResourceInfo_PC resInfoIntro(intro, ARRAYSIZE(intro));
+ SoundResourceInfo_PC resInfoFinale(finale, ARRAYSIZE(finale));
+ _sound->initAudioResourceInfo(kMusicIntro, &resInfoIntro);
+ // In game music file handling is different, thus does not need a file list.
+ _sound->initAudioResourceInfo(kMusicFinale, &resInfoFinale);
+ }
} else if (_flags.platform == Common::kPlatformPC98) {
- _soundData[0].fileList = pc98MusicFileListIntro;
- _soundData[0].fileListLen = ARRAYSIZE(pc98MusicFileListIntro);
- _soundData[1].fileList = pc98MusicFileListIngame;
- _soundData[1].fileListLen = ARRAYSIZE(pc98MusicFileListIngame);
- _soundData[2].fileList = pc98MusicFileListFinale;
- _soundData[2].fileListLen = ARRAYSIZE(pc98MusicFileListFinale);
+ static const char *const fileListIntro[] = { 0, "lore84.86", "lore82.86", 0, 0, 0, "lore83.86", "lore81.86" };
+ static const char *const fileListFinale[] = { 0, 0, "lore85.86", "lore86.86", "lore87.86" };
+ SoundResourceInfo_TownsPC98V2 resInfoIntro(fileListIntro, ARRAYSIZE(fileListIntro), 0, 0, 0);
+ SoundResourceInfo_TownsPC98V2 resInfoIngame(0, 0, "lore%02d.86", 0, 0);
+ SoundResourceInfo_TownsPC98V2 resInfoFinale(fileListFinale, ARRAYSIZE(fileListFinale), 0, 0, 0);
+ _sound->initAudioResourceInfo(kMusicIntro, &resInfoIntro);
+ _sound->initAudioResourceInfo(kMusicIngame, &resInfoIngame);
+ _sound->initAudioResourceInfo(kMusicFinale, &resInfoFinale);
+ } else if (_flags.platform == Common::kPlatformFMTowns) {
+ static const char *const fileListIntro[] = { 0, "lore84.twn", "lore82.twn", 0, 0, 0, "lore83.twn", "lore81.twn" };
+ static const char *const fileListFinale[] = { 0, 0, "lore85.twn", "lore86.twn", "lore87.twn" };
+ SoundResourceInfo_TownsPC98V2 resInfoIntro(fileListIntro, ARRAYSIZE(fileListIntro), 0, 0, 0);
+ SoundResourceInfo_TownsPC98V2 resInfoIngame(0, 0, "lore%02d.twn", 0, 0);
+ SoundResourceInfo_TownsPC98V2 resInfoFinale(fileListFinale, ARRAYSIZE(fileListFinale), 0, 0, 0);
+ _sound->initAudioResourceInfo(kMusicIntro, &resInfoIntro);
+ _sound->initAudioResourceInfo(kMusicIngame, &resInfoIngame);
+ _sound->initAudioResourceInfo(kMusicFinale, &resInfoFinale);
}
if (_flags.isDemo)
@@ -260,7 +270,10 @@ void LoLEngine::initStaticResource() {
_charDefsKieran = _staticres->loadRawDataBe16(kLoLCharDefsKieran, tempSize);
_charDefsAkshel = _staticres->loadRawDataBe16(kLoLCharDefsAkshel, tempSize);
_expRequirements = (const int32 *)_staticres->loadRawDataBe32(kLoLExpRequirements, tempSize);
- _monsterModifiers = _staticres->loadRawDataBe16(kLoLMonsterModifiers, tempSize);
+ _monsterModifiers1 = _staticres->loadRawDataBe16(kLoLMonsterModifiers1, tempSize);
+ _monsterModifiers2 = _staticres->loadRawDataBe16(kLoLMonsterModifiers2, tempSize);
+ _monsterModifiers3 = _staticres->loadRawDataBe16(kLoLMonsterModifiers3, tempSize);
+ _monsterModifiers4 = _staticres->loadRawDataBe16(kLoLMonsterModifiers4, tempSize);
_monsterShiftOffs = (const int8 *)_staticres->loadRawData(kLoLMonsterShiftOffsets, tempSize);
_monsterDirFlags = _staticres->loadRawData(kLoLMonsterDirFlags, tempSize);
_monsterScaleX = _staticres->loadRawData(kLoLMonsterScaleX, tempSize);
@@ -303,14 +316,14 @@ void LoLEngine::initStaticResource() {
}
_buttonData = _staticres->loadButtonDefs(kLoLButtonDefs, tempSize);
- _buttonList1 = (const int16 *)_staticres->loadRawDataBe16(kLoLButtonList1, tempSize);
- _buttonList2 = (const int16 *)_staticres->loadRawDataBe16(kLoLButtonList2, tempSize);
- _buttonList3 = (const int16 *)_staticres->loadRawDataBe16(kLoLButtonList3, tempSize);
- _buttonList4 = (const int16 *)_staticres->loadRawDataBe16(kLoLButtonList4, tempSize);
- _buttonList5 = (const int16 *)_staticres->loadRawDataBe16(kLoLButtonList5, tempSize);
- _buttonList6 = (const int16 *)_staticres->loadRawDataBe16(kLoLButtonList6, tempSize);
- _buttonList7 = (const int16 *)_staticres->loadRawDataBe16(kLoLButtonList7, tempSize);
- _buttonList8 = (const int16 *)_staticres->loadRawDataBe16(kLoLButtonList8, tempSize);
+ _buttonList1 = _staticres->loadRawData(kLoLButtonList1, tempSize);
+ _buttonList2 = _staticres->loadRawData(kLoLButtonList2, tempSize);
+ _buttonList3 = _staticres->loadRawData(kLoLButtonList3, tempSize);
+ _buttonList4 = _staticres->loadRawData(kLoLButtonList4, tempSize);
+ _buttonList5 = _staticres->loadRawData(kLoLButtonList5, tempSize);
+ _buttonList6 = _staticres->loadRawData(kLoLButtonList6, tempSize);
+ _buttonList7 = _staticres->loadRawData(kLoLButtonList7, tempSize);
+ _buttonList8 = _staticres->loadRawData(kLoLButtonList8, tempSize);
_autoMapStrings = _staticres->loadRawDataBe16(kLoLMapStringId, tempSize);
@@ -457,11 +470,11 @@ void LoLEngine::initStaticResource() {
}
void GUI_LoL::initStaticData() {
- GUI_V2_BUTTON(_scrollUpButton, 20, 96, 0, 1, 1, 1, 0x4487, 0, 0, 0, 25, 16, 0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x01, 0);
- GUI_V2_BUTTON(_scrollDownButton, 21, 98, 0, 1, 1, 1, 0x4487, 0, 0, 0, 25, 16, 0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x01, 0);
+ GUI_V2_BUTTON(_scrollUpButton, 20, 96, 0, 1, 1, 1, 0x4487, 0, 0, 0, 25, 16, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0);
+ GUI_V2_BUTTON(_scrollDownButton, 21, 98, 0, 1, 1, 1, 0x4487, 0, 0, 0, 25, 16, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0);
for (uint i = 0; i < ARRAYSIZE(_menuButtons); ++i)
- GUI_V2_BUTTON(_menuButtons[i], i, 0, 0, 0, 0, 0, 0x4487, 0, 0, 0, 0, 0, 0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x01, 0);
+ GUI_V2_BUTTON(_menuButtons[i], i, 0, 0, 0, 0, 0, 0x4487, 0, 0, 0, 0, 0, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0);
if (_vm->gameFlags().isTalkie)
GUI_LOL_MENU(_mainMenu, 9, 0x4000, 0, 7, -1, -1, -1, -1);
@@ -486,61 +499,61 @@ void GUI_LoL::initStaticData() {
for (int i = 0; i < _mainMenu.numberOfItems; ++i)
_mainMenu.item[i].callback = mainMenuFunctor;
- GUI_LOL_MENU(_loadMenu, 10, 0x400e, 1, 5, 128, 20, 128, 118);
- GUI_LOL_MENU_ITEM(_loadMenu.item[0], 0xfffe, 8, 39, 256, 15, 0, 0);
- GUI_LOL_MENU_ITEM(_loadMenu.item[1], 0xfffd, 8, 56, 256, 15, 0, 0);
- GUI_LOL_MENU_ITEM(_loadMenu.item[2], 0xfffc, 8, 73, 256, 15, 0, 0);
- GUI_LOL_MENU_ITEM(_loadMenu.item[3], 0xfffb, 8, 90, 256, 15, 0, 0);
+ GUI_LOL_MENU(_loadMenu, 10, 0x400E, 1, 5, 128, 20, 128, 118);
+ GUI_LOL_MENU_ITEM(_loadMenu.item[0], 0xFFFE, 8, 39, 256, 15, 0, 0);
+ GUI_LOL_MENU_ITEM(_loadMenu.item[1], 0xFFFD, 8, 56, 256, 15, 0, 0);
+ GUI_LOL_MENU_ITEM(_loadMenu.item[2], 0xFFFC, 8, 73, 256, 15, 0, 0);
+ GUI_LOL_MENU_ITEM(_loadMenu.item[3], 0xFFFB, 8, 90, 256, 15, 0, 0);
GUI_LOL_MENU_ITEM(_loadMenu.item[4], 0x4011, 168, 118, 96, 15, 0, _vm->_keyMap[Common::KEYCODE_ESCAPE]);
Button::Callback loadMenuFunctor = BUTTON_FUNCTOR(GUI_LoL, this, &GUI_LoL::clickedLoadMenu);
for (int i = 0; i < 5; ++i)
_loadMenu.item[i].callback = loadMenuFunctor;
- GUI_LOL_MENU(_saveMenu, 10, 0x400d, 1, 5, 128, 20, 128, 118);
- GUI_LOL_MENU_ITEM(_saveMenu.item[0], 0xfffe, 8, 39, 256, 15, 0, 0);
- GUI_LOL_MENU_ITEM(_saveMenu.item[1], 0xfffd, 8, 56, 256, 15, 0, 0);
- GUI_LOL_MENU_ITEM(_saveMenu.item[2], 0xfffc, 8, 73, 256, 15, 0, 0);
- GUI_LOL_MENU_ITEM(_saveMenu.item[3], 0xfffb, 8, 90, 256, 15, 0, 0);
+ GUI_LOL_MENU(_saveMenu, 10, 0x400D, 1, 5, 128, 20, 128, 118);
+ GUI_LOL_MENU_ITEM(_saveMenu.item[0], 0xFFFE, 8, 39, 256, 15, 0, 0);
+ GUI_LOL_MENU_ITEM(_saveMenu.item[1], 0xFFFD, 8, 56, 256, 15, 0, 0);
+ GUI_LOL_MENU_ITEM(_saveMenu.item[2], 0xFFFC, 8, 73, 256, 15, 0, 0);
+ GUI_LOL_MENU_ITEM(_saveMenu.item[3], 0xFFFB, 8, 90, 256, 15, 0, 0);
GUI_LOL_MENU_ITEM(_saveMenu.item[4], 0x4011, 168, 118, 96, 15, 0, _vm->_keyMap[Common::KEYCODE_ESCAPE]);
Button::Callback saveMenuFunctor = BUTTON_FUNCTOR(GUI_LoL, this, &GUI_LoL::clickedSaveMenu);
for (int i = 0; i < 5; ++i)
_saveMenu.item[i].callback = saveMenuFunctor;
- GUI_LOL_MENU(_deleteMenu, 10, 0x400f, 1, 5, 128, 20, 128, 118);
- GUI_LOL_MENU_ITEM(_deleteMenu.item[0], 0xfffe, 8, 39, 256, 15, 0, 0);
- GUI_LOL_MENU_ITEM(_deleteMenu.item[1], 0xfffd, 8, 56, 256, 15, 0, 0);
- GUI_LOL_MENU_ITEM(_deleteMenu.item[2], 0xfffc, 8, 73, 256, 15, 0, 0);
- GUI_LOL_MENU_ITEM(_deleteMenu.item[3], 0xfffb, 8, 90, 256, 15, 0, 0);
+ GUI_LOL_MENU(_deleteMenu, 10, 0x400F, 1, 5, 128, 20, 128, 118);
+ GUI_LOL_MENU_ITEM(_deleteMenu.item[0], 0xFFFE, 8, 39, 256, 15, 0, 0);
+ GUI_LOL_MENU_ITEM(_deleteMenu.item[1], 0xFFFD, 8, 56, 256, 15, 0, 0);
+ GUI_LOL_MENU_ITEM(_deleteMenu.item[2], 0xFFFC, 8, 73, 256, 15, 0, 0);
+ GUI_LOL_MENU_ITEM(_deleteMenu.item[3], 0xFFFB, 8, 90, 256, 15, 0, 0);
GUI_LOL_MENU_ITEM(_deleteMenu.item[4], 0x4011, 168, 118, 96, 15, 0, _vm->_keyMap[Common::KEYCODE_ESCAPE]);
Button::Callback deleteMenuFunctor = BUTTON_FUNCTOR(GUI_LoL, this, &GUI_LoL::clickedDeleteMenu);
for (int i = 0; i < 5; ++i)
_deleteMenu.item[i].callback = deleteMenuFunctor;
- GUI_LOL_MENU(_gameOptions, 17, 0x400c, 0, 6, -1, -1, -1, -1);
+ GUI_LOL_MENU(_gameOptions, 17, 0x400C, 0, 6, -1, -1, -1, -1);
if (_vm->gameFlags().isTalkie) {
- GUI_LOL_MENU_ITEM(_gameOptions.item[0], 0xfff7, 120, 22, 80, 15, 0x406e, 0);
- GUI_LOL_MENU_ITEM(_gameOptions.item[1], 0xfff6, 120, 39, 80, 15, 0x406c, 0);
- GUI_LOL_MENU_ITEM(_gameOptions.item[2], 0xfff5, 120, 56, 80, 15, 0x406d, 0);
- GUI_LOL_MENU_ITEM(_gameOptions.item[3], 0xfff4, 120, 73, 80, 15, 0x42d5, 0);
- GUI_LOL_MENU_ITEM(_gameOptions.item[4], 0xfff3, 120, 90, 80, 15, 0x42d2, 0);
+ GUI_LOL_MENU_ITEM(_gameOptions.item[0], 0xFFF7, 120, 22, 80, 15, 0x406E, 0);
+ GUI_LOL_MENU_ITEM(_gameOptions.item[1], 0xFFF6, 120, 39, 80, 15, 0x406C, 0);
+ GUI_LOL_MENU_ITEM(_gameOptions.item[2], 0xFFF5, 120, 56, 80, 15, 0x406D, 0);
+ GUI_LOL_MENU_ITEM(_gameOptions.item[3], 0xFFF4, 120, 73, 80, 15, 0x42D5, 0);
+ GUI_LOL_MENU_ITEM(_gameOptions.item[4], 0xFFF3, 120, 90, 80, 15, 0x42D2, 0);
GUI_LOL_MENU_ITEM(_gameOptions.item[5], 0x4072, 104, 110, 96, 15, 0, _vm->_keyMap[Common::KEYCODE_ESCAPE]);
} else {
- GUI_LOL_MENU_ITEM(_gameOptions.item[0], 0xfff9, 120, 22, 80, 15, 0x406a, 0);
- GUI_LOL_MENU_ITEM(_gameOptions.item[1], 0xfff8, 120, 39, 80, 15, 0x406b, 0);
- GUI_LOL_MENU_ITEM(_gameOptions.item[2], 0xfff7, 120, 56, 80, 15, 0x406e, 0);
- GUI_LOL_MENU_ITEM(_gameOptions.item[3], 0xfff6, 120, 73, 80, 15, 0x406c, 0);
- GUI_LOL_MENU_ITEM(_gameOptions.item[4], 0xfff5, 120, 90, 80, 15, 0x406d, 0);
+ GUI_LOL_MENU_ITEM(_gameOptions.item[0], 0xFFF9, 120, 22, 80, 15, 0x406A, 0);
+ GUI_LOL_MENU_ITEM(_gameOptions.item[1], 0xFFF8, 120, 39, 80, 15, 0x406B, 0);
+ GUI_LOL_MENU_ITEM(_gameOptions.item[2], 0xFFF7, 120, 56, 80, 15, 0x406E, 0);
+ GUI_LOL_MENU_ITEM(_gameOptions.item[3], 0xFFF6, 120, 73, 80, 15, 0x406C, 0);
+ GUI_LOL_MENU_ITEM(_gameOptions.item[4], 0xFFF5, 120, 90, 80, 15, 0x406D, 0);
GUI_LOL_MENU_ITEM(_gameOptions.item[5], 0x4072, 104, 110, 96, 15, 0, _vm->_keyMap[Common::KEYCODE_ESCAPE]);
}
Button::Callback optionsMenuFunctor = BUTTON_FUNCTOR(GUI_LoL, this, &GUI_LoL::clickedOptionsMenu);
for (int i = 0; i < _gameOptions.numberOfItems; ++i)
_gameOptions.item[i].callback = optionsMenuFunctor;
- GUI_LOL_MENU(_audioOptions, 18, 0x42d9, 2, 1, -1, -1, -1, -1);
+ GUI_LOL_MENU(_audioOptions, 18, 0x42D9, 2, 1, -1, -1, -1, -1);
GUI_LOL_MENU_ITEM(_audioOptions.item[0], 0x4072, 152, 76, 96, 15, 0, _vm->_keyMap[Common::KEYCODE_ESCAPE]);
- GUI_LOL_MENU_ITEM(_audioOptions.item[1], 3, 128, 22, 114, 14, 0x42db, 0);
- GUI_LOL_MENU_ITEM(_audioOptions.item[2], 4, 128, 39, 114, 14, 0x42da, 0);
- GUI_LOL_MENU_ITEM(_audioOptions.item[3], 5, 128, 56, 114, 14, 0x42dc, 0);
+ GUI_LOL_MENU_ITEM(_audioOptions.item[1], 3, 128, 22, 114, 14, 0x42DB, 0);
+ GUI_LOL_MENU_ITEM(_audioOptions.item[2], 4, 128, 39, 114, 14, 0x42DA, 0);
+ GUI_LOL_MENU_ITEM(_audioOptions.item[3], 5, 128, 56, 114, 14, 0x42DC, 0);
Button::Callback audioMenuFunctor = BUTTON_FUNCTOR(GUI_LoL, this, &GUI_LoL::clickedAudioMenu);
for (int i = 0; i < 4; ++i)
_audioOptions.item[i].callback = audioMenuFunctor;
@@ -658,11 +671,11 @@ const uint16 LoLEngine::_charPosXPC98[] = {
92, 152, 212, 268
};
-const uint8 LoLEngine::_charNamesPC98[][11] = {
- { 0x83, 0x41, 0x83, 0x4E, 0x83, 0x56, 0x83, 0x46, 0x83, 0x8B, 0x00 },
- { 0x83, 0x7D, 0x83, 0x43, 0x83, 0x50, 0x83, 0x8B, 0x00, 0x00, 0x00 },
- { 0x83, 0x4C, 0x81, 0x5B, 0x83, 0x89, 0x83, 0x93, 0x00, 0x00, 0x00 },
- { 0x83, 0x52, 0x83, 0x93, 0x83, 0x89, 0x83, 0x62, 0x83, 0x68, 0x00 }
+const char *const LoLEngine::_charNamesJapanese[] = {
+ "\x83\x41\x83\x4E\x83\x56\x83\x46\x83\x8B\0",
+ "\x83\x7D\x83\x43\x83\x50\x83\x8B\x00\x00\0",
+ "\x83\x4C\x81\x5B\x83\x89\x83\x93\x00\x00\0",
+ "\x83\x52\x83\x93\x83\x89\x83\x62\x83\x68\0"
};
const uint8 LoLEngine::_chargenFrameTableTalkie[] = {
diff --git a/engines/kyra/text_hof.cpp b/engines/kyra/text_hof.cpp
index 06067d6693..7fa823da0f 100644
--- a/engines/kyra/text_hof.cpp
+++ b/engines/kyra/text_hof.cpp
@@ -464,9 +464,9 @@ void KyraEngine_HoF::processDialogue(int dlgOffset, int vocH, int csEntry) {
nextTimSequence = READ_LE_UINT16(&_ingameTalkObjIndex[cmd]);
if (nextTimSequence == 10) {
- if (queryGameFlag(0x3e))
+ if (queryGameFlag(0x3E))
nextTimSequence = 14;
- if (queryGameFlag(0x3f))
+ if (queryGameFlag(0x3F))
nextTimSequence = 15;
if (queryGameFlag(0x40))
nextTimSequence = 16;
diff --git a/engines/kyra/text_lol.cpp b/engines/kyra/text_lol.cpp
index ee42d6db92..6e77db1f8a 100644
--- a/engines/kyra/text_lol.cpp
+++ b/engines/kyra/text_lol.cpp
@@ -85,7 +85,7 @@ void TextDisplayer_LoL::setupField(bool mode) {
_screen->copyBlockToPage(3, 0, 0, 320, 200, _vm->_pageBuffer1);
_screen->setCurPage(cp);
- _vm->_updateFlags &= 0xfffd;
+ _vm->_updateFlags &= 0xFFFD;
}
} else {
if (!mode)
@@ -136,18 +136,16 @@ void TextDisplayer_LoL::expandField() {
void TextDisplayer_LoL::printDialogueText(int dim, char *str, EMCState *script, const uint16 *paramList, int16 paramIndex) {
int oldDim = 0;
- const bool isPc98 = (_vm->gameFlags().platform == Common::kPlatformPC98);
-
if (dim == 3) {
if (_vm->_updateFlags & 2) {
oldDim = clearDim(4);
- _textDimData[4].color1 = isPc98 ? 0x33 : 254;
+ _textDimData[4].color1 = _vm->gameFlags().use16ColorMode ? 0x33 : 254;
_textDimData[4].color2 = _screen->_curDim->unkA;
} else {
oldDim = clearDim(3);
- _textDimData[3].color1 = isPc98 ? 0x33 : 192;
+ _textDimData[3].color1 = _vm->gameFlags().use16ColorMode ? 0x33 : 192;
_textDimData[3].color2 = _screen->_curDim->unkA;
- if (!isPc98)
+ if (!_vm->gameFlags().use16ColorMode)
_screen->copyColor(192, 254);
_vm->enableTimer(11);
_vm->_textColorFlag = 0;
@@ -157,12 +155,12 @@ void TextDisplayer_LoL::printDialogueText(int dim, char *str, EMCState *script,
oldDim = _screen->curDimIndex();
_screen->setScreenDim(dim);
_lineCount = 0;
- _textDimData[dim].color1 = isPc98 ? 0x33 : 254;
+ _textDimData[dim].color1 = _vm->gameFlags().use16ColorMode ? 0x33 : 254;
_textDimData[dim].color2 = _screen->_curDim->unkA;
}
int cp = _screen->setCurPage(0);
- Screen::FontId of = _screen->setFont(_vm->gameFlags().use16ColorMode ? Screen::FID_SJIS_FNT : Screen::FID_9_FNT);
+ Screen::FontId of = _screen->setFont((_vm->gameFlags().lang == Common::JA_JPN && _vm->gameFlags().use16ColorMode) ? Screen::FID_SJIS_FNT : Screen::FID_9_FNT);
preprocessString(str, script, paramList, paramIndex);
_numCharsTotal = strlen(_dialogueBuffer);
@@ -176,8 +174,8 @@ void TextDisplayer_LoL::printDialogueText(int dim, char *str, EMCState *script,
}
void TextDisplayer_LoL::printMessage(uint16 type, const char *str, ...) {
- static const uint8 textColors256[] = { 0xfe, 0xa2, 0x84, 0x97, 0x9F };
- static const uint8 textColors16[] = { 0x33, 0xaa, 0x88, 0x55, 0x99 };
+ static const uint8 textColors256[] = { 0xFE, 0xA2, 0x84, 0x97, 0x9F };
+ static const uint8 textColors16[] = { 0x33, 0xAA, 0x88, 0x55, 0x99 };
static const uint8 soundEffect[] = { 0x0B, 0x00, 0x2B, 0x1B, 0x00 };
const uint8 *textColors = _vm->gameFlags().use16ColorMode ? textColors16 : textColors256;
@@ -187,7 +185,7 @@ void TextDisplayer_LoL::printMessage(uint16 type, const char *str, ...) {
else
_vm->stopPortraitSpeechAnim();
- uint16 col = textColors[type & 0x7fff];
+ uint16 col = textColors[type & 0x7FFF];
int od = _screen->curDimIndex();
@@ -222,16 +220,15 @@ void TextDisplayer_LoL::printMessage(uint16 type, const char *str, ...) {
_vm->sound()->playSoundEffect(soundEffect[type]);
}
- _vm->_textColorFlag = type & 0x7fff;
+ _vm->_textColorFlag = type & 0x7FFF;
_vm->_fadeText = false;
}
void TextDisplayer_LoL::preprocessString(char *str, EMCState *script, const uint16 *paramList, int16 paramIndex) {
char *dst = _dialogueBuffer;
- const bool isPc98 = (_vm->gameFlags().platform == Common::kPlatformPC98);
for (char *s = str; *s;) {
- if (isPc98) {
+ if (_vm->gameFlags().lang == Common::JA_JPN) {
uint8 c = *s;
if (c >= 0xE0 || (c > 0x80 && c < 0xA0)) {
*dst++ = *s++;
diff --git a/engines/kyra/text_rpg.cpp b/engines/kyra/text_rpg.cpp
index 52c14c7223..a19d678e35 100644
--- a/engines/kyra/text_rpg.cpp
+++ b/engines/kyra/text_rpg.cpp
@@ -36,7 +36,7 @@ enum {
TextDisplayer_rpg::TextDisplayer_rpg(KyraRpgEngine *engine, Screen *scr) : _vm(engine), _screen(scr),
_lineCount(0), _printFlag(false), _lineWidth(0), _numCharsTotal(0), _allowPageBreak(true),
- _numCharsLeft(0), _numCharsPrinted(0), _sjisLineBreakFlag(false), _waitButtonMode(1) {
+ _numCharsLeft(0), _numCharsPrinted(0), _sjisTextModeLineBreak(false), _waitButtonMode(1) {
_dialogueBuffer = new char[kEoBTextBufferSize];
memset(_dialogueBuffer, 0, kEoBTextBufferSize);
@@ -88,8 +88,8 @@ void TextDisplayer_rpg::resetDimTextPositions(int dim) {
}
void TextDisplayer_rpg::resetPageBreakString() {
- if (vm()->_moreStrings)
- strcpy(_pageBreakString, vm()->_moreStrings[0]);
+ if (_vm->_moreStrings)
+ strcpy(_pageBreakString, _vm->_moreStrings[0]);
}
void TextDisplayer_rpg::setPageBreakFlag() {
@@ -102,8 +102,6 @@ void TextDisplayer_rpg::removePageBreakFlag() {
}
void TextDisplayer_rpg::displayText(char *str, ...) {
- const bool isPc98 = (_vm->gameFlags().platform == Common::kPlatformPC98);
-
_printFlag = false;
_lineWidth = 0;
@@ -125,7 +123,9 @@ void TextDisplayer_rpg::displayText(char *str, ...) {
const ScreenDim *sd = _screen->_curDim;
int sdx = _screen->curDimIndex();
- bool pc98PrintFlag = (isPc98 && (sdx == 3 || sdx == 4 || sdx == 5 || sdx == 15)) ? true : false;
+ bool sjisTextMode = (_vm->gameFlags().lang == Common::JA_JPN && _vm->gameFlags().use16ColorMode && (sdx == 3 || sdx == 4 || sdx == 5 || sdx == 15)) ? true : false;
+ int sjisOffs = sjisTextMode ? 8 : 9;
+
uint16 charsPerLine = (sd->w << 3) / (_screen->getFontWidth() + _screen->_charWidth);
while (c) {
@@ -146,15 +146,25 @@ void TextDisplayer_rpg::displayText(char *str, ...) {
c = parseCommand();
}
- if (isPc98) {
+ if (_vm->gameFlags().lang == Common::JA_JPN) {
uint8 cu = (uint8) c;
if (cu >= 0xE0 || (cu > 0x80 && cu < 0xA0)) {
- _currentLine[_numCharsLeft++] = c;
- _currentLine[_numCharsLeft++] = parseCommand();
- _currentLine[_numCharsLeft] = '\0';
- _lineWidth += 8;
- if ((_textDimData[sdx].column + _lineWidth) > (sd->w << 3))
+ if (sjisTextMode) {
+ _currentLine[_numCharsLeft++] = c;
+ _currentLine[_numCharsLeft++] = parseCommand();
+ _currentLine[_numCharsLeft] = '\0';
+ }
+
+ if ((_textDimData[sdx].column + _lineWidth + sjisOffs) > (sd->w << 3))
printLine(_currentLine);
+
+ if (!sjisTextMode) {
+ _currentLine[_numCharsLeft++] = c;
+ _currentLine[_numCharsLeft++] = parseCommand();
+ _currentLine[_numCharsLeft] = '\0';
+ }
+
+ _lineWidth += sjisOffs;
c = parseCommand();
continue;
}
@@ -182,17 +192,17 @@ void TextDisplayer_rpg::displayText(char *str, ...) {
case 8:
printLine(_currentLine);
dv = _textDimData[sdx].column / (_screen->getFontWidth() + _screen->_charWidth);
- dv = ((dv + 8) & 0xfff8) - 1;
+ dv = ((dv + 8) & 0xFFF8) - 1;
if (dv >= charsPerLine)
dv = 0;
_textDimData[sdx].column = (_screen->getFontWidth() + _screen->_charWidth) * dv;
break;
case 12:
- if (isPc98)
- _sjisLineBreakFlag = true;
+ if (sjisTextMode)
+ _sjisTextModeLineBreak = true;
printLine(_currentLine);
- _sjisLineBreakFlag = false;
+ _sjisTextModeLineBreak = false;
_lineCount++;
_textDimData[sdx].column = 0;
_textDimData[sdx].line++;
@@ -208,7 +218,7 @@ void TextDisplayer_rpg::displayText(char *str, ...) {
default:
if (_vm->game() == GI_LOL || (unsigned char)c > 30) {
- _lineWidth += (pc98PrintFlag ? 4 : _screen->getCharWidth((uint8)c));
+ _lineWidth += (sjisTextMode ? 4 : (_screen->_currentFont == Screen::FID_SJIS_FNT ? 9 : _screen->getCharWidth((uint8)c)));
_currentLine[_numCharsLeft++] = c;
_currentLine[_numCharsLeft] = 0;
@@ -266,7 +276,7 @@ void TextDisplayer_rpg::readNextPara() {
// versions depend on this code we'll have to look at this again.
#if 0
if ((_vm->game() != GI_LOL) && (d & 0x80)) {
- d &= 0x7f;
+ d &= 0x7F;
c = d & 7;
d = (d & 0x78) >> 3;
uint8 l = d;
@@ -280,10 +290,9 @@ void TextDisplayer_rpg::readNextPara() {
}
void TextDisplayer_rpg::printLine(char *str) {
- const bool isPc98 = (_vm->gameFlags().platform == Common::kPlatformPC98);
const ScreenDim *sd = _screen->_curDim;
int sdx = _screen->curDimIndex();
- bool pc98PrintFlag = (isPc98 && (sdx == 3 || sdx == 4 || sdx == 5 || sdx == 15)) ? true : false;
+ bool sjisTextMode = (_vm->gameFlags().lang == Common::JA_JPN && _vm->gameFlags().use16ColorMode && (sdx == 3 || sdx == 4 || sdx == 5 || sdx == 15)) ? true : false;
int fh = (_screen->_currentFont == Screen::FID_SJIS_FNT) ? 9 : (_screen->getFontHeight() + _screen->_charOffset);
int lines = (sd->h - _screen->_charOffset) / fh;
@@ -307,25 +316,27 @@ void TextDisplayer_rpg::printLine(char *str) {
}
int x1 = (sd->sx << 3) + _textDimData[sdx].column;
- int y = sd->sy + (pc98PrintFlag ? (_textDimData[sdx].line << 3) : (fh * _textDimData[sdx].line));
+ int y = sd->sy + (sjisTextMode ? (_textDimData[sdx].line << 3) : (fh * _textDimData[sdx].line));
int w = sd->w << 3;
int lw = _lineWidth;
int s = _numCharsLeft;
char c = 0;
+ uint8 twoByteCharOffs = 0;
- if (pc98PrintFlag) {
+
+ if (sjisTextMode) {
bool ct = true;
if ((lw + _textDimData[sdx].column) > w) {
if ((lines - 1 - (_waitButtonSpace << 1)) <= _lineCount)
// cut off line to leave space for "MORE" button
- w -= vm()->guiSettings()->buttons.waitReserve;
+ w -= _vm->guiSettings()->buttons.waitReserve;
} else {
- if (!_sjisLineBreakFlag || (_lineCount + 1 < lines - 1))
+ if (!_sjisTextModeLineBreak || (_lineCount + 1 < lines - 1))
ct = false;
else
// cut off line to leave space for "MORE" button
- w -= vm()->guiSettings()->buttons.waitReserve;
+ w -= _vm->guiSettings()->buttons.waitReserve;
}
if (ct) {
@@ -344,41 +355,88 @@ void TextDisplayer_rpg::printLine(char *str) {
s = n2;
}
} else {
- if ((lw + _textDimData[sdx].column) > w) {
+ if (_vm->gameFlags().lang == Common::JA_JPN) {
+ for (int i = 0; i < s; ++i) {
+ uint8 cu = (uint8) str[i];
+ if (cu >= 0xE0 || (cu > 0x80 && cu < 0xA0))
+ twoByteCharOffs = 8;
+ }
+ }
+
+ if ((lw + _textDimData[sdx].column) >= w) {
if ((lines - 1) <= _lineCount && _allowPageBreak)
// cut off line to leave space for "MORE" button
- w -= vm()->guiSettings()->buttons.waitReserve;
+ w -= _vm->guiSettings()->buttons.waitReserve;
w -= _textDimData[sdx].column;
- int n2 = 0;
- int n1 = s - 1;
+ int lineLastCharPos = 0;
+ int strPos = s - 1;
+
+ if (twoByteCharOffs) {
+ lw = 0;
+ int prevStrPos = 0;
+ c = str[0];
+
+ for (strPos = 0; strPos < s; ++strPos) {
+ uint8 cu = (uint8) str[strPos];
+ if (cu >= 0xE0 || (cu > 0x80 && cu < 0xA0)) {
+ lw += 9;
+ strPos++;
+ } else {
+ lw += _screen->getCharWidth((uint8)c);
+ }
+
+ if (!lineLastCharPos && w < lw + twoByteCharOffs)
+ lineLastCharPos = prevStrPos;
+
+ if (lineLastCharPos && c == ' ') {
+ s = strPos;
+ _printFlag = false;
+ break;
+ }
+ prevStrPos = strPos;
+ c = (char) cu;
+ }
+
+ if (!lineLastCharPos) {
+ lineLastCharPos = s - 1;
+ if (lineLastCharPos && str[lineLastCharPos] == ' ') {
+ s = strPos;
+ _printFlag = false;
+ }
+ }
- while (n1 > 0) {
- //cut off line after last space
- c = str[n1];
+ lw = _lineWidth;
- lw -= _screen->getCharWidth((uint8)c);
+ } else {
+ while (strPos > 0) {
+ //cut off line after last space
+ c = str[strPos];
- if (!n2 && lw <= w)
- n2 = n1;
+ lw -= _screen->getCharWidth((uint8)c);
- if (n2 && c == ' ') {
- s = n1;
- _printFlag = false;
- break;
+ if (!lineLastCharPos && lw <= w)
+ lineLastCharPos = strPos;
+
+ if (lineLastCharPos && c == ' ') {
+ s = strPos;
+ _printFlag = false;
+ break;
+ }
+ strPos--;
}
- n1--;
}
- if (!n1) {
+ if (!strPos) {
if (_textDimData[sdx].column && !_printFlag) {
s = lw = 0;
_printFlag = true;
} else {
- s = n2;
+ s = lineLastCharPos;
}
}
+
}
}
@@ -386,7 +444,7 @@ void TextDisplayer_rpg::printLine(char *str) {
str[s] = 0;
uint8 col = _textDimData[sdx].color1;
- if (isPc98 && (sdx == 2 || sdx == 3 || sdx == 4 || sdx == 5 || sdx == 15)) {
+ if (sjisTextMode && (sdx == 2 || sdx == 3 || sdx == 4 || sdx == 5 || sdx == 15)) {
switch (_textDimData[sdx].color1) {
case 0x88:
col = 0x41;
@@ -394,14 +452,14 @@ void TextDisplayer_rpg::printLine(char *str) {
case 0x55:
col = 0x81;
break;
- case 0xaa:
+ case 0xAA:
col = 0x21;
break;
case 0x99:
- col = 0xa1;
+ col = 0xA1;
break;
case 0x33:
- col = 0xe1;
+ col = 0xE1;
break;
case 0x18:
col = 0x61;
@@ -413,6 +471,7 @@ void TextDisplayer_rpg::printLine(char *str) {
_screen->printText(str, x1 & ~3, (y + 8) & ~7, col, 0);
} else {
_screen->printText(str, x1, y, col, _textDimData[sdx].color2);
+ _screen->updateScreen();
}
_textDimData[sdx].column += lw;
@@ -432,9 +491,9 @@ void TextDisplayer_rpg::printLine(char *str) {
str[len] = 0;
_numCharsLeft = strlen(str);
- _lineWidth = pc98PrintFlag ? (_numCharsLeft << 2) : _screen->getTextWidth(str);
+ _lineWidth = sjisTextMode ? (_numCharsLeft << 2) : (_screen->_currentFont == Screen::FID_SJIS_FNT ? _numCharsLeft * 9: _screen->getTextWidth(str));
- if (!_numCharsLeft && _textDimData[sdx].column < (sd->w << 3))
+ if (!_numCharsLeft && (_textDimData[sdx].column + twoByteCharOffs) <= (sd->w << 3))
return;
_textDimData[sdx].column = 0;
@@ -483,7 +542,7 @@ void TextDisplayer_rpg::printMessage(const char *str, int textColor, ...) {
displayText(_dialogueBuffer);
- if (vm()->game() != GI_EOB1)
+ if (_vm->game() != GI_EOB1)
_textDimData[_screen->curDimIndex()].color1 = tc;
if (!_screen->_curPage)
@@ -494,7 +553,7 @@ int TextDisplayer_rpg::clearDim(int dim) {
int res = _screen->curDimIndex();
_screen->setScreenDim(dim);
_textDimData[dim].color1 = _screen->_curDim->unk8;
- _textDimData[dim].color2 = vm()->game() == GI_LOL ? _screen->_curDim->unkA : vm()->guiSettings()->colors.fill;
+ _textDimData[dim].color2 = _vm->game() == GI_LOL ? _screen->_curDim->unkA : _vm->guiSettings()->colors.fill;
clearCurDim();
return res;
}
@@ -502,7 +561,7 @@ int TextDisplayer_rpg::clearDim(int dim) {
void TextDisplayer_rpg::clearCurDim() {
int d = _screen->curDimIndex();
const ScreenDim *tmp = _screen->getScreenDim(d);
- if (vm()->gameFlags().use16ColorMode) {
+ if (_vm->gameFlags().use16ColorMode) {
_screen->fillRect(tmp->sx << 3, tmp->sy, ((tmp->sx + tmp->w) << 3) - 2, (tmp->sy + tmp->h) - 2, _textDimData[d].color2);
} else
_screen->fillRect(tmp->sx << 3, tmp->sy, ((tmp->sx + tmp->w) << 3) - 1, (tmp->sy + tmp->h) - 1, _textDimData[d].color2);
@@ -512,40 +571,40 @@ void TextDisplayer_rpg::clearCurDim() {
}
void TextDisplayer_rpg::textPageBreak() {
- if (vm()->game() != GI_LOL)
- SWAP(vm()->_dialogueButtonLabelColor1, vm()->_dialogueButtonLabelColor2);
+ if (_vm->game() != GI_LOL)
+ SWAP(_vm->_dialogueButtonLabelColor1, _vm->_dialogueButtonLabelColor2);
int cp = _screen->setCurPage(0);
- Screen::FontId cf = _screen->setFont(vm()->gameFlags().use16ColorMode ? Screen::FID_SJIS_FNT : Screen::FID_6_FNT);
+ Screen::FontId cf = _screen->setFont((_vm->gameFlags().lang == Common::JA_JPN && _vm->gameFlags().use16ColorMode) ? Screen::FID_SJIS_FNT : Screen::FID_6_FNT);
- if (vm()->game() == GI_LOL)
- vm()->_timer->pauseSingleTimer(11, true);
+ if (_vm->game() == GI_LOL)
+ _vm->_timer->pauseSingleTimer(11, true);
- vm()->_fadeText = false;
+ _vm->_fadeText = false;
int resetPortraitAfterSpeechAnim = 0;
int updatePortraitSpeechAnimDuration = 0;
- if (vm()->_updateCharNum != -1) {
- resetPortraitAfterSpeechAnim = vm()->_resetPortraitAfterSpeechAnim;
- vm()->_resetPortraitAfterSpeechAnim = 0;
- updatePortraitSpeechAnimDuration = vm()->_updatePortraitSpeechAnimDuration;
- if (vm()->_updatePortraitSpeechAnimDuration > 36)
- vm()->_updatePortraitSpeechAnimDuration = 36;
+ if (_vm->_updateCharNum != -1) {
+ resetPortraitAfterSpeechAnim = _vm->_resetPortraitAfterSpeechAnim;
+ _vm->_resetPortraitAfterSpeechAnim = 0;
+ updatePortraitSpeechAnimDuration = _vm->_updatePortraitSpeechAnimDuration;
+ if (_vm->_updatePortraitSpeechAnimDuration > 36)
+ _vm->_updatePortraitSpeechAnimDuration = 36;
}
uint32 speechPartTime = 0;
- if (vm()->speechEnabled() && vm()->_activeVoiceFileTotalTime && _numCharsTotal)
- speechPartTime = vm()->_system->getMillis() + ((_numCharsPrinted * vm()->_activeVoiceFileTotalTime) / _numCharsTotal);
+ if (_vm->speechEnabled() && _vm->_activeVoiceFileTotalTime && _numCharsTotal)
+ speechPartTime = _vm->_system->getMillis() + ((_numCharsPrinted * _vm->_activeVoiceFileTotalTime) / _numCharsTotal);
const ScreenDim *dim = _screen->getScreenDim(_screen->curDimIndex());
int x = ((dim->sx + dim->w) << 3) - (_vm->_dialogueButtonWidth + 3);
int y = 0;
- int w = vm()->_dialogueButtonWidth;
+ int w = _vm->_dialogueButtonWidth;
- if (vm()->game() == GI_LOL) {
- if (vm()->_needSceneRestore && (vm()->_updateFlags & 2)) {
- if (vm()->_currentControlMode || !(vm()->_updateFlags & 2)) {
+ if (_vm->game() == GI_LOL) {
+ if (_vm->_needSceneRestore && (_vm->_updateFlags & 2)) {
+ if (_vm->_currentControlMode || !(_vm->_updateFlags & 2)) {
y = dim->sy + dim->h - 5;
} else {
x += 6;
@@ -555,49 +614,49 @@ void TextDisplayer_rpg::textPageBreak() {
y = dim->sy + dim->h - 10;
}
} else {
- y = vm()->guiSettings()->buttons.waitY[_waitButtonMode];
- x = vm()->guiSettings()->buttons.waitX[_waitButtonMode];
- w = vm()->guiSettings()->buttons.waitWidth[_waitButtonMode];
+ y = _vm->guiSettings()->buttons.waitY[_waitButtonMode];
+ x = _vm->guiSettings()->buttons.waitX[_waitButtonMode];
+ w = _vm->guiSettings()->buttons.waitWidth[_waitButtonMode];
}
- if (vm()->gameFlags().use16ColorMode) {
- vm()->gui_drawBox(x + 8, (y & ~7) - 1, 66, 10, 0xee, 0xcc, -1);
- _screen->printText(_pageBreakString, (x + 37 - (strlen(_pageBreakString) << 1) + 4) & ~3, (y + 2) & ~7, 0xc1, 0);
+ if (_vm->gameFlags().use16ColorMode) {
+ _vm->gui_drawBox(x + 8, (y & ~7) - 1, 66, 10, 0xEE, 0xCC, -1);
+ _screen->printText(_pageBreakString, (x + 37 - (strlen(_pageBreakString) << 1) + 4) & ~3, (y + 2) & ~7, 0xC1, 0);
} else {
- vm()->gui_drawBox(x, y, w, vm()->guiSettings()->buttons.height, vm()->guiSettings()->colors.frame1, vm()->guiSettings()->colors.frame2, vm()->guiSettings()->colors.fill);
- _screen->printText(_pageBreakString, x + (w >> 1) - (vm()->screen()->getTextWidth(_pageBreakString) >> 1), y + 2, vm()->_dialogueButtonLabelColor1, 0);
+ _vm->gui_drawBox(x, y, w, _vm->guiSettings()->buttons.height, _vm->guiSettings()->colors.frame1, _vm->guiSettings()->colors.frame2, _vm->guiSettings()->colors.fill);
+ _screen->printText(_pageBreakString, x + (w >> 1) - (_vm->screen()->getTextWidth(_pageBreakString) >> 1), y + 2, _vm->_dialogueButtonLabelColor1, 0);
}
- vm()->removeInputTop();
+ _vm->removeInputTop();
bool loop = true;
bool target = false;
do {
- int inputFlag = vm()->checkInput(0, false) & 0xFF;
- vm()->removeInputTop();
+ int inputFlag = _vm->checkInput(0, false) & 0xFF;
+ _vm->removeInputTop();
while (!inputFlag && !_vm->shouldQuit()) {
- vm()->update();
+ _vm->update();
- if (vm()->speechEnabled()) {
- if (((vm()->_system->getMillis() > speechPartTime) || (vm()->snd_updateCharacterSpeech() != 2)) && speechPartTime) {
+ if (_vm->speechEnabled()) {
+ if (((_vm->_system->getMillis() > speechPartTime) || (_vm->snd_updateCharacterSpeech() != 2)) && speechPartTime) {
loop = false;
- inputFlag = vm()->_keyMap[Common::KEYCODE_RETURN];
+ inputFlag = _vm->_keyMap[Common::KEYCODE_RETURN];
break;
}
}
- inputFlag = vm()->checkInput(0, false) & 0xFF;
- vm()->removeInputTop();
+ inputFlag = _vm->checkInput(0, false) & 0xFF;
+ _vm->removeInputTop();
}
- vm()->gui_notifyButtonListChanged();
+ _vm->gui_notifyButtonListChanged();
- if (inputFlag == vm()->_keyMap[Common::KEYCODE_SPACE] || inputFlag == vm()->_keyMap[Common::KEYCODE_RETURN]) {
+ if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) {
loop = false;
} else if (inputFlag == 199 || inputFlag == 201) {
- if (vm()->posWithinRect(vm()->_mouseX, vm()->_mouseY, x, y, x + w, y + 9)) {
+ if (_vm->posWithinRect(_vm->_mouseX, _vm->_mouseY, x, y, x + w, y + 9)) {
if (_vm->game() == GI_LOL)
target = true;
else
@@ -609,7 +668,7 @@ void TextDisplayer_rpg::textPageBreak() {
}
} while (loop && !_vm->shouldQuit());
- if (vm()->gameFlags().use16ColorMode)
+ if (_vm->gameFlags().use16ColorMode)
_screen->fillRect(x + 8, y, x + 57, y + 9, _textDimData[_screen->curDimIndex()].color2);
else
_screen->fillRect(x, y, x + w - 1, y + 8, _textDimData[_screen->curDimIndex()].color2);
@@ -617,52 +676,52 @@ void TextDisplayer_rpg::textPageBreak() {
clearCurDim();
_screen->updateScreen();
- if (vm()->game() == GI_LOL)
- vm()->_timer->pauseSingleTimer(11, false);
+ if (_vm->game() == GI_LOL)
+ _vm->_timer->pauseSingleTimer(11, false);
- if (vm()->_updateCharNum != -1) {
- vm()->_resetPortraitAfterSpeechAnim = resetPortraitAfterSpeechAnim;
+ if (_vm->_updateCharNum != -1) {
+ _vm->_resetPortraitAfterSpeechAnim = resetPortraitAfterSpeechAnim;
if (updatePortraitSpeechAnimDuration > 36)
updatePortraitSpeechAnimDuration -= 36;
else
updatePortraitSpeechAnimDuration >>= 1;
- vm()->_updatePortraitSpeechAnimDuration = updatePortraitSpeechAnimDuration;
+ _vm->_updatePortraitSpeechAnimDuration = updatePortraitSpeechAnimDuration;
}
_screen->setFont(cf);
_screen->setCurPage(cp);
- if (vm()->game() != GI_LOL)
- SWAP(vm()->_dialogueButtonLabelColor1, vm()->_dialogueButtonLabelColor2);
+ if (_vm->game() != GI_LOL)
+ SWAP(_vm->_dialogueButtonLabelColor1, _vm->_dialogueButtonLabelColor2);
- vm()->removeInputTop();
+ _vm->removeInputTop();
}
void TextDisplayer_rpg::displayWaitButton() {
- vm()->_dialogueNumButtons = 1;
- vm()->_dialogueButtonString[0] = _pageBreakString;
- vm()->_dialogueButtonString[1] = 0;
- vm()->_dialogueButtonString[2] = 0;
- vm()->_dialogueHighlightedButton = 0;
+ _vm->_dialogueNumButtons = 1;
+ _vm->_dialogueButtonString[0] = _pageBreakString;
+ _vm->_dialogueButtonString[1] = 0;
+ _vm->_dialogueButtonString[2] = 0;
+ _vm->_dialogueHighlightedButton = 0;
- vm()->_dialogueButtonPosX = &vm()->guiSettings()->buttons.waitX[_waitButtonMode];
- vm()->_dialogueButtonPosY = &vm()->guiSettings()->buttons.waitY[_waitButtonMode];
- vm()->_dialogueButtonWidth = vm()->guiSettings()->buttons.waitWidth[_waitButtonMode];
- vm()->_dialogueButtonYoffs = 0;
+ _vm->_dialogueButtonPosX = &_vm->guiSettings()->buttons.waitX[_waitButtonMode];
+ _vm->_dialogueButtonPosY = &_vm->guiSettings()->buttons.waitY[_waitButtonMode];
+ _vm->_dialogueButtonWidth = _vm->guiSettings()->buttons.waitWidth[_waitButtonMode];
+ _vm->_dialogueButtonYoffs = 0;
- SWAP(vm()->_dialogueButtonLabelColor1, vm()->_dialogueButtonLabelColor2);
- vm()->drawDialogueButtons();
+ SWAP(_vm->_dialogueButtonLabelColor1, _vm->_dialogueButtonLabelColor2);
+ _vm->drawDialogueButtons();
- if (!vm()->shouldQuit())
- vm()->removeInputTop();
+ if (!_vm->shouldQuit())
+ _vm->removeInputTop();
- while (!vm()->processDialogue() && !vm()->shouldQuit()) {}
+ while (!_vm->processDialogue() && !_vm->shouldQuit()) {}
- _screen->fillRect(vm()->_dialogueButtonPosX[0], vm()->_dialogueButtonPosY[0], vm()->_dialogueButtonPosX[0] + vm()->_dialogueButtonWidth - 1, vm()->_dialogueButtonPosY[0] + vm()->guiSettings()->buttons.height - 1, vm()->guiSettings()->colors.fill);
+ _screen->fillRect(_vm->_dialogueButtonPosX[0], _vm->_dialogueButtonPosY[0], _vm->_dialogueButtonPosX[0] + _vm->_dialogueButtonWidth - 1, _vm->_dialogueButtonPosY[0] + _vm->guiSettings()->buttons.height - 1, _vm->guiSettings()->colors.fill);
_screen->updateScreen();
- vm()->_dialogueButtonWidth = 95;
- SWAP(vm()->_dialogueButtonLabelColor1, vm()->_dialogueButtonLabelColor2);
+ _vm->_dialogueButtonWidth = 95;
+ SWAP(_vm->_dialogueButtonLabelColor1, _vm->_dialogueButtonLabelColor2);
clearCurDim();
}
diff --git a/engines/kyra/text_rpg.h b/engines/kyra/text_rpg.h
index 5ad8899484..eb8617a371 100644
--- a/engines/kyra/text_rpg.h
+++ b/engines/kyra/text_rpg.h
@@ -79,7 +79,7 @@ protected:
uint32 _numCharsPrinted;
bool _printFlag;
- bool _sjisLineBreakFlag;
+ bool _sjisTextModeLineBreak;
char _pageBreakString[20];
char _scriptParaString[11];
diff --git a/engines/kyra/timer_eob.cpp b/engines/kyra/timer_eob.cpp
index 766fe453ab..f7a4e23006 100644
--- a/engines/kyra/timer_eob.cpp
+++ b/engines/kyra/timer_eob.cpp
@@ -57,7 +57,7 @@ void EoBCoreEngine::setupTimers() {
void EoBCoreEngine::setCharEventTimer(int charIndex, uint32 countdown, int evnt, int updateExistingTimer) {
uint32 ntime = _system->getMillis() + countdown * _tickLength;
- uint8 timerId = 0x30 | (charIndex & 0x0f);
+ uint8 timerId = 0x30 | (charIndex & 0x0F);
EoBCharacter *c = &_characters[charIndex];
if (!_timer->isEnabled(timerId)) {
@@ -118,7 +118,7 @@ void EoBCoreEngine::setupCharacterTimers() {
if (!testCharacter(i, 1))
continue;
- uint32 nextTimer = 0xffffffff;
+ uint32 nextTimer = 0xFFFFFFFF;
for (int ii = 0; ii < 10; ii++) {
if (c->timers[ii] && c->timers[ii] < nextTimer)
@@ -126,7 +126,7 @@ void EoBCoreEngine::setupCharacterTimers() {
}
uint32 ctime = _system->getMillis();
- if (nextTimer == 0xffffffff)
+ if (nextTimer == 0xFFFFFFFF)
_timer->disable(0x30 | i);
else {
enableTimer(0x30 | i);
@@ -219,11 +219,11 @@ void EoBCoreEngine::timerProcessFlyingObjects(int timerNum) {
}
void EoBCoreEngine::timerProcessMonsters(int timerNum) {
- updateMonsters(timerNum & 0x0f);
+ updateMonsters(timerNum & 0x0F);
}
void EoBCoreEngine::timerSpecialCharacterUpdate(int timerNum) {
- int charIndex = timerNum & 0x0f;
+ int charIndex = timerNum & 0x0F;
EoBCharacter *c = &_characters[charIndex];
uint32 ctime = _system->getMillis();
@@ -249,6 +249,7 @@ void EoBCoreEngine::timerSpecialCharacterUpdate(int timerNum) {
case 2:
case 3:
setCharEventTimer(charIndex, (c->effectFlags & 0x10000) ? 9 : 36, evt + 2, 1);
+ // fall through
case 0:
case 1:
case 4:
@@ -309,13 +310,13 @@ void EoBCoreEngine::timerSpecialCharacterUpdate(int timerNum) {
_screen->setFont(of);
}
- uint32 nextTimer = 0xffffffff;
+ uint32 nextTimer = 0xFFFFFFFF;
for (int i = 0; i < 10; i++) {
if (c->timers[i] && c->timers[i] < nextTimer)
nextTimer = c->timers[i];
}
- if (nextTimer == 0xffffffff)
+ if (nextTimer == 0xFFFFFFFF)
_timer->disable(timerNum);
else
_timer->setCountdown(timerNum, (nextTimer - ctime) / _tickLength);
diff --git a/engines/kyra/timer_lol.cpp b/engines/kyra/timer_lol.cpp
index a3df8dbe00..9d0cc0dd72 100644
--- a/engines/kyra/timer_lol.cpp
+++ b/engines/kyra/timer_lol.cpp
@@ -49,7 +49,7 @@ void LoLEngine::setupTimers() {
}
void LoLEngine::timerProcessMonsters(int timerNum) {
- for (int i = timerNum & 0x0f; i < 30; i += 2)
+ for (int i = timerNum & 0x0F; i < 30; i += 2)
updateMonster(&_monsters[i]);
}
@@ -77,7 +77,7 @@ void LoLEngine::timerSpecialCharacterUpdate(int timerNum) {
if (_characters[i].characterUpdateDelay[ii] > eventsLeft)
eventsLeft = _characters[i].characterUpdateDelay[ii];
} else {
- _characters[i].flags &= 0xfffb;
+ _characters[i].flags &= 0xFFFB;
}
gui_drawCharPortraitWithStats(i);
@@ -89,7 +89,7 @@ void LoLEngine::timerSpecialCharacterUpdate(int timerNum) {
break;
case 2:
- _characters[i].flags &= 0xffbf;
+ _characters[i].flags &= 0xFFBF;
gui_drawCharPortraitWithStats(i);
break;
@@ -104,7 +104,7 @@ void LoLEngine::timerSpecialCharacterUpdate(int timerNum) {
break;
case 4:
- _characters[i].flags &= 0xfeff;
+ _characters[i].flags &= 0xFEFF;
_txt->printMessage(0, getLangString(0x4027), _characters[i].name);
gui_drawCharPortraitWithStats(i);
break;
@@ -114,7 +114,7 @@ void LoLEngine::timerSpecialCharacterUpdate(int timerNum) {
break;
case 6:
- _characters[i].flags &= 0xefff;
+ _characters[i].flags &= 0xEFFF;
gui_drawCharPortraitWithStats(i);
break;
@@ -146,7 +146,7 @@ void LoLEngine::timerProcessFlyingObjects(int timerNum) {
}
void LoLEngine::timerRunSceneAnimScript(int timerNum) {
- runLevelScript(0x401 + (timerNum & 0x0f), -1);
+ runLevelScript(0x401 + (timerNum & 0x0F), -1);
}
void LoLEngine::timerRegeneratePoints(int timerNum) {
diff --git a/engines/kyra/vqa.cpp b/engines/kyra/vqa.cpp
index 471e83c9ed..081d94a050 100644
--- a/engines/kyra/vqa.cpp
+++ b/engines/kyra/vqa.cpp
@@ -126,8 +126,8 @@ void VQAMovie::decodeSND1(byte *inbuf, uint32 insize, byte *outbuf, uint32 outsi
while (outsize > 0) {
input = *inbuf++ << 2;
- code = (input >> 8) & 0xff;
- count = (input & 0xff) >> 2;
+ code = (input >> 8) & 0xFF;
+ count = (input & 0xFF) >> 2;
switch (code) {
case 2:
@@ -149,7 +149,7 @@ void VQAMovie::decodeSND1(byte *inbuf, uint32 insize, byte *outbuf, uint32 outsi
for (; count >= 0; count--) {
code = *inbuf++;
- curSample += WSTable4Bit[code & 0x0f];
+ curSample += WSTable4Bit[code & 0x0F];
curSample = CLIP<int16>(curSample, 0, 255);
*outbuf++ = curSample;
@@ -264,7 +264,7 @@ bool VQAMovie::open(const char *filename) {
_frameInfo = new uint32[_header.numFrames];
_frame = new byte[_header.width * _header.height];
- _codeBookSize = 0xf00 * _header.blockW * _header.blockH;
+ _codeBookSize = 0xF00 * _header.blockW * _header.blockH;
_codeBook = new byte[_codeBookSize];
_partialCodeBook = new byte[_codeBookSize];
memset(_codeBook, 0, _codeBookSize);