aboutsummaryrefslogtreecommitdiff
path: root/engines/fullpipe/scenes/scene27.cpp
blob: 9dd8d2a0afd9adb1e02294da3c770e2070c4e202 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#include "fullpipe/fullpipe.h"

#include "fullpipe/objectnames.h"
#include "fullpipe/constants.h"

#include "fullpipe/gameloader.h"
#include "fullpipe/motion.h"
#include "fullpipe/scenes.h"
#include "fullpipe/statics.h"

#include "fullpipe/interaction.h"
#include "fullpipe/behavior.h"


namespace Fullpipe {

void scene27_initScene(Scene *sc) {
	g_vars->scene27_var01 = 200;
	g_vars->scene27_var02 = 200;
	g_vars->scene27_var03 = 300;
	g_vars->scene27_var04 = 300;
	g_vars->scene27_hitZone = sc->getPictureObjectById(PIC_SC27_HITZONE2, 0);
	g_vars->scene27_driver = sc->getStaticANIObject1ById(ANI_VODILLA, -1);
	g_vars->scene27_maid = sc->getStaticANIObject1ById(ANI_MAID, -1);
	g_vars->scene27_batHandler = sc->getStaticANIObject1ById(ANI_BITAHANDLER, -1);

	g_vars->scene27_balls.numBalls = 0;
	g_vars->scene27_balls.pPrev = 0;
	g_vars->scene27_balls.pNext = 0;
	g_vars->scene27_balls.ball = 0;
	CPlex::FreeDataChain(g_vars->scene27_balls.cPlex);
	g_vars->scene27_balls.cPlex = 0;
	scene27_bats.clear();
	scene27_var07.clear();

	g_vars->scene27_var15 = 1;
	g_vars->scene27_bat = sc->getStaticANIObject1ById(ANI_BITA, -1);

	for (int i = 0; i < 4; i++) {
		StaticANIObject *newbat = new StaticANIObject(g_vars->scene27_bat);

		v5 = g_vars->scene27_balls.pPrev;
		v6 = g_vars->scene27_balls.pNext;

		if (!g_vars->scene27_balls.pPrev) {
			v7 = CPlex::Create(&g_vars->scene27_balls.cPlex, g_vars->scene27_balls.cPlexLen, 12) + 4 + 12 * g_vars->scene27_balls.cPlexLen - 12;
			if (g_vars->scene27_balls.cPlexLen - 1 < 0) {
				v5 = g_vars->scene27_balls.pPrev;
			} else {
				v8 = g_vars->scene27_balls.cPlexLen;
				v5 = g_vars->scene27_balls.pPrev;
				do {
					*(_DWORD *)v7 = v5;
					v5 = (Ball *)v7;
					v7 -= 12;
					--v8;
				} while (v8);

				g_vars->scene27_balls.pPrev = v5;
			}
		}

		g_vars->scene27_balls.pPrev = v5->pNext;
		v5->pPrev = v6;
		v5->pNext = 0;
		++g_vars->scene27_balls.numBalls;
		v5->ani = 0;
		v5->ani = newbat;

		if (g_vars->scene27_balls.pNext)
			g_vars->scene27_balls.pNext->pNext = v5;
		else
			g_vars->scene27_balls.ball = v5;
		g_vars->scene27_balls.pNext = v5;

		sc->addStaticANIObject(newbat, 1);
	}

	g_vars->scene27_var08 = 0;
	g_vars->scene27_var09 = 0;
	g_vars->scene27_var10 = 0;
	g_vars->scene27_var11 = 0;
	g_vars->scene27_var12 = 0;
	g_vars->scene27_var13 = 0;
	g_vars->scene27_launchPhase = 0;

	oldsc = g_fp->_currentScene;
	g_fp->_currentScene = sc;

	if (g_fp->getObjectState(sO_Maid) == g_fp->getObjectEnumState(sO_Maid, sO_WithSwab)) {
		StaticANIObject_changeStatics2(g_vars->scene27_maid, ST_MID_SWAB2);
	} else if (g_fp->getObjectState(sO_Maid) == g_fp->getObjectEnumState(sO_Maid, sO_WithBroom)) {
		StaticANIObject_changeStatics2(g_vars->scene27_maid, ST_MID_BROOM);
	} else if (g_fp->getObjectState(sO_Maid) == g_fp->getObjectEnumState(sO_Maid, sO_WithSpade)) {
		StaticANIObject_changeStatics2(g_vars->scene27_maid, ST_MID_SPADE);
	}

	g_fp->_currentScene = oldsc;

	g_fp->setArcadeOverlay(PIC_CSR_ARCADE7);
}

} // End of namespace Fullpipe