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
|
|
|
|
|
|
|
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 23:41:15 +02:00
|
|
|
_spriteNum = 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() {
|
2013-09-03 23:41:15 +02:00
|
|
|
forgetBackgroundSprites();
|
2013-07-26 14:19:54 +02:00
|
|
|
}
|
|
|
|
|
2013-09-04 13:28:15 +02:00
|
|
|
/**
|
|
|
|
* @remarks Originally called 'pics_link'
|
|
|
|
*/
|
2013-09-04 09:25:11 +02:00
|
|
|
void Celer::updateBackgroundSprites() {
|
2013-09-06 16:23:57 +02:00
|
|
|
if (_vm->_gyro->_dropdownActive)
|
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-09-06 16:23:57 +02:00
|
|
|
switch (_vm->_gyro->_dna._room) {
|
2013-06-30 14:10:33 +02:00
|
|
|
case r__outsideargentpub:
|
2013-09-06 16:23:57 +02:00
|
|
|
if ((_vm->_gyro->_roomTime % 12) == 0)
|
|
|
|
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-09-06 16:23:57 +02:00
|
|
|
if ((_vm->_gyro->_roomTime % 2) == 0)
|
|
|
|
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-09-06 16:23:57 +02:00
|
|
|
if ((_vm->_gyro->_roomTime % 2) == 0)
|
|
|
|
drawBackgroundSprite(-1, -1, 4 + (_vm->_gyro->_roomTime / 2) % 4);
|
2013-06-30 14:10:33 +02:00
|
|
|
break;
|
|
|
|
case r__yours:
|
2013-09-06 16:23:57 +02:00
|
|
|
if ((!_vm->_gyro->_dna._avvyIsAwake) && ((_vm->_gyro->_roomTime % 4) == 0))
|
|
|
|
drawBackgroundSprite(-1, -1, 1 + (_vm->_gyro->_roomTime / 12) % 2);
|
2013-06-30 14:10:33 +02:00
|
|
|
break;
|
2013-09-04 16:10:48 +02:00
|
|
|
case r__argentpub:
|
2013-09-06 16:23:57 +02:00
|
|
|
if (((_vm->_gyro->_roomTime % 7) == 1) && (_vm->_gyro->_dna._malagauche != 177)) {
|
2013-09-04 16:10:48 +02:00
|
|
|
// Malagauche cycle.
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_dna._malagauche += 1;
|
|
|
|
switch (_vm->_gyro->_dna._malagauche) {
|
2013-09-04 16:10:48 +02:00
|
|
|
case 1:
|
|
|
|
case 11:
|
|
|
|
case 21:
|
|
|
|
drawBackgroundSprite(-1, -1, 12); // Looks forwards.
|
2013-09-07 09:00:34 +02:00
|
|
|
break;
|
2013-09-04 16:10:48 +02:00
|
|
|
case 8:
|
|
|
|
case 18:
|
|
|
|
case 28:
|
|
|
|
case 32:
|
|
|
|
drawBackgroundSprite(-1, -1, 11); // Looks at you.
|
2013-09-07 09:00:34 +02:00
|
|
|
break;
|
2013-09-04 16:10:48 +02:00
|
|
|
case 30:
|
|
|
|
drawBackgroundSprite(-1, -1, 13); // Winks.
|
2013-09-07 09:00:34 +02:00
|
|
|
break;
|
2013-09-04 16:10:48 +02:00
|
|
|
case 33:
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_dna._malagauche = 0;
|
2013-09-04 16:10:48 +02:00
|
|
|
break;
|
2013-06-28 17:58:22 +02:00
|
|
|
}
|
2013-09-04 16:10:48 +02:00
|
|
|
}
|
2013-06-26 14:14:01 +02:00
|
|
|
|
2013-09-06 16:23:57 +02:00
|
|
|
switch (_vm->_gyro->_roomTime % 200) {
|
2013-09-04 16:10:48 +02:00
|
|
|
case 179:
|
|
|
|
case 197:
|
|
|
|
drawBackgroundSprite(-1, -1, 5); // Dogfood's drinking cycle.
|
2013-09-07 09:00:34 +02:00
|
|
|
break;
|
2013-09-04 16:10:48 +02:00
|
|
|
case 182:
|
|
|
|
case 194:
|
|
|
|
drawBackgroundSprite(-1, -1, 6);
|
|
|
|
break;
|
|
|
|
case 185:
|
|
|
|
drawBackgroundSprite(-1, -1, 7);
|
|
|
|
break;
|
|
|
|
case 199:
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_dna._dogFoodPos = 177; // Impossible value for this.
|
2013-09-07 09:00:34 +02:00
|
|
|
break;
|
2013-09-04 16:10:48 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 16:23:57 +02:00
|
|
|
if ((_vm->_gyro->_roomTime % 200 >= 0) && (_vm->_gyro->_roomTime % 200 <= 178)) { // Normally.
|
2013-09-04 16:10:48 +02:00
|
|
|
byte direction = 0;
|
|
|
|
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;
|
|
|
|
|
2013-09-06 16:23:57 +02:00
|
|
|
if (direction != _vm->_gyro->_dna._dogFoodPos) { // Only if it's changed.
|
2013-09-04 16:10:48 +02:00
|
|
|
drawBackgroundSprite(-1, -1, direction);
|
2013-09-06 16:23:57 +02:00
|
|
|
_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-09-06 16:23:57 +02:00
|
|
|
if ((_vm->_gyro->_roomTime % 3) == 0) {
|
|
|
|
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-09-06 16:23:57 +02:00
|
|
|
if (!(_vm->_gyro->_dna._lustieIsAsleep)) {
|
2013-09-04 13:28:15 +02:00
|
|
|
byte direction = 0;
|
2013-09-04 18:34:58 +02:00
|
|
|
uint16 angle = _vm->_lucerna->bearing(2);
|
2013-09-06 16:23:57 +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-09-04 18:34:58 +02:00
|
|
|
else if ((angle <= 45) || ((angle >= 315) && (angle <= 360)))
|
2013-09-03 22:22:42 +02:00
|
|
|
direction = 1; // Middle.
|
2013-09-04 18:34:58 +02:00
|
|
|
else if ((angle >= 45) && (angle <= 180))
|
2013-09-03 22:22:42 +02:00
|
|
|
direction = 2; // Left.
|
2013-09-04 18:34:58 +02:00
|
|
|
else if ((angle >= 181) && (angle <= 314))
|
2013-09-03 22:22:42 +02:00
|
|
|
direction = 3; // Right.
|
2013-06-28 17:58:22 +02:00
|
|
|
|
2013-09-06 16:23:57 +02:00
|
|
|
if (direction != _vm->_gyro->_dna._dogFoodPos) { // Only if it's changed.
|
2013-09-03 22:22:42 +02:00
|
|
|
drawBackgroundSprite(-1, -1, direction);
|
2013-09-06 16:23:57 +02:00
|
|
|
_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-09-06 16:23:57 +02:00
|
|
|
if ((!_vm->_gyro->_dna._aylesIsAwake) && (_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.
|
2013-09-07 09:00:34 +02:00
|
|
|
break;
|
2013-06-30 14:10:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case r__robins:
|
2013-09-06 16:23:57 +02:00
|
|
|
if (_vm->_gyro->_dna._tiedUp) {
|
|
|
|
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.
|
2013-09-07 09:00:34 +02:00
|
|
|
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.
|
2013-09-07 09:00:34 +02:00
|
|
|
break;
|
2013-06-30 14:10:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2013-09-03 22:22:42 +02:00
|
|
|
case r__nottspub: {
|
2013-09-04 13:28:15 +02:00
|
|
|
// Bearing of Avvy from Port.
|
|
|
|
byte direction = 0;
|
2013-09-04 18:34:58 +02:00
|
|
|
uint16 angle = _vm->_lucerna->bearing(5);
|
|
|
|
if ((angle <= 45) || ((angle >= 315) && (angle <= 360)))
|
2013-09-04 13:28:15 +02:00
|
|
|
direction = 2; // Middle.
|
2013-09-04 18:34:58 +02:00
|
|
|
else if ((angle >= 45) && (angle <= 180))
|
2013-09-04 13:28:15 +02:00
|
|
|
direction = 6; // Left.
|
2013-09-04 18:34:58 +02:00
|
|
|
else if ((angle >= 181) && (angle <= 314))
|
2013-09-04 13:28:15 +02:00
|
|
|
direction = 8; // Right.
|
|
|
|
|
2013-09-06 16:23:57 +02:00
|
|
|
if ((_vm->_gyro->_roomTime % 60) > 57)
|
2013-09-04 13:28:15 +02:00
|
|
|
direction--; // Blinks.
|
|
|
|
|
2013-09-06 16:23:57 +02:00
|
|
|
if (direction != _vm->_gyro->_dna._dogFoodPos) { // Only if it's changed.
|
2013-09-04 13:28:15 +02:00
|
|
|
drawBackgroundSprite(-1, -1, direction);
|
2013-09-06 16:23:57 +02:00
|
|
|
_vm->_gyro->_dna._dogFoodPos = direction; // We use DogfoodPos here too - why not?
|
2013-09-04 13:28:15 +02:00
|
|
|
}
|
2013-06-30 14:10:33 +02:00
|
|
|
|
2013-09-06 16:23:57 +02:00
|
|
|
switch (_vm->_gyro->_roomTime % 50) {
|
2013-09-04 13:28:15 +02:00
|
|
|
case 45 :
|
|
|
|
drawBackgroundSprite(-1, -1, 9); // Spurge blinks.
|
2013-09-07 09:00:34 +02:00
|
|
|
break;
|
2013-09-04 13:28:15 +02:00
|
|
|
case 49 :
|
|
|
|
drawBackgroundSprite(-1, -1, 10);
|
|
|
|
break;
|
2013-06-30 14:10:33 +02:00
|
|
|
}
|
|
|
|
break;
|
2013-09-04 13:28:15 +02:00
|
|
|
}
|
2013-09-03 22:22:42 +02:00
|
|
|
case r__ducks: {
|
2013-09-06 16:23:57 +02:00
|
|
|
if ((_vm->_gyro->_roomTime % 3) == 0) // The fire flickers.
|
|
|
|
drawBackgroundSprite(-1, -1, 1 + (_vm->_gyro->_roomTime / 3) % 3);
|
2013-09-04 13:28:15 +02:00
|
|
|
|
|
|
|
// Bearing of Avvy from Duck.
|
|
|
|
byte direction = 0;
|
2013-09-04 18:34:58 +02:00
|
|
|
uint16 angle = _vm->_lucerna->bearing(2);
|
|
|
|
if ((angle <= 45) || ((angle >= 315) && (angle <= 360)))
|
2013-09-04 13:28:15 +02:00
|
|
|
direction = 4; // Middle.
|
2013-09-04 18:34:58 +02:00
|
|
|
else if ((angle >= 45) && (angle <= 180))
|
2013-09-04 13:28:15 +02:00
|
|
|
direction = 6; // Left.
|
2013-09-04 18:34:58 +02:00
|
|
|
else if ((angle >= 181) && (angle <= 314))
|
2013-09-04 13:28:15 +02:00
|
|
|
direction = 8; // Right.
|
|
|
|
|
2013-09-06 16:23:57 +02:00
|
|
|
if ((_vm->_gyro->_roomTime % 45) > 42)
|
2013-09-04 13:28:15 +02:00
|
|
|
direction++; // Duck blinks.
|
|
|
|
|
2013-09-06 16:23:57 +02:00
|
|
|
if (direction != _vm->_gyro->_dna._dogFoodPos) { // Only if it's changed.
|
2013-09-04 13:28:15 +02:00
|
|
|
drawBackgroundSprite(-1, -1, direction);
|
2013-09-06 16:23:57 +02:00
|
|
|
_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-09-04 13:28:15 +02:00
|
|
|
}
|
2013-06-26 14:14:01 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 16:23:57 +02:00
|
|
|
if ((_vm->_gyro->_dna._bellsAreRinging) && (_vm->_gyro->setFlag('B'))) {
|
2013-09-03 22:22:42 +02:00
|
|
|
// They're ringing the bells.
|
2013-09-06 16:23:57 +02:00
|
|
|
switch (_vm->_gyro->_roomTime % 4) {
|
2013-06-30 14:10:33 +02:00
|
|
|
case 1:
|
2013-09-06 16:23:57 +02:00
|
|
|
if (_vm->_gyro->_dna._nextBell < 5)
|
|
|
|
_vm->_gyro->_dna._nextBell = 12;
|
|
|
|
_vm->_gyro->_dna._nextBell--;
|
|
|
|
_vm->_gyro->note(_vm->_gyro->kNotes[_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-09-04 13:29:18 +02:00
|
|
|
updateBackgroundSprites();
|
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
|
|
|
}
|
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);
|
2013-09-03 23:41:15 +02:00
|
|
|
_spriteNum = f.readByte();
|
|
|
|
for (byte i = 0; i < _spriteNum; i++)
|
2013-09-03 22:48:38 +02:00
|
|
|
_offsets[i] = f.readSint32LE();
|
2013-07-03 17:06:36 +02:00
|
|
|
|
2013-09-03 23:41:15 +02:00
|
|
|
for (byte i = 0; i < _spriteNum; i++) {
|
2013-09-03 22:48:38 +02:00
|
|
|
f.seek(_offsets[i]);
|
2013-09-07 09:00:34 +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();
|
2013-09-03 23:41:15 +02:00
|
|
|
bool natural = f.readByte();
|
2013-09-04 10:14:12 +02:00
|
|
|
bool memorize = f.readByte();
|
2013-09-07 09:00:34 +02:00
|
|
|
|
2013-09-04 10:14:12 +02:00
|
|
|
if (memorize) {
|
2013-09-03 23:41:15 +02:00
|
|
|
_sprites[i]._x = sprite._x;
|
|
|
|
_sprites[i]._xl = sprite._xl;
|
|
|
|
_sprites[i]._y = sprite._y;
|
|
|
|
_sprites[i]._yl = sprite._yl;
|
|
|
|
_sprites[i]._type = sprite._type;
|
|
|
|
|
|
|
|
if (natural) {
|
2013-09-03 23:56:37 +02:00
|
|
|
_sprites[i]._type = kNaturalImage; // We simply read from the screen and later, in drawSprite() we draw it right back.
|
2013-09-07 09:00:34 +02:00
|
|
|
_sprites[i]._size = _sprites[i]._xl * 8 * _sprites[i]._yl + 1;
|
2013-09-03 23:41:15 +02:00
|
|
|
_sprites[i]._picture.create(_sprites[i]._xl * 8, _sprites[i]._yl + 1, ::Graphics::PixelFormat::createFormatCLUT8());
|
|
|
|
|
2013-09-04 16:10:48 +02:00
|
|
|
for (uint16 y = 0; y < _sprites[i]._yl + 1; y++) {
|
2013-09-03 23:41:15 +02:00
|
|
|
for (uint16 x = 0; x < _sprites[i]._xl * 8; x++)
|
2013-09-05 13:20:03 +02:00
|
|
|
*(byte *)_sprites[i]._picture.getBasePtr(x, y) = *(byte *)_vm->_graphics->_surface.getBasePtr(_sprites[i]._x * 8 + x, _sprites[i]._y + y);
|
2013-09-04 16:10:48 +02:00
|
|
|
}
|
2013-07-25 12:15:15 +02:00
|
|
|
} else {
|
2013-09-03 23:41:15 +02:00
|
|
|
_sprites[i]._size = sprite._size;
|
2013-09-03 23:56:37 +02:00
|
|
|
_sprites[i]._picture = _vm->_graphics->loadPictureRow(f, _sprites[i]._xl * 8, _sprites[i]._yl + 1);
|
2013-07-25 12:15:15 +02:00
|
|
|
}
|
2013-07-03 17:06:36 +02:00
|
|
|
} else
|
2013-09-03 23:41:15 +02:00
|
|
|
_sprites[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() {
|
2013-09-04 16:10:48 +02:00
|
|
|
for (byte i = 0; i < _spriteNum; i++) {
|
2013-09-03 23:41:15 +02:00
|
|
|
if (_sprites[i]._x > kOnDisk)
|
|
|
|
_sprites[i]._picture.free();
|
2013-09-04 16:10:48 +02:00
|
|
|
}
|
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 23:41:15 +02:00
|
|
|
if (_sprites[which]._x > kOnDisk) {
|
2013-09-03 22:22:42 +02:00
|
|
|
if (destX < 0) {
|
2013-09-03 23:41:15 +02:00
|
|
|
destX = _sprites[which]._x * 8;
|
|
|
|
destY = _sprites[which]._y;
|
2013-08-30 11:56:16 +02:00
|
|
|
}
|
2013-09-03 23:41:15 +02:00
|
|
|
drawSprite(destX, destY, _sprites[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();
|
2013-09-04 10:14:12 +02:00
|
|
|
f.skip(2); // For the now not existing natural and memorize data members of the SpriteType (called chunkblocktype in the original).
|
2013-09-03 23:41:15 +02:00
|
|
|
sprite._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 23:41:15 +02:00
|
|
|
drawSprite(destX, destY, sprite);
|
2013-07-05 12:31:12 +02:00
|
|
|
|
2013-09-05 12:31:29 +02:00
|
|
|
sprite._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-04 13:34:58 +02:00
|
|
|
for (byte i = 0; i < 2; i++)
|
2013-09-03 22:22:42 +02:00
|
|
|
_vm->_trip->getset[i].remember(_r);
|
2013-06-28 17:58:22 +02:00
|
|
|
}
|
2013-06-26 14:14:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-09-05 10:51:47 +02:00
|
|
|
void Celer::drawSprite(int16 x, int16 y, SpriteType &sprite) {
|
2013-09-06 16:23:57 +02:00
|
|
|
_r._x1 = x;
|
|
|
|
_r._y1 = y;
|
|
|
|
_r._y2 = y + sprite._yl;
|
2013-09-03 23:41:15 +02:00
|
|
|
|
|
|
|
switch (sprite._type) {
|
2013-09-04 16:10:48 +02:00
|
|
|
case kNaturalImage: // Allow fallthrough on purpose.
|
2013-09-03 23:41:15 +02:00
|
|
|
case kBgi:
|
2013-09-06 16:23:57 +02:00
|
|
|
_r._x2 = x + sprite._xl + 1;
|
2013-09-03 23:41:15 +02:00
|
|
|
break;
|
|
|
|
case kEga:
|
2013-09-06 16:23:57 +02:00
|
|
|
_r._x2 = x + sprite._xl;
|
2013-09-03 23:41:15 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// These pictures are practically parts of the background. -10 is for the drop-down menu.
|
|
|
|
_vm->_graphics->drawPicture(_vm->_graphics->_background, sprite._picture, x, y - 10);
|
|
|
|
}
|
|
|
|
|
2013-06-26 14:14:01 +02:00
|
|
|
} // End of namespace Avalanche.
|