aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBertrand Augereau2011-11-15 14:12:44 +0100
committerBertrand Augereau2011-11-15 15:50:53 +0100
commit11ae1d594044051a0c6d19bf57dcec14904157b6 (patch)
tree3d9e21e26514355434cc3197bc6ff90d7c58ebfa /engines
parent46ec2c4d732797d300608cc04bf14dd0a699ebe8 (diff)
downloadscummvm-rg350-11ae1d594044051a0c6d19bf57dcec14904157b6.tar.gz
scummvm-rg350-11ae1d594044051a0c6d19bf57dcec14904157b6.tar.bz2
scummvm-rg350-11ae1d594044051a0c6d19bf57dcec14904157b6.zip
DREAMWEB: 'splitintolines' ported to C++
Diffstat (limited to 'engines')
-rw-r--r--engines/dreamweb/dreamgen.cpp57
-rw-r--r--engines/dreamweb/dreamgen.h5
-rw-r--r--engines/dreamweb/sprite.cpp53
-rw-r--r--engines/dreamweb/stubs.h2
4 files changed, 57 insertions, 60 deletions
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index aa1ea88551..f33ee0c8d2 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -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;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 990bba0201..8ff6bbe2fa 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -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();
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index 3c3d148214..7ac3a8a7dc 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -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 */
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index a838c77137..31086d7b20 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -253,4 +253,6 @@
void showwatch();
void roomname();
void transfertext();
+ void splitintolines();
+ Rain *splitintolines(uint8 x, uint8 y, Rain *rain);