DREAMWEB: Port 'findinvpos', 'selectob' to C++ and fix a regression in identifyOb()

This commit is contained in:
Filippos Karapetis 2011-12-17 13:47:42 +02:00
parent 8dec805d85
commit 05c5e224b4
5 changed files with 46 additions and 71 deletions

View File

@ -412,6 +412,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'finalframe',
'findallryan',
'findexobject',
'findinvpos',
'findlen',
'findnextcolon',
'findobname',
@ -710,6 +711,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'security',
'seecommandtail',
'selectlocation',
'selectob',
'selectslot',
'selectslot2',
'set16colpalette',

View File

@ -1091,36 +1091,6 @@ void DreamGenContext::getSetAd() {
es = data.word(kSetdat);
}
void DreamGenContext::findInvPos() {
STACK_CHECK;
cx = data.word(kMousex);
_sub(cx, (80));
bx = -1;
findinv1:
_inc(bx);
_sub(cx, (44));
if (!flags.c())
goto findinv1;
cx = data.word(kMousey);
_sub(cx, (58));
_sub(bx, 5);
findinv2:
_add(bx, 5);
_sub(cx, (44));
if (!flags.c())
goto findinv2;
al = data.byte(kRyanpage);
ah = 0;
cx = 10;
_mul(cx);
_add(bx, ax);
al = bl;
data.byte(kLastinvpos) = al;
_add(bx, bx);
es = data.word(kBuffers);
_add(bx, (0+(228*13)+32));
}
void DreamGenContext::findOpenPos() {
STACK_CHECK;
cx = data.word(kMousex);
@ -2736,45 +2706,6 @@ lookcolon:
goto lookcolon;
}
void DreamGenContext::selectOb() {
STACK_CHECK;
findInvPos();
ax = es.word(bx);
_cmp(al, 255);
if (!flags.z())
goto canselectob;
blank();
return;
canselectob:
data.byte(kWithobject) = al;
data.byte(kWithtype) = ah;
_cmp(ax, data.word(kOldsubject));
if (!flags.z())
goto diffsub3;
_cmp(data.byte(kCommandtype), 221);
if (flags.z())
goto alreadyselob;
data.byte(kCommandtype) = 221;
diffsub3:
data.word(kOldsubject) = ax;
bx = ax;
al = 0;
commandWithOb();
alreadyselob:
ax = data.word(kMousebutton);
_cmp(ax, data.word(kOldbutton));
if (flags.z())
return /* (notselob) */;
_and(ax, 1);
if (!flags.z())
goto doselob;
return;
doselob:
delPointer();
data.byte(kInvopen) = 0;
useRoutine();
}
void DreamGenContext::showDiaryKeys() {
STACK_CHECK;
_cmp(data.byte(kPresscount), 0);

View File

@ -496,9 +496,7 @@ public:
void removeObFromInv();
void dirFile();
void pickupConts();
void findInvPos();
void getKeyAndLogo();
void selectOb();
void fadeUpMon();
void reExFromInv();
void outOfInv();

View File

@ -331,6 +331,8 @@ void DreamGenContext::identifyOb() {
push(ax);
findPathOfPoint();
data.byte(kPointerspath) = dl;
ax = pop();
push(ax);
findFirstPath();
data.byte(kPointerfirstpath) = al;
ax = pop();
@ -354,4 +356,43 @@ void DreamGenContext::identifyOb() {
blank();
}
uint16 DreamGenContext::findInvPosCPP() {
uint16 x = data.word(kMousex) - kInventx;
uint16 y = data.word(kMousey) - kInventy;
uint16 pos = (x / kItempicsize) + (y / kItempicsize) * 5;
uint16 invPos = data.byte(kRyanpage) * 10 + pos;
data.byte(kLastinvpos) = invPos & 0xFF;
return invPos * 2 + kRyaninvlist;
}
void DreamGenContext::findInvPos() {
bx = findInvPosCPP();
es = data.word(kBuffers);
}
void DreamGenContext::selectOb() {
es = data.word(kBuffers);
uint16 objectId = es.word(findInvPosCPP());
if ((objectId & 0xFF) == 255) {
blank();
return;
}
data.byte(kWithobject) = objectId & 0x00FF;
data.byte(kWithtype) = objectId & 0xFF00;
if (objectId == data.word(kOldsubject) && data.byte(kCommandtype) != 221)
data.byte(kCommandtype) = 221;
data.word(kOldsubject) = objectId;
commandWithOb(0, data.byte(kWithtype), data.byte(kWithobject));
if (data.word(kMousebutton) != data.word(kOldbutton) && (data.word(kMousebutton) & 1)) {
delPointer();
data.byte(kInvopen) = 0;
useRoutine();
}
}
} // End of namespace DreamGen

View File

@ -398,5 +398,8 @@
void useStereo();
void checkInside();
uint16 checkInside(uint16 command, uint16 type);
void selectOb();
void findInvPos();
uint16 findInvPosCPP();
#endif