aboutsummaryrefslogtreecommitdiff
path: root/engines/sword1
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sword1')
-rw-r--r--engines/sword1/POTFILES4
-rw-r--r--engines/sword1/animation.cpp62
-rw-r--r--engines/sword1/animation.h3
-rw-r--r--engines/sword1/configure.engine3
-rw-r--r--engines/sword1/music.cpp6
-rw-r--r--engines/sword1/music.h2
-rw-r--r--engines/sword1/screen.cpp24
-rw-r--r--engines/sword1/sound.cpp3
-rw-r--r--engines/sword1/sword1.cpp11
9 files changed, 86 insertions, 32 deletions
diff --git a/engines/sword1/POTFILES b/engines/sword1/POTFILES
new file mode 100644
index 0000000000..849bef9060
--- /dev/null
+++ b/engines/sword1/POTFILES
@@ -0,0 +1,4 @@
+engines/sword1/animation.cpp
+engines/sword1/control.cpp
+engines/sword1/logic.cpp
+engines/sword1/sword1.cpp
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp
index 206bd68b07..742aac1a53 100644
--- a/engines/sword1/animation.cpp
+++ b/engines/sword1/animation.cpp
@@ -37,7 +37,14 @@
#include "gui/message.h"
+#ifdef USE_MPEG2
+#include "video/avi_decoder.h"
+#endif
+
+#ifdef USE_ZLIB
#include "video/dxa_decoder.h"
+#endif
+
#include "video/psx_decoder.h"
#include "video/smk_decoder.h"
@@ -176,27 +183,26 @@ bool MoviePlayer::load(uint32 id) {
break;
case kVideoDecoderPSX:
filename = Common::String::format("%s.str", (_vm->_systemVars.isDemo) ? sequenceList[id] : sequenceListPSX[id]);
+ break;
+ case kVideoDecoderMP2:
+ filename = Common::String::format("%s.mp2", sequenceList[id]);
+ break;
+ }
- // Need to switch to true color
+ // Need to switch to true color for PSX/MP2 videos
+ if (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2)
initGraphics(g_system->getWidth(), g_system->getHeight(), true, 0);
- // Need to load here in case it fails in which case we'd need
- // to go back to paletted mode
- if (_decoder->loadFile(filename)) {
- _decoder->start();
- return true;
- } else {
+ if (!_decoder->loadFile(filename)) {
+ // Go back to 8bpp color
+ if (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2)
initGraphics(g_system->getWidth(), g_system->getHeight(), true);
- return false;
- }
- break;
- }
- if (!_decoder->loadFile(filename))
return false;
+ }
- // For DXA, also add the external sound file
- if (_decoderType == kVideoDecoderDXA)
+ // For DXA/MP2, also add the external sound file
+ if (_decoderType == kVideoDecoderDXA || _decoderType == kVideoDecoderMP2)
_decoder->addStreamFileTrack(sequenceList[id]);
_decoder->start();
@@ -224,9 +230,9 @@ void MoviePlayer::play() {
}
void MoviePlayer::performPostProcessing(byte *screen) {
- // TODO: We don't support the PSX stream videos yet
+ // TODO: We don't support displaying these in true color yet,
// nor using the PSX fonts to display subtitles.
- if (_vm->isPsx())
+ if (_vm->isPsx() || _decoderType == kVideoDecoderMP2)
return;
if (!_movieTexts.empty()) {
@@ -308,7 +314,7 @@ bool MoviePlayer::playVideo() {
if (_decoderType == kVideoDecoderPSX)
drawFramePSX(frame);
else
- _vm->_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, frame->w, frame->h);
+ _vm->_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
}
if (_decoder->hasDirtyPalette()) {
@@ -401,7 +407,7 @@ bool MoviePlayer::playVideo() {
}
Graphics::Surface *screen = _vm->_system->lockScreen();
- performPostProcessing((byte *)screen->pixels);
+ performPostProcessing((byte *)screen->getPixels());
_vm->_system->unlockScreen();
_vm->_system->updateScreen();
}
@@ -414,20 +420,19 @@ bool MoviePlayer::playVideo() {
_vm->_system->delayMillis(10);
}
- if (_decoderType == kVideoDecoderPSX) {
- // Need to jump back to paletted color
+ // Need to jump back to paletted color
+ if (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2)
initGraphics(g_system->getWidth(), g_system->getHeight(), true);
- }
return !_vm->shouldQuit() && !skipped;
}
uint32 MoviePlayer::getBlackColor() {
- return (_decoderType == kVideoDecoderPSX) ? g_system->getScreenFormat().RGBToColor(0x00, 0x00, 0x00) : _black;
+ return (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2) ? g_system->getScreenFormat().RGBToColor(0x00, 0x00, 0x00) : _black;
}
uint32 MoviePlayer::findTextColor() {
- if (_decoderType == kVideoDecoderPSX) {
+ if (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2) {
// We're in true color mode, so return the actual colors
switch (_textColor) {
case 1:
@@ -493,7 +498,7 @@ void MoviePlayer::drawFramePSX(const Graphics::Surface *frame) {
uint16 x = (g_system->getWidth() - scaledFrame.w) / 2;
uint16 y = (g_system->getHeight() - scaledFrame.h) / 2;
- _vm->_system->copyRectToScreen(scaledFrame.pixels, scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
+ _vm->_system->copyRectToScreen(scaledFrame.getPixels(), scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
scaledFrame.free();
}
@@ -547,9 +552,16 @@ MoviePlayer *makeMoviePlayer(uint32 id, SwordEngine *vm, Text *textMan, ResMan *
filename = Common::String::format("%s.mp2", sequenceList[id]);
if (Common::File::exists(filename)) {
- GUI::MessageDialog dialog(_("MPEG2 cutscenes are no longer supported"), _("OK"));
+#ifdef USE_MPEG2
+ // HACK: Old ScummVM builds ignored the AVI frame rate field and forced the video
+ // to be played back at 12fps.
+ Video::VideoDecoder *aviDecoder = new Video::AVIDecoder(12);
+ return new MoviePlayer(vm, textMan, resMan, system, aviDecoder, kVideoDecoderMP2);
+#else
+ GUI::MessageDialog dialog(_("MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"), _("OK"));
dialog.runModal();
return 0;
+#endif
}
if (!vm->isPsx() || scumm_stricmp(sequenceList[id], "enddemo") != 0) {
diff --git a/engines/sword1/animation.h b/engines/sword1/animation.h
index d0c61f5eb3..2c51a74f71 100644
--- a/engines/sword1/animation.h
+++ b/engines/sword1/animation.h
@@ -41,7 +41,8 @@ namespace Sword1 {
enum DecoderType {
kVideoDecoderDXA = 0,
kVideoDecoderSMK = 1,
- kVideoDecoderPSX = 2
+ kVideoDecoderPSX = 2,
+ kVideoDecoderMP2 = 3
};
class MovieText {
diff --git a/engines/sword1/configure.engine b/engines/sword1/configure.engine
new file mode 100644
index 0000000000..0578d176a9
--- /dev/null
+++ b/engines/sword1/configure.engine
@@ -0,0 +1,3 @@
+# This file is included from the main "configure" script
+# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
+add_engine sword1 "Broken Sword" yes
diff --git a/engines/sword1/music.cpp b/engines/sword1/music.cpp
index c34630aceb..f31faffd5e 100644
--- a/engines/sword1/music.cpp
+++ b/engines/sword1/music.cpp
@@ -110,7 +110,7 @@ bool MusicHandle::play(const Common::String &filename, bool loop) {
return true;
}
-bool MusicHandle::playPSX(uint16 id) {
+bool MusicHandle::playPSX(uint16 id, bool loop) {
stop();
if (!_file.isOpen())
@@ -131,7 +131,7 @@ bool MusicHandle::playPSX(uint16 id) {
// not over file size
if ((size != 0) && (size != 0xffffffff) && ((int32)(offset + size) <= _file.size())) {
_file.seek(offset, SEEK_SET);
- _audioSource = Audio::makeXAStream(_file.readStream(size), 11025);
+ _audioSource = Audio::makeLoopingAudioStream(Audio::makeXAStream(_file.readStream(size), 11025), loop ? 0 : 1);
fadeUp();
} else {
_audioSource = NULL;
@@ -297,7 +297,7 @@ void Music::startMusic(int32 tuneId, int32 loopFlag) {
the mutex before, to have the soundthread playing normally.
As the corresponding _converter is NULL, the handle will be ignored by the playing thread */
if (SwordEngine::isPsx()) {
- if (_handles[newStream].playPSX(tuneId)) {
+ if (_handles[newStream].playPSX(tuneId, loopFlag != 0)) {
_mutex.lock();
_converter[newStream] = Audio::makeRateConverter(_handles[newStream].getRate(), _mixer->getOutputRate(), _handles[newStream].isStereo(), false);
_mutex.unlock();
diff --git a/engines/sword1/music.h b/engines/sword1/music.h
index f1366202d7..4207019c13 100644
--- a/engines/sword1/music.h
+++ b/engines/sword1/music.h
@@ -44,7 +44,7 @@ public:
MusicHandle() : _fading(0), _audioSource(NULL) {}
virtual int readBuffer(int16 *buffer, const int numSamples);
bool play(const Common::String &filename, bool loop);
- bool playPSX(uint16 id);
+ bool playPSX(uint16 id, bool loop);
void stop();
void fadeUp();
void fadeDown();
diff --git a/engines/sword1/screen.cpp b/engines/sword1/screen.cpp
index ae128b8c05..76957e0a70 100644
--- a/engines/sword1/screen.cpp
+++ b/engines/sword1/screen.cpp
@@ -57,6 +57,30 @@ Screen::Screen(OSystem *system, ResMan *pResMan, ObjectMan *pObjMan) {
_psxCache.extPlxCache = NULL;
_oldScrollX = 0;
_oldScrollY = 0;
+
+ _textMan = 0;
+
+ for (int i = 0; i < 4; i++)
+ _layerGrid[i] = 0;
+
+ for (int i = 0; i < 4; i++)
+ _layerBlocks[i] = 0;
+
+ _parallax[0] = 0;
+ _parallax[1] = 0;
+
+ _fullRefresh = 0;
+
+ for (int i = 0; i < MAX_SORT; i++) {
+ _sortList[i].id = 0;
+ _sortList[i].y = 0;
+ }
+ _scrnSizeX = 0;
+ _scrnSizeY = 0;
+ _gridSizeX = 0;
+ _gridSizeY = 0;
+ _fadingDirection = 0;
+ _isBlack = 0;
}
Screen::~Screen() {
diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp
index 268da74508..643657c71f 100644
--- a/engines/sword1/sound.cpp
+++ b/engines/sword1/sound.cpp
@@ -269,9 +269,8 @@ void Sound::playSample(QueueElement *elem) {
uint8 volume = (volR + volL) / 2;
if (SwordEngine::isPsx()) {
- // We ignore FX_LOOP as XA has its own looping mechanism
uint32 size = READ_LE_UINT32(sampleData);
- Audio::AudioStream *audStream = Audio::makeXAStream(new Common::MemoryReadStream(sampleData + 4, size - 4), 11025);
+ Audio::AudioStream *audStream = Audio::makeLoopingAudioStream(Audio::makeXAStream(new Common::MemoryReadStream(sampleData + 4, size - 4), 11025), (_fxList[elem->id].type == FX_LOOP) ? 0 : 1);
_mixer->playStream(Audio::Mixer::kSFXSoundType, &elem->handle, audStream, elem->id, volume, pan);
} else {
uint32 size = READ_LE_UINT32(sampleData + 0x28);
diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp
index 2d5452778d..5738431dce 100644
--- a/engines/sword1/sword1.cpp
+++ b/engines/sword1/sword1.cpp
@@ -67,6 +67,17 @@ SwordEngine::SwordEngine(OSystem *syst)
SearchMan.addSubDirectoryMatching(gameDataDir, "italian"); // PSX Demo
_console = new SwordConsole(this);
+
+ _mouseState = 0;
+ _resMan = 0;
+ _objectMan = 0;
+ _screen = 0;
+ _mouse = 0;
+ _logic = 0;
+ _sound = 0;
+ _menu = 0;
+ _music = 0;
+ _control = 0;
}
SwordEngine::~SwordEngine() {