aboutsummaryrefslogtreecommitdiff
path: root/scumm/smush
diff options
context:
space:
mode:
authorPaweł Kołodziejski2003-01-18 21:51:00 +0000
committerPaweł Kołodziejski2003-01-18 21:51:00 +0000
commit6478b944b279a451aeec48729dc4872666bd22db (patch)
tree3af9b879dc0449fb8fba34c7774063b7b5881c8a /scumm/smush
parente225720414409a27a3aed383379d4c1ae865c2d0 (diff)
downloadscummvm-rg350-6478b944b279a451aeec48729dc4872666bd22db.tar.gz
scummvm-rg350-6478b944b279a451aeec48729dc4872666bd22db.tar.bz2
scummvm-rg350-6478b944b279a451aeec48729dc4872666bd22db.zip
added preliminary support for subtitles in smush comi
svn-id: r6506
Diffstat (limited to 'scumm/smush')
-rw-r--r--scumm/smush/codec44.cpp76
-rw-r--r--scumm/smush/frenderer.cpp19
-rw-r--r--scumm/smush/player.cpp42
-rw-r--r--scumm/smush/player.h2
4 files changed, 86 insertions, 53 deletions
diff --git a/scumm/smush/codec44.cpp b/scumm/smush/codec44.cpp
index 5e8ee1c081..8d872573aa 100644
--- a/scumm/smush/codec44.cpp
+++ b/scumm/smush/codec44.cpp
@@ -27,45 +27,47 @@
bool Codec44Decoder::decode(Blitter & dst, Chunk & src) {
int32 size_line;
int32 num;
- int32 w, width = getRect().width() + 1;
- int32 h, height = getRect().height() + 1;
- bool zero;
-#ifdef DEBUG_CODEC44
- debug(7, "codec44 : %dx%d", width, height);
-#endif
+ int32 length = src.getSize() - 14;
+ int32 width = getRect().width();
+ int32 height = getRect().height();
+ byte * src2 = (byte*)malloc(length);
+ byte * org_src2 = src2;
+ src.read(src2, length);
+ byte * dst2 = (byte*)malloc(2000);
+ byte * org_dst2 = dst2;
+ byte val;
- for(h = 0; h < height - 1; h++) {
- w = width;
- size_line = src.getWord(); // size of compressed line !
-#ifdef DEBUG_CODEC44
- debug(7, "codec44 : h == %d, size_line == %d", h, size_line);
-#endif
- zero = true;
- while(size_line > 1) {
- num = src.getWord();
+ do {
+ size_line = READ_LE_UINT16(src2);
+ src2 += 2;
+ length -= 2;
+
+ while (size_line != 0) {
+ num = *src2++;
+ val = *src2++;
+ memset(dst2, val, num);
+ dst2 += num;
+ length -= 2;
size_line -= 2;
- if(zero) {
-#ifdef DEBUG_CODEC44
- debug(7, "codec44 : zeroing %d, entries", num);
-#endif
- if(w == num)
- num--;
- w -= num;
- if(num)
- dst.put(0, num);
- } else {
- num += 1;
-#ifdef DEBUG_CODEC44
- debug(7, "codec44 : blitting %d, entries", num);
-#endif
- if(w == num)
- num--;
- w -= num;
- dst.blit(src, num);
- size_line -= num;
- }
- zero = !zero;
+ if (size_line == 0)
+ break;
+
+ num = READ_LE_UINT16(src2) + 1;
+ src2 += 2;
+ memcpy(dst2, src2, num);
+ dst2 += num;
+ src2 += num;
+ length -= num + 2;
+ size_line -= num + 2;
}
- }
+ dst2--;
+
+ } while (length > 1);
+
+ dst.blit(org_dst2, width * height);
+
+ free(org_src2);
+ free(org_dst2);
+
return true;
}
diff --git a/scumm/smush/frenderer.cpp b/scumm/smush/frenderer.cpp
index ea754472ab..84451da672 100644
--- a/scumm/smush/frenderer.cpp
+++ b/scumm/smush/frenderer.cpp
@@ -114,12 +114,12 @@ int32 FontRenderer::drawChar(char * buffer, const Point & size, int32 x, int32 y
}
static char * * split(const char * str, char sep) {
- char * * ret = new char *[32];
+ char * * ret = new char *[62];
int32 n = 0;
const char * i = str, * j = strchr(i, sep);
while(j != NULL) {
- assert(n < 30);
+ assert(n < 60);
ret[n] = new char[j - i + 1];
memcpy(ret[n], i, j - i);
ret[n++][j - i] = 0;
@@ -160,7 +160,10 @@ bool FontRenderer::drawStringAbsolute(const char * str, char * buffer, const Poi
bool FontRenderer::drawStringCentered(const char * str, char * buffer, const Point & size, int32 y, int32 xmin, int32 width, int32 offset) const {
debug(9, "FontRenderer::drawStringCentered(%s, %d, %d)", str, xmin, y);
- assert(strchr(str, '\n') == 0);
+ if ((strchr(str, '\n') != 0)) {
+ char * j = strchr(str, '\n');
+ *j = 0;
+ }
char * * words = split(str, ' ');
int32 nb_sub = 0;
@@ -235,7 +238,10 @@ bool FontRenderer::drawStringCentered(const char * str, char * buffer, const Poi
bool FontRenderer::drawStringWrap(const char * str, char * buffer, const Point & size, int32 x, int32 y, int32 width) const {
debug(9, "FontRenderer::drawStringWrap(%s, %d, %d)", str, x, y);
- assert(strchr(str, '\n') == 0);
+ if ((strchr(str, '\n') != 0)) {
+ char * j = strchr(str, '\n');
+ *j = 0;
+ }
char * * words = split(str, ' ');
int32 nb_sub = 0;
@@ -308,7 +314,10 @@ bool FontRenderer::drawStringWrap(const char * str, char * buffer, const Point &
bool FontRenderer::drawStringWrapCentered(const char * str, char * buffer, const Point & size, int32 x, int32 y, int32 width) const {
int32 max_substr_width = 0;
debug(9, "FontRenderer::drawStringWrapCentered(%s, %d, %d)", str, x, y);
- assert(strchr(str, '\n') == 0);
+ if ((strchr(str, '\n') != 0)) {
+ char * j = strchr(str, '\n');
+ *j = 0;
+ }
char * * words = split(str, ' ');
int32 nb_sub = 0;
diff --git a/scumm/smush/player.cpp b/scumm/smush/player.cpp
index 0a904769f7..e954cc54c9 100644
--- a/scumm/smush/player.cpp
+++ b/scumm/smush/player.cpp
@@ -23,7 +23,6 @@
#include "common/file.h"
#include "common/util.h"
#include "common/engine.h" // for debug, warning, error
-#include "common/engine.h" // for debug, warning, error
#include "scumm/scumm.h"
#include "sound/mixer.h"
@@ -209,7 +208,7 @@ SmushPlayer::SmushPlayer(Renderer * renderer, bool wait, bool sound) :
_bgmusic(true),
_voices(true),
_curBuffer(0) {
- _fr[0] = _fr[1] = _fr[2] = _fr[3] = 0;
+ _fr[0] = _fr[1] = _fr[2] = _fr[3] = _fr[4] = 0;
assert(_renderer != 0);
_IACTchannel = -1;
_IACTrest = 0;
@@ -231,6 +230,7 @@ void SmushPlayer::clean() {
if(_fr[1]) delete _fr[1];
if(_fr[2]) delete _fr[2];
if(_fr[3]) delete _fr[3];
+ if(_fr[4]) delete _fr[4];
}
void SmushPlayer::checkBlock(const Chunk & b, Chunk::type type_expected, uint32 min_size) {
@@ -430,7 +430,6 @@ void SmushPlayer::handleImuseAction(Chunk & b) {
}
void SmushPlayer::handleTextResource(Chunk & b) {
- checkBlock(b, TYPE_TRES, 18);
int32 pos_x = b.getShort();
int32 pos_y = b.getShort();
int32 flags = b.getShort();
@@ -439,18 +438,30 @@ void SmushPlayer::handleTextResource(Chunk & b) {
int32 width = b.getShort();
/*int32 height =*/ b.getShort();
/*int32 unk2 =*/ b.getWord();
- int32 string_id = b.getWord();
- debug(6, "SmushPlayer::handleTextResource(%d)", string_id);
- if(!_strings) return;
+
+ const char * str;
+ char * string;
+ if (g_scumm->_gameId == GID_CMI) {
+ string = (char*)malloc(b.getSize() - 16);
+ str = string;
+ b.read(string, b.getSize() - 16);
+ } else {
+ int32 string_id = b.getWord();
+ debug(6, "SmushPlayer::handleTextResource(%d)", string_id);
+ if(!_strings)
+ return;
+ str = _strings->get(string_id);
+ }
// if subtitles disabled and bit 3 is set, then do not draw
if((!_subtitles) && ((flags & 8) == 8))
return;
- const char * str = _strings->get(string_id);
FontRenderer * fr = _fr[0];
int32 color = 15;
while(*str == '/') str++; // For Full Throttle text resources
+ if (g_scumm->_gameId == GID_CMI)
+ while(*str++ != '/');
while(str[0] == '^') {
switch(str[1]) {
case 'f':
@@ -503,6 +514,10 @@ void SmushPlayer::handleTextResource(Chunk & b) {
}
else
warning("SmushPlayer::handleTextResource. Not handled flags: %d\n", flags);
+
+ if (g_scumm->_gameId == GID_CMI) {
+ free (string);
+ }
}
void SmushPlayer::readPalette(Palette & out, Chunk & in) {
@@ -607,7 +622,6 @@ void SmushPlayer::handleFrameObject(Chunk & b) {
decodeCodec(b, r, _codec1);
break;
case 37:
- // assert(left == 0 && top == 0);
initSize(r, true, false);
decodeCodec(b, r, _codec37);
_codec37Called = true;
@@ -665,6 +679,7 @@ void SmushPlayer::handleFrame(Chunk & b) {
handleSkip(*sub);
break;
case TYPE_TEXT:
+ handleTextResource(*sub);
break;
default:
error("Unknown frame subChunk found : %s, %d", Chunk::ChunkString(sub->getType()), sub->getSize());
@@ -806,10 +821,10 @@ bool SmushPlayer::play(const char * file, const char * directory) {
clean();
if(_wait) {
- bool isFullthrottle;
+ bool isFullthrottle = false;
if(!readString(file, directory, isFullthrottle))
debug(2, "unable to read text information for \"%s\"", file);
- if(_strings) {
+ if((_strings) || (g_scumm->_gameId == GID_CMI)) {
if(isFullthrottle) {
_fr[0] = loadFont("scummfnt.nut", directory, true);
_fr[2] = loadFont("titlfnt.nut", directory, true);
@@ -821,6 +836,13 @@ bool SmushPlayer::play(const char * file, const char * directory) {
}
}
}
+ if(g_scumm->_gameId == GID_CMI) {
+ for(int i = 0; i < 5; i++) {
+ char file_font[20];
+ sprintf((char*)&file_font, "font%d.nut", i);
+ _fr[i] = loadFont(file_font, directory, i != 0);
+ }
+ }
}
File test;
diff --git a/scumm/smush/player.h b/scumm/smush/player.h
index 7d181086d0..5977678382 100644
--- a/scumm/smush/player.h
+++ b/scumm/smush/player.h
@@ -53,7 +53,7 @@ private:
int16 _deltaPal[768]; //!< the delta palette information set by an xpal
Renderer * _renderer; //!< pointer to the ::renderer
StringResource * _strings; //!< pointer to the string resources associated with the animation
- FontRenderer * _fr[4]; //!< pointers to the fonts for the animation
+ FontRenderer * _fr[5]; //!< pointers to the fonts for the animation
Codec1Decoder _codec1; //!< the ::decoder for codec 1 and 3
Codec37Decoder _codec37; //!< the ::decoder for codec 37
Codec47Decoder _codec47; //!< the ::decoder for codec 47