DREAMWEB: 'monprint' ported to C++

This commit is contained in:
Bertrand Augereau 2011-11-18 18:17:16 +01:00
parent 105c90b9d5
commit 2701439250
5 changed files with 52 additions and 89 deletions

View File

@ -249,6 +249,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'scrollmonitor',
'showcurrentfile',
'input',
'monprint',
], skip_output = [
# These functions are processed but not output
'dreamweb',

View File

@ -3168,92 +3168,6 @@ realcreditsearly:
data.byte(kLasthardkey) = 0;
}
void DreamGenContext::monprint() {
STACK_CHECK;
data.byte(kKerning) = 1;
si = bx;
dl = 166;
di = data.word(kMonadx);
bx = data.word(kMonady);
ds = data.word(kTempcharset);
printloop8:
push(bx);
push(di);
push(dx);
getnumber();
ch = 0;
printloop7:
al = es.byte(si);
_inc(si);
_cmp(al, ':');
if (flags.z())
goto finishmon2;
_cmp(al, 0);
if (flags.z())
goto finishmon;
_cmp(al, 34);
if (flags.z())
goto finishmon;
_cmp(al, '=');
if (flags.z())
goto finishmon;
_cmp(al, '%');
if (!flags.z())
goto nottrigger;
ah = es.byte(si);
_inc(si);
_inc(si);
goto finishmon;
nottrigger:
push(cx);
push(es);
modifychar();
printchar();
data.word(kCurslocx) = di;
data.word(kCurslocy) = bx;
data.word(kMaintimer) = 1;
printcurs();
vsync();
push(si);
push(dx);
push(ds);
push(es);
push(bx);
push(di);
lockmon();
di = pop();
bx = pop();
es = pop();
ds = pop();
dx = pop();
si = pop();
delcurs();
es = pop();
cx = pop();
if (--cx)
goto printloop7;
finishmon2:
dx = pop();
di = pop();
bx = pop();
scrollmonitor();
data.word(kCurslocx) = di;
goto printloop8;
finishmon:
dx = pop();
di = pop();
bx = pop();
_cmp(al, '%');
if (!flags.z())
goto nottrigger2;
data.byte(kLasttrigger) = ah;
nottrigger2:
data.word(kCurslocx) = di;
scrollmonitor();
bx = si;
data.byte(kKerning) = 0;
}
void DreamGenContext::fillopen() {
STACK_CHECK;
deltextline();
@ -15229,7 +15143,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_mode640x480: mode640x480(); break;
case addr_set16colpalette: set16colpalette(); break;
case addr_realcredits: realcredits(); break;
case addr_monprint: monprint(); break;
case addr_fillopen: fillopen(); break;
case addr_findallopen: findallopen(); break;
case addr_makemainscreen: makemainscreen(); break;

View File

@ -452,7 +452,6 @@ public:
static const uint16 addr_makemainscreen = 0xc340;
static const uint16 addr_findallopen = 0xc32c;
static const uint16 addr_fillopen = 0xc324;
static const uint16 addr_monprint = 0xc314;
static const uint16 addr_realcredits = 0xc2f8;
static const uint16 addr_set16colpalette = 0xc2f4;
static const uint16 addr_mode640x480 = 0xc2f0;
@ -1357,7 +1356,7 @@ public:
void delchar();
void getanyad();
void endgame();
void monprint();
//void monprint();
void usepipe();
//void startloading();
void getunderzoom();

View File

@ -234,5 +234,53 @@ uint16 DreamGenContext::waitframes() {
return data.word(kMousebutton);
}
void DreamGenContext::monprint() {
uint16 originalBx = bx;
const char *string = (const char *)es.ptr(bx, 0);
const char *nextString = monprint(string);
bx = originalBx + (nextString - string);
}
const char *DreamGenContext::monprint(const char *string) {
data.byte(kKerning) = 1;
uint16 x = data.word(kMonadx);
Frame *tempCharset = (Frame *)segRef(data.word(kTempcharset)).ptr(0, 0);
const char *iterator = string;
while (true) {
uint16 count = getnumber(tempCharset, (const uint8 *)iterator, 166, false, &x);
do {
char c = *iterator++;
if (c == ':')
break;
if ((c == 0) || (c == 34) || (c == '='))
goto finishmon;
if (c == '%') {
data.byte(kLasttrigger) = *iterator;
iterator += 2;
goto finishmon;
}
c = engine->modifyChar(c);
printchar(tempCharset, &x, data.word(kMonady), c, 0, NULL, NULL);
data.word(kCurslocx) = x;
data.word(kCurslocy) = data.word(kMonady);
data.word(kMaintimer) = 1;
printcurs();
vsync();
lockmon();
delcurs();
--count;
}
while(count);
x = data.word(kMonadx);
scrollmonitor();
data.word(kCurslocx) = data.word(kMonadx);
}
finishmon:
data.word(kCurslocx) = data.word(kMonadx);
scrollmonitor();
data.byte(kKerning) = 0;
return iterator;
}
} /*namespace dreamgen */

View File

@ -302,4 +302,6 @@
void scrollmonitor();
void showcurrentfile();
void input();
void monprint();
const char *monprint(const char *string);