[Scummvm-git-logs] scummvm master -> e9c60720c039a34fa6c6291afb7adf55a50db84f
bluegr
bluegr at gmail.com
Thu Jul 1 13:24:04 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e9c60720c0 SAGA: Remove SAGA2 references, code and stubs
Commit: e9c60720c039a34fa6c6291afb7adf55a50db84f
https://github.com/scummvm/scummvm/commit/e9c60720c039a34fa6c6291afb7adf55a50db84f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2021-07-01T16:23:48+03:00
Commit Message:
SAGA: Remove SAGA2 references, code and stubs
All SAGA2 game development will continue in the new SAGA2 engine
Changed paths:
R engines/saga/introproc_saga2.cpp
R engines/saga/resource_hrs.cpp
R engines/saga/shorten.cpp
R engines/saga/shorten.h
engines/saga/actor.cpp
engines/saga/detection.h
engines/saga/detection_tables.h
engines/saga/displayinfo.h
engines/saga/interface.cpp
engines/saga/metaengine.cpp
engines/saga/module.mk
engines/saga/music.cpp
engines/saga/resource.cpp
engines/saga/resource.h
engines/saga/saga.cpp
engines/saga/saga.h
engines/saga/scene.cpp
engines/saga/script.cpp
engines/saga/script.h
engines/saga/sndres.cpp
diff --git a/engines/saga/actor.cpp b/engines/saga/actor.cpp
index 866e806430..44575342ba 100644
--- a/engines/saga/actor.cpp
+++ b/engines/saga/actor.cpp
@@ -1055,11 +1055,6 @@ bool Actor::getSpriteParams(CommonObjectData *commonObjectData, int &frameNumber
}
void Actor::drawActors() {
- // Do nothing for SAGA2 games for now
- if (_vm->isSaga2()) {
- return;
- }
-
// WORKAROUND
// Bug #4746: 'ITE: Graphic Glitches during racoon death "Cut Scene"'
if (_vm->_anim->hasCutaway() || _vm->_scene->currentSceneNumber() == 287 || _vm->_scene->currentSceneNumber() == 286) {
diff --git a/engines/saga/detection.h b/engines/saga/detection.h
index fd001b5381..4d9aed08ac 100644
--- a/engines/saga/detection.h
+++ b/engines/saga/detection.h
@@ -58,9 +58,7 @@ struct GamePatchDescription {
enum GameIds {
GID_ITE = 0,
- GID_IHNM = 1,
- GID_DINO = 2,
- GID_FTA2 = 3
+ GID_IHNM = 1
};
enum GameFeatures {
diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h
index 2f67d21ce7..ec63cad795 100644
--- a/engines/saga/detection_tables.h
+++ b/engines/saga/detection_tables.h
@@ -1151,66 +1151,6 @@ static const SAGAGameDescription gameDescriptions[] = {
NULL,
},
-#if 0
- // Dinotopia Section //////////////////////////////////////////////////////////////////////////////////////
- {
- {
- "dino",
- "",
- {
- {"dinodata.hrs", GAME_RESOURCEFILE, "45aa7026d441dd69957385c25d2fd33e", 2698},
- {"dino.hrs", GAME_OBJRESOURCEFILE, "7cf3665887a4a18e2fff6938a954c050", 66018},
- {"scripts.hrs", GAME_SCRIPTFILE, "d405841a249a365cf92fc65dd52fb953", 164181},
- {"dinosnd.hrs", GAME_SOUNDFILE | GAME_VOICEFILE, "dcf4ade416614b8a64f99dacfd3bd071", 199163997},
- {"dinoimag.hrs", GAME_IMAGEFILE, "d24d80676f7afcfaca0b61c95056044f", 42342931},
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NOASPECT)
- },
- GID_DINO,
- 0,
- // TODO: fill out the data below
- -1, // default scene
- NULL, // game resources
- 0, // number of fonts
- NULL, // font array
- NULL,
- },
-
- // Faery Tale Adventure II: Halls of the Dead Section /////////////////////////////////////////////////////
-
- // Faery Tale Adventure II: Halls of the Dead - English CD version
- {
- {
- "fta2",
- "",
- {
- {"ftadata.hrs", GAME_RESOURCEFILE, "6dc3cbed8df2ddd9f060a7dba4d33ef8", 15042},
- {"fta.hrs", GAME_OBJRESOURCEFILE, "c34a5ee5f1a14a87712a35c4a209a033", 213376},
- {"scripts.hrs", GAME_SCRIPTFILE, "95f33928f6c4f02ee04d2ec5c3314c30", 1041948},
- {"ftasound.hrs", GAME_SOUNDFILE, "ce930cb38922e6a03461f55d51b4e165", 12403350},
- {"ftaimage.hrs", GAME_IMAGEFILE, "09bb003733b20f924e2e373d2ddcd394", 21127397},
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NOASPECT)
- },
- GID_FTA2,
- 0,
- // TODO: fill out the data below
- -1, // default scene
- NULL, // game resources
- 0, // number of fonts
- NULL, // font array
- NULL,
- },
-#endif
-
{ AD_TABLE_END_MARKER, 0, 0, 0, NULL, 0, NULL, NULL }
};
diff --git a/engines/saga/displayinfo.h b/engines/saga/displayinfo.h
index 67448936ce..68559c73bb 100644
--- a/engines/saga/displayinfo.h
+++ b/engines/saga/displayinfo.h
@@ -278,7 +278,7 @@ static const GameDisplayInfo ITE_DisplayInfo = {
};
-#if defined(ENABLE_IHNM) || defined(ENABLE_SAGA2)
+#if defined(ENABLE_IHNM)
// IHNM
#define IHNM_CONVERSE_MAX_TEXT_WIDTH (485 - 8)
@@ -431,75 +431,6 @@ static const GameDisplayInfo IHNM_DisplayInfo = {
};
#endif
-#ifdef ENABLE_SAGA2
-// TODO: Fill in missing bits, currently contains IHNM_DisplayInfo
-static const GameDisplayInfo FTA2_DisplayInfo = {
- 640, 480, // logical width&height
-
- 0, // scene path y offset
- 304, // scene height
-
- 0, // status x offset
- 304, // status y offset
- 616, // status width
- 24, // status height
- 8, // status text y offset
- 253, // status text color
- 250, // status BG color
- 616, 304, // save reminder pos
- 24, 24, // save reminder w&h
- 0, // save reminder first sprite number
- 16, // number of save reminder sprites
-
- 11, 12, // left portrait x, y offset
- -1, -1, // right portrait x, y offset
-
- 8, 9, // inventory Up & Down button indexes
- 2, 4, // inventory rows, columns
-
- 0, 328, // main panel offsets
- ARRAYSIZE(IHNM_MainPanelButtons),
- IHNM_MainPanelButtons,
-
- IHNM_CONVERSE_MAX_TEXT_WIDTH,
- IHNM_CONVERSE_TEXT_HEIGHT,
- IHNM_CONVERSE_TEXT_LINES,
- 11, 12, // converse Up & Down button indexes
- 0, 328, // converse panel offsets
- ARRAYSIZE(IHNM_ConversePanelButtons),
- IHNM_ConversePanelButtons,
-
- 11, 0, // save file index
- 15, // optionSaveFileVisible
- 92, 46, // option panel offsets
- ARRAYSIZE(IHNM_OptionPanelButtons),
- IHNM_OptionPanelButtons,
-
- 190,94, // quit panel offsets
- 260,115, // quit panel width & height
- ARRAYSIZE(IHNM_QuitPanelButtons),
- IHNM_QuitPanelButtons,
-
- 190, 94, // load panel offsets
- 260, 115, // load panel width & height
- ARRAYSIZE(IHNM_LoadPanelButtons),
- IHNM_LoadPanelButtons,
-
- 2, // save edit index
- 190, 94, // save panel offsets
- 260, 115, // save panel width & height
- ARRAYSIZE(IHNM_SavePanelButtons),
- IHNM_SavePanelButtons,
-
- // No protection panel in IHNM
- -1, // protect edit index
- 0, 0, // protect panel offsets
- 0, 0, // protect panel width & height
- ARRAYSIZE(IHNM_SavePanelButtons),
- IHNM_SavePanelButtons
-};
-#endif
-
} // End of namespace Saga
#endif
diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp
index 2e2b5eeea3..06dfd6fef7 100644
--- a/engines/saga/interface.cpp
+++ b/engines/saga/interface.cpp
@@ -147,11 +147,6 @@ Interface::Interface(SagaEngine *vm) : _vm(vm) {
error("Interface::Interface() resource context not found");
}
- // Do nothing for SAGA2 games for now
- if (_vm->isSaga2()) {
- return;
- }
-
// Main panel
_mainPanel.buttons = _vm->getDisplayInfo().mainPanelButtons;
_mainPanel.buttonsCount = _vm->getDisplayInfo().mainPanelButtonsCount;
@@ -720,11 +715,6 @@ bool Interface::processAscii(Common::KeyState keystate) {
}
void Interface::setStatusText(const char *text, int statusColor) {
- if (_vm->getGameId() == GID_FTA2 || _vm->getGameId() == GID_DINO) {
- warning("setStatusText not implemented for SAGA2");
- return;
- }
-
if (_vm->getGameId() == GID_IHNM) {
// Don't show the status text for the IHNM chapter selection screens (chapter 8), or
// scene 0 (IHNM demo introduction)
diff --git a/engines/saga/introproc_saga2.cpp b/engines/saga/introproc_saga2.cpp
deleted file mode 100644
index 0b773b03f0..0000000000
--- a/engines/saga/introproc_saga2.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/* 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.
- *
- */
-
-#ifdef ENABLE_SAGA2
-
-// "Dinotopia" and "Faery Tale Adventure II: Halls of the Dead" Intro sequence scene procedures
-
-#include "saga/saga.h"
-#include "saga/scene.h"
-#include "saga/gfx.h"
-
-#include "common/events.h"
-#include "common/keyboard.h"
-#include "common/system.h"
-#include "common/textconsole.h"
-#include "graphics/palette.h"
-#include "graphics/surface.h"
-#include "video/smk_decoder.h"
-
-namespace Saga {
-
-int Scene::DinoStartProc() {
- _vm->_gfx->showCursor(false);
-
- playMovie("testvid.smk");
-
- return SUCCESS;
-}
-
-int Scene::FTA2StartProc() {
- _vm->_gfx->showCursor(false);
-
- playMovie("trimark.smk");
- playMovie("intro.smk");
-
- return SUCCESS;
-}
-
-int Scene::FTA2EndProc(FTA2Endings whichEnding) {
- char videoName[20];
-
- switch (whichEnding) {
- case kFta2BadEndingLaw:
- strcpy(videoName, "end_1.smk");
- break;
- case kFta2BadEndingChaos:
- strcpy(videoName, "end_2.smk");
- break;
- case kFta2GoodEnding1:
- strcpy(videoName, "end_3a.smk");
- break;
- case kFta2GoodEnding2:
- strcpy(videoName, "end_3b.smk");
- break;
- case kFta2BadEndingDeath:
- strcpy(videoName, "end_4.smk");
- break;
- default:
- error("Unknown FTA2 ending");
- }
-
- _vm->_gfx->showCursor(false);
-
- // Play ending
- playMovie(videoName);
-
- return SUCCESS;
-}
-
-void Scene::playMovie(const char *filename) {
- Video::SmackerDecoder *smkDecoder = new Video::SmackerDecoder();
-
- if (!smkDecoder->loadFile(filename))
- return;
-
- uint16 x = (g_system->getWidth() - smkDecoder->getWidth()) / 2;
- uint16 y = (g_system->getHeight() - smkDecoder->getHeight()) / 2;
- bool skipVideo = false;
-
- smkDecoder->start();
-
- while (!_vm->shouldQuit() && !smkDecoder->endOfVideo() && !skipVideo) {
- if (smkDecoder->needsUpdate()) {
- const Graphics::Surface *frame = smkDecoder->decodeNextFrame();
- if (frame) {
- _vm->_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
-
- if (smkDecoder->hasDirtyPalette())
- _vm->_system->getPaletteManager()->setPalette(smkDecoder->getPalette(), 0, 256);
-
- _vm->_system->updateScreen();
- }
- }
-
- Common::Event event;
- while (_vm->_system->getEventManager()->pollEvent(event)) {
- if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP)
- skipVideo = true;
- }
-
- _vm->_system->delayMillis(10);
- }
-}
-
-} // End of namespace Saga
-
-#endif
diff --git a/engines/saga/metaengine.cpp b/engines/saga/metaengine.cpp
index e4fe89d3ad..9ebfefd5b0 100644
--- a/engines/saga/metaengine.cpp
+++ b/engines/saga/metaengine.cpp
@@ -112,12 +112,6 @@ Common::Error SagaMetaEngine::createInstance(OSystem *syst, Engine **engine, con
case Saga::GID_IHNM:
#ifndef ENABLE_IHNM
return Common::Error(Common::kUnsupportedGameidError, _s("I Have No Mouth support not compiled in"));
-#endif
- break;
- case Saga::GID_DINO:
- case Saga::GID_FTA2:
-#ifndef ENABLE_SAGA2
- return Common::Error(Common::kUnsupportedGameidError, _s("SAGA2 support not compiled in"));
#endif
break;
default:
@@ -265,12 +259,6 @@ const GameDisplayInfo &SagaEngine::getDisplayInfo() {
#ifdef ENABLE_IHNM
case GID_IHNM:
return IHNM_DisplayInfo;
-#endif
-#ifdef ENABLE_SAGA2
- case GID_DINO:
- return FTA2_DisplayInfo; // TODO
- case GID_FTA2:
- return FTA2_DisplayInfo;
#endif
default:
error("getDisplayInfo: Unknown game ID");
diff --git a/engines/saga/module.mk b/engines/saga/module.mk
index 07af31efc0..54d0fddb19 100644
--- a/engines/saga/module.mk
+++ b/engines/saga/module.mk
@@ -42,12 +42,6 @@ MODULE_OBJS += \
sfuncs_ihnm.o
endif
-ifdef ENABLE_SAGA2
-MODULE_OBJS += \
- introproc_saga2.o \
- resource_hrs.o
-endif
-
# This module can be built as a plugin
ifeq ($(ENABLE_SAGA), DYNAMIC_PLUGIN)
PLUGIN := 1
diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp
index 9a7d91b084..fb45bac54d 100644
--- a/engines/saga/music.cpp
+++ b/engines/saga/music.cpp
@@ -212,8 +212,6 @@ Music::Music(SagaEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer), _pla
// Note that the IHNM demo has only got one music file
// (music.rsc). It is assumed that it contains FM music
_musicContext = _vm->_resource->getContext(GAME_MUSICFILE_FM);
- } else if (_vm->getGameId() == GID_DINO || _vm->getGameId() == GID_FTA2) {
- _musicContext = _vm->_resource->getContext(GAME_SOUNDFILE);
}
}
@@ -323,10 +321,6 @@ void Music::play(uint32 resourceId, MusicFlags flags) {
realTrackNumber = resourceId - 8;
} else if (_vm->getGameId() == GID_IHNM) {
realTrackNumber = resourceId + 1;
- } else if (_vm->getGameId() == GID_DINO || _vm->getGameId() == GID_FTA2) {
- realTrackNumber = resourceId + 1;
- uint32 musicTrackTag = MKTAG('X','M','I', (byte)(resourceId + 1));
- resourceId = _musicContext->getEntryNum(musicTrackTag);
}
// Try to open standalone digital track
diff --git a/engines/saga/resource.cpp b/engines/saga/resource.cpp
index 55e4b53138..9f1ee723ae 100644
--- a/engines/saga/resource.cpp
+++ b/engines/saga/resource.cpp
@@ -184,10 +184,6 @@ bool Resource::createContexts() {
#ifdef ENABLE_IHNM
{ GID_IHNM, "sfx.res", false, 0 },
{ GID_IHNM, "sfx.cmp", true, 0 },
-#endif
-#ifdef ENABLE_SAGA2
- { GID_FTA2, "ftasound.hrs", false, 0 },
- { GID_DINO, "dinosnd.hrs", false, 0 },
#endif
{ -1, "", false, 0 }
};
@@ -224,9 +220,6 @@ bool Resource::createContexts() {
{ GID_IHNM, "voicess.cmp", true , 0},
{ GID_IHNM, "voicesd.res", false , 0},
{ GID_IHNM, "voicesd.cmp", true , 0},
-#endif
-#ifdef ENABLE_SAGA2
- { GID_FTA2, "ftavoice.hrs", false , 0},
#endif
{ -1, "", false , 0}
};
diff --git a/engines/saga/resource.h b/engines/saga/resource.h
index fc2ad1283c..0f584ae47e 100644
--- a/engines/saga/resource.h
+++ b/engines/saga/resource.h
@@ -59,14 +59,12 @@ struct PatchData {
};
struct ResourceData {
- uint32 id; // SAGA2
- uint32 category; // SAGA2
size_t offset;
size_t size;
PatchData *patchData;
ResourceData() :
- id(0), category(0), offset(0), size(0), patchData(NULL) {
+ offset(0), size(0), patchData(NULL) {
}
~ResourceData() {
@@ -75,10 +73,6 @@ struct ResourceData {
patchData = NULL;
}
}
-
- bool isExternal() { // SAGA2
- return ((offset & (1L<<31)) != 0L);
- }
};
typedef Common::Array<ResourceData> ResourceDataArray;
@@ -128,22 +122,6 @@ public:
return &_table[resourceId];
}
- // SAGA 2
- int32 getEntryNum(uint32 id) {
- int32 num = 0;
- uint32 miloCategory = MKTAG('M', 'I', 'L', 'O');
-
- for (ResourceDataArray::const_iterator i = _table.begin(); i != _table.end(); ++i) {
- //uint32 c = i->category;
- //debug("%c%c%c%c, offset: %d, size: %d", (c >> 24), (c >> 16) & 0xFF, (c >> 8) & 0xFF, c & 0xFF, i->offset, i->size);
- // Ignore low quality music resources (MILO)
- if (i->id == id && i->category != miloCategory)
- return num;
-
- num++;
- }
- return -1;
- }
protected:
const char *_fileName;
uint16 _fileType;
@@ -278,38 +256,6 @@ private:
};
#endif
-#ifdef ENABLE_SAGA2
-// DINO, FTA2
-class ResourceContext_HRS: public ResourceContext {
-protected:
- ResourceDataArray _categories;
-
- bool loadRes(uint32 contextOffset, uint32 contextSize) override {
- return loadResV2(contextSize);
- }
- bool loadResV2(uint32 contextSize);
-
- void readCategory(ResourceData &element);
- void readEntry(ResourceData &element);
- uint32 getCategory(uint32 resourceOffset);
-};
-
-class Resource_HRS : public Resource {
-public:
- Resource_HRS(SagaEngine *vm) : Resource(vm) {}
- uint32 convertResourceId(uint32 resourceId) override { return resourceId; }
- void loadGlobalResources(int chapter, int actorsEntrance) override {}
- MetaResource* getMetaResource() override {
- MetaResource *dummy = 0;
- return dummy;
- }
-protected:
- ResourceContext *createContext() override {
- return new ResourceContext_HRS();
- }
-};
-#endif
-
} // End of namespace Saga
#endif
diff --git a/engines/saga/resource_hrs.cpp b/engines/saga/resource_hrs.cpp
deleted file mode 100644
index 9257f65cbc..0000000000
--- a/engines/saga/resource_hrs.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/* 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.
- *
- */
-
-#ifdef ENABLE_SAGA2
-
-// HRS Resource file management module (SAGA 2, used in DINO and FTA2)
-
-#include "saga/saga.h"
-
-#include "saga/actor.h"
-#include "saga/animation.h"
-#include "saga/interface.h"
-#include "saga/music.h"
-#include "saga/resource.h"
-#include "saga/scene.h"
-#include "saga/sndres.h"
-
-#include "common/endian.h"
-
-namespace Saga {
-
-void ResourceContext_HRS::readCategory(ResourceData &element) {
- element.id = _file.readUint32BE();
- element.offset = _file.readUint32LE();
- element.size = _file.readUint32LE();
- element.category = 0;
- debug(3, "Category: id %u, offset %u, size %u", element.id, (uint)element.offset, (uint)element.size);
-}
-
-void ResourceContext_HRS::readEntry(ResourceData &element) {
- element.id = _file.readUint32BE();
- element.offset = _file.readUint32LE();
- element.size = _file.readUint32LE();
- element.category = getCategory(_file.pos());
- debug(3, "Entry: id %u, offset %u, size %u", element.id, (uint)element.offset, (uint)element.size);
-}
-
-uint32 ResourceContext_HRS::getCategory(uint32 resourceOffset) {
- for (int i = _categories.size() - 1; i >= 0; --i) {
- if (resourceOffset >= _categories[i].offset)
- return _categories[i].id;
- }
-
- error("Unknown category for offset %d", resourceOffset);
-}
-
-static bool categorySortHelper(const ResourceData &r1, const ResourceData &r2) {
- return r1.offset < r2.offset;
-}
-
-bool ResourceContext_HRS::loadResV2(uint32 contextSize) {
- ResourceData origin;
- uint32 firstEntryOffset;
- uint32 tableSize;
- int i, count;
- const uint32 resourceSize = 4 + 4 + 4; // id, size, offset
-
- debug(3, "Context %s =====", _fileName);
- _file.seek(0, SEEK_SET);
-
- readCategory(origin);
-
- // Check if the file is valid
- if (origin.id != MKTAG('H','R','E','S')) { // header
- return false;
- }
-
- // Read offset of first entry
- _file.seek(origin.offset - sizeof(uint32), SEEK_SET);
- firstEntryOffset = _file.readUint32LE();
-
- // Allocate buffers for table, categories and data
- _categories.resize(origin.size / resourceSize);
- tableSize = origin.offset - firstEntryOffset - sizeof(uint32);
- _table.resize(tableSize / resourceSize);
-
- // Read categories
- count = origin.size / resourceSize;
- debug(3, "File: %s, categories: %d =====", _file.getName(), count);
- for (i = 0; i < count; i++) {
- readCategory(_categories[i]);
- //uint32 id = _categories[i].id;
- //debug("%i: %c%c%c%c, offset: %d, size: %d", i, (id >> 24), (id >> 16) & 0xFF, (id >> 8) & 0xFF, id & 0xFF, _categories[i].offset, _categories[i].size);
- }
-
- Common::sort(_categories.begin(), _categories.end(), categorySortHelper);
-
- _file.seek(firstEntryOffset, SEEK_SET);
-
- // Read table entries
- count = tableSize / resourceSize;
- debug(3, "File: %s, entries: %d =====", _file.getName(), count);
- for (i = 0; i < count; i++) {
- readEntry(_table[i]);
- //debug("%i: offset: %d, size: %d", i, _table[i].offset, _table[i].size);
- }
- return true;
-}
-
-} // End of namespace Saga
-
-#endif
diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp
index 7c2d21a407..727d803f17 100644
--- a/engines/saga/saga.cpp
+++ b/engines/saga/saga.cpp
@@ -158,13 +158,11 @@ SagaEngine::~SagaEngine() {
delete _events;
_events = NULL;
- if (!isSaga2()) {
- delete _font;
- _font = NULL;
+ delete _font;
+ _font = NULL;
- delete _sprite;
- _sprite = NULL;
- }
+ delete _sprite;
+ _sprite = NULL;
delete _anim;
_anim = NULL;
@@ -172,10 +170,8 @@ SagaEngine::~SagaEngine() {
delete _script;
_script = NULL;
- if (!isSaga2()) {
- delete _interface;
- _interface = NULL;
- }
+ delete _interface;
+ _interface = NULL;
delete _actor;
_actor = NULL;
@@ -231,12 +227,6 @@ Common::Error SagaEngine::run() {
case GID_IHNM:
_resource = new Resource_RES(this);
break;
-#endif
-#ifdef ENABLE_SAGA2
- case GID_DINO:
- case GID_FTA2:
- _resource = new Resource_HRS(this);
- break;
#endif
default:
break;
@@ -249,20 +239,15 @@ Common::Error SagaEngine::run() {
}
// Initialize engine modules
- // TODO: implement differences for SAGA2
_sndRes = new SndRes(this);
_events = new Events(this);
- if (!isSaga2()) {
- if (getLanguage() == Common::JA_JPN)
- _font = new SJISFont(this);
- else
- _font = new DefaultFont(this);
- _sprite = new Sprite(this);
- _script = new SAGA1Script(this);
- } else {
- _script = new SAGA2Script(this);
- }
+ if (getLanguage() == Common::JA_JPN)
+ _font = new SJISFont(this);
+ else
+ _font = new DefaultFont(this);
+ _sprite = new Sprite(this);
+ _script = new SAGA1Script(this);
_anim = new Anim(this);
_interface = new Interface(this); // requires script module
@@ -296,16 +281,12 @@ Common::Error SagaEngine::run() {
// Initialize system specific sound
_sound = new Sound(this, _mixer);
- if (!isSaga2()) {
- _interface->converseClear();
- _script->setVerb(_script->getVerbType(kVerbWalkTo));
- }
+ _interface->converseClear();
+ _script->setVerb(_script->getVerbType(kVerbWalkTo));
_music->setVolume(_musicVolume, 1);
- if (!isSaga2()) {
- _gfx->initPalette();
- }
+ _gfx->initPalette();
if (_voiceFilesExist) {
if (getGameId() == GID_IHNM) {
diff --git a/engines/saga/saga.h b/engines/saga/saga.h
index 514031f7fe..a4fdc1a5ca 100644
--- a/engines/saga/saga.h
+++ b/engines/saga/saga.h
@@ -38,25 +38,12 @@ struct ADGameFileDescription;
/**
* This is the namespace of the SAGA engine.
*
- * Status of this engine:
- *
- * This engine contains 2 main engine generations, SAGA and SAGA2
- *
- * SAGA status: complete
- *
- * SAGA2 status: in early stages of development, no recent activity. Contact sev
- * if you want to work on it, since we have some original source codes.
+ * Status of this engine: complete
*
* Games using this engine:
- *
- * SAGA:
* - Inherit the Earth
* - I Have No Mouth And I Must Scream
*
- * SAGA2:
- * - Dinotopia
- * - Faery Tale Adventure II: Halls of the Dead
- *
*/
namespace Saga {
@@ -549,7 +536,6 @@ public:
bool isBigEndian() const;
bool isMacResources() const;
- bool isSaga2() const { return getGameId() == GID_DINO || getGameId() == GID_FTA2; }
const GameResourceDescription *getResourceDescription() const;
const GameFontDescription *getFontDescription(int index) const;
diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp
index b9a0f765aa..1823d4886b 100644
--- a/engines/saga/scene.cpp
+++ b/engines/saga/scene.cpp
@@ -139,13 +139,6 @@ Scene::Scene(SagaEngine *vm) : _vm(vm) {
uint32 resourceId;
uint i;
- // Do nothing for SAGA2 games for now
- if (_vm->isSaga2()) {
- _inGame = false;
- _sceneLoaded = false;
- return;
- }
-
// Load scene module resource context
_sceneContext = _vm->_resource->getContext(GAME_RESOURCEFILE);
if (_sceneContext == NULL) {
@@ -214,11 +207,6 @@ Scene::Scene(SagaEngine *vm) : _vm(vm) {
}
Scene::~Scene() {
- // Do nothing for SAGA2 games for now
- if (_vm->isSaga2()) {
- return;
- }
-
delete _actionMap;
delete _objectMap;
}
@@ -275,14 +263,6 @@ void Scene::startScene() {
case GID_IHNM:
IHNMStartProc();
break;
-#endif
-#ifdef ENABLE_SAGA2
- case GID_DINO:
- DinoStartProc();
- break;
- case GID_FTA2:
- FTA2StartProc();
- break;
#endif
default:
error("Scene::start(): Error: Can't start game... gametype not supported");
@@ -1094,11 +1074,6 @@ void Scene::processSceneResources(SceneResourceDataArray &resourceList) {
}
void Scene::draw() {
- // Do nothing for SAGA2 games for now
- if (_vm->isSaga2()) {
- return;
- }
-
if (_sceneDescription.flags & kSceneFlagISO) {
_vm->_isoMap->adjustScroll(false);
_vm->_isoMap->draw();
diff --git a/engines/saga/script.cpp b/engines/saga/script.cpp
index 08af70a00d..d468653d48 100644
--- a/engines/saga/script.cpp
+++ b/engines/saga/script.cpp
@@ -149,50 +149,6 @@ SAGA1Script::~SAGA1Script() {
debug(8, "Shutting down scripting subsystem.");
}
-SAGA2Script::SAGA2Script(SagaEngine *vm) : Script(vm) {
- ByteArray resourceData;
-
- debug(8, "Initializing scripting subsystem");
- // Load script resource file context
- _scriptContext = _vm->_resource->getContext(GAME_SCRIPTFILE);
- if (_scriptContext == NULL) {
- error("Script::Script() script context not found");
- }
-
- // Script export segment (lookup table)
- uint32 saga2ExportSegId = MKTAG('_','E','X','P');
- int32 entryNum = _scriptContext->getEntryNum(saga2ExportSegId);
- if (entryNum < 0)
- error("Unable to locate the script's export segment");
- debug(3, "Loading module LUT from resource %i", entryNum);
- _vm->_resource->loadResource(_scriptContext, (uint32)entryNum, resourceData);
-
- _modulesLUTEntryLen = sizeof(uint32);
-
- // Calculate number of entries
- int modulesCount = resourceData.size() / _modulesLUTEntryLen + 1;
-
- debug(3, "LUT has %i entries", modulesCount);
-
- // Script data segment
- /*
- uint32 saga2DataSegId = MKTAG('_','_','D','A');
- entryNum = _scriptContext->getEntryNum(saga2DataSegId);
- if (entryNum < 0)
- error("Unable to locate the script's data segment");
- debug(3, "Loading module data from resource %i", entryNum);
- _vm->_resource->loadResource(_scriptContext, (uint32)entryNum, resourcePointer, resourceLength);
- */
-
- // TODO
-}
-
-SAGA2Script::~SAGA2Script() {
- debug(8, "Shutting down scripting subsystem.");
-
- // TODO
-}
-
// Initializes the scripting module.
// Loads script resource look-up table, initializes script data system
Script::Script(SagaEngine *vm) : _vm(vm) {
@@ -316,134 +272,7 @@ void Script::setupScriptOpcodeList() {
OPCODE(opAnimate) // 87
};
-#ifdef ENABLE_SAGA2
- static const ScriptOpDescription SAGA2ScriptOpcodes[] = {
- OPCODE(opDummy), // 00: Undefined
- // Internal operations
- OPCODE(opNextBlock), // 01: Continue execution at next block
- OPCODE(opDup), // 02: Duplicate 16-bit value on stack
- OPCODE(opDrop), // 03: Drop 16-bit value on stack
- // Primary values
- OPCODE(opZero), // 04: Push a zero on the stack
- OPCODE(opOne), // 05: Push a one on the stack
- OPCODE(opConstInt), // 06: Constant integer
- OPCODE(opDummy), // 07: Constant ID reference (unused)
- OPCODE(opStrLit), // 08: String literal
- OPCODE(opDummy), // 09: Symbol address (unused)
- OPCODE(opDummy), // 10: Symbol contents (unused)
- OPCODE(opDummy), // 11: Reference to "this" (unused)
- OPCODE(opDummy), // 12: Dereference of an ID (unused)
- // References within this module
- OPCODE(opGetFlag), // 13: Read flag bit
- OPCODE(opGetByte), // 14: Read byte
- OPCODE(opGetInt), // 15: Read integer
- OPCODE(opDummy), // 16: Read string (unused)
- OPCODE(opDummy), // 17: Read id (unused)
- OPCODE(opPutFlag), // 18: Write flag bit
- OPCODE(opPutByte), // 19: Write byte
- OPCODE(opPutInt), // 20: Write integer
- OPCODE(opDummy), // 21: Write string (unused)
- OPCODE(opDummy), // 22: Write id (unused)
- OPCODE(opDummy), // 23: Push effective address (unused)
- // Void versions, which consume their arguments
- OPCODE(opPutFlagV), // 24: Write flag bit
- OPCODE(opPutByteV), // 25: Write byte
- OPCODE(opPutIntV), // 26: Write integer
- OPCODE(opDummy), // 27: Write string (unused)
- OPCODE(opDummy), // 28: Write id (unused)
- // Function calling
- OPCODE(opCallNear), // 29: Call function in the same segment
- OPCODE(opCallFar), // 30: Call function in other segment
- OPCODE(opCcall), // 31: Call C function
- OPCODE(opCcallV), // 32: Call C function ()
- OPCODE(opCallMember), // 33: Call member function
- OPCODE(opCallMemberV), // 34: Call member function ()
- OPCODE(opEnter), // 35: Enter a function
- OPCODE(opReturn), // 36: Return from a function
- OPCODE(opReturnV), // 37: Return from a function ()
- // Branching
- OPCODE(opJmp), // 38
- OPCODE(opJmpTrueV), // 39: Test argument and consume it
- OPCODE(opJmpFalseV), // 40: Test argument and consume it
- OPCODE(opJmpTrue), // 41: Test argument but don't consume it
- OPCODE(opJmpFalse), // 42: Test argument but don't consume it
- OPCODE(opJmpSwitch), // 43: Switch (integer)
- OPCODE(opDummy), // 44: Switch (string) (unused)
- OPCODE(opJmpRandom), // 45: Random jump
- // Unary operators
- OPCODE(opNegate), // 46
- OPCODE(opNot), // 47
- OPCODE(opCompl), // 48
- OPCODE(opIncV), // 49: Increment, don't push
- OPCODE(opDecV), // 50: Increment, don't push
- OPCODE(opPostInc), // 51
- OPCODE(opPostDec), // 52
- // Arithmetic
- OPCODE(opAdd), // 53
- OPCODE(opSub), // 54
- OPCODE(opMul), // 55
- OPCODE(opDiv), // 56
- OPCODE(opMod), // 57
- // Conditional
- OPCODE(opDummy), // 58: opConditional (unused)
- OPCODE(opDummy), // 59: opComma (unused)
- // Comparison
- OPCODE(opEq), // 60
- OPCODE(opNe), // 61
- OPCODE(opGt), // 62
- OPCODE(opLt), // 63
- OPCODE(opGe), // 64
- OPCODE(opLe), // 65
- // String comparison
- OPCODE(opDummy), // 66: opStrEq (unused)
- OPCODE(opDummy), // 67: opStrNe (unused)
- OPCODE(opDummy), // 68: opStrGt (unused)
- OPCODE(opDummy), // 69: opStrLt (unused)
- OPCODE(opDummy), // 70: opStrGe (unused)
- OPCODE(opDummy), // 71: opStrLe (unused)
- // Shift
- OPCODE(opRsh), // 72
- OPCODE(opLsh), // 73
- // Bitwise
- OPCODE(opAnd), // 74
- OPCODE(opOr), // 75
- OPCODE(opXor), // 76
- // Logical
- OPCODE(opLAnd), // 77
- OPCODE(opLOr), // 78
- OPCODE(opLXor), // 79
- // String manipulation
- OPCODE(opDummy), // 80: opStrCat, string concatenation (unused)
- OPCODE(opDummy), // 81: opStrFormat, string formatting (unused)
- // Assignment
- OPCODE(opDummy), // 82: assign (unused)
- OPCODE(opDummy), // 83: += (unused)
- OPCODE(opDummy), // 84: -= (unused)
- OPCODE(opDummy), // 85: *= (unused)
- OPCODE(opDummy), // 86: /= (unused)
- OPCODE(opDummy), // 87: %= (unused)
- OPCODE(opDummy), // 88: <<= (unused)
- OPCODE(opDummy), // 89: >>= (unused)
- OPCODE(opDummy), // 90: and (unused)
- OPCODE(opDummy), // 91: or (unused)
- // Special
- OPCODE(opSpeak), // 92
- OPCODE(opDialogBegin), // 93
- OPCODE(opDialogEnd), // 94
- OPCODE(opReply), // 95
- OPCODE(opAnimate), // 96
- OPCODE(opJmpSeedRandom),// 97: Seeded random jump
- OPCODE(opDummy) // 98: Get seeded export number (unused)
- };
-#endif
-
- if (!_vm->isSaga2()) {
- _scriptOpsList = SAGA1ScriptOpcodes;
-#ifdef ENABLE_SAGA2
- } else {
- _scriptOpsList = SAGA2ScriptOpcodes;
-#endif
- }
+ _scriptOpsList = SAGA1ScriptOpcodes;
}
diff --git a/engines/saga/script.h b/engines/saga/script.h
index f4aacff3f0..3f614f33f2 100644
--- a/engines/saga/script.h
+++ b/engines/saga/script.h
@@ -612,12 +612,6 @@ public:
~SAGA1Script() override;
};
-class SAGA2Script : public Script {
-public:
- SAGA2Script(SagaEngine *vm);
- ~SAGA2Script() override;
-};
-
} // End of namespace Saga
#endif
diff --git a/engines/saga/shorten.cpp b/engines/saga/shorten.cpp
deleted file mode 100644
index 8284e9ec7c..0000000000
--- a/engines/saga/shorten.cpp
+++ /dev/null
@@ -1,568 +0,0 @@
-/* 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/stream.h"
-#include "common/textconsole.h"
-#include "audio/audiostream.h"
-
-#include "saga/shorten.h"
-
-#ifdef SOUND_SHORTEN_H
-
-// Based on etree's Shorten tool, version 3.6.1
-// http://etree.org/shnutils/shorten/
-// and
-// https://github.com/soiaf/Java-Shorten-decoder
-
-// FIXME: This doesn't work yet correctly
-
-#include "common/util.h"
-
-#include "audio/decoders/raw.h"
-
-namespace Saga {
-
-#define MASKTABSIZE 33
-#define MAX_SUPPORTED_VERSION 3
-#define DEFAULT_BLOCK_SIZE 256
-
-enum kShortenTypes {
- kTypeAU1 = 0, // lossless ulaw
- kTypeS8 = 1, // signed 8 bit
- kTypeU8 = 2, // unsigned 8 bit
- kTypeS16HL = 3, // signed 16 bit shorts: high-low
- kTypeU16HL = 4, // unsigned 16 bit shorts: high-low
- kTypeS16LH = 5, // signed 16 bit shorts: low-high
- kTypeU16LH = 6, // unsigned 16 bit shorts: low-high
- kTypeULaw = 7, // lossy ulaw
- kTypeAU2 = 8, // new ulaw with zero mapping
- kTypeAU3 = 9, // lossless alaw
- kTypeALaw = 10, // lossy alaw
- kTypeWAV = 11, // WAV
- kTypeAIFF = 12, // AIFF
- kTypeEOF = 13,
- kTypeGenericULaw = 128,
- kTypeGenericALaw = 129
-};
-
-enum kShortenCommands {
- kCmdDiff0 = 0,
- kCmdDiff1 = 1,
- kCmdDiff2 = 2,
- kCmdDiff3 = 3,
- kCmdQuit = 4,
- kCmdBlockSize = 5,
- kCmdBitShift = 6,
- kCmdQLPC = 7,
- kCmdZero = 8,
- kCmdVerbatim = 9
-};
-
-#ifndef M_LN2
-#define M_LN2 0.69314718055994530942
-#endif
-
-// ---------------------------------------------------------------------------
-
-class ShortenGolombReader {
-public:
- ShortenGolombReader(Common::ReadStream *stream, int version);
- ~ShortenGolombReader() {}
- uint32 getUint32(uint32 numBits); // UINT_GET
- int32 getURice(uint32 numBits); // uvar_get
- int32 getSRice(uint32 numBits); // var_get
-private:
- int _version;
- uint32 _nbitget;
- uint32 _buf;
- uint32 _masktab[MASKTABSIZE];
- Common::ReadStream *_stream;
-};
-
-ShortenGolombReader::ShortenGolombReader(Common::ReadStream *stream, int version) {
- _stream = stream;
- _version = version;
- uint32 val = 0;
- _masktab[0] = 0;
- _nbitget = 0;
- _buf = 0;
-
- for (int i = 1; i < MASKTABSIZE; i++) {
- val <<= 1;
- val |= 1;
- _masktab[i] = val;
- }
-}
-
-int32 ShortenGolombReader::getURice(uint32 numBits) {
- int32 result = 0;
-
- if (!_nbitget) {
- _buf = _stream->readUint32BE();
- _nbitget = 32;
- }
-
- for (result = 0; !(_buf & (1L << --_nbitget)); result++) {
- if (!_nbitget) {
- _buf = _stream->readUint32BE();
- _nbitget = 32;
- }
- }
-
- while (numBits != 0) {
- if (_nbitget >= numBits) {
- result = (result << numBits) | ((_buf >> (_nbitget - numBits)) & _masktab[numBits]);
- _nbitget -= numBits;
- numBits = 0;
- } else {
- result = (result << _nbitget) | (_buf & _masktab[_nbitget]);
- _buf = _stream->readUint32BE();
- numBits -= _nbitget;
- _nbitget = 32;
- }
- }
-
- return result;
-}
-
-int32 ShortenGolombReader::getSRice(uint32 numBits) {
- uint32 uvar = (uint32) getURice(numBits + 1);
- return (uvar & 1) ? (int32) ~(uvar >> 1) : (int32) (uvar >> 1);
-}
-
-uint32 ShortenGolombReader::getUint32(uint32 numBits) {
- return (_version == 0) ? (uint32)getURice(numBits) : (uint32)getURice(getURice(2));
-}
-
-// ---------------------------------------------------------------------------
-
-byte *loadShortenFromStream(Common::ReadStream &stream, int &size, int &rate, byte &flags) {
- int32 *buffer[2], *offset[2]; // up to 2 channels
- int32 *oldValues[2];
- byte *unpackedBuffer = 0;
- byte *pBuf = unpackedBuffer;
- int prevSize = 0;
- int32 *lpc = 0;
-
- ShortenGolombReader *gReader;
- uint32 i, j, version, mean, type, channels, blockSize;
- uint32 maxLPC = 0, lpcqOffset = 0;
- int32 bitShift = 0, wrap = 0;
- flags = 0;
- size = 0;
-
- // Read header
- byte magic[4];
- stream.read(magic, 4);
- if (memcmp(magic, "ajkg", 4) != 0) {
- warning("loadShortenFromStream: No 'ajkg' header");
- return NULL;
- }
-
- version = stream.readByte();
-
- if (version > MAX_SUPPORTED_VERSION) {
- warning("loadShortenFromStream: Can't decode version %d, maximum supported version is %d", version, MAX_SUPPORTED_VERSION);
- return NULL;
- }
-
- mean = (version < 2) ? 0 : 4;
-
- gReader = new ShortenGolombReader(&stream, version);
-
- // Get file type
- type = gReader->getUint32(4);
-
- switch (type) {
- case kTypeS8:
- mean = 0;
- break;
- case kTypeU8:
- flags |= Audio::FLAG_UNSIGNED;
- mean = 0x80;
- break;
- case kTypeS16LH:
- flags |= Audio::FLAG_LITTLE_ENDIAN;
- // fallthrough
- case kTypeS16HL:
- flags |= Audio::FLAG_16BITS;
- mean = 0;
- break;
- case kTypeU16LH:
- flags |= Audio::FLAG_LITTLE_ENDIAN;
- // fallthrough
- case kTypeU16HL:
- flags |= Audio::FLAG_16BITS;
- flags |= Audio::FLAG_UNSIGNED;
- mean = 0x8000;
- break;
- case kTypeWAV:
- // TODO: Perhaps implement this if we find WAV Shorten encoded files
- warning("loadShortenFromStream: Type WAV is not supported");
- delete gReader;
- return NULL;
- case kTypeAIFF:
- // TODO: Perhaps implement this if we find AIFF Shorten encoded files
- warning("loadShortenFromStream: Type AIFF is not supported");
- delete gReader;
- return NULL;
- case kTypeAU1:
- case kTypeAU2:
- case kTypeAU3:
- case kTypeULaw:
- case kTypeALaw:
- case kTypeEOF:
- case kTypeGenericULaw:
- case kTypeGenericALaw:
- default:
- warning("loadShortenFromStream: Type %d is not supported", type);
- delete gReader;
- return NULL;
- }
-
- // Get channels
- channels = gReader->getUint32(0);
- if (channels != 1 && channels != 2) {
- warning("loadShortenFromStream: Only 1 or 2 channels are supported, stream contains %d channels", channels);
- delete gReader;
- return NULL;
- }
-
- // Get block size
- if (version > 0) {
- blockSize = gReader->getUint32((int)(log((double) DEFAULT_BLOCK_SIZE) / M_LN2));
- maxLPC = gReader->getUint32(2);
- mean = gReader->getUint32(0);
- uint32 skipBytes = gReader->getUint32(1);
- if (skipBytes > 0) {
- prevSize = size;
- size += skipBytes;
- unpackedBuffer = (byte *) realloc(unpackedBuffer, size);
- pBuf = unpackedBuffer + prevSize;
- for (i = 0; i < skipBytes; i++) {
- *pBuf++ = gReader->getUint32(7) & 0xFF;
- }
- }
- } else {
- blockSize = DEFAULT_BLOCK_SIZE;
- }
-
- wrap = MAX<uint32>(3, maxLPC);
-
- // Initialize buffers
- for (i = 0; i < channels; i++) {
- buffer[i] = (int32 *)malloc((blockSize + wrap) * 4);
- offset[i] = (int32 *)malloc((MAX<uint32>(1, mean)) * 4);
- oldValues[i] = (int32 *)malloc(64 * 4);
- memset(buffer[i], 0, (blockSize + wrap) * 4);
- memset(offset[i], 0, (MAX<uint32>(1, mean)) * 4);
- memset(oldValues[i], 0, 64 * 4);
- }
-
- if (maxLPC > 0)
- lpc = (int32 *) malloc(maxLPC * 4);
-
- if (version > 1)
- lpcqOffset = 1 << 5;
-
- // Init offset
- int32 offsetMean = 0;
- uint32 blocks = MAX<int>(1, mean);
-
- if (type == kTypeU8)
- offsetMean = 0x80;
- else if (type == kTypeU16HL || type == kTypeU16LH)
- offsetMean = 0x8000;
-
- for (uint32 channel = 0; channel < channels; channel++)
- for (uint32 block = 0; block < blocks; block++)
- offset[channel][block] = offsetMean;
-
-
- uint32 curChannel = 0, cmd = 0;
-
- // Parse Shorten commands
- while (true) {
- cmd = gReader->getURice(2);
-
- if (cmd == kCmdQuit)
- break;
-
- switch (cmd) {
- case kCmdZero:
- case kCmdDiff0:
- case kCmdDiff1:
- case kCmdDiff2:
- case kCmdDiff3:
- case kCmdQLPC:
- {
- int32 channelOffset = 0, energy = 0;
- uint32 lpcNum = 0;
-
- if (cmd != kCmdZero) {
- energy = gReader->getURice(3);
- // hack for version 0
- if (version == 0)
- energy--;
- }
-
- // Find mean offset (code duplicated below)
- if (mean == 0) {
- channelOffset = offset[curChannel][0];
- } else {
- int32 sum = (version < 2) ? 0 : mean / 2;
- for (i = 0; i < mean; i++)
- sum += offset[curChannel][i];
-
- channelOffset = sum / mean;
-
- if (version >= 2 && bitShift > 0)
- channelOffset = (channelOffset >> (bitShift - 1)) >> 1;
- }
-
- switch (cmd) {
- case kCmdZero:
- for (i = 0; i < blockSize; i++)
- buffer[curChannel][i] = 0;
- break;
- case kCmdDiff0:
- for (i = 0; i < blockSize; i++)
- buffer[curChannel][i] = gReader->getSRice(energy) + channelOffset;
- break;
- case kCmdDiff1:
- for (i = 0; i < blockSize; i++) {
- if (i == 0)
- buffer[curChannel][i] = gReader->getSRice(energy) + oldValues[curChannel][0];
- else
- buffer[curChannel][i] = gReader->getSRice(energy) + buffer[curChannel][i - 1];
- }
- break;
- case kCmdDiff2:
- for (i = 0; i < blockSize; i++) {
- if (i == 0)
- buffer[curChannel][i] = gReader->getSRice(energy) + 2 * oldValues[curChannel][0] - oldValues[curChannel][1];
- else if (i == 1)
- buffer[curChannel][i] = gReader->getSRice(energy) + 2 * buffer[curChannel][0] - oldValues[curChannel][0];
- else
- buffer[curChannel][i] = gReader->getSRice(energy) + 2 * buffer[curChannel][i - 1] - buffer[curChannel][i - 2];
- }
- break;
- case kCmdDiff3:
- for (i = 0; i < blockSize; i++) {
- if (i == 0)
- buffer[curChannel][i] = gReader->getSRice(energy) + 3 * (oldValues[curChannel][0] - oldValues[curChannel][1]) + oldValues[curChannel][2];
- else if (i == 1)
- buffer[curChannel][i] = gReader->getSRice(energy) + 3 * (buffer[curChannel][0] - oldValues[curChannel][0]) + oldValues[curChannel][1];
- else if (i == 2)
- buffer[curChannel][i] = gReader->getSRice(energy) + 3 * (buffer[curChannel][1] - buffer[curChannel][0]) + oldValues[curChannel][0];
- else
- buffer[curChannel][i] = gReader->getSRice(energy) + 3 * (buffer[curChannel][i - 1] - buffer[curChannel][i - 2]) + buffer[curChannel][i - 3];
- }
- break;
- case kCmdQLPC:
- lpcNum = gReader->getURice(2);
-
- // Safeguard: if maxLPC < lpcNum, realloc the lpc buffer
- if (maxLPC < lpcNum) {
- warning("Safeguard: maxLPC < lpcNum (should never happen)");
- maxLPC = lpcNum;
- int32 *tmp = (int32 *) realloc(lpc, maxLPC * 4);
- if ((tmp != NULL) || (maxLPC == 0)) {
- lpc = tmp;
- } else {
- error("loadShortenFromStream(): Error while reallocating memory");
- }
- }
-
- for (i = 0; i < lpcNum; i++)
- lpc[i] = gReader->getSRice(5);
-
- for (i = 0; i < lpcNum; i++)
- buffer[curChannel][i - lpcNum] -= channelOffset;
-
- for (i = 0; i < blockSize; i++) {
- int32 sum = lpcqOffset;
- for (j = 0; j < lpcNum; j++) {
- // FIXME: The original code did an invalid memory access here
- // (if i and j are 0, the array index requested is -1)
- // I've removed those invalid writes, since they happen all the time (even when curChannel is 0)
- if (i <= j) // ignore invalid table/memory access
- continue;
- sum += lpc[j] * buffer[curChannel][i - j - 1];
- }
- buffer[curChannel][i] = gReader->getSRice(energy) + (sum >> 5);
- }
-
- if (channelOffset > 0)
- for (i = 0; i < blockSize; i++)
- buffer[curChannel][i] += channelOffset;
-
- break;
- default:
- break;
- }
-
- // Store mean value, if appropriate (duplicated code from above)
- if (mean > 0) {
- int32 sum = (version < 2) ? 0 : blockSize / 2;
- for (i = 0; i < blockSize; i++)
- sum += buffer[curChannel][i];
-
- for (i = 1; i < mean; i++)
- offset[curChannel][i - 1] = offset[curChannel][i];
-
- offset[curChannel][mean - 1] = sum / blockSize;
-
- if (version >= 2 && bitShift > 0)
- offset[curChannel][mean - 1] = offset[curChannel][mean - 1] << bitShift;
- }
-
-
- // Do the wrap
- for (i = 0; i < 64; ++i)
- oldValues[curChannel][i] = 0;
-
- uint arrayTerminator = MIN<int>(64, blockSize);
- for (i = 0; i < arrayTerminator; ++i)
- oldValues[curChannel][i] = buffer[curChannel][blockSize - (i + 1)];
-
- // Fix bitshift
- if (bitShift > 0) {
- for (i = 0; i < blockSize; i++)
- buffer[curChannel][i] <<= bitShift;
- }
-
- if (curChannel == channels - 1) {
- int dataSize = (flags & Audio::FLAG_16BITS) ? 2 : 1;
- int limit = (flags & Audio::FLAG_16BITS) ? 32767 : 127;
- limit = (flags & Audio::FLAG_UNSIGNED) ? limit * 2 + 1 : limit;
-
- prevSize = size;
- size += (blockSize * dataSize);
- byte *tmp = (byte *) realloc(unpackedBuffer, size);
- if ((tmp != NULL) || (size == 0)) {
- unpackedBuffer = tmp;
- } else {
- error("loadShortenFromStream(): Error while reallocating memory");
- }
- pBuf = unpackedBuffer + prevSize;
-
- if (flags & Audio::FLAG_16BITS) {
- for (i = 0; i < blockSize; i++) {
- for (j = 0; j < channels; j++) {
- int16 val = (int16)(MIN<int32>(buffer[j][i], limit) & 0xFFFF);
- // values are written in LE
- *pBuf++ = (byte) (val & 0xFF);
- *pBuf++ = (byte) ((val >> 8) & 0xFF);
- }
- }
- } else {
- for (i = 0; i < blockSize; i++)
- for (j = 0; j < channels; j++)
- *pBuf++ = (byte)(MIN<int32>(buffer[j][i], limit) & 0xFF);
- }
- }
- curChannel = (curChannel + 1) % channels;
-
- }
- break;
- case kCmdBlockSize:
- blockSize = gReader->getUint32((uint32)log((double) blockSize / M_LN2));
- break;
- case kCmdBitShift:
- bitShift = gReader->getURice(2);
- break;
- case kCmdVerbatim:
- {
-
- uint32 vLen = (uint32)gReader->getURice(5);
- prevSize = size;
- size += vLen;
- byte *tmp = (byte *) realloc(unpackedBuffer, size);
- if ((tmp != NULL) || (size == 0)) {
- unpackedBuffer = tmp;
- } else {
- error("loadShortenFromStream(): Error while reallocating memory");
- }
- pBuf = unpackedBuffer + prevSize;
-
- while (vLen--) {
- *pBuf++ = (byte)(gReader->getURice(8) & 0xFF);
- }
-
- }
- break;
- default:
- warning("loadShortenFromStream: Unknown command: %d", cmd);
-
- // Cleanup
- for (i = 0; i < channels; i++) {
- free(buffer[i]);
- free(offset[i]);
- free(oldValues[i]);
- }
-
- if (maxLPC > 0)
- free(lpc);
-
- if (size > 0)
- free(unpackedBuffer);
-
- delete gReader;
- return NULL;
- break;
- }
- }
-
- // Rate is always 44100Hz
- rate = 44100;
-
- // Cleanup
- for (i = 0; i < channels; i++) {
- free(buffer[i]);
- free(offset[i]);
- free(oldValues[i]);
- }
-
- if (maxLPC > 0)
- free(lpc);
-
- delete gReader;
- return unpackedBuffer;
-}
-
-Audio::AudioStream *makeShortenStream(Common::SeekableReadStream &stream) {
- int size, rate;
- byte *data, flags;
- data = loadShortenFromStream(stream, size, rate, flags);
-
- if (!data)
- return 0;
-
- // Since we allocated our own buffer for the data, we must specify DisposeAfterUse::YES.
- return Audio::makeRawStream(data, size, rate, flags);
-}
-
-} // End of namespace Audio
-
-#endif // defined(SOUND_SHORTEN_H)
diff --git a/engines/saga/shorten.h b/engines/saga/shorten.h
deleted file mode 100644
index 4d4ec328c6..0000000000
--- a/engines/saga/shorten.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* 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.
- *
- */
-
-// The code in this file is currently only used in SAGA2.
-// So when it is disabled, we will skip compiling it.
-#if !(defined(ENABLE_SAGA2))
-
-#else
-
-#ifndef SOUND_SHORTEN_H
-#define SOUND_SHORTEN_H
-
-#include "common/scummsys.h"
-
-namespace Audio {
-class AudioStream;
-}
-
-namespace Common {
-class ReadStream;
-}
-
-namespace Saga {
-
-/**
- * Try to load a Shorten file from the given stream. Returns true if
- * successful. In that case, the stream's seek position will be set to the
- * start of the audio data, and size, rate and flags contain information
- * necessary for playback.
- */
-byte *loadShortenFromStream(Common::ReadStream &stream, int &size, int &rate, byte &flags);
-
-/**
- * Try to load a Shorten file from the given stream and create an AudioStream
- * from that data.
- *
- * This function uses loadShortenFromStream() internally.
- */
-Audio::AudioStream *makeShortenStream(Common::ReadStream &stream);
-
-} // End of namespace Audio
-
-#endif
-
-#endif // engine and dynamic plugins guard
diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp
index f9cff2b19b..bedac99a39 100644
--- a/engines/saga/sndres.cpp
+++ b/engines/saga/sndres.cpp
@@ -42,9 +42,6 @@
#include "audio/decoders/voc.h"
#include "audio/decoders/vorbis.h"
#include "audio/decoders/wave.h"
-#ifdef ENABLE_SAGA2
-#include "saga/shorten.h"
-#endif
namespace Saga {
@@ -94,12 +91,6 @@ SndRes::SndRes(SagaEngine *vm) : _vm(vm), _sfxContext(NULL), _voiceContext(NULL)
for (uint i = 0; i < _fxTableIDs.size(); i++) {
_fxTableIDs[i] = metaS.readSint16LE();
}
-#endif
-#ifdef ENABLE_SAGA2
- } else if (_vm->getGameId() == GID_DINO) {
- // TODO
- } else if (_vm->getGameId() == GID_FTA2) {
- // TODO
#endif
}
}
@@ -187,7 +178,7 @@ enum GameSoundType {
kSoundOGG = 5,
kSoundFLAC = 6,
kSoundAIFF = 7,
- kSoundShorten = 8,
+ //kSoundShorten = 8, // used in SAGA2
kSoundMacSND = 9,
kSoundPC98 = 10
};
@@ -254,8 +245,6 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
resourceType = kSoundWAV;
} else if (!memcmp(header, "FORM", 4)) {
resourceType = kSoundAIFF;
- } else if (!memcmp(header, "ajkg", 4)) {
- resourceType = kSoundShorten;
}
// If patch data exists for sound resource 4 (used in ITE intro), don't treat this sound as compressed
@@ -407,14 +396,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
result = true;
} break;
case kSoundWAV:
- case kSoundShorten:
- if (resourceType == kSoundWAV) {
- result = Audio::loadWAVFromStream(readS, size, rate, rawFlags);
-#ifdef ENABLE_SAGA2
- } else if (resourceType == kSoundShorten) {
- result = loadShortenFromStream(readS, size, rate, rawFlags);
-#endif
- }
+ result = Audio::loadWAVFromStream(readS, size, rate, rawFlags);
if (result) {
Audio::SeekableAudioStream *audStream = Audio::makeRawStream(READ_STREAM(size), rate, rawFlags);
More information about the Scummvm-git-logs
mailing list