diff options
author | Fabio Battaglia | 2009-04-18 08:37:22 +0000 |
---|---|---|
committer | Fabio Battaglia | 2009-04-18 08:37:22 +0000 |
commit | 0b2e06e4a4225a6ede1be4e9f6c09fe2cd4caf16 (patch) | |
tree | b75afb3e841b313515da7497ef35f7b4564caea7 /engines/sword2 | |
parent | 5cd22613822797a7405ae60c35a7ccae4196b9b1 (diff) | |
download | scummvm-rg350-0b2e06e4a4225a6ede1be4e9f6c09fe2cd4caf16.tar.gz scummvm-rg350-0b2e06e4a4225a6ede1be4e9f6c09fe2cd4caf16.tar.bz2 scummvm-rg350-0b2e06e4a4225a6ede1be4e9f6c09fe2cd4caf16.zip |
sword2: add support for BS2 PSX demo
svn-id: r39977
Diffstat (limited to 'engines/sword2')
-rw-r--r-- | engines/sword2/resman.cpp | 1 | ||||
-rw-r--r-- | engines/sword2/screen.cpp | 13 | ||||
-rw-r--r-- | engines/sword2/sound.cpp | 6 | ||||
-rw-r--r-- | engines/sword2/sprite.cpp | 9 | ||||
-rw-r--r-- | engines/sword2/sword2.cpp | 5 |
5 files changed, 29 insertions, 5 deletions
diff --git a/engines/sword2/resman.cpp b/engines/sword2/resman.cpp index a6a8a9e54a..3b6592c9f4 100644 --- a/engines/sword2/resman.cpp +++ b/engines/sword2/resman.cpp @@ -520,6 +520,7 @@ uint8 ResourceManager::fetchType(byte *ptr) { } else { // In PSX version there is no resource header for audio files, return WAV_FILE; // but hopefully all audio files got first 16 bytes zeroed, } // Allowing us to check for this condition. + // Alas, this doesn't work with PSX DEMO audio files. } } diff --git a/engines/sword2/screen.cpp b/engines/sword2/screen.cpp index da7122386e..3a174b2352 100644 --- a/engines/sword2/screen.cpp +++ b/engines/sword2/screen.cpp @@ -549,6 +549,15 @@ void Screen::processLayer(byte *file, uint32 layer_number) { } void Screen::processImage(BuildUnit *build_unit) { + + // We have some problematic animation frames in PSX demo (looks like there is missing data), + // so we just skip them. + if ( (Sword2Engine::isPsx() && _vm->_logic->readVar(DEMO)) && + ((build_unit->anim_resource == 369 && build_unit->anim_pc == 0) || + (build_unit->anim_resource == 296 && build_unit->anim_pc == 5) || + (build_unit->anim_resource == 534 && build_unit->anim_pc == 13)) ) + return; + byte *file = _vm->_resman->openResource(build_unit->anim_resource); byte *colTablePtr = NULL; @@ -662,10 +671,10 @@ void Screen::processImage(BuildUnit *build_unit) { uint32 rv = drawSprite(&spriteInfo); if (rv) { - error("Driver Error %.8x with sprite %s (%d) in processImage", + error("Driver Error %.8x with sprite %s (%d, %d) in processImage", rv, _vm->_resman->fetchName(build_unit->anim_resource), - build_unit->anim_resource); + build_unit->anim_resource, build_unit->anim_pc); } // release the anim resource diff --git a/engines/sword2/sound.cpp b/engines/sword2/sound.cpp index eb0b6d82eb..706143aded 100644 --- a/engines/sword2/sound.cpp +++ b/engines/sword2/sound.cpp @@ -267,7 +267,11 @@ void Sound::queueFx(int32 res, int32 type, int32 delay, int32 volume, int32 pan) if (!_fxQueue[i].resource) { byte *data = _vm->_resman->openResource(res); - assert(_vm->_resman->fetchType(data) == WAV_FILE); + // Check that we really have a WAV file here, alas this + // check is useless with psx demo game, because psx audio files + // are headerless and there is no way to check the type + if (!(Sword2Engine::isPsx() && (_vm->_features & GF_DEMO))) + assert(_vm->_resman->fetchType(data) == WAV_FILE); uint32 len = _vm->_resman->fetchLen(res); diff --git a/engines/sword2/sprite.cpp b/engines/sword2/sprite.cpp index 52ed0efbd0..2474293500 100644 --- a/engines/sword2/sprite.cpp +++ b/engines/sword2/sprite.cpp @@ -527,6 +527,10 @@ int32 Screen::drawSprite(SpriteInfo *s) { decompData = decompressHIF(s->data, tempBuf); + // Check that we correctly decompressed data + if(!decompData) + return RDERR_DECOMPRESSION; + s->w = (decompData / (s->h / 2)) * 2; byte *tempBuf2 = (byte *)malloc(s->w * s->h * 10); memset(tempBuf2, 0, s->w * s->h * 2); @@ -562,6 +566,11 @@ int32 Screen::drawSprite(SpriteInfo *s) { } else { byte *tempBuf = (byte *)malloc(s->w * s->h); uint32 decompData = decompressHIF(s->data, tempBuf); + + // Check that we correctly decompressed data + if(!decompData) + return RDERR_DECOMPRESSION; + s->w = (decompData / (s->h / 2)); sprite = (byte *)malloc(s->w * s->h); diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp index 78fb890deb..e9ad1dba4a 100644 --- a/engines/sword2/sword2.cpp +++ b/engines/sword2/sword2.cpp @@ -69,6 +69,7 @@ static const GameSettings sword2_settings[] = { {"sword2", "Broken Sword 2: The Smoking Mirror", 0, "players.clu" }, {"sword2alt", "Broken Sword 2: The Smoking Mirror (alt)", 0, "r2ctlns.ocx" }, {"sword2psx", "Broken Sword 2: The Smoking Mirror (PlayStation)", 0, "screens.clu"}, + {"sword2psxdemo", "Broken Sword 2: The Smoking Mirror (PlayStation/Demo)", Sword2::GF_DEMO, "rdemo.str"}, {"sword2demo", "Broken Sword 2: The Smoking Mirror (Demo)", Sword2::GF_DEMO, "players.clu" }, {NULL, NULL, 0, NULL} }; @@ -264,13 +265,13 @@ Sword2Engine::Sword2Engine(OSystem *syst) : Engine(syst) { Common::File::addDefaultDirectory(_gameDataDir.getChild("video")); Common::File::addDefaultDirectory(_gameDataDir.getChild("smacks")); - if (0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2demo")) + if (!scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2demo") || !scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2psxdemo")) _features = GF_DEMO; else _features = 0; // Check if we are running PC or PSX version. - if (0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2psx")) + if (!scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2psx") || !scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2psxdemo")) Sword2Engine::_platform = Common::kPlatformPSX; else Sword2Engine::_platform = Common::kPlatformPC; |