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', 'panelicons1',
'paneltomap', 'paneltomap',
'parseblaster', 'parseblaster',
'parser',
'personnametext', 'personnametext',
'pickupconts', 'pickupconts',
'pickupob', 'pickupob',

View File

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

View File

@ -148,45 +148,6 @@ notfound:
al = 1; 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() { void DreamGenContext::__start() {
static const uint8 src[] = { static const uint8 src[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x13, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 dirFile();
void dreamweb(); void dreamweb();
void searchForString(); void searchForString();
void parser();
}; };
} // End of namespace DreamGen } // End of namespace DreamGen

View File

@ -458,8 +458,11 @@ void DreamGenContext::getKeyAndLogo() {
void DreamGenContext::dirCom() { void DreamGenContext::dirCom() {
randomAccess(30); randomAccess(30);
parser();
if (es.byte(di + 1)) { const char *dirname = parser();
if (dirname[1]) {
es = cs;
di = offset_operand1; // cs:operand1 == dirname
dirFile(); dirFile();
return; return;
} }
@ -479,8 +482,8 @@ void DreamGenContext::read() {
bool foundFile = false; bool foundFile = false;
randomAccess(40); randomAccess(40);
parser(); const char *name = parser();
if (es.byte(di+1) == 0) { if (name[1] == 0) {
netError(); netError();
return; return;
} }
@ -552,10 +555,10 @@ void DreamGenContext::read() {
} }
void DreamGenContext::signOn() { void DreamGenContext::signOn() {
parser(); const char *name = parser();
int8 foundIndex = -1; int8 foundIndex = -1;
Common::String inputLine = (const char *)data.ptr(offset_operand1 + 1, 0); Common::String inputLine = name + 1;
inputLine.trim(); inputLine.trim();
for (byte i = 0; i < 4; i++) { 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 } // End of namespace DreamGen

View File

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

View File

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