DREAMWEB: 'input' ported to C++

This commit is contained in:
Bertrand Augereau 2011-11-18 07:48:07 +01:00
parent 2631da9409
commit 26dd3f52f2
5 changed files with 56 additions and 100 deletions

View File

@ -246,6 +246,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'loadroomssample',
'printlogo',
'usemon',
'input',
], skip_output = [
# These functions are processed but not output
'dreamweb',

View File

@ -6306,102 +6306,6 @@ void DreamGenContext::locklightoff() {
multidump();
}
void DreamGenContext::input() {
STACK_CHECK;
es = cs;
di = 8045;
cx = 64;
al = 0;
_stosb(cx, true);
data.word(kCurpos) = 0;
al = '>';
di = data.word(kMonadx);
bx = data.word(kMonady);
ds = data.word(kTempcharset);
ah = 0;
printchar();
di = data.word(kMonadx);
bx = data.word(kMonady);
cl = 6;
ch = 8;
multidump();
_add(data.word(kMonadx), 6);
ax = data.word(kMonadx);
data.word(kCurslocx) = ax;
ax = data.word(kMonady);
data.word(kCurslocy) = ax;
waitkey:
printcurs();
vsync();
delcurs();
readkey();
al = data.byte(kCurrentkey);
_cmp(al, 0);
if (flags.z())
goto waitkey;
_cmp(al, 13);
if (flags.z())
return /* (endofinput) */;
_cmp(al, 8);
if (!flags.z())
goto notdel;
_cmp(data.word(kCurpos), 0);
if (flags.z())
goto waitkey;
delchar();
goto waitkey;
notdel:
_cmp(data.word(kCurpos), 28);
if (flags.z())
goto waitkey;
_cmp(data.byte(kCurrentkey), 32);
if (!flags.z())
goto notleadingspace;
_cmp(data.word(kCurpos), 0);
if (flags.z())
goto waitkey;
notleadingspace:
makecaps();
es = cs;
si = data.word(kCurpos);
_add(si, si);
_add(si, 8045);
es.byte(si) = al;
_cmp(al, 'Z'+1);
if (!flags.c())
goto waitkey;
push(ax);
push(es);
push(si);
di = data.word(kMonadx);
bx = data.word(kMonady);
ds = data.word(kMapstore);
ax = data.word(kCurpos);
_xchg(al, ah);
si = ax;
cl = 8;
ch = 8;
multiget();
si = pop();
es = pop();
ax = pop();
push(es);
push(si);
di = data.word(kMonadx);
bx = data.word(kMonady);
ds = data.word(kTempcharset);
ah = 0;
printchar();
si = pop();
es = pop();
es.byte(si+1) = cl;
ch = 0;
_add(data.word(kMonadx), cx);
_inc(data.word(kCurpos));
_add(data.word(kCurslocx), cx);
goto waitkey;
}
void DreamGenContext::makecaps() {
STACK_CHECK;
_cmp(al, 'a');
@ -15468,7 +15372,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_accesslightoff: accesslightoff(); break;
case addr_locklighton: locklighton(); break;
case addr_locklightoff: locklightoff(); break;
case addr_input: input(); break;
case addr_makecaps: makecaps(); break;
case addr_delchar: delchar(); break;
case addr_execcommand: execcommand(); break;

View File

@ -360,7 +360,6 @@ public:
static const uint16 addr_execcommand = 0xc52c;
static const uint16 addr_delchar = 0xc528;
static const uint16 addr_makecaps = 0xc524;
static const uint16 addr_input = 0xc520;
static const uint16 addr_locklightoff = 0xc51c;
static const uint16 addr_locklighton = 0xc518;
static const uint16 addr_accesslightoff = 0xc514;
@ -1770,7 +1769,7 @@ public:
void getridoftemptext();
void setuptimeduse();
void grafittidoor();
void input();
//void input();
void nextdest();
//void getdimension();
void makecaps();

View File

@ -105,5 +105,58 @@ void DreamGenContext::printlogo() {
showcurrentfile();
}
void DreamGenContext::input() {
char *inputLine = (char *)cs.ptr(kInputline, 64);
memset(inputLine, 0, 64);
data.word(kCurpos) = 0;
ds = data.word(kTempcharset);
{
uint16 x = data.word(kMonadx);
uint8 width, height;
printchar((Frame *)segRef(data.word(kTempcharset)).ptr(0, 0), &x, data.word(kMonady), '>', 0, &width, &height);
}
multidump(data.word(kMonadx), data.word(kMonady), 6, 8);
data.word(kMonadx) += 6;
data.word(kCurslocx) = data.word(kMonadx);
data.word(kCurslocy) = data.word(kMonady);
while (true) {
printcurs();
vsync();
delcurs();
readkey();
uint8 currentKey = data.byte(kCurrentkey);
if (currentKey == 0)
continue;
if (currentKey == 13)
return;
if (currentKey == 8) {
if (data.word(kCurpos) > 0)
delchar();
continue;
}
if (data.word(kCurpos) == 28)
continue;
if ((currentKey == 32) && (data.word(kCurpos) == 0))
continue;
al = currentKey;
makecaps();
currentKey = al;
inputLine[data.word(kCurpos) * 2 + 0] = currentKey;
if (currentKey > 'Z')
continue;
multiget(segRef(data.word(kMapstore)).ptr(data.word(kCurpos) * 256, 0), data.word(kMonadx), data.word(kMonady), 8, 8);
uint8 charWidth;
{
uint16 x = data.word(kMonadx);
uint8 height;
printchar((Frame *)segRef(data.word(kTempcharset)).ptr(0, 0), &x, data.word(kMonady), currentKey, 0, &charWidth, &height);
}
inputLine[data.word(kCurpos) * 2 + 1] = charWidth;
data.word(kMonadx) += charWidth;
++data.word(kCurpos);
data.word(kCurslocx) += charWidth;
}
}
} /*namespace dreamgen */

View File

@ -297,5 +297,5 @@
void fadeupmonfirst();
void printlogo();
void usemon();
void input();