2003-03-05 19:04:34 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2003 The ScummVM project
|
|
|
|
*
|
|
|
|
* 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
|
2003-03-06 02:37:37 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-03-05 19:04:34 +00:00
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-03-05 21:34:46 +00:00
|
|
|
#include "stdafx.h"
|
2003-03-05 19:04:34 +00:00
|
|
|
#include "sky/sky.h"
|
|
|
|
#include "sky/skydefs.h" //game specific defines
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/gameDetector.h"
|
|
|
|
#include <errno.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
|
|
|
|
extern bool toolbar_drawn;
|
|
|
|
extern bool draw_keyboard;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static const VersionSettings sky_settings[] = {
|
|
|
|
/* Beneath a Steel Sky */
|
|
|
|
{"sky", "Beneath a Steel Sky", GID_SKY_FIRST, 99, 99, 99, 0, "sky.dsk" },
|
|
|
|
{NULL, NULL, 0, 0, 0, 0, 0, NULL}
|
|
|
|
};
|
|
|
|
|
2003-03-07 14:52:24 +00:00
|
|
|
const VersionSettings *Engine_SKY_targetList() {
|
2003-03-05 19:04:34 +00:00
|
|
|
return sky_settings;
|
|
|
|
}
|
|
|
|
|
2003-03-07 14:52:24 +00:00
|
|
|
Engine *Engine_SKY_create(GameDetector *detector, OSystem *syst) {
|
2003-03-05 19:04:34 +00:00
|
|
|
return new SkyState(detector, syst);
|
|
|
|
}
|
|
|
|
|
|
|
|
SkyState::SkyState(GameDetector *detector, OSystem *syst)
|
2003-03-07 14:52:24 +00:00
|
|
|
: Engine(detector, syst) {
|
|
|
|
|
2003-03-05 19:04:34 +00:00
|
|
|
_game = detector->_gameId;
|
|
|
|
|
2003-03-08 12:46:51 +00:00
|
|
|
if (!_mixer->bindToSystem(syst))
|
2003-03-12 16:54:30 +00:00
|
|
|
warning("Sound initialisation failed.");
|
2003-03-08 12:46:51 +00:00
|
|
|
|
|
|
|
_mixer->setVolume(detector->_sfx_volume); //unnecessary?
|
|
|
|
|
2003-03-05 19:04:34 +00:00
|
|
|
_debugMode = detector->_debugMode;
|
|
|
|
_debugLevel = detector->_debugLevel;
|
2003-03-06 02:37:37 +00:00
|
|
|
_language = detector->_language;
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
|
2003-03-07 14:52:24 +00:00
|
|
|
SkyState::~SkyState() {
|
2003-03-05 19:04:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-03-07 15:38:11 +00:00
|
|
|
void SkyState::errorString(const char *buf1, char *buf2) {
|
|
|
|
strcpy(buf2, buf1);
|
|
|
|
}
|
|
|
|
|
2003-03-07 14:52:24 +00:00
|
|
|
void SkyState::pollMouseXY() {
|
|
|
|
|
2003-03-05 19:04:34 +00:00
|
|
|
_mouse_x = _sdl_mouse_x;
|
|
|
|
_mouse_y = _sdl_mouse_y;
|
|
|
|
}
|
|
|
|
|
2003-03-07 14:52:24 +00:00
|
|
|
void SkyState::go() {
|
|
|
|
|
2003-03-05 19:04:34 +00:00
|
|
|
if (!_dump_file)
|
|
|
|
_dump_file = stdout;
|
|
|
|
|
|
|
|
initialise();
|
2003-04-05 18:01:29 +00:00
|
|
|
if (!_isDemo || _isCDVersion)
|
2003-03-09 00:50:02 +00:00
|
|
|
intro();
|
2003-03-08 12:46:51 +00:00
|
|
|
|
2003-03-05 19:04:34 +00:00
|
|
|
while (1) {
|
|
|
|
delay(100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-07 14:52:24 +00:00
|
|
|
void SkyState::initialise(void) {
|
|
|
|
|
2003-03-06 02:37:37 +00:00
|
|
|
//initialise_memory();
|
2003-03-11 18:32:58 +00:00
|
|
|
initTimer();
|
2003-03-06 02:37:37 +00:00
|
|
|
//init_music();
|
2003-03-08 12:46:51 +00:00
|
|
|
|
|
|
|
_sound = new SkySound(_mixer);
|
|
|
|
|
2003-03-07 14:52:24 +00:00
|
|
|
initialiseDisk();
|
2003-04-05 18:01:29 +00:00
|
|
|
setupVersionSpecifics(_gameVersion); //_gameVersion is initialised in initialiseDisk();
|
2003-03-07 14:52:24 +00:00
|
|
|
initialiseScreen();
|
|
|
|
initVirgin();
|
|
|
|
//initMouse();
|
2003-04-05 18:01:29 +00:00
|
|
|
initItemList();
|
|
|
|
//initScript();
|
2003-03-07 14:52:24 +00:00
|
|
|
initialiseGrids();
|
2003-04-05 18:01:29 +00:00
|
|
|
//initialiseRouter();
|
|
|
|
initialiseText();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkyState::initItemList() {
|
|
|
|
|
|
|
|
//See List.asm for (cryptic) item # descriptions
|
|
|
|
|
|
|
|
for (int i = 0; i < 300; i++)
|
|
|
|
_itemList[i] = (void*)NULL;
|
|
|
|
|
|
|
|
//init the non-null items
|
|
|
|
/*
|
|
|
|
_itemList[119] = (void*)data_0; // Compacts - Section 0
|
|
|
|
_itemList[120] = (void*)data_1; // Compacts - Section 1
|
|
|
|
|
|
|
|
if (_isDemo) {
|
|
|
|
_itemList[121] = _itemList[122] = _itemList[123] = _itemList[124] = _itemList[125] = (void*)data_0;
|
|
|
|
} else {
|
|
|
|
_itemList[121] = (void*)data_2; // Compacts - Section 2
|
|
|
|
_itemList[122] = (void*)data_3; // Compacts - Section 3
|
|
|
|
_itemList[123] = (void*)data_4; // Compacts - Section 4
|
|
|
|
_itemList[124] = (void*)data_5; // Compacts - Section 5
|
|
|
|
_itemList[125] = (void*)data_6; // Compacts - Section 6
|
|
|
|
}
|
|
|
|
*/
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
|
2003-03-07 14:52:24 +00:00
|
|
|
void SkyState::delay(uint amount) { //copied and mutilated from Simon.cpp
|
|
|
|
|
2003-03-05 19:04:34 +00:00
|
|
|
OSystem::Event event;
|
|
|
|
|
|
|
|
uint32 start = _system->get_msecs();
|
|
|
|
uint32 cur = start;
|
|
|
|
|
|
|
|
_rnd.getRandomNumber(2);
|
|
|
|
|
|
|
|
do {
|
|
|
|
while (_system->poll_event(&event)) {
|
|
|
|
switch (event.event_code) {
|
|
|
|
case OSystem::EVENT_KEYDOWN:
|
|
|
|
// Make sure backspace works right (this fixes a small issue on OS X)
|
|
|
|
if (event.kbd.keycode == 8)
|
|
|
|
_key_pressed = 8;
|
|
|
|
else
|
|
|
|
_key_pressed = (byte)event.kbd.ascii;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_MOUSEMOVE:
|
|
|
|
_sdl_mouse_x = event.mouse.x;
|
|
|
|
_sdl_mouse_y = event.mouse.y;
|
|
|
|
_mouse_pos_changed = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_LBUTTONDOWN:
|
|
|
|
_left_button_down++;
|
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
_sdl_mouse_x = event.mouse.x;
|
|
|
|
_sdl_mouse_y = event.mouse.y;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_RBUTTONDOWN:
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (amount == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
{
|
|
|
|
uint this_delay = 20; // 1?
|
|
|
|
if (this_delay > amount)
|
|
|
|
this_delay = amount;
|
|
|
|
_system->delay_msecs(this_delay);
|
|
|
|
}
|
|
|
|
cur = _system->get_msecs();
|
|
|
|
} while (cur < start + amount);
|
|
|
|
}
|
|
|
|
|