aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2011-07-24 17:06:08 -0700
committerEugene Sandulenko2011-07-24 17:06:08 -0700
commit1102c23b5c452b0c9092a9b49bdad5d6acb5d522 (patch)
treea6fedb80ff10860967c1a4cd2a0d766efd17cc5a /engines
parent62862ecb239c23ccd9b41d4e95392f72aacadf0f (diff)
parentcbcdb61b288904658198d086a25153eddd60e5c3 (diff)
downloadscummvm-rg350-1102c23b5c452b0c9092a9b49bdad5d6acb5d522.tar.gz
scummvm-rg350-1102c23b5c452b0c9092a9b49bdad5d6acb5d522.tar.bz2
scummvm-rg350-1102c23b5c452b0c9092a9b49bdad5d6acb5d522.zip
Merge pull request #55 from tramboi/printing
DREAMWEB: Translate printing subsystem
Diffstat (limited to 'engines')
-rw-r--r--engines/dreamweb/dreamgen.cpp401
-rw-r--r--engines/dreamweb/dreamgen.h35
-rw-r--r--engines/dreamweb/stubs.cpp315
-rw-r--r--engines/dreamweb/stubs.h21
4 files changed, 311 insertions, 461 deletions
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 3c10ea69d1..c05cab5238 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -4937,140 +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;
- data.byte(kPointermode) = 3;
- ds = data.word(kCharset1);
-printloopslow6:
- push(bx);
- push(di);
- push(dx);
- getnumber();
- ch = 0;
-printloopslow5:
- push(cx);
- push(si);
- push(es);
- ax = es.word(si);
- push(bx);
- push(cx);
- push(es);
- push(si);
- push(ds);
- modifychar();
- printboth();
- ds = pop();
- si = pop();
- es = pop();
- cx = pop();
- bx = pop();
- ax = es.word(si+1);
- _inc(si);
- _cmp(al, 0);
- if (flags.z())
- goto finishslow;
- _cmp(al, ':');
- if (flags.z())
- goto finishslow;
- _cmp(cl, 1);
- if (flags.z())
- goto afterslow;
- push(di);
- push(ds);
- push(bx);
- push(cx);
- push(es);
- push(si);
- modifychar();
- data.word(kCharshift) = 91;
- printboth();
- data.word(kCharshift) = 0;
- si = pop();
- es = pop();
- cx = pop();
- bx = pop();
- ds = pop();
- di = pop();
- waitframes();
- _cmp(ax, 0);
- if (flags.z())
- goto keepgoing;
- _cmp(ax, data.word(kOldbutton));
- if (!flags.z())
- goto finishslow2;
-keepgoing:
- waitframes();
- _cmp(ax, 0);
- if (flags.z())
- goto afterslow;
- _cmp(ax, data.word(kOldbutton));
- if (!flags.z())
- goto finishslow2;
-afterslow:
- es = pop();
- si = pop();
- cx = pop();
- _inc(si);
- if (--cx)
- goto printloopslow5;
- dx = pop();
- di = pop();
- bx = pop();
- _add(bx, 10);
- goto printloopslow6;
-finishslow:
- es = pop();
- si = pop();
- cx = pop();
- dx = pop();
- di = pop();
- bx = pop();
- al = 0;
- return;
-finishslow2:
- es = pop();
- si = pop();
- cx = pop();
- dx = pop();
- di = pop();
- bx = pop();
- al = 1;
-}
-
void DreamGenContext::waitframes() {
STACK_CHECK;
push(di);
@@ -5091,62 +4957,6 @@ void DreamGenContext::waitframes() {
di = pop();
}
-void DreamGenContext::printboth() {
- STACK_CHECK;
- push(ax);
- push(cx);
- push(bx);
- push(di);
- printchar();
- ax = pop();
- push(di);
- di = ax;
- multidump();
- di = pop();
- bx = pop();
- cx = pop();
- ax = pop();
-}
-
-void DreamGenContext::printdirect() {
- STACK_CHECK;
- data.word(kLastxpos) = di;
- ds = data.word(kCurrentset);
-printloop6:
- push(bx);
- push(di);
- push(dx);
- getnumber();
- ch = 0;
-printloop5:
- ax = es.word(si);
- _inc(si);
- _cmp(al, 0);
- if (flags.z())
- goto finishdirct;
- _cmp(al, ':');
- if (flags.z())
- goto finishdirct;
- push(cx);
- push(es);
- modifychar();
- printchar();
- data.word(kLastxpos) = di;
- es = pop();
- cx = pop();
- if (--cx)
- goto printloop5;
- dx = pop();
- di = pop();
- bx = pop();
- _add(bx, data.word(kLinespacing));
- goto printloop6;
-finishdirct:
- dx = pop();
- di = pop();
- bx = pop();
-}
-
void DreamGenContext::monprint() {
STACK_CHECK;
data.byte(kKerning) = 1;
@@ -5233,114 +5043,6 @@ nottrigger2:
data.byte(kKerning) = 0;
}
-void DreamGenContext::getnumber() {
- STACK_CHECK;
- cx = 0;
- push(si);
- push(bx);
- push(di);
- push(ds);
- push(es);
- di = si;
-wordloop:
- push(cx);
- push(dx);
- getnextword();
- dx = pop();
- cx = pop();
- _cmp(al, 1);
- if (flags.z())
- goto endoftext;
- al = cl;
- ah = 0;
- push(bx);
- bh = 0;
- _add(ax, bx);
- bx = pop();
- _sub(ax, 10);
- dh = 0;
- _cmp(ax, dx);
- if (!flags.c())
- goto gotoverend;
- _add(cl, bl);
- _add(ch, bh);
- goto wordloop;
-gotoverend:
- al = dl;
- _and(al, 1);
- if (flags.z())
- goto notcentre;
- push(cx);
- al = dl;
- _and(al, 0xfe);
- ah = 0;
- ch = 0;
- _sub(ax, cx);
- _add(ax, 20);
- _shr(ax, 1);
- cx = pop();
- es = pop();
- ds = pop();
- di = pop();
- bx = pop();
- si = pop();
- _add(di, ax);
- cl = ch;
- return;
-notcentre:
- es = pop();
- ds = pop();
- di = pop();
- bx = pop();
- si = pop();
- cl = ch;
- return;
-endoftext:
- al = cl;
- ah = 0;
- push(bx);
- bh = 0;
- _add(ax, bx);
- bx = pop();
- _sub(ax, 10);
- dh = 0;
- _cmp(ax, dx);
- if (!flags.c())
- goto gotoverend2;
- _add(cl, bl);
- _add(ch, bh);
-gotoverend2:
- al = dl;
- _and(al, 1);
- if (flags.z())
- goto notcent2;
- push(cx);
- al = dl;
- _and(al, 0xfe);
- _add(al, 2);
- ah = 0;
- ch = 0;
- _add(ax, 20);
- _sub(ax, cx);
- _shr(ax, 1);
- cx = pop();
- es = pop();
- ds = pop();
- di = pop();
- bx = pop();
- si = pop();
- _add(di, ax);
- cl = ch;
- return;
-notcent2:
- es = pop();
- ds = pop();
- di = pop();
- bx = pop();
- si = pop();
- cl = ch;
-}
-
void DreamGenContext::fillryan() {
STACK_CHECK;
es = data.word(kBuffers);
@@ -13151,46 +12853,6 @@ notonsartroof:
placesetobject();
}
-void DreamGenContext::getundertimed() {
- STACK_CHECK;
- al = data.byte(kTimedy);
- _cmp(data.byte(kForeignrelease), 0);
- if (flags.z())
- goto _tmp1;
- _sub(al, 3);
-_tmp1:
- ah = 0;
- bx = ax;
- al = data.byte(kTimedx);
- ah = 0;
- di = ax;
- ch = (30);
- cl = 240;
- ds = data.word(kBuffers);
- si = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40)+(5*80)+(250*4));
- multiget();
-}
-
-void DreamGenContext::putundertimed() {
- STACK_CHECK;
- al = data.byte(kTimedy);
- _cmp(data.byte(kForeignrelease), 0);
- if (flags.z())
- goto _tmp1;
- _sub(al, 3);
-_tmp1:
- ah = 0;
- bx = ax;
- al = data.byte(kTimedx);
- ah = 0;
- di = ax;
- ch = (30);
- cl = 240;
- ds = data.word(kBuffers);
- si = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40)+(5*80)+(250*4));
- multiput();
-}
-
void DreamGenContext::dumptimedtext() {
STACK_CHECK;
_cmp(data.byte(kNeedtodumptimed), 1);
@@ -13287,42 +12949,6 @@ notloadspeech3:
data.word(kTimedoffset) = bx;
}
-void DreamGenContext::usetimedtext() {
- STACK_CHECK;
- _cmp(data.word(kTimecount), 0);
- if (flags.z())
- return /* (notext) */;
- _dec(data.word(kTimecount));
- _cmp(data.word(kTimecount), 0);
- if (flags.z())
- goto deltimedtext;
- ax = data.word(kTimecount);
- _cmp(ax, data.word(kCounttotimed));
- if (flags.z())
- goto firsttimed;
- if (!flags.c())
- return /* (notext) */;
- goto notfirsttimed;
-firsttimed:
- getundertimed();
-notfirsttimed:
- bl = data.byte(kTimedy);
- bh = 0;
- al = data.byte(kTimedx);
- ah = 0;
- di = ax;
- es = data.word(kTimedseg);
- si = data.word(kTimedoffset);
- dl = 237;
- ah = 0;
- printdirect();
- data.byte(kNeedtodumptimed) = 1;
- return;
-deltimedtext:
- putundertimed();
- data.byte(kNeedtodumptimed) = 1;
-}
-
void DreamGenContext::edenscdplayer() {
STACK_CHECK;
showfirstuse();
@@ -19836,24 +19462,6 @@ _tmp1:
multiput();
}
-void DreamGenContext::dumptextline() {
- STACK_CHECK;
- _cmp(data.byte(kNewtextline), 1);
- if (!flags.z())
- return /* (nodumptextline) */;
- data.byte(kNewtextline) = 0;
- di = data.word(kTextaddressx);
- bx = data.word(kTextaddressy);
- _cmp(data.byte(kForeignrelease), 0);
- if (flags.z())
- goto _tmp1;
- _sub(bx, 3);
-_tmp1:
- cl = (228);
- ch = (13);
- multidump();
-}
-
void DreamGenContext::animpointer() {
STACK_CHECK;
_cmp(data.byte(kPointermode), 2);
@@ -21548,13 +21156,8 @@ 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;
- case addr_printdirect: printdirect(); break;
case addr_monprint: monprint(); break;
- case addr_getnumber: getnumber(); break;
case addr_fillryan: fillryan(); break;
case addr_fillopen: fillopen(); break;
case addr_findallryan: findallryan(); break;
@@ -21805,12 +21408,9 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_setallchanges: setallchanges(); break;
case addr_dochange: dochange(); break;
case addr_autoappear: autoappear(); break;
- case addr_getundertimed: getundertimed(); break;
- case addr_putundertimed: putundertimed(); break;
case addr_dumptimedtext: dumptimedtext(); break;
case addr_setuptimeduse: setuptimeduse(); break;
case addr_setuptimedtemp: setuptimedtemp(); break;
- case addr_usetimedtext: usetimedtext(); break;
case addr_edenscdplayer: edenscdplayer(); break;
case addr_usewall: usewall(); break;
case addr_usechurchgate: usechurchgate(); break;
@@ -22044,7 +21644,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_dumppointer: dumppointer(); break;
case addr_undertextline: undertextline(); break;
case addr_deltextline: deltextline(); break;
- case addr_dumptextline: dumptextline(); break;
case addr_animpointer: animpointer(); break;
case addr_setmouse: setmouse(); break;
case addr_readmouse: readmouse(); break;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 88ecfd53d4..c2aa204942 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -92,7 +92,6 @@ public:
static const uint16 addr_readmouse = 0xcae4;
static const uint16 addr_setmouse = 0xcae0;
static const uint16 addr_animpointer = 0xcadc;
- static const uint16 addr_dumptextline = 0xcad8;
static const uint16 addr_deltextline = 0xcad4;
static const uint16 addr_undertextline = 0xcad0;
static const uint16 addr_dumppointer = 0xcacc;
@@ -328,12 +327,9 @@ public:
static const uint16 addr_usechurchgate = 0xc730;
static const uint16 addr_usewall = 0xc72c;
static const uint16 addr_edenscdplayer = 0xc728;
- static const uint16 addr_usetimedtext = 0xc724;
static const uint16 addr_setuptimedtemp = 0xc720;
static const uint16 addr_setuptimeduse = 0xc71c;
static const uint16 addr_dumptimedtext = 0xc718;
- static const uint16 addr_putundertimed = 0xc714;
- static const uint16 addr_getundertimed = 0xc710;
static const uint16 addr_autoappear = 0xc70c;
static const uint16 addr_dochange = 0xc708;
static const uint16 addr_setallchanges = 0xc704;
@@ -584,13 +580,8 @@ public:
static const uint16 addr_findallryan = 0xc328;
static const uint16 addr_fillopen = 0xc324;
static const uint16 addr_fillryan = 0xc320;
- static const uint16 addr_getnumber = 0xc318;
static const uint16 addr_monprint = 0xc314;
- static const uint16 addr_printdirect = 0xc310;
- 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;
@@ -1347,8 +1338,9 @@ public:
void clearbuffers();
void neterror();
void storeit();
+ void lockeddoorway();
void isitworn();
- void putundertimed();
+ //void putundertimed();
void dumpmap();
//void multidump();
void channel0only();
@@ -1374,7 +1366,7 @@ public:
void restoreall();
void screenupdate();
void addlength();
- void usetimedtext();
+ void wornerror();
void putundercentre();
void checkobjectsize();
void commandonly();
@@ -1488,7 +1480,7 @@ public:
void turnonpower();
void manasleep2();
void moretalk();
- void printslow();
+ //void printslow();
void loadroom();
void starttalk();
void delchar();
@@ -1520,9 +1512,10 @@ public:
void openpoolboss();
void buttontwo();
void fillopen();
+ //void usetimedtext();
void delsprite();
void getroomspaths();
- void dumptextline();
+ //void dumptextline();
void fadescreendownhalf();
void useplate();
void candles1();
@@ -1535,7 +1528,7 @@ public:
//void printsprites();
void checkifperson();
void showallobs();
- void getnumber();
+ //void getnumber();
void adjustleft();
void calledenslift();
void useclearbox();
@@ -1550,7 +1543,7 @@ public:
void showpcx();
void showdecisions();
void checkspeed();
- void printchar();
+ //void printchar();
void showkeypad();
void obtoinv();
void removeobfrominv();
@@ -1567,7 +1560,7 @@ public:
//void spriteupdate();
void usetempcharset();
void discops();
- void printdirect();
+ //void printdirect();
void delthisone();
void makebackob();
void middlepanel();
@@ -1575,7 +1568,6 @@ public:
void saveload();
void monitorlogo();
void loadposition();
- void wornerror();
void entersymbol();
void showword();
void dirfile();
@@ -1702,8 +1694,9 @@ public:
void showmonk();
void diarykeyn();
void set16colpalette();
- void sparky();
+ void convicons();
void interviewer();
+ void sparky();
void purgeanitem();
void madman();
void createpanel();
@@ -1795,7 +1788,7 @@ public:
void findsetobject();
void singlekey();
//void seecommandtail();
- void getundertimed();
+ //void getundertimed();
void hangone();
void carparkdrip();
void usediary();
@@ -1890,7 +1883,7 @@ public:
void turnanypathon();
void restorereels();
void setwalk();
- void printboth();
+ //void printboth();
void useroutine();
void zoomicon();
void hotelcontrol();
@@ -1999,14 +1992,12 @@ public:
void usechurchgate();
void monkandryan();
void allocatebuffers();
- void convicons();
void swapwithinv();
void usecontrol();
void buttonseven();
void redrawmainscrn();
void finishedwalking();
void findallryan();
- void lockeddoorway();
void channel0tran();
void buttonpress();
void parseblaster();
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index cd5350823a..ec94ffc40c 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -36,8 +36,10 @@ Common::String getFilename(Context &context) {
}
void DreamGenContext::multiget() {
- unsigned w = (uint8)cl, h = (uint8)ch;
- unsigned x = (uint16)di, y = (uint16)bx;
+ multiget(di, bx, cl, ch);
+}
+
+void DreamGenContext::multiget(uint16 x, uint16 y, uint8 w, uint8 h) {
unsigned src = x + y * kScreenwidth;
unsigned dst = (uint16)si;
es = ds;
@@ -58,8 +60,10 @@ void DreamGenContext::multiget() {
}
void DreamGenContext::multiput() {
- unsigned w = (uint8)cl, h = (uint8)ch;
- unsigned x = (uint16)di, y = (uint16)bx;
+ multiput(di, bx, cl, ch);
+}
+
+void DreamGenContext::multiput(uint16 x, uint16 y, uint8 w, uint8 h) {
unsigned src = (uint16)si;
unsigned dst = x + y * kScreenwidth;
es = data.word(kWorkspace);
@@ -78,14 +82,17 @@ void DreamGenContext::multiput() {
cx = 0;
}
-void DreamGenContext::multidump() {
+void DreamGenContext::multidump(uint16 x, uint16 y, uint8 width, uint8 height) {
ds = data.word(kWorkspace);
- int w = (uint8)cl, h = (uint8)ch;
- int x = (int16)di, y = (int16)bx;
unsigned offset = x + y * kScreenwidth;
//debug(1, "multidump %ux%u(segment: %04x) -> %d,%d(address: %d)", w, h, (uint16)ds, x, y, offset);
- engine->blit(ds.ptr(offset, w * h), kScreenwidth, x, y, w, h);
- si = di = offset + h * kScreenwidth;
+ engine->blit(ds.ptr(offset, width * height), kScreenwidth, x, y, width, height);
+}
+
+void DreamGenContext::multidump() {
+ multidump(di, bx, cl, ch);
+ unsigned offset = di + bx * kScreenwidth;
+ si = di = offset + ch * kScreenwidth;
cx = 0;
}
@@ -239,12 +246,26 @@ void DreamGenContext::setmouse() {
data.word(kOldpointerx) = 0xffff;
}
-uint8 DreamGenContext::getnextword(uint8 *totalWidth, uint8 *charCount) {
+void DreamGenContext::printboth() {
+ uint16 x = di;
+ printboth(es, ds, &x, bx, al);
+ di = x;
+}
+
+void DreamGenContext::printboth(uint16 dst, uint16 src, uint16 *x, uint16 y, uint8 c) {
+ uint16 newX = *x;
+ uint8 width, height;
+ printchar(dst, src, &newX, y, c, &width, &height);
+ multidump(*x, y, width, height);
+ *x = newX;
+}
+
+uint8 DreamGenContext::getnextword(const uint8 *string, uint8 *totalWidth, uint8 *charCount) {
*totalWidth = 0;
*charCount = 0;
while(true) {
- uint8 firstChar = es.byte(di);
- ++di;
+ uint8 firstChar = *string;
+ ++string;
++*charCount;
if ((firstChar == ':') || (firstChar == 0)) { //endall
*totalWidth += 6;
@@ -256,7 +277,7 @@ uint8 DreamGenContext::getnextword(uint8 *totalWidth, uint8 *charCount) {
}
firstChar = engine->modifyChar(firstChar);
if (firstChar != 255) {
- uint8 secondChar = es.byte(di);
+ uint8 secondChar = *string;
uint8 width = ds.byte(6*(firstChar - 32 + data.word(kCharshift)));
width = kernchars(firstChar, secondChar, width);
*totalWidth += width;
@@ -266,9 +287,222 @@ uint8 DreamGenContext::getnextword(uint8 *totalWidth, uint8 *charCount) {
void DreamGenContext::getnextword() {
uint8 totalWidth, charCount;
- al = getnextword(&totalWidth, &charCount);
+ al = getnextword(es.ptr(di, 0), &totalWidth, &charCount);
bl = totalWidth;
- bh = charCount;
+ bh = charCount;
+ di += charCount;
+}
+
+void DreamGenContext::printchar() {
+ uint16 x = di;
+ uint8 width, height;
+ printchar(es, ds, &x, bx, al, &width, &height);
+ di = x;
+ cl = width;
+ ch = height;
+}
+
+void DreamGenContext::printchar(uint16 dst, uint16 src, uint16* x, uint16 y, uint8 c, uint8 *width, uint8 *height) {
+ if (c == 255)
+ return;
+ push(si);
+ push(di);
+ if (data.byte(kForeignrelease) != 0)
+ y -= 3;
+ showframe(dst, src, *x, y, c - 32 + data.word(kCharshift), 0, width, height);
+ di = pop();
+ si = pop();
+ _cmp(data.byte(kKerning), 0);
+ if (flags.z())
+ kernchars();
+ (*x) += *width;
+}
+
+void DreamGenContext::printslow() {
+ al = printslow(di, bx, dl, (bool)(dl & 1));
+}
+
+void DreamGenContext::dumptextline() {
+ if (data.byte(kNewtextline) != 1)
+ return;
+ data.byte(kNewtextline) = 0;
+ uint16 x = data.word(kTextaddressx);
+ uint16 y = data.word(kTextaddressy);
+ if (data.byte(kForeignrelease) != 0)
+ y -= 3;
+ multidump(x, y, 228, 13);
+}
+
+uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool centered) {
+ data.byte(kPointerframe) = 1;
+ data.byte(kPointermode) = 3;
+ ds = data.word(kCharset1);
+ do {
+ uint16 offset = x;
+ uint16 charCount = getnumber(si, maxWidth, centered, &offset);
+ do {
+ push(si);
+ push(es);
+ uint8 c0 = es.byte(si);
+ push(es);
+ push(ds);
+ c0 = engine->modifyChar(c0);
+ printboth(es, ds, &offset, y, c0);
+ ds = pop();
+ es = pop();
+ uint8 c1 = es.byte(si+1);
+ ++si;
+ if ((c1 == 0) || (c1 == ':')) {
+ es = pop();
+ si = pop();
+ return 0;
+ }
+ if (charCount != 1) {
+ push(ds);
+ push(es);
+ c1 = engine->modifyChar(c1);
+ data.word(kCharshift) = 91;
+ uint16 offset2 = offset;
+ printboth(es, ds, &offset2, y, c1);
+ data.word(kCharshift) = 0;
+ es = pop();
+ ds = pop();
+ for (int i=0; i<2; ++i) {
+ waitframes();
+ if (ax == 0)
+ continue;
+ if (ax != data.word(kOldbutton)) {
+ es = pop();
+ si = pop();
+ return 1;
+ }
+ }
+ }
+
+ es = pop();
+ si = pop();
+ ++si;
+ --charCount;
+ } while (charCount);
+ y += 10;
+ } while (true);
+}
+
+void DreamGenContext::printdirect() {
+ uint16 y = bx;
+ printdirect(di, &y, dl, (bool)(dl & 1));
+ bx = y;
+}
+
+void DreamGenContext::printdirect(uint16 x, uint16 *y, uint8 maxWidth, bool centered) {
+ data.word(kLastxpos) = x;
+ ds = data.word(kCurrentset);
+ while (true) {
+ uint16 offset = x;
+ uint8 charCount = getnumber(si, maxWidth, centered, &offset);
+ uint16 i = offset;
+ do {
+ uint8 c = es.byte(si);
+ ++si;
+ if ((c == 0) || (c == ':')) {
+ return;
+ }
+ c = engine->modifyChar(c);
+ uint8 width, height;
+ push(es);
+ printchar(es, ds, &i, *y, c, &width, &height);
+ es = pop();
+ data.word(kLastxpos) = i;
+ --charCount;
+ } while(charCount);
+ *y += data.word(kLinespacing);
+ }
+}
+
+void DreamGenContext::getundertimed() {
+ uint16 y = data.byte(kTimedy);
+ if (data.byte(kForeignrelease))
+ y -= 3;
+ ds = data.word(kBuffers);
+ si = kUndertimedtext;
+ multiget(data.byte(kTimedx), y, 240, kUndertimedysize);
+}
+
+void DreamGenContext::putundertimed() {
+ uint16 y = data.byte(kTimedy);
+ if (data.byte(kForeignrelease))
+ y -= 3;
+ ds = data.word(kBuffers);
+ si = kUndertimedtext;
+ multiput(data.byte(kTimedx), y, 240, kUndertimedysize);
+}
+
+void DreamGenContext::usetimedtext() {
+ if (data.word(kTimecount) == 0)
+ return;
+ --data.word(kTimecount);
+ if (data.word(kTimecount) == 0) {
+ putundertimed();
+ data.byte(kNeedtodumptimed) = 1;
+ return;
+ }
+
+ if (data.word(kTimecount) == data.word(kCounttotimed))
+ getundertimed();
+ else if (data.word(kTimecount) > data.word(kCounttotimed))
+ return;
+
+ es = data.word(kTimedseg);
+ si = data.word(kTimedoffset);
+ uint16 y = data.byte(kTimedy);
+ printdirect(data.byte(kTimedx), &y, 237, true);
+ data.byte(kNeedtodumptimed) = 1;
+}
+
+void DreamGenContext::getnumber() {
+ uint16 offset = di;
+ cl = getnumber(si, dl, (bool)(dl & 1), &offset);
+ di = offset;
+}
+
+uint8 DreamGenContext::getnumber(uint16 index, uint16 maxWidth, bool centered, uint16* offset) {
+ uint8 totalWidth = 0;
+ uint8 charCount = 0;
+ while (true) {
+ uint8 wordTotalWidth, wordCharCount;
+ uint8 done = getnextword(es.ptr(index, 0), &wordTotalWidth, &wordCharCount);
+ index += wordCharCount;
+
+ if (done == 1) { //endoftext
+ ax = totalWidth + wordTotalWidth - 10;
+ if (ax < maxWidth) {
+ totalWidth += wordTotalWidth;
+ charCount += wordCharCount;
+ }
+
+ if (centered) {
+ ax = (maxWidth & 0xfe) + 2 + 20 - totalWidth;
+ ax /= 2;
+ } else {
+ ax = 0;
+ }
+ *offset += ax;
+ return charCount;
+ }
+ ax = totalWidth + wordTotalWidth - 10;
+ if (ax >= maxWidth) { //gotoverend
+ if (centered) {
+ ax = (maxWidth & 0xfe) - totalWidth + 20;
+ ax /= 2;
+ } else {
+ ax = 0;
+ }
+ *offset += ax;
+ return charCount;
+ }
+ totalWidth += wordTotalWidth;
+ charCount += wordCharCount;
+ }
}
uint8 DreamGenContext::kernchars(uint8 firstChar, uint8 secondChar, uint8 width) {
@@ -677,7 +911,7 @@ Sprite *DreamGenContext::spritetable() {
return sprite;
}
-uint16 DreamGenContext::showframeCPP(uint16 dst, uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag) {
+void DreamGenContext::showframe(uint16 dst, uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) {
es = dst;
ds = src;
di = x;
@@ -687,7 +921,9 @@ uint16 DreamGenContext::showframeCPP(uint16 dst, uint16 src, uint16 x, uint16 y,
si = (ax & 0x1ff) * 6;
if (ds.word(si) == 0) {
- return 0;
+ *width = 0;
+ *height = 0;
+ return;
}
//notblankshow:
@@ -697,19 +933,18 @@ uint16 DreamGenContext::showframeCPP(uint16 dst, uint16 src, uint16 x, uint16 y,
}
//skipoffsets:
cx = ds.word(si + 0);
- uint8 width = cl;
- uint8 height = ch;
- uint16 written = cx;
+ *width = cl;
+ *height = ch;
si = ds.word(si+2) + 2080;
if (effectsFlag) {
if (effectsFlag & 128) { //centred
- di -= width / 2;
- bx -= height / 2;
+ di -= *width / 2;
+ bx -= *height / 2;
}
if (effectsFlag & 64) { //diffdest
- frameoutfx(es.ptr(0, dx * height), ds.ptr(si, width * height), dx, width, height, di, bx);
- return written;
+ frameoutfx(es.ptr(0, dx * *height), ds.ptr(si, *width * *height), dx, *width, *height, di, bx);
+ return;
}
if (effectsFlag & 8) { //printlist
push(ax);
@@ -723,28 +958,31 @@ uint16 DreamGenContext::showframeCPP(uint16 dst, uint16 src, uint16 x, uint16 y,
}
if (effectsFlag & 4) { //flippedx
es = data.word(kWorkspace);
- frameoutfx(es.ptr(0, 320 * height), ds.ptr(si, width * height), 320, width, height, di, bx);
- return written;
+ frameoutfx(es.ptr(0, 320 * *height), ds.ptr(si, *width * *height), 320, *width, *height, di, bx);
+ return;
}
if (effectsFlag & 2) { //nomask
es = data.word(kWorkspace);
- frameoutnm(es.ptr(0, 320 * height), ds.ptr(si, width * height), 320, width, height, di, bx);
- return written;
+ frameoutnm(es.ptr(0, 320 * *height), ds.ptr(si, *width * *height), 320, *width, *height, di, bx);
+ return;
}
if (effectsFlag & 32) {
es = data.word(kWorkspace);
- frameoutbh(es.ptr(0, 320 * height), ds.ptr(si, width * height), 320, width, height, di, bx);
- return written;
+ frameoutbh(es.ptr(0, 320 * *height), ds.ptr(si, *width * *height), 320, *width, *height, di, bx);
+ return;
}
}
//noeffects:
es = data.word(kWorkspace);
- frameoutv(es.ptr(0, 65536), ds.ptr(si, width * height), 320, width, height, di, bx);
- return written;
+ frameoutv(es.ptr(0, 65536), ds.ptr(si, *width * *height), 320, *width, *height, di, bx);
+ return;
}
void DreamGenContext::showframe() {
- cx = showframeCPP(es, ds, di, bx, al, ah);
+ uint8 width, height;
+ showframe(es, ds, di, bx, al, ah, &width, &height);
+ cl = width;
+ ch = height;
}
void DreamGenContext::printsprites() {
@@ -781,10 +1019,15 @@ void DreamGenContext::printasprite(const Sprite *sprite) {
di = ax + data.word(kMapadx);
}
- ax = sprite->b15;
+ uint8 c;
if (sprite->b29 != 0)
- ah = 8;
- showframe();
+ c = 8;
+ else
+ c = 0;
+ uint8 width, height;
+ showframe(es, ds, di, bx, sprite->b15, c, &width, &height);
+ cl = width;
+ ch = height;
bx = pop();
es = pop();
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 6d9c08dd2d..20d987d374 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -21,12 +21,14 @@
*/
void multidump();
+ void multidump(uint16 x, uint16 y, uint8 width, uint8 height);
void frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
void frameoutnm(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
void frameoutbh(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
void frameoutfx(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
void worktoscreen();
void multiget();
+ void multiget(uint16 x, uint16 y, uint8 width, uint8 height);
void convertkey();
void cls();
void printsprites();
@@ -37,14 +39,29 @@
void randomnumber();
void quickquit2();
void getnextword();
- uint8 getnextword(uint8 *totalWidth, uint8 *charCount);
+ uint8 getnextword(const uint8 *string, uint8 *totalWidth, uint8 *charCount);
+ void printboth();
+ void printboth(uint16 dst, uint16 src, uint16 *x, uint16 y, uint8 c);
+ void printchar();
+ void printchar(uint16 dst, uint16 src, uint16 *x, uint16 y, uint8 c, uint8 *width, uint8 *height);
+ void printdirect();
+ void printdirect(uint16 x, uint16 *y, uint8 maxWidth, bool centered);
+ void usetimedtext();
+ void getundertimed();
+ void putundertimed();
+ uint8 printslow(uint16 x, uint16 y, uint8 maxWidth, bool centered);
+ void printslow();
+ void dumptextline();
+ void getnumber();
+ uint8 getnumber(uint16 index, uint16 maxWidth, bool centered, uint16* offset);
void kernchars();
uint8 kernchars(uint8 firstChar, uint8 secondChar, uint8 width);
Sprite *spritetable();
void showframe();
- uint16 showframeCPP(uint16 dst, uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag);
+ void showframe(uint16 dst, uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height);
void printasprite(const Sprite *sprite);
void width160();
+ void multiput(uint16 x, uint16 y, uint8 width, uint8 height);
void multiput();
void eraseoldobs();
void clearsprites();