aboutsummaryrefslogtreecommitdiff
path: root/engines/cge2/vga13h.cpp
diff options
context:
space:
mode:
authorStrangerke2014-06-12 07:20:55 +0200
committerStrangerke2014-06-12 07:20:55 +0200
commit207f3c8be22b03b8f33e1f92a9010613747a5d03 (patch)
tree99925ee11fe8de2a773b2d32ec3122ef847b962d /engines/cge2/vga13h.cpp
parent45f8bd755cd6d741f6c342272e01ce1af6464ea7 (diff)
downloadscummvm-rg350-207f3c8be22b03b8f33e1f92a9010613747a5d03.tar.gz
scummvm-rg350-207f3c8be22b03b8f33e1f92a9010613747a5d03.tar.bz2
scummvm-rg350-207f3c8be22b03b8f33e1f92a9010613747a5d03.zip
CGE2: Implement FXP code. Still WIP, loadTab to be fixed
Diffstat (limited to 'engines/cge2/vga13h.cpp')
-rw-r--r--engines/cge2/vga13h.cpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp
index 61b367b7a5..e59e82579e 100644
--- a/engines/cge2/vga13h.cpp
+++ b/engines/cge2/vga13h.cpp
@@ -531,9 +531,9 @@ void Sprite::gotoxyz(V2D pos) {
byte trim = 0;
if (_ref / 10 == 14) { // HERO
- int z = V2D::trunc(_pos3D._z);
- ctr = (ctr * V2D::trunc(_vm->_eye->_z) / (V2D::trunc(_vm->_eye->_z) - z));
- rem = (rem * V2D::trunc(_vm->_eye->_z) / (V2D::trunc(_vm->_eye->_z) - z));
+ int z = _pos3D._z.trunc();
+ ctr = (ctr * _vm->_eye->_z.trunc()) / (_vm->_eye->_z.trunc() - z);
+ rem = (rem * _vm->_eye->_z.trunc()) / (_vm->_eye->_z.trunc() - z);
ctr = (ctr * 3) / 4;
rem = (rem * 3) / 4;
}
@@ -561,10 +561,15 @@ void Sprite::gotoxyz(V2D pos) {
_flags._trim = (trim != 0);
if (!_follow) {
- double m = _vm->_eye->_z / (_pos3D._z - _vm->_eye->_z);
- _pos3D._x = V2D::round(_vm->_eye->_x + (_vm->_eye->_x - _pos2D.x) / m);
- if (!_constY)
- _pos3D._y = V2D::round(_vm->_eye->_y + (_vm->_eye->_y - _pos2D.y) / m);
+ // CHECKME: Original was using Pos2d.Eye, which shouldn't make a difference (static var)
+ FXP m = _vm->_eye->_z / (_pos3D._z - _vm->_eye->_z);
+ _pos3D._x = (_vm->_eye->_x + (_vm->_eye->_x - _pos2D.x) / m);
+ _pos3D._x.round();
+
+ if (!_constY) {
+ _pos3D._y = _vm->_eye->_y + (_vm->_eye->_y - _pos2D.y) / m;
+ _pos3D._y.round();
+ }
}
if (_next && _next->_flags._slav)
@@ -685,9 +690,23 @@ void Sprite::sync(Common::Serializer &s) {
s.syncAsUint16LE(flags);
}
- s.syncAsUint16LE(_pos3D._x);
- s.syncAsUint16LE(_pos3D._y);
- s.syncAsByte(_pos3D._z);
+ int pos = 0;
+ if (s.isLoading()) {
+ s.syncAsSint16LE(pos);
+ _pos3D._x = FXP(pos, 0);
+ s.syncAsSint16LE(pos);
+ _pos3D._y = pos;
+ s.syncAsSint16LE(pos);
+ _pos3D._z = pos;
+ } else {
+ pos = _pos3D._x.trunc();
+ s.syncAsUint16LE(pos);
+ pos = _pos3D._y.trunc();
+ s.syncAsUint16LE(pos);
+ pos = _pos3D._z.trunc();
+ s.syncAsByte(pos);
+ }
+
s.syncAsUint16LE(_time);
s.syncAsSint16LE(_seqPtr);
s.syncAsUint16LE(_shpCnt);