From 7e71865e91a19b022a5ad839802f79a5f300fe8d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 25 Jul 2009 12:59:46 +0000 Subject: Move the event recorder to its own class (EventRecoder inside common/EventRecorder.[h/cpp]). svn-id: r42751 --- engines/sword1/logic.cpp | 3 ++- engines/sword1/sound.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'engines/sword1') 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/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; -- cgit v1.2.3 From f853376379802198b9b02845dce0c46fec2b0af6 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 28 Jul 2009 17:19:33 +0000 Subject: Fixed drawing subtitles for cutscenes that are narrower than the screen, and erase the subtitles manually if they are drawn outside the frame. svn-id: r42859 --- engines/sword1/animation.cpp | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'engines/sword1') 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; } } -- cgit v1.2.3 From e9cd07e582d27d1e329269d4e3d544eea03f0131 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 29 Jul 2009 21:39:34 +0000 Subject: SWORD1 & SWORD2: Replaced ioFailed by err+eos svn-id: r42912 --- engines/sword1/control.cpp | 2 +- engines/sword1/resman.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/sword1') 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/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 -- cgit v1.2.3