aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/illusions/actor.cpp1
-rw-r--r--engines/illusions/duckman/duckman_specialcode.cpp197
-rw-r--r--engines/illusions/duckman/duckman_specialcode.h27
-rw-r--r--engines/illusions/duckman/illusions_duckman.cpp2
-rw-r--r--engines/illusions/duckman/scriptopcodes_duckman.cpp3
-rw-r--r--engines/illusions/module.mk1
-rw-r--r--engines/illusions/resources/genericresource.cpp40
-rw-r--r--engines/illusions/resources/genericresource.h45
-rw-r--r--engines/illusions/resourcesystem.h2
9 files changed, 314 insertions, 4 deletions
diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp
index 91929466be..29a1e6883c 100644
--- a/engines/illusions/actor.cpp
+++ b/engines/illusions/actor.cpp
@@ -940,7 +940,6 @@ void Control::drawActorRect(const Common::Rect r, byte color) {
}
void Control::fillActor(byte color) {
- debug("FILL %d, %d", _actor->_surface->w, _actor->_surface->h);
Common::Rect r = Common::Rect(_actor->_surface->w, _actor->_surface->h);
_actor->_surface->fillRect(r, color);
_actor->_flags |= 0x4000;
diff --git a/engines/illusions/duckman/duckman_specialcode.cpp b/engines/illusions/duckman/duckman_specialcode.cpp
index b0b859c30e..f0c3698520 100644
--- a/engines/illusions/duckman/duckman_specialcode.cpp
+++ b/engines/illusions/duckman/duckman_specialcode.cpp
@@ -27,8 +27,14 @@
#include "illusions/duckman/propertytimers.h"
#include "illusions/duckman/scriptopcodes_duckman.h"
#include "illusions/actor.h"
+#include "illusions/dictionary.h"
+#include "illusions/resources/fontresource.h"
#include "illusions/resources/scriptresource.h"
+#include "illusions/sound.h"
#include "illusions/specialcode.h"
+#include "illusions/textdrawer.h"
+#include "illusions/time.h"
+#include "illusions/updatefunctions.h"
#include "engines/util.h"
@@ -43,6 +49,8 @@ DuckmanSpecialCode::DuckmanSpecialCode(IllusionsEngine_Duckman *vm)
_inventory = new DuckmanInventory(_vm);
_wasCursorHoldingElvisPoster = false;
_counter = 0;
+ _savedTempMasterSfxVolume = 16;
+ _lastRandomSoundIndex = 6;
}
DuckmanSpecialCode::~DuckmanSpecialCode() {
@@ -71,11 +79,15 @@ void DuckmanSpecialCode::init() {
SPECIAL(0x00160012, spcStopScreenShaker);
SPECIAL(0x00160013, spcIncrCounter);
SPECIAL(0x00160014, spcUpdateObject272Sequence);
+ SPECIAL(0x00160017, spcPlayRandomSound);
SPECIAL(0x0016001A, spcHoldGlowingElvisPoster);
+ SPECIAL(0x0016001B, spcStartCredits);
SPECIAL(0x0016001C, spcSetCursorInventoryMode);
SPECIAL(0x0016001D, spcCenterCurrentScreenText);
SPECIAL(0x0016001E, spcSetDefaultTextCoords);
SPECIAL(0x0016001F, spcSetTextDuration);
+ SPECIAL(0x00160020, spcSetTempMasterSfxVolume);
+ SPECIAL(0x00160021, spcRestoreTempMasterSfxVolume);
}
#undef SPECIAL
@@ -168,7 +180,6 @@ void DuckmanSpecialCode::spcInitTeleporterPosition(OpCall &opCall) {
}
void DuckmanSpecialCode::spcUpdateTeleporterPosition(OpCall &opCall) {
- // TODO
ARG_BYTE(direction);
int16 deltaX = 0;
int16 deltaY = 0;
@@ -286,6 +297,19 @@ void DuckmanSpecialCode::spcUpdateObject272Sequence(OpCall &opCall) {
control->startSequenceActor(sequenceId, 2, opCall._threadId);
}
+void DuckmanSpecialCode::spcPlayRandomSound(OpCall &opCall) {
+ static const uint32 kRandomSoundIds[] = {
+ 0x00090084, 0x00090085, 0x00090086, 0x00090087, 0x00090088, 0x00090089
+ };
+ int16 soundIndex;
+ do {
+ soundIndex = _vm->getRandom(ARRAYSIZE(kRandomSoundIds));
+ } while (soundIndex == _lastRandomSoundIndex);
+ _vm->_soundMan->playSound(kRandomSoundIds[soundIndex], 255, 0);
+ _lastRandomSoundIndex = soundIndex;
+ _vm->notifyThreadId(opCall._threadId);
+}
+
void DuckmanSpecialCode::spcHoldGlowingElvisPoster(OpCall &opCall) {
const uint32 kPosterObjectId = 0x40072;
const uint32 kPosterSequenceId = 0x60034;
@@ -312,6 +336,13 @@ void DuckmanSpecialCode::spcHoldGlowingElvisPoster(OpCall &opCall) {
_vm->notifyThreadId(opCall._threadId);
}
+void DuckmanSpecialCode::spcStartCredits(OpCall &opCall) {
+ ARG_BYTE(mode);
+ if (mode == 0)
+ startCredits();
+ _vm->notifyThreadId(opCall._threadId);
+}
+
void DuckmanSpecialCode::spcSetCursorInventoryMode(OpCall &opCall) {
ARG_BYTE(mode);
ARG_BYTE(value);
@@ -339,6 +370,19 @@ void DuckmanSpecialCode::spcSetTextDuration(OpCall &opCall) {
_vm->notifyThreadId(opCall._threadId);
}
+void DuckmanSpecialCode::spcSetTempMasterSfxVolume(OpCall &opCall) {
+ ARG_INT16(sfxVolume);
+ // TODO _savedTempMasterSfxVolume = _vm->getMasterSfxVolume();
+ // TODO _vm->setMasterSfxVolume(sfxVolume);
+ _vm->notifyThreadId(opCall._threadId);
+}
+
+void DuckmanSpecialCode::spcRestoreTempMasterSfxVolume(OpCall &opCall) {
+ // TODO _vm->setMasterSfxVolume(_savedTempMasterSfxVolume);
+ _savedTempMasterSfxVolume = 16;
+ _vm->notifyThreadId(opCall._threadId);
+}
+
void DuckmanSpecialCode::updateTeleporterProperties() {
_vm->_scriptResource->_properties.set(0x000E0074, _teleporterPosition.x == 4 && _teleporterPosition.y == 2);
_vm->_scriptResource->_properties.set(0x000E0075, _teleporterPosition.x == 4 && _teleporterPosition.y == 3);
@@ -347,4 +391,155 @@ void DuckmanSpecialCode::updateTeleporterProperties() {
_vm->_scriptResource->_properties.set(0x000E0078, _teleporterPosition.x == 1 && _teleporterPosition.y == 1);
}
+void DuckmanSpecialCode::startCredits() {
+ static const struct { uint32 objectId; int scrollPosY; } kCreditsItems[] = {
+ {0x40136, 0}, {0x40137, 16}, {0x40138, 32}, {0x40139, 48},
+ {0x4013A, 64}, {0x4013B, 80}, {0x4013C, 96}, {0x4013D, 112}
+ };
+ _creditsCurrText = (char*)_vm->_resSys->getResource(0x190052)->_data;
+ _creditsItems.clear();
+ for (uint i = 0; i < ARRAYSIZE(kCreditsItems); ++i) {
+ CreditsItem creditsItem;
+ creditsItem.objectId = kCreditsItems[i].objectId;
+ creditsItem.scrollPosY = kCreditsItems[i].scrollPosY;
+ creditsItem.scrollPosIndex = 0;
+ creditsItem.active = false;
+ _creditsItems.push_back(creditsItem);
+ }
+ uint32 currSceneId = _vm->getCurrentScene();
+ _vm->_updateFunctions->add(0, currSceneId, new Common::Functor1Mem<uint, int, DuckmanSpecialCode>(this, &DuckmanSpecialCode::updateCredits));
+ _creditsNextUpdateTicks = getCurrentTime();
+ _creditsLastUpdateTicks = _creditsNextUpdateTicks - 4;
+}
+
+int DuckmanSpecialCode::updateCredits(uint flags) {
+
+ if (_vm->_pauseCtr > 0) {
+ _creditsNextUpdateTicks = getCurrentTime() + 4;
+ return 1;
+ }
+
+ if (flags & 1) {
+ _vm->_scriptResource->_properties.set(0x000E0096, true);
+ _lastCreditsItemIndex = -1;
+ _creditsEndReached = false;
+ return 2;
+ }
+
+ if (!isTimerExpired(_creditsLastUpdateTicks, _creditsNextUpdateTicks)) {
+ return 1;
+ }
+
+ bool creditsRunning = false;
+ int index = 0;
+ for (CreditsItems::iterator it = _creditsItems.begin(); it != _creditsItems.end(); ++it, ++index) {
+ CreditsItem &creditsItem = *it;
+ Control *control = _vm->getObjectControl(creditsItem.objectId);
+ if (!creditsItem.active && creditsItem.scrollPosY == 0 && !_creditsEndReached) {
+ creditsItem.active = true;
+ creditsItem.scrollPosIndex = 0;
+ control->fillActor(0);
+ char *text = readNextCreditsLine();
+ if (!strncmp(text, "&&&END", 6)) {
+ creditsItem.active = false;
+ _creditsEndReached = true;
+ } else {
+ uint16 wtext[128];
+ charToWChar(text, wtext, ARRAYSIZE(wtext));
+
+ FontResource *font = _vm->_dict->findFont(0x120001);
+ TextDrawer textDrawer;
+ WidthHeight dimensions;
+ uint16 *outText;
+ control->getActorFrameDimensions(dimensions);
+ textDrawer.wrapText(font, wtext, &dimensions, Common::Point(0, 0), 2, outText);
+ textDrawer.drawText(_vm->_screen, control->_actor->_surface, 0, 0);
+ control->_actor->_flags |= 0x4000;
+
+ _lastCreditsItemIndex = index;
+ }
+ }
+ if (creditsItem.active) {
+ if (_creditsEndReached && _creditsItems[_lastCreditsItemIndex].scrollPosIndex > 53) {
+ creditsItem.active = false;
+ creditsItem.scrollPosY = -1;
+ } else {
+ creditsRunning = true;
+ control->_actor->_position = getCreditsItemPosition(creditsItem.scrollPosIndex);
+ ++creditsItem.scrollPosIndex;
+ if (getCreditsItemPosition(creditsItem.scrollPosIndex).x < 0)
+ creditsItem.active = false;
+ }
+ }
+ if (creditsItem.scrollPosY > 0)
+ --creditsItem.scrollPosY;
+ }
+ _creditsLastUpdateTicks = _creditsNextUpdateTicks;
+ _creditsNextUpdateTicks = getCurrentTime() + 4;
+
+ if (!creditsRunning) {
+ _vm->_scriptResource->_properties.set(0x000E0096, true);
+ _lastCreditsItemIndex = -1;
+ _creditsEndReached = false;
+ return 2;
+ }
+
+ return 1;
+}
+
+char *DuckmanSpecialCode::readNextCreditsLine() {
+ static char line[256];
+ char *dest = line;
+ char *src = _creditsCurrText;
+ do {
+ if (*src == 10 || *src == 13) {
+ src += 2;
+ *dest = 0;
+ break;
+ }
+ *dest++ = *src++;
+ } while (1);
+ _creditsCurrText = src;
+ return line;
+}
+
+Common::Point DuckmanSpecialCode::getCreditsItemPosition(int index) {
+ static const struct { int16 x, y; } kCreditsItemsPoints[] = {
+ {159, 200}, {158, 195}, {157, 190}, {156, 185}, {156, 180}, {157, 176},
+ {158, 172}, {159, 168}, {161, 164}, {162, 161}, {163, 158}, {163, 155},
+ {162, 152}, {161, 149}, {159, 147}, {158, 144}, {157, 142}, {156, 140},
+ {156, 138}, {157, 136}, {158, 134}, {159, 132}, {161, 130}, {162, 128},
+ {163, 127}, {163, 126}, {162, 125}, {161, 124}, {159, 123}, {158, 122},
+ {157, 121}, {156, 120}, {156, 119}, {157, 118}, {158, 117}, {159, 116},
+ {161, 115}, {162, 114}, {163, 113}, {163, 112}, {162, 111}, {161, 110},
+ {159, 109}, {158, 108}, {157, 107}, {156, 106}, {156, 105}, {157, 104},
+ {158, 103}, {159, 102}, {161, 101}, {162, 100}, {163, 99}, {163, 98},
+ {162, 97}, {161, 96}, {159, 95}, {158, 94}, {157, 93}, {156, 92},
+ {156, 91}, {157, 90}, {158, 89}, {159, 88}, {161, 87}, {162, 86},
+ {163, 85}, {163, 84}, {162, 83}, {161, 82}, {159, 81}, {158, 80},
+ {157, 79}, {156, 78}, {156, 77}, {157, 76}, {158, 75}, {159, 74},
+ {161, 73}, {162, 72}, {163, 71}, {163, 70}, {162, 69}, {161, 68},
+ {159, 67}, {158, 66}, {157, 64}, {156, 62}, {156, 60}, {157, 58},
+ {158, 56}, {159, 54}, {161, 52}, {162, 50}, {163, 40}, {163, 40},
+ {162, 40}, {161, 40}, {159, 40}, {158, 40}, {157, 40}, {156, 40},
+ {156, 40}, {157, 40}, {158, 40}, {159, 40}, {161, 40}, {162, 40},
+ {163, 40}, {163, 40}, {162, 40}, {161, 40}, {159, 40}, {158, 40},
+ {157, 40}, {156, 40}, {156, 40}, {157, 40}, {158, 40}, {159, 40},
+ {161, 40}, {162, 40}, {163, 40}, {163, 40}, {162, 40}, {161, 40},
+ {159, 40}, {158, 40}, { -1, -1}
+ };
+
+ if (index < 0 || index >= ARRAYSIZE(kCreditsItemsPoints))
+ return Common::Point(-1, -1);
+ return Common::Point(kCreditsItemsPoints[index].x, kCreditsItemsPoints[index].y);
+}
+
+void DuckmanSpecialCode::charToWChar(char *text, uint16 *wtext, uint size) {
+ while (*text != 0 && size > 1) {
+ *wtext++ = (byte)*text++;
+ --size;
+ }
+ *wtext++ = 0;
+}
+
} // End of namespace Illusions
diff --git a/engines/illusions/duckman/duckman_specialcode.h b/engines/illusions/duckman/duckman_specialcode.h
index 83430a49ba..9176a643b0 100644
--- a/engines/illusions/duckman/duckman_specialcode.h
+++ b/engines/illusions/duckman/duckman_specialcode.h
@@ -35,6 +35,13 @@ class PropertyTimers;
typedef Common::Functor1<OpCall&, void> SpecialCodeFunction;
+struct CreditsItem {
+ uint32 objectId;
+ bool active;
+ int16 scrollPosIndex;
+ int16 scrollPosY;
+};
+
class DuckmanSpecialCode : public SpecialCode {
public:
DuckmanSpecialCode(IllusionsEngine_Duckman *vm);
@@ -44,6 +51,7 @@ public:
public:
typedef Common::HashMap<uint32, SpecialCodeFunction*> SpecialCodeMap;
typedef SpecialCodeMap::iterator SpecialCodeMapIterator;
+ typedef Common::Array<CreditsItem> CreditsItems;
IllusionsEngine_Duckman *_vm;
SpecialCodeMap _specialCodeMap;
@@ -56,6 +64,15 @@ public:
Common::Point _teleporterPosition;
int16 _counter;
bool _wasCursorHoldingElvisPoster;
+ int16 _savedTempMasterSfxVolume;
+ int16 _lastRandomSoundIndex;
+
+ uint32 _creditsLastUpdateTicks;
+ uint32 _creditsNextUpdateTicks;
+ int _lastCreditsItemIndex;
+ bool _creditsEndReached;
+ CreditsItems _creditsItems;
+ char *_creditsCurrText;
// Special code interface functions
void runSpecialCode(uint32 specialCodeId, OpCall &opCall);
@@ -75,14 +92,24 @@ public:
void spcStopScreenShaker(OpCall &opCall);
void spcIncrCounter(OpCall &opCall);
void spcUpdateObject272Sequence(OpCall &opCall);
+ void spcPlayRandomSound(OpCall &opCall);
void spcHoldGlowingElvisPoster(OpCall &opCall);
+ void spcStartCredits(OpCall &opCall);
void spcSetCursorInventoryMode(OpCall &opCall);
void spcCenterCurrentScreenText(OpCall &opCall);
void spcSetDefaultTextCoords(OpCall &opCall);
void spcSetTextDuration(OpCall &opCall);
+ void spcSetTempMasterSfxVolume(OpCall &opCall);
+ void spcRestoreTempMasterSfxVolume(OpCall &opCall);
void updateTeleporterProperties();
+ void startCredits();
+ int updateCredits(uint flags);
+ char *readNextCreditsLine();
+ Common::Point getCreditsItemPosition(int index);
+ void charToWChar(char *text, uint16 *wtext, uint size);
+
};
} // End of namespace Illusions
diff --git a/engines/illusions/duckman/illusions_duckman.cpp b/engines/illusions/duckman/illusions_duckman.cpp
index 8df01a8f6e..ebfcdca4bd 100644
--- a/engines/illusions/duckman/illusions_duckman.cpp
+++ b/engines/illusions/duckman/illusions_duckman.cpp
@@ -35,6 +35,7 @@
#include "illusions/resources/actorresource.h"
#include "illusions/resources/backgroundresource.h"
#include "illusions/resources/fontresource.h"
+#include "illusions/resources/genericresource.h"
#include "illusions/resources/midiresource.h"
#include "illusions/resources/scriptresource.h"
#include "illusions/resources/soundresource.h"
@@ -99,6 +100,7 @@ Common::Error IllusionsEngine_Duckman::run() {
_resSys->addResourceLoader(0x00100000, new ActorResourceLoader(this));
_resSys->addResourceLoader(0x00110000, new BackgroundResourceLoader(this));
_resSys->addResourceLoader(0x00120000, new FontResourceLoader(this));
+ _resSys->addResourceLoader(0x00190000, new GenericResourceLoader(this));
_screen = new Screen(this, 320, 200, 8);
_screenText = new ScreenText(this);
diff --git a/engines/illusions/duckman/scriptopcodes_duckman.cpp b/engines/illusions/duckman/scriptopcodes_duckman.cpp
index 263c27fb9a..a62a78b46b 100644
--- a/engines/illusions/duckman/scriptopcodes_duckman.cpp
+++ b/engines/illusions/duckman/scriptopcodes_duckman.cpp
@@ -275,7 +275,8 @@ void ScriptOpcodes_Duckman::opUnloadResourcesBySceneId(ScriptThread *scriptThrea
//static uint dsceneId = 0x00010010, dthreadId = 0x0002008A;
//static uint dsceneId = 0x10002, dthreadId = 0x20001;//Debug menu, not supported
//static uint dsceneId = 0x10044, dthreadId = 0x000202B8; // Starship Enterprise
-static uint dsceneId = 0x00010039, dthreadId = 0x00020089;
+//static uint dsceneId = 0x00010039, dthreadId = 0x00020089; // Map
+static uint dsceneId = 0x00010052, dthreadId = 0x00020347; // Credits
void ScriptOpcodes_Duckman::opChangeScene(ScriptThread *scriptThread, OpCall &opCall) {
ARG_SKIP(2);
diff --git a/engines/illusions/module.mk b/engines/illusions/module.mk
index d4bc3930d8..a5aa86d8cc 100644
--- a/engines/illusions/module.mk
+++ b/engines/illusions/module.mk
@@ -33,6 +33,7 @@ MODULE_OBJS := \
resources/actorresource.o \
resources/backgroundresource.o \
resources/fontresource.o \
+ resources/genericresource.o \
resources/midiresource.o \
resources/scriptresource.o \
resources/soundresource.o \
diff --git a/engines/illusions/resources/genericresource.cpp b/engines/illusions/resources/genericresource.cpp
new file mode 100644
index 0000000000..8d83026206
--- /dev/null
+++ b/engines/illusions/resources/genericresource.cpp
@@ -0,0 +1,40 @@
+/* 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.
+ *
+ */
+
+#include "illusions/illusions.h"
+#include "illusions/resources/genericresource.h"
+#include "illusions/dictionary.h"
+
+namespace Illusions {
+
+// GenericResourceLoader
+
+void GenericResourceLoader::load(Resource *resource) {
+ resource->_instance = 0;
+}
+
+bool GenericResourceLoader::isFlag(int flag) {
+ return
+ flag == kRlfLoadFile;
+}
+
+} // End of namespace Illusions
diff --git a/engines/illusions/resources/genericresource.h b/engines/illusions/resources/genericresource.h
new file mode 100644
index 0000000000..e875b01f68
--- /dev/null
+++ b/engines/illusions/resources/genericresource.h
@@ -0,0 +1,45 @@
+/* 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 ILLUSIONS_GENERICRESOURCE_H
+#define ILLUSIONS_GENERICRESOURCE_H
+
+#include "illusions/graphics.h"
+#include "illusions/resourcesystem.h"
+
+namespace Illusions {
+
+class IllusionsEngine;
+
+class GenericResourceLoader : public BaseResourceLoader {
+public:
+ GenericResourceLoader(IllusionsEngine *vm) : _vm(vm) {}
+ virtual ~GenericResourceLoader() {}
+ virtual void load(Resource *resource);
+ virtual bool isFlag(int flag);
+protected:
+ IllusionsEngine *_vm;
+};
+
+} // End of namespace Illusions
+
+#endif // ILLUSIONS_GENERICRESOURCE_H
diff --git a/engines/illusions/resourcesystem.h b/engines/illusions/resourcesystem.h
index b761b9460a..a54cda69e9 100644
--- a/engines/illusions/resourcesystem.h
+++ b/engines/illusions/resourcesystem.h
@@ -97,6 +97,7 @@ public:
void unloadResourceById(uint32 resId);
void unloadResourcesBySceneId(uint32 sceneId);
void unloadSceneResources(uint32 sceneId1, uint32 sceneId2);
+ Resource *getResource(uint32 resId);
protected:
typedef Common::HashMap<uint32, BaseResourceLoader*> ResourceLoadersMap;
@@ -141,7 +142,6 @@ protected:
}
};
- Resource *getResource(uint32 resId);
void unloadResource(Resource *resource);
};