aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction
diff options
context:
space:
mode:
authorNicola Mettifogo2007-02-04 08:12:33 +0000
committerNicola Mettifogo2007-02-04 08:12:33 +0000
commite3b9bda909a7fd550d283c7d35960cf68fcd8751 (patch)
tree275e627863991c5962dde161e637e4e695054bd2 /engines/parallaction
parentb7d72fd959ee95b390c06439ea35909df8555d9e (diff)
downloadscummvm-rg350-e3b9bda909a7fd550d283c7d35960cf68fcd8751.tar.gz
scummvm-rg350-e3b9bda909a7fd550d283c7d35960cf68fcd8751.tar.bz2
scummvm-rg350-e3b9bda909a7fd550d283c7d35960cf68fcd8751.zip
changed handling of zone labels to match original engine
svn-id: r25376
Diffstat (limited to 'engines/parallaction')
-rw-r--r--engines/parallaction/animation.cpp18
-rw-r--r--engines/parallaction/commands.cpp6
-rw-r--r--engines/parallaction/defs.h1
-rw-r--r--engines/parallaction/graphics.cpp23
-rw-r--r--engines/parallaction/inventory.cpp2
-rw-r--r--engines/parallaction/parallaction.cpp44
-rw-r--r--engines/parallaction/parallaction.h37
-rw-r--r--engines/parallaction/zone.cpp22
-rw-r--r--engines/parallaction/zone.h11
9 files changed, 99 insertions, 65 deletions
diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp
index fa68f47562..e780c425fc 100644
--- a/engines/parallaction/animation.cpp
+++ b/engines/parallaction/animation.cpp
@@ -67,7 +67,7 @@ Animation *findAnimation(const char *name) {
Animation *v4 = (Animation*)_animations._next;
while (v4) {
- if (!scumm_stricmp(name, v4->_zone._name)) return v4;
+ if (!scumm_stricmp(name, v4->_zone._label._text)) return v4;
v4 = (Animation*)v4->_zone._node._next;
}
@@ -81,8 +81,8 @@ Animation *Parallaction::parseAnimation(ArchivedFile *file, Node *list, char *na
Animation *vD0 = (Animation*)memAlloc(sizeof(Animation));
memset(vD0, 0, sizeof(Animation));
- vD0->_zone._name = (char*)memAlloc(strlen(name)+1);
- strcpy(vD0->_zone._name, name);
+ vD0->_zone._label._text = (char*)memAlloc(strlen(name)+1);
+ strcpy(vD0->_zone._label._text, name);
addNode(list, &vD0->_zone._node);
@@ -109,7 +109,7 @@ Animation *Parallaction::parseAnimation(ArchivedFile *file, Node *list, char *na
}
}
if (!scumm_stricmp(_tokens[0], "label")) {
- _vm->_graphics->makeCnvFromString(&vD0->_zone._label, _tokens[1]);
+ _vm->_graphics->makeCnvFromString(&vD0->_zone._label._cnv, _tokens[1]);
}
if (!scumm_stricmp(_tokens[0], "flags")) {
uint16 _si = 1;
@@ -226,7 +226,7 @@ void jobDisplayAnimations(void *parm, Job *j) {
void jobEraseAnimations(void *arg_0, Job *j) {
-// printf("jobEraseAnimations()...\n");
+ debugC(1, kDebugLocation, "jobEraseAnimations");
Animation *a = (Animation*)_animations._next;
@@ -358,7 +358,7 @@ void Parallaction::parseScriptLine(Instruction *inst, Animation *a, LocalVariabl
case INST_ON: // on
case INST_OFF: // off
case INST_START: // start
- if (!scumm_stricmp(_tokens[1], a->_zone._name)) {
+ if (!scumm_stricmp(_tokens[1], a->_zone._label._text)) {
inst->_opBase._a = a;
} else {
inst->_opBase._a = findAnimation(_tokens[1]);
@@ -426,7 +426,7 @@ void Parallaction::parseScriptLine(Instruction *inst, Animation *a, LocalVariabl
break;
case INST_PUT: // put
- if (!scumm_stricmp(_tokens[1], a->_zone._name)) {
+ if (!scumm_stricmp(_tokens[1], a->_zone._label._text)) {
inst->_opBase._a = a;
} else {
inst->_opBase._a = findAnimation(_tokens[1]);
@@ -521,7 +521,7 @@ LValue getLValue(Instruction *inst, char *str, LocalVariable *locals, Animation
void jobRunScripts(void *parm, Job *j) {
-// printf("jobRunScripts()\n");
+ debugC(1, kDebugLocation, "jobRunScripts");
static uint16 modCounter = 0;
@@ -607,7 +607,7 @@ void jobRunScripts(void *parm, Job *j) {
case INST_MOVE: // move
v4 = buildWalkPath(*inst->_opA._pvalue, *inst->_opB._pvalue);
- addJob(jobWalk, v4, JOBPRIORITY_WALK );
+ addJob(jobWalk, v4, kPriority19 );
_engineFlags |= kEngineWalking;
break;
diff --git a/engines/parallaction/commands.cpp b/engines/parallaction/commands.cpp
index 2f9005136e..0fe79a255e 100644
--- a/engines/parallaction/commands.cpp
+++ b/engines/parallaction/commands.cpp
@@ -286,7 +286,7 @@ void runCommands(Command *list, Zone *z) {
case CMD_OPEN: // open
u->_zone->_flags &= ~kFlagsClosed;
if (u->_zone->u.door->_cnv._count != 0) {
- addJob(&jobToggleDoor, (void*)u->_zone, JOBPRIORITY_TOGGLEDOOR );
+ addJob(&jobToggleDoor, (void*)u->_zone, kPriority18 );
}
break;
@@ -298,7 +298,7 @@ void runCommands(Command *list, Zone *z) {
u->_zone->_flags &= ~kFlagsRemove;
u->_zone->_flags |= kFlagsActive;
if ((u->_zone->_type & 0xFFFF) == kZoneGet) {
- addJob(&jobDisplayDroppedItem, u->_zone, JOBPRIORITY_ADDREMOVEITEMS );
+ addJob(&jobDisplayDroppedItem, u->_zone, kPriority17 );
}
break;
@@ -326,7 +326,7 @@ void runCommands(Command *list, Zone *z) {
WalkNode *vC = buildWalkPath(u->_move._x, u->_move._y);
- addJob(&jobWalk, vC, JOBPRIORITY_WALK );
+ addJob(&jobWalk, vC, kPriority19 );
_engineFlags |= kEngineWalking;
}
break;
diff --git a/engines/parallaction/defs.h b/engines/parallaction/defs.h
index e00a1c7062..002b4832db 100644
--- a/engines/parallaction/defs.h
+++ b/engines/parallaction/defs.h
@@ -83,6 +83,7 @@ struct Cnv {
struct ArchivedFile;
struct Animation;
struct Zone;
+struct ZoneLabel;
struct Command;
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index 7b40642d55..c94a02ff25 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -27,6 +27,7 @@
#include "parallaction/parallaction.h"
#include "parallaction/inventory.h"
#include "parallaction/disk.h"
+#include "parallaction/zone.h"
extern OSystem *g_system;
@@ -456,35 +457,39 @@ void Graphics::blit(uint16 w, uint16 h, int16 x, int16 y, uint16 z, byte *data,
void jobDisplayLabel(void *parm, Job *j) {
- StaticCnv *cnv = (StaticCnv*)parm;
+ ZoneLabel *label = (ZoneLabel*)parm;
- if (cnv->_data0 == NULL) return;
- _vm->_graphics->flatBlitCnv(cnv, Graphics::_labelPosition[0]._x, Graphics::_labelPosition[0]._y, Graphics::kBitBack, cnv->_data1);
+ debugC(1, kDebugLocation, "jobDisplayLabel (%x)", (uint32) label);
+
+ if (label->_cnv._width == 0) return;
+ _vm->_graphics->flatBlitCnv(&label->_cnv, Graphics::_labelPosition[0]._x, Graphics::_labelPosition[0]._y, Graphics::kBitBack, label->_cnv._data1);
return;
}
void jobEraseLabel(void *parm, Job *j) {
- StaticCnv *cnv = (StaticCnv*)parm;
+ ZoneLabel *label = (ZoneLabel*)parm;
+
+ debugC(1, kDebugLocation, "jobEraseLabel (%x)", (uint32) label);
int16 _si, _di;
if (_vm->_activeItem._id != 0) {
- _si = _mousePos._x + 16 - cnv->_width/2;
+ _si = _mousePos._x + 16 - label->_cnv._width/2;
_di = _mousePos._y + 34;
} else {
- _si = _mousePos._x + 8 - cnv->_width/2;
- _di = _mousePos._y + 33;
+ _si = _mousePos._x + 8 - label->_cnv._width/2;
+ _di = _mousePos._y + 21;
}
if (_si < 0) _si = 0;
if (_di > 190) _di = 190;
- if (cnv->_width > SCREEN_WIDTH)
+ if (label->_cnv._width + _si > SCREEN_WIDTH)
_si = SCREEN_WIDTH - _si;
- _vm->_graphics->restoreBackground(Graphics::_labelPosition[1]._x, Graphics::_labelPosition[1]._y, cnv->_width, cnv->_height);
+ _vm->_graphics->restoreBackground(Graphics::_labelPosition[1]._x, Graphics::_labelPosition[1]._y, label->_cnv._width, label->_cnv._height);
Graphics::_labelPosition[1]._x = Graphics::_labelPosition[0]._x;
Graphics::_labelPosition[1]._y = Graphics::_labelPosition[0]._y;
diff --git a/engines/parallaction/inventory.cpp b/engines/parallaction/inventory.cpp
index c6ee0f7e8d..35bcb05a64 100644
--- a/engines/parallaction/inventory.cpp
+++ b/engines/parallaction/inventory.cpp
@@ -124,7 +124,7 @@ int16 pickupItem(Zone *z) {
_inventory[_si]._id = (z->u.get->_icon << 16) & 0xFFFF0000;
_inventory[_si]._index = z->u.get->_icon;
- addJob(jobRemovePickedItem, z, JOBPRIORITY_ADDREMOVEITEMS);
+ addJob(jobRemovePickedItem, z, kPriority17 );
if (_inventory[_si]._id == 0) return 0;
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 29d903cf5b..a437010c54 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -140,7 +140,7 @@ uint16 _introSarcData2 = 1;
static Job *_jDrawInventory = NULL;
static Job *_jDrawLabel = NULL;
static Job *_jEraseLabel = NULL;
-static Zone *_hoverZone = NULL;
+Zone *_hoverZone = NULL;
static Job *_jRunScripts = NULL;
static Cnv _miniCharacterFrames;
@@ -257,8 +257,8 @@ int Parallaction::init() {
_yourself._zone._flags = kFlagsActive | kFlagsNoName;
_yourself._zone._type = kZoneYou;
- _yourself._zone._label._data0 = NULL;
- _yourself._zone._name = strdup("yourself");
+ _yourself._zone._label._cnv._data0 = NULL;
+ _yourself._zone._label._text = strdup("yourself");
addNode(&_animations, &_yourself._zone._node);
_graphics = new Graphics(this);
@@ -395,9 +395,9 @@ void waitUntilLeftClick() {
void Parallaction::runGame() {
// printf("runGame()\n");
- addJob(jobEraseAnimations, (void*)1, JOBPRIORITY_ERASEANIMATIONS);
- _jRunScripts = addJob(jobRunScripts, 0, JOBPRIORITY_RUNSTUFF);
- addJob(jobDisplayAnimations, 0, JOBPRIORITY_DRAWANIMATIONS);
+ addJob(jobEraseAnimations, (void*)1, kPriority20);
+ _jRunScripts = addJob(jobRunScripts, 0, kPriority15);
+ addJob(jobDisplayAnimations, 0, kPriority3);
_graphics->copyScreen(Graphics::kBitBack, Graphics::kBit2);
@@ -422,6 +422,8 @@ void Parallaction::runGame() {
_keyDown = updateInput();
if ((_mouseHidden == 0) && ((_engineFlags & kEngineMouse) == 0) && ((_engineFlags & kEngineWalking) == 0)) {
+ debugC(1, kDebugLocation, "runGame: checking input");
+
InputData *v8 = translateInput();
if (v8) processInput(v8);
}
@@ -469,21 +471,24 @@ void Parallaction::processInput(InputData *data) {
switch (data->_event) {
case kEvEnterZone:
+ debugC(1, kDebugLocation, "processInput: kEvEnterZone");
_graphics->_labelPosition[1]._x = -1000;
_graphics->_labelPosition[1]._y = -1000;
_graphics->_labelPosition[0]._x = -1000;
_graphics->_labelPosition[0]._y = -1000;
- _jDrawLabel = addJob(&jobDisplayLabel, (void*)data->_cnv, JOBPRIORITY_DRAWLABEL);
- _jEraseLabel = addJob(&jobEraseLabel, (void*)data->_cnv, JOBPRIORITY_HIDEINVENTORY);
+ _jDrawLabel = addJob(&jobDisplayLabel, (void*)data->_label, kPriority0);
+ _jEraseLabel = addJob(&jobEraseLabel, (void*)data->_label, kPriority20);
break;
case kEvExitZone:
+ debugC(1, kDebugLocation, "processInput: kEvExitZone");
removeJob(_jDrawLabel);
- addJob(&jobWaitRemoveJob, _jEraseLabel, JOBPRIORITY_RUNSTUFF);
+ addJob(&jobWaitRemoveJob, _jEraseLabel, kPriority15);
_jDrawLabel = NULL;
break;
case kEvAction:
+ debugC(1, kDebugLocation, "processInput: kEvAction");
_procCurrentHoverItem = -1;
_hoverZone = NULL;
pauseJobs();
@@ -496,16 +501,16 @@ void Parallaction::processInput(InputData *data) {
case kEvOpenInventory:
_procCurrentHoverItem = -1;
- _hoverZone = 0;
+ _hoverZone = NULL;
if (_jDrawLabel != 0) {
removeJob(_jDrawLabel);
_jDrawLabel = NULL;
- addJob(&jobWaitRemoveJob, _jEraseLabel, JOBPRIORITY_SHOWINVENTORY);
+ addJob(&jobWaitRemoveJob, _jEraseLabel, kPriority2);
}
if (hitZone(kZoneYou, _mousePos._x, _mousePos._y) == 0)
changeCursor(kCursorArrow);
removeJob(_jRunScripts);
- _jDrawInventory = addJob(&jobShowInventory, 0, JOBPRIORITY_SHOWINVENTORY);
+ _jDrawInventory = addJob(&jobShowInventory, 0, kPriority2);
openInventory();
break;
@@ -515,8 +520,8 @@ void Parallaction::processInput(InputData *data) {
// activates item
changeCursor(data->_inventoryIndex);
}
- _jRunScripts = addJob(&jobRunScripts, 0, JOBPRIORITY_RUNSTUFF);
- addJob(&jobHideInventory, 0, JOBPRIORITY_HIDEINVENTORY);
+ _jRunScripts = addJob(&jobRunScripts, 0, kPriority15);
+ addJob(&jobHideInventory, 0, kPriority20);
removeJob(_jDrawInventory);
break;
@@ -527,12 +532,13 @@ void Parallaction::processInput(InputData *data) {
break;
case kEvWalk:
- _hoverZone = 0;
+ debugC(1, kDebugLocation, "processInput: kEvWalk");
+ _hoverZone = NULL;
changeCursor(kCursorArrow);
if (_yourself._zone._flags & kFlagsRemove) break;
if ((_yourself._zone._flags & kFlagsActive) == 0) break;
v4 = buildWalkPath(data->_mousePos._x, data->_mousePos._y);
- addJob(jobWalk, v4, JOBPRIORITY_WALK);
+ addJob(jobWalk, v4, kPriority19);
_engineFlags |= kEngineWalking; // inhibits processing of input until walking is over
break;
@@ -639,7 +645,7 @@ Parallaction::InputData *Parallaction::translateInput() {
_hoverZone = z;
_input._event = kEvEnterZone;
- _input._cnv = &z->_label;
+ _input._label = &z->_label;
return &_input;
}
@@ -751,9 +757,11 @@ void Parallaction::changeCursor(int32 index) {
if (index == kCursorArrow) { // standard mouse pointer
+ debugC(1, kDebugLocation, "changeCursor(%i), label: %p", index, (const void*)_jDrawLabel);
+
if (_jDrawLabel != NULL) {
removeJob(_jDrawLabel);
- addJob(&jobWaitRemoveJob, _jEraseLabel, JOBPRIORITY_RUNSTUFF);
+ addJob(&jobWaitRemoveJob, _jEraseLabel, kPriority15 );
_jDrawLabel = NULL;
}
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index c55da285a1..5da24517f4 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -32,17 +32,30 @@ namespace Parallaction {
// high values mean high priority
-#define JOBPRIORITY_DRAWLABEL 0
-#define JOBPRIORITY_DRAWMOUSE 1
-#define JOBPRIORITY_SHOWINVENTORY 2
-#define JOBPRIORITY_DRAWANIMATIONS 3
-#define JOBPRIORITY_RUNSTUFF 15
-#define JOBPRIORITY_ADDREMOVEITEMS 17
-#define JOBPRIORITY_TOGGLEDOOR 18
-#define JOBPRIORITY_WALK 19
-#define JOBPRIORITY_ERASEANIMATIONS 20
-#define JOBPRIORITY_HIDEINVENTORY 20
-#define JOBPRIORITY_ERASEMOUSE 21
+enum {
+ kPriority0 = 0,
+ kPriority1 = 1,
+ kPriority2 = 2,
+ kPriority3 = 3,
+ kPriority4 = 4,
+ kPriority5 = 5,
+ kPriority6 = 6,
+ kPriority7 = 7,
+ kPriority8 = 8,
+ kPriority9 = 9,
+ kPriority10 = 10,
+ kPriority11 = 11,
+ kPriority12 = 12,
+ kPriority13 = 13,
+ kPriority14 = 14,
+ kPriority15 = 15,
+ kPriority16 = 16,
+ kPriority17 = 17,
+ kPriority18 = 18,
+ kPriority19 = 19,
+ kPriority20 = 20,
+ kPriority21 = 21
+};
enum {
kMouseNone = 0,
@@ -250,7 +263,7 @@ protected: // data
int16 _inventoryIndex;
Zone* _zone;
- StaticCnv* _cnv;
+ ZoneLabel* _label;
};
bool _skipMenu;
diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp
index f8cb9da8a1..46de82dfdc 100644
--- a/engines/parallaction/zone.cpp
+++ b/engines/parallaction/zone.cpp
@@ -41,7 +41,7 @@ Zone *findZone(const char *name) {
Zone *v4 = (Zone*)_zones._next;
while (v4) {
- if (!scumm_stricmp(name, v4->_name)) return v4;
+ if (!scumm_stricmp(name, v4->_label._text)) return v4;
v4 = (Zone*)v4->_node._next;
}
@@ -65,8 +65,8 @@ void Parallaction::parseZone(ArchivedFile *file, Node *list, char *name) {
Zone *z = (Zone*)memAlloc(sizeof(Zone));
memset(z, 0, sizeof(Zone));
- z->_name = (char*)memAlloc(strlen(name)+1);
- strcpy(z->_name, name);
+ z->_label._text = (char*)memAlloc(strlen(name)+1);
+ strcpy(z->_label._text, name);
addNode(list, &z->_node);
@@ -100,7 +100,7 @@ void Parallaction::parseZone(ArchivedFile *file, Node *list, char *name) {
}
if (!scumm_stricmp(_tokens[0], "label")) {
// printf("label: %s", _tokens[1]);
- _vm->_graphics->makeCnvFromString(&z->_label, _tokens[1]);
+ _vm->_graphics->makeCnvFromString(&z->_label._cnv, _tokens[1]);
}
if (!scumm_stricmp(_tokens[0], "flags")) {
uint16 _si = 1;
@@ -119,6 +119,7 @@ void Parallaction::parseZone(ArchivedFile *file, Node *list, char *name) {
}
void freeZones(Node *list) {
+ debugC(1, kDebugLocation, "freeZones: kEngineQuit = %i", _engineFlags & kEngineQuit);
Zone *z = (Zone*)list;
Zone *v8 = NULL;
@@ -129,7 +130,9 @@ void freeZones(Node *list) {
// TODO: understand and simplify this monster
if (((z->_limits._top == -1) || ((z->_limits._left == -2) && ((isItemInInventory(z->u.merge->_obj1) != 0) || (isItemInInventory(z->u.merge->_obj2) != 0)))) &&
- (_engineFlags & kEngineQuit) == 0) {
+ ((_engineFlags & kEngineQuit) == 0)) {
+
+ debugC(1, kDebugLocation, "freeZones preserving zone '%s'", z->_label._text);
v8 = (Zone*)z->_node._next;
removeNode(&z->_node);
@@ -176,8 +179,9 @@ void freeZones(Node *list) {
break;
}
- memFree(z->_name);
- _vm->_graphics->freeStaticCnv(&z->_label);
+ memFree(z->_label._text);
+ z->_label._text = NULL;
+ _vm->_graphics->freeStaticCnv(&z->_label._cnv);
freeCommands(z->_commands);
}
@@ -460,7 +464,7 @@ void displayItemComment(ExamineData *data) {
uint16 runZone(Zone *z) {
- debugC(1, kDebugLocation, "runZone (%s)", z->_name);
+ debugC(1, kDebugLocation, "runZone (%s)", z->_label._text);
uint16 subtype = z->_type & 0xFFFF;
@@ -487,7 +491,7 @@ uint16 runZone(Zone *z) {
if (z->_flags & kFlagsLocked) break;
z->_flags ^= kFlagsClosed;
if (z->u.door->_cnv._count == 0) break;
- addJob(jobToggleDoor, z, JOBPRIORITY_TOGGLEDOOR);
+ addJob(jobToggleDoor, z, kPriority18 );
break;
case kZoneHear:
diff --git a/engines/parallaction/zone.h b/engines/parallaction/zone.h
index 761af51353..f9a8251d9e 100644
--- a/engines/parallaction/zone.h
+++ b/engines/parallaction/zone.h
@@ -117,8 +117,10 @@ struct ZoneTypeData {
MergeData *merge;
};
-
-
+struct ZoneLabel {
+ char* _text;
+ StaticCnv _cnv;
+};
struct Zone {
Node _node;
@@ -131,8 +133,9 @@ struct Zone {
};
uint32 _type;
uint32 _flags;
- char* _name;
- StaticCnv _label;
+// char* _labeltext;
+// StaticCnv _labelcnv;
+ ZoneLabel _label;
uint16 field_2C; // unused
uint16 field_2E; // unused
ZoneTypeData u;