2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2003-07-28 01:44:38 +00:00
|
|
|
*
|
2007-05-31 20:28:29 +00:00
|
|
|
* Additional copyright for this file:
|
|
|
|
* Copyright (C) 1994-1998 Revolution Software Ltd.
|
|
|
|
*
|
2003-07-28 01:44:38 +00:00
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-07-28 01:44:38 +00:00
|
|
|
*
|
2006-02-09 15:12:44 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2003-07-28 01:44:38 +00:00
|
|
|
*/
|
|
|
|
|
2003-09-19 06:42:22 +00:00
|
|
|
// MAKETEXT - Constructs a single-frame text sprite: returns a handle to a
|
|
|
|
// FLOATING memory block containing the sprite, given a
|
|
|
|
// null-terminated string, max width allowed, pen colour and
|
|
|
|
// pointer to required character set.
|
2003-07-28 01:44:38 +00:00
|
|
|
//
|
2003-09-19 06:42:22 +00:00
|
|
|
// NB 1) The routine does not create a standard file header or
|
|
|
|
// an anim header for the text sprite - the data simply begins
|
|
|
|
// with the frame header.
|
2003-07-28 01:44:38 +00:00
|
|
|
//
|
2003-09-19 06:42:22 +00:00
|
|
|
// NB 2) If pen colour is zero, it copies the characters into
|
|
|
|
// the sprite without remapping the colours.
|
|
|
|
// ie. It can handle both the standard 2-colour font for speech
|
|
|
|
// and any multicoloured fonts for control panels, etc.
|
2003-07-28 01:44:38 +00:00
|
|
|
//
|
2003-09-19 06:42:22 +00:00
|
|
|
// Based on textsprt.c as used for Broken Sword 1, but updated
|
|
|
|
// for new system by JEL on 9oct96 and updated again (for font
|
|
|
|
// as a resource) on 5dec96.
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
#include "common/stdafx.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/system.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
#include "sword2/sword2.h"
|
|
|
|
#include "sword2/defs.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "sword2/header.h"
|
2004-04-14 07:12:10 +00:00
|
|
|
#include "sword2/logic.h"
|
|
|
|
#include "sword2/maketext.h"
|
|
|
|
#include "sword2/resman.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "sword2/screen.h"
|
2004-04-14 07:12:10 +00:00
|
|
|
|
|
|
|
namespace Sword2 {
|
|
|
|
|
2003-09-19 06:42:22 +00:00
|
|
|
#define MAX_LINES 30 // max character lines in output sprite
|
|
|
|
|
|
|
|
#define BORDER_COL 200 // source colour for character border (only
|
|
|
|
// needed for remapping colours)
|
|
|
|
#define LETTER_COL 193 // source colour for bulk of character ( " )
|
|
|
|
#define SPACE ' '
|
|
|
|
#define FIRST_CHAR SPACE // first character in character set
|
|
|
|
#define LAST_CHAR 255 // last character in character set
|
|
|
|
#define DUD 64 // the first "chequered flag" (dud) symbol in
|
|
|
|
// our character set is in the '@' position
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
/**
|
2004-04-23 07:02:11 +00:00
|
|
|
* This function creates a new text sprite. The sprite data contains a
|
|
|
|
* FrameHeader, but not a standard file header.
|
2004-04-14 07:12:10 +00:00
|
|
|
*
|
|
|
|
* @param sentence pointer to a null-terminated string
|
|
|
|
* @param maxWidth the maximum allowed text sprite width in pixels
|
|
|
|
* @param pen the text colour, or zero to use the source colours
|
|
|
|
* @param fontRes the font resource id
|
|
|
|
* @param border the border colour; black by default
|
|
|
|
* @return a handle to a floating memory block containing the text sprite
|
|
|
|
* @note The sentence must contain no leading, trailing or extra spaces.
|
|
|
|
* Out-of-range characters in the string are replaced by a special
|
|
|
|
* error-signal character (chequered flag)
|
|
|
|
*/
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
byte *FontRenderer::makeTextSprite(byte *sentence, uint16 maxWidth, uint8 pen, uint32 fontRes, uint8 border) {
|
2005-12-21 10:57:48 +00:00
|
|
|
debug(5, "makeTextSprite(\"%s\", maxWidth=%u)", sentence, maxWidth);
|
2003-10-11 12:26:53 +00:00
|
|
|
|
|
|
|
_borderPen = border;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Line- and character spacing are hard-wired, rather than being part
|
|
|
|
// of the resource.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-19 18:40:53 +00:00
|
|
|
if (fontRes == _vm->_speechFontId) {
|
2004-04-14 07:12:10 +00:00
|
|
|
_lineSpacing = -6;
|
|
|
|
_charSpacing = -3;
|
2003-09-19 06:42:22 +00:00
|
|
|
} else if (fontRes == CONSOLE_FONT_ID) {
|
2004-04-14 07:12:10 +00:00
|
|
|
_lineSpacing = 0;
|
|
|
|
_charSpacing = 1;
|
2003-09-19 06:42:22 +00:00
|
|
|
} else {
|
2003-10-11 12:26:53 +00:00
|
|
|
_lineSpacing = 0;
|
|
|
|
_charSpacing = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Allocate memory for array of lineInfo structures
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2005-05-12 13:12:15 +00:00
|
|
|
byte *line = (byte *)malloc(MAX_LINES * sizeof(LineInfo));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Get details of sentence breakdown into array of LineInfo structures
|
|
|
|
// and get the number of lines involved
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-05-12 13:12:15 +00:00
|
|
|
uint16 noOfLines = analyseSentence(sentence, maxWidth, fontRes, (LineInfo *)line);
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Construct the sprite based on the info gathered - returns floating
|
2003-09-19 06:42:22 +00:00
|
|
|
// mem block
|
|
|
|
|
2005-05-12 13:12:15 +00:00
|
|
|
byte *textSprite = buildTextSprite(sentence, fontRes, pen, (LineInfo *)line, noOfLines);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
free(line);
|
2003-09-19 06:42:22 +00:00
|
|
|
return textSprite;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
uint16 FontRenderer::analyseSentence(byte *sentence, uint16 maxWidth, uint32 fontRes, LineInfo *line) {
|
2003-09-19 06:42:22 +00:00
|
|
|
// joinWidth = how much extra space is needed to append a word to a
|
2003-10-11 12:26:53 +00:00
|
|
|
// line. NB. SPACE requires TWICE the '_charSpacing' to join a word
|
2003-09-19 06:42:22 +00:00
|
|
|
// to line
|
|
|
|
|
2003-10-11 12:26:53 +00:00
|
|
|
uint16 joinWidth = charWidth(SPACE, fontRes) + 2 * _charSpacing;
|
2004-04-14 07:12:10 +00:00
|
|
|
|
|
|
|
uint16 lineNo = 0;
|
|
|
|
uint16 pos = 0;
|
|
|
|
bool firstWord = true;
|
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
byte ch;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-19 06:42:22 +00:00
|
|
|
do {
|
2004-04-14 07:12:10 +00:00
|
|
|
uint16 wordWidth = 0;
|
|
|
|
uint16 wordLength = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Calculate the width of the word.
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
ch = sentence[pos++];
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
while (ch && ch != SPACE) {
|
2003-10-11 12:26:53 +00:00
|
|
|
wordWidth += charWidth(ch, fontRes) + _charSpacing;
|
2003-07-28 01:44:38 +00:00
|
|
|
wordLength++;
|
2003-09-19 06:42:22 +00:00
|
|
|
ch = sentence[pos++];
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Don't include any character spacing at the end of the word.
|
2003-10-11 12:26:53 +00:00
|
|
|
wordWidth -= _charSpacing;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// 'ch' is now the SPACE or NULL following the word
|
|
|
|
// 'pos' indexes to the position following 'ch'
|
|
|
|
|
2003-09-19 06:42:22 +00:00
|
|
|
if (firstWord) {
|
2004-04-14 07:12:10 +00:00
|
|
|
// This is the first word on the line, so no separating
|
|
|
|
// space is needed.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
line[0].width = wordWidth;
|
|
|
|
line[0].length = wordLength;
|
2003-09-24 06:40:23 +00:00
|
|
|
firstWord = false;
|
2003-09-19 06:42:22 +00:00
|
|
|
} else {
|
2004-04-14 07:12:10 +00:00
|
|
|
// See how much extra space this word will need to
|
2003-09-19 06:42:22 +00:00
|
|
|
// fit on current line (with a separating space
|
|
|
|
// character - also overlapped)
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
uint16 spaceNeeded = joinWidth + wordWidth;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-19 06:42:22 +00:00
|
|
|
if (line[lineNo].width + spaceNeeded <= maxWidth) {
|
2004-04-14 07:12:10 +00:00
|
|
|
// The word fits on this line.
|
2003-07-28 01:44:38 +00:00
|
|
|
line[lineNo].width += spaceNeeded;
|
2004-04-14 07:12:10 +00:00
|
|
|
line[lineNo].length += (1 + wordLength);
|
2003-09-19 06:42:22 +00:00
|
|
|
} else {
|
2004-04-14 07:12:10 +00:00
|
|
|
// The word spills over to the next line, i.e.
|
|
|
|
// no separating space.
|
2003-09-19 06:42:22 +00:00
|
|
|
|
|
|
|
lineNo++;
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
assert(lineNo < MAX_LINES);
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
line[lineNo].width = wordWidth;
|
|
|
|
line[lineNo].length = wordLength;
|
|
|
|
}
|
|
|
|
}
|
2003-09-19 06:42:22 +00:00
|
|
|
} while (ch);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-19 06:42:22 +00:00
|
|
|
return lineNo + 1;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
/**
|
|
|
|
* This function creates a new text sprite in a movable memory block. It must
|
|
|
|
* be locked before use, i.e. lock, draw sprite, unlock/free. The sprite data
|
|
|
|
* contains a FrameHeader, but not a standard file header.
|
|
|
|
*
|
|
|
|
* @param sentence pointer to a null-terminated string
|
|
|
|
* @param fontRes the font resource id
|
|
|
|
* @param pen the text colour, or zero to use the source colours
|
|
|
|
* @param line array of LineInfo structures, created by analyseSentence()
|
|
|
|
* @param noOfLines the number of lines, i.e. the number of elements in 'line'
|
|
|
|
* @return a handle to a floating memory block containing the text sprite
|
|
|
|
* @note The sentence must contain no leading, trailing or extra spaces.
|
|
|
|
* Out-of-range characters in the string are replaced by a special
|
|
|
|
* error-signal character (chequered flag)
|
|
|
|
*/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
byte *FontRenderer::buildTextSprite(byte *sentence, uint32 fontRes, uint8 pen, LineInfo *line, uint16 noOfLines) {
|
2004-04-14 07:12:10 +00:00
|
|
|
uint16 i;
|
|
|
|
|
|
|
|
// Find the width of the widest line in the output text
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
uint16 spriteWidth = 0;
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
for (i = 0; i < noOfLines; i++)
|
|
|
|
if (line[i].width > spriteWidth)
|
|
|
|
spriteWidth = line[i].width;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Find the total height of the text sprite: the total height of the
|
|
|
|
// text lines, plus the total height of the spacing between them.
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
uint16 char_height = charHeight(fontRes);
|
|
|
|
uint16 spriteHeight = char_height * noOfLines + _lineSpacing * (noOfLines - 1);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Allocate memory for the text sprite
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
uint32 sizeOfSprite = spriteWidth * spriteHeight;
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
byte *textSprite = (byte *)malloc(FrameHeader::size() + sizeOfSprite);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// At this stage, textSprite points to an unmovable memory block. Set
|
|
|
|
// up the frame header.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
FrameHeader frame_head;
|
2003-09-19 06:42:22 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
frame_head.compSize = 0;
|
|
|
|
frame_head.width = spriteWidth;
|
|
|
|
frame_head.height = spriteHeight;
|
|
|
|
|
|
|
|
frame_head.write(textSprite);
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
debug(4, "Text sprite size: %ux%u", spriteWidth, spriteHeight);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Clear the entire sprite to make it transparent.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
byte *linePtr = textSprite + FrameHeader::size();
|
2004-04-14 07:12:10 +00:00
|
|
|
memset(linePtr, 0, sizeOfSprite);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
byte *charSet = _vm->_resman->openResource(fontRes);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Build the sprite, one line at a time
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
uint16 pos = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
for (i = 0; i < noOfLines; i++) {
|
|
|
|
// Center each line
|
2004-04-23 07:02:11 +00:00
|
|
|
byte *spritePtr = linePtr + (spriteWidth - line[i].width) / 2;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-19 06:42:22 +00:00
|
|
|
// copy the sprite for each character in this line to the
|
|
|
|
// text sprite and inc the sprite ptr by the character's
|
|
|
|
// width minus the 'overlap'
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
for (uint j = 0; j < line[i].length; j++) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
byte *charPtr = findChar(sentence[pos++], charSet);
|
|
|
|
|
|
|
|
frame_head.read(charPtr);
|
2003-09-19 06:42:22 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
assert(frame_head.height == char_height);
|
2003-10-11 12:26:53 +00:00
|
|
|
copyChar(charPtr, spritePtr, spriteWidth, pen);
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
spritePtr += frame_head.width + _charSpacing;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Skip space at end of last word in this line
|
2003-09-19 06:42:22 +00:00
|
|
|
pos++;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-11 12:26:53 +00:00
|
|
|
linePtr += (char_height + _lineSpacing) * spriteWidth;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-11-16 14:18:29 +00:00
|
|
|
_vm->_resman->closeResource(fontRes);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-19 06:42:22 +00:00
|
|
|
return textSprite;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
/**
|
|
|
|
* @param ch the ASCII code of the character
|
|
|
|
* @param fontRes the font resource id
|
|
|
|
* @return the width of the character
|
|
|
|
*/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
uint16 FontRenderer::charWidth(byte ch, uint32 fontRes) {
|
|
|
|
byte *charSet = _vm->_resman->openResource(fontRes);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
FrameHeader frame_head;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
frame_head.read(findChar(ch, charSet));
|
2003-11-16 14:18:29 +00:00
|
|
|
_vm->_resman->closeResource(fontRes);
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
|
|
|
|
return frame_head.width;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
/**
|
|
|
|
* @param fontRes the font resource id
|
|
|
|
* @return the height of a character sprite
|
|
|
|
* @note All characters in a font are assumed to have the same height, so
|
|
|
|
* there is no need to specify which one to look at.
|
|
|
|
*/
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// Returns the height of a character sprite, given the character's ASCII code
|
|
|
|
// and a pointer to the start of the character set.
|
|
|
|
|
2003-10-11 12:26:53 +00:00
|
|
|
uint16 FontRenderer::charHeight(uint32 fontRes) {
|
2004-04-23 07:02:11 +00:00
|
|
|
byte *charSet = _vm->_resman->openResource(fontRes);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
FrameHeader frame_head;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
frame_head.read(findChar(FIRST_CHAR, charSet));
|
2003-11-16 14:18:29 +00:00
|
|
|
_vm->_resman->closeResource(fontRes);
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
|
|
|
|
return frame_head.height;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
/**
|
|
|
|
* @param ch the ASCII code of the character to find
|
|
|
|
* @param charSet pointer to the start of the character set
|
|
|
|
* @return pointer to the requested character or, if it's out of range, the
|
|
|
|
* 'dud' character (chequered flag)
|
|
|
|
*/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
byte *FontRenderer::findChar(byte ch, byte *charSet) {
|
2003-09-19 06:42:22 +00:00
|
|
|
if (ch < FIRST_CHAR)
|
|
|
|
ch = DUD;
|
2003-11-19 18:40:53 +00:00
|
|
|
return _vm->fetchFrameHeader(charSet, ch - FIRST_CHAR);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
/**
|
|
|
|
* Copies a character sprite to the sprite buffer.
|
|
|
|
* @param charPtr pointer to the character sprite
|
|
|
|
* @param spritePtr pointer to the sprite buffer
|
|
|
|
* @param spriteWidth the width of the character
|
|
|
|
* @param pen If zero, copy the data directly. Otherwise remap the
|
|
|
|
* sprite's colours from BORDER_COL to _borderPen and from
|
|
|
|
* LETTER_COL to pen.
|
|
|
|
*/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
void FontRenderer::copyChar(byte *charPtr, byte *spritePtr, uint16 spriteWidth, uint8 pen) {
|
|
|
|
FrameHeader frame;
|
|
|
|
|
|
|
|
frame.read(charPtr);
|
|
|
|
|
|
|
|
byte *source = charPtr + FrameHeader::size();
|
2004-04-23 07:02:11 +00:00
|
|
|
byte *rowPtr = spritePtr;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
for (uint i = 0; i < frame.height; i++) {
|
2004-04-23 07:02:11 +00:00
|
|
|
byte *dest = rowPtr;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-19 06:42:22 +00:00
|
|
|
if (pen) {
|
2004-04-14 07:12:10 +00:00
|
|
|
// Use the specified colours
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
for (uint j = 0; j < frame.width; j++) {
|
2003-09-19 06:42:22 +00:00
|
|
|
switch (*source++) {
|
2003-09-21 16:11:26 +00:00
|
|
|
case LETTER_COL:
|
|
|
|
*dest = pen;
|
|
|
|
break;
|
|
|
|
case BORDER_COL:
|
2004-04-14 07:12:10 +00:00
|
|
|
// Don't do a border pixel if there's
|
2003-09-21 16:11:26 +00:00
|
|
|
// already a bit of another character
|
|
|
|
// underneath (for overlapping!)
|
|
|
|
if (!*dest)
|
2003-10-11 12:26:53 +00:00
|
|
|
*dest = _borderPen;
|
2003-09-21 16:11:26 +00:00
|
|
|
break;
|
2004-04-14 07:12:10 +00:00
|
|
|
default:
|
|
|
|
// Do nothing if source pixel is zero,
|
2003-09-19 06:42:22 +00:00
|
|
|
// ie. transparent
|
2004-04-14 07:12:10 +00:00
|
|
|
break;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-19 06:42:22 +00:00
|
|
|
dest++;
|
|
|
|
}
|
|
|
|
} else {
|
2004-04-14 07:12:10 +00:00
|
|
|
// Pen is zero, so just copy character sprites
|
|
|
|
// directly into text sprite without remapping colours.
|
|
|
|
// Apparently overlapping is never considered here?
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
memcpy(dest, source, frame.width);
|
|
|
|
source += frame.width;
|
2005-07-30 21:11:48 +00:00
|
|
|
}
|
2003-09-19 06:42:22 +00:00
|
|
|
rowPtr += spriteWidth;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Distance to keep speech text from edges of screen
|
2003-09-19 06:42:22 +00:00
|
|
|
#define TEXT_MARGIN 12
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
/**
|
|
|
|
* Creates a text bloc in the list and returns the bloc number. The list of
|
|
|
|
* blocs is read and blitted at render time. Choose alignment type
|
|
|
|
* RDSPR_DISPLAYALIGN or 0
|
|
|
|
*/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
uint32 FontRenderer::buildNewBloc(byte *ascii, int16 x, int16 y, uint16 width, uint8 pen, uint32 type, uint32 fontRes, uint8 justification) {
|
2004-04-14 07:12:10 +00:00
|
|
|
uint32 i = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
while (i < MAX_text_blocs && _blocList[i].text_mem)
|
|
|
|
i++;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
assert(i < MAX_text_blocs);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Create and position the sprite
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
_blocList[i].text_mem = makeTextSprite(ascii, width, pen, fontRes);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-19 06:42:22 +00:00
|
|
|
// 'NO_JUSTIFICATION' means print sprite with top-left at (x,y)
|
|
|
|
// without margin checking - used for debug text
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-19 06:42:22 +00:00
|
|
|
if (justification != NO_JUSTIFICATION) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
FrameHeader frame_head;
|
|
|
|
|
|
|
|
frame_head.read(_blocList[i].text_mem);
|
2003-09-19 06:42:22 +00:00
|
|
|
|
|
|
|
switch (justification) {
|
2003-09-21 16:11:26 +00:00
|
|
|
case POSITION_AT_CENTRE_OF_BASE:
|
2004-04-14 07:12:10 +00:00
|
|
|
// This one is always used for SPEECH TEXT; possibly
|
|
|
|
// also for pointer text
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
x -= (frame_head.width / 2);
|
|
|
|
y -= frame_head.height;
|
2003-09-21 16:11:26 +00:00
|
|
|
break;
|
|
|
|
case POSITION_AT_CENTRE_OF_TOP:
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
x -= (frame_head.width / 2);
|
2003-09-21 16:11:26 +00:00
|
|
|
break;
|
|
|
|
case POSITION_AT_LEFT_OF_TOP:
|
2004-04-14 07:12:10 +00:00
|
|
|
// The given coords are already correct for this!
|
2003-09-21 16:11:26 +00:00
|
|
|
break;
|
|
|
|
case POSITION_AT_RIGHT_OF_TOP:
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
x -= frame_head.width;
|
2003-09-21 16:11:26 +00:00
|
|
|
break;
|
|
|
|
case POSITION_AT_LEFT_OF_BASE:
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
y -= frame_head.height;
|
2003-09-21 16:11:26 +00:00
|
|
|
break;
|
|
|
|
case POSITION_AT_RIGHT_OF_BASE:
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
x -= frame_head.width;
|
|
|
|
y -= frame_head.height;
|
2003-09-21 16:11:26 +00:00
|
|
|
break;
|
|
|
|
case POSITION_AT_LEFT_OF_CENTRE:
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
y -= (frame_head.height / 2);
|
2003-09-21 16:11:26 +00:00
|
|
|
break;
|
|
|
|
case POSITION_AT_RIGHT_OF_CENTRE:
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
x -= frame_head.width;
|
|
|
|
y -= (frame_head.height) / 2;
|
2003-09-21 16:11:26 +00:00
|
|
|
break;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Ensure text sprite is a few pixels inside the visible screen
|
2003-09-19 06:42:22 +00:00
|
|
|
// remember - it's RDSPR_DISPLAYALIGN
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
uint16 text_left_margin = TEXT_MARGIN;
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
uint16 text_right_margin = 640 - TEXT_MARGIN - frame_head.width;
|
2004-04-14 07:12:10 +00:00
|
|
|
uint16 text_top_margin = TEXT_MARGIN;
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
uint16 text_bottom_margin = 400 - TEXT_MARGIN - frame_head.height;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Move if too far left or too far right
|
2003-09-19 06:42:22 +00:00
|
|
|
|
|
|
|
if (x < text_left_margin)
|
2003-07-28 01:44:38 +00:00
|
|
|
x = text_left_margin;
|
|
|
|
else if (x > text_right_margin)
|
|
|
|
x = text_right_margin;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Move if too high or too low
|
2003-09-19 06:42:22 +00:00
|
|
|
|
|
|
|
if (y < text_top_margin)
|
2003-07-28 01:44:38 +00:00
|
|
|
y = text_top_margin;
|
|
|
|
else if (y > text_bottom_margin)
|
|
|
|
y = text_bottom_margin;
|
|
|
|
}
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// The sprite is always uncompressed
|
|
|
|
_blocList[i].type = type | RDSPR_NOCOMPRESSION;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
_blocList[i].x = x;
|
|
|
|
_blocList[i].y = y;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
return i + 1;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
/**
|
|
|
|
* Called by buildDisplay()
|
|
|
|
*/
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2005-05-02 05:41:01 +00:00
|
|
|
void FontRenderer::printTextBlocs() {
|
2004-04-14 07:12:10 +00:00
|
|
|
for (uint i = 0; i < MAX_text_blocs; i++) {
|
|
|
|
if (_blocList[i].text_mem) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
FrameHeader frame_head;
|
2004-04-14 07:12:10 +00:00
|
|
|
SpriteInfo spriteInfo;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
frame_head.read(_blocList[i].text_mem);
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
spriteInfo.x = _blocList[i].x;
|
|
|
|
spriteInfo.y = _blocList[i].y;
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
spriteInfo.w = frame_head.width;
|
|
|
|
spriteInfo.h = frame_head.height;
|
2003-09-19 06:42:22 +00:00
|
|
|
spriteInfo.scale = 0;
|
|
|
|
spriteInfo.scaledWidth = 0;
|
|
|
|
spriteInfo.scaledHeight = 0;
|
2004-04-14 07:12:10 +00:00
|
|
|
spriteInfo.type = _blocList[i].type;
|
2003-09-19 06:42:22 +00:00
|
|
|
spriteInfo.blend = 0;
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
spriteInfo.data = _blocList[i].text_mem + FrameHeader::size();
|
2003-09-19 06:42:22 +00:00
|
|
|
spriteInfo.colourTable = 0;
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
uint32 rv = _vm->_screen->drawSprite(&spriteInfo);
|
2003-07-28 01:44:38 +00:00
|
|
|
if (rv)
|
2004-04-14 07:12:10 +00:00
|
|
|
error("Driver Error %.8x in printTextBlocs", rv);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-11 12:26:53 +00:00
|
|
|
void FontRenderer::killTextBloc(uint32 bloc_number) {
|
2003-09-19 06:42:22 +00:00
|
|
|
bloc_number--;
|
2004-04-23 07:02:11 +00:00
|
|
|
free(_blocList[bloc_number].text_mem);
|
|
|
|
_blocList[bloc_number].text_mem = NULL;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Resource 3258 contains text from location script for 152 (install, save &
|
2003-09-19 06:42:22 +00:00
|
|
|
// restore text, etc)
|
|
|
|
|
|
|
|
#define TEXT_RES 3258
|
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Local line number of "save" (actor no. 1826)
|
2003-09-19 06:42:22 +00:00
|
|
|
|
|
|
|
#define SAVE_LINE_NO 1
|
|
|
|
|
2005-05-02 05:41:01 +00:00
|
|
|
void Sword2Engine::initialiseFontResourceFlags() {
|
2004-04-23 07:02:11 +00:00
|
|
|
byte *textFile = _resman->openResource(TEXT_RES);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-19 06:42:22 +00:00
|
|
|
// If language is Polish or Finnish it requires alternate fonts.
|
|
|
|
// Otherwise, use regular fonts
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-01-06 12:30:24 +00:00
|
|
|
// "tallenna" Finnish for "save"
|
|
|
|
// "zapisz" Polish for "save"
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
// Get the text line (& skip the 2 chars containing the wavId)
|
2005-05-12 13:12:15 +00:00
|
|
|
char *textLine = (char *)fetchTextLine(textFile, SAVE_LINE_NO) + 2;
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
if (strcmp(textLine, "tallenna") == 0)
|
|
|
|
initialiseFontResourceFlags(FINNISH_TEXT);
|
|
|
|
else if (strcmp(textLine, "zapisz") == 0)
|
|
|
|
initialiseFontResourceFlags(POLISH_TEXT);
|
|
|
|
else
|
|
|
|
initialiseFontResourceFlags(DEFAULT_TEXT);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// Get the game name for the windows application
|
|
|
|
|
2003-10-07 07:07:47 +00:00
|
|
|
// According to the GetNameFunction(), which was never called and has
|
|
|
|
// therefore been removed, the name of the game is:
|
|
|
|
//
|
|
|
|
// ENGLISH: "Broken Sword II"
|
|
|
|
// AMERICAN: "Circle of Blood II"
|
|
|
|
// GERMAN: "Baphomet's Fluch II"
|
|
|
|
// default: "Some game or other, part 86"
|
2004-04-14 07:12:10 +00:00
|
|
|
//
|
|
|
|
// But we get it from the text resource instead.
|
2003-10-07 07:07:47 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (_logic->readVar(DEMO))
|
2005-05-12 13:12:15 +00:00
|
|
|
textLine = (char *)fetchTextLine(textFile, 451) + 2;
|
2004-04-14 07:12:10 +00:00
|
|
|
else
|
2005-05-12 13:12:15 +00:00
|
|
|
textLine = (char *)fetchTextLine(textFile, 54) + 2;
|
2003-07-28 07:00:15 +00:00
|
|
|
|
2004-06-17 06:46:18 +00:00
|
|
|
_system->setWindowCaption(textLine);
|
2003-11-16 14:18:29 +00:00
|
|
|
_resman->closeResource(TEXT_RES);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2004-04-14 07:12:10 +00:00
|
|
|
/**
|
|
|
|
* Called from initialiseFontResourceFlags(), and also from console.cpp
|
|
|
|
*/
|
2003-09-19 06:42:22 +00:00
|
|
|
|
2003-10-11 12:26:53 +00:00
|
|
|
void Sword2Engine::initialiseFontResourceFlags(uint8 language) {
|
2003-09-19 06:42:22 +00:00
|
|
|
switch (language) {
|
2004-04-14 07:12:10 +00:00
|
|
|
case FINNISH_TEXT:
|
2003-10-11 12:26:53 +00:00
|
|
|
_speechFontId = FINNISH_SPEECH_FONT_ID;
|
|
|
|
_controlsFontId = FINNISH_CONTROLS_FONT_ID;
|
|
|
|
_redFontId = FINNISH_RED_FONT_ID;
|
2003-09-21 16:11:26 +00:00
|
|
|
break;
|
2004-04-14 07:12:10 +00:00
|
|
|
case POLISH_TEXT:
|
2003-10-11 12:26:53 +00:00
|
|
|
_speechFontId = POLISH_SPEECH_FONT_ID;
|
|
|
|
_controlsFontId = POLISH_CONTROLS_FONT_ID;
|
|
|
|
_redFontId = POLISH_RED_FONT_ID;
|
2003-09-21 16:11:26 +00:00
|
|
|
break;
|
2004-04-14 07:12:10 +00:00
|
|
|
default:
|
2003-10-11 12:26:53 +00:00
|
|
|
_speechFontId = ENGLISH_SPEECH_FONT_ID;
|
|
|
|
_controlsFontId = ENGLISH_CONTROLS_FONT_ID;
|
|
|
|
_redFontId = ENGLISH_RED_FONT_ID;
|
2003-09-21 16:11:26 +00:00
|
|
|
break;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
2003-10-04 00:52:27 +00:00
|
|
|
|
|
|
|
} // End of namespace Sword2
|