aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2014-06-14 19:34:30 -0400
committerPaul Gilbert2014-06-14 19:34:30 -0400
commitc48c585f88a4c037e3fe5f2363a7aaca1946b343 (patch)
treecb82ff2679d5845fa830bfc4c50a18174d576c00
parent600c32adf91a3fa4d8c54e4b7f85bd8cc06b6746 (diff)
downloadscummvm-rg350-c48c585f88a4c037e3fe5f2363a7aaca1946b343.tar.gz
scummvm-rg350-c48c585f88a4c037e3fe5f2363a7aaca1946b343.tar.bz2
scummvm-rg350-c48c585f88a4c037e3fe5f2363a7aaca1946b343.zip
CGE2: Fix loading of fixed-point integer values
-rw-r--r--engines/cge2/cge2_main.cpp33
-rw-r--r--engines/cge2/fileio.cpp4
-rw-r--r--engines/cge2/fileio.h1
-rw-r--r--engines/cge2/vga13h.cpp1
-rw-r--r--engines/cge2/vga13h.h2
5 files changed, 15 insertions, 26 deletions
diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp
index 9a736efdf0..802b72ed4d 100644
--- a/engines/cge2/cge2_main.cpp
+++ b/engines/cge2/cge2_main.cpp
@@ -711,36 +711,21 @@ void CGE2Engine::loadTab() {
for (int i = 0; i < kCaveMax; i++)
*(_eyeTab[i]) = *_eye;
-if (_resman->exist(kTabName)) {
+ if (_resman->exist(kTabName)) {
EncryptedStream f(this, kTabName);
+ uint32 v;
+
for (int i = 0; i < kCaveMax; i++) {
- int16 varI = f.readSint16BE();
- int16 varF = f.readUint16BE();
- if (varF & 0x8000) {
- varI = -varI;
- varF &= 0x7FFF;
- }
- _eyeTab[i]->_x = FXP(varI, varF);
+ v = f.readUint32LE();
+ _eyeTab[i]->_x = FXP(v >> 8, static_cast<int>((int8)(v & 0xff)));
- varI = f.readSint16BE();
- varF = f.readUint16BE();
- if (varF & 0x8000) {
- varI = -varI;
- varF &= 0x7FFF;
- }
- _eyeTab[i]->_y = FXP(varI, varF);
+ v = f.readUint32LE();
+ _eyeTab[i]->_y = FXP(v >> 8, static_cast<int>((int8)(v & 0xff)));
- varI = f.readSint16BE();
- varF = f.readUint16BE();
- if (varF & 0x8000) {
- varI = -varI;
- varF &= 0x7FFF;
- }
- _eyeTab[i]->_z = FXP(varI, varF);
+ v = f.readUint32LE();
+ _eyeTab[i]->_z = FXP(v >> 8, static_cast<int>((int8)(v & 0xff)));
}
}
-
- warning("STUB: CGE2Engine::loadTab()");
}
void CGE2Engine::cge2_main() {
diff --git a/engines/cge2/fileio.cpp b/engines/cge2/fileio.cpp
index 0ec1bce043..cc07ef6fc1 100644
--- a/engines/cge2/fileio.cpp
+++ b/engines/cge2/fileio.cpp
@@ -232,6 +232,10 @@ signed EncryptedStream::readUint16LE() {
return _readStream->readUint16LE();
}
+uint32 EncryptedStream::readUint32LE() {
+ return _readStream->readUint32LE();
+}
+
bool EncryptedStream::err() {
return (_error & _readStream->err());
}
diff --git a/engines/cge2/fileio.h b/engines/cge2/fileio.h
index 6bf59424ef..093850735a 100644
--- a/engines/cge2/fileio.h
+++ b/engines/cge2/fileio.h
@@ -126,6 +126,7 @@ public:
signed readSint16BE();
signed readSint16LE();
signed readUint16LE();
+ uint32 readUint32LE();
Common::String readLine();
int getLineCount() { return _lineCount; }
diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp
index 302d12938f..5c3b59b084 100644
--- a/engines/cge2/vga13h.cpp
+++ b/engines/cge2/vga13h.cpp
@@ -1065,7 +1065,6 @@ void Bitmap::show(int16 x, int16 y) {
x = pos.x;
y = pos.y;
- // TODO: This doesn't currently support left/right side clipping
const byte *srcP = (const byte *)_v;
byte *screenStartP = (byte *)_vm->_vga->_page[1]->getPixels();
byte *screenEndP = (byte *)_vm->_vga->_page[1]->getBasePtr(0, kScrHeight);
diff --git a/engines/cge2/vga13h.h b/engines/cge2/vga13h.h
index 67506c8739..90889718d5 100644
--- a/engines/cge2/vga13h.h
+++ b/engines/cge2/vga13h.h
@@ -59,7 +59,7 @@ class FXP // fixed point
long& Joined (void) const { return *(long *)&f; }
public:
FXP (void): f(0), i(0) { }
- FXP (int i0, int f0 = 0) : i(i0), f((int) ((((long) f0) << 16)/100)) { }
+ FXP (int i0, int f0 = 0) : i(i0), f(0) { }
FXP& operator = (const int& x) { i = x; f = 0; return *this; }
FXP operator + (const FXP& x) const { FXP y; y.Joined() = Joined()+x.Joined(); return y; }
FXP operator - (const FXP& x) const { FXP y; y.Joined() = Joined()-x.Joined(); return y; }