aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/script_v0.cpp
diff options
context:
space:
mode:
authorTravis Howell2009-07-25 06:27:41 +0000
committerTravis Howell2009-07-25 06:27:41 +0000
commitc02ad3b7bfe5813c9bd86672ead37110d21d9bb5 (patch)
tree28640b732810b3f603903ae42eb8fc99450b5f49 /engines/scumm/script_v0.cpp
parent41ef4938ac8cfcccba4d42c5e474a5a619d9db2b (diff)
downloadscummvm-rg350-c02ad3b7bfe5813c9bd86672ead37110d21d9bb5.tar.gz
scummvm-rg350-c02ad3b7bfe5813c9bd86672ead37110d21d9bb5.tar.bz2
scummvm-rg350-c02ad3b7bfe5813c9bd86672ead37110d21d9bb5.zip
Add patch #2821100 - MM C64 Objects / Verb fixes, with minor clean up applied.
svn-id: r42737
Diffstat (limited to 'engines/scumm/script_v0.cpp')
-rw-r--r--engines/scumm/script_v0.cpp134
1 files changed, 102 insertions, 32 deletions
diff --git a/engines/scumm/script_v0.cpp b/engines/scumm/script_v0.cpp
index 50c4a89e0a..873f2fa281 100644
--- a/engines/scumm/script_v0.cpp
+++ b/engines/scumm/script_v0.cpp
@@ -410,41 +410,43 @@ void ScummEngine_v0::decodeParseString() {
actorTalk(buffer);
}
-void ScummEngine_v0::drawSentence() {
- Common::Rect sentenceline;
+void ScummEngine_v0::drawSentenceWord(int object, bool usePrep, bool objInInventory) {
const byte *temp;
int sentencePrep = 0;
+
+ // If object not in inventory, we except an index
+ if (!objInInventory)
+ _v0ObjectIndex = true;
+ else
+ _v0ObjectInInventory = true;
- if (!(_userState & 32))
- return;
+ temp = getObjOrActorName(object);
- if (getResourceAddress(rtVerb, _activeVerb)) {
- strcpy(_sentenceBuf, (char*)getResourceAddress(rtVerb, _activeVerb));
- } else {
- return;
+ _v0ObjectInInventory = false;
+ _v0ObjectIndex = false;
+
+ // Append the 'object-name'
+ if (temp) {
+ strcat(_sentenceBuf, " ");
+ strcat(_sentenceBuf, (const char*)temp);
}
- if (_activeObject > 0) {
- temp = getObjOrActorName(_activeObject);
- if (temp) {
- strcat(_sentenceBuf, " ");
- strcat(_sentenceBuf, (const char*)temp);
- }
+ // Append the modifier? (With / On / To / In)
+ if (!usePrep)
+ return;
- if (_verbs[_activeVerb].prep == 0xFF) {
- byte *ptr = getOBCDFromObject(_activeObject);
- assert(ptr);
- sentencePrep = (*(ptr + 11) >> 5);
- } else {
- sentencePrep = _verbs[_activeVerb].prep;
- }
+ if (_verbs[_activeVerb].prep == 0xFF) {
+ _v0ObjectInInventory = objInInventory;
+ sentencePrep = verbPrep(object);
+ } else {
+ sentencePrep = _verbs[_activeVerb].prep;
}
if (sentencePrep > 0 && sentencePrep <= 4) {
// The prepositions, like the fonts, were hard code in the engine. Thus
// we have to do that, too, and provde localized versions for all the
// languages MM/Zak are available in.
- const char *prepositions[][5] = {
+ static const char *prepositions[][5] = {
{ " ", " in", " with", " on", " to" }, // English
{ " ", " mit", " mit", " mit", " zu" }, // German
{ " ", " dans", " avec", " sur", " <" }, // French
@@ -471,13 +473,65 @@ void ScummEngine_v0::drawSentence() {
strcat(_sentenceBuf, prepositions[lang][sentencePrep]);
}
+}
+
+void ScummEngine_v0::drawSentence() {
+ Common::Rect sentenceline;
+ bool inventoryFirst = false;
+
+ if (!(_userState & 32))
+ return;
+
+ // Current Verb, Walk/Use
+ if (getResourceAddress(rtVerb, _activeVerb)) {
+ strcpy(_sentenceBuf, (char*)getResourceAddress(rtVerb, _activeVerb));
+ } else {
+ return;
+ }
- if (_activeInventory > 0) {
- temp = getObjOrActorName(_activeInventory);
- if (temp) {
- strcat(_sentenceBuf, " ");
- strcat(_sentenceBuf, (const char*)temp);
+ // If using inventory first, draw it first
+ if (_activeInvExecute && _activeInventory) {
+ drawSentenceWord(_activeInventory, true, true);
+ } else {
+ // Not using inventory, use selected object
+ if (_activeObject)
+ drawSentenceWord(_activeObjectIndex, true, false);
+ else
+ inventoryFirst = true;
+ }
+
+
+ // Draw the inventory?
+ if (_activeInventory > 0 && _activeObject2 == 0) {
+ // Only if inventory isnt first (it will already be drawn by now)
+ if (!_activeInvExecute) {
+ drawSentenceWord(_activeInventory, inventoryFirst, true);
+ } else {
+ // Draw the active object, which could be inventory based, or room based
+ if (_activeObject && !_activeObjectIndex) {
+ drawSentenceWord(_activeObject, inventoryFirst, true);
+ } else // Room based
+ drawSentenceWord(_activeObjectIndex, inventoryFirst, false);
}
+
+ // Draw the 2nd active object
+ } else if (_activeObject2) {
+
+ // 2nd Object is in inventory
+ if (_activeObject2Inv) {
+ _v0ObjectInInventory = true;
+ drawSentenceWord(_activeObject2, inventoryFirst, true);
+ } else {
+ drawSentenceWord(_activeObject2Index, inventoryFirst, false);
+ }
+ }
+
+ // Draw the active actor
+ if (_activeActor) {
+ Actor *a = derefActor(_activeActor, "");
+
+ strcat(_sentenceBuf, " ");
+ strcat(_sentenceBuf, (const char*)a->getActorName());
}
_string[2].charset = 1;
@@ -664,6 +718,7 @@ void ScummEngine_v0::o_animateActor() {
int act = getVarOrDirectByte(PARAM_1);
int anim = getVarOrDirectByte(PARAM_2);
int unk = fetchScriptByte();
+
debug(0,"o_animateActor: unk %d", unk);
ActorC64 *a = (ActorC64*) derefActor(act, "o_animateActor");
@@ -725,9 +780,9 @@ void ScummEngine_v0::o_pickupObject() {
if (getObjectIndex(obj) == -1)
return;
- if (whereIsObject(obj) == WIO_INVENTORY) /* Don't take an */
+ if (whereIsObjectInventory(_activeObject2) == WIO_INVENTORY) /* Don't take an */
return; /* object twice */
-
+
addObjectToInventory(obj, _roomResource);
markObjectRectAsDirty(obj);
putOwner(obj, VAR(VAR_EGO));
@@ -917,10 +972,25 @@ void ScummEngine_v0::o_setOwnerOf() {
setOwnerOf(obj, owner);
}
-void ScummEngine_v0::resetSentence() {
- _activeInventory = 0;
- _activeObject = 0;
+void ScummEngine_v0::resetSentence(bool walking) {
_activeVerb = 13;
+
+ if (!walking) {
+ _activeInventory = 0;
+ _activeObject = 0;
+ _activeObject2 = 0;
+ _activeObjectIndex = 0;
+ _activeObject2Index = 0;
+ }
+
+ _verbExecuting = false;
+ _verbPickup = false;
+
+ _activeActor = 0;
+ _activeInvExecute = false;
+ _activeObject2Inv = false;
+ _activeObjectObtained = false;
+ _activeObject2Obtained = false;
}
} // End of namespace Scumm