diff options
-rw-r--r-- | engines/cine/anim.cpp | 123 | ||||
-rw-r--r-- | engines/cine/bg.cpp | 5 | ||||
-rw-r--r-- | engines/cine/part.cpp | 3 | ||||
-rw-r--r-- | engines/cine/part.h | 12 | ||||
-rw-r--r-- | engines/cine/various.cpp | 9 | ||||
-rw-r--r-- | engines/cine/various.h | 2 |
6 files changed, 97 insertions, 57 deletions
diff --git a/engines/cine/anim.cpp b/engines/cine/anim.cpp index b5a52bed2b..10aee450cb 100644 --- a/engines/cine/anim.cpp +++ b/engines/cine/anim.cpp @@ -24,6 +24,7 @@ #include "common/stdafx.h" #include "common/endian.h" +#include "common/stream.h" #include "cine/cine.h" #include "cine/anim.h" @@ -404,14 +405,28 @@ void loadMsk(const char *resourceName) { foundFileIdx = findFileInBundle(resourceName); dataPtr = readBundleFile(foundFileIdx); - ptr = dataPtr; - - memcpy(&animHeader, ptr, sizeof(animHeaderStruct)); - ptr += sizeof(animHeaderStruct); - - animHeader.frameWidth = TO_BE_16(animHeader.frameWidth); - animHeader.frameHeight = TO_BE_16(animHeader.frameHeight); - animHeader.numFrames = TO_BE_16(animHeader.numFrames); + Common::MemoryReadStream readS(dataPtr, 0x16); + + animHeader.field_0 = readS.readByte(); + animHeader.field_1 = readS.readByte(); + animHeader.field_2 = readS.readByte(); + animHeader.field_3 = readS.readByte(); + animHeader.frameWidth = readS.readUint16BE(); + animHeader.frameHeight = readS.readUint16BE(); + animHeader.field_8 = readS.readByte(); + animHeader.field_9 = readS.readByte(); + animHeader.field_A = readS.readByte(); + animHeader.field_B = readS.readByte(); + animHeader.field_C = readS.readByte(); + animHeader.field_D = readS.readByte(); + animHeader.numFrames = readS.readUint16BE(); + animHeader.field_10 = readS.readByte(); + animHeader.field_11 = readS.readByte(); + animHeader.field_12 = readS.readByte(); + animHeader.field_13 = readS.readByte(); + animHeader.field_14 = readS.readUint16BE(); + + ptr = dataPtr + 0x16; for (i = 0; i < animHeader.numFrames; i++) { entry = allocFrame(animHeader.frameWidth * 2, animHeader.frameHeight, 1); @@ -439,14 +454,28 @@ void loadAni(const char *resourceName) { foundFileIdx = findFileInBundle(resourceName); dataPtr = readBundleFile(foundFileIdx); - ptr = dataPtr; - - memcpy(&animHeader, ptr, sizeof(animHeaderStruct)); - ptr += sizeof(animHeaderStruct); - - animHeader.frameWidth = TO_BE_16(animHeader.frameWidth); - animHeader.frameHeight = TO_BE_16(animHeader.frameHeight); - animHeader.numFrames = TO_BE_16(animHeader.numFrames); + Common::MemoryReadStream readS(dataPtr, 0x16); + + animHeader.field_0 = readS.readByte(); + animHeader.field_1 = readS.readByte(); + animHeader.field_2 = readS.readByte(); + animHeader.field_3 = readS.readByte(); + animHeader.frameWidth = readS.readUint16BE(); + animHeader.frameHeight = readS.readUint16BE(); + animHeader.field_8 = readS.readByte(); + animHeader.field_9 = readS.readByte(); + animHeader.field_A = readS.readByte(); + animHeader.field_B = readS.readByte(); + animHeader.field_C = readS.readByte(); + animHeader.field_D = readS.readByte(); + animHeader.numFrames = readS.readUint16BE(); + animHeader.field_10 = readS.readByte(); + animHeader.field_11 = readS.readByte(); + animHeader.field_12 = readS.readByte(); + animHeader.field_13 = readS.readByte(); + animHeader.field_14 = readS.readUint16BE(); + + ptr = dataPtr + 0x16; transparentColor = getAnimTransparentColor(resourceName); @@ -631,13 +660,17 @@ void loadSet(const char *resourceName) { int16 typeParam; byte table[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; - memcpy(&header2, ptr, 0x10); - ptr += 0x10; + Common::MemoryReadStream readS(ptr, 0x10); - header2.field_0 = TO_BE_32(header2.field_0); - header2.width = TO_BE_16(header2.width); - header2.height = TO_BE_16(header2.height); - header2.type = TO_BE_16(header2.type); + header2.field_0 = readS.readUint32BE(); + header2.width = readS.readUint16BE(); + header2.height = readS.readUint16BE(); + header2.type = readS.readUint16BE(); + header2.field_A = readS.readUint16BE(); + header2.field_C = readS.readUint16BE(); + header2.field_E = readS.readUint16BE(); + + ptr += 0x10; fullSize = header2.width * header2.height; @@ -714,13 +747,17 @@ void loadSetAbs(const char *resourceName, uint16 idx) { int16 typeParam; byte table[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; - memcpy(&header2, ptr, 0x10); - ptr += 0x10; + Common::MemoryReadStream readS(ptr, 0x10); - header2.field_0 = TO_BE_32(header2.field_0); - header2.width = TO_BE_16(header2.width); - header2.height = TO_BE_16(header2.height); - header2.type = TO_BE_16(header2.type); + header2.field_0 = readS.readUint32BE(); + header2.width = readS.readUint16BE(); + header2.height = readS.readUint16BE(); + header2.type = readS.readUint16BE(); + header2.field_A = readS.readUint16BE(); + header2.field_C = readS.readUint16BE(); + header2.field_E = readS.readUint16BE(); + + ptr += 0x10; fullSize = header2.width * header2.height; @@ -855,7 +892,7 @@ void loadResourcesFromSave() { for (currentAnim = 0; currentAnim < NUM_MAX_ANIMDATA; currentAnim++) { AnimData *currentPtr = &animDataTable[currentAnim]; - if (refreshAnimData[currentAnim] && currentPtr->fileIdx != -1) { + if (currentPtr->refresh && currentPtr->fileIdx != -1) { int8 isMask = 0; int8 isSpl = 0; int16 foundFileIdx; @@ -892,12 +929,28 @@ void loadResourcesFromSave() { animHeader.numFrames = 1; isMask = -1; } else { - memcpy(&animHeader, ptr, sizeof(animHeaderStruct)); - ptr += sizeof(animHeaderStruct); - - animHeader.frameWidth = TO_BE_16(animHeader.frameWidth); - animHeader.frameHeight = TO_BE_16(animHeader.frameHeight); - animHeader.numFrames = TO_BE_16(animHeader.numFrames); + Common::MemoryReadStream readS(ptr, 0x22); + + animHeader.field_0 = readS.readByte(); + animHeader.field_1 = readS.readByte(); + animHeader.field_2 = readS.readByte(); + animHeader.field_3 = readS.readByte(); + animHeader.frameWidth = readS.readUint16BE(); + animHeader.frameHeight = readS.readUint16BE(); + animHeader.field_8 = readS.readByte(); + animHeader.field_9 = readS.readByte(); + animHeader.field_A = readS.readByte(); + animHeader.field_B = readS.readByte(); + animHeader.field_C = readS.readByte(); + animHeader.field_D = readS.readByte(); + animHeader.numFrames = readS.readUint16BE(); + animHeader.field_10 = readS.readByte(); + animHeader.field_11 = readS.readByte(); + animHeader.field_12 = readS.readByte(); + animHeader.field_13 = readS.readByte(); + animHeader.field_14 = readS.readUint16BE(); + + ptr += 0x16; } { diff --git a/engines/cine/bg.cpp b/engines/cine/bg.cpp index d2dcf60c75..397557d905 100644 --- a/engines/cine/bg.cpp +++ b/engines/cine/bg.cpp @@ -24,6 +24,7 @@ #include "common/stdafx.h" #include "common/endian.h" +#include "common/stream.h" #include "cine/cine.h" #include "cine/various.h" @@ -58,10 +59,10 @@ byte loadCt(const char *ctName) { assert(strstr(ctName, ".NEO")); - memcpy(header, ptr, 32); + Common::MemoryReadStream readS(ptr, 32); for (int i = 0; i < 16; i++) { - header[i] = TO_BE_16(header[i]); + header[i] = readS.readUint16BE(); } gfxConvertSpriteToRaw(page3Raw, ptr + 0x80, 160, 200); diff --git a/engines/cine/part.cpp b/engines/cine/part.cpp index 37bf41ec69..5346a380a9 100644 --- a/engines/cine/part.cpp +++ b/engines/cine/part.cpp @@ -193,8 +193,7 @@ void readFromPart(int16 idx, byte *dataPtr) { byte *readBundleFile(int16 foundFileIdx) { byte *dataPtr; - dataPtr = (byte *) malloc(partBuffer[foundFileIdx].unpackedSize); - memset(dataPtr, 0, partBuffer[foundFileIdx].unpackedSize); + dataPtr = (byte *)calloc(partBuffer[foundFileIdx].unpackedSize, 1); if (partBuffer[foundFileIdx].unpackedSize != partBuffer[foundFileIdx].packedSize) { byte *unpackBuffer; diff --git a/engines/cine/part.h b/engines/cine/part.h index f02cf2996d..ff51f8e307 100644 --- a/engines/cine/part.h +++ b/engines/cine/part.h @@ -26,16 +26,13 @@ #define CINE_PART_H_ namespace Cine { -#if !defined(__GNUC__) - #pragma START_PACK_STRUCTS -#endif struct PartBuffer { char partName[14]; uint32 offset; uint32 packedSize; uint32 unpackedSize; -} GCC_PACK; +}; struct AnimData { uint16 width; @@ -48,11 +45,10 @@ struct AnimData { int16 fileIdx; int16 frameIdx; char name[10]; -} GCC_PACK; -#if !defined(__GNUC__) - #pragma END_PACK_STRUCTS -#endif + // Not part of the data, but used when saving/restoring it. + bool refresh; +}; #define NUM_MAX_PARTDATA 255 #define NUM_MAX_ANIMDATA 255 diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index 4ea8f8712f..a36dd7b229 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -54,13 +54,6 @@ uint16 var5; int16 buildObjectListCommand(void); -// TODO: This could/should be a field in the AnimData struct, but as long as it -// is marked as packed I don't dare add anything to it without knowing more -// about how it's used. (It's quite possible that it no longer needs to be -// packed.) - -bool refreshAnimData[NUM_MAX_ANIMDATA]; - void drawString(const char *string, byte param) { } @@ -760,7 +753,7 @@ int16 makeLoad(char *saveName) { animDataTable[i].fileIdx = fHandle->readSint16BE(); animDataTable[i].frameIdx = fHandle->readSint16BE(); fHandle->read(animDataTable[i].name, 10); - refreshAnimData[i] = (fHandle->readByte() != 0); + animDataTable[i].refresh = (fHandle->readByte() != 0); } // TODO: handle screen params (really required ?) diff --git a/engines/cine/various.h b/engines/cine/various.h index a7d20b8397..b4fd60ade8 100644 --- a/engines/cine/various.h +++ b/engines/cine/various.h @@ -84,8 +84,6 @@ extern uint16 var3; extern uint16 var4; extern uint16 var5; -extern bool refreshAnimData[NUM_MAX_ANIMDATA]; - extern Common::File palFileHandle; extern Common::File partFileHandle; |