aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/gfx/font.cpp101
-rw-r--r--engines/sci/gfx/font.h130
-rw-r--r--engines/sci/gfx/gfx_options.h4
-rw-r--r--engines/sci/gfx/gfx_resmgr.h2
-rw-r--r--engines/sci/gfx/gfx_resource.h81
-rw-r--r--engines/sci/gfx/gfx_system.h24
-rw-r--r--engines/sci/gfx/operations.cpp1
-rw-r--r--engines/sci/gfx/operations.h2
-rw-r--r--engines/sci/gfx/resmgr.cpp1
-rw-r--r--engines/sci/gfx/resource/sci_font.cpp1
-rw-r--r--engines/sci/gfx/resource/sci_resmgr.cpp1
-rw-r--r--engines/sci/gfx/sci_widgets.cpp1
-rw-r--r--engines/sci/sci.cpp1
-rw-r--r--engines/sci/scicore/vocab.cpp6
14 files changed, 148 insertions, 208 deletions
diff --git a/engines/sci/gfx/font.cpp b/engines/sci/gfx/font.cpp
index 2bda51f050..02412a2f43 100644
--- a/engines/sci/gfx/font.cpp
+++ b/engines/sci/gfx/font.cpp
@@ -27,114 +27,25 @@
#include "sci/gfx/gfx_system.h"
#include "sci/gfx/gfx_resource.h"
#include "sci/gfx/gfx_tools.h"
+#include "sci/gfx/font.h"
namespace Sci {
int font_counter = 0;
void gfxr_free_font(gfx_bitmap_font_t *font) {
- if (font->widths)
- free(font->widths);
-
- if (font->data)
- free(font->data);
+ free(font->widths);
+ free(font->data);
--font_counter;
free(font);
}
-void scale_char(byte *dest, byte *src, int width, int height, int newwidth, int xfact, int yfact) {
- int x, y;
-
- for (y = 0; y < height; y++) {
- int yc;
- byte *bdest = dest;
- byte *bsrc = src;
-
- for (x = 0; x < width; x++) {
- int xbitc;
- int bits = 0;
- int value = 0;
-
- for (xbitc = 128; xbitc; xbitc >>= 1) {
- int xc;
-
- for (xc = 0; xc < xfact; xc++) {
- if (*bsrc & xbitc)
- value |= 1;
- value <<= 1;
-
- if (++bits == 8) {
- *bdest++ = value;
- bits = value = 0;
- }
- }
- }
- bsrc++;
- }
-
- src += width;
- for (yc = 1; yc < yfact; yc++) {
- memcpy(dest + newwidth, dest, newwidth);
- dest += newwidth;
- }
- dest += newwidth;
- }
-}
-
-gfx_bitmap_font_t *gfxr_scale_font_unfiltered(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode) {
- gfx_bitmap_font_t *font = (gfx_bitmap_font_t *)sci_malloc(sizeof(gfx_bitmap_font_t));
- int height = orig_font->height * mode->yfact;
- int width = 0;
- int byte_width;
- int i;
-
- font->chars_nr = orig_font->chars_nr;
- for (i = 0; i < font->chars_nr; i++)
- if (orig_font->widths[i] > width)
- width = orig_font->widths[i];
-
- width *= mode->xfact;
- byte_width = (width + 7) >> 3;
- if (byte_width == 3)
- byte_width = 4;
- if (byte_width > 4)
- byte_width = (byte_width + 3) & ~3;
-
- font->row_size = byte_width;
- font->height = height;
- font->line_height = orig_font->line_height * mode->yfact;
-
- font->widths = (int*)sci_malloc(sizeof(int) * orig_font->chars_nr);
- font->char_size = byte_width * height;
- font->data = (byte*)sci_malloc(font->chars_nr * font->char_size);
-
- for (i = 0; i < font->chars_nr; i++) {
- font->widths[i] = orig_font->widths[i] * mode->xfact;
- scale_char(font->data + font->char_size * i, orig_font->data + orig_font->char_size * i,
- orig_font->row_size, orig_font->height, font->row_size, mode->xfact, mode->yfact);
- }
-
- return font;
-}
-
-gfx_bitmap_font_t *gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode, gfxr_font_scale_filter_t filter) {
- GFXWARN("This function hasn't been tested yet!\n");
-
- switch (filter) {
-
- case GFXR_FONT_SCALE_FILTER_NONE:
- return gfxr_scale_font_unfiltered(orig_font, mode);
-
- default:
- GFXERROR("Invalid font filter mode %d!\n", filter);
- return NULL;
- }
-}
-
-text_fragment_t *gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *text, int *width, int *height,
+text_fragment_t *gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width,
+ const char *text, int *width, int *height,
int *lines, int *line_height_p, int *last_offset_p, int flags) {
+
int est_char_width = font->widths[(font->chars_nr > 'M')? 'M' : font->chars_nr - 1];
// 'M' is typically among the widest chars
int fragments_nr;
diff --git a/engines/sci/gfx/font.h b/engines/sci/gfx/font.h
new file mode 100644
index 0000000000..81d5b4274f
--- /dev/null
+++ b/engines/sci/gfx/font.h
@@ -0,0 +1,130 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef SCI_GFX_FONT_H
+#define SCI_GFX_FONT_H
+
+#include "common/scummsys.h"
+
+
+namespace Sci {
+
+struct text_fragment_t {
+ const char *offset;
+ int length;
+};
+
+
+struct gfx_bitmap_font_t { /* gfx_bitmap_font_t: Bitmap font information */
+ int ID; /* Unique resource ID */
+
+ int chars_nr; /* Numer of available characters */
+
+ int *widths; /* chars_nr character widths, in pixels */
+
+ int row_size; /* Byte size of each pixel row. For unscaled fonts, this is
+ ** always 1, 2, or 4. Otherwise, it's a multiple of 4.
+ */
+
+ int line_height; /* Height of each text line (usually identical to height) */
+ int height; /* Height for all characters, in pixel rows */
+ int char_size; /* Amount of memory occupied by one character in data */
+
+ byte *data; /* Font data, consisting of 'chars_nr' entries of 'height' rows
+ ** of 'row_size' bytes. For each character ch, its first byte
+ ** (the topmost row) is located at (data + (charsize * ch)), and
+ ** its pixel width is widths[ch], provided that (ch < chars_nr).
+ */
+
+};
+
+/*******************/
+/* Font operations */
+/*******************/
+
+/* SCI0, SCI01 and SCI1 all use the same font format. */
+
+/* SQ3 uses a somewhat different scheme for calculating text sizes: it counts
+** whitespace while calculating the text size. */
+#define GFXR_FONT_FLAG_COUNT_WHITESPACE (1<<0)
+/* Don't give newline characters special semantics */
+#define GFXR_FONT_FLAG_NO_NEWLINES (1<<1)
+/* Interpret CR LF sequences as a single newline, rather than two of them */
+#define GFXR_FONT_FLAG_EAT_TRAILING_LF (1<<2)
+
+
+gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size);
+/* Geneartes a bitmap font data structure from a resource
+** Parameters: (int) id: Resource ID of the resulting font
+** (byte *) resource: Pointer to the resource data
+** (int) size: Size of the resource block
+** Returns : (gfx_bitmap_font_t *) The resulting font structure, or
+** NULL on error
+*/
+
+void gfxr_free_font(gfx_bitmap_font_t *font);
+/* Frees a previously allocated font structure
+** Parameters: (gfx_bitmap_font_t *) font: The font to free
+** Returns : (void)
+*/
+
+text_fragment_t *gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *text,
+ int *width, int *height, int *lines, int *line_height, int *last_offset, int flags);
+/* Calculates the size that would be occupied by drawing a specified text
+** Parameters: (gfx_bitmap_font_t *) font: The font to calculate with
+** (int) max_width: Maximum pixel width allowed for the output
+** (const char *) text: The text to calculate for
+** (int) flags: Any text formatting flags
+** Returns : (text_fragment *) a newly allocated array of text_fragments,
+** containing the start and size of each string
+** segment
+** (int) *width: The resulting width
+** (int) *height: The resulting height
+** (int) *lines: Number of lines used
+** (int) *line_height: Pixel height of a single line of text
+** (int) *last_offset: Pixel offset after the last drawn line
+** This function assumes 320x200 mode.
+*/
+
+gfx_pixmap_t *gfxr_draw_font(gfx_bitmap_font_t *font, const char *text, int characters,
+ gfx_pixmap_color_t *fg0, gfx_pixmap_color_t *fg1, gfx_pixmap_color_t *bg);
+/* Draws text in a specific font to a pixmap
+** Parameters: (gfx_bitmap_font_t *) font: The font to use for drawing
+** (char *) text: The start of the text to draw
+** (int) characters: The number of characters to draw
+** (gfx_pixmap_color_t *) fg0: The first foreground color
+** (gfx_pixmap_color_t *) fg1: The second foreground color
+** (gfx_pixmap_color_t *) bg: The background color
+** Returns : (gfx_pixmap_t *) The result pixmap, or NULL on error
+** The results are written to the pixmap's index buffer. Contents of the
+** foreground and background fields are copied into a newly allocated font
+** structure, so that the pixmap may be translated directly.
+** If any of the colors is null, it will be assumed to be transparent.
+** In color index mode, the specified colors have to be preallocated.
+*/
+
+} // End of namespace Sci
+
+#endif // SCI_GFX_FONT_H
diff --git a/engines/sci/gfx/gfx_options.h b/engines/sci/gfx/gfx_options.h
index e83298bf1b..e6a2112286 100644
--- a/engines/sci/gfx/gfx_options.h
+++ b/engines/sci/gfx/gfx_options.h
@@ -49,9 +49,6 @@ struct gfx_options_t {
int buffer_pics_nr; /* Number of unused pics to buffer */
- int correct_rendering; /* Whether to render slow, but correct (rather than
- ** fast and almost correct) */
-
/* SCI0 pic resource options */
int pic0_unscaled; /* Don't draw scaled SCI0 pics */
@@ -65,7 +62,6 @@ struct gfx_options_t {
gfx_xlate_filter_t view_xlate_filter;
gfx_xlate_filter_t pic_xlate_filter; /* Only relevant if (pic0_unscaled) */
gfx_xlate_filter_t text_xlate_filter;
- gfxr_font_scale_filter_t fixed_font_xlate_filter; /* Scale filter for systems that provide font support which isn't scaled */
gfx_res_fullconf_t res_conf; /* Resource customisation: Per-resource palettes etc. */
diff --git a/engines/sci/gfx/gfx_resmgr.h b/engines/sci/gfx/gfx_resmgr.h
index 2f97dee8dc..005025670c 100644
--- a/engines/sci/gfx/gfx_resmgr.h
+++ b/engines/sci/gfx/gfx_resmgr.h
@@ -35,6 +35,8 @@
namespace Sci {
+struct gfx_bitmap_font_t;
+
enum gfx_resource_type_t {
GFX_RESOURCE_TYPE_VIEW = 0,
GFX_RESOURCE_TYPE_PIC,
diff --git a/engines/sci/gfx/gfx_resource.h b/engines/sci/gfx/gfx_resource.h
index 55b3fc9c14..c508971c74 100644
--- a/engines/sci/gfx/gfx_resource.h
+++ b/engines/sci/gfx/gfx_resource.h
@@ -123,16 +123,6 @@ struct gfxr_view_t {
};
-enum gfxr_font_scale_filter_t {
- GFXR_FONT_SCALE_FILTER_NONE
-};
-
-
-struct text_fragment_t {
- const char *offset;
- int length;
-};
-
/* unscaled color index mode: Used in addition to a scaled mode
** to render the pic resource twice. See gfxr_remove_artifacts_pic0().
*/
@@ -167,77 +157,6 @@ void gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view);
*/
-/*******************/
-/* Font operations */
-/*******************/
-/* SCI0, SCI01 and SCI1 all use the same font format. */
-
-/* SQ3 uses a somewhat different scheme for calculating text sizes: it counts
-** whitespace while calculating the text size. */
-#define GFXR_FONT_FLAG_COUNT_WHITESPACE (1<<0)
-/* Don't give newline characters special semantics */
-#define GFXR_FONT_FLAG_NO_NEWLINES (1<<1)
-/* Interpret CR LF sequences as a single newline, rather than two of them */
-#define GFXR_FONT_FLAG_EAT_TRAILING_LF (1<<2)
-
-
-gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size);
-/* Geneartes a bitmap font data structure from a resource
-** Parameters: (int) id: Resource ID of the resulting font
-** (byte *) resource: Pointer to the resource data
-** (int) size: Size of the resource block
-** Returns : (gfx_bitmap_font_t *) The resulting font structure, or
-** NULL on error
-*/
-
-void gfxr_free_font(gfx_bitmap_font_t *font);
-/* Frees a previously allocated font structure
-** Parameters: (gfx_bitmap_font_t *) font: The font to free
-** Returns : (void)
-*/
-
-gfx_bitmap_font_t *gfxr_scale_font(gfx_bitmap_font_t *font, gfx_mode_t *mode, gfxr_font_scale_filter_t filter);
-/* Scales a font resource
-** Parameters: (gfx_bitmap_font_t *) font: The font to scale
-** (gfx_mode_t *) mode: The graphics mode to scale it for
-** (gfxr_font_scale_filter_t) filter: A filter to use
-** Returns : (gfx_bitmap_font_t *) A scaled font, or NULL on error
-*/
-
-text_fragment_t *gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *text,
- int *width, int *height, int *lines, int *line_height, int *last_offset, int flags);
-/* Calculates the size that would be occupied by drawing a specified text
-** Parameters: (gfx_bitmap_font_t *) font: The font to calculate with
-** (int) max_width: Maximum pixel width allowed for the output
-** (const char *) text: The text to calculate for
-** (int) flags: Any text formatting flags
-** Returns : (text_fragment *) a newly allocated array of text_fragments,
-** containing the start and size of each string
-** segment
-** (int) *width: The resulting width
-** (int) *height: The resulting height
-** (int) *lines: Number of lines used
-** (int) *line_height: Pixel height of a single line of text
-** (int) *last_offset: Pixel offset after the last drawn line
-** This function assumes 320x200 mode.
-*/
-
-gfx_pixmap_t *gfxr_draw_font(gfx_bitmap_font_t *font, const char *text, int characters,
- gfx_pixmap_color_t *fg0, gfx_pixmap_color_t *fg1, gfx_pixmap_color_t *bg);
-/* Draws text in a specific font to a pixmap
-** Parameters: (gfx_bitmap_font_t *) font: The font to use for drawing
-** (char *) text: The start of the text to draw
-** (int) characters: The number of characters to draw
-** (gfx_pixmap_color_t *) fg0: The first foreground color
-** (gfx_pixmap_color_t *) fg1: The second foreground color
-** (gfx_pixmap_color_t *) bg: The background color
-** Returns : (gfx_pixmap_t *) The result pixmap, or NULL on error
-** The results are written to the pixmap's index buffer. Contents of the
-** foreground and background fields are copied into a newly allocated font
-** structure, so that the pixmap may be translated directly.
-** If any of the colors is null, it will be assumed to be transparent.
-** In color index mode, the specified colors have to be preallocated.
-*/
/*********************/
diff --git a/engines/sci/gfx/gfx_system.h b/engines/sci/gfx/gfx_system.h
index 9f843304fb..a6fb285315 100644
--- a/engines/sci/gfx/gfx_system.h
+++ b/engines/sci/gfx/gfx_system.h
@@ -289,30 +289,6 @@ struct gfx_pixmap_t { /* gfx_pixmap_t: Pixel map */
};
-struct gfx_bitmap_font_t { /* gfx_bitmap_font_t: Bitmap font information */
- int ID; /* Unique resource ID */
-
- int chars_nr; /* Numer of available characters */
-
- int *widths; /* chars_nr character widths, in pixels */
-
- int row_size; /* Byte size of each pixel row. For unscaled fonts, this is
- ** always 1, 2, or 4. Otherwise, it's a multiple of 4.
- */
-
- int line_height; /* Height of each text line (usually identical to height) */
- int height; /* Height for all characters, in pixel rows */
- int char_size; /* Amount of memory occupied by one character in data */
-
- byte *data; /* Font data, consisting of 'chars_nr' entries of 'height' rows
- ** of 'row_size' bytes. For each character ch, its first byte
- ** (the topmost row) is located at (data + (charsize * ch)), and
- ** its pixel width is widths[ch], provided that (ch < chars_nr).
- */
-
-};
-
-
/***********************/
/*** Constant values ***/
diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp
index e66156a482..e1040327a4 100644
--- a/engines/sci/gfx/operations.cpp
+++ b/engines/sci/gfx/operations.cpp
@@ -27,6 +27,7 @@
#include "sci/sci_memory.h"
#include "sci/gfx/operations.h"
+#include "sci/gfx/font.h"
#include "common/system.h"
#include "common/events.h"
diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h
index ad8372c510..b2edb9a022 100644
--- a/engines/sci/gfx/operations.h
+++ b/engines/sci/gfx/operations.h
@@ -38,6 +38,8 @@
namespace Sci {
+struct text_fragment_t;
+
#define GFXOP_NO_POINTER -1
/* Threshold in color index mode to differentiate between visible and non-visible stuff.
diff --git a/engines/sci/gfx/resmgr.cpp b/engines/sci/gfx/resmgr.cpp
index dba08fef2e..1737c2e6fa 100644
--- a/engines/sci/gfx/resmgr.cpp
+++ b/engines/sci/gfx/resmgr.cpp
@@ -34,6 +34,7 @@
#include "sci/gfx/gfx_driver.h"
#include "sci/gfx/gfx_resmgr.h"
#include "sci/gfx/gfx_state_internal.h"
+#include "sci/gfx/font.h"
#include "common/system.h"
diff --git a/engines/sci/gfx/resource/sci_font.cpp b/engines/sci/gfx/resource/sci_font.cpp
index e37306405e..9813c1350d 100644
--- a/engines/sci/gfx/resource/sci_font.cpp
+++ b/engines/sci/gfx/resource/sci_font.cpp
@@ -27,6 +27,7 @@
#include "sci/gfx/gfx_system.h"
#include "sci/gfx/gfx_resource.h"
#include "sci/gfx/gfx_tools.h"
+#include "sci/gfx/font.h"
namespace Sci {
diff --git a/engines/sci/gfx/resource/sci_resmgr.cpp b/engines/sci/gfx/resource/sci_resmgr.cpp
index fe74348ffd..645f24fb2f 100644
--- a/engines/sci/gfx/resource/sci_resmgr.cpp
+++ b/engines/sci/gfx/resource/sci_resmgr.cpp
@@ -30,6 +30,7 @@
#include "sci/gfx/gfx_widgets.h"
#include "sci/gfx/gfx_resmgr.h"
#include "sci/gfx/gfx_options.h"
+#include "sci/gfx/font.h"
#include "common/util.h"
diff --git a/engines/sci/gfx/sci_widgets.cpp b/engines/sci/gfx/sci_widgets.cpp
index 36a723ee4e..3e6329d426 100644
--- a/engines/sci/gfx/sci_widgets.cpp
+++ b/engines/sci/gfx/sci_widgets.cpp
@@ -29,6 +29,7 @@
#include "sci/gfx/menubar.h"
#include "sci/gfx/sci_widgets.h"
#include "sci/gfx/gfx_state_internal.h"
+#include "sci/gfx/font.h"
#include "common/system.h"
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index aea517f2dd..6946d86f12 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -251,7 +251,6 @@ Common::Error SciEngine::run() {
gfx_options_t gfx_options;
gfx_options.workarounds = 0;
gfx_options.buffer_pics_nr = 0;
- gfx_options.correct_rendering = 1;
gfx_options.pic0_unscaled = 1;
gfx_options.pic0_dither_mode = GFXR_DITHER_MODE_D256;
gfx_options.pic0_dither_pattern = GFXR_DITHER_PATTERN_SCALED;
diff --git a/engines/sci/scicore/vocab.cpp b/engines/sci/scicore/vocab.cpp
index 885a393a14..3955952b98 100644
--- a/engines/sci/scicore/vocab.cpp
+++ b/engines/sci/scicore/vocab.cpp
@@ -47,9 +47,6 @@ int _vocab_cmp_words(const void *word1, const void *word2) {
}
word_t **vocab_get_words(ResourceManager *resmgr, int *word_counter) {
- int counter = 0;
- unsigned int seeker;
- word_t **words;
char currentword[256] = ""; // They're not going to use words longer than 255 ;-)
int currentwordpos = 0;
@@ -71,6 +68,7 @@ word_t **vocab_get_words(ResourceManager *resmgr, int *word_counter) {
return NULL; // NOT critical: SCI1 games and some demos don't have one!
}
+ unsigned int seeker;
if (vocab_version == 1)
seeker = 255 * 2; // vocab.900 starts with 255 16-bit pointers which we don't use
else
@@ -82,6 +80,8 @@ word_t **vocab_get_words(ResourceManager *resmgr, int *word_counter) {
// Now this ought to be critical, but it'll just cause parse() and said() not to work
}
+ int counter = 0;
+ word_t **words;
words = (word_t **)sci_malloc(sizeof(word_t *));
while (seeker < resource->size) {