2013-06-26 14:14:01 +02: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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on the original source code of Lord Avalot d'Argent version 1.3.
|
|
|
|
* Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* CELER The unit for updating the screen pics. */
|
|
|
|
|
2013-06-29 16:36:40 +02:00
|
|
|
#include "avalanche/avalanche.h"
|
|
|
|
|
2013-06-26 14:14:01 +02:00
|
|
|
#include "avalanche/celer2.h"
|
2013-06-28 17:58:22 +02:00
|
|
|
#include "avalanche/trip6.h"
|
2013-06-26 14:14:01 +02:00
|
|
|
#include "avalanche/lucerna2.h"
|
|
|
|
#include "avalanche/gyro2.h"
|
|
|
|
#include "avalanche/roomnums.h"
|
2013-06-29 16:36:40 +02:00
|
|
|
|
|
|
|
#include "common/textconsole.h"
|
2013-06-26 14:14:01 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
|
|
|
|
|
2013-06-26 14:14:01 +02:00
|
|
|
namespace Avalanche {
|
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
const int16 Celer::kOnDisk = -1;
|
2013-06-26 14:14:01 +02:00
|
|
|
|
|
|
|
|
2013-07-24 19:43:10 +02:00
|
|
|
Celer::Celer(AvalancheEngine *vm) {
|
2013-06-28 17:58:22 +02:00
|
|
|
_vm = vm;
|
2013-09-03 22:22:42 +02:00
|
|
|
_chunkNum = 0;
|
2013-06-28 17:58:22 +02:00
|
|
|
}
|
2013-06-26 14:14:01 +02:00
|
|
|
|
2013-07-26 14:19:54 +02:00
|
|
|
Celer::~Celer() {
|
|
|
|
for (byte i = 0; i < 40; i++)
|
2013-09-03 22:22:42 +02:00
|
|
|
_memory[i].free();
|
2013-07-26 14:19:54 +02:00
|
|
|
}
|
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
void Celer::refreshBackgroundSprites() {
|
2013-07-24 18:25:07 +02:00
|
|
|
if (_vm->_gyro->ddmnow)
|
2013-09-03 22:22:42 +02:00
|
|
|
return; // No animation when the menus are up.
|
2013-06-30 14:10:33 +02:00
|
|
|
|
2013-07-24 18:25:07 +02:00
|
|
|
switch (_vm->_gyro->dna.room) {
|
2013-06-30 14:10:33 +02:00
|
|
|
case r__outsideargentpub:
|
2013-08-23 11:33:37 +02:00
|
|
|
if ((_vm->_gyro->roomtime % 12) == 0)
|
2013-09-03 22:22:42 +02:00
|
|
|
drawBackgroundSprite(-1, -1, 1 + (_vm->_gyro->roomtime / 12) % 4);
|
2013-06-30 22:01:05 +02:00
|
|
|
break;
|
2013-06-30 14:10:33 +02:00
|
|
|
case r__brummieroad:
|
2013-08-23 11:33:37 +02:00
|
|
|
if ((_vm->_gyro->roomtime % 2) == 0)
|
2013-09-03 22:22:42 +02:00
|
|
|
drawBackgroundSprite(-1, -1, 1 + (_vm->_gyro->roomtime / 2) % 4);
|
2013-06-28 17:58:22 +02:00
|
|
|
break;
|
2013-06-30 14:10:33 +02:00
|
|
|
case r__bridge:
|
2013-08-23 11:33:37 +02:00
|
|
|
if ((_vm->_gyro->roomtime % 2) == 0)
|
2013-09-03 22:22:42 +02:00
|
|
|
drawBackgroundSprite(-1, -1, 4 + (_vm->_gyro->roomtime / 2) % 4);
|
2013-06-30 14:10:33 +02:00
|
|
|
break;
|
|
|
|
case r__yours:
|
2013-08-23 11:33:37 +02:00
|
|
|
if ((!_vm->_gyro->dna.avvy_is_awake) && ((_vm->_gyro->roomtime % 4) == 0))
|
2013-09-03 22:22:42 +02:00
|
|
|
drawBackgroundSprite(-1, -1, 1 + (_vm->_gyro->roomtime / 12) % 2);
|
2013-06-30 14:10:33 +02:00
|
|
|
break;
|
2013-09-03 22:22:42 +02:00
|
|
|
case r__argentpub: {
|
|
|
|
if (((_vm->_gyro->roomtime % 7) == 1) && (_vm->_gyro->dna.malagauche != 177)) {
|
|
|
|
// Malagauche cycle.
|
|
|
|
_vm->_gyro->dna.malagauche += 1;
|
|
|
|
switch (_vm->_gyro->dna.malagauche) {
|
|
|
|
case 1:
|
|
|
|
case 11:
|
|
|
|
case 21:
|
|
|
|
drawBackgroundSprite(-1, -1, 12); // Looks forwards.
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
case 18:
|
|
|
|
case 28:
|
|
|
|
case 32:
|
|
|
|
drawBackgroundSprite(-1, -1, 11); // Looks at you.
|
|
|
|
break;
|
|
|
|
case 30:
|
|
|
|
drawBackgroundSprite(-1, -1, 13); // Winks.
|
|
|
|
break;
|
|
|
|
case 33:
|
|
|
|
_vm->_gyro->dna.malagauche = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-06-26 14:14:01 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
switch (_vm->_gyro->roomtime % 200) {
|
|
|
|
case 179:
|
|
|
|
case 197:
|
|
|
|
drawBackgroundSprite(-1, -1, 5); // Dogfood's drinking cycle.
|
|
|
|
break;
|
|
|
|
case 182:
|
|
|
|
case 194:
|
|
|
|
drawBackgroundSprite(-1, -1, 6);
|
|
|
|
break;
|
|
|
|
case 185:
|
|
|
|
drawBackgroundSprite(-1, -1, 7);
|
2013-06-26 14:14:01 +02:00
|
|
|
break;
|
2013-09-03 22:22:42 +02:00
|
|
|
case 199:
|
|
|
|
_vm->_gyro->dna.dogfoodpos = 177; // Impossible value for this.
|
|
|
|
break;
|
2013-06-28 17:58:22 +02:00
|
|
|
}
|
2013-06-26 14:14:01 +02:00
|
|
|
|
2013-09-03 22:36:28 +02:00
|
|
|
byte direction;
|
2013-09-03 22:22:42 +02:00
|
|
|
if ((_vm->_gyro->roomtime % 200 >= 0) && (_vm->_gyro->roomtime % 200 <= 178)) { // Normally.
|
|
|
|
if (((_vm->_lucerna->bearing(2) >= 1) && (_vm->_lucerna->bearing(2) <= 90)) || ((_vm->_lucerna->bearing(2) >= 358) && (_vm->_lucerna->bearing(2) <= 360)))
|
|
|
|
direction = 3;
|
|
|
|
else if ((_vm->_lucerna->bearing(2) >= 293) && (_vm->_lucerna->bearing(2) <= 357))
|
|
|
|
direction = 2;
|
|
|
|
else if ((_vm->_lucerna->bearing(2) >= 271) && (_vm->_lucerna->bearing(2) <= 292))
|
|
|
|
direction = 4;
|
|
|
|
|
|
|
|
if (direction != _vm->_gyro->dna.dogfoodpos) { // Only if it's changed.
|
|
|
|
drawBackgroundSprite(-1, -1, direction);
|
|
|
|
_vm->_gyro->dna.dogfoodpos = direction;
|
|
|
|
}
|
2013-06-26 14:14:01 +02:00
|
|
|
}
|
2013-06-30 14:10:33 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case r__westhall:
|
2013-08-23 11:33:37 +02:00
|
|
|
if ((_vm->_gyro->roomtime % 3) == 0) {
|
2013-07-24 18:25:07 +02:00
|
|
|
switch ((_vm->_gyro->roomtime / int32(3)) % int32(6)) {
|
2013-06-30 14:10:33 +02:00
|
|
|
case 4:
|
2013-09-03 22:22:42 +02:00
|
|
|
drawBackgroundSprite(-1, -1, 1);
|
2013-06-30 14:10:33 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 3:
|
|
|
|
case 5:
|
2013-09-03 22:22:42 +02:00
|
|
|
drawBackgroundSprite(-1, -1, 2);
|
2013-06-30 14:10:33 +02:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 2:
|
2013-09-03 22:22:42 +02:00
|
|
|
drawBackgroundSprite(-1, -1, 3);
|
2013-06-28 17:58:22 +02:00
|
|
|
break;
|
2013-06-26 14:14:01 +02:00
|
|
|
}
|
|
|
|
}
|
2013-06-28 17:58:22 +02:00
|
|
|
break;
|
2013-06-30 14:10:33 +02:00
|
|
|
case r__lustiesroom:
|
2013-07-24 18:25:07 +02:00
|
|
|
if (!(_vm->_gyro->dna.lustie_is_asleep)) {
|
2013-09-03 22:36:28 +02:00
|
|
|
byte direction;
|
2013-08-23 11:33:37 +02:00
|
|
|
if ((_vm->_gyro->roomtime % 45) > 42)
|
2013-09-03 22:22:42 +02:00
|
|
|
direction = 4; // du Lustie blinks.
|
|
|
|
// Bearing of Avvy from du Lustie.
|
2013-07-24 19:43:10 +02:00
|
|
|
else if (((_vm->_lucerna->bearing(2) >= 0) && (_vm->_lucerna->bearing(2) <= 45)) || ((_vm->_lucerna->bearing(2) >= 315) && (_vm->_lucerna->bearing(2) <= 360)))
|
2013-09-03 22:22:42 +02:00
|
|
|
direction = 1; // Middle.
|
2013-07-24 19:43:10 +02:00
|
|
|
else if ((_vm->_lucerna->bearing(2) >= 45) && (_vm->_lucerna->bearing(2) <= 180))
|
2013-09-03 22:22:42 +02:00
|
|
|
direction = 2; // Left.
|
2013-07-24 19:43:10 +02:00
|
|
|
else if ((_vm->_lucerna->bearing(2) >= 181) && (_vm->_lucerna->bearing(2) <= 314))
|
2013-09-03 22:22:42 +02:00
|
|
|
direction = 3; // Right.
|
2013-06-28 17:58:22 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
if (direction != _vm->_gyro->dna.dogfoodpos) { // Only if it's changed.
|
|
|
|
drawBackgroundSprite(-1, -1, direction);
|
|
|
|
_vm->_gyro->dna.dogfoodpos = direction; // We use DogfoodPos here too - why not?
|
2013-06-26 14:14:01 +02:00
|
|
|
}
|
|
|
|
}
|
2013-06-28 17:58:22 +02:00
|
|
|
break;
|
2013-06-30 14:10:33 +02:00
|
|
|
case r__aylesoffice:
|
2013-08-23 11:33:37 +02:00
|
|
|
if ((!_vm->_gyro->dna.ayles_is_awake) && (_vm->_gyro->roomtime % 14 == 0)) {
|
|
|
|
switch ((_vm->_gyro->roomtime / 14) % 2) {
|
2013-06-30 14:10:33 +02:00
|
|
|
case 0:
|
2013-09-03 22:22:42 +02:00
|
|
|
drawBackgroundSprite(-1, -1, 1); // Frame 2: EGA.
|
|
|
|
break;
|
2013-06-30 14:10:33 +02:00
|
|
|
case 1:
|
2013-09-03 22:22:42 +02:00
|
|
|
drawBackgroundSprite(-1, -1, 3); // Frame 1: Natural.
|
|
|
|
break;
|
2013-06-30 14:10:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case r__robins:
|
2013-07-24 18:25:07 +02:00
|
|
|
if (_vm->_gyro->dna.tied_up) {
|
2013-08-23 11:33:37 +02:00
|
|
|
switch (_vm->_gyro->roomtime % 54) {
|
2013-06-30 14:10:33 +02:00
|
|
|
case 20:
|
2013-09-03 22:22:42 +02:00
|
|
|
drawBackgroundSprite(-1, -1, 4); // Frame 4: Avalot blinks.
|
|
|
|
break;
|
2013-06-30 14:10:33 +02:00
|
|
|
case 23:
|
2013-09-03 22:22:42 +02:00
|
|
|
drawBackgroundSprite(-1, -1, 2); // Frame 1: Back to normal.
|
|
|
|
break;
|
2013-06-30 14:10:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2013-09-03 22:22:42 +02:00
|
|
|
case r__nottspub: {
|
|
|
|
// Bearing of Avvy from Port.
|
2013-09-03 22:36:28 +02:00
|
|
|
byte direction;
|
2013-09-03 22:22:42 +02:00
|
|
|
if (((_vm->_lucerna->bearing(5) >= 0) && (_vm->_lucerna->bearing(5) <= 45)) || ((_vm->_lucerna->bearing(5) >= 315) && (_vm->_lucerna->bearing(5) <= 360)))
|
|
|
|
direction = 2; // Middle.
|
|
|
|
else if ((_vm->_lucerna->bearing(5) >= 45) && (_vm->_lucerna->bearing(5) <= 180))
|
|
|
|
direction = 6; // Left.
|
|
|
|
else if ((_vm->_lucerna->bearing(5) >= 181) && (_vm->_lucerna->bearing(5) <= 314))
|
|
|
|
direction = 8; // Right.
|
|
|
|
|
|
|
|
if ((_vm->_gyro->roomtime % 60) > 57)
|
|
|
|
direction--; // Blinks.
|
|
|
|
|
|
|
|
if (direction != _vm->_gyro->dna.dogfoodpos) { // Only if it's changed.
|
|
|
|
drawBackgroundSprite(-1, -1, direction);
|
|
|
|
_vm->_gyro->dna.dogfoodpos = direction; // We use DogfoodPos here too - why not?
|
|
|
|
}
|
2013-06-30 14:10:33 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
switch (_vm->_gyro->roomtime % 50) {
|
|
|
|
case 45 :
|
|
|
|
drawBackgroundSprite(-1, -1, 9); // Spurge blinks.
|
|
|
|
break;
|
|
|
|
case 49 :
|
|
|
|
drawBackgroundSprite(-1, -1, 10);
|
|
|
|
break;
|
|
|
|
}
|
2013-06-30 14:10:33 +02:00
|
|
|
}
|
|
|
|
break;
|
2013-09-03 22:22:42 +02:00
|
|
|
case r__ducks: {
|
|
|
|
if ((_vm->_gyro->roomtime % 3) == 0) // The fire flickers.
|
|
|
|
drawBackgroundSprite(-1, -1, 1 + (_vm->_gyro->roomtime / 3) % 3);
|
2013-06-30 14:10:33 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
// Bearing of Avvy from Duck.
|
2013-09-03 22:36:28 +02:00
|
|
|
byte direction;
|
2013-09-03 22:22:42 +02:00
|
|
|
if (((_vm->_lucerna->bearing(2) >= 0) && (_vm->_lucerna->bearing(2) <= 45)) || ((_vm->_lucerna->bearing(2) >= 315) && (_vm->_lucerna->bearing(2) <= 360)))
|
|
|
|
direction = 4; // Middle.
|
|
|
|
else if ((_vm->_lucerna->bearing(2) >= 45) && (_vm->_lucerna->bearing(2) <= 180))
|
|
|
|
direction = 6; // Left.
|
|
|
|
else if ((_vm->_lucerna->bearing(2) >= 181) && (_vm->_lucerna->bearing(2) <= 314))
|
|
|
|
direction = 8; // Right.
|
2013-06-30 14:10:33 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
if ((_vm->_gyro->roomtime % 45) > 42)
|
|
|
|
direction++; // Duck blinks.
|
2013-06-30 14:10:33 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
if (direction != _vm->_gyro->dna.dogfoodpos) { // Only if it's changed.
|
|
|
|
drawBackgroundSprite(-1, -1, direction);
|
|
|
|
_vm->_gyro->dna.dogfoodpos = direction; // We use DogfoodPos here too - why not?
|
|
|
|
}
|
2013-06-28 17:58:22 +02:00
|
|
|
}
|
2013-06-30 14:10:33 +02:00
|
|
|
break;
|
2013-06-26 14:14:01 +02:00
|
|
|
}
|
|
|
|
|
2013-07-24 18:25:07 +02:00
|
|
|
if ((_vm->_gyro->dna.ringing_bells) && (_vm->_gyro->flagset('B'))) {
|
2013-09-03 22:22:42 +02:00
|
|
|
// They're ringing the bells.
|
2013-08-23 11:33:37 +02:00
|
|
|
switch (_vm->_gyro->roomtime % 4) {
|
2013-06-30 14:10:33 +02:00
|
|
|
case 1:
|
2013-07-24 18:25:07 +02:00
|
|
|
if (_vm->_gyro->dna.nextbell < 5)
|
|
|
|
_vm->_gyro->dna.nextbell = 12;
|
2013-09-03 22:36:28 +02:00
|
|
|
_vm->_gyro->dna.nextbell--;
|
2013-07-24 18:25:07 +02:00
|
|
|
_vm->_gyro->note(_vm->_gyro->notes[_vm->_gyro->dna.nextbell]);
|
2013-06-30 14:10:33 +02:00
|
|
|
break;
|
2013-06-28 17:58:22 +02:00
|
|
|
case 2:
|
2013-09-03 22:22:42 +02:00
|
|
|
//nosound();
|
2013-06-28 17:58:22 +02:00
|
|
|
warning("STUB: Celer::pics_link()");
|
|
|
|
break;
|
|
|
|
}
|
2013-06-26 14:14:01 +02:00
|
|
|
}
|
2013-06-28 17:58:22 +02:00
|
|
|
}
|
2013-06-26 14:14:01 +02:00
|
|
|
|
2013-09-03 22:36:28 +02:00
|
|
|
void Celer::loadBackgroundSprites(byte number) {
|
2013-09-03 22:48:38 +02:00
|
|
|
Common::File f;
|
2013-09-03 22:36:28 +02:00
|
|
|
_filename = _filename.format("chunk%d.avd", number);
|
2013-09-03 22:48:38 +02:00
|
|
|
if (!f.open(_filename)) {
|
2013-09-03 22:22:42 +02:00
|
|
|
warning("AVALANCHE: Celer: File not found: %s", _filename.c_str());
|
2013-07-03 17:06:36 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-03 22:48:38 +02:00
|
|
|
f.seek(44);
|
|
|
|
_chunkNum = f.readByte();
|
2013-09-03 22:22:42 +02:00
|
|
|
for (byte i = 0; i < _chunkNum; i++)
|
2013-09-03 22:48:38 +02:00
|
|
|
_offsets[i] = f.readSint32LE();
|
2013-07-03 17:06:36 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
for (byte i = 0; i < _chunkNum; i++) {
|
2013-09-03 22:48:38 +02:00
|
|
|
f.seek(_offsets[i]);
|
2013-07-03 17:06:36 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
SpriteType sprite;
|
2013-09-03 22:48:38 +02:00
|
|
|
sprite._type = PictureType(f.readByte());
|
|
|
|
sprite._x = f.readSint16LE();
|
|
|
|
sprite._y = f.readSint16LE();
|
|
|
|
sprite._xl = f.readSint16LE();
|
|
|
|
sprite._yl = f.readSint16LE();
|
|
|
|
sprite._size = f.readSint32LE();
|
|
|
|
sprite._natural = f.readByte();
|
|
|
|
sprite._memorise = f.readByte();
|
2013-07-03 17:06:36 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
if (sprite._memorise) {
|
|
|
|
_memos[i]._x = sprite._x;
|
|
|
|
_memos[i]._xl = sprite._xl;
|
|
|
|
_memos[i]._y = sprite._y;
|
|
|
|
_memos[i]._yl = sprite._yl;
|
|
|
|
_memos[i]._type = sprite._type;
|
|
|
|
|
|
|
|
if (sprite._natural) {
|
2013-09-03 22:36:28 +02:00
|
|
|
_memos[i]._type = kNaturalImage; // We simply read from the screen and later, in display_it() we draw it right back.
|
2013-09-03 22:22:42 +02:00
|
|
|
_memos[i]._size = _memos[i]._xl * 8 * _memos[i]._yl + 1;
|
|
|
|
_memory[i].create(_memos[i]._xl * 8, _memos[i]._yl + 1, ::Graphics::PixelFormat::createFormatCLUT8());
|
|
|
|
|
|
|
|
for (uint16 y = 0; y < _memos[i]._yl + 1; y++)
|
|
|
|
for (uint16 x = 0; x < _memos[i]._xl * 8; x++)
|
|
|
|
*(byte *)_memory[i].getBasePtr(x, y) = *_vm->_graphics->getPixel(_memos[i]._x * 8 + x, _memos[i]._y + y);
|
2013-07-25 12:15:15 +02:00
|
|
|
} else {
|
2013-09-03 22:22:42 +02:00
|
|
|
_memos[i]._size = sprite._size;
|
2013-09-03 22:48:38 +02:00
|
|
|
_memory[i] = _vm->_graphics->loadPictureRow(f, _memos[i]._xl * 8, _memos[i]._yl + 1); // Celer::forget_chunks() deallocates it.
|
2013-07-25 12:15:15 +02:00
|
|
|
}
|
2013-07-03 17:06:36 +02:00
|
|
|
} else
|
2013-09-03 22:22:42 +02:00
|
|
|
_memos[i]._x = kOnDisk;
|
2013-07-03 17:06:36 +02:00
|
|
|
}
|
2013-09-03 22:48:38 +02:00
|
|
|
f.close();
|
2013-06-28 17:58:22 +02:00
|
|
|
}
|
2013-06-26 14:14:01 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
void Celer::forgetBackgroundSprites() {
|
|
|
|
for (byte i = 0; i < _chunkNum; i ++)
|
|
|
|
if (_memos[i]._x > kOnDisk)
|
|
|
|
_memory[i].free();
|
2013-07-05 11:32:49 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
memset(_memos, 255, sizeof(_memos)); /* x=-1, => on disk. */
|
2013-06-28 17:58:22 +02:00
|
|
|
}
|
2013-06-26 14:14:01 +02:00
|
|
|
|
2013-09-03 22:36:28 +02:00
|
|
|
void Celer::drawSprite(int16 x, int16 y, int16 xl, int16 yl, PictureType type, const ::Graphics::Surface &picture) {
|
2013-09-03 22:22:42 +02:00
|
|
|
_r.x1 = x;
|
|
|
|
_r.y1 = y;
|
|
|
|
_r.y2 = y + yl;
|
2013-07-26 13:32:08 +02:00
|
|
|
|
2013-09-03 22:36:28 +02:00
|
|
|
switch (type) {
|
|
|
|
case kNaturalImage: // Allow fallthorugh on purpose.
|
2013-09-03 22:22:42 +02:00
|
|
|
case kBgi : {
|
|
|
|
_r.x2 = x + xl + 1;
|
2013-07-25 12:15:15 +02:00
|
|
|
}
|
|
|
|
break;
|
2013-09-03 22:22:42 +02:00
|
|
|
case kEga : {
|
|
|
|
_r.x2 = x + xl;
|
2013-07-25 12:15:15 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-07-26 14:19:54 +02:00
|
|
|
|
2013-08-21 18:01:31 +02:00
|
|
|
// These pictures are practically parts of the background. -10 is for the drop-down menu.
|
2013-08-30 11:56:16 +02:00
|
|
|
_vm->_graphics->drawPicture(_vm->_graphics->_background, picture, x, y - 10);
|
2013-06-28 17:58:22 +02:00
|
|
|
}
|
2013-06-26 14:14:01 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
void Celer::drawBackgroundSprite(int16 destX, int16 destY, byte which) {
|
2013-08-23 11:33:37 +02:00
|
|
|
which--; // For the difference between the Pascal and C array indexes.
|
2013-07-05 12:31:12 +02:00
|
|
|
//setactivepage(3);
|
|
|
|
warning("STUB: Celer::show_one()");
|
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
if (_memos[which]._x > kOnDisk) {
|
|
|
|
if (destX < 0) {
|
|
|
|
destX = _memos[which]._x * 8;
|
|
|
|
destY = _memos[which]._y;
|
2013-08-30 11:56:16 +02:00
|
|
|
}
|
2013-09-03 22:22:42 +02:00
|
|
|
drawSprite(destX, destY, _memos[which]._xl, _memos[which]._yl, _memos[which]._type, _memory[which]);
|
2013-08-30 11:56:16 +02:00
|
|
|
} else {
|
2013-09-03 22:48:38 +02:00
|
|
|
Common::File f;
|
|
|
|
if (!f.open(_filename)) { // Filename was set in loadBackgroundSprites().
|
2013-09-03 22:22:42 +02:00
|
|
|
warning("AVALANCHE: Celer: File not found: %s", _filename.c_str());
|
2013-07-05 12:31:12 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-03 22:48:38 +02:00
|
|
|
f.seek(_offsets[which]);
|
2013-07-05 12:31:12 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
SpriteType sprite;
|
2013-09-03 22:48:38 +02:00
|
|
|
sprite._type = PictureType(f.readByte());
|
|
|
|
sprite._x = f.readSint16LE();
|
|
|
|
sprite._y = f.readSint16LE();
|
|
|
|
sprite._xl = f.readSint16LE();
|
|
|
|
sprite._yl = f.readSint16LE();
|
|
|
|
sprite._size = f.readSint32LE();
|
|
|
|
sprite._natural = f.readByte();
|
|
|
|
sprite._memorise = f.readByte();
|
2013-07-05 12:31:12 +02:00
|
|
|
|
2013-09-03 22:48:38 +02:00
|
|
|
::Graphics::Surface picture = _vm->_graphics->loadPictureRow(f, sprite._xl * 8, sprite._yl + 1);
|
2013-07-05 12:31:12 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
if (destX < 0) {
|
|
|
|
destX = sprite._x * 8;
|
|
|
|
destY = sprite._y;
|
2013-08-30 11:56:16 +02:00
|
|
|
}
|
2013-09-03 22:22:42 +02:00
|
|
|
drawSprite(destX, destY, sprite._xl, sprite._yl, sprite._type, picture);
|
2013-07-05 12:31:12 +02:00
|
|
|
|
2013-07-26 14:19:54 +02:00
|
|
|
picture.free();
|
2013-09-03 22:48:38 +02:00
|
|
|
f.close();
|
2013-07-05 12:31:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//setactivepage(1 - cp);
|
2013-06-28 17:58:22 +02:00
|
|
|
warning("STUB: Celer::show_one()");
|
2013-07-05 12:31:12 +02:00
|
|
|
|
2013-09-03 22:22:42 +02:00
|
|
|
for (byte i = 0; i < 2; i ++)
|
|
|
|
_vm->_trip->getset[i].remember(_r);
|
2013-06-28 17:58:22 +02:00
|
|
|
}
|
2013-06-26 14:14:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // End of namespace Avalanche.
|