DREAMWEB: 'splitintolines' ported to C++

This commit is contained in:
Bertrand Augereau 2011-11-15 14:12:44 +01:00
parent 46ec2c4d73
commit 11ae1d5940
5 changed files with 58 additions and 60 deletions

View File

@ -209,6 +209,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'showwatch',
'roomname',
'transfertext',
'splitintolines',
], skip_output = [
# These functions are processed but not output
'dreamweb',

View File

@ -2329,62 +2329,6 @@ finishinitrain:
_stosb();
}
void DreamGenContext::splitintolines() {
STACK_CHECK;
lookforlinestart:
getblockofpixel();
_cmp(al, 0);
if (!flags.z())
goto foundlinestart;
_dec(cl);
_inc(ch);
_cmp(cl, 0);
if (flags.z())
return /* (endofthisline) */;
_cmp(ch, data.byte(kMapysize));
if (!flags.c())
return /* (endofthisline) */;
goto lookforlinestart;
foundlinestart:
es.word(di) = cx;
bh = 1;
lookforlineend:
getblockofpixel();
_cmp(al, 0);
if (flags.z())
goto foundlineend;
_dec(cl);
_inc(ch);
_cmp(cl, 0);
if (flags.z())
goto foundlineend;
_cmp(ch, data.byte(kMapysize));
if (!flags.c())
goto foundlineend;
_inc(bh);
goto lookforlineend;
foundlineend:
push(cx);
es.byte(di+2) = bh;
randomnumber();
es.byte(di+3) = al;
randomnumber();
es.byte(di+4) = al;
randomnumber();
_and(al, 3);
_add(al, 4);
es.byte(di+5) = al;
_add(di, 6);
cx = pop();
_cmp(cl, 0);
if (flags.z())
return /* (endofthisline) */;
_cmp(ch, data.byte(kMapysize));
if (!flags.c())
return /* (endofthisline) */;
goto lookforlinestart;
}
void DreamGenContext::liftnoise() {
STACK_CHECK;
_cmp(data.byte(kReallocation), 5);
@ -16342,7 +16286,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_adjustright: adjustright(); break;
case addr_reminders: reminders(); break;
case addr_initrain: initrain(); break;
case addr_splitintolines: splitintolines(); break;
case addr_backobject: backobject(); break;
case addr_liftnoise: liftnoise(); break;
case addr_random: random(); break;

View File

@ -541,7 +541,6 @@ public:
static const uint16 addr_random = 0xc17c;
static const uint16 addr_liftnoise = 0xc178;
static const uint16 addr_backobject = 0xc170;
static const uint16 addr_splitintolines = 0xc164;
static const uint16 addr_initrain = 0xc160;
static const uint16 addr_reminders = 0xc15c;
static const uint16 addr_adjustright = 0xc158;
@ -1360,7 +1359,7 @@ public:
void watchcount();
void fadedownmon();
void loadcart();
//void calcfrframe();
//void splitintolines();
void bartender();
void eden();
void showdiary();
@ -1882,7 +1881,7 @@ public:
void closefile();
void delcurs();
void randomaccess();
void splitintolines();
//void calcfrframe();
//void checkifex();
//void findobname();
void initialmoncols();

View File

@ -890,5 +890,58 @@ void DreamGenContext::addtopeoplelist(ReelRoutine *routine) {
data.word(kListpos) += sizeof(People);
}
void DreamGenContext::splitintolines() {
uint8 x = cl;
uint8 y = ch;
Rain *rain = (Rain *)es.ptr(di, 0);
Rain *newRain = splitintolines(x, y, rain);
di += (newRain - rain) * sizeof(Rain);
}
Rain *DreamGenContext::splitintolines(uint8 x, uint8 y, Rain *rain) {
do {
// Look for line start
do {
if (getblockofpixel(x, y))
break;
--x;
++y;
if (x == 0)
return rain;
if (y >= data.byte(kMapysize))
return rain;
} while (true);
rain->x = x;
rain->y = y;
uint8 length = 1;
// Look for line end
do {
if (! getblockofpixel(x, y))
break;
--x;
++y;
if (x == 0)
break;
if (y >= data.byte(kMapysize))
break;
++length;
} while (true);
rain->size = length;
rain->w3_lo = engine->randomNumber();
rain->w3_hi = engine->randomNumber();
rain->b5 = (engine->randomNumber() & 3) + 4;
++rain;
if (x == 0)
return rain;
if (y >= data.byte(kMapysize))
return rain;
} while (true);
return rain;
}
} /*namespace dreamgen */

View File

@ -253,4 +253,6 @@
void showwatch();
void roomname();
void transfertext();
void splitintolines();
Rain *splitintolines(uint8 x, uint8 y, Rain *rain);