aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kohaut2016-10-06 22:32:27 +0200
committerPeter Kohaut2016-10-06 22:32:27 +0200
commitc934941e4f1d72723924f6f6fb7b76712784ff82 (patch)
treee299e32bf2711f8a96024d7ed306b7f37111276e
parent566da748e16f90218aab6bd1f7ea19adc57e098a (diff)
downloadscummvm-rg350-c934941e4f1d72723924f6f6fb7b76712784ff82.tar.gz
scummvm-rg350-c934941e4f1d72723924f6f6fb7b76712784ff82.tar.bz2
scummvm-rg350-c934941e4f1d72723924f6f6fb7b76712784ff82.zip
BLADERUNNER: fixed some of endianness issues
-rw-r--r--engines/bladerunner/fog.cpp8
-rw-r--r--engines/bladerunner/font.cpp58
-rw-r--r--engines/bladerunner/font.h6
-rw-r--r--engines/bladerunner/light.cpp14
4 files changed, 51 insertions, 35 deletions
diff --git a/engines/bladerunner/fog.cpp b/engines/bladerunner/fog.cpp
index b51ec1060a..73e802667f 100644
--- a/engines/bladerunner/fog.cpp
+++ b/engines/bladerunner/fog.cpp
@@ -44,8 +44,12 @@ int Fog::readCommon(Common::ReadStream *stream) {
void Fog::readAnimationData(Common::ReadStream *stream, int size) {
_animatedParameters = stream->readUint32LE();
- _animationData = new float[size / sizeof(float)];
- stream->read(_animationData, size);
+
+ int floatsCount = size / 4;
+ _animationData = new float[floatsCount];
+ for (int i = 0; i < floatsCount; i++) {
+ _animationData[i] = stream->readFloatLE();
+ }
_m11ptr = _animationData;
_m12ptr = _m11ptr + (_animatedParameters & 0x1 ? _framesCount : 1);
diff --git a/engines/bladerunner/font.cpp b/engines/bladerunner/font.cpp
index 2f15780719..972f50a784 100644
--- a/engines/bladerunner/font.cpp
+++ b/engines/bladerunner/font.cpp
@@ -61,8 +61,16 @@ bool Font::open(const Common::String &fileName, int screenWidth, int screenHeigh
return false;
}
- stream->read(_characters, _characterCount * sizeof(FontCharacter));
- stream->read(_data, _dataSize * sizeof(uint16));
+ for (int i = 0; i < _characterCount; i++) {
+ _characters[i]._x = stream->readUint32LE();
+ _characters[i]._y = stream->readUint32LE();
+ _characters[i]._width = stream->readUint32LE();
+ _characters[i]._height = stream->readUint32LE();
+ _characters[i]._dataOffset = stream->readUint32LE();
+ }
+ for(int i = 0; i < _dataSize; i++) {
+ _data[i] = stream->readUint16LE();
+ }
return true;
}
@@ -88,28 +96,30 @@ void Font::setColor(uint16 color) {
}
void Font::draw(const Common::String &text, Graphics::Surface &surface, int x, int y) {
- if (_data) {
- if (x < 0) {
- x = 0;
- }
- if (y < 0) {
- y = 0;
- }
+ if (!_data) {
+ return;
+ }
- int textWidth = getTextWidth(text);
- if (textWidth + x >= _screenWidth) {
- x = _screenWidth - (textWidth + 1);
- }
- if (_maxHeight + y >= _screenHeight) {
- y = _screenHeight - _maxHeight;
- }
+ if (x < 0) {
+ x = 0;
+ }
+ if (y < 0) {
+ y = 0;
+ }
- const char *character = text.c_str();
- while (*character != 0) {
- drawCharacter(*character, surface, x, y);
- x += _spacing1 + _characters[*character + 1]._width;
- character++;
- }
+ int textWidth = getTextWidth(text);
+ if (textWidth + x >= _screenWidth) {
+ x = _screenWidth - (textWidth + 1);
+ }
+ if (_maxHeight + y >= _screenHeight) {
+ y = _screenHeight - _maxHeight;
+ }
+
+ const char *character = text.c_str();
+ while (*character != 0) {
+ drawCharacter(*character, surface, x, y);
+ x += _spacing1 + _characters[*character + 1]._width;
+ character++;
}
}
@@ -151,7 +161,7 @@ void Font::reset() {
_color = 0x7FFF;
_intersperse = 0;
- memset(_characters, 0, 5120);
+ memset(_characters, 0, 256 * sizeof(FontCharacter));
}
void Font::replaceColor(uint16 oldColor, uint16 newColor) {
@@ -166,7 +176,7 @@ void Font::replaceColor(uint16 oldColor, uint16 newColor) {
}
void Font::drawCharacter(const char character, Graphics::Surface &surface, int x, int y) {
- if (x < 0 || x >= this->_screenWidth || y < 0 || y >= _screenHeight || !_data || character + 1 >= _characterCount) {
+ if (x < 0 || x >= _screenWidth || y < 0 || y >= _screenHeight || !_data || character + 1 >= _characterCount) {
return;
}
diff --git a/engines/bladerunner/font.h b/engines/bladerunner/font.h
index 329bc48abe..de790b0244 100644
--- a/engines/bladerunner/font.h
+++ b/engines/bladerunner/font.h
@@ -33,17 +33,13 @@ namespace BladeRunner {
class BladeRunnerEngine;
-#include "common/pack-start.h"
-
struct FontCharacter {
int _x;
int _y;
int _width;
int _height;
int _dataOffset;
-} PACKED_STRUCT;
-
-#include "common/pack-end.h"
+};
class Font {
BladeRunnerEngine *_vm;
diff --git a/engines/bladerunner/light.cpp b/engines/bladerunner/light.cpp
index fbbf595493..08eb8ab5be 100644
--- a/engines/bladerunner/light.cpp
+++ b/engines/bladerunner/light.cpp
@@ -43,8 +43,11 @@ void Light::read(Common::ReadStream *stream, int framesCount, int frame, int ani
_animatedParameters = stream->readUint32LE();
- _animationData = new float[size / sizeof(float)];
- stream->read(_animationData, size);
+ int floatsCount = size / 4;
+ _animationData = new float[floatsCount];
+ for (int i = 0; i < floatsCount; i++) {
+ _animationData[i] = stream->readFloatLE();
+ }
_m11ptr = _animationData;
_m12ptr = _m11ptr + (_animatedParameters & 0x1 ? framesCount : 1);
@@ -77,8 +80,11 @@ void Light::readVqa(Common::ReadStream *stream, int framesCount, int frame, int
int size = stream->readUint32LE();
- _animationData = new float[size / sizeof(float)];
- stream->read(_animationData, size);
+ int floatsCount = size / 4;
+ _animationData = new float[floatsCount];
+ for (int i = 0; i < floatsCount; i++) {
+ _animationData[i] = stream->readFloatLE();
+ }
_m11ptr = _animationData;
_m12ptr = _m11ptr + (_animatedParameters & 0x1 ? framesCount : 1);