Skip to content
Permalink
Browse files

CRYO: Use byteswap functions from common/endian.h

  • Loading branch information...
ccawley2011 authored and bluegr committed Nov 8, 2019
1 parent 8ac0012 commit b2452d6ffde98777353b2e2d9fcfd2de66d5a28b
Showing with 6 additions and 22 deletions.
  1. +0 −16 engines/cryo/cryolib.h
  2. +4 −4 engines/cryo/resource.cpp
  3. +2 −2 engines/cryo/video.cpp
@@ -32,22 +32,6 @@ namespace Cryo {

class CryoEngine;

#define SW16(n) ( (((n) & 0xFF) << 8) | (((n) >> 8) & 0xFF) )
#define SW32(n) ( (((n) & 0xFF) << 24) | (((n) >> 24) & 0xFF) | (((n) & 0xFF00) << 8) | (((n) >> 8) & 0xFF00))
#ifdef SCUMM_BIG_ENDIAN
//big-endian host
#define LE16(n) SW16(n)
#define LE32(n) SW32(n)
#define BE16(n) (n)
#define BE32(n) (n)
#else
//little-endian host
#define LE16(n) (n)
#define LE32(n) (n)
#define BE16(n) SW16(n)
#define BE32(n) SW32(n)
#endif

enum {
fsFromStart = 1
};
@@ -234,13 +234,13 @@ int EdenGame::loadSound(uint16 num) {

uint32 val = 0;
_bigfile.read(&val, 3);
unsigned int chunkLen = LE32(val);
unsigned int chunkLen = FROM_LE_32(val);

if (chunkType == 5) {
_bigfile.read(_gameLipsync + 7260, chunkLen);
chunkType = _bigfile.readByte();
_bigfile.read(&val, 3);
chunkLen = LE32(val);
chunkLen = FROM_LE_32(val);
}

// 3. Normal sound data
@@ -259,7 +259,7 @@ void EdenGame::convertMacToPC() {
// Array of longs
int *p = (int *)_gameLipsync;
for (int i = 0; i < 7240 / 4; i++)
p[i] = BE32(p[i]);
p[i] = FROM_BE_32(p[i]);
}

void EdenGame::loadpermfiles() {
@@ -472,7 +472,7 @@ bool EdenGame::ReadDataSyncVOC(unsigned int num) {
uint32 chunkLen = 0;
loadpartoffile(resNum, &chunkLen, filePos, 3);
filePos += 3;
chunkLen = LE32(chunkLen);
chunkLen = FROM_LE_32(chunkLen);
loadpartoffile(resNum, _gameLipsync + 7260, filePos, chunkLen);
return true;
}
@@ -129,7 +129,7 @@ void HnmPlayer::closeSound() {
void HnmPlayer::loadDecompTable(int16 *buffer) {
for (int16 i = 0; i < 256; i++) {
int16 e = *buffer++;
decompTable[i] = LE16(e);
decompTable[i] = FROM_LE_16(e);
}
}

@@ -225,7 +225,7 @@ void HnmPlayer::tryRead(int size) {
bool HnmPlayer::loadFrame() {
tryRead(4);
int chunk = *(int *)_readBuffer;
chunk = LE32(chunk);
chunk = FROM_LE_32(chunk);
chunk &= 0xFFFFFF; // upper bit - keyframe mark?
if (!chunk)
return false;

0 comments on commit b2452d6

Please sign in to comment.
You can’t perform that action at this time.