scummvm/engines/fullpipe/fullpipe.cpp

237 lines
5.5 KiB
C++
Raw Normal View History

/* 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 "base/plugins.h"
#include "common/archive.h"
#include "common/config-manager.h"
#include "engines/util.h"
#include "fullpipe/fullpipe.h"
#include "fullpipe/gameloader.h"
#include "fullpipe/messages.h"
#include "fullpipe/behavior.h"
namespace Fullpipe {
2013-06-20 15:26:21 -04:00
FullpipeEngine *g_fullpipe = 0;
FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
// Setup mixer
if (!_mixer->isReady()) {
warning("Sound initialization failed.");
}
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
_rnd = new Common::RandomSource("fullpipe");
2013-06-24 16:22:26 -04:00
_gameProjectVersion = 0;
_pictureScale = 8;
2013-06-24 16:22:26 -04:00
_scrollSpeed = 0;
_currSoundListCount = 0;
_currArchive = 0;
2013-06-24 16:22:26 -04:00
_soundEnabled = true;
_flgSoundList = true;
_inputController = 0;
_inputDisabled = false;
_needQuit = false;
2013-07-28 14:54:25 +03:00
_flgPlayIntro = true;
_musicAllowed = -1;
_aniMan = 0;
_aniMan2 = 0;
_currentScene = 0;
_scene2 = 0;
2013-07-28 14:54:25 +03:00
_movTable = 0;
_globalMessageQueueList = 0;
_messageHandlers = 0;
_updateScreenCallback = 0;
_updateCursorCallback = 0;
_behaviorManager = 0;
_cursorId = 0;
2013-06-20 15:26:21 -04:00
g_fullpipe = this;
}
FullpipeEngine::~FullpipeEngine() {
delete _rnd;
delete _globalMessageQueueList;
}
void FullpipeEngine::initialize() {
_globalMessageQueueList = new GlobalMessageQueueList;
_behaviorManager = new BehaviorManager;
2013-07-27 23:54:06 +03:00
_sceneRect.left = 0;
_sceneRect.top = 0;
_sceneRect.right = 799;
_sceneRect.bottom = 599;
}
Common::Error FullpipeEngine::run() {
const Graphics::PixelFormat format(2, 5, 6, 5, 0, 11, 5, 0, 0);
// Initialize backend
initGraphics(800, 600, true, &format);
_backgroundSurface.create(800, 600, format);
initialize();
_isSaveAllowed = false;
2013-06-01 17:20:40 +03:00
loadGam("fullpipe.gam");
EntranceInfo ent;
2013-07-26 00:14:47 +03:00
if (ConfMan.hasKey("boot_param"))
ent._sceneId = ConfMan.getInt("boot_param");
else
ent._sceneId = 3896;
sceneSwitcher(&ent);
_currentScene->draw();
while (!g_fullpipe->_needQuit) {
updateEvents();
_system->delayMillis(10);
_system->updateScreen();
switch (g_fullpipe->_keyState) {
case Common::KEYCODE_q:
g_fullpipe->_needQuit = true;
break;
case Common::KEYCODE_UP:
_sceneRect.moveTo(_sceneRect.left, _sceneRect.top + 10);
_currentScene->draw();
g_fullpipe->_keyState = Common::KEYCODE_INVALID;
break;
case Common::KEYCODE_DOWN:
_sceneRect.moveTo(_sceneRect.left, _sceneRect.top - 10);
_currentScene->draw();
g_fullpipe->_keyState = Common::KEYCODE_INVALID;
break;
case Common::KEYCODE_LEFT:
_sceneRect.moveTo(_sceneRect.left + 10, _sceneRect.top);
_currentScene->draw();
g_fullpipe->_keyState = Common::KEYCODE_INVALID;
break;
case Common::KEYCODE_RIGHT:
_sceneRect.moveTo(_sceneRect.left - 10, _sceneRect.top);
_currentScene->draw();
g_fullpipe->_keyState = Common::KEYCODE_INVALID;
break;
case Common::KEYCODE_z:
_sceneRect.moveTo(0, 0);
_currentScene->draw();
g_fullpipe->_keyState = Common::KEYCODE_INVALID;
break;
default:
break;
}
}
return Common::kNoError;
}
void FullpipeEngine::updateEvents() {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
_keyState = event.kbd.keycode;
break;
case Common::EVENT_KEYUP:
_keyState = Common::KEYCODE_INVALID;
break;
case Common::EVENT_MOUSEMOVE:
_mouseX = event.mouse.x;
_mouseY = event.mouse.y;
break;
case Common::EVENT_QUIT:
_needQuit = true;
break;
default:
break;
}
}
}
2013-06-19 14:46:25 -04:00
int FullpipeEngine::getObjectEnumState(const char *name, const char *state) {
2013-07-06 22:56:11 +03:00
CGameVar *var = _gameLoader->_gameVar->getSubVarByName("OBJSTATES");
2013-06-19 14:46:25 -04:00
2013-07-06 22:56:11 +03:00
if (!var) {
var = _gameLoader->_gameVar->addSubVarAsInt("OBJSTATES", 0);
}
2013-06-19 14:46:25 -04:00
2013-07-06 22:56:11 +03:00
var = var->getSubVarByName(name);
if (var) {
var = var->getSubVarByName("ENUMSTATES");
if (var)
return var->getSubVarAsInt(state);
}
2013-06-19 14:46:25 -04:00
2013-07-06 22:56:11 +03:00
return 0;
2013-06-19 14:46:25 -04:00
}
void FullpipeEngine::setObjectState(const char *name, int state) {
2013-07-06 22:56:11 +03:00
CGameVar *var = _gameLoader->_gameVar->getSubVarByName("OBJSTATES");
2013-06-19 14:46:25 -04:00
2013-07-06 22:56:11 +03:00
if (!var) {
var = _gameLoader->_gameVar->addSubVarAsInt("OBJSTATES", 0);
}
2013-06-19 14:46:25 -04:00
2013-07-06 22:56:11 +03:00
var->setSubVarAsInt(name, state);
2013-06-19 14:46:25 -04:00
}
2013-07-28 14:54:25 +03:00
void FullpipeEngine::updateMapPiece(int mapId, int update) {
for (int i = 0; i < 200; i++) {
int hiWord = (_mapTable[i] >> 16) & 0xffff;
if (hiWord == mapId) {
_mapTable[i] |= update;
return;
}
if (!hiWord) {
_mapTable[i] = (mapId << 16) | update;
return;
}
}
}
} // End of namespace Fullpipe