diff options
author | Bertrand Augereau | 2011-09-18 15:33:24 +0200 |
---|---|---|
committer | Bertrand Augereau | 2011-09-18 19:30:45 +0200 |
commit | b76b038ffc8173942927dd9be42dc731573ee3ed (patch) | |
tree | 346d74df3094ea53f9bdcf357e2b413c78c0aef5 | |
parent | a1825e4d02b179233d0f8074e5c38136959a9eeb (diff) | |
download | scummvm-rg350-b76b038ffc8173942927dd9be42dc731573ee3ed.tar.gz scummvm-rg350-b76b038ffc8173942927dd9be42dc731573ee3ed.tar.bz2 scummvm-rg350-b76b038ffc8173942927dd9be42dc731573ee3ed.zip |
DREAMWEB: 'bresenhams' ported to C++
-rwxr-xr-x | devtools/tasmrecover/tasm-recover | 1 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.cpp | 129 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.h | 5 | ||||
-rw-r--r-- | engines/dreamweb/pathfind.cpp | 120 | ||||
-rw-r--r-- | engines/dreamweb/stubs.h | 2 |
5 files changed, 125 insertions, 132 deletions
diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index e8921055e4..f41fb5f87b 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -197,6 +197,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'hangonp', 'findnextcolon', 'usetext', + 'bresenhams', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 1bcb34c211..4ef2255949 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -14731,134 +14731,6 @@ holdingreel: data.byte(kWatchmode) = 2; } -void DreamGenContext::bresenhams() { - STACK_CHECK; - workoutframes(); - dx = data; - es = dx; - di = 8173; - si = 1; - data.byte(kLinedirection) = 0; - cx = data.word(kLineendx); - _sub(cx, data.word(kLinestartx)); - if (flags.z()) - goto vertline; - if (!flags.s()) - goto line1; - _neg(cx); - bx = data.word(kLineendx); - _xchg(bx, data.word(kLinestartx)); - data.word(kLineendx) = bx; - bx = data.word(kLineendy); - _xchg(bx, data.word(kLinestarty)); - data.word(kLineendy) = bx; - data.byte(kLinedirection) = 1; -line1: - bx = data.word(kLineendy); - _sub(bx, data.word(kLinestarty)); - if (flags.z()) - goto horizline; - if (!flags.s()) - goto line3; - _neg(bx); - _neg(si); -line3: - push(si); - data.byte(kLineroutine) = 0; - _cmp(bx, cx); - if (flags.le()) - goto line4; - data.byte(kLineroutine) = 1; - _xchg(bx, cx); -line4: - _shl(bx, 1); - data.word(kIncrement1) = bx; - _sub(bx, cx); - si = bx; - _sub(bx, cx); - data.word(kIncrement2) = bx; - ax = data.word(kLinestartx); - bx = data.word(kLinestarty); - ah = bl; - _inc(cx); - bx = pop(); - _cmp(data.byte(kLineroutine), 1); - if (flags.z()) - goto hislope; - goto loslope; -vertline: - ax = data.word(kLinestarty); - bx = data.word(kLineendy); - cx = bx; - _sub(cx, ax); - if (!flags.l()) - goto line31; - _neg(cx); - ax = bx; - data.byte(kLinedirection) = 1; -line31: - _inc(cx); - bx = data.word(kLinestartx); - _xchg(ax, bx); - ah = bl; - bx = si; -line32: - _stosw(); - _add(ah, bl); - if (--cx) - goto line32; - goto lineexit; -horizline: - ax = data.word(kLinestartx); - bx = data.word(kLinestarty); - ah = bl; - _inc(cx); -horizloop: - _stosw(); - _inc(al); - if (--cx) - goto horizloop; - goto lineexit; -loslope: -loloop: - _stosw(); - _inc(al); - _or(si, si); - if (!flags.s()) - goto line12; - _add(si, data.word(kIncrement1)); - if (--cx) - goto loloop; - goto lineexit; -line12: - _add(si, data.word(kIncrement2)); - _add(ah, bl); - if (--cx) - goto loloop; - goto lineexit; -hislope: -hiloop: - _stosw(); - _add(ah, bl); - _or(si, si); - if (!flags.s()) - goto line23; - _add(si, data.word(kIncrement1)); - if (--cx) - goto hiloop; - goto lineexit; -line23: - _add(si, data.word(kIncrement2)); - _inc(al); - if (--cx) - goto hiloop; -lineexit: - _sub(di, 8173); - ax = di; - _shr(ax, 1); - data.byte(kLinelength) = al; -} - void DreamGenContext::workoutframes() { STACK_CHECK; bx = data.word(kLinestartx); @@ -17396,7 +17268,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_examineobtext: examineobtext(); break; case addr_printmessage2: printmessage2(); break; case addr_setwalk: setwalk(); break; - case addr_bresenhams: bresenhams(); break; case addr_workoutframes: workoutframes(); break; case addr_showicon: showicon(); break; case addr_middlepanel: middlepanel(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 026b412b55..ca2e089790 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -100,7 +100,6 @@ public: static const uint16 addr_middlepanel = 0xca68; static const uint16 addr_showicon = 0xca64; static const uint16 addr_workoutframes = 0xca54; - static const uint16 addr_bresenhams = 0xca50; static const uint16 addr_setwalk = 0xca44; static const uint16 addr_printmessage2 = 0xca30; static const uint16 addr_examineobtext = 0xca20; @@ -1282,7 +1281,7 @@ public: void buttonenter(); void checkinput(); //void crosshair(); - void bresenhams(); + void setmode(); void getbackfromops(); //void frameoutv(); void showbyte(); @@ -1496,7 +1495,7 @@ public: void entersymbol(); void showword(); void dirfile(); - void setmode(); + //void bresenhams(); //void walktotext(); void pickupconts(); void locklightoff(); diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp index d6ef7f48be..d367f02d15 100644 --- a/engines/dreamweb/pathfind.cpp +++ b/engines/dreamweb/pathfind.cpp @@ -130,5 +130,125 @@ bool DreamGenContext::checkifpathison(uint8 index) { return pathOn == 0xff; } +void DreamGenContext::bresenhams() { + workoutframes(); + int8 *lineData = (int8 *)data.ptr(kLinedata, 0); + int16 startX = (int16)data.word(kLinestartx); + int16 startY = (int16)data.word(kLinestarty); + int16 endX = (int16)data.word(kLineendx); + int16 endY = (int16)data.word(kLineendy); + + if (endX == startX) { + uint16 deltaY; + int8 y; + if (endY < startY) { + deltaY = startY - endY; + y = (int8)endY; + data.byte(kLinedirection) = 1; + } else { + deltaY = endY - startY; + y = (int8)startY; + data.byte(kLinedirection) = 0; + } + ++deltaY; + int8 x = (int8)startX; + data.byte(kLinelength) = deltaY; + do { + lineData[0] = x; + lineData[1] = y; + lineData += 2; + ++y; + --deltaY; + } while (deltaY); + return; + } + uint16 deltaX; + if (endX < startX) { + deltaX = startX - endX; + SWAP(startX, endX); + SWAP(startY, endY); + data.word(kLinestartx) = (uint16)startX; + data.word(kLinestarty) = (uint16)startY; + data.word(kLineendx) = (uint16)endX; + data.word(kLineendy) = (uint16)endY; + data.byte(kLinedirection) = 1; + } else { + deltaX = endX - startX; + data.byte(kLinedirection) = 0; + } + + int16 increment; + if (endY == startY) { + int8 x = (int8)startX; + int8 y = (int8)startY; + ++deltaX; + data.byte(kLinelength) = deltaX; + do { + lineData[0] = x; + lineData[1] = y; + lineData += 2; + ++x; + --deltaX; + } while (deltaX); + return; + } + uint16 deltaY; + if (startY > endY) { + deltaY = startY - endY; + increment = -1; + } else { + deltaY = endY - startY; + increment = 1; + } + + uint16 delta1, delta2; + if (deltaY > deltaX) { + data.byte(kLineroutine) = 1; + delta1 = deltaY; + delta2 = deltaX; + } else { + data.byte(kLineroutine) = 0; + delta1 = deltaX; + delta2 = deltaY; + } + + data.word(kIncrement1) = delta2 * 2; + int16 remainder = delta2 * 2 - delta1; + data.word(kIncrement2) = delta2 * 2 - delta1 * 2; + ++delta1; + int8 x = (int8)startX; + int8 y = (int8)startY; + data.byte(kLinelength) = delta1; + if (data.byte(kLineroutine) != 1) { + do { + lineData[0] = x; + lineData[1] = y; + lineData += 2; + ++x; + if (remainder < 0) { + remainder += data.word(kIncrement1); + } else { + remainder += data.word(kIncrement2); + y += increment; + } + --delta1; + } while (delta1); + } else { + do { + lineData[0] = x; + lineData[1] = y; + lineData += 2; + y += increment; + if (remainder < 0) { + remainder += data.word(kIncrement1); + } else { + remainder += data.word(kIncrement2); + ++x; + } + --delta1; + } while (delta1); + } +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index ab272744e0..595061676a 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -243,4 +243,6 @@ void usetext(); void getblockofpixel(); uint8 getblockofpixel(uint8 x, uint8 y); + void bresenhams(); + |