DREAMWEB: Port 'dropobject' to C++

This commit is contained in:
Filippos Karapetis 2011-12-24 13:27:09 +02:00
parent b9839635ea
commit be1a4de291
5 changed files with 54 additions and 102 deletions

View File

@ -385,6 +385,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'drawitall',
'drinker',
'droperror',
'dropobject',
'drunk',
'dumpblink',
'dumpcurrent',

View File

@ -580,107 +580,6 @@ findopenp1:
_add(bx, (0+(228*13)));
}
void DreamGenContext::dropObject() {
STACK_CHECK;
_cmp(data.byte(kCommandtype), 223);
if (flags.z())
goto alreadydrop;
data.byte(kCommandtype) = 223;
_cmp(data.byte(kPickup), 0);
if (flags.z())
{ blank(); return; };
bl = data.byte(kItemframe);
bh = data.byte(kObjecttype);
al = 37;
commandWithOb();
alreadydrop:
ax = data.word(kMousebutton);
_cmp(ax, data.word(kOldbutton));
if (flags.z())
return /* (nodrop) */;
_and(ax, 1);
if (!flags.z())
goto dodrop;
return;
dodrop:
getEitherAd();
isItWorn();
if (!flags.z())
goto nowornerror;
wornError();
return;
nowornerror:
_cmp(data.byte(kReallocation), 47);
if (flags.z())
goto nodrop2;
cl = data.byte(kRyanx);
_add(cl, 12);
ch = data.byte(kRyany);
_add(ch, 12);
checkOne();
_cmp(cl, 2);
if (flags.c())
goto nodroperror;
nodrop2:
dropError();
return;
nodroperror:
_cmp(data.byte(kMapxsize), 64);
if (!flags.z())
goto notinlift;
_cmp(data.byte(kMapysize), 64);
if (!flags.z())
goto notinlift;
dropError();
return;
notinlift:
al = data.byte(kItemframe);
ah = 4;
cl = 'G';
ch = 'U';
dl = 'N';
dh = 'A';
compare();
if (flags.z())
{ cantDrop(); return; };
al = data.byte(kItemframe);
ah = 4;
cl = 'S';
ch = 'H';
dl = 'L';
dh = 'D';
compare();
if (flags.z())
{ cantDrop(); return; };
data.byte(kObjecttype) = 4;
al = data.byte(kItemframe);
getExAd();
es.byte(bx+2) = 0;
al = data.byte(kRyanx);
_add(al, 4);
cl = 4;
_shr(al, cl);
_add(al, data.byte(kMapx));
ah = data.byte(kRyany);
_add(ah, 8);
cl = 4;
_shr(ah, cl);
_add(ah, data.byte(kMapy));
es.byte(bx+3) = al;
es.byte(bx+5) = ah;
al = data.byte(kRyanx);
_add(al, 4);
_and(al, 15);
ah = data.byte(kRyany);
_add(ah, 8);
_and(ah, 15);
es.byte(bx+4) = al;
es.byte(bx+6) = ah;
data.byte(kPickup) = 0;
al = data.byte(kReallocation);
es.byte(bx) = al;
}
void DreamGenContext::selectOpenOb() {
STACK_CHECK;
al = data.byte(kCommand);

View File

@ -475,7 +475,6 @@ public:
void findAllOpen();
void fillOpen();
void getEitherAd();
void dropObject();
void useOpened();
void locationPic();
void swapWithOpen();

View File

@ -704,5 +704,57 @@ const uint8 *DreamBase::getObTextStart() {
}
}
void DreamGenContext::dropObject() {
if (data.byte(kCommandtype) != 223) {
data.byte(kCommandtype) = 223;
if (!data.byte(kPickup)) {
blank();
return;
}
commandWithOb(37, data.byte(kObjecttype), data.byte(kItemframe));
}
if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1))
return;
if (isItWorn(getEitherAdCPP())) {
wornError();
return;
}
if (data.byte(kReallocation) != 47) {
byte flag, flagEx, type, flagX, flagY;
checkOne(data.byte(kRyanx) + 12, data.byte(kRyany) + 12, &flag, &flagEx, &type, &flagX, &flagY);
if (flag >= 2) {
dropError();
return;
}
} else {
dropError();
return;
}
if (data.byte(kMapxsize) == 64 && data.byte(kMapysize) == 64) {
// Inside lift
dropError();
return;
}
if (compare(data.byte(kItemframe), 4, "GUNA") || compare(data.byte(kItemframe), 4, "SHLD")) {
cantDrop();
return;
}
data.byte(kObjecttype) = 4;
DynObject *object = getExAd(data.byte(kItemframe));
object->mapad[0] = 0;
object->mapad[1] = ((data.byte(kRyanx) + 4) >> 4) + data.byte(kMapx);
object->mapad[2] = (data.byte(kRyanx) + 4) & 0xF;
object->mapad[3] = ((data.byte(kRyany) + 8) >> 4) + data.byte(kMapy);
object->mapad[4] = (data.byte(kRyany) + 8) & 0xF;
data.byte(kPickup) = 0;
object->currentLocation = data.byte(kReallocation);
}
} // End of namespace DreamGen

View File

@ -339,5 +339,6 @@
void outOfInv();
void edensFlatReminders();
void incRyanPage();
void dropObject();
#endif