2009-09-07 23:51:12 +09:30
|
|
|
/* Residual - A 3D game interpreter
|
|
|
|
*
|
|
|
|
* Residual is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the AUTHORS
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "engines/stark/stark.h"
|
2010-01-21 20:29:34 +10:30
|
|
|
#include "engines/stark/xmg.h"
|
2009-09-07 23:51:12 +09:30
|
|
|
|
2010-01-24 23:23:39 +08:00
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "common/events.h"
|
2009-09-07 23:51:12 +09:30
|
|
|
#include "sound/mixer.h"
|
|
|
|
|
|
|
|
namespace Stark {
|
|
|
|
|
2010-01-25 17:42:19 +01:00
|
|
|
StarkEngine::StarkEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _gfx(NULL) {
|
2009-09-07 23:51:12 +09:30
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, 127);
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
|
|
|
|
}
|
|
|
|
|
|
|
|
StarkEngine::~StarkEngine() {
|
|
|
|
_xArchive.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error StarkEngine::run() {
|
2010-01-25 17:42:19 +01:00
|
|
|
_gfx = GfxDriver::create();
|
2010-01-21 20:29:34 +10:30
|
|
|
|
2010-01-21 21:26:06 +10:30
|
|
|
// Get the screen prepared
|
2010-01-25 17:42:19 +01:00
|
|
|
_gfx->setupScreen(640, 480, ConfMan.getBool("fullscreen"));
|
2010-01-21 20:29:34 +10:30
|
|
|
|
2010-01-21 21:26:06 +10:30
|
|
|
// Start running
|
2010-01-24 23:23:39 +08:00
|
|
|
mainLoop();
|
2009-09-07 23:51:12 +09:30
|
|
|
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
2010-01-24 23:23:39 +08:00
|
|
|
void StarkEngine::mainLoop() {
|
2010-01-27 01:28:41 +01:00
|
|
|
while (!shouldQuit()) {
|
2010-01-21 20:29:34 +10:30
|
|
|
// Process events
|
|
|
|
Common::Event e;
|
|
|
|
while (g_system->getEventManager()->pollEvent(e)) {
|
|
|
|
// Handle any buttons, keys and joystick operations
|
|
|
|
if (e.type == Common::EVENT_KEYDOWN) {
|
|
|
|
if (e.kbd.ascii == 'q') {
|
2010-01-27 01:28:41 +01:00
|
|
|
quitGame();
|
2010-01-21 20:29:34 +10:30
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
//handleChars(event.type, event.kbd.keycode, event.kbd.flags, event.kbd.ascii);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_KEYUP) {
|
|
|
|
handleControls(event.type, event.kbd.keycode, event.kbd.flags, event.kbd.ascii);
|
|
|
|
}*/
|
|
|
|
// Check for "Hard" quit"
|
2010-01-27 01:28:41 +01:00
|
|
|
//if (e.type == Common::EVENT_QUIT)
|
|
|
|
// return;
|
2010-01-21 20:29:34 +10:30
|
|
|
/*if (event.type == Common::EVENT_SCREEN_CHANGED)
|
|
|
|
_refreshDrawNeeded = true;*/
|
|
|
|
}
|
|
|
|
|
|
|
|
updateDisplayScene();
|
|
|
|
g_system->delayMillis(50);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-27 01:28:41 +01:00
|
|
|
void renderXMG(GfxDriver *gfx, const Common::String &name, int x, int y) {
|
|
|
|
Common::File f;
|
|
|
|
f.open(name);
|
|
|
|
|
|
|
|
Graphics::Surface *surf;
|
|
|
|
surf = XMGDecoder::decode(&f);
|
|
|
|
|
|
|
|
gfx->drawSurface(surf, Common::Point(x, y));
|
|
|
|
|
|
|
|
surf->free();
|
|
|
|
delete surf;
|
|
|
|
f.close();
|
|
|
|
}
|
|
|
|
|
2010-01-24 23:23:39 +08:00
|
|
|
void StarkEngine::updateDisplayScene() {
|
2010-01-25 17:42:19 +01:00
|
|
|
_gfx->clearScreen();
|
2010-01-21 20:29:34 +10:30
|
|
|
|
|
|
|
// Draw bg
|
2010-01-27 01:28:41 +01:00
|
|
|
renderXMG(_gfx, "house_layercenter.xmg", 0, 0);
|
|
|
|
//renderXMG(_gfx, "vista-scapehaze-more-fog3-final.xmg", 0, 0);
|
2010-01-21 21:26:06 +10:30
|
|
|
|
2010-01-21 20:29:34 +10:30
|
|
|
// Draw other things
|
2010-01-27 01:28:41 +01:00
|
|
|
renderXMG(_gfx, "house_prop01_pillow.xmg", 384, 267);
|
|
|
|
renderXMG(_gfx, "house_prop02_pillow.xmg", 324, 299);
|
|
|
|
renderXMG(_gfx, "house_prop03_pillow.xmg", 141, 312);
|
|
|
|
renderXMG(_gfx, "house_prop4_armrest.xmg", 171, 184);
|
|
|
|
renderXMG(_gfx, "house_prop5_chair.xmg", 170, 164);
|
|
|
|
renderXMG(_gfx, "house_prop6_wall.xmg", 0, 0);
|
|
|
|
renderXMG(_gfx, "house_prop8_pillar.xmg", 534, 0);
|
2010-01-21 20:29:34 +10:30
|
|
|
|
|
|
|
// setup cam
|
|
|
|
|
2010-01-25 17:42:19 +01:00
|
|
|
//_gfx->set3DMode();
|
2010-01-21 20:29:34 +10:30
|
|
|
|
|
|
|
// setup lights
|
|
|
|
|
|
|
|
// draw actors
|
2010-01-21 21:26:06 +10:30
|
|
|
|
2010-01-21 20:29:34 +10:30
|
|
|
// draw overlay
|
|
|
|
|
2010-01-25 17:42:19 +01:00
|
|
|
// Swap buffers
|
|
|
|
_gfx->flipBuffer();
|
2010-01-21 20:29:34 +10:30
|
|
|
}
|
2010-01-24 23:23:39 +08:00
|
|
|
|
|
|
|
} // End of namespace Stark
|