2008-07-23 09:02:47 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-05-04 11:59:22 +00:00
|
|
|
#include "common/debug-channels.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "common/endian.h"
|
2008-12-01 20:35:36 +00:00
|
|
|
#include "common/error.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "common/events.h"
|
|
|
|
#include "common/keyboard.h"
|
2010-05-04 11:56:52 +00:00
|
|
|
#include "common/fs.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "common/config-manager.h"
|
2009-03-15 20:30:57 +00:00
|
|
|
#include "common/serializer.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2010-11-08 23:07:42 +00:00
|
|
|
#include "backends/audiocd/audiocd.h"
|
|
|
|
|
2010-05-04 11:58:12 +00:00
|
|
|
#include "engines/util.h"
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "tinsel/actors.h"
|
|
|
|
#include "tinsel/background.h"
|
2009-10-20 14:05:35 +00:00
|
|
|
#include "tinsel/bmv.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "tinsel/config.h"
|
|
|
|
#include "tinsel/cursor.h"
|
2008-12-01 20:35:36 +00:00
|
|
|
#include "tinsel/drives.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "tinsel/dw.h"
|
|
|
|
#include "tinsel/events.h"
|
|
|
|
#include "tinsel/faders.h"
|
|
|
|
#include "tinsel/film.h"
|
|
|
|
#include "tinsel/handle.h"
|
|
|
|
#include "tinsel/heapmem.h" // MemoryInit
|
2008-12-01 20:35:36 +00:00
|
|
|
#include "tinsel/dialogs.h"
|
|
|
|
#include "tinsel/mareels.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "tinsel/music.h"
|
|
|
|
#include "tinsel/object.h"
|
|
|
|
#include "tinsel/pid.h"
|
2008-07-25 09:12:03 +00:00
|
|
|
#include "tinsel/polygons.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "tinsel/savescn.h"
|
|
|
|
#include "tinsel/scn.h"
|
|
|
|
#include "tinsel/sound.h"
|
|
|
|
#include "tinsel/strres.h"
|
2008-12-01 20:35:36 +00:00
|
|
|
#include "tinsel/sysvar.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "tinsel/timers.h"
|
|
|
|
#include "tinsel/tinsel.h"
|
|
|
|
|
|
|
|
namespace Tinsel {
|
|
|
|
|
|
|
|
//----------------- EXTERNAL FUNCTIONS ---------------------
|
|
|
|
|
|
|
|
// In BG.CPP
|
|
|
|
extern void SetDoFadeIn(bool tf);
|
2009-11-02 21:54:57 +00:00
|
|
|
extern void DropBackground();
|
2010-11-16 22:09:46 +00:00
|
|
|
extern const BACKGND *pCurBgnd;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// In CURSOR.CPP
|
2008-07-24 08:59:17 +00:00
|
|
|
extern void CursorProcess(CORO_PARAM, const void *);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// In INVENTORY.CPP
|
2008-07-24 08:59:17 +00:00
|
|
|
extern void InventoryProcess(CORO_PARAM, const void *);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// In SCENE.CPP
|
2008-07-24 08:59:17 +00:00
|
|
|
extern void PrimeBackground();
|
2009-11-02 21:54:57 +00:00
|
|
|
extern SCNHANDLE GetSceneHandle();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
//----------------- FORWARD DECLARATIONS ---------------------
|
|
|
|
void SetNewScene(SCNHANDLE scene, int entrance, int transition);
|
|
|
|
|
|
|
|
//----------------- GLOBAL GLOBAL DATA --------------------
|
|
|
|
|
2010-11-16 09:53:55 +00:00
|
|
|
// FIXME: Avoid non-const global vars
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
bool bRestart = false;
|
|
|
|
bool bHasRestarted = false;
|
2009-01-20 00:33:26 +00:00
|
|
|
bool loadingFromGMM = false;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
static bool bCuttingScene = false;
|
|
|
|
|
|
|
|
static bool bChangingForRestore = false;
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
bool bFast; // set to make it go ludicrously fast
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//----------------- LOCAL GLOBAL DATA --------------------
|
|
|
|
|
|
|
|
struct Scene {
|
|
|
|
SCNHANDLE scene; // Memory handle for scene
|
|
|
|
int entry; // Entrance number
|
|
|
|
int trans; // Transition - not yet used
|
|
|
|
};
|
|
|
|
|
|
|
|
static Scene NextScene = { 0, 0, 0 };
|
|
|
|
static Scene HookScene = { 0, 0, 0 };
|
|
|
|
static Scene DelayedScene = { 0, 0, 0 };
|
|
|
|
|
|
|
|
static PROCESS *pMouseProcess = 0;
|
|
|
|
static PROCESS *pKeyboardProcess = 0;
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
static SCNHANDLE hCdChangeScene;
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
//----------------- LOCAL PROCEDURES --------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process to handle keypresses
|
|
|
|
*/
|
2008-07-24 08:59:17 +00:00
|
|
|
void KeyboardProcess(CORO_PARAM, const void *) {
|
2008-07-23 09:02:47 +00:00
|
|
|
// COROUTINE
|
|
|
|
CORO_BEGIN_CONTEXT;
|
|
|
|
CORO_END_CONTEXT(_ctx);
|
|
|
|
|
|
|
|
CORO_BEGIN_CODE(_ctx);
|
|
|
|
while (true) {
|
2009-10-20 19:12:54 +00:00
|
|
|
if (_vm->_keypresses.empty()) {
|
2008-07-23 09:02:47 +00:00
|
|
|
// allow scheduling
|
|
|
|
CORO_SLEEP(1);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the next keyboard event off the stack
|
2009-10-20 19:12:54 +00:00
|
|
|
Common::Event evt = _vm->_keypresses.front();
|
|
|
|
_vm->_keypresses.pop_front();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2009-01-01 15:06:43 +00:00
|
|
|
// Switch for special keys
|
2008-07-23 09:02:47 +00:00
|
|
|
switch (evt.kbd.keycode) {
|
|
|
|
// Drag action
|
|
|
|
case Common::KEYCODE_LALT:
|
|
|
|
case Common::KEYCODE_RALT:
|
|
|
|
if (evt.type == Common::EVENT_KEYDOWN) {
|
2009-11-02 21:56:29 +00:00
|
|
|
if (!_vm->_config->_swapButtons)
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessButEvent(PLR_DRAG2_START);
|
2008-07-23 09:02:47 +00:00
|
|
|
else
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessButEvent(PLR_DRAG1_START);
|
2008-07-23 09:02:47 +00:00
|
|
|
} else {
|
2009-11-02 21:56:29 +00:00
|
|
|
if (!_vm->_config->_swapButtons)
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessButEvent(PLR_DRAG1_END);
|
2008-07-23 09:02:47 +00:00
|
|
|
else
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessButEvent(PLR_DRAG2_END);
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case Common::KEYCODE_LCTRL:
|
|
|
|
case Common::KEYCODE_RCTRL:
|
|
|
|
if (evt.type == Common::EVENT_KEYDOWN) {
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_LOOK);
|
2008-07-23 09:02:47 +00:00
|
|
|
} else {
|
|
|
|
// Control key release
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// At this point only key down events need processing
|
|
|
|
if (evt.type == Common::EVENT_KEYUP)
|
|
|
|
continue;
|
|
|
|
|
2009-01-01 15:06:43 +00:00
|
|
|
if (_vm->_keyHandler != NULL)
|
2008-07-23 09:02:47 +00:00
|
|
|
// Keyboard is hooked, so pass it on to that handler first
|
|
|
|
if (!_vm->_keyHandler(evt.kbd))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (evt.kbd.keycode) {
|
|
|
|
/*** SPACE = WALKTO ***/
|
|
|
|
case Common::KEYCODE_SPACE:
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_WALKTO);
|
2008-07-23 09:02:47 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/*** RETURN = ACTION ***/
|
|
|
|
case Common::KEYCODE_RETURN:
|
|
|
|
case Common::KEYCODE_KP_ENTER:
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_ACTION);
|
2008-07-23 09:02:47 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/*** l = LOOK ***/
|
|
|
|
case Common::KEYCODE_l: // LOOK
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_LOOK);
|
2008-07-23 09:02:47 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case Common::KEYCODE_ESCAPE:
|
2009-04-29 10:37:00 +00:00
|
|
|
ProcessKeyEvent(PLR_ESCAPE);
|
2008-07-23 09:02:47 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
#ifdef SLOW_RINCE_DOWN
|
|
|
|
case '>':
|
|
|
|
AddInterlude(1);
|
|
|
|
continue;
|
|
|
|
case '<':
|
|
|
|
AddInterlude(-1);
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
|
2011-04-08 10:43:41 +00:00
|
|
|
case Common::KEYCODE_1:
|
2008-07-23 09:02:47 +00:00
|
|
|
case Common::KEYCODE_F1:
|
|
|
|
// Options dialog
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_MENU);
|
2008-07-23 09:02:47 +00:00
|
|
|
continue;
|
2011-04-08 10:43:41 +00:00
|
|
|
case Common::KEYCODE_5:
|
2008-07-23 09:02:47 +00:00
|
|
|
case Common::KEYCODE_F5:
|
|
|
|
// Save game
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_SAVE);
|
2008-07-23 09:02:47 +00:00
|
|
|
continue;
|
2011-04-08 10:43:41 +00:00
|
|
|
case Common::KEYCODE_7:
|
2008-07-23 09:02:47 +00:00
|
|
|
case Common::KEYCODE_F7:
|
|
|
|
// Load game
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_LOAD);
|
2008-07-23 09:02:47 +00:00
|
|
|
continue;
|
2008-12-01 20:35:36 +00:00
|
|
|
case Common::KEYCODE_m:
|
|
|
|
// Debug facility - scene hopper
|
2010-02-21 04:04:13 +00:00
|
|
|
if (TinselV2 && (evt.kbd.hasFlags(Common::KBD_ALT)))
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_JUMP);
|
|
|
|
break;
|
2008-07-23 09:02:47 +00:00
|
|
|
case Common::KEYCODE_q:
|
2010-02-21 04:04:13 +00:00
|
|
|
if ((evt.kbd.hasFlags(Common::KBD_CTRL)) || (evt.kbd.hasFlags(Common::KBD_ALT)))
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_QUIT);
|
2008-07-23 09:02:47 +00:00
|
|
|
continue;
|
|
|
|
case Common::KEYCODE_PAGEUP:
|
|
|
|
case Common::KEYCODE_KP9:
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_PGUP);
|
2008-07-23 09:02:47 +00:00
|
|
|
continue;
|
|
|
|
case Common::KEYCODE_PAGEDOWN:
|
|
|
|
case Common::KEYCODE_KP3:
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_PGDN);
|
2008-07-23 09:02:47 +00:00
|
|
|
continue;
|
|
|
|
case Common::KEYCODE_HOME:
|
|
|
|
case Common::KEYCODE_KP7:
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_HOME);
|
2008-07-23 09:02:47 +00:00
|
|
|
continue;
|
|
|
|
case Common::KEYCODE_END:
|
|
|
|
case Common::KEYCODE_KP1:
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_END);
|
2008-07-23 09:02:47 +00:00
|
|
|
continue;
|
|
|
|
default:
|
2008-12-01 20:35:36 +00:00
|
|
|
ProcessKeyEvent(PLR_NOEVENT);
|
2008-07-23 09:02:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CORO_END_CODE;
|
|
|
|
}
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
/**
|
|
|
|
* Handles launching a single click action result if the timeout for a double-click
|
|
|
|
* expires
|
|
|
|
*/
|
2010-04-28 22:23:00 +00:00
|
|
|
static void SingleLeftProcess(CORO_PARAM, const void *param) {
|
2008-12-01 20:35:36 +00:00
|
|
|
CORO_BEGIN_CONTEXT;
|
|
|
|
uint32 endTicks;
|
|
|
|
CORO_END_CONTEXT(_ctx);
|
|
|
|
|
|
|
|
CORO_BEGIN_CODE(_ctx);
|
|
|
|
|
|
|
|
// Work out when to wait until
|
2009-11-02 21:56:29 +00:00
|
|
|
_ctx->endTicks = DwGetCurrentTime() + (uint32)_vm->_config->_dclickSpeed;
|
2008-12-01 20:35:36 +00:00
|
|
|
|
|
|
|
// Timeout a double click (may not work once every 49 days!)
|
|
|
|
do {
|
|
|
|
CORO_SLEEP(1);
|
2009-01-29 05:26:12 +00:00
|
|
|
} while (DwGetCurrentTime() < _ctx->endTicks);
|
2008-12-01 20:35:36 +00:00
|
|
|
|
2010-04-28 22:23:00 +00:00
|
|
|
if (GetProvNotProcessed()) {
|
2010-08-17 11:01:41 +00:00
|
|
|
const Common::Point clickPos = *(const Common::Point *)param;
|
2008-12-01 20:35:36 +00:00
|
|
|
PlayerEvent(PLR_WALKTO, clickPos);
|
2010-04-28 22:23:00 +00:00
|
|
|
}
|
2008-12-01 20:35:36 +00:00
|
|
|
|
|
|
|
CORO_KILL_SELF();
|
|
|
|
CORO_END_CODE;
|
|
|
|
}
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
/**
|
|
|
|
* Process to handle changes in the mouse buttons.
|
|
|
|
*/
|
2008-12-01 20:35:36 +00:00
|
|
|
static void MouseProcess(CORO_PARAM, const void *) {
|
2008-07-23 09:02:47 +00:00
|
|
|
// COROUTINE
|
|
|
|
CORO_BEGIN_CONTEXT;
|
|
|
|
bool lastLWasDouble;
|
|
|
|
bool lastRWasDouble;
|
2008-07-24 08:59:17 +00:00
|
|
|
uint32 lastLeftClick, lastRightClick;
|
2010-04-28 22:23:00 +00:00
|
|
|
Common::Point clickPos;
|
2008-07-23 09:02:47 +00:00
|
|
|
CORO_END_CONTEXT(_ctx);
|
|
|
|
|
|
|
|
CORO_BEGIN_CODE(_ctx);
|
|
|
|
|
|
|
|
_ctx->lastLWasDouble = false;
|
|
|
|
_ctx->lastRWasDouble = false;
|
2008-07-24 08:59:17 +00:00
|
|
|
_ctx->lastLeftClick = _ctx->lastRightClick = DwGetCurrentTime();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
2009-10-20 19:12:54 +00:00
|
|
|
if (_vm->_mouseButtons.empty()) {
|
2008-07-23 09:02:47 +00:00
|
|
|
// allow scheduling
|
|
|
|
CORO_SLEEP(1);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get next mouse button event
|
2009-10-20 19:12:54 +00:00
|
|
|
Common::EventType type = _vm->_mouseButtons.front();
|
|
|
|
_vm->_mouseButtons.pop_front();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
int xp, yp;
|
|
|
|
GetCursorXYNoWait(&xp, &yp, true);
|
|
|
|
const Common::Point mousePos(xp, yp);
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
switch (type) {
|
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
|
|
|
// left button press
|
2009-11-02 21:56:29 +00:00
|
|
|
if (DwGetCurrentTime() - _ctx->lastLeftClick < (uint32)_vm->_config->_dclickSpeed) {
|
2008-12-01 20:35:36 +00:00
|
|
|
// Left button double-click
|
|
|
|
|
|
|
|
if (TinselV2) {
|
|
|
|
// Kill off the button process and fire off the action command
|
|
|
|
g_scheduler->killMatchingProcess(PID_BTN_CLICK, -1);
|
2010-04-28 22:23:00 +00:00
|
|
|
PlayerEvent(PLR_ACTION, _ctx->clickPos);
|
2008-12-01 20:35:36 +00:00
|
|
|
} else {
|
|
|
|
// signal left drag start
|
|
|
|
ProcessButEvent(PLR_DRAG1_START);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
// signal left double click event
|
|
|
|
ProcessButEvent(PLR_DLEFT);
|
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
_ctx->lastLWasDouble = true;
|
|
|
|
} else {
|
2008-12-01 20:35:36 +00:00
|
|
|
// Initial mouse down - either for a single click, or potentially
|
|
|
|
// the start of a double-click action
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
if (TinselV2) {
|
|
|
|
PlayerEvent(PLR_DRAG1_START, mousePos);
|
|
|
|
|
|
|
|
ProvNotProcessed();
|
|
|
|
PlayerEvent(PLR_PROV_WALKTO, mousePos);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// signal left drag start
|
|
|
|
ProcessButEvent(PLR_DRAG1_START);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
// signal left single click event
|
|
|
|
ProcessButEvent(PLR_SLEFT);
|
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
_ctx->lastLWasDouble = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Common::EVENT_LBUTTONUP:
|
|
|
|
// left button release
|
|
|
|
|
|
|
|
// update click timer
|
2008-12-01 20:35:36 +00:00
|
|
|
if (_ctx->lastLWasDouble == false) {
|
2008-07-24 08:59:17 +00:00
|
|
|
_ctx->lastLeftClick = DwGetCurrentTime();
|
2008-12-01 20:35:36 +00:00
|
|
|
|
2009-01-01 15:06:43 +00:00
|
|
|
// If player control is enabled, start a process which, if it times out,
|
2008-12-01 20:35:36 +00:00
|
|
|
// will activate a single button click
|
|
|
|
if (TinselV2 && ControlIsOn()) {
|
2010-04-28 22:23:00 +00:00
|
|
|
_ctx->clickPos = mousePos;
|
|
|
|
g_scheduler->createProcess(PID_BTN_CLICK, SingleLeftProcess, &_ctx->clickPos, sizeof(Common::Point));
|
2008-12-01 20:35:36 +00:00
|
|
|
}
|
|
|
|
} else
|
2009-11-02 21:56:29 +00:00
|
|
|
_ctx->lastLeftClick -= _vm->_config->_dclickSpeed;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
if (TinselV2)
|
|
|
|
// Signal left drag end
|
|
|
|
PlayerEvent(PLR_DRAG1_END, mousePos);
|
|
|
|
else
|
|
|
|
// signal left drag end
|
|
|
|
ProcessButEvent(PLR_DRAG1_END);
|
2008-07-23 09:02:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
|
|
|
// right button press
|
|
|
|
|
2009-11-02 21:56:29 +00:00
|
|
|
if (DwGetCurrentTime() - _ctx->lastRightClick < (uint32)_vm->_config->_dclickSpeed) {
|
2008-12-01 20:35:36 +00:00
|
|
|
// Right button double-click
|
|
|
|
if (TinselV2) {
|
2010-04-28 22:23:00 +00:00
|
|
|
PlayerEvent(PLR_NOEVENT, _ctx->clickPos);
|
2008-12-01 20:35:36 +00:00
|
|
|
} else {
|
|
|
|
// signal right drag start
|
|
|
|
ProcessButEvent(PLR_DRAG2_START);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
// signal right double click event
|
|
|
|
ProcessButEvent(PLR_DRIGHT);
|
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
_ctx->lastRWasDouble = true;
|
|
|
|
} else {
|
2008-12-01 20:35:36 +00:00
|
|
|
if (TinselV2) {
|
|
|
|
PlayerEvent(PLR_DRAG2_START, mousePos);
|
|
|
|
PlayerEvent(PLR_LOOK, mousePos);
|
|
|
|
} else {
|
|
|
|
// signal right drag start
|
|
|
|
ProcessButEvent(PLR_DRAG2_START);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
// signal right single click event
|
|
|
|
ProcessButEvent(PLR_SRIGHT);
|
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
_ctx->lastRWasDouble = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Common::EVENT_RBUTTONUP:
|
|
|
|
// right button release
|
|
|
|
|
|
|
|
// update click timer
|
|
|
|
if (_ctx->lastRWasDouble == false)
|
2008-07-24 08:59:17 +00:00
|
|
|
_ctx->lastRightClick = DwGetCurrentTime();
|
2008-07-23 09:02:47 +00:00
|
|
|
else
|
2009-11-02 21:56:29 +00:00
|
|
|
_ctx->lastRightClick -= _vm->_config->_dclickSpeed;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
if (TinselV2)
|
|
|
|
// Signal left drag end
|
|
|
|
PlayerEvent(PLR_DRAG2_END, mousePos);
|
|
|
|
else
|
|
|
|
// signal right drag end
|
|
|
|
ProcessButEvent(PLR_DRAG2_END);
|
2008-07-23 09:02:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CORO_END_CODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run the master script.
|
|
|
|
* Continues between scenes, or until Interpret() returns.
|
|
|
|
*/
|
2008-07-24 08:59:17 +00:00
|
|
|
static void MasterScriptProcess(CORO_PARAM, const void *) {
|
2008-07-23 09:02:47 +00:00
|
|
|
// COROUTINE
|
|
|
|
CORO_BEGIN_CONTEXT;
|
2008-07-25 09:12:03 +00:00
|
|
|
INT_CONTEXT *pic;
|
2008-07-23 09:02:47 +00:00
|
|
|
CORO_END_CONTEXT(_ctx);
|
|
|
|
|
|
|
|
CORO_BEGIN_CODE(_ctx);
|
|
|
|
_ctx->pic = InitInterpretContext(GS_MASTER, 0, NOEVENT, NOPOLY, 0, NULL);
|
|
|
|
CORO_INVOKE_1(Interpret, _ctx->pic);
|
|
|
|
CORO_END_CODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store the facts pertaining to a scene change.
|
|
|
|
*/
|
|
|
|
void SetNewScene(SCNHANDLE scene, int entrance, int transition) {
|
2008-12-01 20:35:36 +00:00
|
|
|
if (!bCuttingScene && TinselV2)
|
|
|
|
WrapScene();
|
|
|
|
|
2009-01-20 17:30:23 +00:00
|
|
|
// If we're loading from the GMM, load the scene as a delayed one
|
|
|
|
if (loadingFromGMM) {
|
|
|
|
DelayedScene.scene = scene;
|
|
|
|
DelayedScene.entry = entrance;
|
|
|
|
DelayedScene.trans = transition;
|
|
|
|
loadingFromGMM = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
// If CD change will be required, stick in the scene change scene
|
2009-01-20 17:30:23 +00:00
|
|
|
if (CdNumber(scene) != GetCurrentCD()) {
|
2008-12-01 20:35:36 +00:00
|
|
|
// This scene gets delayed
|
|
|
|
DelayedScene.scene = scene;
|
|
|
|
DelayedScene.entry = entrance;
|
|
|
|
DelayedScene.trans = transition;
|
|
|
|
|
|
|
|
NextScene.scene = hCdChangeScene;
|
|
|
|
NextScene.entry = CdNumber(scene) - '0';
|
|
|
|
NextScene.trans = TRANS_FADE;
|
2009-01-20 00:33:26 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HookScene.scene == 0 || bCuttingScene) {
|
2008-07-23 09:02:47 +00:00
|
|
|
// This scene comes next
|
|
|
|
NextScene.scene = scene;
|
|
|
|
NextScene.entry = entrance;
|
|
|
|
NextScene.trans = transition;
|
|
|
|
} else {
|
|
|
|
// This scene gets delayed
|
|
|
|
DelayedScene.scene = scene;
|
|
|
|
DelayedScene.entry = entrance;
|
|
|
|
DelayedScene.trans = transition;
|
|
|
|
|
|
|
|
// The hooked scene comes next
|
|
|
|
NextScene.scene = HookScene.scene;
|
|
|
|
NextScene.entry = HookScene.entry;
|
|
|
|
NextScene.trans = HookScene.trans;
|
|
|
|
|
|
|
|
HookScene.scene = 0;
|
|
|
|
}
|
2009-05-31 14:41:54 +00:00
|
|
|
|
|
|
|
// Workaround for "Missing Red Dragon in square" bug in Discworld 1 PSX, act IV.
|
2010-01-25 01:39:44 +00:00
|
|
|
// This happens with the original interpreter on PSX too: the red dragon in Act IV
|
2009-05-31 14:41:54 +00:00
|
|
|
// doesn't show up inside the square at the right time. Original game required the
|
|
|
|
// player to go in and out the square until the dragon appears (wasting hours).
|
|
|
|
// I'm forcing the load of the right scene by checking that the player has (or has not) the
|
|
|
|
// right items: player must have Mambo the swamp dragon, and mustn't have fireworks (used on
|
|
|
|
// the swamp dragon previously to "load it up").
|
|
|
|
if (TinselV1PSX && NextScene.scene == 0x1800000 && NextScene.entry == 2) {
|
2010-01-25 01:39:44 +00:00
|
|
|
if ((IsInInventory(261, INV_1) || IsInInventory(261, INV_2)) &&
|
2009-05-31 14:41:54 +00:00
|
|
|
(!IsInInventory(232, INV_1) && !IsInInventory(232, INV_2)))
|
|
|
|
NextScene.entry = 1;
|
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
/**
|
|
|
|
* Store a scene as hooked
|
|
|
|
*/
|
2008-07-23 09:02:47 +00:00
|
|
|
void SetHookScene(SCNHANDLE scene, int entrance, int transition) {
|
|
|
|
assert(HookScene.scene == 0); // scene already hooked
|
|
|
|
|
|
|
|
HookScene.scene = scene;
|
|
|
|
HookScene.entry = entrance;
|
|
|
|
HookScene.trans = transition;
|
|
|
|
}
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
/**
|
|
|
|
* Hooked scene is over, trigger a change to the delayed scene
|
|
|
|
*/
|
2009-11-02 21:54:57 +00:00
|
|
|
void UnHookScene() {
|
2008-07-23 09:02:47 +00:00
|
|
|
assert(DelayedScene.scene != 0); // no scene delayed
|
|
|
|
|
|
|
|
// The delayed scene can go now
|
|
|
|
NextScene.scene = DelayedScene.scene;
|
|
|
|
NextScene.entry = DelayedScene.entry;
|
|
|
|
NextScene.trans = DelayedScene.trans;
|
|
|
|
|
|
|
|
DelayedScene.scene = 0;
|
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void SuspendHook() {
|
2008-12-01 20:35:36 +00:00
|
|
|
bCuttingScene = true;
|
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void CdHasChanged() {
|
2008-12-01 20:35:36 +00:00
|
|
|
if (bChangingForRestore) {
|
|
|
|
bChangingForRestore = false;
|
|
|
|
RestoreGame(-2);
|
|
|
|
} else {
|
|
|
|
assert(DelayedScene.scene != 0);
|
|
|
|
|
|
|
|
WrapScene();
|
|
|
|
|
|
|
|
// The delayed scene can go now
|
|
|
|
NextScene.scene = DelayedScene.scene;
|
|
|
|
NextScene.entry = DelayedScene.entry;
|
|
|
|
NextScene.trans = DelayedScene.trans;
|
|
|
|
|
|
|
|
DelayedScene.scene = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetCdChangeScene(SCNHANDLE hScene) {
|
|
|
|
hCdChangeScene = hScene;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDChangeForRestore(int cdNumber) {
|
|
|
|
NextScene.scene = hCdChangeScene;
|
|
|
|
NextScene.entry = cdNumber;
|
|
|
|
NextScene.trans = TRANS_FADE;
|
|
|
|
bChangingForRestore = true;
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void UnSuspendHook() {
|
2008-12-01 20:35:36 +00:00
|
|
|
bCuttingScene = false;
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
2009-03-15 20:30:57 +00:00
|
|
|
void syncSCdata(Common::Serializer &s) {
|
2008-07-23 09:02:47 +00:00
|
|
|
s.syncAsUint32LE(HookScene.scene);
|
|
|
|
s.syncAsSint32LE(HookScene.entry);
|
|
|
|
s.syncAsSint32LE(HookScene.trans);
|
|
|
|
|
|
|
|
s.syncAsUint32LE(DelayedScene.scene);
|
|
|
|
s.syncAsSint32LE(DelayedScene.entry);
|
|
|
|
s.syncAsSint32LE(DelayedScene.trans);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
|
2008-07-24 08:59:17 +00:00
|
|
|
static void RestoredProcess(CORO_PARAM, const void *param) {
|
2008-07-23 09:02:47 +00:00
|
|
|
// COROUTINE
|
|
|
|
CORO_BEGIN_CONTEXT;
|
2008-07-25 09:12:03 +00:00
|
|
|
INT_CONTEXT *pic;
|
2008-12-01 20:35:36 +00:00
|
|
|
bool bConverse;
|
2008-07-23 09:02:47 +00:00
|
|
|
CORO_END_CONTEXT(_ctx);
|
|
|
|
|
|
|
|
CORO_BEGIN_CODE(_ctx);
|
|
|
|
|
|
|
|
// get the stuff copied to process when it was created
|
2008-12-01 20:35:36 +00:00
|
|
|
_ctx->pic = *((INT_CONTEXT * const *)param);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
_ctx->pic = RestoreInterpretContext(_ctx->pic);
|
2008-12-01 20:35:36 +00:00
|
|
|
_ctx->bConverse = TinselV2 && (_ctx->pic->event == CONVERSE);
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
CORO_INVOKE_1(Interpret, _ctx->pic);
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
// Restore control after CallScene() from a conversation icon
|
|
|
|
if (_ctx->bConverse)
|
|
|
|
ControlOn();
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
CORO_END_CODE;
|
|
|
|
}
|
|
|
|
|
2008-07-25 09:12:03 +00:00
|
|
|
void RestoreProcess(INT_CONTEXT *pic) {
|
2008-07-24 08:59:17 +00:00
|
|
|
g_scheduler->createProcess(PID_TCODE, RestoredProcess, &pic, sizeof(pic));
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
2008-07-25 09:12:03 +00:00
|
|
|
void RestoreMasterProcess(INT_CONTEXT *pic) {
|
2008-07-24 08:59:17 +00:00
|
|
|
g_scheduler->createProcess(PID_MASTER_SCR, RestoredProcess, &pic, sizeof(pic));
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: CountOut is used by ChangeScene
|
2010-11-16 09:53:55 +00:00
|
|
|
// FIXME: Avoid non-const global vars
|
2008-07-23 09:02:47 +00:00
|
|
|
static int CountOut = 1; // == 1 for immediate start of first scene
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If a scene restore is going on, just return (we don't update the
|
|
|
|
* screen during this time).
|
|
|
|
* If a scene change is required, 'order' the data for the new scene and
|
|
|
|
* start a fade out and a countdown.
|
|
|
|
* When the count expires, the screen will have faded. Ensure the scene |
|
|
|
|
* is loaded, clear the screen, and start the new scene.
|
|
|
|
*/
|
2008-12-01 20:35:36 +00:00
|
|
|
bool ChangeScene(bool bReset) {
|
|
|
|
|
|
|
|
// Prevent attempt to fade-out when restarting game
|
|
|
|
if (bReset) {
|
|
|
|
CountOut = 1; // immediate start of first scene again
|
|
|
|
DelayedScene.scene = HookScene.scene = 0;
|
|
|
|
return false;
|
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
if (IsRestoringScene())
|
2008-12-01 20:35:36 +00:00
|
|
|
return true;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
if (NextScene.scene != 0) {
|
|
|
|
if (!CountOut) {
|
|
|
|
switch (NextScene.trans) {
|
|
|
|
case TRANS_CUT:
|
|
|
|
CountOut = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TRANS_FADE:
|
|
|
|
default:
|
|
|
|
// Trigger pre-load and fade and start countdown
|
|
|
|
CountOut = COUNTOUT_COUNT;
|
|
|
|
FadeOutFast(NULL);
|
2008-12-01 20:35:36 +00:00
|
|
|
if (TinselV2)
|
|
|
|
_vm->_pcmMusic->startFadeOut(COUNTOUT_COUNT);
|
2008-07-23 09:02:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (--CountOut == 0) {
|
2008-12-01 20:35:36 +00:00
|
|
|
if (!TinselV2)
|
|
|
|
ClearScreen();
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
StartNewScene(NextScene.scene, NextScene.entry);
|
2008-07-23 09:02:47 +00:00
|
|
|
NextScene.scene = 0;
|
|
|
|
|
|
|
|
switch (NextScene.trans) {
|
|
|
|
case TRANS_CUT:
|
|
|
|
SetDoFadeIn(false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TRANS_FADE:
|
|
|
|
default:
|
|
|
|
SetDoFadeIn(true);
|
|
|
|
break;
|
|
|
|
}
|
2008-12-01 20:35:36 +00:00
|
|
|
} else
|
|
|
|
_vm->_pcmMusic->fadeOutIteration();
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
2008-12-01 20:35:36 +00:00
|
|
|
|
|
|
|
return false;
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-12-01 20:35:36 +00:00
|
|
|
* CuttingScene
|
2008-07-23 09:02:47 +00:00
|
|
|
*/
|
2008-12-01 20:35:36 +00:00
|
|
|
void CuttingScene(bool bCutting) {
|
|
|
|
bCuttingScene = bCutting;
|
|
|
|
|
|
|
|
if (!bCutting)
|
|
|
|
WrapScene();
|
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
/**
|
|
|
|
* LoadBasicChunks
|
|
|
|
*/
|
2009-11-02 21:54:57 +00:00
|
|
|
void LoadBasicChunks() {
|
2008-07-23 09:02:47 +00:00
|
|
|
byte *cptr;
|
|
|
|
int numObjects;
|
|
|
|
|
|
|
|
// Allocate RAM for savescene data
|
2011-05-25 15:17:11 +00:00
|
|
|
InitializeSaveScenes();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// CHUNK_TOTAL_ACTORS seems to be missing in the released version, hard coding a value
|
|
|
|
// TODO: Would be nice to just change 511 to MAX_SAVED_ALIVES
|
|
|
|
cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_TOTAL_ACTORS);
|
2010-11-20 03:14:03 +00:00
|
|
|
RegisterActors((cptr != NULL) ? READ_32(cptr) : 511);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// CHUNK_TOTAL_GLOBALS seems to be missing in some versions.
|
|
|
|
// So if it is missing, set a reasonably high value for the number of globals.
|
|
|
|
cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_TOTAL_GLOBALS);
|
2010-11-20 03:14:03 +00:00
|
|
|
RegisterGlobals((cptr != NULL) ? READ_32(cptr) : 512);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
cptr = FindChunk(INV_OBJ_SCNHANDLE, CHUNK_TOTAL_OBJECTS);
|
2010-11-20 03:14:03 +00:00
|
|
|
numObjects = (cptr != NULL) ? READ_32(cptr) : 0;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
cptr = FindChunk(INV_OBJ_SCNHANDLE, CHUNK_OBJECTS);
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
#ifdef SCUMM_BIG_ENDIAN
|
|
|
|
//convert to native endianness
|
|
|
|
INV_OBJECT *io = (INV_OBJECT *)cptr;
|
|
|
|
for (int i = 0; i < numObjects; i++, io++) {
|
|
|
|
io->id = FROM_LE_32(io->id);
|
2008-12-02 17:53:58 +00:00
|
|
|
io->hIconFilm = FROM_LE_32(io->hIconFilm);
|
2008-07-23 09:02:47 +00:00
|
|
|
io->hScript = FROM_LE_32(io->hScript);
|
|
|
|
io->attribute = FROM_LE_32(io->attribute);
|
|
|
|
}
|
|
|
|
#endif
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
RegisterIcons(cptr, numObjects);
|
|
|
|
|
|
|
|
cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_TOTAL_POLY);
|
|
|
|
if (cptr != NULL)
|
|
|
|
MaxPolygons(*cptr);
|
2008-12-01 20:35:36 +00:00
|
|
|
|
|
|
|
if (TinselV2) {
|
|
|
|
// Global processes
|
|
|
|
cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_NUM_PROCESSES);
|
|
|
|
assert(cptr && (*cptr < 100));
|
|
|
|
int num = *cptr;
|
|
|
|
cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_PROCESSES);
|
|
|
|
assert(!num || cptr);
|
|
|
|
GlobalProcesses(num, cptr);
|
|
|
|
|
|
|
|
// CdPlay() stuff
|
|
|
|
cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_CDPLAY_HANDLE);
|
|
|
|
assert(cptr);
|
2010-11-20 03:14:03 +00:00
|
|
|
uint32 playHandle = READ_32(cptr);
|
2008-12-01 20:35:36 +00:00
|
|
|
assert(playHandle < 512);
|
|
|
|
SetCdPlayHandle(playHandle);
|
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------- TinselEngine --------------------
|
|
|
|
|
|
|
|
// Global pointer to engine
|
|
|
|
TinselEngine *_vm;
|
|
|
|
|
|
|
|
struct GameSettings {
|
|
|
|
const char *gameid;
|
|
|
|
const char *description;
|
|
|
|
byte id;
|
|
|
|
uint32 features;
|
|
|
|
const char *detectname;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const GameSettings tinselSettings[] = {
|
|
|
|
{"tinsel", "Tinsel game", 0, 0, 0},
|
|
|
|
|
|
|
|
{NULL, NULL, 0, 0, NULL}
|
|
|
|
};
|
|
|
|
|
2008-12-03 18:54:22 +00:00
|
|
|
// For the languages, refer to the LANGUAGE enum in dw.h
|
|
|
|
|
2011-09-08 18:15:07 +00:00
|
|
|
const char *const TinselEngine::_sampleIndices[][3] = {
|
2008-12-03 18:54:22 +00:00
|
|
|
{ "english.idx", "english1.idx", "english2.idx" }, // English
|
|
|
|
{ "french.idx", "french1.idx", "french2.idx" }, // French
|
|
|
|
{ "german.idx", "german1.idx", "german2.idx" }, // German
|
|
|
|
{ "english.idx", "english1.idx", "english2.idx" }, // Italian
|
|
|
|
{ "english.idx", "english1.idx", "english2.idx" }, // Spanish
|
|
|
|
{ "english.idx", "english1.idx", "english2.idx" }, // Hebrew (FIXME: not sure if this is correct)
|
|
|
|
{ "english.idx", "english1.idx", "english2.idx" }, // Hungarian (FIXME: not sure if this is correct)
|
|
|
|
{ "english.idx", "english1.idx", "english2.idx" }, // Japanese (FIXME: not sure if this is correct)
|
|
|
|
{ "us.idx", "us1.idx", "us2.idx" } // US English
|
2008-12-01 20:35:36 +00:00
|
|
|
};
|
2011-09-08 18:15:07 +00:00
|
|
|
const char *const TinselEngine::_sampleFiles[][3] = {
|
2008-12-03 18:54:22 +00:00
|
|
|
{ "english.smp", "english1.smp", "english2.smp" }, // English
|
|
|
|
{ "french.smp", "french1.smp", "french2.smp" }, // French
|
|
|
|
{ "german.smp", "german1.smp", "german2.smp" }, // German
|
|
|
|
{ "english.smp", "english1.smp", "english2.smp" }, // Italian
|
|
|
|
{ "english.smp", "english1.smp", "english2.smp" }, // Spanish
|
|
|
|
{ "english.smp", "english1.smp", "english2.smp" }, // Hebrew (FIXME: not sure if this is correct)
|
|
|
|
{ "english.smp", "english1.smp", "english2.smp" }, // Hungarian (FIXME: not sure if this is correct)
|
|
|
|
{ "english.smp", "english1.smp", "english2.smp" }, // Japanese (FIXME: not sure if this is correct)
|
|
|
|
{ "us.smp", "us1.smp", "us2.smp" }, // US English
|
2008-12-01 20:35:36 +00:00
|
|
|
};
|
2011-09-08 18:15:07 +00:00
|
|
|
const char *const TinselEngine::_textFiles[][3] = {
|
2008-12-03 18:54:22 +00:00
|
|
|
{ "english.txt", "english1.txt", "english2.txt" }, // English
|
|
|
|
{ "french.txt", "french1.txt", "french2.txt" }, // French
|
|
|
|
{ "german.txt", "german1.txt", "german2.txt" }, // German
|
|
|
|
{ "italian.txt", "italian1.txt", "italian2.txt" }, // Italian
|
|
|
|
{ "spanish.txt", "spanish1.txt", "spanish2.txt" }, // Spanish
|
|
|
|
{ "english.txt", "english1.txt", "english2.txt" }, // Hebrew (FIXME: not sure if this is correct)
|
|
|
|
{ "english.txt", "english1.txt", "english2.txt" }, // Hungarian (FIXME: not sure if this is correct)
|
|
|
|
{ "english.txt", "english1.txt", "english2.txt" }, // Japanese (FIXME: not sure if this is correct)
|
|
|
|
{ "us.txt", "us1.txt", "us2.txt" } // US English
|
2008-12-01 20:35:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-01-01 15:06:43 +00:00
|
|
|
TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) :
|
2011-05-16 14:35:10 +00:00
|
|
|
Engine(syst), _gameDescription(gameDesc), _random("tinsel") {
|
2008-07-23 09:02:47 +00:00
|
|
|
_vm = this;
|
|
|
|
|
2009-11-02 21:56:29 +00:00
|
|
|
_config = new Config(this);
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
// Register debug flags
|
2010-04-27 21:40:52 +00:00
|
|
|
DebugMan.addDebugChannel(kTinselDebugAnimations, "animations", "Animations debugging");
|
|
|
|
DebugMan.addDebugChannel(kTinselDebugActions, "actions", "Actions debugging");
|
|
|
|
DebugMan.addDebugChannel(kTinselDebugSound, "sound", "Sound debugging");
|
|
|
|
DebugMan.addDebugChannel(kTinselDebugMusic, "music", "Music debugging");
|
2008-12-01 20:35:36 +00:00
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
// Setup mixer
|
2010-08-25 07:41:35 +00:00
|
|
|
syncSoundSettings();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2009-04-25 06:42:01 +00:00
|
|
|
// Add DW2 subfolder to search path in case user is running directly from the CDs
|
2010-05-04 11:56:52 +00:00
|
|
|
const Common::FSNode gameDataDir(ConfMan.get("path"));
|
|
|
|
SearchMan.addSubDirectoryMatching(gameDataDir, "dw2");
|
2009-04-25 06:42:01 +00:00
|
|
|
|
2010-01-25 01:39:44 +00:00
|
|
|
// Add subfolders needed for psx versions of Discworld 1
|
2009-06-16 19:26:44 +00:00
|
|
|
if (TinselV1PSX)
|
2010-05-04 11:56:52 +00:00
|
|
|
SearchMan.addDirectory(gameDataDir.getPath(), gameDataDir, 0, 3, true);
|
2009-05-26 08:41:25 +00:00
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
const GameSettings *g;
|
|
|
|
|
|
|
|
const char *gameid = ConfMan.get("gameid").c_str();
|
|
|
|
for (g = tinselSettings; g->gameid; ++g)
|
|
|
|
if (!scumm_stricmp(g->gameid, gameid))
|
|
|
|
_gameId = g->id;
|
|
|
|
|
|
|
|
int cd_num = ConfMan.getInt("cdrom");
|
|
|
|
if (cd_num >= 0)
|
2010-06-15 04:13:12 +00:00
|
|
|
_system->getAudioCDManager()->openCD(cd_num);
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2011-03-23 15:14:39 +00:00
|
|
|
_midiMusic = new MidiMusicPlayer();
|
2008-12-01 20:35:36 +00:00
|
|
|
_pcmMusic = new PCMMusicPlayer();
|
MIDI: Send a reset MIDI device signal on startup.
This is currently done in the engine code. I adapted AGI, AGOS, DRACI,
GROOVIE, LURE, MADE, QUEEN, SAGA, SKY, TINSEL and TOUCHE to send a reset
device on startup. The sound output still works fine (started up a game
from every engine), so this should hopefully not introduce any regressions.
As far as I can tell it seems that SCUMM does send a proper device reset, so
I did not touch it. KYRA only sends a proper reset for MT-32 currently. I am
not sure about SCI though.
This fixes bug #3066826 "SIMON: MIDI notes off when using RTL after SCI".
svn-id: r52736
2010-09-15 22:00:20 +00:00
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
_sound = new SoundManager(this);
|
|
|
|
|
2009-10-20 14:06:17 +00:00
|
|
|
_bmv = new BMVPlayer();
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
_mousePos.x = 0;
|
|
|
|
_mousePos.y = 0;
|
|
|
|
_keyHandler = NULL;
|
|
|
|
_dosPlayerDir = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
TinselEngine::~TinselEngine() {
|
2009-10-20 14:06:17 +00:00
|
|
|
if (_bmv->MoviePlaying())
|
|
|
|
_bmv->FinishBMV();
|
2008-12-01 20:35:36 +00:00
|
|
|
|
2010-06-15 04:13:12 +00:00
|
|
|
_system->getAudioCDManager()->stop();
|
2009-10-20 14:06:17 +00:00
|
|
|
delete _bmv;
|
2008-07-23 09:02:47 +00:00
|
|
|
delete _sound;
|
2008-12-01 20:35:36 +00:00
|
|
|
delete _midiMusic;
|
|
|
|
delete _pcmMusic;
|
2008-07-23 09:02:47 +00:00
|
|
|
delete _console;
|
2008-08-13 21:37:02 +00:00
|
|
|
_screenSurface.free();
|
2008-12-01 20:35:36 +00:00
|
|
|
FreeSaveScenes();
|
2008-07-23 09:02:47 +00:00
|
|
|
FreeTextBuffer();
|
|
|
|
FreeHandleTable();
|
|
|
|
FreeActors();
|
|
|
|
FreeObjectList();
|
2008-12-01 20:35:36 +00:00
|
|
|
FreeGlobalProcesses();
|
2008-07-23 09:02:47 +00:00
|
|
|
FreeGlobals();
|
2008-07-24 08:59:17 +00:00
|
|
|
delete _scheduler;
|
2009-10-27 00:36:56 +00:00
|
|
|
|
2009-11-02 21:56:29 +00:00
|
|
|
delete _config;
|
|
|
|
|
2009-10-27 00:36:56 +00:00
|
|
|
MemoryDeinit();
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
2009-03-01 04:42:46 +00:00
|
|
|
Common::String TinselEngine::getSavegameFilename(int16 saveNum) const {
|
2011-06-02 02:58:27 +00:00
|
|
|
return Common::String::format("%s.%03d", getTargetName().c_str(), saveNum);
|
2009-03-01 04:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error TinselEngine::run() {
|
2008-07-23 09:02:47 +00:00
|
|
|
// Initialize backend
|
2008-12-01 20:35:36 +00:00
|
|
|
if (getGameID() == GID_DW2) {
|
|
|
|
#ifndef DW2_EXACT_SIZE
|
|
|
|
initGraphics(640, 480, true);
|
|
|
|
#else
|
|
|
|
initGraphics(640, 432, true);
|
|
|
|
#endif
|
2011-04-17 14:33:50 +00:00
|
|
|
_screenSurface.create(640, 432, Graphics::PixelFormat::createFormatCLUT8());
|
2008-12-01 20:35:36 +00:00
|
|
|
} else {
|
|
|
|
initGraphics(320, 200, false);
|
2011-04-17 14:33:50 +00:00
|
|
|
_screenSurface.create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
|
2008-12-01 20:35:36 +00:00
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
_console = new Console();
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-07-24 08:59:17 +00:00
|
|
|
_scheduler = new Scheduler();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
InitSysVars();
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
// init memory manager
|
|
|
|
MemoryInit();
|
|
|
|
|
|
|
|
// load user configuration
|
2009-11-02 21:56:29 +00:00
|
|
|
_vm->_config->readFromDisk();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
#if 1
|
|
|
|
// FIXME: The following is taken from RestartGame().
|
|
|
|
// It may have to be adjusted a bit
|
2008-08-06 21:44:43 +00:00
|
|
|
CountOut = 1;
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
RebootCursor();
|
|
|
|
RebootDeadTags();
|
|
|
|
RebootMovers();
|
2008-12-01 20:35:36 +00:00
|
|
|
resetUserEventTime();
|
2008-07-23 09:02:47 +00:00
|
|
|
RebootTimers();
|
|
|
|
RebootScalingReels();
|
|
|
|
|
|
|
|
DelayedScene.scene = HookScene.scene = 0;
|
|
|
|
#endif
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
// Load in text strings
|
2009-11-02 21:56:29 +00:00
|
|
|
ChangeLanguage(_vm->_config->_language);
|
2008-12-01 20:35:36 +00:00
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
// Init palette and object managers, scheduler, keyboard and mouse
|
|
|
|
RestartDrivers();
|
|
|
|
|
|
|
|
// load in graphics info
|
|
|
|
SetupHandleTable();
|
|
|
|
|
|
|
|
// Actors, globals and inventory icons
|
|
|
|
LoadBasicChunks();
|
|
|
|
|
|
|
|
// Continuous game processes
|
|
|
|
CreateConstProcesses();
|
|
|
|
|
|
|
|
// allow game to run in the background
|
|
|
|
//RestartBackgroundProcess(); // FIXME: is this still needed?
|
|
|
|
|
|
|
|
//dumpMusic(); // dumps all of the game's music in external XMIDI files
|
|
|
|
|
|
|
|
// Load game from specified slot, if any
|
2008-12-20 23:15:46 +00:00
|
|
|
//
|
2009-05-25 13:40:46 +00:00
|
|
|
// TODO: We might want to think about properly taking care of possible
|
|
|
|
// errors when loading the save state.
|
2009-01-20 00:33:26 +00:00
|
|
|
|
2008-12-21 00:48:23 +00:00
|
|
|
if (ConfMan.hasKey("save_slot")) {
|
2011-04-18 15:39:31 +00:00
|
|
|
if (loadGameState(ConfMan.getInt("save_slot")).getCode() == Common::kNoError)
|
2009-05-25 13:40:46 +00:00
|
|
|
loadingFromGMM = true;
|
2008-12-21 00:48:23 +00:00
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// Foreground loop
|
2009-03-01 04:42:46 +00:00
|
|
|
uint32 timerVal = 0;
|
2008-09-30 12:27:38 +00:00
|
|
|
while (!shouldQuit()) {
|
2008-07-23 09:02:47 +00:00
|
|
|
assert(_console);
|
2010-07-17 18:38:42 +00:00
|
|
|
_console->onFrame();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// Check for time to do next game cycle
|
|
|
|
if ((g_system->getMillis() > timerVal + GAME_FRAME_DELAY)) {
|
|
|
|
timerVal = g_system->getMillis();
|
2010-06-15 04:13:12 +00:00
|
|
|
_system->getAudioCDManager()->updateCD();
|
2008-07-23 09:02:47 +00:00
|
|
|
NextGameCycle();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bRestart) {
|
|
|
|
RestartGame();
|
|
|
|
bRestart = false;
|
|
|
|
bHasRestarted = true; // Set restarted flag
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save/Restore scene file transfers
|
|
|
|
ProcessSRQueue();
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
// Handle any playing movie
|
2009-10-20 14:06:17 +00:00
|
|
|
_bmv->FettleBMV();
|
2008-12-01 20:35:36 +00:00
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (bFast)
|
|
|
|
continue; // run flat-out
|
|
|
|
#endif
|
|
|
|
// Loop processing events while there are any pending
|
2009-01-29 05:26:12 +00:00
|
|
|
while (pollEvent())
|
|
|
|
;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
DoCdChange();
|
|
|
|
|
2009-10-20 14:06:17 +00:00
|
|
|
if (_bmv->MoviePlaying() && _bmv->NextMovieTime())
|
|
|
|
g_system->delayMillis(MAX<int>(_bmv->NextMovieTime() - g_system->getMillis() + _bmv->MovieAudioLag(), 0));
|
2008-12-01 20:35:36 +00:00
|
|
|
else
|
|
|
|
g_system->delayMillis(10);
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Write configuration
|
2009-11-02 21:56:29 +00:00
|
|
|
_vm->_config->writeToDisk();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2010-11-01 20:59:17 +00:00
|
|
|
EndScene();
|
|
|
|
pCurBgnd = NULL;
|
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
return Common::kNoError;
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void TinselEngine::NextGameCycle() {
|
2008-12-01 20:35:36 +00:00
|
|
|
// Dim Music
|
|
|
|
_pcmMusic->dimIteration();
|
|
|
|
|
|
|
|
// Check for scene change
|
|
|
|
ChangeScene(false);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// Allow a user event for this schedule
|
|
|
|
ResetEcount();
|
|
|
|
|
|
|
|
// schedule process
|
2008-07-24 08:59:17 +00:00
|
|
|
_scheduler->schedule();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2009-10-20 14:06:17 +00:00
|
|
|
if (_bmv->MoviePlaying())
|
|
|
|
_bmv->CopyMovieToScreen();
|
2009-01-01 15:06:43 +00:00
|
|
|
else
|
2008-12-01 20:35:36 +00:00
|
|
|
// redraw background
|
|
|
|
DrawBackgnd();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// Why waste resources on yet another process?
|
|
|
|
FettleTimers();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TinselEngine::pollEvent() {
|
2008-07-23 17:01:42 +00:00
|
|
|
Common::Event event;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
|
|
|
if (!g_system->getEventManager()->pollEvent(event))
|
2008-07-23 09:02:47 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// Handle the various kind of events
|
2008-07-23 17:01:42 +00:00
|
|
|
switch (event.type) {
|
2008-07-23 09:02:47 +00:00
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
|
|
|
case Common::EVENT_LBUTTONUP:
|
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
|
|
|
case Common::EVENT_RBUTTONUP:
|
|
|
|
// Add button to queue for the mouse process
|
2009-10-20 19:12:54 +00:00
|
|
|
_mouseButtons.push_back(event.type);
|
2008-07-23 09:02:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Common::EVENT_MOUSEMOVE:
|
2008-12-01 20:35:36 +00:00
|
|
|
{
|
2009-01-01 15:06:43 +00:00
|
|
|
// This fragment takes care of Tinsel 2 when it's been compiled with
|
2008-12-01 20:35:36 +00:00
|
|
|
// blank areas at the top and bottom of thes creen
|
2009-03-01 21:03:46 +00:00
|
|
|
int ySkip = TinselV2 ? (g_system->getHeight() - _vm->screen().h) / 2 : 0;
|
|
|
|
if ((event.mouse.y >= ySkip) && (event.mouse.y < (g_system->getHeight() - ySkip)))
|
|
|
|
_mousePos = Common::Point(event.mouse.x, event.mouse.y - ySkip);
|
2008-12-01 20:35:36 +00:00
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Common::EVENT_KEYDOWN:
|
|
|
|
case Common::EVENT_KEYUP:
|
2008-07-23 17:01:42 +00:00
|
|
|
ProcessKeyEvent(event);
|
2008-07-23 09:02:47 +00:00
|
|
|
break;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start the processes that continue between scenes.
|
|
|
|
*/
|
2009-11-02 21:54:57 +00:00
|
|
|
void TinselEngine::CreateConstProcesses() {
|
2008-07-23 09:02:47 +00:00
|
|
|
// Process to run the master script
|
2008-07-24 08:59:17 +00:00
|
|
|
_scheduler->createProcess(PID_MASTER_SCR, MasterScriptProcess, NULL, 0);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// Processes to run the cursor and inventory,
|
2008-07-24 08:59:17 +00:00
|
|
|
_scheduler->createProcess(PID_CURSOR, CursorProcess, NULL, 0);
|
|
|
|
_scheduler->createProcess(PID_INVENTORY, InventoryProcess, NULL, 0);
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restart the game
|
|
|
|
*/
|
2009-11-02 21:54:57 +00:00
|
|
|
void TinselEngine::RestartGame() {
|
2008-07-23 09:02:47 +00:00
|
|
|
HoldItem(INV_NOICON); // Holding nothing
|
|
|
|
|
|
|
|
DropBackground(); // No background
|
|
|
|
|
|
|
|
// Ditches existing infrastructure background
|
|
|
|
PrimeBackground();
|
|
|
|
|
|
|
|
// Next scene change won't need to fade out
|
|
|
|
// -> reset the count used by ChangeScene
|
|
|
|
CountOut = 1;
|
|
|
|
|
|
|
|
RebootCursor();
|
|
|
|
RebootDeadTags();
|
|
|
|
RebootMovers();
|
|
|
|
RebootTimers();
|
|
|
|
RebootScalingReels();
|
|
|
|
|
|
|
|
DelayedScene.scene = HookScene.scene = 0;
|
|
|
|
|
|
|
|
// remove keyboard, mouse and joystick drivers
|
|
|
|
ChopDrivers();
|
|
|
|
|
|
|
|
// Init palette and object managers, scheduler, keyboard and mouse
|
|
|
|
RestartDrivers();
|
|
|
|
|
|
|
|
// Actors, globals and inventory icons
|
|
|
|
LoadBasicChunks();
|
|
|
|
|
|
|
|
// Continuous game processes
|
|
|
|
CreateConstProcesses();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Init palette and object managers, scheduler, keyboard and mouse.
|
|
|
|
*/
|
2009-11-02 21:54:57 +00:00
|
|
|
void TinselEngine::RestartDrivers() {
|
2008-07-23 09:02:47 +00:00
|
|
|
// init the palette manager
|
|
|
|
ResetPalAllocator();
|
|
|
|
|
|
|
|
// init the object manager
|
|
|
|
KillAllObjects();
|
|
|
|
|
|
|
|
// init the process scheduler
|
2008-07-24 08:59:17 +00:00
|
|
|
_scheduler->reset();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// init the event handlers
|
2009-01-01 15:06:43 +00:00
|
|
|
pMouseProcess = _scheduler->createProcess(PID_MOUSE, MouseProcess, NULL, 0);
|
|
|
|
pKeyboardProcess = _scheduler->createProcess(PID_KEYBOARD, KeyboardProcess, NULL, 0);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-07-24 10:31:37 +00:00
|
|
|
// open MIDI files
|
|
|
|
OpenMidiFiles();
|
|
|
|
|
|
|
|
// open sample files (only if mixer is ready)
|
|
|
|
if (_mixer->isReady()) {
|
|
|
|
_sound->openSampleFiles();
|
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// Set midi volume
|
2010-09-11 05:28:54 +00:00
|
|
|
bool mute = false;
|
|
|
|
if (ConfMan.hasKey("mute"))
|
|
|
|
mute = ConfMan.getBool("mute");
|
|
|
|
|
|
|
|
SetMidiVolume(mute ? 0 : _vm->_config->_musicVolume);
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove keyboard, mouse and joystick drivers.
|
|
|
|
*/
|
2009-11-02 21:54:57 +00:00
|
|
|
void TinselEngine::ChopDrivers() {
|
2008-07-23 09:02:47 +00:00
|
|
|
// remove sound driver
|
2008-07-24 10:31:37 +00:00
|
|
|
StopMidi();
|
|
|
|
_sound->stopAllSamples();
|
|
|
|
DeleteMidiBuffer();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// remove event drivers
|
2008-07-24 08:59:17 +00:00
|
|
|
_scheduler->killProcess(pMouseProcess);
|
|
|
|
_scheduler->killProcess(pKeyboardProcess);
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process a keyboard event
|
|
|
|
*/
|
2008-07-23 17:01:42 +00:00
|
|
|
void TinselEngine::ProcessKeyEvent(const Common::Event &event) {
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// Handle any special keys immediately
|
2008-07-23 17:01:42 +00:00
|
|
|
switch (event.kbd.keycode) {
|
2008-07-23 09:02:47 +00:00
|
|
|
case Common::KEYCODE_d:
|
2010-02-21 04:04:13 +00:00
|
|
|
// Checks for CTRL flag, ignoring all the sticky flags
|
|
|
|
if ((Common::KBD_CTRL == (event.kbd.flags & ~(Common::KBD_NUM|Common::KBD_CAPS|Common::KBD_SCRL))) && (event.type == Common::EVENT_KEYDOWN)) {
|
2008-07-23 09:02:47 +00:00
|
|
|
// Activate the debugger
|
|
|
|
assert(_console);
|
|
|
|
_console->attach();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for movement keys
|
|
|
|
int idx = 0;
|
2008-07-23 17:01:42 +00:00
|
|
|
switch (event.kbd.keycode) {
|
2008-07-23 09:02:47 +00:00
|
|
|
case Common::KEYCODE_UP:
|
|
|
|
case Common::KEYCODE_KP8:
|
|
|
|
idx = MSK_UP;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_DOWN:
|
|
|
|
case Common::KEYCODE_KP2:
|
|
|
|
idx = MSK_DOWN;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_LEFT:
|
|
|
|
case Common::KEYCODE_KP4:
|
|
|
|
idx = MSK_LEFT;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_RIGHT:
|
|
|
|
case Common::KEYCODE_KP6:
|
|
|
|
idx = MSK_RIGHT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (idx != 0) {
|
2008-07-23 17:01:42 +00:00
|
|
|
if (event.type == Common::EVENT_KEYDOWN)
|
2008-07-23 09:02:47 +00:00
|
|
|
_dosPlayerDir |= idx;
|
|
|
|
else
|
|
|
|
_dosPlayerDir &= ~idx;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-01-01 15:06:43 +00:00
|
|
|
// All other keypresses add to the queue for processing in KeyboardProcess
|
2009-10-20 19:12:54 +00:00
|
|
|
_keypresses.push_back(event);
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
const char *TinselEngine::getSampleIndex(LANGUAGE lang) {
|
|
|
|
int cd;
|
|
|
|
|
|
|
|
if (TinselV2) {
|
|
|
|
cd = GetCurrentCD();
|
|
|
|
assert((cd == 1) || (cd == 2));
|
2008-12-03 18:54:22 +00:00
|
|
|
assert(((unsigned int) lang) < NUM_LANGUAGES);
|
2008-12-04 19:42:42 +00:00
|
|
|
|
|
|
|
if (lang == TXT_ENGLISH)
|
|
|
|
if (_vm->getLanguage() == Common::EN_USA)
|
|
|
|
lang = TXT_US;
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
} else {
|
|
|
|
cd = 0;
|
|
|
|
lang = TXT_ENGLISH;
|
|
|
|
}
|
|
|
|
|
|
|
|
return _sampleIndices[lang][cd];
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *TinselEngine::getSampleFile(LANGUAGE lang) {
|
|
|
|
int cd;
|
|
|
|
|
|
|
|
if (TinselV2) {
|
|
|
|
cd = GetCurrentCD();
|
|
|
|
assert((cd == 1) || (cd == 2));
|
2008-12-03 18:54:22 +00:00
|
|
|
assert(((unsigned int) lang) < NUM_LANGUAGES);
|
2008-12-04 19:42:42 +00:00
|
|
|
|
|
|
|
if (lang == TXT_ENGLISH)
|
|
|
|
if (_vm->getLanguage() == Common::EN_USA)
|
|
|
|
lang = TXT_US;
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
} else {
|
|
|
|
cd = 0;
|
|
|
|
lang = TXT_ENGLISH;
|
|
|
|
}
|
|
|
|
|
|
|
|
return _sampleFiles[lang][cd];
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *TinselEngine::getTextFile(LANGUAGE lang) {
|
2008-12-03 18:54:22 +00:00
|
|
|
assert(((unsigned int) lang) < NUM_LANGUAGES);
|
2008-12-01 20:35:36 +00:00
|
|
|
|
|
|
|
int cd;
|
|
|
|
|
|
|
|
if (TinselV2) {
|
|
|
|
cd = GetCurrentCD();
|
|
|
|
assert((cd == 1) || (cd == 2));
|
2008-12-04 19:42:42 +00:00
|
|
|
|
|
|
|
if (lang == TXT_ENGLISH)
|
|
|
|
if (_vm->getLanguage() == Common::EN_USA)
|
|
|
|
lang = TXT_US;
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
} else
|
|
|
|
cd = 0;
|
|
|
|
|
|
|
|
return _textFiles[lang][cd];
|
|
|
|
}
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
} // End of namespace Tinsel
|