diff options
author | Filippos Karapetis | 2011-12-25 17:10:49 +0200 |
---|---|---|
committer | Filippos Karapetis | 2011-12-25 17:10:49 +0200 |
commit | 0fff97b4b023895256cb8cce9b30684d433bfae4 (patch) | |
tree | cda595690856df90881e739d40edea09ed86b527 /engines/dreamweb | |
parent | e322d6257dae83761c86c9d5bfbc7d02c0a9988d (diff) | |
download | scummvm-rg350-0fff97b4b023895256cb8cce9b30684d433bfae4.tar.gz scummvm-rg350-0fff97b4b023895256cb8cce9b30684d433bfae4.tar.bz2 scummvm-rg350-0fff97b4b023895256cb8cce9b30684d433bfae4.zip |
DREAMWEB: Port 'useopened' to C++
Diffstat (limited to 'engines/dreamweb')
-rw-r--r-- | engines/dreamweb/dreamgen.cpp | 94 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.h | 1 | ||||
-rw-r--r-- | engines/dreamweb/object.cpp | 68 | ||||
-rw-r--r-- | engines/dreamweb/stubs.h | 1 |
4 files changed, 69 insertions, 95 deletions
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 55ab3755af..4d89322a77 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -527,100 +527,6 @@ findopenp1: _add(bx, (0+(228*13))); } -void DreamGenContext::useOpened() { - STACK_CHECK; - _cmp(data.byte(kOpenedob), 255); - if (flags.z()) - return /* (cannotuseopen) */; - _cmp(data.byte(kPickup), 0); - if (!flags.z()) - goto notout2; - outOfOpen(); - return; -notout2: - findOpenPos(); - ax = es.word(bx); - _cmp(al, 255); - if (flags.z()) - goto canplace3; - swapWithOpen(); - return; -canplace3: - _cmp(data.byte(kPickup), 1); - if (flags.z()) - goto intoopen; - blank(); - return; -intoopen: - al = data.byte(kItemframe); - ah = data.byte(kObjecttype); - _cmp(ax, data.word(kOldsubject)); - if (!flags.z()) - goto difsub2; - _cmp(data.byte(kCommandtype), 227); - if (flags.z()) - goto alreadyplc2; - data.byte(kCommandtype) = 227; -difsub2: - data.word(kOldsubject) = ax; - bx = ax; - al = 35; - commandWithOb(); -alreadyplc2: - ax = data.word(kMousebutton); - _cmp(ax, data.word(kOldbutton)); - if (flags.z()) - return /* (notletgo3) */; - _cmp(ax, 1); - if (flags.z()) - goto doplace2; - return; -doplace2: - getEitherAd(); - isItWorn(); - if (!flags.z()) - goto notworntoopen; - wornError(); - return; -notworntoopen: - delPointer(); - al = data.byte(kItemframe); - _cmp(al, data.byte(kOpenedob)); - if (!flags.z()) - goto isntsame; - al = data.byte(kObjecttype); - _cmp(al, data.byte(kOpenedtype)); - if (!flags.z()) - goto isntsame; - errorMessage1(); - return; -isntsame: - checkObjectSize(); - _cmp(al, 0); - if (flags.z()) - goto sizeok1; - return; -sizeok1: - data.byte(kPickup) = 0; - al = data.byte(kItemframe); - getEitherAd(); - al = data.byte(kOpenedtype); - es.byte(bx+2) = al; - al = data.byte(kOpenedob); - es.byte(bx+3) = al; - al = data.byte(kLastinvpos); - es.byte(bx+4) = al; - al = data.byte(kReallocation); - es.byte(bx+5) = al; - fillOpen(); - underTextLine(); - readMouse(); - useOpened(); - showPointer(); - workToScreen(); - delPointer(); -} - void DreamGenContext::outOfOpen() { STACK_CHECK; _cmp(data.byte(kOpenedob), 255); diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index ffefa0dd3e..3ddf858053 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -469,7 +469,6 @@ public: void findAllOpen(); void fillOpen(); void getEitherAd(); - void useOpened(); void swapWithOpen(); void dreamweb(); void findPathOfPoint(); diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp index 9d81825964..8399c6f26a 100644 --- a/engines/dreamweb/object.cpp +++ b/engines/dreamweb/object.cpp @@ -834,4 +834,72 @@ void DreamGenContext::reExFromInv() { data.byte(kPointermode) = 0; } +void DreamGenContext::useOpened() { + if (data.byte(kOpenedob) == 255) + return; // cannot use opened object + + if (!data.byte(kPickup)) { + outOfOpen(); + return; + } + + findOpenPos(); + ax = es.word(bx); + + if (al != 255) { + swapWithOpen(); + return; + } + + if (data.byte(kPickup) != 1) { + blank(); + return; + } + + uint16 subject = (data.byte(kObjecttype) << 8) | data.byte(kItemframe); + if (subject == data.word(kOldsubject)) { + if (data.byte(kCommandtype) != 227) { + data.byte(kCommandtype) = 227; + data.word(kOldsubject) = subject; + commandWithOb(35, data.byte(kObjecttype), data.byte(kItemframe)); + } + } else { + data.word(kOldsubject) = subject; + commandWithOb(35, data.byte(kObjecttype), data.byte(kItemframe)); + } + + if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) + return; + + if (isItWorn(getEitherAdCPP())) { + wornError(); + return; + } + + delPointer(); + + if (data.byte(kItemframe) == data.byte(kOpenedob) && + data.byte(kObjecttype) == data.byte(kOpenedtype)) { + errorMessage1(); + return; + } + + if (!checkObjectSizeCPP()) + return; + + data.byte(kPickup) = 0; + DynObject *object = getEitherAdCPP(); + object->mapad[0] = data.byte(kOpenedtype); + object->mapad[1] = data.byte(kOpenedob); + object->mapad[2] = data.byte(kLastinvpos); + object->mapad[3] = data.byte(kReallocation); + fillOpen(); + underTextLine(); + readMouse(); + useOpened(); + showPointer(); + workToScreenCPP(); + delPointer(); +} + } // End of namespace DreamGen diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index a4fcbf761d..4ba8cd6dd9 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -195,5 +195,6 @@ void selectLocation(); void reExFromInv(); void locationPic(); + void useOpened(); #endif |