diff options
author | D G Turner | 2011-12-25 23:33:11 +0000 |
---|---|---|
committer | D G Turner | 2011-12-25 23:33:11 +0000 |
commit | c7b1ec21980d622c138fa2dcac5a03f80aa415e1 (patch) | |
tree | 05e5ec95a789277c02b2a328595b07a5ab1a929f /engines/dreamweb/object.cpp | |
parent | 1f346baa92064388de2958110d93006ac96a5479 (diff) | |
download | scummvm-rg350-c7b1ec21980d622c138fa2dcac5a03f80aa415e1.tar.gz scummvm-rg350-c7b1ec21980d622c138fa2dcac5a03f80aa415e1.tar.bz2 scummvm-rg350-c7b1ec21980d622c138fa2dcac5a03f80aa415e1.zip |
DREAMWEB: Ported 'findfirstpath' to C++.
This conversion could do with a bit more work to remove the es/ax/cx
temp usage and clean up the code.
Diffstat (limited to 'engines/dreamweb/object.cpp')
-rw-r--r-- | engines/dreamweb/object.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp index c202ac765c..84829bf440 100644 --- a/engines/dreamweb/object.cpp +++ b/engines/dreamweb/object.cpp @@ -341,6 +341,32 @@ void DreamGenContext::openOb() { _openChangeSize = getOpenedSlotCount() * kItempicsize + kInventx; } +uint8 DreamGenContext::findFirstPath(uint16 param) { + es = data.word(kReels); + uint16 ptr = 144 * data.byte(kRoomnum); + // TODO: Replace ax, cx usage with temporary uint8/16 variables... + cx = param; + + for (uint8 pathLoop = 0; pathLoop < 12; pathLoop++, ptr += 8) { + ax = es.word(ptr+2); + + if (ax == 0x0ffff) + continue; // "nofirst" + + if (cl < al || ch < ah) + continue; // "nofirst" + + ax = es.word(ptr+4); + + if (cl > al || ch > ah) + continue; // "nofirst" + + return es.byte(ptr+6); // "gotfirst" + } + + return 0; +} + void DreamGenContext::identifyOb() { if (data.word(kWatchingtime) != 0) { blank(); @@ -362,8 +388,7 @@ void DreamGenContext::identifyOb() { data.byte(kPointerspath) = dl; ax = pop(); push(ax); - findFirstPath(); - data.byte(kPointerfirstpath) = al; + data.byte(kPointerfirstpath) = findFirstPath(ax); ax = pop(); byte x = al; |