aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood/modules/module1500.cpp
blob: 00d64a8c2d0c842dce604d7fe0728939600bf544 (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
126
127
128
129
130
131
132
133
134
/* 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 "neverhood/modules/module1500.h"

namespace Neverhood {

Module1500::Module1500(NeverhoodEngine *vm, Module *parentModule, int which)
	: Module(vm, parentModule) {
	
	if (which < 0)
		createScene(_vm->gameState().sceneNum, -1);
	else
		createScene(3, -1);

}

void Module1500::createScene(int sceneNum, int which) {
	debug(1, "Module1500::createScene(%d, %d)", sceneNum, which);
	_sceneNum = sceneNum;
	switch (_sceneNum) {
	case 0:
		_vm->gameState().sceneNum = 0;
		_childObject = new Scene1501(_vm, this, 0x8420221D, 0xA61024C4, 150, 48);
		break;
	case 1:
		_vm->gameState().sceneNum = 1;
		_childObject = new Scene1501(_vm, this, 0x30050A0A, 0x58B45E58, 110, 48);
		break;
	case 2:
		_vm->gameState().sceneNum = 2;
		sendMessage(_parentModule, 0x0800, 0);
		createSmackerScene(0x001A0005, true, true, true);
		break;
	case 3:
		_vm->gameState().sceneNum = 3;
		_childObject = new Scene1501(_vm, this, 0x0CA04202, 0, 110, 48);
		break;
	}
	SetUpdateHandler(&Module1500::updateScene);
	_childObject->handleUpdate();
}

void Module1500::updateScene() {
	if (!updateChild()) {
		switch (_sceneNum) {
		case 0:
			createScene(1, -1);
			break;
		case 1:
			createScene(2, -1);
			break;
		case 3:
			createScene(0, -1);
			break;
		default:
			leaveModule(0);
			break;
		}
	}
}

// Scene1501

Scene1501::Scene1501(NeverhoodEngine *vm, Module *parentModule, uint32 backgroundFileHash, uint32 soundFileHash, int countdown2, int countdown3)
	: Scene(vm, parentModule), _countdown3(countdown3), _countdown2(countdown2), _countdown1(0), _skip(false) {

	SetUpdateHandler(&Scene1501::update);
	SetMessageHandler(&Scene1501::handleMessage);
	
	setBackground(backgroundFileHash);
	setPalette();
	addEntity(_palette);
	_palette->addBasePalette(backgroundFileHash, 0, 256, 0);
	_palette->startFadeToPalette(12);

	if (soundFileHash != 0)
		playSound(0, soundFileHash);

}

void Scene1501::update() {
	Scene::update();
	if (_countdown1 != 0) {
		_countdown1--;
		if (_countdown1 == 0) {
			_vm->_screen->clear();
			leaveScene(0);
		}
	} else if ((_countdown2 != 0 && (--_countdown2 == 0)) || (_countdown2 == 0 && !isSoundPlaying(0))) {
		_countdown1 = 12;
		_palette->startFadeToBlack(11);
	}

	if (_countdown3 != 0)
		_countdown3--;

	if (_countdown3 == 0 && _skip && _countdown1 == 0) {
		_countdown1 = 12;
		_palette->startFadeToBlack(11);
	}
	
}

uint32 Scene1501::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
	uint32 messageResult = Scene::handleMessage(messageNum, param, sender);
	switch (messageNum) {
	case 0x0009:
		_skip = true;
		break;
	}
	return messageResult;
}

} // End of namespace Neverhood