Skip to content

Commit

Permalink
DREAMWEB: Port 'intoinv', 'outofinv' to C++
Browse files Browse the repository at this point in the history
  • Loading branch information
bluegr committed Dec 19, 2011
1 parent 9916d2e commit f0eee81
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 114 deletions.
2 changes: 2 additions & 0 deletions devtools/tasmrecover/tasm-recover
Expand Up @@ -509,6 +509,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'input',
'interupttest',
'interviewer',
'intoinv',
'intro',
'intro1text',
'intro2text',
Expand Down Expand Up @@ -638,6 +639,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'openyourneighbour',
'othersmoker',
'out22c',
'outofinv',
'paltoendpal',
'paltostartpal',
'panelicons1',
Expand Down
112 changes: 0 additions & 112 deletions engines/dreamweb/dreamgen.cpp
Expand Up @@ -691,118 +691,6 @@ void DreamGenContext::swapWithOpen() {
delPointer();
}

void DreamGenContext::inToInv() {
STACK_CHECK;
_cmp(data.byte(kPickup), 0);
if (!flags.z())
goto notout;
outOfInv();
return;
notout:
findInvPos();
ax = es.word(bx);
_cmp(al, 255);
if (flags.z())
goto canplace1;
swapWithInv();
return;
canplace1:
al = data.byte(kItemframe);
ah = data.byte(kObjecttype);
_cmp(ax, data.word(kOldsubject));
if (!flags.z())
goto difsub1;
_cmp(data.byte(kCommandtype), 220);
if (flags.z())
goto alreadyplce;
data.byte(kCommandtype) = 220;
difsub1:
data.word(kOldsubject) = ax;
bx = ax;
al = 35;
commandWithOb();
alreadyplce:
ax = data.word(kMousebutton);
_cmp(ax, data.word(kOldbutton));
if (flags.z())
return /* (notletgo2) */;
_and(ax, 1);
if (!flags.z())
goto doplace;
return;
doplace:
delPointer();
al = data.byte(kItemframe);
getExAd();
es.byte(bx+2) = 4;
es.byte(bx+3) = 255;
al = data.byte(kLastinvpos);
es.byte(bx+4) = al;
data.byte(kPickup) = 0;
fillRyan();
readMouse();
showPointer();
outOfInv();
workToScreen();
delPointer();
}

void DreamGenContext::outOfInv() {
STACK_CHECK;
findInvPos();
ax = es.word(bx);
_cmp(al, 255);
if (!flags.z())
goto canpick2;
blank();
return;
canpick2:
bx = data.word(kMousebutton);
_cmp(bx, 2);
if (!flags.z())
goto canpick2a;
reExFromInv();
return;
canpick2a:
_cmp(ax, data.word(kOldsubject));
if (!flags.z())
goto difsub3;
_cmp(data.byte(kCommandtype), 221);
if (flags.z())
goto alreadygrab;
data.byte(kCommandtype) = 221;
difsub3:
data.word(kOldsubject) = ax;
bx = ax;
al = 36;
commandWithOb();
alreadygrab:
ax = data.word(kMousebutton);
_cmp(ax, data.word(kOldbutton));
if (flags.z())
return /* (notletgo) */;
_and(ax, 1);
if (!flags.z())
goto dograb;
return;
dograb:
delPointer();
data.byte(kPickup) = 1;
findInvPos();
ax = es.word(bx);
data.byte(kItemframe) = al;
data.byte(kObjecttype) = ah;
getExAd();
es.byte(bx+2) = 20;
es.byte(bx+3) = 255;
fillRyan();
readMouse();
showPointer();
inToInv();
workToScreen();
delPointer();
}

void DreamGenContext::getFreeAd() {
STACK_CHECK;
ah = 0;
Expand Down
2 changes: 0 additions & 2 deletions engines/dreamweb/dreamgen.h
Expand Up @@ -477,13 +477,11 @@ class DreamGenContext : public DreamBase, public Context {
void startTalk();
void getAnyAd();
void reminders();
void inToInv();
void getFreeAd();
void dirFile();
void pickupConts();
void fadeUpMon();
void reExFromInv();
void outOfInv();
void transferMap();
void purgeAnItem();
void purgeALocation();
Expand Down
82 changes: 82 additions & 0 deletions engines/dreamweb/object.cpp
Expand Up @@ -562,5 +562,87 @@ void DreamBase::removeObFromInv() {
deleteExObject(data.byte(kCommand));
}

void DreamGenContext::inToInv() {
if (!data.byte(kPickup)) {
outOfInv();
return;
}

findInvPos();
ax = es.word(bx);

This comment has been minimized.

Copy link
@wjp

wjp Dec 19, 2011

Contributor

Why are you using ax/es/bx here, instead of the return value of findInvPosCPP for bx, getSegment(data.word(kBuffers)) for es, and a regular local for ax, given that its value is only used for the al != 255 check directly below? (swapWithInv doesn't use ax as input.) Same question for the other usage of ax further down, and also for outOfInv.

This comment has been minimized.

Copy link
@bluegr

bluegr Dec 19, 2011

Author Member

My mistake, I didn't notice that there was a C++ version of findInvPos(), I'll update the code tonight

if (al != 255) {
swapWithInv();
return;
}

al = data.byte(kItemframe);
ah = data.byte(kObjecttype);

if (ax == data.word(kOldsubject) && data.byte(kCommandtype) != 220)
data.byte(kCommandtype) = 220;

This comment has been minimized.

Copy link
@wjp

wjp Dec 19, 2011

Contributor

This is wrong. The asm had no && here, but both checks did different things. Same for outOfInv.

data.word(kOldsubject) = ax;
commandWithOb(35, data.byte(kObjecttype), data.byte(kItemframe));

if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1))
return; // notletgo2

delPointer();
DynObject *object = getExAd(data.byte(kItemframe));
object->mapad[0] = 4;
object->mapad[1] = 255;
object->mapad[2] = data.byte(kLastinvpos);
data.byte(kPickup) = 0;
fillRyan();
readMouse();
showPointer();
outOfInv();
workToScreen();
delPointer();
}

void DreamGenContext::outOfInv() {
findInvPos();
ax = es.word(bx);

if (al == 255) {
blank();
return;
}

if (data.word(kMousebutton) == 2) {
reExFromInv();
return;
}

if (ax == data.word(kOldsubject) && data.byte(kCommandtype) != 221)
data.byte(kCommandtype) = 221;

data.word(kOldsubject) = ax;
commandWithOb(36, ah, al);

if (data.word(kMousebutton) == data.word(kOldbutton))
return; // notletgo

if (!(data.word(kMousebutton) & 1))
return;

delPointer();
data.byte(kPickup) = 1;
findInvPos();
ax = es.word(bx);
data.byte(kItemframe) = al;
data.byte(kObjecttype) = ah;
DynObject *object = getExAd(data.byte(kItemframe));
object->mapad[0] = 20;
object->mapad[1] = 255;
fillRyan();
readMouse();
showPointer();
inToInv();
workToScreen();
delPointer();
}

} // End of namespace DreamGen
2 changes: 2 additions & 0 deletions engines/dreamweb/stubs.h
Expand Up @@ -375,5 +375,7 @@
}
void signOn();
void lookAtPlace();
void inToInv();
void outOfInv();

#endif

0 comments on commit f0eee81

Please sign in to comment.