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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
/* 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/module1500.h"
namespace Neverhood {
Module1500::Module1500(NeverhoodEngine *vm, Module *parentModule, int which, bool flag)
: Module(vm, parentModule), _flag(flag) {
debug("Create Module1500(%d)", which);
if (which < 0) {
switch (_vm->gameState().sceneNum) {
case 1:
createScene1502();
break;
case 2:
createScene1503();
break;
case 3:
createScene1504();
break;
default:
createScene1501();
}
} else {
createScene1504();
}
}
void Module1500::update() {
_childObject->handleUpdate();
if (_done) {
_done = false;
delete _childObject;
_childObject = NULL;
switch (_vm->gameState().sceneNum) {
case 0:
createScene1502();
break;
case 1:
if (_flag) {
createScene1503();
} else {
sendMessage(_parentModule, 0x1009, 0);
}
break;
case 3:
createScene1501();
break;
default:
sendMessage(_parentModule, 0x1009, 0);
break;
}
}
}
void Module1500::createScene1501() {
debug("createScene1501");
_vm->gameState().sceneNum = 0;
_childObject = new Scene1501(_vm, this, 0x8420221D, 0xA61024C4, 150, 48);
SetUpdateHandler(&Module1500::update);
}
void Module1500::createScene1502() {
debug("createScene1502");
_vm->gameState().sceneNum = 1;
_childObject = new Scene1501(_vm, this, 0x30050A0A, 0x58B45E58, 110, 48);
SetUpdateHandler(&Module1500::update);
}
void Module1500::createScene1503() {
sendMessage(_parentModule, 0x0800, 0);
_vm->gameState().sceneNum = 2;
createSmackerScene(0x001A0005, true, true, true);
SetUpdateHandler(&Module1500::update);
}
void Module1500::createScene1504() {
_vm->gameState().sceneNum = 3;
_childObject = new Scene1501(_vm, this, 0x0CA04202, 0, 110, 48);
SetUpdateHandler(&Module1500::update);
}
// Scene1501
Scene1501::Scene1501(NeverhoodEngine *vm, Module *parentModule, uint32 backgroundFileHash, uint32 soundFileHash, int countdown2, int countdown3)
: Scene(vm, parentModule, true), _soundResource(vm),
_countdown3(countdown3), _countdown2(countdown2), _countdown1(0), _flag(false) {
debug("Create Scene1501(%08X, %08X, %d, %d)", backgroundFileHash, soundFileHash, countdown2, countdown3);
Palette2 *palette2;
SetUpdateHandler(&Scene1501::update);
SetMessageHandler(&Scene1501::handleMessage);
_surfaceFlag = true;
_background = addBackground(new DirtyBackground(_vm, backgroundFileHash, 0, 0));
palette2 = new Palette2(_vm);
palette2->usePalette();
_palette = palette2;
addEntity(_palette);
palette2->addPalette(backgroundFileHash, 0, 256, 0);
palette2->startFadeToPalette(12);
/*
if (soundFileHash != 0) {
_soundResource.set(soundFileHash);
_soundResource.load();
_soundResource.play();
}
*/
}
void Scene1501::update() {
Scene::update();
// TODO: Since these countdowns are used a lot, maybe these can be wrapped in a class/struct
// so the code gets a little cleaner.
if (_countdown1 != 0) {
_countdown1--;
if (_countdown1 == 0) {
_vm->_screen->clear();
sendMessage(_parentModule, 0x1009, 0);
}
} else if ((_countdown2 != 0 && (--_countdown2 == 0)) /*|| !_soundResource.isPlaying()*/) {
_countdown1 = 12;
_palette->startFadeToBlack(11);
}
if (_countdown3 != 0)
_countdown3--;
if (_countdown3 == 0 && _flag && _countdown1 == 0) {
_countdown1 = 12;
_palette->startFadeToBlack(11);
}
}
uint32 Scene1501::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
uint32 messageResult = Scene::handleMessage(messageNum, param, sender);
if (messageNum == 0x0009) {
_flag = true;
}
return messageResult;
}
} // End of namespace Neverhood
|