aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2011-12-08 11:12:48 -0800
committerFilippos Karapetis2011-12-08 11:12:48 -0800
commit05fff73c66d70f2f8ce45b6784cf9089b7cd2f71 (patch)
treeb95ef72f135cd92e887bdaeace2bbc6ab9a276ae
parent96360bb153201ccbd0b5748c2f153ae1277258b5 (diff)
parentc8d4f608526f6843bb942f7b8778df68b14f0aba (diff)
downloadscummvm-rg350-05fff73c66d70f2f8ce45b6784cf9089b7cd2f71.tar.gz
scummvm-rg350-05fff73c66d70f2f8ce45b6784cf9089b7cd2f71.tar.bz2
scummvm-rg350-05fff73c66d70f2f8ce45b6784cf9089b7cd2f71.zip
Merge pull request #130 from fingolfin/dreamweb-misc
Dreamweb: convert workoutFrames to c++, some cleanup
-rwxr-xr-xdevtools/tasmrecover/tasm-recover2
-rw-r--r--engines/dreamweb/backdrop.cpp2
-rw-r--r--engines/dreamweb/detection.cpp2
-rw-r--r--engines/dreamweb/dreambase.h6
-rw-r--r--engines/dreamweb/dreamgen.cpp87
-rw-r--r--engines/dreamweb/dreamgen.h1
-rw-r--r--engines/dreamweb/dreamweb.cpp8
-rw-r--r--engines/dreamweb/pathfind.cpp70
-rw-r--r--engines/dreamweb/print.cpp4
-rw-r--r--engines/dreamweb/runtime.h6
-rw-r--r--engines/dreamweb/sound.cpp2
-rw-r--r--engines/dreamweb/sprite.cpp9
-rw-r--r--engines/dreamweb/stubs.cpp14
-rw-r--r--engines/dreamweb/stubs.h5
-rw-r--r--engines/dreamweb/vgagrafx.cpp20
15 files changed, 100 insertions, 138 deletions
diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index fdff5a1079..08471f3875 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -725,6 +725,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'wheelsound',
'widedoor',
'width160',
+ 'workoutframes',
'worktoscreen',
'worktoscreenm',
'wornerror',
@@ -913,7 +914,6 @@ generator = cpp(context, "DreamGen", blacklist = [
'findinvpos' : 'findInvPos',
'dumpmenu' : 'dumpMenu',
'liftnoise' : 'liftNoise',
- 'workoutframes' : 'workoutFrames',
'dumpsymbox' : 'dumpSymBox',
'loadgame' : 'loadGame',
'getridoftemp' : 'getRidOfTemp',
diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp
index cf07ffcfe2..3e005fdec9 100644
--- a/engines/dreamweb/backdrop.cpp
+++ b/engines/dreamweb/backdrop.cpp
@@ -247,7 +247,7 @@ void DreamGenContext::showAllFree() {
data.word(kFramesad) = kFrframes;
data.byte(kCurrentfree) = 0;
const DynObject *freeObjects = (const DynObject *)getSegment(data.word(kFreedat)).ptr(0, 0);
- for(size_t i = 0; i < 80; ++i) {
+ for (size_t i = 0; i < 80; ++i) {
uint8 mapAd = getMapAd(freeObjects[i].mapad);
if (mapAd != 0) {
uint8 width, height;
diff --git a/engines/dreamweb/detection.cpp b/engines/dreamweb/detection.cpp
index a3f311c304..ba7152beb5 100644
--- a/engines/dreamweb/detection.cpp
+++ b/engines/dreamweb/detection.cpp
@@ -95,7 +95,7 @@ SaveStateList DreamWebMetaEngine::listSaves(const char *target) const {
Common::sort(files.begin(), files.end());
SaveStateList saveList;
- for(uint i = 0; i < files.size(); ++i) {
+ for (uint i = 0; i < files.size(); ++i) {
const Common::String &file = files[i];
Common::InSaveFile *stream = saveFileMan->openForLoading(file);
if (!stream)
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 28feb5b975..bc272c1b19 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -69,6 +69,12 @@ public:
Common::Point _lineData[200]; // Output of Bresenham
void checkDest(const RoomPaths *roomsPaths);
RoomPaths *getRoomsPaths();
+ void faceRightWay();
+ void setWalk();
+ void autoSetWalk();
+ void findXYFromPath();
+ void bresenhams();
+ void workoutFrames();
// from print.cpp
uint8 getNextWord(const Frame *charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount);
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index a1d0799565..ab4d8cbead 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -6849,93 +6849,6 @@ searchmess:
printDirect();
}
-void DreamGenContext::workoutFrames() {
- STACK_CHECK;
- bx = data.word(kLinestartx);
- _add(bx, 32);
- ax = data.word(kLineendx);
- _add(ax, 32);
- _sub(bx, ax);
- if (!flags.c())
- goto notneg1;
- _neg(bx);
-notneg1:
- cx = data.word(kLinestarty);
- _add(cx, 32);
- ax = data.word(kLineendy);
- _add(ax, 32);
- _sub(cx, ax);
- if (!flags.c())
- goto notneg2;
- _neg(cx);
-notneg2:
- _cmp(bx, cx);
- if (!flags.c())
- goto tendstohoriz;
- dl = 2;
- ax = cx;
- _shr(ax, 1);
- _cmp(bx, ax);
- if (flags.c())
- goto gotquad;
- dl = 1;
- goto gotquad;
-tendstohoriz:
- dl = 0;
- ax = bx;
- _shr(ax, 1);
- _cmp(cx, ax);
- if (flags.c())
- goto gotquad;
- dl = 1;
- goto gotquad;
-gotquad:
- bx = data.word(kLinestartx);
- _add(bx, 32);
- ax = data.word(kLineendx);
- _add(ax, 32);
- _sub(bx, ax);
- if (flags.c())
- goto isinright;
- cx = data.word(kLinestarty);
- _add(cx, 32);
- ax = data.word(kLineendy);
- _add(ax, 32);
- _sub(cx, ax);
- if (!flags.c())
- goto topleft;
- _cmp(dl, 1);
- if (flags.z())
- goto noswap1;
- _xor(dl, 2);
-noswap1:
- _add(dl, 4);
- goto success;
-topleft:
- _add(dl, 6);
- goto success;
-isinright:
- cx = data.word(kLinestarty);
- _add(cx, 32);
- ax = data.word(kLineendy);
- _add(ax, 32);
- _sub(cx, ax);
- if (!flags.c())
- goto botright;
- _add(dl, 2);
- goto success;
-botright:
- _cmp(dl, 1);
- if (flags.z())
- goto noswap2;
- _xor(dl, 2);
-noswap2:
-success:
- _and(dl, 7);
- data.byte(kTurntoface) = dl;
- data.byte(kTurndirection) = 0;
-}
-
void DreamGenContext::getUnderZoom() {
STACK_CHECK;
di = (8)+5;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 674b952f1f..2b5538750c 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -599,7 +599,6 @@ public:
void cantDrop();
void putUnderZoom();
void findInvPos();
- void workoutFrames();
void rollEndCredits();
void getKeyAndLogo();
void selectOb();
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index 717c0620f4..e15f315c1e 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -326,14 +326,14 @@ void DreamWebEngine::mouseCall(uint16 *x, uint16 *y, uint16 *state) {
void DreamWebEngine::getPalette(uint8 *data, uint start, uint count) {
_system->getPaletteManager()->grabPalette(data, start, count);
- while(count--)
+ while (count--)
*data++ >>= 2;
}
void DreamWebEngine::setPalette(const uint8 *data, uint start, uint count) {
assert(start + count <= 256);
uint8 fixed[768];
- for(uint i = 0; i < count * 3; ++i) {
+ for (uint i = 0; i < count * 3; ++i) {
fixed[i] = data[i] << 2;
}
_system->getPaletteManager()->setPalette(fixed, start, count);
@@ -356,9 +356,9 @@ void DreamWebEngine::printUnderMonitor() {
if (!s)
error("lockScreen failed");
- for(uint y = 0; y < 104; ++y) {
+ for (uint y = 0; y < 104; ++y) {
uint8 *src = (uint8 *)s->getBasePtr(76, 43 + 8 + y);
- for(uint x = 0; x < 170; ++x) {
+ for (uint x = 0; x < 170; ++x) {
if (*src < 231)
*dst++ = *src++;
else {
diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp
index 0f717a983f..ee6ced7e4d 100644
--- a/engines/dreamweb/pathfind.cpp
+++ b/engines/dreamweb/pathfind.cpp
@@ -73,7 +73,14 @@ RoomPaths *DreamBase::getRoomsPaths() {
return (RoomPaths *)result;
}
-void DreamGenContext::setWalk() {
+void DreamBase::faceRightWay() {
+ PathNode *paths = getRoomsPaths()->nodes;
+ uint8 dir = paths[data.byte(kManspath)].dir;
+ data.byte(kTurntoface) = dir;
+ data.byte(kLeavedirection) = dir;
+}
+
+void DreamBase::setWalk() {
if (data.byte(kLinepointer) != 254) {
// Already walking
data.byte(kFinaldest) = data.byte(kPointerspath);
@@ -100,7 +107,7 @@ void DreamGenContext::setWalk() {
}
}
-void DreamGenContext::autoSetWalk() {
+void DreamBase::autoSetWalk() {
if (data.byte(kFinaldest) == data.byte(kManspath))
return;
const RoomPaths *roomsPaths = getRoomsPaths();
@@ -137,7 +144,7 @@ void DreamBase::checkDest(const RoomPaths *roomsPaths) {
data.byte(kDestination) = destination;
}
-void DreamGenContext::findXYFromPath() {
+void DreamBase::findXYFromPath() {
const PathNode *roomsPaths = getRoomsPaths()->nodes;
data.byte(kRyanx) = roomsPaths[data.byte(kManspath)].x - 12;
data.byte(kRyany) = roomsPaths[data.byte(kManspath)].y - 12;
@@ -153,7 +160,7 @@ bool DreamGenContext::checkIfPathIsOn(uint8 index) {
return pathOn == 0xff;
}
-void DreamGenContext::bresenhams() {
+void DreamBase::bresenhams() {
workoutFrames();
Common::Point *lineData = &_lineData[0];
int16 startX = (int16)data.word(kLinestartx);
@@ -269,4 +276,59 @@ void DreamGenContext::bresenhams() {
}
}
+void DreamBase::workoutFrames() {
+ byte tmp;
+ uint16 diffx, diffy;
+
+ // FIXME: Paranoia asserts, to be removed after sufficient play
+ // testing has happened. Background: The original code used to add
+ // 32 to the four values listed in the asserts below. Which seems
+ // nonsensical, as only the differences of the values matter, so the
+ // +32 cancels out. Unless there is an overflow somewhere... So we
+ // check for that here.
+ assert(data.word(kLinestartx) < 0xFFFF - 32);
+ assert(data.word(kLineendx) < 0xFFFF - 32);
+ assert(data.word(kLinestarty) < 0xFFFF - 32);
+ assert(data.word(kLineendy) < 0xFFFF - 32);
+
+
+ diffx = ABS(data.word(kLinestartx) - data.word(kLineendx));
+ diffy = ABS(data.word(kLinestarty) - data.word(kLineendy));
+
+ if (diffx < diffy) {
+ tmp = 2;
+ if (diffx >= (diffy >> 1))
+ tmp = 1;
+ } else {
+ // tendstohoriz
+ tmp = 0;
+ if (diffy >= (diffx >> 1))
+ tmp = 1;
+ }
+
+ if (data.word(kLinestartx) >= data.word(kLineendx)) {
+ // isinleft
+ if (data.word(kLinestarty) < data.word(kLineendy)) {
+ if (tmp != 1)
+ tmp ^= 2;
+ tmp += 4;
+ } else {
+ // topleft
+ tmp += 6;
+ }
+ } else {
+ // isinright
+ if (data.word(kLinestarty) < data.word(kLineendy)) {
+ tmp += 2;
+ } else {
+ // botright
+ if (tmp != 1)
+ tmp ^= 2;
+ }
+ }
+
+ data.byte(kTurntoface) = tmp & 7;
+ data.byte(kTurndirection) = 0;
+}
+
} // End of namespace DreamGen
diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp
index df89df28ef..dc7ca8a2f7 100644
--- a/engines/dreamweb/print.cpp
+++ b/engines/dreamweb/print.cpp
@@ -35,7 +35,7 @@ void DreamBase::printBoth(const Frame *charSet, uint16 *x, uint16 y, uint8 c, ui
uint8 DreamBase::getNextWord(const Frame *charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount) {
*totalWidth = 0;
*charCount = 0;
- while(true) {
+ while (true) {
uint8 firstChar = *string;
++string;
++*charCount;
@@ -153,7 +153,7 @@ uint8 DreamBase::printDirect(const uint8** string, uint16 x, uint16 *y, uint8 ma
printChar(charSet, &i, *y, c, nextChar, &width, &height);
data.word(kLastxpos) = i;
--charCount;
- } while(charCount);
+ } while (charCount);
*y += data.word(kLinespacing);
}
}
diff --git a/engines/dreamweb/runtime.h b/engines/dreamweb/runtime.h
index 1ed7f39ad6..9b70d164a6 100644
--- a/engines/dreamweb/runtime.h
+++ b/engines/dreamweb/runtime.h
@@ -40,12 +40,6 @@ struct Register {
inline Register(): _value() {}
inline Register& operator=(uint16 v) { _value = v; return *this; }
inline operator uint16&() { return _value; }
- inline void cbw() {
- if (_value & 0x80)
- _value |= 0xff00;
- else
- _value &= 0x7f;
- }
};
template<int kIndex> //from low to high
diff --git a/engines/dreamweb/sound.cpp b/engines/dreamweb/sound.cpp
index 8bccc5e280..fc68a8f996 100644
--- a/engines/dreamweb/sound.cpp
+++ b/engines/dreamweb/sound.cpp
@@ -289,7 +289,7 @@ void DreamWebEngine::loadSounds(uint bank, const Common::String &filename) {
SoundData &soundData = _soundData[bank];
soundData.samples.resize(tablesize / 6);
uint total = 0;
- for(uint i = 0; i < tablesize / 6; ++i) {
+ for (uint i = 0; i < tablesize / 6; ++i) {
uint8 entry[6];
Sample &sample = soundData.samples[i];
file.read(entry, sizeof(entry));
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index b14cfc554c..f1f3ff5e48 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -457,13 +457,6 @@ void DreamGenContext::liftSprite(Sprite *sprite, SetObject *objData) {
}
}
-void DreamGenContext::faceRightWay() {
- PathNode *paths = getRoomsPaths()->nodes;
- uint8 dir = paths[data.byte(kManspath)].dir;
- data.byte(kTurntoface) = dir;
- data.byte(kLeavedirection) = dir;
-}
-
Reel *DreamBase::getReelStart(uint16 reelPointer) {
Reel *reel = (Reel *)getSegment(data.word(kReels)).ptr(kReellist + reelPointer * sizeof(Reel) * 8, sizeof(Reel));
return reel;
@@ -530,7 +523,7 @@ void DreamGenContext::showRain() {
rain->setW3(ax);
const uint8 *src = ds.ptr(si, 0) + ax;
uint8 *dst = workspace() + y * 320 + x;
- for(uint16 i = 0; i < size; ++i) {
+ for (uint16 i = 0; i < size; ++i) {
uint8 v = src[i];
if (v != 0)
*dst = v;
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 465cb68741..9d3719f806 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -993,7 +993,7 @@ void DreamGenContext::deallocateMem(uint16 segment) {
MutableSegmentRef buffers(this);
buffers = bseg;
uint8 *ptr = buffers.ptr(kSpritetable, tsize);
- for(uint i = 0; i < tsize; i += 32) {
+ for (uint i = 0; i < tsize; i += 32) {
uint16 seg = READ_LE_UINT16(ptr + i + 6);
//debug(1, "sprite segment = %04x", seg);
if (seg == segment)
@@ -1032,8 +1032,8 @@ void DreamGenContext::fadeDOS() {
//processEvents will be called from vsync
uint8 *dst = es.ptr(kStartpal, 768);
engine->getPalette(dst, 0, 64);
- for(int fade = 0; fade < 64; ++fade) {
- for(int c = 0; c < 768; ++c) { //original sources decrement 768 values -> 256 colors
+ for (int fade = 0; fade < 64; ++fade) {
+ for (int c = 0; c < 768; ++c) { //original sources decrement 768 values -> 256 colors
if (dst[c]) {
--dst[c];
}
@@ -1475,7 +1475,7 @@ void DreamGenContext::doChange(uint8 index, uint8 value, uint8 type) {
void DreamGenContext::deleteTaken() {
const DynObject *extraObjects = (const DynObject *)getSegment(data.word(kExtras)).ptr(kExdata, 0);
DynObject *freeObjects = (DynObject *)getSegment(data.word(kFreedat)).ptr(0, 0);
- for(size_t i = 0; i < kNumexobjects; ++i) {
+ for (size_t i = 0; i < kNumexobjects; ++i) {
uint8 location = extraObjects[i].initialLocation;
if (location == data.byte(kReallocation)) {
uint8 index = extraObjects[i].index;
@@ -1873,7 +1873,7 @@ bool DreamGenContext::compare(uint8 index, uint8 flag, const char id[4]) {
void *ptr = getAnyAdDir(index, flag);
const char *objId = (const char *)(((const uint8 *)ptr) + 12); // whether it is a DynObject or a SetObject
for (size_t i = 0; i < 4; ++i) {
- if(id[i] != objId[i] + 'A')
+ if (id[i] != objId[i] + 'A')
return false;
}
return true;
@@ -3549,7 +3549,7 @@ void DreamGenContext::nextDest() {
data.byte(kDestpos) = 0; // last destination
getDestInfo();
- } while(al == 0);
+ } while (al == 0);
data.byte(kNewtextline) = 1;
delTextLine();
@@ -3580,7 +3580,7 @@ void DreamGenContext::lastDest() {
data.byte(kDestpos) = 15; // first destination
getDestInfo();
- } while(al == 0);
+ } while (al == 0);
data.byte(kNewtextline) = 1;
delTextLine();
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 702a6359de..cfebddd308 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -96,9 +96,7 @@
void initMan();
void mainMan(Sprite *sprite);
void mainMan();
- void faceRightWay();
void walking(Sprite *sprite);
- void autoSetWalk();
void aboutTurn(Sprite *sprite);
void backObject(Sprite *sprite);
void backObject();
@@ -161,7 +159,6 @@
void blockNameText();
void walkToText();
void personNameText();
- void findXYFromPath();
void findOrMake();
void findOrMake(uint8 index, uint8 value, uint8 type) {
DreamBase::findOrMake(index, value, type);
@@ -239,7 +236,6 @@
void useText();
void getBlockOfPixel();
uint8 getBlockOfPixel(uint8 x, uint8 y);
- void bresenhams();
void examineObText();
void sortOutMap();
void showCity();
@@ -498,7 +494,6 @@
void openSarters();
void openLouis();
void DOSReturn();
- void setWalk();
void useLadder();
void useLadderB();
void useCart();
diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp
index 8d303d1a04..2a69124fdf 100644
--- a/engines/dreamweb/vgagrafx.cpp
+++ b/engines/dreamweb/vgagrafx.cpp
@@ -43,7 +43,7 @@ void DreamBase::multiGet(uint8 *dst, uint16 x, uint16 y, uint8 w, uint8 h) {
if (x + w > 320)
w = 320 - x;
//debug(1, "multiGet %u,%u %ux%u -> segment: %04x->%04x", x, y, w, h, (uint16)ds, (uint16)es);
- for(unsigned l = 0; l < h; ++l) {
+ for (unsigned l = 0; l < h; ++l) {
const uint8 *src_p = src + kScreenwidth * l;
uint8 *dst_p = dst + w * l;
memcpy(dst_p, src_p, w);
@@ -66,7 +66,7 @@ void DreamBase::multiPut(const uint8 *src, uint16 x, uint16 y, uint8 w, uint8 h)
if (x + w > 320)
w = 320 - x;
//debug(1, "multiPut %ux%u -> segment: %04x->%04x", w, h, (uint16)ds, (uint16)es);
- for(unsigned l = 0; l < h; ++l) {
+ for (unsigned l = 0; l < h; ++l) {
const uint8 *src_p = src + w * l;
uint8 *dst_p = dst + kScreenwidth * l;
memcpy(dst_p, src_p, w);
@@ -260,26 +260,26 @@ void DreamBase::frameOutV(uint8 *dst, const uint8 *src, uint16 pitch, uint16 wid
// or was something broken during porting to C++?
assert(pitch == 320);
- if(x < 0) {
+ if (x < 0) {
assert(width >= -x);
width -= -x;
src += -x;
x = 0;
}
- if(y < 0) {
+ if (y < 0) {
assert(height >= -y);
height -= -y;
src += (-y) * width;
y = 0;
}
- if(x >= 320)
+ if (x >= 320)
return;
- if(y >= 200)
+ if (y >= 200)
return;
- if(x + width > 320) {
+ if (x + width > 320) {
width = 320 - x;
}
- if(y + height > 200) {
+ if (y + height > 200) {
height = 200 - y;
}
@@ -384,8 +384,8 @@ void DreamGenContext::zoom() {
uint16 dstOffset = (kZoomy + 4) * 320 + (kZoomx + 5);
const uint8 *src = workspace() + srcOffset;
uint8 *dst = workspace() + dstOffset;
- for(size_t i=0; i<20; ++i) {
- for(size_t j=0; j<23; ++j) {
+ for (size_t i = 0; i < 20; ++i) {
+ for (size_t j = 0; j < 23; ++j) {
uint8 v = src[j];
dst[2*j+0] = v;
dst[2*j+1] = v;