diff options
author | Bertrand Augereau | 2011-08-18 10:36:57 +0200 |
---|---|---|
committer | Bertrand Augereau | 2011-08-18 17:11:24 +0200 |
commit | efe76ac494e23f94a7a320fe0f7e31cab8225020 (patch) | |
tree | f9005c1e089fea988b9c12e2702323bdbb80054a /engines | |
parent | f92b21b37719d1d24ec92a2fdaa0959fcc5a8341 (diff) | |
download | scummvm-rg350-efe76ac494e23f94a7a320fe0f7e31cab8225020.tar.gz scummvm-rg350-efe76ac494e23f94a7a320fe0f7e31cab8225020.tar.bz2 scummvm-rg350-efe76ac494e23f94a7a320fe0f7e31cab8225020.zip |
DREAMWEB: 'getposition' ported to C++
Diffstat (limited to 'engines')
-rw-r--r-- | engines/dreamweb/backdrop.cpp | 56 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.cpp | 121 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.h | 11 | ||||
-rw-r--r-- | engines/dreamweb/stubs.h | 4 |
4 files changed, 64 insertions, 128 deletions
diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp index 708a544dc4..be957bf51d 100644 --- a/engines/dreamweb/backdrop.cpp +++ b/engines/dreamweb/backdrop.cpp @@ -172,5 +172,61 @@ void DreamGenContext::showallobs() { } } +void DreamGenContext::getdimension() +{ + uint8 mapXstart, mapYstart; + uint8 mapXsize, mapYsize; + getdimension(&mapXstart, &mapYstart, &mapXsize, &mapYsize); + cl = mapXstart; + ch = mapYstart; + dl = mapXsize; + dh = mapYsize; +} + +bool DreamGenContext::addalong(const uint8 *mapFlags) { + for (size_t i = 0; i < 11; ++i) { + if (mapFlags[3 * i] != 0) + return true; + } + return false; +} + +bool DreamGenContext::addlength(const uint8 *mapFlags) { + for (size_t i = 0; i < 10; ++i) { + if (mapFlags[3 * 11 * i] != 0) + return true; + } + return false; +} + +void DreamGenContext::getdimension(uint8 *mapXstart, uint8 *mapYstart, uint8 *mapXsize, uint8 *mapYsize) { + const uint8 *mapFlags = segRef(data.word(kBuffers)).ptr(kMapflags, 0); + + uint8 yStart = 0; + while (! addalong(mapFlags + 3 * 11 * yStart)) + ++yStart; + + uint8 xStart = 0; + while (! addlength(mapFlags + 3 * xStart)) + ++xStart; + + uint8 yEnd = 10; + while (! addalong(mapFlags + 3 * 11 * (yEnd - 1))) + --yEnd; + + uint8 xEnd = 11; + while (! addlength(mapFlags + 3 * (xEnd - 1))) + --xEnd; + + *mapXstart = xStart; + *mapYstart = yStart; + *mapXsize = xEnd - xStart; + *mapYsize = yEnd - yStart; + data.word(kMapxstart) = xStart << 4; + data.word(kMapystart) = yStart << 4; + data.byte(kMapxsize) = *mapXsize << 4; + data.byte(kMapysize) = *mapYsize << 4; +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 4c69c21278..75794bda0b 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -6428,124 +6428,6 @@ void DreamGenContext::calcmapad() { data.word(kMapady) = ax; } -void DreamGenContext::getdimension() { - STACK_CHECK; - es = data.word(kBuffers); - bx = (0+(228*13)+32+60+(32*32)); - ch = 0; -dimloop1: - addalong(); - _cmp(al, 0); - if (!flags.z()) - goto finishdim1; - _inc(ch); - goto dimloop1; -finishdim1: - bx = (0+(228*13)+32+60+(32*32)); - cl = 0; -dimloop2: - push(bx); - addlength(); - bx = pop(); - _cmp(al, 0); - if (!flags.z()) - goto finishdim2; - _inc(cl); - _add(bx, 3); - goto dimloop2; -finishdim2: - bx = (0+(228*13)+32+60+(32*32))+(11*3*9); - dh = 10; -dimloop3: - push(bx); - addalong(); - bx = pop(); - _cmp(al, 0); - if (!flags.z()) - goto finishdim3; - _dec(dh); - _sub(bx, 11*3); - goto dimloop3; -finishdim3: - bx = (0+(228*13)+32+60+(32*32))+(3*10); - dl = 11; -dimloop4: - push(bx); - addlength(); - bx = pop(); - _cmp(al, 0); - if (!flags.z()) - goto finishdim4; - _dec(dl); - _sub(bx, 3); - goto dimloop4; -finishdim4: - al = cl; - ah = 0; - _shl(ax, 1); - _shl(ax, 1); - _shl(ax, 1); - _shl(ax, 1); - data.word(kMapxstart) = ax; - al = ch; - ah = 0; - _shl(ax, 1); - _shl(ax, 1); - _shl(ax, 1); - _shl(ax, 1); - data.word(kMapystart) = ax; - _sub(dl, cl); - _sub(dh, ch); - al = dl; - ah = 0; - _shl(ax, 1); - _shl(ax, 1); - _shl(ax, 1); - _shl(ax, 1); - data.byte(kMapxsize) = al; - al = dh; - ah = 0; - _shl(ax, 1); - _shl(ax, 1); - _shl(ax, 1); - _shl(ax, 1); - data.byte(kMapysize) = al; -} - -void DreamGenContext::addalong() { - STACK_CHECK; - ah = 11; -addloop: - _cmp(es.byte(bx), 0); - if (!flags.z()) - goto gotalong; - _add(bx, 3); - _dec(ah); - if (!flags.z()) - goto addloop; - al = 0; - return; -gotalong: - al = 1; -} - -void DreamGenContext::addlength() { - STACK_CHECK; - ah = 10; -addloop2: - _cmp(es.byte(bx), 0); - if (!flags.z()) - goto gotlength; - _add(bx, 3*11); - _dec(ah); - if (!flags.z()) - goto addloop2; - al = 0; - return; -gotlength: - al = 1; -} - void DreamGenContext::drawflags() { STACK_CHECK; es = data.word(kBuffers); @@ -18770,9 +18652,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_blockget: blockget(); break; case addr_drawfloor: drawfloor(); break; case addr_calcmapad: calcmapad(); break; - case addr_getdimension: getdimension(); break; - case addr_addalong: addalong(); break; - case addr_addlength: addlength(); break; case addr_drawflags: drawflags(); break; case addr_showallfree: showallfree(); break; case addr_showallex: showallex(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index efa9b42d17..f466504b7a 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -480,9 +480,6 @@ public: static const uint16 addr_showallex = 0xc450; static const uint16 addr_showallfree = 0xc44c; static const uint16 addr_drawflags = 0xc43c; - static const uint16 addr_addlength = 0xc438; - static const uint16 addr_addalong = 0xc434; - static const uint16 addr_getdimension = 0xc430; static const uint16 addr_calcmapad = 0xc42c; static const uint16 addr_drawfloor = 0xc428; static const uint16 addr_blockget = 0xc424; @@ -1365,7 +1362,7 @@ public: //void frameoutv(); void opensarters(); void screenupdate(); - void addlength(); + //void addlength(); void wornerror(); void putundercentre(); void checkobjectsize(); @@ -1820,7 +1817,7 @@ public: //void copyname(); void look(); void setmouse(); - void checkone(); + //void getdimension(); void transferinv(); void candles2(); void pickupob(); @@ -1896,7 +1893,7 @@ public: void grafittidoor(); void input(); void nextdest(); - void getdimension(); + void checkone(); void makecaps(); void read(); void fadescreenups(); @@ -1943,7 +1940,7 @@ public: void usecharset1(); //void makenextblock(); void showpuztext(); - void addalong(); + //void addalong(); //void width160(); void incryanpage(); //void dodoor(); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 710ebf9e6c..adca64f704 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -132,6 +132,10 @@ void madmantext(); void madmode(); void movemap(uint8 param); + bool addalong(const uint8 *mapFlags); + bool addlength(const uint8 *mapFlags); + void getdimension(); + void getdimension(uint8 *mapXstart, uint8 *mapYstart, uint8 *mapXsize, uint8 *mapYsize); void getmapad(); uint8 getmapad(const uint8 *setData); uint8 getxad(const uint8 *setData, uint8 *result); |