2003-10-01 17:57:09 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 16:09:25 +00:00
|
|
|
* Copyright (C) 2003-2005 The ScummVM project
|
2003-10-01 17:57:09 +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
2003-10-23 18:50:47 +00:00
|
|
|
#include "queen/cutaway.h"
|
2003-12-11 22:16:35 +00:00
|
|
|
|
2004-01-08 14:10:32 +00:00
|
|
|
#include "queen/bankman.h"
|
2003-10-23 18:50:47 +00:00
|
|
|
#include "queen/display.h"
|
|
|
|
#include "queen/graphics.h"
|
2004-01-08 14:10:32 +00:00
|
|
|
#include "queen/grid.h"
|
2003-10-23 18:50:47 +00:00
|
|
|
#include "queen/input.h"
|
2003-12-01 20:48:41 +00:00
|
|
|
#include "queen/logic.h"
|
2003-12-11 22:16:35 +00:00
|
|
|
#include "queen/queen.h"
|
2003-12-01 20:48:41 +00:00
|
|
|
#include "queen/resource.h"
|
2003-10-23 18:50:47 +00:00
|
|
|
#include "queen/sound.h"
|
|
|
|
#include "queen/talk.h"
|
|
|
|
#include "queen/walk.h"
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2003-10-03 19:47:41 +00:00
|
|
|
namespace Queen {
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
void Cutaway::run(
|
2003-10-01 17:57:09 +00:00
|
|
|
const char *filename,
|
2003-10-02 11:07:43 +00:00
|
|
|
char *nextFilename,
|
2003-12-11 22:16:35 +00:00
|
|
|
QueenEngine *vm) {
|
|
|
|
Cutaway *cutaway = new Cutaway(filename, vm);
|
2003-10-02 11:07:43 +00:00
|
|
|
cutaway->run(nextFilename);
|
2003-10-01 17:57:09 +00:00
|
|
|
delete cutaway;
|
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
Cutaway::Cutaway(
|
2003-10-01 17:57:09 +00:00
|
|
|
const char *filename,
|
2003-12-11 22:16:35 +00:00
|
|
|
QueenEngine *vm)
|
|
|
|
: _vm(vm), _personDataCount(0), _personFaceCount(0), _lastSong(0), _songBeforeComic(0) {
|
2003-10-02 11:07:43 +00:00
|
|
|
memset(&_bankNames, 0, sizeof(_bankNames));
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->cutawayQuitReset();
|
2003-10-07 03:58:44 +00:00
|
|
|
load(filename);
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
Cutaway::~Cutaway() {
|
2003-10-01 17:57:09 +00:00
|
|
|
delete[] _fileData;
|
|
|
|
}
|
|
|
|
|
2003-10-07 03:58:44 +00:00
|
|
|
void Cutaway::load(const char *filename) {
|
2003-10-01 17:57:09 +00:00
|
|
|
byte *ptr;
|
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "----- Cutaway::load(\"%s\") -----", filename);
|
2003-10-12 19:16:48 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
ptr = _fileData = _vm->resource()->loadFile(filename, 20);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2003-10-03 07:45:41 +00:00
|
|
|
if (0 == scumm_stricmp(filename, "comic.cut"))
|
2004-02-27 23:54:13 +00:00
|
|
|
_songBeforeComic = _vm->sound()->lastOverride();
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2003-10-01 17:57:09 +00:00
|
|
|
strcpy(_basename, filename);
|
|
|
|
_basename[strlen(_basename)-4] = '\0';
|
|
|
|
|
2003-10-14 12:37:07 +00:00
|
|
|
_comPanel = READ_BE_UINT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "_comPanel = %i", _comPanel);
|
2004-03-23 20:34:19 +00:00
|
|
|
_cutawayObjectCount = (int16)READ_BE_INT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
2004-03-23 20:34:19 +00:00
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "_cutawayObjectCount = %i", _cutawayObjectCount);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
if (_cutawayObjectCount < 0) {
|
|
|
|
_cutawayObjectCount = -_cutawayObjectCount;
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->canQuit(false);
|
2004-10-08 18:43:24 +00:00
|
|
|
} else
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->canQuit(true);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
int16 flags1 = (int16)READ_BE_INT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "flags1 = %i", flags1);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
if (flags1 < 0) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->entryObj(0);
|
2003-10-01 17:57:09 +00:00
|
|
|
_finalRoom = -flags1;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else
|
2003-10-01 17:57:09 +00:00
|
|
|
_finalRoom = PREVIOUS_ROOM;
|
|
|
|
|
2003-10-02 11:07:43 +00:00
|
|
|
_anotherCutaway = (flags1 == 1);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "[Cutaway::load] _finalRoom = %i", _finalRoom);
|
|
|
|
debug(6, "[Cutaway::load] _anotherCutaway = %i", _anotherCutaway);
|
2003-11-06 08:44:33 +00:00
|
|
|
|
2003-10-01 17:57:09 +00:00
|
|
|
/*
|
|
|
|
Pointers to other places in the cutaway data
|
|
|
|
*/
|
|
|
|
|
2004-08-24 16:31:46 +00:00
|
|
|
_gameStatePtr = _fileData + READ_BE_UINT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
|
|
|
|
2004-08-24 16:31:46 +00:00
|
|
|
_nextSentenceOff = READ_BE_UINT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
|
|
|
|
2004-08-24 16:31:46 +00:00
|
|
|
uint16 bankNamesOff = READ_BE_UINT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
|
|
|
|
|
|
|
_objectData = ptr;
|
|
|
|
|
2004-08-24 16:31:46 +00:00
|
|
|
loadStrings(bankNamesOff);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
if (_bankNames[0][0]) {
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Loading bank '%s'", _bankNames[0]);
|
2004-01-05 13:40:28 +00:00
|
|
|
_vm->bankMan()->load(_bankNames[0], CUTAWAY_BANK);
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char entryString[MAX_STRING_SIZE];
|
2004-08-24 16:31:46 +00:00
|
|
|
Talk::getString(_fileData, _nextSentenceOff, entryString, MAX_STRING_LENGTH);
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Entry string = '%s'", entryString);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->joeCutFacing(_vm->logic()->joeFacing());
|
|
|
|
_vm->logic()->joeFace();
|
2003-12-10 15:36:44 +00:00
|
|
|
|
2003-10-01 17:57:09 +00:00
|
|
|
if (entryString[0] == '*' &&
|
|
|
|
entryString[1] == 'F' &&
|
|
|
|
entryString[3] == '\0') {
|
|
|
|
switch (entryString[2]) {
|
2004-10-08 18:43:24 +00:00
|
|
|
case 'L':
|
|
|
|
_vm->logic()->joeCutFacing(DIR_LEFT);
|
|
|
|
break;
|
|
|
|
case 'R':
|
|
|
|
_vm->logic()->joeCutFacing(DIR_RIGHT);
|
|
|
|
break;
|
|
|
|
case 'F':
|
|
|
|
_vm->logic()->joeCutFacing(DIR_FRONT);
|
|
|
|
break;
|
|
|
|
case 'B':
|
|
|
|
_vm->logic()->joeCutFacing(DIR_BACK);
|
|
|
|
break;
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-08-24 16:31:46 +00:00
|
|
|
void Cutaway::loadStrings(uint16 offset) {
|
|
|
|
int bankNameCount = READ_BE_UINT16(_fileData + offset);
|
|
|
|
offset += 2;
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2004-08-06 11:28:33 +00:00
|
|
|
debug(6, "Bank name count = %i", bankNameCount);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
The _bankNames zero-based array is the one-based BANK_NAMEstr array in
|
|
|
|
the original source code.
|
|
|
|
*/
|
|
|
|
|
2005-05-09 18:25:28 +00:00
|
|
|
for (int i = 0, j = 0; i < bankNameCount; i++) {
|
2004-08-24 16:31:46 +00:00
|
|
|
Talk::getString(_fileData, offset, _bankNames[j], MAX_FILENAME_LENGTH);
|
2003-10-01 17:57:09 +00:00
|
|
|
if (_bankNames[j][0]) {
|
2004-08-06 11:28:33 +00:00
|
|
|
debug(6, "Bank name %i = '%s'", j, _bankNames[j]);
|
2003-10-01 17:57:09 +00:00
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Getting talk file");
|
2004-08-24 16:31:46 +00:00
|
|
|
Talk::getString(_fileData, offset, _talkFile, MAX_FILENAME_LENGTH);
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Talk file = '%s'", _talkFile);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2004-08-24 16:31:46 +00:00
|
|
|
_talkTo = (int16)READ_BE_INT16(_fileData + offset);
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "_talkTo = %i", _talkTo);
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
2004-08-24 16:31:46 +00:00
|
|
|
const byte *Cutaway::getCutawayObject(const byte *ptr, CutawayObject &object)
|
2003-10-01 17:57:09 +00:00
|
|
|
{
|
2004-08-24 16:31:46 +00:00
|
|
|
const byte *oldPtr = ptr;
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2004-08-14 22:33:13 +00:00
|
|
|
object.objectNumber = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2004-03-23 20:34:19 +00:00
|
|
|
object.moveToX = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
object.moveToY = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2004-08-14 22:33:13 +00:00
|
|
|
object.bank = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
object.animList = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
object.execute = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2004-03-23 20:34:19 +00:00
|
|
|
object.limitBobX1 = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
object.limitBobY1 = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
object.limitBobX2 = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
object.limitBobY2 = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2004-08-14 22:33:13 +00:00
|
|
|
object.specialMove = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
object.animType = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
object.fromObject = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2004-03-23 20:34:19 +00:00
|
|
|
object.bobStartX = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
object.bobStartY = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2004-08-14 22:33:13 +00:00
|
|
|
object.room = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
object.scale = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
if ((ptr - oldPtr) != 17*sizeof(int16))
|
|
|
|
error("Wrong number of values read");
|
|
|
|
|
|
|
|
// Make ugly reuse of data less ugly
|
2003-10-15 10:01:54 +00:00
|
|
|
if (object.limitBobX1 < 0) {
|
2003-10-01 17:57:09 +00:00
|
|
|
object.song = -object.limitBobX1;
|
2003-10-15 10:01:54 +00:00
|
|
|
object.limitBobX1 = 0;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else
|
2003-10-01 17:57:09 +00:00
|
|
|
object.song = 0;
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
void Cutaway::dumpCutawayObject(int index, CutawayObject &object)
|
2003-10-01 17:57:09 +00:00
|
|
|
{
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "----- CutawayObject[%i] -----", index);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
const char *objectNumberStr;
|
|
|
|
|
|
|
|
switch (object.objectNumber) {
|
2004-10-08 18:43:24 +00:00
|
|
|
case -1:
|
|
|
|
objectNumberStr = "MESSAGE";
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
objectNumberStr = "Joe";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (object.objectNumber > 0)
|
|
|
|
objectNumberStr = _vm->logic()->objectName(ABS(_vm->logic()->objectData(object.objectNumber)->name));
|
|
|
|
else
|
|
|
|
objectNumberStr = "Unknown!";
|
|
|
|
break;
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "objectNumber = %i (%s)", object.objectNumber, objectNumberStr);
|
|
|
|
|
|
|
|
if (object.moveToX) debug(6, "moveToX = %i", object.moveToX);
|
|
|
|
if (object.moveToY) debug(6, "moveToY = %i", object.moveToY);
|
|
|
|
if (object.bank) debug(6, "bank = %i", object.bank);
|
|
|
|
if (object.animList) debug(6, "animList = %i", object.animList);
|
|
|
|
if (object.execute) debug(6, "execute = %i", object.execute);
|
|
|
|
if (object.limitBobX1) debug(6, "limitBobX1 = %i", object.limitBobX1);
|
|
|
|
if (object.limitBobY1) debug(6, "limitBobY1 = %i", object.limitBobY1);
|
|
|
|
if (object.limitBobX2) debug(6, "limitBobX2 = %i", object.limitBobX2);
|
|
|
|
if (object.limitBobY2) debug(6, "limitBobY2 = %i", object.limitBobY2);
|
|
|
|
if (object.specialMove) debug(6, "specialMove = %i", object.specialMove);
|
|
|
|
if (object.animType) debug(6, "animType = %i", object.animType);
|
|
|
|
if (object.fromObject) debug(6, "fromObject = %i", object.fromObject);
|
|
|
|
if (object.bobStartX) debug(6, "bobStartX = %i", object.bobStartX);
|
|
|
|
if (object.bobStartY) debug(6, "bobStartY = %i", object.bobStartY);
|
|
|
|
if (object.room) debug(6, "room = %i", object.room);
|
|
|
|
if (object.scale) debug(6, "scale = %i", object.scale);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-24 16:31:46 +00:00
|
|
|
const byte *Cutaway::turnOnPeople(const byte *ptr, CutawayObject &object) {
|
2003-10-01 17:57:09 +00:00
|
|
|
// Lines 1248-1259 in cutaway.c
|
2004-03-23 20:34:19 +00:00
|
|
|
object.personCount = (int16)READ_BE_INT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
|
|
|
|
|
|
|
if (object.personCount > MAX_PERSON_COUNT)
|
2003-10-05 16:07:07 +00:00
|
|
|
error("[Cutaway::turnOnPeople] object.personCount > MAX_PERSON_COUNT");
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < object.personCount; i++) {
|
2004-03-23 20:34:19 +00:00
|
|
|
object.person[i] = (int16)READ_BE_INT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
2004-08-06 11:28:33 +00:00
|
|
|
debug(7, "[%i] Turn on person %i", i, object.person[i]);
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
void Cutaway::limitBob(CutawayObject &object) {
|
2003-10-01 17:57:09 +00:00
|
|
|
if (object.limitBobX1) {
|
2003-10-03 12:55:11 +00:00
|
|
|
|
|
|
|
if (object.objectNumber < 0) {
|
|
|
|
warning("QueenCutaway::limitBob called with objectNumber = %i", object.objectNumber);
|
|
|
|
return;
|
|
|
|
}
|
2003-10-12 19:16:48 +00:00
|
|
|
|
2003-10-03 12:55:11 +00:00
|
|
|
BobSlot *bob =
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bob( _vm->logic()->findBob(object.objectNumber) );
|
2003-10-03 12:55:11 +00:00
|
|
|
|
|
|
|
if (!bob) {
|
|
|
|
warning("Failed to find bob");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bob->box.x1 = object.limitBobX1;
|
|
|
|
bob->box.y1 = object.limitBobY1;
|
|
|
|
bob->box.x2 = object.limitBobX2;
|
|
|
|
bob->box.y2 = object.limitBobY2;
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
void Cutaway::restorePersonData() {
|
2003-10-02 11:07:43 +00:00
|
|
|
for (int i = 0; i < _personDataCount; i++) {
|
|
|
|
int index = _personData[i].index;
|
2003-12-11 22:16:35 +00:00
|
|
|
ObjectData *objectData = _vm->logic()->objectData(index);
|
2003-10-03 12:55:11 +00:00
|
|
|
objectData->name = _personData[i].name;
|
|
|
|
objectData->image = _personData[i].image;
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
void Cutaway::changeRooms(CutawayObject &object) {
|
2003-10-01 17:57:09 +00:00
|
|
|
// Lines 1291-1385 in cutaway.c
|
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Changing from room %i to room %i",
|
2003-10-14 12:37:07 +00:00
|
|
|
_temporaryRoom,
|
|
|
|
object.room);
|
|
|
|
|
2003-10-02 11:07:43 +00:00
|
|
|
restorePersonData();
|
|
|
|
_personDataCount = 0;
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
if (_finalRoom != object.room) {
|
2003-12-11 22:16:35 +00:00
|
|
|
int firstObjectInRoom = _vm->logic()->roomData(object.room) + 1;
|
2004-01-08 14:10:32 +00:00
|
|
|
int lastObjectInRoom = _vm->logic()->roomData(object.room) + _vm->grid()->objMax(object.room);
|
2003-10-02 11:07:43 +00:00
|
|
|
|
|
|
|
for (int i = firstObjectInRoom; i <= lastObjectInRoom; i++) {
|
2003-12-11 22:16:35 +00:00
|
|
|
ObjectData *objectData = _vm->logic()->objectData(i);
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2003-10-03 12:55:11 +00:00
|
|
|
if (objectData->image == -3 || objectData->image == -4) {
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2004-01-14 15:51:54 +00:00
|
|
|
assert(_personDataCount < MAX_PERSON_COUNT);
|
2003-10-02 11:07:43 +00:00
|
|
|
// The object is a person! So record the details...
|
|
|
|
_personData[_personDataCount].index = i;
|
2003-10-03 12:55:11 +00:00
|
|
|
_personData[_personDataCount].name = objectData->name;
|
|
|
|
_personData[_personDataCount].image = objectData->image;
|
2003-10-02 11:07:43 +00:00
|
|
|
_personDataCount++;
|
|
|
|
|
2003-10-14 12:37:07 +00:00
|
|
|
// Now, check to see if we need to keep the person on
|
2003-10-02 11:07:43 +00:00
|
|
|
bool on = false;
|
|
|
|
for (int j = 0; j < object.personCount; j++) {
|
|
|
|
if (object.person[j] == i) {
|
|
|
|
on = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (on) {
|
|
|
|
// It is needed, so ensure it's ON
|
2003-12-05 13:56:07 +00:00
|
|
|
objectData->name = ABS(objectData->name);
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-10-02 11:07:43 +00:00
|
|
|
// Not needed, so switch off!
|
2003-12-05 13:56:07 +00:00
|
|
|
objectData->name = -ABS(objectData->name);
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2005-05-08 21:49:52 +00:00
|
|
|
} // for ()
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// set coordinates for Joe if he is on screen
|
|
|
|
|
2003-12-30 10:46:05 +00:00
|
|
|
_vm->logic()->joePos(0, 0);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < object.personCount; i++) {
|
|
|
|
if (PERSON_JOE == object.person[i]) {
|
2003-12-30 10:46:05 +00:00
|
|
|
_vm->logic()->joePos(object.bobStartX, object.bobStartY);
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->oldRoom(_initialRoom);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2004-01-10 12:56:07 +00:00
|
|
|
// FIXME - the first cutaway is played at the end of the command 0x178. This
|
|
|
|
// command setups some persons and associates bob slots to them. They should be
|
|
|
|
// hidden as their y coordinate is > 150, but they aren't ! A (temporary)
|
|
|
|
// workaround is to display the room with the panel area enabled. Same problem
|
|
|
|
// for cutaway c62c.
|
2003-12-07 15:19:00 +00:00
|
|
|
int16 comPanel = _comPanel;
|
2004-01-10 12:56:07 +00:00
|
|
|
if ((strcmp(_basename, "c41f") == 0 && _temporaryRoom == 106 && object.room == 41) ||
|
|
|
|
(strcmp(_basename, "c62c") == 0 && _temporaryRoom == 105 && object.room == 41)) {
|
2003-12-07 15:19:00 +00:00
|
|
|
comPanel = 1;
|
|
|
|
}
|
|
|
|
|
2004-01-11 14:11:36 +00:00
|
|
|
// FIXME - in the original engine, panel is hidden once the 'head room' is displayed, we
|
|
|
|
// do it before (ie before palette fading)
|
|
|
|
if (object.room == FAYE_HEAD || object.room == AZURA_HEAD || object.room == FRANK_HEAD) {
|
2003-12-10 15:36:44 +00:00
|
|
|
comPanel = 2;
|
|
|
|
}
|
|
|
|
|
2003-10-12 19:16:48 +00:00
|
|
|
RoomDisplayMode mode;
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (!_vm->logic()->joeX() && !_vm->logic()->joeY()) {
|
2003-10-12 19:16:48 +00:00
|
|
|
mode = RDM_FADE_NOJOE;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-10-12 19:16:48 +00:00
|
|
|
// We need to display Joe on screen
|
2003-12-05 20:16:32 +00:00
|
|
|
if (_roomFade)
|
2003-10-12 19:16:48 +00:00
|
|
|
mode = RDM_NOFADE_JOE;
|
2003-10-01 17:57:09 +00:00
|
|
|
else
|
2003-10-12 19:16:48 +00:00
|
|
|
mode = RDM_FADE_JOE_XY;
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
2004-01-09 13:36:37 +00:00
|
|
|
_vm->logic()->displayRoom(_vm->logic()->currentRoom(), mode, object.scale, comPanel, true);
|
2003-10-12 19:16:48 +00:00
|
|
|
|
2004-01-08 22:46:42 +00:00
|
|
|
_currentImage = _vm->graphics()->numFrames();
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_temporaryRoom = _vm->logic()->currentRoom();
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2003-10-02 11:07:43 +00:00
|
|
|
restorePersonData();
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
Cutaway::ObjectType Cutaway::getObjectType(CutawayObject &object) {
|
2003-10-02 11:07:43 +00:00
|
|
|
// Lines 1387-1449 in cutaway.c
|
|
|
|
|
2003-10-01 17:57:09 +00:00
|
|
|
ObjectType objectType = OBJECT_TYPE_ANIMATION;
|
|
|
|
|
|
|
|
if (object.objectNumber > 0) {
|
|
|
|
if (!object.animList) {
|
|
|
|
// No anim frames, so treat as a PERSON, ie. allow to speak/walk
|
2003-12-11 22:16:35 +00:00
|
|
|
ObjectData *objectData = _vm->logic()->objectData(object.objectNumber);
|
2003-10-03 12:55:11 +00:00
|
|
|
if (objectData->image == -3 || objectData->image == -4)
|
2003-10-02 11:07:43 +00:00
|
|
|
objectType = OBJECT_TYPE_PERSON;
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
2004-10-08 18:43:24 +00:00
|
|
|
} else if (object.objectNumber == OBJECT_JOE) {
|
2003-10-01 17:57:09 +00:00
|
|
|
// It's Joe. See if he's to be treated as a person.
|
|
|
|
if (!object.animList) {
|
|
|
|
// There's no animation list, so Joe must be talking.
|
|
|
|
objectType = OBJECT_TYPE_PERSON;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (object.fromObject > 0) {
|
|
|
|
/* Copy FROM_OBJECT into OBJECT */
|
|
|
|
|
2004-11-23 22:21:45 +00:00
|
|
|
if (object.objectNumber != object.fromObject) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->objectCopy(object.fromObject, object.objectNumber);
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-10-01 17:57:09 +00:00
|
|
|
// Same object, so just turn it on!
|
2003-12-11 22:16:35 +00:00
|
|
|
ObjectData *objectData = _vm->logic()->objectData(object.objectNumber);
|
2003-12-05 13:56:07 +00:00
|
|
|
objectData->name = ABS(objectData->name);
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
2003-10-14 12:37:07 +00:00
|
|
|
|
2004-01-08 22:46:42 +00:00
|
|
|
_vm->graphics()->refreshObject(object.objectNumber);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
// Skip doing any anim stuff
|
|
|
|
objectType = OBJECT_TYPE_NO_ANIMATION;
|
|
|
|
}
|
|
|
|
|
2005-04-07 08:57:40 +00:00
|
|
|
switch (object.objectNumber) {
|
2004-10-08 18:43:24 +00:00
|
|
|
case -2:
|
|
|
|
// Text to be spoken
|
|
|
|
objectType = OBJECT_TYPE_TEXT_SPEAK;
|
|
|
|
break;
|
|
|
|
case -3:
|
|
|
|
// Text to be displayed AND spoken
|
|
|
|
objectType = OBJECT_TYPE_TEXT_DISPLAY_AND_SPEAK;
|
|
|
|
break;
|
|
|
|
case -4:
|
|
|
|
// Text to be displayed only (not spoken)
|
|
|
|
objectType = OBJECT_TYPE_TEXT_DISPLAY;
|
|
|
|
break;
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (OBJECT_TYPE_ANIMATION == objectType && !object.execute) {
|
|
|
|
// Execute is not on, and it's an object, so ignore any Anims
|
|
|
|
objectType = OBJECT_TYPE_NO_ANIMATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
return objectType;
|
|
|
|
}
|
|
|
|
|
2004-08-24 16:31:46 +00:00
|
|
|
const byte *Cutaway::getCutawayAnim(const byte *ptr, int header, CutawayAnim &anim) {
|
2003-10-18 10:58:10 +00:00
|
|
|
// lines 1531-1607 in cutaway.c
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
//debug(6, "[Cutaway::getCutawayAnim] header=%i", header);
|
2003-10-19 11:01:23 +00:00
|
|
|
|
2003-10-01 17:57:09 +00:00
|
|
|
anim.currentFrame = 0;
|
|
|
|
anim.originalFrame = 0;
|
|
|
|
|
|
|
|
if (-1 == header)
|
|
|
|
header = 0;
|
|
|
|
|
|
|
|
if (0 == header) {
|
|
|
|
anim.object = 0;
|
2004-10-03 21:34:39 +00:00
|
|
|
anim.originalFrame = 31;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-12-11 22:16:35 +00:00
|
|
|
anim.object = _vm->logic()->findBob(header);
|
|
|
|
anim.originalFrame = _vm->logic()->findFrame(header);
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
anim.unpackFrame = (int16)READ_BE_INT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
anim.speed = ((int16)READ_BE_INT16(ptr)) / 3 + 1;
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
anim.bank = (int16)READ_BE_INT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
|
|
|
|
2003-10-18 10:58:10 +00:00
|
|
|
if (anim.bank == 0) {
|
|
|
|
anim.bank = 15;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-10-18 10:58:10 +00:00
|
|
|
if (anim.bank != 13) {
|
2004-01-19 21:38:07 +00:00
|
|
|
_vm->bankMan()->load(_bankNames[anim.bank-1], CUTAWAY_BANK);
|
2003-10-18 10:58:10 +00:00
|
|
|
anim.bank = 8;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-10-18 10:58:10 +00:00
|
|
|
// Make sure we ref correct JOE bank (7)
|
|
|
|
anim.bank = 7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
anim.mx = (int16)READ_BE_INT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
anim.my = (int16)READ_BE_INT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
anim.cx = (int16)READ_BE_INT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
anim.cy = (int16)READ_BE_INT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
anim.scale = (int16)READ_BE_INT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->resource()->isDemo()) {
|
2003-11-13 12:17:53 +00:00
|
|
|
anim.song = 0;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2004-03-23 20:34:19 +00:00
|
|
|
anim.song = (int16)READ_BE_INT16(ptr);
|
2003-11-13 12:17:53 +00:00
|
|
|
ptr += 2;
|
|
|
|
}
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2003-10-18 10:58:10 +00:00
|
|
|
// Extract information that depend on the signedness of values
|
|
|
|
if (anim.unpackFrame < 0) {
|
|
|
|
anim.flip = true;
|
|
|
|
anim.unpackFrame = -anim.unpackFrame;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else
|
2003-10-18 10:58:10 +00:00
|
|
|
anim.flip = false;
|
|
|
|
|
2003-10-01 17:57:09 +00:00
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
void Cutaway::dumpCutawayAnim(CutawayAnim &anim) {
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "----- CutawayAnim -----");
|
|
|
|
if (anim.object) debug(6, "object = %i", anim.object);
|
|
|
|
if (anim.unpackFrame) debug(6, "unpackFrame = %i", anim.unpackFrame);
|
|
|
|
if (anim.speed) debug(6, "speed = %i", anim.speed);
|
|
|
|
if (anim.bank) debug(6, "bank = %i", anim.bank);
|
|
|
|
if (anim.mx) debug(6, "mx = %i", anim.mx);
|
|
|
|
if (anim.my) debug(6, "my = %i", anim.my);
|
|
|
|
if (anim.cx) debug(6, "cx = %i", anim.cx);
|
|
|
|
if (anim.cy) debug(6, "cy = %i", anim.cy);
|
|
|
|
if (anim.scale) debug(6, "scale = %i", anim.scale);
|
|
|
|
if (anim.currentFrame) debug(6, "currentFrame = %i", anim.currentFrame);
|
|
|
|
if (anim.originalFrame) debug(6, "originalFrame = %i", anim.originalFrame);
|
|
|
|
if (anim.song) debug(6, "song = %i", anim.song);
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
2004-08-24 16:31:46 +00:00
|
|
|
const byte *Cutaway::handleAnimation(const byte *ptr, CutawayObject &object) {
|
2003-10-18 10:58:10 +00:00
|
|
|
// lines 1517-1770 in cutaway.c
|
2003-10-01 17:57:09 +00:00
|
|
|
int frameCount = 0;
|
|
|
|
int header = 0;
|
2003-10-18 10:58:10 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
CutawayAnim objAnim[56];
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
// Read animation frames
|
|
|
|
for (;;) {
|
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
header = (int16)READ_BE_INT16(ptr);
|
2003-10-01 17:57:09 +00:00
|
|
|
ptr += 2;
|
|
|
|
|
|
|
|
if (-2 == header)
|
|
|
|
break;
|
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
//debug(6, "Animation frame %i, header = %i", frameCount, header);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
if (header > 1000)
|
|
|
|
error("Header too large");
|
|
|
|
|
2003-10-18 10:58:10 +00:00
|
|
|
ptr = getCutawayAnim(ptr, header, objAnim[frameCount]);
|
2003-10-19 11:01:23 +00:00
|
|
|
//dumpCutawayAnim(objAnim[frameCount]);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
frameCount++;
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->input()->cutawayQuit())
|
2003-10-01 17:57:09 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (object.animType == 1) {
|
2003-10-18 10:58:10 +00:00
|
|
|
// lines 1615-1636 in cutaway.c
|
2003-10-18 12:48:05 +00:00
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "----- Complex cutaway animation (animType = %i) -----", object.animType);
|
2003-10-18 10:58:10 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if ((_vm->logic()->currentRoom() == 47 || _vm->logic()->currentRoom() == 63) &&
|
2003-12-03 20:53:59 +00:00
|
|
|
objAnim[0].object == 1) {
|
|
|
|
//CR 2 - 3/3/95, Special harcoded section to make Oracle work...
|
2004-01-08 22:46:42 +00:00
|
|
|
makeComplexAnimation(_vm->graphics()->personFrames(1) - 1, objAnim, frameCount);
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-10-19 11:01:23 +00:00
|
|
|
_currentImage = makeComplexAnimation(_currentImage, objAnim, frameCount);
|
2003-10-18 10:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (object.bobStartX || object.bobStartY) {
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *bob = _vm->graphics()->bob(objAnim[0].object);
|
2003-10-18 10:58:10 +00:00
|
|
|
bob->x = object.bobStartX;
|
|
|
|
bob->y = object.bobStartY;
|
|
|
|
}
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Setup the SYNCHRO bob channels
|
2003-10-18 10:58:10 +00:00
|
|
|
|
|
|
|
for (i = 0; i < frameCount; i++) {
|
|
|
|
if (objAnim[i].mx || objAnim[i].my) {
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *bob = _vm->graphics()->bob(objAnim[i].object);
|
2003-10-18 10:58:10 +00:00
|
|
|
bob->frameNum = objAnim[i].originalFrame;
|
2003-11-30 20:41:02 +00:00
|
|
|
bob->move(objAnim[i].mx, objAnim[i].my, (object.specialMove > 0) ? object.specialMove : 4);
|
2003-12-03 20:53:59 +00:00
|
|
|
// Boat room hard coded
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->logic()->currentRoom() == ROOM_TEMPLE_OUTSIDE) {
|
|
|
|
BobSlot *bobJoe = _vm->graphics()->bob(0);
|
2003-12-03 20:53:59 +00:00
|
|
|
if (bobJoe->x < 320) {
|
|
|
|
bobJoe->move(bobJoe->x + 346, bobJoe->y, 4);
|
|
|
|
}
|
|
|
|
}
|
2003-10-18 10:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-01 17:57:09 +00:00
|
|
|
// Normal cutaway
|
|
|
|
|
|
|
|
if (object.animType != 1) {
|
2003-10-18 10:58:10 +00:00
|
|
|
// lines 1657-1761 in cutaway.c
|
2003-10-18 12:48:05 +00:00
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "----- Normal cutaway animation (animType = %i) -----", object.animType);
|
2003-10-18 12:48:05 +00:00
|
|
|
|
2003-10-18 11:46:52 +00:00
|
|
|
for (i = 0; i < frameCount; i++) {
|
2003-12-29 21:05:33 +00:00
|
|
|
//debug(6, "===== Animating frame %i =====", i);
|
2003-10-18 16:19:36 +00:00
|
|
|
//dumpCutawayAnim(objAnim[i]);
|
2003-10-18 15:33:23 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *bob = _vm->graphics()->bob(objAnim[i].object);
|
2003-10-18 11:46:52 +00:00
|
|
|
bob->active = true;
|
|
|
|
if (bob->animating) {
|
|
|
|
bob->animating = false;
|
|
|
|
bob->frameNum = objAnim[i].originalFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (objAnim[i].object < 4)
|
2004-10-03 21:34:39 +00:00
|
|
|
bob->frameNum = 31 + objAnim[i].object;
|
2003-10-18 11:46:52 +00:00
|
|
|
|
|
|
|
if (objAnim[i].unpackFrame == 0) {
|
|
|
|
// Turn off the bob
|
|
|
|
bob->active = false;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-10-18 11:46:52 +00:00
|
|
|
if (object.animType == 2 || object.animType == 0) {
|
|
|
|
// Unpack animation, but do not unpack moving people
|
|
|
|
|
2004-01-08 10:25:18 +00:00
|
|
|
if (!((objAnim[i].mx > 0 || objAnim[i].my > 0) && inRange(objAnim[i].object, 1, 3))) {
|
2004-01-05 13:40:28 +00:00
|
|
|
_vm->bankMan()->unpack(
|
2003-10-18 11:46:52 +00:00
|
|
|
objAnim[i].unpackFrame,
|
|
|
|
objAnim[i].originalFrame,
|
|
|
|
objAnim[i].bank);
|
2003-10-18 15:33:23 +00:00
|
|
|
}
|
2003-10-18 12:59:44 +00:00
|
|
|
|
|
|
|
if (0 == objAnim[i].object) {
|
|
|
|
// Scale Joe
|
2003-10-19 11:41:24 +00:00
|
|
|
bob->scale = scale(object);
|
2003-10-18 12:59:44 +00:00
|
|
|
}
|
2003-10-18 11:46:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (objAnim[i].cx || objAnim[i].cy) {
|
|
|
|
bob->x = objAnim[i].cx;
|
|
|
|
bob->y = objAnim[i].cy;
|
|
|
|
}
|
|
|
|
|
2003-11-09 21:24:23 +00:00
|
|
|
// Only flip if we are not moving or it is not a person object
|
2003-11-17 19:55:17 +00:00
|
|
|
if (!(objAnim[i].object > 0 && objAnim[i].object < 4) ||
|
|
|
|
!(objAnim[i].mx || objAnim[i].my) )
|
2003-10-18 11:46:52 +00:00
|
|
|
bob->xflip = objAnim[i].flip;
|
|
|
|
|
|
|
|
// Add frame alteration
|
2003-11-17 19:55:17 +00:00
|
|
|
if (!(objAnim[i].object > 0 && objAnim[i].object < 4)) {
|
|
|
|
bob->frameNum = objAnim[i].originalFrame;
|
|
|
|
}
|
2003-10-18 11:46:52 +00:00
|
|
|
|
|
|
|
int j;
|
|
|
|
for (j = 0; j < objAnim[i].speed; j++)
|
2004-01-08 10:25:18 +00:00
|
|
|
_vm->update();
|
2003-10-18 11:46:52 +00:00
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->input()->cutawayQuit())
|
2003-10-18 11:46:52 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (objAnim[i].song > 0)
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->sound()->playSong(objAnim[i].song);
|
2003-10-18 11:46:52 +00:00
|
|
|
|
2005-05-08 21:49:52 +00:00
|
|
|
} // for ()
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
2003-10-18 10:58:10 +00:00
|
|
|
bool moving = true;
|
|
|
|
|
|
|
|
while (moving) {
|
|
|
|
moving = false;
|
2004-01-08 10:25:18 +00:00
|
|
|
_vm->update();
|
2003-10-18 10:58:10 +00:00
|
|
|
|
|
|
|
for (i = 0; i < frameCount; i++) {
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *bob = _vm->graphics()->bob(objAnim[i].object);
|
2003-10-18 10:58:10 +00:00
|
|
|
if (bob->moving) {
|
|
|
|
moving = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->input()->cutawayQuit())
|
2003-10-23 18:50:47 +00:00
|
|
|
return NULL;
|
2003-10-18 10:58:10 +00:00
|
|
|
}
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2003-10-12 19:16:48 +00:00
|
|
|
static void findCdCut(const char *basename, int index, char *result) {
|
|
|
|
strcpy(result, basename);
|
|
|
|
for (int i = strlen(basename); i < 5; i++)
|
|
|
|
result[i] = '_';
|
2003-10-19 11:01:23 +00:00
|
|
|
snprintf(result + 5, 3, "%02i", index);
|
2003-10-12 19:16:48 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
void Cutaway::handlePersonRecord(
|
2003-10-01 17:57:09 +00:00
|
|
|
int index,
|
|
|
|
CutawayObject &object,
|
|
|
|
const char *sentence) {
|
|
|
|
// Lines 1455-1516 in cutaway.c
|
|
|
|
|
2003-10-15 11:33:02 +00:00
|
|
|
Person p;
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
if (object.objectNumber == OBJECT_JOE) {
|
|
|
|
if (object.moveToX || object.moveToY) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->walk()->moveJoe(0, object.moveToX, object.moveToY, true);
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2004-01-07 15:45:24 +00:00
|
|
|
_vm->logic()->initPerson(
|
2003-12-11 22:16:35 +00:00
|
|
|
object.objectNumber - _vm->logic()->currentRoomData(),
|
2003-10-14 12:37:07 +00:00
|
|
|
"", true, &p);
|
2003-10-15 11:33:02 +00:00
|
|
|
|
2003-10-15 08:46:04 +00:00
|
|
|
if (object.bobStartX || object.bobStartY) {
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *bob = _vm->graphics()->bob(p.actor->bobNum);
|
2003-10-19 11:41:24 +00:00
|
|
|
bob->scale = scale(object);
|
2003-10-15 08:46:04 +00:00
|
|
|
bob->x = object.bobStartX;
|
|
|
|
bob->y = object.bobStartY;
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
2003-10-18 16:19:36 +00:00
|
|
|
if (object.moveToX || object.moveToY)
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->walk()->movePerson(
|
2003-10-18 16:19:36 +00:00
|
|
|
&p,
|
|
|
|
object.moveToX, object.moveToY,
|
2004-03-07 10:46:02 +00:00
|
|
|
_currentImage + 1,
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->objectData(object.objectNumber)->image
|
2003-10-18 16:19:36 +00:00
|
|
|
);
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->input()->cutawayQuit())
|
2003-10-01 17:57:09 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (0 != strcmp(sentence, "*")) {
|
|
|
|
if (sentence[0] == '#') {
|
2004-01-25 14:21:37 +00:00
|
|
|
debug(4, "Starting credits '%s'", sentence + 1);
|
2004-01-05 11:58:20 +00:00
|
|
|
_vm->logic()->startCredits(sentence + 1);
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-10-01 17:57:09 +00:00
|
|
|
if (object.objectNumber > 0) {
|
2003-10-12 19:16:48 +00:00
|
|
|
bool foundPerson = false;
|
|
|
|
|
|
|
|
for (int i = 1; i <= _personFaceCount; i++) {
|
|
|
|
if (_personFace[i].index == object.objectNumber) {
|
|
|
|
foundPerson = true;
|
|
|
|
break;
|
|
|
|
}
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
2003-10-12 19:16:48 +00:00
|
|
|
|
|
|
|
if (!foundPerson) {
|
|
|
|
_personFaceCount++;
|
2004-01-14 15:51:54 +00:00
|
|
|
assert(_personFaceCount < MAX_PERSON_FACE_COUNT);
|
2003-10-12 19:16:48 +00:00
|
|
|
_personFace[_personFaceCount].index = object.objectNumber;
|
2003-12-11 22:16:35 +00:00
|
|
|
_personFace[_personFaceCount].image = _vm->logic()->objectData(object.objectNumber)->image;
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-12 19:16:48 +00:00
|
|
|
char voiceFilePrefix[MAX_STRING_SIZE];
|
2003-11-26 21:46:29 +00:00
|
|
|
findCdCut(_basename, index, voiceFilePrefix);
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->makePersonSpeak(sentence, (object.objectNumber == OBJECT_JOE) ? NULL : &p, voiceFilePrefix);
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->input()->cutawayQuit())
|
2003-10-01 17:57:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
void Cutaway::run(char *nextFilename) {
|
2003-11-06 08:44:33 +00:00
|
|
|
int i;
|
2003-10-02 11:07:43 +00:00
|
|
|
nextFilename[0] = '\0';
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2004-01-08 22:46:42 +00:00
|
|
|
_currentImage = _vm->graphics()->numFrames();
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *joeBob = _vm->graphics()->bob(0);
|
2003-11-09 12:19:47 +00:00
|
|
|
int initialJoeX = joeBob->x;
|
|
|
|
int initialJoeY = joeBob->y;
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "[Cutaway::run] Joe started at (%i, %i)", initialJoeX, initialJoeY);
|
2003-11-06 08:44:33 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->cutawayRunning(true);
|
2003-10-23 18:50:47 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_initialRoom = _temporaryRoom = _vm->logic()->currentRoom();
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->screenMode(_comPanel, true);
|
2003-11-14 14:35:52 +00:00
|
|
|
|
|
|
|
if (_comPanel == 0 || _comPanel == 2) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->sceneStart();
|
2003-11-14 14:35:52 +00:00
|
|
|
}
|
2003-10-01 17:57:09 +00:00
|
|
|
|
2004-01-05 20:46:37 +00:00
|
|
|
memset(_personFace, 0, sizeof(_personFace));
|
|
|
|
_personFaceCount = 0;
|
|
|
|
|
2004-08-24 16:31:46 +00:00
|
|
|
const byte *ptr = _objectData;
|
2003-11-07 10:57:21 +00:00
|
|
|
|
2003-11-06 08:44:33 +00:00
|
|
|
for (i = 0; i < _cutawayObjectCount; i++) {
|
2003-10-01 17:57:09 +00:00
|
|
|
CutawayObject object;
|
|
|
|
ptr = getCutawayObject(ptr, object);
|
2003-10-19 11:01:23 +00:00
|
|
|
//dumpCutawayObject(i, object);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
if (!object.moveToX &&
|
|
|
|
!object.moveToY &&
|
2003-12-29 21:31:02 +00:00
|
|
|
object.specialMove > 0 &&
|
2003-10-01 17:57:09 +00:00
|
|
|
object.objectNumber >= 0) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->executeSpecialMove(object.specialMove);
|
2003-10-01 17:57:09 +00:00
|
|
|
object.specialMove = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CURRENT_ROOM == object.room) {
|
|
|
|
// Get current room
|
2003-12-11 22:16:35 +00:00
|
|
|
object.room = _vm->logic()->currentRoom();
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-10-01 17:57:09 +00:00
|
|
|
// Change current room
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->currentRoom(object.room);
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ptr = turnOnPeople(ptr, object);
|
|
|
|
|
|
|
|
limitBob(object);
|
|
|
|
|
|
|
|
char sentence[MAX_STRING_SIZE];
|
2004-08-24 16:31:46 +00:00
|
|
|
Talk::getString(_fileData, _nextSentenceOff, sentence, MAX_STRING_LENGTH);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
if (OBJECT_ROOMFADE == object.objectNumber) {
|
2003-10-12 19:16:48 +00:00
|
|
|
_roomFade = true;
|
2003-10-01 17:57:09 +00:00
|
|
|
object.objectNumber = OBJECT_JOE;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-10-12 19:16:48 +00:00
|
|
|
_roomFade = false;
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
2003-10-02 11:07:43 +00:00
|
|
|
if (object.room != _temporaryRoom)
|
2003-10-01 17:57:09 +00:00
|
|
|
changeRooms(object);
|
|
|
|
|
|
|
|
ObjectType objectType = getObjectType(object);
|
|
|
|
|
2003-11-07 02:33:20 +00:00
|
|
|
if (object.song)
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->sound()->playSong(object.song);
|
2003-10-01 17:57:09 +00:00
|
|
|
|
|
|
|
switch (objectType) {
|
2004-10-08 18:43:24 +00:00
|
|
|
case OBJECT_TYPE_ANIMATION:
|
|
|
|
ptr = handleAnimation(ptr, object);
|
|
|
|
break;
|
|
|
|
case OBJECT_TYPE_PERSON:
|
|
|
|
handlePersonRecord(i + 1, object, sentence);
|
|
|
|
break;
|
|
|
|
case OBJECT_TYPE_NO_ANIMATION:
|
|
|
|
// Do nothing?
|
|
|
|
break;
|
|
|
|
case OBJECT_TYPE_TEXT_SPEAK:
|
|
|
|
case OBJECT_TYPE_TEXT_DISPLAY_AND_SPEAK:
|
|
|
|
case OBJECT_TYPE_TEXT_DISPLAY:
|
|
|
|
handleText(i + 1, objectType, object, sentence);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
warning("Unhandled object type: %i", objectType);
|
|
|
|
break;
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->input()->cutawayQuit())
|
2003-10-01 17:57:09 +00:00
|
|
|
break;
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2003-12-05 20:16:32 +00:00
|
|
|
if (_roomFade) {
|
2004-01-08 10:25:18 +00:00
|
|
|
_vm->update();
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *j = _vm->graphics()->bob(0);
|
2004-12-02 22:59:57 +00:00
|
|
|
_vm->display()->palFadeIn(_vm->logic()->currentRoom(), j->active, j->x, j->y);
|
2003-12-05 20:16:32 +00:00
|
|
|
_roomFade = false;
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
2003-12-05 20:16:32 +00:00
|
|
|
|
2005-05-08 21:49:52 +00:00
|
|
|
} // for ()
|
2004-01-13 14:43:13 +00:00
|
|
|
|
|
|
|
_vm->display()->clearTexts(0, 198);
|
|
|
|
// XXX lines 1887-1895 in cutaway.c
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2003-11-06 08:44:33 +00:00
|
|
|
stop();
|
2003-10-02 11:07:43 +00:00
|
|
|
|
|
|
|
updateGameState();
|
|
|
|
|
2004-01-05 13:40:28 +00:00
|
|
|
_vm->bankMan()->close(CUTAWAY_BANK);
|
2003-10-02 11:07:43 +00:00
|
|
|
|
|
|
|
talk(nextFilename);
|
|
|
|
|
2003-11-10 12:32:46 +00:00
|
|
|
if (_comPanel == 0 || (_comPanel == 2 && !_anotherCutaway)) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->sceneStop();
|
2003-11-06 08:44:33 +00:00
|
|
|
_comPanel = 0;
|
|
|
|
}
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2004-12-03 22:39:55 +00:00
|
|
|
if (nextFilename[0] == '\0' && !_anotherCutaway && _vm->logic()->currentRoom() != ROOM_ENDING_CREDITS) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->fullscreen(false);
|
2003-11-14 14:35:52 +00:00
|
|
|
|
2003-10-02 11:07:43 +00:00
|
|
|
// Lines 2138-2182 in cutaway.c
|
2003-11-06 08:44:33 +00:00
|
|
|
if (_finalRoom) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->newRoom(0);
|
|
|
|
_vm->logic()->entryObj(0);
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-11-06 08:44:33 +00:00
|
|
|
/// No need to stay in current room, so return to previous room
|
|
|
|
// if one exists. Reset Joe's X,Y coords to those when first entered
|
|
|
|
|
|
|
|
restorePersonData();
|
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "_vm->logic()->entryObj() = %i", _vm->logic()->entryObj());
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->logic()->entryObj() > 0) {
|
|
|
|
_initialRoom = _vm->logic()->objectData(_vm->logic()->entryObj())->room;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-11-06 08:44:33 +00:00
|
|
|
// We're not returning to new room, so return to old Joe X,Y coords
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "[Cutaway::run] Moving joe to (%i, %i)", initialJoeX, initialJoeY);
|
2003-12-30 10:46:05 +00:00
|
|
|
_vm->logic()->joePos(initialJoeX, initialJoeY);
|
2003-11-06 08:44:33 +00:00
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->logic()->currentRoom() != _initialRoom) {
|
|
|
|
_vm->logic()->currentRoom(_initialRoom);
|
|
|
|
_vm->logic()->changeRoom();
|
|
|
|
if (_vm->logic()->currentRoom() == _vm->logic()->newRoom()) {
|
|
|
|
_vm->logic()->newRoom(0);
|
2003-12-10 15:36:44 +00:00
|
|
|
}
|
2003-11-16 20:31:14 +00:00
|
|
|
}
|
2003-12-30 10:46:05 +00:00
|
|
|
_vm->logic()->joePos(0, 0);
|
2003-11-06 08:44:33 +00:00
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->joeCutFacing(0);
|
2003-11-06 08:44:33 +00:00
|
|
|
_comPanel = 0;
|
|
|
|
|
|
|
|
int k = 0;
|
2003-12-11 22:16:35 +00:00
|
|
|
for (i = _vm->logic()->roomData(_vm->logic()->currentRoom());
|
|
|
|
i <= _vm->logic()->roomData(_vm->logic()->currentRoom() + 1); i++) {
|
2003-11-06 08:44:33 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
ObjectData *object = _vm->logic()->objectData(i);
|
2003-11-06 08:44:33 +00:00
|
|
|
if (object->image == -3 || object->image == -4) {
|
|
|
|
k++;
|
2003-11-17 13:31:00 +00:00
|
|
|
if (object->name > 0) {
|
2004-01-07 15:45:24 +00:00
|
|
|
_vm->graphics()->resetPersonAnim(k);
|
2003-11-17 13:31:00 +00:00
|
|
|
}
|
2003-11-06 08:44:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-08 10:25:18 +00:00
|
|
|
_vm->logic()->removeHotelItemsFromInventory();
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
|
|
|
|
2003-10-12 19:16:48 +00:00
|
|
|
joeBob->animating = 0;
|
|
|
|
joeBob->moving = 0;
|
|
|
|
|
2004-09-26 18:55:11 +00:00
|
|
|
// if the cutaway has been cancelled, we must stop the speech and the sfx as well
|
2004-10-03 20:27:39 +00:00
|
|
|
if (_vm->input()->cutawayQuit()) {
|
2004-12-19 12:19:21 +00:00
|
|
|
if (_vm->sound()->isSpeechActive())
|
2004-10-03 20:27:39 +00:00
|
|
|
_vm->sound()->stopSpeech();
|
|
|
|
_vm->sound()->stopSfx();
|
|
|
|
}
|
2004-09-25 23:47:10 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->cutawayRunning(false);
|
|
|
|
_vm->input()->cutawayQuitReset();
|
2004-03-23 23:47:01 +00:00
|
|
|
_vm->input()->quickSaveReset();
|
|
|
|
_vm->input()->quickLoadReset();
|
|
|
|
|
2003-10-02 11:07:43 +00:00
|
|
|
if (_songBeforeComic > 0)
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->sound()->playSong(_songBeforeComic);
|
2003-10-02 11:07:43 +00:00
|
|
|
else if (_lastSong > 0)
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->sound()->playSong(_lastSong);
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
|
|
|
|
2003-11-06 08:44:33 +00:00
|
|
|
void Cutaway::stop() {
|
2003-10-02 11:07:43 +00:00
|
|
|
// Lines 1901-2032 in cutaway.c
|
|
|
|
byte *ptr = _gameStatePtr;
|
|
|
|
|
|
|
|
// Skipping GAMESTATE data
|
2004-03-23 20:34:19 +00:00
|
|
|
int gameStateCount = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2003-10-02 11:07:43 +00:00
|
|
|
if (gameStateCount > 0)
|
|
|
|
ptr += (gameStateCount * 12);
|
|
|
|
|
|
|
|
// Get the final room and Joe's final position
|
|
|
|
|
2003-11-06 08:44:33 +00:00
|
|
|
int16 joeRoom = READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
int16 joeX = READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
int16 joeY = READ_BE_UINT16(ptr); ptr += 2;
|
2003-11-09 12:19:47 +00:00
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "[Cutaway::stop] Final position is room %i and coordinates (%i, %i)",
|
2003-11-09 12:19:47 +00:00
|
|
|
joeRoom, joeX, joeY);
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if ((!_vm->input()->cutawayQuit() || (!_anotherCutaway && joeRoom == _finalRoom)) &&
|
2003-10-02 11:07:43 +00:00
|
|
|
joeRoom != _temporaryRoom &&
|
|
|
|
joeRoom != 0) {
|
2003-11-09 12:19:47 +00:00
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "[Cutaway::stop] Changing rooms and moving Joe");
|
2003-11-06 08:44:33 +00:00
|
|
|
|
2003-12-30 10:46:05 +00:00
|
|
|
_vm->logic()->joePos(joeX, joeY);
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->currentRoom(joeRoom);
|
|
|
|
_vm->logic()->oldRoom(_initialRoom);
|
2004-01-09 13:36:37 +00:00
|
|
|
_vm->logic()->displayRoom(_vm->logic()->currentRoom(), RDM_FADE_JOE_XY, 0, _comPanel, true);
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->input()->cutawayQuit()) {
|
2003-10-02 11:07:43 +00:00
|
|
|
// Lines 1927-2032 in cutaway.c
|
2003-11-06 08:44:33 +00:00
|
|
|
int i;
|
2003-10-02 11:07:43 +00:00
|
|
|
|
|
|
|
// Stop the credits from running
|
2004-01-05 11:58:20 +00:00
|
|
|
_vm->logic()->stopCredits();
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2004-01-09 13:36:37 +00:00
|
|
|
_vm->graphics()->stopBobs();
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2003-11-06 08:44:33 +00:00
|
|
|
for (i = 1; i <= _personFaceCount; i++) {
|
|
|
|
int index = _personFace[i].index;
|
|
|
|
if (index > 0) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->objectData(_personFace[i].index)->image = _personFace[i].image;
|
2003-11-06 08:44:33 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bob(_vm->logic()->findBob(index))->xflip =
|
2003-11-06 08:44:33 +00:00
|
|
|
(_personFace[i].image != -4);
|
|
|
|
}
|
|
|
|
}
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
int quitObjectCount = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2003-11-06 08:44:33 +00:00
|
|
|
for (i = 0; i < quitObjectCount; i++) {
|
2004-03-23 20:34:19 +00:00
|
|
|
int16 objectIndex = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
int16 fromIndex = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
int16 x = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
int16 y = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
int16 room = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
int16 frame = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
int16 bank = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2003-11-06 08:44:33 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
int bobIndex = _vm->logic()->findBob(objectIndex);
|
|
|
|
ObjectData *object = _vm->logic()->objectData(objectIndex);
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2003-11-06 08:44:33 +00:00
|
|
|
if (fromIndex > 0) {
|
|
|
|
if (fromIndex == objectIndex) {
|
|
|
|
// Enable object
|
2003-12-05 13:56:07 +00:00
|
|
|
object->name = ABS(object->name);
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->objectCopy(fromIndex, objectIndex);
|
2003-11-06 08:44:33 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
ObjectData *from = _vm->logic()->objectData(fromIndex);
|
|
|
|
if (object->image && !from->image && bobIndex && _vm->logic()->currentRoom() == object->room)
|
2004-01-23 10:34:57 +00:00
|
|
|
_vm->graphics()->bob(bobIndex)->clear();
|
2003-11-06 08:44:33 +00:00
|
|
|
}
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->logic()->currentRoom() == room)
|
2004-01-08 22:46:42 +00:00
|
|
|
_vm->graphics()->refreshObject(objectIndex);
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->logic()->currentRoom() == object->room) {
|
|
|
|
BobSlot *pbs = _vm->graphics()->bob(bobIndex);
|
2003-11-06 08:44:33 +00:00
|
|
|
|
|
|
|
if (x || y) {
|
|
|
|
pbs->x = x;
|
|
|
|
pbs->y = y;
|
2004-01-08 10:25:18 +00:00
|
|
|
if (inRange(object->image, -4, -3))
|
2004-01-08 14:10:32 +00:00
|
|
|
pbs->scale = _vm->grid()->findScale(x, y);
|
2003-11-06 08:44:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
if (0 == bank)
|
|
|
|
bank = 15;
|
|
|
|
else if (bank != 13) {
|
2004-01-05 13:40:28 +00:00
|
|
|
_vm->bankMan()->load(_bankNames[bank-1], CUTAWAY_BANK);
|
2003-11-06 08:44:33 +00:00
|
|
|
bank = 8;
|
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
int objectFrame = _vm->logic()->findFrame(objectIndex);
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2003-11-06 08:44:33 +00:00
|
|
|
if (objectFrame == 1000) {
|
2004-01-23 10:34:57 +00:00
|
|
|
_vm->graphics()->bob(bobIndex)->clear();
|
2004-10-08 18:43:24 +00:00
|
|
|
} else if (objectFrame) {
|
2004-01-05 13:40:28 +00:00
|
|
|
_vm->bankMan()->unpack(ABS(frame), objectFrame, bank);
|
2003-11-06 08:44:33 +00:00
|
|
|
pbs->frameNum = objectFrame;
|
|
|
|
if (frame < 0)
|
|
|
|
pbs->xflip = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
2005-05-08 21:49:52 +00:00
|
|
|
} // for ()
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
int16 specialMove = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2003-12-29 21:31:02 +00:00
|
|
|
if (specialMove > 0)
|
|
|
|
_vm->logic()->executeSpecialMove(specialMove);
|
2003-10-02 11:07:43 +00:00
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
_lastSong = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (joeRoom == _temporaryRoom &&
|
2004-03-07 10:46:02 +00:00
|
|
|
joeRoom != 37 && joeRoom != 105 && joeRoom != 106 &&
|
2003-10-02 11:07:43 +00:00
|
|
|
(joeX || joeY)) {
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *joeBob = _vm->graphics()->bob(0);
|
2003-11-09 12:19:47 +00:00
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "[Cutaway::stop] Moving Joe");
|
2003-11-09 12:19:47 +00:00
|
|
|
|
2003-10-12 19:16:48 +00:00
|
|
|
joeBob->x = joeX;
|
|
|
|
joeBob->y = joeY;
|
2004-01-08 14:10:32 +00:00
|
|
|
_vm->logic()->joeScale(_vm->grid()->findScale(joeX, joeY));
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->joeFace();
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
void Cutaway::updateGameState() {
|
2003-10-02 11:07:43 +00:00
|
|
|
// Lines 2047-2115 in cutaway.c
|
|
|
|
byte *ptr = _gameStatePtr;
|
|
|
|
|
2004-03-23 20:34:19 +00:00
|
|
|
int gameStateCount = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2003-10-02 11:07:43 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < gameStateCount; i++) {
|
2004-03-23 20:34:19 +00:00
|
|
|
int16 stateIndex = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
int16 stateValue = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
int16 objectIndex = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
int16 areaIndex = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
int16 areaSubIndex = (int16)READ_BE_INT16(ptr); ptr += 2;
|
|
|
|
int16 fromObject = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2003-10-02 11:07:43 +00:00
|
|
|
|
|
|
|
bool update = false;
|
|
|
|
|
|
|
|
if (stateIndex > 0) {
|
2004-11-23 22:21:45 +00:00
|
|
|
if (_vm->logic()->gameState(stateIndex) == stateValue)
|
2003-10-04 08:50:48 +00:00
|
|
|
update = true;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->gameState(ABS(stateIndex), stateValue);
|
2003-10-02 11:07:43 +00:00
|
|
|
update = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update) {
|
|
|
|
|
|
|
|
if (objectIndex > 0) { // Show the object
|
2003-12-11 22:16:35 +00:00
|
|
|
ObjectData *objectData = _vm->logic()->objectData(objectIndex);
|
2003-12-05 13:56:07 +00:00
|
|
|
objectData->name = ABS(objectData->name);
|
2003-10-02 11:07:43 +00:00
|
|
|
if (fromObject > 0)
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->logic()->objectCopy(fromObject, objectIndex);
|
2004-01-08 22:46:42 +00:00
|
|
|
_vm->graphics()->refreshObject(objectIndex);
|
2004-10-08 18:43:24 +00:00
|
|
|
} else if (objectIndex < 0) { // Hide the object
|
2003-10-03 12:55:11 +00:00
|
|
|
objectIndex = -objectIndex;
|
2003-12-11 22:16:35 +00:00
|
|
|
ObjectData *objectData = _vm->logic()->objectData(objectIndex);
|
2003-12-05 13:56:07 +00:00
|
|
|
objectData->name = -ABS(objectData->name);
|
2004-01-08 22:46:42 +00:00
|
|
|
_vm->graphics()->refreshObject(objectIndex);
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (areaIndex > 0) {
|
|
|
|
|
|
|
|
// Turn area on or off
|
|
|
|
|
|
|
|
if (areaSubIndex > 0) {
|
2004-01-08 14:10:32 +00:00
|
|
|
Area *area = _vm->grid()->area(areaIndex, areaSubIndex);
|
2003-12-05 13:56:07 +00:00
|
|
|
area->mapNeighbours = ABS(area->mapNeighbours);
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2004-01-08 14:10:32 +00:00
|
|
|
Area *area = _vm->grid()->area(areaIndex, ABS(areaSubIndex));
|
2003-12-05 13:56:07 +00:00
|
|
|
area->mapNeighbours = -ABS(area->mapNeighbours);
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2005-05-08 21:49:52 +00:00
|
|
|
} // for ()
|
2003-10-02 11:07:43 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
void Cutaway::talk(char *nextFilename) {
|
2004-12-06 20:42:11 +00:00
|
|
|
const char *p = strrchr(_talkFile, '.');
|
|
|
|
if (p && 0 == scumm_stricmp(p, ".dog")) {
|
2003-10-02 11:07:43 +00:00
|
|
|
nextFilename[0] = '\0';
|
2004-12-06 20:42:11 +00:00
|
|
|
assert(_talkTo > 0);
|
|
|
|
int personInRoom = _talkTo - _vm->logic()->roomData(_vm->logic()->currentRoom());
|
2004-01-07 15:46:45 +00:00
|
|
|
_vm->logic()->startDialogue(_talkFile, personInRoom, nextFilename);
|
2003-10-01 17:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-18 10:58:10 +00:00
|
|
|
int Cutaway::makeComplexAnimation(int16 currentImage, Cutaway::CutawayAnim *objAnim, int frameCount) {
|
2003-10-21 12:13:56 +00:00
|
|
|
int frameIndex[256];
|
2003-10-18 10:58:10 +00:00
|
|
|
int i;
|
2004-04-06 20:15:19 +00:00
|
|
|
assert(frameCount < 30);
|
|
|
|
AnimFrame cutAnim[30];
|
2004-01-10 12:56:07 +00:00
|
|
|
|
2003-10-21 12:13:56 +00:00
|
|
|
memset(frameIndex, 0, sizeof(frameIndex));
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "[Cutaway::makeComplexAnimation] currentImage = %i", currentImage);
|
2003-10-18 10:58:10 +00:00
|
|
|
|
|
|
|
for (i = 0; i < frameCount; i++) {
|
2004-04-06 20:15:19 +00:00
|
|
|
cutAnim[i].frame = objAnim[i].unpackFrame;
|
|
|
|
cutAnim[i].speed = objAnim[i].speed;
|
2003-10-21 12:13:56 +00:00
|
|
|
frameIndex[objAnim[i].unpackFrame] = 1;
|
2003-10-18 10:58:10 +00:00
|
|
|
}
|
|
|
|
|
2004-04-06 20:15:19 +00:00
|
|
|
cutAnim[frameCount].frame = 0;
|
|
|
|
cutAnim[frameCount].speed = 0;
|
2003-10-18 10:58:10 +00:00
|
|
|
|
2003-10-21 12:13:56 +00:00
|
|
|
int nextFrameIndex = 1;
|
2003-10-18 10:58:10 +00:00
|
|
|
|
|
|
|
for (i = 1; i < 256; i++)
|
2003-10-21 12:13:56 +00:00
|
|
|
if (frameIndex[i])
|
|
|
|
frameIndex[i] = nextFrameIndex++;
|
|
|
|
|
|
|
|
for (i = 0; i < frameCount; i++) {
|
2004-04-06 20:15:19 +00:00
|
|
|
cutAnim[i].frame = currentImage + frameIndex[objAnim[i].unpackFrame];
|
2003-10-21 12:13:56 +00:00
|
|
|
}
|
2003-10-18 10:58:10 +00:00
|
|
|
|
|
|
|
for (i = 1; i < 256; i++) {
|
2003-10-21 12:13:56 +00:00
|
|
|
if (frameIndex[i]) {
|
2003-10-18 10:58:10 +00:00
|
|
|
currentImage++;
|
2004-01-05 13:40:28 +00:00
|
|
|
_vm->bankMan()->unpack(i, currentImage, objAnim[0].bank);
|
2003-10-18 10:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-06 20:15:19 +00:00
|
|
|
_vm->graphics()->setBobCutawayAnim(objAnim[0].object, objAnim[0].flip, cutAnim, frameCount + 1);
|
2003-10-21 12:13:56 +00:00
|
|
|
return currentImage;
|
2003-10-18 10:58:10 +00:00
|
|
|
}
|
|
|
|
|
2003-10-18 12:48:05 +00:00
|
|
|
void Cutaway::handleText(
|
2003-10-21 13:18:02 +00:00
|
|
|
int index,
|
2003-10-18 12:48:05 +00:00
|
|
|
ObjectType type,
|
|
|
|
CutawayObject &object,
|
|
|
|
const char *sentence) {
|
|
|
|
// lines 1776-1863 in cutaway.c
|
|
|
|
|
|
|
|
int spaces = countSpaces(type, sentence);
|
|
|
|
|
|
|
|
int x;
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
if (OBJECT_TYPE_TEXT_DISPLAY == type) {
|
2004-01-09 13:36:37 +00:00
|
|
|
x = _vm->display()->textCenterX(sentence);
|
2003-10-18 12:48:05 +00:00
|
|
|
flags = 2;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-10-20 13:08:59 +00:00
|
|
|
x = object.bobStartX;
|
2003-10-18 12:48:05 +00:00
|
|
|
flags = 1;
|
|
|
|
}
|
|
|
|
|
2004-01-10 16:13:21 +00:00
|
|
|
BobSlot *bob =
|
|
|
|
_vm->graphics()->bob( _vm->logic()->findBob(ABS(object.objectNumber)) );
|
2003-10-18 12:48:05 +00:00
|
|
|
|
2004-01-10 16:13:21 +00:00
|
|
|
_vm->graphics()->setBobText(bob, sentence, x, object.bobStartY, object.specialMove, flags);
|
2003-10-18 12:48:05 +00:00
|
|
|
|
|
|
|
if (OBJECT_TYPE_TEXT_SPEAK == type || OBJECT_TYPE_TEXT_DISPLAY_AND_SPEAK == type) {
|
2004-01-10 16:13:21 +00:00
|
|
|
if (_vm->sound()->speechOn()) {
|
|
|
|
char voiceFileName[MAX_STRING_SIZE];
|
|
|
|
findCdCut(_basename, index, voiceFileName);
|
|
|
|
strcat(voiceFileName, "1");
|
2004-01-25 22:10:23 +00:00
|
|
|
_vm->sound()->playSfx(voiceFileName, true);
|
2004-01-10 16:13:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (OBJECT_TYPE_TEXT_SPEAK == type && _vm->sound()->speechOn() && !_vm->subtitles())
|
|
|
|
_vm->display()->clearTexts(0, 150);
|
2003-10-18 12:48:05 +00:00
|
|
|
}
|
|
|
|
|
2004-12-06 20:42:11 +00:00
|
|
|
while (1) {
|
2004-01-08 10:25:18 +00:00
|
|
|
_vm->update();
|
2003-10-18 12:48:05 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->input()->cutawayQuit())
|
2003-10-23 18:50:47 +00:00
|
|
|
return;
|
2003-10-18 12:48:05 +00:00
|
|
|
|
2003-12-12 10:33:34 +00:00
|
|
|
if (_vm->input()->keyVerb() == VERB_SKIP_TEXT) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->clearKeyVerb();
|
2003-10-23 18:50:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-12-06 20:42:11 +00:00
|
|
|
|
2004-12-19 12:19:21 +00:00
|
|
|
if ((OBJECT_TYPE_TEXT_SPEAK == type || OBJECT_TYPE_TEXT_DISPLAY_AND_SPEAK == type) && _vm->sound()->speechOn() && _vm->sound()->speechSfxExists()) {
|
2004-12-06 20:42:11 +00:00
|
|
|
if (!_vm->sound()->isSpeechActive()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
--spaces;
|
|
|
|
if (spaces <= 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-10-18 12:48:05 +00:00
|
|
|
}
|
|
|
|
|
2004-12-06 20:42:11 +00:00
|
|
|
_vm->display()->clearTexts(0, 198);
|
2004-01-08 10:25:18 +00:00
|
|
|
_vm->update();
|
2003-10-18 12:48:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Cutaway::countSpaces(ObjectType type, const char *segment) {
|
|
|
|
int tmp = 0;
|
|
|
|
|
|
|
|
while (*segment++)
|
|
|
|
tmp++;
|
|
|
|
|
2004-01-10 15:52:00 +00:00
|
|
|
if (tmp < 50)
|
|
|
|
tmp = 50;
|
2003-10-18 12:48:05 +00:00
|
|
|
|
|
|
|
if (OBJECT_TYPE_TEXT_DISPLAY == type)
|
|
|
|
tmp *= 3;
|
|
|
|
|
2004-01-08 10:25:18 +00:00
|
|
|
return (tmp * 2) / (_vm->talkSpeed() / 3);
|
2003-10-18 12:48:05 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-10-19 11:41:24 +00:00
|
|
|
int Cutaway::scale(CutawayObject &object) {
|
|
|
|
int scaling = 100;
|
|
|
|
|
|
|
|
if (object.scale > 0)
|
|
|
|
scaling = object.scale;
|
|
|
|
else if (!object.objectNumber) {
|
|
|
|
// Only scale Joe
|
|
|
|
int x, y;
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-19 11:41:24 +00:00
|
|
|
if (object.bobStartX > 0 || object.bobStartY > 0) {
|
|
|
|
x = object.bobStartX;
|
|
|
|
y = object.bobStartY;
|
2004-10-08 18:43:24 +00:00
|
|
|
} else {
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *bob = _vm->graphics()->bob(0);
|
2003-10-19 11:41:24 +00:00
|
|
|
x = bob->x;
|
|
|
|
y = bob->y;
|
|
|
|
}
|
|
|
|
|
2004-01-08 14:10:32 +00:00
|
|
|
int zone = _vm->grid()->findAreaForPos(GS_ROOM, x, y);
|
2003-10-19 11:41:24 +00:00
|
|
|
if (zone > 0) {
|
2004-01-08 14:10:32 +00:00
|
|
|
Area *area = _vm->grid()->area(_vm->logic()->currentRoom(), zone);
|
2003-10-19 11:41:24 +00:00
|
|
|
scaling = area->calcScale(y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return scaling;
|
|
|
|
}
|
|
|
|
|
2003-10-03 19:47:41 +00:00
|
|
|
} // End of namespace Queen
|