aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorEugene Sandulenko2005-05-23 02:23:34 +0000
committerEugene Sandulenko2005-05-23 02:23:34 +0000
commit0ccb1b726b80de340408946412a757d7b90253d8 (patch)
tree48abd600af3150579206c3432a44a8f77c566d34 /saga
parentb9e8e4080559f0ce9b249d3fb4c39db1431692f0 (diff)
downloadscummvm-rg350-0ccb1b726b80de340408946412a757d7b90253d8.tar.gz
scummvm-rg350-0ccb1b726b80de340408946412a757d7b90253d8.tar.bz2
scummvm-rg350-0ccb1b726b80de340408946412a757d7b90253d8.zip
Plug in Puzzle. Now it consists mainly of stubs but neverthless lets skip
the Puzzle and continue game pretending like you completed the Puzzle. svn-id: r18225
Diffstat (limited to 'saga')
-rw-r--r--saga/actor.cpp8
-rw-r--r--saga/actor.h2
-rw-r--r--saga/interface.cpp7
-rw-r--r--saga/module.mk1
-rw-r--r--saga/puzzle.cpp68
-rw-r--r--saga/puzzle.h55
-rw-r--r--saga/render.cpp15
-rw-r--r--saga/resnames.h2
-rw-r--r--saga/saga.cpp24
-rw-r--r--saga/saga.h2
-rw-r--r--saga/scene.cpp6
-rw-r--r--saga/scene.h2
-rw-r--r--saga/script.h2
-rw-r--r--saga/sfuncs.cpp10
14 files changed, 179 insertions, 25 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp
index 25d4156aa3..26005fc222 100644
--- a/saga/actor.cpp
+++ b/saga/actor.cpp
@@ -1298,13 +1298,19 @@ void Actor::drawActors() {
}
}
-// draw speeches
+ drawSpeech();
+}
+
+void Actor::drawSpeech(void) {
if (isSpeaking() && _activeSpeech.playing && !_vm->_script->_skipSpeeches) {
int i;
int textDrawFlags;
char oneChar[2];
oneChar[1] = 0;
const char *outputString;
+ SURFACE *back_buf;
+
+ back_buf = _vm->_gfx->getBackBuffer();
if (_activeSpeech.speechFlags & kSpeakSlow) {
outputString = oneChar;
diff --git a/saga/actor.h b/saga/actor.h
index d1d53e73d7..d2ddd00d3f 100644
--- a/saga/actor.h
+++ b/saga/actor.h
@@ -471,6 +471,8 @@ public:
void drawActors();
void updateActorsScene(int actorsEntrance); // calls from scene loading to update Actors info
+ void drawSpeech();
+
void drawPathTest();
uint16 hitTest(const Point &testPoint, bool skipProtagonist);
diff --git a/saga/interface.cpp b/saga/interface.cpp
index f946b2b489..5ef8e0357b 100644
--- a/saga/interface.cpp
+++ b/saga/interface.cpp
@@ -30,6 +30,7 @@
#include "saga/font.h"
#include "saga/objectmap.h"
#include "saga/itedata.h"
+#include "saga/puzzle.h"
#include "saga/rscfile_mod.h"
#include "saga/scene.h"
#include "saga/script.h"
@@ -302,7 +303,8 @@ bool Interface::processKeyCode(int keyCode) {
switch (keyCode) {
case 'x':
setMode(kPanelMain);
- // FIXME: puzzle
+ if (_vm->_puzzle->isActive())
+ _vm->_puzzle->exitPuzzle();
break;
case 'u':
@@ -1124,7 +1126,8 @@ void Interface::converseSetPos(int key) {
_vm->_script->finishDialog(ct->replyId, ct->replyFlags, ct->replyBit);
- // FIXME: TODO: Puzzle
+ if (_vm->_puzzle->isActive())
+ _vm->_puzzle->handleReply(ct->replyId);
_conversePos = -1;
}
diff --git a/saga/module.mk b/saga/module.mk
index adbb632b66..8a358f7a21 100644
--- a/saga/module.mk
+++ b/saga/module.mk
@@ -16,6 +16,7 @@ MODULE_OBJS := \
saga/ite_introproc.o \
saga/itedata.o \
saga/objectmap.o \
+ saga/puzzle.o \
saga/palanim.o \
saga/render.o \
saga/rscfile.o \
diff --git a/saga/puzzle.cpp b/saga/puzzle.cpp
new file mode 100644
index 0000000000..7756931f63
--- /dev/null
+++ b/saga/puzzle.cpp
@@ -0,0 +1,68 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2005 The ScummVM project
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "saga/saga.h"
+
+#include "saga/interface.h"
+#include "saga/scene.h"
+#include "saga/puzzle.h"
+#include "saga/resnames.h"
+
+#include "common/timer.h"
+
+namespace Saga {
+
+Puzzle::Puzzle(SagaEngine *vm) : _vm(vm), _solved(false), _active(false) {
+}
+
+void Puzzle::execute(void) {
+ _active = true;
+ Common::g_timer->installTimerProc(&hintTimerCallback, ticksToMSec(30), this);
+
+ _solved = true; // Cheat
+ exitPuzzle();
+}
+
+void Puzzle::exitPuzzle(void) {
+ _active = false;
+
+ Common::g_timer->removeTimerProc(&hintTimerCallback);
+
+ _vm->_scene->changeScene(ITE_SCENE_LODGE, 0, kTransitionNoFade);
+ _vm->_interface->setMode(kPanelMain);
+}
+
+
+void Puzzle::hintTimerCallback(void *refCon) {
+ ((Puzzle *)refCon)->hintTimer();
+}
+
+void Puzzle::hintTimer(void) {
+}
+
+void Puzzle::handleReply(int reply) {
+}
+
+void Puzzle::movePiece(Point mousePt) {
+}
+
+
+} // End of namespace Saga
diff --git a/saga/puzzle.h b/saga/puzzle.h
new file mode 100644
index 0000000000..f857f5b969
--- /dev/null
+++ b/saga/puzzle.h
@@ -0,0 +1,55 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2005 The ScummVM project
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#ifndef SAGA_PUZZLE_H_
+#define SAGA_PUZZLE_H_
+
+namespace Saga {
+
+class Puzzle {
+private:
+ SagaEngine *_vm;
+
+ bool _solved;
+ bool _active;
+
+public:
+ Puzzle(SagaEngine *vm);
+
+ void execute(void);
+ void exitPuzzle(void);
+
+ bool isSolved(void) { return _solved; }
+ bool isActive(void) { return _active; }
+
+ void handleReply(int reply);
+
+ void movePiece(Point mousePt);
+
+private:
+ static void hintTimerCallback(void *refCon);
+
+ void hintTimer(void);
+};
+
+} // End of namespace Saga
+
+#endif
diff --git a/saga/render.cpp b/saga/render.cpp
index 7410e7f3a4..6276402694 100644
--- a/saga/render.cpp
+++ b/saga/render.cpp
@@ -24,16 +24,15 @@
// Main rendering loop
#include "saga/saga.h"
-#include "saga/gfx.h"
#include "saga/actor.h"
#include "saga/font.h"
+#include "saga/gfx.h"
#include "saga/interface.h"
-#include "saga/scene.h"
-#include "saga/text.h"
-
#include "saga/objectmap.h"
-
+#include "saga/puzzle.h"
#include "saga/render.h"
+#include "saga/scene.h"
+#include "saga/text.h"
#include "common/timer.h"
#include "common/system.h"
@@ -119,6 +118,12 @@ int Render::drawScene() {
if (_vm->_interface->getMode() != kPanelFade) {
// Draw queued actors
_vm->_actor->drawActors();
+
+ if (_vm->_puzzle->isActive()) {
+ _vm->_puzzle->movePiece(mouse_pt);
+ _vm->_actor->drawSpeech();
+ }
+
if (getFlags() & RF_OBJECTMAP_TEST) {
if (_vm->_scene->_objectMap)
_vm->_scene->_objectMap->draw(backbuf_surface, mouse_pt, kITEColorBrightWhite, kITEColorBlack);
diff --git a/saga/resnames.h b/saga/resnames.h
index 10a236b8a8..a4aee1dcba 100644
--- a/saga/resnames.h
+++ b/saga/resnames.h
@@ -45,6 +45,8 @@ namespace Saga {
// SCENES
#define ITE_SCENE_INV -1
+#define ITE_SCENE_PUZZLE 26
+#define ITE_SCENE_LODGE 21
#define ITE_DEFAULT_SCENE 32
#define IHNM_DEFAULT_SCENE 152
diff --git a/saga/saga.cpp b/saga/saga.cpp
index fc7fcbad85..4695016518 100644
--- a/saga/saga.cpp
+++ b/saga/saga.cpp
@@ -44,6 +44,7 @@
#include "saga/font.h"
#include "saga/interface.h"
#include "saga/isomap.h"
+#include "saga/puzzle.h"
#include "saga/script.h"
#include "saga/scene.h"
#include "saga/sndres.h"
@@ -138,6 +139,7 @@ SagaEngine::SagaEngine(GameDetector *detector, OSystem *syst)
_render = NULL;
_music = NULL;
_sound = NULL;
+ _puzzle = NULL;
// The Linux version of Inherit the Earth puts all data files in an
@@ -170,6 +172,7 @@ SagaEngine::~SagaEngine() {
_scene->endScene();
}
+ delete _puzzle;
delete _sndRes;
delete _events;
delete _font;
@@ -234,6 +237,7 @@ int SagaEngine::init(GameDetector &detector) {
_palanim = new PalAnim(this);
_scene = new Scene(this);
_isoMap = new IsoMap(this);
+ _puzzle = new Puzzle(this);
if (!_scene->initialized()) {
warning("Couldn't initialize scene module");
@@ -245,7 +249,7 @@ int SagaEngine::init(GameDetector &detector) {
_previousTicks = _system->getMillis();
// Initialize graphics
- _gfx = new Gfx(_system, _vm->getDisplayWidth(), _vm->getDisplayHeight(), detector);
+ _gfx = new Gfx(_system, getDisplayWidth(), getDisplayHeight(), detector);
// Graphics driver should be initialized before console
_console = new Console(this);
@@ -319,10 +323,14 @@ int SagaEngine::go() {
msec = MAX_TIME_DELTA;
}
- if (!_vm->_scene->isInDemo() && getGameType() == GType_ITE)
- if (_vm->_interface->getMode() == kPanelMain ||
- _vm->_interface->getMode() == kPanelConverse ||
- _vm->_interface->getMode() == kPanelNull)
+ // Since Puzzle is actorless, we do it here
+ if (_puzzle->isActive())
+ _actor->handleSpeech(msec);
+
+ if (!_scene->isInDemo() && getGameType() == GType_ITE)
+ if (_interface->getMode() == kPanelMain ||
+ _interface->getMode() == kPanelConverse ||
+ _interface->getMode() == kPanelNull)
_actor->direct(msec);
_events->handleEvents(msec);
@@ -383,8 +391,8 @@ const char *SagaEngine::getObjectName(uint16 objectId) {
return _actor->_actorsStrings.getString(actor->nameIndex);
break;
case kGameObjectHitZone:
- hitZone = _vm->_scene->_objectMap->getHitZone(objectIdToIndex(objectId));
- return _vm->_scene->_sceneStrings.getString(hitZone->getNameIndex());
+ hitZone = _scene->_objectMap->getHitZone(objectIdToIndex(objectId));
+ return _scene->_sceneStrings.getString(hitZone->getNameIndex());
}
warning("SagaEngine::getObjectName name not found for 0x%X", objectId);
return NULL;
@@ -392,7 +400,7 @@ const char *SagaEngine::getObjectName(uint16 objectId) {
const char *SagaEngine::getTextString(int textStringId) {
const char *string;
- int lang = _vm->getFeatures() & GF_LANG_DE ? 1 : 0;
+ int lang = getFeatures() & GF_LANG_DE ? 1 : 0;
string = interfaceTextStrings[lang][textStringId];
if (!string)
diff --git a/saga/saga.h b/saga/saga.h
index fa417eb404..5e2db072bd 100644
--- a/saga/saga.h
+++ b/saga/saga.h
@@ -55,6 +55,7 @@ class Interface;
class Console;
class Events;
class PalAnim;
+class Puzzle;
#define MIN_IMG_RLECODE 3
#define MODEX_SCANLINE_LIMIT 200
@@ -482,6 +483,7 @@ public:
Console *_console;
Events *_events;
PalAnim *_palanim;
+ Puzzle *_puzzle;
/** Random number generator */
diff --git a/saga/scene.cpp b/saga/scene.cpp
index 33eec23349..0464618c50 100644
--- a/saga/scene.cpp
+++ b/saga/scene.cpp
@@ -32,6 +32,7 @@
#include "saga/isomap.h"
#include "saga/objectmap.h"
#include "saga/palanim.h"
+#include "saga/puzzle.h"
#include "saga/render.h"
#include "saga/rscfile_mod.h"
#include "saga/script.h"
@@ -620,9 +621,12 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) {
// We probably don't want "followers" to go into scene -1 , 0. At the very
// least we don't want garbage to be drawn that early in the ITE intro.
- if (_sceneNumber > 0)
+ if (_sceneNumber > 0 && _sceneNumber != ITE_SCENE_PUZZLE)
_vm->_actor->updateActorsScene(loadSceneParams->actorsEntrance);
+ if (_sceneNumber == ITE_SCENE_PUZZLE)
+ _vm->_puzzle->execute();
+
if (_sceneDescription.flags & kSceneFlagShowCursor)
_vm->_interface->activate();
diff --git a/saga/scene.h b/saga/scene.h
index d16fc4573b..f92661bb04 100644
--- a/saga/scene.h
+++ b/saga/scene.h
@@ -120,7 +120,7 @@ struct SceneEntryList {
const SceneEntry * getEntry(int index) {
if ((index < 0) || (index >= entryListCount)) {
- error("SceneEntryList::getEntry wrong index");
+ error("SceneEntryList::getEntry wrong index (%d)", index);
}
return &entryList[index];
}
diff --git a/saga/script.h b/saga/script.h
index 1639249a57..04fd328101 100644
--- a/saga/script.h
+++ b/saga/script.h
@@ -530,7 +530,7 @@ private:
void SF_tossRif(SCRIPTFUNC_PARAMS);
void SF_showControls(SCRIPTFUNC_PARAMS);
void SF_showMap(SCRIPTFUNC_PARAMS);
- void SF_puzzleWon(SCRIPTFUNC_PARAMS);
+ void sfPuzzleWon(SCRIPTFUNC_PARAMS);
void sfEnableEscape(SCRIPTFUNC_PARAMS);
void sfPlaySound(SCRIPTFUNC_PARAMS);
void SF_playLoopedSound(SCRIPTFUNC_PARAMS);
diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp
index 751861018d..28d66f9947 100644
--- a/saga/sfuncs.cpp
+++ b/saga/sfuncs.cpp
@@ -34,6 +34,7 @@
#include "saga/interface.h"
#include "saga/music.h"
#include "saga/itedata.h"
+#include "saga/puzzle.h"
#include "saga/render.h"
#include "saga/sound.h"
#include "saga/sndres.h"
@@ -118,7 +119,7 @@ void Script::setupScriptFuncList(void) {
OPCODE(SF_tossRif),
OPCODE(SF_showControls),
OPCODE(SF_showMap),
- OPCODE(SF_puzzleWon),
+ OPCODE(sfPuzzleWon),
OPCODE(sfEnableEscape),
OPCODE(sfPlaySound),
OPCODE(SF_playLoopedSound),
@@ -1501,11 +1502,8 @@ void Script::SF_showMap(SCRIPTFUNC_PARAMS) {
}
// Script function #68 (0x44)
-void Script::SF_puzzleWon(SCRIPTFUNC_PARAMS) {
- for (int i = 0; i < nArgs; i++)
- thread->pop();
-
- debug(0, "STUB: SF_puzzleWon(), %d args", nArgs);
+void Script::sfPuzzleWon(SCRIPTFUNC_PARAMS) {
+ thread->_returnValue = _vm->_puzzle->isSolved();
}
// Script function #69 (0x45)