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

@ -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