aboutsummaryrefslogtreecommitdiff
path: root/engines/saga
diff options
context:
space:
mode:
authoragent-q2011-05-21 15:54:20 +0100
committeragent-q2011-05-21 15:54:20 +0100
commit3ce4b76b0db10fe878305ed1c8b84c6bb1ad4883 (patch)
treed518a2f676c16e078a993d3e38bbd3bf44a8cb62 /engines/saga
parent6fdec4dfac164fd131c4e36a67a789b4b17878a7 (diff)
downloadscummvm-rg350-3ce4b76b0db10fe878305ed1c8b84c6bb1ad4883.tar.gz
scummvm-rg350-3ce4b76b0db10fe878305ed1c8b84c6bb1ad4883.tar.bz2
scummvm-rg350-3ce4b76b0db10fe878305ed1c8b84c6bb1ad4883.zip
DS/SAGA: Due to what looks like a compiler bug, having one Common::Array template inside another causes the DS build to crash during Common::Array::resize(). The only fix I can find is to make the internal byte array a normal malloc'ed() buffer. This way, the code runs fine. Need to dig into the assembly output for this to find out what's truly going on with the original code.
Diffstat (limited to 'engines/saga')
-rw-r--r--engines/saga/font.cpp36
-rw-r--r--engines/saga/font.h4
2 files changed, 39 insertions, 1 deletions
diff --git a/engines/saga/font.cpp b/engines/saga/font.cpp
index 2434f7aad8..60e7c98e7a 100644
--- a/engines/saga/font.cpp
+++ b/engines/saga/font.cpp
@@ -43,14 +43,32 @@ Font::Font(SagaEngine *vm) : _vm(vm) {
_fonts.resize(_vm->getFontsCount());
for (i = 0; i < _vm->getFontsCount(); i++) {
+#ifdef __DS__
+ _fonts[i].outline.font = NULL;
+ _fonts[i].normal.font = NULL;
+#endif
loadFont(&_fonts[i], _vm->getFontDescription(i)->fontResourceId);
}
+
+
_fontMapping = 0;
}
Font::~Font() {
debug(8, "Font::~Font(): Freeing fonts.");
+
+#ifdef __DS__
+ for (int i = 0; i < _vm->getFontsCount(); i++) {
+ if (_fonts[i].outline.font) {
+ free(_fonts[i].outline.font);
+ }
+
+ if (_fonts[i].normal.font) {
+ free(_fonts[i].normal.font);
+ }
+ }
+#endif
}
@@ -107,9 +125,17 @@ void Font::loadFont(FontData *font, uint32 fontResourceId) {
error("Invalid font resource size");
}
+#ifndef __DS__
font->normal.font.resize(fontResourceData.size() - FONT_DESCSIZE);
memcpy(font->normal.font.getBuffer(), fontResourceData.getBuffer() + FONT_DESCSIZE, fontResourceData.size() - FONT_DESCSIZE);
-
+#else
+ if (font->normal.font) {
+ free(font->normal.font);
+ }
+
+ font->normal.font = (byte *) malloc(fontResourceData.size() - FONT_DESCSIZE);
+ memcpy(font->normal.font, fontResourceData.getBuffer() + FONT_DESCSIZE, fontResourceData.size() - FONT_DESCSIZE);
+#endif
// Create outline font style
createOutline(font);
@@ -153,7 +179,15 @@ void Font::createOutline(FontData *font) {
font->outline.header.rowLength = newRowLength;
// Allocate new font representation storage
+#ifdef __DS__
+ if (font->outline.font) {
+ free(font->outline.font);
+ }
+
+ font->outline.font = (byte *) calloc(newRowLength * font->outline.header.charHeight, 1);
+#else
font->outline.font.resize(newRowLength * font->outline.header.charHeight);
+#endif
// Generate outline font representation
diff --git a/engines/saga/font.h b/engines/saga/font.h
index 6f66545756..57e8278c46 100644
--- a/engines/saga/font.h
+++ b/engines/saga/font.h
@@ -120,7 +120,11 @@ struct FontCharEntry {
struct FontStyle {
FontHeader header;
FontCharEntry fontCharEntry[256];
+#ifndef __DS__
ByteArray font;
+#else
+ byte* font;
+#endif
};
struct FontData {