2001-10-09 14:30:12 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2003-03-06 21:46:56 +00:00
|
|
|
* Copyright (C) 2001-2003 The ScummVM project
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
2001-11-06 20:00:47 +00:00
|
|
|
* $Header$
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
2002-12-25 21:04:47 +00:00
|
|
|
#include "charset.h"
|
2002-07-16 21:03:14 +00:00
|
|
|
#include "object.h"
|
|
|
|
#include "resource.h"
|
2002-12-25 21:04:47 +00:00
|
|
|
#include "scumm.h"
|
2002-11-29 15:13:49 +00:00
|
|
|
#include "verbs.h"
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2003-05-30 14:29:07 +00:00
|
|
|
enum {
|
|
|
|
kInventoryUpArrow = 4,
|
|
|
|
kInventoryDownArrow = 5,
|
|
|
|
kSentenceLine = 6
|
|
|
|
};
|
|
|
|
|
|
|
|
void Scumm::initV2MouseOver() {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
v2_mouseover_box = -1;
|
|
|
|
|
|
|
|
// Inventory items
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
v2_mouseover_boxes[2 * i].left = 0;
|
|
|
|
v2_mouseover_boxes[2 * i].right = 144;
|
|
|
|
v2_mouseover_boxes[2 * i].top = 34 + 8 * i;
|
|
|
|
v2_mouseover_boxes[2 * i].bottom = v2_mouseover_boxes[2 * i].top + 8;
|
|
|
|
|
|
|
|
v2_mouseover_boxes[2 * i + 1].left = 176;
|
|
|
|
v2_mouseover_boxes[2 * i + 1].right = 320;
|
|
|
|
v2_mouseover_boxes[2 * i + 1].top = v2_mouseover_boxes[2 * i].top;
|
|
|
|
v2_mouseover_boxes[2 * i + 1].bottom = v2_mouseover_boxes[2 * i].bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Inventory arrows
|
|
|
|
|
|
|
|
v2_mouseover_boxes[kInventoryUpArrow].left = 144;
|
|
|
|
v2_mouseover_boxes[kInventoryUpArrow].right = 176;
|
|
|
|
v2_mouseover_boxes[kInventoryUpArrow].top = 32;
|
|
|
|
v2_mouseover_boxes[kInventoryUpArrow].bottom = 40;
|
|
|
|
|
|
|
|
v2_mouseover_boxes[kInventoryDownArrow].left = 144;
|
|
|
|
v2_mouseover_boxes[kInventoryDownArrow].right = 176;
|
|
|
|
v2_mouseover_boxes[kInventoryDownArrow].top = 48;
|
|
|
|
v2_mouseover_boxes[kInventoryDownArrow].bottom = 56;
|
|
|
|
|
|
|
|
// Sentence line
|
|
|
|
|
|
|
|
v2_mouseover_boxes[kSentenceLine].left = 0;
|
|
|
|
v2_mouseover_boxes[kSentenceLine].right = 320;
|
|
|
|
v2_mouseover_boxes[kSentenceLine].top = 0;
|
|
|
|
v2_mouseover_boxes[kSentenceLine].bottom = 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scumm::checkV2MouseOver(ScummVM::Point pos) {
|
|
|
|
VirtScreen *vs = &virtscr[2];
|
|
|
|
ScummVM::Rect rect;
|
|
|
|
byte *ptr, *dst;
|
|
|
|
int i, x, y, new_box = -1;
|
|
|
|
|
|
|
|
// Don't do anything unless the inventory is active
|
|
|
|
if (!(_userState & 64)) {
|
|
|
|
v2_mouseover_box = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_cursor.state > 0) {
|
|
|
|
for (i = 0; i < ARRAYSIZE(v2_mouseover_boxes); i++) {
|
|
|
|
if (v2_mouseover_boxes[i].contains(pos.x, pos.y - vs->topline)) {
|
|
|
|
new_box = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_box != v2_mouseover_box) {
|
|
|
|
if (v2_mouseover_box != -1) {
|
|
|
|
rect = v2_mouseover_boxes[v2_mouseover_box];
|
|
|
|
|
|
|
|
dst = ptr = vs->screenPtr + vs->xstart + rect.top * _screenWidth + rect.left;
|
|
|
|
|
|
|
|
// Hackish way to undo highlight: replace color 14 with color 5
|
|
|
|
for (y = rect.height() - 1; y >= 0; y--) {
|
|
|
|
for (x = rect.width() - 1; x >= 0; x--) {
|
|
|
|
if (dst[x] == 14)
|
|
|
|
dst[x] = 5;
|
|
|
|
}
|
|
|
|
dst += _screenWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateDirtyRect(2, rect.left, rect.right, rect.top, rect.bottom, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_box != -1) {
|
|
|
|
rect = v2_mouseover_boxes[new_box];
|
|
|
|
|
|
|
|
dst = ptr = vs->screenPtr + vs->xstart + rect.top * _screenWidth + rect.left;
|
|
|
|
|
|
|
|
// Hackish way to apply highlight: replace color 5 with color 14
|
|
|
|
for (y = rect.height() - 1; y >= 0; y--) {
|
|
|
|
for (x = rect.width() - 1; x >= 0; x--) {
|
|
|
|
if (dst[x] == 5)
|
|
|
|
dst[x] = 14;
|
|
|
|
}
|
|
|
|
dst += _screenWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateDirtyRect(2, rect.left, rect.right, rect.top, rect.bottom, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
v2_mouseover_box = new_box;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-21 10:13:06 +00:00
|
|
|
void Scumm::checkV2Inventory(int x, int y) {
|
|
|
|
int object = 0;
|
|
|
|
|
2003-05-30 14:29:07 +00:00
|
|
|
y -= virtscr[2].topline;
|
2003-05-21 10:13:06 +00:00
|
|
|
|
2003-05-30 14:29:07 +00:00
|
|
|
if ((y < 34) || !(_mouseButStat & MBS_LEFT_CLICK))
|
|
|
|
return;
|
2003-05-22 05:44:18 +00:00
|
|
|
|
2003-05-30 14:29:07 +00:00
|
|
|
if (v2_mouseover_boxes[kInventoryUpArrow].contains(x, y)) {
|
|
|
|
_inventoryOffset -= 2;
|
2003-05-22 05:44:18 +00:00
|
|
|
if (_inventoryOffset < 0)
|
|
|
|
_inventoryOffset = 0;
|
2003-05-30 14:29:07 +00:00
|
|
|
redrawV2Inventory();
|
|
|
|
} else if (v2_mouseover_boxes[kInventoryDownArrow].contains(x, y)) {
|
|
|
|
_inventoryOffset += 2;
|
2003-05-22 05:44:18 +00:00
|
|
|
if (_inventoryOffset > (getInventoryCount(_scummVars[VAR_EGO])-2))
|
|
|
|
_inventoryOffset = (getInventoryCount(_scummVars[VAR_EGO])-2);
|
|
|
|
redrawV2Inventory();
|
2003-05-30 14:29:07 +00:00
|
|
|
}
|
2003-05-22 05:44:18 +00:00
|
|
|
|
2003-05-30 14:29:07 +00:00
|
|
|
for (object = 0; object < 4; object++) {
|
|
|
|
if (v2_mouseover_boxes[object].contains(x, y)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-05-21 10:13:06 +00:00
|
|
|
|
2003-05-30 14:29:07 +00:00
|
|
|
if (object >= 4)
|
|
|
|
return;
|
|
|
|
|
|
|
|
object = findInventory(_scummVars[VAR_EGO], object + 1 + _inventoryOffset);
|
2003-05-21 10:13:06 +00:00
|
|
|
if (object > 0) {
|
2003-05-21 23:54:39 +00:00
|
|
|
runInputScript(3, object, 0);
|
2003-05-21 10:13:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-21 09:29:24 +00:00
|
|
|
void Scumm::redrawV2Inventory() {
|
2003-05-30 14:29:07 +00:00
|
|
|
int i;
|
|
|
|
int max_inv;
|
2003-05-22 05:44:18 +00:00
|
|
|
ScummVM::Rect inventoryBox;
|
2003-05-21 09:29:24 +00:00
|
|
|
|
2003-05-30 14:29:07 +00:00
|
|
|
v2_mouseover_box = -1;
|
|
|
|
|
2003-05-22 05:44:18 +00:00
|
|
|
// Clear on all invocations, so hiding works properly
|
2003-05-30 14:29:07 +00:00
|
|
|
inventoryBox.top = virtscr[2].topline + 32;
|
|
|
|
inventoryBox.bottom = virtscr[2].topline + virtscr[2].height;
|
|
|
|
inventoryBox.left = 0;
|
|
|
|
inventoryBox.right = virtscr[2].width;
|
|
|
|
restoreBG(inventoryBox);
|
2003-05-21 09:29:24 +00:00
|
|
|
|
2003-05-22 05:44:18 +00:00
|
|
|
if (!(_userState & 64)) // Don't draw inventory unless active
|
|
|
|
return;
|
2003-05-21 09:29:24 +00:00
|
|
|
|
2003-05-21 10:13:06 +00:00
|
|
|
_string[1].charset = 1;
|
|
|
|
_string[1].color = 5;
|
2003-05-21 09:29:24 +00:00
|
|
|
|
2003-05-30 14:29:07 +00:00
|
|
|
max_inv = getInventoryCount(_scummVars[VAR_EGO]) - _inventoryOffset;
|
|
|
|
if (max_inv > 4)
|
|
|
|
max_inv = 4;
|
|
|
|
for (i = 0; i < max_inv; i++) {
|
|
|
|
int obj = findInventory(_scummVars[VAR_EGO], i + 1 + _inventoryOffset);
|
|
|
|
if (obj == 0)
|
|
|
|
break;
|
2003-05-21 10:13:06 +00:00
|
|
|
|
2003-05-30 14:29:07 +00:00
|
|
|
_string[1].ypos = v2_mouseover_boxes[i].top + virtscr[2].topline;
|
|
|
|
_string[1].xpos = v2_mouseover_boxes[i].left;
|
2003-05-21 09:29:24 +00:00
|
|
|
|
2003-05-21 10:13:06 +00:00
|
|
|
_messagePtr = getObjOrActorName(obj);
|
2003-05-21 18:09:49 +00:00
|
|
|
assert(_messagePtr);
|
2003-05-21 10:13:06 +00:00
|
|
|
drawString(1);
|
2003-05-21 09:29:24 +00:00
|
|
|
}
|
|
|
|
|
2003-05-30 14:29:07 +00:00
|
|
|
// If necessary, draw "up" arrow
|
|
|
|
if (_inventoryOffset > 0) {
|
|
|
|
_string[1].xpos = v2_mouseover_boxes[kInventoryUpArrow].left;
|
|
|
|
_string[1].ypos = v2_mouseover_boxes[kInventoryUpArrow].top + virtscr[2].topline;
|
|
|
|
_messagePtr = (const byte *)" \1\2";
|
2003-05-21 09:29:24 +00:00
|
|
|
drawString(1);
|
|
|
|
}
|
|
|
|
|
2003-05-30 14:29:07 +00:00
|
|
|
// If necessary, draw "down" arrow
|
|
|
|
if (_inventoryOffset + 4 < getInventoryCount(_scummVars[VAR_EGO])) {
|
|
|
|
_string[1].xpos = v2_mouseover_boxes[kInventoryDownArrow].left;
|
|
|
|
_string[1].ypos = v2_mouseover_boxes[kInventoryDownArrow].top + virtscr[2].topline;
|
|
|
|
_messagePtr = (const byte *)" \3\4";
|
2003-05-21 09:29:24 +00:00
|
|
|
drawString(1);
|
|
|
|
}
|
|
|
|
}
|
2003-05-21 10:13:06 +00:00
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::redrawVerbs() {
|
2001-10-09 14:30:12 +00:00
|
|
|
int i;
|
2003-05-15 22:41:35 +00:00
|
|
|
int verb = (_cursor.state > 0 ? checkMouseOver(_mouse.x, _mouse.y) : 0);
|
2003-03-28 19:11:16 +00:00
|
|
|
for (i = _maxVerbs-1; i >= 0; i--) {
|
|
|
|
if (i == verb && _verbs[verb].hicolor)
|
|
|
|
drawVerb(i, 1);
|
|
|
|
else
|
|
|
|
drawVerb(i, 0);
|
|
|
|
}
|
|
|
|
_verbMouseOver = verb;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::checkExecVerbs() {
|
2002-04-11 17:19:16 +00:00
|
|
|
int i, over;
|
2001-10-09 14:30:12 +00:00
|
|
|
VerbSlot *vs;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_userPut <= 0 || _mouseButStat == 0)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
|
2001-11-14 20:09:39 +00:00
|
|
|
if (_mouseButStat < MBS_MAX_KEY) {
|
2001-10-09 14:30:12 +00:00
|
|
|
/* Check keypresses */
|
2001-10-16 10:01:48 +00:00
|
|
|
vs = &_verbs[1];
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 1; i < _maxVerbs; i++, vs++) {
|
|
|
|
if (vs->verbid && vs->saveid == 0 && vs->curmode == 1) {
|
2001-10-09 14:30:12 +00:00
|
|
|
if (_mouseButStat == vs->key) {
|
|
|
|
runInputScript(1, vs->verbid, 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
runInputScript(4, _mouseButStat, 1);
|
2002-04-11 17:19:16 +00:00
|
|
|
} else if (_mouseButStat & MBS_MOUSE_MASK) {
|
2003-05-21 23:54:39 +00:00
|
|
|
VirtScreen *zone = findVirtScreen(_mouse.y);
|
2002-04-11 17:19:16 +00:00
|
|
|
byte code = _mouseButStat & MBS_LEFT_CLICK ? 1 : 2;
|
2003-05-21 23:54:39 +00:00
|
|
|
if (zone->number == 0) {
|
2003-05-15 22:41:35 +00:00
|
|
|
over = checkMouseOver(_mouse.x, _mouse.y);
|
2001-10-09 14:30:12 +00:00
|
|
|
if (over != 0) {
|
2002-04-11 17:19:16 +00:00
|
|
|
runInputScript(1, _verbs[over].verbid, code);
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
runInputScript(2, 0, code);
|
2003-05-21 23:54:39 +00:00
|
|
|
} else if (_features & GF_AFTER_V2 && zone->number == 2 && _mouse.y > zone->topline + 32) {
|
|
|
|
checkV2Inventory(_mouse.x, _mouse.y);
|
2001-10-09 14:30:12 +00:00
|
|
|
} else {
|
2003-05-15 22:41:35 +00:00
|
|
|
over = checkMouseOver(_mouse.x, _mouse.y);
|
2002-07-07 20:25:23 +00:00
|
|
|
|
2002-05-07 18:44:34 +00:00
|
|
|
// FIXME For the future: Indy3 and under inv scrolling
|
|
|
|
/*
|
2002-07-07 20:25:23 +00:00
|
|
|
if (over >= 31 && over <= 36)
|
|
|
|
over += _inventoryOffset;
|
|
|
|
*/
|
2002-04-11 17:19:16 +00:00
|
|
|
runInputScript(1, over != 0 ? _verbs[over].verbid : 0, code);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::verbMouseOver(int verb) {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_verbMouseOver == verb)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-11-29 18:27:35 +00:00
|
|
|
if (_verbs[_verbMouseOver].type != kImageVerbType) {
|
2001-10-09 14:30:12 +00:00
|
|
|
drawVerb(_verbMouseOver, 0);
|
|
|
|
_verbMouseOver = verb;
|
|
|
|
}
|
|
|
|
|
2002-11-29 18:27:35 +00:00
|
|
|
if (_verbs[verb].type != kImageVerbType && _verbs[verb].hicolor) {
|
2002-04-11 17:19:16 +00:00
|
|
|
drawVerb(verb, 1);
|
2001-10-09 14:30:12 +00:00
|
|
|
_verbMouseOver = verb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
int Scumm::checkMouseOver(int x, int y) {
|
2001-10-09 14:30:12 +00:00
|
|
|
VerbSlot *vs;
|
2002-04-11 17:19:16 +00:00
|
|
|
int i = _maxVerbs - 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
vs = &_verbs[i];
|
2001-10-09 14:30:12 +00:00
|
|
|
do {
|
2002-07-07 20:25:23 +00:00
|
|
|
if (vs->curmode != 1 || !vs->verbid || vs->saveid || y < vs->y || y >= vs->bottom)
|
2002-04-11 17:19:16 +00:00
|
|
|
continue;
|
2001-10-09 14:30:12 +00:00
|
|
|
if (vs->center) {
|
|
|
|
if (x < -(vs->right - vs->x - vs->x) || x >= vs->right)
|
2002-03-11 13:05:54 +00:00
|
|
|
continue;
|
2002-04-11 17:19:16 +00:00
|
|
|
} else {
|
2001-10-09 14:30:12 +00:00
|
|
|
if (x < vs->x || x >= vs->right)
|
|
|
|
continue;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
return i;
|
2002-04-11 17:19:16 +00:00
|
|
|
} while (--vs, --i);
|
2003-05-21 10:13:06 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::drawVerb(int verb, int mode) {
|
2001-10-09 14:30:12 +00:00
|
|
|
VerbSlot *vs;
|
2002-12-26 01:24:19 +00:00
|
|
|
bool tmp;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-12-13 00:52:14 +00:00
|
|
|
if (!verb)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
|
2002-12-13 00:52:14 +00:00
|
|
|
vs = &_verbs[verb];
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
if (!vs->saveid && vs->curmode && vs->verbid) {
|
2002-11-29 18:27:35 +00:00
|
|
|
if (vs->type == kImageVerbType) {
|
2002-12-13 00:52:14 +00:00
|
|
|
drawVerbBitmap(verb, vs->x, vs->y);
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-01-15 02:35:40 +00:00
|
|
|
|
2003-03-28 19:11:16 +00:00
|
|
|
restoreVerbBG(verb);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-09-22 01:17:53 +00:00
|
|
|
_string[4].charset = vs->charset_nr;
|
|
|
|
_string[4].xpos = vs->x;
|
|
|
|
_string[4].ypos = vs->y;
|
2003-05-10 21:49:59 +00:00
|
|
|
_string[4].right = _screenWidth - 1;
|
2002-09-22 01:17:53 +00:00
|
|
|
_string[4].center = vs->center;
|
2002-05-20 14:43:22 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (vs->curmode == 2)
|
2002-09-22 01:17:53 +00:00
|
|
|
_string[4].color = vs->dimcolor;
|
2002-05-20 14:43:22 +00:00
|
|
|
else if (mode && vs->hicolor)
|
2002-09-22 01:17:53 +00:00
|
|
|
_string[4].color = vs->hicolor;
|
2002-05-20 14:43:22 +00:00
|
|
|
else
|
2002-09-22 01:17:53 +00:00
|
|
|
_string[4].color = vs->color;
|
2002-03-11 13:05:54 +00:00
|
|
|
|
2002-05-07 18:44:34 +00:00
|
|
|
// FIXME For the future: Indy3 and under inv scrolling
|
|
|
|
/*
|
2002-12-13 00:52:14 +00:00
|
|
|
if (verb >= 31 && verb <= 36)
|
|
|
|
verb += _inventoryOffset;
|
2002-07-07 20:25:23 +00:00
|
|
|
*/
|
2002-05-07 18:44:34 +00:00
|
|
|
|
2002-12-13 00:52:14 +00:00
|
|
|
_messagePtr = getResourceAddress(rtVerb, verb);
|
2002-06-27 10:40:37 +00:00
|
|
|
if (!_messagePtr)
|
|
|
|
return;
|
2001-10-09 14:30:12 +00:00
|
|
|
assert(_messagePtr);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-01-12 21:12:28 +00:00
|
|
|
if ((_features & GF_AFTER_V8) && (_messagePtr[0] == '/')) {
|
|
|
|
char pointer[20];
|
|
|
|
int i, j;
|
2002-12-29 17:35:38 +00:00
|
|
|
|
2003-01-12 21:12:28 +00:00
|
|
|
translateText(_messagePtr, _transText);
|
2002-12-29 17:35:38 +00:00
|
|
|
|
2003-01-12 21:12:28 +00:00
|
|
|
for (i = 0, j = 0; (_messagePtr[i] != '/' || j == 0) && j < 19; i++) {
|
|
|
|
if (_messagePtr[i] != '/')
|
|
|
|
pointer[j++] = _messagePtr[i];
|
|
|
|
}
|
|
|
|
pointer[j] = 0;
|
2002-12-29 17:35:38 +00:00
|
|
|
_messagePtr = _transText;
|
|
|
|
}
|
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
tmp = _charset->_center;
|
|
|
|
_charset->_center = 0;
|
2001-10-09 14:30:12 +00:00
|
|
|
drawString(4);
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_center = tmp;
|
|
|
|
|
2003-05-15 22:30:32 +00:00
|
|
|
vs->right = _charset->_str.right;
|
|
|
|
vs->bottom = _charset->_str.bottom;
|
2003-05-15 22:36:43 +00:00
|
|
|
vs->old = _charset->_str;
|
2003-05-15 22:30:32 +00:00
|
|
|
_charset->_str.left = _charset->_str.right;
|
2001-10-09 14:30:12 +00:00
|
|
|
} else {
|
2002-12-13 00:52:14 +00:00
|
|
|
restoreVerbBG(verb);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::restoreVerbBG(int verb) {
|
2001-10-09 14:30:12 +00:00
|
|
|
VerbSlot *vs;
|
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
vs = &_verbs[verb];
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2003-05-15 22:36:43 +00:00
|
|
|
if (vs->old.left != -1) {
|
|
|
|
restoreBG(vs->old, vs->bkcolor);
|
|
|
|
vs->old.left = -1;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::drawVerbBitmap(int verb, int x, int y) {
|
2001-10-09 14:30:12 +00:00
|
|
|
VirtScreen *vs;
|
|
|
|
VerbSlot *vst;
|
2003-05-28 20:01:47 +00:00
|
|
|
byte twobufs;
|
|
|
|
const byte *imptr = 0;
|
2001-10-09 14:30:12 +00:00
|
|
|
int ydiff, xstrip;
|
|
|
|
int imgw, imgh;
|
2002-04-11 17:19:16 +00:00
|
|
|
int i, tmp;
|
2001-10-26 17:34:50 +00:00
|
|
|
byte *obim;
|
2003-05-28 20:01:47 +00:00
|
|
|
const ImageHeader *imhd;
|
2002-02-15 17:17:35 +00:00
|
|
|
uint32 size;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if ((vs = findVirtScreen(y)) == NULL)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
|
2001-10-26 17:34:50 +00:00
|
|
|
gdi.disableZBuffer();
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
twobufs = vs->alloctwobuffers;
|
|
|
|
vs->alloctwobuffers = 0;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
xstrip = x >> 3;
|
2001-10-09 14:30:12 +00:00
|
|
|
ydiff = y - vs->topline;
|
|
|
|
|
2003-04-30 22:37:03 +00:00
|
|
|
obim = getResourceAddress(rtVerb, verb);
|
|
|
|
assert(obim);
|
2003-04-12 20:19:29 +00:00
|
|
|
if (_features & GF_OLD_BUNDLE) {
|
2003-04-29 01:38:10 +00:00
|
|
|
imgw = obim[0];
|
|
|
|
imgh = obim[1] >> 3;
|
|
|
|
imptr = obim + 2;
|
2003-04-12 19:44:06 +00:00
|
|
|
} else if (_features & GF_SMALL_HEADER) {
|
2002-04-11 17:19:16 +00:00
|
|
|
size = READ_LE_UINT32(obim);
|
|
|
|
|
|
|
|
imgw = (*(obim + size + 11));
|
|
|
|
imgh = (*(obim + size + 17)) >> 3;
|
|
|
|
imptr = (obim + 8);
|
|
|
|
} else {
|
2003-05-28 20:01:47 +00:00
|
|
|
imhd = (const ImageHeader *)findResourceData(MKID('IMHD'), obim);
|
2002-03-05 21:03:32 +00:00
|
|
|
if (_features & GF_AFTER_V7) {
|
|
|
|
imgw = READ_LE_UINT16(&imhd->v7.width) >> 3;
|
|
|
|
imgh = READ_LE_UINT16(&imhd->v7.height) >> 3;
|
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
imgw = READ_LE_UINT16(&imhd->old.width) >> 3;
|
|
|
|
imgh = READ_LE_UINT16(&imhd->old.height) >> 3;
|
2002-03-05 21:03:32 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-12-31 03:32:06 +00:00
|
|
|
if (_features & GF_AFTER_V8) {
|
|
|
|
warning("drawVerbBitmap(%d, %d, %d)", verb, x, y);
|
|
|
|
imptr = findResource(MKID('IMAG'), obim);
|
|
|
|
assert(imptr);
|
|
|
|
imptr = findResource(MKID('WRAP'), imptr);
|
|
|
|
assert(imptr);
|
|
|
|
imptr = findResource(MKID('OFFS'), imptr);
|
|
|
|
assert(imptr);
|
|
|
|
// Get the address of the second SMAP (corresponds to IM01)
|
|
|
|
imptr += READ_LE_UINT32(imptr + 12);
|
|
|
|
} else
|
|
|
|
imptr = findResource(MKID('IM01'), obim);
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!imptr)
|
2002-12-13 00:52:14 +00:00
|
|
|
error("No image for verb %d", verb);
|
2002-04-11 17:19:16 +00:00
|
|
|
}
|
2003-04-12 19:44:06 +00:00
|
|
|
assert(imptr);
|
2003-06-06 05:27:45 +00:00
|
|
|
if (_features & GF_AFTER_V1) {
|
|
|
|
gdi._C64ObjectMode = true;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < imgw; i++) {
|
2001-10-26 17:34:50 +00:00
|
|
|
tmp = xstrip + i;
|
2002-10-24 06:28:54 +00:00
|
|
|
if (tmp < gdi._numStrips)
|
2003-05-12 16:57:04 +00:00
|
|
|
gdi.drawBitmap(imptr, vs, tmp, ydiff, imgw * 8, imgh * 8, i, 1, Gdi::dbAllowMaskOr);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-12-13 00:52:14 +00:00
|
|
|
vst = &_verbs[verb];
|
2003-05-12 16:57:04 +00:00
|
|
|
vst->right = vst->x + imgw * 8;
|
|
|
|
vst->bottom = vst->y + imgh * 8;
|
2003-05-15 22:36:43 +00:00
|
|
|
vst->old.left = vst->x;
|
|
|
|
vst->old.right = vst->right;
|
|
|
|
vst->old.top = vst->y;
|
|
|
|
vst->old.bottom = vst->bottom;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-26 17:34:50 +00:00
|
|
|
gdi.enableZBuffer();
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
vs->alloctwobuffers = twobufs;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
int Scumm::getVerbSlot(int id, int mode) {
|
2001-10-09 14:30:12 +00:00
|
|
|
int i;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 1; i < _maxVerbs; i++) {
|
2001-10-16 10:01:48 +00:00
|
|
|
if (_verbs[i].verbid == id && _verbs[i].saveid == mode) {
|
2001-10-09 14:30:12 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::killVerb(int slot) {
|
2001-10-09 14:30:12 +00:00
|
|
|
VerbSlot *vs;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (slot == 0)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
vs = &_verbs[slot];
|
2001-10-09 14:30:12 +00:00
|
|
|
vs->verbid = 0;
|
|
|
|
vs->curmode = 0;
|
|
|
|
|
2001-11-05 19:21:49 +00:00
|
|
|
nukeResource(rtVerb, slot);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (vs->saveid == 0) {
|
2001-10-09 14:30:12 +00:00
|
|
|
drawVerb(slot, 0);
|
|
|
|
verbMouseOver(0);
|
|
|
|
}
|
|
|
|
vs->saveid = 0;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::setVerbObject(uint room, uint object, uint verb) {
|
2003-05-28 20:01:47 +00:00
|
|
|
const byte *obimptr;
|
|
|
|
const byte *obcdptr;
|
2002-02-15 17:17:35 +00:00
|
|
|
uint32 size, size2;
|
2001-11-26 19:57:57 +00:00
|
|
|
FindObjectInRoom foir;
|
2002-02-14 17:02:07 +00:00
|
|
|
int i;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2001-11-12 20:50:36 +00:00
|
|
|
if (whereIsObject(object) == WIO_FLOBJECT)
|
2001-10-09 14:30:12 +00:00
|
|
|
error("Can't grab verb image from flobject");
|
|
|
|
|
2003-04-12 19:44:06 +00:00
|
|
|
if (_features & GF_OLD_BUNDLE) {
|
2003-04-29 01:38:10 +00:00
|
|
|
for (i = (_numLocalObjects-1); i > 0; i--) {
|
|
|
|
if (_objs[i].obj_nr == object) {
|
|
|
|
findObjectInRoom(&foir, foImageHeader, object, room);
|
|
|
|
size = READ_LE_UINT16(foir.obim);
|
|
|
|
byte *ptr = createResource(rtVerb, verb, size + 2);
|
|
|
|
obcdptr = getResourceAddress(rtRoom, room) + getOBCDOffs(object);
|
|
|
|
ptr[0] = *(obcdptr + 9); // Width
|
|
|
|
ptr[1] = *(obcdptr + 15); // Height
|
|
|
|
memcpy(ptr + 2, foir.obim, size);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2003-04-12 19:44:06 +00:00
|
|
|
} else if (_features & GF_SMALL_HEADER) {
|
2003-01-12 08:37:59 +00:00
|
|
|
for (i = (_numLocalObjects-1); i > 0; i--) {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_objs[i].obj_nr == object) {
|
2003-04-29 01:38:10 +00:00
|
|
|
// FIXME - the only thing we need from the OBCD is the image size!
|
|
|
|
// So we could use almost the same code (save for offsets)
|
|
|
|
// as in the GF_OLD_BUNDLE code. But of course that would break save games
|
|
|
|
// unless we insert special conversion code... <sigh>
|
2002-02-14 17:02:07 +00:00
|
|
|
findObjectInRoom(&foir, foImageHeader, object, room);
|
|
|
|
size = READ_LE_UINT32(foir.obim);
|
2002-02-15 17:17:35 +00:00
|
|
|
obcdptr = getResourceAddress(rtRoom, room) + getOBCDOffs(object);
|
|
|
|
size2 = READ_LE_UINT32(obcdptr);
|
2002-04-11 17:19:16 +00:00
|
|
|
createResource(rtVerb, verb, size + size2);
|
2002-02-14 17:02:07 +00:00
|
|
|
obimptr = getResourceAddress(rtRoom, room) - foir.roomptr + foir.obim;
|
2002-02-15 17:17:35 +00:00
|
|
|
obcdptr = getResourceAddress(rtRoom, room) + getOBCDOffs(object);
|
2002-02-14 17:02:07 +00:00
|
|
|
memcpy(getResourceAddress(rtVerb, verb), obimptr, size);
|
2002-04-11 17:19:16 +00:00
|
|
|
memcpy(getResourceAddress(rtVerb, verb) + size, obcdptr, size2);
|
2003-04-12 19:44:06 +00:00
|
|
|
return;
|
2002-02-14 17:02:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
findObjectInRoom(&foir, foImageHeader, object, room);
|
2002-04-11 17:19:16 +00:00
|
|
|
size = READ_BE_UINT32_UNALIGNED(foir.obim + 4);
|
2002-02-14 17:02:07 +00:00
|
|
|
createResource(rtVerb, verb, size);
|
|
|
|
obimptr = getResourceAddress(rtRoom, room) - foir.roomptr + foir.obim;
|
|
|
|
memcpy(getResourceAddress(rtVerb, verb), obimptr, size);
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|