aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS5
-rw-r--r--README56
-rw-r--r--backends/platform/wince/CEActionsPocket.cpp11
-rw-r--r--backends/platform/wince/CEActionsSmartphone.cpp11
-rw-r--r--backends/platform/wince/README-WinCE.txt6
-rw-r--r--backends/platform/wince/wince-sdl.cpp27
-rw-r--r--backends/platform/wince/wince-sdl.h1
-rw-r--r--base/plugins.cpp3
-rw-r--r--common/math.h17
-rwxr-xr-xconfigure1
-rw-r--r--devtools/create_kyradat/create_kyradat.cpp9
-rw-r--r--devtools/create_kyradat/create_kyradat.h4
-rw-r--r--devtools/create_kyradat/extract.cpp122
-rw-r--r--devtools/create_kyradat/games.cpp95
-rw-r--r--devtools/create_kyradat/tables.cpp80
-rwxr-xr-xdevtools/tasmrecover/tasm-recover17
-rw-r--r--devtools/tasmrecover/tasm/cpp.py6
-rw-r--r--dists/engine-data/kyra.datbin356433 -> 385091 bytes
-rw-r--r--engines/composer/composer.cpp495
-rw-r--r--engines/composer/composer.h212
-rw-r--r--engines/composer/detection.cpp179
-rw-r--r--engines/composer/graphics.cpp758
-rw-r--r--engines/composer/graphics.h71
-rw-r--r--engines/composer/module.mk16
-rw-r--r--engines/composer/resource.cpp336
-rw-r--r--engines/composer/resource.h124
-rw-r--r--engines/composer/scripting.cpp729
-rw-r--r--engines/dreamweb/dreamgen.cpp572
-rw-r--r--engines/dreamweb/dreamgen.h67
-rw-r--r--engines/dreamweb/dreamweb.cpp10
-rw-r--r--engines/dreamweb/dreamweb.h2
-rw-r--r--engines/dreamweb/runtime.h8
-rw-r--r--engines/dreamweb/stubs.cpp601
-rw-r--r--engines/dreamweb/stubs.h58
-rw-r--r--engines/engines.mk5
-rw-r--r--engines/gob/inter.h5
-rw-r--r--engines/gob/inter_v3.cpp35
-rw-r--r--engines/gob/scenery.cpp2
-rw-r--r--engines/kyra/detection_tables.h197
-rw-r--r--engines/kyra/gui_lol.cpp4
-rw-r--r--engines/kyra/items_lok.cpp7
-rw-r--r--engines/kyra/kyra_lok.cpp4
-rw-r--r--engines/kyra/kyra_v1.h1
-rw-r--r--engines/kyra/lol.cpp57
-rw-r--r--engines/kyra/lol.h4
-rw-r--r--engines/kyra/resource.h1
-rw-r--r--engines/kyra/script_lok.cpp5
-rw-r--r--engines/kyra/sequences_lok.cpp2
-rw-r--r--engines/kyra/sequences_lol.cpp3
-rw-r--r--engines/kyra/staticres.cpp21
-rw-r--r--engines/kyra/staticres_lol.cpp22
-rw-r--r--engines/mohawk/myst_scripts.cpp2
-rw-r--r--engines/toon/path.cpp77
-rw-r--r--engines/toon/path.h17
-rw-r--r--engines/tsage/debugger.cpp14
-rw-r--r--engines/tsage/debugger.h2
-rw-r--r--engines/tsage/ringworld_scenes1.cpp26
-rw-r--r--engines/tsage/ringworld_scenes1.h7
-rw-r--r--engines/tsage/ringworld_scenes3.cpp6
-rw-r--r--engines/tsage/ringworld_scenes8.cpp2
-rw-r--r--engines/tsage/scenes.cpp11
-rw-r--r--engines/tsage/sound.cpp272
-rw-r--r--engines/tsage/sound.h47
-rw-r--r--video/bink_decoder.cpp19
64 files changed, 4486 insertions, 1100 deletions
diff --git a/NEWS b/NEWS
index 4d5fa5c325..fd0de079f8 100644
--- a/NEWS
+++ b/NEWS
@@ -2,8 +2,13 @@ For a more comprehensive changelog of the latest experimental code, see:
https://github.com/scummvm/scummvm/commits/
1.4.0 (????-??-??)
+ New Games:
+ - Added support for Lands of Lore: The Throne of Chaos.
+
SCUMM:
- Implemented PC Speaker support for SCUMM v5 games.
+ - Fixed priority bug in iMuse. As a result the AdLib music should sound
+ better, since important notes are not interrupted anymore.
SDL ports:
- Added support for OpenGL (GSoC Task).
diff --git a/README b/README
index 48929816fd..4843d9dc9a 100644
--- a/README
+++ b/README
@@ -153,7 +153,7 @@ support an unsupported game -- read the FAQ on our web site first.
---- ---------------
To report a bug, please create a SourceForge account and follow the
"Bug Tracker" link from our homepage. Please make sure the bug is
-reproducible, and still occurs in the latest SVN/Daily build version.
+reproducible, and still occurs in the latest git/Daily build version.
Also check the known problems list (below) and the compatibility list
on our website for that game, to ensure the issue is not already known:
@@ -164,7 +164,7 @@ completeable in the 'Supported Games' section, or compatibility list. We
-know- those games have bugs.
Please include the following information:
- - ScummVM version (PLEASE test the latest SVN/Daily build)
+ - ScummVM version (PLEASE test the latest git/Daily build)
- Bug details, including instructions on reproducing
- Language of game (English, German, ...)
- Version of game (talkie, floppy, ...)
@@ -303,12 +303,12 @@ SCUMM Games by Humongous Entertainment:
From Your Head to Your Feet [pajama3]
Pajama Sam's Lost & Found [lost]
Pajama Sam's Sock Works [socks]
- Putt-Putt Enters the Race [puttrace]
- Putt-Putt Goes to the Moon [puttmoon]
- Putt-Putt Joins the Circus [puttcircus]
Putt-Putt Joins the Parade [puttputt]
+ Putt-Putt Goes to the Moon [puttmoon]
Putt-Putt Saves the Zoo [puttzoo]
Putt-Putt Travels Through Time [putttime]
+ Putt-Putt Enters the Race [puttrace]
+ Putt-Putt Joins the Circus [puttcircus]
Putt-Putt and Pep's Balloon-O-Rama [balloon]
Putt-Putt and Pep's Dog on a Stick [dog]
Putt-Putt & Fatty Bear's Activity Pack [activity]
@@ -770,11 +770,12 @@ to be able to play the game under ScummVM.
3.19) Dragon History notes:
----- ---------------------
-There are 3 language variants of the game: Czech, English, and Polish.
-Each of them is distributed in a separate archive. The only official
-version is the Czech one, and the English and Polish ports have always
-been work in progress and never officially released. Although all texts
-are fully translated, it is known that some of them contain typos.
+There are 4 language variants of the game: Czech, English, Polish and
+German. Each of them is distributed in a separate archive. The only
+official version is the Czech one, and the English, Polish and German
+ports have always been work in progress and never officially released.
+Although all texts are fully translated, it is known that some of them
+contain typos.
There exists an optional Czech dubbing for the game. For bandwidth
reasons, you can download it separately and then unpack it to the
@@ -846,8 +847,8 @@ site, please see the section on reporting bugs.
Simon the Sorcerer's Puzzle Pack:
- No support for displaying, entering, loading or saving high scores.
- - No support for displaying explanation, when clicking on items in
- Swampy Adventures.
+ - No support for displaying names of items, when hovering over them
+ in Swampy Adventures.
The Feeble Files:
- Subtitles are often incomplete, they were always disabled in the
@@ -868,7 +869,7 @@ site, please see the section on reporting bugs.
ScummVM has been ported to run on many platforms and operating systems.
Links to these ports can be found either on the ScummVM web page or by a
Google search. Many thanks to our porters for their efforts. If you have
-a port of ScummVM and wish to commit it into the main SVN, feel free to
+a port of ScummVM and wish to commit it into the master git, feel free to
contact us!
Supported platforms include (but are not limited to):
@@ -955,7 +956,7 @@ arguments -- see the next section.
--themepath=PATH Path to where GUI themes are stored
--list-themes Display list of all usable GUI themes
-e, --music-driver=MODE Select music driver (see also section 7.0)
- -q, --language=LANG Select language (see also section 5.2)
+ -q, --language=LANG Select game's language (see also section 5.2)
-m, --music-volume=NUM Set the music volume, 0-255 (default: 192)
-s, --sfx-volume=NUM Set the sfx volume, 0-255 (default: 192)
-r, --speech-volume=NUM Set the voice volume, 0-255 (default: 192)
@@ -1026,8 +1027,8 @@ Examples:
5.2) Language options:
---- -----------------
ScummVM includes a language option for Maniac Mansion, Zak McKracken,
-The Dig, The Curse of Monkey Island, Beneath a Steel Sky, Broken Sword
-and Simon the Sorcerer 1 and 2.
+The Dig, The Curse of Monkey Island, Beneath a Steel Sky and
+Broken Sword.
Note that with the exception of Beneath a Steel Sky, Broken Sword,
multilanguage versions of Goblins games and Nippon Safes Inc., using
@@ -1081,16 +1082,6 @@ Broken Sword
pt - Portuguese
cz - Czech
-Simon the Sorcerer 1 and 2
- en - English (default)
- de - German
- fr - French
- it - Italian
- es - Spanish
- he - Hebrew
- pl - Polish
- ru - Russian
-
5.3) Graphics filters:
---- -----------------
@@ -1284,10 +1275,14 @@ other games.
b - Background sounds on/off
[Simon the Sorcerer 2 only]
Pause - Pauses
- t - Switch between speech and subtitles
+ t - Switch between speech only and
+ combined speech and subtitles
+ [Simon the Sorcerer 1 CD (other than
+ English and German) and Simon the
+ Sorcerer 2 CD (all languages)]
v - Switch between subtitles only and
combined speech and subtitles
- [Simon the Sorcerer 2 only]
+ [Simon the Sorcerer 2 CD only]
Simon the Sorcerer's Puzzle Pack
Ctrl-d - Starts the debugger
@@ -1305,7 +1300,8 @@ other games.
F9 - Hitbox names on/off
s - Sound effects on/off
Pause - Pauses
- t - Switch between speech and subtitles
+ t - Switch between speech only and
+ combined speech and subtitles
v - Switch between subtitles only and
combined speech and subtitles
@@ -2140,7 +2136,7 @@ debug messages (see http://www.sysinternals.com/ntw2k/freeware/debugview.shtml).
Maemo:
* Get Scratchbox environment with Maemo 2.2 rootstrap (2.2 is for 770 and up)
* Install libmad, Tremor, FLAC from source
- * patch scummvm source (some stuff is currently too dirty to be in svn directly)
+ * patch scummvm source (some stuff is currently too dirty to be in git directly)
patch -p1 < backends/platform/maemo/scummvm-[currentversion]-maemo.patch
* update debian/changelog
* run 'fakeroot dpkg-buildpackage -b -d'
diff --git a/backends/platform/wince/CEActionsPocket.cpp b/backends/platform/wince/CEActionsPocket.cpp
index 194f855e98..5980a41caa 100644
--- a/backends/platform/wince/CEActionsPocket.cpp
+++ b/backends/platform/wince/CEActionsPocket.cpp
@@ -215,6 +215,8 @@ void CEActionsPocket::initInstanceGame() {
_key_action[POCKET_ACTION_MULTI].setKey(Common::ASCII_F1, SDLK_F1); // bargon : F1 to start
else if (gameid == "atlantis")
_key_action[POCKET_ACTION_MULTI].setKey(0, SDLK_KP0); // fate of atlantis : Ins to sucker-punch
+ else if (is_simon)
+ _key_action[POCKET_ACTION_MULTI].setKey(Common::ASCII_F10, SDLK_F10); // F10
else
_key_action[POCKET_ACTION_MULTI].setKey('V', SDLK_v, KMOD_SHIFT); // FT cheat : shift-V
// Key bind method
@@ -268,6 +270,15 @@ bool CEActionsPocket::perform(GUI::ActionType action, bool pushed) {
else
_key_action[action].setKey(SDLK_s);
}
+ if (action == POCKET_ACTION_SKIP && ConfMan.get("gameid") == "agi") {
+ // In several AGI games (for example SQ2) it is needed to press F10 to exit from
+ // a screen. But we still want be able to skip normally with the skip button.
+ // Because of this, we inject a F10 keystroke here (this works and doesn't seem
+ // to have side-effects)
+ _key_action[action].setKey(Common::ASCII_F10, SDLK_F10); // F10
+ EventsBuffer::simulateKey(&_key_action[action], true);
+ _key_action[action].setKey(KEY_ALL_SKIP);
+ }
EventsBuffer::simulateKey(&_key_action[action], true);
return true;
case POCKET_ACTION_KEYBOARD:
diff --git a/backends/platform/wince/CEActionsSmartphone.cpp b/backends/platform/wince/CEActionsSmartphone.cpp
index c6456d3eb5..2cce288323 100644
--- a/backends/platform/wince/CEActionsSmartphone.cpp
+++ b/backends/platform/wince/CEActionsSmartphone.cpp
@@ -181,6 +181,8 @@ void CEActionsSmartphone::initInstanceGame() {
_key_action[SMARTPHONE_ACTION_MULTI].setKey(Common::ASCII_F1, SDLK_F1); // bargon : F1 to start
else if (gameid == "atlantis")
_key_action[SMARTPHONE_ACTION_MULTI].setKey(0, SDLK_KP0); // fate of atlantis : Ins to sucker-punch
+ else if (is_simon)
+ _key_action[SMARTPHONE_ACTION_MULTI].setKey(Common::ASCII_F10, SDLK_F10); // F10
else
_key_action[SMARTPHONE_ACTION_MULTI].setKey('V', SDLK_v, KMOD_SHIFT); // FT cheat : shift-V
// Bind keys
@@ -232,6 +234,15 @@ bool CEActionsSmartphone::perform(GUI::ActionType action, bool pushed) {
else
_key_action[action].setKey(SDLK_s);
}
+ if (action == SMARTPHONE_ACTION_SKIP && ConfMan.get("gameid") == "agi") {
+ // In several AGI games (for example SQ2) it is needed to press F10 to exit from
+ // a screen. But we still want be able to skip normally with the skip button.
+ // Because of this, we inject a F10 keystroke here (this works and doesn't seem
+ // to have side-effects)
+ _key_action[action].setKey(Common::ASCII_F10, SDLK_F10); // F10
+ EventsBuffer::simulateKey(&_key_action[action], true);
+ _key_action[action].setKey(KEY_ALL_SKIP);
+ }
EventsBuffer::simulateKey(&_key_action[action], true);
return true;
case SMARTPHONE_ACTION_RIGHTCLICK:
diff --git a/backends/platform/wince/README-WinCE.txt b/backends/platform/wince/README-WinCE.txt
index 87f6e78ffe..60bcf710bb 100644
--- a/backends/platform/wince/README-WinCE.txt
+++ b/backends/platform/wince/README-WinCE.txt
@@ -1,5 +1,5 @@
ScummVM Windows CE FAQ
-Last updated: 2011-07-14
+Last updated: 2011-07-20
Release version: x.x.x
------------------------------------------------------------------------
@@ -9,6 +9,10 @@ x.x.x:
- Changed default values for "high_sample_rate" & "FM_high_quality" to "true" as
most devices today are fast enough to handle this. It's still possible to set
this to "false" if you have a slower device.
+- Fix for TeenAgent & Hugo engines (both weren't running at all, crashed right
+ at the beginning)
+- Replaced the game mass-adding functionality with the functionality used on all
+ other platforms. It now shows progress while searching for games.
1.3.1:
- Fix for Normal2xAspect scaler which was causing screen update issues in some
diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp
index ec222c6fc1..1abc3cb350 100644
--- a/backends/platform/wince/wince-sdl.cpp
+++ b/backends/platform/wince/wince-sdl.cpp
@@ -42,6 +42,7 @@
#include "audio/mixer_intern.h"
#include "audio/fmopl.h"
+#include "backends/mutex/sdl/sdl-mutex.h"
#include "backends/timer/sdl/sdl-timer.h"
#include "gui/Actions.h"
@@ -379,14 +380,6 @@ void OSystem_WINCE3::initBackend() {
((WINCESdlEventSource *)_eventSource)->init((WINCESdlGraphicsManager *)_graphicsManager);
- // Create the timer (but remove the timer manager from the SDL backend first).
- // CE SDL does not support multiple timers (SDL_AddTimer).
- // We work around this by using the SetTimer function, since we only use
- // one timer in scummvm (for the time being)
- delete _timerManager;
- _timerManager = new DefaultTimerManager();
- SDL_SetTimer(10, &timer_handler_wrapper);
-
// Call parent implementation of this method
OSystem_SDL::initBackend();
@@ -546,6 +539,24 @@ void OSystem_WINCE3::initSDL() {
}
}
+void OSystem_WINCE3::init() {
+ // Create SdlMutexManager instance as the TimerManager relies on the
+ // MutexManager being already initialized
+ if (_mutexManager == 0)
+ _mutexManager = new SdlMutexManager();
+
+ // Create the timer. CE SDL does not support multiple timers (SDL_AddTimer).
+ // We work around this by using the SetTimer function, since we only use
+ // one timer in scummvm (for the time being)
+ if (_timerManager == 0) {
+ _timerManager = new DefaultTimerManager();
+ SDL_SetTimer(10, &timer_handler_wrapper);
+ }
+
+ // Call parent implementation of this method
+ OSystem_SDL::init();
+}
+
void OSystem_WINCE3::quit() {
fclose(stdout_file);
fclose(stderr_file);
diff --git a/backends/platform/wince/wince-sdl.h b/backends/platform/wince/wince-sdl.h
index 481956c19a..b4f323c9e2 100644
--- a/backends/platform/wince/wince-sdl.h
+++ b/backends/platform/wince/wince-sdl.h
@@ -52,6 +52,7 @@ public:
void initBackend();
// Overloaded from SDL backend
+ void init();
void quit();
virtual Common::String getSystemLanguage() const;
diff --git a/base/plugins.cpp b/base/plugins.cpp
index 4413995b88..4fa1a961da 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -97,6 +97,9 @@ public:
#if PLUGIN_ENABLED_STATIC(CINE)
LINK_PLUGIN(CINE)
#endif
+ #if PLUGIN_ENABLED_STATIC(COMPOSER)
+ LINK_PLUGIN(COMPOSER)
+ #endif
#if PLUGIN_ENABLED_STATIC(CRUISE)
LINK_PLUGIN(CRUISE)
#endif
diff --git a/common/math.h b/common/math.h
index ebe01fbaf5..56ab171bd3 100644
--- a/common/math.h
+++ b/common/math.h
@@ -50,6 +50,20 @@ struct Complex {
float re, im;
};
+#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+inline int intLog2(uint32 v) {
+ // This is a slightly optimized implementation of log2 for natural numbers
+ // targeting gcc. It also saves some binary size over our fallback
+ // implementation, since it does not need any table.
+ if (v == 0)
+ return -1;
+ else
+ // This is really "sizeof(unsigned int) * CHAR_BIT - 1" but using 8
+ // instead of CHAR_BIT is sane enough and it saves us from including
+ // limits.h
+ return (sizeof(unsigned int) * 8 - 1) - __builtin_clz(v);
+}
+#else
// See http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogLookup
static const char LogTable256[256] = {
#define LT(n) n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n
@@ -58,7 +72,7 @@ static const char LogTable256[256] = {
LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7)
};
-inline uint32 intLog2(uint32 v) {
+inline int intLog2(uint32 v) {
register uint32 t, tt;
if ((tt = v >> 16))
@@ -66,6 +80,7 @@ inline uint32 intLog2(uint32 v) {
else
return (t = v >> 8) ? 8 + LogTable256[t] : LogTable256[v];
}
+#endif
inline float rad2deg(float rad) {
return rad * 180.0 / M_PI;
diff --git a/configure b/configure
index 1a449fd6e9..8045a8b52b 100755
--- a/configure
+++ b/configure
@@ -84,6 +84,7 @@ add_engine agi "AGI" yes
add_engine agos "AGOS" yes "agos2"
add_engine agos2 "AGOS 2 games" yes
add_engine cine "Cinematique evo 1" yes
+add_engine composer "Magic Composer" no
add_engine cruise "Cinematique evo 2" yes
add_engine draci "Dragon History" yes
add_engine drascula "Drascula: The Vampire Strikes Back" yes
diff --git a/devtools/create_kyradat/create_kyradat.cpp b/devtools/create_kyradat/create_kyradat.cpp
index e4686cc66c..27cc82efd4 100644
--- a/devtools/create_kyradat/create_kyradat.cpp
+++ b/devtools/create_kyradat/create_kyradat.cpp
@@ -45,7 +45,7 @@
#include <map>
enum {
- kKyraDatVersion = 74
+ kKyraDatVersion = 78
};
const ExtractFilename extractFilenames[] = {
@@ -119,6 +119,7 @@ const ExtractFilename extractFilenames[] = {
// AUDIO filename table
{ k1AudioTracks, kTypeStringList, false },
+ { k1AudioTracks2, kTypeStringList, false },
{ k1AudioTracksIntro, kTypeStringList, false },
// AMULET anim
@@ -219,7 +220,7 @@ const ExtractFilename extractFilenames[] = {
// Ingame
{ kLolIngamePakFiles, kTypeStringList, false },
- { kLolCharacterDefs, kLolTypeCharData, false },
+ { kLolCharacterDefs, kLolTypeCharData, true },
{ kLolIngameSfxFiles, k2TypeSfxList, false },
{ kLolIngameSfxIndex, kTypeRawData, false },
{ kLolMusicTrackMap, kTypeRawData, false },
@@ -341,6 +342,7 @@ const TypeTable languageTable[] = {
{ ES_ESP, 4 },
{ IT_ITA, 5 },
{ JA_JPN, 6 },
+ { RU_RUS, 7 },
{ -1, -1 }
};
@@ -366,6 +368,7 @@ const TypeTable specialTable[] = {
{ kTalkieVersion, 1 },
{ kDemoVersion, 2 },
{ kTalkieDemoVersion, 3 },
+ { kOldFloppy, 4 },
{ -1, -1 }
};
@@ -767,6 +770,8 @@ const char *getIdString(const int id) {
return "k1CharacterImageFilenames";
case k1AudioTracks:
return "k1AudioTracks";
+ case k1AudioTracks2:
+ return "k1AudioTracks2";
case k1AudioTracksIntro:
return "k1AudioTracksIntro";
case k1ItemNames:
diff --git a/devtools/create_kyradat/create_kyradat.h b/devtools/create_kyradat/create_kyradat.h
index 22a6db4b39..983ba3c228 100644
--- a/devtools/create_kyradat/create_kyradat.h
+++ b/devtools/create_kyradat/create_kyradat.h
@@ -131,6 +131,7 @@ enum kExtractID {
k1ConfigStrings,
k1AudioTracks,
+ k1AudioTracks2,
k1AudioTracksIntro,
k1CreditsStrings,
@@ -275,7 +276,8 @@ enum kSpecial {
kNoSpecial = 0,
kTalkieVersion,
kDemoVersion,
- kTalkieDemoVersion
+ kTalkieDemoVersion,
+ kOldFloppy,
};
enum kGame {
diff --git a/devtools/create_kyradat/extract.cpp b/devtools/create_kyradat/extract.cpp
index 5581dacec0..88452ab4fc 100644
--- a/devtools/create_kyradat/extract.cpp
+++ b/devtools/create_kyradat/extract.cpp
@@ -142,19 +142,56 @@ bool extractRaw(PAKFile &out, const ExtractInformation *info, const byte *data,
}
bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id) {
- int fmtPatch = 0;
+ // Skip tables for skipping English string left-overs in the hacky Russian fan translations
+ static const uint8 rusFanSkip_k2SeqplayStrings[] = { 1, 3, 5, 8, 10, 11, 13, 15, 17, 20, 22, 25, 26, 30, 33, 38, 40, 41, 44, 49, 51, 55, 104, 119, 121, 123 };
+ static const uint8 rusFanSkip_k1IntroStrings[] = { 3, 5, 9, 11, 13, 16, 18, 21, 24, 32, 34, 36, 38, 41, 44, 49, 52, 55, 57, 59, 61, 64, 66, 69, 72, 75 };
+ static const uint8 rusFanSkip_k1ThePoisonStrings[] = { 1, 4 };
+ static const uint8 rusFanSkip_k1FullFlaskStrings[] = { 1, 2, 4, 5, 7 };
+ static const uint8 rusFanSkip_k1WispJewelStrings[] = { 2 };
+ static const uint8 rusFanSkip_k1GUIStrings[] = { 1, 3, 6, 8, 11, 13, 18 };
+ uint32 rusFanSkipIdLen = 0;
+ const uint8 *rusFanSkipId = 0;
+ int rusFanEmptyId = 10000;
+ uint32 skipCount = 0;
+
+ int patch = 0;
// FM Towns files that need addional patches
if (info->platform == kPlatformFMTowns) {
if (id == k1TakenStrings || id == k1NoDropStrings || id == k1PoisonGoneString ||
id == k1ThePoisonStrings || id == k1FluteStrings || id == k1WispJewelStrings)
- fmtPatch = 1;
+ patch = 1;
else if (id == k1IntroStrings)
- fmtPatch = 2;
+ patch = 2;
else if (id == k2SeqplayStrings)
- fmtPatch = 3;
+ patch = 3;
} else if (info->platform == kPlatformPC) {
if (id == k2IngamePakFiles)
- fmtPatch = 4;
+ patch = 4;
+
+ if (info->lang == Common::RU_RUS) {
+ patch = 5;
+ if (id == k2SeqplayStrings) {
+ rusFanSkipId = rusFanSkip_k2SeqplayStrings;
+ rusFanSkipIdLen = ARRAYSIZE(rusFanSkip_k2SeqplayStrings);
+ rusFanEmptyId = 81;
+ } else if (id == k1IntroStrings) {
+ rusFanSkipId = rusFanSkip_k1IntroStrings;
+ rusFanSkipIdLen = ARRAYSIZE(rusFanSkip_k1IntroStrings);
+ rusFanEmptyId = 30;
+ } else if (id == k1ThePoisonStrings) {
+ rusFanSkipId = rusFanSkip_k1ThePoisonStrings;
+ rusFanSkipIdLen = ARRAYSIZE(rusFanSkip_k1ThePoisonStrings);
+ } else if (id == k1FullFlaskString) {
+ rusFanSkipId = rusFanSkip_k1FullFlaskStrings;
+ rusFanSkipIdLen = ARRAYSIZE(rusFanSkip_k1FullFlaskStrings);
+ } else if (id == k1GUIStrings) {
+ rusFanSkipId = rusFanSkip_k1GUIStrings;
+ rusFanSkipIdLen = ARRAYSIZE(rusFanSkip_k1GUIStrings);
+ } else if (id == k1WispJewelStrings) {
+ rusFanSkipId = rusFanSkip_k1WispJewelStrings;
+ rusFanSkipIdLen = ARRAYSIZE(rusFanSkip_k1WispJewelStrings);
+ }
+ }
// HACK
if (id == k2SeqplayIntroTracks && info->game == kLol)
@@ -183,7 +220,7 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
break;
targetsize--;
}
- if (fmtPatch == 1) {
+ if (patch == 1) {
// Here is the first step of the extra treatment for all FM-TOWNS string arrays that
// contain more than one string and which the original code
// addresses via stringname[boolJapanese].
@@ -201,11 +238,38 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
targetsize--;
}
}
+ } else if (patch == 5) {
+ ++skipCount;
+ while (!data[i + 1]) {
+ if (skipCount == rusFanEmptyId) {
+ ++skipCount;
+ ++entries;
+ break;
+ }
+ if (++i == size)
+ break;
+ targetsize--;
+ }
+
+ // Skip English string left-overs in the hacky Russian fan translation
+ for (uint32 ii = 0; ii < rusFanSkipIdLen; ++ii) {
+ if (skipCount == rusFanSkipId[ii]) {
+ ++skipCount;
+ uint32 len = strlen((const char*) data + i);
+ i += len;
+ targetsize = targetsize - 1 - len;
+ while (!data[i + 1]) {
+ if (++i == len)
+ break;
+ targetsize--;
+ }
+ }
+ }
}
}
}
- if (fmtPatch == 2) {
+ if (patch == 2) {
if (info->lang == EN_ANY) {
targetsize--;
entries += 1;
@@ -215,12 +279,12 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
}
}
- if (fmtPatch == 3) {
+ if (patch == 3) {
entries++;
targetsize++;
}
- if (fmtPatch == 4) {
+ if (patch == 4) {
targetsize -= 9;
}
@@ -229,12 +293,13 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
memset(buffer, 0, targetsize);
uint8 *output = buffer;
const uint8 *input = (const uint8*) data;
+ skipCount = 0;
WRITE_BE_UINT32(output, entries); output += 4;
if (info->platform == kPlatformFMTowns) {
const byte *c = data + size;
do {
- if (fmtPatch == 2 && input - data == 0x3C0 && input[0x10] == 0x32) {
+ if (patch == 2 && input - data == 0x3C0 && input[0x10] == 0x32) {
memcpy(output, input, 0x0F);
input += 0x11; output += 0x0F;
}
@@ -245,14 +310,14 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
// skip empty entries
while (!*input) {
// Write one empty string into intro strings file
- if (fmtPatch == 2) {
+ if (patch == 2) {
if ((info->lang == EN_ANY && input - data == 0x260) ||
(info->lang == JA_JPN && (input - data == 0x2BD || input - data == 0x2BE)))
*output++ = *input;
}
// insert one dummy string at hof sequence strings position 59
- if (fmtPatch == 3) {
+ if (patch == 3) {
if ((info->lang == EN_ANY && input - data == 0x695) ||
(info->lang == JA_JPN && input - data == 0x598))
*output++ = *input;
@@ -262,7 +327,7 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
break;
}
- if (fmtPatch == 1) {
+ if (patch == 1) {
// Here is the extra treatment for all FM-TOWNS string arrays that
// contain more than one string and which the original code
// addresses via stringname[boolJapanese].
@@ -292,9 +357,38 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
++dstPos;
}
targetsize = dstPos + 4;
+ } else if (patch == 5) {
+ const byte *c = data + size;
+ do {
+ strcpy((char*) output, (const char*) input);
+ uint32 stringsize = strlen((const char*)output) + 1;
+ input += stringsize; output += stringsize;
+
+ ++skipCount;
+ while (!*input) {
+ if (skipCount == rusFanEmptyId) {
+ *output++ = *input;
+ ++skipCount;
+ }
+ if (++input == c)
+ break;
+ }
+ // Skip English string left-overs in the hacky Russian fan translation
+ for (uint32 ii = 0; ii < rusFanSkipIdLen; ++ii) {
+ if (skipCount == rusFanSkipId[ii]) {
+ ++skipCount;
+ input += strlen((const char*)input);
+ while (!*input) {
+ if (++input == c)
+ break;
+ }
+ }
+ }
+
+ } while (input < c);
} else {
uint32 copySize = size;
- if (fmtPatch == 4) {
+ if (patch == 4) {
memcpy(output, data, 44);
output += 44;
data += 44;
diff --git a/devtools/create_kyradat/games.cpp b/devtools/create_kyradat/games.cpp
index 76d5d70186..1a86ad4729 100644
--- a/devtools/create_kyradat/games.cpp
+++ b/devtools/create_kyradat/games.cpp
@@ -44,6 +44,7 @@ const Game kyra1Games[] = {
{ kKyra1, { FR_FRA, -1, -1 }, kPlatformPC, kNoSpecial, { "aa9d6d78d8b199deaf48efeca6d19af2", 0 } },
{ kKyra1, { IT_ITA, -1, -1 }, kPlatformPC, kNoSpecial, { "5d7550306b369a3492f9f3402702477c", 0 } },
{ kKyra1, { ES_ESP, -1, -1 }, kPlatformPC, kNoSpecial, { "9ff130d2558bcd674d4074849d93c362", 0 } },
+ { kKyra1, { RU_RUS, -1, -1 }, kPlatformPC, kOldFloppy, { "3b4719e1f8a4d67813b7ada29774aead", 0 } },
// Talkie
{ kKyra1, { EN_ANY, -1, -1 }, kPlatformPC, kTalkieVersion, { "1ebc18f3e7fbb72474a55cb0fa089ed4", 0 } },
@@ -71,6 +72,7 @@ const Game kyra2Games[] = {
{ kKyra2, { FR_FRA, -1, -1 }, kPlatformPC, kNoSpecial, { "df31cc9e37e1cf68df2fdc75ddf2d87b", "fc2c6782778e6c6d5a553d1cb73c98ad" } },
{ kKyra2, { DE_DEU, -1, -1 }, kPlatformPC, kNoSpecial, { "0ca4f9a1438264a4c63c3218e064ed3b", "0d9b0eb7b0ad889ec942d74d80dde1bf" } },
{ kKyra2, { IT_ITA, -1, -1 }, kPlatformPC, kNoSpecial, { "178d3ab913f61bfba21d2fb196405e8c", "3a61ed6b7c00ddae383a0361799e2ba6" } },
+ { kKyra2, { RU_RUS, -1, -1 }, kPlatformPC, kNoSpecial, { "fd6a388c01de9a578e24e3bbeacd8012", "3a61ed6b7c00ddae383a0361799e2ba6" } },
// talkie games
{ kKyra2, { EN_ANY, FR_FRA, DE_DEU }, kPlatformPC, kTalkieVersion, { "85bbc1cc6c4cef6ad31fc6ee79518efb", "e20d0d2e500f01e399ec588247a7e213" } },
@@ -98,8 +100,9 @@ const Game lolGames[] = {
// DOS demo
{ kLol, { EN_ANY, -1, -1 }, kPlatformPC, kDemoVersion, { "30bb5af87d38adb47d3e6ce06b1cb042", 0 } },
- // DOS floppy (no language specifc strings)
+ // DOS floppy (no language specifc strings except character presets)
{ kLol, { EN_ANY, -1, -1 }, kPlatformPC, kNoSpecial, { "0cc764a204f7ba8cefe1a5f14c479619", 0 } },
+ { kLol, { RU_RUS, -1, -1 }, kPlatformPC, kNoSpecial, { "80a9f9bf243bc6ed36d98584fc6988c4", 0 } },
{ kLol, { DE_DEU, -1, -1 }, kPlatformPC, kNoSpecial, { "6b843869772c1b779e1386be868c15dd", 0 } },
// PC98 (no language specifc strings)
@@ -108,6 +111,7 @@ const Game lolGames[] = {
// DOS CD (multi language version, with no language specific strings)
{ kLol, { EN_ANY, FR_FRA, DE_DEU }, kPlatformPC, kTalkieVersion, { "9d1778314de80598c0b0d032e2a1a1cf", "263998ec600afca1cc7b935c473df670" } },
{ kLol, { IT_ITA, FR_FRA, DE_DEU }, kPlatformPC, kTalkieVersion, { "9d1778314de80598c0b0d032e2a1a1cf", "f2af366e00f79dbf832fa19701d71ed9" } }, // Italian fan translation
+ { kLol, { EN_ANY, FR_FRA, RU_RUS }, kPlatformPC, kTalkieVersion, { "9d1778314de80598c0b0d032e2a1a1cf", "5b33478718968676343803911dd5e3e4" } }, // Russian fan translation
GAME_DUMMY_ENTRY
};
@@ -208,6 +212,93 @@ const int kyra1FloppyNeed[] = {
k1NewGameString,
k1ConfigStrings,
k1AudioTracks,
+ k1AudioTracks2,
+ k1AudioTracksIntro,
+ -1
+};
+
+const int kyra1FloppyOldNeed[] = {
+ k1KallakWritingSeq,
+ k1MalcolmTreeSeq,
+ k1WestwoodLogoSeq,
+ k1KyrandiaLogoSeq,
+ k1KallakMalcolmSeq,
+ k1ForestSeq,
+ k1IntroCPSStrings,
+ k1IntroCOLStrings,
+ k1IntroWSAStrings,
+ k1IntroStrings,
+ k1RoomList,
+ k1RoomFilenames,
+ k1CharacterImageFilenames,
+ k1DefaultShapes,
+ k1ItemNames,
+ k1TakenStrings,
+ k1PlacedStrings,
+ k1DroppedStrings,
+ k1AmuleteAnimSeq,
+ k1SpecialPalette1,
+ k1SpecialPalette2,
+ k1SpecialPalette3,
+ k1SpecialPalette4,
+ k1SpecialPalette5,
+ k1SpecialPalette6,
+ k1SpecialPalette7,
+ k1SpecialPalette8,
+ k1SpecialPalette9,
+ k1SpecialPalette10,
+ k1SpecialPalette11,
+ k1SpecialPalette12,
+ k1SpecialPalette13,
+ k1SpecialPalette14,
+ k1SpecialPalette15,
+ k1SpecialPalette16,
+ k1SpecialPalette17,
+ k1SpecialPalette18,
+ k1SpecialPalette19,
+ k1SpecialPalette20,
+ k1SpecialPalette21,
+ k1SpecialPalette22,
+ k1SpecialPalette23,
+ k1SpecialPalette24,
+ k1SpecialPalette25,
+ k1SpecialPalette26,
+ k1SpecialPalette27,
+ k1SpecialPalette28,
+ k1SpecialPalette29,
+ k1SpecialPalette30,
+ k1SpecialPalette31,
+ k1SpecialPalette32,
+ k1PutDownString,
+ k1WaitAmuletString,
+ k1BlackJewelString,
+ k1HealingTipString,
+ k1PoisonGoneString,
+ k1Healing1Shapes,
+ k1Healing2Shapes,
+ k1ThePoisonStrings,
+ k1FluteStrings,
+ k1PoisonDeathShapes,
+ k1FluteShapes,
+ k1Winter1Shapes,
+ k1Winter2Shapes,
+ k1Winter3Shapes,
+ k1DrinkShapes,
+ k1WispShapes,
+ k1MagicAnimShapes,
+ k1BranStoneShapes,
+ k1WispJewelStrings,
+ k1MagicJewelStrings,
+ k1FlaskFullString,
+ k1FullFlaskString,
+ k1OutroReunionSeq,
+ k1OutroHomeString,
+ k1VeryCleverString,
+ k1GUIStrings,
+ k1NewGameString,
+ k1ConfigStrings,
+ k1AudioTracks,
+ k1AudioTracks2,
k1AudioTracksIntro,
-1
};
@@ -295,6 +386,7 @@ const int kyra1CDNeed[] = {
k1NewGameString,
k1ConfigStrings,
k1AudioTracks,
+ k1AudioTracks2,
k1AudioTracksIntro,
-1
};
@@ -938,6 +1030,7 @@ struct GameNeed {
const GameNeed gameNeedTable[] = {
{ kKyra1, kPlatformPC, kNoSpecial, kyra1FloppyNeed },
+ { kKyra1, kPlatformPC, kOldFloppy, kyra1FloppyOldNeed },
{ kKyra1, kPlatformAmiga, kNoSpecial, kyra1AmigaNeed },
{ kKyra1, kPlatformPC, kTalkieVersion, kyra1CDNeed },
diff --git a/devtools/create_kyradat/tables.cpp b/devtools/create_kyradat/tables.cpp
index 090b32debc..40e528267a 100644
--- a/devtools/create_kyradat/tables.cpp
+++ b/devtools/create_kyradat/tables.cpp
@@ -68,6 +68,7 @@ const ExtractEntrySearchData k1KyrandiaLogoSeqProvider[] = {
const ExtractEntrySearchData k1KallakMalcolmSeqProvider[] = {
{ UNK_LANG, kPlatformPC, { 0x0000026B, 0x00002132, { { 0x51, 0x07, 0x32, 0xA2, 0x09, 0x47, 0x97, 0x02, 0x85, 0x31, 0x39, 0x93, 0x3A, 0x53, 0x47, 0xA5 } } } }, // floppy
+ { UNK_LANG, kPlatformPC, { 0x00000267, 0x00002100, { { 0xD9, 0x5E, 0x59, 0xF0, 0x7B, 0xC8, 0xF1, 0x40, 0x4F, 0x68, 0x6F, 0xEC, 0xB5, 0xE8, 0x88, 0xE2 } } } }, // floppy
{ UNK_LANG, kPlatformUnknown, { 0x0000027B, 0x0000220A, { { 0xB7, 0xC1, 0x57, 0x04, 0x9B, 0x67, 0x82, 0x7B, 0x6E, 0xFD, 0x59, 0xF2, 0x10, 0x93, 0x89, 0x12 } } } }, // CD + Amiga
{ UNK_LANG, kPlatformUnknown, { 0x000002B8, 0x0000280B, { { 0x98, 0xC8, 0x36, 0x8C, 0xF8, 0x92, 0xC2, 0xB9, 0x1B, 0x71, 0x6B, 0x4C, 0xA4, 0x6C, 0xF6, 0x30 } } } }, // Amiga + CD demo
@@ -134,8 +135,9 @@ const ExtractEntrySearchData k1AmuleteAnimSeqProvider[] = {
const ExtractEntrySearchData k1OutroReunionSeqProvider[] = {
{ UNK_LANG, kPlatformPC, { 0x00000547, 0x0000781C, { { 0xCF, 0xD6, 0x1D, 0x3D, 0x14, 0x40, 0x88, 0x35, 0x36, 0x4F, 0x0B, 0x1F, 0x9A, 0x1C, 0x3D, 0xAC } } } }, // floppy
+ { UNK_LANG, kPlatformPC, { 0x00000547, 0x000077E0, { { 0x80, 0xC4, 0xFC, 0xD5, 0xEB, 0xAA, 0xA5, 0x87, 0x58, 0x5E, 0xAA, 0xE7, 0x01, 0x8F, 0x59, 0x3F } } } }, // floppy
{ UNK_LANG, kPlatformPC, { 0x000005E5, 0x00008918, { { 0x6A, 0x33, 0x8C, 0xB0, 0x16, 0x57, 0x2D, 0xEB, 0xB2, 0xE1, 0x64, 0x80, 0x98, 0x99, 0x98, 0x19 } } } }, // CD
-
+
{ UNK_LANG, kPlatformAmiga, { 0x0000054A, 0x0000785F, { { 0x55, 0xEA, 0xB8, 0x7F, 0x3A, 0x86, 0xCD, 0xA6, 0xBC, 0xA7, 0x9A, 0x39, 0xED, 0xF5, 0x30, 0x0A } } } },
{ UNK_LANG, kPlatformUnknown, { 0x00000547, 0x00007876, { { 0x7A, 0xC7, 0x80, 0x34, 0x7A, 0x1B, 0xAB, 0xF8, 0xA7, 0x2F, 0x63, 0x3C, 0xDA, 0x89, 0x3F, 0x82 } } } }, // some floppy DOS + FM-TOWNS
@@ -150,6 +152,7 @@ const ExtractEntrySearchData k1IntroCPSStringsProvider[] = {
{ UNK_LANG, kPlatformUnknown, { 0x00000014, 0x0000071D, { { 0xBA, 0xB6, 0x58, 0xB3, 0x28, 0x5E, 0x9F, 0x77, 0x69, 0x9D, 0x77, 0x53, 0x9D, 0x0D, 0xB0, 0x29 } } } }, // floppy + PC98
{ UNK_LANG, kPlatformPC, { 0x00000015, 0x00000786, { { 0xCF, 0x09, 0xE1, 0xD9, 0x8E, 0x34, 0x5D, 0xEA, 0xBC, 0xAC, 0xC4, 0xF4, 0x4A, 0xEC, 0xFF, 0xC1 } } } }, // CD
+ { UNK_LANG, kPlatformPC, { 0x00000019, 0x000008DB, { { 0x3A, 0xDC, 0x1D, 0xAD, 0xF4, 0x5E, 0xC9, 0x19, 0xE9, 0x84, 0xD1, 0x31, 0x89, 0x6B, 0x6C, 0xF7 } } } }, // Old floppy
{ UNK_LANG, kPlatformPC, { 0x0000000C, 0x00000413, { { 0xA1, 0xE3, 0x06, 0x53, 0x23, 0x9A, 0xE0, 0xF1, 0xE4, 0xFD, 0xD9, 0x05, 0x22, 0xA6, 0x28, 0x46 } } } }, // demo
{ UNK_LANG, kPlatformAmiga, { 0x00000016, 0x0000070A, { { 0xD9, 0xDB, 0x91, 0xCD, 0x93, 0x81, 0xC4, 0x3F, 0x14, 0xF1, 0xC5, 0x02, 0xE7, 0x3F, 0x3A, 0x6C } } } },
@@ -194,6 +197,8 @@ const ExtractEntrySearchData k1IntroStringsProvider[] = {
{ ES_ESP, kPlatformPC, { 0x000005CF, 0x00020415, { { 0xCC, 0xE5, 0x9F, 0xB8, 0xCA, 0xFA, 0x2D, 0x05, 0xB8, 0xAF, 0x9F, 0x1F, 0x8A, 0xA8, 0x56, 0xDE } } } },
+ { RU_RUS, kPlatformPC, { 0x000004F6, 0x000131C6, { { 0x77, 0x76, 0x12, 0xB1, 0xDA, 0x9C, 0xA9, 0xB5, 0x21, 0x1E, 0x49, 0x08, 0x46, 0xB3, 0xE4, 0x61 } } } },
+
{ EN_ANY, kPlatformAmiga, { 0x0000050A, 0x0001A7B1, { { 0x1B, 0x74, 0x71, 0x4C, 0xAB, 0x81, 0x10, 0x59, 0x8A, 0x21, 0x50, 0xBB, 0xFE, 0x6F, 0xD0, 0xE8 } } } },
{ DE_DEU, kPlatformAmiga, { 0x00000626, 0x00021319, { { 0x80, 0x55, 0x54, 0x14, 0x5D, 0x6F, 0x49, 0x04, 0x4A, 0xEF, 0x92, 0xB8, 0x5B, 0x01, 0x0F, 0x97 } } } },
@@ -219,6 +224,8 @@ const ExtractEntrySearchData k1OutroHomeStringProvider[] = {
{ IT_ITA, kPlatformPC, { 0x00000007, 0x000001B8, { { 0x17, 0x95, 0x5B, 0x4F, 0xE2, 0x07, 0x5A, 0x49, 0xFA, 0xCE, 0x53, 0x8B, 0xE7, 0x46, 0x69, 0xC7 } } } }, // (fan) CD
+ { RU_RUS, kPlatformPC, { 0x00000005, 0x000000EF, { { 0xA0, 0xB4, 0xF2, 0x11, 0x16, 0x92, 0xC8, 0xEB, 0xF2, 0x0C, 0xFE, 0x43, 0xFE, 0x18, 0xF6, 0xBB } } } },
+
EXTRACT_END_ENTRY
};
@@ -235,6 +242,7 @@ const ExtractEntrySearchData k1RoomListProvider[] = {
{ UNK_LANG, kPlatformFMTowns, { 0x000064E8, 0x0010312B, { { 0x94, 0x5C, 0x87, 0x35, 0x35, 0x6B, 0x3E, 0xBF, 0x55, 0x3D, 0xDB, 0xD9, 0xFB, 0x97, 0x27, 0x5D } } } },
{ UNK_LANG, kPlatformUnknown, { 0x00004DD6, 0x0010312B, { { 0xC6, 0xF0, 0xC4, 0x2C, 0x5A, 0xD7, 0x48, 0xE4, 0x41, 0x23, 0x65, 0x6D, 0xC8, 0xC7, 0xCE, 0xF5 } } } }, // DOS + PC98
+ { UNK_LANG, kPlatformUnknown, { 0x00004DD6, 0x0010315D, { { 0x4A, 0x1B, 0xA2, 0x35, 0xE1, 0x22, 0xD3, 0x7A, 0xE9, 0x69, 0x12, 0x3A, 0x9C, 0x92, 0x6F, 0x5C } } } }, // Old DOS floppy
{ UNK_LANG, kPlatformAmiga, { 0x00004ECC, 0x0010312B, { { 0x9A, 0x91, 0xF1, 0x9C, 0x8A, 0x96, 0x1C, 0x7B, 0xB7, 0xE4, 0xF1, 0xE9, 0x7D, 0xEF, 0x40, 0xBF } } } },
@@ -252,13 +260,19 @@ const ExtractEntrySearchData k1CharacterImageFilenamesProvider[] = {
};
const ExtractEntrySearchData k1AudioTracksProvider[] = {
- { UNK_LANG, kPlatformPC, { 0x00000041, 0x00000FBF, { { 0xB5, 0xA2, 0x90, 0xE9, 0x73, 0x83, 0x47, 0x5A, 0xB3, 0x3E, 0x04, 0xBB, 0xAA, 0xC8, 0x84, 0x53 } } } },
+ { UNK_LANG, kPlatformPC, { 0x00000038, 0x00000D5C, { { 0x65, 0x35, 0x2F, 0xA3, 0x93, 0x22, 0x15, 0xA0, 0xC6, 0x2B, 0x73, 0x7C, 0x3E, 0xB8, 0x7A, 0xB5 } } } },
{ UNK_LANG, kPlatformFMTowns, { 0x0000005D, 0x0000154E, { { 0xA7, 0x7E, 0x03, 0x0A, 0x81, 0x54, 0xD2, 0x5D, 0x7B, 0x33, 0x07, 0xBF, 0x70, 0x01, 0x4B, 0x79 } } } },
EXTRACT_END_ENTRY
};
+const ExtractEntrySearchData k1AudioTracks2Provider[] = {
+ { UNK_LANG, kPlatformPC, { 0x00000009, 0x00000363, { { 0x16, 0xA2, 0x68, 0x21, 0x04, 0xA8, 0x39, 0x7E, 0xA1, 0x7D, 0x70, 0xFD, 0x86, 0xC7, 0x69, 0x28 } } } },
+
+ EXTRACT_END_ENTRY
+};
+
const ExtractEntrySearchData k1AudioTracksIntroProvider[] = {
{ UNK_LANG, kPlatformUnknown, { 0x00000006, 0x0000022C, { { 0x5F, 0xC9, 0xE1, 0x4B, 0x34, 0x52, 0xB9, 0xF8, 0xFF, 0x37, 0x8B, 0xF4, 0xEF, 0x5E, 0xC5, 0xDA } } } }, // floppy + demo
{ UNK_LANG, kPlatformUnknown, { 0x0000000C, 0x00000458, { { 0xEB, 0xB3, 0x96, 0xA5, 0x07, 0xE6, 0x11, 0x58, 0xDB, 0x3F, 0x34, 0x30, 0xFB, 0x7B, 0x92, 0xC8 } } } }, // CD
@@ -278,6 +292,8 @@ const ExtractEntrySearchData k1ItemNamesProvider[] = {
{ ES_ESP, kPlatformPC, { 0x00000530, 0x0001D90A, { { 0x52, 0xFB, 0xA8, 0x3F, 0xA3, 0x6F, 0xC2, 0x67, 0x55, 0x9F, 0x66, 0x9F, 0xFD, 0x79, 0x44, 0xDF } } } },
+ { RU_RUS, kPlatformPC, { 0x000004AE, 0x00011888, { { 0x6F, 0x4D, 0xBE, 0xC8, 0xAE, 0x7C, 0x12, 0x3E, 0x69, 0x0B, 0x39, 0xCB, 0x4D, 0x4B, 0xA8, 0x3A } } } }, // floppy
+
{ EN_ANY, kPlatformAmiga, { 0x00000380, 0x00012960, { { 0x2D, 0x81, 0xCF, 0x7A, 0x9D, 0x71, 0x83, 0xB7, 0xE5, 0x00, 0xB0, 0x6E, 0x25, 0x94, 0xCB, 0xA4 } } } },
{ DE_DEU, kPlatformAmiga, { 0x000003E5, 0x0001607D, { { 0x6D, 0xBE, 0xAD, 0xE5, 0xD1, 0x41, 0x6C, 0x42, 0x71, 0x79, 0x9C, 0x78, 0x93, 0x84, 0xC8, 0x11 } } } },
@@ -302,6 +318,8 @@ const ExtractEntrySearchData k1TakenStringsProvider[] = {
{ ES_ESP, kPlatformPC, { 0x00000014, 0x000005D8, { { 0xD6, 0x00, 0x90, 0x6A, 0x75, 0x3B, 0xF1, 0xFE, 0xF4, 0x3E, 0x0E, 0x1D, 0x39, 0xEB, 0x2D, 0xC8 } } } },
+ { RU_RUS, kPlatformPC, { 0x00000010, 0x00000262, { { 0x1E, 0x90, 0x20, 0xC8, 0xD3, 0x08, 0x53, 0x4F, 0x28, 0x95, 0x6A, 0xA4, 0x14, 0x37, 0x05, 0xF0 } } } },
+
{ EN_ANY, kPlatformAmiga, { 0x00000008, 0x00000261, { { 0x93, 0x5B, 0x79, 0xE8, 0x89, 0x8E, 0xB5, 0x37, 0x39, 0x2A, 0xB0, 0x04, 0x98, 0x80, 0x5A, 0x4E } } } },
{ DE_DEU, kPlatformAmiga, { 0x0000000E, 0x000004E0, { { 0x52, 0x4D, 0x74, 0x91, 0x70, 0x0D, 0x4C, 0x40, 0x5C, 0x7E, 0xBA, 0xDA, 0x24, 0x49, 0xF3, 0x1A } } } },
@@ -324,8 +342,10 @@ const ExtractEntrySearchData k1PlacedStringsProvider[] = {
{ IT_ITA, kPlatformPC, { 0x0000000D, 0x0000040D, { { 0x9C, 0x71, 0x53, 0x35, 0xC3, 0xE8, 0x46, 0xB9, 0xD2, 0xFA, 0x1C, 0x8C, 0xC3, 0xFF, 0xBC, 0x1F } } } }, // floppy
{ IT_ITA, kPlatformPC, { 0x00000011, 0x000003B8, { { 0xC8, 0xA6, 0xE4, 0x8A, 0xF7, 0x4C, 0x3F, 0xA6, 0x24, 0x7F, 0xEF, 0xE4, 0x63, 0x8B, 0x72, 0xF3 } } } }, // (fan) CD
-
+
{ ES_ESP, kPlatformPC, { 0x0000000D, 0x00000439, { { 0x57, 0xAE, 0x1C, 0xC1, 0xF5, 0xE8, 0x5B, 0x9E, 0x90, 0x02, 0xB9, 0x8D, 0x86, 0x38, 0xFB, 0xA8 } } } },
+
+ { RU_RUS, kPlatformPC, { 0x00000009, 0x00000203, { { 0x7D, 0xAE, 0x67, 0x94, 0x8E, 0x73, 0x35, 0xC1, 0x11, 0xB4, 0x55, 0x6E, 0x92, 0x25, 0x39, 0xE4 } } } },
EXTRACT_END_ENTRY
};
@@ -344,6 +364,8 @@ const ExtractEntrySearchData k1DroppedStringsProvider[] = {
{ ES_ESP, kPlatformPC, { 0x00000008, 0x00000261, { { 0x1D, 0xB5, 0xFB, 0x23, 0x94, 0xA7, 0x86, 0x7A, 0xAC, 0x53, 0xDA, 0x6F, 0xCC, 0x41, 0x0F, 0xD7 } } } },
+ { RU_RUS, kPlatformPC, { 0x0000000A, 0x000001F5, { { 0xAA, 0x21, 0x88, 0x6D, 0xD0, 0xAB, 0x5C, 0x15, 0x7F, 0xAD, 0x0E, 0x3B, 0x2F, 0x17, 0xBF, 0xAD } } } },
+
EXTRACT_END_ENTRY
};
@@ -384,6 +406,8 @@ const ExtractEntrySearchData k1PutDownStringProvider[] = {
{ ES_ESP, kPlatformPC, { 0x0000002D, 0x00001052, { { 0x12, 0x0A, 0x23, 0x11, 0xDF, 0x8A, 0x59, 0xD4, 0xF2, 0xCA, 0xA5, 0xA7, 0x76, 0x1B, 0x54, 0xB6 } } } },
+ { RU_RUS, kPlatformPC, { 0x00000024, 0x0000099F, { { 0x05, 0xD7, 0xB8, 0x32, 0x95, 0x93, 0x29, 0x5F, 0xF3, 0x1A, 0xF0, 0x2E, 0xBA, 0x3A, 0x0D, 0x27 } } } },
+
EXTRACT_END_ENTRY
};
@@ -401,6 +425,8 @@ const ExtractEntrySearchData k1WaitAmuletStringProvider[] = {
{ ES_ESP, kPlatformPC, { 0x00000042, 0x000017FD, { { 0x0A, 0x8A, 0x7E, 0x9A, 0x5F, 0x4A, 0x35, 0x06, 0x4D, 0x6B, 0xBF, 0x29, 0x1B, 0xAD, 0xD8, 0x37 } } } },
+ { RU_RUS, kPlatformPC, { 0x0000003C, 0x00000EF1, { { 0xC1, 0x0A, 0xFA, 0xBB, 0x65, 0xC3, 0x31, 0xC9, 0x80, 0x9B, 0x0C, 0x16, 0xED, 0xBF, 0x47, 0xFA } } } },
+
{ EN_ANY, kPlatformUnknown, { 0x0000003E, 0x0000150D, { { 0xA8, 0xBF, 0x99, 0x9B, 0xC1, 0x36, 0x21, 0x47, 0x6D, 0x99, 0x4F, 0x34, 0xE6, 0x61, 0x47, 0xFD } } } }, // Amiga + FM-TOWNS
EXTRACT_END_ENTRY
@@ -420,6 +446,8 @@ const ExtractEntrySearchData k1BlackJewelStringProvider[] = {
{ ES_ESP, kPlatformPC, { 0x00000025, 0x00000CF6, { { 0x4B, 0x13, 0x39, 0xCB, 0x3F, 0x44, 0x18, 0x46, 0x43, 0xDB, 0x94, 0xC5, 0x3E, 0x6B, 0xC4, 0x74 } } } },
+ { RU_RUS, kPlatformPC, { 0x00000021, 0x000007FF, { { 0x3F, 0x26, 0xB4, 0xB4, 0x11, 0x0C, 0xEF, 0xC0, 0x6A, 0xD1, 0xCC, 0x0E, 0x68, 0x7D, 0xA5, 0x1A } } } },
+
{ EN_ANY, kPlatformUnknown, { 0x00000024, 0x00000B73, { { 0x8D, 0x57, 0x5F, 0x93, 0x85, 0x75, 0xF2, 0xD8, 0x36, 0xC2, 0x7C, 0x0E, 0x3B, 0xEA, 0xE0, 0x0A } } } }, // Amiga + FM-TOWNS
EXTRACT_END_ENTRY
@@ -438,6 +466,8 @@ const ExtractEntrySearchData k1PoisonGoneStringProvider[] = {
{ ES_ESP, kPlatformPC, { 0x00000033, 0x0000127E, { { 0x67, 0xEB, 0xD3, 0x00, 0xF8, 0x4F, 0xF1, 0x79, 0x48, 0xE6, 0x9C, 0xB2, 0xA7, 0xCF, 0x76, 0x07 } } } },
+ { RU_RUS, kPlatformPC, { 0x00000027, 0x00000952, { { 0x36, 0x64, 0x30, 0x1C, 0x5A, 0xC0, 0x0D, 0x73, 0xE5, 0xA6, 0x2F, 0xD8, 0x64, 0x98, 0x81, 0x56 } } } },
+
{ EN_ANY, kPlatformAmiga, { 0x0000002E, 0x00000F59, { { 0xAD, 0x95, 0xF3, 0xA7, 0xBB, 0x04, 0x08, 0x77, 0xD0, 0x71, 0xFC, 0x8B, 0x33, 0x2A, 0x6D, 0xD3 } } } },
{ DE_DEU, kPlatformAmiga, { 0x00000037, 0x00001324, { { 0xB3, 0xE6, 0x0A, 0x49, 0x37, 0x73, 0x3C, 0xAF, 0x78, 0x9E, 0x7D, 0x13, 0x75, 0xAE, 0xA8, 0x89 } } } },
@@ -463,6 +493,8 @@ const ExtractEntrySearchData k1HealingTipStringProvider[] = {
{ ES_ESP, kPlatformPC, { 0x00000028, 0x00000E0F, { { 0x3E, 0x40, 0xCA, 0x2A, 0x5F, 0xFE, 0x74, 0x30, 0x8C, 0x31, 0x41, 0x09, 0xBD, 0xFD, 0xA3, 0x7E } } } },
+ { RU_RUS, kPlatformPC, { 0x00000026, 0x000008EE, { { 0x7C, 0xC0, 0x62, 0x39, 0x66, 0x9E, 0x63, 0xCD, 0x21, 0x3D, 0x72, 0x91, 0xB8, 0xB9, 0xB6, 0x92 } } } },
+
{ EN_ANY, kPlatformUnknown, { 0x0000002E, 0x00000F04, { { 0x95, 0x39, 0x36, 0x89, 0xC4, 0x60, 0x7C, 0x0C, 0xDC, 0x06, 0xF7, 0x86, 0x1A, 0xF7, 0x93, 0x2B } } } }, // Amiga + FM-TOWNS
EXTRACT_END_ENTRY
@@ -483,6 +515,9 @@ const ExtractEntrySearchData k1WispJewelStringsProvider[] = {
{ ES_ESP, kPlatformPC, { 0x0000005F, 0x0000211E, { { 0xE7, 0x0A, 0x85, 0x25, 0x44, 0x41, 0x47, 0x3B, 0x7A, 0xA6, 0x62, 0xAE, 0xAE, 0xD5, 0x92, 0x45 } } } },
+ // only one of two strings translated in the fan translation
+ { RU_RUS, kPlatformPC, { 0x00000053, 0x0000191F, { { 0x14, 0xEB, 0x38, 0x54, 0x40, 0x40, 0x04, 0xA6, 0xA0, 0xFE, 0xDB, 0xD0, 0x8C, 0xA6, 0x1F, 0x55 } } } },
+
{ EN_ANY, kPlatformAmiga, { 0x00000056, 0x00001C62, { { 0x43, 0x28, 0x3C, 0x0F, 0x78, 0x52, 0xE7, 0x2A, 0x77, 0xF3, 0x21, 0x5A, 0xF0, 0xFC, 0x9E, 0xF8 } } } },
{ DE_DEU, kPlatformAmiga, { 0x00000063, 0x00002184, { { 0x6B, 0xDC, 0x6B, 0xCF, 0xD4, 0xC7, 0x2A, 0x9A, 0x2E, 0x34, 0x71, 0x4E, 0xB7, 0xF6, 0xAF, 0xDA } } } },
@@ -508,6 +543,8 @@ const ExtractEntrySearchData k1MagicJewelStringsProvider[] = {
{ ES_ESP, kPlatformPC, { 0x00000011, 0x000005CD, { { 0x32, 0x2A, 0xFF, 0x9F, 0x10, 0x75, 0x6B, 0xD6, 0x46, 0xAE, 0x55, 0xD3, 0x68, 0x4F, 0xBB, 0x5A } } } },
+ { RU_RUS, kPlatformPC, { 0x00000012, 0x0000047D, { { 0xB1, 0xC3, 0x66, 0xBC, 0x42, 0xAD, 0x5B, 0xD8, 0xF5, 0x3D, 0xB9, 0x50, 0x77, 0x32, 0xA7, 0x15 } } } },
+
{ EN_ANY, kPlatformUnknown, { 0x00000014, 0x0000069E, { { 0x6A, 0x1C, 0x9B, 0x85, 0x61, 0xC7, 0x28, 0xA9, 0xA3, 0xF4, 0xFA, 0x47, 0x90, 0x8F, 0x06, 0xB4 } } } }, // Amiga + FM-TOWNS
EXTRACT_END_ENTRY
@@ -525,6 +562,8 @@ const ExtractEntrySearchData k1ThePoisonStringsProvider[] = {
{ ES_ESP, kPlatformPC, { 0x00000059, 0x00001DF7, { { 0x16, 0x7B, 0x5F, 0x91, 0x06, 0x5B, 0xFC, 0x9C, 0x88, 0x61, 0xCC, 0x1B, 0x52, 0x4F, 0x91, 0xC5 } } } },
+ { RU_RUS, kPlatformPC, { 0x00000052, 0x0000136F, { { 0xEF, 0xD2, 0xA0, 0x5F, 0xD5, 0xE6, 0x77, 0x96, 0xFA, 0xC5, 0x60, 0x7C, 0xB7, 0xA8, 0x7C, 0x7A } } } },
+
{ EN_ANY, kPlatformAmiga, { 0x00000058, 0x00001C24, { { 0xBA, 0x1F, 0xBD, 0x5C, 0x85, 0x3D, 0x3C, 0x92, 0xD1, 0x13, 0xF3, 0x40, 0x2E, 0xBB, 0x1C, 0xE2 } } } },
{ DE_DEU, kPlatformAmiga, { 0x00000073, 0x00002690, { { 0x44, 0xAE, 0xC9, 0xFD, 0x9F, 0x8E, 0x1B, 0xDD, 0x3F, 0xE4, 0x4D, 0x4B, 0x5A, 0x13, 0xE5, 0x99 } } } },
@@ -549,6 +588,9 @@ const ExtractEntrySearchData k1FluteStringsProvider[] = {
{ ES_ESP, kPlatformPC, { 0x00000052, 0x00001D8E, { { 0x9D, 0xA5, 0xF1, 0x42, 0xD1, 0x48, 0xEB, 0x8F, 0x4B, 0xDC, 0xD9, 0x10, 0x55, 0xBD, 0x12, 0xBB } } } },
+ // not translated in the fan translation
+ { RU_RUS, kPlatformPC, { 0x0000003C, 0x00001599, { { 0x96, 0x72, 0x5A, 0x8A, 0xA0, 0xEE, 0xA2, 0xCE, 0x4D, 0x21, 0x01, 0x6C, 0xC5, 0x1A, 0xEB, 0x21 } } } },
+
{ EN_ANY, kPlatformFMTowns, { 0x0000005A, 0x000024F9, { { 0xCA, 0x1F, 0x62, 0x23, 0x22, 0x25, 0x4A, 0x94, 0x8A, 0x50, 0x59, 0xD5, 0xB4, 0x4E, 0xF1, 0xA6 } } } },
{ JA_JPN, kPlatformFMTowns, { 0x00000053, 0x00002745, { { 0x7A, 0xBB, 0xFC, 0x30, 0xB6, 0xCE, 0x61, 0xD4, 0xDB, 0xB0, 0xE6, 0xB2, 0xF4, 0x4D, 0x81, 0x35 } } } },
@@ -571,6 +613,8 @@ const ExtractEntrySearchData k1FlaskFullStringProvider[] = {
{ ES_ESP, kPlatformPC, { 0x0000001B, 0x0000099D, { { 0x13, 0x23, 0x5D, 0x38, 0x9B, 0xFB, 0x00, 0x5C, 0xA1, 0x3A, 0x22, 0xD6, 0xCD, 0x5C, 0x09, 0xAE } } } },
+ { RU_RUS, kPlatformPC, { 0x0000001A, 0x0000066E, { { 0x36, 0x43, 0xB6, 0xB2, 0xED, 0xBA, 0x21, 0x0C, 0x16, 0x54, 0x99, 0xF9, 0x2E, 0x6E, 0x0A, 0x28 } } } },
+
EXTRACT_END_ENTRY
};
@@ -586,6 +630,8 @@ const ExtractEntrySearchData k1FullFlaskStringProvider[] = {
{ ES_ESP, kPlatformPC, { 0x0000009A, 0x0000363B, { { 0x38, 0x25, 0xE6, 0xB5, 0xCB, 0x78, 0x5E, 0xAD, 0x2D, 0xD4, 0x2E, 0x8B, 0x89, 0x20, 0xB1, 0x95 } } } },
+ { RU_RUS, kPlatformPC, { 0x00000094, 0x0000232B, { { 0xBF, 0x68, 0xF9, 0x8F, 0x82, 0xE9, 0xE7, 0x69, 0x33, 0xD6, 0x41, 0x15, 0x2C, 0xFE, 0x72, 0xAB } } } },
+
{ EN_ANY, kPlatformAmiga, { 0x0000009A, 0x00003521, { { 0x26, 0xE5, 0xC8, 0x6D, 0x14, 0x81, 0x9F, 0x90, 0x38, 0x3C, 0x00, 0x9D, 0x8E, 0x72, 0xB1, 0x83 } } } },
{ DE_DEU, kPlatformAmiga, { 0x000000B0, 0x00003E38, { { 0x8A, 0x6D, 0x42, 0x36, 0x29, 0x06, 0xB2, 0xCE, 0xA3, 0x41, 0x14, 0xE8, 0xB1, 0xEF, 0x6E, 0x3B } } } },
@@ -611,6 +657,9 @@ const ExtractEntrySearchData k1VeryCleverStringProvider[] = {
{ ES_ESP, kPlatformPC, { 0x00000036, 0x000013F8, { { 0x2D, 0x9B, 0x7D, 0x58, 0xD1, 0x94, 0x04, 0x45, 0x6E, 0x81, 0xCC, 0x1E, 0x2F, 0xC5, 0xC9, 0xEA } } } },
+ // not translated in the fan translation
+ { RU_RUS, kPlatformPC, { 0x00000032, 0x0000118D, { { 0x4B, 0x6D, 0xD4, 0xDC, 0x3E, 0xA2, 0x2D, 0x6D, 0x2C, 0x5A, 0xF7, 0x67, 0x4B, 0x6D, 0x40, 0xEF } } } },
+
EXTRACT_END_ENTRY
};
@@ -628,6 +677,8 @@ const ExtractEntrySearchData k1NewGameStringProvider[] = {
{ ES_ESP, kPlatformPC, { 0x0000001B, 0x00000701, { { 0x2B, 0x87, 0xC3, 0x82, 0x68, 0xA5, 0xFC, 0xC5, 0x64, 0x9E, 0xAB, 0xD2, 0x8A, 0x07, 0x9C, 0x1E } } } },
+ { RU_RUS, kPlatformPC, { 0x00000015, 0x0000035F, { { 0x7E, 0x49, 0xC1, 0xCB, 0x2D, 0x61, 0xA7, 0x4C, 0x20, 0xAC, 0xEC, 0x54, 0x80, 0x14, 0x6A, 0xCA } } } },
+
EXTRACT_END_ENTRY
};
@@ -654,7 +705,7 @@ const ExtractEntrySearchData k1Healing2ShapesProvider[] = {
const ExtractEntrySearchData k1PoisonDeathShapesProvider[] = {
{ UNK_LANG, kPlatformUnknown, { 0x0000008C, 0x00002E90, { { 0xBC, 0x44, 0xFB, 0x98, 0xE7, 0x42, 0xF6, 0xC8, 0x87, 0xDD, 0x00, 0x42, 0x85, 0xD8, 0x1E, 0x81 } } } },
-
+ { UNK_LANG, kPlatformUnknown, { 0x0000008C, 0x00002E7C, { { 0xA5, 0xD7, 0x13, 0xFC, 0x43, 0x22, 0x13, 0xBC, 0x5F, 0x3F, 0xC8, 0x28, 0xDA, 0x04, 0xB0, 0xDD } } } }, // Old Dos Floppy
EXTRACT_END_ENTRY
};
@@ -931,6 +982,8 @@ const ExtractEntrySearchData k1GUIStringsProvider[] = {
{ ES_ESP, kPlatformPC, { 0x0000023A, 0x0000C3BD, { { 0xED, 0x0D, 0xE7, 0x5B, 0xDC, 0x21, 0x41, 0x54, 0x68, 0x7D, 0x8E, 0x97, 0x1A, 0xB1, 0xA1, 0x4A } } } }, // floppy
+ { RU_RUS, kPlatformPC, { 0x000001B1, 0x000065E8, { { 0x91, 0x22, 0x61, 0x8B, 0xCD, 0x7C, 0x0E, 0xD4, 0x32, 0x00, 0xC3, 0x6E, 0x50, 0x7F, 0x3C, 0x82 } } } }, // floppy
+
{ EN_ANY, kPlatformAmiga, { 0x000001DF, 0x00009042, { { 0x0D, 0xD3, 0x1A, 0x92, 0x8D, 0x9C, 0x72, 0x55, 0xEF, 0xFB, 0x81, 0x21, 0x3B, 0x43, 0xA7, 0xE8 } } } },
{ DE_DEU, kPlatformAmiga, { 0x00000237, 0x0000BAF7, { { 0xD7, 0x1A, 0x8E, 0xCC, 0x6D, 0x3E, 0xA9, 0xDD, 0x9A, 0x6B, 0x71, 0xFE, 0xD4, 0x50, 0x30, 0x6E } } } },
@@ -957,6 +1010,9 @@ const ExtractEntrySearchData k1ConfigStringsProvider[] = {
{ ES_ESP, kPlatformPC, { 0x0000004A, 0x00001B7B, { { 0x6B, 0x69, 0x50, 0x92, 0x9B, 0x35, 0x58, 0xE1, 0xEA, 0xBF, 0x42, 0x0B, 0xEB, 0x88, 0x41, 0x8D } } } }, // floppy
+ // not translated in the fan translation
+ { RU_RUS, kPlatformPC, { 0x0000003F, 0x00000B0D, { { 0x0E, 0x60, 0x0F, 0x4A, 0xA9, 0xF0, 0x1B, 0x76, 0xBB, 0x33, 0xB2, 0x4B, 0x5C, 0xB5, 0x4A, 0x97 } } } }, // floppy
+
{ EN_ANY, kPlatformAmiga, { 0x0000002E, 0x00000FA1, { { 0x5E, 0xFF, 0xFF, 0x3D, 0xF8, 0x11, 0x6F, 0x3B, 0xC5, 0x39, 0x8F, 0x25, 0x8F, 0x0F, 0xE9, 0x2B } } } },
{ DE_DEU, kPlatformAmiga, { 0x00000043, 0x00001783, { { 0xB2, 0x2B, 0xAB, 0x27, 0x06, 0x9A, 0x1E, 0x4B, 0xA7, 0xD3, 0xFF, 0xEB, 0xFD, 0x12, 0xDC, 0x94 } } } },
@@ -1057,6 +1113,8 @@ const ExtractEntrySearchData k2SeqplayStringsProvider[] = {
{ IT_ITA, kPlatformPC, { 0x00000916, 0x0003188F, { { 0xDC, 0x46, 0x06, 0xE1, 0xB0, 0x66, 0xBC, 0x18, 0x2E, 0x6E, 0x9E, 0xC9, 0xA4, 0x14, 0x8D, 0x08 } } } }, // floppy
{ IT_ITA, kPlatformPC, { 0x000008C8, 0x00030947, { { 0x7F, 0x75, 0x5F, 0x99, 0x94, 0xFE, 0xA1, 0xE6, 0xEF, 0xB8, 0x93, 0x71, 0x83, 0x1B, 0xAC, 0x4A } } } }, // (fan) CD
+ { RU_RUS, kPlatformPC, { 0x000008C8, 0x00028639, { { 0xF9, 0x1D, 0x6A, 0x85, 0x23, 0x5E, 0x2A, 0x64, 0xBC, 0x45, 0xB2, 0x48, 0x13, 0x49, 0xD4, 0xF7 } } } }, // (fan) floppy
+
{ EN_ANY, kPlatformFMTowns, { 0x00000990, 0x00030C61, { { 0x60, 0x51, 0x11, 0x83, 0x3F, 0x06, 0xC3, 0xA3, 0xE0, 0xC0, 0x2F, 0x41, 0x29, 0xDE, 0x65, 0xB1 } } } },
{ JA_JPN, kPlatformFMTowns, { 0x000008A8, 0x00036831, { { 0x56, 0x5B, 0x23, 0x61, 0xE8, 0x3B, 0xE1, 0x36, 0xD6, 0x62, 0xD0, 0x84, 0x00, 0x04, 0x05, 0xAD } } } },
@@ -1281,10 +1339,15 @@ const ExtractEntrySearchData kLolIngamePakFilesProvider[] = {
};
const ExtractEntrySearchData kLolCharacterDefsProvider[] = {
- { UNK_LANG, kPlatformPC, { 0x00000492, 0x000046B0, { { 0x7A, 0x94, 0x8B, 0xC6, 0xF7, 0xF1, 0x2F, 0xF3, 0xBC, 0x1B, 0x0B, 0x4E, 0x00, 0xC9, 0x44, 0x58 } } } }, // floppy
- { UNK_LANG, kPlatformPC, { 0x00000492, 0x000047FD, { { 0x8C, 0x0B, 0x8B, 0xCE, 0xE0, 0xB0, 0x8F, 0xA9, 0x06, 0xC3, 0x98, 0xE6, 0x2E, 0x09, 0xB6, 0x93 } } } }, // floppy
- { UNK_LANG, kPlatformPC, { 0x00000492, 0x00004ACD, { { 0xDF, 0x87, 0xFE, 0x89, 0x59, 0xCC, 0x01, 0xD7, 0xC7, 0xEB, 0x16, 0xA4, 0x09, 0xAF, 0x5D, 0xC0 } } } }, // CD
- { UNK_LANG, kPlatformPC98, { 0x00000492, 0x00005893, { { 0x7C, 0x7E, 0xFB, 0x80, 0xD9, 0xB6, 0x16, 0x87, 0x80, 0xB7, 0x46, 0x9B, 0x96, 0x1A, 0x6A, 0xBE } } } },
+ { RU_RUS, kPlatformPC, { 0x00000492, 0x000052BA, { { 0x52, 0x29, 0x0D, 0x49, 0xFD, 0x17, 0xD7, 0x70, 0x6D, 0xCA, 0xEB, 0xB6, 0x7E, 0xFA, 0xBE, 0x08 } } } }, // floppy
+ { EN_ANY, kPlatformPC, { 0x00000492, 0x000046B0, { { 0x7A, 0x94, 0x8B, 0xC6, 0xF7, 0xF1, 0x2F, 0xF3, 0xBC, 0x1B, 0x0B, 0x4E, 0x00, 0xC9, 0x44, 0x58 } } } }, // floppy
+ { DE_DEU, kPlatformPC, { 0x00000492, 0x000047FD, { { 0x8C, 0x0B, 0x8B, 0xCE, 0xE0, 0xB0, 0x8F, 0xA9, 0x06, 0xC3, 0x98, 0xE6, 0x2E, 0x09, 0xB6, 0x93 } } } }, // floppy
+ { EN_ANY, kPlatformPC, { 0x00000492, 0x00004ACD, { { 0xDF, 0x87, 0xFE, 0x89, 0x59, 0xCC, 0x01, 0xD7, 0xC7, 0xEB, 0x16, 0xA4, 0x09, 0xAF, 0x5D, 0xC0 } } } }, // CD
+ { DE_DEU, kPlatformPC, { 0x00000492, 0x00004ACD, { { 0xDF, 0x87, 0xFE, 0x89, 0x59, 0xCC, 0x01, 0xD7, 0xC7, 0xEB, 0x16, 0xA4, 0x09, 0xAF, 0x5D, 0xC0 } } } }, // CD
+ { FR_FRA, kPlatformPC, { 0x00000492, 0x00004ACD, { { 0xDF, 0x87, 0xFE, 0x89, 0x59, 0xCC, 0x01, 0xD7, 0xC7, 0xEB, 0x16, 0xA4, 0x09, 0xAF, 0x5D, 0xC0 } } } }, // CD
+ { RU_RUS, kPlatformPC, { 0x00000492, 0x00004ACD, { { 0xDF, 0x87, 0xFE, 0x89, 0x59, 0xCC, 0x01, 0xD7, 0xC7, 0xEB, 0x16, 0xA4, 0x09, 0xAF, 0x5D, 0xC0 } } } }, // CD
+ { IT_ITA, kPlatformPC, { 0x00000492, 0x00004ACD, { { 0xDF, 0x87, 0xFE, 0x89, 0x59, 0xCC, 0x01, 0xD7, 0xC7, 0xEB, 0x16, 0xA4, 0x09, 0xAF, 0x5D, 0xC0 } } } }, // CD
+ { JA_JPN, kPlatformPC98, { 0x00000492, 0x00005893, { { 0x7C, 0x7E, 0xFB, 0x80, 0xD9, 0xB6, 0x16, 0x87, 0x80, 0xB7, 0x46, 0x9B, 0x96, 0x1A, 0x6A, 0xBE } } } },
EXTRACT_END_ENTRY
};
@@ -1766,6 +1829,7 @@ const ExtractEntry extractProviders[] = {
{ k1RoomList, k1RoomListProvider },
{ k1CharacterImageFilenames, k1CharacterImageFilenamesProvider },
{ k1AudioTracks, k1AudioTracksProvider },
+ { k1AudioTracks2, k1AudioTracks2Provider },
{ k1AudioTracksIntro, k1AudioTracksIntroProvider },
{ k1ItemNames, k1ItemNamesProvider },
{ k1TakenStrings, k1TakenStringsProvider },
diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 52085daac5..183792b5df 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -29,6 +29,7 @@ p.strip_path = 3
context = p.parse('dreamweb/dreamweb.asm')
p.link()
generator = cpp(context, "DreamGen", blacklist = [
+ # These functions are not processed
'randomnumber',
'quickquit',
'quickquit2',
@@ -43,6 +44,15 @@ generator = cpp(context, "DreamGen", blacklist = [
'printundermon',
'kernchars',
'getnextword',
+ 'getnumber',
+ 'dumptextline',
+ 'printboth',
+ 'printchar',
+ 'printdirect',
+ 'printslow',
+ 'usetimedtext',
+ 'putundertimed',
+ 'getundertimed',
'worktoscreen',
'width160',
'convertkey',
@@ -61,6 +71,11 @@ generator = cpp(context, "DreamGen", blacklist = [
'liftsprite',
'frameoutv',
'modifychar',
- 'lockmon'
+ 'lockmon',
+ 'cancelch0',
+ 'cancelch1'
+ ], skip_output = [
+ # These functions are processed but not output
+ 'dreamweb'
])
generator.generate('dreamweb') #start routine
diff --git a/devtools/tasmrecover/tasm/cpp.py b/devtools/tasmrecover/tasm/cpp.py
index a73fd6c890..4ed89f650d 100644
--- a/devtools/tasmrecover/tasm/cpp.py
+++ b/devtools/tasmrecover/tasm/cpp.py
@@ -33,7 +33,7 @@ def parse_bin(s):
return v
class cpp:
- def __init__(self, context, namespace, skip_first = 0, blacklist = []):
+ def __init__(self, context, namespace, skip_first = 0, blacklist = [], skip_output = []):
self.namespace = namespace
fname = namespace.lower() + ".cpp"
header = namespace.lower() + ".h"
@@ -79,6 +79,7 @@ class cpp:
self.proc_done = []
self.blacklist = blacklist
self.failed = list(blacklist)
+ self.skip_output = skip_output
self.translated = []
self.proc_addr = []
self.methods = []
@@ -527,7 +528,8 @@ namespace %s {
self.proc.optimize(keep_labels=[label])
self.proc.visit(self, start)
self.body += "}\n";
- self.translated.insert(0, self.body)
+ if name not in self.skip_output:
+ self.translated.insert(0, self.body)
self.proc = None
if self.temps_count > 0:
raise Exception("temps count == %d at the exit of proc" %self.temps_count);
diff --git a/dists/engine-data/kyra.dat b/dists/engine-data/kyra.dat
index 1d79ceddfd..902d55c457 100644
--- a/dists/engine-data/kyra.dat
+++ b/dists/engine-data/kyra.dat
Binary files differ
diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp
new file mode 100644
index 0000000000..cf773dc2dc
--- /dev/null
+++ b/engines/composer/composer.cpp
@@ -0,0 +1,495 @@
+/* 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 "common/scummsys.h"
+
+#include "common/config-manager.h"
+#include "common/events.h"
+#include "common/file.h"
+#include "common/random.h"
+#include "common/fs.h"
+#include "common/keyboard.h"
+#include "common/substream.h"
+
+#include "graphics/cursorman.h"
+#include "graphics/surface.h"
+#include "graphics/pixelformat.h"
+
+#include "engines/util.h"
+#include "engines/advancedDetector.h"
+
+#include "audio/audiostream.h"
+
+#include "composer/composer.h"
+#include "composer/graphics.h"
+#include "composer/resource.h"
+
+namespace Composer {
+
+ComposerEngine::ComposerEngine(OSystem *syst, const ComposerGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
+ _rnd = new Common::RandomSource("composer");
+ _audioStream = NULL;
+}
+
+ComposerEngine::~ComposerEngine() {
+ DebugMan.clearAllDebugChannels();
+
+ for (Common::List<Library>::iterator i = _libraries.begin(); i != _libraries.end(); i++)
+ delete i->_archive;
+ for (Common::List<Sprite>::iterator i = _sprites.begin(); i != _sprites.end(); i++)
+ i->_surface.free();
+
+ delete _rnd;
+}
+
+Common::Error ComposerEngine::run() {
+ Common::Event event;
+
+ _vars.resize(1000);
+ for (uint i = 0; i < _vars.size(); i++)
+ _vars[i] = 0;
+
+ _queuedScripts.resize(10);
+ for (uint i = 0; i < _queuedScripts.size(); i++) {
+ _queuedScripts[i]._count = 0;
+ _queuedScripts[i]._scriptId = 0;
+ }
+
+ _mouseVisible = true;
+ _mouseEnabled = false;
+ _mouseSpriteId = 0;
+ _lastButton = NULL;
+
+ _directoriesToStrip = 1;
+ if (!_bookIni.loadFromFile("book.ini")) {
+ _directoriesToStrip = 0;
+ if (!_bookIni.loadFromFile("programs/book.ini"))
+ error("failed to find book.ini");
+ }
+
+ uint width = 640;
+ if (_bookIni.hasKey("Width", "Common"))
+ width = atoi(getStringFromConfig("Common", "Width").c_str());
+ uint height = 480;
+ if (_bookIni.hasKey("Height", "Common"))
+ height = atoi(getStringFromConfig("Common", "Height").c_str());
+ initGraphics(width, height, true);
+ _surface.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+ _needsUpdate = true;
+
+ loadLibrary(0);
+
+ uint fps = atoi(getStringFromConfig("Common", "FPS").c_str());
+ uint frameTime = 1000 / fps;
+ uint32 lastDrawTime = 0;
+ while (!shouldQuit()) {
+ for (uint i = 0; i < _pendingPageChanges.size(); i++) {
+ if (_pendingPageChanges[i]._remove)
+ unloadLibrary(_pendingPageChanges[i]._pageId);
+ else
+ loadLibrary(_pendingPageChanges[i]._pageId);
+
+ lastDrawTime = _system->getMillis();
+ }
+ _pendingPageChanges.clear();
+
+ uint32 thisTime = _system->getMillis();
+ for (uint i = 0; i < _queuedScripts.size(); i++) {
+ QueuedScript &script = _queuedScripts[i];
+ if (!script._count)
+ continue;
+ if (script._baseTime + script._duration > thisTime)
+ continue;
+ if (script._count != 0xffffffff)
+ script._count--;
+ script._baseTime = thisTime;
+ runScript(script._scriptId, i, 0, 0);
+ }
+
+ if (lastDrawTime + frameTime <= thisTime) {
+ // catch up if we're more than 5 frames behind
+ if (lastDrawTime + (frameTime * 5) <= thisTime)
+ lastDrawTime = thisTime - (frameTime * 5);
+ else
+ lastDrawTime += frameTime;
+
+ redraw();
+
+ processAnimFrame();
+ } else if (_needsUpdate) {
+ redraw();
+ }
+
+ while (_eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ onMouseDown(event.mouse);
+ break;
+
+ case Common::EVENT_LBUTTONUP:
+ break;
+
+ case Common::EVENT_RBUTTONDOWN:
+ break;
+
+ case Common::EVENT_MOUSEMOVE:
+ onMouseMove(event.mouse);
+ break;
+
+ case Common::EVENT_KEYDOWN:
+ switch (event.kbd.keycode) {
+ case Common::KEYCODE_d:
+ /*if (event.kbd.hasFlags(Common::KBD_CTRL)) {
+ // Start the debugger
+ getDebugger()->attach();
+ getDebugger()->onFrame();
+ }*/
+ break;
+
+ case Common::KEYCODE_q:
+ if (event.kbd.hasFlags(Common::KBD_CTRL))
+ quitGame();
+ break;
+
+ default:
+ break;
+ }
+
+ onKeyDown(event.kbd.keycode);
+ break;
+
+ case Common::EVENT_QUIT:
+ case Common::EVENT_RTL:
+ quitGame();
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ _system->delayMillis(20);
+ }
+
+ return Common::kNoError;
+}
+
+void ComposerEngine::onMouseDown(const Common::Point &pos) {
+ if (!_mouseEnabled || !_mouseVisible)
+ return;
+
+ const Sprite *sprite = getSpriteAtPos(pos);
+ const Button *button = getButtonFor(sprite, pos);
+ if (!button)
+ return;
+
+ // TODO: other buttons?
+ uint16 buttonsDown = 1; // MK_LBUTTON
+
+ uint16 spriteId = sprite ? sprite->_id : 0;
+ runScript(button->_scriptId, button->_id, buttonsDown, spriteId);
+}
+
+void ComposerEngine::onMouseMove(const Common::Point &pos) {
+ _lastMousePos = pos;
+
+ if (!_mouseEnabled || !_mouseVisible)
+ return;
+
+ // TODO: do we need to keep track of this?
+ uint buttonsDown = 0;
+
+ const Sprite *sprite = getSpriteAtPos(pos);
+ const Button *button = getButtonFor(sprite, pos);
+ if (_lastButton != button) {
+ if (_lastButton && _lastButton->_scriptIdRollOff)
+ runScript(_lastButton->_scriptIdRollOff, _lastButton->_id, buttonsDown, 0);
+ _lastButton = button;
+ if (_lastButton && _lastButton->_scriptIdRollOn)
+ runScript(_lastButton->_scriptIdRollOn, _lastButton->_id, buttonsDown, 0);
+ }
+
+ if (_mouseSpriteId) {
+ addSprite(_mouseSpriteId, 0, 0, _lastMousePos - _mouseOffset);
+ _needsUpdate = true;
+ }
+}
+
+void ComposerEngine::onKeyDown(uint16 keyCode) {
+ runEvent(kEventKeyDown, keyCode, 0, 0);
+ runEvent(kEventChar, keyCode, 0, 0);
+}
+
+void ComposerEngine::setCursor(uint16 id, const Common::Point &offset) {
+ _mouseOffset = offset;
+ if (_mouseSpriteId == id)
+ return;
+
+ if (_mouseSpriteId && _mouseVisible) {
+ removeSprite(_mouseSpriteId, 0);
+ }
+ _mouseSpriteId = id;
+ if (_mouseSpriteId && _mouseVisible) {
+ addSprite(_mouseSpriteId, 0, 0, _lastMousePos - _mouseOffset);
+ }
+}
+
+void ComposerEngine::setCursorVisible(bool visible) {
+ if (!_mouseSpriteId)
+ return;
+
+ if (visible && !_mouseVisible) {
+ _mouseVisible = true;
+ addSprite(_mouseSpriteId, 0, 0, _lastMousePos - _mouseOffset);
+ onMouseMove(_lastMousePos);
+ } else if (!visible && _mouseVisible) {
+ _mouseVisible = false;
+ removeSprite(_mouseSpriteId, 0);
+ }
+}
+
+Common::String ComposerEngine::getStringFromConfig(const Common::String &section, const Common::String &key) {
+ Common::String value;
+ if (!_bookIni.getKey(key, section, value))
+ error("failed to find key '%s' in section '%s' of book config", key.c_str(), section.c_str());
+ return value;
+}
+
+Common::String ComposerEngine::getFilename(const Common::String &section, uint id) {
+ Common::String key = Common::String::format("%d", id);
+ Common::String filename = getStringFromConfig(section, key);
+ while (filename.size() && (filename[0] == '~' || filename[0] == ':' || filename[0] == '\\'))
+ filename = filename.c_str() + 1;
+
+ uint slashesToStrip = _directoriesToStrip;
+ while (slashesToStrip--) {
+ for (uint i = 0; i < filename.size(); i++) {
+ if (filename[i] != '\\')
+ continue;
+ filename = filename.c_str() + i + 1;
+ break;
+ }
+ }
+
+ Common::String outFilename;
+ for (uint i = 0; i < filename.size(); i++) {
+ if (filename[i] == '\\')
+ outFilename += '/';
+ else
+ outFilename += filename[i];
+ }
+ return outFilename;
+}
+
+void ComposerEngine::loadLibrary(uint id) {
+ if (!id)
+ id = atoi(getStringFromConfig("Common", "StartUp").c_str());
+ Common::String filename = getFilename("Libs", id);
+
+ Library library;
+
+ library._id = id;
+ library._archive = new ComposerArchive();
+ if (!library._archive->openFile(filename))
+ error("failed to open '%s'", filename.c_str());
+ _libraries.push_front(library);
+
+ Library &newLib = _libraries.front();
+
+ Common::Array<uint16> buttonResources = library._archive->getResourceIDList(ID_BUTN);
+ for (uint i = 0; i < buttonResources.size(); i++) {
+ uint16 buttonId = buttonResources[i];
+ Common::SeekableReadStream *stream = library._archive->getResource(ID_BUTN, buttonId);
+ Button button(stream, buttonId);
+
+ bool inserted = false;
+ for (Common::List<Button>::iterator b = newLib._buttons.begin(); b != newLib._buttons.end(); b++) {
+ if (button._zorder <= b->_zorder)
+ continue;
+ newLib._buttons.insert(b, button);
+ inserted = true;
+ break;
+ }
+ if (!inserted)
+ newLib._buttons.push_back(button);
+ }
+
+ // add background sprite, if it exists
+ if (hasResource(ID_BMAP, 1000))
+ setBackground(1000);
+
+ // TODO: better CTBL logic
+ loadCTBL(1000, 100);
+
+ // Run the startup script.
+ runScript(1000, 0, 0, 0);
+
+ _mouseEnabled = true;
+ onMouseMove(_lastMousePos);
+
+ runEvent(kEventLoad, id, 0, 0);
+}
+
+void ComposerEngine::unloadLibrary(uint id) {
+ for (Common::List<Library>::iterator i = _libraries.begin(); i != _libraries.end(); i++) {
+ if (i->_id != id)
+ continue;
+
+ for (Common::List<Animation *>::iterator j = _anims.begin(); j != _anims.end(); j++) {
+ delete *j;
+ }
+ _anims.clear();
+ for (Common::List<Pipe *>::iterator j = _pipes.begin(); j != _pipes.end(); j++) {
+ delete *j;
+ }
+ _pipes.clear();
+
+ for (Common::List<Sprite>::iterator j = _sprites.begin(); j != _sprites.end(); j++) {
+ j->_surface.free();
+ }
+ _sprites.clear();
+ i->_buttons.clear();
+
+ _lastButton = NULL;
+
+ _mixer->stopAll();
+ _audioStream = NULL;
+
+ for (uint j = 0; j < _queuedScripts.size(); j++) {
+ _queuedScripts[j]._count = 0;
+ _queuedScripts[j]._scriptId = 0;
+ }
+
+ delete i->_archive;
+ _libraries.erase(i);
+
+ runEvent(kEventUnload, id, 0, 0);
+
+ return;
+ }
+
+ error("tried to unload library %d, which isn't loaded", id);
+}
+
+bool ComposerEngine::hasResource(uint32 tag, uint16 id) {
+ for (Common::List<Library>::iterator i = _libraries.begin(); i != _libraries.end(); i++)
+ if (i->_archive->hasResource(tag, id))
+ return true;
+
+ return false;
+}
+
+Common::SeekableReadStream *ComposerEngine::getResource(uint32 tag, uint16 id) {
+ for (Common::List<Library>::iterator i = _libraries.begin(); i != _libraries.end(); i++)
+ if (i->_archive->hasResource(tag, id))
+ return i->_archive->getResource(tag, id);
+
+ error("No loaded library contains '%s' %04x", tag2str(tag), id);
+}
+
+Button::Button(Common::SeekableReadStream *stream, uint16 id) {
+ _id = id;
+
+ _type = stream->readUint16LE();
+ _active = (_type & 0x8000) ? true : false;
+ _type &= 0xfff;
+ debug(9, "button: type %d, active %d", _type, _active);
+
+ _zorder = stream->readUint16LE();
+ _scriptId = stream->readUint16LE();
+ _scriptIdRollOn = stream->readUint16LE();
+ _scriptIdRollOff = stream->readUint16LE();
+
+ stream->skip(4);
+
+ uint16 size = stream->readUint16LE();
+
+ switch (_type) {
+ case kButtonRect:
+ case kButtonEllipse:
+ if (size != 4)
+ error("button %d of type %d had %d points, not 4", id, _type, size);
+ _rect.left = stream->readSint16LE();
+ _rect.top = stream->readSint16LE();
+ _rect.right = stream->readSint16LE();
+ _rect.bottom = stream->readSint16LE();
+ debug(9, "button: (%d, %d, %d, %d)", _rect.left, _rect.top, _rect.right, _rect.bottom);
+ break;
+ case kButtonSprites:
+ for (uint i = 0; i < size; i++) {
+ _spriteIds.push_back(stream->readSint16LE());
+ }
+ break;
+ default:
+ error("unknown button type %d", _type);
+ }
+
+ delete stream;
+}
+
+bool Button::contains(const Common::Point &pos) const {
+ switch (_type) {
+ case kButtonRect:
+ return _rect.contains(pos);
+ case kButtonEllipse:
+ if (!_rect.contains(pos))
+ return false;
+ {
+ int16 a = _rect.width() / 2;
+ int16 b = _rect.height() / 2;
+ if (!a || !b)
+ return false;
+ Common::Point adjustedPos = pos - Common::Point(_rect.left + a, _rect.top + b);
+ return ((adjustedPos.x*adjustedPos.x)/(a*a) + (adjustedPos.y*adjustedPos.y)/(b*b) < 1);
+ }
+ case kButtonSprites:
+ return false;
+ default:
+ error("internal error (button type %d)", _type);
+ }
+}
+
+const Button *ComposerEngine::getButtonFor(const Sprite *sprite, const Common::Point &pos) {
+ for (Common::List<Library>::iterator l = _libraries.begin(); l != _libraries.end(); l++) {
+ for (Common::List<Button>::iterator i = l->_buttons.reverse_begin(); i != l->_buttons.end(); --i) {
+ if (!i->_active)
+ continue;
+
+ if (i->_spriteIds.empty()) {
+ if (i->contains(pos))
+ return &(*i);
+ continue;
+ }
+
+ if (!sprite)
+ continue;
+
+ for (uint j = 0; j < i->_spriteIds.size(); j++) {
+ if (i->_spriteIds[j] == sprite->_id)
+ return &(*i);
+ }
+ }
+ }
+
+ return NULL;
+}
+
+} // End of namespace Composer
diff --git a/engines/composer/composer.h b/engines/composer/composer.h
new file mode 100644
index 0000000000..99ed56ead7
--- /dev/null
+++ b/engines/composer/composer.h
@@ -0,0 +1,212 @@
+/* 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 COMPOSER_H
+#define COMPOSER_H
+
+#include "common/config-file.h"
+#include "common/random.h"
+#include "common/system.h"
+#include "common/debug.h"
+#include "common/debug-channels.h"
+#include "common/textconsole.h"
+#include "common/rect.h"
+
+#include "engines/engine.h"
+#include "engines/util.h"
+
+#include "graphics/surface.h"
+
+#include "audio/mixer.h"
+
+#include "composer/resource.h"
+
+namespace Audio {
+ class QueuingAudioStream;
+}
+
+namespace Composer {
+
+struct ComposerGameDescription;
+
+enum GameType {
+ GType_ComposerV1,
+ GType_ComposerV2
+};
+
+class Archive;
+struct Animation;
+class ComposerEngine;
+class Pipe;
+struct Sprite;
+
+enum {
+ kButtonRect = 0,
+ kButtonEllipse = 1,
+ kButtonSprites = 4
+};
+
+class Button {
+public:
+ Button() { }
+ Button(Common::SeekableReadStream *stream, uint16 id);
+
+ bool contains(const Common::Point &pos) const;
+
+ uint16 _id;
+ uint16 _type;
+ uint16 _zorder;
+ uint16 _scriptId;
+ uint16 _scriptIdRollOn;
+ uint16 _scriptIdRollOff;
+ bool _active;
+
+ Common::Rect _rect;
+ Common::Array<uint16> _spriteIds;
+};
+
+enum {
+ kEventAnimStarted = 1,
+ kEventAnimDone = 2,
+ kEventLoad = 3,
+ kEventUnload = 4,
+ kEventKeyDown = 5,
+ kEventChar = 6,
+ kEventKeyUp = 7
+};
+
+struct Library {
+ uint _id;
+ Archive *_archive;
+
+ Common::List<Button> _buttons;
+};
+
+struct QueuedScript {
+ uint32 _baseTime;
+ uint32 _duration;
+ uint32 _count;
+ uint16 _scriptId;
+};
+
+struct PendingPageChange {
+ PendingPageChange() { }
+ PendingPageChange(uint16 id, bool remove) : _pageId(id), _remove(remove) { }
+
+ uint16 _pageId;
+ bool _remove;
+};
+
+class ComposerEngine : public Engine {
+protected:
+ Common::Error run();
+
+public:
+ ComposerEngine(OSystem *syst, const ComposerGameDescription *gameDesc);
+ virtual ~ComposerEngine();
+
+ virtual bool hasFeature(EngineFeature f) const;
+
+ int getGameType() const;
+ const char *getGameId() const;
+ uint32 getFeatures() const;
+ Common::Language getLanguage() const;
+
+ const ComposerGameDescription *_gameDescription;
+
+private:
+ Common::RandomSource *_rnd;
+
+ Audio::SoundHandle _soundHandle;
+ Audio::QueuingAudioStream *_audioStream;
+ uint16 _currSoundPriority;
+
+ bool _needsUpdate;
+ Common::Array<Common::Rect> _dirtyRects;
+ Graphics::Surface _surface;
+ Common::List<Sprite> _sprites;
+
+ uint _directoriesToStrip;
+ Common::ConfigFile _bookIni;
+ Common::List<Library> _libraries;
+ Common::Array<PendingPageChange> _pendingPageChanges;
+
+ Common::Array<uint16> _stack;
+ Common::Array<uint16> _vars;
+
+ Common::Array<QueuedScript> _queuedScripts;
+ Common::List<Animation *> _anims;
+ Common::List<Pipe *> _pipes;
+
+ void onMouseDown(const Common::Point &pos);
+ void onMouseMove(const Common::Point &pos);
+ void onKeyDown(uint16 keyCode);
+ void setCursor(uint16 id, const Common::Point &offset);
+ void setCursorVisible(bool visible);
+
+ bool _mouseEnabled;
+ bool _mouseVisible;
+ Common::Point _lastMousePos;
+ const Button *_lastButton;
+ uint16 _mouseSpriteId;
+ Common::Point _mouseOffset;
+
+ Common::String getStringFromConfig(const Common::String &section, const Common::String &key);
+ Common::String getFilename(const Common::String &section, uint id);
+ void loadLibrary(uint id);
+ void unloadLibrary(uint id);
+
+ bool hasResource(uint32 tag, uint16 id);
+ Common::SeekableReadStream *getResource(uint32 tag, uint16 id);
+
+ void runEvent(uint16 id, int16 param1, int16 param2, int16 param3);
+ int16 runScript(uint16 id, int16 param1, int16 param2, int16 param3);
+
+ int16 getArg(uint16 arg, uint16 type);
+ void setArg(uint16 arg, uint16 type, uint16 val);
+ void runScript(uint16 id);
+ int16 scriptFuncCall(uint16 id, int16 param1, int16 param2, int16 param3);
+
+ void playAnimation(uint16 animId, int16 param1, int16 param2, int16 param3);
+ void stopAnimation(Animation *anim, bool localOnly = false, bool pipesOnly = false);
+ void playWaveForAnim(uint16 id, uint16 priority, bool bufferingOnly);
+ void processAnimFrame();
+
+ bool spriteVisible(uint16 id, uint16 animId);
+ Sprite *addSprite(uint16 id, uint16 animId, uint16 zorder, const Common::Point &pos);
+ void removeSprite(uint16 id, uint16 animId);
+ const Sprite *getSpriteAtPos(const Common::Point &pos);
+ const Button *getButtonFor(const Sprite *sprite, const Common::Point &pos);
+
+ void dirtySprite(const Sprite &sprite);
+ void redraw();
+ void loadCTBL(uint16 id, uint fadePercent);
+ void setBackground(uint16 id);
+ void decompressBitmap(uint16 type, Common::SeekableReadStream *stream, byte *buffer, uint32 size, uint width, uint height);
+ bool initSprite(Sprite &sprite);
+ Common::SeekableReadStream *getStreamForSprite(uint16 id);
+ void drawSprite(const Sprite &sprite);
+};
+
+} // End of namespace Composer
+
+#endif
diff --git a/engines/composer/detection.cpp b/engines/composer/detection.cpp
new file mode 100644
index 0000000000..cbd4dd1ebd
--- /dev/null
+++ b/engines/composer/detection.cpp
@@ -0,0 +1,179 @@
+/* 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 "base/plugins.h"
+#include "engines/advancedDetector.h"
+
+#include "composer/composer.h"
+
+namespace Composer {
+
+struct ComposerGameDescription {
+ ADGameDescription desc;
+
+ int gameType;
+};
+
+int ComposerEngine::getGameType() const {
+ return _gameDescription->gameType;
+}
+
+const char *ComposerEngine::getGameId() const {
+ return _gameDescription->desc.gameid;
+}
+
+uint32 ComposerEngine::getFeatures() const {
+ return _gameDescription->desc.flags;
+}
+
+Common::Language ComposerEngine::getLanguage() const {
+ return _gameDescription->desc.language;
+}
+
+}
+
+static const PlainGameDescriptor composerGames[] = {
+ {"composer", "Composer Game"},
+ {"darby", "Darby the Dragon"},
+ {"gregory", "Gregory and the Hot Air Balloon"},
+ {"liam", "Magic Tales: Liam Finds a Story"},
+ {0, 0}
+};
+
+namespace Composer {
+
+using Common::GUIO_NONE;
+
+static const ComposerGameDescription gameDescriptions[] = {
+ // from Liam Finds a Story CD
+ {
+ {
+ "magictales",
+ "Magic Tales Demo: Baby Yaga, Samurai, Imo",
+ AD_ENTRY1("book.ini", "dbc98c566f4ac61b544443524585dccb"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_USEEXTRAASTITLE,
+ Common::GUIO_NONE
+ },
+ GType_ComposerV1
+ },
+
+ {
+ {
+ "liam",
+ 0,
+ AD_ENTRY1("install.inf", "320d2f1d4f8dd96947676ae25d6688c6"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_ComposerV2
+ },
+
+ // from Liam Finds a Story CD
+ {
+ {
+ "magictales",
+ "Magic Tales Demo: Sleeping Cub, Princess & Crab",
+ AD_ENTRY1("book.ini", "3dede2522bb0886c95667b082987a87f"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_USEEXTRAASTITLE,
+ Common::GUIO_NONE
+ },
+ GType_ComposerV2
+ },
+
+ {
+ {
+ "darby",
+ 0,
+ AD_ENTRY1("install.inf", "e83cc20ee18a2e138da1aadfc640dff2"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_ComposerV2
+ },
+
+ {
+ {
+ "gregory",
+ 0,
+ AD_ENTRY1("install.inf", "b7e9d6f7949d412dad0a183375069844"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_ComposerV2
+ },
+
+ { AD_TABLE_END_MARKER, 0 }
+};
+
+} // End of namespace Composer
+
+using namespace Composer;
+
+class ComposerMetaEngine : public AdvancedMetaEngine {
+public:
+ ComposerMetaEngine() : AdvancedMetaEngine(Composer::gameDescriptions, sizeof(Composer::ComposerGameDescription), composerGames) {
+ _singleid = "composer";
+ }
+
+ virtual const char *getName() const {
+ return "Magic Composer Engine";
+ }
+
+ virtual const char *getOriginalCopyright() const {
+ return "Copyright (C) 1995-1999 Animation Magic";
+ }
+
+ virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+ virtual bool hasFeature(MetaEngineFeature f) const;
+};
+
+bool ComposerMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+ const Composer::ComposerGameDescription *gd = (const Composer::ComposerGameDescription *)desc;
+ if (gd) {
+ *engine = new Composer::ComposerEngine(syst, gd);
+ }
+ return gd != 0;
+}
+
+bool ComposerMetaEngine::hasFeature(MetaEngineFeature f) const {
+ return false;
+}
+
+bool Composer::ComposerEngine::hasFeature(EngineFeature f) const {
+ return (f == kSupportsRTL);
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(COMPOSER)
+REGISTER_PLUGIN_DYNAMIC(COMPOSER, PLUGIN_TYPE_ENGINE, ComposerMetaEngine);
+#else
+REGISTER_PLUGIN_STATIC(COMPOSER, PLUGIN_TYPE_ENGINE, ComposerMetaEngine);
+#endif
diff --git a/engines/composer/graphics.cpp b/engines/composer/graphics.cpp
new file mode 100644
index 0000000000..3de244970e
--- /dev/null
+++ b/engines/composer/graphics.cpp
@@ -0,0 +1,758 @@
+/* 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 "common/scummsys.h"
+
+#include "graphics/palette.h"
+
+#include "audio/audiostream.h"
+#include "audio/decoders/raw.h"
+
+#include "composer/composer.h"
+#include "composer/graphics.h"
+#include "composer/resource.h"
+
+namespace Composer {
+
+bool Sprite::contains(const Common::Point &pos) const {
+ Common::Point adjustedPos = pos - _pos;
+
+ if (adjustedPos.x < 0 || adjustedPos.x >= _surface.w)
+ return false;
+ if (adjustedPos.y < 0 || adjustedPos.y >= _surface.h)
+ return false;
+ byte *pixels = (byte *)_surface.pixels;
+ return (pixels[(_surface.h - adjustedPos.y - 1) * _surface.w + adjustedPos.x] != 0);
+}
+
+enum {
+ kAnimOpEvent = 1,
+ kAnimOpPlayWave = 2,
+ kAnimOpPlayAnim = 3,
+ kAnimOpDrawSprite = 4
+};
+
+Animation::Animation(Common::SeekableReadStream *stream, uint16 id, Common::Point basePos, uint32 eventParam)
+ : _stream(stream), _id(id), _basePos(basePos), _eventParam(eventParam) {
+ uint32 size = _stream->readUint32LE();
+ _state = _stream->readUint32LE() + 1;
+
+ // probably total size?
+ uint32 unknown = _stream->readUint32LE();
+
+ debug(8, "anim: size %d, state %08x, unknown %08x", size, _state, unknown);
+
+ for (uint i = 0; i < size; i++) {
+ AnimationEntry entry;
+ entry.op = _stream->readUint16LE();
+ entry.priority = _stream->readUint16LE();
+ entry.state = _stream->readUint16LE();
+ entry.counter = 0;
+ entry.prevValue = 0;
+ debug(8, "anim entry: %04x, %04x, %04x", entry.op, entry.priority, entry.state);
+ _entries.push_back(entry);
+ }
+
+ _offset = _stream->pos();
+}
+
+Animation::~Animation() {
+ delete _stream;
+}
+
+void Animation::seekToCurrPos() {
+ _stream->seek(_offset, SEEK_SET);
+}
+
+void ComposerEngine::playAnimation(uint16 animId, int16 x, int16 y, int16 eventParam) {
+ // First, we check if this animation is already playing,
+ // and if it is, we sabotage that running one first.
+ for (Common::List<Animation *>::iterator i = _anims.begin(); i != _anims.end(); i++) {
+ Animation *anim = *i;
+ if (anim->_id != animId)
+ continue;
+
+ stopAnimation(*i);
+ }
+
+ Common::SeekableReadStream *stream = NULL;
+ Pipe *newPipe = NULL;
+
+ // First, check the existing pipes.
+ for (Common::List<Pipe *>::iterator j = _pipes.begin(); j != _pipes.end(); j++) {
+ Pipe *pipe = *j;
+ if (!pipe->hasResource(ID_ANIM, animId))
+ continue;
+ stream = pipe->getResource(ID_ANIM, animId, false);
+ break;
+ }
+
+ // If we didn't find it, try the libraries.
+ if (!stream) {
+ if (!hasResource(ID_ANIM, animId)) {
+ warning("ignoring attempt to play invalid anim %d", animId);
+ return;
+ }
+ stream = getResource(ID_ANIM, animId);
+
+ uint32 type = 0;
+ for (Common::List<Library>::iterator i = _libraries.begin(); i != _libraries.end(); i++)
+ if (i->_archive->hasResource(ID_ANIM, animId)) {
+ type = i->_archive->getResourceFlags(ID_ANIM, animId);
+ break;
+ }
+
+ // If the resource is a pipe itself, then load the pipe
+ // and then fish the requested animation out of it.
+ if (type != 1) {
+ newPipe = new Pipe(stream);
+ _pipes.push_front(newPipe);
+ stream = newPipe->getResource(ID_ANIM, animId, false);
+ }
+ }
+
+ Animation *anim = new Animation(stream, animId, Common::Point(x, y), eventParam);
+ _anims.push_back(anim);
+ runEvent(kEventAnimStarted, animId, eventParam, 0);
+ if (newPipe)
+ newPipe->_anim = anim;
+}
+
+void ComposerEngine::stopAnimation(Animation *anim, bool localOnly, bool pipesOnly) {
+ // disable the animation
+ anim->_state = 0;
+
+ // stop any animations it may have spawned
+ for (uint j = 0; j < anim->_entries.size(); j++) {
+ AnimationEntry &entry = anim->_entries[j];
+ if (!entry.prevValue)
+ continue;
+ if (localOnly) {
+ if (pipesOnly)
+ continue;
+ if (entry.op == kAnimOpDrawSprite) {
+ removeSprite(entry.prevValue, anim->_id);
+ } else if (entry.op == kAnimOpPlayWave) {
+ if (_currSoundPriority >= entry.priority) {
+ _mixer->stopAll();
+ _audioStream = NULL;
+ }
+ }
+ } else {
+ if (entry.op != kAnimOpPlayAnim)
+ continue;
+ for (Common::List<Animation *>::iterator i = _anims.begin(); i != _anims.end(); i++) {
+ if ((*i)->_id == entry.prevValue)
+ stopAnimation(*i);
+ }
+ }
+ }
+
+ // kill any pipe owned by the animation
+ for (Common::List<Pipe *>::iterator j = _pipes.begin(); j != _pipes.end(); j++) {
+ Pipe *pipe = *j;
+ if (pipe->_anim != anim)
+ continue;
+ j = _pipes.reverse_erase(j);
+ delete pipe;
+ break;
+ }
+}
+
+void ComposerEngine::playWaveForAnim(uint16 id, uint16 priority, bool bufferingOnly) {
+ if (_audioStream && _audioStream->numQueuedStreams() != 0) {
+ if (_currSoundPriority < priority)
+ return;
+ if (_currSoundPriority > priority) {
+ _mixer->stopAll();
+ _audioStream = NULL;
+ }
+ }
+ Common::SeekableReadStream *stream = NULL;
+ if (!bufferingOnly && hasResource(ID_WAVE, id)) {
+ stream = getResource(ID_WAVE, id);
+ } else {
+ for (Common::List<Pipe *>::iterator k = _pipes.begin(); k != _pipes.end(); k++) {
+ Pipe *pipe = *k;
+ if (!pipe->hasResource(ID_WAVE, id))
+ continue;
+ stream = pipe->getResource(ID_WAVE, id, true);
+ break;
+ }
+ }
+ if (!stream)
+ return;
+ // FIXME: non-pipe buffers have fixed wav header (data at +44, size at +40)
+ byte *buffer = (byte *)malloc(stream->size());
+ stream->read(buffer, stream->size());
+ if (!_audioStream)
+ _audioStream = Audio::makeQueuingAudioStream(22050, false);
+ _audioStream->queueBuffer(buffer, stream->size(), DisposeAfterUse::YES, Audio::FLAG_UNSIGNED);
+ _currSoundPriority = priority;
+ delete stream;
+ if (!_mixer->isSoundHandleActive(_soundHandle))
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, _audioStream);
+}
+
+void ComposerEngine::processAnimFrame() {
+ for (Common::List<Animation *>::iterator i = _anims.begin(); i != _anims.end(); i++) {
+ Animation *anim = *i;
+
+ anim->seekToCurrPos();
+
+ if (anim->_state <= 1) {
+ bool normalEnd = (anim->_state == 1);
+ if (normalEnd) {
+ runEvent(kEventAnimDone, anim->_id, anim->_eventParam, 0);
+ }
+ stopAnimation(anim, true, normalEnd);
+ delete anim;
+ i = _anims.reverse_erase(i);
+
+ continue;
+ }
+
+ for (uint j = 0; j < anim->_entries.size(); j++) {
+ AnimationEntry &entry = anim->_entries[j];
+ if (entry.op != kAnimOpEvent)
+ break;
+ if (entry.counter) {
+ entry.counter--;
+ } else {
+ if ((anim->_state > 1) && (anim->_stream->pos() + 2 > anim->_stream->size())) {
+ warning("anim with id %d ended too soon", anim->_id);
+ anim->_state = 0;
+ break;
+ }
+
+ uint16 event = anim->_stream->readUint16LE();
+ anim->_offset += 2;
+ if (event == 0xffff) {
+ entry.counter = anim->_stream->readUint16LE() - 1;
+ anim->_offset += 2;
+ } else {
+ debug(4, "anim: event %d", event);
+ runEvent(event, anim->_id, 0, 0);
+ }
+ }
+ }
+ }
+
+ for (Common::List<Animation *>::iterator i = _anims.begin(); i != _anims.end(); i++) {
+ Animation *anim = *i;
+
+ // did the anim get disabled?
+ if (anim->_state == 0) {
+ stopAnimation(anim, true, false);
+ delete anim;
+ i = _anims.reverse_erase(i);
+ continue;
+ }
+
+ anim->_state--;
+
+ bool foundWait = false;
+ for (uint j = 0; j < anim->_entries.size(); j++) {
+ AnimationEntry &entry = anim->_entries[j];
+
+ // only skip these at the start
+ if (!foundWait && (entry.op == kAnimOpEvent))
+ continue;
+ foundWait = true;
+
+ if (entry.counter) {
+ entry.counter--;
+ if ((entry.op == kAnimOpPlayWave) && entry.prevValue) {
+ debug(4, "anim: continue play wave %d", entry.prevValue);
+ playWaveForAnim(entry.prevValue, entry.priority, true);
+ }
+ } else {
+ anim->seekToCurrPos();
+ if ((anim->_state > 1) && (anim->_stream->pos() + 2 > anim->_stream->size())) {
+ warning("anim with id %d ended too soon", anim->_id);
+ anim->_state = 0;
+ break;
+ }
+
+ uint16 data = anim->_stream->readUint16LE();
+ anim->_offset += 2;
+ if (data == 0xffff) {
+ entry.counter = anim->_stream->readUint16LE() - 1;
+ anim->_offset += 2;
+ } else {
+ switch (entry.op) {
+ case kAnimOpEvent:
+ debug(4, "anim: event %d", data);
+ runEvent(data, anim->_id, 0, 0);
+ break;
+ case kAnimOpPlayWave:
+ debug(4, "anim: play wave %d", data);
+ playWaveForAnim(data, entry.priority, false);
+ break;
+ case kAnimOpPlayAnim:
+ debug(4, "anim: play anim %d", data);
+ playAnimation(data, anim->_basePos.x, anim->_basePos.y, 1);
+ break;
+ case kAnimOpDrawSprite:
+ if (!data || (entry.prevValue && (data != entry.prevValue))) {
+ debug(4, "anim: erase sprite %d", entry.prevValue);
+ removeSprite(entry.prevValue, anim->_id);
+ }
+ if (data) {
+ int16 x = anim->_stream->readSint16LE();
+ int16 y = anim->_stream->readSint16LE();
+ Common::Point pos(x, y);
+ anim->_offset += 4;
+ uint16 animId = anim->_id;
+ if (anim->_state == entry.state)
+ animId = 0;
+ debug(4, "anim: draw sprite %d at (relative) %d,%d", data, x, y);
+ bool wasVisible = spriteVisible(data, animId);
+ addSprite(data, animId, entry.priority, anim->_basePos + pos);
+ if (wasVisible) {
+ // make sure modified sprite isn't removed by another entry
+ for (uint k = 0; k < anim->_entries.size(); k++) {
+ if (anim->_entries[k].op != kAnimOpDrawSprite)
+ continue;
+ if (anim->_entries[k].prevValue == data)
+ anim->_entries[k].prevValue = 1;
+ }
+ }
+ }
+ break;
+ default:
+ warning("unknown anim op %d", entry.op);
+ }
+
+ entry.prevValue = data;
+ }
+ }
+ }
+ }
+
+ for (Common::List<Pipe *>::iterator j = _pipes.begin(); j != _pipes.end(); j++) {
+ Pipe *pipe = *j;
+ pipe->nextFrame();
+ }
+}
+
+bool ComposerEngine::spriteVisible(uint16 id, uint16 animId) {
+ for (Common::List<Sprite>::iterator i = _sprites.begin(); i != _sprites.end(); i++) {
+ if (i->_id != id)
+ continue;
+ if (i->_animId && animId && (i->_animId != animId))
+ continue;
+ return true;
+ }
+
+ return false;
+}
+
+Sprite *ComposerEngine::addSprite(uint16 id, uint16 animId, uint16 zorder, const Common::Point &pos) {
+ Sprite sprite;
+ bool foundSprite = false;
+
+ // re-use old sprite, if any (the BMAP for this id might well have
+ // changed in the meantime, but the scripts depend on that!)
+ for (Common::List<Sprite>::iterator i = _sprites.begin(); i != _sprites.end(); i++) {
+ if (i->_id != id)
+ continue;
+ if (i->_animId && animId && (i->_animId != animId))
+ continue;
+
+ dirtySprite(*i);
+
+ // if the zordering is identical, modify it in-place
+ if (i->_zorder == zorder) {
+ i->_animId = animId;
+ i->_pos = pos;
+ dirtySprite(*i);
+ return &(*i);
+ }
+
+ // otherwise, take a copy and remove it from the list
+ sprite = *i;
+ foundSprite = true;
+ _sprites.erase(i);
+ break;
+ }
+
+ sprite._animId = animId;
+ sprite._zorder = zorder;
+ sprite._pos = pos;
+
+ if (!foundSprite) {
+ sprite._id = id;
+ if (!initSprite(sprite)) {
+ debug(1, "ignoring addSprite on invalid sprite %d", id);
+ return NULL;
+ }
+ }
+
+ dirtySprite(sprite);
+
+ for (Common::List<Sprite>::iterator i = _sprites.begin(); i != _sprites.end(); i++) {
+ if (sprite._zorder <= i->_zorder)
+ continue;
+ // insert *before* this sprite
+ _sprites.insert(i, sprite);
+ --i;
+ return &(*i);
+ }
+ _sprites.push_back(sprite);
+ return &_sprites.back();
+}
+
+void ComposerEngine::removeSprite(uint16 id, uint16 animId) {
+ for (Common::List<Sprite>::iterator i = _sprites.begin(); i != _sprites.end(); i++) {
+ if (!i->_id || (id && i->_id != id))
+ continue;
+ if (i->_animId && animId && (i->_animId != animId))
+ continue;
+ dirtySprite(*i);
+ i->_surface.free();
+ i = _sprites.reverse_erase(i);
+ if (id)
+ break;
+ }
+}
+
+const Sprite *ComposerEngine::getSpriteAtPos(const Common::Point &pos) {
+ for (Common::List<Sprite>::iterator i = _sprites.reverse_begin(); i != _sprites.end(); --i) {
+ // avoid highest-level objects (e.g. the cursor)
+ if (!i->_zorder)
+ continue;
+
+ if (i->contains(pos))
+ return &(*i);
+ }
+
+ return NULL;
+}
+
+void ComposerEngine::dirtySprite(const Sprite &sprite) {
+ Common::Rect rect(sprite._pos.x, sprite._pos.y, sprite._pos.x + sprite._surface.w, sprite._pos.y + sprite._surface.h);
+ rect.clip(_surface.w, _surface.h);
+ if (rect.isEmpty())
+ return;
+
+ for (uint i = 0; i < _dirtyRects.size(); i++) {
+ if (!_dirtyRects[i].intersects(rect))
+ continue;
+ _dirtyRects[i].extend(rect);
+ return;
+ }
+
+ _dirtyRects.push_back(rect);
+}
+
+void ComposerEngine::redraw() {
+ if (!_needsUpdate && _dirtyRects.empty())
+ return;
+
+ for (Common::List<Sprite>::iterator i = _sprites.begin(); i != _sprites.end(); i++) {
+ Common::Rect rect(i->_pos.x, i->_pos.y, i->_pos.x + i->_surface.w, i->_pos.y + i->_surface.h);
+ bool intersects = false;
+ for (uint j = 0; j < _dirtyRects.size(); j++) {
+ if (!_dirtyRects[j].intersects(rect))
+ continue;
+ intersects = true;
+ break;
+ }
+ if (!intersects)
+ continue;
+ drawSprite(*i);
+ }
+
+ for (uint i = 0; i < _dirtyRects.size(); i++) {
+ const Common::Rect &rect = _dirtyRects[i];
+ byte *pixels = (byte *)_surface.pixels + (rect.top * _surface.pitch) + rect.left;
+ _system->copyRectToScreen(pixels, _surface.pitch, rect.left, rect.top, rect.width(), rect.height());
+ }
+ _system->updateScreen();
+
+ _needsUpdate = false;
+ _dirtyRects.clear();
+}
+
+void ComposerEngine::loadCTBL(uint16 id, uint fadePercent) {
+ Common::SeekableReadStream *stream = getResource(ID_CTBL, id);
+
+ uint16 numEntries = stream->readUint16LE();
+ debug(1, "CTBL: %d entries", numEntries);
+
+ assert(numEntries <= 256);
+ assert(stream->size() == 2 + (numEntries * 3));
+
+ byte buffer[256 * 3];
+ stream->read(buffer, numEntries * 3);
+ delete stream;
+
+ for (uint i = 0; i < numEntries * 3; i++)
+ buffer[i] = ((unsigned int)buffer[i] * fadePercent) / 100;
+
+ _system->getPaletteManager()->setPalette(buffer, 0, numEntries);
+ _needsUpdate = true;
+}
+
+void ComposerEngine::setBackground(uint16 id) {
+ for (Common::List<Sprite>::iterator i = _sprites.begin(); i != _sprites.end(); i++) {
+ if (i->_id)
+ continue;
+ dirtySprite(*i);
+ i->_surface.free();
+ i->_id = id;
+ if (!initSprite(*i))
+ error("failed to set background %d", id);
+ dirtySprite(*i);
+ i->_id = 0;
+ return;
+ }
+
+ Sprite *background = addSprite(id, 0, 0xffff, Common::Point());
+ if (background)
+ background->_id = 0;
+}
+
+static void decompressSLWM(byte *buffer, Common::SeekableReadStream *stream) {
+ uint bitsLeft = 0;
+ uint16 lastBits;
+ byte currBit;
+ while (true) {
+ if (bitsLeft == 0) { bitsLeft = 16; lastBits = stream->readUint16LE(); }
+ currBit = (lastBits & 1); lastBits >>= 1; bitsLeft--;
+
+ if (currBit) {
+ // single byte
+ *buffer++ = stream->readByte();
+ continue;
+ }
+
+ if (bitsLeft == 0) { bitsLeft = 16; lastBits = stream->readUint16LE(); }
+ currBit = (lastBits & 1); lastBits >>= 1; bitsLeft--;
+
+ uint start;
+ uint count;
+ if (currBit) {
+ uint orMask = stream->readByte();
+ uint in = stream->readByte();
+ count = in & 7;
+ start = ((in & ~7) << 5) | orMask;
+ if (!count) {
+ count = stream->readByte();
+ if (!count)
+ break;
+ count -= 2;
+ }
+ } else {
+ // count encoded in the next two bits
+ count = 0;
+
+ if (bitsLeft == 0) { bitsLeft = 16; lastBits = stream->readUint16LE(); }
+ currBit = (lastBits & 1); lastBits >>= 1; bitsLeft--;
+
+ count = (count << 1) | currBit;
+
+ if (bitsLeft == 0) { bitsLeft = 16; lastBits = stream->readUint16LE(); }
+ currBit = (lastBits & 1); lastBits >>= 1; bitsLeft--;
+
+ count = (count << 1) | currBit;
+
+ start = stream->readByte();
+ }
+
+ count += 2;
+ start++;
+ for (uint i = 0; i < count; i++) {
+ *buffer = *(buffer - start);
+ buffer++;
+ }
+ }
+}
+
+// bitmap compression types
+enum {
+ kBitmapUncompressed = 0,
+ kBitmapSpp32 = 1,
+ kBitmapSLW8 = 3,
+ kBitmapRLESLWM = 4,
+ kBitmapSLWM = 5
+};
+
+void ComposerEngine::decompressBitmap(uint16 type, Common::SeekableReadStream *stream, byte *buffer, uint32 size, uint width, uint height) {
+ switch (type) {
+ case kBitmapUncompressed:
+ assert(stream->size() - (uint)stream->pos() == size);
+ assert(size == width * height);
+ stream->read(buffer, size);
+ break;
+ case kBitmapSpp32:
+ byte lookup[16];
+ stream->read(lookup, 16);
+ while (size--) {
+ uint in = stream->readByte();
+ byte lowBits = in & 0xF;
+ byte highBits = (in & 0xF0) >> 4;
+ if (highBits == 0xf) {
+ // run of a single color
+ uint count = (uint)stream->readByte() + 3;
+ size--;
+ memset(buffer, lookup[lowBits], count);
+ buffer += count;
+ } else {
+ // two pixels
+ *buffer++ = lookup[highBits];
+ *buffer++ = lookup[lowBits];
+ }
+ }
+ break;
+ case kBitmapSLW8:
+ while (size--) {
+ byte val = stream->readByte();
+ if (val != 0xff) {
+ *buffer++ = val;
+ continue;
+ }
+ uint count = stream->readByte();
+ size--;
+
+ uint16 step;
+ if (!(count & 0x80)) {
+ step = stream->readByte();
+ size--;
+ } else {
+ count = (count ^ 0x80);
+ step = stream->readUint16LE();
+ size -= 2;
+ }
+ count += 4;
+ // this is often overlapping (for repeating patterns)
+ for (uint i = 0; i < count; i++) {
+ *buffer = *(buffer - step - 1);
+ buffer++;
+ }
+ }
+ break;
+ case kBitmapRLESLWM:
+ {
+ uint32 bufSize = stream->readUint32LE();
+ byte *tempBuf = new byte[bufSize];
+ decompressSLWM(tempBuf, stream);
+
+ uint instrPos = tempBuf[0] + 1;
+ instrPos += READ_LE_UINT16(tempBuf + instrPos) + 2;
+ byte *instr = tempBuf + instrPos;
+
+ uint line = 0;
+ while (line++ < height) {
+ uint pixels = 0;
+
+ while (pixels < width) {
+ byte data = *instr++;
+ byte color = tempBuf[(data & 0x7F) + 1];
+ if (!(data & 0x80)) {
+ *buffer++ = color;
+ pixels++;
+ } else {
+ byte count = *instr++;
+ if (!count) {
+ while (pixels++ < width)
+ *buffer++ = color;
+ break;
+ }
+ for (uint i = 0; i < count; i++) {
+ *buffer++ = color;
+ pixels++;
+ }
+ }
+ }
+ }
+ delete[] tempBuf;
+ }
+ break;
+ case kBitmapSLWM:
+ decompressSLWM(buffer, stream);
+ break;
+ default:
+ error("decompressBitmap can't handle type %d", type);
+ }
+}
+
+Common::SeekableReadStream *ComposerEngine::getStreamForSprite(uint16 id) {
+ for (Common::List<Pipe *>::iterator k = _pipes.begin(); k != _pipes.end(); k++) {
+ Pipe *pipe = *k;
+ if (!pipe->hasResource(ID_BMAP, id))
+ continue;
+ return pipe->getResource(ID_BMAP, id, true);
+ }
+ if (hasResource(ID_BMAP, id))
+ return getResource(ID_BMAP, id);
+ return NULL;
+}
+
+bool ComposerEngine::initSprite(Sprite &sprite) {
+ Common::SeekableReadStream *stream = getStreamForSprite(sprite._id);
+ if (!stream)
+ return false;
+
+ uint16 type = stream->readUint16LE();
+ int16 height = stream->readSint16LE();
+ int16 width = stream->readSint16LE();
+ uint32 size = stream->readUint32LE();
+ debug(1, "loading BMAP: type %d, width %d, height %d, size %d", type, width, height, size);
+
+ if (width > 0 && height > 0) {
+ sprite._surface.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+ decompressBitmap(type, stream, (byte *)sprite._surface.pixels, size, width, height);
+ } else {
+ // there are some sprites (e.g. a -998x-998 one in Gregory's title screen)
+ // which have an invalid size, but the original engine doesn't notice for
+ // RLE sprites since the width/height is ignored until the actual draw
+ if (type != kBitmapRLESLWM)
+ error("sprite (type %d) had invalid size %dx%d", type, width, height);
+ delete stream;
+ return false;
+ }
+ delete stream;
+
+ return true;
+}
+
+void ComposerEngine::drawSprite(const Sprite &sprite) {
+ int x = sprite._pos.x;
+ int y = sprite._pos.y;
+
+ // incoming data is BMP-style (bottom-up), so flip it
+ byte *pixels = (byte *)_surface.pixels;
+ for (int j = 0; j < sprite._surface.h; j++) {
+ if (j + y < 0)
+ continue;
+ if (j + y >= _surface.h)
+ break;
+ byte *in = (byte *)sprite._surface.pixels + (sprite._surface.h - j - 1) * sprite._surface.w;
+ byte *out = pixels + ((j + y) * _surface.w) + x;
+ for (int i = 0; i < sprite._surface.w; i++)
+ if ((x + i >= 0) && (x + i < _surface.w) && in[i])
+ out[i] = in[i];
+ }
+}
+
+} // End of namespace Composer
diff --git a/engines/composer/graphics.h b/engines/composer/graphics.h
new file mode 100644
index 0000000000..e9d82920ba
--- /dev/null
+++ b/engines/composer/graphics.h
@@ -0,0 +1,71 @@
+/* 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 COMPOSER_GRAPHICS_H
+#define COMPOSER_GRAPHICS_H
+
+#include "common/rect.h"
+#include "graphics/surface.h"
+
+namespace Composer {
+
+class ComposerEngine;
+
+struct Sprite {
+ uint16 _id;
+ uint16 _animId;
+ uint16 _zorder;
+ Common::Point _pos;
+ Graphics::Surface _surface;
+
+ bool contains(const Common::Point &pos) const;
+};
+
+struct AnimationEntry {
+ uint32 state;
+ uint16 op;
+ uint16 priority;
+ uint16 counter;
+ uint16 prevValue;
+};
+
+struct Animation {
+ Animation(Common::SeekableReadStream *stream, uint16 id, Common::Point basePos, uint32 eventParam);
+ ~Animation();
+
+ void seekToCurrPos();
+
+ uint16 _id;
+ Common::Point _basePos;
+ uint32 _eventParam;
+
+ uint32 _state;
+
+ Common::Array<AnimationEntry> _entries;
+
+ uint32 _offset;
+ Common::SeekableReadStream *_stream;
+};
+
+} // End of namespace Composer
+
+#endif
diff --git a/engines/composer/module.mk b/engines/composer/module.mk
new file mode 100644
index 0000000000..8bfaf932e8
--- /dev/null
+++ b/engines/composer/module.mk
@@ -0,0 +1,16 @@
+MODULE := engines/composer
+
+MODULE_OBJS = \
+ composer.o \
+ detection.o \
+ graphics.o \
+ resource.o \
+ scripting.o
+
+# This module can be built as a plugin
+ifeq ($(ENABLE_COMPOSER), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
diff --git a/engines/composer/resource.cpp b/engines/composer/resource.cpp
new file mode 100644
index 0000000000..e0893380bf
--- /dev/null
+++ b/engines/composer/resource.cpp
@@ -0,0 +1,336 @@
+/* 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 "composer/resource.h"
+
+#include "common/debug.h"
+#include "common/memstream.h"
+#include "common/substream.h"
+#include "common/util.h"
+#include "common/textconsole.h"
+
+namespace Composer {
+
+// Base Archive code
+// (copied from clone2727's mohawk code)
+
+Archive::Archive() {
+ _stream = 0;
+}
+
+Archive::~Archive() {
+ close();
+}
+
+bool Archive::openFile(const Common::String &fileName) {
+ Common::File *file = new Common::File();
+
+ if (!file->open(fileName)) {
+ delete file;
+ return false;
+ }
+
+ if (!openStream(file)) {
+ close();
+ return false;
+ }
+
+ return true;
+}
+
+void Archive::close() {
+ _types.clear();
+ delete _stream; _stream = 0;
+}
+
+bool Archive::hasResource(uint32 tag, uint16 id) const {
+ if (!_types.contains(tag))
+ return false;
+
+ return _types[tag].contains(id);
+}
+
+bool Archive::hasResource(uint32 tag, const Common::String &resName) const {
+ if (!_types.contains(tag) || resName.empty())
+ return false;
+
+ const ResourceMap &resMap = _types[tag];
+
+ for (ResourceMap::const_iterator it = resMap.begin(); it != resMap.end(); it++)
+ if (it->_value.name.matchString(resName))
+ return true;
+
+ return false;
+}
+
+Common::SeekableReadStream *Archive::getResource(uint32 tag, uint16 id) {
+ if (!_types.contains(tag))
+ error("Archive does not contain '%s' %04x", tag2str(tag), id);
+
+ const ResourceMap &resMap = _types[tag];
+
+ if (!resMap.contains(id))
+ error("Archive does not contain '%s' %04x", tag2str(tag), id);
+
+ const Resource &res = resMap[id];
+
+ return new Common::SeekableSubReadStream(_stream, res.offset, res.offset + res.size);
+}
+
+uint32 Archive::getResourceFlags(uint32 tag, uint16 id) const {
+ if (!_types.contains(tag))
+ error("Archive does not contain '%s' %04x", tag2str(tag), id);
+
+ const ResourceMap &resMap = _types[tag];
+
+ if (!resMap.contains(id))
+ error("Archive does not contain '%s' %04x", tag2str(tag), id);
+
+ const Resource &res = resMap[id];
+
+ return res.flags;
+}
+
+uint32 Archive::getOffset(uint32 tag, uint16 id) const {
+ if (!_types.contains(tag))
+ error("Archive does not contain '%s' %04x", tag2str(tag), id);
+
+ const ResourceMap &resMap = _types[tag];
+
+ if (!resMap.contains(id))
+ error("Archive does not contain '%s' %04x", tag2str(tag), id);
+
+ return resMap[id].offset;
+}
+
+uint16 Archive::findResourceID(uint32 tag, const Common::String &resName) const {
+ if (!_types.contains(tag) || resName.empty())
+ return 0xFFFF;
+
+ const ResourceMap &resMap = _types[tag];
+
+ for (ResourceMap::const_iterator it = resMap.begin(); it != resMap.end(); it++)
+ if (it->_value.name.matchString(resName))
+ return it->_key;
+
+ return 0xFFFF;
+}
+
+Common::String Archive::getName(uint32 tag, uint16 id) const {
+ if (!_types.contains(tag))
+ error("Archive does not contain '%s' %04x", tag2str(tag), id);
+
+ const ResourceMap &resMap = _types[tag];
+
+ if (!resMap.contains(id))
+ error("Archive does not contain '%s' %04x", tag2str(tag), id);
+
+ return resMap[id].name;
+}
+
+Common::Array<uint32> Archive::getResourceTypeList() const {
+ Common::Array<uint32> typeList;
+
+ for (TypeMap::const_iterator it = _types.begin(); it != _types.end(); it++)
+ typeList.push_back(it->_key);
+
+ return typeList;
+}
+
+Common::Array<uint16> Archive::getResourceIDList(uint32 type) const {
+ Common::Array<uint16> idList;
+
+ if (!_types.contains(type))
+ return idList;
+
+ const ResourceMap &resMap = _types[type];
+
+ for (ResourceMap::const_iterator it = resMap.begin(); it != resMap.end(); it++)
+ idList.push_back(it->_key);
+
+ return idList;
+}
+
+// Composer Archive code
+
+bool ComposerArchive::openStream(Common::SeekableReadStream *stream) {
+ // Make sure no other file is open...
+ close();
+
+ bool newStyle = false;
+ uint32 headerSize = stream->readUint32LE();
+ if (headerSize == SWAP_CONSTANT_32(ID_LBRC)) {
+ // new-style file
+ newStyle = true;
+ headerSize = stream->readUint32LE();
+ uint32 zeros = stream->readUint32LE();
+ if (zeros != 0)
+ error("invalid LBRC header (%d instead of zeros)", zeros);
+ }
+
+ uint16 numResourceTypes = stream->readUint16LE();
+ if (newStyle) {
+ uint16 unknown = stream->readUint16LE();
+ debug(4, "skipping unknown %04x", unknown);
+ }
+
+ debug(4, "Reading LBRC resource table with %d entries", numResourceTypes);
+ for (uint i = 0; i < numResourceTypes; i++) {
+ uint32 tag = stream->readUint32BE();
+ uint32 tableOffset = stream->readUint32LE();
+ debug(4, "Type '%s' at offset %d", tag2str(tag), tableOffset);
+ // starting from the start of the resource table, which differs
+ // according to whether we have the 10 extra bytes for newStyle
+ if (newStyle)
+ tableOffset += 16;
+ else
+ tableOffset += 6;
+
+ ResourceMap &resMap = _types[tag];
+
+ uint32 oldPos = stream->pos();
+ stream->seek(tableOffset);
+
+ while (true) {
+ if (stream->eos())
+ error("LBRC file ran out of stream");
+
+ uint32 offset, size, id, flags;
+ if (newStyle) {
+ offset = stream->readUint32LE();
+ if (!offset)
+ break;
+ size = stream->readUint32LE();
+ id = stream->readUint16LE();
+ flags = stream->readUint16LE(); // set to 1 for preload, otherwise no preload
+ /*uint32 junk = */ stream->readUint32LE();
+ } else {
+ id = stream->readUint16LE();
+ if (!id)
+ break;
+ offset = stream->readUint32LE();
+ offset += headerSize;
+ size = stream->readUint32LE();
+ flags = stream->readUint16LE(); // FIXME
+
+ }
+
+ Resource &res = resMap[id];
+ res.offset = offset;
+ res.size = size;
+ res.flags = flags;
+ debug(4, "Id %d, offset %d, size %d, flags %08x", id, offset, size, flags);
+ }
+
+ stream->seek(oldPos);
+ }
+
+ _stream = stream;
+ return true;
+}
+
+Pipe::Pipe(Common::SeekableReadStream *stream) {
+ _offset = 0;
+ _stream = stream;
+
+ nextFrame();
+}
+
+void Pipe::nextFrame() {
+ if (_offset == (uint)_stream->size())
+ return;
+
+ _stream->seek(_offset, SEEK_SET);
+
+ uint32 tagCount = _stream->readUint32LE();
+ _offset += 4;
+ for (uint i = 0; i < tagCount; i++) {
+ uint32 tag = _stream->readUint32BE();
+ uint32 count = _stream->readUint32LE();
+ _offset += 8;
+
+ ResourceMap &resMap = _types[tag];
+
+ _offset += (12 * count);
+ for (uint j = 0; j < count; j++) {
+ uint32 offset = _stream->readUint32LE();
+ uint32 size = _stream->readUint32LE();
+ uint16 id = _stream->readUint16LE();
+ uint32 unknown = _stream->readUint16LE(); // frame id?
+ debug(9, "pipe: %s/%d: offset %d, size %d, unknown %d", tag2str(tag), id, offset, size, unknown);
+
+ PipeResourceEntry entry;
+ entry.size = size;
+ entry.offset = _offset;
+ resMap[id].entries.push_back(entry);
+
+ _offset += size;
+ }
+ _stream->seek(_offset, SEEK_SET);
+ }
+}
+
+bool Pipe::hasResource(uint32 tag, uint16 id) const {
+ if (!_types.contains(tag))
+ return false;
+
+ return _types[tag].contains(id);
+}
+
+Common::SeekableReadStream *Pipe::getResource(uint32 tag, uint16 id, bool buffering) {
+ if (!_types.contains(tag))
+ error("Pipe does not contain '%s' %04x", tag2str(tag), id);
+
+ const ResourceMap &resMap = _types[tag];
+
+ if (!resMap.contains(id))
+ error("Archive does not contain '%s' %04x", tag2str(tag), id);
+
+ const PipeResource &res = resMap[id];
+
+ if (res.entries.size() == 1) {
+ Common::SeekableReadStream *stream = new Common::SeekableSubReadStream(_stream,
+ res.entries[0].offset, res.entries[0].offset + res.entries[0].size);
+ if (buffering)
+ _types[tag].erase(id);
+ return stream;
+ }
+
+ // If there are multiple entries in the pipe, we have to concaternate them together.
+
+ uint32 size = 0;
+ for (uint i = 0; i < res.entries.size(); i++)
+ size += res.entries[i].size;
+
+ byte *buffer = (byte *)malloc(size);
+ uint32 offset = 0;
+ for (uint i = 0; i < res.entries.size(); i++) {
+ _stream->seek(res.entries[i].offset, SEEK_SET);
+ _stream->read(buffer + offset, res.entries[i].size);
+ offset += res.entries[i].size;
+ }
+ if (buffering)
+ _types[tag].erase(id);
+ return new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES);
+}
+
+} // End of namespace Composer
diff --git a/engines/composer/resource.h b/engines/composer/resource.h
new file mode 100644
index 0000000000..9408cdffb8
--- /dev/null
+++ b/engines/composer/resource.h
@@ -0,0 +1,124 @@
+/* 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 "common/scummsys.h"
+#include "common/endian.h"
+#include "common/hashmap.h"
+#include "common/file.h"
+#include "common/str.h"
+
+#ifndef COMPOSER_RESOURCE_H
+#define COMPOSER_RESOURCE_H
+
+namespace Composer {
+
+struct Animation;
+
+#define ID_LBRC MKTAG('L','B','R','C') // Main FourCC
+
+#define ID_ANIM MKTAG('A','N','I','M') // Animation
+#define ID_BMAP MKTAG('B','M','A','P') // Bitmap
+#define ID_BUTN MKTAG('B','U','T','N') // Button
+#define ID_CTBL MKTAG('C','T','B','L') // Color Table
+#define ID_EVNT MKTAG('E','V','N','T') // Event
+#define ID_PIPE MKTAG('P','I','P','E') // Pipe
+#define ID_SCRP MKTAG('S','C','R','P') // Script
+#define ID_VARI MKTAG('V','A','R','I') // Variables
+#define ID_WAVE MKTAG('W','A','V','E') // Wave
+
+class Archive {
+public:
+ Archive();
+ virtual ~Archive();
+
+ bool openFile(const Common::String &fileName);
+ virtual bool openStream(Common::SeekableReadStream *stream) = 0;
+ void close();
+
+ bool isOpen() const { return _stream != 0; }
+
+ bool hasResource(uint32 tag, uint16 id) const;
+ bool hasResource(uint32 tag, const Common::String &resName) const;
+ Common::SeekableReadStream *getResource(uint32 tag, uint16 id);
+ uint32 getResourceFlags(uint32 tag, uint16 id) const;
+ uint32 getOffset(uint32 tag, uint16 id) const;
+ uint16 findResourceID(uint32 tag, const Common::String &resName) const;
+ Common::String getName(uint32 tag, uint16 id) const;
+
+ Common::Array<uint32> getResourceTypeList() const;
+ Common::Array<uint16> getResourceIDList(uint32 type) const;
+
+protected:
+ Common::SeekableReadStream *_stream;
+
+ struct Resource {
+ uint32 offset;
+ uint32 size;
+ Common::String name;
+ uint32 flags;
+ };
+
+ typedef Common::HashMap<uint16, Resource> ResourceMap;
+ typedef Common::HashMap<uint32, ResourceMap> TypeMap;
+ TypeMap _types;
+};
+
+class ComposerArchive : public Archive {
+public:
+ ComposerArchive() : Archive() {}
+ ~ComposerArchive() {}
+
+ bool openStream(Common::SeekableReadStream *stream);
+};
+
+struct PipeResourceEntry {
+ uint32 size;
+ uint32 offset;
+};
+
+struct PipeResource {
+ Common::Array<PipeResourceEntry> entries;
+};
+
+class Pipe {
+public:
+ Pipe(Common::SeekableReadStream *stream);
+ void nextFrame();
+
+ Animation *_anim;
+
+ bool hasResource(uint32 tag, uint16 id) const;
+ Common::SeekableReadStream *getResource(uint32 tag, uint16 id, bool buffering);
+
+protected:
+ Common::SeekableReadStream *_stream;
+
+ typedef Common::HashMap<uint16, PipeResource> ResourceMap;
+ typedef Common::HashMap<uint32, ResourceMap> TypeMap;
+ TypeMap _types;
+
+ uint32 _offset;
+};
+
+} // End of namespace Composer
+
+#endif
diff --git a/engines/composer/scripting.cpp b/engines/composer/scripting.cpp
new file mode 100644
index 0000000000..d85bd524e0
--- /dev/null
+++ b/engines/composer/scripting.cpp
@@ -0,0 +1,729 @@
+/* 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 "common/scummsys.h"
+#include "common/savefile.h"
+
+#include "composer/composer.h"
+#include "composer/graphics.h"
+#include "composer/resource.h"
+
+namespace Composer {
+
+// new script ops
+enum {
+ kOpPlusPlus = 0x1,
+ kOpMinusMinus = 0x2,
+ kOpAssign = 0x3,
+ kOpAdd = 0x4,
+ kOpSubtract = 0x5,
+ kOpMultiply = 0x6,
+ kOpDivide = 0x7,
+ kOpModulo = 0x8,
+ kOpMaybeAlsoAssign = 0x9,
+ kOpBooleanAssign = 0xA,
+ kOpNegate = 0xB,
+ kOpAnd = 0xC,
+ kOpOr = 0xD,
+ kOpXor = 0xE,
+ kOpNot = 0xF,
+ kOpSqrt = 0x10,
+ kOpRandom = 0x11,
+ kOpExecuteScript = 0x12,
+ kOpCallFunc = 0x13,
+ kOpBoolLessThanEq = 0x17,
+ kOpBoolLessThan = 0x16,
+ kOpBoolGreaterThanEq = 0x15,
+ kOpBoolGreaterThan = 0x14,
+ kOpBoolEqual = 0x18,
+ kOpBoolNotEqual = 0x19,
+ kOpSaveArgs = 0x1A,
+ kOpRestoreArgs = 0x1B,
+ kOpReturn = 0x20,
+ kOpLessThanEq = 0x22,
+ kOpLessThan = 0x21,
+ kOpGreaterThanEq = 0x24,
+ kOpGreaterThan = 0x23,
+ kOpEqual = 0x25,
+ kOpNotEqual = 0x26,
+ kOpJump = 0x80,
+ kOpJumpIfNot = 0x81,
+ kOpJumpIf = 0x82,
+ kOpJumpIfNotValue = 0x83,
+ kOpJumpIfValue = 0x84
+};
+
+enum {
+ kFuncPlayAnim = 35001,
+ kFuncStopAnim = 35002,
+ // (no 35003)
+ kFuncQueueScript = 35004,
+ kFuncDequeueScript = 35005,
+ kFuncSetCursor = 35006,
+ kFuncGetCursor = 35007,
+ kFuncShowCursor = 35008,
+ kFuncHideCursor = 35009,
+ // (no 35010)
+ kFuncActivateButton = 35011,
+ kFuncDeactivateButton = 35012,
+ kFuncNewPage = 35013,
+ kFuncLoadPage = 35014,
+ kFuncUnloadPage = 35015,
+ kFuncSetPalette = 35016,
+ kFuncSaveVars = 35017,
+ kFuncLoadVars = 35018,
+ kFuncQueueScriptOnce = 35019,
+ kFuncGetMousePos = 35020,
+ kFuncChangeBackground = 35021,
+ kFuncSetBackgroundColor = 35022,
+ kFuncClearSprites = 35023,
+ kFuncAddSprite = 35024,
+ kFuncRemoveSprite = 35025,
+ kFuncQuit = 35026,
+ kFuncSaveData = 35027,
+ kFuncLoadData = 35028,
+ kFuncGetSpriteSize = 35029
+};
+
+void ComposerEngine::runEvent(uint16 id, int16 param1, int16 param2, int16 param3) {
+ if (!hasResource(ID_EVNT, id))
+ return;
+
+ Common::SeekableReadStream *stream = getResource(ID_EVNT, id);
+ if (stream->size() != 2)
+ error("bad EVNT size %d", stream->size());
+ uint16 scriptId = stream->readUint16LE();
+ delete stream;
+
+ if (!scriptId)
+ return;
+
+ debug(2, "running event %d via script %d(%d, %d, %d)", id, scriptId, param1, param2, param3);
+
+ runScript(scriptId, param1, param2, param3);
+}
+
+int16 ComposerEngine::runScript(uint16 id, int16 param1, int16 param2, int16 param3) {
+ _vars[1] = param1;
+ _vars[2] = param2;
+ _vars[3] = param3;
+
+ runScript(id);
+
+ return _vars[0];
+}
+
+int16 ComposerEngine::getArg(uint16 arg, uint16 type) {
+ switch (type) {
+ case 0:
+ return (int16)arg;
+ case 1:
+ return (int16)_vars[arg];
+ case 2:
+ return (int16)_vars[_vars[arg]];
+ default:
+ error("invalid argument type %d (getting arg %d)", type, arg);
+ }
+}
+
+void ComposerEngine::setArg(uint16 arg, uint16 type, uint16 val) {
+ switch (type) {
+ case 1:
+ _vars[arg] = val;
+ break;
+ case 2:
+ _vars[_vars[arg]] = val;
+ break;
+ default:
+ error("invalid argument type %d (setting arg %d)", type, arg);
+ }
+
+}
+
+void ComposerEngine::runScript(uint16 id) {
+ if (!hasResource(ID_SCRP, id)) {
+ warning("ignoring attempt to run script %d, because it doesn't exist", id);
+ return;
+ }
+
+ uint stackBase = _stack.size();
+ _stack.resize(_stack.size() + 19);
+
+ Common::SeekableReadStream *stream = getResource(ID_SCRP, id);
+ if (stream->size() < 2)
+ error("SCRP was too small (%d)", stream->size());
+ uint16 size = stream->readUint16LE();
+ if (stream->size() < 2 + 2*size)
+ error("SCRP was too small (%d, but claimed %d entries)", stream->size(), size);
+ uint16 *script = new uint16[size];
+ for (uint i = 0; i < size; i++)
+ script[i] = stream->readUint16LE();
+ delete stream;
+
+ uint16 pos = 0;
+ bool lastResult = false;
+ while (pos < size) {
+ int16 val1, val2, val3;
+
+ byte op = (byte)script[pos];
+ uint numParams = (script[pos] & 0x300) >> 8; // 2 bits
+ if (pos + numParams >= size)
+ error("script ran out of content");
+ uint arg1 = (script[pos] & 0xc00) >> 10; // 2 bits
+ uint arg2 = (script[pos] & 0x3000) >> 12; // 2 bits
+ uint arg3 = (script[pos] & 0xC000) >> 14; // 2 bits
+ switch (op) {
+ case kOpPlusPlus:
+ if (numParams != 1)
+ error("kOpPlusPlus had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ debug(9, "[%d/%d]++ (now %d)", script[pos + 1], arg1, val1 + 1);
+ setArg(script[pos + 1], arg1, val1 + 1);
+ break;
+ case kOpMinusMinus:
+ if (numParams != 1)
+ error("kOpMinusMinus had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ debug(9, "[%d/%d]-- (now %d)", script[pos + 1], arg1, val1 - 1);
+ setArg(script[pos + 1], arg1, val1 - 1);
+ break;
+ case kOpAssign:
+ if (numParams != 2)
+ error("kOpAssign had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "[%d/%d] = [%d/%d] (%d)", script[pos + 1], arg1, script[pos + 2], arg2, val2);
+ setArg(script[pos + 1], arg1, val2);
+ break;
+ case kOpAdd:
+ if (numParams != 3)
+ error("kOpAdd had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ debug(9, "[%d/%d] = [%d/%d]=%d + [%d/%d]=%d (%d)", script[pos + 1], arg1, script[pos + 2], arg2, val2, script[pos+3], arg3, val3, val2 + val3);
+ setArg(script[pos + 1], arg1, val2 + val3);
+ break;
+ case kOpSubtract:
+ if (numParams != 3)
+ error("kOpSubtract had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ debug(9, "[%d/%d] = [%d/%d]=%d - [%d/%d]=%d (%d)", script[pos + 1], arg1, script[pos + 2], arg2, val2, script[pos+3], arg3, val3, val2 - val3);
+ setArg(script[pos + 1], arg1, val2 - val3);
+ break;
+ case kOpMultiply:
+ if (numParams != 3)
+ error("kOpMultiply had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ debug(9, "[%d/%d] = [%d/%d]=%d * [%d/%d]=%d (%d)", script[pos + 1], arg1, script[pos + 2], arg2, val2, script[pos+3], arg3, val3, val2 * val3);
+ setArg(script[pos + 1], arg1, val2 * val3);
+ break;
+ case kOpDivide:
+ if (numParams != 3)
+ error("kOpDivide had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ if (val3 == 0)
+ error("script tried to divide by zero");
+ debug(9, "[%d/%d] = [%d/%d]=%d / [%d/%d]=%d (%d)", script[pos + 1], arg1, script[pos + 2], arg2, val2, script[pos+3], arg3, val3, val2 / val3);
+ setArg(script[pos + 1], arg1, val2 / val3);
+ break;
+ case kOpModulo:
+ if (numParams != 3)
+ error("kOpModulo had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ if (val3 == 0)
+ error("script tried to divide by zero (modulo)");
+ debug(9, "[%d/%d] = [%d/%d]=%d %% [%d/%d]=%d (%d)", script[pos + 1], arg1, script[pos + 2], arg2, val2, script[pos+3], arg3, val3, val2 % val3);
+ setArg(script[pos + 1], arg1, val2 % val3);
+ break;
+ case kOpMaybeAlsoAssign:
+ if (numParams != 2)
+ error("kOpMaybeAlsoAssign had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "[%d/%d] =(?) [%d/%d] (%d)", script[pos + 1], arg1, script[pos + 2], arg2, val2);
+ setArg(script[pos + 1], arg1, val2);
+ break;
+ case kOpBooleanAssign:
+ if (numParams != 2)
+ error("kOpBooleanAssign had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "[%d/%d] = [%d/%d] (%d) ? 1 : 0", script[pos + 1], arg1, script[pos + 2], arg2, val2);
+ setArg(script[pos + 1], arg1, val2 ? 1 : 0);
+ break;
+ case kOpNegate:
+ if (numParams != 2)
+ error("kOpNegate had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "[%d/%d] = -[%d/%d] (%d)", script[pos + 1], arg1, script[pos + 2], arg2, val2);
+ setArg(script[pos + 1], arg1, -val2);
+ break;
+ case kOpAnd:
+ if (numParams != 3)
+ error("kOpAnd had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ debug(9, "[%d/%d] = [%d/%d]=%d & [%d/%d]=%d (%d)", script[pos + 1], arg1, script[pos + 2], arg2, val2, script[pos+3], arg3, val3, val2 & val3);
+ setArg(script[pos + 1], arg1, val2 & val3);
+ break;
+ case kOpOr:
+ if (numParams != 3)
+ error("kOpOr had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ debug(9, "[%d/%d] = [%d/%d]=%d | [%d/%d]=%d (%d)", script[pos + 1], arg1, script[pos + 2], arg2, val2, script[pos+3], arg3, val3, val2 | val3);
+ setArg(script[pos + 1], arg1, val2 | val3);
+ break;
+ case kOpXor:
+ if (numParams != 3)
+ error("kOpXor had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ debug(9, "[%d/%d] = [%d/%d]=%d ^ [%d/%d]=%d (%d)", script[pos + 1], arg1, script[pos + 2], arg2, val2, script[pos+3], arg3, val3, val2 ^ val3);
+ setArg(script[pos + 1], arg1, val2 ^ val3);
+ break;
+ case kOpNot:
+ if (numParams != 2)
+ error("kOpNot had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "[%d/%d] = ![%d/%d] (!%d)", script[pos + 1], arg1, script[pos + 2], arg2, val2);
+ setArg(script[pos + 1], arg1, val2 ? 0 : 1);
+ break;
+ case kOpSqrt:
+ if (numParams != 2)
+ error("kOpSqrt had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "[%d/%d] = sqrt([%d/%d] (%d))", script[pos + 1], arg1, script[pos + 2], arg2, val2);
+ setArg(script[pos + 1], arg1, (int16)sqrt((double)val2));
+ break;
+ case kOpRandom:
+ if (numParams != 3)
+ error("kOpRandom had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ val1 = _rnd->getRandomNumberRng(val2, val3);
+ debug(9, "[%d/%d] = rnd([%d/%d]=%d, [%d/%d]=%d) (%d)", script[pos + 1], arg1, script[pos + 2], arg2, val2, script[pos+3], arg3, val3, val1);
+ setArg(script[pos + 1], arg1, val1);
+ break;
+ case kOpExecuteScript:
+ if (numParams != 1)
+ error("kOpExecuteScript had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ debug(8, "run script [%d/%d]=%d", script[pos + 1], arg1, val1);
+ runScript(val1);
+ debug(8, "done run script");
+ break;
+ case kOpCallFunc:
+ if (numParams != 1)
+ error("kOpCallFunc had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ debug(8, "%d(%d, %d, %d)", (uint16)val1, _vars[1], _vars[2], _vars[3]);
+ _vars[0] = scriptFuncCall(val1, _vars[1], _vars[2], _vars[3]);
+ break;
+ case kOpBoolLessThanEq:
+ if (numParams != 2)
+ error("kOpBoolLessThanEq had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "[%d/%d] <= [%d/%d]? (%d <= %d)", script[pos + 1], arg1, script[pos + 2], arg2, val1, val2);
+ lastResult = (val1 <= val2);
+ break;
+ case kOpBoolLessThan:
+ if (numParams != 2)
+ error("kOpBoolLessThan had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "[%d/%d] < [%d/%d]? (%d < %d)", script[pos + 1], arg1, script[pos + 2], arg2, val1, val2);
+ lastResult = (val1 < val2);
+ break;
+ case kOpBoolGreaterThanEq:
+ if (numParams != 2)
+ error("kOpBoolGreaterThanEq had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "[%d/%d] >= [%d/%d]? (%d >= %d)", script[pos + 1], arg1, script[pos + 2], arg2, val1, val2);
+ lastResult = (val1 >= val2);
+ break;
+ case kOpBoolGreaterThan:
+ if (numParams != 2)
+ error("kOpBoolGreaterThan had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "[%d/%d] > [%d/%d]? (%d > %d)", script[pos + 1], arg1, script[pos + 2], arg2, val1, val2);
+ lastResult = (val1 > val2);
+ break;
+ case kOpBoolEqual:
+ if (numParams != 2)
+ error("kOpBoolEqual had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "[%d/%d] == [%d/%d]? (%d == %d)", script[pos + 1], arg1, script[pos + 2], arg2, val1, val2);
+ lastResult = (val1 == val2);
+ break;
+ case kOpBoolNotEqual:
+ if (numParams != 2)
+ error("kOpBoolNotEqual had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "[%d/%d] != [%d/%d]? (%d != %d)", script[pos + 1], arg1, script[pos + 2], arg2, val1, val2);
+ lastResult = (val1 != val2);
+ break;
+ case kOpSaveArgs:
+ if (numParams != 0)
+ error("kOpSaveArgs had wrong number of params (%d)", numParams);
+ debug(9, "save args");
+ for (uint i = 1; i < 19; i++)
+ _stack[stackBase + i] = _vars[i];
+ break;
+ case kOpRestoreArgs:
+ if (numParams != 0)
+ error("kOpRestoreArgs had wrong number of params (%d)", numParams);
+ debug(9, "restore args");
+ for (uint i = 1; i < 19; i++)
+ _vars[i] = _stack[stackBase + i];
+ break;
+ case kOpReturn:
+ if (numParams != 1)
+ error("kOpReturn had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ debug(9, "return [%d/%d]=%d", script[pos + 1], arg1, val1);
+ _vars[0] = val1;
+ break;
+ case kOpLessThanEq:
+ if (numParams != 3)
+ error("kOpLessThanEq had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ debug(9, "[%d/%d] = [%d/%d] <= [%d/%d]? (%d <= %d)", script[pos + 1], arg1, script[pos + 2], arg2, script[pos + 3], arg3, val3, val2);
+ setArg(script[pos + 1], arg1, (val3 <= val2) ? 1 : 0);
+ break;
+ case kOpLessThan:
+ if (numParams != 3)
+ error("kOpLessThan had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ debug(9, "[%d/%d] = [%d/%d] < [%d/%d]? (%d < %d)", script[pos + 1], arg1, script[pos + 2], arg2, script[pos + 3], arg3, val3, val2);
+ setArg(script[pos + 1], arg1, (val3 < val2) ? 1 : 0);
+ break;
+ case kOpGreaterThanEq:
+ if (numParams != 3)
+ error("kOpGreaterThanEq had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ debug(9, "[%d/%d] = [%d/%d] >= [%d/%d]? (%d >= %d)", script[pos + 1], arg1, script[pos + 2], arg2, script[pos + 3], arg3, val3, val2);
+ setArg(script[pos + 1], arg1, (val3 >= val2) ? 1 : 0);
+ break;
+ case kOpGreaterThan:
+ if (numParams != 3)
+ error("kOpGreaterThan had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ debug(9, "[%d/%d] = [%d/%d] > [%d/%d]? (%d > %d)", script[pos + 1], arg1, script[pos + 2], arg2, script[pos + 3], arg3, val3, val2);
+ setArg(script[pos + 1], arg1, (val3 > val2) ? 1 : 0);
+ break;
+ case kOpEqual:
+ if (numParams != 3)
+ error("kOpEqual had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ debug(9, "[%d/%d] = [%d/%d] == [%d/%d]? (%d == %d)", script[pos + 1], arg1, script[pos + 2], arg2, script[pos + 3], arg3, val2, val3);
+ setArg(script[pos + 1], arg1, (val3 == val2) ? 1 : 0);
+ break;
+ case kOpNotEqual:
+ if (numParams != 3)
+ error("kOpNotEqual had wrong number of params (%d)", numParams);
+ val2 = getArg(script[pos + 2], arg2);
+ val3 = getArg(script[pos + 3], arg3);
+ debug(9, "[%d/%d] = [%d/%d] != [%d/%d]? (%d != %d)", script[pos + 1], arg1, script[pos + 2], arg2, script[pos + 3], arg3, val2, val3);
+ setArg(script[pos + 1], arg1, (val3 != val2) ? 1 : 0);
+ break;
+ case kOpJump:
+ if (numParams != 1)
+ error("kOpJump had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ debug(9, "jump by [%d/%d]=%d", script[pos + 1], arg1, val1);
+ pos += val1;
+ break;
+ case kOpJumpIfNot:
+ if (numParams != 1)
+ error("kOpJumpIfNot had wrong number of params (%d)", numParams);
+ if (lastResult)
+ break;
+ val1 = getArg(script[pos + 1], arg1);
+ debug(9, "jump if not, by [%d/%d]=%d", script[pos + 1], arg1, val1);
+ pos += val1;
+ break;
+ case kOpJumpIf:
+ if (numParams != 1)
+ error("kOpJumpIf had wrong number of params (%d)", numParams);
+ if (!lastResult)
+ break;
+ val1 = getArg(script[pos + 1], arg1);
+ debug(9, "jump if, by [%d/%d]=%d", script[pos + 1], arg1, val1);
+ pos += val1;
+ break;
+ case kOpJumpIfNotValue:
+ if (numParams != 2)
+ error("kOpJumpIfNotValue had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "jump if not [%d/%d]=%d", script[pos + 1], arg1, val1);
+ if (val1)
+ break;
+ debug(9, "--> jump by [%d/%d]=%d", script[pos + 2], arg2, val2);
+ pos += val2;
+ break;
+ case kOpJumpIfValue:
+ if (numParams != 2)
+ error("kOpJumpIfValue had wrong number of params (%d)", numParams);
+ val1 = getArg(script[pos + 1], arg1);
+ val2 = getArg(script[pos + 2], arg2);
+ debug(9, "jump if [%d/%d]=%d", script[pos + 1], arg1, val1);
+ if (!val1)
+ break;
+ debug(9, "--> jump by [%d/%d]=%d", script[pos + 2], arg2, val2);
+ pos += val2;
+ break;
+ default:
+ error("unknown script op 0x%02x", op);
+ }
+ pos += (1 + numParams);
+
+ if (op == kOpReturn)
+ break;
+ }
+
+ delete[] script;
+ _stack.resize(_stack.size() - 19);
+}
+
+int16 ComposerEngine::scriptFuncCall(uint16 id, int16 param1, int16 param2, int16 param3) {
+ switch (id) {
+ case kFuncPlayAnim:
+ debug(3, "kFuncPlayAnim(%d, %d, %d)", param1, param2, param3);
+ playAnimation(param1, param2, param3, 0);
+ return 1; // TODO: return 0 on failure
+ case kFuncStopAnim:
+ debug(3, "kFuncStopAnim(%d)", param1);
+ for (Common::List<Animation *>::iterator i = _anims.begin(); i != _anims.end(); i++) {
+ if ((*i)->_id == param1)
+ stopAnimation(*i);
+ }
+ return 0;
+ case kFuncQueueScript:
+ debug(3, "kFuncQueueScript(%d, %d, %d)", param1, param2, param3);
+ _queuedScripts[param1]._baseTime = _system->getMillis();
+ _queuedScripts[param1]._duration = 10 * param2;
+ _queuedScripts[param1]._count = 0xffffffff;
+ _queuedScripts[param1]._scriptId = param3;
+ return 0;
+ case kFuncDequeueScript:
+ debug(3, "kFuncDequeueScript(%d)", param1);
+ _queuedScripts[param1]._count = 0;
+ _queuedScripts[param1]._scriptId = 0;
+ return 0;
+ case kFuncSetCursor:
+ debug(3, "kSetCursor(%d, (%d, %d))", param1, param2, param3);
+ {
+ uint16 oldCursor = _mouseSpriteId;
+ setCursor(param1, Common::Point(param2, param3));
+ return oldCursor;
+ }
+ case kFuncGetCursor:
+ debug(3, "kFuncGetCursor()");
+ return _mouseSpriteId;
+ case kFuncShowCursor:
+ debug(3, "kFuncShowCursor()");
+ setCursorVisible(true);
+ return 0;
+ case kFuncHideCursor:
+ debug(3, "kFuncHideCursor()");
+ setCursorVisible(false);
+ return 0;
+ case kFuncActivateButton:
+ debug(3, "kFuncActivateButton(%d)", param1);
+ for (Common::List<Library>::iterator l = _libraries.begin(); l != _libraries.end(); l++) {
+ for (Common::List<Button>::iterator i = l->_buttons.begin(); i != l->_buttons.end(); i++) {
+ if (i->_id != param1)
+ continue;
+ i->_active = true;
+ }
+ }
+ onMouseMove(_lastMousePos);
+ return 1;
+ case kFuncDeactivateButton:
+ debug(3, "kFuncDeactivateButton(%d)", param1);
+ for (Common::List<Library>::iterator l = _libraries.begin(); l != _libraries.end(); l++) {
+ for (Common::List<Button>::iterator i = l->_buttons.begin(); i != l->_buttons.end(); i++) {
+ if (i->_id != param1)
+ continue;
+ i->_active = false;
+ }
+ }
+ onMouseMove(_lastMousePos);
+ return 1;
+ case kFuncNewPage:
+ debug(3, "kFuncNewPage(%d, %d)", param1, param2);
+ _pendingPageChanges.push_back(PendingPageChange(param1, true));
+ _pendingPageChanges.push_back(PendingPageChange(param2, false));
+ return 1;
+ case kFuncLoadPage:
+ debug(3, "kFuncLoadPage(%d)", param1);
+ _pendingPageChanges.push_back(PendingPageChange(param1, false));
+ return 1;
+ case kFuncUnloadPage:
+ debug(3, "kFuncUnloadPage(%d)", param1);
+ _pendingPageChanges.push_back(PendingPageChange(param1, true));
+ return 1;
+ case kFuncSetPalette:
+ // TODO: return 0 if not disabling (0) and doesn't exist
+ debug(4, "kFuncSetPalette(%d, %d)", param1, param2);
+ // this seems only needed for a script bug in the Gregory credits, sigh
+ if ((uint16)param2 > 100)
+ param2 = 100;
+ loadCTBL(param1, param2);
+ return 1;
+ case kFuncSaveVars:
+ debug(3, "kFuncSaveVars(%d)", param1);
+ {
+ Common::String filename = _targetName + Common::String::format(".%03d", param1);
+ Common::WriteStream *stream = _saveFileMan->openForSaving(filename);
+ for (uint i = 0; i < 1000; i++) {
+ stream->writeUint16LE(_vars[i]);
+ }
+ delete stream;
+ }
+ return 1;
+ case kFuncLoadVars:
+ debug(3, "kFuncLoadVars(%d, %d, %d)", param1, param2, param3);
+ {
+ Common::String filename = _targetName + Common::String::format(".%03d", param1);
+ Common::SeekableReadStream *stream = _saveFileMan->openForLoading(filename);
+ if (!stream) {
+ if (!_bookIni.hasKey(Common::String::format("%d", param1), "Data"))
+ return 0;
+ filename = getFilename("Data", param1);
+ Common::File *file = new Common::File();
+ if (!file->open(filename))
+ error("couldn't open '%s' to get vars id '%d'", filename.c_str(), param1);
+ stream = file;
+ }
+ if (param3 == 0)
+ param3 = 1000;
+ if (param2 < 0 || param3 < 0 || param2 + param3 > 1000)
+ error("can't read %d entries into %d from file '%s' for vars id '%d'", param3, param2, filename.c_str(), param1);
+ stream->skip(param2 * 2);
+ for (uint i = 0; i < (uint)param3; i++) {
+ if (stream->pos() + 1 > stream->size())
+ break;
+ _vars[param2 + i] = stream->readUint16LE();
+ }
+ delete stream;
+ }
+ return 1;
+ case kFuncQueueScriptOnce:
+ debug(3, "kFuncQueueScriptOnce(%d, %d, %d)", param1, param2, param3);
+ _queuedScripts[param1]._baseTime = _system->getMillis();
+ _queuedScripts[param1]._duration = 10 * param2;
+ _queuedScripts[param1]._count = 1;
+ _queuedScripts[param1]._scriptId = param3;
+ return 0;
+ case kFuncGetMousePos:
+ debug(3, "kFuncGetMousePos(%d, %d)", param1, param2);
+ _vars[param1] = _lastMousePos.x;
+ _vars[param2] = _lastMousePos.y;
+ return 0;
+ case kFuncChangeBackground:
+ debug(3, "kFuncChangeBackground(%d)", param1);
+ // TODO: return 1 if background existed, else 0
+ setBackground(param1);
+ return 1;
+ case kFuncSetBackgroundColor:
+ // TODO
+ warning("ignoring kFuncSetBackgroundColor(%d)", param1);
+ return 0;
+ case kFuncClearSprites:
+ debug(3, "kFuncClearSprites()");
+ removeSprite(0, 0);
+ return 0;
+ case kFuncAddSprite:
+ {
+ Common::Point pos(_vars[param3], _vars[param3 + 1]);
+ int16 zorder = _vars[param3 + 2];
+ debug(3, "kFuncAddSprite(%d, %d, [%d = (%d, %d), %d])", param1, param2, param3, pos.x, pos.y, zorder);
+ addSprite(param1, param2, zorder, pos);
+ }
+ return 0;
+ case kFuncRemoveSprite:
+ debug(3, "kFuncRemoveSprite(%d, %d)", param1, param2);
+ removeSprite(param1, param2);
+ return 0;
+ case kFuncQuit:
+ debug(3, "kFuncQuit()");
+ quitGame();
+ return 0;
+ case kFuncSaveData:
+ // TODO
+ warning("ignoring kFuncSaveData(%d, %d, %d)", param1, param2, param3);
+ return 1;
+ case kFuncLoadData:
+ debug(3, "kFuncLoadData(%d, %d, %d)", param1, param2, param3);
+ {
+ Common::String filename = getFilename("Data", param1);
+ Common::File *file = new Common::File();
+ if (!file->open(filename))
+ error("couldn't open '%s' to get data id '%d'", filename.c_str(), param1);
+ if (param3 == 0)
+ param3 = 1000;
+ if (param2 < 0 || param3 < 0 || param2 + param3 > 1000)
+ error("can't read %d entries into %d from file '%s' for data id '%d'", param3, param2, filename.c_str(), param1);
+ for (uint i = 0; i < (uint)param3; i++) {
+ if (file->pos() + 1 > file->size())
+ break;
+ _vars[param2 + i] = file->readUint16LE();
+ }
+ delete file;
+ }
+ return 1;
+ case kFuncGetSpriteSize:
+ debug(3, "kFuncGetSpriteSize(%d, %d, %d)", param1, param2, param3);
+ int16 width, height;
+ width = 0;
+ height = 0;
+ {
+ Common::SeekableReadStream *stream = getStreamForSprite(param1);
+ if (stream) {
+ stream->readUint16LE();
+ height = stream->readSint16LE();
+ width = stream->readSint16LE();
+ delete stream;
+ }
+ }
+ _vars[param2] = width;
+ _vars[param3] = height;
+ return 0;
+ default:
+ error("unknown scriptFuncCall %d(%d, %d, %d)", (uint32)id, param1, param2, param3);
+ }
+}
+
+} // End of namespace Composer
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index b8a5e5122b..59d69758b6 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -1,5 +1,29 @@
/* PLEASE DO NOT MODIFY THIS FILE. ALL CHANGES WILL BE LOST! LOOK FOR README FOR DETAILS */
+/* 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 "dreamgen.h"
namespace DreamGen {
@@ -4913,140 +4937,6 @@ realcreditsearly:
data.byte(kLasthardkey) = 0;
}
-void DreamGenContext::printchar() {
- STACK_CHECK;
- _cmp(al, 255);
- if (flags.z())
- return /* (ignoreit) */;
- push(si);
- push(bx);
- push(di);
- _cmp(data.byte(kForeignrelease), 0);
- if (flags.z())
- goto _tmp1;
- _sub(bx, 3);
-_tmp1:
- push(ax);
- _sub(al, 32);
- ah = 0;
- _add(ax, data.word(kCharshift));
- showframe();
- ax = pop();
- di = pop();
- bx = pop();
- si = pop();
- _cmp(data.byte(kKerning), 0);
- if (!flags.z())
- goto nokern;
- kernchars();
-nokern:
- push(cx);
- ch = 0;
- _add(di, cx);
- cx = pop();
-}
-
-void DreamGenContext::printslow() {
- STACK_CHECK;
- data.byte(kPointerframe) = 1;
- data.byte(kPointermode) = 3;
- ds = data.word(kCharset1);
-printloopslow6:
- push(bx);
- push(di);
- push(dx);
- getnumber();
- ch = 0;
-printloopslow5:
- push(cx);
- push(si);
- push(es);
- ax = es.word(si);
- push(bx);
- push(cx);
- push(es);
- push(si);
- push(ds);
- modifychar();
- printboth();
- ds = pop();
- si = pop();
- es = pop();
- cx = pop();
- bx = pop();
- ax = es.word(si+1);
- _inc(si);
- _cmp(al, 0);
- if (flags.z())
- goto finishslow;
- _cmp(al, ':');
- if (flags.z())
- goto finishslow;
- _cmp(cl, 1);
- if (flags.z())
- goto afterslow;
- push(di);
- push(ds);
- push(bx);
- push(cx);
- push(es);
- push(si);
- modifychar();
- data.word(kCharshift) = 91;
- printboth();
- data.word(kCharshift) = 0;
- si = pop();
- es = pop();
- cx = pop();
- bx = pop();
- ds = pop();
- di = pop();
- waitframes();
- _cmp(ax, 0);
- if (flags.z())
- goto keepgoing;
- _cmp(ax, data.word(kOldbutton));
- if (!flags.z())
- goto finishslow2;
-keepgoing:
- waitframes();
- _cmp(ax, 0);
- if (flags.z())
- goto afterslow;
- _cmp(ax, data.word(kOldbutton));
- if (!flags.z())
- goto finishslow2;
-afterslow:
- es = pop();
- si = pop();
- cx = pop();
- _inc(si);
- if (--cx)
- goto printloopslow5;
- dx = pop();
- di = pop();
- bx = pop();
- _add(bx, 10);
- goto printloopslow6;
-finishslow:
- es = pop();
- si = pop();
- cx = pop();
- dx = pop();
- di = pop();
- bx = pop();
- al = 0;
- return;
-finishslow2:
- es = pop();
- si = pop();
- cx = pop();
- dx = pop();
- di = pop();
- bx = pop();
- al = 1;
-}
-
void DreamGenContext::waitframes() {
STACK_CHECK;
push(di);
@@ -5067,62 +4957,6 @@ void DreamGenContext::waitframes() {
di = pop();
}
-void DreamGenContext::printboth() {
- STACK_CHECK;
- push(ax);
- push(cx);
- push(bx);
- push(di);
- printchar();
- ax = pop();
- push(di);
- di = ax;
- multidump();
- di = pop();
- bx = pop();
- cx = pop();
- ax = pop();
-}
-
-void DreamGenContext::printdirect() {
- STACK_CHECK;
- data.word(kLastxpos) = di;
- ds = data.word(kCurrentset);
-printloop6:
- push(bx);
- push(di);
- push(dx);
- getnumber();
- ch = 0;
-printloop5:
- ax = es.word(si);
- _inc(si);
- _cmp(al, 0);
- if (flags.z())
- goto finishdirct;
- _cmp(al, ':');
- if (flags.z())
- goto finishdirct;
- push(cx);
- push(es);
- modifychar();
- printchar();
- data.word(kLastxpos) = di;
- es = pop();
- cx = pop();
- if (--cx)
- goto printloop5;
- dx = pop();
- di = pop();
- bx = pop();
- _add(bx, data.word(kLinespacing));
- goto printloop6;
-finishdirct:
- dx = pop();
- di = pop();
- bx = pop();
-}
-
void DreamGenContext::monprint() {
STACK_CHECK;
data.byte(kKerning) = 1;
@@ -5209,114 +5043,6 @@ nottrigger2:
data.byte(kKerning) = 0;
}
-void DreamGenContext::getnumber() {
- STACK_CHECK;
- cx = 0;
- push(si);
- push(bx);
- push(di);
- push(ds);
- push(es);
- di = si;
-wordloop:
- push(cx);
- push(dx);
- getnextword();
- dx = pop();
- cx = pop();
- _cmp(al, 1);
- if (flags.z())
- goto endoftext;
- al = cl;
- ah = 0;
- push(bx);
- bh = 0;
- _add(ax, bx);
- bx = pop();
- _sub(ax, 10);
- dh = 0;
- _cmp(ax, dx);
- if (!flags.c())
- goto gotoverend;
- _add(cl, bl);
- _add(ch, bh);
- goto wordloop;
-gotoverend:
- al = dl;
- _and(al, 1);
- if (flags.z())
- goto notcentre;
- push(cx);
- al = dl;
- _and(al, 0xfe);
- ah = 0;
- ch = 0;
- _sub(ax, cx);
- _add(ax, 20);
- _shr(ax, 1);
- cx = pop();
- es = pop();
- ds = pop();
- di = pop();
- bx = pop();
- si = pop();
- _add(di, ax);
- cl = ch;
- return;
-notcentre:
- es = pop();
- ds = pop();
- di = pop();
- bx = pop();
- si = pop();
- cl = ch;
- return;
-endoftext:
- al = cl;
- ah = 0;
- push(bx);
- bh = 0;
- _add(ax, bx);
- bx = pop();
- _sub(ax, 10);
- dh = 0;
- _cmp(ax, dx);
- if (!flags.c())
- goto gotoverend2;
- _add(cl, bl);
- _add(ch, bh);
-gotoverend2:
- al = dl;
- _and(al, 1);
- if (flags.z())
- goto notcent2;
- push(cx);
- al = dl;
- _and(al, 0xfe);
- _add(al, 2);
- ah = 0;
- ch = 0;
- _add(ax, 20);
- _sub(ax, cx);
- _shr(ax, 1);
- cx = pop();
- es = pop();
- ds = pop();
- di = pop();
- bx = pop();
- si = pop();
- _add(di, ax);
- cl = ch;
- return;
-notcent2:
- es = pop();
- ds = pop();
- di = pop();
- bx = pop();
- si = pop();
- cl = ch;
-}
-
void DreamGenContext::fillryan() {
STACK_CHECK;
es = data.word(kBuffers);
@@ -13127,46 +12853,6 @@ notonsartroof:
placesetobject();
}
-void DreamGenContext::getundertimed() {
- STACK_CHECK;
- al = data.byte(kTimedy);
- _cmp(data.byte(kForeignrelease), 0);
- if (flags.z())
- goto _tmp1;
- _sub(al, 3);
-_tmp1:
- ah = 0;
- bx = ax;
- al = data.byte(kTimedx);
- ah = 0;
- di = ax;
- ch = (30);
- cl = 240;
- ds = data.word(kBuffers);
- si = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40)+(5*80)+(250*4));
- multiget();
-}
-
-void DreamGenContext::putundertimed() {
- STACK_CHECK;
- al = data.byte(kTimedy);
- _cmp(data.byte(kForeignrelease), 0);
- if (flags.z())
- goto _tmp1;
- _sub(al, 3);
-_tmp1:
- ah = 0;
- bx = ax;
- al = data.byte(kTimedx);
- ah = 0;
- di = ax;
- ch = (30);
- cl = 240;
- ds = data.word(kBuffers);
- si = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40)+(5*80)+(250*4));
- multiput();
-}
-
void DreamGenContext::dumptimedtext() {
STACK_CHECK;
_cmp(data.byte(kNeedtodumptimed), 1);
@@ -13263,42 +12949,6 @@ notloadspeech3:
data.word(kTimedoffset) = bx;
}
-void DreamGenContext::usetimedtext() {
- STACK_CHECK;
- _cmp(data.word(kTimecount), 0);
- if (flags.z())
- return /* (notext) */;
- _dec(data.word(kTimecount));
- _cmp(data.word(kTimecount), 0);
- if (flags.z())
- goto deltimedtext;
- ax = data.word(kTimecount);
- _cmp(ax, data.word(kCounttotimed));
- if (flags.z())
- goto firsttimed;
- if (!flags.c())
- return /* (notext) */;
- goto notfirsttimed;
-firsttimed:
- getundertimed();
-notfirsttimed:
- bl = data.byte(kTimedy);
- bh = 0;
- al = data.byte(kTimedx);
- ah = 0;
- di = ax;
- es = data.word(kTimedseg);
- si = data.word(kTimedoffset);
- dl = 237;
- ah = 0;
- printdirect();
- data.byte(kNeedtodumptimed) = 1;
- return;
-deltimedtext:
- putundertimed();
- data.byte(kNeedtodumptimed) = 1;
-}
-
void DreamGenContext::edenscdplayer() {
STACK_CHECK;
showfirstuse();
@@ -16570,19 +16220,6 @@ endlessloop:
data.word(kCh0blockstocopy) = ax;
}
-void DreamGenContext::cancelch0() {
- STACK_CHECK;
- data.byte(kCh0repeat) = 0;
- data.word(kCh0blockstocopy) = 0;
- data.byte(kCh0playing) = 255;
-}
-
-void DreamGenContext::cancelch1() {
- STACK_CHECK;
- data.word(kCh1blockstocopy) = 0;
- data.byte(kCh1playing) = 255;
-}
-
void DreamGenContext::channel0tran() {
STACK_CHECK;
_cmp(data.byte(kVolume), 0);
@@ -19825,24 +19462,6 @@ _tmp1:
multiput();
}
-void DreamGenContext::dumptextline() {
- STACK_CHECK;
- _cmp(data.byte(kNewtextline), 1);
- if (!flags.z())
- return /* (nodumptextline) */;
- data.byte(kNewtextline) = 0;
- di = data.word(kTextaddressx);
- bx = data.word(kTextaddressy);
- _cmp(data.byte(kForeignrelease), 0);
- if (flags.z())
- goto _tmp1;
- _sub(bx, 3);
-_tmp1:
- cl = (228);
- ch = (13);
- multidump();
-}
-
void DreamGenContext::animpointer() {
STACK_CHECK;
_cmp(data.byte(kPointermode), 2);
@@ -20660,138 +20279,6 @@ transfer:
dx = 6059;
}
-void DreamGenContext::dreamweb() {
- STACK_CHECK;
- seecommandtail();
- checkbasemem();
- soundstartup();
- setkeyboardint();
- setupemm();
- allocatebuffers();
- setmouse();
- fadedos();
- gettime();
- clearbuffers();
- clearpalette();
- set16colpalette();
- readsetdata();
- data.byte(kWongame) = 0;
- dx = 1909;
- loadsample();
- setsoundoff();
- scanfornames();
- _cmp(al, 0);
- if (!flags.z())
- goto dodecisions;
- setmode();
- loadpalfromiff();
- titles();
- credits();
- goto playgame;
-dodecisions:
- cls();
- setmode();
- decide();
- _cmp(data.byte(kQuitrequested), 0);
- if (!flags.z())
- return /* (exitgame) */;
- _cmp(data.byte(kGetback), 4);
- if (flags.z())
- goto mainloop;
- titles();
- _cmp(data.byte(kQuitrequested), 0);
- if (!flags.z())
- return /* (exitgame) */;
- credits();
-playgame:
- _cmp(data.byte(kQuitrequested), 0);
- if (!flags.z())
- return /* (exitgame) */;
- clearchanges();
- setmode();
- loadpalfromiff();
- data.byte(kLocation) = 255;
- data.byte(kRoomafterdream) = 1;
- data.byte(kNewlocation) = 35;
- data.byte(kVolume) = 7;
- loadroom();
- clearsprites();
- initman();
- entrytexts();
- entryanims();
- data.byte(kDestpos) = 3;
- initialinv();
- data.byte(kLastflag) = 32;
- startup1();
- data.byte(kVolumeto) = 0;
- data.byte(kVolumedirection) = -1;
- data.byte(kCommandtype) = 255;
- goto mainloop;
-loadnew:
- clearbeforeload();
- loadroom();
- clearsprites();
- initman();
- entrytexts();
- entryanims();
- data.byte(kNewlocation) = 255;
- startup();
- data.byte(kCommandtype) = 255;
- worktoscreenm();
- goto mainloop;
- data.byte(kNewlocation) = 255;
- clearsprites();
- initman();
- startup();
- data.byte(kCommandtype) = 255;
-mainloop:
- _cmp(data.byte(kQuitrequested), 0);
- if (!flags.z())
- return /* (exitgame) */;
- screenupdate();
- _cmp(data.byte(kWongame), 0);
- if (!flags.z())
- goto endofgame;
- _cmp(data.byte(kMandead), 1);
- if (flags.z())
- goto gameover;
- _cmp(data.byte(kMandead), 2);
- if (flags.z())
- goto gameover;
- _cmp(data.word(kWatchingtime), 0);
- if (flags.z())
- goto notwatching;
- al = data.byte(kFinaldest);
- _cmp(al, data.byte(kManspath));
- if (!flags.z())
- goto mainloop;
- _dec(data.word(kWatchingtime));
- if (!flags.z())
- goto mainloop;
-notwatching:
- _cmp(data.byte(kMandead), 4);
- if (flags.z())
- goto gameover;
- _cmp(data.byte(kNewlocation), 255);
- if (!flags.z())
- goto loadnew;
- goto mainloop;
-gameover:
- clearbeforeload();
- showgun();
- fadescreendown();
- cx = 100;
- hangon();
- goto dodecisions;
-endofgame:
- clearbeforeload();
- fadescreendowns();
- cx = 200;
- hangon();
- endgame();
- { quickquit2(); return; };
-}
-
void DreamGenContext::__start() {
@@ -21537,13 +21024,8 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_mode640x480: mode640x480(); break;
case addr_set16colpalette: set16colpalette(); break;
case addr_realcredits: realcredits(); break;
- case addr_printchar: printchar(); break;
- case addr_printslow: printslow(); break;
case addr_waitframes: waitframes(); break;
- case addr_printboth: printboth(); break;
- case addr_printdirect: printdirect(); break;
case addr_monprint: monprint(); break;
- case addr_getnumber: getnumber(); break;
case addr_fillryan: fillryan(); break;
case addr_fillopen: fillopen(); break;
case addr_findallryan: findallryan(); break;
@@ -21794,12 +21276,9 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_setallchanges: setallchanges(); break;
case addr_dochange: dochange(); break;
case addr_autoappear: autoappear(); break;
- case addr_getundertimed: getundertimed(); break;
- case addr_putundertimed: putundertimed(); break;
case addr_dumptimedtext: dumptimedtext(); break;
case addr_setuptimeduse: setuptimeduse(); break;
case addr_setuptimedtemp: setuptimedtemp(); break;
- case addr_usetimedtext: usetimedtext(); break;
case addr_edenscdplayer: edenscdplayer(); break;
case addr_usewall: usewall(); break;
case addr_usechurchgate: usechurchgate(); break;
@@ -21922,8 +21401,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_makenextblock: makenextblock(); break;
case addr_volumeadjust: volumeadjust(); break;
case addr_loopchannel0: loopchannel0(); break;
- case addr_cancelch0: cancelch0(); break;
- case addr_cancelch1: cancelch1(); break;
case addr_channel0only: channel0only(); break;
case addr_channel1only: channel1only(); break;
case addr_channel0tran: channel0tran(); break;
@@ -22035,7 +21512,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_dumppointer: dumppointer(); break;
case addr_undertextline: undertextline(); break;
case addr_deltextline: deltextline(); break;
- case addr_dumptextline: dumptextline(); break;
case addr_animpointer: animpointer(); break;
case addr_setmouse: setmouse(); break;
case addr_readmouse: readmouse(); break;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 032ad5847c..c2aa204942 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -3,6 +3,30 @@
/* PLEASE DO NOT MODIFY THIS FILE. ALL CHANGES WILL BE LOST! LOOK FOR README FOR DETAILS */
+/* 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 "dreamweb/runtime.h"
@@ -68,7 +92,6 @@ public:
static const uint16 addr_readmouse = 0xcae4;
static const uint16 addr_setmouse = 0xcae0;
static const uint16 addr_animpointer = 0xcadc;
- static const uint16 addr_dumptextline = 0xcad8;
static const uint16 addr_deltextline = 0xcad4;
static const uint16 addr_undertextline = 0xcad0;
static const uint16 addr_dumppointer = 0xcacc;
@@ -180,8 +203,6 @@ public:
static const uint16 addr_channel0tran = 0xc920;
static const uint16 addr_channel1only = 0xc91c;
static const uint16 addr_channel0only = 0xc918;
- static const uint16 addr_cancelch1 = 0xc914;
- static const uint16 addr_cancelch0 = 0xc910;
static const uint16 addr_loopchannel0 = 0xc90c;
static const uint16 addr_volumeadjust = 0xc908;
static const uint16 addr_makenextblock = 0xc904;
@@ -306,12 +327,9 @@ public:
static const uint16 addr_usechurchgate = 0xc730;
static const uint16 addr_usewall = 0xc72c;
static const uint16 addr_edenscdplayer = 0xc728;
- static const uint16 addr_usetimedtext = 0xc724;
static const uint16 addr_setuptimedtemp = 0xc720;
static const uint16 addr_setuptimeduse = 0xc71c;
static const uint16 addr_dumptimedtext = 0xc718;
- static const uint16 addr_putundertimed = 0xc714;
- static const uint16 addr_getundertimed = 0xc710;
static const uint16 addr_autoappear = 0xc70c;
static const uint16 addr_dochange = 0xc708;
static const uint16 addr_setallchanges = 0xc704;
@@ -562,13 +580,8 @@ public:
static const uint16 addr_findallryan = 0xc328;
static const uint16 addr_fillopen = 0xc324;
static const uint16 addr_fillryan = 0xc320;
- static const uint16 addr_getnumber = 0xc318;
static const uint16 addr_monprint = 0xc314;
- static const uint16 addr_printdirect = 0xc310;
- static const uint16 addr_printboth = 0xc30c;
static const uint16 addr_waitframes = 0xc308;
- static const uint16 addr_printslow = 0xc304;
- static const uint16 addr_printchar = 0xc2fc;
static const uint16 addr_realcredits = 0xc2f8;
static const uint16 addr_set16colpalette = 0xc2f4;
static const uint16 addr_mode640x480 = 0xc2f0;
@@ -1327,7 +1340,7 @@ public:
void storeit();
void lockeddoorway();
void isitworn();
- void putundertimed();
+ //void putundertimed();
void dumpmap();
//void multidump();
void channel0only();
@@ -1353,7 +1366,7 @@ public:
void restoreall();
void screenupdate();
void addlength();
- void usetimedtext();
+ void wornerror();
void putundercentre();
void checkobjectsize();
void commandonly();
@@ -1454,10 +1467,10 @@ public:
void dumpkeypad();
void dumpzoom();
void endgameseq();
- void cancelch0();
+ //void cancelch0();
void setbotleft();
void findfirstpath();
- void showallfree();
+ void fadescreenup();
void loadold();
void loadtempcharset();
void useslab();
@@ -1467,7 +1480,7 @@ public:
void turnonpower();
void manasleep2();
void moretalk();
- void printslow();
+ //void printslow();
void loadroom();
void starttalk();
void delchar();
@@ -1499,9 +1512,10 @@ public:
void openpoolboss();
void buttontwo();
void fillopen();
+ //void usetimedtext();
void delsprite();
void getroomspaths();
- void dumptextline();
+ //void dumptextline();
void fadescreendownhalf();
void useplate();
void candles1();
@@ -1512,9 +1526,9 @@ public:
void loadspeech();
//void cls();
//void printsprites();
- void dumptimedtext();
+ void checkifperson();
void showallobs();
- void getnumber();
+ //void getnumber();
void adjustleft();
void calledenslift();
void useclearbox();
@@ -1529,7 +1543,7 @@ public:
void showpcx();
void showdecisions();
void checkspeed();
- void printchar();
+ //void printchar();
void showkeypad();
void obtoinv();
void removeobfrominv();
@@ -1546,7 +1560,7 @@ public:
//void spriteupdate();
void usetempcharset();
void discops();
- void printdirect();
+ //void printdirect();
void delthisone();
void makebackob();
void middlepanel();
@@ -1554,7 +1568,6 @@ public:
void saveload();
void monitorlogo();
void loadposition();
- void wornerror();
void entersymbol();
void showword();
void dirfile();
@@ -1580,7 +1593,7 @@ public:
void folderhints();
void openhoteldoor();
void removesetobject();
- void checkifperson();
+ void dumptimedtext();
//void frameoutfx();
void blank();
void drinker();
@@ -1634,7 +1647,6 @@ public:
void fadetowhite();
void textformonk();
void loadsavebox();
- void fadescreenup();
void soundend();
void redes();
void errormessage1();
@@ -1776,7 +1788,7 @@ public:
void findsetobject();
void singlekey();
//void seecommandtail();
- void getundertimed();
+ //void getundertimed();
void hangone();
void carparkdrip();
void usediary();
@@ -1813,6 +1825,7 @@ public:
void pickupob();
void error();
void showopbox();
+ //void cancelch1();
void clearbeforeload();
void biblequote();
void doload();
@@ -1870,7 +1883,7 @@ public:
void turnanypathon();
void restorereels();
void setwalk();
- void printboth();
+ //void printboth();
void useroutine();
void zoomicon();
void hotelcontrol();
@@ -1964,7 +1977,7 @@ public:
void initialmoncols();
void checkforshake();
void usebuttona();
- void cancelch1();
+ void showallfree();
//void getnextword();
void generalerror();
void actualload();
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index a5a6c9096a..caf3a987c4 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -477,6 +477,16 @@ void DreamWebEngine::playSound(uint8 channel, uint8 id, uint8 loops) {
_mixer->playStream(type, &_channelHandle[channel], stream);
}
+void DreamWebEngine::stopSound(uint8 channel) {
+ debug(1, "stopSound(%u)", channel);
+ assert(channel == 0 || channel == 1);
+ _mixer->stopHandle(_channelHandle[channel]);
+ if (channel == 0)
+ _channel0 = 0;
+ else
+ _channel1 = 0;
+}
+
bool DreamWebEngine::loadSpeech(const Common::String &filename) {
if (ConfMan.getBool("speech_mute"))
return false;
diff --git a/engines/dreamweb/dreamweb.h b/engines/dreamweb/dreamweb.h
index 1bc2f19d1c..6ada207496 100644
--- a/engines/dreamweb/dreamweb.h
+++ b/engines/dreamweb/dreamweb.h
@@ -111,6 +111,8 @@ public:
Common::Language getLanguage() const { return _language; }
uint8 modifyChar(uint8 c) const;
+ void stopSound(uint8 channel);
+
private:
void keyPressed(uint16 ascii);
void setSpeed(uint speed);
diff --git a/engines/dreamweb/runtime.h b/engines/dreamweb/runtime.h
index decd1cddd8..714a8d5850 100644
--- a/engines/dreamweb/runtime.h
+++ b/engines/dreamweb/runtime.h
@@ -133,7 +133,7 @@ struct Segment {
return WordRef(data, index);
}
- inline uint8* ptr(unsigned index, unsigned size) {
+ inline uint8 *ptr(unsigned index, unsigned size) {
assert(index + size <= data.size());
return data.begin() + index;
}
@@ -186,7 +186,7 @@ public:
_segment->assign(b, e);
}
- inline uint8* ptr(unsigned index, unsigned size) {
+ inline uint8 *ptr(unsigned index, unsigned size) {
assert(_segment != 0);
return _segment->ptr(index, size);
}
@@ -487,7 +487,7 @@ public:
inline void _movsb(uint size, bool clear_cx = false) {
assert(size != 0xffff);
//fixme: add overlap and segment boundary check and rewrite
- while(size--)
+ while (size--)
_movsb();
if (clear_cx)
cx = 0;
@@ -525,7 +525,7 @@ public:
assert(size != 0xffff);
uint8 *dst = es.ptr(di, size * 2);
di += 2 * size;
- while(size--) {
+ while (size--) {
*dst++ = al;
*dst++ = ah;
}
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 96d46110f9..00d082b4d3 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -26,6 +26,154 @@
namespace DreamGen {
+void DreamGenContext::dreamweb() {
+ STACK_CHECK;
+ seecommandtail();
+ checkbasemem();
+ soundstartup();
+ setkeyboardint();
+ setupemm();
+ allocatebuffers();
+ setmouse();
+ fadedos();
+ gettime();
+ clearbuffers();
+ clearpalette();
+ set16colpalette();
+ readsetdata();
+ data.byte(kWongame) = 0;
+
+ dx = 1909;
+ loadsample();
+ setsoundoff();
+
+ bool firstLoop = true;
+
+ while (true) {
+
+ scanfornames();
+
+ bool startNewGame = true;
+
+ if (al == 0 && firstLoop) {
+
+ // no savegames found, and we're not restarting.
+
+ setmode();
+ loadpalfromiff();
+
+ } else {
+ // "dodecisions"
+
+ // Savegames found, so ask if we should load one.
+ // (If we're restarting after game over, we also always show these
+ // options.)
+
+ cls();
+ setmode();
+ decide();
+ if (data.byte(kQuitrequested))
+ return; // exit game
+
+ if (data.byte(kGetback) == 4)
+ startNewGame = false; // savegame has been loaded
+
+ }
+
+ firstLoop = false;
+
+ if (startNewGame) {
+ // "playgame"
+
+ titles();
+ if (data.byte(kQuitrequested))
+ return; // exit game
+ credits();
+
+ if (data.byte(kQuitrequested))
+ return; // exit game
+
+ clearchanges();
+ setmode();
+ loadpalfromiff();
+ data.byte(kLocation) = 255;
+ data.byte(kRoomafterdream) = 1;
+ data.byte(kNewlocation) = 35;
+ data.byte(kVolume) = 7;
+ loadroom();
+ clearsprites();
+ initman();
+ entrytexts();
+ entryanims();
+ data.byte(kDestpos) = 3;
+ initialinv();
+ data.byte(kLastflag) = 32;
+ startup1();
+ data.byte(kVolumeto) = 0;
+ data.byte(kVolumedirection) = -1;
+ data.byte(kCommandtype) = 255;
+
+ }
+
+ // main loop
+ while (true) {
+
+ if (data.byte(kQuitrequested))
+ return; // exit game
+
+ screenupdate();
+
+ if (data.byte(kWongame) != 0) {
+ // "endofgame"
+ clearbeforeload();
+ fadescreendowns();
+ cx = 200;
+ hangon();
+ endgame();
+ quickquit2();
+ return;
+ }
+
+ if (data.byte(kMandead) == 1 || data.byte(kMandead) == 2)
+ break;
+
+ if (data.word(kWatchingtime) > 0) {
+ if (data.byte(kFinaldest) == data.byte(kManspath))
+ data.word(kWatchingtime)--;
+ }
+
+ if (data.word(kWatchingtime) == 0) {
+ // "notwatching"
+
+ if (data.byte(kMandead) == 4)
+ break;
+
+ if (data.byte(kNewlocation) != 255) {
+ // "loadnew"
+ clearbeforeload();
+ loadroom();
+ clearsprites();
+ initman();
+ entrytexts();
+ entryanims();
+ data.byte(kNewlocation) = 255;
+ startup();
+ data.byte(kCommandtype) = 255;
+ worktoscreenm();
+ }
+ }
+ }
+
+ // "gameover"
+ clearbeforeload();
+ showgun();
+ fadescreendown();
+ cx = 100;
+ hangon();
+
+ }
+}
+
Common::String getFilename(Context &context) {
uint16 name_ptr = context.dx;
Common::String name;
@@ -36,8 +184,10 @@ Common::String getFilename(Context &context) {
}
void DreamGenContext::multiget() {
- unsigned w = (uint8)cl, h = (uint8)ch;
- unsigned x = (uint16)di, y = (uint16)bx;
+ multiget(di, bx, cl, ch);
+}
+
+void DreamGenContext::multiget(uint16 x, uint16 y, uint8 w, uint8 h) {
unsigned src = x + y * kScreenwidth;
unsigned dst = (uint16)si;
es = ds;
@@ -58,8 +208,10 @@ void DreamGenContext::multiget() {
}
void DreamGenContext::multiput() {
- unsigned w = (uint8)cl, h = (uint8)ch;
- unsigned x = (uint16)di, y = (uint16)bx;
+ multiput(di, bx, cl, ch);
+}
+
+void DreamGenContext::multiput(uint16 x, uint16 y, uint8 w, uint8 h) {
unsigned src = (uint16)si;
unsigned dst = x + y * kScreenwidth;
es = data.word(kWorkspace);
@@ -78,14 +230,17 @@ void DreamGenContext::multiput() {
cx = 0;
}
-void DreamGenContext::multidump() {
+void DreamGenContext::multidump(uint16 x, uint16 y, uint8 width, uint8 height) {
ds = data.word(kWorkspace);
- int w = (uint8)cl, h = (uint8)ch;
- int x = (int16)di, y = (int16)bx;
unsigned offset = x + y * kScreenwidth;
//debug(1, "multidump %ux%u(segment: %04x) -> %d,%d(address: %d)", w, h, (uint16)ds, x, y, offset);
- engine->blit(ds.ptr(offset, w * h), kScreenwidth, x, y, w, h);
- si = di = offset + h * kScreenwidth;
+ engine->blit(ds.ptr(offset, width * height), kScreenwidth, x, y, width, height);
+}
+
+void DreamGenContext::multidump() {
+ multidump(di, bx, cl, ch);
+ unsigned offset = di + bx * kScreenwidth;
+ si = di = offset + ch * kScreenwidth;
cx = 0;
}
@@ -105,7 +260,7 @@ void DreamGenContext::cls() {
engine->cls();
}
-void DreamGenContext::frameoutnm(uint8* dst, const uint8* src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) {
+void DreamGenContext::frameoutnm(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) {
dst += pitch * y + x;
for (uint16 j = 0; j < height; ++j) {
@@ -115,7 +270,7 @@ void DreamGenContext::frameoutnm(uint8* dst, const uint8* src, uint16 pitch, uin
}
}
-void DreamGenContext::frameoutbh(uint8* dst, const uint8* src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) {
+void DreamGenContext::frameoutbh(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) {
uint16 stride = pitch - width;
dst += y * pitch + x;
@@ -131,7 +286,7 @@ void DreamGenContext::frameoutbh(uint8* dst, const uint8* src, uint16 pitch, uin
}
}
-void DreamGenContext::frameoutfx(uint8* dst, const uint8* src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) {
+void DreamGenContext::frameoutfx(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) {
uint16 stride = pitch - width;
dst += y * pitch + x;
dst -= width;
@@ -239,12 +394,26 @@ void DreamGenContext::setmouse() {
data.word(kOldpointerx) = 0xffff;
}
-uint8 DreamGenContext::getnextword(uint8 *totalWidth, uint8 *charCount) {
+void DreamGenContext::printboth() {
+ uint16 x = di;
+ printboth(es, ds, &x, bx, al);
+ di = x;
+}
+
+void DreamGenContext::printboth(uint16 dst, uint16 src, uint16 *x, uint16 y, uint8 c) {
+ uint16 newX = *x;
+ uint8 width, height;
+ printchar(dst, src, &newX, y, c, &width, &height);
+ multidump(*x, y, width, height);
+ *x = newX;
+}
+
+uint8 DreamGenContext::getnextword(const uint8 *string, uint8 *totalWidth, uint8 *charCount) {
*totalWidth = 0;
*charCount = 0;
while(true) {
- uint8 firstChar = es.byte(di);
- ++di;
+ uint8 firstChar = *string;
+ ++string;
++*charCount;
if ((firstChar == ':') || (firstChar == 0)) { //endall
*totalWidth += 6;
@@ -256,7 +425,7 @@ uint8 DreamGenContext::getnextword(uint8 *totalWidth, uint8 *charCount) {
}
firstChar = engine->modifyChar(firstChar);
if (firstChar != 255) {
- uint8 secondChar = es.byte(di);
+ uint8 secondChar = *string;
uint8 width = ds.byte(6*(firstChar - 32 + data.word(kCharshift)));
width = kernchars(firstChar, secondChar, width);
*totalWidth += width;
@@ -266,9 +435,225 @@ uint8 DreamGenContext::getnextword(uint8 *totalWidth, uint8 *charCount) {
void DreamGenContext::getnextword() {
uint8 totalWidth, charCount;
- al = getnextword(&totalWidth, &charCount);
+ al = getnextword(es.ptr(di, 0), &totalWidth, &charCount);
bl = totalWidth;
- bh = charCount;
+ bh = charCount;
+ di += charCount;
+}
+
+void DreamGenContext::printchar() {
+ uint16 x = di;
+ uint8 width, height;
+ printchar(es, ds, &x, bx, al, &width, &height);
+ di = x;
+ cl = width;
+ ch = height;
+}
+
+void DreamGenContext::printchar(uint16 dst, uint16 src, uint16* x, uint16 y, uint8 c, uint8 *width, uint8 *height) {
+ if (c == 255)
+ return;
+ push(si);
+ push(di);
+ push(ax);
+ if (data.byte(kForeignrelease) != 0)
+ y -= 3;
+ showframe(dst, src, *x, y, c - 32 + data.word(kCharshift), 0, width, height);
+ ax = pop();
+ di = pop();
+ si = pop();
+ _cmp(data.byte(kKerning), 0);
+ if (flags.z())
+ *width = kernchars(c, ah, *width);
+ (*x) += *width;
+}
+
+void DreamGenContext::printslow() {
+ al = printslow(di, bx, dl, (bool)(dl & 1));
+}
+
+void DreamGenContext::dumptextline() {
+ if (data.byte(kNewtextline) != 1)
+ return;
+ data.byte(kNewtextline) = 0;
+ uint16 x = data.word(kTextaddressx);
+ uint16 y = data.word(kTextaddressy);
+ if (data.byte(kForeignrelease) != 0)
+ y -= 3;
+ multidump(x, y, 228, 13);
+}
+
+uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool centered) {
+ data.byte(kPointerframe) = 1;
+ data.byte(kPointermode) = 3;
+ ds = data.word(kCharset1);
+ do {
+ uint16 offset = x;
+ uint16 charCount = getnumber(si, maxWidth, centered, &offset);
+ do {
+ push(si);
+ push(es);
+ uint8 c0 = es.byte(si);
+ push(es);
+ push(ds);
+ c0 = engine->modifyChar(c0);
+ printboth(es, ds, &offset, y, c0);
+ ds = pop();
+ es = pop();
+ uint8 c1 = es.byte(si+1);
+ ++si;
+ if ((c1 == 0) || (c1 == ':')) {
+ es = pop();
+ si = pop();
+ return 0;
+ }
+ if (charCount != 1) {
+ push(ds);
+ push(es);
+ c1 = engine->modifyChar(c1);
+ data.word(kCharshift) = 91;
+ uint16 offset2 = offset;
+ printboth(es, ds, &offset2, y, c1);
+ data.word(kCharshift) = 0;
+ es = pop();
+ ds = pop();
+ for (int i=0; i<2; ++i) {
+ waitframes();
+ if (ax == 0)
+ continue;
+ if (ax != data.word(kOldbutton)) {
+ es = pop();
+ si = pop();
+ return 1;
+ }
+ }
+ }
+
+ es = pop();
+ si = pop();
+ ++si;
+ --charCount;
+ } while (charCount);
+ y += 10;
+ } while (true);
+}
+
+void DreamGenContext::printdirect() {
+ uint16 y = bx;
+ printdirect(di, &y, dl, (bool)(dl & 1));
+ bx = y;
+}
+
+void DreamGenContext::printdirect(uint16 x, uint16 *y, uint8 maxWidth, bool centered) {
+ data.word(kLastxpos) = x;
+ ds = data.word(kCurrentset);
+ while (true) {
+ uint16 offset = x;
+ uint8 charCount = getnumber(si, maxWidth, centered, &offset);
+ uint16 i = offset;
+ do {
+ uint8 c = es.byte(si);
+ ++si;
+ if ((c == 0) || (c == ':')) {
+ return;
+ }
+ c = engine->modifyChar(c);
+ ah = es.byte(si); // get next char for kerning
+ uint8 width, height;
+ push(es);
+ printchar(es, ds, &i, *y, c, &width, &height);
+ es = pop();
+ data.word(kLastxpos) = i;
+ --charCount;
+ } while(charCount);
+ *y += data.word(kLinespacing);
+ }
+}
+
+void DreamGenContext::getundertimed() {
+ uint16 y = data.byte(kTimedy);
+ if (data.byte(kForeignrelease))
+ y -= 3;
+ ds = data.word(kBuffers);
+ si = kUndertimedtext;
+ multiget(data.byte(kTimedx), y, 240, kUndertimedysize);
+}
+
+void DreamGenContext::putundertimed() {
+ uint16 y = data.byte(kTimedy);
+ if (data.byte(kForeignrelease))
+ y -= 3;
+ ds = data.word(kBuffers);
+ si = kUndertimedtext;
+ multiput(data.byte(kTimedx), y, 240, kUndertimedysize);
+}
+
+void DreamGenContext::usetimedtext() {
+ if (data.word(kTimecount) == 0)
+ return;
+ --data.word(kTimecount);
+ if (data.word(kTimecount) == 0) {
+ putundertimed();
+ data.byte(kNeedtodumptimed) = 1;
+ return;
+ }
+
+ if (data.word(kTimecount) == data.word(kCounttotimed))
+ getundertimed();
+ else if (data.word(kTimecount) > data.word(kCounttotimed))
+ return;
+
+ es = data.word(kTimedseg);
+ si = data.word(kTimedoffset);
+ uint16 y = data.byte(kTimedy);
+ printdirect(data.byte(kTimedx), &y, 237, true);
+ data.byte(kNeedtodumptimed) = 1;
+}
+
+void DreamGenContext::getnumber() {
+ uint16 offset = di;
+ cl = getnumber(si, dl, (bool)(dl & 1), &offset);
+ di = offset;
+}
+
+uint8 DreamGenContext::getnumber(uint16 index, uint16 maxWidth, bool centered, uint16* offset) {
+ uint8 totalWidth = 0;
+ uint8 charCount = 0;
+ while (true) {
+ uint8 wordTotalWidth, wordCharCount;
+ uint8 done = getnextword(es.ptr(index, 0), &wordTotalWidth, &wordCharCount);
+ index += wordCharCount;
+
+ if (done == 1) { //endoftext
+ ax = totalWidth + wordTotalWidth - 10;
+ if (ax < maxWidth) {
+ totalWidth += wordTotalWidth;
+ charCount += wordCharCount;
+ }
+
+ if (centered) {
+ ax = (maxWidth & 0xfe) + 2 + 20 - totalWidth;
+ ax /= 2;
+ } else {
+ ax = 0;
+ }
+ *offset += ax;
+ return charCount;
+ }
+ ax = totalWidth + wordTotalWidth - 10;
+ if (ax >= maxWidth) { //gotoverend
+ if (centered) {
+ ax = (maxWidth & 0xfe) - totalWidth + 20;
+ ax /= 2;
+ } else {
+ ax = 0;
+ }
+ *offset += ax;
+ return charCount;
+ }
+ totalWidth += wordTotalWidth;
+ charCount += wordCharCount;
+ }
}
uint8 DreamGenContext::kernchars(uint8 firstChar, uint8 secondChar, uint8 width) {
@@ -522,7 +907,7 @@ void DreamGenContext::doshake() {
1, -3, 3, 0,
};
int offset = shakeTable[counter];
- engine->setShakePos(offset >= 0? offset: -offset);
+ engine->setShakePos(offset >= 0 ? offset : -offset);
}
void DreamGenContext::vsync() {
@@ -626,14 +1011,14 @@ void DreamGenContext::frameoutv() {
uint16 width = cx & 0xff;
uint16 height = cx >> 8;
- const uint8* src = ds.ptr(si, width * height);
- uint8* dst = es.ptr(0, pitch * height);
+ const uint8 *src = ds.ptr(si, width * height);
+ uint8 *dst = es.ptr(0, pitch * height);
frameoutv(dst, src, pitch, width, height, di, bx);
}
*/
-void DreamGenContext::frameoutv(uint8* dst, const uint8* src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) {
+void DreamGenContext::frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) {
// NB : These resilience checks were not in the original engine, but did they result in undefined behaviour
// or was something broken during porting to C++?
assert(pitch == 320);
@@ -663,13 +1048,13 @@ void DreamGenContext::frameoutv(uint8* dst, const uint8* src, uint16 pitch, uint
}
}
-Sprite* DreamGenContext::spritetable() {
+Sprite *DreamGenContext::spritetable() {
push(es);
push(bx);
es = data.word(kBuffers);
bx = kSpritetable;
- Sprite *sprite = (Sprite*)es.ptr(bx, 16*sizeof(Sprite));
+ Sprite *sprite = (Sprite *)es.ptr(bx, 16 * sizeof(Sprite));
bx = pop();
es = pop();
@@ -677,39 +1062,43 @@ Sprite* DreamGenContext::spritetable() {
return sprite;
}
-uint16 DreamGenContext::showframeCPP(uint16 dst, uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag) {
+void DreamGenContext::showframe(uint16 dst, uint16 src, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) {
+ // frameNumber takes up 9 bits of ax, and effectsFlag 7.
+ assert(!(effectsFlag & 1));
+
es = dst;
ds = src;
di = x;
bx = y;
- al = frameNumber;
- ah = effectsFlag;
+ ax = frameNumber | (effectsFlag << 8);
+
si = (ax & 0x1ff) * 6;
if (ds.word(si) == 0) {
- return 0;
+ *width = 0;
+ *height = 0;
+ return;
}
//notblankshow:
if ((effectsFlag & 128) == 0) {
- di += ds.byte(si+4);
- bx += ds.byte(si+5);
+ di += ds.byte(si + 4);
+ bx += ds.byte(si + 5);
}
//skipoffsets:
- cx = ds.word(si+0);
- uint8 width = cl;
- uint8 height = ch;
- uint16 written = cx;
+ cx = ds.word(si + 0);
+ *width = cl;
+ *height = ch;
si = ds.word(si+2) + 2080;
if (effectsFlag) {
if (effectsFlag & 128) { //centred
- di -= width / 2;
- bx -= height / 2;
+ di -= *width / 2;
+ bx -= *height / 2;
}
if (effectsFlag & 64) { //diffdest
- frameoutfx(es.ptr(0, dx * height), ds.ptr(si, width * height), dx, width, height, di, bx);
- return written;
+ frameoutfx(es.ptr(0, dx * *height), ds.ptr(si, *width * *height), dx, *width, *height, di, bx);
+ return;
}
if (effectsFlag & 8) { //printlist
push(ax);
@@ -723,28 +1112,31 @@ uint16 DreamGenContext::showframeCPP(uint16 dst, uint16 src, uint16 x, uint16 y,
}
if (effectsFlag & 4) { //flippedx
es = data.word(kWorkspace);
- frameoutfx(es.ptr(0, 320 * height), ds.ptr(si, width * height), 320, width, height, di, bx);
- return written;
+ frameoutfx(es.ptr(0, 320 * *height), ds.ptr(si, *width * *height), 320, *width, *height, di, bx);
+ return;
}
if (effectsFlag & 2) { //nomask
es = data.word(kWorkspace);
- frameoutnm(es.ptr(0, 320 * height), ds.ptr(si, width * height), 320, width, height, di, bx);
- return written;
+ frameoutnm(es.ptr(0, 320 * *height), ds.ptr(si, *width * *height), 320, *width, *height, di, bx);
+ return;
}
if (effectsFlag & 32) {
es = data.word(kWorkspace);
- frameoutbh(es.ptr(0, 320 * height), ds.ptr(si, width * height), 320, width, height, di, bx);
- return written;
+ frameoutbh(es.ptr(0, 320 * *height), ds.ptr(si, *width * *height), 320, *width, *height, di, bx);
+ return;
}
}
//noeffects:
es = data.word(kWorkspace);
- frameoutv(es.ptr(0, 65536), ds.ptr(si, width * height), 320, width, height, di, bx);
- return written;
+ frameoutv(es.ptr(0, 65536), ds.ptr(si, *width * *height), 320, *width, *height, di, bx);
+ return;
}
void DreamGenContext::showframe() {
- cx = showframeCPP(es, ds, di, bx, al, ah);
+ uint8 width, height;
+ showframe(es, ds, di, bx, ax & 0x1ff, ah & 0xfe, &width, &height);
+ cl = width;
+ ch = height;
}
void DreamGenContext::printsprites() {
@@ -763,7 +1155,7 @@ void DreamGenContext::printsprites() {
}
}
-void DreamGenContext::printasprite(const Sprite* sprite) {
+void DreamGenContext::printasprite(const Sprite *sprite) {
push(es);
push(bx);
ds = READ_LE_UINT16(&sprite->w6);
@@ -781,10 +1173,15 @@ void DreamGenContext::printasprite(const Sprite* sprite) {
di = ax + data.word(kMapadx);
}
- ax = sprite->b15;
+ uint8 c;
if (sprite->b29 != 0)
- ah = 8;
- showframe();
+ c = 8;
+ else
+ c = 0;
+ uint8 width, height;
+ showframe(es, ds, di, bx, sprite->b15, c, &width, &height);
+ cl = width;
+ ch = height;
bx = pop();
es = pop();
@@ -795,7 +1192,7 @@ void DreamGenContext::eraseoldobs() {
return;
Sprite *sprites = spritetable();
- for (size_t i=0; i<16; ++i) {
+ for (size_t i=0; i < 16; ++i) {
Sprite &sprite = sprites[i];
if (READ_LE_UINT16(&sprite.obj_data) != 0xffff) {
memset(&sprite, 0xff, sizeof(Sprite));
@@ -804,10 +1201,10 @@ void DreamGenContext::eraseoldobs() {
}
void DreamGenContext::clearsprites() {
- memset(spritetable(), 0xff, sizeof(Sprite)*16);
+ memset(spritetable(), 0xff, sizeof(Sprite) * 16);
}
-Sprite* DreamGenContext::makesprite(uint8 x, uint8 y, uint16 updateCallback, uint16 somethingInDx, uint16 somethingInDi) {
+Sprite *DreamGenContext::makesprite(uint8 x, uint8 y, uint16 updateCallback, uint16 somethingInDx, uint16 somethingInDi) {
Sprite *sprite = spritetable();
while (sprite->b15 != 0xff) { // NB: No boundchecking in the original code either
++sprite;
@@ -830,8 +1227,8 @@ void DreamGenContext::makesprite() { // NB: returns new sprite in es:bx
// Recover es:bx from sprite
es = data.word(kBuffers);
bx = kSpritetable;
- Sprite *sprites = (Sprite*)es.ptr(bx, sizeof(Sprite)*16);
- bx += sizeof(Sprite)*(sprite-sprites);
+ Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16);
+ bx += sizeof(Sprite) * (sprite - sprites);
//
}
@@ -840,7 +1237,7 @@ void DreamGenContext::spriteupdate() {
sprites[0].hidden = data.byte(kRyanon);
Sprite *sprite = sprites;
- for (size_t i=0; i<16; ++i) {
+ for (size_t i=0; i < 16; ++i) {
uint16 updateCallback = READ_LE_UINT16(&sprite->updateCallback);
if (updateCallback != 0xffff) {
sprite->w24 = sprite->w2;
@@ -867,20 +1264,20 @@ void DreamGenContext::initman() {
// Recover es:bx from sprite
es = data.word(kBuffers);
bx = kSpritetable;
- Sprite *sprites = (Sprite*)es.ptr(bx, sizeof(Sprite)*16);
- bx += 32*(sprite-sprites);
+ Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16);
+ bx += 32 * (sprite - sprites);
//
}
-void DreamGenContext::mainmanCPP(Sprite* sprite) {
+void DreamGenContext::mainmanCPP(Sprite *sprite) {
push(es);
push(ds);
// Recover es:bx from sprite
es = data.word(kBuffers);
bx = kSpritetable;
- Sprite *sprites = (Sprite*)es.ptr(bx, sizeof(Sprite)*16);
- bx += 32*(sprite-sprites);
+ Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16);
+ bx += 32 * (sprite - sprites);
//
if (data.byte(kResetmanxy) == 1) {
@@ -937,7 +1334,7 @@ void DreamGenContext::mainmanCPP(Sprite* sprite) {
}
void DreamGenContext::walking() {
- Sprite *sprite = (Sprite*)es.ptr(bx, sizeof(Sprite));
+ Sprite *sprite = (Sprite *)es.ptr(bx, sizeof(Sprite));
uint8 comp;
if (data.byte(kLinedirection) != 0) {
@@ -967,51 +1364,54 @@ void DreamGenContext::walking() {
es = pop();
}
-void DreamGenContext::aboutturn(Sprite* sprite) {
+void DreamGenContext::aboutturn(Sprite *sprite) {
+ bool incdir = true;
+
if (data.byte(kTurndirection) == 1)
- goto incdir;
+ incdir = true;
else if ((int8)data.byte(kTurndirection) == -1)
- goto decdir;
+ incdir = false;
else {
if (data.byte(kFacing) < data.byte(kTurntoface)) {
uint8 delta = data.byte(kTurntoface) - data.byte(kFacing);
if (delta >= 4)
- goto decdir;
+ incdir = false;
else
- goto incdir;
+ incdir = true;
} else {
uint8 delta = data.byte(kFacing) - data.byte(kTurntoface);
if (delta >= 4)
- goto incdir;
+ incdir = true;
else
- goto decdir;
+ incdir = false;
}
}
-incdir:
- data.byte(kTurndirection) = 1;
- data.byte(kFacing) = (data.byte(kFacing) + 1) & 7;
- sprite->b29 = 0;
- return;
-decdir:
- data.byte(kTurndirection) = -1;
- data.byte(kFacing) = (data.byte(kFacing) - 1) & 7;
- sprite->b29 = 0;
+
+ if (incdir) {
+ data.byte(kTurndirection) = 1;
+ data.byte(kFacing) = (data.byte(kFacing) + 1) & 7;
+ sprite->b29 = 0;
+ } else {
+ data.byte(kTurndirection) = -1;
+ data.byte(kFacing) = (data.byte(kFacing) - 1) & 7;
+ sprite->b29 = 0;
+ }
}
-void DreamGenContext::backobject(Sprite* sprite) {
+void DreamGenContext::backobject(Sprite *sprite) {
push(es);
push(ds);
// Recover es:bx from sprite
es = data.word(kBuffers);
bx = kSpritetable;
- Sprite *sprites = (Sprite*)es.ptr(bx, sizeof(Sprite)*16);
- bx += 32*(sprite-sprites);
+ Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16);
+ bx += 32 * (sprite - sprites);
//
ds = data.word(kSetdat);
di = READ_LE_UINT16(&sprite->obj_data);
- ObjData* objData = (ObjData*)ds.ptr(di, 0);
+ ObjData *objData = (ObjData *)ds.ptr(di, 0);
if (sprite->delay != 0) {
--sprite->delay;
@@ -1040,7 +1440,7 @@ void DreamGenContext::backobject(Sprite* sprite) {
es = pop();
}
-void DreamGenContext::constant(Sprite* sprite, ObjData* objData) {
+void DreamGenContext::constant(Sprite *sprite, ObjData *objData) {
++sprite->frame;
if (objData->b18[sprite->frame] == 255) {
sprite->frame = 0;
@@ -1050,13 +1450,13 @@ void DreamGenContext::constant(Sprite* sprite, ObjData* objData) {
sprite->b15 = b18;
}
-void DreamGenContext::random(Sprite* sprite, ObjData* objData) {
+void DreamGenContext::random(Sprite *sprite, ObjData *objData) {
randomnum1();
uint16 r = ax;
sprite->b15 = objData->b18[r&7];
}
-void DreamGenContext::doorway(Sprite* sprite, ObjData* objData) {
+void DreamGenContext::doorway(Sprite *sprite, ObjData *objData) {
data.byte(kDoorcheck1) = -24;
data.byte(kDoorcheck2) = 10;
data.byte(kDoorcheck3) = -30;
@@ -1064,7 +1464,7 @@ void DreamGenContext::doorway(Sprite* sprite, ObjData* objData) {
dodoor(sprite, objData);
}
-void DreamGenContext::widedoor(Sprite* sprite, ObjData* objData) {
+void DreamGenContext::widedoor(Sprite *sprite, ObjData *objData) {
data.byte(kDoorcheck1) = -24;
data.byte(kDoorcheck2) = 24;
data.byte(kDoorcheck3) = -30;
@@ -1073,12 +1473,12 @@ void DreamGenContext::widedoor(Sprite* sprite, ObjData* objData) {
}
void DreamGenContext::dodoor() {
- Sprite *sprite = (Sprite*)es.ptr(bx, sizeof(Sprite));
- ObjData *objData = (ObjData*)ds.ptr(di, 0);
+ Sprite *sprite = (Sprite *)es.ptr(bx, sizeof(Sprite));
+ ObjData *objData = (ObjData *)ds.ptr(di, 0);
dodoor(sprite, objData);
}
-void DreamGenContext::dodoor(Sprite* sprite, ObjData* objData) {
+void DreamGenContext::dodoor(Sprite *sprite, ObjData *objData) {
uint8 ryanx = data.byte(kRyanx);
uint8 ryany = data.byte(kRyany);
int8 deltax = ryanx - sprite->x;
@@ -1131,7 +1531,7 @@ shutdoor:
data.byte(kThroughdoor) = 0;
}
-void DreamGenContext::steady(Sprite* sprite, ObjData* objData) {
+void DreamGenContext::steady(Sprite *sprite, ObjData *objData) {
uint8 b18 = objData->b18[0];
objData->b17 = b18;
sprite->b15 = b18;
@@ -1156,12 +1556,12 @@ void DreamGenContext::turnpathoffCPP(uint8 param) {
}
void DreamGenContext::liftsprite() {
- Sprite *sprite = (Sprite*)es.ptr(bx, sizeof(Sprite));
- ObjData *objData = (ObjData*)ds.ptr(di, 0);
+ Sprite *sprite = (Sprite *)es.ptr(bx, sizeof(Sprite));
+ ObjData *objData = (ObjData *)ds.ptr(di, 0);
liftsprite(sprite, objData);
}
-void DreamGenContext::liftsprite(Sprite* sprite, ObjData* objData) {
+void DreamGenContext::liftsprite(Sprite *sprite, ObjData *objData) {
uint8 liftFlag = data.byte(kLiftflag);
if (liftFlag == 0) { //liftclosed
turnpathoffCPP(data.byte(kLiftpath));
@@ -1241,5 +1641,18 @@ void DreamGenContext::lockmon() {
}
}
+void DreamGenContext::cancelch0() {
+ data.byte(kCh0repeat) = 0;
+ data.word(kCh0blockstocopy) = 0;
+ data.byte(kCh0playing) = 255;
+ engine->stopSound(0);
+}
+
+void DreamGenContext::cancelch1() {
+ data.word(kCh1blockstocopy) = 0;
+ data.byte(kCh1playing) = 255;
+ engine->stopSound(1);
+}
+
} /*namespace dreamgen */
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index a113bf79cd..b633684f4d 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -21,12 +21,14 @@
*/
void multidump();
- void frameoutv(uint8* dst, const uint8* src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
- void frameoutnm(uint8* dst, const uint8* src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
- void frameoutbh(uint8* dst, const uint8* src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
- void frameoutfx(uint8* dst, const uint8* src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
+ void multidump(uint16 x, uint16 y, uint8 width, uint8 height);
+ void frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
+ void frameoutnm(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
+ void frameoutbh(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
+ void frameoutfx(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
void worktoscreen();
void multiget();
+ void multiget(uint16 x, uint16 y, uint8 width, uint8 height);
void convertkey();
void cls();
void printsprites();
@@ -37,36 +39,52 @@
void randomnumber();
void quickquit2();
void getnextword();
- uint8 getnextword(uint8 *totalWidth, uint8 *charCount);
+ uint8 getnextword(const uint8 *string, uint8 *totalWidth, uint8 *charCount);
+ void printboth();
+ void printboth(uint16 dst, uint16 src, uint16 *x, uint16 y, uint8 c);
+ void printchar();
+ void printchar(uint16 dst, uint16 src, uint16 *x, uint16 y, uint8 c, uint8 *width, uint8 *height);
+ void printdirect();
+ void printdirect(uint16 x, uint16 *y, uint8 maxWidth, bool centered);
+ void usetimedtext();
+ void getundertimed();
+ void putundertimed();
+ uint8 printslow(uint16 x, uint16 y, uint8 maxWidth, bool centered);
+ void printslow();
+ void dumptextline();
+ void getnumber();
+ uint8 getnumber(uint16 index, uint16 maxWidth, bool centered, uint16* offset);
void kernchars();
uint8 kernchars(uint8 firstChar, uint8 secondChar, uint8 width);
- Sprite* spritetable();
+ Sprite *spritetable();
void showframe();
- uint16 showframeCPP(uint16 dst, uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag);
- void printasprite(const Sprite* sprite);
+ void showframe(uint16 dst, uint16 src, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height);
+ void printasprite(const Sprite *sprite);
void width160();
+ void multiput(uint16 x, uint16 y, uint8 width, uint8 height);
void multiput();
void eraseoldobs();
void clearsprites();
void makesprite();
- Sprite* makesprite(uint8 x, uint8 y, uint16 updateCallback, uint16 somethingInDx, uint16 somethingInDi);
+ Sprite *makesprite(uint8 x, uint8 y, uint16 updateCallback, uint16 somethingInDx, uint16 somethingInDi);
void spriteupdate();
void initman();
- void mainmanCPP(Sprite* sprite);
+ void mainmanCPP(Sprite *sprite);
void walking();
- void aboutturn(Sprite* sprite);
- void backobject(Sprite* sprite);
- void constant(Sprite* sprite, ObjData* objData);
- void steady(Sprite* sprite, ObjData* objData);
- void random(Sprite* sprite, ObjData* objData);
+ void aboutturn(Sprite *sprite);
+ void backobject(Sprite *sprite);
+ void constant(Sprite *sprite, ObjData *objData);
+ void steady(Sprite *sprite, ObjData *objData);
+ void random(Sprite *sprite, ObjData *objData);
void dodoor();
- void dodoor(Sprite* sprite, ObjData* objData);
- void doorway(Sprite* sprite, ObjData* objData);
- void widedoor(Sprite* sprite, ObjData* objData);
+ void dodoor(Sprite *sprite, ObjData *objData);
+ void doorway(Sprite *sprite, ObjData *objData);
+ void widedoor(Sprite *sprite, ObjData *objData);
void liftsprite();
- void liftsprite(Sprite* sprite, ObjData* objData);
+ void liftsprite(Sprite *sprite, ObjData *objData);
void turnpathonCPP(uint8 param);
void turnpathoffCPP(uint8 param);
void modifychar();
void lockmon();
-
+ void cancelch0();
+ void cancelch1();
diff --git a/engines/engines.mk b/engines/engines.mk
index dc09fbd54e..de11496b7b 100644
--- a/engines/engines.mk
+++ b/engines/engines.mk
@@ -31,6 +31,11 @@ DEFINES += -DENABLE_CINE=$(ENABLE_CINE)
MODULES += engines/cine
endif
+ifdef ENABLE_COMPOSER
+DEFINES += -DENABLE_COMPOSER=$(ENABLE_COMPOSER)
+MODULES += engines/composer
+endif
+
ifdef ENABLE_CRUISE
DEFINES += -DENABLE_CRUISE=$(ENABLE_CRUISE)
MODULES += engines/cruise
diff --git a/engines/gob/inter.h b/engines/gob/inter.h
index 78d5e34271..b1689e8d9e 100644
--- a/engines/gob/inter.h
+++ b/engines/gob/inter.h
@@ -477,9 +477,14 @@ protected:
virtual void setupOpcodesGob();
void o3_getTotTextItemPart(OpFuncParams &params);
+ void o3_speakerOn(OpFuncParams &params);
+ void o3_speakerOff(OpFuncParams &params);
void o3_copySprite(OpFuncParams &params);
void o3_wobble(OpGobParams &params);
+
+private:
+ bool _ignoreSpeakerOff;
};
class Inter_Inca2 : public Inter_v3 {
diff --git a/engines/gob/inter_v3.cpp b/engines/gob/inter_v3.cpp
index 47486b0899..edf56012d9 100644
--- a/engines/gob/inter_v3.cpp
+++ b/engines/gob/inter_v3.cpp
@@ -31,6 +31,7 @@
#include "gob/game.h"
#include "gob/script.h"
#include "gob/resources.h"
+#include "gob/sound/sound.h"
namespace Gob {
@@ -39,7 +40,7 @@ namespace Gob {
#define OPCODEFUNC(i, x) _opcodesFunc[i]._OPCODEFUNC(OPCODEVER, x)
#define OPCODEGOB(i, x) _opcodesGob[i]._OPCODEGOB(OPCODEVER, x)
-Inter_v3::Inter_v3(GobEngine *vm) : Inter_v2(vm) {
+Inter_v3::Inter_v3(GobEngine *vm) : Inter_v2(vm), _ignoreSpeakerOff(false) {
}
void Inter_v3::setupOpcodesDraw() {
@@ -50,6 +51,8 @@ void Inter_v3::setupOpcodesFunc() {
Inter_v2::setupOpcodesFunc();
OPCODEFUNC(0x1A, o3_getTotTextItemPart);
+ OPCODEFUNC(0x22, o3_speakerOn);
+ OPCODEFUNC(0x23, o3_speakerOff);
OPCODEFUNC(0x32, o3_copySprite);
}
@@ -245,6 +248,36 @@ void Inter_v3::o3_getTotTextItemPart(OpFuncParams &params) {
delete textItem;
}
+void Inter_v3::o3_speakerOn(OpFuncParams &params) {
+ int16 frequency = _vm->_game->_script->readValExpr();
+ int32 length = -1;
+
+ _ignoreSpeakerOff = false;
+
+ // WORKAROUND: This is the footsteps sound. The scripts just fire
+ // speaker on" and then a "speaker off" after a short while. Since
+ // we have delay in certain places avoid 100% CPU all the time and
+ // our PC speaker emulator sometimes "swallows" very short beeper
+ // bursts issued in this way, this is in general quite wonky and
+ // prone to fail, as can be seen in bug report #3376547. Therefore,
+ // we explicitely set a length in this case and ignore the next
+ // speaker off command.
+ if (frequency == 50) {
+ length = 5;
+
+ _ignoreSpeakerOff = true;
+ }
+
+ _vm->_sound->speakerOn(frequency, length);
+}
+
+void Inter_v3::o3_speakerOff(OpFuncParams &params) {
+ if (!_ignoreSpeakerOff)
+ _vm->_sound->speakerOff();
+
+ _ignoreSpeakerOff = false;
+}
+
void Inter_v3::o3_copySprite(OpFuncParams &params) {
o1_copySprite(params);
diff --git a/engines/gob/scenery.cpp b/engines/gob/scenery.cpp
index bb50818ed8..33fdfcaa2a 100644
--- a/engines/gob/scenery.cpp
+++ b/engines/gob/scenery.cpp
@@ -622,7 +622,7 @@ void Scenery::updateAnim(int16 layer, int16 frame, int16 animation, int16 flags,
if (frame >= (int32)_vm->_vidPlayer->getFrameCount(obj.videoSlot - 1))
frame = _vm->_vidPlayer->getFrameCount(obj.videoSlot - 1) - 1;
- if (_vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1) >= 255) {
+ if ((int32)_vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1) >= 255) {
// Allow for object videos with more than 255 frames, although the
// object frame counter is just a byte.
diff --git a/engines/kyra/detection_tables.h b/engines/kyra/detection_tables.h
index 165eddf599..c224c8f46d 100644
--- a/engines/kyra/detection_tables.h
+++ b/engines/kyra/detection_tables.h
@@ -21,38 +21,41 @@
namespace {
-#define FLAGS(x, y, z, a, b, c, d, id) { Common::UNK_LANG, Common::UNK_LANG, Common::UNK_LANG, Common::kPlatformUnknown, x, y, z, a, b, c, d, id }
-#define FLAGS_FAN(fanLang, repLang, x, y, z, a, b, c, d, id) { Common::UNK_LANG, fanLang, repLang, Common::kPlatformUnknown, x, y, z, a, b, c, d, id }
-
-#define KYRA1_FLOPPY_FLAGS FLAGS(false, false, false, false, false, false, false, Kyra::GI_KYRA1)
-#define KYRA1_FLOPPY_CMP_FLAGS FLAGS(false, false, false, false, false, false, true, Kyra::GI_KYRA1)
-#define KYRA1_AMIGA_FLAGS FLAGS(false, false, false, false, false, false, false, Kyra::GI_KYRA1)
-#define KYRA1_TOWNS_FLAGS FLAGS(false, true, false, false, false, false, false, Kyra::GI_KYRA1)
-#define KYRA1_TOWNS_SJIS_FLAGS FLAGS(false, true, false, true, false, false, false, Kyra::GI_KYRA1)
-#define KYRA1_CD_FLAGS FLAGS(false, true, true, false, false, false, false, Kyra::GI_KYRA1)
-#define KYRA1_DEMO_FLAGS FLAGS(true, false, false, false, false, false, false, Kyra::GI_KYRA1)
-#define KYRA1_DEMO_CD_FLAGS FLAGS(true, true, true, false, false, false, false, Kyra::GI_KYRA1)
-
-#define KYRA2_FLOPPY_FLAGS FLAGS(false, false, false, false, false, false, false, Kyra::GI_KYRA2)
-#define KYRA2_FLOPPY_CMP_FLAGS FLAGS(false, false, false, false, false, false, true, Kyra::GI_KYRA2)
-#define KYRA2_CD_FLAGS FLAGS(false, false, true, false, false, false, false, Kyra::GI_KYRA2)
-#define KYRA2_CD_FAN_FLAGS(x, y) FLAGS_FAN(x, y, false, false, true, false, false, false, false, Kyra::GI_KYRA2)
-#define KYRA2_CD_DEMO_FLAGS FLAGS(true, false, true, false, false, false, false, Kyra::GI_KYRA2)
-#define KYRA2_DEMO_FLAGS FLAGS(true, false, false, false, false, false, false, Kyra::GI_KYRA2)
-#define KYRA2_TOWNS_FLAGS FLAGS(false, false, false, false, false, false, false, Kyra::GI_KYRA2)
-#define KYRA2_TOWNS_SJIS_FLAGS FLAGS(false, false, false, true, false, false, false, Kyra::GI_KYRA2)
-
-#define KYRA3_CD_FLAGS FLAGS(false, false, true, false, false, true, true, Kyra::GI_KYRA3)
-#define KYRA3_CD_INS_FLAGS FLAGS(false, false, true, false, false, true, false, Kyra::GI_KYRA3)
-#define KYRA3_CD_FAN_FLAGS(x, y) FLAGS_FAN(x, y, false, false, true, false, false, true, false, Kyra::GI_KYRA3)
-
-#define LOL_CD_FLAGS FLAGS(false, false, true, false, false, false, false, Kyra::GI_LOL)
-#define LOL_CD_FAN_FLAGS(x, y) FLAGS_FAN(x, y, false, false, true, false, false, false, false, Kyra::GI_LOL)
-#define LOL_FLOPPY_FLAGS FLAGS(false, false, false, false, false, false, false, Kyra::GI_LOL)
-#define LOL_FLOPPY_CMP_FLAGS FLAGS(false, false, false, false, false, false, true, Kyra::GI_LOL)
-#define LOL_PC98_SJIS_FLAGS FLAGS(false, false, false, true, true, false, false, Kyra::GI_LOL)
-#define LOL_DEMO_FLAGS FLAGS(true, true, false, false, false, false, false, Kyra::GI_LOL)
-#define LOL_KYRA2_DEMO_FLAGS FLAGS(true, false, false, false, false, false, false, Kyra::GI_KYRA2)
+#define FLAGS(x, y, z, a, b, c, d, e, id) { Common::UNK_LANG, Common::UNK_LANG, Common::UNK_LANG, Common::kPlatformUnknown, x, y, z, a, b, c, d, e, id }
+#define FLAGS_FAN(fanLang, repLang, x, y, z, a, b, c, d, e, id) { Common::UNK_LANG, fanLang, repLang, Common::kPlatformUnknown, x, y, z, a, b, c, d, e, id }
+
+#define KYRA1_FLOPPY_FLAGS FLAGS(false, false, false, false, false, false, false, false, Kyra::GI_KYRA1)
+#define KYRA1_FLOPPY_CMP_FLAGS FLAGS(false, false, false, false, false, false, false, true, Kyra::GI_KYRA1)
+#define KYRA1_OLDFLOPPY_FLAGS FLAGS(false, false, false, true, false, false, false, false, Kyra::GI_KYRA1)
+#define KYRA1_AMIGA_FLAGS FLAGS(false, false, false, false, false, false, false, false, Kyra::GI_KYRA1)
+#define KYRA1_TOWNS_FLAGS FLAGS(false, true, false, false, false, false, false, false, Kyra::GI_KYRA1)
+#define KYRA1_TOWNS_SJIS_FLAGS FLAGS(false, true, false, false, true, false, false, false, Kyra::GI_KYRA1)
+#define KYRA1_CD_FLAGS FLAGS(false, true, true, false, false, false, false, false, Kyra::GI_KYRA1)
+#define KYRA1_DEMO_FLAGS FLAGS(true, false, false, false, false, false, false, false, Kyra::GI_KYRA1)
+#define KYRA1_DEMO_CD_FLAGS FLAGS(true, true, true, false, false, false, false, false, Kyra::GI_KYRA1)
+
+#define KYRA2_FLOPPY_FLAGS FLAGS(false, false, false, false, false, false, false, false, Kyra::GI_KYRA2)
+#define KYRA2_FLOPPY_CMP_FLAGS FLAGS(false, false, false, false, false, false, false, true, Kyra::GI_KYRA2)
+#define KYRA2_FLOPPY_FAN_FLAGS(x, y) FLAGS_FAN(x, y, false, false, false, false, false, false, false, false, Kyra::GI_KYRA2)
+#define KYRA2_CD_FLAGS FLAGS(false, false, true, false, false, false, false, false, Kyra::GI_KYRA2)
+#define KYRA2_CD_FAN_FLAGS(x, y) FLAGS_FAN(x, y, false, false, true, false, false, false, false, false, Kyra::GI_KYRA2)
+#define KYRA2_CD_DEMO_FLAGS FLAGS(true, false, true, false, false, false, false, false, Kyra::GI_KYRA2)
+#define KYRA2_DEMO_FLAGS FLAGS(true, false, false, false, false, false, false, false, Kyra::GI_KYRA2)
+#define KYRA2_TOWNS_FLAGS FLAGS(false, false, false, false, false, false, false, false, Kyra::GI_KYRA2)
+#define KYRA2_TOWNS_SJIS_FLAGS FLAGS(false, false, false, false, true, false, false, false, Kyra::GI_KYRA2)
+
+#define KYRA3_CD_FLAGS FLAGS(false, false, true, false, false, false, true, true, Kyra::GI_KYRA3)
+#define KYRA3_CD_INS_FLAGS FLAGS(false, false, true, false, false, false, true, false, Kyra::GI_KYRA3)
+#define KYRA3_CD_FAN_FLAGS(x, y) FLAGS_FAN(x, y, false, false, true, false, false, false, true, false, Kyra::GI_KYRA3)
+
+#define LOL_CD_FLAGS FLAGS(false, false, true, false, false, false, false, false, Kyra::GI_LOL)
+#define LOL_CD_FAN_FLAGS(x, y) FLAGS_FAN(x, y, false, false, true, false, false, false, false, false, Kyra::GI_LOL)
+#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_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)
const KYRAGameDescription adGameDescs[] = {
/* disable these targets until they get supported
@@ -95,18 +98,7 @@ const KYRAGameDescription adGameDescs[] = {
},
KYRA1_FLOPPY_FLAGS
},
- {
- {
- "kyra1",
- "Extracted",
- AD_ENTRY1("GEMCUT.EMC", "689b62b7519215c1b2571d466c95624c"),
- Common::RU_RUS,
- Common::kPlatformPC,
- ADGF_NO_FLAGS,
- Common::GUIO_NOSPEECH | Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIPCSPK
- },
- KYRA1_FLOPPY_FLAGS
- },
+
{
{
"kyra1",
@@ -155,6 +147,18 @@ const KYRAGameDescription adGameDescs[] = {
},
KYRA1_FLOPPY_FLAGS
},
+ {
+ {
+ "kyra1",
+ "Extracted",
+ AD_ENTRY1("GEMCUT.EMC", "689b62b7519215c1b2571d466c95624c"),
+ Common::RU_RUS,
+ Common::kPlatformPC,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NOSPEECH | Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIPCSPK
+ },
+ KYRA1_OLDFLOPPY_FLAGS
+ },
{ // from VooD
{
"kyra1",
@@ -498,6 +502,32 @@ const KYRAGameDescription adGameDescs[] = {
KYRA2_FLOPPY_FLAGS
},
+ { // Floppy version extracted
+ {
+ "kyra2",
+ "Extracted",
+ AD_ENTRY1("CH01-S00.DLG", "54b7a5a94f6e1ec91f0fb1311eec09ab"),
+ Common::RU_RUS,
+ Common::kPlatformPC,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NOSPEECH | Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIGM | Common::GUIO_MIDIPCSPK
+ },
+ KYRA2_FLOPPY_FAN_FLAGS(Common::RU_RUS, Common::EN_ANY)
+ },
+
+ { // Floppy version extracted
+ {
+ "kyra2",
+ "Extracted",
+ AD_ENTRY1("CH01-S00.DLG", "7c36c0e63ab8c81cbb3ea58681331366"),
+ Common::RU_RUS,
+ Common::kPlatformPC,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NOSPEECH | Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIGM | Common::GUIO_MIDIPCSPK
+ },
+ KYRA2_FLOPPY_FAN_FLAGS(Common::RU_RUS, Common::EN_ANY)
+ },
+
{ // CD version
{
"kyra2",
@@ -989,12 +1019,11 @@ const KYRAGameDescription adGameDescs[] = {
"lol",
"CD",
{
- { "GENERAL.PAK", 0, "19354b0f464295c38c801d30588df062", -1 },
- { "L01.PAK", 0, "174d37f21e0336c5d91020f8c58717ef", -1 },
- { "VOC.PAK", 0, "eb398f09ba3321d872b6174a68a987d9", -1 },
+ { "GENERAL.PAK", 0, "05a4f588fb81dc9c0ef1f2ec20d89e24", -1 },
+ { "L01.PAK", 0, "759a0ac26808d77ea968bd392355ba1d", -1 },
{ 0, 0, 0, 0 }
},
- Common::RU_RUS,
+ Common::DE_DEU,
Common::kPlatformPC,
ADGF_DROPLANGUAGE | ADGF_CD,
Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIGM | Common::GUIO_MIDIPCSPK
@@ -1011,7 +1040,7 @@ const KYRAGameDescription adGameDescs[] = {
{ "L01.PAK", 0, "759a0ac26808d77ea968bd392355ba1d", -1 },
{ 0, 0, 0, 0 }
},
- Common::DE_DEU,
+ Common::FR_FRA,
Common::kPlatformPC,
ADGF_DROPLANGUAGE | ADGF_CD,
Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIGM | Common::GUIO_MIDIPCSPK
@@ -1024,11 +1053,11 @@ const KYRAGameDescription adGameDescs[] = {
"lol",
"CD",
{
- { "GENERAL.PAK", 0, "05a4f588fb81dc9c0ef1f2ec20d89e24", -1 },
+ { "GENERAL.PAK", 0, "9e4bab499b7ea9337b91ac29fcba6d13", -1 },
{ "L01.PAK", 0, "759a0ac26808d77ea968bd392355ba1d", -1 },
{ 0, 0, 0, 0 }
},
- Common::FR_FRA,
+ Common::EN_ANY,
Common::kPlatformPC,
ADGF_DROPLANGUAGE | ADGF_CD,
Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIGM | Common::GUIO_MIDIPCSPK
@@ -1045,7 +1074,7 @@ const KYRAGameDescription adGameDescs[] = {
{ "L01.PAK", 0, "759a0ac26808d77ea968bd392355ba1d", -1 },
{ 0, 0, 0, 0 }
},
- Common::EN_ANY,
+ Common::DE_DEU,
Common::kPlatformPC,
ADGF_DROPLANGUAGE | ADGF_CD,
Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIGM | Common::GUIO_MIDIPCSPK
@@ -1062,7 +1091,7 @@ const KYRAGameDescription adGameDescs[] = {
{ "L01.PAK", 0, "759a0ac26808d77ea968bd392355ba1d", -1 },
{ 0, 0, 0, 0 }
},
- Common::DE_DEU,
+ Common::FR_FRA,
Common::kPlatformPC,
ADGF_DROPLANGUAGE | ADGF_CD,
Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIGM | Common::GUIO_MIDIPCSPK
@@ -1070,13 +1099,32 @@ const KYRAGameDescription adGameDescs[] = {
LOL_CD_FLAGS
},
+ // Russian fan translation
{
{
"lol",
"CD",
{
- { "GENERAL.PAK", 0, "9e4bab499b7ea9337b91ac29fcba6d13", -1 },
- { "L01.PAK", 0, "759a0ac26808d77ea968bd392355ba1d", -1 },
+ { "GENERAL.PAK", 0, "19354b0f464295c38c801d30588df062", -1 },
+ { "L01.PAK", 0, "174d37f21e0336c5d91020f8c58717ef", -1 },
+ { 0, 0, 0, 0 }
+ },
+ Common::EN_ANY,
+ Common::kPlatformPC,
+ ADGF_DROPLANGUAGE | ADGF_CD,
+ Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIGM | Common::GUIO_MIDIPCSPK
+ },
+ LOL_CD_FAN_FLAGS(Common::RU_RUS, Common::DE_DEU)
+ },
+
+ {
+ {
+ "lol",
+ "CD",
+ {
+
+ { "GENERAL.PAK", 0, "19354b0f464295c38c801d30588df062", -1 },
+ { "L01.PAK", 0, "174d37f21e0336c5d91020f8c58717ef", -1 },
{ 0, 0, 0, 0 }
},
Common::FR_FRA,
@@ -1084,7 +1132,24 @@ const KYRAGameDescription adGameDescs[] = {
ADGF_DROPLANGUAGE | ADGF_CD,
Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIGM | Common::GUIO_MIDIPCSPK
},
- LOL_CD_FLAGS
+ LOL_CD_FAN_FLAGS(Common::RU_RUS, Common::DE_DEU)
+ },
+
+ {
+ {
+ "lol",
+ "CD",
+ {
+ { "GENERAL.PAK", 0, "19354b0f464295c38c801d30588df062", -1 },
+ { "L01.PAK", 0, "174d37f21e0336c5d91020f8c58717ef", -1 },
+ { 0, 0, 0, 0 }
+ },
+ Common::RU_RUS,
+ Common::kPlatformPC,
+ ADGF_DROPLANGUAGE | ADGF_CD,
+ Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIGM | Common::GUIO_MIDIPCSPK
+ },
+ LOL_CD_FAN_FLAGS(Common::RU_RUS, Common::DE_DEU)
},
// Italian fan translation
@@ -1306,6 +1371,24 @@ const KYRAGameDescription adGameDescs[] = {
LOL_FLOPPY_FLAGS
},
+ // Russian fan translation
+ {
+ {
+ "lol",
+ "Extracted",
+ {
+ { "GENERAL.PAK", 0, "d8f4c1153aed2418f41f886c3fb27543", -1 },
+ { "CHAPTER7.PAK", 0, "f0b8a2fdff951738834fadc12248ac1f", -1 },
+ { 0, 0, 0, 0 }
+ },
+ Common::RU_RUS,
+ Common::kPlatformPC,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NOSPEECH | Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIGM | Common::GUIO_MIDIPCSPK
+ },
+ LOL_FLOPPY_FAN_FLAGS(Common::RU_RUS, Common::EN_ANY)
+ },
+
{
{
"lol",
@@ -1356,7 +1439,7 @@ const KYRAGameDescription adGameDescs[] = {
LOL_KYRA2_DEMO_FLAGS
},
#endif // ENABLE_LOL
- { AD_TABLE_END_MARKER, FLAGS(0, 0, 0, 0, 0, 0, 0, 0) }
+ { AD_TABLE_END_MARKER, FLAGS(0, 0, 0, 0, 0, 0, 0, 0, 0) }
};
const PlainGameDescriptor gameList[] = {
diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp
index c64d3e7723..9b70e536b8 100644
--- a/engines/kyra/gui_lol.cpp
+++ b/engines/kyra/gui_lol.cpp
@@ -395,8 +395,8 @@ void LoLEngine::gui_drawCharPortraitWithStats(int charNum) {
} else {
gui_drawLiveMagicBar(33, 32, _characters[charNum].magicPointsCur, 0, _characters[charNum].magicPointsMax, 5, 32, 162, 1, 0);
gui_drawLiveMagicBar(39, 32, _characters[charNum].hitPointsCur, 0, _characters[charNum].hitPointsMax, 5, 32, 154, 1, 1);
- _screen->printText(getLangString(0x4253), 33, 1, 160, 0);
- _screen->printText(getLangString(0x4254), 39, 1, 152, 0);
+ _screen->printText((_flags.platform == Common::kPlatformPC && !_flags.isTalkie) ? "M" : getLangString(0x4253), 33, 1, 160, 0);
+ _screen->printText((_flags.platform == Common::kPlatformPC && !_flags.isTalkie) ? "H" : getLangString(0x4254), 39, 1, 152, 0);
}
int spellLevels = 0;
diff --git a/engines/kyra/items_lok.cpp b/engines/kyra/items_lok.cpp
index d66eb553f2..105a8efa0d 100644
--- a/engines/kyra/items_lok.cpp
+++ b/engines/kyra/items_lok.cpp
@@ -575,7 +575,14 @@ void KyraEngine_LoK::dropItem(int unk1, int item, int x, int y, int unk2) {
if (processItemDrop(_currentCharacter->sceneId, item, x, y, unk1, unk2))
return;
snd_playSoundEffect(54);
+
+ // Old floppy versions don't print warning messages and don't have the necessary string resources.
+ // These versions will only play the warning sound effect.
+ if (_flags.isOldFloppy && !_noDropList)
+ return;
+
assert(_noDropList);
+
if (12 == countItemsInScene(_currentCharacter->sceneId))
drawSentenceCommand(_noDropList[0], 6);
else
diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp
index 7f356f34c1..27d0849e5f 100644
--- a/engines/kyra/kyra_lok.cpp
+++ b/engines/kyra/kyra_lok.cpp
@@ -98,6 +98,8 @@ KyraEngine_LoK::KyraEngine_LoK(OSystem *system, const GameFlags &flags)
_malcolmFrame = 0;
_malcolmTimer1 = _malcolmTimer2 = 0;
+
+ _soundFiles = 0;
}
KyraEngine_LoK::~KyraEngine_LoK() {
@@ -121,6 +123,8 @@ KyraEngine_LoK::~KyraEngine_LoK() {
delete _animator;
delete _seq;
+ delete[] _soundFiles;
+
delete[] _characterList;
delete[] _roomTable;
diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h
index 83455f3922..43a709456d 100644
--- a/engines/kyra/kyra_v1.h
+++ b/engines/kyra/kyra_v1.h
@@ -109,6 +109,7 @@ struct GameFlags {
bool isDemo : 1;
bool useAltShapeHeader : 1; // alternative shape header (uses 2 bytes more, those are unused though)
bool isTalkie : 1;
+ bool isOldFloppy : 1;
bool useHiResOverlay : 1;
bool use16ColorMode : 1;
bool useDigSound : 1;
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp
index 2cca4fd4e3..7d7bb0ed4a 100644
--- a/engines/kyra/lol.cpp
+++ b/engines/kyra/lol.cpp
@@ -1038,11 +1038,14 @@ char *LoLEngine::getLangString(uint16 id) {
char *string = (char *)getTableEntry(buffer, realId);
char *srcBuffer = _stringBuffer[_lastUsedStringBuffer];
- if (_flags.lang != Common::JA_JPN) {
- Util::decodeString1(string, srcBuffer);
+ if (_flags.lang == Common::JA_JPN) {
+ decodeSjis(string, srcBuffer);
+ } else if (_flags.lang == Common::RU_RUS && !_flags.isTalkie) {
+ decodeCyrillic(string, srcBuffer);
Util::decodeString2(srcBuffer, srcBuffer);
} else {
- decodeSjis(string, srcBuffer);
+ Util::decodeString1(string, srcBuffer);
+ Util::decodeString2(srcBuffer, srcBuffer);
}
++_lastUsedStringBuffer;
@@ -1081,6 +1084,54 @@ void LoLEngine::decodeSjis(const char *src, char *dst) {
*dst = 0;
}
+int LoLEngine::decodeCyrillic(const char *src, char *dst) {
+ static const uint8 decodeTable1[] = {
+ 0x20, 0xAE, 0xA5, 0xA0, 0xE2, 0xAD, 0xA8, 0xE0, 0xE1, 0xAB, 0xA2,
+ 0xA4, 0xAC, 0xAA, 0xE3, 0x2E
+ };
+
+ static const uint8 decodeTable2[] = {
+ 0xAD, 0xAF, 0xA2, 0xE1, 0xAC, 0xAA, 0x20, 0xA4, 0xAB, 0x20,
+ 0xE0, 0xE2, 0xA4, 0xA2, 0xA6, 0xAA, 0x20, 0xAD, 0xE2, 0xE0,
+ 0xAB, 0xAC, 0xE1, 0xA1, 0x20, 0xAC, 0xE1, 0xAA, 0xAB, 0xE0,
+ 0xE2, 0xAD, 0xAE, 0xEC, 0xA8, 0xA5, 0xA0, 0x20, 0xE0, 0xEB,
+ 0xAE, 0xA0, 0xA8, 0xA5, 0xEB, 0xEF, 0x20, 0xE3, 0xE2, 0x20,
+ 0xAD, 0xE7, 0xAB, 0xAC, 0xA5, 0xE0, 0xAE, 0xA0, 0xA5, 0xA8,
+ 0xE3, 0xEB, 0xEF, 0xAA, 0xE2, 0xEF, 0xA5, 0xEC, 0xAB, 0xAE,
+ 0xAA, 0xAF, 0xA8, 0xA0, 0xA5, 0xEF, 0xAE, 0xEE, 0xEC, 0xE3,
+ 0xA0, 0xAE, 0xA5, 0xA8, 0xEB, 0x20, 0xE0, 0xE3, 0xA0, 0xA5,
+ 0xAE, 0xA8, 0xE3, 0xE1, 0xAD, 0xAB, 0x20, 0xAE, 0xA5, 0xA0,
+ 0xA8, 0xAD, 0x2E, 0xE3, 0xAE, 0xA0, 0xA8, 0x20, 0xE0, 0xE3,
+ 0xAB, 0xE1, 0x20, 0xA4, 0xAD, 0xE2, 0xA1, 0xA6, 0xAC, 0xE1,
+ 0x0D, 0x20, 0x2E, 0x09, 0xA0, 0xA1, 0x9D, 0xA5
+ };
+
+ int size = 0;
+ uint cChar = 0;
+ while ((cChar = *src++) != 0) {
+ if (cChar & 0x80) {
+ cChar &= 0x7F;
+ int index = (cChar & 0x78) >> 3;
+ *dst++ = decodeTable1[index];
+ ++size;
+ assert(cChar < sizeof(decodeTable2));
+ cChar = decodeTable2[cChar];
+ } else if (cChar >= 0x70) {
+ cChar = *src++;
+ } else if (cChar >= 0x30) {
+ if (cChar < 0x60)
+ cChar -= 0x30;
+ cChar |= 0x80;
+ }
+
+ *dst++ = cChar;
+ ++size;
+ }
+
+ *dst++ = 0;
+ return size;
+}
+
bool LoLEngine::addCharacter(int id) {
const uint16 *cdf[] = { _charDefsMan, _charDefsMan, _charDefsMan, _charDefsWoman,
_charDefsMan, _charDefsMan, _charDefsWoman, _charDefsKieran, _charDefsAkshel };
diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h
index 06a4f29f63..3b887c2a86 100644
--- a/engines/kyra/lol.h
+++ b/engines/kyra/lol.h
@@ -363,12 +363,13 @@ private:
void showIntro();
struct CharacterPrev {
- const char *name;
int x, y;
int attrib[3];
};
static const CharacterPrev _charPreviews[];
+ static const char *const _charPreviewNamesDefault[];
+ static const char *const _charPreviewNamesRussianFloppy[];
// PC98 specific data
static const uint16 _charPosXPC98[];
@@ -875,6 +876,7 @@ private:
char *getLangString(uint16 id);
uint8 *getTableEntry(uint8 *buffer, uint16 id);
void decodeSjis(const char *src, char *dst);
+ int decodeCyrillic(const char *src, char *dst);
static const char * const _languageExt[];
diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h
index 1c69362bfd..3f64442858 100644
--- a/engines/kyra/resource.h
+++ b/engines/kyra/resource.h
@@ -202,6 +202,7 @@ enum KyraResources {
k1ConfigStrings,
k1AudioTracks,
+ k1AudioTracks2,
k1AudioTracksIntro,
k1CreditsStrings,
diff --git a/engines/kyra/script_lok.cpp b/engines/kyra/script_lok.cpp
index 2b90d001ca..ea46958b50 100644
--- a/engines/kyra/script_lok.cpp
+++ b/engines/kyra/script_lok.cpp
@@ -558,7 +558,10 @@ int KyraEngine_LoK::o1_setCustomPaletteRange(EMCState *script) {
_screen->copyPalette(0, 12);
}
} else {
- _screen->getPalette(1).copy(_specialPalettes[stackPos(0)], 0, stackPos(2), stackPos(1));
+ if (!_specialPalettes[stackPos(0)])
+ warning("KyraEngine_LoK::o1_setCustomPaletteRange(): Trying to use missing special palette %d", stackPos(0));
+ else
+ _screen->getPalette(1).copy(_specialPalettes[stackPos(0)], 0, stackPos(2), stackPos(1));
}
return 0;
}
diff --git a/engines/kyra/sequences_lok.cpp b/engines/kyra/sequences_lok.cpp
index 5f9bd86724..c26d2e352b 100644
--- a/engines/kyra/sequences_lok.cpp
+++ b/engines/kyra/sequences_lok.cpp
@@ -250,7 +250,7 @@ bool KyraEngine_LoK::seq_introStory() {
if (!textEnabled() && speechEnabled() && _flags.lang != Common::IT_ITA)
return false;
- if ((_flags.lang == Common::EN_ANY && !_flags.isTalkie && _flags.platform == Common::kPlatformPC) || _flags.platform == Common::kPlatformAmiga)
+ if (((_flags.lang == Common::EN_ANY || _flags.lang == Common::RU_RUS) && !_flags.isTalkie && _flags.platform == Common::kPlatformPC) || _flags.platform == Common::kPlatformAmiga)
_screen->loadBitmap("TEXT.CPS", 3, 3, &_screen->getPalette(0));
else if (_flags.lang == Common::EN_ANY || _flags.lang == Common::JA_JPN)
_screen->loadBitmap("TEXT_ENG.CPS", 3, 3, &_screen->getPalette(0));
diff --git a/engines/kyra/sequences_lol.cpp b/engines/kyra/sequences_lol.cpp
index 27f3951faf..d887133b70 100644
--- a/engines/kyra/sequences_lol.cpp
+++ b/engines/kyra/sequences_lol.cpp
@@ -316,8 +316,9 @@ 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;
for (int i = 0; i < 4; ++i) {
- _screen->fprintStringIntro("%s", _charPreviews[i].x + 16, _charPreviews[i].y + 36, 0xC0, 0x00, 0x9C, 0x120, _charPreviews[i].name);
+ _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]);
_screen->fprintStringIntro("%d", _charPreviews[i].x + 21, _charPreviews[i].y + 56, 0x98, 0x00, 0x9C, 0x220, _charPreviews[i].attrib[1]);
_screen->fprintStringIntro("%d", _charPreviews[i].x + 21, _charPreviews[i].y + 64, 0x98, 0x00, 0x9C, 0x220, _charPreviews[i].attrib[2]);
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index d56abc5d47..ecb32e68d9 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -38,7 +38,7 @@
namespace Kyra {
-#define RESFILE_VERSION 74
+#define RESFILE_VERSION 78
namespace {
bool checkKyraDat(Common::SeekableReadStream *file) {
@@ -90,6 +90,7 @@ const IndexTable iLanguageTable[] = {
{ Common::ES_ESP, 4 },
{ Common::IT_ITA, 5 },
{ Common::JA_JPN, 6 },
+ { Common::RU_RUS, 7 },
{ -1, -1 }
};
@@ -111,7 +112,9 @@ byte getPlatformID(const GameFlags &flags) {
}
byte getSpecialID(const GameFlags &flags) {
- if (flags.isDemo && flags.isTalkie)
+ if (flags.isOldFloppy)
+ return 4;
+ else if (flags.isDemo && flags.isTalkie)
return 3;
else if (flags.isDemo)
return 2;
@@ -748,7 +751,17 @@ void KyraEngine_LoK::initStaticResource() {
_storyStrings = _staticres->loadStrings(k1PC98StoryStrings, _storyStringsSize);
- _soundFiles = _staticres->loadStrings(k1AudioTracks, _soundFilesSize);
+ 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);
@@ -926,7 +939,7 @@ void KyraEngine_LoK::loadButtonShapes() {
void KyraEngine_LoK::loadMainScreen(int page) {
_screen->clearPage(page);
- if ((_flags.lang == Common::EN_ANY && !_flags.isTalkie && _flags.platform == Common::kPlatformPC) || _flags.platform == Common::kPlatformAmiga)
+ if (((_flags.lang == Common::EN_ANY || _flags.lang == Common::RU_RUS) && !_flags.isTalkie && _flags.platform == Common::kPlatformPC) || _flags.platform == Common::kPlatformAmiga)
_screen->loadBitmap("MAIN15.CPS", page, page, &_screen->getPalette(0));
else if (_flags.lang == Common::EN_ANY || _flags.lang == Common::JA_JPN || (_flags.isTalkie && _flags.lang == Common::IT_ITA))
_screen->loadBitmap("MAIN_ENG.CPS", page, page, 0);
diff --git a/engines/kyra/staticres_lol.cpp b/engines/kyra/staticres_lol.cpp
index cf75a317e1..e4029505bf 100644
--- a/engines/kyra/staticres_lol.cpp
+++ b/engines/kyra/staticres_lol.cpp
@@ -687,11 +687,25 @@ const char * const LoLEngine::_languageExt[] = {
"GER"
};
+const char *const LoLEngine::_charPreviewNamesDefault[] = {
+ "Ak\'shel",
+ "Michael",
+ "Kieran",
+ "Conrad"
+};
+
+const char *const LoLEngine::_charPreviewNamesRussianFloppy[] = {
+ "\x80\xAA\xE8\xA5\xAB\0",
+ "\x8C\xA0\xA9\xAA\xAB\0",
+ "\x8A\xA8\xE0\xA0\xAD\0",
+ "\x8A\xAE\xAD\xE0\xA0\xA4\0"
+};
+
const LoLEngine::CharacterPrev LoLEngine::_charPreviews[] = {
- { "Ak\'shel", 0x060, 0x7F, { 0x0F, 0x08, 0x05 } },
- { "Michael", 0x09A, 0x7F, { 0x06, 0x0A, 0x0F } },
- { "Kieran", 0x0D4, 0x7F, { 0x08, 0x06, 0x08 } },
- { "Conrad", 0x10F, 0x7F, { 0x0A, 0x0C, 0x0A } }
+ { 0x060, 0x7F, { 0x0F, 0x08, 0x05 } },
+ { 0x09A, 0x7F, { 0x06, 0x0A, 0x0F } },
+ { 0x0D4, 0x7F, { 0x08, 0x06, 0x08 } },
+ { 0x10F, 0x7F, { 0x0A, 0x0C, 0x0A } }
};
const uint16 LoLEngine::_charPosXPC98[] = {
diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp
index 307be2dd05..ca8e985491 100644
--- a/engines/mohawk/myst_scripts.cpp
+++ b/engines/mohawk/myst_scripts.cpp
@@ -500,7 +500,7 @@ void MystScriptParser::o_disableAreas(uint16 op, uint16 var, uint16 argc, uint16
resource = _vm->_resources[argv[i + 1]];
if (resource)
- resource->setEnabled(true);
+ resource->setEnabled(false);
else
warning("Unknown Resource in disableAreas script Opcode");
}
diff --git a/engines/toon/path.cpp b/engines/toon/path.cpp
index 43a134e39b..785b84a78e 100644
--- a/engines/toon/path.cpp
+++ b/engines/toon/path.cpp
@@ -28,7 +28,7 @@ namespace Toon {
PathFindingHeap::PathFindingHeap() {
_count = 0;
- _alloc = 0;
+ _size = 0;
_data = NULL;
}
@@ -36,46 +36,50 @@ PathFindingHeap::~PathFindingHeap() {
delete[] _data;
}
-int32 PathFindingHeap::init(int32 size) {
+void PathFindingHeap::init(int32 size) {
debugC(1, kDebugPath, "init(%d)", size);
+ _size = size;
delete[] _data;
- _data = new HeapDataGrid[size * 2];
- memset(_data, 0, sizeof(HeapDataGrid) * size * 2);
+ _data = new HeapDataGrid[_size];
+ memset(_data, 0, sizeof(HeapDataGrid) * _size);
_count = 0;
- _alloc = size;
- return size;
}
-int32 PathFindingHeap::unload() {
+void PathFindingHeap::unload() {
+ _count = 0;
+ _size = 0;
delete[] _data;
_data = NULL;
- return 0;
}
-int32 PathFindingHeap::clear() {
- //debugC(1, kDebugPath, "clear()");
+void PathFindingHeap::clear() {
+ debugC(1, kDebugPath, "clear()");
_count = 0;
- memset(_data, 0, sizeof(HeapDataGrid) * _alloc * 2);
- return 1;
+ memset(_data, 0, sizeof(HeapDataGrid) * _size);
}
-int32 PathFindingHeap::push(int32 x, int32 y, int32 weight) {
- //debugC(6, kDebugPath, "push(%d, %d, %d)", x, y, weight);
+void PathFindingHeap::push(int32 x, int32 y, int32 weight) {
+ debugC(2, kDebugPath, "push(%d, %d, %d)", x, y, weight);
+
+ if (_count == _size) {
+ warning("Aborting attempt to push onto PathFindingHeap at maximum size: %d", _count);
+ return;
+ }
- _count++;
_data[_count]._x = x;
_data[_count]._y = y;
_data[_count]._weight = weight;
+ _count++;
- int32 lMax = _count;
+ int32 lMax = _count-1;
int32 lT = 0;
while (1) {
- lT = lMax / 2;
- if (lT < 1)
+ if (lMax <= 0)
break;
+ lT = (lMax-1) / 2;
if (_data[lT]._weight > _data[lMax]._weight) {
HeapDataGrid temp;
@@ -87,31 +91,31 @@ int32 PathFindingHeap::push(int32 x, int32 y, int32 weight) {
break;
}
}
- return 1;
}
-int32 PathFindingHeap::pop(int32 *x, int32 *y, int32 *weight) {
- //debugC(6, kDebugPath, "pop(x, y, weight)");
+void PathFindingHeap::pop(int32 *x, int32 *y, int32 *weight) {
+ debugC(2, kDebugPath, "pop(x, y, weight)");
- if (!_count)
- return 0;
+ if (!_count) {
+ warning("Attempt to pop empty PathFindingHeap!");
+ return;
+ }
- *x = _data[1]._x;
- *y = _data[1]._y;
- *weight = _data[1]._weight;
+ *x = _data[0]._x;
+ *y = _data[0]._y;
+ *weight = _data[0]._weight;
- _data[1] = _data[_count];
- _count--;
+ _data[0] = _data[--_count];
if (!_count)
- return 0;
+ return;
- int32 lMin = 1;
- int32 lT = 1;
+ int32 lMin = 0;
+ int32 lT = 0;
while (1) {
- lT = lMin << 1;
- if (lT <= _count) {
- if (lT < _count) {
+ lT = (lMin << 1) + 1;
+ if (lT < _count) {
+ if (lT < _count-1) {
if (_data[lT + 1]._weight < _data[lT]._weight)
lT++;
}
@@ -129,7 +133,6 @@ int32 PathFindingHeap::pop(int32 *x, int32 *y, int32 *weight) {
break;
}
}
- return 0;
}
PathFinding::PathFinding(ToonEngine *vm) : _vm(vm) {
@@ -164,7 +167,7 @@ bool PathFinding::isLikelyWalkable(int32 x, int32 y) {
}
bool PathFinding::isWalkable(int32 x, int32 y) {
- //debugC(6, kDebugPath, "isWalkable(%d, %d)", x, y);
+ debugC(2, kDebugPath, "isWalkable(%d, %d)", x, y);
bool maskWalk = (_currentMask->getData(x, y) & 0x1f) > 0;
@@ -299,7 +302,7 @@ int32 PathFinding::findPath(int32 x, int32 y, int32 destx, int32 desty) {
_heap->push(curX, curY, abs(destx - x) + abs(desty - y));
int wei = 0;
- while (_heap->_count) {
+ while (_heap->getCount()) {
wei = 0;
_heap->pop(&curX, &curY, &curWeight);
int curNode = curX + curY * _width;
diff --git a/engines/toon/path.h b/engines/toon/path.h
index 329127c9ce..2de58064f0 100644
--- a/engines/toon/path.h
+++ b/engines/toon/path.h
@@ -38,17 +38,18 @@ public:
PathFindingHeap();
~PathFindingHeap();
- int32 _alloc;
- int32 _count;
-
- int32 push(int32 x, int32 y, int32 weight);
- int32 pop(int32 *x, int32 *y, int32 *weight);
- int32 init(int32 size);
- int32 clear();
- int32 unload();
+ void push(int32 x, int32 y, int32 weight);
+ void pop(int32 *x, int32 *y, int32 *weight);
+ void init(int32 size);
+ void clear();
+ void unload();
+ int32 getCount() { return _count; }
private:
HeapDataGrid *_data;
+
+ int32 _size;
+ int32 _count;
};
class PathFinding {
diff --git a/engines/tsage/debugger.cpp b/engines/tsage/debugger.cpp
index 9277fd429a..00cd61ae07 100644
--- a/engines/tsage/debugger.cpp
+++ b/engines/tsage/debugger.cpp
@@ -38,6 +38,7 @@ Debugger::Debugger() : GUI::Debugger() {
DCmd_Register("listobjects", WRAP_METHOD(Debugger, Cmd_ListObjects));
DCmd_Register("moveobject", WRAP_METHOD(Debugger, Cmd_MoveObject));
DCmd_Register("hotspots", WRAP_METHOD(Debugger, Cmd_Hotspots));
+ DCmd_Register("sound", WRAP_METHOD(Debugger, Cmd_Sound));
}
static int strToInt(const char *s) {
@@ -434,5 +435,18 @@ bool Debugger::Cmd_Hotspots(int argc, const char **argv) {
return false;
}
+/**
+ * Play the specified sound
+ */
+bool Debugger::Cmd_Sound(int argc, const char **argv) {
+ if (argc != 2) {
+ DebugPrintf("Usage: %s <sound number>\n", argv[0]);
+ return true;
+ }
+
+ int soundNum = strToInt(argv[1]);
+ _globals->_soundHandler.play(soundNum);
+ return false;
+}
} // End of namespace tSage
diff --git a/engines/tsage/debugger.h b/engines/tsage/debugger.h
index 3c14cd7bed..44fd61ec5e 100644
--- a/engines/tsage/debugger.h
+++ b/engines/tsage/debugger.h
@@ -42,8 +42,8 @@ protected:
bool Cmd_ClearFlag(int argc, const char **argv);
bool Cmd_ListObjects(int argc, const char **argv);
bool Cmd_MoveObject(int argc, const char **argv);
-
bool Cmd_Hotspots(int argc, const char **argv);
+ bool Cmd_Sound(int argc, const char **argv);
};
} // End of namespace tSage
diff --git a/engines/tsage/ringworld_scenes1.cpp b/engines/tsage/ringworld_scenes1.cpp
index 8299a05967..f97cfa4ae6 100644
--- a/engines/tsage/ringworld_scenes1.cpp
+++ b/engines/tsage/ringworld_scenes1.cpp
@@ -1330,6 +1330,24 @@ void Scene40::Action8::signal() {
}
}
+void Scene40::Action8::dispatch() {
+ if (_action)
+ _action->dispatch();
+
+ if (_delayFrames) {
+ uint32 frameNumber = _globals->_events.getFrameNumber();
+ if ((_startFrame + 60) < frameNumber) {
+ --_delayFrames;
+ _startFrame = frameNumber;
+
+ if (_delayFrames <= 0) {
+ _delayFrames = 0;
+ signal();
+ }
+ }
+ }
+}
+
/*--------------------------------------------------------------------------*/
void Scene40::DyingKzin::doAction(int action) {
@@ -1416,7 +1434,7 @@ void Scene40::Item2::doAction(int action) {
SceneItem::display2(40, 37);
break;
default:
- SceneItem::doAction(action);
+ SceneHotspot::doAction(action);
break;
}
}
@@ -1437,7 +1455,7 @@ void Scene40::Item6::doAction(int action) {
SceneItem::display2(40, 36);
break;
default:
- SceneItem::doAction(action);
+ SceneHotspot::doAction(action);
break;
}
}
@@ -1446,7 +1464,7 @@ void Scene40::Item6::doAction(int action) {
Scene40::Scene40() :
_item1(2, OBJECT_SCANNER, 40, 24, OBJECT_STUNNER, 40, 25, CURSOR_LOOK, 40, 7, CURSOR_USE, 40, 16, LIST_END),
- _item3(5, OBJECT_SCANNER, 40, 26, OBJECT_STUNNER, 40, 27, CURSOR_LOOK, 40, 9, CURSOR_USE, 40, 17, LIST_END),
+ _item3(5, OBJECT_SCANNER, 40, 28, OBJECT_STUNNER, 40, 27, CURSOR_LOOK, 40, 2, CURSOR_USE, 40, 30, LIST_END),
_item4(6, OBJECT_SCANNER, 40, 31, OBJECT_STUNNER, 40, 32, CURSOR_LOOK, 40, 5, CURSOR_USE, 40, 33, LIST_END),
_item5(0, CURSOR_LOOK, 40, 11, LIST_END),
_item7(4, OBJECT_SCANNER, 40, 26, OBJECT_STUNNER, 40, 27, CURSOR_LOOK, 40, 9, CURSOR_USE, 40, 17, LIST_END),
@@ -2271,7 +2289,7 @@ void Scene60::Item::doAction(int action) {
setAction(&scene->_sequenceManager, this, 62, NULL);
break;
default:
- SceneItem::doAction(action);
+ SceneHotspot::doAction(action);
break;
}
}
diff --git a/engines/tsage/ringworld_scenes1.h b/engines/tsage/ringworld_scenes1.h
index 283cf68e07..0f9bf61117 100644
--- a/engines/tsage/ringworld_scenes1.h
+++ b/engines/tsage/ringworld_scenes1.h
@@ -201,6 +201,7 @@ class Scene40 : public Scene {
class Action8 : public Action {
public:
virtual void signal();
+ virtual void dispatch();
};
/* Objects */
@@ -214,15 +215,15 @@ class Scene40 : public Scene {
};
/* Items */
- class Item2 : public SceneItem {
+ class Item2 : public SceneHotspot {
public:
virtual void doAction(int action);
};
- class Item6 : public SceneItem {
+ class Item6 : public SceneHotspot {
public:
virtual void doAction(int action);
};
- class Item8 : public SceneItem {
+ class Item8 : public SceneHotspot {
public:
virtual void doAction(int action);
};
diff --git a/engines/tsage/ringworld_scenes3.cpp b/engines/tsage/ringworld_scenes3.cpp
index 3f9921b0ad..209144766a 100644
--- a/engines/tsage/ringworld_scenes3.cpp
+++ b/engines/tsage/ringworld_scenes3.cpp
@@ -324,7 +324,7 @@ void Scene2000::Action14::signal() {
scene->_stripManager.start(2001, this, scene);
break;
case 6:
- _globals->_soundHandler.fadeOut(0/* was false */);
+ _globals->_soundHandler.fadeOut(NULL);
scene->_object8.setStrip(1);
scene->_object8.setFrame(scene->_object8.getFrameCount());
scene->_object8.animate(ANIM_MODE_6, this);
@@ -786,7 +786,7 @@ void Scene2100::Action9::signal() {
scene->_stripManager.start(6051, this, scene);
break;
case 4:
- scene->_soundHandler.fadeOut(0/* was false */);
+ scene->_soundHandler.fadeOut(NULL);
scene->_object4.setStrip(1);
scene->_object4.setFrame(scene->_object4.getFrameCount());
scene->_object4.animate(ANIM_MODE_6, this);
@@ -1105,7 +1105,7 @@ void Scene2100::Action14::signal() {
scene->_stripManager.start(6009, this, scene);
break;
case 6:
- scene->_soundHandler.fadeOut(0/* was false */);
+ scene->_soundHandler.fadeOut(NULL);
scene->_object4.setStrip(1);
scene->_object4.setFrame(scene->_object4.getFrameCount());
scene->_object4.animate(ANIM_MODE_6, this);
diff --git a/engines/tsage/ringworld_scenes8.cpp b/engines/tsage/ringworld_scenes8.cpp
index 2b329b958a..d0e7491d4a 100644
--- a/engines/tsage/ringworld_scenes8.cpp
+++ b/engines/tsage/ringworld_scenes8.cpp
@@ -2223,7 +2223,7 @@ void Scene7700::signal() {
}
break;
case 7702:
- _soundHandler.fadeOut(0);
+ _globals->_soundHandler.fadeOut(NULL);
_globals->_sceneManager.changeScene(7600);
break;
case 7703:
diff --git a/engines/tsage/scenes.cpp b/engines/tsage/scenes.cpp
index b94e95c696..3e23205633 100644
--- a/engines/tsage/scenes.cpp
+++ b/engines/tsage/scenes.cpp
@@ -45,7 +45,7 @@ SceneManager::~SceneManager() {
}
void SceneManager::setNewScene(int sceneNumber) {
- warning("SetNewScene(%d)", sceneNumber);
+ debug(1, "SetNewScene(%d)", sceneNumber);
_nextSceneNumber = sceneNumber;
}
@@ -146,7 +146,7 @@ void SceneManager::fadeInIfNecessary() {
}
void SceneManager::changeScene(int newSceneNumber) {
- warning("changeScene(%d)", newSceneNumber);
+ debug(1, "changeScene(%d)", newSceneNumber);
// Fade out the scene
ScenePalette scenePalette;
uint32 adjustData = 0;
@@ -173,6 +173,11 @@ void SceneManager::changeScene(int newSceneNumber) {
// Blank out the screen
_globals->_screenSurface.fillRect(_globals->_screenSurface.getBounds(), 0);
+ // If there are any fading sounds, wait until fading is complete
+ while (_globals->_soundManager.isFading()) {
+ g_system->delayMillis(10);
+ }
+
// Set the new scene to be loaded
setNewScene(newSceneNumber);
}
@@ -296,7 +301,7 @@ void Scene::dispatch() {
}
void Scene::loadScene(int sceneNum) {
- warning("loadScene(%d)", sceneNum);
+ debug(1, "loadScene(%d)", sceneNum);
_screenNumber = sceneNum;
if (_globals->_scenePalette.loadPalette(sceneNum))
_globals->_sceneManager._hasPalette = true;
diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp
index e26b3d1544..1754bd71b9 100644
--- a/engines/tsage/sound.cpp
+++ b/engines/tsage/sound.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "audio/decoders/raw.h"
#include "common/config-manager.h"
#include "tsage/core.h"
#include "tsage/globals.h"
@@ -53,6 +54,7 @@ SoundManager::SoundManager() {
SoundManager::~SoundManager() {
if (__sndmgrReady) {
Common::StackLock slock(_serverDisabledMutex);
+ _vm->_mixer->stopAll();
for (Common::List<Sound *>::iterator i = _soundList.begin(); i != _soundList.end(); ) {
Sound *s = *i;
@@ -66,7 +68,7 @@ SoundManager::~SoundManager() {
}
_sfTerminate();
- g_system->getTimerManager()->removeTimerProc(_sfUpdateCallback);
+// g_system->getTimerManager()->removeTimerProc(_sfUpdateCallback);
}
_soundManager = NULL;
@@ -78,9 +80,12 @@ void SoundManager::postInit() {
_saver->addLoadNotifier(&SoundManager::loadNotifier);
_saver->addListener(this);
- // Install a timer for handling sound manager updates at 60Hz
- g_system->getTimerManager()->installTimerProc(_sfUpdateCallback, 1000000 / GAME_FRAME_RATE, NULL);
+// I originally separated the sound manager update method into a separate thread, since
+// it handles updates for both music and Fx. However, since Adlib updates also get done in a
+// thread, and doesn't get too far ahead, I've left it to the AdlibSoundDriver class to
+// call the update method, rather than having it be called separately
+// g_system->getTimerManager()->installTimerProc(_sfUpdateCallback, 1000000 / SOUND_FREQUENCY, NULL);
__sndmgrReady = true;
}
}
@@ -155,9 +160,7 @@ Common::List<SoundDriverEntry> &SoundManager::buildDriverList(bool detectFlag) {
void SoundManager::installConfigDrivers() {
installDriver(ADLIB_DRIVER_NUM);
-#ifdef DEBUG
installDriver(SBLASTER_DRIVER_NUM);
-#endif
}
Common::List<SoundDriverEntry> &SoundManager::getDriverList(bool detectFlag) {
@@ -226,7 +229,7 @@ SoundDriver *SoundManager::instantiateDriver(int driverNum) {
case ADLIB_DRIVER_NUM:
return new AdlibSoundDriver();
case SBLASTER_DRIVER_NUM:
- return new AdlibFxSoundDriver();
+ return new SoundBlasterDriver();
default:
error("Unknown sound driver - %d", driverNum);
}
@@ -357,9 +360,6 @@ void SoundManager::rethinkVoiceTypes() {
}
void SoundManager::_sfSoundServer() {
- Common::StackLock slock1(sfManager()._serverDisabledMutex);
- Common::StackLock slock2(sfManager()._serverSuspendedMutex);
-
if (sfManager()._needToRethink) {
_sfRethinkVoiceTypes();
sfManager()._needToRethink = false;
@@ -451,6 +451,22 @@ void SoundManager::_sfProcessFading() {
}
}
+bool SoundManager::isFading() {
+ Common::StackLock slock(sfManager()._serverSuspendedMutex);
+
+ // Loop through any active sounds to see if any are being actively faded
+ Common::List<Sound *>::iterator i = sfManager()._playList.begin();
+ while (i != sfManager()._playList.end()) {
+ Sound *s = *i;
+ ++i;
+
+ if (s->_fadeDest != -1)
+ return true;
+ }
+
+ return false;
+}
+
void SoundManager::_sfUpdateVoiceStructs() {
for (int voiceIndex = 0; voiceIndex < SOUND_ARR_SIZE; ++voiceIndex) {
VoiceTypeStruct *vs = sfManager()._voiceTypeStructPtrs[voiceIndex];
@@ -1967,9 +1983,9 @@ void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) {
if (channelNum != -1) {
if (voiceType != VOICETYPE_0) {
if (chFlags & 0x10)
- _soProc42(vtStruct, channelNum, chVoiceType, v);
+ _soPlaySound2(vtStruct, channelData, channelNum, chVoiceType, v);
else
- _soProc32(vtStruct, channelNum, chVoiceType, v, b);
+ _soPlaySound(vtStruct, channelData, channelNum, chVoiceType, v, b);
} else if (voiceNum != -1) {
assert(driver);
driver->proc20(voiceNum, chVoiceType);
@@ -2137,7 +2153,7 @@ void Sound::_soUpdateDamper(VoiceTypeStruct *voiceType, int channelNum, VoiceTyp
}
}
-void Sound::_soProc32(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voiceType, int v0, int v1) {
+void Sound::_soPlaySound(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0, int v1) {
int entryIndex = _soFindSound(vtStruct, channelNum);
if (entryIndex != -1) {
SoundDriver *driver = vtStruct->_entries[entryIndex]._driver;
@@ -2147,11 +2163,11 @@ void Sound::_soProc32(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voice
vtStruct->_entries[entryIndex]._type1._field4 = v0;
vtStruct->_entries[entryIndex]._type1._field5 = 0;
- driver->proc32(this, vtStruct->_entries[entryIndex]._voiceNum, _chProgram[channelNum], v0, v1);
+ driver->playSound(channelData, 0, _chProgram[channelNum], vtStruct->_entries[entryIndex]._voiceNum, v0, v1);
}
}
-void Sound::_soProc42(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voiceType, int v0) {
+void Sound::_soPlaySound2(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0) {
for (int trackCtr = 0; trackCtr < _trackInfo._numTracks; ++trackCtr) {
const byte *instrument = _channelData[trackCtr];
if ((*(instrument + 13) == v0) && (*instrument == 1)) {
@@ -2166,7 +2182,7 @@ void Sound::_soProc42(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voice
vtStruct->_entries[entryIndex]._type1._field5 = 0;
int v1, v2;
- driver->proc32(this, vtStruct->_entries[entryIndex]._voiceNum, -1, v0, 0x7F);
+ driver->playSound(channelData, 14, -1, vtStruct->_entries[entryIndex]._voiceNum, v0, 0x7F);
driver->proc42(vtStruct->_entries[entryIndex]._voiceNum, voiceType, 0, &v1, &v2);
}
break;
@@ -2295,24 +2311,26 @@ void Sound::_soServiceTrackType1(int trackIndex, const byte *channelData) {
vtStruct->_entries[entryIndex]._type1._field5 = 0;
int v1, v2;
- driver->proc32(this, vtStruct->_entries[entryIndex]._voiceNum, -1, *(channelData + 1), 0x7f);
+ driver->playSound(channelData, 14, -1, vtStruct->_entries[entryIndex]._voiceNum, *(channelData + 1), 0x7f);
driver->proc42(vtStruct->_entries[entryIndex]._voiceNum, *(channelData + 1), _loop ? 1 : 0,
&v1, &v2);
+ _trkState[trackIndex] = 2;
}
} else {
for (uint entryIndex = 0; entryIndex < vtStruct->_entries.size(); ++entryIndex) {
VoiceStructEntry &vte = vtStruct->_entries[entryIndex];
VoiceStructEntryType1 &vse = vte._type1;
- if ((vse._sound == this) && (vse._channelNum == channel) && (vse._field4 == vtStruct->_total)) {
+ if ((vse._sound == this) && (vse._channelNum == channel) && (vse._field4 == *(channelData + 1))) {
SoundDriver *driver = vte._driver;
- int v1, v2;
- driver->proc42(vte._voiceNum, vtStruct->_total, _loop ? 1 : 0, &v1, &v2);
- if (v2) {
+ int isEnded, resetTimer;
+ driver->proc42(vte._voiceNum, vtStruct->_total, _loop ? 1 : 0, &isEnded, &resetTimer);
+ if (isEnded) {
_trkState[trackIndex] = 0;
- } else if (vtStruct->_total) {
+ } else if (resetTimer) {
_timer = 0;
}
+ return;
}
}
@@ -2488,7 +2506,12 @@ AdlibSoundDriver::AdlibSoundDriver(): SoundDriver() {
_opl = OPL::Config::create();
assert(_opl);
_opl->init(_sampleRate);
-
+
+ _samplesTillCallback = 0;
+ _samplesTillCallbackRemainder = 0;
+ _samplesPerCallback = getRate() / CALLBACKS_PER_SECOND;
+ _samplesPerCallbackRemainder = getRate() % CALLBACKS_PER_SECOND;
+
_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
Common::set_to(_channelVoiced, _channelVoiced + ADLIB_CHANNEL_COUNT, false);
@@ -2558,7 +2581,7 @@ int AdlibSoundDriver::setMasterVolume(int volume) {
return oldVolume;
}
-void AdlibSoundDriver::proc32(Sound *sound, int channel, int program, int v0, int v1) {
+void AdlibSoundDriver::playSound(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1) {
if (program == -1)
return;
@@ -2750,34 +2773,40 @@ void AdlibSoundDriver::setFrequency(int channel) {
}
int AdlibSoundDriver::readBuffer(int16 *buffer, const int numSamples) {
- update(buffer, numSamples);
- return numSamples;
-}
-
-void AdlibSoundDriver::update(int16 *buf, int len) {
- static int samplesLeft = 0;
- while (len != 0) {
- int count = samplesLeft;
- if (count > len) {
- count = len;
- }
- samplesLeft -= count;
- len -= count;
- _opl->readBuffer(buf, count);
- if (samplesLeft == 0) {
+ Common::StackLock slock1(SoundManager::sfManager()._serverDisabledMutex);
+ Common::StackLock slock2(SoundManager::sfManager()._serverSuspendedMutex);
+
+ int32 samplesLeft = numSamples;
+ memset(buffer, 0, sizeof(int16) * numSamples);
+ while (samplesLeft) {
+ if (!_samplesTillCallback) {
+ SoundManager::_sfUpdateCallback(NULL);
flush();
- samplesLeft = _sampleRate / 50;
+
+ _samplesTillCallback = _samplesPerCallback;
+ _samplesTillCallbackRemainder += _samplesPerCallbackRemainder;
+ if (_samplesTillCallbackRemainder >= CALLBACKS_PER_SECOND) {
+ _samplesTillCallback++;
+ _samplesTillCallbackRemainder -= CALLBACKS_PER_SECOND;
+ }
}
- buf += count;
+
+ int32 render = MIN(samplesLeft, _samplesTillCallback);
+ samplesLeft -= render;
+ _samplesTillCallback -= render;
+
+ _opl->readBuffer(buffer, render);
+ buffer += render;
}
+ return numSamples;
}
/*--------------------------------------------------------------------------*/
-const byte adlibFx_group_data[] = { 3, 1, 1, 0, 0xff };
+const byte soundBlaster_group_data[] = { 3, 1, 1, 0, 0xff };
-AdlibFxSoundDriver::AdlibFxSoundDriver(): SoundDriver() {
+SoundBlasterDriver::SoundBlasterDriver(): SoundDriver() {
_minVersion = 0x102;
_maxVersion = 0x10A;
_masterVolume = 0;
@@ -2785,167 +2814,98 @@ AdlibFxSoundDriver::AdlibFxSoundDriver(): SoundDriver() {
_groupData.groupMask = 1;
_groupData.v1 = 0x3E;
_groupData.v2 = 0;
- _groupData.pData = &adlib_group_data[0];
+ _groupData.pData = &soundBlaster_group_data[0];
_mixer = _vm->_mixer;
_sampleRate = _mixer->getOutputRate();
- _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
-/*
- Common::set_to(_channelVoiced, _channelVoiced + ADLIB_CHANNEL_COUNT, false);
- memset(_channelVolume, 0, ADLIB_CHANNEL_COUNT * sizeof(int));
- memset(_v4405E, 0, ADLIB_CHANNEL_COUNT * sizeof(int));
- memset(_v44067, 0, ADLIB_CHANNEL_COUNT * sizeof(int));
- memset(_v44070, 0, ADLIB_CHANNEL_COUNT * sizeof(int));
- memset(_v44079, 0, ADLIB_CHANNEL_COUNT * sizeof(int));
- memset(_v44082, 0, ADLIB_CHANNEL_COUNT * sizeof(int));
- _v44082[ADLIB_CHANNEL_COUNT] = 0x90;
- Common::set_to(_pitchBlend, _pitchBlend + ADLIB_CHANNEL_COUNT, 0x2000);
- memset(_v4409E, 0, ADLIB_CHANNEL_COUNT * sizeof(int));
- _patchData = NULL;
-*/
+ _audioStream = NULL;
+ _channelData = NULL;
}
-AdlibFxSoundDriver::~AdlibFxSoundDriver() {
+SoundBlasterDriver::~SoundBlasterDriver() {
_mixer->stopHandle(_soundHandle);
}
-bool AdlibFxSoundDriver::open() {
- write209();
- write(64);
- write(165);
-
- // for (int idx = 0; idx < 5000 * 16; ++idx) al = port[21h]
-
-// _v45071 = 1;
-// _v4506F = 0;
-
+bool SoundBlasterDriver::open() {
return true;
}
-void AdlibFxSoundDriver::close() {
- write(208);
- write211();
-
+void SoundBlasterDriver::close() {
}
-bool AdlibFxSoundDriver::reset() {
-
+bool SoundBlasterDriver::reset() {
return true;
}
-const GroupData *AdlibFxSoundDriver::getGroupData() {
+const GroupData *SoundBlasterDriver::getGroupData() {
return &_groupData;
}
-void AdlibFxSoundDriver::poll() {
- if (!_masterVolume || !_channelVolume) {
- if (_v45046)
- write211();
- } else {
- if (!_v45046)
- write209();
- }
-}
-
-int AdlibFxSoundDriver::setMasterVolume(int volume) {
+int SoundBlasterDriver::setMasterVolume(int volume) {
int oldVolume = _masterVolume;
_masterVolume = volume;
return oldVolume;
}
-void AdlibFxSoundDriver::proc32(Sound *sound, int channel, int program, int v0, int v1) {
- if (program == -1)
+void SoundBlasterDriver::playSound(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1) {
+ if (program != -1)
return;
- if (_sound)
+ assert(channel == 0);
+
+ // If sound data has been previously set, then release it
+ if (_channelData)
updateVoice(channel);
- // TODO: Stuff
+ // Set the new channel data
+ _channelData = channelData + dataOffset;
+ // Make a copy of the buffer
+ int dataSize = _vm->_memoryManager.getSize(channelData);
+ byte *soundData = (byte *)malloc(dataSize - dataOffset);
+ Common::copy(_channelData, _channelData + (dataSize - dataOffset), soundData);
+ _audioStream = Audio::makeQueuingAudioStream(11025, false);
+ _audioStream->queueBuffer(soundData, dataSize - dataOffset, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED);
+ // Start the new sound
+ if (!_mixer->isSoundHandleActive(_soundHandle))
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, _audioStream);
}
-void AdlibFxSoundDriver::updateVoice(int channel) {
- if (_sound) {
- write(208);
+void SoundBlasterDriver::updateVoice(int channel) {
+ // Stop the playing voice
+ if (_mixer->isSoundHandleActive(_soundHandle))
+ _mixer->stopHandle(_soundHandle);
- _sound = NULL;
- _v45062 = 0;
- _v45066 = 0;
- _v45068 = 0;
- }
+ _audioStream = NULL;
+ _channelData = NULL;
}
-void AdlibFxSoundDriver::proc38(int channel, int cmd, int value) {
+void SoundBlasterDriver::proc38(int channel, int cmd, int value) {
if (cmd == 7) {
// Set channel volume
_channelVolume = value;
+ _mixer->setChannelVolume(_soundHandle, (byte)MIN(255, value * 2));
}
}
-void AdlibFxSoundDriver::proc42(int channel, int cmd, int value, int *v1, int *v2) {
- _v4506A = value;
- *v1 = _v4506B;
+void SoundBlasterDriver::proc42(int channel, int cmd, int value, int *v1, int *v2) {
+ // TODO: v2 is used for flagging a reset of the timer. I'm not sure if it's needed
+ *v1 = 0;
*v2 = 0;
- _v4506B = 0;
-
- if (!_sound)
- *v2 = 1;
-}
-
-void AdlibFxSoundDriver::write(int v) {
- /*
- port[adlib_port + 12] = v;
- for (int i = 0; i < 100; ++i) {
- if (!port[adlib_port + 12] & 0x80)
- break;
- }
- */
-}
-
-void AdlibFxSoundDriver::flush() {
- Common::StackLock slock(SoundManager::sfManager()._serverDisabledMutex);
-
- // No data output yet
-}
-
-
-
-int AdlibFxSoundDriver::readBuffer(int16 *buffer, const int numSamples) {
- update(buffer, numSamples);
- return numSamples;
-}
-void AdlibFxSoundDriver::update(int16 *buf, int len) {
-/*
- static int samplesLeft = 0;
- while (len != 0) {
- int count = samplesLeft;
- if (count > len) {
- count = len;
- }
- samplesLeft -= count;
- len -= count;
- YM3812UpdateOne(_opl, buf, count);
- if (samplesLeft == 0) {
- flush();
- samplesLeft = _sampleRate / 50;
- }
- buf += count;
+ // Note: Checking whether a playing Fx sound had finished was originally done in another
+ // method in the sample playing code. But since we're using the ScummVM audio soundsystem,
+ // it's easier simply to do the check right here
+ if (_audioStream && (_audioStream->numQueuedStreams() == 0)) {
+ updateVoice(channel);
}
-*/
-}
-
-void AdlibFxSoundDriver::write209() {
- write(209);
- _v45046 = true;
-}
-void AdlibFxSoundDriver::write211() {
- write(211);
- _v45046 = false;
+ if (!_channelData)
+ // Flag that sound isn't playing
+ *v1 = 1;
}
} // End of namespace tSage
diff --git a/engines/tsage/sound.h b/engines/tsage/sound.h
index 6a47a1aaf5..46a29e57a4 100644
--- a/engines/tsage/sound.h
+++ b/engines/tsage/sound.h
@@ -41,6 +41,7 @@ class Sound;
#define ROLAND_DRIVER_NUM 2
#define ADLIB_DRIVER_NUM 3
#define SBLASTER_DRIVER_NUM 4
+#define CALLBACKS_PER_SECOND 60
struct trackInfoStruct {
int _numTracks;
@@ -107,7 +108,7 @@ public:
virtual void setProgram(int channel, int program) {} // Method #13
virtual void setVolume1(int channel, int v2, int v3, int volume) {}
virtual void setPitchBlend(int channel, int pitchBlend) {} // Method #15
- virtual void proc32(Sound *sound, int channel, int program, int v0, int v1) {}// Method #16
+ virtual void playSound(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1) {}// Method #16
virtual void updateVoice(int channel) {} // Method #17
virtual void proc36() {} // Method #18
virtual void proc38(int channel, int cmd, int value) {} // Method #19
@@ -224,6 +225,7 @@ public:
int getMasterVol() const;
void loadSound(int soundNum, bool showErrors);
void unloadSound(int soundNum);
+ bool isFading();
// _sf methods
static SoundManager &sfManager();
@@ -348,8 +350,8 @@ public:
void _soRemoteReceive();
void _soServiceTrackType0(int trackIndex, const byte *channelData);
void _soUpdateDamper(VoiceTypeStruct *voiceType, int channelNum, VoiceType mode, int v0);
- void _soProc32(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voiceType, int v0, int v1);
- void _soProc42(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voiceType, int v0);
+ void _soPlaySound(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0, int v1);
+ void _soPlaySound2(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0);
void _soProc38(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voiceType, int cmd, int value);
void _soProc40(VoiceTypeStruct *vtStruct, int channelNum, int pitchBlend);
void _soDoTrackCommand(int channelNum, int command, int value);
@@ -411,6 +413,10 @@ private:
const byte *_patchData;
int _masterVolume;
Common::Queue<RegisterValue> _queue;
+ int _samplesTillCallback;
+ int _samplesTillCallbackRemainder;
+ int _samplesPerCallback;
+ int _samplesPerCallbackRemainder;
bool _channelVoiced[ADLIB_CHANNEL_COUNT];
int _channelVolume[ADLIB_CHANNEL_COUNT];
@@ -440,7 +446,7 @@ public:
virtual const GroupData *getGroupData();
virtual void installPatch(const byte *data, int size);
virtual int setMasterVolume(int volume);
- virtual void proc32(Sound *sound, int channel, int program, int v0, int v1);
+ virtual void playSound(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1);
virtual void updateVoice(int channel);
virtual void proc38(int channel, int cmd, int value);
virtual void setPitch(int channel, int pitchBlend);
@@ -454,51 +460,30 @@ public:
void update(int16 *buf, int len);
};
-class AdlibFxSoundDriver: public SoundDriver, Audio::AudioStream {
+class SoundBlasterDriver: public SoundDriver {
private:
- Common::Queue<RegisterValue> _queue;
GroupData _groupData;
Audio::Mixer *_mixer;
Audio::SoundHandle _soundHandle;
+ Audio::QueuingAudioStream *_audioStream;
int _sampleRate;
- int _v45062;
- int _v45066;
- int _v45068;
- int _v4506A;
- int _v4506B;
- bool _v45046;
byte _masterVolume;
byte _channelVolume;
- Sound *_sound;
-
- void write(int v);
- void flush();
- void sub_4556E();
- void write209();
- void write211();
+ const byte *_channelData;
public:
- AdlibFxSoundDriver();
- virtual ~AdlibFxSoundDriver();
+ SoundBlasterDriver();
+ virtual ~SoundBlasterDriver();
virtual bool open();
virtual void close();
virtual bool reset();
virtual const GroupData *getGroupData();
- virtual void poll();
virtual int setMasterVolume(int volume);
- virtual void proc32(Sound *sound, int channel, int program, int v0, int v1);
+ virtual void playSound(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1);
virtual void updateVoice(int channel);
virtual void proc38(int channel, int cmd, int value);
virtual void proc42(int channel, int cmd, int value, int *v1, int *v2);
-
- // AudioStream interface
- virtual int readBuffer(int16 *buffer, const int numSamples);
- virtual bool isStereo() const { return false; }
- virtual bool endOfData() const { return false; }
- virtual int getRate() const { return _sampleRate; }
-
- void update(int16 *buf, int len);
};
diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp
index de716269c9..c60dbc29be 100644
--- a/video/bink_decoder.cpp
+++ b/video/bink_decoder.cpp
@@ -1418,10 +1418,6 @@ void BinkDecoder::audioBlock(AudioTrack &audio, int16 *out) {
else if (audio.codec == kAudioCodecRDFT)
audioBlockRDFT(audio);
- for (uint32 i = 0; i < audio.channels; i++)
- for (uint32 j = 0; j < audio.frameLen; j++)
- audio.coeffsPtr[i][j] = 385.0 + audio.coeffsPtr[i][j] * (1.0 / 32767.0);
-
floatToInt16Interleave(out, const_cast<const float **>(audio.coeffsPtr), audio.frameLen, audio.channels);
if (!audio.first) {
@@ -1535,25 +1531,20 @@ void BinkDecoder::readAudioCoeffs(AudioTrack &audio, float *coeffs) {
}
-static inline int floatToInt16One(const float *src) {
- int32 tmp = *(const int32 *) src;
-
- if (tmp & 0xF0000)
- tmp = (0x43C0FFFF - tmp) >> 31;
-
- return tmp - 0x8000;
+static inline int floatToInt16One(float src) {
+ return (int16) CLIP<int>((int) floor(src + 0.5), -32768, 32767);
}
void BinkDecoder::floatToInt16Interleave(int16 *dst, const float **src, uint32 length, uint8 channels) {
if (channels == 2) {
for (uint32 i = 0; i < length; i++) {
- dst[2 * i ] = TO_LE_16(floatToInt16One(src[0] + i));
- dst[2 * i + 1] = TO_LE_16(floatToInt16One(src[1] + i));
+ dst[2 * i ] = TO_LE_16(floatToInt16One(src[0][i]));
+ dst[2 * i + 1] = TO_LE_16(floatToInt16One(src[1][i]));
}
} else {
for(uint8 c = 0; c < channels; c++)
for(uint32 i = 0, j = c; i < length; i++, j += channels)
- dst[j] = TO_LE_16(floatToInt16One(src[c] + i));
+ dst[j] = TO_LE_16(floatToInt16One(src[c][i]));
}
}