2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2006-02-22 22:40:53 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2006-02-22 22:40:53 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-03-29 15:59:37 +00:00
|
|
|
#include "common/endian.h"
|
2008-10-06 12:48:52 +00:00
|
|
|
#include "common/events.h"
|
2006-03-29 15:59:37 +00:00
|
|
|
|
2006-02-22 22:40:53 +00:00
|
|
|
#include "cine/cine.h"
|
2006-02-25 01:18:01 +00:00
|
|
|
#include "cine/main_loop.h"
|
|
|
|
#include "cine/object.h"
|
2007-05-19 12:08:41 +00:00
|
|
|
#include "cine/sound.h"
|
2006-11-08 21:46:57 +00:00
|
|
|
#include "cine/bg_list.h"
|
2006-02-25 01:18:01 +00:00
|
|
|
#include "cine/various.h"
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-02-25 00:26:14 +00:00
|
|
|
namespace Cine {
|
|
|
|
|
2006-11-24 20:25:55 +00:00
|
|
|
bool disableSystemMenu = false;
|
2006-11-19 18:54:06 +00:00
|
|
|
bool inMenu;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 commandVar3[4];
|
|
|
|
int16 commandVar1;
|
|
|
|
int16 commandVar2;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
//Message messageTable[NUM_MAX_MESSAGE];
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-02-23 09:12:21 +00:00
|
|
|
uint16 var2;
|
|
|
|
uint16 var3;
|
|
|
|
uint16 var4;
|
|
|
|
uint16 var5;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-12-13 13:17:45 +00:00
|
|
|
int16 buildObjectListCommand(int16 param);
|
|
|
|
int16 canUseOnObject = 0;
|
2006-05-08 19:49:52 +00:00
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
void drawString(const char *string, byte param) {
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void waitPlayerInput() {
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-03-09 23:02:29 +00:00
|
|
|
void setTextWindow(uint16 param1, uint16 param2, uint16 param3, uint16 param4) {
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-02-23 09:12:21 +00:00
|
|
|
uint16 errorVar;
|
2006-03-23 03:45:52 +00:00
|
|
|
byte menuVar;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-12-12 21:39:00 +00:00
|
|
|
bool fadeRequired;
|
2006-02-23 09:12:21 +00:00
|
|
|
uint16 allowPlayerInput;
|
|
|
|
uint16 checkForPendingDataLoadSwitch;
|
|
|
|
uint16 isDrawCommandEnabled;
|
|
|
|
uint16 waitForPlayerClick;
|
2006-03-02 20:08:41 +00:00
|
|
|
uint16 menuCommandLen;
|
2007-12-14 19:21:19 +00:00
|
|
|
bool _paletteNeedUpdate;
|
|
|
|
uint16 _messageLen;
|
|
|
|
byte _danKeysPressed;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 playerCommand;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-08-12 00:13:27 +00:00
|
|
|
Common::String commandBuffer;
|
2006-02-22 22:40:53 +00:00
|
|
|
char currentPrcName[20];
|
|
|
|
char currentRelName[20];
|
|
|
|
char currentObjectName[20];
|
|
|
|
char currentMsgName[20];
|
|
|
|
char newPrcName[20];
|
|
|
|
char newRelName[20];
|
|
|
|
char newObjectName[20];
|
|
|
|
char newMsgName[20];
|
|
|
|
char currentCtName[15];
|
|
|
|
char currentPartName[15];
|
|
|
|
char currentDatName[30];
|
2009-05-11 19:31:55 +00:00
|
|
|
uint16 musicIsPlaying;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
byte isInPause = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2010-01-24 16:25:08 +00:00
|
|
|
/*! \brief Bit masks for mouse buttons' states
|
|
|
|
* Bit on = mouse button down
|
|
|
|
* Bit off = mouse button up
|
|
|
|
*/
|
|
|
|
enum MouseButtonState
|
|
|
|
{
|
|
|
|
kLeftMouseButton = (1 << 0),
|
|
|
|
kRightMouseButton = (1 << 1)
|
|
|
|
};
|
|
|
|
|
2008-08-08 13:30:01 +00:00
|
|
|
/*! \brief Values used by the xMoveKeyb variable */
|
|
|
|
enum xMoveKeybEnums {
|
|
|
|
kKeybMoveCenterX = 0,
|
|
|
|
kKeybMoveRight = 1,
|
|
|
|
kKeybMoveLeft = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
/*! \brief Values used by the yMoveKeyb variable */
|
|
|
|
enum yMoveKeybEnums {
|
|
|
|
kKeybMoveCenterY = 0,
|
|
|
|
kKeybMoveDown = 1,
|
|
|
|
kKeybMoveUp = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
uint16 xMoveKeyb = kKeybMoveCenterX;
|
|
|
|
bool egoMovedWithKeyboard = false;
|
|
|
|
uint16 yMoveKeyb = kKeybMoveCenterY;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-12-14 19:21:19 +00:00
|
|
|
SelectedObjStruct currentSelectedObject;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-11-12 23:21:05 +00:00
|
|
|
CommandeType currentSaveName[10];
|
2007-12-12 21:39:00 +00:00
|
|
|
|
|
|
|
static const int16 choiceResultTable[] = { 1, 1, 1, 2, 1, 1, 1 };
|
|
|
|
static const int16 subObjectUseTable[] = { 3, 3, 3, 3, 3, 0, 0 };
|
|
|
|
static const int16 canUseOnItemTable[] = { 1, 0, 0, 1, 1, 0, 0 };
|
|
|
|
|
2007-12-14 19:21:19 +00:00
|
|
|
CommandeType objectListCommand[20];
|
2007-12-12 21:39:00 +00:00
|
|
|
int16 objListTab[20];
|
|
|
|
|
2008-08-09 22:38:03 +00:00
|
|
|
Common::Array<uint16> zoneData;
|
2009-10-08 21:28:57 +00:00
|
|
|
Common::Array<uint16> zoneQuery; ///< Only exists in Operation Stealth
|
2007-12-12 21:39:00 +00:00
|
|
|
|
2008-08-08 13:30:01 +00:00
|
|
|
/*! \brief Move the player character using the keyboard
|
|
|
|
* \param x Negative values move left, positive right, zero not at all
|
|
|
|
* \param y Negative values move down, positive up, zero not at all
|
|
|
|
* NOTE: If both x and y are zero then the character stops
|
|
|
|
* FIXME: This seems to only work in Operation Stealth. May need code changes somewhere else...
|
|
|
|
*/
|
|
|
|
void moveUsingKeyboard(int x, int y) {
|
|
|
|
if (x > 0) {
|
|
|
|
xMoveKeyb = kKeybMoveRight;
|
|
|
|
} else if (x < 0) {
|
|
|
|
xMoveKeyb = kKeybMoveLeft;
|
|
|
|
} else {
|
|
|
|
xMoveKeyb = kKeybMoveCenterX;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (y > 0) {
|
|
|
|
yMoveKeyb = kKeybMoveUp;
|
|
|
|
} else if (y < 0) {
|
|
|
|
yMoveKeyb = kKeybMoveDown;
|
|
|
|
} else {
|
|
|
|
yMoveKeyb = kKeybMoveCenterY;
|
|
|
|
}
|
|
|
|
|
|
|
|
egoMovedWithKeyboard = x || y;
|
|
|
|
}
|
2007-12-12 21:39:00 +00:00
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void stopMusicAfterFadeOut() {
|
2007-12-14 19:21:19 +00:00
|
|
|
// if (g_sfxPlayer->_fadeOutCounter != 0 && g_sfxPlayer->_fadeOutCounter < 100) {
|
|
|
|
// g_sfxPlayer->stop();
|
|
|
|
// }
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-02-23 09:12:21 +00:00
|
|
|
void runObjectScript(int16 entryIdx) {
|
2008-04-07 20:24:40 +00:00
|
|
|
ScriptPtr tmp(scriptInfo->create(*relTable[entryIdx], entryIdx));
|
|
|
|
assert(tmp);
|
|
|
|
objectScripts.push_back(tmp);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
/*! \brief Add action result message to overlay list
|
|
|
|
* \param cmd Message description
|
|
|
|
* \todo Why are x, y, width and color left uninitialized?
|
|
|
|
*/
|
2006-04-12 16:34:23 +00:00
|
|
|
void addPlayerCommandMessage(int16 cmd) {
|
2008-04-21 20:51:17 +00:00
|
|
|
overlay tmp;
|
2008-07-01 10:33:25 +00:00
|
|
|
memset(&tmp, 0, sizeof(tmp));
|
2008-04-21 20:51:17 +00:00
|
|
|
tmp.objIdx = cmd;
|
|
|
|
tmp.type = 3;
|
2006-04-12 22:06:30 +00:00
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
overlayList.push_back(tmp);
|
2006-04-12 16:34:23 +00:00
|
|
|
}
|
|
|
|
|
2007-12-14 19:21:19 +00:00
|
|
|
int16 getRelEntryForObject(uint16 param1, uint16 param2, SelectedObjStruct *pSelectedObject) {
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 i;
|
2008-04-07 20:24:40 +00:00
|
|
|
int16 found = -1;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-04-07 20:24:40 +00:00
|
|
|
for (i = 0; i < (int16)relTable.size(); i++) {
|
|
|
|
if (relTable[i]->_param1 == param1 && relTable[i]->_param2 == pSelectedObject->idx) {
|
2006-02-22 22:40:53 +00:00
|
|
|
if (param2 == 1) {
|
2008-04-07 20:24:40 +00:00
|
|
|
found = i;
|
2006-02-22 22:40:53 +00:00
|
|
|
} else if (param2 == 2) {
|
2008-04-07 20:24:40 +00:00
|
|
|
if (relTable[i]->_param3 == pSelectedObject->param) {
|
|
|
|
found = i;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-07 20:24:40 +00:00
|
|
|
if (found != -1)
|
2006-02-22 22:40:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-04-07 20:24:40 +00:00
|
|
|
return found;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
/*! \brief Find index of the object under cursor
|
|
|
|
* \param x Mouse cursor coordinate
|
|
|
|
* \param y Mouse cursor coordinate
|
|
|
|
* \todo Fix displaced type 1 objects
|
|
|
|
*/
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 getObjectUnderCursor(uint16 x, uint16 y) {
|
2008-04-21 20:51:17 +00:00
|
|
|
Common::List<overlay>::iterator it;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-12-12 21:39:00 +00:00
|
|
|
int16 objX, objY, frame, part, threshold, height, xdif, ydif;
|
2008-04-07 20:24:40 +00:00
|
|
|
int width;
|
2007-12-12 21:39:00 +00:00
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
// reverse_iterator would be nice
|
|
|
|
for (it = overlayList.reverse_begin(); it != overlayList.end(); --it) {
|
|
|
|
if (it->type >= 2 || !objectTable[it->objIdx].name[0]) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
objX = objectTable[it->objIdx].x;
|
|
|
|
objY = objectTable[it->objIdx].y;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
frame = ABS((int16)(objectTable[it->objIdx].frame));
|
|
|
|
part = objectTable[it->objIdx].part;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-08-04 19:32:52 +00:00
|
|
|
// Additional case for negative frame values in Operation Stealth
|
|
|
|
if (g_cine->getGameType() == Cine::GType_OS && objectTable[it->objIdx].frame < 0) {
|
|
|
|
if ((it->type == 1) && (x >= objX) && (objX + frame >= x) && (y >= objY) && (objY + part >= y)) {
|
|
|
|
return it->objIdx;
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
if (it->type == 0) {
|
|
|
|
threshold = animDataTable[frame]._var1;
|
|
|
|
} else {
|
|
|
|
threshold = animDataTable[frame]._width / 2;
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
height = animDataTable[frame]._height;
|
|
|
|
width = animDataTable[frame]._realWidth;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
xdif = x - objX;
|
|
|
|
ydif = y - objY;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-08-04 19:32:52 +00:00
|
|
|
if ((xdif < 0) || ((threshold << 4) <= xdif) || (ydif <= 0) || (ydif >= height) || !animDataTable[frame].data()) {
|
2008-04-21 20:51:17 +00:00
|
|
|
continue;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
2008-08-04 19:32:52 +00:00
|
|
|
// This test isn't present in Operation Stealth's PC version's disassembly
|
|
|
|
// but removing it makes things crash sometimes (e.g. when selecting a verb
|
|
|
|
// and moving the mouse cursor around the floor in the airport's bathroom).
|
2008-04-21 20:51:17 +00:00
|
|
|
if (xdif >= width) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-08-04 19:32:52 +00:00
|
|
|
if (it->type == 0 && animDataTable[frame].getColor(xdif, ydif) != (part & 0x0F)) {
|
2008-04-21 20:51:17 +00:00
|
|
|
return it->objIdx;
|
|
|
|
} else if (it->type == 1 && gfxGetBit(xdif, ydif, animDataTable[frame].data(), animDataTable[frame]._width * 4)) {
|
|
|
|
return it->objIdx;
|
|
|
|
}
|
|
|
|
} else if (it->type == 0) { // use generated mask
|
|
|
|
if (gfxGetBit(xdif, ydif, animDataTable[frame].mask(), animDataTable[frame]._width)) {
|
|
|
|
return it->objIdx;
|
|
|
|
}
|
|
|
|
} else if (it->type == 1) { // is mask
|
|
|
|
if (gfxGetBit(xdif, ydif, animDataTable[frame].data(), animDataTable[frame]._width * 4)) {
|
|
|
|
return it->objIdx;
|
|
|
|
}
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-07-27 14:33:37 +00:00
|
|
|
void CineEngine::resetEngine() {
|
2007-05-19 12:08:41 +00:00
|
|
|
g_sound->stopMusic();
|
2006-03-09 23:02:29 +00:00
|
|
|
freeAnimDataTable();
|
2008-04-21 20:51:17 +00:00
|
|
|
overlayList.clear();
|
2008-04-07 20:24:40 +00:00
|
|
|
bgIncrustList.clear();
|
2006-02-22 22:40:53 +00:00
|
|
|
closePart();
|
|
|
|
|
2008-04-07 20:24:40 +00:00
|
|
|
objectScripts.clear();
|
|
|
|
globalScripts.clear();
|
|
|
|
relTable.clear();
|
|
|
|
scriptTable.clear();
|
2008-04-21 20:51:17 +00:00
|
|
|
messageTable.clear();
|
2008-08-09 20:50:10 +00:00
|
|
|
resetObjectTable();
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-01-01 16:57:03 +00:00
|
|
|
globalVars.reset();
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-12-13 13:17:45 +00:00
|
|
|
var2 = var3 = var4 = var5 = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
strcpy(newPrcName, "");
|
|
|
|
strcpy(newRelName, "");
|
|
|
|
strcpy(newObjectName, "");
|
|
|
|
strcpy(newMsgName, "");
|
|
|
|
strcpy(currentCtName, "");
|
|
|
|
|
|
|
|
allowPlayerInput = 0;
|
|
|
|
waitForPlayerClick = 0;
|
|
|
|
playerCommand = -1;
|
|
|
|
isDrawCommandEnabled = 0;
|
|
|
|
|
2008-08-12 00:13:27 +00:00
|
|
|
commandBuffer = "";
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-02-24 22:34:22 +00:00
|
|
|
globalVars[VAR_MOUSE_X_POS] = 0;
|
|
|
|
globalVars[VAR_MOUSE_Y_POS] = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-12-09 13:41:59 +00:00
|
|
|
fadeRequired = false;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
renderer->clear();
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
checkForPendingDataLoadSwitch = 0;
|
2008-07-28 16:02:40 +00:00
|
|
|
|
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
|
|
|
seqList.clear();
|
|
|
|
currentAdditionalBgIdx = 0;
|
|
|
|
currentAdditionalBgIdx2 = 0;
|
|
|
|
// TODO: Add resetting of the following variables
|
|
|
|
// adBgVar1 = 0;
|
2009-01-01 15:06:43 +00:00
|
|
|
// adBgVar0 = 0;
|
2008-07-28 16:02:40 +00:00
|
|
|
// gfxFadeOutCompleted = 0;
|
|
|
|
}
|
2008-07-27 14:33:37 +00:00
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void CineEngine::makeSystemMenu() {
|
2007-12-13 13:17:45 +00:00
|
|
|
int16 numEntry, systemCommand;
|
|
|
|
int16 mouseX, mouseY, mouseButton;
|
|
|
|
int16 selectedSave;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-11-24 20:25:55 +00:00
|
|
|
if (!disableSystemMenu) {
|
2006-11-19 18:54:06 +00:00
|
|
|
inMenu = true;
|
|
|
|
|
2007-12-13 13:17:45 +00:00
|
|
|
do {
|
2006-02-22 22:40:53 +00:00
|
|
|
manageEvents();
|
2006-02-23 20:02:46 +00:00
|
|
|
getMouseData(mouseUpdateStatus, (uint16 *)&mouseButton, (uint16 *)&mouseX, (uint16 *)&mouseY);
|
2007-12-13 13:17:45 +00:00
|
|
|
} while (mouseButton);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
numEntry = 6;
|
|
|
|
|
|
|
|
if (!allowPlayerInput) {
|
|
|
|
numEntry--;
|
|
|
|
}
|
|
|
|
|
2006-02-23 20:02:46 +00:00
|
|
|
systemCommand = makeMenuChoice(systemMenu, numEntry, mouseX, mouseY, 140);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
switch (systemCommand) {
|
|
|
|
case 0:
|
|
|
|
{
|
2006-11-11 15:37:03 +00:00
|
|
|
drawString(otherMessages[2], 0);
|
2006-02-22 22:40:53 +00:00
|
|
|
waitPlayerInput();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
2006-02-23 20:02:46 +00:00
|
|
|
getMouseData(mouseUpdateStatus, (uint16 *)&mouseButton, (uint16 *)&mouseX, (uint16 *)&mouseY);
|
|
|
|
if (!makeMenuChoice(confirmMenu, 2, mouseX, mouseY + 8, 100)) {
|
2006-02-22 22:40:53 +00:00
|
|
|
//reinitEngine();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
2006-02-23 20:02:46 +00:00
|
|
|
getMouseData(mouseUpdateStatus, (uint16 *)&mouseButton, (uint16 *)&mouseX, (uint16 *)&mouseY);
|
|
|
|
if (!makeMenuChoice(confirmMenu, 2, mouseX, mouseY + 8, 100)) {
|
2008-07-09 02:27:05 +00:00
|
|
|
quitGame();
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3: // Select save drive... change ?
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 4: // load game
|
|
|
|
{
|
|
|
|
if (loadSaveDirectory()) {
|
2007-12-13 13:26:49 +00:00
|
|
|
// int16 selectedSave;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-02-23 20:02:46 +00:00
|
|
|
getMouseData(mouseUpdateStatus, (uint16 *)&mouseButton, (uint16 *)&mouseX, (uint16 *)&mouseY);
|
|
|
|
selectedSave = makeMenuChoice(currentSaveName, 10, mouseX, mouseY + 8, 180);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
if (selectedSave >= 0) {
|
|
|
|
char saveNameBuffer[256];
|
2006-11-14 09:29:41 +00:00
|
|
|
sprintf(saveNameBuffer, "%s.%1d", _targetName.c_str(), selectedSave);
|
2006-02-23 20:02:46 +00:00
|
|
|
|
|
|
|
getMouseData(mouseUpdateStatus, (uint16 *)&mouseButton, (uint16 *)&mouseX, (uint16 *)&mouseY);
|
|
|
|
if (!makeMenuChoice(confirmMenu, 2, mouseX, mouseY + 8, 100)) {
|
2006-02-22 22:40:53 +00:00
|
|
|
char loadString[256];
|
|
|
|
|
2006-11-11 15:37:03 +00:00
|
|
|
sprintf(loadString, otherMessages[3], currentSaveName[selectedSave]);
|
2006-02-23 20:02:46 +00:00
|
|
|
drawString(loadString, 0);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-02-23 20:02:46 +00:00
|
|
|
makeLoad(saveNameBuffer);
|
2006-02-22 22:40:53 +00:00
|
|
|
} else {
|
2006-11-11 15:37:03 +00:00
|
|
|
drawString(otherMessages[4], 0);
|
2006-02-22 22:40:53 +00:00
|
|
|
waitPlayerInput();
|
|
|
|
checkDataDisk(-1);
|
|
|
|
}
|
|
|
|
} else {
|
2006-11-11 15:37:03 +00:00
|
|
|
drawString(otherMessages[4], 0);
|
2006-02-22 22:40:53 +00:00
|
|
|
waitPlayerInput();
|
|
|
|
checkDataDisk(-1);
|
|
|
|
}
|
|
|
|
} else {
|
2006-11-11 15:37:03 +00:00
|
|
|
drawString(otherMessages[5], 0);
|
2006-02-22 22:40:53 +00:00
|
|
|
waitPlayerInput();
|
|
|
|
checkDataDisk(-1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
loadSaveDirectory();
|
2006-02-23 20:02:46 +00:00
|
|
|
selectedSave = makeMenuChoice(currentSaveName, 10, mouseX, mouseY + 8, 180);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
if (selectedSave >= 0) {
|
|
|
|
char saveFileName[256];
|
2006-11-18 15:16:44 +00:00
|
|
|
char saveName[20];
|
|
|
|
saveName[0] = 0;
|
|
|
|
|
|
|
|
if (!makeTextEntryMenu(otherMessages[6], saveName, 20, 120))
|
|
|
|
break;
|
|
|
|
|
|
|
|
strncpy(currentSaveName[selectedSave], saveName, 20);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-11-14 09:29:41 +00:00
|
|
|
sprintf(saveFileName, "%s.%1d", _targetName.c_str(), selectedSave);
|
2006-02-23 20:02:46 +00:00
|
|
|
|
|
|
|
getMouseData(mouseUpdateStatus, (uint16 *)&mouseButton, (uint16 *)&mouseX, (uint16 *)&mouseY);
|
|
|
|
if (!makeMenuChoice(confirmMenu, 2, mouseX, mouseY + 8, 100)) {
|
2006-11-14 09:29:41 +00:00
|
|
|
char saveString[256], tmp[80];
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-11-14 09:29:41 +00:00
|
|
|
snprintf(tmp, 80, "%s.dir", _targetName.c_str());
|
|
|
|
|
2007-05-30 18:43:28 +00:00
|
|
|
Common::OutSaveFile *fHandle = g_saveFileMan->openForSaving(tmp);
|
|
|
|
if (!fHandle) {
|
|
|
|
warning("Unable to open file %s for saving", tmp);
|
|
|
|
break;
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-04-10 05:37:31 +00:00
|
|
|
fHandle->write(currentSaveName, 200);
|
|
|
|
delete fHandle;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-11-11 15:37:03 +00:00
|
|
|
sprintf(saveString, otherMessages[3], currentSaveName[selectedSave]);
|
2006-02-22 22:40:53 +00:00
|
|
|
drawString(saveString, 0);
|
|
|
|
|
|
|
|
makeSave(saveFileName);
|
|
|
|
|
|
|
|
checkDataDisk(-1);
|
|
|
|
} else {
|
2006-11-11 15:37:03 +00:00
|
|
|
drawString(otherMessages[4], 0);
|
2006-02-22 22:40:53 +00:00
|
|
|
waitPlayerInput();
|
|
|
|
checkDataDisk(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-11-19 18:54:06 +00:00
|
|
|
|
|
|
|
inMenu = false;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-13 13:17:45 +00:00
|
|
|
void drawMessageBox(int16 x, int16 y, int16 width, int16 currentY, int16 offset, int16 color, byte* page) {
|
|
|
|
gfxDrawLine(x + offset, y + offset, x + width - offset, y + offset, color, page); // top
|
|
|
|
gfxDrawLine(x + offset, currentY + 4 - offset, x + width - offset, currentY + 4 - offset, color, page); // bottom
|
|
|
|
gfxDrawLine(x + offset, y + offset, x + offset, currentY + 4 - offset, color, page); // left
|
|
|
|
gfxDrawLine(x + width - offset, y + offset, x + width - offset, currentY + 4 - offset, color, page); // right
|
|
|
|
}
|
|
|
|
|
2007-12-21 02:43:21 +00:00
|
|
|
void drawDoubleMessageBox(int16 x, int16 y, int16 width, int16 currentY, int16 color, byte* page) {
|
|
|
|
drawMessageBox(x, y, width, currentY, 1, 0, page);
|
|
|
|
drawMessageBox(x, y, width, currentY, 0, color, page);
|
|
|
|
}
|
|
|
|
|
2006-05-08 19:49:52 +00:00
|
|
|
void processInventory(int16 x, int16 y) {
|
|
|
|
uint16 button;
|
2008-08-12 14:44:44 +00:00
|
|
|
int menuWidth;
|
|
|
|
int listSize;
|
|
|
|
int commandParam;
|
|
|
|
|
|
|
|
if (g_cine->getGameType() == Cine::GType_FW) {
|
|
|
|
menuWidth = 140;
|
|
|
|
commandParam = -2;
|
|
|
|
} else { // Operation Stealth
|
|
|
|
menuWidth = 160;
|
|
|
|
commandParam = -3;
|
|
|
|
}
|
|
|
|
|
|
|
|
listSize = buildObjectListCommand(commandParam);
|
2006-05-08 19:49:52 +00:00
|
|
|
|
|
|
|
if (!listSize)
|
|
|
|
return;
|
|
|
|
|
2009-09-22 17:51:06 +00:00
|
|
|
Common::StringList list;
|
|
|
|
for (int i = 0; i < listSize; ++i)
|
|
|
|
list.push_back(objectListCommand[i]);
|
|
|
|
SelectionMenu *menu = new SelectionMenu(Common::Point(x, y), menuWidth, list);
|
|
|
|
renderer->pushMenu(menu);
|
|
|
|
renderer->drawFrame();
|
|
|
|
renderer->popMenu();
|
|
|
|
delete menu;
|
|
|
|
menu = 0;
|
2006-05-08 19:49:52 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
manageEvents();
|
|
|
|
getMouseData(mouseUpdateStatus, &button, &dummyU16, &dummyU16);
|
|
|
|
} while (!button);
|
2008-08-12 14:44:44 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
manageEvents();
|
|
|
|
getMouseData(mouseUpdateStatus, &button, &dummyU16, &dummyU16);
|
|
|
|
} while (button);
|
|
|
|
|
|
|
|
// TODO: Both Future Wars and Operation Stealth call showMouse, drawMouse or something similar here.
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2007-12-13 13:17:45 +00:00
|
|
|
int16 buildObjectListCommand(int16 param) {
|
|
|
|
int16 i = 0, j = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 20; i++) {
|
|
|
|
objectListCommand[i][0] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 255; i++) {
|
|
|
|
if (objectTable[i].name[0] && objectTable[i].costume == param) {
|
|
|
|
strcpy(objectListCommand[j], objectTable[i].name);
|
|
|
|
objListTab[j] = i;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-08 08:04:23 +00:00
|
|
|
return j;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2007-12-13 13:17:45 +00:00
|
|
|
int16 selectSubObject(int16 x, int16 y, int16 param) {
|
|
|
|
int16 listSize = buildObjectListCommand(param);
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 selectedObject;
|
2007-12-13 13:17:45 +00:00
|
|
|
bool osExtras = g_cine->getGameType() == Cine::GType_OS;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
if (!listSize) {
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2007-12-13 13:17:45 +00:00
|
|
|
selectedObject = makeMenuChoice(objectListCommand, listSize, x, y, 140, osExtras);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
if (selectedObject == -1)
|
|
|
|
return -1;
|
|
|
|
|
2007-12-13 13:17:45 +00:00
|
|
|
if (osExtras) {
|
|
|
|
if (selectedObject >= 8000) {
|
|
|
|
return objListTab[selectedObject - 8000] + 8000;
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return objListTab[selectedObject];
|
|
|
|
}
|
|
|
|
|
2008-08-12 19:33:17 +00:00
|
|
|
// TODO: Make separate functions for Future Wars's and Operation Stealth's version of this function, this is getting too messy
|
|
|
|
// TODO: Add support for using the different prepositions for different verbs (Doesn't work currently)
|
2009-11-02 21:54:57 +00:00
|
|
|
void makeCommandLine() {
|
2007-12-13 13:17:45 +00:00
|
|
|
uint16 x, y;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
commandVar1 = 0;
|
|
|
|
commandVar2 = -10;
|
|
|
|
|
|
|
|
if (playerCommand != -1) {
|
2008-08-12 00:13:27 +00:00
|
|
|
commandBuffer = defaultActionCommand[playerCommand];
|
2006-02-22 22:40:53 +00:00
|
|
|
} else {
|
2008-08-12 00:13:27 +00:00
|
|
|
commandBuffer = "";
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-02-23 20:02:46 +00:00
|
|
|
if ((playerCommand != -1) && (choiceResultTable[playerCommand] == 2)) { // need object selection ?
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 si;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
getMouseData(mouseUpdateStatus, &dummyU16, &x, &y);
|
|
|
|
|
2006-10-15 01:06:44 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_FW) {
|
2007-12-13 13:17:45 +00:00
|
|
|
si = selectSubObject(x, y + 8, -2);
|
2006-02-22 22:40:53 +00:00
|
|
|
} else {
|
2007-12-13 13:17:45 +00:00
|
|
|
si = selectSubObject(x, y + 8, -subObjectUseTable[playerCommand]);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (si < 0) {
|
2008-08-12 19:33:17 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
|
|
|
canUseOnObject = 0;
|
|
|
|
} else { // Future Wars
|
|
|
|
playerCommand = -1;
|
|
|
|
commandBuffer = "";
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
} else {
|
2006-10-15 01:06:44 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
2006-02-22 22:40:53 +00:00
|
|
|
if (si >= 8000) {
|
|
|
|
si -= 8000;
|
2006-02-23 20:02:46 +00:00
|
|
|
canUseOnObject = canUseOnItemTable[playerCommand];
|
2006-02-22 22:40:53 +00:00
|
|
|
} else {
|
|
|
|
canUseOnObject = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commandVar3[0] = si;
|
|
|
|
commandVar1 = 1;
|
2008-08-12 00:13:27 +00:00
|
|
|
commandBuffer += " ";
|
|
|
|
commandBuffer += objectTable[commandVar3[0]].name;
|
|
|
|
commandBuffer += " ";
|
2008-08-12 19:33:17 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
|
|
|
commandBuffer += commandPrepositionTable[playerCommand];
|
|
|
|
} else { // Future Wars
|
|
|
|
commandBuffer += defaultCommandPreposition;
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
2008-08-12 19:33:17 +00:00
|
|
|
}
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-08-12 19:33:17 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS || !(playerCommand != -1 && choiceResultTable[playerCommand] == 2)) {
|
2006-02-22 22:40:53 +00:00
|
|
|
if (playerCommand == 2) {
|
|
|
|
getMouseData(mouseUpdateStatus, &dummyU16, &x, &y);
|
2006-05-08 19:49:52 +00:00
|
|
|
processInventory(x, y + 8);
|
2006-02-22 22:40:53 +00:00
|
|
|
playerCommand = -1;
|
|
|
|
commandVar1 = 0;
|
2008-08-12 00:13:27 +00:00
|
|
|
commandBuffer = "";
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-12 19:33:17 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS && playerCommand != 2) {
|
2006-02-23 20:02:46 +00:00
|
|
|
if (playerCommand != -1 && canUseOnObject != 0) { // call use on sub object
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 si;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
getMouseData(mouseUpdateStatus, &dummyU16, &x, &y);
|
|
|
|
|
2007-12-13 13:17:45 +00:00
|
|
|
si = selectSubObject(x, y + 8, -subObjectUseTable[playerCommand]);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-08-12 19:33:17 +00:00
|
|
|
if (si >= 0) {
|
2006-02-22 22:40:53 +00:00
|
|
|
if (si >= 8000) {
|
|
|
|
si -= 8000;
|
|
|
|
}
|
|
|
|
|
|
|
|
commandVar3[commandVar1] = si;
|
|
|
|
commandVar1++;
|
2008-08-12 19:33:17 +00:00
|
|
|
commandBuffer += " ";
|
|
|
|
commandBuffer += objectTable[si].name;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
2008-08-12 19:33:17 +00:00
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-08-12 19:33:17 +00:00
|
|
|
isDrawCommandEnabled = 1;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-08-12 19:33:17 +00:00
|
|
|
if (playerCommand != -1 && choiceResultTable[playerCommand] == commandVar1) {
|
|
|
|
SelectedObjStruct obj;
|
|
|
|
obj.idx = commandVar3[0];
|
|
|
|
obj.param = commandVar3[1];
|
|
|
|
int16 di = getRelEntryForObject(playerCommand, commandVar1, &obj);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-08-12 19:33:17 +00:00
|
|
|
if (di != -1) {
|
|
|
|
runObjectScript(di);
|
|
|
|
} // TODO: else addFailureMessage(playerCommand)
|
|
|
|
|
|
|
|
playerCommand = -1;
|
|
|
|
commandVar1 = 0;
|
|
|
|
commandBuffer = "";
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-12 19:33:17 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS || !disableSystemMenu) {
|
2008-08-05 12:58:23 +00:00
|
|
|
isDrawCommandEnabled = 1;
|
2008-05-24 22:11:41 +00:00
|
|
|
renderer->setCommand(commandBuffer);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-23 09:12:21 +00:00
|
|
|
uint16 needMouseSave = 0;
|
|
|
|
|
|
|
|
uint16 menuVar4 = 0;
|
|
|
|
uint16 menuVar5 = 0;
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
int16 makeMenuChoice(const CommandeType commandList[], uint16 height, uint16 X, uint16 Y, uint16 width, bool recheckValue) {
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 paramY;
|
|
|
|
uint16 button;
|
|
|
|
int16 var_A;
|
|
|
|
int16 di;
|
|
|
|
uint16 j;
|
2007-12-13 13:17:45 +00:00
|
|
|
int16 mouseX, mouseY;
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 var_16;
|
|
|
|
int16 var_14;
|
2007-12-13 13:17:45 +00:00
|
|
|
int16 currentSelection, oldSelection;
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 var_4;
|
2009-09-22 17:51:06 +00:00
|
|
|
SelectionMenu *menu;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-11-24 20:25:55 +00:00
|
|
|
if (disableSystemMenu)
|
2006-02-22 22:40:53 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
paramY = (height * 9) + 10;
|
|
|
|
|
|
|
|
if (X + width > 319) {
|
|
|
|
X = 319 - width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Y + paramY > 199) {
|
|
|
|
Y = 199 - paramY;
|
|
|
|
}
|
|
|
|
|
2009-09-22 17:51:06 +00:00
|
|
|
Common::StringList list;
|
|
|
|
for (uint16 i = 0; i < height; ++i)
|
|
|
|
list.push_back(commandList[i]);
|
|
|
|
menu = new SelectionMenu(Common::Point(X, Y), width, list);
|
|
|
|
renderer->pushMenu(menu);
|
|
|
|
renderer->drawFrame();
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
manageEvents();
|
|
|
|
getMouseData(mouseUpdateStatus, &button, &dummyU16, &dummyU16);
|
2009-09-21 01:15:11 +00:00
|
|
|
} while (button && !g_cine->shouldQuit());
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
var_A = 0;
|
|
|
|
|
|
|
|
currentSelection = 0;
|
|
|
|
|
|
|
|
di = currentSelection * 9 + Y + 4;
|
|
|
|
|
2009-09-22 17:51:06 +00:00
|
|
|
menu->setSelection(currentSelection);
|
|
|
|
renderer->drawFrame();
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
manageEvents();
|
2006-02-23 20:02:46 +00:00
|
|
|
getMouseData(mouseUpdateStatus, &button, (uint16 *)&mouseX, (uint16 *)&mouseY);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
var_16 = mouseX;
|
|
|
|
var_14 = mouseY;
|
|
|
|
|
|
|
|
menuVar = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
manageEvents();
|
2006-02-23 20:02:46 +00:00
|
|
|
getMouseData(mouseUpdateStatus, &button, (uint16 *)&mouseX, (uint16 *)&mouseY);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
if (button) {
|
|
|
|
var_A = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
oldSelection = currentSelection;
|
|
|
|
|
|
|
|
if (needMouseSave) {
|
|
|
|
for (j = 0; j < 3; j++) {
|
|
|
|
mainLoopSub6();
|
|
|
|
}
|
|
|
|
|
2006-02-23 20:02:46 +00:00
|
|
|
if (menuVar4 && currentSelection > 0) { // go up
|
2006-02-22 22:40:53 +00:00
|
|
|
currentSelection--;
|
|
|
|
}
|
|
|
|
|
2006-02-23 20:02:46 +00:00
|
|
|
if (menuVar5) { // go down
|
2006-02-22 22:40:53 +00:00
|
|
|
if (height - 1 > currentSelection) {
|
|
|
|
currentSelection++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2006-02-23 20:02:46 +00:00
|
|
|
if (mouseX > X && mouseX < X + width && mouseY > Y && mouseY < Y + height * 9) {
|
2006-02-22 22:40:53 +00:00
|
|
|
currentSelection = (mouseY - (Y + 4)) / 9;
|
|
|
|
|
|
|
|
if (currentSelection < 0)
|
|
|
|
currentSelection = 0;
|
|
|
|
|
|
|
|
if (currentSelection >= height)
|
|
|
|
currentSelection = height - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-23 20:02:46 +00:00
|
|
|
if (currentSelection != oldSelection) { // old != new
|
2006-02-22 22:40:53 +00:00
|
|
|
if (needMouseSave) {
|
|
|
|
hideMouse();
|
|
|
|
}
|
|
|
|
|
|
|
|
di = currentSelection * 9 + Y + 4;
|
|
|
|
|
2009-09-22 17:51:06 +00:00
|
|
|
menu->setSelection(currentSelection);
|
|
|
|
renderer->drawFrame();
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-12-14 19:21:19 +00:00
|
|
|
// if (needMouseSave) {
|
|
|
|
// gfxRedrawMouseCursor();
|
|
|
|
// }
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2009-09-21 01:15:11 +00:00
|
|
|
} while (!var_A && !g_cine->shouldQuit());
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-04-05 13:06:03 +00:00
|
|
|
assert(!needMouseSave);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
var_4 = button;
|
|
|
|
|
|
|
|
menuVar = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
manageEvents();
|
|
|
|
getMouseData(mouseUpdateStatus, &button, &dummyU16, &dummyU16);
|
2009-09-21 01:15:11 +00:00
|
|
|
} while (button && !g_cine->shouldQuit());
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-02-23 20:02:46 +00:00
|
|
|
if (var_4 == 2) { // recheck
|
2007-12-12 21:39:00 +00:00
|
|
|
if (!recheckValue)
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
return currentSelection + 8000;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return currentSelection;
|
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void makeActionMenu() {
|
2006-04-11 23:31:03 +00:00
|
|
|
uint16 mouseButton;
|
|
|
|
uint16 mouseX;
|
|
|
|
uint16 mouseY;
|
|
|
|
|
2006-11-19 18:54:06 +00:00
|
|
|
inMenu = true;
|
|
|
|
|
2006-04-11 23:31:03 +00:00
|
|
|
getMouseData(mouseUpdateStatus, &mouseButton, &mouseX, &mouseY);
|
|
|
|
|
2006-10-15 01:06:44 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
2007-12-12 21:39:00 +00:00
|
|
|
playerCommand = makeMenuChoice(defaultActionCommand, 6, mouseX, mouseY, 70, true);
|
2006-04-11 23:31:03 +00:00
|
|
|
|
|
|
|
if (playerCommand >= 8000) {
|
|
|
|
playerCommand -= 8000;
|
2010-01-24 18:20:22 +00:00
|
|
|
canUseOnObject = canUseOnItemTable[playerCommand];
|
2006-04-11 23:31:03 +00:00
|
|
|
}
|
|
|
|
} else {
|
2006-11-19 18:54:06 +00:00
|
|
|
playerCommand = makeMenuChoice(defaultActionCommand, 6, mouseX, mouseY, 70);
|
2006-04-11 23:31:03 +00:00
|
|
|
}
|
2006-11-19 18:54:06 +00:00
|
|
|
|
|
|
|
inMenu = false;
|
2006-04-11 23:31:03 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
uint16 executePlayerInput() {
|
2006-02-23 09:12:21 +00:00
|
|
|
uint16 var_5E;
|
|
|
|
uint16 var_2;
|
2007-12-13 13:17:45 +00:00
|
|
|
uint16 mouseX, mouseY, mouseButton;
|
|
|
|
uint16 currentEntry = 0;
|
|
|
|
uint16 di = 0;
|
2010-01-24 17:46:37 +00:00
|
|
|
bool limitMouseCheckCount = false;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
canUseOnObject = 0;
|
|
|
|
|
|
|
|
if (isInPause) {
|
2006-11-11 15:37:03 +00:00
|
|
|
drawString(otherMessages[2], 0);
|
2006-02-22 22:40:53 +00:00
|
|
|
waitPlayerInput();
|
|
|
|
isInPause = 0;
|
|
|
|
}
|
|
|
|
|
2010-01-24 16:40:37 +00:00
|
|
|
if (allowPlayerInput) { // Player input is allowed
|
2010-01-24 17:46:37 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_FW && isDrawCommandEnabled) {
|
2008-08-05 12:58:23 +00:00
|
|
|
renderer->setCommand(commandBuffer);
|
|
|
|
}
|
2010-01-24 17:46:37 +00:00
|
|
|
isDrawCommandEnabled = 0;
|
|
|
|
limitMouseCheckCount = true;
|
|
|
|
}
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2010-01-24 17:46:37 +00:00
|
|
|
// Get mouse position and button states
|
|
|
|
di = 0;
|
|
|
|
currentEntry = 0;
|
|
|
|
getMouseData(mouseUpdateStatus, &mouseButton, &mouseX, &mouseY);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2010-01-24 17:46:37 +00:00
|
|
|
while (mouseButton && (!limitMouseCheckCount || currentEntry < 200) && !g_cine->shouldQuit()) {
|
|
|
|
di |= (mouseButton & (kLeftMouseButton | kRightMouseButton));
|
|
|
|
manageEvents();
|
|
|
|
getMouseData(mouseUpdateStatus, &mouseButton, &mouseX, &mouseY);
|
|
|
|
currentEntry++;
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2010-01-24 17:46:37 +00:00
|
|
|
if (di) {
|
|
|
|
mouseButton = di;
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2010-01-24 17:46:37 +00:00
|
|
|
if ((mouseButton & kLeftMouseButton) && (mouseButton & kRightMouseButton)) {
|
|
|
|
// Left and right mouse buttons are down
|
|
|
|
g_cine->makeSystemMenu();
|
|
|
|
} else if (allowPlayerInput) { // Player input is allowed
|
2010-01-24 18:20:22 +00:00
|
|
|
if (!(mouseButton & kLeftMouseButton) && (mouseButton & kRightMouseButton)) {
|
|
|
|
// Player input is allowed, left mouse button is up, right mouse button is down
|
|
|
|
makeActionMenu();
|
|
|
|
makeCommandLine();
|
|
|
|
} else if (playerCommand != -1) { // A player command is given
|
2010-01-24 16:40:37 +00:00
|
|
|
if (mouseButton & kLeftMouseButton) { // Left mouse button is down
|
2010-01-24 17:46:37 +00:00
|
|
|
if (!(mouseButton & kRightMouseButton)) { // Right mouse button is up
|
2010-01-24 16:40:37 +00:00
|
|
|
// A player command is given, left mouse button is down, right mouse button is up
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 si;
|
2006-02-22 22:40:53 +00:00
|
|
|
do {
|
|
|
|
manageEvents();
|
2006-02-23 20:02:46 +00:00
|
|
|
getMouseData(mouseUpdateStatus, &mouseButton, &dummyU16, &dummyU16);
|
2009-09-21 01:15:11 +00:00
|
|
|
} while (mouseButton && !g_cine->shouldQuit());
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
si = getObjectUnderCursor(mouseX,
|
|
|
|
mouseY);
|
|
|
|
|
|
|
|
if (si != -1) {
|
|
|
|
commandVar3[commandVar1] = si;
|
|
|
|
commandVar1++;
|
|
|
|
|
2008-08-12 00:13:27 +00:00
|
|
|
commandBuffer += " ";
|
|
|
|
commandBuffer += objectTable[si].name;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
isDrawCommandEnabled = 1;
|
|
|
|
|
2006-02-23 20:02:46 +00:00
|
|
|
if (choiceResultTable[playerCommand] == commandVar1) {
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 relEntry;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-12-14 19:21:19 +00:00
|
|
|
SelectedObjStruct obj;
|
2006-04-09 12:04:33 +00:00
|
|
|
obj.idx = commandVar3[0];
|
|
|
|
obj.param = commandVar3[1];
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-04-09 12:04:33 +00:00
|
|
|
relEntry = getRelEntryForObject(playerCommand, commandVar1, &obj);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
if (relEntry != -1) {
|
2006-02-23 20:02:46 +00:00
|
|
|
runObjectScript(relEntry);
|
2006-02-22 22:40:53 +00:00
|
|
|
} else {
|
2006-04-12 16:34:23 +00:00
|
|
|
addPlayerCommandMessage(playerCommand);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
playerCommand = -1;
|
|
|
|
|
|
|
|
commandVar1 = 0;
|
2008-08-12 00:13:27 +00:00
|
|
|
commandBuffer = "";
|
|
|
|
renderer->setCommand(commandBuffer);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
} else {
|
2006-02-24 22:34:22 +00:00
|
|
|
globalVars[VAR_MOUSE_X_POS] = mouseX;
|
|
|
|
globalVars[VAR_MOUSE_Y_POS] = mouseY;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
2010-01-24 18:20:22 +00:00
|
|
|
} else if (!(mouseButton & kRightMouseButton)) { // Right mouse button is up
|
2010-01-24 16:40:37 +00:00
|
|
|
// A player command is given, left and right mouse buttons are up
|
2008-05-24 22:11:41 +00:00
|
|
|
int16 objIdx;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
objIdx = getObjectUnderCursor(mouseX, mouseY);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2010-01-24 18:27:56 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS || commandVar2 != objIdx) {
|
2008-05-24 22:11:41 +00:00
|
|
|
if (objIdx != -1) {
|
2008-08-12 00:13:27 +00:00
|
|
|
renderer->setCommand(commandBuffer + " " + objectTable[objIdx].name);
|
2008-05-24 22:11:41 +00:00
|
|
|
} else {
|
|
|
|
isDrawCommandEnabled = 1;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-24 22:11:41 +00:00
|
|
|
|
|
|
|
commandVar2 = objIdx;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
2010-01-24 16:40:37 +00:00
|
|
|
} else { // No player command is given
|
2010-01-24 18:20:22 +00:00
|
|
|
if (!(mouseButton & kRightMouseButton)) { // Right mouse button is up
|
2010-01-24 16:40:37 +00:00
|
|
|
if (mouseButton & kLeftMouseButton) { // Left mouse button is down
|
|
|
|
// No player command is given, left mouse button is down, right mouse button is up
|
|
|
|
int16 objIdx;
|
|
|
|
int16 relEntry;
|
|
|
|
|
|
|
|
globalVars[VAR_MOUSE_X_POS] = mouseX;
|
|
|
|
if (!mouseX) {
|
|
|
|
globalVars[VAR_MOUSE_X_POS]++;
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2010-01-24 16:40:37 +00:00
|
|
|
globalVars[VAR_MOUSE_Y_POS] = mouseY;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2010-01-24 18:40:29 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
|
|
|
if (!mouseY) {
|
|
|
|
globalVars[VAR_MOUSE_Y_POS]++;
|
|
|
|
}
|
|
|
|
globalVars[VAR_MOUSE_X_POS_2ND] = globalVars[VAR_MOUSE_X_POS];
|
|
|
|
globalVars[VAR_MOUSE_Y_POS_2ND] = globalVars[VAR_MOUSE_X_POS];
|
|
|
|
}
|
|
|
|
|
2010-01-24 16:40:37 +00:00
|
|
|
objIdx = getObjectUnderCursor(mouseX, mouseY);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2010-01-24 16:40:37 +00:00
|
|
|
if (objIdx != -1) {
|
|
|
|
currentSelectedObject.idx = objIdx;
|
|
|
|
currentSelectedObject.param = -1;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2010-01-24 16:40:37 +00:00
|
|
|
relEntry = getRelEntryForObject(6, 1, ¤tSelectedObject);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2010-01-24 16:40:37 +00:00
|
|
|
if (relEntry != -1) {
|
|
|
|
runObjectScript(relEntry);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var_2 = menuVar & 0x7F;
|
|
|
|
var_5E = var_2;
|
|
|
|
|
|
|
|
if (menuVar & 0x80) {
|
|
|
|
var_5E = 0;
|
|
|
|
var_2 = 0;
|
|
|
|
}
|
|
|
|
|
2008-08-08 13:30:01 +00:00
|
|
|
if (egoMovedWithKeyboard && allowPlayerInput) { // use keyboard
|
|
|
|
egoMovedWithKeyboard = false;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-02-24 22:34:22 +00:00
|
|
|
switch (globalVars[VAR_MOUSE_X_MODE]) {
|
2006-02-22 22:40:53 +00:00
|
|
|
case 1:
|
2006-04-08 08:04:23 +00:00
|
|
|
mouseX = objectTable[1].x + 12;
|
|
|
|
break;
|
2006-02-22 22:40:53 +00:00
|
|
|
case 2:
|
2006-04-08 08:04:23 +00:00
|
|
|
mouseX = objectTable[1].x + 7;
|
|
|
|
break;
|
2006-02-22 22:40:53 +00:00
|
|
|
default:
|
2006-04-08 08:04:23 +00:00
|
|
|
mouseX = globalVars[VAR_MOUSE_X_POS];
|
|
|
|
break;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 22:34:22 +00:00
|
|
|
switch (globalVars[VAR_MOUSE_Y_MODE]) {
|
2006-02-22 22:40:53 +00:00
|
|
|
case 1:
|
2006-04-08 08:04:23 +00:00
|
|
|
mouseY = objectTable[1].y + 34;
|
|
|
|
break;
|
2006-02-22 22:40:53 +00:00
|
|
|
case 2:
|
2006-04-08 08:04:23 +00:00
|
|
|
mouseY = objectTable[1].y + 28;
|
|
|
|
break;
|
2006-02-22 22:40:53 +00:00
|
|
|
default:
|
2006-04-08 08:04:23 +00:00
|
|
|
mouseY = globalVars[VAR_MOUSE_Y_POS];
|
|
|
|
break;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (var_5E == bgVar0) {
|
|
|
|
var_5E = 0;
|
|
|
|
|
2006-02-24 22:34:22 +00:00
|
|
|
globalVars[VAR_MOUSE_X_POS] = mouseX;
|
|
|
|
globalVars[VAR_MOUSE_Y_POS] = mouseY;
|
2006-02-22 22:40:53 +00:00
|
|
|
} else {
|
2008-08-08 13:30:01 +00:00
|
|
|
if (xMoveKeyb) {
|
|
|
|
if (xMoveKeyb == kKeybMoveLeft) {
|
2006-02-24 22:34:22 +00:00
|
|
|
globalVars[VAR_MOUSE_X_POS] = 1;
|
2006-02-22 22:40:53 +00:00
|
|
|
} else {
|
2006-02-24 22:34:22 +00:00
|
|
|
globalVars[VAR_MOUSE_X_POS] = 320;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
} else {
|
2006-02-24 22:34:22 +00:00
|
|
|
globalVars[VAR_MOUSE_X_POS] = mouseX;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2008-08-08 13:30:01 +00:00
|
|
|
if (yMoveKeyb) {
|
|
|
|
if (yMoveKeyb == kKeybMoveUp) {
|
2006-02-24 22:34:22 +00:00
|
|
|
globalVars[VAR_MOUSE_Y_POS] = 1;
|
2006-02-22 22:40:53 +00:00
|
|
|
} else {
|
2006-02-24 22:34:22 +00:00
|
|
|
globalVars[VAR_MOUSE_Y_POS] = 200;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
} else {
|
2006-02-24 22:34:22 +00:00
|
|
|
globalVars[VAR_MOUSE_Y_POS] = mouseY;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bgVar0 = var_5E;
|
2006-02-23 20:02:46 +00:00
|
|
|
} else { // don't use keyboard for move -> shortcuts to commands
|
|
|
|
getMouseData(mouseUpdateStatus, &mouseButton, &mouseX, &mouseY);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
switch (var_2 - 59) {
|
2010-01-24 17:56:23 +00:00
|
|
|
case 0: // F1 = EXAMINE
|
|
|
|
case 1: // F2 = TAKE
|
|
|
|
case 2: // F3 = INVENTORY
|
|
|
|
case 3: // F4 = USE
|
|
|
|
case 4: // F5 = OPERATE
|
|
|
|
case 5: // F6 = SPEAK
|
2006-04-08 08:04:23 +00:00
|
|
|
if (allowPlayerInput) {
|
2007-12-08 02:38:04 +00:00
|
|
|
playerCommand = var_2 - 59;
|
2006-04-08 08:04:23 +00:00
|
|
|
makeCommandLine();
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
2006-04-08 08:04:23 +00:00
|
|
|
break;
|
2010-01-24 17:56:23 +00:00
|
|
|
case 6: // F7
|
|
|
|
case 7: // F8
|
|
|
|
case 8: // F9
|
|
|
|
case 23: // Keypad-0/Ins
|
2006-04-08 08:04:23 +00:00
|
|
|
break;
|
2010-01-24 17:56:23 +00:00
|
|
|
case 9: // F10
|
|
|
|
case 24: // Keypad-./Del
|
2006-11-14 09:29:41 +00:00
|
|
|
g_cine->makeSystemMenu();
|
2006-04-08 08:04:23 +00:00
|
|
|
break;
|
2006-02-22 22:40:53 +00:00
|
|
|
default:
|
2006-11-14 09:29:41 +00:00
|
|
|
// printf("Unhandled case %d in last part of executePlayerInput\n",var2-59);
|
2006-04-08 08:04:23 +00:00
|
|
|
break;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-22 17:51:06 +00:00
|
|
|
renderer->clearMenuStack();
|
|
|
|
|
2008-08-14 20:49:34 +00:00
|
|
|
// Update Operation Stealth specific global variables.
|
|
|
|
// This fixes swimming at the bottom of the ocean after
|
|
|
|
// having been thrown into it with the girl.
|
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
2009-06-27 12:26:26 +00:00
|
|
|
globalVars[VAR_MOUSE_X_POS_2ND] = globalVars[VAR_MOUSE_X_POS];
|
|
|
|
globalVars[VAR_MOUSE_Y_POS_2ND] = globalVars[VAR_MOUSE_Y_POS];
|
2008-08-14 20:49:34 +00:00
|
|
|
}
|
|
|
|
|
2006-02-22 22:40:53 +00:00
|
|
|
return var_5E;
|
|
|
|
}
|
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
void drawSprite(Common::List<overlay>::iterator it, const byte *spritePtr, const byte *maskPtr, uint16 width, uint16 height, byte *page, int16 x, int16 y) {
|
2007-05-17 22:13:31 +00:00
|
|
|
byte *msk = NULL;
|
2007-12-12 21:39:00 +00:00
|
|
|
int16 maskX, maskY, maskWidth, maskHeight;
|
|
|
|
uint16 maskSpriteIdx;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
msk = (byte *)malloc(width * height);
|
|
|
|
|
2007-05-17 22:13:31 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
2008-04-21 20:51:17 +00:00
|
|
|
generateMask(spritePtr, msk, width * height, objectTable[it->objIdx].part);
|
|
|
|
} else {
|
|
|
|
memcpy(msk, maskPtr, width * height);
|
2007-05-17 22:13:31 +00:00
|
|
|
}
|
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
for (++it; it != overlayList.end(); ++it) {
|
|
|
|
if (it->type != 5) {
|
|
|
|
continue;
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
maskX = objectTable[it->objIdx].x;
|
|
|
|
maskY = objectTable[it->objIdx].y;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
maskSpriteIdx = ABS((int16)(objectTable[it->objIdx].frame));
|
|
|
|
|
|
|
|
maskWidth = animDataTable[maskSpriteIdx]._realWidth;
|
|
|
|
maskHeight = animDataTable[maskSpriteIdx]._height;
|
|
|
|
gfxUpdateSpriteMask(msk, x, y, width, height, animDataTable[maskSpriteIdx].data(), maskX, maskY, maskWidth, maskHeight);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-05-19 20:06:50 +00:00
|
|
|
#ifdef DEBUG_SPRITE_MASK
|
2008-04-21 20:51:17 +00:00
|
|
|
gfxFillSprite(animDataTable[maskSpriteIdx].data(), maskWidth, maskHeight, page, maskX, maskY, 1);
|
2007-05-18 09:19:35 +00:00
|
|
|
#endif
|
2007-09-19 08:40:12 +00:00
|
|
|
}
|
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
gfxDrawMaskedSprite(spritePtr, msk, width, height, page, x, y);
|
|
|
|
free(msk);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
void removeMessages() {
|
2008-04-21 20:51:17 +00:00
|
|
|
Common::List<overlay>::iterator it;
|
2008-08-07 19:04:19 +00:00
|
|
|
bool remove;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-04-24 17:32:24 +00:00
|
|
|
for (it = overlayList.begin(); it != overlayList.end(); ) {
|
2008-08-07 19:04:19 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
|
|
|
// NOTE: These are really removeOverlay calls that have been deferred.
|
|
|
|
// In Operation Stealth's disassembly elements are removed from the
|
|
|
|
// overlay list right in the drawOverlays function (And actually in
|
|
|
|
// some other places too) and that's where incrementing a the overlay's
|
|
|
|
// last parameter by one if it's negative and testing it for positivity
|
|
|
|
// comes from too.
|
|
|
|
remove = it->type == 3 || (it->type == 2 && (it->color >= 0 || ++it->color >= 0));
|
|
|
|
} else { // Future Wars
|
|
|
|
remove = it->type == 2 || it->type == 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (remove) {
|
2008-04-24 17:32:24 +00:00
|
|
|
it = overlayList.erase(it);
|
|
|
|
} else {
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-02-23 09:12:21 +00:00
|
|
|
uint16 processKeyboard(uint16 param) {
|
2006-02-22 22:40:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void mainLoopSub6() {
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void checkForPendingDataLoad() {
|
2006-02-22 22:40:53 +00:00
|
|
|
if (newPrcName[0] != 0) {
|
2008-07-14 23:10:51 +00:00
|
|
|
bool loadPrcOk = loadPrc(newPrcName);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
strcpy(currentPrcName, newPrcName);
|
|
|
|
strcpy(newPrcName, "");
|
|
|
|
|
2008-07-14 23:10:51 +00:00
|
|
|
// Check that the loading of the script file was successful before
|
|
|
|
// trying to add script 1 from it to the global scripts list. This
|
|
|
|
// fixes a crash when failing copy protection in Amiga or Atari ST
|
|
|
|
// versions of Future Wars.
|
|
|
|
if (loadPrcOk) {
|
2008-07-29 13:44:14 +00:00
|
|
|
addScriptToGlobalScripts(1);
|
2008-07-14 23:10:51 +00:00
|
|
|
} else if (scumm_stricmp(currentPrcName, COPY_PROT_FAIL_PRC_NAME)) {
|
|
|
|
// We only show an error here for other files than the file that
|
|
|
|
// is loaded if copy protection fails (i.e. L201.ANI).
|
|
|
|
warning("checkForPendingDataLoad: loadPrc(%s) failed", currentPrcName);
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (newRelName[0] != 0) {
|
|
|
|
loadRel(newRelName);
|
|
|
|
|
|
|
|
strcpy(currentRelName, newRelName);
|
|
|
|
strcpy(newRelName, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newObjectName[0] != 0) {
|
2008-04-21 20:51:17 +00:00
|
|
|
overlayList.clear();
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
loadObject(newObjectName);
|
|
|
|
|
|
|
|
strcpy(currentObjectName, newObjectName);
|
|
|
|
strcpy(newObjectName, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newMsgName[0] != 0) {
|
|
|
|
loadMsg(newMsgName);
|
|
|
|
|
|
|
|
strcpy(currentMsgName, newMsgName);
|
|
|
|
strcpy(newMsgName, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void hideMouse() {
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void removeExtention(char *dest, const char *source) {
|
|
|
|
strcpy(dest, source);
|
|
|
|
|
2007-12-13 13:17:45 +00:00
|
|
|
byte *ptr = (byte *) strchr(dest, '.');
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
if (ptr) {
|
|
|
|
*ptr = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
void addMessage(byte param1, int16 param2, int16 param3, int16 param4, int16 param5) {
|
2008-04-21 20:51:17 +00:00
|
|
|
overlay tmp;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
tmp.objIdx = param1;
|
|
|
|
tmp.type = 2;
|
|
|
|
tmp.x = param2;
|
|
|
|
tmp.y = param3;
|
|
|
|
tmp.width = param4;
|
|
|
|
tmp.color = param5;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
overlayList.push_back(tmp);
|
|
|
|
}
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
Common::List<SeqListElement> seqList;
|
2008-04-21 20:51:17 +00:00
|
|
|
|
|
|
|
void removeSeq(uint16 param1, uint16 param2, uint16 param3) {
|
2008-05-24 22:11:41 +00:00
|
|
|
Common::List<SeqListElement>::iterator it;
|
2008-04-21 20:51:17 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
for (it = seqList.begin(); it != seqList.end(); ++it) {
|
|
|
|
if (it->objIdx == param1 && it->var4 == param2 && it->varE == param3) {
|
|
|
|
it->var4 = -1;
|
|
|
|
break;
|
|
|
|
}
|
2008-04-21 20:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-06-26 17:29:21 +00:00
|
|
|
bool isSeqRunning(uint16 param1, uint16 param2, uint16 param3) {
|
2008-05-24 22:11:41 +00:00
|
|
|
Common::List<SeqListElement>::iterator it;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
for (it = seqList.begin(); it != seqList.end(); ++it) {
|
|
|
|
if (it->objIdx == param1 && it->var4 == param2 && it->varE == param3) {
|
2008-06-26 17:29:21 +00:00
|
|
|
// Just to be on the safe side there's a restriction of the
|
|
|
|
// addition's result to 16-bit arithmetic here like in the
|
|
|
|
// original. It's possible that it's not strictly needed.
|
|
|
|
return ((it->var14 + it->var16) & 0xFFFF) == 0;
|
2008-05-24 22:11:41 +00:00
|
|
|
}
|
2008-04-21 20:51:17 +00:00
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-06-26 17:29:21 +00:00
|
|
|
return true;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
void addSeqListElement(uint16 objIdx, int16 param1, int16 param2, int16 frame, int16 param4, int16 param5, int16 param6, int16 param7, int16 param8) {
|
|
|
|
Common::List<SeqListElement>::iterator it;
|
|
|
|
SeqListElement tmp;
|
|
|
|
|
|
|
|
for (it = seqList.begin(); it != seqList.end() && it->varE < param7; ++it) ;
|
|
|
|
|
|
|
|
tmp.objIdx = objIdx;
|
|
|
|
tmp.var4 = param1;
|
|
|
|
tmp.var8 = param2;
|
|
|
|
tmp.frame = frame;
|
|
|
|
tmp.varC = param4;
|
|
|
|
tmp.var14 = 0;
|
|
|
|
tmp.var16 = 0;
|
|
|
|
tmp.var18 = param5;
|
|
|
|
tmp.var1A = param6;
|
|
|
|
tmp.varE = param7;
|
|
|
|
tmp.var10 = param8;
|
|
|
|
tmp.var12 = param8;
|
|
|
|
tmp.var1C = 0;
|
|
|
|
tmp.var1E = 0;
|
|
|
|
|
|
|
|
seqList.insert(it, tmp);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 17:14:44 +00:00
|
|
|
void modifySeqListElement(uint16 objIdx, int16 var4Test, int16 param1, int16 param2, int16 param3, int16 param4) {
|
|
|
|
// Find a suitable list element and modify it
|
|
|
|
for (Common::List<SeqListElement>::iterator it = seqList.begin(); it != seqList.end(); ++it) {
|
|
|
|
if (it->objIdx == objIdx && it->var4 == var4Test) {
|
|
|
|
it->varC = param1;
|
|
|
|
it->var18 = param2;
|
|
|
|
it->var1A = param3;
|
|
|
|
it->var10 = it->var12 = param4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
void computeMove1(SeqListElement &element, int16 x, int16 y, int16 param1,
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 param2, int16 x2, int16 y2) {
|
2008-05-24 22:11:41 +00:00
|
|
|
element.var16 = 0;
|
|
|
|
element.var14 = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
if (y2) {
|
|
|
|
if (y - param2 > y2) {
|
2008-05-24 22:11:41 +00:00
|
|
|
element.var16 = 2;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (y + param2 < y2) {
|
2008-05-24 22:11:41 +00:00
|
|
|
element.var16 = 1;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x2) {
|
|
|
|
if (x - param1 > x2) {
|
2008-05-24 22:11:41 +00:00
|
|
|
element.var14 = 2;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x + param1 < x2) {
|
2008-05-24 22:11:41 +00:00
|
|
|
element.var14 = 1;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
uint16 computeMove2(SeqListElement &element) {
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 returnVar = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
if (element.var16 == 1) {
|
2006-02-22 22:40:53 +00:00
|
|
|
returnVar = 4;
|
2008-05-24 22:11:41 +00:00
|
|
|
} else if (element.var16 == 2) {
|
2006-02-22 22:40:53 +00:00
|
|
|
returnVar = 3;
|
|
|
|
}
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
if (element.var14 == 1) {
|
2006-02-22 22:40:53 +00:00
|
|
|
returnVar = 1;
|
2008-05-24 22:11:41 +00:00
|
|
|
} else if (element.var14 == 2) {
|
2006-02-22 22:40:53 +00:00
|
|
|
returnVar = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return returnVar;
|
|
|
|
}
|
|
|
|
|
2008-07-02 04:31:50 +00:00
|
|
|
uint16 addAni(uint16 param1, uint16 objIdx, const int8 *ptr, SeqListElement &element, uint16 param3, int16 *param4) {
|
2008-06-30 17:24:23 +00:00
|
|
|
const int8 *ptrData;
|
|
|
|
const int8 *ptr2;
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 di;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-07-30 11:36:14 +00:00
|
|
|
debug(5, "addAni: param1 = %d, objIdx = %d, ptr = %p, element.var8 = %d, element.var14 = %d param3 = %d",
|
|
|
|
param1, objIdx, ptr, element.var8, element.var14, param3);
|
2008-07-30 11:03:52 +00:00
|
|
|
|
2008-06-30 17:24:23 +00:00
|
|
|
// In the original an error string is set and 0 is returned if the following doesn't hold
|
2006-03-23 03:17:47 +00:00
|
|
|
assert(ptr);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-06-30 17:24:23 +00:00
|
|
|
// We probably could just use a local variable here instead of the dummyU16 but
|
|
|
|
// haven't checked if this has any side-effects so keeping it this way still.
|
|
|
|
dummyU16 = READ_BE_UINT16(ptr + param1 * 2 + 8);
|
2006-02-22 22:40:53 +00:00
|
|
|
ptrData = ptr + dummyU16;
|
|
|
|
|
2008-06-30 17:24:23 +00:00
|
|
|
// In the original an error string is set and 0 is returned if the following doesn't hold
|
2006-03-23 03:17:47 +00:00
|
|
|
assert(*ptrData);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
di = (objectTable[objIdx].costume + 1) % (*ptrData);
|
2008-06-30 17:24:23 +00:00
|
|
|
++ptrData; // Jump over the just read byte
|
|
|
|
// Here ptr2 seems to be indexing a table of structs (8 bytes per struct):
|
|
|
|
// struct {
|
|
|
|
// int8 x; // 0 (Used with checkCollision)
|
|
|
|
// int8 y; // 1 (Used with checkCollision)
|
|
|
|
// int8 numZones; // 2 (Used with checkCollision)
|
|
|
|
// int8 var3; // 3 (Not used in this function)
|
|
|
|
// int8 xAdd; // 4 (Used with an object)
|
|
|
|
// int8 yAdd; // 5 (Used with an object)
|
|
|
|
// int8 maskAdd; // 6 (Used with an object)
|
|
|
|
// int8 frameAdd; // 7 (Used with an object)
|
|
|
|
// };
|
|
|
|
ptr2 = ptrData + di * 8;
|
|
|
|
|
|
|
|
// We might probably safely discard the AND by 1 here because
|
|
|
|
// at least in the original checkCollision returns always 0 or 1.
|
2008-05-24 22:11:41 +00:00
|
|
|
if ((checkCollision(objIdx, ptr2[0], ptr2[1], ptr2[2], ptr[0]) & 1)) {
|
2006-02-22 22:40:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-30 17:24:23 +00:00
|
|
|
objectTable[objIdx].x += ptr2[4];
|
|
|
|
objectTable[objIdx].y += ptr2[5];
|
|
|
|
objectTable[objIdx].mask += ptr2[6];
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-06-30 17:24:23 +00:00
|
|
|
if (ptr2[6]) {
|
2008-05-24 22:11:41 +00:00
|
|
|
resetGfxEntityEntry(objIdx);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
objectTable[objIdx].frame = ptr2[7] + element.var8;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
if (param3 || !element.var14) {
|
|
|
|
objectTable[objIdx].costume = di;
|
2006-02-22 22:40:53 +00:00
|
|
|
} else {
|
2008-06-30 17:24:23 +00:00
|
|
|
assert(param4);
|
2006-02-22 22:40:53 +00:00
|
|
|
*param4 = di;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-01-01 15:06:43 +00:00
|
|
|
/*!
|
2008-06-30 03:33:08 +00:00
|
|
|
* Permutates the overlay list into a different order according to some logic.
|
|
|
|
* \todo Check this function for correctness (Wasn't very easy to reverse engineer so there may be errors)
|
|
|
|
*/
|
|
|
|
void resetGfxEntityEntry(uint16 objIdx) {
|
|
|
|
Common::List<overlay>::iterator it, bObjsCutPoint;
|
|
|
|
Common::List<overlay> aReverseObjs, bObjs;
|
2009-01-01 15:06:43 +00:00
|
|
|
bool foundCutPoint = false;
|
2008-06-30 03:33:08 +00:00
|
|
|
|
|
|
|
// Go through the overlay list and partition the whole list into two categories (Type A and type B objects)
|
|
|
|
for (it = overlayList.begin(); it != overlayList.end(); ++it) {
|
|
|
|
if (it->objIdx == objIdx && it->type != 2 && it->type != 3) { // Type A object
|
|
|
|
aReverseObjs.push_front(*it);
|
|
|
|
} else { // Type B object
|
|
|
|
bObjs.push_back(*it);
|
|
|
|
uint16 objectMask;
|
|
|
|
if (it->type == 2 || it->type == 3) {
|
|
|
|
objectMask = 10000;
|
|
|
|
} else {
|
|
|
|
objectMask = objectTable[it->objIdx].mask;
|
|
|
|
}
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-06-30 03:33:08 +00:00
|
|
|
if (objectTable[objIdx].mask > objectMask) { // Check for B objects' cut point
|
|
|
|
bObjsCutPoint = bObjs.reverse_begin();
|
|
|
|
foundCutPoint = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-06-30 03:33:08 +00:00
|
|
|
// Recreate the overlay list in a different order.
|
|
|
|
overlayList.clear();
|
|
|
|
if (foundCutPoint) {
|
|
|
|
// If a cut point was found the order is:
|
|
|
|
// B objects before the cut point, the cut point, A objects in reverse order, B objects after cut point.
|
|
|
|
++bObjsCutPoint; // Include the cut point in the first list insertion
|
|
|
|
overlayList.insert(overlayList.end(), bObjs.begin(), bObjsCutPoint);
|
|
|
|
overlayList.insert(overlayList.end(), aReverseObjs.begin(), aReverseObjs.end());
|
|
|
|
overlayList.insert(overlayList.end(), bObjsCutPoint, bObjs.end());
|
|
|
|
} else {
|
|
|
|
// If no cut point was found the order is:
|
|
|
|
// A objects in reverse order, B objects.
|
|
|
|
overlayList.insert(overlayList.end(), aReverseObjs.begin(), aReverseObjs.end());
|
|
|
|
overlayList.insert(overlayList.end(), bObjs.begin(), bObjs.end());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
void processSeqListElement(SeqListElement &element) {
|
|
|
|
int16 x = objectTable[element.objIdx].x;
|
|
|
|
int16 y = objectTable[element.objIdx].y;
|
2008-07-02 04:31:50 +00:00
|
|
|
const int8 *ptr1 = (const int8 *) animDataTable[element.frame].data();
|
2006-02-23 09:12:21 +00:00
|
|
|
int16 var_10;
|
|
|
|
int16 var_4;
|
|
|
|
int16 var_2;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-07-30 11:03:52 +00:00
|
|
|
// Initial interpretations for variables addressed through ptr1 (8-bit addressing):
|
|
|
|
// These may be inaccurate!
|
|
|
|
// 0: ?
|
|
|
|
// 1: xRadius
|
|
|
|
// 2: yRadius
|
|
|
|
// 3: ?
|
|
|
|
// 4: xAdd
|
|
|
|
// 5: yAdd
|
|
|
|
// 6: ?
|
|
|
|
// 7: ?
|
|
|
|
// After this come (At least at positions 0, 1 and 3 in 16-bit addressing)
|
|
|
|
// 16-bit big-endian values used for addressing through ptr1.
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
if (element.var12 < element.var10) {
|
|
|
|
element.var12++;
|
2006-02-22 22:40:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
element.var12 = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
if (ptr1) {
|
2008-07-02 04:31:50 +00:00
|
|
|
int16 param1 = ptr1[1];
|
|
|
|
int16 param2 = ptr1[2];
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
if (element.varC != 255) {
|
2008-07-02 04:31:50 +00:00
|
|
|
int16 x2 = element.var18;
|
|
|
|
int16 y2 = element.var1A;
|
|
|
|
if (element.varC) {
|
|
|
|
x2 += objectTable[element.varC].x;
|
|
|
|
y2 += objectTable[element.varC].y;
|
|
|
|
}
|
|
|
|
computeMove1(element, ptr1[4] + x, ptr1[5] + y, param1, param2, x2, y2);
|
2006-02-22 22:40:53 +00:00
|
|
|
} else {
|
2008-08-08 13:30:01 +00:00
|
|
|
if (xMoveKeyb && allowPlayerInput) {
|
2008-07-02 04:31:50 +00:00
|
|
|
int16 adder = param1 + 1;
|
2008-08-08 13:30:01 +00:00
|
|
|
if (xMoveKeyb != kKeybMoveRight) {
|
2008-07-02 04:31:50 +00:00
|
|
|
adder = -adder;
|
|
|
|
}
|
2009-06-27 12:26:26 +00:00
|
|
|
globalVars[VAR_MOUSE_X_POS] = globalVars[VAR_MOUSE_X_POS_2ND] = ptr1[4] + x + adder;
|
2008-07-02 04:31:50 +00:00
|
|
|
}
|
|
|
|
|
2008-08-08 13:30:01 +00:00
|
|
|
if (yMoveKeyb && allowPlayerInput) {
|
2008-07-02 04:31:50 +00:00
|
|
|
int16 adder = param2 + 1;
|
2008-08-08 13:30:01 +00:00
|
|
|
if (yMoveKeyb != kKeybMoveDown) {
|
2008-07-02 04:31:50 +00:00
|
|
|
adder = -adder;
|
|
|
|
}
|
2009-06-27 12:26:26 +00:00
|
|
|
globalVars[VAR_MOUSE_Y_POS] = globalVars[VAR_MOUSE_Y_POS_2ND] = ptr1[5] + y + adder;
|
2008-07-02 04:31:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (globalVars[VAR_MOUSE_X_POS] || globalVars[VAR_MOUSE_Y_POS]) {
|
|
|
|
computeMove1(element, ptr1[4] + x, ptr1[5] + y, param1, param2, globalVars[VAR_MOUSE_X_POS], globalVars[VAR_MOUSE_Y_POS]);
|
|
|
|
} else {
|
|
|
|
element.var16 = 0;
|
|
|
|
element.var14 = 0;
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var_10 = computeMove2(element);
|
|
|
|
|
|
|
|
if (var_10) {
|
2008-05-24 22:11:41 +00:00
|
|
|
element.var1C = var_10;
|
|
|
|
element.var1E = var_10;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var_4 = -1;
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
if ((element.var16 == 1
|
|
|
|
&& !addAni(3, element.objIdx, ptr1, element, 0, &var_4)) || (element.var16 == 2 && !addAni(2, element.objIdx, ptr1, element, 0,
|
2006-02-22 22:40:53 +00:00
|
|
|
&var_4))) {
|
2008-05-24 22:11:41 +00:00
|
|
|
if (element.varC == 255) {
|
2006-02-24 22:34:22 +00:00
|
|
|
globalVars[VAR_MOUSE_Y_POS] = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
if ((element.var14 == 1
|
|
|
|
&& !addAni(0, element.objIdx, ptr1, element, 1, &var_2))) {
|
|
|
|
if (element.varC == 255) {
|
2006-02-24 22:34:22 +00:00
|
|
|
globalVars[VAR_MOUSE_X_POS] = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
if (var_4 != -1) {
|
2008-05-24 22:11:41 +00:00
|
|
|
objectTable[element.objIdx].costume = var_4;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
if ((element.var14 == 2 && !addAni(1, element.objIdx, ptr1, element, 1, &var_2))) {
|
|
|
|
if (element.varC == 255) {
|
2006-02-24 22:34:22 +00:00
|
|
|
globalVars[VAR_MOUSE_X_POS] = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
if (var_4 != -1) {
|
2008-05-24 22:11:41 +00:00
|
|
|
objectTable[element.objIdx].costume = var_4;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-02 04:31:50 +00:00
|
|
|
if (element.var16 + element.var14 == 0) {
|
2008-05-24 22:11:41 +00:00
|
|
|
if (element.var1C) {
|
|
|
|
if (element.var1E) {
|
|
|
|
objectTable[element.objIdx].costume = 0;
|
|
|
|
element.var1E = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2008-07-02 04:31:50 +00:00
|
|
|
addAni(element.var1C + 3, element.objIdx, ptr1, element, 1, &var_2);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void processSeqList() {
|
2008-05-24 22:11:41 +00:00
|
|
|
Common::List<SeqListElement>::iterator it;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
for (it = seqList.begin(); it != seqList.end(); ++it) {
|
|
|
|
if (it->var4 == -1) {
|
|
|
|
continue;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
processSeqListElement(*it);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-25 00:26:14 +00:00
|
|
|
|
2006-11-18 15:16:44 +00:00
|
|
|
|
|
|
|
bool makeTextEntryMenu(const char *messagePtr, char *inputString, int stringMaxLength, int y) {
|
|
|
|
int len = strlen(messagePtr);
|
|
|
|
int16 width = 6 * len + 20;
|
|
|
|
|
2007-12-14 13:55:18 +00:00
|
|
|
width = CLIP((int)width, 180, 250);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-11-18 15:16:44 +00:00
|
|
|
int16 x = (320 - width) / 2;
|
|
|
|
|
|
|
|
getKeyData(); // clear input key
|
|
|
|
|
|
|
|
int quit = 0;
|
|
|
|
bool redraw = true;
|
2007-12-14 19:21:19 +00:00
|
|
|
CommandeType tempString;
|
2006-11-18 15:16:44 +00:00
|
|
|
int inputLength = strlen(inputString);
|
|
|
|
int inputPos = inputLength + 1;
|
|
|
|
|
2009-09-22 17:51:06 +00:00
|
|
|
TextInputMenu *inputBox = new TextInputMenu(Common::Point(x - 16, y), width + 32, messagePtr);
|
|
|
|
renderer->pushMenu(inputBox);
|
2009-09-21 01:15:34 +00:00
|
|
|
|
2006-11-18 15:16:44 +00:00
|
|
|
while (!quit) {
|
|
|
|
if (redraw) {
|
2009-09-22 17:51:06 +00:00
|
|
|
inputBox->setInput(inputString, inputPos);
|
|
|
|
renderer->drawFrame();
|
2006-11-18 15:16:44 +00:00
|
|
|
redraw = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
char ch[2];
|
|
|
|
memset(tempString, 0, stringMaxLength);
|
|
|
|
ch[1] = 0;
|
|
|
|
|
|
|
|
manageEvents();
|
2007-06-22 21:10:57 +00:00
|
|
|
int keycode = getKeyData();
|
2006-11-20 20:27:30 +00:00
|
|
|
uint16 mouseButton, mouseX, mouseY;
|
2006-11-18 15:16:44 +00:00
|
|
|
|
2006-11-20 20:27:30 +00:00
|
|
|
getMouseData(0, &mouseButton, &mouseX, &mouseY);
|
|
|
|
|
2010-01-24 16:25:08 +00:00
|
|
|
if ((mouseButton & kRightMouseButton) || g_cine->shouldQuit())
|
|
|
|
quit = kRightMouseButton;
|
|
|
|
else if (mouseButton & kLeftMouseButton)
|
|
|
|
quit = kLeftMouseButton;
|
2006-11-20 20:27:30 +00:00
|
|
|
|
2007-06-22 21:10:57 +00:00
|
|
|
switch (keycode) {
|
|
|
|
case Common::KEYCODE_BACKSPACE:
|
2006-11-18 15:16:44 +00:00
|
|
|
if (inputPos <= 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
inputPos--;
|
|
|
|
redraw = true;
|
2007-06-22 21:10:57 +00:00
|
|
|
case Common::KEYCODE_DELETE:
|
2006-11-18 16:26:51 +00:00
|
|
|
if (inputPos <= inputLength) {
|
|
|
|
if (inputPos != 1) {
|
|
|
|
strncpy(tempString, inputString, inputPos - 1);
|
|
|
|
}
|
|
|
|
if (inputPos != inputLength) {
|
|
|
|
strncat(tempString, &inputString[inputPos], inputLength - inputPos);
|
|
|
|
}
|
|
|
|
strcpy(inputString, tempString);
|
|
|
|
inputLength = strlen(inputString);
|
|
|
|
redraw = true;
|
2006-11-18 15:16:44 +00:00
|
|
|
}
|
2006-11-18 16:26:51 +00:00
|
|
|
break;
|
2007-06-22 21:10:57 +00:00
|
|
|
case Common::KEYCODE_LEFT:
|
2006-11-18 16:26:51 +00:00
|
|
|
if (inputPos > 1) {
|
|
|
|
inputPos--;
|
|
|
|
redraw = true;
|
|
|
|
}
|
|
|
|
break;
|
2007-06-22 21:10:57 +00:00
|
|
|
case Common::KEYCODE_RIGHT:
|
2006-11-18 16:26:51 +00:00
|
|
|
if (inputPos <= inputLength) {
|
|
|
|
inputPos++;
|
|
|
|
redraw = true;
|
2006-11-18 15:16:44 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2007-06-22 21:10:57 +00:00
|
|
|
if (((keycode >= 'a') && (keycode <='z')) ||
|
|
|
|
((keycode >= '0') && (keycode <='9')) ||
|
|
|
|
((keycode >= 'A') && (keycode <='Z')) ||
|
|
|
|
(keycode == ' ')) {
|
2006-11-18 15:16:44 +00:00
|
|
|
if (inputLength < stringMaxLength - 1) {
|
2007-06-22 21:10:57 +00:00
|
|
|
ch[0] = keycode;
|
2006-11-18 15:16:44 +00:00
|
|
|
if (inputPos != 1) {
|
|
|
|
strncpy(tempString, inputString, inputPos - 1);
|
|
|
|
strcat(tempString, ch);
|
|
|
|
}
|
|
|
|
if ((inputLength == 0) || (inputPos == 1)) {
|
|
|
|
strcpy(tempString, ch);
|
|
|
|
}
|
|
|
|
if ((inputLength != 0) && (inputPos != inputLength)) {
|
|
|
|
strncat(tempString, &inputString[inputPos - 1], inputLength - inputPos + 1);
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-11-18 15:16:44 +00:00
|
|
|
strcpy(inputString, tempString);
|
|
|
|
inputLength = strlen(inputString);
|
|
|
|
inputPos++;
|
|
|
|
redraw = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-22 17:51:06 +00:00
|
|
|
renderer->popMenu();
|
|
|
|
delete inputBox;
|
2009-09-21 01:15:34 +00:00
|
|
|
|
2010-01-24 16:25:08 +00:00
|
|
|
if (quit == kRightMouseButton)
|
2006-11-18 15:16:44 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-02-25 00:26:14 +00:00
|
|
|
} // End of namespace Cine
|