DREAMWEB: Convert resetLocation and purgeALocation to C++

This commit is contained in:
Max Horn 2011-12-20 11:23:51 +01:00
parent f41412186b
commit b6e139d112
7 changed files with 43 additions and 92 deletions

View File

@ -676,6 +676,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'printsprites',
'printundermon',
'processtrigger',
'purgealocation',
'putbackobstuff',
'putundercentre',
'putundermenu',
@ -716,6 +717,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'removesetobject',
'removeobfrominv',
'resetkeyboard',
'resetlocation',
'restoreall',
'restoreems',
'restorereels',

View File

@ -143,6 +143,7 @@ public:
void showArrows();
uint8 getLocation(uint8 index);
void setLocation(uint8 index);
void resetLocation(uint8 index);
// from object.cpp
void obIcons();
@ -154,6 +155,7 @@ public:
void deleteExObject(uint8 index);
void deleteExFrame(uint8 frameNum);
void deleteExText(uint8 textNum);
void purgeALocation(uint8 index);
// from pathfind.cpp
void turnPathOn(uint8 param);

View File

@ -1130,37 +1130,6 @@ void DreamGenContext::transferConToEx() {
ds.byte(si+2) = 255;
}
void DreamGenContext::purgeALocation() {
STACK_CHECK;
push(ax);
es = data.word(kExtras);
di = (0+2080+30000);
bx = pop();
cx = 0;
purgeloc:
_cmp(bl, es.byte(di+0));
if (!flags.z())
goto dontpurge;
_cmp(es.byte(di+2), 0);
if (!flags.z())
goto dontpurge;
push(di);
push(es);
push(bx);
push(cx);
deleteExObject();
cx = pop();
bx = pop();
es = pop();
di = pop();
dontpurge:
_add(di, 16);
_inc(cx);
_cmp(cx, (114));
if (!flags.z())
goto purgeloc;
}
void DreamGenContext::emergencyPurge() {
STACK_CHECK;
checkpurgeagain:
@ -1491,57 +1460,6 @@ void DreamGenContext::getDestInfo() {
ax = pop();
}
void DreamGenContext::resetLocation() {
STACK_CHECK;
push(ax);
_cmp(al, 5);
if (!flags.z())
goto notdelhotel;
purgeALocation();
al = 21;
purgeALocation();
al = 22;
purgeALocation();
al = 27;
purgeALocation();
goto clearedlocations;
notdelhotel:
_cmp(al, 8);
if (!flags.z())
goto notdeltvstud;
purgeALocation();
al = 28;
purgeALocation();
goto clearedlocations;
notdeltvstud:
_cmp(al, 6);
if (!flags.z())
goto notdelsarters;
purgeALocation();
al = 20;
purgeALocation();
al = 25;
purgeALocation();
goto clearedlocations;
notdelsarters:
_cmp(al, 13);
if (!flags.z())
goto notdelboathouse;
purgeALocation();
al = 29;
purgeALocation();
goto clearedlocations;
notdelboathouse:
clearedlocations:
ax = pop();
ah = 0;
bx = ax;
dx = data;
es = dx;
_add(bx, 555);
es.byte(bx) = 0;
}
void DreamGenContext::dirCom() {
STACK_CHECK;
cx = 30;

View File

@ -469,7 +469,6 @@ public:
void getObTextStart();
void checkObjectSize();
void doSomeTalk();
void resetLocation();
void outOfOpen();
void dirCom();
void findFirstPath();
@ -481,7 +480,6 @@ public:
void reExFromInv();
void transferMap();
void purgeAnItem();
void purgeALocation();
void getSetAd();
void findOpenPos();
void searchForSame();

View File

@ -631,4 +631,39 @@ void DreamGenContext::outOfInv() {
delPointer();
}
void DreamBase::resetLocation(uint8 index) {
if (index == 5) {
// delete hotel
purgeALocation(5);
purgeALocation(21);
purgeALocation(22);
purgeALocation(27);
} else if (index == 8) {
// delete TV studio
purgeALocation(8);
purgeALocation(28);
} else if (index == 6) {
// delete sarters
purgeALocation(6);
purgeALocation(20);
purgeALocation(25);
} else if (index == 13) {
// delete boathouse
purgeALocation(13);
purgeALocation(29);
}
data.byte(kRoomscango + index) = 0;
}
void DreamBase::purgeALocation(uint8 index) {
// index == al
for (uint8 i = 0; i < kNumexobjects; ++i) {
DynObject *t = getExAd(i);
if (t->currentLocation == index && t->mapad[0] == 0) {
deleteExObject(i);
}
}
}
} // End of namespace DreamGen

View File

@ -3901,8 +3901,7 @@ void DreamGenContext::useButtonA() {
void DreamGenContext::autoAppear() {
if (data.byte(kLocation) == 32) {
// In alley
al = 5;
resetLocation();
resetLocation(5);
setLocation(10);
data.byte(kDestpos) = 10;
return;
@ -3932,8 +3931,7 @@ void DreamGenContext::autoAppear() {
if (data.byte(kReallocation) == 25) {
// Sart roof
data.byte(kNewsitem) = 3;
al = 6;
resetLocation();
resetLocation(6);
setLocation(11);
data.byte(kDestpos) = 11;
} else {
@ -4013,8 +4011,7 @@ void DreamGenContext::entryAnims() {
data.byte(kSpeedcount) = 1;
break;
case 44: // Sparky's
al = 8;
resetLocation();
resetLocation(8);
data.word(kWatchingtime) = 50*2;
data.word(kReeltowatch) = 247;
data.word(kEndwatchreel) = 297;

View File

@ -823,8 +823,7 @@ void DreamGenContext::useGun() {
} else if (data.byte(kReallocation) == 29) {
// aide
data.byte(kGetback) = 1;
al = 13;
resetLocation();
resetLocation(13);
setLocation(12);
data.byte(kDestpos) = 12;
data.byte(kDestination) = 2;