diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/dreamweb/dreamgen.cpp | 102 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.h | 1 | ||||
-rw-r--r-- | engines/dreamweb/object.cpp | 91 | ||||
-rw-r--r-- | engines/dreamweb/stubs.h | 1 |
4 files changed, 82 insertions, 113 deletions
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 1afca17560..d68bd3b88f 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -284,108 +284,6 @@ findopen2a: goto findopen1a; } -void DreamGenContext::swapWithOpen() { - STACK_CHECK; - al = data.byte(kItemframe); - ah = data.byte(kObjecttype); - _cmp(ax, data.word(kOldsubject)); - if (!flags.z()) - goto difsub8; - _cmp(data.byte(kCommandtype), 242); - if (flags.z()) - goto alreadyswap2; - data.byte(kCommandtype) = 242; -difsub8: - data.word(kOldsubject) = ax; - bx = ax; - al = 34; - commandWithOb(); -alreadyswap2: - ax = data.word(kMousebutton); - _cmp(ax, data.word(kOldbutton)); - if (flags.z()) - return /* (cantswap2) */; - _and(ax, 1); - if (!flags.z()) - goto doswap2; - return; -doswap2: - getEitherAd(); - isItWorn(); - if (!flags.z()) - goto notwornswap; - wornError(); - return; -notwornswap: - delPointer(); - al = data.byte(kItemframe); - _cmp(al, data.byte(kOpenedob)); - if (!flags.z()) - goto isntsame2; - al = data.byte(kObjecttype); - _cmp(al, data.byte(kOpenedtype)); - if (!flags.z()) - goto isntsame2; - errorMessage1(); - return; -isntsame2: - checkObjectSize(); - _cmp(al, 0); - if (flags.z()) - goto sizeok2; - return; -sizeok2: - ah = data.byte(kObjecttype); - al = data.byte(kItemframe); - push(ax); - findOpenPos(); - ax = es.word(bx); - data.byte(kItemframe) = al; - data.byte(kObjecttype) = ah; - _cmp(ah, 4); - if (!flags.z()) - goto makeswapex; - getEitherAd(); - es.byte(bx+2) = 20; - es.byte(bx+3) = 255; - goto actuallyswap; -makeswapex: - transferToEx(); - data.byte(kItemframe) = al; - data.byte(kObjecttype) = 4; - getEitherAd(); - es.byte(bx+2) = 20; - es.byte(bx+3) = 255; -actuallyswap: - bl = data.byte(kItemframe); - bh = data.byte(kObjecttype); - ax = pop(); - data.byte(kObjecttype) = ah; - data.byte(kItemframe) = al; - push(bx); - findOpenPos(); - 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; - ax = pop(); - data.byte(kObjecttype) = ah; - data.byte(kItemframe) = al; - fillOpen(); - fillRyan(); - underTextLine(); - readMouse(); - useOpened(); - showPointer(); - workToScreen(); - delPointer(); -} - void DreamGenContext::getFreeAd() { STACK_CHECK; ah = 0; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 25901250b6..f585c6a7b4 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -469,7 +469,6 @@ public: void findAllOpen(); void fillOpen(); void getEitherAd(); - void swapWithOpen(); void dreamweb(); void findPathOfPoint(); void getDestInfo(); diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp index 9eb31f438f..6546f19da4 100644 --- a/engines/dreamweb/object.cpp +++ b/engines/dreamweb/object.cpp @@ -834,6 +834,49 @@ void DreamGenContext::reExFromInv() { data.byte(kPointermode) = 0; } +void DreamGenContext::swapWithInv() { + uint16 subject = (data.byte(kObjecttype) << 8) | data.byte(kItemframe); + if (subject == data.word(kOldsubject)) { + if (data.byte(kCommandtype) != 243) { + data.byte(kCommandtype) = 243; + data.word(kOldsubject) = subject; + commandWithOb(34, data.byte(kObjecttype), data.byte(kItemframe)); + } + } else { + data.word(kOldsubject) = subject; + commandWithOb(34, data.byte(kObjecttype), data.byte(kItemframe)); + } + + if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) + return; + + byte prevType = data.byte(kObjecttype); + byte prevFrame = data.byte(kItemframe); + uint16 objectId = getSegment(data.word(kBuffers)).word(findInvPosCPP()); + data.byte(kItemframe) = objectId & 0x00FF; + data.byte(kObjecttype) = objectId >> 8; + DynObject *object = getEitherAdCPP(); + object->mapad[0] = 20; + object->mapad[1] = 255; + byte prevType2 = data.byte(kObjecttype); + byte prevFrame2 = data.byte(kItemframe); + data.byte(kObjecttype) = prevType; + data.byte(kItemframe) = prevFrame; + //findInvPosCPP(); // found in the original source, but it seems to be useless + delPointer(); + object = getEitherAdCPP(); + object->mapad[0] = 4; + object->mapad[1] = 255; + object->mapad[2] = data.byte(kLastinvpos); + data.byte(kObjecttype) = prevType2; + data.byte(kItemframe) = prevFrame2; + fillRyan(); + readMouse(); + showPointer(); + workToScreenCPP(); + delPointer(); +} + void DreamGenContext::useOpened() { if (data.byte(kOpenedob) == 255) return; // cannot use opened object @@ -902,11 +945,11 @@ void DreamGenContext::useOpened() { delPointer(); } -void DreamGenContext::swapWithInv() { +void DreamGenContext::swapWithOpen() { uint16 subject = (data.byte(kObjecttype) << 8) | data.byte(kItemframe); if (subject == data.word(kOldsubject)) { - if (data.byte(kCommandtype) != 243) { - data.byte(kCommandtype) = 243; + if (data.byte(kCommandtype) != 242) { + data.byte(kCommandtype) = 242; data.word(kOldsubject) = subject; commandWithOb(34, data.byte(kObjecttype), data.byte(kItemframe)); } @@ -918,28 +961,56 @@ void DreamGenContext::swapWithInv() { 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; + byte prevType = data.byte(kObjecttype); byte prevFrame = data.byte(kItemframe); - uint16 objectId = getSegment(data.word(kBuffers)).word(findInvPosCPP()); - data.byte(kItemframe) = objectId & 0x00FF; - data.byte(kObjecttype) = objectId >> 8; + findOpenPos(); + ax = es.word(bx); + data.byte(kItemframe) = al; + data.byte(kObjecttype) = ah; + + if (data.byte(kObjecttype) != 4) { + transferToEx(); + data.byte(kItemframe) = al; + data.byte(kObjecttype) = 4; + } + DynObject *object = getEitherAdCPP(); object->mapad[0] = 20; object->mapad[1] = 255; + byte prevType2 = data.byte(kObjecttype); byte prevFrame2 = data.byte(kItemframe); data.byte(kObjecttype) = prevType; data.byte(kItemframe) = prevFrame; - //findInvPosCPP(); // found in the original source, but it seems to be useless - delPointer(); + findOpenPos(); object = getEitherAdCPP(); - object->mapad[0] = 4; - object->mapad[1] = 255; + object->mapad[0] = data.byte(kOpenedtype); + object->mapad[1] = data.byte(kOpenedob); object->mapad[2] = data.byte(kLastinvpos); + object->mapad[3] = data.byte(kReallocation); data.byte(kObjecttype) = prevType2; data.byte(kItemframe) = prevFrame2; + fillOpen(); fillRyan(); + underTextLine(); readMouse(); + useOpened(); showPointer(); workToScreenCPP(); delPointer(); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 2ac944b06a..0cdd68fa18 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -196,6 +196,7 @@ void reExFromInv(); void locationPic(); void useOpened(); + void swapWithOpen(); void swapWithInv(); #endif |