svn-id: r27552
This commit is contained in:
Travis Howell 2007-06-20 01:01:29 +00:00
parent b51f2f3212
commit 61c91cafb9
5 changed files with 127 additions and 110 deletions

View File

@ -759,7 +759,7 @@ void AGOSEngine_Simon2::setupGame() {
_itemMemSize = 20000;
_tableMemSize = 100000;
// Check whether to use MT-32 MIDI tracks in Simon the Sorcerer 2
if ((getGameType() == GType_SIMON2) && _nativeMT32)
if (getGameType() == GType_SIMON2 && _nativeMT32)
_musicIndexBase = (1128 + 612) / 4;
else
_musicIndexBase = 1128 / 4;

View File

@ -574,7 +574,7 @@ protected:
void setupStringTable(byte *mem, int num);
void setupLocalStringTable(byte *mem, int num);
void readGamePcText(Common::SeekableReadStream *in);
void readItemChildren(Common::SeekableReadStream *in, Item *item, uint tmp);
virtual void readItemChildren(Common::SeekableReadStream *in, Item *item, uint tmp);
void readItemFromGamePc(Common::SeekableReadStream *in, Item *item);
void loadGamePcFile();
void readGamePcFile(Common::SeekableReadStream *in);
@ -1369,6 +1369,8 @@ protected:
const OpcodeEntryElvira2 *_opcodesElvira2;
virtual void readItemChildren(Common::SeekableReadStream *in, Item *item, uint tmp);
virtual bool loadGame(const char *filename, bool restartMode = false);
virtual bool saveGame(uint slot, const char *caption);

View File

@ -351,104 +351,33 @@ void AGOSEngine::readItemFromGamePc(Common::SeekableReadStream *in, Item *item)
void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, uint type) {
if (type == 1) {
if (getGameType() == GType_ELVIRA1) {
SubRoom *subRoom = (SubRoom *)allocateChildBlock(item, 1, sizeof(SubRoom));
subRoom->roomShort = in->readUint32BE();
subRoom->roomLong = in->readUint32BE();
subRoom->flags = in->readUint16BE();
} else {
uint fr1 = in->readUint16BE();
uint fr2 = in->readUint16BE();
uint i, size;
uint j, k;
SubRoom *subRoom;
size = SubRoom_SIZE;
for (i = 0, j = fr2; i != 6; i++, j >>= 2)
if (j & 3)
size += sizeof(subRoom->roomExit[0]);
subRoom = (SubRoom *)allocateChildBlock(item, 1, size);
subRoom->subroutine_id = fr1;
subRoom->roomExitStates = fr2;
for (i = k = 0, j = fr2; i != 6; i++, j >>= 2)
if (j & 3)
subRoom->roomExit[k++] = (uint16)fileReadItemID(in);
}
SubRoom *subRoom = (SubRoom *)allocateChildBlock(item, 1, sizeof(SubRoom));
subRoom->roomShort = in->readUint32BE();
subRoom->roomLong = in->readUint32BE();
subRoom->flags = in->readUint16BE();
} else if (type == 2) {
if (getGameType() == GType_ELVIRA1) {
SubObject *subObject = (SubObject *)allocateChildBlock(item, 2, sizeof(SubObject));
in->readUint32BE();
in->readUint32BE();
in->readUint32BE();
subObject->objectName = in->readUint32BE();
subObject->objectSize = in->readUint16BE();
subObject->objectWeight = in->readUint16BE();
subObject->objectFlags = in->readUint16BE();
} else {
uint32 fr = in->readUint32BE();
uint i, k, size;
SubObject *subObject;
size = SubObject_SIZE;
for (i = 0; i != 16; i++)
if (fr & (1 << i))
size += sizeof(subObject->objectFlagValue[0]);
subObject = (SubObject *)allocateChildBlock(item, 2, size);
subObject->objectFlags = fr;
k = 0;
if (fr & 1) {
subObject->objectFlagValue[k++] = (uint16)in->readUint32BE();
}
for (i = 1; i != 16; i++)
if (fr & (1 << i))
subObject->objectFlagValue[k++] = in->readUint16BE();
if (getGameType() != GType_ELVIRA2)
subObject->objectName = (uint16)in->readUint32BE();
}
SubObject *subObject = (SubObject *)allocateChildBlock(item, 2, sizeof(SubObject));
in->readUint32BE();
in->readUint32BE();
in->readUint32BE();
subObject->objectName = in->readUint32BE();
subObject->objectSize = in->readUint16BE();
subObject->objectWeight = in->readUint16BE();
subObject->objectFlags = in->readUint16BE();
} else if (type == 4) {
if (getGameType() == GType_ELVIRA2) {
uint i, j, k, size;
uint id, x, y, z;
SubSuperRoom *subSuperRoom;
id = in->readUint16BE();
x = in->readUint16BE();
y = in->readUint16BE();
z = in->readUint16BE();
j = x * y * z;
size = SubSuperRoom_SIZE;
for (i = 0; i != j; i++)
size += sizeof(subSuperRoom->roomExitStates[0]);
subSuperRoom = (SubSuperRoom *)allocateChildBlock(item, 4, size);
subSuperRoom->subroutine_id = id;
subSuperRoom->roomX = x;
subSuperRoom->roomY = y;
subSuperRoom->roomZ = z;
for (i = k = 0; i != j; i++)
subSuperRoom->roomExitStates[k++] = in->readUint16BE();
} else if (getGameType() == GType_ELVIRA1) {
SubGenExit *genExit = (SubGenExit *)allocateChildBlock(item, 4, sizeof(SubGenExit));
genExit->dest[0] = (uint16)fileReadItemID(in);
genExit->dest[1] = (uint16)fileReadItemID(in);
genExit->dest[2] = (uint16)fileReadItemID(in);
genExit->dest[3] = (uint16)fileReadItemID(in);
genExit->dest[4] = (uint16)fileReadItemID(in);
genExit->dest[5] = (uint16)fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
}
SubGenExit *genExit = (SubGenExit *)allocateChildBlock(item, 4, sizeof(SubGenExit));
genExit->dest[0] = (uint16)fileReadItemID(in);
genExit->dest[1] = (uint16)fileReadItemID(in);
genExit->dest[2] = (uint16)fileReadItemID(in);
genExit->dest[3] = (uint16)fileReadItemID(in);
genExit->dest[4] = (uint16)fileReadItemID(in);
genExit->dest[5] = (uint16)fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
} else if (type == 7) {
SubContainer *container = (SubContainer *)allocateChildBlock(item, 7, sizeof(SubContainer));
container->volume = in->readUint16BE();
@ -461,17 +390,103 @@ void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, ui
setUserFlag(item, 1, in->readUint16BE());
setUserFlag(item, 2, in->readUint16BE());
setUserFlag(item, 3, in->readUint16BE());
if (getGameType() == GType_ELVIRA1) {
setUserFlag(item, 4, in->readUint16BE());
setUserFlag(item, 5, in->readUint16BE());
setUserFlag(item, 6, in->readUint16BE());
setUserFlag(item, 7, in->readUint16BE());
SubUserFlag *subUserFlag = (SubUserFlag *) findChildOfType(item, 9);
subUserFlag->userItems[0] = (uint16)fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
setUserFlag(item, 4, in->readUint16BE());
setUserFlag(item, 5, in->readUint16BE());
setUserFlag(item, 6, in->readUint16BE());
setUserFlag(item, 7, in->readUint16BE());
SubUserFlag *subUserFlag = (SubUserFlag *) findChildOfType(item, 9);
subUserFlag->userItems[0] = (uint16)fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
fileReadItemID(in);
} else if (type == 255) {
SubInherit *inherit = (SubInherit *)allocateChildBlock(item, 255, sizeof(SubInherit));
inherit->inMaster = (uint16)fileReadItemID(in);
} else {
error("readItemChildren: invalid type %d", type);
}
}
void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item *item, uint type) {
if (type == 1) {
uint fr1 = in->readUint16BE();
uint fr2 = in->readUint16BE();
uint i, size;
uint j, k;
SubRoom *subRoom;
size = SubRoom_SIZE;
for (i = 0, j = fr2; i != 6; i++, j >>= 2)
if (j & 3)
size += sizeof(subRoom->roomExit[0]);
subRoom = (SubRoom *)allocateChildBlock(item, 1, size);
subRoom->subroutine_id = fr1;
subRoom->roomExitStates = fr2;
for (i = k = 0, j = fr2; i != 6; i++, j >>= 2)
if (j & 3)
subRoom->roomExit[k++] = (uint16)fileReadItemID(in);
} else if (type == 2) {
uint32 fr = in->readUint32BE();
uint i, k, size;
SubObject *subObject;
size = SubObject_SIZE;
for (i = 0; i != 16; i++)
if (fr & (1 << i))
size += sizeof(subObject->objectFlagValue[0]);
subObject = (SubObject *)allocateChildBlock(item, 2, size);
subObject->objectFlags = fr;
k = 0;
if (fr & 1) {
subObject->objectFlagValue[k++] = (uint16)in->readUint32BE();
}
for (i = 1; i != 16; i++)
if (fr & (1 << i))
subObject->objectFlagValue[k++] = in->readUint16BE();
if (getGameType() != GType_ELVIRA2)
subObject->objectName = (uint16)in->readUint32BE();
} else if (type == 4) {
assert(getGameType() == GType_ELVIRA2);
uint i, j, k, size;
uint id, x, y, z;
SubSuperRoom *subSuperRoom;
id = in->readUint16BE();
x = in->readUint16BE();
y = in->readUint16BE();
z = in->readUint16BE();
j = x * y * z;
size = SubSuperRoom_SIZE;
for (i = 0; i != j; i++)
size += sizeof(subSuperRoom->roomExitStates[0]);
subSuperRoom = (SubSuperRoom *)allocateChildBlock(item, 4, size);
subSuperRoom->subroutine_id = id;
subSuperRoom->roomX = x;
subSuperRoom->roomY = y;
subSuperRoom->roomZ = z;
for (i = k = 0; i != j; i++)
subSuperRoom->roomExitStates[k++] = in->readUint16BE();
} else if (type == 7) {
SubContainer *container = (SubContainer *)allocateChildBlock(item, 7, sizeof(SubContainer));
container->volume = in->readUint16BE();
container->flags = in->readUint16BE();
} else if (type == 8) {
SubChain *chain = (SubChain *)allocateChildBlock(item, 8, sizeof(SubChain));
chain->chChained = (uint16)fileReadItemID(in);
} else if (type == 9) {
setUserFlag(item, 0, in->readUint16BE());
setUserFlag(item, 1, in->readUint16BE());
setUserFlag(item, 2, in->readUint16BE());
setUserFlag(item, 3, in->readUint16BE());
} else if (type == 255) {
SubInherit *inherit = (SubInherit *)allocateChildBlock(item, 255, sizeof(SubInherit));
inherit->inMaster = (uint16)fileReadItemID(in);

View File

@ -304,7 +304,7 @@ void AGOSEngine::printScreenText(uint vgaSpriteId, uint color, const char *strin
lettersPerRowJustified = stringLength / (stringLength / lettersPerRow + 1) + 1;
talkDelay = (stringLength + 3) / 3;
if ((getGameType() == GType_SIMON1) && (getFeatures() & GF_TALKIE)) {
if (getGameType() == GType_SIMON1 && (getFeatures() & GF_TALKIE)) {
if (_variableArray[141] == 0)
_variableArray[141] = 9;
_variableArray[85] = _variableArray[141] * talkDelay;

View File

@ -217,7 +217,7 @@ void AGOSEngine::checkScrollX(int16 x, int16 xpos) {
if (_scrollXMax == 0 || x == 0)
return;
if ((getGameType() == GType_FF) && (getBitFlag(80) || getBitFlag(82)))
if (getGameType() == GType_FF && (getBitFlag(80) || getBitFlag(82)))
return;
int16 tmp;