aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2006-10-16 04:31:09 +0000
committerTravis Howell2006-10-16 04:31:09 +0000
commit0c761c26ab953323192bc1772c389e712af91a63 (patch)
tree87ecd50879346397fc8d83b1b98237a25a9bf84f
parentb2ce8001cd2d683bceacea2496db5606e8c4032b (diff)
downloadscummvm-rg350-0c761c26ab953323192bc1772c389e712af91a63.tar.gz
scummvm-rg350-0c761c26ab953323192bc1772c389e712af91a63.tar.bz2
scummvm-rg350-0c761c26ab953323192bc1772c389e712af91a63.zip
Auto decrunch the gamexx file when required
svn-id: r24344
-rw-r--r--engines/agos/agos.h19
-rw-r--r--engines/agos/game.cpp8
-rw-r--r--engines/agos/intern.h13
-rw-r--r--engines/agos/res.cpp66
-rw-r--r--engines/agos/subroutine.cpp8
5 files changed, 70 insertions, 44 deletions
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index 16cb15575f..09d4850e37 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -41,7 +41,7 @@ namespace AGOS {
//#define DUMP_FILE_NR 8
//#define DUMP_BITMAPS_FILE_NR 8
-uint fileReadItemID(Common::File *in);
+uint fileReadItemID(Common::SeekableReadStream *in);
#define CHECK_BOUNDS(x, y) assert((uint)(x) < ARRAYSIZE(y))
@@ -532,15 +532,16 @@ protected:
uint16 readUint16Wrapper(const void *src);
uint32 readUint32Wrapper(const void *src);
- int allocGamePcVars(Common::File *in);
+ int allocGamePcVars(Common::SeekableReadStream *in);
void createPlayer();
void allocateStringTable(int num);
void setupStringTable(byte *mem, int num);
void setupLocalStringTable(byte *mem, int num);
- void readGamePcText(Common::File *in);
- void readItemChildren(Common::File *in, Item *item, uint tmp);
- void readItemFromGamePc(Common::File *in, Item *item);
+ void readGamePcText(Common::SeekableReadStream *in);
+ void readItemChildren(Common::SeekableReadStream *in, Item *item, uint tmp);
+ void readItemFromGamePc(Common::SeekableReadStream *in, Item *item);
void loadGamePcFile();
+ void readGamePcFile(Common::SeekableReadStream *in);
void decompressData(const char *srcName, byte *dst, uint32 offset, uint32 srcSize, uint32 dstSize);
void loadOffsets(const char *filename, int number, uint32 &file, uint32 &offset, uint32 &compressedSize, uint32 &size);
void loadSound(uint sound, int pan, int vol, uint type);
@@ -564,11 +565,11 @@ protected:
void allocTablesHeap();
Subroutine *createSubroutine(uint a);
- void readSubroutine(Common::File *in, Subroutine *sub);
+ void readSubroutine(Common::SeekableReadStream *in, Subroutine *sub);
SubroutineLine *createSubroutineLine(Subroutine *sub, int a);
- void readSubroutineLine(Common::File *in, SubroutineLine *new_table, Subroutine *sub);
- byte *readSingleOpcode(Common::File *in, byte *ptr);
- void readSubroutineBlock(Common::File *in);
+ void readSubroutineLine(Common::SeekableReadStream *in, SubroutineLine *new_table, Subroutine *sub);
+ byte *readSingleOpcode(Common::SeekableReadStream *in, byte *ptr);
+ void readSubroutineBlock(Common::SeekableReadStream *in);
Subroutine *getSubroutineByID(uint subroutine_id);
diff --git a/engines/agos/game.cpp b/engines/agos/game.cpp
index 4756e5a353..a5f56c7ccf 100644
--- a/engines/agos/game.cpp
+++ b/engines/agos/game.cpp
@@ -225,7 +225,7 @@ static const ADGameFileDescription ELVIRA2DOS_FR_GameFiles[] = {
};
static const ADGameFileDescription WAXWORKSAMIGA_GameFiles[] = {
- { "gameamiga", GAME_BASEFILE, "e6207a69cf7356f13acbe8d14bdd844e"}, // Unpacked version
+ { "gameamiga", GAME_BASEFILE, "eca24fe7c3e005caca47cecac56f7245"},
{ "icon.pkd", GAME_ICONFILE, "4822a91c18b1b2005ac17fc617f7dcbe"},
{ "menus.dat", GAME_MENUFILE, "3409eeb8ca8b46fc04da99de67573f5e"},
{ "stripped.txt", GAME_STRFILE, "6faaebff2786216900061eeb978f10af"},
@@ -267,7 +267,7 @@ static const ADGameFileDescription SIMON1AMIGA_ECS_GameFiles[] = {
};
static const ADGameFileDescription SIMON1AMIGA_ECS_DEMO_GameFiles[] = {
- { "gameamiga", GAME_BASEFILE, "a12b696170f14eca5ff75f1549829251"}, // Unpacked version
+ { "gameamiga", GAME_BASEFILE, "4696309eed9d7335c62ebb87a0f006ad"},
{ "icon.pkd", GAME_ICONFILE, "ebc96af15bfaf75ba8210326b9260d2f"},
{ "stripped.txt", GAME_STRFILE, "8edde5b9498dc9f31da1093028da467c"},
{ "tbllist", GAME_TBLFILE, "1247e024e1f13ca54c1e354120c7519c"},
@@ -851,7 +851,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_WW,
GID_WAXWORKS,
- GF_OLD_BUNDLE | GF_CRUNCHED,
+ GF_OLD_BUNDLE | GF_CRUNCHED | GF_CRUNCHED_GAMEPC,
},
// Waxworks - English DOS Floppy
@@ -931,7 +931,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_SIMON1,
GID_SIMON1AMIGA,
- GF_32COLOR | GF_CRUNCHED | GF_OLD_BUNDLE | GF_DEMO,
+ GF_32COLOR | GF_CRUNCHED | GF_CRUNCHED_GAMEPC | GF_OLD_BUNDLE | GF_DEMO,
},
// Simon the Sorcerer 1 - English Amiga AGA Floppy
diff --git a/engines/agos/intern.h b/engines/agos/intern.h
index 2abb4a2547..573c900f69 100644
--- a/engines/agos/intern.h
+++ b/engines/agos/intern.h
@@ -205,12 +205,13 @@ enum SubObjectFlags {
};
enum GameFeatures {
- GF_TALKIE = 1 << 0,
- GF_OLD_BUNDLE = 1 << 1,
- GF_CRUNCHED = 1 << 2,
- GF_ZLIBCOMP = 1 << 3,
- GF_32COLOR = 1 << 4,
- GF_DEMO = 1 << 5
+ GF_TALKIE = 1 << 0,
+ GF_OLD_BUNDLE = 1 << 1,
+ GF_CRUNCHED = 1 << 2,
+ GF_CRUNCHED_GAMEPC = 1 << 3,
+ GF_ZLIBCOMP = 1 << 4,
+ GF_32COLOR = 1 << 5,
+ GF_DEMO = 1 << 6
};
enum GameFileTypes {
diff --git a/engines/agos/res.cpp b/engines/agos/res.cpp
index d2dbe5154e..7900d7823a 100644
--- a/engines/agos/res.cpp
+++ b/engines/agos/res.cpp
@@ -108,7 +108,7 @@ void AGOSEngine::loadOffsets(const char *filename, int number, uint32 &file, uin
in.close();
}
-int AGOSEngine::allocGamePcVars(File *in) {
+int AGOSEngine::allocGamePcVars(Common::SeekableReadStream *in) {
uint item_array_size, item_array_inited, stringtable_num;
uint32 version;
uint i;
@@ -118,11 +118,12 @@ int AGOSEngine::allocGamePcVars(File *in) {
item_array_inited = in->readUint32BE();
stringtable_num = in->readUint32BE();
+ // First two items are predefined
if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2) {
item_array_size += 2;
item_array_inited = item_array_size;
} else {
- item_array_inited += 2; // first two items are predefined
+ item_array_inited += 2;
item_array_size += 2;
}
@@ -149,27 +150,34 @@ int AGOSEngine::allocGamePcVars(File *in) {
void AGOSEngine::loadGamePcFile() {
Common::File in;
- int num_inited_objects;
- int i, fileSize;
+ int fileSize;
- /* read main gamepc file */
- in.open(getFileName(GAME_BASEFILE));
- if (in.isOpen() == false) {
- error("loadGamePcFile: Can't load gamepc file '%s'", getFileName(GAME_BASEFILE));
- }
+ if (getFileName(GAME_BASEFILE) != NULL) {
+ /* Read main gamexx file */
+ in.open(getFileName(GAME_BASEFILE));
+ if (in.isOpen() == false) {
+ error("loadGamePcFile: Can't load gamexx file '%s'", getFileName(GAME_BASEFILE));
+ }
- num_inited_objects = allocGamePcVars(&in);
+ if (getFeatures() & GF_CRUNCHED_GAMEPC) {
+ uint srcSize = in.size();
+ byte *srcBuf = (byte *)malloc(srcSize);
+ in.read(srcBuf, srcSize);
- createPlayer();
- readGamePcText(&in);
+ uint dstSize = READ_BE_UINT32(srcBuf + srcSize - 4);
+ byte *dstBuf = (byte *)malloc(dstSize);
+ decrunchFile(srcBuf, dstBuf, srcSize);
+ free(srcBuf);
- for (i = 2; i < num_inited_objects; i++) {
- readItemFromGamePc(&in, _itemArrayPtr[i]);
+ Common::MemoryReadStream stream(dstBuf, dstSize);
+ readGamePcFile(&stream);
+ free(dstBuf);
+ } else {
+ readGamePcFile(&in);
+ }
+ in.close();
}
- readSubroutineBlock(&in);
- in.close();
-
if (getFileName(GAME_TBLFILE) != NULL) {
/* Read list of TABLE resources */
in.open(getFileName(GAME_TBLFILE));
@@ -243,7 +251,23 @@ void AGOSEngine::loadGamePcFile() {
}
}
-void AGOSEngine::readGamePcText(Common::File *in) {
+void AGOSEngine::readGamePcFile(Common::SeekableReadStream *in) {
+ int num_inited_objects;
+ int i;
+
+ num_inited_objects = allocGamePcVars(in);
+
+ createPlayer();
+ readGamePcText(in);
+
+ for (i = 2; i < num_inited_objects; i++) {
+ readItemFromGamePc(in, _itemArrayPtr[i]);
+ }
+
+ readSubroutineBlock(in);
+}
+
+void AGOSEngine::readGamePcText(Common::SeekableReadStream *in) {
_textSize = in->readUint32BE();
_textMem = (byte *)malloc(_textSize);
if (_textMem == NULL)
@@ -254,7 +278,7 @@ void AGOSEngine::readGamePcText(Common::File *in) {
setupStringTable(_textMem, _stringTabNum);
}
-void AGOSEngine::readItemFromGamePc(Common::File *in, Item *item) {
+void AGOSEngine::readItemFromGamePc(Common::SeekableReadStream *in, Item *item) {
uint32 type;
if (getGameType() == GType_ELVIRA1) {
@@ -303,7 +327,7 @@ void AGOSEngine::readItemFromGamePc(Common::File *in, Item *item) {
}
}
-void AGOSEngine::readItemChildren(Common::File *in, Item *item, uint type) {
+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));
@@ -435,7 +459,7 @@ void AGOSEngine::readItemChildren(Common::File *in, Item *item, uint type) {
}
}
-uint fileReadItemID(Common::File *in) {
+uint fileReadItemID(Common::SeekableReadStream *in) {
uint32 val = in->readUint32BE();
if (val == 0xFFFFFFFF)
return 0;
diff --git a/engines/agos/subroutine.cpp b/engines/agos/subroutine.cpp
index c7535d0197..3cd05a5b31 100644
--- a/engines/agos/subroutine.cpp
+++ b/engines/agos/subroutine.cpp
@@ -579,18 +579,18 @@ bool AGOSEngine::checkIfToRunSubroutineLine(SubroutineLine *sl, Subroutine *sub)
return true;
}
-void AGOSEngine::readSubroutineBlock(File *in) {
+void AGOSEngine::readSubroutineBlock(Common::SeekableReadStream *in) {
while (in->readUint16BE() == 0) {
readSubroutine(in, createSubroutine(in->readUint16BE()));
}
}
-void AGOSEngine::readSubroutine(File *in, Subroutine *sub) {
+void AGOSEngine::readSubroutine(Common::SeekableReadStream *in, Subroutine *sub) {
while (in->readUint16BE() == 0) {
readSubroutineLine(in, createSubroutineLine(sub, 0xFFFF), sub);
}
}
-void AGOSEngine::readSubroutineLine(File *in, SubroutineLine *sl, Subroutine *sub) {
+void AGOSEngine::readSubroutineLine(Common::SeekableReadStream *in, SubroutineLine *sl, Subroutine *sub) {
byte line_buffer[2048], *q = line_buffer;
int size;
@@ -634,7 +634,7 @@ void AGOSEngine::readSubroutineLine(File *in, SubroutineLine *sl, Subroutine *su
}
}
-byte *AGOSEngine::readSingleOpcode(Common::File *in, byte *ptr) {
+byte *AGOSEngine::readSingleOpcode(Common::SeekableReadStream *in, byte *ptr) {
int i, l;
const char *string_ptr;
uint opcode, val;