2003-09-28 15:50:47 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2003 The ScummVM project
|
|
|
|
*
|
|
|
|
* 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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-10-17 13:12:50 +00:00
|
|
|
#include "stdafx.h"
|
2003-09-28 15:50:47 +00:00
|
|
|
#include "queen/logic.h"
|
2003-12-11 22:16:35 +00:00
|
|
|
|
|
|
|
#include "common/config-manager.h"
|
2003-10-31 13:47:28 +00:00
|
|
|
#include "queen/command.h"
|
2003-10-21 09:05:16 +00:00
|
|
|
#include "queen/cutaway.h"
|
2003-11-09 20:50:03 +00:00
|
|
|
#include "queen/debug.h"
|
2003-12-26 12:58:27 +00:00
|
|
|
#include "queen/defs.h"
|
2003-10-16 13:54:48 +00:00
|
|
|
#include "queen/display.h"
|
2003-10-11 10:09:23 +00:00
|
|
|
#include "queen/graphics.h"
|
2003-10-23 06:44:35 +00:00
|
|
|
#include "queen/input.h"
|
2003-11-26 13:53:17 +00:00
|
|
|
#include "queen/journal.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-11-15 21:33:04 +00:00
|
|
|
#include "queen/sound.h"
|
2003-12-11 13:26:13 +00:00
|
|
|
#include "queen/state.h"
|
2003-10-27 15:00:25 +00:00
|
|
|
#include "queen/talk.h"
|
2003-10-11 10:09:23 +00:00
|
|
|
#include "queen/walk.h"
|
2003-10-17 13:12:50 +00:00
|
|
|
|
2003-09-28 15:50:47 +00:00
|
|
|
|
2003-10-03 19:47:41 +00:00
|
|
|
namespace Queen {
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
Logic::Logic(QueenEngine *vm)
|
|
|
|
: _vm(vm) {
|
2003-10-10 09:19:52 +00:00
|
|
|
_joe.x = _joe.y = 0;
|
2003-10-16 16:58:30 +00:00
|
|
|
_joe.scale = 100;
|
2003-10-13 14:21:17 +00:00
|
|
|
memset(_gameState, 0, sizeof(_gameState));
|
2003-11-09 14:16:46 +00:00
|
|
|
memset(_talkSelected, 0, sizeof(_talkSelected));
|
2003-09-28 15:50:47 +00:00
|
|
|
initialise();
|
2003-12-29 16:35:08 +00:00
|
|
|
if (_vm->resource()->isDemo()) {
|
|
|
|
_preChangeRoom = &Logic::preChangeRoom_Demo;
|
2003-12-29 20:17:43 +00:00
|
|
|
_executeASM = &Logic::executeASM_Demo;
|
|
|
|
} else if (_vm->resource()->isInterview()) {
|
2003-12-29 16:35:08 +00:00
|
|
|
_preChangeRoom = &Logic::preChangeRoom_Interview;
|
2003-12-29 20:17:43 +00:00
|
|
|
_executeASM = &Logic::executeASM_Interview;
|
|
|
|
} else {
|
2003-12-29 16:35:08 +00:00
|
|
|
_preChangeRoom = &Logic::preChangeRoom_Game;
|
2003-12-29 20:17:43 +00:00
|
|
|
_executeASM = &Logic::executeASM_Game;
|
2003-12-29 16:35:08 +00:00
|
|
|
}
|
2003-09-28 15:50:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
void Logic::initialise() {
|
2003-12-11 10:24:27 +00:00
|
|
|
|
2003-10-09 09:09:40 +00:00
|
|
|
int16 i, j;
|
2003-12-11 10:24:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Step 1 : read queen.jas file and 'unserialize' some arrays
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
uint8 *jas = _vm->resource()->loadFile("QUEEN.JAS", 20);
|
2003-12-11 10:24:27 +00:00
|
|
|
uint8 *ptr = jas;
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-14 12:55:31 +00:00
|
|
|
_numRooms = READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
_numNames = READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
_numObjects = READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
_numDescriptions = READ_BE_UINT16(ptr); ptr += 2;
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-14 12:55:31 +00:00
|
|
|
// Object data
|
2003-10-02 14:44:51 +00:00
|
|
|
_objectData = new ObjectData[_numObjects + 1];
|
2003-10-14 12:55:31 +00:00
|
|
|
memset(&_objectData[0], 0, sizeof(ObjectData));
|
2003-10-06 13:20:29 +00:00
|
|
|
for (i = 1; i <= _numObjects; i++) {
|
2003-12-28 01:17:29 +00:00
|
|
|
_objectData[i].readFromBE(ptr);
|
2003-10-02 14:44:51 +00:00
|
|
|
}
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-14 12:55:31 +00:00
|
|
|
// Room data
|
2003-09-28 19:57:01 +00:00
|
|
|
_roomData = new uint16[_numRooms + 2];
|
2003-10-14 12:55:31 +00:00
|
|
|
_roomData[0] = 0;
|
2003-10-06 13:20:29 +00:00
|
|
|
for (i = 1; i <= (_numRooms + 1); i++) {
|
2003-10-14 12:55:31 +00:00
|
|
|
_roomData[i] = READ_BE_UINT16(ptr); ptr += 2;
|
2003-09-28 15:50:47 +00:00
|
|
|
}
|
|
|
|
_roomData[_numRooms + 1] = _numObjects;
|
|
|
|
|
2003-10-14 12:55:31 +00:00
|
|
|
// SFX Name
|
2003-10-02 14:55:28 +00:00
|
|
|
// the following table isn't available in demo version
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->resource()->isDemo()) {
|
2003-10-02 14:55:28 +00:00
|
|
|
_sfxName = NULL;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-02 14:55:28 +00:00
|
|
|
_sfxName = new uint16[_numRooms + 1];
|
2003-10-14 12:55:31 +00:00
|
|
|
_sfxName[0] = 0;
|
2003-10-06 13:20:29 +00:00
|
|
|
for (i = 1; i <= _numRooms; i++) {
|
2003-10-14 12:55:31 +00:00
|
|
|
_sfxName[i] = READ_BE_UINT16(ptr); ptr += 2;
|
2003-10-02 14:55:28 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-28 15:50:47 +00:00
|
|
|
|
2003-10-14 12:55:31 +00:00
|
|
|
// Item information
|
|
|
|
_numItems = READ_BE_UINT16(ptr); ptr += 2;
|
2003-09-28 15:50:47 +00:00
|
|
|
|
2003-10-08 08:55:07 +00:00
|
|
|
_itemData = new ItemData[_numItems + 1];
|
2003-10-14 12:55:31 +00:00
|
|
|
memset(&_itemData[0], 0, sizeof(ItemData));
|
2003-10-06 13:20:29 +00:00
|
|
|
for (i = 1; i <= _numItems; i++) {
|
2003-12-28 01:17:29 +00:00
|
|
|
_itemData[i].readFromBE(ptr);
|
2003-09-28 15:50:47 +00:00
|
|
|
}
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-14 12:55:31 +00:00
|
|
|
// Graphic Image Data
|
|
|
|
_numGraphics = READ_BE_UINT16(ptr); ptr += 2;
|
2003-09-28 15:50:47 +00:00
|
|
|
|
2003-10-02 14:44:51 +00:00
|
|
|
_graphicData = new GraphicData[_numGraphics + 1];
|
2003-10-14 12:55:31 +00:00
|
|
|
memset(&_graphicData[0], 0, sizeof(GraphicData));
|
2003-10-06 13:20:29 +00:00
|
|
|
for (i = 1; i <= _numGraphics; i++) {
|
2003-12-28 01:17:29 +00:00
|
|
|
_graphicData[i].readFromBE(ptr);
|
2003-10-02 14:44:51 +00:00
|
|
|
}
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-06 08:24:38 +00:00
|
|
|
_objMax = new int16[_numRooms + 1];
|
|
|
|
_areaMax = new int16[_numRooms + 1];
|
2003-10-14 12:55:31 +00:00
|
|
|
_area = new Area[_numRooms + 1][MAX_AREAS_NUMBER];
|
2003-10-05 16:07:07 +00:00
|
|
|
|
2003-10-14 12:55:31 +00:00
|
|
|
_objMax[0] = 0;
|
|
|
|
_areaMax[0] = 0;
|
|
|
|
memset(&_area[0], 0, sizeof(Area) * MAX_AREAS_NUMBER);
|
2003-10-06 13:20:29 +00:00
|
|
|
for (i = 1; i <= _numRooms; i++) {
|
2003-10-14 12:55:31 +00:00
|
|
|
_objMax[i] = (int16)READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
_areaMax[i] = (int16)READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
memset(&_area[i][0], 0, sizeof(Area));
|
2003-10-09 09:09:40 +00:00
|
|
|
for (j = 1; j <= _areaMax[i]; j++) {
|
2003-10-14 12:55:31 +00:00
|
|
|
assert(j < MAX_AREAS_NUMBER);
|
2003-12-28 01:17:29 +00:00
|
|
|
_area[i][j].readFromBE(ptr);
|
2003-10-09 09:09:40 +00:00
|
|
|
}
|
2003-10-07 08:22:53 +00:00
|
|
|
}
|
|
|
|
|
2003-10-06 13:20:29 +00:00
|
|
|
_objectBox = new Box[_numObjects + 1];
|
2003-10-14 12:55:31 +00:00
|
|
|
memset(&_objectBox[0], 0, sizeof(Box));
|
2003-10-06 13:20:29 +00:00
|
|
|
for (i = 1; i <= _numObjects; i++) {
|
2003-12-28 01:17:29 +00:00
|
|
|
_objectBox[i].readFromBE(ptr);
|
2003-10-06 13:20:29 +00:00
|
|
|
}
|
2003-10-07 08:22:53 +00:00
|
|
|
|
2003-10-14 12:55:31 +00:00
|
|
|
// Walk OFF Data
|
|
|
|
_numWalkOffs = READ_BE_UINT16(ptr); ptr += 2;
|
2003-10-06 13:20:29 +00:00
|
|
|
|
|
|
|
_walkOffData = new WalkOffData[_numWalkOffs + 1];
|
2003-10-14 12:55:31 +00:00
|
|
|
memset(&_walkOffData[0], 0, sizeof(WalkOffData));
|
2003-10-06 13:20:29 +00:00
|
|
|
for (i = 1; i <= _numWalkOffs; i++) {
|
2003-12-28 01:17:29 +00:00
|
|
|
_walkOffData[i].readFromBE(ptr);
|
2003-10-06 13:20:29 +00:00
|
|
|
}
|
|
|
|
|
2003-10-14 12:55:31 +00:00
|
|
|
// Special Object Descriptions
|
|
|
|
_numObjDesc = READ_BE_UINT16(ptr); ptr += 2;
|
2003-10-06 13:20:29 +00:00
|
|
|
|
|
|
|
_objectDescription = new ObjectDescription[_numObjDesc + 1];
|
2003-10-14 12:55:31 +00:00
|
|
|
memset(&_objectDescription[0], 0, sizeof(ObjectDescription));
|
2003-10-06 13:20:29 +00:00
|
|
|
for (i = 1; i <= _numObjDesc; i++) {
|
2003-12-28 01:17:29 +00:00
|
|
|
_objectDescription[i].readFromBE(ptr);
|
2003-10-06 13:20:29 +00:00
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->command()->readCommandsFrom(ptr);
|
2003-10-12 18:44:44 +00:00
|
|
|
|
2003-10-14 12:55:31 +00:00
|
|
|
_entryObj = READ_BE_UINT16(ptr); ptr += 2;
|
2003-10-12 18:44:44 +00:00
|
|
|
|
2003-10-14 12:55:31 +00:00
|
|
|
// Furniture DATA
|
|
|
|
_numFurniture = READ_BE_UINT16(ptr); ptr += 2;
|
2003-10-12 18:44:44 +00:00
|
|
|
|
|
|
|
_furnitureData = new FurnitureData[_numFurniture + 1];
|
2003-10-14 12:55:31 +00:00
|
|
|
memset(&_furnitureData[0], 0, sizeof(_furnitureData));
|
2003-10-12 18:44:44 +00:00
|
|
|
for (i = 1; i <= _numFurniture; i++) {
|
2003-12-28 01:17:29 +00:00
|
|
|
_furnitureData[i].readFromBE(ptr);
|
2003-10-12 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2003-10-14 12:55:31 +00:00
|
|
|
// Actors
|
|
|
|
_numActors = READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
_numAAnim = READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
_numAName = READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
_numAFile = READ_BE_UINT16(ptr); ptr += 2;
|
2003-10-12 18:44:44 +00:00
|
|
|
|
|
|
|
_actorData = new ActorData[_numActors + 1];
|
2003-10-14 12:55:31 +00:00
|
|
|
memset(&_actorData[0], 0, sizeof(ActorData));
|
2003-10-12 18:44:44 +00:00
|
|
|
for (i = 1; i <= _numActors; i++) {
|
2003-12-28 01:17:29 +00:00
|
|
|
_actorData[i].readFromBE(ptr);
|
2003-10-12 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2003-10-14 12:55:31 +00:00
|
|
|
_numGraphicAnim = READ_BE_UINT16(ptr); ptr += 2;
|
2003-10-12 18:44:44 +00:00
|
|
|
|
|
|
|
_graphicAnim = new GraphicAnim[_numGraphicAnim + 1];
|
2003-10-14 12:55:31 +00:00
|
|
|
memset(&_graphicAnim[0], 0, sizeof(GraphicAnim));
|
2003-10-12 18:44:44 +00:00
|
|
|
for (i = 1; i <= _numGraphicAnim; i++) {
|
2003-12-28 01:17:29 +00:00
|
|
|
_graphicAnim[i].readFromBE(ptr);
|
2003-10-12 18:44:44 +00:00
|
|
|
}
|
2003-10-13 14:21:17 +00:00
|
|
|
|
2003-10-12 18:44:44 +00:00
|
|
|
_currentRoom = _objectData[_entryObj].room;
|
|
|
|
_entryObj = 0;
|
2003-10-14 12:55:31 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if(memcmp(ptr, _vm->resource()->JASVersion(), 5) != 0) {
|
2003-10-14 12:55:31 +00:00
|
|
|
warning("Unexpected queen.jas file format");
|
|
|
|
}
|
2003-12-11 10:24:27 +00:00
|
|
|
|
|
|
|
delete[] jas;
|
|
|
|
|
|
|
|
|
|
|
|
// Step 2 : read queen2.jas and grab all description texts
|
2003-10-12 18:44:44 +00:00
|
|
|
|
|
|
|
_objDescription = new char*[_numDescriptions + 1];
|
|
|
|
_objDescription[0] = 0;
|
|
|
|
for (i = 1; i <= _numDescriptions; i++)
|
2003-12-11 22:16:35 +00:00
|
|
|
_objDescription[i] = _vm->resource()->getJAS2Line();
|
2003-10-12 18:44:44 +00:00
|
|
|
|
|
|
|
//Patch for German text bug
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->resource()->getLanguage() == GERMAN) {
|
2003-10-12 18:44:44 +00:00
|
|
|
char *txt = new char[48];
|
|
|
|
strcpy(txt, "Es bringt nicht viel, das festzubinden.");
|
|
|
|
_objDescription[296] = txt;
|
|
|
|
}
|
|
|
|
|
|
|
|
_objName = new char*[_numNames + 1];
|
|
|
|
_objName[0] = 0;
|
|
|
|
for (i = 1; i <= _numNames; i++)
|
2003-12-11 22:16:35 +00:00
|
|
|
_objName[i] = _vm->resource()->getJAS2Line();
|
2003-10-12 18:44:44 +00:00
|
|
|
|
|
|
|
_roomName = new char*[_numRooms + 1];
|
|
|
|
_roomName[0] = 0;
|
|
|
|
for (i = 1; i <= _numRooms; i++)
|
2003-12-11 22:16:35 +00:00
|
|
|
_roomName[i] = _vm->resource()->getJAS2Line();
|
2003-10-12 18:44:44 +00:00
|
|
|
|
2003-12-12 10:33:34 +00:00
|
|
|
_verbName[0] = 0;
|
2003-10-12 18:44:44 +00:00
|
|
|
for (i = 1; i <= 12; i++)
|
2003-12-12 10:33:34 +00:00
|
|
|
_verbName[i] = _vm->resource()->getJAS2Line();
|
2003-10-12 18:44:44 +00:00
|
|
|
|
|
|
|
_joeResponse[0] = 0;
|
|
|
|
for (i = 1; i <= JOE_RESPONSE_MAX; i++)
|
2003-12-11 22:16:35 +00:00
|
|
|
_joeResponse[i] = _vm->resource()->getJAS2Line();
|
2003-10-12 18:44:44 +00:00
|
|
|
|
|
|
|
_aAnim = new char*[_numAAnim + 1];
|
|
|
|
_aAnim[0] = 0;
|
|
|
|
for (i = 1; i <= _numAAnim; i++)
|
2003-12-11 22:16:35 +00:00
|
|
|
_aAnim[i] = _vm->resource()->getJAS2Line();
|
2003-10-12 18:44:44 +00:00
|
|
|
|
|
|
|
_aName = new char*[_numAName + 1];
|
|
|
|
_aName[0] = 0;
|
|
|
|
for (i = 1; i <= _numAName; i++)
|
2003-12-11 22:16:35 +00:00
|
|
|
_aName[i] = _vm->resource()->getJAS2Line();
|
2003-10-12 18:44:44 +00:00
|
|
|
|
|
|
|
_aFile = new char*[_numAFile + 1];
|
|
|
|
_aFile[0] = 0;
|
|
|
|
for (i = 1; i <= _numAFile; i++)
|
2003-12-11 22:16:35 +00:00
|
|
|
_aFile[i] = _vm->resource()->getJAS2Line();
|
2003-10-12 18:44:44 +00:00
|
|
|
|
2003-12-11 10:24:27 +00:00
|
|
|
|
|
|
|
// Step 3 : initialise game state / variables
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->command()->clear(false);
|
2003-11-08 11:32:32 +00:00
|
|
|
_scene = 0;
|
2003-10-31 13:47:28 +00:00
|
|
|
memset(_gameState, 0, sizeof(_gameState));
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->loadPanel();
|
|
|
|
_vm->graphics()->bobSetupControl();
|
2003-10-14 19:06:44 +00:00
|
|
|
joeSetup();
|
2003-10-13 14:21:17 +00:00
|
|
|
zoneSetupPanel();
|
2003-10-12 17:38:01 +00:00
|
|
|
|
2003-10-11 10:09:23 +00:00
|
|
|
_oldRoom = 0;
|
2003-09-28 15:50:47 +00:00
|
|
|
}
|
|
|
|
|
2003-10-02 11:03:34 +00:00
|
|
|
|
2003-12-02 16:49:56 +00:00
|
|
|
ObjectData* Logic::objectData(int index) const {
|
2003-12-10 15:36:44 +00:00
|
|
|
|
|
|
|
if (index < 0) {
|
|
|
|
warning("Logic::objectData() called with negative object index: %i", index);
|
|
|
|
}
|
2003-12-05 13:56:07 +00:00
|
|
|
index = ABS(index); // cyx: is that really necessary ?
|
2003-11-06 21:06:01 +00:00
|
|
|
if (index <= _numObjects)
|
|
|
|
return &_objectData[index];
|
|
|
|
else
|
|
|
|
error("[Logic::objectData] Invalid object data index: %i", index);
|
2003-10-02 14:44:51 +00:00
|
|
|
}
|
2003-10-02 06:38:58 +00:00
|
|
|
|
2003-12-02 16:49:56 +00:00
|
|
|
uint16 Logic::roomData(int room) const {
|
2003-10-02 08:49:38 +00:00
|
|
|
return _roomData[room];
|
2003-10-02 06:38:58 +00:00
|
|
|
}
|
|
|
|
|
2003-12-02 16:49:56 +00:00
|
|
|
uint16 Logic::objMax(int room) const {
|
2003-10-02 08:49:38 +00:00
|
|
|
return _objMax[room];
|
2003-10-02 06:38:58 +00:00
|
|
|
}
|
|
|
|
|
2003-12-02 16:49:56 +00:00
|
|
|
GraphicData *Logic::graphicData(int index) const {
|
|
|
|
return &_graphicData[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
Area *Logic::area(int room, int num) const {
|
2003-10-09 13:14:16 +00:00
|
|
|
return &_area[room][num];
|
|
|
|
}
|
|
|
|
|
2003-12-02 16:49:56 +00:00
|
|
|
Area *Logic::currentRoomArea(int num) const {
|
2003-10-18 17:42:24 +00:00
|
|
|
if (num == 0 || num > _areaMax[_currentRoom]) {
|
|
|
|
error("Logic::currentRoomArea() - Bad area number = %d (max = %d), currentRoom = %d", num, _areaMax[_currentRoom], _currentRoom);
|
|
|
|
}
|
2003-11-06 21:06:01 +00:00
|
|
|
|
2003-10-09 13:14:16 +00:00
|
|
|
return &_area[_currentRoom][num];
|
|
|
|
}
|
|
|
|
|
2003-12-02 16:49:56 +00:00
|
|
|
uint16 Logic::areaMax(int room) const {
|
2003-10-09 13:14:16 +00:00
|
|
|
return _areaMax[room];
|
|
|
|
}
|
|
|
|
|
2003-12-02 16:49:56 +00:00
|
|
|
uint16 Logic::currentRoomAreaMax() const {
|
2003-10-09 13:14:16 +00:00
|
|
|
return _areaMax[_currentRoom];
|
2003-10-02 11:03:34 +00:00
|
|
|
}
|
|
|
|
|
2003-12-02 16:49:56 +00:00
|
|
|
uint16 Logic::walkOffCount() const {
|
2003-10-02 08:49:38 +00:00
|
|
|
return _numWalkOffs;
|
|
|
|
}
|
|
|
|
|
2003-12-02 16:49:56 +00:00
|
|
|
WalkOffData *Logic::walkOffData(int index) const {
|
2003-10-06 13:20:29 +00:00
|
|
|
return &_walkOffData[index];
|
2003-10-02 08:49:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
uint16 Logic::findBob(uint16 obj) {
|
2003-10-02 14:44:51 +00:00
|
|
|
|
|
|
|
uint16 i;
|
|
|
|
uint16 bobnum = 0;
|
|
|
|
uint16 bobtype = 0; // 1 for animated, 0 for static
|
|
|
|
|
2003-10-02 19:37:51 +00:00
|
|
|
if (obj > _numObjects)
|
|
|
|
error("Object index (%i) > _numObjects (%i)", obj, _numObjects);
|
2003-10-02 19:20:00 +00:00
|
|
|
|
2003-10-02 14:44:51 +00:00
|
|
|
uint16 room = _objectData[obj].room;
|
2003-10-02 19:20:00 +00:00
|
|
|
|
|
|
|
if (room >= _numRooms) {
|
|
|
|
warning("room (%i) > _numRooms (%i)", room, _numRooms);
|
|
|
|
}
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-02 14:44:51 +00:00
|
|
|
int16 img = _objectData[obj].image;
|
|
|
|
if(img != 0) {
|
|
|
|
if(img == -3 || img == -4) {
|
|
|
|
// a person object
|
|
|
|
for(i = _roomData[room] + 1; i <= obj; ++i) {
|
|
|
|
img = _objectData[i].image;
|
|
|
|
if(img == -3 || img == -4) {
|
|
|
|
++bobnum;
|
|
|
|
}
|
|
|
|
}
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-02 14:44:51 +00:00
|
|
|
if(img <= -10) {
|
|
|
|
// object has been turned off, but the image order hasn't been updated
|
|
|
|
if(_graphicData[-(img + 10)].lastFrame != 0) {
|
|
|
|
bobtype = 1;
|
|
|
|
}
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if(img == -2) {
|
2003-10-02 14:44:51 +00:00
|
|
|
// -1 static, -2 animated
|
|
|
|
bobtype = 1;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if(img > 0) {
|
2003-10-02 14:44:51 +00:00
|
|
|
if(_graphicData[img].lastFrame != 0) {
|
|
|
|
bobtype = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16 idxAnimated = 0;
|
|
|
|
uint16 idxStatic = 0;
|
|
|
|
for(i = _roomData[room] + 1; i <= obj; ++i) {
|
|
|
|
img = _objectData[i].image;
|
|
|
|
if(img <= -10) {
|
|
|
|
if(_graphicData[-(img + 10)].lastFrame != 0) {
|
|
|
|
++idxAnimated;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-02 14:44:51 +00:00
|
|
|
++idxStatic;
|
|
|
|
}
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if(img > 0) {
|
2003-10-02 14:44:51 +00:00
|
|
|
if(img > 5000) {
|
|
|
|
img -= 5000;
|
|
|
|
}
|
2003-10-02 19:20:00 +00:00
|
|
|
|
|
|
|
if (img >= _numGraphics)
|
|
|
|
warning("img (%i) >= _numGraphics (%i)", img, _numGraphics);
|
|
|
|
|
2003-10-02 14:44:51 +00:00
|
|
|
if(_graphicData[img].lastFrame != 0) {
|
|
|
|
++idxAnimated;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-02 14:44:51 +00:00
|
|
|
++idxStatic;
|
|
|
|
}
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if(img == -1) {
|
2003-10-03 19:59:19 +00:00
|
|
|
++idxStatic;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if(img == -2) {
|
2003-10-03 19:59:19 +00:00
|
|
|
++idxAnimated;
|
|
|
|
}
|
2003-10-02 14:44:51 +00:00
|
|
|
}
|
|
|
|
if(bobtype == 0) {
|
|
|
|
// static bob
|
2003-10-03 19:59:19 +00:00
|
|
|
if(idxStatic > 0) {
|
2003-10-11 10:09:23 +00:00
|
|
|
bobnum = 19 + _numFurnitureStatic + idxStatic;
|
2003-10-03 19:59:19 +00:00
|
|
|
}
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-02 14:44:51 +00:00
|
|
|
// animated bob
|
2003-10-03 19:59:19 +00:00
|
|
|
if(idxAnimated > 0) {
|
2003-10-12 13:16:35 +00:00
|
|
|
bobnum = 4 + _numFurnitureAnimated + idxAnimated;
|
2003-10-03 19:59:19 +00:00
|
|
|
}
|
2003-10-02 14:44:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bobnum;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
uint16 Logic::findFrame(uint16 obj) {
|
2003-10-02 14:44:51 +00:00
|
|
|
|
|
|
|
uint16 i;
|
|
|
|
uint16 framenum = 0;
|
|
|
|
|
|
|
|
uint16 room = _objectData[obj].room;
|
|
|
|
int16 img = _objectData[obj].image;
|
|
|
|
if(img == -3 || img == -4) {
|
|
|
|
uint16 bobnum = 0;
|
|
|
|
for(i = _roomData[room] + 1; i <= obj; ++i) {
|
|
|
|
img = _objectData[i].image;
|
|
|
|
if(img == -3 || img == -4) {
|
|
|
|
++bobnum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(bobnum <= 3) {
|
2003-10-12 13:16:35 +00:00
|
|
|
framenum = 29 + FRAMES_JOE_XTRA + bobnum;
|
2003-10-02 14:44:51 +00:00
|
|
|
}
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-02 14:44:51 +00:00
|
|
|
uint16 idx = 0;
|
|
|
|
for(i = _roomData[room] + 1; i < obj; ++i) {
|
|
|
|
img = _objectData[i].image;
|
|
|
|
if(img <= -10) {
|
|
|
|
GraphicData* pgd = &_graphicData[-(img + 10)];
|
2003-11-26 23:06:34 +00:00
|
|
|
if(pgd->lastFrame != 0) {
|
2003-10-02 14:44:51 +00:00
|
|
|
// skip all the frames of the animation
|
|
|
|
idx += ABS(pgd->lastFrame) - pgd->firstFrame + 1;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-12 13:16:35 +00:00
|
|
|
// static bob, skip one frame
|
2003-10-02 14:44:51 +00:00
|
|
|
++idx;
|
|
|
|
}
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if(img == -1) {
|
2003-10-02 14:44:51 +00:00
|
|
|
++idx;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if(img > 0) {
|
2003-10-02 14:44:51 +00:00
|
|
|
if(img > 5000) {
|
|
|
|
img -= 5000;
|
|
|
|
}
|
|
|
|
GraphicData* pgd = &_graphicData[img];
|
|
|
|
uint16 lastFrame = ABS(pgd->lastFrame);
|
|
|
|
if(pgd->firstFrame < 0) {
|
|
|
|
idx += lastFrame;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if(lastFrame != 0) {
|
2003-10-02 14:44:51 +00:00
|
|
|
idx += (lastFrame - pgd->firstFrame) + 1;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-02 14:44:51 +00:00
|
|
|
++idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
img = _objectData[obj].image;
|
|
|
|
if(img <= -10) {
|
|
|
|
GraphicData* pgd = &_graphicData[-(img + 10)];
|
|
|
|
if(pgd->lastFrame != 0) {
|
2003-10-03 19:59:19 +00:00
|
|
|
idx += ABS(pgd->lastFrame) - pgd->firstFrame + 1;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-02 14:44:51 +00:00
|
|
|
++idx;
|
|
|
|
}
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if(img == -1 || img > 0) {
|
2003-10-02 14:44:51 +00:00
|
|
|
++idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculate only if there are person frames
|
|
|
|
if(idx > 0) {
|
2003-10-12 13:16:35 +00:00
|
|
|
framenum = 36 + FRAMES_JOE_XTRA + _numFurnitureStatic + _numFurnitureAnimatedLen + idx;
|
2003-10-02 14:44:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return framenum;
|
|
|
|
}
|
2003-10-03 19:47:41 +00:00
|
|
|
|
2003-10-10 09:19:52 +00:00
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
uint16 Logic::objectForPerson(uint16 bobNum) const {
|
2003-10-10 09:19:52 +00:00
|
|
|
|
|
|
|
uint16 bobcur = 0;
|
|
|
|
// first object number in the room
|
|
|
|
uint16 cur = _roomData[_currentRoom] + 1;
|
|
|
|
// last object number in the room
|
|
|
|
uint16 last = _roomData[_currentRoom + 1];
|
|
|
|
while (cur <= last) {
|
|
|
|
int16 image = _objectData[cur].image;
|
|
|
|
if (image == -3 || image == -4) {
|
|
|
|
// the object is a bob
|
|
|
|
++bobcur;
|
|
|
|
}
|
|
|
|
if (bobcur == bobNum) {
|
|
|
|
return cur;
|
|
|
|
}
|
2003-10-10 20:03:34 +00:00
|
|
|
++cur;
|
2003-10-10 09:19:52 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
WalkOffData *Logic::walkOffPointForObject(uint16 obj) const {
|
2003-10-10 09:19:52 +00:00
|
|
|
|
|
|
|
uint16 i;
|
|
|
|
for (i = 1; i <= _numWalkOffs; ++i) {
|
|
|
|
if (_walkOffData[i].entryObj == obj) {
|
|
|
|
return &_walkOffData[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-07 00:26:04 +00:00
|
|
|
void Logic::joeFacing(uint16 dir) {
|
|
|
|
_joe.facing = dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Logic::joeX(uint16 x) {
|
|
|
|
_joe.x = x;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Logic::joeY(uint16 y) {
|
|
|
|
_joe.y = y;
|
|
|
|
}
|
|
|
|
|
2003-11-15 15:44:50 +00:00
|
|
|
void Logic::joeWalk(JoeWalkMode walking) {
|
2003-10-15 09:23:05 +00:00
|
|
|
_joe.walk = walking;
|
2003-11-15 21:16:01 +00:00
|
|
|
|
|
|
|
// Do this so that Input doesn't need to know the walk value
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->dialogueRunning(JWM_SPEAK == walking);
|
2003-10-09 09:09:40 +00:00
|
|
|
}
|
|
|
|
|
2003-10-09 13:14:16 +00:00
|
|
|
void Logic::joeScale(uint16 scale) {
|
|
|
|
_joe.scale = scale;
|
|
|
|
}
|
|
|
|
|
2003-11-27 13:49:00 +00:00
|
|
|
void Logic::joeCutFacing(uint16 dir) {
|
|
|
|
|
|
|
|
_joe.cutFacing = dir;
|
|
|
|
}
|
|
|
|
|
2003-10-14 19:06:44 +00:00
|
|
|
void Logic::joePrevFacing(uint16 dir) {
|
|
|
|
_joe.prevFacing = dir;
|
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
int16 Logic::gameState(int index) {
|
2003-10-04 08:50:48 +00:00
|
|
|
if (index >= 0 && index < GAME_STATE_COUNT)
|
|
|
|
return _gameState[index];
|
|
|
|
else
|
|
|
|
error("[QueenLogic::gameState] invalid index: %i", index);
|
|
|
|
}
|
|
|
|
|
2003-10-05 16:07:07 +00:00
|
|
|
void Logic::gameState(int index, int16 newValue) {
|
2003-11-08 16:36:54 +00:00
|
|
|
if (index >= 0 && index < GAME_STATE_COUNT) {
|
2003-12-29 21:05:33 +00:00
|
|
|
// debug(6, "Logic::gameState() - GAMESTATE[%d] = %d", index, newValue);
|
2003-11-08 16:36:54 +00:00
|
|
|
_gameState[index] = newValue;
|
|
|
|
}
|
2003-10-04 08:50:48 +00:00
|
|
|
else
|
|
|
|
error("[QueenLogic::gameState] invalid index: %i", index);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-09 09:09:40 +00:00
|
|
|
void Logic::zoneSet(uint16 screen, uint16 zone, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
|
|
|
|
|
2003-10-18 17:42:24 +00:00
|
|
|
debug(9, "Logic::zoneSet(%d, %d, (%d,%d), (%d,%d))", screen, zone, x1, y1, x2, y2);
|
2003-10-09 09:09:40 +00:00
|
|
|
ZoneSlot *pzs = &_zones[screen][zone];
|
|
|
|
pzs->valid = true;
|
|
|
|
pzs->box.x1 = x1;
|
|
|
|
pzs->box.y1 = y1;
|
|
|
|
pzs->box.x2 = x2;
|
|
|
|
pzs->box.y2 = y2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::zoneSet(uint16 screen, uint16 zone, const Box& box) {
|
|
|
|
|
|
|
|
debug(9, "Logic::zoneSet(%d, %d, (%d,%d), (%d,%d))", screen, zone, box.x1, box.y1, box.x2, box.y2);
|
|
|
|
ZoneSlot *pzs = &_zones[screen][zone];
|
|
|
|
pzs->valid = true;
|
|
|
|
pzs->box = box;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-25 09:11:35 +00:00
|
|
|
uint16 Logic::zoneIn(uint16 screen, uint16 x, uint16 y) const {
|
2003-10-09 09:09:40 +00:00
|
|
|
|
2003-10-31 13:47:28 +00:00
|
|
|
debug(9, "Logic::zoneIn(%d, (%d,%d))", screen, x, y);
|
2003-10-09 09:09:40 +00:00
|
|
|
int i;
|
|
|
|
if (screen == ZONE_PANEL) {
|
|
|
|
y -= ROOM_ZONE_HEIGHT;
|
|
|
|
}
|
|
|
|
for(i = 1; i < MAX_ZONES_NUMBER; ++i) {
|
2003-10-25 09:11:35 +00:00
|
|
|
const ZoneSlot *pzs = &_zones[screen][i];
|
2003-10-09 09:09:40 +00:00
|
|
|
if (pzs->valid && pzs->box.contains(x, y)) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-25 09:11:35 +00:00
|
|
|
uint16 Logic::zoneInArea(uint16 screen, uint16 x, uint16 y) const {
|
|
|
|
|
2003-10-09 09:09:40 +00:00
|
|
|
uint16 zone = zoneIn(screen, x, y);
|
|
|
|
if (zone <= _objMax[_currentRoom]) {
|
|
|
|
zone = 0;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-09 09:09:40 +00:00
|
|
|
zone -= _objMax[_currentRoom];
|
|
|
|
}
|
|
|
|
return zone;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::zoneClearAll(uint16 screen) {
|
|
|
|
|
2003-10-31 13:47:28 +00:00
|
|
|
debug(9, "Logic::zoneClearAll(%d)", screen);
|
2003-10-09 09:09:40 +00:00
|
|
|
int i;
|
|
|
|
for(i = 1; i < MAX_ZONES_NUMBER; ++i) {
|
|
|
|
_zones[screen][i].valid = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::zoneSetup() {
|
|
|
|
|
2003-10-18 17:42:24 +00:00
|
|
|
debug(9, "Logic::zoneSetup()");
|
2003-10-09 09:09:40 +00:00
|
|
|
zoneClearAll(ZONE_ROOM);
|
|
|
|
|
|
|
|
int i;
|
|
|
|
int zoneNum;
|
|
|
|
|
|
|
|
// setup objects zones
|
|
|
|
uint16 maxObjRoom = _objMax[_currentRoom];
|
|
|
|
uint16 objRoomNum = _roomData[_currentRoom];
|
|
|
|
zoneNum = 1;
|
|
|
|
for (i = objRoomNum + 1; i <= objRoomNum + maxObjRoom; ++i) {
|
|
|
|
if (_objectData[i].name != 0) {
|
|
|
|
zoneSet(ZONE_ROOM, zoneNum, _objectBox[i]);
|
|
|
|
}
|
|
|
|
++zoneNum;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup room zones (areas)
|
|
|
|
uint16 maxAreaRoom = _areaMax[_currentRoom];
|
|
|
|
for (zoneNum = 1; zoneNum <= maxAreaRoom; ++zoneNum) {
|
|
|
|
zoneSet(ZONE_ROOM, maxObjRoom + zoneNum, _area[_currentRoom][zoneNum].box);
|
2003-10-11 10:09:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-12 17:38:01 +00:00
|
|
|
void Logic::zoneSetupPanel() {
|
|
|
|
|
|
|
|
// verbs
|
2003-10-25 09:11:35 +00:00
|
|
|
int i;
|
2003-10-12 17:38:01 +00:00
|
|
|
for (i = 0; i <= 7; ++i) {
|
|
|
|
int x = i * 20;
|
|
|
|
zoneSet(ZONE_PANEL, i + 1, x, 10, x + 19, 49);
|
|
|
|
}
|
|
|
|
|
|
|
|
// inventory scrolls
|
2003-10-25 09:11:35 +00:00
|
|
|
zoneSet(ZONE_PANEL, 9, 160, 10, 179, 29);
|
|
|
|
zoneSet(ZONE_PANEL, 10, 160, 30, 179, 49);
|
2003-10-12 17:38:01 +00:00
|
|
|
|
|
|
|
// inventory items
|
2003-10-25 09:11:35 +00:00
|
|
|
zoneSet(ZONE_PANEL, 11, 180, 10, 213, 49);
|
|
|
|
zoneSet(ZONE_PANEL, 12, 214, 10, 249, 49);
|
|
|
|
zoneSet(ZONE_PANEL, 13, 250, 10, 284, 49);
|
|
|
|
zoneSet(ZONE_PANEL, 14, 285, 10, 320, 49);
|
2003-10-12 17:38:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-11 10:09:23 +00:00
|
|
|
void Logic::roomErase() {
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->frameEraseAll(false);
|
|
|
|
_vm->graphics()->bankErase(15);
|
|
|
|
_vm->graphics()->bankErase(11);
|
|
|
|
_vm->graphics()->bankErase(10);
|
|
|
|
_vm->graphics()->bankErase(12);
|
2003-10-11 10:09:23 +00:00
|
|
|
|
2003-10-16 13:54:48 +00:00
|
|
|
if (_currentRoom >= 114) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palFadeOut(0, 255, _currentRoom);
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palFadeOut(0, 223, _currentRoom);
|
2003-10-16 13:54:48 +00:00
|
|
|
}
|
|
|
|
|
2003-10-11 10:09:23 +00:00
|
|
|
// TODO: credits system
|
2003-10-13 14:21:17 +00:00
|
|
|
|
|
|
|
// invalidates all persons animations
|
|
|
|
uint16 i;
|
|
|
|
for (i = 0; i <= 3; ++i) {
|
|
|
|
_personFrames[i] = 0;
|
|
|
|
}
|
|
|
|
for (i = 1; i <= 16; ++i) {
|
2003-10-15 16:31:51 +00:00
|
|
|
_newAnim[i][0].frame = 0;
|
2003-10-13 14:21:17 +00:00
|
|
|
}
|
2003-10-11 10:09:23 +00:00
|
|
|
|
|
|
|
uint16 cur = _roomData[_oldRoom] + 1;
|
|
|
|
uint16 last = _roomData[_oldRoom + 1];
|
|
|
|
while (cur <= last) {
|
|
|
|
ObjectData *pod = &_objectData[cur];
|
|
|
|
if (pod->name == 0) {
|
|
|
|
// object has been deleted, invalidate image
|
|
|
|
pod->image = 0;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if (pod->image > -4000 && pod->image <= -10) {
|
2003-10-11 10:09:23 +00:00
|
|
|
if (_graphicData[ABS(pod->image + 10)].lastFrame == 0) {
|
|
|
|
// static Bob
|
|
|
|
pod->image = -1;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-11 10:09:23 +00:00
|
|
|
// animated Bob
|
|
|
|
pod->image = -2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++cur;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-12 13:16:35 +00:00
|
|
|
void Logic::roomSetupFurniture() {
|
2003-11-08 16:36:54 +00:00
|
|
|
|
|
|
|
int16 gstate[9];
|
2003-10-11 10:09:23 +00:00
|
|
|
_numFurnitureStatic = 0;
|
|
|
|
_numFurnitureAnimated = 0;
|
|
|
|
_numFurnitureAnimatedLen = 0;
|
|
|
|
uint16 curImage = 36 + FRAMES_JOE_XTRA;
|
|
|
|
|
|
|
|
// count the furniture and update gameState
|
|
|
|
uint16 furnitureTotal = 0;
|
|
|
|
uint16 i;
|
2003-10-13 14:21:17 +00:00
|
|
|
for (i = 1; i <= _numFurniture; ++i) {
|
|
|
|
if (_furnitureData[i].room == _currentRoom) {
|
|
|
|
++furnitureTotal;
|
2003-11-08 16:36:54 +00:00
|
|
|
gstate[furnitureTotal] = _furnitureData[i].gameStateValue;
|
2003-10-13 14:21:17 +00:00
|
|
|
}
|
|
|
|
}
|
2003-10-12 13:16:35 +00:00
|
|
|
if (furnitureTotal == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2003-10-11 10:09:23 +00:00
|
|
|
|
|
|
|
// unpack the furniture from the bank 15
|
|
|
|
// there are 3 kinds :
|
2003-10-12 13:16:35 +00:00
|
|
|
// - static (bobs), gamestate range = ]0;5000]
|
2003-10-11 10:09:23 +00:00
|
|
|
// - animated (bobs), gamestate range = ]0;5000]
|
2003-10-12 13:16:35 +00:00
|
|
|
// - static (paste downs), gamestate range = [5000; [
|
2003-10-11 10:09:23 +00:00
|
|
|
|
2003-10-12 13:16:35 +00:00
|
|
|
// unpack the static bobs
|
2003-10-11 10:09:23 +00:00
|
|
|
for (i = 1; i <= furnitureTotal; ++i) {
|
2003-11-08 16:36:54 +00:00
|
|
|
int16 obj = gstate[i];
|
2003-10-11 10:09:23 +00:00
|
|
|
if (obj > 0 && obj <= 5000) {
|
|
|
|
GraphicData *pgd = &_graphicData[obj];
|
|
|
|
if (pgd->lastFrame == 0) {
|
|
|
|
++_numFurnitureStatic;
|
|
|
|
++curImage;
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(pgd->firstFrame, curImage, 15);
|
2003-10-12 13:16:35 +00:00
|
|
|
++_numFrames;
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *pbs = _vm->graphics()->bob(19 + _numFurnitureStatic);
|
2003-12-29 20:51:28 +00:00
|
|
|
pbs->curPos(pgd->x, pgd->y);
|
2003-10-11 10:09:23 +00:00
|
|
|
pbs->frameNum = curImage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// unpack the animated bobs
|
|
|
|
uint16 curBob = 0;
|
|
|
|
for (i = 1; i <= furnitureTotal; ++i) {
|
2003-11-08 16:36:54 +00:00
|
|
|
int16 obj = gstate[i];
|
2003-10-11 10:09:23 +00:00
|
|
|
if (obj > 0 && obj <= 5000) {
|
|
|
|
GraphicData *pgd = &_graphicData[obj];
|
|
|
|
|
|
|
|
bool rebound = false;
|
|
|
|
int16 lastFrame = pgd->lastFrame;
|
|
|
|
if (lastFrame < 0) {
|
|
|
|
rebound = true;
|
|
|
|
lastFrame = -lastFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastFrame > 0) {
|
|
|
|
_numFurnitureAnimatedLen += lastFrame - pgd->firstFrame + 1;
|
|
|
|
++_numFurnitureAnimated;
|
|
|
|
uint16 image = curImage + 1;
|
|
|
|
int k;
|
2003-11-13 10:44:31 +00:00
|
|
|
for (k = pgd->firstFrame; k <= lastFrame; ++k) {
|
2003-10-11 10:09:23 +00:00
|
|
|
++curImage;
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(k, curImage, 15);
|
2003-10-12 13:16:35 +00:00
|
|
|
++_numFrames;
|
2003-10-11 10:09:23 +00:00
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *pbs = _vm->graphics()->bob(5 + curBob);
|
2003-11-30 20:41:02 +00:00
|
|
|
pbs->animNormal(image, curImage, pgd->speed / 4, rebound, false);
|
2003-12-29 20:51:28 +00:00
|
|
|
pbs->curPos(pgd->x, pgd->y);
|
2003-10-11 10:09:23 +00:00
|
|
|
++curBob;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-12 13:16:35 +00:00
|
|
|
// unpack the paste downs
|
2003-10-11 10:09:23 +00:00
|
|
|
++curImage;
|
|
|
|
for (i = 1; i <= furnitureTotal; ++i) {
|
2003-11-08 16:36:54 +00:00
|
|
|
int16 obj = gstate[i];
|
2003-10-11 10:09:23 +00:00
|
|
|
if (obj > 5000) {
|
|
|
|
obj -= 5000;
|
|
|
|
GraphicData *pgd = &_graphicData[obj];
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(pgd->firstFrame, curImage, 15);
|
|
|
|
_vm->graphics()->bobPaste(curImage, pgd->x, pgd->y);
|
2003-10-12 13:16:35 +00:00
|
|
|
// no need to increment curImage here, as bobPaste() destroys the
|
|
|
|
// unpacked frame after blitting it
|
2003-10-11 10:09:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::roomSetupObjects() {
|
2003-10-12 13:16:35 +00:00
|
|
|
|
|
|
|
uint16 i;
|
2003-10-12 16:37:56 +00:00
|
|
|
// furniture frames are reserved in ::roomSetupFurniture(), we append objects
|
|
|
|
// frames after the furniture ones.
|
2003-10-12 13:16:35 +00:00
|
|
|
uint16 curImage = 36 + FRAMES_JOE_XTRA + _numFurnitureStatic + _numFurnitureAnimatedLen;
|
|
|
|
uint16 firstRoomObj = _roomData[_currentRoom] + 1;
|
|
|
|
uint16 lastRoomObj = _roomData[_currentRoom + 1];
|
2003-10-12 16:37:56 +00:00
|
|
|
uint16 numObjectStatic = 0;
|
|
|
|
uint16 numObjectAnimated = 0;
|
|
|
|
uint16 curBob;
|
2003-10-12 13:16:35 +00:00
|
|
|
|
2003-10-12 16:37:56 +00:00
|
|
|
// invalidates all Bobs for persons (except Joe's one)
|
2003-10-12 13:16:35 +00:00
|
|
|
for (i = 1; i <= 3; ++i) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bob(i)->active = false;
|
2003-10-12 13:16:35 +00:00
|
|
|
}
|
|
|
|
|
2003-10-12 16:37:56 +00:00
|
|
|
// static/animated Bobs
|
|
|
|
for (i = firstRoomObj; i <= lastRoomObj; ++i) {
|
2003-10-15 08:46:18 +00:00
|
|
|
ObjectData *pod = &_objectData[i];
|
2003-10-12 16:37:56 +00:00
|
|
|
// setup blanks bobs for turned off objects (in case
|
|
|
|
// you turn them on again)
|
2003-10-15 08:46:18 +00:00
|
|
|
if (pod->image == -1) {
|
2003-10-12 16:37:56 +00:00
|
|
|
// static OFF Bob
|
|
|
|
curBob = 20 + _numFurnitureStatic + numObjectStatic;
|
|
|
|
++numObjectStatic;
|
|
|
|
// create a blank frame for the for the OFF object
|
|
|
|
++_numFrames;
|
|
|
|
++curImage;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if(pod->image == -2) {
|
2003-10-12 16:37:56 +00:00
|
|
|
// animated OFF Bob
|
|
|
|
curBob = 5 + _numFurnitureAnimated + numObjectAnimated;
|
|
|
|
++numObjectAnimated;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if(pod->image > 0 && pod->image < 5000) {
|
2003-10-15 08:46:18 +00:00
|
|
|
GraphicData *pgd = &_graphicData[pod->image];
|
|
|
|
int16 lastFrame = pgd->lastFrame;
|
|
|
|
bool rebound = false;
|
|
|
|
if (lastFrame < 0) {
|
|
|
|
lastFrame = -lastFrame;
|
|
|
|
rebound = true;
|
|
|
|
}
|
|
|
|
if (pgd->firstFrame < 0) {
|
2003-10-15 16:31:51 +00:00
|
|
|
// FIXME: if(TEMPA[1]<0) bobs[CURRBOB].xflip=1;
|
|
|
|
curBob = 5 + _numFurnitureAnimated;
|
2003-10-20 08:34:48 +00:00
|
|
|
animSetup(pgd, curImage + 1, curBob + numObjectAnimated, pod->name > 0);
|
|
|
|
curImage += pgd->lastFrame;
|
2003-10-15 16:31:51 +00:00
|
|
|
++numObjectAnimated;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if (lastFrame != 0) {
|
2003-10-15 08:46:18 +00:00
|
|
|
// animated objects
|
|
|
|
uint16 j;
|
|
|
|
uint16 firstFrame = curImage + 1;
|
|
|
|
for (j = pgd->firstFrame; j <= lastFrame; ++j) {
|
|
|
|
++curImage;
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(j, curImage, 15);
|
2003-10-15 08:46:18 +00:00
|
|
|
++_numFrames;
|
|
|
|
}
|
|
|
|
curBob = 5 + _numFurnitureAnimated + numObjectAnimated;
|
|
|
|
if (pod->name > 0) {
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *pbs = _vm->graphics()->bob(curBob);
|
2003-12-29 20:51:28 +00:00
|
|
|
pbs->curPos(pgd->x, pgd->y);
|
2003-10-15 08:46:18 +00:00
|
|
|
pbs->frameNum = firstFrame;
|
|
|
|
if (pgd->speed > 0) {
|
2003-11-30 20:41:02 +00:00
|
|
|
pbs->animNormal(firstFrame, curImage, pgd->speed / 4, rebound, false);
|
2003-10-15 08:46:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
++numObjectAnimated;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-15 08:46:18 +00:00
|
|
|
// static objects
|
|
|
|
curBob = 20 + _numFurnitureStatic + numObjectStatic;
|
|
|
|
++curImage;
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bobClear(curBob);
|
2003-10-15 08:46:18 +00:00
|
|
|
|
|
|
|
// FIXME: if((COMPANEL==2) && (FULLSCREEN==1)) bobs[CURRBOB].y2=199;
|
2003-10-12 16:37:56 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(pgd->firstFrame, curImage, 15);
|
2003-10-15 08:46:18 +00:00
|
|
|
++_numFrames;
|
|
|
|
if (pod->name > 0) {
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *pbs = _vm->graphics()->bob(curBob);
|
2003-12-29 20:51:28 +00:00
|
|
|
pbs->curPos(pgd->x, pgd->y);
|
2003-10-15 08:46:18 +00:00
|
|
|
pbs->frameNum = curImage;
|
|
|
|
}
|
|
|
|
++numObjectStatic;
|
|
|
|
}
|
|
|
|
}
|
2003-10-12 16:37:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// persons Bobs
|
|
|
|
for (i = firstRoomObj; i <= lastRoomObj; ++i) {
|
|
|
|
ObjectData *pod = &_objectData[i];
|
|
|
|
if (pod->image == -3 || pod->image == -4) {
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Logic::roomSetupObjects() - Setting up person %X, name=%X", i, pod->name);
|
2003-10-13 14:21:17 +00:00
|
|
|
uint16 noun = i - _roomData[_currentRoom];
|
|
|
|
if (pod->name > 0) {
|
|
|
|
curImage = personSetup(noun, curImage);
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-13 14:21:17 +00:00
|
|
|
curImage = personAllocate(noun, curImage);
|
|
|
|
}
|
2003-10-12 16:37:56 +00:00
|
|
|
}
|
|
|
|
}
|
2003-10-12 13:16:35 +00:00
|
|
|
|
|
|
|
// paste downs list
|
|
|
|
++curImage;
|
|
|
|
_numFrames = curImage;
|
|
|
|
for (i = firstRoomObj; i <= lastRoomObj; ++i) {
|
2003-11-14 16:16:55 +00:00
|
|
|
ObjectData *pod = &_objectData[i];
|
|
|
|
if (pod->name > 0) {
|
|
|
|
int16 obj = pod->image;
|
|
|
|
if (obj > 5000) {
|
|
|
|
obj -= 5000;
|
|
|
|
GraphicData *pgd = &_graphicData[obj];
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(pgd->firstFrame, curImage, 15);
|
|
|
|
_vm->graphics()->bobPaste(curImage, pgd->x, pgd->y);
|
2003-11-14 16:16:55 +00:00
|
|
|
}
|
2003-10-12 13:16:35 +00:00
|
|
|
}
|
|
|
|
}
|
2003-10-11 10:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-15 08:46:18 +00:00
|
|
|
uint16 Logic::roomRefreshObject(uint16 obj) {
|
2003-10-19 18:52:28 +00:00
|
|
|
|
2003-10-15 08:46:18 +00:00
|
|
|
uint16 curImage = _numFrames;
|
|
|
|
|
2003-11-04 19:51:31 +00:00
|
|
|
if (obj == 0 || obj > _numObjects) {
|
|
|
|
warning("Invalid object number %d", obj);
|
|
|
|
return curImage;
|
|
|
|
}
|
|
|
|
|
2003-10-15 08:46:18 +00:00
|
|
|
ObjectData *pod = &_objectData[obj];
|
|
|
|
if (pod->image == 0) {
|
|
|
|
return curImage;
|
|
|
|
}
|
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Logic::roomRefreshObject(%X, %s)", obj, _objName[ABS(pod->name)]);
|
2003-11-16 10:47:31 +00:00
|
|
|
|
2003-10-15 08:46:18 +00:00
|
|
|
// check the object is in the current room
|
|
|
|
if (pod->room != _currentRoom) {
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Refreshing an object (%i=%s) not in current room (object room=%i, current room=%i)", obj, _objName[ABS(pod->name)], pod->room, _currentRoom);
|
2003-10-15 08:46:18 +00:00
|
|
|
return curImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
// find bob for the object
|
|
|
|
uint16 curBob = findBob(obj);
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *pbs = _vm->graphics()->bob(curBob);
|
2003-10-15 08:46:18 +00:00
|
|
|
|
|
|
|
if (pod->image == -3 || pod->image == -4) {
|
|
|
|
// a person object
|
2003-11-10 14:06:55 +00:00
|
|
|
if (pod->name <= 0) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bobClear(curBob);
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-15 08:46:18 +00:00
|
|
|
// find person number
|
|
|
|
uint16 pNum = 1;
|
|
|
|
uint16 i = _roomData[_currentRoom] + 1;
|
|
|
|
while (i < obj) {
|
|
|
|
if (_objectData[i].image == -3 || _objectData[i].image == -4) {
|
|
|
|
++pNum;
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
curImage = _personFrames[pNum] - 1;
|
|
|
|
if (_personFrames[pNum] == 0) {
|
|
|
|
curImage = _numFrames;
|
|
|
|
_personFrames[pNum] = curImage;
|
|
|
|
}
|
|
|
|
curImage = personSetup(obj - _roomData[_currentRoom], curImage);
|
|
|
|
}
|
|
|
|
return curImage;
|
|
|
|
}
|
|
|
|
|
2003-11-26 23:03:21 +00:00
|
|
|
// find frame used for object
|
|
|
|
curImage = findFrame(obj);
|
|
|
|
|
2003-10-15 08:46:18 +00:00
|
|
|
if (pod->name < 0 || pod->image < 0) {
|
|
|
|
// object is hidden or disabled
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bobClear(curBob);
|
2003-10-15 08:46:18 +00:00
|
|
|
return curImage;
|
|
|
|
}
|
|
|
|
|
2003-10-15 10:01:54 +00:00
|
|
|
int image = pod->image;
|
2003-10-15 16:31:51 +00:00
|
|
|
if (image > 5000) {
|
2003-10-15 10:01:54 +00:00
|
|
|
image -= 5000;
|
2003-10-15 16:31:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GraphicData *pgd = &_graphicData[image];
|
|
|
|
bool rebound = false;
|
|
|
|
int16 lastFrame = pgd->lastFrame;
|
|
|
|
if (lastFrame < 0) {
|
|
|
|
lastFrame = -lastFrame;
|
|
|
|
rebound = true;
|
|
|
|
}
|
|
|
|
if (pgd->firstFrame < 0) {
|
2003-10-20 08:34:48 +00:00
|
|
|
animSetup(pgd, curImage, curBob, pod->name != 0);
|
|
|
|
curImage += pgd->lastFrame - 1;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if (lastFrame != 0) {
|
2003-10-15 16:31:51 +00:00
|
|
|
// turn on an animated bob
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(pgd->firstFrame, 2, 15);
|
2003-10-15 16:31:51 +00:00
|
|
|
pbs->animating = false;
|
|
|
|
uint16 firstImage = curImage;
|
|
|
|
--curImage;
|
|
|
|
uint16 j;
|
|
|
|
for (j = pgd->firstFrame; j <= lastFrame; ++j) {
|
|
|
|
++curImage;
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(j, curImage, 15);
|
2003-10-15 16:31:51 +00:00
|
|
|
}
|
2003-12-29 20:51:28 +00:00
|
|
|
pbs->curPos(pgd->x, pgd->y);
|
2003-10-15 16:31:51 +00:00
|
|
|
pbs->frameNum = firstImage;
|
|
|
|
if (pgd->speed > 0) {
|
2003-11-30 20:41:02 +00:00
|
|
|
pbs->animNormal(firstImage, curImage, pgd->speed / 4, rebound, false);
|
2003-10-15 08:46:18 +00:00
|
|
|
}
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-15 16:31:51 +00:00
|
|
|
// frame 2 is used as a buffer frame to prevent BOB flickering
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(pgd->firstFrame, 2, 15);
|
|
|
|
_vm->graphics()->bankUnpack(pgd->firstFrame, curImage, 15);
|
2003-12-29 20:51:28 +00:00
|
|
|
pbs->curPos(pgd->x, pgd->y);
|
2003-10-15 16:31:51 +00:00
|
|
|
pbs->frameNum = curImage;
|
|
|
|
}
|
2003-10-15 10:01:54 +00:00
|
|
|
|
2003-10-15 08:46:18 +00:00
|
|
|
return curImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-26 13:53:17 +00:00
|
|
|
void Logic::roomSetup(const char *room, int comPanel, bool inCutaway) {
|
2003-10-11 10:09:23 +00:00
|
|
|
|
2003-10-17 13:12:50 +00:00
|
|
|
char filename[20];
|
|
|
|
|
2003-10-11 10:09:23 +00:00
|
|
|
// loads background image
|
2003-10-17 13:12:50 +00:00
|
|
|
sprintf(filename, "%s.PCX", room);
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->loadBackdrop(filename, _currentRoom);
|
2003-10-17 13:12:50 +00:00
|
|
|
|
|
|
|
// custom colors
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palCustomColors(_currentRoom);
|
2003-10-11 10:09:23 +00:00
|
|
|
|
|
|
|
// setup graphics to enter fullscreen/panel mode
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->screenMode(comPanel, inCutaway);
|
2003-10-11 10:09:23 +00:00
|
|
|
|
|
|
|
// reset sprites table (bounding box...)
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bobClearAll();
|
2003-10-11 10:09:23 +00:00
|
|
|
|
|
|
|
// load/setup objects associated to this room
|
2003-10-17 13:12:50 +00:00
|
|
|
sprintf(filename, "%s.BBK", room);
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankLoad(filename, 15);
|
2003-10-17 13:12:50 +00:00
|
|
|
|
2003-10-18 17:42:24 +00:00
|
|
|
zoneSetup();
|
2003-10-12 13:16:35 +00:00
|
|
|
_numFrames = 37 + FRAMES_JOE_XTRA;
|
|
|
|
roomSetupFurniture();
|
2003-10-11 10:09:23 +00:00
|
|
|
roomSetupObjects();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-30 20:41:02 +00:00
|
|
|
void Logic::roomDisplay(uint16 room, RoomDisplayMode mode, uint16 scale, int comPanel, bool inCutaway) {
|
2003-10-12 13:16:35 +00:00
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Logic::roomDisplay(%d, %d, %d, %d, %d)", room, mode, scale, comPanel, inCutaway);
|
2003-10-11 10:09:23 +00:00
|
|
|
|
|
|
|
roomErase();
|
2003-11-30 20:41:02 +00:00
|
|
|
|
|
|
|
roomSetup(roomName(room), comPanel, inCutaway);
|
2003-10-11 10:09:23 +00:00
|
|
|
ObjectData *pod = NULL;
|
2003-10-12 13:16:35 +00:00
|
|
|
if (mode != RDM_FADE_NOJOE) {
|
2003-10-14 19:06:44 +00:00
|
|
|
pod = joeSetupInRoom(mode != RDM_FADE_JOE_XY, scale);
|
2003-10-11 10:09:23 +00:00
|
|
|
}
|
2003-12-05 20:16:32 +00:00
|
|
|
if (mode != RDM_NOFADE_JOE) {
|
2003-10-23 06:44:35 +00:00
|
|
|
update();
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *joe = _vm->graphics()->bob(0);
|
2003-12-05 20:16:32 +00:00
|
|
|
if (IS_CD_INTRO_ROOM(_currentRoom)) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palFadeIn(0, 255, _currentRoom, joe->active, joe->x, joe->y);
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palFadeIn(0, 223, _currentRoom, joe->active, joe->x, joe->y);
|
2003-10-16 13:54:48 +00:00
|
|
|
}
|
2003-12-05 20:16:32 +00:00
|
|
|
}
|
2003-10-11 10:09:23 +00:00
|
|
|
if (pod != NULL) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->walk()->moveJoe(0, pod->x, pod->y, inCutaway);
|
2003-10-09 09:09:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint16 Logic::findScale(uint16 x, uint16 y) {
|
|
|
|
uint16 scale = 100;
|
|
|
|
uint16 areaNum = zoneInArea(ZONE_ROOM, x, y);
|
|
|
|
if(areaNum != 0) {
|
|
|
|
scale = _area[_currentRoom][areaNum].calcScale(y);
|
|
|
|
}
|
|
|
|
return scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-13 14:21:17 +00:00
|
|
|
void Logic::personSetData(int16 noun, const char *actorName, bool loadBank, Person *pp) {
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-13 14:21:17 +00:00
|
|
|
if (noun <= 0) {
|
2003-11-07 10:57:21 +00:00
|
|
|
warning("Logic::personSetData() - Invalid object number: %i", noun);
|
2003-10-13 14:21:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16 i;
|
|
|
|
uint16 obj = _roomData[_currentRoom] + noun;
|
|
|
|
int16 img = _objectData[obj].image;
|
|
|
|
if (img != -3 && img != -4) {
|
|
|
|
warning("Logic::personSetData() - Object %d is not a person", obj);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// search Bob number for the person
|
|
|
|
uint16 bobNum = 0;
|
|
|
|
for (i = _roomData[_currentRoom] + 1; i <= obj; ++i) {
|
|
|
|
img = _objectData[i].image;
|
|
|
|
if (img == -3 || img == -4) {
|
|
|
|
++bobNum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// search for a matching actor
|
2003-10-14 06:41:08 +00:00
|
|
|
uint16 actor = 0;
|
2003-10-13 14:21:17 +00:00
|
|
|
for (i = 1; i <= _numActors; ++i) {
|
|
|
|
ActorData *pad = &_actorData[i];
|
|
|
|
if (pad->room == _currentRoom) {
|
|
|
|
if (_gameState[pad->gameStateSlot] == pad->gameStateValue) {
|
2003-10-14 06:41:08 +00:00
|
|
|
if ((bobNum > 0 && bobNum == pad->bobNum) || strcmp(_aName[pad->name], actorName) == 0) {
|
2003-10-13 14:21:17 +00:00
|
|
|
actor = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-06 13:15:17 +00:00
|
|
|
if (actor != 0) {
|
2003-10-14 06:41:08 +00:00
|
|
|
|
2003-12-06 13:15:17 +00:00
|
|
|
pp->actor = &_actorData[actor];
|
|
|
|
pp->name = _aName[pp->actor->name];
|
|
|
|
if (pp->actor->anim != 0) {
|
|
|
|
pp->anim = _aAnim[pp->actor->anim];
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-12-06 13:15:17 +00:00
|
|
|
pp->anim = NULL;
|
|
|
|
}
|
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Logic::personSetData() - name=%s n=%d", pp->name, actor);
|
2003-12-06 13:15:17 +00:00
|
|
|
|
|
|
|
if (loadBank) {
|
|
|
|
const char *actorFile = _aFile[pp->actor->actorFile];
|
|
|
|
if (actorFile) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankLoad(actorFile, pp->actor->bankNum);
|
2003-12-06 13:15:17 +00:00
|
|
|
}
|
|
|
|
// if actorFile is null, the person data is already loaded as
|
|
|
|
// it is contained in objects room bank (.bbk)
|
|
|
|
}
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-13 14:21:17 +00:00
|
|
|
pp->bobFrame = 29 + FRAMES_JOE_XTRA + pp->actor->bobNum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint16 Logic::personSetup(uint16 noun, uint16 curImage) {
|
|
|
|
|
|
|
|
Person p;
|
|
|
|
personSetData(noun, "", true, &p);
|
|
|
|
|
|
|
|
const ActorData *pad = p.actor;
|
|
|
|
uint16 scale = 100;
|
|
|
|
uint16 a = zoneInArea(ZONE_ROOM, pad->x, pad->y);
|
|
|
|
if (a > 0) {
|
|
|
|
// person is not standing in the area box, scale it accordingly
|
|
|
|
scale = currentRoomArea(a)->calcScale(pad->y);
|
|
|
|
}
|
2003-11-20 09:38:54 +00:00
|
|
|
|
|
|
|
if (noun == 0) {
|
|
|
|
warning("Trying to setup person 0");
|
|
|
|
return curImage;
|
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(pad->bobFrameStanding, p.bobFrame, p.actor->bankNum);
|
2003-10-13 14:21:17 +00:00
|
|
|
bool xflip = false;
|
|
|
|
uint16 person = _roomData[_currentRoom] + noun;
|
|
|
|
if (_objectData[person].image == -3) {
|
|
|
|
// person is facing left
|
|
|
|
xflip = true;
|
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *pbs = _vm->graphics()->bob(pad->bobNum);
|
2003-12-29 20:51:28 +00:00
|
|
|
pbs->curPos(pad->x, pad->y);
|
2003-10-13 14:21:17 +00:00
|
|
|
pbs->scale = scale;
|
|
|
|
pbs->frameNum = p.bobFrame;
|
|
|
|
pbs->xflip = xflip;
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Logic::personSetup(%d, %d) - bob = %d name = %s", noun, curImage, pad->bobNum, p.name);
|
2003-11-13 10:44:31 +00:00
|
|
|
|
2003-10-13 14:21:17 +00:00
|
|
|
if (p.anim != NULL) {
|
|
|
|
_personFrames[pad->bobNum] = curImage + 1;
|
|
|
|
curImage = animCreate(curImage, &p);
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-13 14:21:17 +00:00
|
|
|
animErase(pad->bobNum);
|
|
|
|
}
|
|
|
|
return curImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint16 Logic::personAllocate(uint16 noun, uint16 curImage) {
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-13 14:21:17 +00:00
|
|
|
uint16 i;
|
|
|
|
uint16 person = _roomData[_currentRoom] + noun;
|
|
|
|
|
|
|
|
// search Bob number for the person
|
|
|
|
uint16 bobNum = 0;
|
|
|
|
for (i = _roomData[_currentRoom] + 1; i <= person; ++i) {
|
|
|
|
int16 img = _objectData[i].image;
|
|
|
|
if (img == -3 || img == -4) {
|
|
|
|
++bobNum;
|
|
|
|
}
|
|
|
|
}
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-13 14:21:17 +00:00
|
|
|
// search for a matching actor
|
|
|
|
uint16 actor = 0;
|
|
|
|
for (i = 1; i <= _numActors; ++i) {
|
|
|
|
ActorData *pad = &_actorData[i];
|
|
|
|
if (pad->room == _currentRoom) {
|
|
|
|
if (_gameState[pad->gameStateSlot] == pad->gameStateValue) {
|
|
|
|
if (bobNum > 0 && bobNum == pad->bobNum) {
|
|
|
|
actor = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-13 14:21:17 +00:00
|
|
|
if (actor > 0) {
|
2003-11-08 23:20:23 +00:00
|
|
|
const char *animStr = _aAnim[_actorData[actor].anim];
|
|
|
|
if (animStr) {
|
2003-10-13 14:21:17 +00:00
|
|
|
bool allocatedFrames[256];
|
|
|
|
memset(allocatedFrames, 0, sizeof(allocatedFrames));
|
|
|
|
uint16 f1, f2;
|
|
|
|
do {
|
|
|
|
sscanf(animStr, "%3hu,%3hu", &f1, &f2);
|
|
|
|
animStr += 8;
|
|
|
|
allocatedFrames[f1] = true;
|
|
|
|
} while(f1 != 0);
|
|
|
|
for (i = 1; i <= 255; ++i) {
|
|
|
|
if (allocatedFrames[i]) {
|
|
|
|
++curImage;
|
|
|
|
}
|
|
|
|
}
|
2003-10-20 08:34:48 +00:00
|
|
|
// FIXME: shouldn't this line be executed BEFORE curImage is incremented ?
|
2003-10-13 14:21:17 +00:00
|
|
|
_personFrames[bobNum] = curImage + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return curImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint16 Logic::animCreate(uint16 curImage, const Person *person) {
|
|
|
|
|
2003-10-15 16:31:51 +00:00
|
|
|
AnimFrame *animFrames = _newAnim[person->actor->bobNum];
|
2003-10-13 14:21:17 +00:00
|
|
|
|
|
|
|
uint16 allocatedFrames[256];
|
|
|
|
memset(allocatedFrames, 0, sizeof(allocatedFrames));
|
|
|
|
const char *p = person->anim;
|
|
|
|
int frame = 0;
|
|
|
|
uint16 f1, f2;
|
|
|
|
do {
|
|
|
|
sscanf(p, "%3hu,%3hu", &f1, &f2);
|
2003-10-15 16:31:51 +00:00
|
|
|
animFrames[frame].frame = f1;
|
|
|
|
animFrames[frame].speed = f2;
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-13 14:21:17 +00:00
|
|
|
if (f1 > 500) {
|
|
|
|
// SFX
|
|
|
|
allocatedFrames[f1 - 500] = 1;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-13 14:21:17 +00:00
|
|
|
allocatedFrames[f1] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
p += 8;
|
2003-10-15 16:31:51 +00:00
|
|
|
++frame;
|
2003-10-13 14:21:17 +00:00
|
|
|
} while(f1 != 0);
|
|
|
|
|
|
|
|
// ajust frame numbers
|
|
|
|
uint16 n = 1;
|
|
|
|
uint16 i;
|
|
|
|
for (i = 1; i <= 255; ++i) {
|
|
|
|
if (allocatedFrames[i] != 0) {
|
|
|
|
allocatedFrames[i] = n;
|
|
|
|
++n;
|
|
|
|
}
|
|
|
|
}
|
2003-10-15 16:31:51 +00:00
|
|
|
for (i = 0; animFrames[i].frame != 0; ++i) {
|
|
|
|
uint16 frameNum = animFrames[i].frame;
|
2003-10-13 14:21:17 +00:00
|
|
|
if (frameNum > 500) {
|
2003-10-15 16:31:51 +00:00
|
|
|
animFrames[i].frame = curImage + allocatedFrames[frameNum - 500] + 500;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-15 16:31:51 +00:00
|
|
|
animFrames[i].frame = curImage + allocatedFrames[frameNum];
|
2003-10-13 14:21:17 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-13 14:21:17 +00:00
|
|
|
// unpack necessary frames
|
|
|
|
for (i = 1; i <= 255; ++i) {
|
|
|
|
if (allocatedFrames[i] != 0) {
|
|
|
|
++curImage;
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(i, curImage, person->actor->bankNum);
|
2003-10-13 14:21:17 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-13 14:21:17 +00:00
|
|
|
// start animation
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bob(person->actor->bobNum)->animString(animFrames);
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-13 14:21:17 +00:00
|
|
|
return curImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::animErase(uint16 bobNum) {
|
2003-10-20 08:34:48 +00:00
|
|
|
|
2003-10-15 16:31:51 +00:00
|
|
|
_newAnim[bobNum][0].frame = 0;
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *pbs = _vm->graphics()->bob(bobNum);
|
2003-10-13 14:21:17 +00:00
|
|
|
pbs->animating = false;
|
|
|
|
pbs->anim.string.buffer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-03 13:00:56 +00:00
|
|
|
void Logic::animReset(uint16 bobNum) {
|
|
|
|
|
|
|
|
if (_newAnim[bobNum][0].frame != 0) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bob(bobNum)->animString(_newAnim[bobNum]);
|
2003-12-03 13:00:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-20 08:34:48 +00:00
|
|
|
void Logic::animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible) {
|
2003-10-15 16:31:51 +00:00
|
|
|
|
|
|
|
int16 tempFrames[20];
|
|
|
|
memset(tempFrames, 0, sizeof(tempFrames));
|
|
|
|
uint16 numTempFrames = 0;
|
|
|
|
uint16 i, j;
|
|
|
|
for (i = 1; i <= _numGraphicAnim; ++i) {
|
|
|
|
const GraphicAnim *pga = &_graphicAnim[i];
|
|
|
|
if (pga->keyFrame == gd->firstFrame) {
|
|
|
|
int16 frame = pga->frame;
|
|
|
|
if (frame > 500) { // SFX
|
|
|
|
frame -= 500;
|
|
|
|
}
|
|
|
|
bool foundMatchingFrame = false;
|
|
|
|
for (j = 0; j < numTempFrames; ++j) {
|
|
|
|
if (tempFrames[j] == frame) {
|
|
|
|
foundMatchingFrame = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!foundMatchingFrame) {
|
|
|
|
assert(numTempFrames < 20);
|
|
|
|
tempFrames[numTempFrames] = frame;
|
|
|
|
++numTempFrames;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// sort found frames ascending
|
|
|
|
bool swap = true;
|
|
|
|
while (swap) {
|
|
|
|
swap = false;
|
|
|
|
for (i = 0; i < numTempFrames - 1; ++i) {
|
|
|
|
if (tempFrames[i] > tempFrames[i + 1]) {
|
|
|
|
SWAP(tempFrames[i], tempFrames[i + 1]);
|
|
|
|
swap = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// queen.c l.962-980 / l.1269-1294
|
|
|
|
for (i = 0; i < gd->lastFrame; ++i) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(ABS(tempFrames[i]), firstImage + i, 15);
|
2003-10-15 16:31:51 +00:00
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *pbs = _vm->graphics()->bob(bobNum);
|
2003-10-20 08:34:48 +00:00
|
|
|
pbs->animating = false;
|
|
|
|
if (visible) {
|
2003-12-29 20:51:28 +00:00
|
|
|
pbs->curPos(gd->x, gd->y);
|
2003-10-20 08:34:48 +00:00
|
|
|
if (tempFrames[0] < 0) {
|
|
|
|
pbs->xflip = true;
|
|
|
|
}
|
|
|
|
AnimFrame *paf = _newAnim[bobNum];
|
2003-10-15 16:31:51 +00:00
|
|
|
for (i = 1; i <= _numGraphicAnim; ++i) {
|
|
|
|
const GraphicAnim *pga = &_graphicAnim[i];
|
|
|
|
if (pga->keyFrame == gd->firstFrame) {
|
2003-10-19 18:52:28 +00:00
|
|
|
uint16 frameNr = 0;
|
2003-10-15 16:31:51 +00:00
|
|
|
for (j = 1; j <= gd->lastFrame; ++j) {
|
2003-10-19 18:52:28 +00:00
|
|
|
if (pga->frame > 500) {
|
|
|
|
if (pga->frame - 500 == tempFrames[j - 1]) {
|
|
|
|
frameNr = j + firstImage - 1 + 500;
|
|
|
|
}
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if (pga->frame == tempFrames[j - 1]) {
|
2003-10-15 16:31:51 +00:00
|
|
|
frameNr = j + firstImage - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
paf->frame = frameNr;
|
|
|
|
paf->speed = pga->speed;
|
|
|
|
++paf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
paf->frame = 0;
|
|
|
|
paf->speed = 0;
|
2003-10-20 08:34:48 +00:00
|
|
|
pbs->animString(_newAnim[bobNum]);
|
2003-10-15 16:31:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-23 18:46:04 +00:00
|
|
|
void Logic::joeSetupFromBanks(const char *animBank, const char *standBank) {
|
2003-10-21 09:05:16 +00:00
|
|
|
|
|
|
|
int i;
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankLoad(animBank, 13);
|
2003-10-14 19:06:44 +00:00
|
|
|
for (i = 11; i <= 28 + FRAMES_JOE_XTRA; ++i) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(i - 10, i, 13);
|
2003-10-14 19:06:44 +00:00
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankErase(13);
|
2003-10-14 19:06:44 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankLoad(standBank, 7);
|
|
|
|
_vm->graphics()->bankUnpack(1, 33 + FRAMES_JOE_XTRA, 7);
|
|
|
|
_vm->graphics()->bankUnpack(3, 34 + FRAMES_JOE_XTRA, 7);
|
|
|
|
_vm->graphics()->bankUnpack(5, 35 + FRAMES_JOE_XTRA, 7);
|
2003-10-21 09:05:16 +00:00
|
|
|
}
|
|
|
|
|
2003-10-14 19:06:44 +00:00
|
|
|
|
2003-10-21 09:05:16 +00:00
|
|
|
void Logic::joeSetup() {
|
|
|
|
|
|
|
|
joeSetupFromBanks("joe_a.BBK", "joe_b.BBK");
|
2003-11-27 13:49:00 +00:00
|
|
|
joeFacing(DIR_FRONT);
|
2003-10-14 19:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ObjectData *Logic::joeSetupInRoom(bool autoPosition, uint16 scale) {
|
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Logic::joeSetupInRoom(%d, %d) joe.x=%d joe.y=%d", autoPosition, scale, _joe.x, _joe.y);
|
2003-11-16 19:55:04 +00:00
|
|
|
|
2003-10-14 19:06:44 +00:00
|
|
|
uint16 oldx;
|
|
|
|
uint16 oldy;
|
|
|
|
WalkOffData *pwo = NULL;
|
2003-11-06 21:06:01 +00:00
|
|
|
ObjectData *pod = objectData(_entryObj);
|
2003-10-14 19:06:44 +00:00
|
|
|
if (pod == NULL) {
|
|
|
|
error("Logic::joeSetupInRoom() - No object data for obj %d", _entryObj);
|
|
|
|
}
|
|
|
|
|
2003-11-16 19:55:04 +00:00
|
|
|
if (!autoPosition || joeX() != 0 || joeY() != 0) {
|
|
|
|
oldx = joeX();
|
|
|
|
oldy = joeY();
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-14 19:06:44 +00:00
|
|
|
// find the walk off point for the entry object and make
|
|
|
|
// Joe walking to that point
|
|
|
|
pwo = walkOffPointForObject(_entryObj);
|
|
|
|
if (pwo != NULL) {
|
|
|
|
oldx = pwo->x;
|
|
|
|
oldy = pwo->y;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-14 19:06:44 +00:00
|
|
|
// no walk off point, use object position
|
|
|
|
oldx = pod->x;
|
|
|
|
oldy = pod->y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Logic::joeSetupInRoom() - oldx=%d, oldy=%d scale=%d", oldx, oldy, scale);
|
2003-10-14 19:06:44 +00:00
|
|
|
|
|
|
|
if (scale > 0 && scale < 100) {
|
2003-12-05 20:16:32 +00:00
|
|
|
joeScale(scale);
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-14 19:06:44 +00:00
|
|
|
uint16 a = zoneInArea(ZONE_ROOM, oldx, oldy);
|
|
|
|
if (a > 0) {
|
2003-12-05 20:16:32 +00:00
|
|
|
joeScale(currentRoomArea(a)->calcScale(oldy));
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-12-05 20:16:32 +00:00
|
|
|
joeScale(100);
|
2003-10-14 19:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-27 13:49:00 +00:00
|
|
|
if (joeCutFacing() > 0) {
|
|
|
|
joeFacing(joeCutFacing());
|
|
|
|
joeCutFacing(0);
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-11-27 13:49:00 +00:00
|
|
|
// check to see which way Joe entered room
|
|
|
|
switch (State::findDirection(pod->state)) {
|
|
|
|
case DIR_BACK:
|
|
|
|
joeFacing(DIR_FRONT);
|
|
|
|
break;
|
|
|
|
case DIR_FRONT:
|
|
|
|
joeFacing(DIR_BACK);
|
|
|
|
break;
|
|
|
|
case DIR_LEFT:
|
|
|
|
joeFacing(DIR_RIGHT);
|
|
|
|
break;
|
|
|
|
case DIR_RIGHT:
|
|
|
|
joeFacing(DIR_LEFT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
joePrevFacing(joeFacing());
|
2003-10-23 18:46:04 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *pbs = _vm->graphics()->bob(0);
|
2003-12-05 20:16:32 +00:00
|
|
|
pbs->scale = joeScale();
|
2003-10-14 19:06:44 +00:00
|
|
|
|
2003-11-27 13:49:00 +00:00
|
|
|
if (_currentRoom == 108) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(-1);
|
|
|
|
_vm->graphics()->bankLoad("joe_e.act", 7);
|
|
|
|
_vm->graphics()->bankUnpack(2, 29 + FRAMES_JOE_XTRA, 7);
|
2003-11-27 13:49:00 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->horizontalScroll(320);
|
2003-11-27 13:49:00 +00:00
|
|
|
|
|
|
|
joeFacing(DIR_RIGHT);
|
|
|
|
joeCutFacing(DIR_RIGHT);
|
|
|
|
joePrevFacing(DIR_RIGHT);
|
|
|
|
}
|
2003-10-14 19:06:44 +00:00
|
|
|
|
|
|
|
joeFace();
|
2003-12-29 20:51:28 +00:00
|
|
|
pbs->curPos(oldx, oldy);
|
2003-10-14 19:06:44 +00:00
|
|
|
pbs->frameNum = 29 + FRAMES_JOE_XTRA;
|
2003-11-16 19:55:04 +00:00
|
|
|
joeX(0);
|
|
|
|
joeY(0);
|
2003-10-14 19:06:44 +00:00
|
|
|
|
|
|
|
if (pwo != NULL) {
|
|
|
|
// entryObj has a walk off point, then walk from there to object x,y
|
|
|
|
return pod;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint16 Logic::joeFace() {
|
|
|
|
|
|
|
|
debug(9, "Logic::joeFace() - curFace = %d, prevFace = %d", _joe.facing, _joe.prevFacing);
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *pbs = _vm->graphics()->bob(0);
|
2003-10-14 19:06:44 +00:00
|
|
|
uint16 frame;
|
|
|
|
if (_currentRoom == 108) {
|
|
|
|
frame = 1;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-14 19:06:44 +00:00
|
|
|
frame = 33;
|
2003-11-27 13:49:00 +00:00
|
|
|
if (joeFacing() == DIR_FRONT) {
|
|
|
|
if (joePrevFacing() == DIR_BACK) {
|
2003-10-14 19:06:44 +00:00
|
|
|
pbs->frameNum = 33 + FRAMES_JOE_XTRA;
|
2003-10-23 06:44:35 +00:00
|
|
|
update();
|
2003-10-14 19:06:44 +00:00
|
|
|
}
|
|
|
|
frame = 34;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if (joeFacing() == DIR_BACK) {
|
2003-11-27 13:49:00 +00:00
|
|
|
if (joePrevFacing() == DIR_FRONT) {
|
2003-10-14 19:06:44 +00:00
|
|
|
pbs->frameNum = 33 + FRAMES_JOE_XTRA;
|
2003-10-23 06:44:35 +00:00
|
|
|
update();
|
2003-10-14 19:06:44 +00:00
|
|
|
}
|
|
|
|
frame = 35;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if ((joeFacing() == DIR_LEFT && joePrevFacing() == DIR_RIGHT)
|
2003-11-27 13:49:00 +00:00
|
|
|
|| (joeFacing() == DIR_RIGHT && joePrevFacing() == DIR_LEFT)) {
|
2003-10-14 19:06:44 +00:00
|
|
|
pbs->frameNum = 34 + FRAMES_JOE_XTRA;
|
2003-10-23 06:44:35 +00:00
|
|
|
update();
|
2003-10-14 19:06:44 +00:00
|
|
|
}
|
|
|
|
pbs->frameNum = frame + FRAMES_JOE_XTRA;
|
2003-12-05 20:16:32 +00:00
|
|
|
pbs->scale = joeScale();
|
2003-11-27 13:49:00 +00:00
|
|
|
pbs->xflip = (joeFacing() == DIR_LEFT);
|
2003-10-23 06:44:35 +00:00
|
|
|
update();
|
2003-11-27 13:49:00 +00:00
|
|
|
joePrevFacing(joeFacing());
|
2003-10-14 19:06:44 +00:00
|
|
|
switch (frame) {
|
2003-11-27 13:49:00 +00:00
|
|
|
case 33:
|
|
|
|
frame = 1;
|
|
|
|
break;
|
|
|
|
case 34:
|
|
|
|
frame = 3;
|
|
|
|
break;
|
|
|
|
case 35:
|
|
|
|
frame = 5;
|
|
|
|
break;
|
2003-10-14 19:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pbs->frameNum = 29 + FRAMES_JOE_XTRA;
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(frame, pbs->frameNum, 7);
|
2003-10-14 19:06:44 +00:00
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-11 13:26:13 +00:00
|
|
|
void Logic::joeGrab(int16 grabState) {
|
2003-10-21 09:05:16 +00:00
|
|
|
|
|
|
|
uint16 frame = 0;
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *bobJoe = _vm->graphics()->bob(0);
|
2003-12-11 13:26:13 +00:00
|
|
|
|
|
|
|
switch (grabState) {
|
2003-10-21 09:05:16 +00:00
|
|
|
case STATE_GRAB_NONE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STATE_GRAB_MID:
|
2003-12-05 20:16:32 +00:00
|
|
|
if (joeFacing() == DIR_BACK) {
|
2003-11-16 10:47:31 +00:00
|
|
|
frame = 6;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if (joeFacing() == DIR_FRONT) {
|
2003-11-16 10:47:31 +00:00
|
|
|
frame = 4;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-21 09:05:16 +00:00
|
|
|
frame = 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STATE_GRAB_DOWN:
|
2003-12-05 20:16:32 +00:00
|
|
|
if (joeFacing() == DIR_BACK) {
|
2003-10-21 09:05:16 +00:00
|
|
|
frame = 9;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-21 09:05:16 +00:00
|
|
|
frame = 8;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STATE_GRAB_UP:
|
|
|
|
// turn back
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(5, 29 + FRAMES_JOE_XTRA, 7);
|
2003-12-05 20:16:32 +00:00
|
|
|
bobJoe->xflip = (joeFacing() == DIR_LEFT);
|
|
|
|
bobJoe->scale = joeScale();
|
2003-10-23 06:44:35 +00:00
|
|
|
update();
|
2003-10-21 09:05:16 +00:00
|
|
|
// grab up
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(7, 29 + FRAMES_JOE_XTRA, 7);
|
2003-12-05 20:16:32 +00:00
|
|
|
bobJoe->xflip = (joeFacing() == DIR_LEFT);
|
|
|
|
bobJoe->scale = joeScale();
|
2003-11-08 23:45:45 +00:00
|
|
|
update();
|
2003-10-21 09:05:16 +00:00
|
|
|
// turn back
|
2003-12-11 13:26:13 +00:00
|
|
|
frame = 7;
|
2003-10-21 09:05:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-21 09:05:16 +00:00
|
|
|
if (frame != 0) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(frame, 29 + FRAMES_JOE_XTRA, 7);
|
2003-12-05 20:16:32 +00:00
|
|
|
bobJoe->xflip = (joeFacing() == DIR_LEFT);
|
|
|
|
bobJoe->scale = joeScale();
|
2003-10-23 06:44:35 +00:00
|
|
|
update();
|
2003-10-21 09:05:16 +00:00
|
|
|
|
|
|
|
// extra delay for grab down
|
2003-12-11 13:26:13 +00:00
|
|
|
if (grabState == STATE_GRAB_DOWN) {
|
2003-10-23 06:44:35 +00:00
|
|
|
update();
|
|
|
|
update();
|
2003-10-21 09:05:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::joeUseDress(bool showCut) {
|
|
|
|
|
|
|
|
if (showCut) {
|
|
|
|
joeFacing(DIR_FRONT);
|
|
|
|
joeFace();
|
|
|
|
if (gameState(VAR_DRESSING_MODE) == 0) {
|
|
|
|
playCutaway("cdres.CUT");
|
2003-11-06 15:47:37 +00:00
|
|
|
inventoryInsertItem(ITEM_CLOTHES);
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-21 09:05:16 +00:00
|
|
|
playCutaway("cudrs.CUT");
|
|
|
|
}
|
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palSetJoe(JP_DRESS);
|
2003-10-21 09:05:16 +00:00
|
|
|
joeSetupFromBanks("JoeD_A.BBK", "JoeD_B.BBK");
|
2003-11-06 15:47:37 +00:00
|
|
|
inventoryDeleteItem(ITEM_DRESS);
|
2003-10-21 09:05:16 +00:00
|
|
|
gameState(VAR_DRESSING_MODE, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::joeUseClothes(bool showCut) {
|
|
|
|
|
|
|
|
if (showCut) {
|
|
|
|
joeFacing(DIR_FRONT);
|
|
|
|
joeFace();
|
|
|
|
playCutaway("cdclo.CUT");
|
2003-11-06 15:47:37 +00:00
|
|
|
inventoryInsertItem(ITEM_DRESS);
|
2003-10-21 09:05:16 +00:00
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palSetJoe(JP_CLOTHES);
|
2003-10-21 09:05:16 +00:00
|
|
|
joeSetupFromBanks("Joe_A.BBK", "Joe_B.BBK");
|
2003-11-06 15:47:37 +00:00
|
|
|
inventoryDeleteItem(ITEM_CLOTHES);
|
2003-10-21 09:05:16 +00:00
|
|
|
gameState(VAR_DRESSING_MODE, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::joeUseUnderwear() {
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palSetJoe(JP_CLOTHES);
|
2003-10-21 09:05:16 +00:00
|
|
|
joeSetupFromBanks("JoeU_A.BBK", "JoeU_B.BBK");
|
|
|
|
gameState(VAR_DRESSING_MODE, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-26 21:46:29 +00:00
|
|
|
void Logic::makePersonSpeak(const char *sentence, Person *person, const char *voiceFilePrefix) {
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->command()->clear(false);
|
|
|
|
Talk::speak(sentence, person, voiceFilePrefix, _vm);
|
2003-11-26 21:46:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-06 08:44:33 +00:00
|
|
|
void Logic::dialogue(const char *dlgFile, int personInRoom, char *cutaway) {
|
|
|
|
|
|
|
|
char cutawayFile[20];
|
|
|
|
if (cutaway == NULL) {
|
|
|
|
cutaway = cutawayFile;
|
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->fullscreen(true);
|
|
|
|
Talk::talk(dlgFile, personInRoom, cutaway, _vm);
|
2003-12-03 13:00:56 +00:00
|
|
|
if (!cutaway[0]) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->fullscreen(false);
|
2003-12-03 13:00:56 +00:00
|
|
|
}
|
2003-11-06 08:44:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-02 16:47:31 +00:00
|
|
|
void Logic::playCutaway(const char *cutFile, char *next) {
|
2003-10-21 09:05:16 +00:00
|
|
|
|
2003-11-02 16:47:31 +00:00
|
|
|
char nextFile[20];
|
|
|
|
if (next == NULL) {
|
|
|
|
next = nextFile;
|
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS);
|
|
|
|
Cutaway::run(cutFile, next, _vm);
|
2003-10-21 09:05:16 +00:00
|
|
|
}
|
|
|
|
|
2003-10-23 18:46:04 +00:00
|
|
|
|
2003-10-27 15:00:25 +00:00
|
|
|
void Logic::joeSpeak(uint16 descNum, bool objectType) {
|
|
|
|
|
|
|
|
// joeSpeak(k, false) == SPEAK(JOE_RESPstr[k],"JOE",find_cd_desc(k))
|
|
|
|
// joeSpeak(k, true) == SPEAK(OBJECT_DESCRstr[k],"JOE",find_cd_desc(JOERESPMAX+k))
|
|
|
|
const char *text = objectType ? _objDescription[descNum] : _joeResponse[descNum];
|
|
|
|
if (objectType) {
|
|
|
|
descNum += JOE_RESPONSE_MAX;
|
|
|
|
}
|
|
|
|
char descFilePrefix[10];
|
|
|
|
sprintf(descFilePrefix, "JOE%04i", descNum);
|
2003-11-26 21:46:29 +00:00
|
|
|
makePersonSpeak(text, NULL, descFilePrefix);
|
2003-10-27 15:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Verb Logic::findVerbUnderCursor(int16 cursorx, int16 cursory) const {
|
2003-12-13 20:05:28 +00:00
|
|
|
|
2003-12-12 20:26:20 +00:00
|
|
|
static const Verb pv[] = {
|
|
|
|
VERB_NONE,
|
|
|
|
VERB_OPEN,
|
|
|
|
VERB_CLOSE,
|
|
|
|
VERB_MOVE,
|
|
|
|
VERB_GIVE,
|
|
|
|
VERB_LOOK_AT,
|
|
|
|
VERB_PICK_UP,
|
|
|
|
VERB_TALK_TO,
|
|
|
|
VERB_USE,
|
|
|
|
VERB_SCROLL_UP,
|
|
|
|
VERB_SCROLL_DOWN,
|
|
|
|
VERB_INV_1,
|
|
|
|
VERB_INV_2,
|
|
|
|
VERB_INV_3,
|
|
|
|
VERB_INV_4,
|
|
|
|
};
|
|
|
|
return pv[zoneIn(ZONE_PANEL, cursorx, cursory)];
|
2003-10-25 09:11:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-27 15:00:25 +00:00
|
|
|
uint16 Logic::findObjectUnderCursor(int16 cursorx, int16 cursory) const {
|
|
|
|
|
|
|
|
uint16 roomObj = 0;
|
|
|
|
if (cursory < ROOM_ZONE_HEIGHT) {
|
2003-12-11 22:16:35 +00:00
|
|
|
int16 x = cursorx + _vm->display()->horizontalScroll();
|
2003-10-27 15:00:25 +00:00
|
|
|
roomObj = zoneIn(ZONE_ROOM, x, cursory);
|
|
|
|
}
|
|
|
|
return roomObj;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-13 20:05:28 +00:00
|
|
|
uint16 Logic::findObjectNumber(uint16 zoneNum) const {
|
2003-10-25 20:26:50 +00:00
|
|
|
|
|
|
|
// l.316-327 select.c
|
2003-12-13 20:05:28 +00:00
|
|
|
uint16 obj = zoneNum;
|
|
|
|
uint16 objectMax = currentRoomObjMax();
|
|
|
|
debug(9, "Logic::findObjectNumber(%X, %X)", zoneNum, objectMax);
|
2003-10-25 20:26:50 +00:00
|
|
|
if (zoneNum > objectMax) {
|
|
|
|
// this is an area box, check for associated object
|
2003-12-13 20:05:28 +00:00
|
|
|
obj = currentRoomArea(zoneNum - objectMax)->object;
|
|
|
|
if (obj != 0) {
|
2003-10-25 20:26:50 +00:00
|
|
|
// there is an object, get its number
|
2003-12-13 20:05:28 +00:00
|
|
|
obj -= currentRoomData();
|
2003-10-25 20:26:50 +00:00
|
|
|
}
|
|
|
|
}
|
2003-12-13 20:05:28 +00:00
|
|
|
return obj;
|
2003-10-26 13:54:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-31 13:47:28 +00:00
|
|
|
uint16 Logic::findInventoryItem(int invSlot) const {
|
|
|
|
// queen.c l.3894-3898
|
|
|
|
if (invSlot >= 0 && invSlot < 4) {
|
|
|
|
return _inventoryItem[invSlot];
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::inventorySetup() {
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankLoad("objects.BBK", 14);
|
2003-11-06 15:47:37 +00:00
|
|
|
_inventoryItem[0] = ITEM_BAT;
|
2003-11-13 12:39:37 +00:00
|
|
|
_inventoryItem[1] = ITEM_JOURNAL;
|
2003-11-07 02:33:20 +00:00
|
|
|
_inventoryItem[2] = ITEM_NONE;
|
|
|
|
_inventoryItem[3] = ITEM_NONE;
|
2003-10-31 13:47:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Logic::inventoryRefresh() {
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-10-31 13:47:28 +00:00
|
|
|
int16 i;
|
|
|
|
uint16 x = 182;
|
|
|
|
for (i = 0; i < 4; ++i) {
|
|
|
|
uint16 itemNum = _inventoryItem[i];
|
|
|
|
if (itemNum != 0) {
|
|
|
|
// 1st object in inventory uses frame 8,
|
|
|
|
// whereas 2nd, 3rd and 4th uses frame 9
|
|
|
|
uint16 dstFrame = (itemNum != 0) ? 8 : 9;
|
|
|
|
// unpack frame for object and draw it
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(_itemData[itemNum].frame, dstFrame, 14);
|
|
|
|
_vm->graphics()->bobDrawInventoryItem(dstFrame, x, 14);
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-10-31 13:47:28 +00:00
|
|
|
// no object, clear the panel
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bobDrawInventoryItem(0, x, 14);
|
2003-10-31 13:47:28 +00:00
|
|
|
}
|
|
|
|
x += 35;
|
|
|
|
}
|
|
|
|
// XXX OLDVERB=VERB;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2003-11-02 14:49:51 +00:00
|
|
|
int16 Logic::previousInventoryItem(int16 start) const {
|
|
|
|
int i;
|
|
|
|
for (i = start - 1; i >= 1; i--)
|
|
|
|
if (_itemData[i].name > 0)
|
|
|
|
return i;
|
|
|
|
for (i = _numItems; i > start; i--)
|
|
|
|
if (_itemData[i].name > 0)
|
|
|
|
return i;
|
|
|
|
|
|
|
|
return 0; //nothing found
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 Logic::nextInventoryItem(int16 start) const {
|
|
|
|
int i;
|
|
|
|
for (i = start + 1; i < _numItems; i++)
|
|
|
|
if (_itemData[i].name > 0)
|
|
|
|
return i;
|
|
|
|
for (i = 1; i < start; i++)
|
|
|
|
if (_itemData[i].name > 0)
|
|
|
|
return i;
|
|
|
|
|
|
|
|
return 0; //nothing found
|
|
|
|
}
|
|
|
|
|
|
|
|
void Logic::removeDuplicateItems() {
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
for (int j = i + 1; j < 4; j++)
|
|
|
|
if (_inventoryItem[i] == _inventoryItem[j])
|
2003-11-07 02:33:20 +00:00
|
|
|
_inventoryItem[j] = ITEM_NONE;
|
2003-11-02 14:49:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16 Logic::numItemsInventory() const {
|
|
|
|
uint16 count = 0;
|
|
|
|
for (int i = 1; i < _numItems; i++)
|
|
|
|
if (_itemData[i].name > 0)
|
|
|
|
count++;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
2003-10-31 13:47:28 +00:00
|
|
|
|
|
|
|
void Logic::inventoryInsertItem(uint16 itemNum, bool refresh) {
|
2003-11-02 14:49:51 +00:00
|
|
|
int16 item = _inventoryItem[0] = (int16)itemNum;
|
2003-12-05 13:56:07 +00:00
|
|
|
_itemData[itemNum].name = ABS(_itemData[itemNum].name); //set visible
|
2003-11-02 14:49:51 +00:00
|
|
|
for (int i = 1; i < 4; i++) {
|
|
|
|
item = nextInventoryItem(item);
|
|
|
|
_inventoryItem[i] = item;
|
|
|
|
removeDuplicateItems();
|
|
|
|
}
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-11-02 14:49:51 +00:00
|
|
|
if (refresh)
|
|
|
|
inventoryRefresh();
|
2003-10-31 13:47:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::inventoryDeleteItem(uint16 itemNum, bool refresh) {
|
2003-11-02 14:49:51 +00:00
|
|
|
int16 item = (int16)itemNum;
|
2003-12-05 13:56:07 +00:00
|
|
|
_itemData[itemNum].name = -ABS(_itemData[itemNum].name); //set invisible
|
2003-11-02 14:49:51 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
item = nextInventoryItem(item);
|
|
|
|
_inventoryItem[i] = item;
|
|
|
|
removeDuplicateItems();
|
|
|
|
}
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-11-02 14:49:51 +00:00
|
|
|
if (refresh)
|
|
|
|
inventoryRefresh();
|
2003-10-31 13:47:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::inventoryScroll(uint16 count, bool up) {
|
2003-11-02 14:49:51 +00:00
|
|
|
if (!(numItemsInventory() > 4))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (up) {
|
|
|
|
for (int i = 3; i > 0; i--)
|
|
|
|
_inventoryItem[i] = _inventoryItem[i - 1];
|
|
|
|
_inventoryItem[0] = previousInventoryItem(_inventoryItem[0]);
|
2003-11-02 21:37:20 +00:00
|
|
|
} else {
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
_inventoryItem[i] = _inventoryItem[i + 1];
|
|
|
|
_inventoryItem[3] = nextInventoryItem(_inventoryItem[3]);
|
2003-11-02 14:49:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inventoryRefresh();
|
2003-10-31 13:47:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::objectCopy(int dummyObjectIndex, int realObjectIndex) {
|
|
|
|
// P3_COPY_FROM function in cutaway.c
|
|
|
|
/* Copy data from Dummy (D) object to object (K)
|
|
|
|
If COPY_FROM Object images are greater than COPY_TO Object
|
|
|
|
images then swap the objects around. */
|
|
|
|
|
|
|
|
ObjectData *dummyObject = objectData(dummyObjectIndex);
|
|
|
|
ObjectData *realObject = objectData(realObjectIndex);
|
|
|
|
|
|
|
|
int fromState = (dummyObject->name < 0) ? -1 : 0;
|
|
|
|
|
|
|
|
int frameCountReal = 1;
|
|
|
|
int frameCountDummy = 1;
|
|
|
|
|
|
|
|
int graphic = realObject->image;
|
|
|
|
if (graphic > 0) {
|
|
|
|
if (graphic > 5000)
|
|
|
|
graphic -= 5000;
|
|
|
|
|
|
|
|
GraphicData *data = graphicData(graphic);
|
|
|
|
|
|
|
|
if (data->lastFrame > 0)
|
|
|
|
frameCountReal = data->lastFrame - data->firstFrame + 1;
|
|
|
|
|
|
|
|
graphic = dummyObject->image;
|
|
|
|
if (graphic > 0) {
|
|
|
|
if (graphic > 5000)
|
|
|
|
graphic -= 5000;
|
|
|
|
|
|
|
|
data = graphicData(graphic);
|
|
|
|
|
|
|
|
if (data->lastFrame > 0)
|
|
|
|
frameCountDummy = data->lastFrame - data->firstFrame + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjectData temp = *realObject;
|
|
|
|
*realObject = *dummyObject;
|
|
|
|
|
|
|
|
if (frameCountDummy > frameCountReal)
|
|
|
|
*dummyObject = temp;
|
|
|
|
|
2003-12-05 13:56:07 +00:00
|
|
|
realObject->name = ABS(realObject->name);
|
2003-10-31 13:47:28 +00:00
|
|
|
|
|
|
|
if (fromState == -1)
|
2003-12-05 13:56:07 +00:00
|
|
|
dummyObject->name = -ABS(dummyObject->name);
|
2003-10-31 13:47:28 +00:00
|
|
|
|
|
|
|
// Make sure that WALK_OFF_DATA is copied too!
|
|
|
|
|
|
|
|
for (int i = 1; i <= _numWalkOffs; i++) {
|
|
|
|
WalkOffData *walkOff = &_walkOffData[i];
|
|
|
|
if (walkOff->entryObj == (int16)dummyObjectIndex) {
|
|
|
|
walkOff->entryObj = (int16)realObjectIndex;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::checkPlayer() {
|
2003-12-13 20:05:28 +00:00
|
|
|
|
2003-10-31 13:47:28 +00:00
|
|
|
update();
|
2003-12-13 20:05:28 +00:00
|
|
|
if (!_vm->input()->cutawayRunning()) {
|
|
|
|
_vm->command()->updatePlayer();
|
|
|
|
}
|
2003-10-31 13:47:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-02 16:47:31 +00:00
|
|
|
void Logic::customMoveJoe(int facing, uint16 areaNum, uint16 walkDataNum) {
|
|
|
|
|
|
|
|
// queen.c l.2838-2911
|
|
|
|
debug(9, "customMoveJoe(%d, %d, %d)\n", facing, areaNum, walkDataNum);
|
|
|
|
|
|
|
|
// Stop animating Joe
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bob(0)->animating = false;
|
2003-11-02 16:47:31 +00:00
|
|
|
|
2003-11-08 23:45:45 +00:00
|
|
|
// Make Joe face the right direction
|
2003-11-02 16:47:31 +00:00
|
|
|
joeFacing(facing);
|
|
|
|
joeFace();
|
|
|
|
|
|
|
|
_newRoom = 0;
|
|
|
|
_entryObj = 0;
|
|
|
|
|
|
|
|
char nextCut[20];
|
|
|
|
memset(nextCut, 0, sizeof(nextCut));
|
|
|
|
|
|
|
|
switch (_currentRoom) {
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_JUNGLE_BRIDGE:
|
2003-11-02 16:47:31 +00:00
|
|
|
joeSpeak(16);
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_JUNGLE_GORILLA_1:
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway("c6c.CUT", nextCut);
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_JUNGLE_GORILLA_2:
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway("c14b.CUT", nextCut);
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_AMAZON_ENTRANCE:
|
2003-11-02 16:47:31 +00:00
|
|
|
if (areaNum == 3) {
|
|
|
|
playCutaway("c16a.CUT", nextCut);
|
|
|
|
}
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_AMAZON_HIDEOUT:
|
2003-11-02 16:47:31 +00:00
|
|
|
if (walkDataNum == 4) {
|
|
|
|
playCutaway("c17a.CUT", nextCut);
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if (walkDataNum == 2) {
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway("c17b.CUT", nextCut);
|
|
|
|
}
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_FLODA_OUTSIDE:
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway("c22a.CUT", nextCut);
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_FLODA_KITCHEN:
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway("c26b.CUT", nextCut);
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_FLODA_KLUNK:
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway("c30a.CUT", nextCut);
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_FLODA_HENRY:
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway("c32c.CUT", nextCut);
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_TEMPLE_ZOMBIES:
|
2003-11-02 16:47:31 +00:00
|
|
|
if (areaNum == 6) {
|
|
|
|
if (_gameState[21] == 0) {
|
|
|
|
playCutaway("c50d.CUT", nextCut);
|
|
|
|
while (nextCut[0] != '\0') {
|
|
|
|
playCutaway(nextCut, nextCut);
|
|
|
|
}
|
2003-11-03 19:52:14 +00:00
|
|
|
_gameState[21] = 1;
|
2003-11-02 16:47:31 +00:00
|
|
|
} else {
|
|
|
|
playCutaway("c50h.CUT", nextCut);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_TEMPLE_SNAKE:
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway("c53b.CUT", nextCut);
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_TEMPLE_LIZARD_LASER:
|
2003-11-02 16:47:31 +00:00
|
|
|
joeSpeak(19);
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_HOTEL_DOWNSTAIRS:
|
2003-11-02 16:47:31 +00:00
|
|
|
joeSpeak(21);
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_HOTEL_LOBBY:
|
|
|
|
if (_gameState[VAR_ESCAPE_FROM_HOTEL_COUNT] == 0) {
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway("c73a.CUT");
|
2003-12-03 10:32:12 +00:00
|
|
|
_gameState[VAR_ESCAPE_FROM_HOTEL_COUNT] = 1;
|
2003-11-02 16:47:31 +00:00
|
|
|
joeUseUnderwear();
|
|
|
|
joeFace();
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if (_gameState[VAR_ESCAPE_FROM_HOTEL_COUNT] == 1) {
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway("c73b.CUT");
|
2003-12-03 10:32:12 +00:00
|
|
|
_gameState[VAR_ESCAPE_FROM_HOTEL_COUNT] = 2;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if (_gameState[VAR_ESCAPE_FROM_HOTEL_COUNT] == 2) {
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway("c73c.CUT");
|
|
|
|
}
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_TEMPLE_MAZE_5:
|
2003-11-02 16:47:31 +00:00
|
|
|
if (areaNum == 7) {
|
|
|
|
joeSpeak(17);
|
|
|
|
}
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_TEMPLE_MAZE_6:
|
2003-11-02 16:47:31 +00:00
|
|
|
if (areaNum == 5 && _gameState[187] == 0) {
|
|
|
|
playCutaway("c101b.CUT", nextCut);
|
|
|
|
}
|
|
|
|
break;
|
2003-12-03 10:32:12 +00:00
|
|
|
case ROOM_FLODA_FRONTDESK:
|
2003-11-02 16:47:31 +00:00
|
|
|
if (areaNum == 3) {
|
2003-12-03 10:32:12 +00:00
|
|
|
if (_gameState[VAR_BYPASS_FLODA_RECEPTIONIST] == 1) {
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway("c103e.CUT", nextCut);
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if (_gameState[VAR_BYPASS_FLODA_RECEPTIONIST] == 0) {
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway("c103b.CUT", nextCut);
|
2003-12-03 10:32:12 +00:00
|
|
|
_gameState[VAR_BYPASS_FLODA_RECEPTIONIST] = 1;
|
2003-11-02 16:47:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (strlen(nextCut) > 4 &&
|
2003-12-03 10:32:12 +00:00
|
|
|
scumm_stricmp(nextCut + strlen(nextCut) - 4, ".cut") == 0) {
|
2003-11-02 16:47:31 +00:00
|
|
|
playCutaway(nextCut, nextCut);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-04 13:51:36 +00:00
|
|
|
void Logic::handlePinnacleRoom() {
|
|
|
|
|
|
|
|
// camera does not follow Joe anymore
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(-1);
|
2003-11-30 20:41:02 +00:00
|
|
|
roomDisplay(ROOM_JUNGLE_PINNACLE, RDM_NOFADE_JOE, 100, 2, true);
|
2003-11-04 13:51:36 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *joe = _vm->graphics()->bob(6);
|
|
|
|
BobSlot *piton = _vm->graphics()->bob(7);
|
2003-11-04 13:51:36 +00:00
|
|
|
|
|
|
|
// set scrolling value to mouse position to avoid glitch
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->horizontalScroll(_vm->input()->mousePosX());
|
2003-11-04 13:51:36 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
joe->x = piton->x = 3 * _vm->input()->mousePosX() / 4 + 200;
|
2003-11-04 13:51:36 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
joe->frameNum = _vm->input()->mousePosX() / 36 + 43 + FRAMES_JOE_XTRA;
|
2003-11-04 13:51:36 +00:00
|
|
|
|
|
|
|
// adjust bounding box for fullscreen
|
|
|
|
joe->box.y2 = piton->box.y2 = GAME_SCREEN_HEIGHT - 1;
|
|
|
|
|
|
|
|
// bobs have been unpacked from animating objects, we don't need them
|
|
|
|
// to animate anymore ; so turn animating off
|
|
|
|
joe->animating = piton->animating = false;
|
|
|
|
|
|
|
|
update();
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palFadeIn(0, 223, ROOM_JUNGLE_PINNACLE, joe->active, joe->x, joe->y);
|
2003-12-15 13:00:48 +00:00
|
|
|
_vm->graphics()->textCurrentColor(INK_PINNACLE_ROOM);
|
2003-11-04 13:51:36 +00:00
|
|
|
|
|
|
|
_entryObj = 0;
|
|
|
|
uint16 prevObj = 0;
|
2003-12-11 22:16:35 +00:00
|
|
|
while (_vm->input()->mouseButton() == 0 || _entryObj == 0) {
|
2003-11-04 13:51:36 +00:00
|
|
|
|
|
|
|
update();
|
2003-12-11 22:16:35 +00:00
|
|
|
int mx = _vm->input()->mousePosX();
|
|
|
|
int my = _vm->input()->mousePosY();
|
2003-11-04 13:51:36 +00:00
|
|
|
|
|
|
|
// update screen scrolling
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->horizontalScroll(_vm->input()->mousePosX());
|
2003-11-04 13:51:36 +00:00
|
|
|
|
|
|
|
// update bobs position / frame
|
|
|
|
joe->x = piton->x = 3 * mx / 4 + 200;
|
|
|
|
joe->frameNum = mx / 36 + 43 + FRAMES_JOE_XTRA;
|
|
|
|
|
2003-12-15 13:00:48 +00:00
|
|
|
_vm->graphics()->textClear(5, 5);
|
|
|
|
|
2003-11-04 13:51:36 +00:00
|
|
|
uint16 curObj = findObjectUnderCursor(mx, my);
|
|
|
|
if (curObj != 0 && curObj != prevObj) {
|
|
|
|
_entryObj = 0;
|
|
|
|
curObj += _roomData[_currentRoom]; // global object number
|
|
|
|
ObjectData *objData = &_objectData[curObj];
|
|
|
|
if (objData->name > 0) {
|
|
|
|
_entryObj = objData->entryObj;
|
|
|
|
char textCmd[CmdText::MAX_COMMAND_LEN];
|
2003-12-12 10:33:34 +00:00
|
|
|
sprintf(textCmd, "%s %s", verbName(VERB_WALK_TO), _objName[objData->name]);
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->textSetCentered(5, textCmd);
|
2003-11-04 13:51:36 +00:00
|
|
|
}
|
|
|
|
prevObj = curObj;
|
|
|
|
}
|
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->clearMouseButton();
|
2003-11-04 13:51:36 +00:00
|
|
|
|
|
|
|
_newRoom = _objectData[_entryObj].room;
|
|
|
|
|
2003-11-16 10:47:31 +00:00
|
|
|
// Only a few commands can be triggered from this room :
|
|
|
|
// piton -> crash : 0x216 (obj=0x2a, song=3)
|
|
|
|
// piton -> floda : 0x217 (obj=0x29, song=16)
|
|
|
|
// piton -> bob : 0x219 (obj=0x2f, song=6)
|
|
|
|
// piton -> embark : 0x218 (obj=0x2c, song=7)
|
|
|
|
// piton -> jungle : 0x20B (obj=0x2b, song=3)
|
|
|
|
// piton -> amazon : 0x21A (obj=0x30, song=3)
|
2003-11-04 13:51:36 +00:00
|
|
|
//
|
2003-11-16 10:47:31 +00:00
|
|
|
// Because none of these update objects/areas/gamestate, the EXECUTE_ACTION()
|
|
|
|
// call, as the original does, is useless. All we have to do is the playsong
|
|
|
|
// call (all songs have the PLAY_BEFORE type). This way we could get rid of
|
|
|
|
// the hack described in execute.c l.334-339.
|
2003-11-04 13:51:36 +00:00
|
|
|
//
|
|
|
|
// XXX if (com->song > 0) { playsong(com->song); }
|
|
|
|
|
2003-11-16 10:47:31 +00:00
|
|
|
joe->active = piton->active = false;
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->textClear(5, 5);
|
2003-11-16 10:47:31 +00:00
|
|
|
|
2003-11-04 13:51:36 +00:00
|
|
|
// camera follows Joe again
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(0);
|
2003-11-12 10:50:05 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palFadeOut(0, 223, ROOM_JUNGLE_PINNACLE);
|
2003-11-04 13:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-23 06:44:35 +00:00
|
|
|
void Logic::update() {
|
2003-12-26 12:58:27 +00:00
|
|
|
|
|
|
|
if (_vm->debugger()->isAttached()) {
|
|
|
|
_vm->debugger()->onFrame();
|
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->update(_currentRoom);
|
2003-12-26 12:58:27 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->delay();
|
2003-12-26 12:58:27 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palCustomScroll(_currentRoom);
|
2003-12-26 12:58:27 +00:00
|
|
|
if (_vm->debugger()->_drawAreas) {
|
|
|
|
for(int i = 1; i < MAX_ZONES_NUMBER; ++i) {
|
|
|
|
const ZoneSlot *pzs = &_zones[ZONE_ROOM][i];
|
|
|
|
if (pzs->valid) {
|
|
|
|
const Box *b = &pzs->box;
|
|
|
|
_vm->display()->drawBox(b->x1, b->y1, b->x2, b->y2, 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *joe = _vm->graphics()->bob(0);
|
|
|
|
_vm->display()->update(joe->active, joe->x, joe->y);
|
2003-12-26 12:58:27 +00:00
|
|
|
|
|
|
|
_vm->input()->checkKeys();
|
|
|
|
if (_vm->input()->debugger()) {
|
|
|
|
_vm->input()->debuggerReset();
|
|
|
|
_vm->debugger()->attach();
|
|
|
|
}
|
|
|
|
if (!_vm->input()->cutawayRunning()) {
|
|
|
|
if (_vm->input()->quickSave()) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->quickSaveReset();
|
2003-11-09 21:31:18 +00:00
|
|
|
gameSave(0, "Quicksave");
|
|
|
|
}
|
2003-12-26 12:58:27 +00:00
|
|
|
if (_vm->input()->quickLoad()) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->quickLoadReset();
|
2003-11-09 21:31:18 +00:00
|
|
|
gameLoad(0);
|
|
|
|
}
|
2003-12-26 14:49:49 +00:00
|
|
|
if (_vm->input()->idleTime() >= Input::DELAY_SCREEN_BLANKER) {
|
|
|
|
_vm->display()->blankScreen();
|
|
|
|
}
|
2003-12-26 12:58:27 +00:00
|
|
|
}
|
2003-11-09 21:31:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Logic::gameSave(uint16 slot, const char *desc) {
|
|
|
|
if (!desc) //no description entered
|
|
|
|
return false;
|
|
|
|
|
|
|
|
debug(3, "Saving game to slot %d", slot);
|
|
|
|
|
|
|
|
int i, j;
|
|
|
|
char *buf = new char[32];
|
|
|
|
memcpy(buf, desc, strlen(desc) < 32 ? strlen(desc) : 32);
|
|
|
|
for (i = strlen(desc); i < 32; i++)
|
|
|
|
buf[i] = '\0';
|
|
|
|
byte *saveData = new byte[SAVEGAME_SIZE];
|
|
|
|
byte *ptr = saveData;
|
|
|
|
memcpy(ptr, buf, 32); ptr += 32;
|
2003-11-09 21:55:19 +00:00
|
|
|
delete[] buf;
|
2003-11-09 21:31:18 +00:00
|
|
|
|
2003-12-10 20:13:25 +00:00
|
|
|
WRITE_BE_UINT16(ptr, _talkSpeed); ptr += 2;
|
|
|
|
WRITE_BE_UINT16(ptr, 0 /*_settings.musicVolume*/); ptr += 2;
|
2003-12-11 22:16:35 +00:00
|
|
|
WRITE_BE_UINT16(ptr, _vm->sound()->sfxOn() ? 1 : 0); ptr += 2;
|
|
|
|
WRITE_BE_UINT16(ptr, _vm->sound()->speechOn() ? 1 : 0); ptr += 2;
|
|
|
|
WRITE_BE_UINT16(ptr, _vm->sound()->musicOn() ? 1 : 0); ptr += 2;
|
2003-12-10 20:13:25 +00:00
|
|
|
WRITE_BE_UINT16(ptr, _subtitles ? 1 : 0); ptr += 2;
|
2003-11-09 21:31:18 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
WRITE_BE_UINT16(ptr, _inventoryItem[i]); ptr += 2;
|
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
WRITE_BE_UINT16(ptr, _vm->graphics()->bob(0)->x); ptr += 2;
|
|
|
|
WRITE_BE_UINT16(ptr, _vm->graphics()->bob(0)->y); ptr += 2;
|
2003-11-09 21:31:18 +00:00
|
|
|
WRITE_BE_UINT16(ptr, _currentRoom); ptr += 2;
|
|
|
|
|
|
|
|
for (i = 1; i <= _numObjects; i++)
|
2003-12-28 01:17:29 +00:00
|
|
|
_objectData[i].writeToBE(ptr);
|
2003-11-09 21:31:18 +00:00
|
|
|
|
|
|
|
for (i = 1; i <= _numItems; i++)
|
2003-12-28 01:17:29 +00:00
|
|
|
_itemData[i].writeToBE(ptr);
|
2003-11-09 21:31:18 +00:00
|
|
|
|
|
|
|
for (i = 0; i < GAME_STATE_COUNT; i++) {
|
|
|
|
WRITE_BE_UINT16(ptr, gameState(i)); ptr += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i <= _numRooms; i++)
|
|
|
|
for (j = 1; j <= _areaMax[i]; j++)
|
2003-12-28 01:17:29 +00:00
|
|
|
_area[i][j].writeToBE(ptr);
|
2003-11-09 21:31:18 +00:00
|
|
|
|
2003-11-09 21:55:19 +00:00
|
|
|
for (i = 0; i < TALK_SELECTED_COUNT; i++)
|
2003-12-28 01:17:29 +00:00
|
|
|
_talkSelected[i].writeToBE(ptr);
|
2003-11-09 21:31:18 +00:00
|
|
|
|
|
|
|
for (i = 1; i <= _numWalkOffs; i++)
|
2003-12-28 01:17:29 +00:00
|
|
|
_walkOffData[i].writeToBE(ptr);
|
2003-11-09 21:31:18 +00:00
|
|
|
|
|
|
|
WRITE_BE_UINT16(ptr, _joe.facing); ptr += 2;
|
2003-12-19 09:22:20 +00:00
|
|
|
WRITE_BE_UINT16(ptr, _vm->bam()->_flag); ptr += 2;
|
2003-12-28 01:17:29 +00:00
|
|
|
WRITE_BE_UINT16(ptr, _vm->sound()->lastOverride()); ptr += 2;
|
2003-11-09 21:31:18 +00:00
|
|
|
|
|
|
|
//TODO: lastmerge, lastalter, altmrgpri
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
WRITE_BE_UINT16(ptr, 0); ptr += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ptr - saveData) != SAVEGAME_SIZE) {
|
|
|
|
delete[] saveData;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
bool result = _vm->resource()->writeSave(slot, saveData, SAVEGAME_SIZE);
|
2003-11-09 21:31:18 +00:00
|
|
|
delete[] saveData;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Logic::gameLoad(uint16 slot) {
|
|
|
|
int i, j;
|
|
|
|
byte *saveData = new byte[SAVEGAME_SIZE];
|
|
|
|
byte *ptr = saveData;
|
2003-12-11 22:16:35 +00:00
|
|
|
if (!_vm->resource()->readSave(slot, saveData)) {
|
2003-11-09 21:31:18 +00:00
|
|
|
warning("Couldn't load savegame from slot %d", slot);
|
|
|
|
delete[] saveData;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
debug(3, "Loading game from slot %d", slot);
|
|
|
|
ptr += 32; //skip description
|
2003-12-11 22:16:35 +00:00
|
|
|
/*_talkSpeed = (int16)READ_BE_UINT16(ptr);*/ ptr += 2;
|
2003-12-10 20:13:25 +00:00
|
|
|
/*_settings.musicVolume = (int16)READ_BE_UINT16(ptr);*/ ptr += 2;
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->sound()->sfxToggle(READ_BE_UINT16(ptr) != 0); ptr += 2;
|
|
|
|
_vm->sound()->speechToggle(READ_BE_UINT16(ptr) != 0); ptr += 2;
|
|
|
|
_vm->sound()->musicToggle(READ_BE_UINT16(ptr) != 0); ptr += 2;
|
2003-12-10 20:13:25 +00:00
|
|
|
_subtitles = READ_BE_UINT16(ptr) != 0; ptr += 2;
|
2003-11-09 21:31:18 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
_inventoryItem[i] = (int16)READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
_joe.x = (int16)READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
_joe.y = (int16)READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
|
|
|
|
currentRoom(READ_BE_UINT16(ptr)); ptr += 2;
|
|
|
|
|
|
|
|
for (i = 1; i <= _numObjects; i++)
|
2003-12-28 01:17:29 +00:00
|
|
|
_objectData[i].readFromBE(ptr);
|
2003-11-09 21:31:18 +00:00
|
|
|
|
|
|
|
for (i = 1; i <= _numItems; i++)
|
2003-12-28 01:17:29 +00:00
|
|
|
_itemData[i].readFromBE(ptr);
|
2003-11-09 21:31:18 +00:00
|
|
|
|
|
|
|
for (i = 0; i < GAME_STATE_COUNT; i++) {
|
|
|
|
gameState(i, (int16)READ_BE_UINT16(ptr)); ptr += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i <= _numRooms; i++)
|
|
|
|
for (j = 1; j <= _areaMax[i]; j++)
|
2003-12-28 01:17:29 +00:00
|
|
|
_area[i][j].readFromBE(ptr);
|
2003-11-09 21:31:18 +00:00
|
|
|
|
2003-11-09 21:55:19 +00:00
|
|
|
for (i = 0; i < TALK_SELECTED_COUNT; i++)
|
2003-12-28 01:17:29 +00:00
|
|
|
_talkSelected[i].readFromBE(ptr);
|
2003-11-09 21:31:18 +00:00
|
|
|
|
|
|
|
for (i = 1; i <= _numWalkOffs; i++)
|
2003-12-28 01:17:29 +00:00
|
|
|
_walkOffData[i].readFromBE(ptr);
|
2003-11-09 21:31:18 +00:00
|
|
|
|
|
|
|
joeFacing(READ_BE_UINT16(ptr)); ptr += 2;
|
2003-12-19 09:22:20 +00:00
|
|
|
_vm->bam()->_flag = READ_BE_UINT16(ptr); ptr += 2;
|
2003-12-28 01:17:29 +00:00
|
|
|
_vm->sound()->playSong((int16)READ_BE_UINT16(ptr)); ptr += 2;
|
2003-11-09 21:31:18 +00:00
|
|
|
|
|
|
|
//TODO: lastmerge, lastalter, altmrgpri
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
READ_BE_UINT16(ptr); ptr += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ptr - saveData) != SAVEGAME_SIZE) {
|
|
|
|
delete[] saveData;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-12-19 09:22:20 +00:00
|
|
|
if (_vm->bam()->_flag != BamScene::F_STOP) {
|
|
|
|
_vm->bam()->prepareAnimation();
|
|
|
|
}
|
|
|
|
|
2003-11-27 13:49:00 +00:00
|
|
|
joeCutFacing(joeFacing());
|
2003-11-09 21:31:18 +00:00
|
|
|
joeFace();
|
|
|
|
|
|
|
|
//OLDX = _joe.x;
|
|
|
|
//OLDY = _joe.y;
|
|
|
|
_oldRoom = 0;
|
|
|
|
newRoom(_currentRoom);
|
|
|
|
_entryObj = 0;
|
|
|
|
|
|
|
|
switch (gameState(VAR_DRESSING_MODE)) {
|
2003-12-19 09:22:20 +00:00
|
|
|
case 0:
|
|
|
|
joeUseClothes(false);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
joeUseUnderwear();
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
joeUseDress(false);
|
|
|
|
break;
|
2003-11-09 21:31:18 +00:00
|
|
|
}
|
2003-12-19 09:22:20 +00:00
|
|
|
|
2003-11-09 21:31:18 +00:00
|
|
|
inventoryRefresh();
|
2003-12-19 09:22:20 +00:00
|
|
|
|
2003-11-09 21:31:18 +00:00
|
|
|
delete[] saveData;
|
|
|
|
return true;
|
2003-10-23 06:44:35 +00:00
|
|
|
}
|
2003-10-21 09:05:16 +00:00
|
|
|
|
2003-11-14 14:35:52 +00:00
|
|
|
void Logic::sceneStart() {
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "[Logic::sceneStart] _scene = %i", _scene);
|
2003-11-08 11:32:32 +00:00
|
|
|
_scene++;
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->showMouseCursor(false);
|
2003-11-08 11:32:32 +00:00
|
|
|
|
2003-12-29 20:17:43 +00:00
|
|
|
if (1 == _scene) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palFadePanel();
|
2003-11-08 11:32:32 +00:00
|
|
|
}
|
2003-11-08 23:45:45 +00:00
|
|
|
|
2003-11-08 11:32:32 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2003-11-14 14:35:52 +00:00
|
|
|
void Logic::sceneStop() {
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "[Logic::sceneStop] _scene = %i", _scene);
|
2003-11-08 11:32:32 +00:00
|
|
|
_scene--;
|
|
|
|
|
|
|
|
if (_scene > 0)
|
|
|
|
return;
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palSetAllDirty();
|
|
|
|
_vm->display()->showMouseCursor(true);
|
2003-11-08 11:32:32 +00:00
|
|
|
zoneSetupPanel();
|
|
|
|
}
|
2003-10-23 18:46:04 +00:00
|
|
|
|
2003-11-15 15:44:50 +00:00
|
|
|
|
2003-12-10 15:36:44 +00:00
|
|
|
void Logic::changeRoom() {
|
|
|
|
|
2003-12-29 16:35:08 +00:00
|
|
|
if (!(this->*_preChangeRoom)())
|
2003-12-10 15:36:44 +00:00
|
|
|
roomDisplay(currentRoom(), RDM_FADE_JOE, 100, 1, false);
|
2003-12-29 16:35:08 +00:00
|
|
|
_vm->display()->showMouseCursor(true);
|
2003-12-10 15:36:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-15 15:44:50 +00:00
|
|
|
void Logic::useJournal() {
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
if (_vm->resource()->isDemo()) {
|
2003-11-26 21:46:29 +00:00
|
|
|
makePersonSpeak("This is a demo, so I can't load or save games*14", NULL, "");
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-11-26 20:40:43 +00:00
|
|
|
|
2003-11-26 13:53:17 +00:00
|
|
|
// XXX save some vars
|
2003-11-26 20:40:43 +00:00
|
|
|
//
|
|
|
|
// XXX tmpbamflag=bamflag;
|
|
|
|
// XXX bamflag=0;
|
|
|
|
// XXX in_journal=1;
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->command()->clear(false);
|
2003-11-26 20:40:43 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
Journal j(_vm);
|
2003-11-26 13:53:17 +00:00
|
|
|
j.use();
|
2003-11-26 20:40:43 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->walk()->stopJoe();
|
2003-11-26 20:40:43 +00:00
|
|
|
|
2003-11-26 13:53:17 +00:00
|
|
|
// XXX restore vars
|
2003-11-26 20:40:43 +00:00
|
|
|
//
|
|
|
|
// XXX in_journal=0;
|
|
|
|
// XXX bamflag=tmpbamflag;
|
|
|
|
// XXX TALKQUIT=CUTQUIT=0; Make sure that we turn off cut stuff in case we use Journal during cutaways
|
2003-11-26 13:53:17 +00:00
|
|
|
|
2003-11-15 15:44:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-10 20:13:25 +00:00
|
|
|
void Logic::registerDefaultSettings() {
|
|
|
|
|
|
|
|
ConfMan.registerDefault("master_volume", 255);
|
|
|
|
ConfMan.registerDefault("music_mute", false);
|
|
|
|
ConfMan.registerDefault("sfx_mute", false);
|
|
|
|
ConfMan.registerDefault("talkspeed", DEFAULT_TALK_SPEED);
|
2003-12-11 22:16:35 +00:00
|
|
|
ConfMan.registerDefault("speech_mute", _vm->resource()->isFloppy());
|
2003-12-10 20:13:25 +00:00
|
|
|
ConfMan.registerDefault("subtitles", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::checkOptionSettings() {
|
|
|
|
|
|
|
|
// check talkspeed value
|
|
|
|
if (_talkSpeed < 4) {
|
|
|
|
_talkSpeed = 4;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if (_talkSpeed > 95) {
|
2003-12-10 20:13:25 +00:00
|
|
|
_talkSpeed = 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX check master_volume value
|
|
|
|
|
|
|
|
// only CD-ROM version has speech
|
2003-12-28 15:29:05 +00:00
|
|
|
if (_vm->resource()->isFloppy() && _vm->sound()->speechOn()) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->sound()->speechToggle(false);
|
2003-12-10 20:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ensure text is always on when voice is off
|
2003-12-11 22:16:35 +00:00
|
|
|
if (!_vm->sound()->speechOn()) {
|
2003-12-10 20:13:25 +00:00
|
|
|
_subtitles = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::readOptionSettings() {
|
|
|
|
|
|
|
|
// XXX master_volume
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->sound()->musicToggle(!ConfMan.getBool("music_mute"));
|
|
|
|
_vm->sound()->sfxToggle(!ConfMan.getBool("sfx_mute"));
|
2003-12-10 20:13:25 +00:00
|
|
|
_talkSpeed = ConfMan.getInt("talkspeed");
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->sound()->speechToggle(!ConfMan.getBool("speech_mute"));
|
2003-12-10 20:13:25 +00:00
|
|
|
_subtitles = ConfMan.getBool("subtitles");
|
|
|
|
|
|
|
|
checkOptionSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::writeOptionSettings() {
|
|
|
|
|
|
|
|
// XXX master_volume
|
2003-12-11 22:16:35 +00:00
|
|
|
ConfMan.set("music_mute", !_vm->sound()->musicOn());
|
|
|
|
ConfMan.set("sfx_mute", !_vm->sound()->sfxOn());
|
2003-12-10 20:13:25 +00:00
|
|
|
ConfMan.set("talkspeed", _talkSpeed);
|
2003-12-11 22:16:35 +00:00
|
|
|
ConfMan.set("speech_mute", !_vm->sound()->speechOn());
|
2003-12-10 20:13:25 +00:00
|
|
|
ConfMan.set("subtitles", _subtitles);
|
|
|
|
|
|
|
|
ConfMan.flushToDisk();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-29 16:35:08 +00:00
|
|
|
bool Logic::preChangeRoom_Demo() {
|
|
|
|
if (currentRoom() == FOTAQ_LOGO && gameState(VAR_INTRO_PLAYED) == 0) {
|
|
|
|
currentRoom(79);
|
|
|
|
roomDisplay(currentRoom(), RDM_FADE_NOJOE, 100, 2, true);
|
|
|
|
playCutaway("clogo.cut");
|
|
|
|
sceneReset();
|
|
|
|
currentRoom(ROOM_HOTEL_LOBBY);
|
|
|
|
entryObj(584);
|
|
|
|
roomDisplay(currentRoom(), RDM_FADE_JOE, 100, 2, true);
|
|
|
|
playCutaway("c70d.cut");
|
|
|
|
gameState(VAR_INTRO_PLAYED, 1);
|
|
|
|
inventorySetup();
|
|
|
|
inventoryRefresh();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Logic::preChangeRoom_Interview() {
|
|
|
|
// XXX
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Logic::preChangeRoom_Game() {
|
|
|
|
if (currentRoom() == ROOM_JUNGLE_PINNACLE) {
|
|
|
|
handlePinnacleRoom();
|
|
|
|
return true;
|
|
|
|
} else if (currentRoom() == FOTAQ_LOGO && gameState(VAR_INTRO_PLAYED) == 0) {
|
|
|
|
roomDisplay(currentRoom(), RDM_FADE_NOJOE, 100, 2, true);
|
|
|
|
playCutaway("copy.cut");
|
|
|
|
playCutaway("clogo.cut");
|
|
|
|
|
|
|
|
// XXX enable talking for talkie version
|
|
|
|
|
|
|
|
if (ConfMan.getBool("alt_intro")) {
|
|
|
|
_vm->graphics()->loadPanel();
|
|
|
|
playCutaway("cintr.cut");
|
|
|
|
} else {
|
|
|
|
playCutaway("cdint.cut");
|
|
|
|
_vm->graphics()->loadPanel();
|
|
|
|
}
|
|
|
|
|
|
|
|
playCutaway("cred.cut");
|
|
|
|
sceneReset();
|
|
|
|
currentRoom(ROOM_HOTEL_LOBBY);
|
|
|
|
entryObj(584);
|
|
|
|
roomDisplay(currentRoom(), RDM_FADE_JOE, 100, 2, true);
|
|
|
|
playCutaway("c70d.cut");
|
|
|
|
gameState(VAR_INTRO_PLAYED, 1);
|
|
|
|
inventorySetup();
|
|
|
|
inventoryRefresh();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-29 20:17:43 +00:00
|
|
|
bool Logic::executeASM_Demo(uint16 sm) {
|
|
|
|
switch (sm) {
|
|
|
|
case 4:
|
|
|
|
asmMakeJoeUseUnderwear();
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
asmSwitchToDressPalette();
|
|
|
|
break;
|
|
|
|
case 14:
|
|
|
|
asmEndDemo();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
2003-12-29 16:35:08 +00:00
|
|
|
}
|
|
|
|
|
2003-12-29 20:17:43 +00:00
|
|
|
bool Logic::executeASM_Interview(uint16 sm) {
|
2003-12-29 16:35:08 +00:00
|
|
|
// XXX
|
2003-12-29 20:17:43 +00:00
|
|
|
return false;
|
2003-12-29 16:35:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-29 20:17:43 +00:00
|
|
|
bool Logic::executeASM_Game(uint16 sm) {
|
|
|
|
typedef void (Logic::*SpecialMoveProc)();
|
|
|
|
static const SpecialMoveProc asmTable[] = {
|
2003-12-10 14:19:04 +00:00
|
|
|
/* 00 */
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&Logic::asmMakeJoeUseDress,
|
|
|
|
&Logic::asmMakeJoeUseNormalClothes,
|
|
|
|
/* 04 */
|
|
|
|
&Logic::asmMakeJoeUseUnderwear,
|
|
|
|
&Logic::asmSwitchToDressPalette,
|
|
|
|
&Logic::asmSwitchToNormalPalette,
|
2003-12-29 20:17:43 +00:00
|
|
|
&Logic::asmStartCarAnimation, // room 74
|
2003-12-10 14:19:04 +00:00
|
|
|
/* 08 */
|
2003-12-29 20:17:43 +00:00
|
|
|
&Logic::asmStopCarAnimation, // room 74
|
|
|
|
&Logic::asmStartFightAnimation, // room 69
|
2003-12-29 16:35:08 +00:00
|
|
|
&Logic::asmWaitForFrankPosition, // c69e.cut
|
|
|
|
&Logic::asmMakeFrankGrowing, // c69z.cut
|
2003-12-10 14:19:04 +00:00
|
|
|
/* 12 */
|
2003-12-29 16:35:08 +00:00
|
|
|
&Logic::asmMakeRobotGrowing, // c69z.cut
|
2003-12-10 14:19:04 +00:00
|
|
|
&Logic::asmShrinkRobot,
|
|
|
|
&Logic::asmEndGame,
|
|
|
|
&Logic::asmPutCameraOnDino,
|
|
|
|
/* 16 */
|
|
|
|
&Logic::asmPutCameraOnJoe,
|
2003-12-29 16:35:08 +00:00
|
|
|
&Logic::asmAltIntroPanRight, // cintr.cut
|
|
|
|
&Logic::asmAltIntroPanLeft, // cintr.cut
|
2003-12-10 14:19:04 +00:00
|
|
|
&Logic::asmSetAzuraInLove,
|
|
|
|
/* 20 */
|
|
|
|
&Logic::asmPanRightFromJoe,
|
|
|
|
&Logic::asmSetLightsOff,
|
|
|
|
&Logic::asmSetLightsOn,
|
|
|
|
&Logic::asmSetManequinAreaOn,
|
|
|
|
/* 24 */
|
|
|
|
&Logic::asmPanToJoe,
|
|
|
|
&Logic::asmTurnGuardOn,
|
|
|
|
&Logic::asmPanLeft320To144,
|
|
|
|
&Logic::asmSmooch,
|
|
|
|
/* 28 */
|
|
|
|
&Logic::asmMakeLightningHitPlane,
|
|
|
|
&Logic::asmScaleBlimp,
|
|
|
|
&Logic::asmScaleEnding,
|
|
|
|
&Logic::asmWaitForCarPosition,
|
|
|
|
/* 32 */
|
|
|
|
&Logic::asmShakeScreen,
|
|
|
|
&Logic::asmAttemptPuzzle,
|
|
|
|
&Logic::asmScaleTitle,
|
2003-12-29 20:17:43 +00:00
|
|
|
NULL,
|
2003-12-10 14:19:04 +00:00
|
|
|
/* 36 */
|
|
|
|
&Logic::asmPanRightToHugh,
|
|
|
|
&Logic::asmMakeWhiteFlash,
|
|
|
|
&Logic::asmPanRightToJoeAndRita,
|
2003-12-29 16:35:08 +00:00
|
|
|
&Logic::asmPanLeftToBomb // cdint.cut
|
2003-12-10 14:19:04 +00:00
|
|
|
};
|
2003-12-29 20:17:43 +00:00
|
|
|
if (sm >= ARRAYSIZE(asmTable) || asmTable[sm] == NULL)
|
|
|
|
return false;
|
|
|
|
(this->*asmTable[sm])();
|
|
|
|
return true;
|
2003-12-29 16:35:08 +00:00
|
|
|
}
|
|
|
|
|
2003-12-10 14:19:04 +00:00
|
|
|
|
2003-12-29 16:35:08 +00:00
|
|
|
void Logic::executeSpecialMove(uint16 sm) {
|
2003-12-29 20:17:43 +00:00
|
|
|
|
2003-12-29 21:05:33 +00:00
|
|
|
debug(6, "Special move: %d", sm);
|
|
|
|
if (sm)
|
|
|
|
if (!(this->*_executeASM)(sm))
|
|
|
|
warning("unhandled / invalid special move : %d", sm);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmMakeJoeUseDress() {
|
|
|
|
joeUseDress(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmMakeJoeUseNormalClothes() {
|
|
|
|
joeUseClothes(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmMakeJoeUseUnderwear() {
|
|
|
|
joeUseUnderwear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmSwitchToDressPalette() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palSetJoe(JP_DRESS);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmSwitchToNormalPalette() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palSetJoe(JP_CLOTHES);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmStartCarAnimation() {
|
2003-12-19 09:22:20 +00:00
|
|
|
_vm->bam()->_flag = BamScene::F_PLAY;
|
|
|
|
_vm->bam()->prepareAnimation();
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmStopCarAnimation() {
|
2003-12-19 09:22:20 +00:00
|
|
|
_vm->bam()->_flag = BamScene::F_STOP;
|
|
|
|
//CR 2 - Turn off big oil splat and gun shots!
|
|
|
|
_vm->graphics()->bob(findBob(594))->active = false; // Oil object
|
|
|
|
_vm->graphics()->bob(7)->active = false;
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmStartFightAnimation() {
|
2003-12-19 09:22:20 +00:00
|
|
|
_vm->bam()->_flag = BamScene::F_PLAY;
|
|
|
|
_vm->bam()->prepareAnimation();
|
2003-12-10 14:19:04 +00:00
|
|
|
gameState(148, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-29 16:35:08 +00:00
|
|
|
void Logic::asmWaitForFrankPosition() {
|
2003-12-19 09:22:20 +00:00
|
|
|
_vm->bam()->_flag = BamScene::F_REQ_STOP;
|
|
|
|
while (_vm->bam()->_flag != BamScene::F_STOP) {
|
2003-12-10 14:19:04 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmMakeFrankGrowing() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(1, 38, 15);
|
|
|
|
BobSlot *bobFrank = _vm->graphics()->bob(5);
|
2003-12-10 14:19:04 +00:00
|
|
|
bobFrank->frameNum = 38;
|
|
|
|
bobFrank->curPos(160, 200);
|
|
|
|
bobFrank->box.y2 = GAME_SCREEN_HEIGHT - 1;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
for (i = 10; i <= 100; i += 4) {
|
|
|
|
bobFrank->scale = i;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
for (i = 0; i <= 20; ++i) {
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
objectData(521)->name = ABS(objectData(521)->name); // Dinoray
|
|
|
|
objectData(526)->name = ABS(objectData(526)->name); // Frank obj
|
|
|
|
objectData(522)->name = -ABS(objectData(522)->name); // TMPD object off
|
|
|
|
objectData(525)->name = -ABS(objectData(525)->name); // Floda guards off
|
|
|
|
objectData(523)->name = -ABS(objectData(523)->name); // Sparky object off
|
|
|
|
gameState(157, 1); // No more Ironstein
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-29 16:35:08 +00:00
|
|
|
void Logic::asmMakeRobotGrowing() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(1, 38, 15);
|
|
|
|
BobSlot *bobRobot = _vm->graphics()->bob(5);
|
2003-12-10 14:19:04 +00:00
|
|
|
bobRobot->frameNum = 38;
|
|
|
|
bobRobot->curPos(160, 200);
|
|
|
|
bobRobot->box.y2 = GAME_SCREEN_HEIGHT - 1;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
for (i = 10; i <= 100; i += 4) {
|
|
|
|
bobRobot->scale = i;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
for (i = 0; i <= 20; ++i) {
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
objectData(524)->name = -ABS(objectData(524)->name); // Azura object off
|
|
|
|
objectData(526)->name = -ABS(objectData(526)->name); // Frank object off
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmShrinkRobot() {
|
|
|
|
int i;
|
|
|
|
for (i = 100; i >= 35; i -= 5) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bob(6)->scale = i;
|
2003-12-10 14:19:04 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmEndGame() {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < 40; ++i) {
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
debug(0, "Game completed");
|
2003-12-19 09:22:20 +00:00
|
|
|
OSystem::instance()->quit();
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmPutCameraOnDino() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(-1);
|
|
|
|
while (_vm->display()->horizontalScroll() < 320) {
|
|
|
|
_vm->display()->horizontalScroll(_vm->display()->horizontalScroll() + 16);
|
|
|
|
if (_vm->display()->horizontalScroll() > 320) {
|
|
|
|
_vm->display()->horizontalScroll(320);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
update();
|
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(1);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmPutCameraOnJoe() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(0);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-27 12:58:26 +00:00
|
|
|
void Logic::asmAltIntroPanRight() {
|
|
|
|
_vm->graphics()->cameraBob(-1);
|
|
|
|
_vm->input()->fastMode(true);
|
|
|
|
update();
|
|
|
|
int16 scrollx = _vm->display()->horizontalScroll();
|
|
|
|
while (scrollx < 285 && !_vm->input()->cutawayQuit()) {
|
|
|
|
++scrollx;
|
|
|
|
if (scrollx > 285) {
|
|
|
|
scrollx = 285;
|
|
|
|
}
|
|
|
|
_vm->display()->horizontalScroll(scrollx);
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
_vm->input()->fastMode(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmAltIntroPanLeft() {
|
|
|
|
_vm->graphics()->cameraBob(-1);
|
|
|
|
_vm->input()->fastMode(true);
|
|
|
|
int16 scrollx = _vm->display()->horizontalScroll();
|
|
|
|
while (scrollx > 0 && !_vm->input()->cutawayQuit()) {
|
|
|
|
scrollx -= 4;
|
|
|
|
if (scrollx < 0) {
|
|
|
|
scrollx = 0;
|
|
|
|
}
|
|
|
|
_vm->display()->horizontalScroll(scrollx);
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
_vm->input()->fastMode(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-10 14:19:04 +00:00
|
|
|
void Logic::asmSetAzuraInLove() {
|
|
|
|
gameState(VAR_AZURA_IN_LOVE, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmPanRightFromJoe() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(-1);
|
|
|
|
while (_vm->display()->horizontalScroll() < 320) {
|
|
|
|
_vm->display()->horizontalScroll(_vm->display()->horizontalScroll() + 16);
|
|
|
|
if (_vm->display()->horizontalScroll() > 320) {
|
|
|
|
_vm->display()->horizontalScroll(320);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmSetLightsOff() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palCustomLightsOff(currentRoom());
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmSetLightsOn() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palCustomLightsOn(currentRoom());
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmSetManequinAreaOn() {
|
|
|
|
area(ROOM_FLODA_FRONTDESK, 7)->mapNeighbours = ABS(area(ROOM_FLODA_FRONTDESK, 7)->mapNeighbours);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmPanToJoe() {
|
2003-12-11 22:16:35 +00:00
|
|
|
int i = _vm->graphics()->bob(0)->x - 160;
|
2003-12-10 14:19:04 +00:00
|
|
|
if (i < 0) {
|
|
|
|
i = 0;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else if (i > 320) {
|
2003-12-10 14:19:04 +00:00
|
|
|
i = 320;
|
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(-1);
|
|
|
|
if (i < _vm->display()->horizontalScroll()) {
|
|
|
|
while (_vm->display()->horizontalScroll() > i) {
|
|
|
|
_vm->display()->horizontalScroll(_vm->display()->horizontalScroll() - 16);
|
|
|
|
if (_vm->display()->horizontalScroll() < i) {
|
|
|
|
_vm->display()->horizontalScroll(i);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
update();
|
|
|
|
}
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-12-11 22:16:35 +00:00
|
|
|
while (_vm->display()->horizontalScroll() < i) {
|
|
|
|
_vm->display()->horizontalScroll(_vm->display()->horizontalScroll() + 16);
|
|
|
|
if (_vm->display()->horizontalScroll() > i ) {
|
|
|
|
_vm->display()->horizontalScroll(i);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
update();
|
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(0);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmTurnGuardOn() {
|
|
|
|
gameState(85, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmPanLeft320To144() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(-1);
|
|
|
|
while (_vm->display()->horizontalScroll() > 144) {
|
|
|
|
_vm->display()->horizontalScroll(_vm->display()->horizontalScroll() - 8);
|
|
|
|
if (_vm->display()->horizontalScroll() < 144) {
|
|
|
|
_vm->display()->horizontalScroll(144);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmSmooch() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(-1);
|
|
|
|
BobSlot *bobAzura = _vm->graphics()->bob(5);
|
|
|
|
BobSlot *bobJoe = _vm->graphics()->bob(6);
|
|
|
|
while (_vm->display()->horizontalScroll() < 320) {
|
|
|
|
_vm->display()->horizontalScroll(_vm->display()->horizontalScroll() + 8);
|
2003-12-10 14:19:04 +00:00
|
|
|
if (bobJoe->x - bobAzura->x > 128) {
|
|
|
|
bobAzura->x += 10;
|
|
|
|
bobJoe->x += 6;
|
2003-12-29 20:51:28 +00:00
|
|
|
} else {
|
2003-12-10 14:19:04 +00:00
|
|
|
bobAzura->x += 8;
|
|
|
|
bobJoe->x += 8;
|
|
|
|
}
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmMakeLightningHitPlane() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(-1);
|
2003-12-10 14:19:04 +00:00
|
|
|
short iy = 0, x, ydir = -1, j, k;
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *planeBob = _vm->graphics()->bob(5);
|
|
|
|
BobSlot *lightningBob = _vm->graphics()->bob(20);
|
2003-12-10 14:19:04 +00:00
|
|
|
|
|
|
|
planeBob->box.y2 = lightningBob->box.y2 = 199;
|
|
|
|
planeBob->y = 135;
|
|
|
|
|
|
|
|
planeBob->scale = 20;
|
|
|
|
|
|
|
|
for (x = 660; x > 163; x -= 6) {
|
|
|
|
planeBob->x = x;
|
|
|
|
planeBob->y = 135 + iy;
|
|
|
|
|
|
|
|
iy -= ydir;
|
|
|
|
if (iy < -9 || iy > 9)
|
|
|
|
ydir = -ydir;
|
|
|
|
|
|
|
|
planeBob->scale++;
|
|
|
|
if (planeBob->scale > 100)
|
|
|
|
planeBob->scale = 100;
|
|
|
|
|
|
|
|
int scrollX = x - 163;
|
|
|
|
if (scrollX > 320)
|
|
|
|
scrollX = 320;
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->horizontalScroll(scrollX);
|
2003-12-10 14:19:04 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
planeBob->scale = 100;
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->horizontalScroll(0);
|
2003-12-10 14:19:04 +00:00
|
|
|
|
|
|
|
planeBob->x -= -8;
|
|
|
|
planeBob->y += 6;
|
|
|
|
|
|
|
|
lightningBob->x = 160;
|
|
|
|
lightningBob->y = 0;
|
|
|
|
|
|
|
|
// 23/2/95 - Play lightning SFX
|
2003-12-20 16:54:46 +00:00
|
|
|
_vm->sound()->playSfx(_vm->logic()->currentRoomSfx());
|
2003-12-10 14:19:04 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(18, lightningBob->frameNum, 15);
|
|
|
|
_vm->graphics()->bankUnpack(4, planeBob ->frameNum, 15);
|
2003-12-10 14:19:04 +00:00
|
|
|
|
|
|
|
// Plane plunges into the jungle!
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *fireBob = _vm->graphics()->bob(6);
|
2003-12-10 14:19:04 +00:00
|
|
|
|
|
|
|
fireBob->animating = true;
|
|
|
|
fireBob->x = planeBob->x;
|
|
|
|
fireBob->y = planeBob->y + 10;
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(19, fireBob->frameNum, 15);
|
2003-12-10 14:19:04 +00:00
|
|
|
update();
|
|
|
|
|
|
|
|
k = 20;
|
|
|
|
j = 1;
|
|
|
|
|
|
|
|
for (x = 163; x > -30; x -= 10) {
|
|
|
|
planeBob->y += 4;
|
|
|
|
fireBob->y += 4;
|
|
|
|
planeBob->x = fireBob->x = x;
|
|
|
|
|
|
|
|
if (k < 40) {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bankUnpack(j, planeBob->frameNum, 15);
|
|
|
|
_vm->graphics()->bankUnpack(k, fireBob ->frameNum, 15);
|
2003-12-10 14:19:04 +00:00
|
|
|
k++;
|
|
|
|
j++;
|
|
|
|
|
|
|
|
if (j == 4)
|
|
|
|
j = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(0);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmScaleBlimp() {
|
|
|
|
int16 z = 256;
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *bob = _vm->graphics()->bob(7);
|
2003-12-10 14:19:04 +00:00
|
|
|
int16 x = bob->x;
|
|
|
|
int16 y = bob->y;
|
|
|
|
while (bob->x > 150) {
|
|
|
|
bob->x = x * 256 / z + 150;
|
|
|
|
bob->x = y * 256 / z + 112;
|
|
|
|
bob->scale = 100 * 256 / z;
|
|
|
|
|
|
|
|
++z;
|
|
|
|
if (z % 6 == 0) {
|
|
|
|
--x;
|
|
|
|
}
|
|
|
|
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmScaleEnding() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->bob(7)->active = false; // Turn off blimp
|
|
|
|
BobSlot *b = _vm->graphics()->bob(20);
|
2003-12-10 14:19:04 +00:00
|
|
|
b->x = 160;
|
|
|
|
b->y = 100;
|
|
|
|
int i;
|
|
|
|
for (i = 5; i <= 100; i += 5) {
|
|
|
|
b->scale = i;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
for (i = 0; i < 50; ++i) {
|
|
|
|
update();
|
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palFadeOut(0, 255, currentRoom());
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmWaitForCarPosition() {
|
|
|
|
// Wait for car to reach correct position before pouring oil
|
2003-12-19 09:22:20 +00:00
|
|
|
while (_vm->bam()->_index != 60) {
|
2003-12-10 14:19:04 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmShakeScreen() {
|
|
|
|
OSystem::instance()->set_shake_pos(3);
|
|
|
|
update();
|
|
|
|
OSystem::instance()->set_shake_pos(0);
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmAttemptPuzzle() {
|
|
|
|
static short n = 0;
|
|
|
|
++n;
|
|
|
|
if (n & 4) {
|
|
|
|
joeSpeak(226, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmScaleTitle() {
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *bob = _vm->graphics()->bob(5);
|
2003-12-10 14:19:04 +00:00
|
|
|
bob->animating = false;
|
|
|
|
bob->x = 161;
|
|
|
|
bob->y = 200;
|
|
|
|
bob->scale = 100;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
for (i = 5; i <= 100; i +=5) {
|
|
|
|
bob->scale = i;
|
|
|
|
bob->y -= 4;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmPanRightToHugh() {
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *bob_thugA1 = _vm->graphics()->bob(20);
|
|
|
|
BobSlot *bob_thugA2 = _vm->graphics()->bob(21);
|
|
|
|
BobSlot *bob_thugA3 = _vm->graphics()->bob(22);
|
|
|
|
BobSlot *bob_hugh1 = _vm->graphics()->bob(1);
|
|
|
|
BobSlot *bob_hugh2 = _vm->graphics()->bob(23);
|
|
|
|
BobSlot *bob_hugh3 = _vm->graphics()->bob(24);
|
|
|
|
BobSlot *bob_thugB1 = _vm->graphics()->bob(25);
|
|
|
|
BobSlot *bob_thugB2 = _vm->graphics()->bob(26);
|
|
|
|
|
|
|
|
_vm->graphics()->cameraBob(-1);
|
|
|
|
_vm->input()->fastMode(true);
|
2003-12-10 14:19:04 +00:00
|
|
|
update();
|
|
|
|
|
|
|
|
int i = 4, k = 160;
|
|
|
|
|
|
|
|
// Adjust thug1 gun so it matches rest of body
|
|
|
|
bob_thugA1->x += (k / 2) * 2 - 45;
|
|
|
|
bob_thugA2->x += (k / 2) * 2;
|
|
|
|
bob_thugA3->x += (k / 2) * 2;
|
|
|
|
|
|
|
|
bob_hugh1->x += (k / 2) * 3 + (k / 2);
|
|
|
|
bob_hugh2->x += (k / 2) * 3 + (k / 2);
|
|
|
|
bob_hugh3->x += (k / 2) * 3 + (k / 2);
|
|
|
|
|
|
|
|
bob_thugB1->x += (k / 2) * 4 + k;
|
|
|
|
bob_thugB2->x += (k / 2) * 4 + k;
|
|
|
|
|
|
|
|
if (i == 3) {
|
|
|
|
bob_thugB1->x += 10;
|
|
|
|
bob_thugB2->x += 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
i *= 2;
|
|
|
|
|
|
|
|
int horizontalScroll = 0;
|
2003-12-29 20:17:43 +00:00
|
|
|
while (horizontalScroll < k && !_vm->input()->cutawayQuit()) {
|
2003-12-10 14:19:04 +00:00
|
|
|
|
|
|
|
horizontalScroll = horizontalScroll + i;
|
|
|
|
if (horizontalScroll > k)
|
|
|
|
horizontalScroll = k;
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->horizontalScroll(horizontalScroll);
|
2003-12-10 14:19:04 +00:00
|
|
|
|
|
|
|
bob_thugA1->x -= i * 2;
|
|
|
|
bob_thugA2->x -= i * 2;
|
|
|
|
bob_thugA3->x -= i * 2;
|
|
|
|
|
|
|
|
bob_hugh1->x -= i * 3;
|
|
|
|
bob_hugh2->x -= i * 3;
|
|
|
|
bob_hugh3->x -= i * 3;
|
|
|
|
|
|
|
|
bob_thugB1->x -= i * 4;
|
|
|
|
bob_thugB2->x -= i * 4;
|
|
|
|
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->fastMode(false);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmMakeWhiteFlash() {
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->palCustomFlash();
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logic::asmPanRightToJoeAndRita() { // cdint.cut
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *bob_box = _vm->graphics()->bob(20);
|
|
|
|
BobSlot *bob_beam = _vm->graphics()->bob(21);
|
|
|
|
BobSlot *bob_crate = _vm->graphics()->bob(22);
|
|
|
|
BobSlot *bob_clock = _vm->graphics()->bob(23);
|
|
|
|
BobSlot *bob_hands = _vm->graphics()->bob(24);
|
2003-12-10 14:19:04 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(-1);
|
|
|
|
_vm->input()->fastMode(true);
|
2003-12-10 14:19:04 +00:00
|
|
|
|
|
|
|
update();
|
|
|
|
|
|
|
|
bob_box ->x += 280 * 2;
|
|
|
|
bob_beam ->x += 30;
|
|
|
|
bob_crate->x += 180 * 3;
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
int horizontalScroll = _vm->display()->horizontalScroll();
|
2003-12-10 14:19:04 +00:00
|
|
|
|
|
|
|
int i = 1;
|
2003-12-29 20:17:43 +00:00
|
|
|
while (horizontalScroll < 290 && !_vm->input()->cutawayQuit()) {
|
2003-12-10 14:19:04 +00:00
|
|
|
|
|
|
|
horizontalScroll = horizontalScroll + i;
|
|
|
|
if (horizontalScroll > 290)
|
|
|
|
horizontalScroll = 290;
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->horizontalScroll(horizontalScroll);
|
2003-12-10 14:19:04 +00:00
|
|
|
|
|
|
|
bob_box ->x -= i * 2;
|
|
|
|
bob_beam ->x -= i;
|
|
|
|
bob_crate->x -= i * 3;
|
|
|
|
bob_clock->x -= i * 2;
|
|
|
|
bob_hands->x -= i * 2;
|
|
|
|
|
|
|
|
update();
|
|
|
|
}
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->fastMode(false);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-29 16:35:08 +00:00
|
|
|
void Logic::asmPanLeftToBomb() {
|
2003-12-11 22:16:35 +00:00
|
|
|
BobSlot *bob21 = _vm->graphics()->bob(21);
|
|
|
|
BobSlot *bob22 = _vm->graphics()->bob(22);
|
2003-12-10 14:19:04 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->graphics()->cameraBob(-1);
|
|
|
|
_vm->input()->fastMode(true);
|
2003-12-10 14:19:04 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
int horizontalScroll = _vm->display()->horizontalScroll();
|
2003-12-10 14:19:04 +00:00
|
|
|
|
|
|
|
int i = 5;
|
2003-12-29 20:17:43 +00:00
|
|
|
while ((horizontalScroll > 0 || bob21->x < 136) && !_vm->input()->cutawayQuit()) {
|
2003-12-10 14:19:04 +00:00
|
|
|
|
|
|
|
horizontalScroll -= i;
|
|
|
|
if (horizontalScroll < 0)
|
|
|
|
horizontalScroll = 0;
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->display()->horizontalScroll(horizontalScroll);
|
2003-12-10 14:19:04 +00:00
|
|
|
|
|
|
|
if (horizontalScroll < 272 && bob21->x < 136)
|
|
|
|
bob21->x += (i/2);
|
|
|
|
|
|
|
|
bob22->x += i;
|
|
|
|
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_vm->input()->fastMode(false);
|
2003-12-10 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-29 16:35:08 +00:00
|
|
|
void Logic::asmEndDemo() {
|
|
|
|
debug(0, "Flight of the Amazon Queen, released January 95");
|
|
|
|
OSystem::instance()->quit();
|
|
|
|
}
|
|
|
|
|
2003-12-10 14:19:04 +00:00
|
|
|
|
2003-10-03 19:47:41 +00:00
|
|
|
} // End of namespace Queen
|
2003-10-05 16:07:07 +00:00
|
|
|
|