2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2006-05-23 23:43:52 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2006-05-23 23:43:52 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-01-05 21:10:49 +00:00
|
|
|
#include "common/md5.h"
|
2008-10-06 12:48:52 +00:00
|
|
|
#include "common/events.h"
|
2009-07-25 12:59:46 +00:00
|
|
|
#include "common/EventRecorder.h"
|
2006-05-23 23:43:52 +00:00
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
|
|
|
|
#include "base/plugins.h"
|
2007-01-12 02:31:04 +00:00
|
|
|
#include "base/version.h"
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-25 22:51:42 +00:00
|
|
|
#include "graphics/cursorman.h"
|
|
|
|
|
2006-05-23 23:43:52 +00:00
|
|
|
#include "sound/mididrv.h"
|
|
|
|
#include "sound/mixer.h"
|
|
|
|
|
|
|
|
#include "agi/agi.h"
|
|
|
|
#include "agi/graphics.h"
|
|
|
|
#include "agi/sprite.h"
|
|
|
|
#include "agi/keyboard.h"
|
|
|
|
#include "agi/menu.h"
|
|
|
|
|
|
|
|
namespace Agi {
|
|
|
|
|
2007-03-17 16:08:29 +00:00
|
|
|
void AgiEngine::allowSynthetic(bool allow) {
|
|
|
|
_allowSynthetic = allow;
|
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void AgiEngine::processEvents() {
|
2007-03-17 19:02:05 +00:00
|
|
|
Common::Event event;
|
2006-05-23 23:43:52 +00:00
|
|
|
int key = 0;
|
|
|
|
|
2007-04-01 17:36:13 +00:00
|
|
|
while (_eventMan->pollEvent(event)) {
|
2006-05-23 23:43:52 +00:00
|
|
|
switch (event.type) {
|
2007-05-29 20:07:19 +00:00
|
|
|
case Common::EVENT_PREDICTIVE_DIALOG:
|
2007-06-02 08:15:06 +00:00
|
|
|
if (_predictiveDialogRunning)
|
|
|
|
break;
|
2008-04-10 08:27:09 +00:00
|
|
|
if (predictiveDialog()) {
|
2007-05-30 19:49:33 +00:00
|
|
|
if (_game.inputMode == INPUT_NORMAL) {
|
|
|
|
strcpy((char *)_game.inputBuffer, _predictiveResult);
|
|
|
|
handleKeys(KEY_ENTER);
|
|
|
|
} else if (_game.inputMode == INPUT_GETSTRING) {
|
|
|
|
strcpy(_game.strings[_stringdata.str], _predictiveResult);
|
|
|
|
newInputMode(INPUT_NORMAL);
|
|
|
|
_gfx->printCharacter(_stringdata.x + strlen(_game.strings[_stringdata.str]) + 1,
|
|
|
|
_stringdata.y, ' ', _game.colorFg, _game.colorBg);
|
2009-05-11 20:58:55 +00:00
|
|
|
} else if (_game.inputMode == INPUT_NONE) {
|
|
|
|
for (int n = 0; _predictiveResult[n]; n++)
|
|
|
|
keyEnqueue(_predictiveResult[n]);
|
2007-05-30 19:49:33 +00:00
|
|
|
}
|
2007-05-29 20:07:19 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = BUTTON_LEFT;
|
2009-10-20 11:13:00 +00:00
|
|
|
_mouse.button = kAgiMouseButtonLeft;
|
2007-01-16 12:40:51 +00:00
|
|
|
keyEnqueue(key);
|
2009-10-20 11:13:00 +00:00
|
|
|
_mouse.x = event.mouse.x;
|
|
|
|
_mouse.y = event.mouse.y;
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = BUTTON_RIGHT;
|
2009-10-20 11:13:00 +00:00
|
|
|
_mouse.button = kAgiMouseButtonRight;
|
2007-01-16 12:40:51 +00:00
|
|
|
keyEnqueue(key);
|
2009-10-20 11:13:00 +00:00
|
|
|
_mouse.x = event.mouse.x;
|
|
|
|
_mouse.y = event.mouse.y;
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_WHEELUP:
|
2007-03-12 08:43:13 +00:00
|
|
|
key = WHEEL_UP;
|
|
|
|
keyEnqueue(key);
|
|
|
|
break;
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_WHEELDOWN:
|
2007-03-12 08:43:13 +00:00
|
|
|
key = WHEEL_DOWN;
|
|
|
|
keyEnqueue(key);
|
|
|
|
break;
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_MOUSEMOVE:
|
2009-10-20 11:13:00 +00:00
|
|
|
_mouse.x = event.mouse.x;
|
|
|
|
_mouse.y = event.mouse.y;
|
2009-06-06 17:47:29 +00:00
|
|
|
|
|
|
|
if (!_game.mouseFence.isEmpty()) {
|
2009-10-20 11:13:00 +00:00
|
|
|
if (_mouse.x < _game.mouseFence.left)
|
|
|
|
_mouse.x = _game.mouseFence.left;
|
|
|
|
if (_mouse.x > _game.mouseFence.right)
|
|
|
|
_mouse.x = _game.mouseFence.right;
|
|
|
|
if (_mouse.y < _game.mouseFence.top)
|
|
|
|
_mouse.y = _game.mouseFence.top;
|
|
|
|
if (_mouse.y > _game.mouseFence.bottom)
|
|
|
|
_mouse.y = _game.mouseFence.bottom;
|
|
|
|
|
|
|
|
g_system->warpMouse(_mouse.x, _mouse.y);
|
2009-06-06 17:47:29 +00:00
|
|
|
}
|
|
|
|
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_LBUTTONUP:
|
|
|
|
case Common::EVENT_RBUTTONUP:
|
2009-10-20 11:13:00 +00:00
|
|
|
_mouse.button = kAgiMouseButtonUp;
|
|
|
|
_mouse.x = event.mouse.x;
|
|
|
|
_mouse.y = event.mouse.y;
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_KEYDOWN:
|
2007-06-21 20:04:10 +00:00
|
|
|
if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == Common::KEYCODE_d) {
|
2006-05-28 11:52:24 +00:00
|
|
|
_console->attach();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-05-23 23:43:52 +00:00
|
|
|
switch (key = event.kbd.keycode) {
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_LEFT:
|
|
|
|
case Common::KEYCODE_KP4:
|
2007-03-17 16:08:29 +00:00
|
|
|
if (_allowSynthetic || !event.synthetic)
|
2007-03-17 15:44:26 +00:00
|
|
|
key = KEY_LEFT;
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_RIGHT:
|
|
|
|
case Common::KEYCODE_KP6:
|
2007-03-17 16:08:29 +00:00
|
|
|
if (_allowSynthetic || !event.synthetic)
|
2007-03-17 15:44:26 +00:00
|
|
|
key = KEY_RIGHT;
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_UP:
|
|
|
|
case Common::KEYCODE_KP8:
|
2007-03-17 16:08:29 +00:00
|
|
|
if (_allowSynthetic || !event.synthetic)
|
2007-03-17 15:44:26 +00:00
|
|
|
key = KEY_UP;
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_DOWN:
|
|
|
|
case Common::KEYCODE_KP2:
|
2007-03-17 16:08:29 +00:00
|
|
|
if (_allowSynthetic || !event.synthetic)
|
2007-03-17 15:44:26 +00:00
|
|
|
key = KEY_DOWN;
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_PAGEUP:
|
|
|
|
case Common::KEYCODE_KP9:
|
2007-03-17 16:08:29 +00:00
|
|
|
if (_allowSynthetic || !event.synthetic)
|
2007-03-17 15:44:26 +00:00
|
|
|
key = KEY_UP_RIGHT;
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_PAGEDOWN:
|
|
|
|
case Common::KEYCODE_KP3:
|
2007-03-17 16:08:29 +00:00
|
|
|
if (_allowSynthetic || !event.synthetic)
|
2007-03-17 15:44:26 +00:00
|
|
|
key = KEY_DOWN_RIGHT;
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_HOME:
|
|
|
|
case Common::KEYCODE_KP7:
|
2007-03-17 16:08:29 +00:00
|
|
|
if (_allowSynthetic || !event.synthetic)
|
2007-03-17 15:44:26 +00:00
|
|
|
key = KEY_UP_LEFT;
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_END:
|
|
|
|
case Common::KEYCODE_KP1:
|
2007-03-17 16:08:29 +00:00
|
|
|
if (_allowSynthetic || !event.synthetic)
|
2007-03-17 15:44:26 +00:00
|
|
|
key = KEY_DOWN_LEFT;
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_KP5:
|
2006-05-28 11:08:46 +00:00
|
|
|
key = KEY_STATIONARY;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_PLUS:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = '+';
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_MINUS:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = '-';
|
|
|
|
break;
|
2007-07-10 21:24:58 +00:00
|
|
|
case Common::KEYCODE_TAB:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = 0x0009;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_F1:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = 0x3b00;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_F2:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = 0x3c00;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_F3:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = 0x3d00;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_F4:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = 0x3e00;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_F5:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = 0x3f00;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_F6:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = 0x4000;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_F7:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = 0x4100;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_F8:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = 0x4200;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_F9:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = 0x4300;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_F10:
|
2006-05-28 11:52:24 +00:00
|
|
|
key = 0x4400;
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_F11:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = KEY_STATUSLN;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_F12:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = KEY_PRIORITY;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_ESCAPE:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = 0x1b;
|
|
|
|
break;
|
2007-06-21 20:04:10 +00:00
|
|
|
case Common::KEYCODE_RETURN:
|
|
|
|
case Common::KEYCODE_KP_ENTER:
|
2006-05-23 23:43:52 +00:00
|
|
|
key = KEY_ENTER;
|
|
|
|
break;
|
2007-06-22 23:12:24 +00:00
|
|
|
case Common::KEYCODE_BACKSPACE:
|
|
|
|
key = KEY_BACKSPACE;
|
|
|
|
break;
|
2006-05-23 23:43:52 +00:00
|
|
|
default:
|
2008-01-09 12:59:11 +00:00
|
|
|
// Not a special key, so get the ASCII code for it
|
|
|
|
key = event.kbd.ascii;
|
2007-12-20 14:57:05 +00:00
|
|
|
|
2008-01-17 11:16:00 +00:00
|
|
|
// Function isalpha is defined in <ctype.h> so the following applies to it:
|
|
|
|
//
|
|
|
|
// The C Programming Language Standard states:
|
|
|
|
// The header <ctype.h> declares several functions useful for classifying
|
|
|
|
// and mapping characters. In all cases the argument is an int, the value
|
|
|
|
// of which shall be representable as an unsigned char or shall equal the
|
|
|
|
// value of the macro EOF. If the argument has any other value, the
|
|
|
|
// behavior is undefined.
|
|
|
|
//
|
|
|
|
// For a concrete example (e.g. in Microsoft Visual Studio 2003):
|
|
|
|
// When used with a debug CRT library, isalpha will display a CRT assert
|
|
|
|
// if passed a parameter that isn't EOF or in the range of 0 through 0xFF.
|
|
|
|
if (key >= 0 && key <= 0xFF && isalpha(key)) {
|
2008-01-27 19:47:41 +00:00
|
|
|
// Key is A-Z.
|
2007-12-20 14:57:05 +00:00
|
|
|
// Map Ctrl-A to 1, Ctrl-B to 2, etc.
|
|
|
|
if (event.kbd.flags & Common::KBD_CTRL) {
|
|
|
|
key = toupper(key) - 'A' + 1;
|
|
|
|
} else if (event.kbd.flags & Common::KBD_ALT) {
|
|
|
|
// Map Alt-A, Alt-B etc. to special scancode values according to an internal scancode table.
|
|
|
|
key = scancodeTable[toupper(key) - 'A'] << 8;
|
|
|
|
}
|
|
|
|
}
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (key)
|
2007-01-16 12:40:51 +00:00
|
|
|
keyEnqueue(key);
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
2009-06-06 17:46:19 +00:00
|
|
|
|
|
|
|
case Common::EVENT_KEYUP:
|
|
|
|
if (_egoHoldKey)
|
|
|
|
_game.viewTable[0].direction = 0;
|
|
|
|
|
2006-05-23 23:43:52 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void AgiEngine::pollTimer() {
|
2006-05-23 23:43:52 +00:00
|
|
|
static uint32 m = 0;
|
|
|
|
uint32 dm;
|
|
|
|
|
2009-10-20 11:13:00 +00:00
|
|
|
if (_tickTimer < m)
|
2006-05-23 23:43:52 +00:00
|
|
|
m = 0;
|
|
|
|
|
2009-10-20 11:13:00 +00:00
|
|
|
while ((dm = _tickTimer - m) < 5) {
|
2006-12-06 19:27:02 +00:00
|
|
|
processEvents();
|
2006-05-24 21:40:24 +00:00
|
|
|
if (_console->isAttached())
|
|
|
|
_console->onFrame();
|
2007-03-17 00:53:21 +00:00
|
|
|
_system->delayMillis(10);
|
|
|
|
_system->updateScreen();
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
2009-10-20 11:13:00 +00:00
|
|
|
m = _tickTimer;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void AgiEngine::agiTimerFunctionLow(void *refCon) {
|
2009-10-20 11:13:00 +00:00
|
|
|
AgiEngine *self = (AgiEngine *)refCon;
|
|
|
|
self->_tickTimer++;
|
2006-12-06 19:27:02 +00:00
|
|
|
}
|
|
|
|
|
2009-06-06 17:39:42 +00:00
|
|
|
void AgiEngine::pause(uint32 msec) {
|
|
|
|
uint32 endTime = _system->getMillis() + msec;
|
|
|
|
|
2009-06-06 17:41:29 +00:00
|
|
|
_gfx->setCursor(_renderMode == Common::kRenderAmiga, true);
|
|
|
|
|
2009-06-06 17:39:42 +00:00
|
|
|
while (_system->getMillis() < endTime) {
|
|
|
|
processEvents();
|
|
|
|
_system->updateScreen();
|
|
|
|
_system->delayMillis(10);
|
|
|
|
}
|
2009-06-06 17:41:29 +00:00
|
|
|
_gfx->setCursor(_renderMode == Common::kRenderAmiga);
|
2009-06-06 17:39:42 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void AgiEngine::initPriTable() {
|
2006-05-23 23:43:52 +00:00
|
|
|
int i, p, y = 0;
|
|
|
|
|
|
|
|
for (p = 1; p < 15; p++) {
|
|
|
|
for (i = 0; i < 12; i++) {
|
2007-01-16 12:40:51 +00:00
|
|
|
_game.priTable[y++] = p < 4 ? 4 : p;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
int AgiEngine::agiInit() {
|
2006-05-23 23:43:52 +00:00
|
|
|
int ec, i;
|
|
|
|
|
|
|
|
debug(2, "initializing");
|
2009-06-06 17:45:52 +00:00
|
|
|
debug(2, "game version = 0x%x", getVersion());
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
// initialize with adj.ego.move.to.x.y(0, 0) so to speak
|
2008-01-21 21:09:42 +00:00
|
|
|
_game.adjMouseX = _game.adjMouseY = 0;
|
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
// reset all flags to false and all variables to 0
|
2006-05-23 23:43:52 +00:00
|
|
|
for (i = 0; i < MAX_FLAGS; i++)
|
2007-01-16 12:40:51 +00:00
|
|
|
_game.flags[i] = 0;
|
2006-05-23 23:43:52 +00:00
|
|
|
for (i = 0; i < MAX_VARS; i++)
|
2007-01-16 12:40:51 +00:00
|
|
|
_game.vars[i] = 0;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
// clear all resources and events
|
2006-05-23 23:43:52 +00:00
|
|
|
for (i = 0; i < MAX_DIRS; i++) {
|
2007-01-16 12:40:51 +00:00
|
|
|
memset(&_game.views[i], 0, sizeof(struct AgiView));
|
|
|
|
memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
|
|
|
|
memset(&_game.logics[i], 0, sizeof(struct AgiLogic));
|
2007-08-15 22:00:31 +00:00
|
|
|
memset(&_game.sounds[i], 0, sizeof(class AgiSound *)); // _game.sounds contains pointers now
|
2007-01-16 12:40:51 +00:00
|
|
|
memset(&_game.dirView[i], 0, sizeof(struct AgiDir));
|
|
|
|
memset(&_game.dirPic[i], 0, sizeof(struct AgiDir));
|
|
|
|
memset(&_game.dirLogic[i], 0, sizeof(struct AgiDir));
|
|
|
|
memset(&_game.dirSound[i], 0, sizeof(struct AgiDir));
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
// clear view table
|
2006-05-23 23:43:52 +00:00
|
|
|
for (i = 0; i < MAX_VIEWTABLE; i++)
|
2007-02-03 21:37:52 +00:00
|
|
|
memset(&_game.viewTable[i], 0, sizeof(VtEntry));
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
initWords();
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
if (!_menu)
|
|
|
|
_menu = new Menu(this, _gfx, _picture);
|
2006-09-07 16:13:41 +00:00
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
initPriTable();
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
// clear string buffer
|
2006-05-23 23:43:52 +00:00
|
|
|
for (i = 0; i < MAX_STRINGS; i++)
|
2007-01-16 12:40:51 +00:00
|
|
|
_game.strings[i][0] = 0;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
// setup emulation
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2009-06-06 17:45:52 +00:00
|
|
|
switch (getVersion() >> 12) {
|
2006-05-23 23:43:52 +00:00
|
|
|
case 2:
|
|
|
|
report("Emulating Sierra AGI v%x.%03x\n",
|
2009-06-06 17:45:52 +00:00
|
|
|
(int)(getVersion() >> 12) & 0xF,
|
|
|
|
(int)(getVersion()) & 0xFFF);
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
report("Emulating Sierra AGI v%x.002.%03x\n",
|
2009-06-06 17:45:52 +00:00
|
|
|
(int)(getVersion() >> 12) & 0xF,
|
|
|
|
(int)(getVersion()) & 0xFFF);
|
2006-05-23 23:43:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-02-13 15:27:36 +00:00
|
|
|
if (getPlatform() == Common::kPlatformAmiga)
|
|
|
|
_game.gameFlags |= ID_AMIGA;
|
|
|
|
|
|
|
|
if (getFeatures() & GF_AGDS)
|
|
|
|
_game.gameFlags |= ID_AGDS;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-06-20 22:54:51 +00:00
|
|
|
// Make the 256 color AGI screen the default AGI screen when AGI256 or AGI256-2 is used
|
|
|
|
if (getFeatures() & (GF_AGI256 | GF_AGI256_2))
|
|
|
|
_game.sbuf = _game.sbuf256c;
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
if (_game.gameFlags & ID_AMIGA)
|
2006-05-23 23:43:52 +00:00
|
|
|
report("Amiga padded game detected.\n");
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
if (_game.gameFlags & ID_AGDS)
|
2006-05-23 23:43:52 +00:00
|
|
|
report("AGDS mode enabled.\n");
|
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
ec = _loader->init(); // load vol files, etc
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
if (ec == errOK)
|
|
|
|
ec = _loader->loadObjects(OBJECTS);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
// note: demogs has no words.tok
|
2007-01-16 12:40:51 +00:00
|
|
|
if (ec == errOK)
|
|
|
|
ec = _loader->loadWords(WORDS);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
// FIXME: load IIgs instruments and samples
|
|
|
|
// load_instruments("kq.sys16");
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
// Load logic 0 into memory
|
2007-01-16 12:40:51 +00:00
|
|
|
if (ec == errOK)
|
|
|
|
ec = _loader->loadResource(rLOGIC, 0);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-07-16 22:55:44 +00:00
|
|
|
#ifdef __DS__
|
|
|
|
// Normally, the engine loads the predictive text dictionary when the predictive dialog
|
|
|
|
// is shown. On the DS version, the word completion feature needs the dictionary too.
|
|
|
|
loadDict();
|
|
|
|
#endif
|
|
|
|
|
2009-06-06 17:46:19 +00:00
|
|
|
_egoHoldKey = false;
|
|
|
|
|
2009-06-06 17:47:29 +00:00
|
|
|
_game.mouseFence.setWidth(0); // Reset
|
|
|
|
|
2006-05-23 23:43:52 +00:00
|
|
|
return ec;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Public functions
|
|
|
|
*/
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void AgiEngine::agiUnloadResources() {
|
2006-05-23 23:43:52 +00:00
|
|
|
int i;
|
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
// Make sure logic 0 is always loaded
|
2006-05-23 23:43:52 +00:00
|
|
|
for (i = 1; i < MAX_DIRS; i++) {
|
2007-01-16 12:40:51 +00:00
|
|
|
_loader->unloadResource(rLOGIC, i);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
for (i = 0; i < MAX_DIRS; i++) {
|
2007-01-16 12:40:51 +00:00
|
|
|
_loader->unloadResource(rVIEW, i);
|
|
|
|
_loader->unloadResource(rPICTURE, i);
|
|
|
|
_loader->unloadResource(rSOUND, i);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
int AgiEngine::agiDeinit() {
|
2006-05-23 23:43:52 +00:00
|
|
|
int ec;
|
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
cleanInput(); // remove all words from memory
|
|
|
|
agiUnloadResources(); // unload resources in memory
|
2007-01-16 12:40:51 +00:00
|
|
|
_loader->unloadResource(rLOGIC, 0);
|
|
|
|
ec = _loader->deinit();
|
|
|
|
unloadObjects();
|
|
|
|
unloadWords();
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
clearImageStack();
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
return ec;
|
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
int AgiEngine::agiLoadResource(int r, int n) {
|
2006-05-23 23:43:52 +00:00
|
|
|
int i;
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
i = _loader->loadResource(r, n);
|
2007-09-01 14:58:46 +00:00
|
|
|
|
2008-01-05 21:10:49 +00:00
|
|
|
// WORKAROUND: Patches broken picture 147 in a corrupted Amiga version of Gold Rush! (v2.05 1989-03-09).
|
|
|
|
// The picture can be seen in room 147 after dropping through the outhouse's hole in room 146.
|
|
|
|
if (i == errOK && getGameID() == GID_GOLDRUSH && r == rPICTURE && n == 147 && _game.dirPic[n].len == 1982) {
|
|
|
|
uint8 *pic = _game.pictures[n].rdata;
|
|
|
|
Common::MemoryReadStream picStream(pic, _game.dirPic[n].len);
|
|
|
|
char md5str[32+1];
|
|
|
|
Common::md5_file_string(picStream, md5str, _game.dirPic[n].len);
|
|
|
|
if (scumm_stricmp(md5str, "1c685eb048656cedcee4eb6eca2cecea") == 0) {
|
|
|
|
pic[0x042] = 0x4B; // 0x49 -> 0x4B
|
|
|
|
pic[0x043] = 0x66; // 0x26 -> 0x66
|
|
|
|
pic[0x204] = 0x68; // 0x28 -> 0x68
|
|
|
|
pic[0x6C0] = 0x2D; // 0x25 -> 0x2D
|
|
|
|
pic[0x6F0] = 0xF0; // 0x70 -> 0xF0
|
|
|
|
pic[0x734] = 0x6F; // 0x2F -> 0x6F
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-23 23:43:52 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
int AgiEngine::agiUnloadResource(int r, int n) {
|
2007-01-16 12:40:51 +00:00
|
|
|
return _loader->unloadResource(r, n);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct GameSettings {
|
|
|
|
const char *gameid;
|
|
|
|
const char *description;
|
|
|
|
byte id;
|
|
|
|
uint32 features;
|
|
|
|
const char *detectname;
|
|
|
|
};
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
static const GameSettings agiSettings[] = {
|
2006-06-26 13:29:40 +00:00
|
|
|
{"agi", "AGI game", GID_AGI, MDT_ADLIB, "OBJECT"},
|
2006-05-23 23:43:52 +00:00
|
|
|
{NULL, NULL, 0, 0, NULL}
|
|
|
|
};
|
|
|
|
|
2007-11-03 21:06:58 +00:00
|
|
|
AgiBase::AgiBase(OSystem *syst, const AGIGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
|
2009-06-06 17:42:37 +00:00
|
|
|
_noSaveLoadAllowed = false;
|
2009-06-06 17:44:46 +00:00
|
|
|
|
|
|
|
initFeatures();
|
2009-06-06 17:45:52 +00:00
|
|
|
initVersion();
|
2007-09-01 14:58:46 +00:00
|
|
|
}
|
|
|
|
|
2007-11-03 21:06:58 +00:00
|
|
|
AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) {
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
// Setup mixer
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
|
|
|
|
|
|
|
|
const GameSettings *g;
|
|
|
|
|
|
|
|
const char *gameid = ConfMan.get("gameid").c_str();
|
2007-01-16 12:40:51 +00:00
|
|
|
for (g = agiSettings; g->gameid; ++g)
|
2006-05-23 23:43:52 +00:00
|
|
|
if (!scumm_stricmp(g->gameid, gameid))
|
|
|
|
_gameId = g->id;
|
|
|
|
|
2009-06-06 17:44:46 +00:00
|
|
|
parseFeatures();
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
_rnd = new Common::RandomSource();
|
2009-07-25 12:59:46 +00:00
|
|
|
g_eventRec.registerRandomSource(*_rnd, "agi");
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2009-01-30 05:10:24 +00:00
|
|
|
Common::addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
|
|
|
|
Common::addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging");
|
|
|
|
Common::addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging");
|
|
|
|
Common::addDebugChannel(kDebugLevelInventory, "Inventory", "Inventory debugging");
|
|
|
|
Common::addDebugChannel(kDebugLevelInput, "Input", "Input events debugging");
|
|
|
|
Common::addDebugChannel(kDebugLevelMenu, "Menu", "Menu debugging");
|
|
|
|
Common::addDebugChannel(kDebugLevelScripts, "Scripts", "Scripts debugging");
|
|
|
|
Common::addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
|
|
|
|
Common::addDebugChannel(kDebugLevelText, "Text", "Text output debugging");
|
|
|
|
Common::addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
|
2006-05-24 13:08:09 +00:00
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
memset(&_game, 0, sizeof(struct AgiGame));
|
|
|
|
memset(&_debug, 0, sizeof(struct AgiDebug));
|
2009-10-20 11:13:00 +00:00
|
|
|
memset(&_mouse, 0, sizeof(struct Mouse));
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
_game.clockEnabled = false;
|
|
|
|
_game.state = STATE_INIT;
|
|
|
|
|
|
|
|
_keyQueueStart = 0;
|
|
|
|
_keyQueueEnd = 0;
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-03-17 16:08:29 +00:00
|
|
|
_allowSynthetic = false;
|
|
|
|
|
2009-10-20 11:13:00 +00:00
|
|
|
_tickTimer = 0;
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
_intobj = NULL;
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
_menu = NULL;
|
2009-06-06 17:43:51 +00:00
|
|
|
_menuSelected = false;
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
_lastSentence[0] = 0;
|
|
|
|
memset(&_stringdata, 0, sizeof(struct StringData));
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
_objects = NULL;
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2009-06-06 17:40:56 +00:00
|
|
|
_restartGame = false;
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
_oldMode = -1;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-06-02 08:15:06 +00:00
|
|
|
_predictiveDialogRunning = false;
|
2007-06-13 12:48:14 +00:00
|
|
|
_predictiveDictText = NULL;
|
|
|
|
_predictiveDictLine = NULL;
|
2007-06-13 13:26:46 +00:00
|
|
|
_predictiveDictLineCount = 0;
|
2007-03-12 08:43:13 +00:00
|
|
|
_firstSlot = 0;
|
2009-07-22 11:48:51 +00:00
|
|
|
|
|
|
|
// NOTE: On game reload the keys do not get set again,
|
|
|
|
// thus it is incorrect to reset it in agiInit(). Fixes bug #2823762
|
|
|
|
_game.lastController = 0;
|
|
|
|
for (int i = 0; i < MAX_DIRS; i++)
|
|
|
|
_game.controllerOccured[i] = false;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AgiEngine::initialize() {
|
2006-06-06 15:38:34 +00:00
|
|
|
// TODO: Some sound emulation modes do not fit our current music
|
|
|
|
// drivers, and I'm not sure what they are. For now, they might
|
|
|
|
// as well be called "PC Speaker" and "Not PC Speaker".
|
|
|
|
|
2007-08-17 13:10:57 +00:00
|
|
|
// If used platform is Apple IIGS then we must use Apple IIGS sound emulation
|
|
|
|
// because Apple IIGS AGI games use only Apple IIGS specific sound resources.
|
2008-04-22 20:33:46 +00:00
|
|
|
if (getPlatform() == Common::kPlatformApple2GS) {
|
2007-08-17 13:10:57 +00:00
|
|
|
_soundemu = SOUND_EMU_APPLE2GS;
|
2009-06-16 21:59:20 +00:00
|
|
|
} else if (getPlatform() == Common::kPlatformCoCo3) {
|
2009-06-17 23:16:21 +00:00
|
|
|
_soundemu = SOUND_EMU_COCO3;
|
2007-08-17 13:10:57 +00:00
|
|
|
} else {
|
|
|
|
switch (MidiDriver::detectMusicDriver(MDT_PCSPK)) {
|
|
|
|
case MD_PCSPK:
|
|
|
|
_soundemu = SOUND_EMU_PC;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
_soundemu = SOUND_EMU_NONE;
|
|
|
|
break;
|
|
|
|
}
|
2006-06-06 15:38:34 +00:00
|
|
|
}
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-02-10 10:27:07 +00:00
|
|
|
if (ConfMan.hasKey("render_mode")) {
|
2007-02-13 15:27:36 +00:00
|
|
|
_renderMode = Common::parseRenderMode(ConfMan.get("render_mode").c_str());
|
2007-02-10 10:27:07 +00:00
|
|
|
} else if (ConfMan.hasKey("platform")) {
|
|
|
|
switch (Common::parsePlatform(ConfMan.get("platform"))) {
|
|
|
|
case Common::kPlatformAmiga:
|
2007-02-13 15:27:36 +00:00
|
|
|
_renderMode = Common::kRenderAmiga;
|
2007-02-10 10:27:07 +00:00
|
|
|
break;
|
|
|
|
case Common::kPlatformPC:
|
2007-02-13 15:27:36 +00:00
|
|
|
_renderMode = Common::kRenderEGA;
|
2007-02-10 10:27:07 +00:00
|
|
|
break;
|
|
|
|
default:
|
2007-02-13 15:27:36 +00:00
|
|
|
_renderMode = Common::kRenderEGA;
|
2007-02-10 10:27:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-05-25 19:46:28 +00:00
|
|
|
|
2007-07-10 15:28:43 +00:00
|
|
|
_buttonStyle = AgiButtonStyle(_renderMode);
|
2007-07-10 18:08:35 +00:00
|
|
|
_defaultButtonStyle = AgiButtonStyle();
|
2006-05-24 21:56:14 +00:00
|
|
|
_console = new Console(this);
|
2006-12-06 19:27:02 +00:00
|
|
|
_gfx = new GfxMgr(this);
|
|
|
|
_sound = new SoundMgr(this, _mixer);
|
|
|
|
_picture = new PictureMgr(this, _gfx);
|
|
|
|
_sprites = new SpritesMgr(this, _gfx);
|
|
|
|
|
|
|
|
_gfx->initMachine();
|
2006-05-24 21:56:14 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
_game.gameFlags = 0;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
_game.colorFg = 15;
|
|
|
|
_game.colorBg = 0;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
_game.name[0] = '\0';
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-06-20 22:54:51 +00:00
|
|
|
_game.sbufOrig = (uint8 *)calloc(_WIDTH, _HEIGHT * 2); // Allocate space for two AGI screens vertically
|
|
|
|
_game.sbuf16c = _game.sbufOrig + SBUF16_OFFSET; // Make sbuf16c point to the 16 color (+control line & priority info) AGI screen
|
|
|
|
_game.sbuf256c = _game.sbufOrig + SBUF256_OFFSET; // Make sbuf256c point to the 256 color AGI screen
|
|
|
|
_game.sbuf = _game.sbuf16c; // Make sbuf point to the 16 color (+control line & priority info) AGI screen by default
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
_gfx->initVideo();
|
2007-01-16 12:40:51 +00:00
|
|
|
_sound->initSound();
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2008-08-10 22:53:43 +00:00
|
|
|
_lastSaveTime = 0;
|
|
|
|
|
2009-10-20 11:13:00 +00:00
|
|
|
_timer->installTimerProc(agiTimerFunctionLow, 10 * 1000, this);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
debugC(2, kDebugLevelMain, "Detect game");
|
2006-12-19 01:11:41 +00:00
|
|
|
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
if (agiDetectGame() == errOK) {
|
|
|
|
_game.state = STATE_LOADED;
|
2006-05-23 23:43:52 +00:00
|
|
|
debugC(2, kDebugLevelMain, "game loaded");
|
|
|
|
} else {
|
|
|
|
report("Could not open AGI game");
|
|
|
|
}
|
|
|
|
|
|
|
|
debugC(2, kDebugLevelMain, "Init sound");
|
|
|
|
}
|
|
|
|
|
|
|
|
AgiEngine::~AgiEngine() {
|
2009-08-22 00:18:22 +00:00
|
|
|
_timer->removeTimerProc(agiTimerFunctionLow);
|
|
|
|
|
2007-07-09 17:39:47 +00:00
|
|
|
// If the engine hasn't been initialized yet via AgiEngine::initialize(), don't attempt to free any resources,
|
|
|
|
// as they haven't been allocated. Fixes bug #1742432 - AGI: Engine crashes if no game is detected
|
|
|
|
if (_game.state == STATE_INIT) {
|
|
|
|
delete _rnd; // delete _rnd, as it is allocated in the constructor, not in initialize()
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
agiDeinit();
|
2008-05-24 00:08:13 +00:00
|
|
|
delete _loader;
|
2007-01-16 12:40:51 +00:00
|
|
|
_sound->deinitSound();
|
2006-12-06 19:27:02 +00:00
|
|
|
delete _sound;
|
|
|
|
_gfx->deinitVideo();
|
2006-05-30 18:53:01 +00:00
|
|
|
delete _sprites;
|
2008-05-24 00:08:13 +00:00
|
|
|
delete _picture;
|
2007-06-20 22:54:51 +00:00
|
|
|
free(_game.sbufOrig);
|
2006-12-06 19:27:02 +00:00
|
|
|
_gfx->deinitMachine();
|
2008-05-24 00:08:13 +00:00
|
|
|
delete _gfx;
|
2007-01-16 12:40:51 +00:00
|
|
|
delete _rnd;
|
2006-05-24 21:40:24 +00:00
|
|
|
delete _console;
|
2007-06-13 12:48:14 +00:00
|
|
|
|
|
|
|
free(_predictiveDictLine);
|
|
|
|
free(_predictiveDictText);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
Common::Error AgiBase::init() {
|
2006-12-19 01:11:41 +00:00
|
|
|
|
2006-05-23 23:43:52 +00:00
|
|
|
// Initialize backend
|
2008-11-14 22:08:10 +00:00
|
|
|
initGraphics(320, 200, false);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
initialize();
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
_gfx->gfxSetPalette();
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
return Common::kNoError;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
Common::Error AgiEngine::go() {
|
2006-05-25 22:51:42 +00:00
|
|
|
CursorMan.showMouse(true);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-12 02:31:04 +00:00
|
|
|
report(" \nAGI engine %s is ready.\n", gScummVMVersion);
|
2007-01-16 12:40:51 +00:00
|
|
|
if (_game.state < STATE_LOADED) {
|
2006-05-23 23:43:52 +00:00
|
|
|
do {
|
2007-01-16 12:40:51 +00:00
|
|
|
mainCycle();
|
|
|
|
} while (_game.state < STATE_RUNNING);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
runGame();
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
return Common::kNoError;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2008-07-07 05:51:39 +00:00
|
|
|
void AgiEngine::syncSoundSettings() {
|
2009-03-10 22:36:06 +00:00
|
|
|
// FIXME/TODO: Please explain why we are using "music_volume" for all
|
|
|
|
// three different entries here.
|
2008-07-07 05:51:39 +00:00
|
|
|
int soundVolumeMusic = ConfMan.getInt("music_volume");
|
|
|
|
int soundVolumeSFX = ConfMan.getInt("music_volume");
|
|
|
|
int soundVolumeSpeech = ConfMan.getInt("music_volume");
|
|
|
|
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic);
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, soundVolumeSFX);
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech);
|
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void AgiEngine::parseFeatures() {
|
2009-06-06 17:44:46 +00:00
|
|
|
if (!ConfMan.hasKey("features"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
char *features = strdup(ConfMan.get("features").c_str());
|
|
|
|
const char *feature[100];
|
|
|
|
int numFeatures = 0;
|
|
|
|
|
|
|
|
char *tok = strtok(features, " ");
|
|
|
|
if (tok) {
|
|
|
|
do {
|
|
|
|
feature[numFeatures++] = tok;
|
|
|
|
} while ((tok = strtok(NULL, " ")) != NULL);
|
|
|
|
} else {
|
|
|
|
feature[numFeatures++] = features;
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct Flags {
|
|
|
|
const char *name;
|
|
|
|
uint32 flag;
|
|
|
|
} flags[] = {
|
|
|
|
{ "agimouse", GF_AGIMOUSE },
|
|
|
|
{ "agds", GF_AGDS },
|
|
|
|
{ "agi256", GF_AGI256 },
|
|
|
|
{ "agi256-2", GF_AGI256_2 },
|
|
|
|
{ "agipal", GF_AGIPAL },
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
for (int i = 0; i < numFeatures; i++) {
|
|
|
|
for (const Flags *flag = flags; flag->name; flag++) {
|
|
|
|
if (!scumm_stricmp(feature[i], flag->name)) {
|
|
|
|
debug(0, "Added feature: %s", flag->name);
|
|
|
|
|
|
|
|
setFeature(flag->flag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-07 18:02:54 +00:00
|
|
|
} // End of namespace Agi
|