From 0a210e8f4e55d5c3cf6d92c71c051087357f6e8b Mon Sep 17 00:00:00 2001
From: Eugene Sandulenko <sev@scummvm.org>
Date: Mon, 23 Dec 2013 00:13:13 +0200
Subject: [PATCH] FULLPIPE: Implement sceneHandler08_pushCallback()

---
 engines/fullpipe/scenes/scene08.cpp | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/engines/fullpipe/scenes/scene08.cpp b/engines/fullpipe/scenes/scene08.cpp
index 45c78566482..c7a6589e986 100644
--- a/engines/fullpipe/scenes/scene08.cpp
+++ b/engines/fullpipe/scenes/scene08.cpp
@@ -175,12 +175,34 @@ void sceneHandler08_resumeFlight() {
 	g_vars->scene08_var07 = 0;
 }
 
-void sceneHandler08_calcOffset() {
-	warning("STUB: sceneHandler08_calcOffset()");
+int sceneHandler08_calcOffset(int off, int flag) {
+	if (off > 0) {
+		if (flag)
+			return off * 31 / 10; // off * 3.1
+		else
+			return 5 * off;
+	} else {
+		return 5 * off;
+	}
 }
 
 void sceneHandler08_pushCallback(int *par) {
-	warning("STUB: sceneHandler08_pushCallback()");
+	Common::Point point;
+
+	int y = g_fp->_aniMan->_oy + g_fp->_aniMan->getSomeXY(point)->y;
+
+	if (g_fp->_aniMan->_statics && g_fp->_aniMan->_statics->_staticsId == ST_MAN8_FLYDOWN)
+		y -= 25;
+
+	*par = (y - 703) / 10;
+	if (*par > 11) {
+		*par = 11;
+		g_vars->scene08_var08 = 0;
+	}
+	if (*par >= 0)
+		g_vars->scene08_var08 -= sceneHandler08_calcOffset(*par, g_vars->scene08_var08 < 0);
+	else
+		*par = 0;
 }
 
 int sceneHandler08_updateScreenCallback() {