diff options
| author | Filippos Karapetis | 2016-10-03 05:29:58 +0300 |
|---|---|---|
| committer | Filippos Karapetis | 2016-10-03 05:29:58 +0300 |
| commit | cec2799c64d996dba247669c6eedfbffacc5f384 (patch) | |
| tree | eab233341f4f917a812301629f8d91fc6ecf855e | |
| parent | 9e5b745a123f0cc9b696eed6946edc31ef702dd8 (diff) | |
| download | scummvm-rg350-cec2799c64d996dba247669c6eedfbffacc5f384.tar.gz scummvm-rg350-cec2799c64d996dba247669c6eedfbffacc5f384.tar.bz2 scummvm-rg350-cec2799c64d996dba247669c6eedfbffacc5f384.zip | |
CHEWY: Properly handle the text encryption in atds.tap (game texts)
| -rw-r--r-- | engines/chewy/resource.cpp | 31 | ||||
| -rw-r--r-- | engines/chewy/resource.h | 1 |
2 files changed, 20 insertions, 12 deletions
diff --git a/engines/chewy/resource.cpp b/engines/chewy/resource.cpp index 90849cd555..352e2f11d7 100644 --- a/engines/chewy/resource.cpp +++ b/engines/chewy/resource.cpp @@ -41,9 +41,9 @@ namespace Chewy { // misc/inventar.iib // misc/inventar.sib // room/test.rdi -// txt/*.tap +// txt/atds.tap (game texts) // txt/diah.adh -// txt/inv_st.s and txt/room_st.s +// txt/inv_st.s and txt/room_st.s (inventory/room control bytes) // txt/inv_use.idx Resource::Resource(Common::String filename) { @@ -52,6 +52,7 @@ Resource::Resource(Common::String filename) { const uint32 headerTxtEnc = MKTAG('T', 'C', 'F', '\1'); const uint32 headerSprite = MKTAG('T', 'A', 'F', '\0'); + filename.toLowercase(); _stream.open(filename); uint32 header = _stream.readUint32BE(); @@ -72,6 +73,9 @@ Resource::Resource(Common::String filename) { _encrypted = false; } + if (filename == "atds.tap") + _encrypted = true; + _chunkCount = _stream.readUint16LE(); for (uint i = 0; i < _chunkCount; i++) { @@ -113,6 +117,8 @@ byte *Resource::getChunkData(uint num) { _stream.seek(chunk->pos, SEEK_SET); _stream.read(data, chunk->size); + if (_encrypted) + decrypt(data, chunk->size); return data; } @@ -170,6 +176,15 @@ void Resource::unpackRLE(byte *buffer, uint32 compressedSize, uint32 uncompresse } } +void Resource::decrypt(byte *data, uint32 size) { + byte *c = data; + + for (uint i = 0; i < size; i++) { + *c = -(*c); + ++c; + } +} + TAFChunk *SpriteResource::getSprite(uint num) { assert(num < _chunkList.size()); @@ -276,17 +291,9 @@ Common::String ErrorMessage::getErrorMessage(uint num) { byte *data = new byte[chunk->size]; _stream.seek(chunk->pos, SEEK_SET); - _stream.read(data, chunk->size); - - if (_encrypted) { - byte *c = data; - - for (uint i = 0; i < chunk->size; i++) { - *c = -(*c); - ++c; - } - } + if (_encrypted) + decrypt(data, chunk->size); str = (char *)data; delete[] data; diff --git a/engines/chewy/resource.h b/engines/chewy/resource.h index 8685cc6adc..7a79beb269 100644 --- a/engines/chewy/resource.h +++ b/engines/chewy/resource.h @@ -136,6 +136,7 @@ public: protected: void initSprite(Common::String filename); void unpackRLE(byte *buffer, uint32 compressedSize, uint32 uncompressedSize); + void decrypt(byte *data, uint32 size); Common::File _stream; uint16 _chunkCount; |
