DREAMWEB: 'printchar' ported to C++

This commit is contained in:
Bertrand Augereau 2011-07-18 22:27:06 +02:00
parent 599fbf4fe6
commit f15661f698
5 changed files with 40 additions and 42 deletions

View File

@ -44,6 +44,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'kernchars',
'getnextword',
'getnumber',
'printchar',
'printdirect',
'worktoscreen',
'width160',

View File

@ -4937,39 +4937,6 @@ realcreditsearly:
data.byte(kLasthardkey) = 0;
}
void DreamGenContext::printchar() {
STACK_CHECK;
_cmp(al, 255);
if (flags.z())
return /* (ignoreit) */;
push(si);
push(bx);
push(di);
_cmp(data.byte(kForeignrelease), 0);
if (flags.z())
goto _tmp1;
_sub(bx, 3);
_tmp1:
push(ax);
_sub(al, 32);
ah = 0;
_add(ax, data.word(kCharshift));
showframe();
ax = pop();
di = pop();
bx = pop();
si = pop();
_cmp(data.byte(kKerning), 0);
if (!flags.z())
goto nokern;
kernchars();
nokern:
push(cx);
ch = 0;
_add(di, cx);
cx = pop();
}
void DreamGenContext::printslow() {
STACK_CHECK;
data.byte(kPointerframe) = 1;
@ -21401,7 +21368,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_mode640x480: mode640x480(); break;
case addr_set16colpalette: set16colpalette(); break;
case addr_realcredits: realcredits(); break;
case addr_printchar: printchar(); break;
case addr_printslow: printslow(); break;
case addr_waitframes: waitframes(); break;
case addr_printboth: printboth(); break;

View File

@ -588,7 +588,6 @@ public:
static const uint16 addr_printboth = 0xc30c;
static const uint16 addr_waitframes = 0xc308;
static const uint16 addr_printslow = 0xc304;
static const uint16 addr_printchar = 0xc2fc;
static const uint16 addr_realcredits = 0xc2f8;
static const uint16 addr_set16colpalette = 0xc2f4;
static const uint16 addr_mode640x480 = 0xc2f0;
@ -1548,7 +1547,7 @@ public:
void showpcx();
void showdecisions();
void checkspeed();
void printchar();
//void printchar();
void showkeypad();
void obtoinv();
void removeobfrominv();

View File

@ -271,6 +271,28 @@ void DreamGenContext::getnextword() {
bh = charCount;
}
void DreamGenContext::printchar() {
uint16 x = di;
printchar(es, ds, &x, bx, al);
di = x;
}
void DreamGenContext::printchar(uint16 dst, uint16 src, uint16* x, uint16 y, uint8 c) {
if (c == 255)
return;
push(si);
push(di);
if (data.byte(kForeignrelease) != 0)
y -= 3;
cx = showframeCPP(dst, src, *x, y, c - 32 + data.word(kCharshift), 0);
di = pop();
si = pop();
_cmp(data.byte(kKerning), 0);
if (flags.z())
kernchars();
(*x) += cl;
}
void DreamGenContext::printdirect() {
data.word(kLastxpos) = di;
ds = data.word(kCurrentset);
@ -278,7 +300,10 @@ void DreamGenContext::printdirect() {
push(bx);
push(di);
push(dx);
uint8 charCount = getnumber(dl, (bool)(dl & 1));
uint16 offset;
uint8 charCount = getnumber(dl, (bool)(dl & 1), &offset);
di = offset;
uint16 x = di;
do {
ax = es.word(si);
++si;
@ -290,8 +315,8 @@ void DreamGenContext::printdirect() {
}
push(es);
al = engine->modifyChar(al);
printchar();
data.word(kLastxpos) = di;
printchar(es, ds, &x, bx, al);
data.word(kLastxpos) = x;
es = pop();
--charCount;
} while(charCount);
@ -303,10 +328,12 @@ void DreamGenContext::printdirect() {
}
void DreamGenContext::getnumber() {
cl = getnumber(dl, (bool)(dl & 1));
uint16 offset = di;
cl = getnumber(dl, (bool)(dl & 1), &offset);
di = offset;
}
uint8 DreamGenContext::getnumber(uint16 maxWidth, bool centered) {
uint8 DreamGenContext::getnumber(uint16 maxWidth, bool centered, uint16* offset) {
uint8 totalWidth = 0;
uint8 charCount = 0;
push(si);
@ -315,6 +342,7 @@ uint8 DreamGenContext::getnumber(uint16 maxWidth, bool centered) {
push(ds);
push(es);
di = si;
*offset = di;
while (true) {
uint8 wordTotalWidth, wordCharCount;
uint8 done = getnextword(&wordTotalWidth, &wordCharCount);
@ -338,6 +366,7 @@ uint8 DreamGenContext::getnumber(uint16 maxWidth, bool centered) {
bx = pop();
si = pop();
_add(di, ax);
*offset = di;
return charCount;
}
ax = totalWidth + wordTotalWidth - 10;
@ -354,6 +383,7 @@ uint8 DreamGenContext::getnumber(uint16 maxWidth, bool centered) {
bx = pop();
si = pop();
_add(di, ax);
*offset = di;
return charCount;
}
totalWidth += wordTotalWidth;

View File

@ -38,9 +38,11 @@
void quickquit2();
void getnextword();
uint8 getnextword(uint8 *totalWidth, uint8 *charCount);
void printchar();
void printchar(uint16 dst, uint16 src, uint16* x, uint16 y, uint8 c);
void printdirect();
void getnumber();
uint8 getnumber(uint16 maxWidth, bool centered);
uint8 getnumber(uint16 maxWidth, bool centered, uint16* offset);
void kernchars();
uint8 kernchars(uint8 firstChar, uint8 secondChar, uint8 width);
Sprite *spritetable();