aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2011-12-24 12:23:24 +0100
committerWillem Jan Palenstijn2011-12-24 12:23:24 +0100
commitb9839635eab502b640c29e23bdbb20240b2bf440 (patch)
tree9a9c952217e6d8b57206067900ce5a5b8f744fd5
parent0133ca823e5948e7a144ae32d2bbcceda3fdc564 (diff)
downloadscummvm-rg350-b9839635eab502b640c29e23bdbb20240b2bf440.tar.gz
scummvm-rg350-b9839635eab502b640c29e23bdbb20240b2bf440.tar.bz2
scummvm-rg350-b9839635eab502b640c29e23bdbb20240b2bf440.zip
DREAMWEB: Convert getObTextStart
-rwxr-xr-xdevtools/tasmrecover/tasm-recover2
-rw-r--r--engines/dreamweb/dreambase.h1
-rw-r--r--engines/dreamweb/dreamgen.cpp47
-rw-r--r--engines/dreamweb/dreamgen.h1
-rw-r--r--engines/dreamweb/object.cpp69
-rw-r--r--engines/dreamweb/stubs.cpp14
-rw-r--r--engines/dreamweb/use.cpp8
7 files changed, 78 insertions, 64 deletions
diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index b75b0d363d..e519aebb9b 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -479,6 +479,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'getnamepos',
'getnextword',
'getnumber',
+ 'getobtextstart',
'getopenedsize',
'getpersframe',
'getreelframeax',
@@ -748,6 +749,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'saveposition',
'saveseg',
'scanfornames',
+ 'scanforsame',
'screenupdate',
'scrollmonitor',
'security',
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 7ba8a93c7c..4dc537c4e3 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -188,6 +188,7 @@ public:
void deleteExFrame(uint8 frameNum);
void deleteExText(uint8 textNum);
void purgeALocation(uint8 index);
+ const uint8 *getObTextStart();
// from pathfind.cpp
void turnPathOn(uint8 param);
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 17f862c411..bcb45f529f 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -284,53 +284,6 @@ findopen2a:
goto findopen1a;
}
-void DreamGenContext::getObTextStart() {
- STACK_CHECK;
- es = data.word(kFreedesc);
- si = (0);
- cx = (0+(82*2));
- _cmp(data.byte(kObjecttype), 2);
- if (flags.z())
- goto describe;
- es = data.word(kSetdesc);
- si = (0);
- cx = (0+(130*2));
- _cmp(data.byte(kObjecttype), 1);
- if (flags.z())
- goto describe;
- es = data.word(kExtras);
- si = (0+2080+30000+(16*114));
- cx = (0+2080+30000+(16*114)+((114+2)*2));
-describe:
- al = data.byte(kCommand);
- ah = 0;
- _add(ax, ax);
- _add(si, ax);
- ax = es.word(si);
- _add(ax, cx);
- si = ax;
- bx = ax;
-tryagain:
- push(si);
- findNextColon();
- al = es.byte(si);
- cx = si;
- si = pop();
- _cmp(data.byte(kObjecttype), 1);
- if (!flags.z())
- return /* (cantmakeoneup) */;
- _cmp(al, 0);
- if (flags.z())
- goto findsometext;
- _cmp(al, ':');
- if (flags.z())
- goto findsometext;
- return;
-findsometext:
- searchForSame();
- goto tryagain;
-}
-
void DreamGenContext::searchForSame() {
STACK_CHECK;
si = cx;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index b620b2179d..2df23e4e08 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -455,7 +455,6 @@ public:
#include "stubs.h" // Allow hand-reversed functions to have a signature different than void f()
void getPersonText();
- void getObTextStart();
void checkObjectSize();
void doSomeTalk();
void outOfOpen();
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index cdd612001f..8e7ade4ffd 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -636,4 +636,73 @@ void DreamBase::purgeALocation(uint8 index) {
}
}
+const uint8 *DreamBase::getObTextStart() {
+ uint16 textSeg, textDatOff, textOff;
+ if (data.byte(kObjecttype) == kFreeObjectType) {
+ textSeg = data.word(kFreedesc);
+ textDatOff = kFreetextdat;
+ textOff = kFreetext;
+ } else if (data.byte(kObjecttype) == kSetObjectType1) {
+ textSeg = data.word(kSetdesc);
+ textDatOff = kSettextdat;
+ textOff = kSettext;
+ } else {
+ textSeg = data.word(kExtras);
+ textDatOff = kExtextdat;
+ textOff = kExtext;
+ }
+ const uint8 *textBase = getSegment(textSeg).ptr(textOff, 0);
+ const uint8 *text = textBase + getSegment(textSeg).word(textDatOff + 2*data.byte(kCommand));
+
+ if (data.byte(kObjecttype) != kSetObjectType1)
+ return text;
+
+ const uint8 *obname = text;
+ while (true) {
+ const uint8 *start = text;
+ findNextColon(&text);
+
+ // Not an empty description string?
+ if (*text != 0 && *text != ':')
+ return start;
+
+ // If the description string (of a SetObjectType1 object) is empty,
+ // look for an object with the same name.
+ // Example: Eden's garage door outside has two parts. The right part
+ // has no description of its own but uses that of the left part.
+
+ bool found = false;
+ do {
+ text++;
+ uint8 c = *obname;
+
+ // scan for matching first character
+ while (*text != c) {
+ text++;
+
+ // arbitrary give-up counter
+ if (text - (textBase - textOff) >= 8000) {
+ warning("Object description for %d/%d not found", data.byte(kObjecttype), data.byte(kCommand));
+ return obname;
+ }
+ }
+
+ // found matching first character, so match the rest
+ const uint8 *s1 = obname;
+ const uint8 *s2 = text;
+ do {
+ s1++;
+ s2++;
+ } while (*s1 != ':' && *s1 != 0 && *s1 == *s2);
+
+ if (*s1 == ':' || *s1 == 0)
+ found = true; // (prefix) matched the entire object name
+ } while (!found);
+
+ // We found an object with the same name. The next loop iteration
+ // will check if this one again has an empty description.
+ }
+}
+
+
} // End of namespace DreamGen
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 09c8b36e81..f15325eaa9 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -1875,16 +1875,6 @@ uint8 DreamBase::findNextColon(const uint8 **string) {
return c;
}
-const uint8 *DreamGenContext::getObTextStartCPP() {
- push(es);
- push(si);
- getObTextStart();
- const uint8 *result = es.ptr(si, 0);
- si = pop();
- es = pop();
- return result;
-}
-
void DreamGenContext::enterSymbol() {
data.byte(kManisoffscreen) = 1;
getRidOfReels();
@@ -2906,7 +2896,7 @@ void DreamGenContext::obsThatDoThings() {
}
void DreamGenContext::describeOb() {
- const uint8 *obText = getObTextStartCPP();
+ const uint8 *obText = getObTextStart();
uint16 y = 92;
if (data.byte(kForeignrelease) && data.byte(kObjecttype) == kSetObjectType1)
y = 82;
@@ -3673,7 +3663,7 @@ void DreamGenContext::lookAtCard() {
loadKeypad();
createPanel2();
showFrame(tempGraphics(), 160, 80, 42, 128);
- const uint8 *obText = getObTextStartCPP();
+ const uint8 *obText = getObTextStart();
findNextColon(&obText);
findNextColon(&obText);
findNextColon(&obText);
diff --git a/engines/dreamweb/use.cpp b/engines/dreamweb/use.cpp
index aa7c2bddea..e891298f2b 100644
--- a/engines/dreamweb/use.cpp
+++ b/engines/dreamweb/use.cpp
@@ -140,7 +140,7 @@ void DreamGenContext::useRoutine() {
}
delPointer();
- const uint8 *obText = getObTextStartCPP();
+ const uint8 *obText = getObTextStart();
if (findNextColon(&obText) != 0) {
if (findNextColon(&obText) != 0) {
if (*obText != 0) {
@@ -175,7 +175,7 @@ void DreamGenContext::useText(const uint8 *string) {
}
void DreamGenContext::showFirstUse() {
- const uint8 *obText = getObTextStartCPP();
+ const uint8 *obText = getObTextStart();
findNextColon(&obText);
findNextColon(&obText);
useText(obText);
@@ -183,7 +183,7 @@ void DreamGenContext::showFirstUse() {
}
void DreamGenContext::showSecondUse() {
- const uint8 *obText = getObTextStartCPP();
+ const uint8 *obText = getObTextStart();
findNextColon(&obText);
findNextColon(&obText);
findNextColon(&obText);
@@ -1611,7 +1611,7 @@ void DreamGenContext::useCashCard() {
showMan();
uint16 y = (!data.byte(kForeignrelease)) ? 120 : 120 - 3;
showFrame(tempGraphics(), 114, y, 39, 0);
- const uint8 *obText = getObTextStartCPP();
+ const uint8 *obText = getObTextStart();
findNextColon(&obText);
findNextColon(&obText);
y = 98;