aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Kagerer2009-02-21 23:20:14 +0000
committerFlorian Kagerer2009-02-21 23:20:14 +0000
commitb5b4cb66a173bfea3792058e160f6b9a0b30e2ff (patch)
tree4d2627ad3245dbe95ad70571e2dcdbebe835145a
parentb18ccb755a1fd7b39618d3f64f997d7123f81c26 (diff)
downloadscummvm-rg350-b5b4cb66a173bfea3792058e160f6b9a0b30e2ff.tar.gz
scummvm-rg350-b5b4cb66a173bfea3792058e160f6b9a0b30e2ff.tar.bz2
scummvm-rg350-b5b4cb66a173bfea3792058e160f6b9a0b30e2ff.zip
LOL: implemented timers (only text fading for now)
svn-id: r38766
-rw-r--r--engines/kyra/gui_lol.cpp16
-rw-r--r--engines/kyra/items_lol.cpp10
-rw-r--r--engines/kyra/lol.cpp9
-rw-r--r--engines/kyra/lol.h36
-rw-r--r--engines/kyra/module.mk1
-rw-r--r--engines/kyra/scene_lol.cpp30
-rw-r--r--engines/kyra/script_lol.cpp30
-rw-r--r--engines/kyra/text_lol.cpp7
-rw-r--r--engines/kyra/timer_lol.cpp95
9 files changed, 186 insertions, 48 deletions
diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp
index 8581b47d86..3dbf6f826e 100644
--- a/engines/kyra/gui_lol.cpp
+++ b/engines/kyra/gui_lol.cpp
@@ -980,7 +980,7 @@ int LoLEngine::clickedTurnLeftArrow(Button *button) {
_sceneDefaultUpdate = 1;
- runSceneScript(_currentBlock, 0x4000);
+ runLevelScript(_currentBlock, 0x4000);
initTextFading(2, 0);
if (!_sceneDefaultUpdate)
@@ -989,7 +989,7 @@ int LoLEngine::clickedTurnLeftArrow(Button *button) {
movePartySmoothScrollTurnLeft(1);
gui_toggleButtonDisplayMode(79, 0);
- runSceneScript(_currentBlock, 0x10);
+ runLevelScript(_currentBlock, 0x10);
return 1;
}
@@ -1002,7 +1002,7 @@ int LoLEngine::clickedTurnRightArrow(Button *button) {
_sceneDefaultUpdate = 1;
- runSceneScript(_currentBlock, 0x4000);
+ runLevelScript(_currentBlock, 0x4000);
initTextFading(2, 0);
if (!_sceneDefaultUpdate)
@@ -1011,7 +1011,7 @@ int LoLEngine::clickedTurnRightArrow(Button *button) {
movePartySmoothScrollTurnRight(1);
gui_toggleButtonDisplayMode(81, 0);
- runSceneScript(_currentBlock, 0x10);
+ runLevelScript(_currentBlock, 0x10);
return 1;
}
@@ -1142,7 +1142,7 @@ int LoLEngine::clickedCharInventorySlot(Button *button) {
int ih = _itemInHand;
- pickupItem(_characters[_selectedCharacter].items[button->data2Val2]);
+ setHandItem(_characters[_selectedCharacter].items[button->data2Val2]);
_characters[_selectedCharacter].items[button->data2Val2] = ih;
gui_drawCharInventoryItem(button->data2Val2);
@@ -1198,6 +1198,8 @@ int LoLEngine::clickedScene1(Button *button) {
return 0;
int cp = _screen->setCurPage(_sceneDrawPage1);
+ clickSceneSub1();
+
_screen->setCurPage(cp);
return 1;
@@ -1245,10 +1247,10 @@ int LoLEngine::clickedInventorySlot(Button *button) {
deleteItem(slotItem);
deleteItem(hItem);
- pickupItem(0);
+ setHandItem(0);
_inventory[slot] = makeItem(280, 0, 0);
} else {
- pickupItem(slotItem);
+ setHandItem(slotItem);
_inventory[slot] = hItem;
}
diff --git a/engines/kyra/items_lol.cpp b/engines/kyra/items_lol.cpp
index 7c5267f164..12cdba57ff 100644
--- a/engines/kyra/items_lol.cpp
+++ b/engines/kyra/items_lol.cpp
@@ -182,7 +182,7 @@ void LoLEngine::runItemScript(int charNum, int item, int reg0, int reg3, int reg
_emc->run(&scriptState);
}
-void LoLEngine::pickupItem(int itemIndex) {
+void LoLEngine::setHandItem(uint16 itemIndex) {
if (itemIndex && _itemProperties[_itemsInPlay[itemIndex].itemPropertyIndex].flags & 0x80) {
runItemScript(-1, itemIndex, 0x400, 0, 0);
if (_itemsInPlay[itemIndex].shpCurFrame_flg & 0x8000)
@@ -201,6 +201,14 @@ void LoLEngine::pickupItem(int itemIndex) {
_screen->setMouseCursor(mouseOffs, mouseOffs, getItemIconShapePtr(itemIndex));
}
+void LoLEngine::clickSceneSub1() {
+
+}
+
+void LoLEngine::clickSceneSub1Sub1(int itemX, int itemY, int partyX, int partyY) {
+
+}
+
} // end of namespace Kyra
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp
index 45283e9430..7a2a91d62f 100644
--- a/engines/kyra/lol.cpp
+++ b/engines/kyra/lol.cpp
@@ -27,6 +27,7 @@
#include "kyra/screen_lol.h"
#include "kyra/resource.h"
#include "kyra/sound.h"
+#include "kyra/timer.h"
#include "kyra/util.h"
#include "sound/voc.h"
@@ -773,11 +774,11 @@ void LoLEngine::runLoop() {
while (!shouldQuit() && _runFlag) {
if (_nextScriptFunc) {
- runSceneScript(_nextScriptFunc, 2);
+ runLevelScript(_nextScriptFunc, 2);
_nextScriptFunc = 0;
}
- //updateTimers();
+ _timer->update();
//checkFloatingPointerRegions();
gui_updateInput();
@@ -1022,7 +1023,7 @@ void LoLEngine::initTextFading(int textType, int clearField) {
_screen->clearDim(3);
_fadeText = false;
- //initGuiUnk(11);
+ _timer->disable(11);
}
void LoLEngine::charCallback4(int redraw) {
@@ -1214,7 +1215,7 @@ void LoLEngine::fadeText() {
_screen->clearDim(3);
- ///initGuiUnk(11);
+ _timer->disable(11);
_fadeText = false;
}
diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h
index 537a1af9bd..dcadab6e86 100644
--- a/engines/kyra/lol.h
+++ b/engines/kyra/lol.h
@@ -123,8 +123,8 @@ struct CLevelItem {
uint8 unk2;
uint16 unk3;
uint16 blockPropertyIndex;
- uint16 p_1a;
- uint16 p_1b;
+ uint16 x;
+ uint16 y;
int8 level;
uint16 itemPosX;
uint16 itemPosY;
@@ -161,8 +161,8 @@ struct ItemInPlay {
uint8 unk2;
uint16 unk3;
uint16 blockPropertyIndex;
- uint16 p_1a;
- uint16 p_1b;
+ uint16 x;
+ uint16 y;
int8 level;
uint16 itemPropertyIndex;
uint16 shpCurFrame_flg;
@@ -307,8 +307,19 @@ private:
static const uint8 _charInfoFrameTable[];
- // timer
- void setupTimers() {}
+ // timers
+ void setupTimers();
+ void enableTimer(int id);
+
+ void timerSub1(int timerNum);
+ void timerSub2(int timerNum);
+ void timerSub3(int timerNum);
+ void timerSub4(int timerNum);
+ void timerSub5(int timerNum);
+ void timerSub6(int timerNum);
+ void timerSub7(int timerNum);
+ void timerUpdateLampState(int timerNum);
+ void timerFadeMessageText(int timerNum);
// sound
void loadTalkFile(int index);
@@ -464,8 +475,8 @@ private:
// emc scripts
void runInitScript(const char *filename, int func);
void runInfScript(const char *filename);
- void runSceneScript(int block, int sub);
- void runSceneScriptCustom(int block, int sub, int charNum, int item, int reg3, int reg4);
+ void runLevelScript(int block, int sub);
+ void runLevelScriptCustom(int block, int sub, int charNum, int item, int reg3, int reg4);
bool checkScriptUnk(int func);
EMCData _scriptData;
@@ -502,6 +513,7 @@ private:
int olol_mapShapeToBlock(EMCState *script);
int olol_resetBlockShapeAssignment(EMCState *script);
int olol_loadMonsterProperties(EMCState *script);
+ int olol_setScriptTimer(EMCState *script);
int olol_loadTimScript(EMCState *script);
int olol_runTimScript(EMCState *script);
int olol_releaseTimScript(EMCState *script);
@@ -685,7 +697,7 @@ private:
void drawLevelModifyScreenDim(int dim, int16 x1, int16 y1, int16 x2, int16 y2);
void drawDecorations(int index);
void drawIceShapes(int index, int iceShapeIndex);
- void drawMonstersAndItems(int index);
+ void drawMonstersAndItems(int block);
void drawDoor(uint8 *shape, uint8 *table, int index, int unk2, int w, int h, int flags);
void drawDoorOrMonsterShape(uint8 *shape, uint8 *table, int x, int y, int flags, const uint8 *ovl);
void drawScriptShapes(int pageNum);
@@ -852,8 +864,9 @@ private:
void deleteItem(int itemIndex);
CLevelItem *findItem(uint16 index);
void runItemScript(int charNum, int item, int reg0, int reg3, int reg4);
-
- void pickupItem(int itemIndex);
+ void setHandItem(uint16 itemIndex);
+ void clickSceneSub1();
+ void clickSceneSub1Sub1(int itemX, int itemY, int partyX, int partyY);
uint8 _moneyColumnHeight[5];
uint16 _credits;
@@ -897,7 +910,6 @@ private:
// unneeded
void setWalkspeed(uint8) {}
- void setHandItem(uint16) {}
void removeHandItem() {}
bool lineIsPassable(int, int) { return false; }
diff --git a/engines/kyra/module.mk b/engines/kyra/module.mk
index fa7fa25ce7..f83b936092 100644
--- a/engines/kyra/module.mk
+++ b/engines/kyra/module.mk
@@ -71,6 +71,7 @@ MODULE_OBJS := \
text_mr.o \
timer.o \
timer_lok.o \
+ timer_lol.o \
timer_hof.o \
timer_mr.o \
util.o \
diff --git a/engines/kyra/scene_lol.cpp b/engines/kyra/scene_lol.cpp
index 48c50738d6..1efd337f19 100644
--- a/engines/kyra/scene_lol.cpp
+++ b/engines/kyra/scene_lol.cpp
@@ -26,6 +26,7 @@
#include "kyra/lol.h"
#include "kyra/screen_lol.h"
#include "kyra/resource.h"
+#include "kyra/timer.h"
#include "kyra/sound.h"
#include "common/endian.h"
@@ -54,7 +55,8 @@ void LoLEngine::loadLevel(int index) {
releaseMonsterShapes(0);
releaseMonsterShapes(1);
- // TODO
+ for (int i = 0x50; i < 0x53; i++)
+ _timer->disable(i);
_currentLevel = index;
_updateFlags = 0;
@@ -148,7 +150,7 @@ void LoLEngine::initCMZ1(CLevelItem *l, int a) {
l->field_15 = 0;
l->itemPosX = _partyPosX;
l->itemPosY = _partyPosY;
- cmzS2(l, cmzS1(l->p_1a, l->p_1b, l->itemPosX, l->itemPosY));
+ cmzS2(l, cmzS1(l->x, l->y, l->itemPosX, l->itemPosY));
}
} else {
l->field_14 = a;
@@ -160,7 +162,7 @@ void LoLEngine::initCMZ1(CLevelItem *l, int a) {
cmzS3(l);
if (_currentLevel != 29)
initCMZ1(l, 14);
- runSceneScriptCustom(0x404, -1, l->field_16, l->field_16, 0, 0);
+ runLevelScriptCustom(0x404, -1, l->field_16, l->field_16, 0, 0);
checkScriptUnk(l->blockPropertyIndex);
if (l->field_14 == 14)
initCMZ2(l, 0, 0);
@@ -182,9 +184,9 @@ void LoLEngine::initCMZ2(CLevelItem *l, uint16 a, uint16 b) {
l->blockPropertyIndex = cmzS5(a, b);
- if (l->p_1a != a || l->p_1b != b) {
- l->p_1a = a;
- l->p_1b = b;
+ if (l->x != a || l->y != b) {
+ l->x = a;
+ l->y = b;
l->anon9 = (++l->anon9) & 3;
}
@@ -202,7 +204,7 @@ void LoLEngine::initCMZ2(CLevelItem *l, uint16 a, uint16 b) {
return;
if (l->blockPropertyIndex != t)
- runSceneScriptCustom(l->blockPropertyIndex, 0x800, -1, l->field_16, 0, 0);
+ runLevelScriptCustom(l->blockPropertyIndex, 0x800, -1, l->field_16, 0, 0);
if (_updateFlags & 1)
return;
@@ -432,7 +434,7 @@ void LoLEngine::loadLevelCmzFile(int index) {
if (_cLevelItems[i].blockPropertyIndex) {
_cLevelItems[i].blockPropertyIndex = 0;
_cLevelItems[i].monsters = _monsterProperties + _cLevelItems[i].field_20;
- initCMZ2(&_cLevelItems[i], _cLevelItems[i].p_1a, _cLevelItems[i].p_1b);
+ initCMZ2(&_cLevelItems[i], _cLevelItems[i].x, _cLevelItems[i].y);
}
}
@@ -873,8 +875,8 @@ void LoLEngine::moveParty(uint16 direction, int unk1, int unk2, int buttonShape)
calcCoordinates(_partyPosX, _partyPosY, _currentBlock, 0x80, 0x80);
_unkFlag &= 0xfdff;
- runSceneScript(opos, 4);
- runSceneScript(npos, 1);
+ runLevelScript(opos, 4);
+ runLevelScript(npos, 1);
if (!(_unkFlag & 0x200)) {
initTextFading(2, 0);
@@ -903,8 +905,8 @@ void LoLEngine::moveParty(uint16 direction, int unk1, int unk2, int buttonShape)
gui_toggleButtonDisplayMode(buttonShape, 0);
if (npos == _currentBlock) {
- runSceneScript(opos, 8);
- runSceneScript(npos, 2);
+ runLevelScript(opos, 8);
+ runLevelScript(npos, 2);
if (_levelBlockProperties[npos].walls[0] == 0x1a)
memset(_levelBlockProperties[npos].walls, 0, 4);
@@ -1785,8 +1787,8 @@ void LoLEngine::drawIceShapes(int index, int iceShapeIndex) {
return;
}
-void LoLEngine::drawMonstersAndItems(int index) {
-
+void LoLEngine::drawMonstersAndItems(int block) {
+
}
diff --git a/engines/kyra/script_lol.cpp b/engines/kyra/script_lol.cpp
index 2c4e5cc06a..07645ca508 100644
--- a/engines/kyra/script_lol.cpp
+++ b/engines/kyra/script_lol.cpp
@@ -25,6 +25,7 @@
#include "kyra/lol.h"
#include "kyra/screen_lol.h"
+#include "kyra/timer.h"
#include "kyra/resource.h"
#include "common/endian.h"
@@ -54,14 +55,14 @@ void LoLEngine::runInitScript(const char *filename, int func) {
void LoLEngine::runInfScript(const char *filename) {
_emc->load(filename, &_scriptData, &_opcodes);
- runSceneScript(0x400, -1);
+ runLevelScript(0x400, -1);
}
-void LoLEngine::runSceneScript(int block, int sub) {
- runSceneScriptCustom(block, sub, -1, 0, 0, 0);
+void LoLEngine::runLevelScript(int block, int sub) {
+ runLevelScriptCustom(block, sub, -1, 0, 0, 0);
}
-void LoLEngine::runSceneScriptCustom(int block, int sub, int charNum, int item, int reg3, int reg4) {
+void LoLEngine::runLevelScriptCustom(int block, int sub, int charNum, int item, int reg3, int reg4) {
EMCState scriptState;
memset(&scriptState, 0, sizeof(EMCState));
@@ -182,9 +183,9 @@ int LoLEngine::olol_getItemPara(EMCState *script) {
case 0:
return i->blockPropertyIndex;
case 1:
- return i->p_1a;
+ return i->x;
case 2:
- return i->p_1b;
+ return i->y;
case 3:
return i->level;
case 4:
@@ -561,6 +562,21 @@ int LoLEngine::olol_loadMonsterProperties(EMCState *script) {
return 1;
}
+int LoLEngine::olol_setScriptTimer(EMCState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_setScriptTimer(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
+ uint8 id = 0x50 + stackPos(0);
+
+ if (stackPos(1)) {
+ _timer->enable(id);
+ _timer->setCountdown(id, stackPos(1));
+
+ } else {
+ _timer->disable(id);
+ }
+
+ return true;
+}
+
int LoLEngine::olol_loadTimScript(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_loadTimScript(%p) (%d, %s)", (const void *)script, stackPos(0), stackPosString(1));
if (_activeTim[stackPos(0)])
@@ -843,7 +859,7 @@ void LoLEngine::setupOpcodeTable() {
OpcodeUnImpl();
// 0x48
- OpcodeUnImpl();
+ Opcode(olol_setScriptTimer);
OpcodeUnImpl();
OpcodeUnImpl();
OpcodeUnImpl();
diff --git a/engines/kyra/text_lol.cpp b/engines/kyra/text_lol.cpp
index 9f724b9486..68523d4c82 100644
--- a/engines/kyra/text_lol.cpp
+++ b/engines/kyra/text_lol.cpp
@@ -25,6 +25,7 @@
#include "kyra/lol.h"
#include "kyra/screen_lol.h"
+#include "kyra/timer.h"
#include "kyra/util.h"
namespace Kyra {
@@ -94,7 +95,7 @@ void TextDisplayer_LoL::expandField() {
if (_vm->textEnabled()) {
_vm->_fadeText = false;
_vm->_textColourFlag = 0;
- //_vm->toggleGuiUnk(11, 0);
+ _vm->_timer->disable(11);
_screen->clearDim(3);
_screen->copyRegionToBuffer(3, 0, 0, 320, 200, _vm->_pageBuffer1);
_screen->copyRegion(83, 140, 0, 0, 235, 3, 0, 2, Screen::CR_NO_P_CHECK);
@@ -149,7 +150,7 @@ void TextDisplayer_LoL::playDialogue(int dim, char *str, EMCState *script, int16
_colour1 = 192;
_colour1prot = true;
_screen->copyColour(192, 254);
- //toggleGuiUnk(11, 1);
+ _vm->enableTimer(11);
_vm->_textColourFlag = 0;
_vm->_fadeText = false;
}
@@ -207,7 +208,7 @@ void TextDisplayer_LoL::printMessage(uint16 type, char *str, ...) {
_screen->setScreenDim(3);
_screen->clearCurDim();
_screen->copyColour(192, col);
- //toggleGuiUnk(11, 1);
+ _vm->enableTimer(11);
}
_colour1 = 192;
diff --git a/engines/kyra/timer_lol.cpp b/engines/kyra/timer_lol.cpp
new file mode 100644
index 0000000000..594aa1733e
--- /dev/null
+++ b/engines/kyra/timer_lol.cpp
@@ -0,0 +1,95 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "kyra/lol.h"
+#include "kyra/screen_lol.h"
+#include "kyra/timer.h"
+
+namespace Kyra {
+
+#define TimerV2(x) new Common::Functor1Mem<int, void, LoLEngine>(this, &LoLEngine::x)
+
+void LoLEngine::setupTimers() {
+ debugC(9, kDebugLevelMain | kDebugLevelTimer, "LoLEngine::setupTimers()");
+
+ _timer->addTimer(0, TimerV2(timerSub1), 15, true);
+ _timer->addTimer(0x10, TimerV2(timerSub2), 6, true);
+ _timer->addTimer(0x11, TimerV2(timerSub2), 6, true);
+ _timer->setNextRun(0x11, 3);
+ _timer->addTimer(3, TimerV2(timerSub3), 15, true);
+ _timer->addTimer(4, TimerV2(timerSub4), 1, true);
+ _timer->addTimer(0x50, TimerV2(timerSub5), 0, false);
+ _timer->addTimer(0x51, TimerV2(timerSub5), 0, false);
+ _timer->addTimer(0x52, TimerV2(timerSub5), 0, false);
+ _timer->addTimer(8, TimerV2(timerSub6), 1200, true);
+ _timer->addTimer(9, TimerV2(timerSub7), 10, true);
+ _timer->addTimer(10, TimerV2(timerUpdateLampState), 360, true);
+ _timer->addTimer(11, TimerV2(timerFadeMessageText), 360, false);
+}
+
+void LoLEngine::enableTimer(int id) {
+ _timer->enable(id);
+ _timer->setNextRun(id, _system->getMillis() + _timer->getDelay(id) * _tickLength);
+}
+
+void LoLEngine::timerSub1(int timerNum) {
+
+}
+
+void LoLEngine::timerSub2(int timerNum) {
+
+}
+
+void LoLEngine::timerSub3(int timerNum) {
+
+}
+
+void LoLEngine::timerSub4(int timerNum) {
+
+}
+
+void LoLEngine::timerSub5(int timerNum) {
+ runLevelScript(0x401 + (timerNum & 0x0f), -1);
+}
+
+void LoLEngine::timerSub6(int timerNum) {
+
+}
+
+void LoLEngine::timerSub7(int timerNum) {
+
+}
+
+void LoLEngine::timerUpdateLampState(int timerNum) {
+ if ((_screen->_drawGuiFlag & 0x800) && (_screen->_drawGuiFlag & 0x400) && _lampStatusUnk)
+ _lampStatusUnk--;
+}
+
+void LoLEngine::timerFadeMessageText(int timerNum) {
+ _timer->disable(timerNum);
+ initTextFading(0, 0);
+}
+
+} // end of namespace Kyra