DREAMWEB: 'getanyad' ported to C++

This commit is contained in:
Bertrand Augereau
2011-08-31 15:15:26 +02:00
parent cee156d596
commit cd5af89557
3 changed files with 22 additions and 0 deletions
+5
View File
@@ -77,6 +77,8 @@ struct SetObject {
uint8 b3;
uint8 b4;
uint8 priority;
uint16 w4() const { return READ_LE_UINT16(&b4); }
void setW4(uint16 v) { WRITE_LE_UINT16(&b4, v); }
uint8 b6;
uint8 delay;
uint8 type;
@@ -124,6 +126,9 @@ struct DynObject {
uint8 mapad[5];
uint8 b7;
uint8 b8;
uint16 w7() const { return READ_LE_UINT16(&b7); }
void setW7(uint16 v) { WRITE_LE_UINT16(&b7, v); }
uint8 b9;
uint8 b10;
uint8 initialLocation;
+16
View File
@@ -1188,6 +1188,22 @@ DynObject *DreamGenContext::geteitheradCPP() {
return getfreead(data.byte(kItemframe));
}
void *DreamGenContext::getanyad(uint16 *value) {
if (data.byte(kObjecttype) == 4) {
DynObject *exObject = getexad(data.byte(kCommand));
*value = exObject->w7();
return exObject;
} else if (data.byte(kObjecttype) == 2) {
DynObject *freeObject = getfreead(data.byte(kCommand));
*value = freeObject->w7();
return freeObject;
} else {
SetObject *setObject = getsetad(data.byte(kCommand));
*value = setObject->w4(); // Suspicious : conflicts with priority being a byte?
return setObject;
}
}
SetObject *DreamGenContext::getsetad(uint8 index) {
return (SetObject *)segRef(data.word(kSetdat)).ptr(0, 0) + index;
}
+1
View File
@@ -162,6 +162,7 @@
DynObject *getexad(uint8 index);
DynObject *geteitheradCPP();
SetObject *getsetad(uint8 index);
void *getanyad(uint16 *value);
void setallchanges();
void dochange();
void dochange(uint8 index, uint8 value, uint8 type);