From b0f792bc35e68a3cbb5e964dbdcb9761f98e1496 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 22 Feb 2014 23:12:27 +0200 Subject: FULLPIPE: Implement sceneHandler09_ballExplode() --- engines/fullpipe/constants.h | 1 + engines/fullpipe/scenes/scene09.cpp | 71 ++++++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/engines/fullpipe/constants.h b/engines/fullpipe/constants.h index 01bb364796..6adf20228e 100644 --- a/engines/fullpipe/constants.h +++ b/engines/fullpipe/constants.h @@ -604,6 +604,7 @@ namespace Fullpipe { #define MV_MAN9_SHOOT 922 #define MV_VSN_CYCLE2 2987 #define PIC_SC9_LADDER_R 2700 +#define QU_SC9_BALLEXPLODE 938 #define QU_SC9_EATBALL 942 #define QU_TTA9_GOL 4937 #define SND_9_006 3650 diff --git a/engines/fullpipe/scenes/scene09.cpp b/engines/fullpipe/scenes/scene09.cpp index 6743795d46..9bff577885 100644 --- a/engines/fullpipe/scenes/scene09.cpp +++ b/engines/fullpipe/scenes/scene09.cpp @@ -139,6 +139,7 @@ void scene09_initScene(Scene *sc) { g_vars->scene09_var07.reset(); Ball *b9 = g_vars->scene09_var07.sub04(g_vars->scene09_var07.field_8, 0); + b9->ani = sc->getStaticANIObject1ById(ANI_BALL9, -1); b9->ani->setAlpha(0xc8); @@ -305,6 +306,7 @@ void sceneHandler09_eatBall() { g_vars->scene09_flyingBall->hide(); Ball *ball = g_vars->scene09_balls.pHead; + if (ball) { while (ball && ball->ani != g_vars->scene09_flyingBall) ball = ball->p0; @@ -462,7 +464,74 @@ void sceneHandler09_collideBall(Ball *ball) { } void sceneHandler09_ballExplode(Ball *ball) { - warning("STUB: sceneHandler09_ballExplode()"); + if (ball == g_vars->scene09_balls.pHead) + g_vars->scene09_balls.pHead = ball->p0; + else + ball->p1->p0 = ball->p0; + + if (ball == g_vars->scene09_balls.field_8) + g_vars->scene09_balls.field_8 = ball->p1; + else + ball->p0->p1 = ball->p1; + + ball->p0 = g_vars->scene09_balls.pTail; + + g_vars->scene09_balls.pTail = ball; + g_vars->scene09_balls.numBalls--; + + if (!g_vars->scene09_balls.numBalls) { + g_vars->scene09_balls.pTail = 0; + g_vars->scene09_balls.field_8 = 0; + g_vars->scene09_balls.pHead = 0; + free(g_vars->scene09_balls.cPlex); + g_vars->scene09_balls.cPlex = 0; + } + + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC9_BALLEXPLODE), 0, 1); + + mq->replaceKeyCode(-1, ball->ani->_okeyCode); + + if (!mq->chain(ball->ani)) + delete mq; + + Ball *runPtr = g_vars->scene09_var07.pTail; + Ball *lastP = g_vars->scene09_var07.field_8; + + if (!g_vars->scene09_var07.pTail) { + g_vars->scene09_var07.cPlex = (byte *)calloc(g_vars->scene09_var07.cPlexLen, sizeof(Ball)); + + byte *p1 = g_vars->scene09_var07.cPlex + (g_vars->scene09_var07.cPlexLen - 1) * sizeof(Ball); + + if (g_vars->scene09_var07.cPlexLen - 1 < 0) { + runPtr = g_vars->scene09_var07.pTail; + } else { + runPtr = g_vars->scene09_var07.pTail; + + for (int j = 0; j < g_vars->scene09_var07.cPlexLen; j++) { + ((Ball *)p1)->p1 = runPtr; + runPtr = (Ball *)p1; + + p1 -= sizeof(Ball); + } + + g_vars->scene09_var07.pTail = runPtr; + } + } + + g_vars->scene09_var07.pTail = runPtr->p0; + runPtr->p1 = lastP; + runPtr->p0 = 0; + runPtr->ani = ball->ani; + + g_vars->scene09_var07.numBalls++; + + if (g_vars->scene09_var07.field_8) { + g_vars->scene09_var07.field_8->p0 = runPtr; + g_vars->scene09_var07.field_8 = runPtr; + } else { + g_vars->scene09_var07.pHead = runPtr; + g_vars->scene09_var07.field_8 = runPtr; + } } void sceneHandler09_checkHangerCollide() { -- cgit v1.2.3