2013-06-20 14:08:58 +02:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
2013-07-24 12:56:55 +02:00
|
|
|
* ScummVM is the legal property of its developers, whose names
|
2013-06-20 14:08:58 +02:00
|
|
|
* 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
|
2013-07-24 12:56:55 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2013-06-20 14:08:58 +02:00
|
|
|
|
2013-07-24 12:56:55 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2013-06-20 14:08:58 +02:00
|
|
|
* 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
|
2013-07-24 12:56:55 +02:00
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2013-06-20 14:08:58 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on the original source code of Lord Avalot d'Argent version 1.3.
|
2013-07-24 12:55:01 +02:00
|
|
|
* Copyright (c) 1994-1995 Mike: Mark and Thomas Thurman.
|
2013-06-20 14:08:58 +02:00
|
|
|
*/
|
|
|
|
|
2013-07-02 16:46:56 +02:00
|
|
|
/* AVALOT The kernel of the program. */
|
|
|
|
|
2013-06-29 10:20:22 +02:00
|
|
|
#include "avalanche/avalanche.h"
|
2013-07-02 13:21:41 +02:00
|
|
|
|
2013-07-24 17:02:08 +02:00
|
|
|
#include "avalanche/graphics.h"
|
2013-06-20 14:08:58 +02:00
|
|
|
#include "avalanche/avalot.h"
|
2013-06-23 21:11:15 +02:00
|
|
|
#include "avalanche/gyro2.h"
|
2013-09-07 19:09:06 +02:00
|
|
|
#include "avalanche/animation.h"
|
2013-07-02 13:21:41 +02:00
|
|
|
#include "avalanche/gyro2.h"
|
|
|
|
#include "avalanche/lucerna2.h"
|
|
|
|
#include "avalanche/scrolls2.h"
|
|
|
|
#include "avalanche/dropdown2.h"
|
|
|
|
#include "avalanche/pingo2.h"
|
2013-09-08 11:30:23 +02:00
|
|
|
#include "avalanche/timer.h"
|
2013-07-02 13:21:41 +02:00
|
|
|
#include "avalanche/celer2.h"
|
|
|
|
#include "avalanche/enid2.h"
|
2013-07-15 11:24:38 +02:00
|
|
|
#include "avalanche/closing2.h"
|
2013-07-02 13:21:41 +02:00
|
|
|
|
|
|
|
#include "common/str.h"
|
|
|
|
#include "common/textconsole.h"
|
2013-08-20 19:23:24 +02:00
|
|
|
#include "common/config-manager.h"
|
2013-06-20 14:08:58 +02:00
|
|
|
|
2013-07-15 11:24:38 +02:00
|
|
|
|
|
|
|
|
2013-06-20 14:08:58 +02:00
|
|
|
namespace Avalanche {
|
|
|
|
|
2013-07-24 12:55:01 +02:00
|
|
|
|
|
|
|
|
2013-07-24 18:12:16 +02:00
|
|
|
Avalot::Avalot(AvalancheEngine *vm) {
|
2013-07-24 12:55:01 +02:00
|
|
|
_vm = vm;
|
|
|
|
}
|
|
|
|
|
2013-08-16 19:24:40 +02:00
|
|
|
void Avalot::handleKeyDown(Common::Event &event) {
|
|
|
|
//if (keyboardclick)
|
|
|
|
// click();
|
2013-09-07 09:00:34 +02:00
|
|
|
//
|
2013-08-16 19:24:40 +02:00
|
|
|
// To be implemented later with the sounds, I assume.
|
2013-09-07 09:00:34 +02:00
|
|
|
|
2013-08-16 19:24:40 +02:00
|
|
|
|
2013-08-23 16:58:22 +02:00
|
|
|
if ((Common::KEYCODE_F1 <= event.kbd.keycode) && (event.kbd.keycode <= Common::KEYCODE_F15))
|
|
|
|
_vm->_parser->handleFunctionKey(event);
|
|
|
|
else if ((32 <= event.kbd.ascii) && (event.kbd.ascii <= 128) && (event.kbd.ascii != 47))
|
2013-08-16 19:24:40 +02:00
|
|
|
_vm->_parser->handleInputText(event);
|
|
|
|
else
|
|
|
|
switch (event.kbd.keycode) { // We can control Avvy with the numpad as well.
|
|
|
|
case Common::KEYCODE_KP8:
|
|
|
|
event.kbd.keycode = Common::KEYCODE_UP;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_KP2:
|
|
|
|
event.kbd.keycode = Common::KEYCODE_DOWN;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_KP6:
|
|
|
|
event.kbd.keycode = Common::KEYCODE_RIGHT;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_KP4:
|
|
|
|
event.kbd.keycode = Common::KEYCODE_LEFT;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_KP9:
|
|
|
|
event.kbd.keycode = Common::KEYCODE_PAGEUP;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_KP3:
|
|
|
|
event.kbd.keycode = Common::KEYCODE_PAGEDOWN;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_KP7:
|
|
|
|
event.kbd.keycode = Common::KEYCODE_HOME;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_KP1:
|
|
|
|
event.kbd.keycode = Common::KEYCODE_END;
|
|
|
|
break;
|
2013-09-04 16:52:44 +02:00
|
|
|
default:
|
|
|
|
break;
|
2013-08-16 19:24:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (event.kbd.keycode) {
|
|
|
|
case Common::KEYCODE_UP:
|
|
|
|
case Common::KEYCODE_DOWN:
|
|
|
|
case Common::KEYCODE_RIGHT:
|
|
|
|
case Common::KEYCODE_LEFT:
|
|
|
|
case Common::KEYCODE_PAGEUP:
|
|
|
|
case Common::KEYCODE_PAGEDOWN:
|
|
|
|
case Common::KEYCODE_HOME:
|
|
|
|
case Common::KEYCODE_END:
|
|
|
|
case Common::KEYCODE_KP5:
|
2013-09-13 21:30:03 +02:00
|
|
|
if (_vm->_gyro->_alive && _vm->_gyro->_avvyIsAwake) {
|
2013-09-07 19:09:06 +02:00
|
|
|
_vm->_animation->handleMoveKey(event); // Fallthroughs are intended.
|
2013-09-07 15:58:02 +02:00
|
|
|
_vm->_lucerna->drawDirection();
|
2013-08-16 19:24:40 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case Common::KEYCODE_BACKSPACE:
|
|
|
|
_vm->_parser->handleBackspace();
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_RETURN:
|
|
|
|
_vm->_parser->handleReturn();
|
|
|
|
break;
|
2013-09-04 16:52:44 +02:00
|
|
|
default:
|
|
|
|
break;
|
2013-08-16 19:24:40 +02:00
|
|
|
}
|
|
|
|
|
2013-09-07 15:58:02 +02:00
|
|
|
_vm->_lucerna->drawDirection();
|
2013-08-16 19:24:40 +02:00
|
|
|
}
|
|
|
|
|
2013-07-04 18:29:04 +02:00
|
|
|
void Avalot::setup() {
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_mouse = _vm->_gyro->kMouseStateNo;
|
|
|
|
_vm->_gyro->_letMeOut = false;
|
2013-09-07 20:37:42 +02:00
|
|
|
_vm->_scrolls->resetScroll();
|
2013-08-16 13:40:58 +02:00
|
|
|
CursorMan.showMouse(true);
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_holdTheDawn = true;
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_lucerna->dusk();
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_currentMouse = 177;
|
2013-09-07 15:58:02 +02:00
|
|
|
_vm->_gyro->setMousePointerWait();
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_dropsOk = true;
|
|
|
|
_vm->_gyro->_mouseText = "";
|
|
|
|
_vm->_gyro->_dropdownActive = false;
|
2013-09-07 15:58:02 +02:00
|
|
|
_vm->_lucerna->loadDigits();
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_cheat = false;
|
|
|
|
_vm->_gyro->_cp = 0;
|
2013-07-27 21:48:28 +02:00
|
|
|
_vm->_parser->_inputTextPos = 0;
|
|
|
|
_vm->_parser->_quote = true;
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_ledStatus = 177;
|
|
|
|
_vm->_gyro->_defaultLed = 2;
|
2013-09-05 07:47:40 +02:00
|
|
|
// TSkellern = 0; Replace with a more local variable sometime
|
2013-09-13 22:58:24 +02:00
|
|
|
_vm->_animation->_direction = Animation::kDirStopped;
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_enidFilename = ""; // Undefined.
|
2013-09-07 15:58:02 +02:00
|
|
|
_vm->_lucerna->drawToolbar();
|
2013-09-07 20:37:42 +02:00
|
|
|
_vm->_scrolls->setReadyLight(2);
|
2013-07-18 12:06:45 +02:00
|
|
|
for (byte i = 0; i < 3; i++)
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_scoreToDisplay[i] = -1; // Impossible digits.
|
2013-06-23 21:11:15 +02:00
|
|
|
|
2013-09-08 12:06:08 +02:00
|
|
|
_vm->_animation->loadAnims();
|
2013-06-23 21:11:15 +02:00
|
|
|
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_holdTheDawn = false;
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_lucerna->dawn();
|
2013-07-28 10:00:14 +02:00
|
|
|
_vm->_parser->_cursorState = false;
|
|
|
|
_vm->_parser->cursorOn();
|
2013-09-08 12:06:08 +02:00
|
|
|
_vm->_animation->_sprites[0]._speedX = _vm->_gyro->kWalk;
|
|
|
|
_vm->_animation->updateSpeed();
|
2013-06-29 10:20:22 +02:00
|
|
|
|
2013-08-20 19:23:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
int16 loadSlot = Common::ConfigManager::instance().getInt("save_slot");
|
2013-09-07 09:00:34 +02:00
|
|
|
if (loadSlot >= 0) {
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_thinks = 2; // You always have money.
|
2013-09-09 23:34:12 +02:00
|
|
|
_vm->_lucerna->thinkAbout(Gyro::kObjectMoney, Gyro::kThing);
|
2013-08-27 11:10:24 +02:00
|
|
|
|
2013-08-20 19:23:24 +02:00
|
|
|
_vm->loadGame(loadSlot);
|
2013-08-25 18:05:02 +02:00
|
|
|
} else {
|
2013-08-21 13:45:22 +02:00
|
|
|
_vm->_gyro->isLoaded = false; // Set to true in _vm->loadGame().
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->newGame(); // No game was requested- load the default.
|
2013-08-20 19:23:24 +02:00
|
|
|
|
2013-09-15 00:36:23 +02:00
|
|
|
_vm->_gyro->_soundFx = !_vm->_gyro->_soundFx;
|
2013-09-07 15:58:02 +02:00
|
|
|
_vm->_lucerna->fxToggle();
|
2013-09-09 23:34:12 +02:00
|
|
|
_vm->_lucerna->thinkAbout(Gyro::kObjectMoney, Gyro::kThing);
|
2013-08-20 19:23:24 +02:00
|
|
|
|
2013-09-15 12:25:07 +02:00
|
|
|
_vm->_scrolls->displayScrollChain('q', 83); // Info on the game, etc.
|
2013-09-07 09:00:34 +02:00
|
|
|
}
|
2013-07-02 13:21:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Avalot::run(Common::String arg) {
|
2013-07-04 18:29:04 +02:00
|
|
|
setup();
|
2013-07-15 11:24:38 +02:00
|
|
|
|
2013-07-02 13:21:41 +02:00
|
|
|
do {
|
2013-07-25 23:32:22 +02:00
|
|
|
uint32 beginLoop = _vm->_system->getMillis();
|
|
|
|
|
2013-07-27 10:17:32 +02:00
|
|
|
_vm->updateEvents(); // The event handler.
|
|
|
|
|
2013-09-07 18:00:00 +02:00
|
|
|
_vm->_lucerna->_clock.update();
|
2013-09-04 18:12:06 +02:00
|
|
|
_vm->_dropdown->updateMenu();
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->forceNumlock();
|
2013-09-04 09:25:11 +02:00
|
|
|
_vm->_celer->updateBackgroundSprites();
|
2013-09-07 20:02:14 +02:00
|
|
|
_vm->_animation->animLink();
|
2013-09-07 15:58:02 +02:00
|
|
|
_vm->_lucerna->checkClick();
|
2013-09-08 11:30:23 +02:00
|
|
|
_vm->_timer->updateTimer();
|
2013-07-02 13:21:41 +02:00
|
|
|
|
2013-09-05 07:47:40 +02:00
|
|
|
#ifdef DEBUG
|
2013-08-23 16:58:22 +02:00
|
|
|
// ONLY FOR TESTING!!!
|
2013-09-15 10:50:43 +02:00
|
|
|
for (byte i = 0; i < _vm->_gyro->_lineNum; i++) {
|
|
|
|
LineType *curLine = &_vm->_gyro->_lines[i];
|
|
|
|
_vm->_graphics->_surface.drawLine(curLine->_x1, curLine->_y1, curLine->_x2, curLine->_y2, curLine->col);
|
|
|
|
}
|
2013-08-23 16:58:22 +02:00
|
|
|
|
2013-09-06 16:23:57 +02:00
|
|
|
for (byte i = 0; i < _vm->_gyro->_fieldNum; i++) {
|
2013-09-15 10:50:43 +02:00
|
|
|
FieldType *curField = &_vm->_gyro->_fields[i];
|
|
|
|
if (curField->_x1 < 640)
|
|
|
|
_vm->_graphics->_surface.frameRect(Common::Rect(curField->_x1, curField->_y1, curField->_x2, curField->_y2), kColorLightmagenta);
|
2013-09-05 07:47:40 +02:00
|
|
|
}
|
|
|
|
// ONLY FOR TESTING!!!
|
|
|
|
#endif
|
2013-08-23 16:58:22 +02:00
|
|
|
|
2013-07-24 17:52:57 +02:00
|
|
|
_vm->_graphics->refreshScreen(); // TODO: Maybe it'll have a better place later. Move it there when it's needed.
|
2013-07-18 22:33:08 +02:00
|
|
|
|
2013-07-25 23:32:22 +02:00
|
|
|
uint32 delay = _vm->_system->getMillis() - beginLoop;
|
2013-07-25 23:38:06 +02:00
|
|
|
if (delay <= 55)
|
|
|
|
_vm->_system->delayMillis(55 - delay); // Replaces _vm->_gyro->slowdown(); 55 comes from 18.2 Hz (B Flight).
|
2013-09-07 15:58:02 +02:00
|
|
|
} while (!_vm->_gyro->_letMeOut && !_vm->shouldQuit());
|
2013-07-02 13:21:41 +02:00
|
|
|
|
|
|
|
//if (logging)
|
|
|
|
// close(logfile);
|
2013-09-03 16:03:16 +02:00
|
|
|
warning("STUB: Avalot::run()");
|
2013-07-02 13:21:41 +02:00
|
|
|
|
2013-09-04 10:09:07 +02:00
|
|
|
_vm->_closing->exitGame();
|
2013-07-02 13:21:41 +02:00
|
|
|
}
|
2013-06-20 14:08:58 +02:00
|
|
|
|
|
|
|
} // End of namespace Avalanche
|