aboutsummaryrefslogtreecommitdiff
path: root/engines/voyeur/voyeur.cpp
blob: 5c3c42c46fdcb49ffc3ff7bb052758c5f120d27f (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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/* 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 "voyeur/voyeur.h"
#include "voyeur/graphics.h"
#include "common/scummsys.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"

namespace Voyeur {

VoyeurEngine *g_vm;

VoyeurEngine::VoyeurEngine(OSystem *syst, const VoyeurGameDescription *gameDesc) : Engine(syst),
		_gameDescription(gameDesc), _randomSource("Voyeur") {
	DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
	_bVoy = NULL;

	initialiseManagers();
}

VoyeurEngine::~VoyeurEngine() {
	delete _bVoy;
}

Common::String VoyeurEngine::generateSaveName(int slot) {
	return Common::String::format("%s.%03d", _targetName.c_str(), slot);
}

/**
 * Returns true if it is currently okay to restore a game
 */
bool VoyeurEngine::canLoadGameStateCurrently() {
	return true;
}

/**
 * Returns true if it is currently okay to save the game
 */
bool VoyeurEngine::canSaveGameStateCurrently() {
	return true;
}

/**
 * Load the savegame at the specified slot index
 */
Common::Error VoyeurEngine::loadGameState(int slot) {
	return Common::kNoError;
}

/**
 * Save the game to the given slot index, and with the given name
 */
Common::Error VoyeurEngine::saveGameState(int slot, const Common::String &desc) {
	//TODO
	return Common::kNoError;
}

Common::Error VoyeurEngine::run() {
	ESP_Init();
	globalInitBolt();

	_eventsManager.resetMouse();
	doHeadTitle();

	//doHeadTitle();

	return Common::kNoError;
}


int VoyeurEngine::getRandomNumber(int maxNumber) {
	return _randomSource.getRandomNumber(maxNumber);
}

void VoyeurEngine::initialiseManagers() {
	_debugger.setVm(this);
	_eventsManager.setVm(this);
	_filesManager.setVm(this);
	_graphicsManager.setVm(this);
}

void VoyeurEngine::ESP_Init() {
}

void VoyeurEngine::globalInitBolt() {
	initBolt();

	_filesManager.openBoltLib("bvoy.blt", _bVoy);
	_bVoy->getBoltGroup(0x10000);
	_bVoy->getBoltGroup(0x10100);
	_fontPtr = _bVoy->memberAddr(0x101);

	// Setup default flags
	Common::fill((byte *)&_voy, (byte *)&_voy + sizeof(SVoy), 0);
	_voy._eCursorOff[0x74 / 2] = 1;
	_voy._eCursorOff[0x68 / 2] = 0;
	_voy._eventTable[998]._data3 = 63;
	_voy._eventTable[998]._data4 = 63;
	_voy._evidence[19] = 0;
	_voy._evidence[17] = 0;
	_voy._evidence[18] = 9999;
	
	_voy._curICF0 = _graphicsManager._palFlag ? 0xFFFFA5E0 : 0x5F90; 
	_eventsManager.addFadeInt();
}

void VoyeurEngine::initBolt() {
	vInitInterrupts();
	_graphicsManager.sInitGraphics();
	_eventsManager.vInitColor();
	initInput();
}

void VoyeurEngine::vInitInterrupts() {
	_eventsManager._intPtr._palette = &_graphicsManager._VGAColors[0];
}

void VoyeurEngine::initInput() {
}

void VoyeurEngine::doHeadTitle() {
//	char dest[144];

	_eventsManager.startMainClockInt();

	// Show starting screen
	if (_bVoy->getBoltGroup(0x10500))
		showConversionScreen();
	if (shouldQuit())
		return;

	doLock();

	// TODO
}

void VoyeurEngine::showConversionScreen() {
	_graphicsManager._backgroundPage = _bVoy->getBoltEntry(0x5020000)._picResource;
	(*_graphicsManager._vPort)->setupViewPort();
	(*_graphicsManager._vPort)->_flags |= 8;

	_graphicsManager.flipPage();
	_eventsManager.sWaitFlip();

	// Immediate palette load to show the initial screen
	CMapResource *cMap = _bVoy->getCMapResource(0x5030000);
	assert(cMap);
	cMap->_steps = 0;
	cMap->startFade();

	// Wait briefly
	_eventsManager.delay(150);
	if (shouldQuit())
		return;

	// Fade out the screen
	cMap = _bVoy->getCMapResource(0x5040000);
	cMap->_steps = 30;
	cMap->startFade();
	if (shouldQuit())
		return;

	(*_graphicsManager._vPort)->_flags |= 8;
	_graphicsManager.flipPage();
	_eventsManager.sWaitFlip();

	while (!shouldQuit() && (_eventsManager._fadeStatus & 1))
		_eventsManager.delay(1);

	_graphicsManager.screenReset();
	_bVoy->freeBoltGroup(0x10500);
}

bool VoyeurEngine::doLock() {
	int var12 = 0;
	int var14 = 0;
	int di = 1;
	int wrongSize;
	byte *buttonVoc = _filesManager.fload("button.voc");
	byte *wrongVoc = _filesManager.fload("wrong.voc", &wrongSize);
	bool result = false;

	if (_bVoy->getBoltGroup(0x10700)) {

	}

	delete[] buttonVoc;
	delete[] wrongVoc;

	return result;
}

} // End of namespace Voyeur