Skip to content

Commit

Permalink
DREAMWEB: Port 'setpickup' to C++ and added an enum for the object types
Browse files Browse the repository at this point in the history
  • Loading branch information
bluegr committed Dec 18, 2011
1 parent f69dfba commit 421c8cd
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 81 deletions.
1 change: 1 addition & 0 deletions devtools/tasmrecover/tasm-recover
Expand Up @@ -733,6 +733,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'setlocation',
'setmode',
'setmouse',
'setpickup',
'setsoundoff',
'settopleft',
'settopright',
Expand Down
65 changes: 0 additions & 65 deletions engines/dreamweb/dreamgen.cpp
Expand Up @@ -519,71 +519,6 @@ void DreamGenContext::searchForSame() {
bx = pop();
}

void DreamGenContext::setPickup() {
STACK_CHECK;
_cmp(data.byte(kObjecttype), 1);
if (flags.z())
goto cantpick;
_cmp(data.byte(kObjecttype), 3);
if (flags.z())
goto cantpick;
getAnyAd();
al = es.byte(bx+2);
_cmp(al, 4);
if (!flags.z())
goto canpick;
cantpick:
blank();
return;
canpick:
_cmp(data.byte(kCommandtype), 209);
if (flags.z())
goto alreadysp;
data.byte(kCommandtype) = 209;
bl = data.byte(kCommand);
bh = data.byte(kObjecttype);
al = 33;
commandWithOb();
alreadysp:
ax = data.word(kMousebutton);
_cmp(ax, 1);
if (!flags.z())
return /* (nosetpick) */;
_cmp(ax, data.word(kOldbutton));
if (!flags.z())
goto dosetpick;
return;
dosetpick:
createPanel();
showPanel();
showMan();
showExit();
examIcon();
data.byte(kPickup) = 1;
data.byte(kInvopen) = 2;
_cmp(data.byte(kObjecttype), 4);
if (flags.z())
goto pickupexob;
al = data.byte(kCommand);
data.byte(kItemframe) = al;
data.byte(kOpenedob) = 255;
transferToEx();
data.byte(kItemframe) = al;
data.byte(kObjecttype) = 4;
getEitherAd();
es.byte(bx+2) = 20;
es.byte(bx+3) = 255;
openInv();
workToScreenM();
return;
pickupexob:
al = data.byte(kCommand);
data.byte(kItemframe) = al;
data.byte(kOpenedob) = 255;
openInv();
workToScreenM();
}

void DreamGenContext::reExFromInv() {
STACK_CHECK;
findInvPos();
Expand Down
1 change: 0 additions & 1 deletion engines/dreamweb/dreamgen.h
Expand Up @@ -506,7 +506,6 @@ class DreamGenContext : public DreamBase, public Context {
void fillOpen();
void deleteExObject();
void getEitherAd();
void setPickup();
void dropObject();
void showDiaryKeys();
void useOpened();
Expand Down
59 changes: 55 additions & 4 deletions engines/dreamweb/object.cpp
Expand Up @@ -108,10 +108,10 @@ void DreamBase::obToInv(uint8 index, uint8 flag, uint16 x, uint16 y) {
}

void DreamBase::obPicture() {
if (data.byte(kObjecttype) == 1)
if (data.byte(kObjecttype) == kSetObjectType1)
return;
Frame *frames;
if (data.byte(kObjecttype) == 4)
if (data.byte(kObjecttype) == kExObjectType)
frames = (Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
else
frames = (Frame *)getSegment(data.word(kFreeframes)).ptr(0, 0);
Expand All @@ -133,15 +133,15 @@ void DreamBase::obIcons() {
void DreamGenContext::examineOb(bool examineAgain) {
data.byte(kPointermode) = 0;
data.word(kTimecount) = 0;

while (true) {
if (examineAgain) {
data.byte(kInmaparea) = 0;
data.byte(kExamagain) = 0;
data.byte(kOpenedob) = 255;
data.byte(kOpenedtype) = 255;
data.byte(kInvopen) = 0;
al = data.byte(kCommandtype);
data.byte(kObjecttype) = al;
data.byte(kObjecttype) = data.byte(kCommandtype);
data.byte(kItemframe) = 0;
data.byte(kPointerframe) = 0;
createPanel();
Expand All @@ -167,6 +167,7 @@ void DreamGenContext::examineOb(bool examineAgain) {
dumpTextLine();
delPointer();
data.byte(kGetback) = 0;

switch (data.byte(kInvopen)) {
case 0: {
RectWithCallback examList[] = {
Expand Down Expand Up @@ -207,6 +208,7 @@ void DreamGenContext::examineOb(bool examineAgain) {
break;
}
}

if (data.byte(kQuitrequested) != 0)
break;
if (data.byte(kExamagain) != 0)
Expand Down Expand Up @@ -426,4 +428,53 @@ void DreamGenContext::selectOb() {
}
}

void DreamGenContext::setPickup() {
if (data.byte(kObjecttype) != kSetObjectType1 && data.byte(kObjecttype) != kSetObjectType3) {
// The original called getAnyAd() here. However, since object types
// 1 and 3 are excluded, the resulting object is a DynObject, so
// we can use getEitherAd() instead.
DynObject *object = getEitherAdCPP();
if (object->mapad[0] == 4) {
blank();
return;
}
} else {
blank();
return;
}

if (data.byte(kCommandtype) != 209) {
data.byte(kCommandtype) = 209;
commandWithOb(33, data.byte(kObjecttype), data.byte(kCommand));
}

if (data.word(kMousebutton) == 1 && data.word(kMousebutton) == data.word(kOldbutton))
return;

createPanel();
showPanel();
showMan();
showExit();
examIcon();
data.byte(kPickup) = 1;
data.byte(kInvopen) = 2;

if (data.byte(kObjecttype) != kExObjectType) {
data.byte(kItemframe) = data.byte(kCommand);
data.byte(kOpenedob) = 255;
transferToEx();
data.byte(kItemframe) = data.byte(kCommand);
data.byte(kObjecttype) = kExObjectType;
DynObject *object = getEitherAdCPP();
object->mapad[0] = 20;
object->mapad[1] = 255;
} else {
data.byte(kItemframe) = data.byte(kCommand);
data.byte(kOpenedob) = 255;
}

openInv();
workToScreenM();
}

} // End of namespace DreamGen
4 changes: 2 additions & 2 deletions engines/dreamweb/people.cpp
Expand Up @@ -941,10 +941,10 @@ void DreamGenContext::mugger(ReelRoutine &routine) {
findXYFromPath();
data.byte(kResetmanxy) = 1;
data.byte(kCommand) = findExObject("WETA");
data.byte(kObjecttype) = 4;
data.byte(kObjecttype) = kExObjectType;
removeObFromInv();
data.byte(kCommand) = findExObject("WETB");
data.byte(kObjecttype) = 4;
data.byte(kObjecttype) = kExObjectType;
removeObFromInv();
makeMainScreen();
DreamBase::setupTimedUse(48, 70, 10, 68 - 32, 54 + 64);
Expand Down
7 changes: 7 additions & 0 deletions engines/dreamweb/structs.h
Expand Up @@ -296,6 +296,13 @@ struct Atmosphere {
uint8 _repeat;
};

enum ObjectTypes {
kSetObjectType1 = 1,
kFreeObjectType = 2,
kSetObjectType3 = 3,
kExObjectType = 4
};

} // End of namespace DreamWeb

#endif
Expand Down
16 changes: 8 additions & 8 deletions engines/dreamweb/stubs.cpp
Expand Up @@ -1354,24 +1354,24 @@ DynObject *DreamBase::getExAd(uint8 index) {
}

DynObject *DreamBase::getEitherAdCPP() {
if (data.byte(kObjecttype) == 4)
if (data.byte(kObjecttype) == kExObjectType)
return getExAd(data.byte(kItemframe));
else
return getFreeAd(data.byte(kItemframe));
}

void *DreamBase::getAnyAd(uint8 *value1, uint8 *value2) {
if (data.byte(kObjecttype) == 4) {
if (data.byte(kObjecttype) == kExObjectType) {
DynObject *exObject = getExAd(data.byte(kCommand));
*value1 = exObject->slotSize;
*value2 = exObject->slotCount;
return exObject;
} else if (data.byte(kObjecttype) == 2) {
} else if (data.byte(kObjecttype) == kFreeObjectType) {
DynObject *freeObject = getFreeAd(data.byte(kCommand));
*value1 = freeObject->slotSize;
*value2 = freeObject->slotCount;
return freeObject;
} else {
} else { // 1 or 3. 0 should never happen
SetObject *setObject = getSetAd(data.byte(kCommand));
// Note: the original returned slotCount/priority (bytes 4 and 5)
// instead of slotSize/slotCount (bytes 3 and 4).
Expand Down Expand Up @@ -1615,7 +1615,7 @@ void DreamBase::showPointer() {
data.word(kOldpointery) = data.word(kMousey);
if (data.byte(kPickup) == 1) {
const Frame *frames;
if (data.byte(kObjecttype) != 4)
if (data.byte(kObjecttype) != kExObjectType)
frames = (const Frame *)getSegment(data.word(kFreeframes)).ptr(0, 0);
else
frames = (const Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
Expand Down Expand Up @@ -3209,7 +3209,7 @@ void DreamBase::getBackToOps() {

void DreamGenContext::pickupOb(uint8 command, uint8 pos) {
data.byte(kLastinvpos) = pos;
data.byte(kObjecttype) = 2;
data.byte(kObjecttype) = kFreeObjectType;
data.byte(kItemframe) = command;
data.byte(kCommand) = command;
getAnyAd();
Expand Down Expand Up @@ -3353,13 +3353,13 @@ void DreamGenContext::obsThatDoThings() {
void DreamGenContext::describeOb() {
const uint8 *obText = getObTextStartCPP();
uint16 y = 92;
if (data.byte(kForeignrelease) && data.byte(kObjecttype) == 1)
if (data.byte(kForeignrelease) && data.byte(kObjecttype) == kSetObjectType1)
y = 82;
data.word(kCharshift) = 91 + 91;
printDirect(&obText, 33, &y, 241, 241 & 1);
data.word(kCharshift) = 0;
y = 104;
if (data.byte(kForeignrelease) && data.byte(kObjecttype) == 1)
if (data.byte(kForeignrelease) && data.byte(kObjecttype) == kSetObjectType1)
y = 94;
printDirect(&obText, 36, &y, 241, 241 & 1);
obsThatDoThings();
Expand Down
1 change: 1 addition & 0 deletions engines/dreamweb/stubs.h
Expand Up @@ -403,5 +403,6 @@
void selectOb();
void findInvPos();
uint16 findInvPosCPP();
void setPickup();

#endif
2 changes: 1 addition & 1 deletion engines/dreamweb/use.cpp
Expand Up @@ -760,7 +760,7 @@ void DreamGenContext::useChurchGate() {

void DreamGenContext::useGun() {

if (data.byte(kObjecttype) != 4) {
if (data.byte(kObjecttype) != kExObjectType) {
// gun is not taken
showSecondUse();
putBackObStuff();
Expand Down

0 comments on commit 421c8cd

Please sign in to comment.