aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authoruruk2014-05-10 14:03:27 +0200
committeruruk2014-05-10 14:03:27 +0200
commit3af6ff54570d290e80f4cf77b1beab071a39b026 (patch)
treed8c2002a72f6d2271e0441e04d4bff9b4090fae0 /engines
parent724899fc1939e26b1805deb9f9c9c7fc19c9a5ee (diff)
downloadscummvm-rg350-3af6ff54570d290e80f4cf77b1beab071a39b026.tar.gz
scummvm-rg350-3af6ff54570d290e80f4cf77b1beab071a39b026.tar.bz2
scummvm-rg350-3af6ff54570d290e80f4cf77b1beab071a39b026.zip
CGE2: Implement Sprite::gotoxyz().
Diffstat (limited to 'engines')
-rw-r--r--engines/cge2/cge2.h2
-rw-r--r--engines/cge2/vga13h.cpp65
2 files changed, 62 insertions, 5 deletions
diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h
index e4a40426f7..f3cf574faf 100644
--- a/engines/cge2/cge2.h
+++ b/engines/cge2/cge2.h
@@ -48,6 +48,8 @@ class Dac;
#define kScrWidth 320
#define kScrHeight 240
+#define kPanHeight 40
+#define kWorldHeight (kScrHeight - kPanHeight)
#define kMaxFile 128
#define kPathMax 128
#define kDimMax 8
diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp
index 0a9add0633..22bd4f4a18 100644
--- a/engines/cge2/vga13h.cpp
+++ b/engines/cge2/vga13h.cpp
@@ -414,23 +414,78 @@ void Sprite::killXlat() {
}
void Sprite::gotoxyz(int x, int y, int z) {
- warning("STUB: Sprite::gotoxyz()");
+ gotoxyz(V3D(x, y, z));
}
void Sprite::gotoxyz(void) {
- warning("STUB: Sprite::gotoxyz()");
+ gotoxyz(_pos3D);
}
void Sprite::gotoxyz(V2D pos) {
- warning("STUB: Sprite::gotoxyz()");
+ V2D o = _pos2D;
+ int ctr = _siz.x >> 1;
+ int rem = _siz.x - ctr;
+ 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));
+ ctr = (ctr * 3) / 4;
+ rem = (rem * 3) / 4;
+ }
+
+ if (pos.x - ctr < 0) {
+ pos.x = ctr;
+ ++trim;
+ }
+ if (pos.x + rem > kScrWidth) {
+ pos.x = kScrWidth - rem;
+ ++trim;
+ }
+ _pos2D.x = pos.x;
+
+ if (pos.y < -kPanHeight) {
+ pos.y = -kPanHeight;
+ ++trim;
+ }
+ if (pos.y + _siz.y > kWorldHeight) {
+ pos.y = kWorldHeight - _siz.y;
+ ++trim;
+ }
+ _pos2D.y = pos.y;
+
+ _flags._trim = (trim != 0);
+
+ if (!_follow) {
+ double m = _vm->_eye->_z / (_pos3D._z - _vm->_eye->_z);
+ _pos3D._x = (_vm->_eye->_x + V2D::round(_vm->_eye->_x - _pos2D.x) / m);
+ if (!_constY)
+ _pos3D._y = (_vm->_eye->_y + V2D::round(_vm->_eye->_y - _pos2D.y) / m);
+ }
+
+ if (_next && _next->_flags._slav)
+ _next->gotoxyz(_next->_pos2D - o + _pos2D);
+
+ if (_flags._shad)
+ _prev->gotoxyz(_prev->_pos2D - o + _pos2D);
+
+ if (_ref == 141 && _pos3D._y >= 5)
+ warning("Sprite::gotoxyz - asm nop");
}
void Sprite::gotoxyz_(V2D pos) {
- warning("STUB: Sprite::gotoxyz()");
+ _constY++;
+ gotoxyz(pos);
+ --_constY;
}
void Sprite::gotoxyz(V3D pos) {
- warning("STUB: Sprite::gotoxyz()");
+ _follow++;
+ if (pos._z != _pos3D._z)
+ _flags._zmov = true;
+ gotoxyz(V2D(_vm, _pos3D = pos));
+ --_follow;
}
void Sprite::center() {