DREAMWEB: Ported 'read' to C++

This commit is contained in:
D G Turner 2011-12-26 20:45:39 +00:00
parent f5da710da4
commit bd70cd9dff
5 changed files with 78 additions and 92 deletions

View File

@ -763,6 +763,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'randomnum1',
'randomnum2',
'randomnumber',
'read',
'readabyte',
'readcitypic',
'readdesticon',

View File

@ -26,97 +26,6 @@
namespace DreamGen {
void DreamGenContext::read() {
STACK_CHECK;
cx = 40;
randomAccess();
parser();
_cmp(es.byte(di+1), 0);
if (!flags.z())
goto okcom;
netError();
return;
okcom:
es = cs;
di = 408;
ax = data.word(kTextfile1);
data.word(kMonsource) = ax;
ds = ax;
si = (66*2);
searchForString();
_cmp(al, 0);
if (flags.z())
goto foundfile2;
ax = data.word(kTextfile2);
data.word(kMonsource) = ax;
ds = ax;
si = (66*2);
searchForString();
_cmp(al, 0);
if (flags.z())
goto foundfile2;
ax = data.word(kTextfile3);
data.word(kMonsource) = ax;
ds = ax;
si = (66*2);
searchForString();
_cmp(al, 0);
if (flags.z())
goto foundfile2;
al = 7;
monMessage();
return;
foundfile2:
getKeyAndLogo();
_cmp(al, 0);
if (flags.z())
goto keyok1;
return;
keyok1:
es = cs;
di = offset_operand1;
ds = data.word(kMonsource);
searchForString();
_cmp(al, 0);
if (flags.z())
goto findtopictext;
al = data.byte(kOldlogonum);
data.byte(kLogonum) = al;
al = 11;
monMessage();
return;
findtopictext:
_inc(bx);
push(es);
push(bx);
monitorLogo();
scrollMonitor();
bx = pop();
es = pop();
moretopic:
monPrint();
al = es.byte(bx);
_cmp(al, 34);
if (flags.z())
goto endoftopic;
_cmp(al, '=');
if (flags.z())
goto endoftopic;
_cmp(al, '*');
if (flags.z())
goto endoftopic;
push(es);
push(bx);
processTrigger();
cx = 24;
randomAccess();
bx = pop();
es = pop();
goto moretopic;
endoftopic:
scrollMonitor();
}
void DreamGenContext::dirFile() {
STACK_CHECK;
al = 34;

View File

@ -418,7 +418,6 @@ public:
void dirFile();
void dreamweb();
void read();
void searchForString();
void parser();
};

View File

@ -475,6 +475,82 @@ void DreamGenContext::dirCom() {
scrollMonitor();
}
void DreamGenContext::read() {
bool foundFile = false;
randomAccess(40);
parser();
if (es.byte(di+1) == 0) {
netError();
return;
}
es = cs;
di = kCurrentfile;
data.word(kMonsource) = data.word(kTextfile1);
ds = data.word(kMonsource);
si = kTextstart;
searchForString();
if (al == 0) {
foundFile = true;
} else {
data.word(kMonsource) = data.word(kTextfile2);
ds = data.word(kMonsource);
si = kTextstart;
searchForString();
if (al == 0) {
foundFile = true;
} else {
data.word(kMonsource) = data.word(kTextfile3);
ds = data.word(kMonsource);
si = kTextstart;
searchForString();
if (al == 0)
foundFile = true;
}
}
if (!foundFile) {
monMessage(7);
return;
}
// "foundfile2"
getKeyAndLogo();
if (al != 0)
return;
// "keyok1"
es = cs;
di = offset_operand1;
ds = data.word(kMonsource);
searchForString();
if (al != 0) {
data.byte(kLogonum) = data.byte(kOldlogonum);
monMessage(11);
return;
}
// "findtopictext"
bx++;
monitorLogo();
scrollMonitor();
while (true) {
monPrint();
if (es.byte(bx) == 34 || es.byte(bx) == '=' || es.byte(bx) == '*') {
// "endoftopic"
scrollMonitor();
return;
}
processTrigger();
randomAccess(24);
}
}
void DreamGenContext::signOn() {
parser();

View File

@ -117,6 +117,7 @@
void getKeyAndLogo();
void signOn();
void searchForFiles(uint16 segment);
void read();
void dirCom();
#endif