[Scummvm-cvs-logs] CVS: scummvm insane.cpp,1.45,1.46 smush.h,1.10,1.11
Pawe? Ko?odziejski
aquadran at users.sourceforge.net
Mon Jul 15 14:26:03 CEST 2002
- Previous message: [Scummvm-cvs-logs] CVS: scummvm newgui.cpp,1.19,1.20 newgui.h,1.14,1.15
- Next message: [Scummvm-cvs-logs] CVS: scummvm actor.cpp,1.89,1.90 boxes.cpp,1.34,1.35 scumm.h,1.181,1.182
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv15389
Modified Files:
insane.cpp smush.h
Log Message:
DIG: corrected placement and multiline subtitles in SMUSH animations
Index: insane.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/insane.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- insane.cpp 15 Jul 2002 12:38:09 -0000 1.45
+++ insane.cpp 15 Jul 2002 21:25:07 -0000 1.46
@@ -154,11 +154,64 @@
return txt;
}
+uint32 SmushPlayer::getFontHeight(uint8 c_font)
+{
+ byte * font = _fonts[c_font];
+ uint32 offset = 0, t_offset = 0;
+
+ if (font == NULL)
+ return 0;
+
+ if (READ_BE_UINT32(font) != 'AHDR')
+ return 0;
+
+ offset = READ_BE_UINT32(font + 4) + 8;
+ if (READ_BE_UINT32(font + offset) == 'FRME') {
+ offset += 8;
+ if (READ_BE_UINT32(font + offset) == 'FOBJ') {
+ t_offset = offset + 8;
+ offset += READ_BE_UINT32(font + offset + 4) + 8;
+ }
+ else
+ return 0;
+ }
+ return *(uint16*)(font + t_offset + 8);
+}
+
+uint32 SmushPlayer::getCharWidth(uint8 c_font, byte txt)
+{
+ byte * font = _fonts[c_font];
+ uint32 offset = 0, t_offset = 0, l;
+
+ if (font == NULL)
+ return 0;
+
+ if (READ_BE_UINT32(font) != 'AHDR')
+ return 0;
+
+ offset = READ_BE_UINT32(font + 4) + 8;
+ for (l = 0; l <= txt; l++) {
+ if (READ_BE_UINT32(font + offset) == 'FRME') {
+ offset += 8;
+ if (READ_BE_UINT32(font + offset) == 'FOBJ') {
+ t_offset = offset + 8;
+ offset += READ_BE_UINT32(font + offset + 4) + 8;
+ }
+ else
+ return 0;
+ }
+ else
+ return 0;
+ }
+ return *(uint16*)(font + t_offset + 6);
+}
+
void SmushPlayer::drawStringTRES(uint32 x, uint32 y, byte * txt)
{
char buf[4];
- uint32 c_line = 0, l = 0, i, tmp_x;
- uint8 c_font = 0, c_color = 0;
+ uint32 c_line = 0, l = 0, i, tmp_x, x_pos, last_l, t_width, t_height;
+ uint8 c_font = 0, c_color = 0, last_j;
+ int j;
if ((txt[l] == '^') && (txt[l + 1] == 'f')) {
buf[0] = txt[l + 2];
@@ -177,6 +230,72 @@
l += 5;
c_color = atoi(buf);
}
+
+ t_height = getFontHeight(c_font);
+ x_pos = x;
+ last_j = 0;
+ last_l = l;
+
+ for (j = 0;; j++) {
+ if (txt[l + j] == 0) {
+ break;
+ }
+ if (txt[l + j] == 0x0d) {
+ if (txt[l + j + 2] == 0x0d) break;
+ l += j + 2;
+ j = -1;
+ last_j = 0;
+ c_line++;
+ x_pos = x;
+ if (c_line * t_height + y >= 200) {
+ if (y > t_height) {
+ y -= t_height;
+ }
+ else
+ {
+ y = 0;
+ printf ("out of screen y\n");
+ }
+ continue;
+ }
+ }
+ t_width = getCharWidth (c_font, txt[l + j]);
+ if (x_pos + t_width >= 320) {
+ if ((x > t_width) && (c_line == 0)) {
+ x -= t_width;
+ x_pos += t_width;
+ if (txt[l + j] == ' ') {
+ last_j = j;
+ }
+ continue;
+ }
+ j = last_j;
+ txt[l + j] = 0x0d;
+ x_pos = x;
+ c_line++;
+ l++;
+ j = -1;
+ last_j = 0;
+ if (c_line * t_height + y >= 200) {
+ if (y > t_height) {
+ y -= t_height;
+ }
+ else {
+ y = 0;
+ printf ("out of screen y\n");
+ }
+ }
+ }
+ else {
+ x_pos += t_width;
+ if (txt[l + j] == ' ') {
+ last_j = j;
+ }
+ }
+ }
+
+ l = last_l;
+ c_line = 0;
for (;;) {
tmp_x = x;
@@ -184,18 +303,16 @@
if (txt[l + i] == 0)
goto exit_loop;
if (txt[l + i] == 0x0d) {
- l += i + 2;
- break;
+ if (txt[l + i + 1] == 0x0a) {
+ l += i + 2;
+ break;
+ }
+ else {
+ l += i + 1;
+ break;
+ }
}
drawCharTRES (&tmp_x, y, c_line, c_font, c_color, txt[l + i]);
-
- // this is hack
- if (y + c_line * 0xe > 170) continue;
-
- if (tmp_x > 320) {
- tmp_x = 0;
- c_line++;
- }
}
c_line++;
}
Index: smush.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/smush.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- smush.h 12 Jul 2002 05:25:32 -0000 1.10
+++ smush.h 15 Jul 2002 21:25:07 -0000 1.11
@@ -72,6 +72,8 @@
byte * loadTres();
void loadFonts();
+ uint32 getCharWidth(uint8 c_font, byte txt);
+ uint32 getFontHeight(uint8 c_font);
byte * getStringTRES(int32 number);
void drawStringTRES(uint32 x, uint32 y, byte * txt);
void drawCharTRES(uint32 * x, uint32 y, uint32 c_line, uint8 c_font, uint8 color, uint8 txt);
- Previous message: [Scummvm-cvs-logs] CVS: scummvm newgui.cpp,1.19,1.20 newgui.h,1.14,1.15
- Next message: [Scummvm-cvs-logs] CVS: scummvm actor.cpp,1.89,1.90 boxes.cpp,1.34,1.35 scumm.h,1.181,1.182
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list