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-07-02 13:21:41 +02:00
|
|
|
#include "avalanche/trip6.h"
|
|
|
|
#include "avalanche/gyro2.h"
|
|
|
|
#include "avalanche/lucerna2.h"
|
|
|
|
#include "avalanche/scrolls2.h"
|
|
|
|
#include "avalanche/basher2.h"
|
|
|
|
#include "avalanche/dropdown2.h"
|
|
|
|
#include "avalanche/pingo2.h"
|
|
|
|
#include "avalanche/logger2.h"
|
|
|
|
#include "avalanche/timeout2.h"
|
|
|
|
#include "avalanche/celer2.h"
|
|
|
|
#include "avalanche/enid2.h"
|
|
|
|
#include "avalanche/visa2.h"
|
2013-07-15 11:24:38 +02:00
|
|
|
#include "avalanche/closing2.h"
|
2013-07-02 13:21:41 +02:00
|
|
|
|
|
|
|
/*#include "Incline.h"*/
|
|
|
|
|
|
|
|
#include "common/str.h"
|
|
|
|
#include "common/textconsole.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-07-04 18:29:04 +02:00
|
|
|
void Avalot::setup() {
|
2013-07-02 13:21:41 +02:00
|
|
|
int16 gd, gm;
|
2013-06-23 21:11:15 +02:00
|
|
|
|
2013-07-02 13:21:41 +02:00
|
|
|
checkbreak = false;
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->visible = _vm->_gyro->m_no;
|
|
|
|
_vm->_gyro->to_do = 0;
|
|
|
|
_vm->_gyro->lmo = false;
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_scrolls->resetscroll();
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->setup_vmc();
|
|
|
|
_vm->_gyro->on_virtual();
|
2013-07-02 13:21:41 +02:00
|
|
|
gd = 3;
|
|
|
|
gm = 0;
|
2013-07-24 12:55:01 +02:00
|
|
|
//initgraph(gd: gm: "");
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->holdthedawn = true;
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_lucerna->dusk();
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->cmp = 177;
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_lucerna->mouse_init(); /*on;*/
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->dropsok = true;
|
|
|
|
_vm->_gyro->ctrl = ckey;
|
|
|
|
_vm->_gyro->oldjw = 177;
|
|
|
|
_vm->_gyro->mousetext = "";
|
|
|
|
_vm->_gyro->c = 999;
|
2013-07-24 12:55:01 +02:00
|
|
|
//settextjustify(0: 0);
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->ddmnow = false;
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_lucerna->load_digits();
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->cheat = false;
|
|
|
|
_vm->_gyro->cp = 0;
|
|
|
|
_vm->_gyro->curpos = 1;
|
|
|
|
_vm->_gyro->quote = true;
|
|
|
|
_vm->_gyro->ledstatus = 177;
|
|
|
|
_vm->_gyro->defaultled = 2;
|
2013-07-02 13:21:41 +02:00
|
|
|
/* TSkellern:=0; { Replace with a more local variable sometime }*/
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->dna.rw = _vm->_gyro->stopped;
|
|
|
|
_vm->_gyro->enid_filename = ""; /* undefined. */
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_lucerna->toolbar();
|
|
|
|
_vm->_scrolls->state(2);
|
2013-07-24 18:50:13 +02:00
|
|
|
_vm->_graphics->refreshScreen(); //_vm->_pingo->copy03(); Replace it with refreshScreen() since they 'almost' have the same functionality.
|
2013-07-18 12:06:45 +02:00
|
|
|
for (byte i = 0; i < 3; i++)
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->lastscore[i] = -1; /* impossible digits */
|
2013-06-23 21:11:15 +02:00
|
|
|
|
2013-07-02 13:21:41 +02:00
|
|
|
/* for gd:=0 to 1 do
|
|
|
|
begin
|
2013-07-24 12:55:01 +02:00
|
|
|
setactivepage(gd); outtextxy(7:177:chr(48+gd));
|
2013-07-02 13:21:41 +02:00
|
|
|
end;*/
|
2013-06-23 21:11:15 +02:00
|
|
|
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_trip->loadtrip();
|
2013-06-23 21:11:15 +02:00
|
|
|
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->reloaded = false; // TODO: Remove it later: when SAVE/LOAD system is implemented. Until then: we always start a new game.
|
2013-07-18 12:06:45 +02:00
|
|
|
|
2013-07-24 18:25:07 +02:00
|
|
|
if ((_vm->_gyro->filetoload.empty()) && (! _vm->_gyro->reloaded))
|
|
|
|
_vm->_gyro->newgame(); /* no game was requested- load the default */
|
2013-07-02 13:21:41 +02:00
|
|
|
else {
|
2013-07-24 18:25:07 +02:00
|
|
|
if (! _vm->_gyro->reloaded)
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_enid->avvy_background();
|
|
|
|
_vm->_dropdown->standard_bar();
|
|
|
|
_vm->_lucerna->sprite_run();
|
2013-07-24 18:25:07 +02:00
|
|
|
if (_vm->_gyro->reloaded)
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_enid->edna_reload();
|
2013-07-02 13:21:41 +02:00
|
|
|
else {
|
|
|
|
/* Filename given on the command line (or loadfirst) */
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_enid->edna_load(_vm->_gyro->filetoload);
|
|
|
|
if (_vm->_enid->there_was_a_problem()) {
|
|
|
|
_vm->_scrolls->display("So let's start from the beginning instead...");
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->holdthedawn = true;
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_lucerna->dusk();
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->newgame();
|
2013-07-02 13:21:41 +02:00
|
|
|
}
|
|
|
|
}
|
2013-06-23 21:11:15 +02:00
|
|
|
}
|
2013-06-20 14:08:58 +02:00
|
|
|
|
2013-07-24 18:25:07 +02:00
|
|
|
if (! _vm->_gyro->reloaded) {
|
|
|
|
_vm->_gyro->soundfx = ! _vm->_gyro->soundfx;
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_lucerna->fxtoggle();
|
|
|
|
_vm->_lucerna->thinkabout(_vm->_gyro->money, _vm->_gyro->a_thing);
|
2013-06-29 10:20:22 +02:00
|
|
|
}
|
|
|
|
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_trip->get_back_loretta();
|
2013-07-24 12:55:01 +02:00
|
|
|
//gm = getpixel(0: 0);
|
2013-07-02 13:21:41 +02:00
|
|
|
//setcolor(7);
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->holdthedawn = false;
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_lucerna->dawn();
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->cursoron = false;
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_basher->cursor_on();
|
|
|
|
_vm->_trip->newspeed();
|
2013-06-29 10:20:22 +02:00
|
|
|
|
2013-07-24 18:25:07 +02:00
|
|
|
if (! _vm->_gyro->reloaded)
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_visa->dixi('q', 83); /* Info on the game: etc. */
|
2013-07-02 13:21:41 +02:00
|
|
|
}
|
|
|
|
|
2013-07-24 12:55:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
void Avalot::handleKeyDown(const Common::Event &event) {
|
2013-07-24 13:54:39 +02:00
|
|
|
//if (keyboardclick)
|
|
|
|
// click();
|
|
|
|
//
|
|
|
|
// To be implemented later with the sounds, I assume.
|
|
|
|
|
2013-07-24 12:55:01 +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:
|
2013-07-24 13:38:32 +02:00
|
|
|
case Common::KEYCODE_KP5:
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_trip->handleMoveKey(event); // Fallthroughs are intended.
|
2013-07-24 12:55:01 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-02 13:21:41 +02:00
|
|
|
|
2013-07-24 12:55:01 +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-24 19:43:10 +02:00
|
|
|
_vm->_lucerna->clock_lucerna();
|
|
|
|
_vm->_basher->keyboard_link();
|
|
|
|
_vm->_dropdown->menu_link();
|
|
|
|
_vm->_trip->readstick();
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->force_numlock();
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_trip->get_back_loretta();
|
|
|
|
_vm->_trip->trippancy_link();
|
|
|
|
_vm->_celer->pics_link();
|
|
|
|
_vm->_lucerna->checkclick();
|
2013-07-02 13:21:41 +02:00
|
|
|
|
2013-07-24 18:25:07 +02:00
|
|
|
if (_vm->_gyro->visible == _vm->_gyro->m_virtual)
|
|
|
|
_vm->_gyro->plot_vmc(_vm->_gyro->mx, _vm->_gyro->my, _vm->_gyro->cp);
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_lucerna->flip_page(); /* <<<! */
|
2013-07-25 23:32:22 +02:00
|
|
|
|
2013-07-24 18:25:07 +02:00
|
|
|
if (_vm->_gyro->visible == _vm->_gyro->m_virtual)
|
|
|
|
_vm->_gyro->wipe_vmc(_vm->_gyro->cp);
|
2013-07-02 13:21:41 +02:00
|
|
|
|
2013-07-25 22:54:28 +02:00
|
|
|
_vm->_timeout->one_tick();
|
2013-07-02 13:21:41 +02:00
|
|
|
|
2013-07-24 12:55:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
// Not in the original:
|
|
|
|
|
|
|
|
_vm->updateEvents(); // The event handler.
|
|
|
|
|
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-07-25 23:32:22 +02:00
|
|
|
|
2013-07-24 18:25:07 +02:00
|
|
|
} while (! _vm->_gyro->lmo);
|
2013-07-02 13:21:41 +02:00
|
|
|
|
|
|
|
//restorecrtmode();
|
|
|
|
//if (logging)
|
|
|
|
// close(logfile);
|
|
|
|
|
2013-07-24 19:43:10 +02:00
|
|
|
_vm->_closing->end_of_program();
|
2013-07-02 13:21:41 +02:00
|
|
|
}
|
2013-06-20 14:08:58 +02:00
|
|
|
|
|
|
|
} // End of namespace Avalanche
|