aboutsummaryrefslogtreecommitdiff
path: root/engines/saga
diff options
context:
space:
mode:
authorJohannes Schickel2010-10-13 03:57:44 +0000
committerJohannes Schickel2010-10-13 03:57:44 +0000
commit75e8452b6e6a2bf4fb2f588aa00b428a60d873b5 (patch)
treef29541d55309487a94bd1d38e8b53bb3dde9aec6 /engines/saga
parent48ee83b88957dab86bc763e9ef21a70179fa8679 (diff)
parente9f50882ea5b6beeefa994040be9d3bab6a1f107 (diff)
downloadscummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.gz
scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.bz2
scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.zip
OPENGL: Merged from trunk, from rev 52105 to 53396.
This includes an rather hacky attempt to merge all the recent gp2x backend changes into the branch. I suppose the gp2x backend and probably all new backends, i.e. gph, dingux etc., might not compile anymore. Since I have no way of testing those it would be nice if porters could look into getting those up to speed in this branch. svn-id: r53399
Diffstat (limited to 'engines/saga')
-rw-r--r--engines/saga/actor.h4
-rw-r--r--engines/saga/font.cpp4
-rw-r--r--engines/saga/font.h2
-rw-r--r--engines/saga/interface.cpp76
-rw-r--r--engines/saga/isomap.cpp22
-rw-r--r--engines/saga/music.cpp14
-rw-r--r--engines/saga/music.h2
-rw-r--r--engines/saga/puzzle.cpp6
-rw-r--r--engines/saga/resource.cpp29
-rw-r--r--engines/saga/scene.cpp4
-rw-r--r--engines/saga/script.cpp6
-rw-r--r--engines/saga/sndres.cpp6
12 files changed, 97 insertions, 78 deletions
diff --git a/engines/saga/actor.h b/engines/saga/actor.h
index 57d06e9e3a..2f8fdea8ec 100644
--- a/engines/saga/actor.h
+++ b/engines/saga/actor.h
@@ -451,8 +451,8 @@ public:
void cmdActorWalkTo(int argc, const char **argv);
bool validActorId(uint16 id) { return (id == ID_PROTAG) || ((id >= objectIndexToId(kGameObjectActor, 0)) && (id < objectIndexToId(kGameObjectActor, _actorsCount))); }
- int actorIdToIndex(uint16 id) { return (id == ID_PROTAG ) ? 0 : objectIdToIndex(id); }
- uint16 actorIndexToId(int index) { return (index == 0 ) ? ID_PROTAG : objectIndexToId(kGameObjectActor, index); }
+ int actorIdToIndex(uint16 id) { return (id == ID_PROTAG) ? 0 : objectIdToIndex(id); }
+ uint16 actorIndexToId(int index) { return (index == 0) ? ID_PROTAG : objectIndexToId(kGameObjectActor, index); }
ActorData *getActor(uint16 actorId);
ActorData *getFirstActor() { return _actors[0]; }
diff --git a/engines/saga/font.cpp b/engines/saga/font.cpp
index 5b7b7289eb..47f1a122c0 100644
--- a/engines/saga/font.cpp
+++ b/engines/saga/font.cpp
@@ -123,7 +123,7 @@ void Font::loadFont(uint32 fontResourceId) {
}
if (readS.pos() != FONT_DESCSIZE) {
- error("Invalid font resource size.");
+ error("Invalid font resource size");
}
font->normal.font = (byte*)malloc(fontResourceLength - FONT_DESCSIZE);
@@ -610,7 +610,7 @@ void Font::textDrawRect(FontId fontId, const char *text, const Common::Rect &rec
}
w_total = 0;
len_total = 0;
- if (wc == 0) {
+ if (wc == 0 && measurePointer) {
searchPointer = measurePointer + 1;
}
wc = 0;
diff --git a/engines/saga/font.h b/engines/saga/font.h
index d8b1da30b9..1b9f290a1b 100644
--- a/engines/saga/font.h
+++ b/engines/saga/font.h
@@ -186,7 +186,7 @@ class Font {
void validate(FontId fontId) {
if (!valid(fontId)) {
- error("Font::validate: Invalid font id.");
+ error("Font::validate: Invalid font id");
}
}
bool valid(FontId fontId) {
diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp
index c4b4688785..a77ec1c140 100644
--- a/engines/saga/interface.cpp
+++ b/engines/saga/interface.cpp
@@ -1398,7 +1398,7 @@ void Interface::setSave(PanelButton *panelButton) {
char *fileName;
switch (panelButton->id) {
case kTextSave:
- if (_textInputStringLength == 0 ) {
+ if (_textInputStringLength == 0) {
break;
}
if (!_vm->isSaveListFull() && (_optionSaveFileTitleNumber == 0)) {
@@ -2166,43 +2166,43 @@ void Interface::drawButtonBox(const Rect& rect, ButtonKind kind, bool down) {
byte solidColor;
byte odl, our, idl, iur;
- switch (kind ) {
- case kSlider:
- cornerColor = 0x8b;
- frameColor = _vm->KnownColor2ColorId(kKnownColorBlack);
- fillColor = kITEColorLightBlue96;
- odl = kITEColorDarkBlue8a;
- our = kITEColorLightBlue92;
- idl = 0x89;
- iur = 0x94;
- solidColor = down ? kITEColorLightBlue94 : kITEColorLightBlue96;
- break;
- case kEdit:
- if (_vm->getGameId() == GID_ITE) {
- cornerColor = frameColor = fillColor = kITEColorLightBlue96;
- our = kITEColorDarkBlue8a;
- odl = kITEColorLightBlue94;
- solidColor = down ? kITEColorBlue : kITEColorDarkGrey0C;
- } else {
- cornerColor = frameColor = fillColor = _vm->KnownColor2ColorId(kKnownColorBlack);
- our = odl = solidColor = _vm->KnownColor2ColorId(kKnownColorBlack);
- }
- iur = 0x97;
- idl = 0x95;
- break;
- default:
- cornerColor = 0x8b;
- frameColor = _vm->KnownColor2ColorId(kKnownColorBlack);
- solidColor = fillColor = kITEColorLightBlue96;
- odl = kITEColorDarkBlue8a;
- our = kITEColorLightBlue94;
- idl = 0x97;
- iur = 0x95;
- if (down) {
- SWAP(odl, our);
- SWAP(idl, iur);
- }
- break;
+ switch (kind) {
+ case kSlider:
+ cornerColor = 0x8b;
+ frameColor = _vm->KnownColor2ColorId(kKnownColorBlack);
+ fillColor = kITEColorLightBlue96;
+ odl = kITEColorDarkBlue8a;
+ our = kITEColorLightBlue92;
+ idl = 0x89;
+ iur = 0x94;
+ solidColor = down ? kITEColorLightBlue94 : kITEColorLightBlue96;
+ break;
+ case kEdit:
+ if (_vm->getGameId() == GID_ITE) {
+ cornerColor = frameColor = fillColor = kITEColorLightBlue96;
+ our = kITEColorDarkBlue8a;
+ odl = kITEColorLightBlue94;
+ solidColor = down ? kITEColorBlue : kITEColorDarkGrey0C;
+ } else {
+ cornerColor = frameColor = fillColor = _vm->KnownColor2ColorId(kKnownColorBlack);
+ our = odl = solidColor = _vm->KnownColor2ColorId(kKnownColorBlack);
+ }
+ iur = 0x97;
+ idl = 0x95;
+ break;
+ default:
+ cornerColor = 0x8b;
+ frameColor = _vm->KnownColor2ColorId(kKnownColorBlack);
+ solidColor = fillColor = kITEColorLightBlue96;
+ odl = kITEColorDarkBlue8a;
+ our = kITEColorLightBlue94;
+ idl = 0x97;
+ iur = 0x95;
+ if (down) {
+ SWAP(odl, our);
+ SWAP(idl, iur);
+ }
+ break;
}
int x = rect.left;
diff --git a/engines/saga/isomap.cpp b/engines/saga/isomap.cpp
index 8999211f2a..f0ad9bbd5e 100644
--- a/engines/saga/isomap.cpp
+++ b/engines/saga/isomap.cpp
@@ -303,8 +303,8 @@ void IsoMap::adjustScroll(bool jump) {
_viewScroll.x = maxScrollPos.x;
}
} else {
- _viewScroll.y = smoothSlide( _viewScroll.y, minScrollPos.y, maxScrollPos.y );
- _viewScroll.x = smoothSlide( _viewScroll.x, minScrollPos.x, maxScrollPos.x );
+ _viewScroll.y = smoothSlide(_viewScroll.y, minScrollPos.y, maxScrollPos.y);
+ _viewScroll.x = smoothSlide(_viewScroll.x, minScrollPos.x, maxScrollPos.x);
}
if (_vm->_scene->currentSceneResourceId() == ITE_SCENE_OVERMAP) {
@@ -429,7 +429,7 @@ void IsoMap::drawTiles(const Location *location) {
workAreaWidth = _vm->getDisplayInfo().width + 128;
workAreaHeight = _vm->_scene->getHeight() + 128 + 80;
- for (u1 = u0, v1 = v0; metaTileY.y < workAreaHeight; u1--, v1-- ) {
+ for (u1 = u0, v1 = v0; metaTileY.y < workAreaHeight; u1--, v1--) {
metaTileX = metaTileY;
for (u2 = u1, v2 = v1; metaTileX.x < workAreaWidth; u2++, v2--, metaTileX.x += 256) {
@@ -611,7 +611,7 @@ void IsoMap::drawSpritePlatform(uint16 platformIndex, const Point &point, const
for (u = SAGA_PLATFORM_W - 1,
copyLocation.u() = location.u() - ((SAGA_PLATFORM_W - 1) << 4);
u >= 0 && s.x + 32 > _tileClip.left && s.y - SAGA_MAX_TILE_H < _tileClip.bottom;
- u--, copyLocation.u() += 16, s.x -= 16, s.y += 8 ) {
+ u--, copyLocation.u() += 16, s.x -= 16, s.y += 8) {
if (s.x < _tileClip.right && s.y > _tileClip.top) {
tileIndex = tilePlatform->tiles[u][v];
@@ -663,7 +663,7 @@ void IsoMap::drawPlatform(uint16 platformIndex, const Point &point, int16 absU,
for (u = SAGA_PLATFORM_W - 1;
u >= 0 && s.x + 32 > _tileClip.left && s.y - SAGA_MAX_TILE_H < _tileClip.bottom;
- u--, s.x -= 16, s.y += 8 ) {
+ u--, s.x -= 16, s.y += 8) {
if (s.x < _tileClip.right && s.y > _tileClip.top) {
tileIndex = tilePlatform->tiles[u][v];
@@ -955,7 +955,7 @@ void IsoMap::pushPoint(int16 u, int16 v, uint16 cost, uint16 direction) {
}
}
- if (mid < _queueCount ) {
+ if (mid < _queueCount) {
memmove(tilePoint + 1, tilePoint, (_queueCount - mid) * sizeof (*tilePoint));
}
_queueCount++;
@@ -1211,7 +1211,7 @@ void IsoMap::placeOnTileMap(const Location &start, Location &result, int16 dista
for (dir = 0; dir < 8; dir++) {
terrainMask = terraComp[dir];
- if (terrainMask & SAGA_IMPASSABLE ) {
+ if (terrainMask & SAGA_IMPASSABLE) {
continue;
}
@@ -1352,11 +1352,11 @@ void IsoMap::findDragonTilePath(ActorData* actor,const Location &start, const Lo
continue;
}
- tile = getTile(u1, v1, _platformHeight );
+ tile = getTile(u1, v1, _platformHeight);
if (tile != NULL) {
mask = tile->terrainMask;
if (((mask != 0) && (tile->GetFGDAttr() >= kTerrBlock)) ||
- ((mask != 0xFFFF) && (tile->GetBGDAttr() >= kTerrBlock)) ) {
+ ((mask != 0xFFFF) && (tile->GetBGDAttr() >= kTerrBlock))) {
pcell->visited = 1;
}
} else {
@@ -1453,7 +1453,7 @@ void IsoMap::findDragonTilePath(ActorData* actor,const Location &start, const Lo
actor->_walkStepsCount = i;
if (i) {
actor->setTileDirectionsSize(i, false);
- memcpy(actor->_tileDirections, res, i );
+ memcpy(actor->_tileDirections, res, i);
}
}
@@ -1586,7 +1586,7 @@ void IsoMap::findTilePath(ActorData* actor, const Location &start, const Locatio
actor->_walkStepsCount = i;
if (i) {
actor->setTileDirectionsSize(i, false);
- memcpy(actor->_tileDirections, res, i );
+ memcpy(actor->_tileDirections, res, i);
}
}
diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp
index e4a16e27da..199b0dfd8a 100644
--- a/engines/saga/music.cpp
+++ b/engines/saga/music.cpp
@@ -49,6 +49,7 @@ MusicDriver::MusicDriver() : _isGM(false) {
MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM);
_driver = MidiDriver::createMidi(dev);
+ _driverType = MidiDriver::getMusicType(dev);
if (isMT32())
_driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
@@ -60,6 +61,19 @@ MusicDriver::~MusicDriver() {
delete _driver;
}
+int MusicDriver::open() {
+ int retValue = _driver->open();
+ if (retValue)
+ return retValue;
+
+ if (_nativeMT32)
+ _driver->sendMT32Reset();
+ else
+ _driver->sendGMReset();
+
+ return 0;
+}
+
void MusicDriver::setVolume(int volume) {
volume = CLIP(volume, 0, 255);
diff --git a/engines/saga/music.h b/engines/saga/music.h
index f3b0f177b0..470b6e18b3 100644
--- a/engines/saga/music.h
+++ b/engines/saga/music.h
@@ -57,7 +57,7 @@ public:
void setGM(bool isGM) { _isGM = isGM; }
//MidiDriver interface implementation
- int open() { return _driver->open(); }
+ int open();
void close() { _driver->close(); }
void send(uint32 b);
diff --git a/engines/saga/puzzle.cpp b/engines/saga/puzzle.cpp
index 5b13473d77..73839eb6ea 100644
--- a/engines/saga/puzzle.cpp
+++ b/engines/saga/puzzle.cpp
@@ -459,9 +459,9 @@ void Puzzle::solicitHint() {
_vm->getTimerManager()->installTimerProc(&hintTimerCallback, 50*1000000, this);
_vm->_interface->converseClear();
- _vm->_interface->converseAddText(optionsStr[_lang][kROAccept], 0, 1, 0, 0 );
- _vm->_interface->converseAddText(optionsStr[_lang][kRODecline], 0, 2, 0, 0 );
- _vm->_interface->converseAddText(optionsStr[_lang][kROLater], 0, 0, 0, 0 );
+ _vm->_interface->converseAddText(optionsStr[_lang][kROAccept], 0, 1, 0, 0);
+ _vm->_interface->converseAddText(optionsStr[_lang][kRODecline], 0, 2, 0, 0);
+ _vm->_interface->converseAddText(optionsStr[_lang][kROLater], 0, 0, 0, 0);
_vm->_interface->converseDisplayText();
break;
diff --git a/engines/saga/resource.cpp b/engines/saga/resource.cpp
index cf7474adc1..7d82aa4bda 100644
--- a/engines/saga/resource.cpp
+++ b/engines/saga/resource.cpp
@@ -165,18 +165,21 @@ bool ResourceContext::load(SagaEngine *vm, Resource *resource) {
if ((patchDescription->fileType & _fileType) != 0) {
if (patchDescription->resourceId < _table.size()) {
resourceData = &_table[patchDescription->resourceId];
- resourceData->patchData = new PatchData(patchDescription->fileName);
- if (resourceData->patchData->_patchFile->open(patchDescription->fileName)) {
- resourceData->offset = 0;
- resourceData->size = resourceData->patchData->_patchFile->size();
- // ITE uses several patch files which are loaded and then not needed
- // anymore (as they're in memory), so close them here. IHNM uses only
- // 1 patch file, which is reused, so don't close it
- if (vm->getGameId() == GID_ITE)
- resourceData->patchData->_patchFile->close();
- } else {
- delete resourceData->patchData;
- resourceData->patchData = NULL;
+ // Check if we've already found a patch for this resource. One is enough.
+ if (!resourceData->patchData) {
+ resourceData->patchData = new PatchData(patchDescription->fileName);
+ if (resourceData->patchData->_patchFile->open(patchDescription->fileName)) {
+ resourceData->offset = 0;
+ resourceData->size = resourceData->patchData->_patchFile->size();
+ // ITE uses several patch files which are loaded and then not needed
+ // anymore (as they're in memory), so close them here. IHNM uses only
+ // 1 patch file, which is reused, so don't close it
+ if (vm->getGameId() == GID_ITE)
+ resourceData->patchData->_patchFile->close();
+ } else {
+ delete resourceData->patchData;
+ resourceData->patchData = NULL;
+ }
}
}
}
@@ -222,7 +225,7 @@ bool Resource::createContexts() {
// If the Wyrmkeep credits file is found, set the Wyrmkeep version flag to true
- if (Common::File::exists("graphics/credit3n.dlt")) {
+ if (Common::File::exists("credit3n.dlt")) {
_vm->_gf_wyrmkeep = true;
}
diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp
index d7ee037c50..2887d79693 100644
--- a/engines/saga/scene.cpp
+++ b/engines/saga/scene.cpp
@@ -987,8 +987,8 @@ void Scene::processSceneResources() {
size_t resourceDataLength;
const byte *palPointer;
size_t i;
- SAGAResourceTypes *types;
- int typesCount;
+ SAGAResourceTypes *types = 0;
+ int typesCount = 0;
SAGAResourceTypes resType;
getResourceTypes(types, typesCount);
diff --git a/engines/saga/script.cpp b/engines/saga/script.cpp
index 5fd120ac33..b0e20da48c 100644
--- a/engines/saga/script.cpp
+++ b/engines/saga/script.cpp
@@ -1315,7 +1315,7 @@ void Script::setVerb(int verb) {
// engine did it, but it appears to work.
_pointerObject = ID_NOTHING;
- setLeftButtonVerb( verb );
+ setLeftButtonVerb(verb);
showVerb();
}
@@ -1549,7 +1549,7 @@ void Script::playfieldClick(const Point& mousePoint, bool leftButton) {
}
if (_pointerObject != ID_NOTHING) {
- hitObject( leftButton );
+ hitObject(leftButton);
} else {
_pendingObject[0] = ID_NOTHING;
_pendingObject[1] = ID_NOTHING;
@@ -1618,7 +1618,7 @@ void Script::playfieldClick(const Point& mousePoint, bool leftButton) {
_vm->_actor->actorWalkTo(ID_PROTAG, pickLocation);
} else {
if (_pendingVerb == getVerbType(kVerbLookAt)) {
- if (objectTypeId(_pendingObject[0]) != kGameObjectActor ) {
+ if (objectTypeId(_pendingObject[0]) != kGameObjectActor) {
_vm->_actor->actorWalkTo(ID_PROTAG, pickLocation);
} else {
doVerb();
diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp
index a27608dcf5..9322918db5 100644
--- a/engines/saga/sndres.cpp
+++ b/engines/saga/sndres.cpp
@@ -225,6 +225,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
}
Common::SeekableReadStream& readS = *file;
+ bool uncompressedSound = false;
if (soundResourceLength >= 8) {
byte header[8];
@@ -242,7 +243,6 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
resourceType = kSoundShorten;
}
- bool uncompressedSound = false;
// If patch data exists for sound resource 4 (used in ITE intro), don't treat this sound as compressed
// Patch data for this resource is in file p2_a.iaf or p2_a.voc
if (_vm->getGameId() == GID_ITE && resourceId == 4 && context->getResourceData(resourceId)->patchData != NULL)
@@ -277,7 +277,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
buffer.flags &= ~Audio::FLAG_16BITS;
} else {
// Voice files in newer ITE demo versions are OKI ADPCM (VOX) encoded
- if (!scumm_stricmp(context->fileName(), "voicesd.rsc"))
+ if (!uncompressedSound && !scumm_stricmp(context->fileName(), "voicesd.rsc"))
resourceType = kSoundVOX;
}
}
@@ -331,6 +331,8 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
if (onlyHeader)
free(data);
buffer.flags |= Audio::FLAG_UNSIGNED;
+ buffer.flags &= ~Audio::FLAG_16BITS;
+ buffer.flags &= ~Audio::FLAG_STEREO;
}
if (result) {