DREAMWEB: Convert 'parser'

This commit is contained in:
Willem Jan Palenstijn 2011-12-26 20:35:20 +01:00
parent bd70cd9dff
commit b08804f360
7 changed files with 55 additions and 50 deletions

View File

@ -718,6 +718,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'panelicons1',
'paneltomap',
'parseblaster',
'parser',
'personnametext',
'pickupconts',
'pickupob',

View File

@ -177,6 +177,7 @@ public:
void loadNews();
void loadCart();
void showKeys();
const char *parser();
// from newplace.cpp
void getUnderCentre();
@ -590,6 +591,7 @@ public:
void errorMessage1();
void errorMessage2();
void errorMessage3();
void decide();
// from talk.cpp
void talk();

View File

@ -148,45 +148,6 @@ notfound:
al = 1;
}
void DreamGenContext::parser() {
STACK_CHECK;
es = cs;
di = offset_operand1;
cx = 13;
al = 0;
_stosb(cx, true);
di = offset_operand1;
al = '=';
_stosb();
ds = cs;
si = 483;
notspace1:
_lodsw();
_cmp(al, 32);
if (flags.z())
goto stillspace1;
_cmp(al, 0);
if (!flags.z())
goto notspace1;
goto finishpars;
stillspace1:
_lodsw();
_cmp(al, 32);
if (flags.z())
goto stillspace1;
copyin1:
_stosb();
_lodsw();
_cmp(al, 0);
if (flags.z())
goto finishpars;
_cmp(al, 32);
if (!flags.z())
goto copyin1;
finishpars:
di = offset_operand1;
}
void DreamGenContext::__start() {
static const uint8 src[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x13, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View File

@ -419,7 +419,6 @@ public:
void dirFile();
void dreamweb();
void searchForString();
void parser();
};
} // End of namespace DreamGen

View File

@ -458,8 +458,11 @@ void DreamGenContext::getKeyAndLogo() {
void DreamGenContext::dirCom() {
randomAccess(30);
parser();
if (es.byte(di + 1)) {
const char *dirname = parser();
if (dirname[1]) {
es = cs;
di = offset_operand1; // cs:operand1 == dirname
dirFile();
return;
}
@ -479,8 +482,8 @@ void DreamGenContext::read() {
bool foundFile = false;
randomAccess(40);
parser();
if (es.byte(di+1) == 0) {
const char *name = parser();
if (name[1] == 0) {
netError();
return;
}
@ -552,10 +555,10 @@ void DreamGenContext::read() {
}
void DreamGenContext::signOn() {
parser();
const char *name = parser();
int8 foundIndex = -1;
Common::String inputLine = (const char *)data.ptr(offset_operand1 + 1, 0);
Common::String inputLine = name + 1;
inputLine.trim();
for (byte i = 0; i < 4; i++) {
@ -623,4 +626,44 @@ void DreamGenContext::searchForFiles(uint16 segment) {
}
}
const char *DreamBase::parser() {
char *output = (char *)data.ptr(offset_operand1, 13);
memset(output, 0, 13);
char *p = output;
*p++ = '=';
const char *in = (const char *)data.ptr(kInputline, 0);
uint8 c;
// skip command
do {
c = *in++;
in++;
if (!c)
return output;
} while (c != 32);
// skip spaces between command and operand
do {
c = *in++;
in++;
} while (c == 32);
// copy first operand
do {
*p++ = c;
c = *in++;
in++;
if (!c)
return output;
} while (c != 32);
return output;
}
} // End of namespace DreamGen

View File

@ -3101,7 +3101,7 @@ void DreamGenContext::madmanRun() {
}
void DreamGenContext::decide() {
void DreamBase::decide() {
setMode();
loadPalFromIFF();
clearPalette();
@ -3118,10 +3118,10 @@ void DreamGenContext::decide() {
fadeScreenUp();
data.byte(kGetback) = 0;
RectWithCallback<DreamGenContext> decideList[] = {
RectWithCallback<DreamBase> decideList[] = {
{ kOpsx+69,kOpsx+124,kOpsy+30,kOpsy+76,&DreamBase::newGame },
{ kOpsx+20,kOpsx+87,kOpsy+10,kOpsy+59,&DreamBase::DOSReturn },
{ kOpsx+123,kOpsx+190,kOpsy+10,kOpsy+59,&DreamGenContext::loadOld },
{ kOpsx+123,kOpsx+190,kOpsy+10,kOpsy+59,&DreamBase::loadOld },
{ 0,320,0,200,&DreamBase::blank },
{ 0xFFFF,0,0,0,0 }
};

View File

@ -107,7 +107,6 @@
void allPointer();
void afterNewRoom();
void madmanRun();
void decide();
void showGun();
void triggerMessage(uint16 index);
void processTrigger();