DREAMWEB: Port 'transfertoex' to C++

This commit is contained in:
Filippos Karapetis 2011-12-26 16:10:28 +02:00
parent e311f678b9
commit 63ba3988ff
5 changed files with 30 additions and 48 deletions

View File

@ -908,6 +908,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'train',
'transferinv',
'transfertext',
'transfertoex',
'trapdoor',
'triggermessage',
'trysoundalloc',

View File

@ -241,47 +241,6 @@ void DreamGenContext::getSetAd() {
es = data.word(kSetdat);
}
void DreamGenContext::transferToEx() {
STACK_CHECK;
emergencyPurge();
getExPos();
al = data.byte(kExpos);
push(ax);
push(di);
al = data.byte(kItemframe);
ah = 0;
bx = 16;
_mul(bx);
ds = data.word(kFreedat);
si = ax;
cx = 8;
_movsw(cx, true);
di = pop();
al = data.byte(kReallocation);
es.byte(di) = al;
es.byte(di+11) = al;
al = data.byte(kItemframe);
es.byte(di+1) = al;
es.byte(di+2) = 4;
es.byte(di+3) = 255;
al = data.byte(kLastinvpos);
es.byte(di+4) = al;
al = data.byte(kItemframe);
data.byte(kItemtotran) = al;
transferMap();
transferInv();
transferText();
al = data.byte(kItemframe);
ah = 0;
bx = 16;
_mul(bx);
ds = data.word(kFreedat);
si = ax;
ds.byte(si+2) = 254;
pickupConts();
ax = pop();
}
void DreamGenContext::pickupConts() {
STACK_CHECK;
al = ds.byte(si+7);

View File

@ -440,7 +440,6 @@ public:
void read();
void searchForString();
void getExAd();
void transferToEx();
void parser();
void transferConToEx();
};

View File

@ -446,8 +446,7 @@ void DreamGenContext::setPickup() {
if (data.byte(kObjecttype) != kExObjectType) {
data.byte(kItemframe) = data.byte(kCommand);
data.byte(kOpenedob) = 255;
transferToEx();
data.byte(kItemframe) = al;
data.byte(kItemframe) = transferToEx();
data.byte(kObjecttype) = kExObjectType;
DynObject *object = getExAd(data.byte(kItemframe));
object->mapad[0] = 20;
@ -964,8 +963,7 @@ void DreamGenContext::outOfOpen() {
data.byte(kItemframe) = objectId & 0xFF;
if (data.byte(kObjecttype) != 4) {
transferToEx();
data.byte(kItemframe) = al;
data.byte(kItemframe) = transferToEx();
data.byte(kObjecttype) = 4;
}
@ -1021,8 +1019,7 @@ void DreamGenContext::swapWithOpen() {
data.byte(kItemframe) = objectId & 0xFF;
if (data.byte(kObjecttype) != 4) {
transferToEx();
data.byte(kItemframe) = al;
data.byte(kItemframe) = transferToEx();
data.byte(kObjecttype) = 4;
}
@ -1059,4 +1056,29 @@ uint16 DreamBase::findOpenPos() {
return pos * 2 + kOpeninvlist; // return the object position in the inventory data
}
byte DreamGenContext::transferToEx() {
emergencyPurge();
getExPos();
byte pos = data.byte(kExpos);
DynObject *exObject = getExAd(pos);
DynObject *freeObject = getFreeAd(data.byte(kItemframe));
memcpy(exObject, freeObject, sizeof(DynObject));
exObject->currentLocation = data.byte(kReallocation);
exObject->initialLocation = data.byte(kReallocation);
exObject->index = data.byte(kItemframe);
exObject->mapad[0] = 4;
exObject->mapad[1] = 255;
exObject->mapad[2] = data.byte(kLastinvpos);
data.byte(kItemtotran) = data.byte(kItemframe);
transferMap();
transferInv();
transferText();
freeObject = getFreeAd(data.byte(kItemframe));
freeObject->mapad[0] = 254;
ds = data.word(kFreedat);
si = data.byte(kItemframe);
pickupConts();
return pos;
}
} // End of namespace DreamGen

View File

@ -139,5 +139,6 @@
void swapWithOpen();
void swapWithInv();
void searchForFiles();
byte transferToEx();
#endif