mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-06 18:27:26 +00:00
DREAMWEB: Convert getObTextStart
This commit is contained in:
parent
0133ca823e
commit
b9839635ea
@ -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',
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user