aboutsummaryrefslogtreecommitdiff
path: root/engines/sword1
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sword1')
-rw-r--r--engines/sword1/animation.cpp42
-rw-r--r--engines/sword1/control.cpp2
-rw-r--r--engines/sword1/logic.cpp3
-rw-r--r--engines/sword1/resman.cpp6
-rw-r--r--engines/sword1/sound.cpp3
5 files changed, 45 insertions, 11 deletions
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp
index 2d0d081ef6..7ed50461af 100644
--- a/engines/sword1/animation.cpp
+++ b/engines/sword1/animation.cpp
@@ -160,6 +160,9 @@ void MoviePlayer::play(void) {
stopEvent.kbd = Common::KEYCODE_ESCAPE;
stopEvents.push_back(stopEvent);
+ _textX = 0;
+ _textY = 0;
+
terminated = !playVideo(stopEvents);
if (terminated)
@@ -200,12 +203,15 @@ void MoviePlayer::performPostProcessing(byte *screen) {
}
}
+ byte *src, *dst;
+ int x, y;
+
if (_textMan->giveSpriteData(2)) {
- byte *src = (byte *)_textMan->giveSpriteData(2) + sizeof(FrameHeader);
- byte *dst = screen + _textY * _decoder->getWidth() + _textX * 1;
+ src = (byte *)_textMan->giveSpriteData(2) + sizeof(FrameHeader);
+ dst = screen + _textY * SCREEN_WIDTH + _textX * 1;
- for (int y = 0; y < _textHeight; y++) {
- for (int x = 0; x < _textWidth; x++) {
+ for (y = 0; y < _textHeight; y++) {
+ for (x = 0; x < _textWidth; x++) {
switch (src[x]) {
case BORDER_COL:
dst[x] = _decoder->getBlack();
@@ -216,8 +222,34 @@ void MoviePlayer::performPostProcessing(byte *screen) {
}
}
src += _textWidth;
- dst += _decoder->getWidth();
+ dst += SCREEN_WIDTH;
+ }
+ } else if (_textX && _textY) {
+ // If the frame doesn't cover the entire screen, we have to
+ // erase the subtitles manually.
+
+ int frameWidth = _decoder->getWidth();
+ int frameHeight = _decoder->getHeight();
+ int frameX = (_system->getWidth() - frameWidth) / 2;
+ int frameY = (_system->getHeight() - frameHeight) / 2;
+
+ dst = screen + _textY * _system->getWidth();
+
+ for (y = 0; y < _textHeight; y++) {
+ if (_textY + y < frameY || _textY + y >= frameY + frameHeight) {
+ memset(dst + _textX, _decoder->getBlack(), _textWidth);
+ } else {
+ if (frameX > _textX)
+ memset(dst + _textX, _decoder->getBlack(), frameX - _textX);
+ if (frameX + frameWidth < _textX + _textWidth)
+ memset(dst + frameX + frameWidth, _decoder->getBlack(), _textX + _textWidth - (frameX + frameWidth));
+ }
+
+ dst += _system->getWidth();
}
+
+ _textX = 0;
+ _textY = 0;
}
}
diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp
index 756ce3a5cc..09d2197f2a 100644
--- a/engines/sword1/control.cpp
+++ b/engines/sword1/control.cpp
@@ -1207,7 +1207,7 @@ bool Control::restoreGameFromFile(uint8 slot) {
for (uint32 cnt2 = 0; cnt2 < playerSize; cnt2++)
playerBuf[cnt2] = inf->readUint32LE();
- if (inf->ioFailed()) {
+ if (inf->err() || inf->eos()) {
displayMessage(0, "Can't read from file '%s'. (%s)", fName, _saveFileMan->popErrorDesc().c_str());
delete inf;
free(_restoreBuf);
diff --git a/engines/sword1/logic.cpp b/engines/sword1/logic.cpp
index 7e911bd197..be3797b0bd 100644
--- a/engines/sword1/logic.cpp
+++ b/engines/sword1/logic.cpp
@@ -28,6 +28,7 @@
#include "common/util.h"
#include "common/system.h"
#include "common/events.h"
+#include "common/EventRecorder.h"
#include "sword1/logic.h"
#include "sword1/text.h"
@@ -55,7 +56,7 @@ namespace Sword1 {
uint32 Logic::_scriptVars[NUM_SCRIPT_VARS];
Logic::Logic(SwordEngine *vm, ObjectMan *pObjMan, ResMan *resMan, Screen *pScreen, Mouse *pMouse, Sound *pSound, Music *pMusic, Menu *pMenu, OSystem *system, Audio::Mixer *mixer) {
- g_system->getEventManager()->registerRandomSource(_rnd, "sword1");
+ g_eventRec.registerRandomSource(_rnd, "sword1");
_vm = vm;
_objMan = pObjMan;
diff --git a/engines/sword1/resman.cpp b/engines/sword1/resman.cpp
index 979bd3210a..90ea5fe677 100644
--- a/engines/sword1/resman.cpp
+++ b/engines/sword1/resman.cpp
@@ -263,9 +263,9 @@ void ResMan::resOpen(uint32 id) { // load resource ID into memory
_memMan->alloc(memHandle, size);
Common::File *clusFile = resFile(id);
assert(clusFile);
- clusFile->seek( resOffset(id) );
- clusFile->read( memHandle->data, size);
- if (clusFile->ioFailed()) {
+ clusFile->seek(resOffset(id));
+ clusFile->read(memHandle->data, size);
+ if (clusFile->err() || clusFile->eos()) {
error("Can't read %d bytes from offset %d from cluster file %s\nResource ID: %d (%08X)", size, resOffset(id), _prj.clu[(id >> 24) - 1].label, id, id);
}
} else
diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp
index b23bf71445..6ad946b28d 100644
--- a/engines/sword1/sound.cpp
+++ b/engines/sword1/sound.cpp
@@ -28,6 +28,7 @@
#include "common/util.h"
#include "common/events.h"
+#include "common/EventRecorder.h"
#include "common/system.h"
#include "sword1/sound.h"
@@ -47,7 +48,7 @@ namespace Sword1 {
#define SPEECH_FLAGS (Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_LITTLE_ENDIAN)
Sound::Sound(const char *searchPath, Audio::Mixer *mixer, ResMan *pResMan) {
- g_system->getEventManager()->registerRandomSource(_rnd, "sword1sound");
+ g_eventRec.registerRandomSource(_rnd, "sword1sound");
strcpy(_filePath, searchPath);
_mixer = mixer;
_resMan = pResMan;