diff options
author | Filippos Karapetis | 2011-12-25 22:31:07 +0200 |
---|---|---|
committer | Filippos Karapetis | 2011-12-25 22:31:07 +0200 |
commit | 1f346baa92064388de2958110d93006ac96a5479 (patch) | |
tree | 50f588266b7bd24d31a1d5ae290623bcea482b59 /engines/dreamweb | |
parent | bdded1ce12212e092452a7b4943e99cad4c16a14 (diff) | |
download | scummvm-rg350-1f346baa92064388de2958110d93006ac96a5479.tar.gz scummvm-rg350-1f346baa92064388de2958110d93006ac96a5479.tar.bz2 scummvm-rg350-1f346baa92064388de2958110d93006ac96a5479.zip |
DREAMWEB: Port 'findopenpos' to C++
Diffstat (limited to 'engines/dreamweb')
-rw-r--r-- | engines/dreamweb/dreambase.h | 1 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.cpp | 17 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.h | 1 | ||||
-rw-r--r-- | engines/dreamweb/object.cpp | 51 |
4 files changed, 28 insertions, 42 deletions
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h index 41409bc323..0dc4e52d86 100644 --- a/engines/dreamweb/dreambase.h +++ b/engines/dreamweb/dreambase.h @@ -204,6 +204,7 @@ public: void wornError(); void makeWorn(DynObject *object); void dropObject(); + uint16 findOpenPos(); // from pathfind.cpp void turnPathOn(uint8 param); diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 0dffe56c2a..32bb520b18 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -335,23 +335,6 @@ void DreamGenContext::getSetAd() { es = data.word(kSetdat); } -void DreamGenContext::findOpenPos() { - STACK_CHECK; - cx = data.word(kMousex); - _sub(cx, (80)); - bx = -1; -findopenp1: - _inc(bx); - _sub(cx, (44)); - if (!flags.c()) - goto findopenp1; - al = bl; - data.byte(kLastinvpos) = al; - _add(bx, bx); - es = data.word(kBuffers); - _add(bx, (0+(228*13))); -} - void DreamGenContext::transferToEx() { STACK_CHECK; emergencyPurge(); diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 0f6bfc0a48..45589cab07 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -461,7 +461,6 @@ public: void pickupConts(); void transferMap(); void getSetAd(); - void findOpenPos(); void rollEm(); void findAllOpen(); void fillOpen(); diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp index f3e27d9a5b..c202ac765c 100644 --- a/engines/dreamweb/object.cpp +++ b/engines/dreamweb/object.cpp @@ -881,10 +881,9 @@ void DreamGenContext::useOpened() { return; } - findOpenPos(); - uint16 subject = es.word(bx); + uint16 objectId = getSegment(data.word(kBuffers)).word(findOpenPos()); - if ((subject & 0x00FF) != 255) { + if ((objectId & 0x00FF) != 255) { swapWithOpen(); return; } @@ -894,15 +893,15 @@ void DreamGenContext::useOpened() { return; } - subject = (data.byte(kObjecttype) << 8) | data.byte(kItemframe); - if (subject == data.word(kOldsubject)) { + objectId = (data.byte(kObjecttype) << 8) | data.byte(kItemframe); + if (objectId == data.word(kOldsubject)) { if (data.byte(kCommandtype) != 227) { data.byte(kCommandtype) = 227; - data.word(kOldsubject) = subject; + data.word(kOldsubject) = objectId; commandWithOb(35, data.byte(kObjecttype), data.byte(kItemframe)); } } else { - data.word(kOldsubject) = subject; + data.word(kOldsubject) = objectId; commandWithOb(35, data.byte(kObjecttype), data.byte(kItemframe)); } @@ -944,23 +943,22 @@ void DreamGenContext::outOfOpen() { if (data.byte(kOpenedob) == 255) return; // cannot use opened object - findOpenPos(); - uint16 subject = es.word(bx); + uint16 objectId = getSegment(data.word(kBuffers)).word(findOpenPos()); - if ((subject & 0x00FF) == 255) { + if ((objectId & 0x00FF) == 255) { blank(); return; } - if (subject == data.word(kOldsubject)) { + if (objectId == data.word(kOldsubject)) { if (data.byte(kCommandtype) != 228) { data.byte(kCommandtype) = 228; - data.word(kOldsubject) = subject; - commandWithOb(36, subject >> 8, subject & 0x00FF); + data.word(kOldsubject) = objectId; + commandWithOb(36, objectId >> 8, objectId & 0x00FF); } } else { - data.word(kOldsubject) = subject; - commandWithOb(36, subject >> 8, subject & 0x00FF); + data.word(kOldsubject) = objectId; + commandWithOb(36, objectId >> 8, objectId & 0x00FF); } if (data.word(kMousebutton) == data.word(kOldbutton)) @@ -976,10 +974,9 @@ void DreamGenContext::outOfOpen() { delPointer(); data.byte(kPickup) = 1; - findOpenPos(); - subject = es.word(bx); - data.byte(kObjecttype) = subject >> 8; - data.byte(kItemframe) = subject & 0xFF; + objectId = getSegment(data.word(kBuffers)).word(findOpenPos()); + data.byte(kObjecttype) = objectId >> 8; + data.byte(kItemframe) = objectId & 0xFF; if (data.byte(kObjecttype) != 4) { transferToEx(); @@ -1034,10 +1031,9 @@ void DreamGenContext::swapWithOpen() { byte prevType = data.byte(kObjecttype); byte prevFrame = data.byte(kItemframe); - findOpenPos(); - subject = es.word(bx); - data.byte(kObjecttype) = subject >> 8; - data.byte(kItemframe) = subject & 0xFF; + uint16 objectId = getSegment(data.word(kBuffers)).word(findOpenPos()); + data.byte(kObjecttype) = objectId >> 8; + data.byte(kItemframe) = objectId & 0xFF; if (data.byte(kObjecttype) != 4) { transferToEx(); @@ -1053,7 +1049,7 @@ void DreamGenContext::swapWithOpen() { byte prevFrame2 = data.byte(kItemframe); data.byte(kObjecttype) = prevType; data.byte(kItemframe) = prevFrame; - findOpenPos(); + //findOpenPos(); // was in the original source, looks to be unused object = getEitherAdCPP(); object->mapad[0] = data.byte(kOpenedtype); object->mapad[1] = data.byte(kOpenedob); @@ -1071,4 +1067,11 @@ void DreamGenContext::swapWithOpen() { delPointer(); } +uint16 DreamBase::findOpenPos() { + uint16 pos = (data.word(kMousex) - kInventx) / kItempicsize; + data.byte(kLastinvpos) = pos & 0xFF; + + return pos * 2 + kOpeninvlist; // return the object position in the inventory data +} + } // End of namespace DreamGen |