Patch #754151: Removed READ_*_UNALIGNED and always read stuff bytewise; augmented by some more changes of mine

svn-id: r8482
This commit is contained in:
Max Horn 2003-06-14 18:52:30 +00:00
parent 9658dd6ea3
commit f7a8cbf7c7
19 changed files with 189 additions and 209 deletions

View file

@ -301,12 +301,21 @@
#error No system type defined #error No system type defined
#endif #endif
#define SWAP_BYTES(a) ((((a) >> 24) & 0xFF) | (((a) >> 8) & 0xFF00) | \ FORCEINLINE uint32 SWAP_BYTES_32(uint32 a) {
(((a) << 8) & 0xFF0000) | (((a) << 24) & 0xFF000000)) return ((a >> 24) & 0x000000FF) |
((a >> 8) & 0x0000FF00) |
((a << 8) & 0x00FF0000) |
((a << 24) & 0xFF000000);
}
FORCEINLINE uint16 SWAP_BYTES_16(uint16 a) {
return ((a >> 8) & 0x00FF) + ((a << 8) & 0xFF00);
}
#if defined(SCUMM_LITTLE_ENDIAN) #if defined(SCUMM_LITTLE_ENDIAN)
#define PROTO_MKID(a) SWAP_BYTES(a) #define PROTO_MKID(a) SWAP_BYTES_32(a)
#define PROTO_MKID_BE(a) (a & 0xffffffff) #define PROTO_MKID_BE(a) (a & 0xffffffff)
#if defined(INVERSE_MKID) #if defined(INVERSE_MKID)
@ -317,97 +326,30 @@
# define MKID_BE(a) PROTO_MKID_BE(a) # define MKID_BE(a) PROTO_MKID_BE(a)
#endif #endif
#if defined(SCUMM_NEED_ALIGNMENT) #define READ_UINT32(a) READ_LE_UINT32(a)
FORCEINLINE uint READ_LE_UINT16(const void *ptr) {
return (((const byte *)ptr)[1] << 8)|((const byte *)ptr)[0];
}
#else
FORCEINLINE uint READ_LE_UINT16(const void *ptr) {
return *(const uint16 *)(ptr);
}
#endif
FORCEINLINE uint READ_BE_UINT16(const void *ptr) { #define FROM_LE_32(a) (a)
return (((const byte *)ptr)[0] << 8)|((const byte *)ptr)[1]; #define FROM_LE_16(a) (a)
}
#if defined(SCUMM_NEED_ALIGNMENT) #define TO_LE_32(a) (a)
FORCEINLINE uint32 READ_LE_UINT32(const void *ptr) { #define TO_LE_16(a) (a)
const byte *b = (const byte *)ptr;
return (b[3] << 24) + (b[2] <<16) + (b[1] << 8) + (b[0]);
}
#else
FORCEINLINE uint32 READ_LE_UINT32(const void *ptr) {
return *(const uint32 *)(ptr);
}
#endif
FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) {
const byte *b = (const byte *)ptr;
return (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + (b[3]);
}
#define READ_BE_UINT32_UNALIGNED READ_BE_UINT32 #define TO_BE_32(a) SWAP_BYTES_32(a)
#define READ_BE_UINT16_UNALIGNED READ_BE_UINT16 #define TO_BE_16(a) SWAP_BYTES_16(a)
#define READ_UINT32_UNALIGNED(a) READ_LE_UINT32(a)
#define FROM_LE_32(__a__) __a__
#define FROM_LE_16(__a__) __a__
#define TO_LE_32(__a__) __a__
#define TO_LE_16(__a__) __a__
#define TO_BE_32(a) SWAP_BYTES(a)
FORCEINLINE uint16 TO_BE_16(uint16 a) { return (a >> 8) | (a << 8); }
#elif defined(SCUMM_BIG_ENDIAN) #elif defined(SCUMM_BIG_ENDIAN)
#define MKID(a) (a) #define MKID(a) (a)
#define MKID_BE(a) (a) #define MKID_BE(a) (a)
//#define MKID_BE(a) SWAP_BYTES(a) //#define MKID_BE(a) SWAP_BYTES_32(a)
FORCEINLINE uint32 FROM_LE_32(uint32 a) { #define READ_UINT32(a) READ_BE_UINT32(a)
return ((a >> 24) & 0xFF) + ((a >> 8) & 0xFF00) + (( a<< 8) & 0xFF0000) \
+ ((a<<24)&0xFF000000);
}
FORCEINLINE uint16 FROM_LE_16(uint16 a) { #define FROM_LE_32(a) SWAP_BYTES_32(a)
return ((a >> 8) & 0xFF) + ((a << 8) & 0xFF00); #define FROM_LE_16(a) SWAP_BYTES_16(a)
}
#define TO_LE_32 FROM_LE_32 #define TO_LE_32(a) SWAP_BYTES_32(a)
#define TO_LE_16 FROM_LE_16 #define TO_LE_16(a) SWAP_BYTES_16(a)
FORCEINLINE uint32 READ_LE_UINT32(const void *ptr) {
const byte *b = (const byte *)ptr;
return (b[3] << 24) + (b[2] << 16) + (b[1] << 8) + (b[0]);
}
FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) {
return *(const uint32 *)(ptr);
}
FORCEINLINE uint READ_LE_UINT16(const void *ptr) {
const byte *b = (const byte *)ptr;
return (b[1] << 8) + b[0];
}
FORCEINLINE uint READ_BE_UINT16(const void *ptr) {
return *(const uint16 *)(ptr);
}
FORCEINLINE uint READ_BE_UINT16_UNALIGNED(const void *ptr) {
return (((const byte *)ptr)[0] << 8)|((const byte *)ptr)[1];
}
FORCEINLINE uint32 READ_BE_UINT32_UNALIGNED(const void *ptr) {
const byte *b = (const byte*)ptr;
return (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + (b[3]);
}
#define READ_UINT32_UNALIGNED READ_BE_UINT32_UNALIGNED
#define TO_BE_32(a) (a) #define TO_BE_32(a) (a)
#define TO_BE_16(a) (a) #define TO_BE_16(a) (a)
@ -418,6 +360,44 @@
#endif #endif
#if defined(SCUMM_NEED_ALIGNMENT) || defined(SCUMM_BIG_ENDIAN)
FORCEINLINE uint16 READ_LE_UINT16(const void *ptr) {
const byte *b = (const byte *)ptr;
return (b[1] << 8) + b[0];
}
FORCEINLINE uint32 READ_LE_UINT32(const void *ptr) {
const byte *b = (const byte *)ptr;
return (b[3] << 24) + (b[2] << 16) + (b[1] << 8) + (b[0]);
}
#else
FORCEINLINE uint16 READ_LE_UINT16(const void *ptr) {
return *(const uint16 *)(ptr);
}
FORCEINLINE uint32 READ_LE_UINT32(const void *ptr) {
return *(const uint32 *)(ptr);
}
#endif
#if defined(SCUMM_NEED_ALIGNMENT) || defined(SCUMM_LITTLE_ENDIAN)
FORCEINLINE uint16 READ_BE_UINT16(const void *ptr) {
return (((const byte *)ptr)[0] << 8)|((const byte *)ptr)[1];
}
FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) {
const byte *b = (const byte*)ptr;
return (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + (b[3]);
}
#else
FORCEINLINE uint16 READ_BE_UINT16(const void *ptr) {
return *(const uint16 *)(ptr);
}
FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) {
return *(const uint32 *)(ptr);
}
#endif
#if defined(NEWGUI_256) #if defined(NEWGUI_256)
// 256 color only on PalmOS // 256 color only on PalmOS

View file

@ -255,7 +255,7 @@ byte AkosRenderer::drawLimb(const CostumeData &cost, int limb) {
if (code != AKC_ComplexChan) { if (code != AKC_ComplexChan) {
off = akof + (code & 0xFFF); off = akof + (code & 0xFFF);
assert((code & 0xFFF) * 6 < READ_BE_UINT32_UNALIGNED((const byte *)akof - 4) - 8); assert((code & 0xFFF) * 6 < READ_BE_UINT32((const byte *)akof - 4) - 8);
assert((code & 0x7000) == 0); assert((code & 0x7000) == 0);
_srcptr = akcd + READ_LE_UINT32(&off->akcd); _srcptr = akcd + READ_LE_UINT32(&off->akcd);

View file

@ -2619,9 +2619,9 @@ void Scumm::initCycl(const byte *ptr) {
ptr += 2; ptr += 2;
cycl->counter = 0; cycl->counter = 0;
cycl->delay = 16384 / READ_BE_UINT16_UNALIGNED(ptr); cycl->delay = 16384 / READ_BE_UINT16(ptr);
ptr += 2; ptr += 2;
cycl->flags = READ_BE_UINT16_UNALIGNED(ptr); cycl->flags = READ_BE_UINT16(ptr);
ptr += 2; ptr += 2;
cycl->start = *ptr++; cycl->start = *ptr++;
cycl->end = *ptr++; cycl->end = *ptr++;

View file

@ -100,7 +100,7 @@ byte *IMuseInternal::findStartOfSound (int sound) {
} }
ptr += 8; ptr += 8;
size = READ_BE_UINT32_UNALIGNED(ptr); size = READ_BE_UINT32(ptr);
ptr += 4; ptr += 4;
// Okay, we're looking for one of those things: either // Okay, we're looking for one of those things: either

View file

@ -803,7 +803,7 @@ void IMuseDigital::startSound(int sound) {
uint32 tag, size = 0, r, t; uint32 tag, size = 0, r, t;
if (READ_UINT32_UNALIGNED(ptr) == MKID('Crea')) { if (READ_UINT32(ptr) == MKID('Crea')) {
_channel[l]._bits = 8; _channel[l]._bits = 8;
_channel[l]._channels = 2; _channel[l]._channels = 2;
_channel[l]._mixerSize = (22050 / 5) * 2; _channel[l]._mixerSize = (22050 / 5) * 2;
@ -827,19 +827,19 @@ void IMuseDigital::startSound(int sound) {
} }
free(t_ptr); free(t_ptr);
_channel[l]._size = size; _channel[l]._size = size;
} else if (READ_UINT32_UNALIGNED(ptr) == MKID('iMUS')) { } else if (READ_UINT32(ptr) == MKID('iMUS')) {
ptr += 16; ptr += 16;
for (;;) { for (;;) {
tag = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4; tag = READ_BE_UINT32(ptr); ptr += 4;
switch(tag) { switch(tag) {
case MKID_BE('FRMT'): case MKID_BE('FRMT'):
ptr += 12; ptr += 12;
_channel[l]._bits = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4; _channel[l]._bits = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._freq = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4; _channel[l]._freq = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._channels = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4; _channel[l]._channels = READ_BE_UINT32(ptr); ptr += 4;
break; break;
case MKID_BE('TEXT'): case MKID_BE('TEXT'):
size = READ_BE_UINT32_UNALIGNED(ptr); ptr += size + 4; size = READ_BE_UINT32(ptr); ptr += size + 4;
break; break;
case MKID_BE('REGN'): case MKID_BE('REGN'):
ptr += 4; ptr += 4;
@ -848,13 +848,13 @@ void IMuseDigital::startSound(int sound) {
ptr += 8; ptr += 8;
break; break;
} }
_channel[l]._region[_channel[l]._numRegions]._offset = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4; _channel[l]._region[_channel[l]._numRegions]._offset = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._region[_channel[l]._numRegions]._length = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4; _channel[l]._region[_channel[l]._numRegions]._length = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._numRegions++; _channel[l]._numRegions++;
break; break;
case MKID_BE('STOP'): case MKID_BE('STOP'):
ptr += 4; ptr += 4;
_channel[l]._offsetStop = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4; _channel[l]._offsetStop = READ_BE_UINT32(ptr); ptr += 4;
break; break;
case MKID_BE('JUMP'): case MKID_BE('JUMP'):
ptr += 4; ptr += 4;
@ -863,15 +863,15 @@ void IMuseDigital::startSound(int sound) {
ptr += 16; ptr += 16;
break; break;
} }
_channel[l]._jump[_channel[l]._numJumps]._offset = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4; _channel[l]._jump[_channel[l]._numJumps]._offset = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._jump[_channel[l]._numJumps]._dest = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4; _channel[l]._jump[_channel[l]._numJumps]._dest = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._jump[_channel[l]._numJumps]._id = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4; _channel[l]._jump[_channel[l]._numJumps]._id = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._jump[_channel[l]._numJumps]._numLoops = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4; _channel[l]._jump[_channel[l]._numJumps]._numLoops = READ_BE_UINT32(ptr); ptr += 4;
_channel[l]._isJump = true; _channel[l]._isJump = true;
_channel[l]._numJumps++; _channel[l]._numJumps++;
break; break;
case MKID_BE('DATA'): case MKID_BE('DATA'):
size = READ_BE_UINT32_UNALIGNED(ptr); ptr += 4; size = READ_BE_UINT32(ptr); ptr += 4;
break; break;
default: default:
error("IMuseDigital::startSound(%d) Unknown sfx header %c%c%c%c", sound, (byte)(tag >> 24), (byte)(tag >> 16), (byte)(tag >> 8), (byte)tag); error("IMuseDigital::startSound(%d) Unknown sfx header %c%c%c%c", sound, (byte)(tag >> 24), (byte)(tag >> 16), (byte)(tag >> 8), (byte)tag);

View file

@ -973,7 +973,7 @@ void Scumm::addObjectToInventory(uint obj, uint room) {
if (whereIsObject(obj) == WIO_FLOBJECT) { if (whereIsObject(obj) == WIO_FLOBJECT) {
i = getObjectIndex(obj); i = getObjectIndex(obj);
ptr = getResourceAddress(rtFlObject, _objs[i].fl_object_index) + 8; ptr = getResourceAddress(rtFlObject, _objs[i].fl_object_index) + 8;
size = READ_BE_UINT32_UNALIGNED(ptr + 4); size = READ_BE_UINT32(ptr + 4);
} else { } else {
findObjectInRoom(&foir, foCodeHeader, obj, room); findObjectInRoom(&foir, foCodeHeader, obj, room);
if (_features & GF_OLD_BUNDLE) if (_features & GF_OLD_BUNDLE)
@ -981,7 +981,7 @@ void Scumm::addObjectToInventory(uint obj, uint room) {
else if (_features & GF_SMALL_HEADER) else if (_features & GF_SMALL_HEADER)
size = READ_LE_UINT32(foir.obcd); size = READ_LE_UINT32(foir.obcd);
else else
size = READ_BE_UINT32_UNALIGNED(foir.obcd + 4); size = READ_BE_UINT32(foir.obcd + 4);
ptr = foir.obcd; ptr = foir.obcd;
} }
@ -1352,7 +1352,7 @@ void Scumm::setCursorImg(uint img, uint room, uint imgindex) {
if (dataptr == NULL) if (dataptr == NULL)
error("setCursorImg: No such image"); error("setCursorImg: No such image");
size = READ_BE_UINT32_UNALIGNED(dataptr + 4); size = READ_BE_UINT32(dataptr + 4);
if (size > sizeof(_grabbedCursor)) if (size > sizeof(_grabbedCursor))
error("setCursorImg: Cursor image too large"); error("setCursorImg: Cursor image too large");
@ -1628,10 +1628,10 @@ void Scumm::loadFlObject(uint object, uint room) {
} }
// Setup sizes // Setup sizes
obcd_size = READ_BE_UINT32_UNALIGNED(foir.obcd + 4); obcd_size = READ_BE_UINT32(foir.obcd + 4);
od->OBCDoffset = 8; od->OBCDoffset = 8;
od->OBIMoffset = obcd_size + 8; od->OBIMoffset = obcd_size + 8;
obim_size = READ_BE_UINT32_UNALIGNED(foir.obim + 4); obim_size = READ_BE_UINT32(foir.obim + 4);
flob_size = obcd_size + obim_size + 8; flob_size = obcd_size + obim_size + 8;
// Lock room/roomScripts for the given room. They contains the OBCD/OBIM // Lock room/roomScripts for the given room. They contains the OBCD/OBIM

View file

@ -1366,7 +1366,7 @@ int Scumm::getResourceDataSize(const byte *ptr) const {
else if (_features & GF_SMALL_HEADER) else if (_features & GF_SMALL_HEADER)
return READ_LE_UINT32(ptr) - 6; return READ_LE_UINT32(ptr) - 6;
else else
return READ_BE_UINT32_UNALIGNED(ptr - 4) - 8; return READ_BE_UINT32(ptr - 4) - 8;
} }
struct FindResourceState { struct FindResourceState {
@ -1381,14 +1381,14 @@ const byte *findResource(uint32 tag, const byte *searchin) {
FindResourceState *f = &frs; /* easier to make it thread safe like this */ FindResourceState *f = &frs; /* easier to make it thread safe like this */
if (searchin) { if (searchin) {
f->size = READ_BE_UINT32_UNALIGNED(searchin + 4); f->size = READ_BE_UINT32(searchin + 4);
f->pos = 8; f->pos = 8;
f->ptr = searchin + 8; f->ptr = searchin + 8;
goto StartScan; goto StartScan;
} }
do { do {
size = READ_BE_UINT32_UNALIGNED(f->ptr + 4); size = READ_BE_UINT32(f->ptr + 4);
if ((int32)size <= 0) if ((int32)size <= 0)
return NULL; return NULL;
@ -1398,7 +1398,7 @@ const byte *findResource(uint32 tag, const byte *searchin) {
StartScan: StartScan:
if (f->pos >= f->size) if (f->pos >= f->size)
return NULL; return NULL;
} while (READ_UINT32_UNALIGNED(f->ptr) != tag); } while (READ_UINT32(f->ptr) != tag);
return f->ptr; return f->ptr;
} }
@ -1440,15 +1440,15 @@ const byte *findResource(uint32 tag, const byte *searchin, int idx) {
assert(searchin); assert(searchin);
searchin += 4; searchin += 4;
totalsize = READ_BE_UINT32_UNALIGNED(searchin); totalsize = READ_BE_UINT32(searchin);
curpos = 8; curpos = 8;
searchin += 4; searchin += 4;
while (curpos < totalsize) { while (curpos < totalsize) {
if (READ_UINT32_UNALIGNED(searchin) == tag && !idx--) if (READ_UINT32(searchin) == tag && !idx--)
return searchin; return searchin;
size = READ_BE_UINT32_UNALIGNED(searchin + 4); size = READ_BE_UINT32(searchin + 4);
if ((int32)size <= 0) { if ((int32)size <= 0) {
error("(%c%c%c%c) Not found in %d... illegal block len %d", error("(%c%c%c%c) Not found in %d... illegal block len %d",
tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size); tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size);

View file

@ -34,7 +34,7 @@ struct ResHdr {
#endif #endif
#define RES_DATA(x) (((const byte*)x) + sizeof(ResHdr)) #define RES_DATA(x) (((const byte*)x) + sizeof(ResHdr))
#define RES_SIZE(x) (READ_BE_UINT32_UNALIGNED(&((const ResHdr* )x)->size)) #define RES_SIZE(x) (READ_BE_UINT32(&((const ResHdr* )x)->size))
enum { enum {
OF_OWNER_MASK = 0x0F, OF_OWNER_MASK = 0x0F,

View file

@ -99,7 +99,7 @@ bool Scumm::loadState(int slot, bool compat, SaveFileManager *mgr) {
// In older versions of ScummVM, the header version was not endian safe. // In older versions of ScummVM, the header version was not endian safe.
// We account for that by retrying once with swapped byte order. // We account for that by retrying once with swapped byte order.
if (hdr.ver > CURRENT_VER) if (hdr.ver > CURRENT_VER)
hdr.ver = SWAP_BYTES(hdr.ver); hdr.ver = SWAP_BYTES_32(hdr.ver);
if (hdr.ver < VER_V7 || hdr.ver > CURRENT_VER) if (hdr.ver < VER_V7 || hdr.ver > CURRENT_VER)
{ {
warning("Invalid version of '%s'", filename); warning("Invalid version of '%s'", filename);

View file

@ -1951,17 +1951,17 @@ void Scumm_v5::o5_setObjectName() {
assert(searchin); assert(searchin);
searchin += 4; searchin += 4;
totalsize = READ_BE_UINT32_UNALIGNED(searchin); totalsize = READ_BE_UINT32(searchin);
curpos = 8; curpos = 8;
searchin += 4; searchin += 4;
while (curpos < totalsize) { while (curpos < totalsize) {
if (READ_UINT32_UNALIGNED(searchin) == tag) { if (READ_UINT32(searchin) == tag) {
name = searchin + _resourceHeaderSize; name = searchin + _resourceHeaderSize;
break; break;
} }
size = READ_BE_UINT32_UNALIGNED(searchin + 4); size = READ_BE_UINT32(searchin + 4);
if ((int32)size <= 0) { if ((int32)size <= 0) {
error("(%c%c%c%c) Not found in %d... illegal block len %d", error("(%c%c%c%c) Not found in %d... illegal block len %d",
tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size); tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size);

View file

@ -1780,7 +1780,7 @@ void Scumm::dumpResource(const char *tag, int idx, const byte *ptr, int length)
else if (_features & GF_SMALL_HEADER) else if (_features & GF_SMALL_HEADER)
size = READ_LE_UINT32(ptr); size = READ_LE_UINT32(ptr);
else else
size = READ_BE_UINT32_UNALIGNED(ptr + 4); size = READ_BE_UINT32(ptr + 4);
#if defined(MACOS_CARBON) #if defined(MACOS_CARBON)
sprintf(buf, ":dumps:%s%d.dmp", tag, idx); sprintf(buf, ":dumps:%s%d.dmp", tag, idx);

View file

@ -72,8 +72,8 @@ bool ImuseChannel::checkParameters(int32 index, int32 nbframes, int32 size, int3
bool ImuseChannel::appendData(Chunk &b, int32 size) { bool ImuseChannel::appendData(Chunk &b, int32 size) {
if (_dataSize == -1) { if (_dataSize == -1) {
assert(size > 8); assert(size > 8);
Chunk::type imus_type = b.getDword(); imus_type = SWAP_BYTES(imus_type); Chunk::type imus_type = b.getDword(); imus_type = SWAP_BYTES_32(imus_type);
uint32 imus_size = b.getDword(); imus_size = SWAP_BYTES(imus_size); uint32 imus_size = b.getDword(); imus_size = SWAP_BYTES_32(imus_size);
if (imus_type != TYPE_iMUS) if (imus_type != TYPE_iMUS)
error("Invalid Chunk for imuse_channel"); error("Invalid Chunk for imuse_channel");
size -= 8; size -= 8;
@ -109,14 +109,14 @@ bool ImuseChannel::appendData(Chunk &b, int32 size) {
bool ImuseChannel::handleFormat(Chunk &src) { bool ImuseChannel::handleFormat(Chunk &src) {
if (src.getSize() != 20) error("invalid size for FRMT Chunk"); if (src.getSize() != 20) error("invalid size for FRMT Chunk");
uint32 imuse_start = src.getDword(); uint32 imuse_start = src.getDword();
imuse_start = SWAP_BYTES(imuse_start); imuse_start = SWAP_BYTES_32(imuse_start);
src.seek(4); src.seek(4);
_bitsize = src.getDword(); _bitsize = src.getDword();
_bitsize = SWAP_BYTES(_bitsize); _bitsize = SWAP_BYTES_32(_bitsize);
_rate = src.getDword(); _rate = src.getDword();
_rate = SWAP_BYTES(_rate); _rate = SWAP_BYTES_32(_rate);
_channels = src.getDword(); _channels = src.getDword();
_channels = SWAP_BYTES(_channels); _channels = SWAP_BYTES_32(_channels);
assert(_channels == 1 || _channels == 2); assert(_channels == 1 || _channels == 2);
return true; return true;
} }

View file

@ -232,8 +232,8 @@ bool SaudChannel::checkParameters(int32 index, int32 nb, int32 flags, int32 volu
bool SaudChannel::appendData(Chunk &b, int32 size) { bool SaudChannel::appendData(Chunk &b, int32 size) {
if (_dataSize == -1) { if (_dataSize == -1) {
assert(size > 8); assert(size > 8);
Chunk::type saud_type = b.getDword(); saud_type = SWAP_BYTES(saud_type); Chunk::type saud_type = b.getDword(); saud_type = SWAP_BYTES_32(saud_type);
uint32 saud_size = b.getDword(); saud_size = SWAP_BYTES(saud_size); uint32 saud_size = b.getDword(); saud_size = SWAP_BYTES_32(saud_size);
if (saud_type != TYPE_SAUD) error("Invalid Chunk for SaudChannel : %X", saud_type); if (saud_type != TYPE_SAUD) error("Invalid Chunk for SaudChannel : %X", saud_type);
size -= 8; size -= 8;
_dataSize = -2; _dataSize = -2;

View file

@ -180,17 +180,17 @@ void Sound::playSound(int soundID) {
debug(3,"playSound #%d (room %d)", soundID, _scumm->getResourceRoomNr(rtSound, soundID)); debug(3,"playSound #%d (room %d)", soundID, _scumm->getResourceRoomNr(rtSound, soundID));
ptr = _scumm->getResourceAddress(rtSound, soundID); ptr = _scumm->getResourceAddress(rtSound, soundID);
if (ptr) { if (ptr) {
if (READ_UINT32_UNALIGNED(ptr) == MKID('iMUS')){ if (READ_UINT32(ptr) == MKID('iMUS')){
assert(_scumm->_imuseDigital); assert(_scumm->_imuseDigital);
_scumm->_imuseDigital->startSound(soundID); _scumm->_imuseDigital->startSound(soundID);
return; return;
} }
else if (READ_UINT32_UNALIGNED(ptr) == MKID('Crea')) { else if (READ_UINT32(ptr) == MKID('Crea')) {
assert(_scumm->_imuseDigital); assert(_scumm->_imuseDigital);
_scumm->_imuseDigital->startSound(soundID); _scumm->_imuseDigital->startSound(soundID);
return; return;
} }
else if (READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) { else if (READ_UINT32(ptr) == MKID('SOUN')) {
ptr += 8; ptr += 8;
_scumm->VAR(_scumm->VAR_MUSIC_TIMER) = 0; _scumm->VAR(_scumm->VAR_MUSIC_TIMER) = 0;
playCDTrack(ptr[16], ptr[17] == 0xff ? -1 : ptr[17], playCDTrack(ptr[16], ptr[17] == 0xff ? -1 : ptr[17],
@ -202,11 +202,11 @@ void Sound::playSound(int soundID) {
// Support for SFX in Monkey Island 1, Mac version // Support for SFX in Monkey Island 1, Mac version
// This is rather hackish right now, but works OK. SFX are not sounding // This is rather hackish right now, but works OK. SFX are not sounding
// 100% correct, though, not sure right now what is causing this. // 100% correct, though, not sure right now what is causing this.
else if (READ_UINT32_UNALIGNED(ptr) == MKID('Mac1')) { else if (READ_UINT32(ptr) == MKID('Mac1')) {
// Read info from the header // Read info from the header
size = READ_BE_UINT32_UNALIGNED(ptr+0x60); size = READ_BE_UINT32(ptr+0x60);
rate = READ_BE_UINT32_UNALIGNED(ptr+0x64) >> 16; rate = READ_BE_UINT32(ptr+0x64) >> 16;
// Skip over the header (fixed size) // Skip over the header (fixed size)
ptr += 0x72; ptr += 0x72;
@ -218,14 +218,14 @@ void Sound::playSound(int soundID) {
return; return;
} }
// Support for Putt-Putt sounds - very hackish, too 8-) // Support for Putt-Putt sounds - very hackish, too 8-)
else if (READ_UINT32_UNALIGNED(ptr) == MKID('DIGI')) { else if (READ_UINT32(ptr) == MKID('DIGI')) {
// TODO - discover what data the first chunk, HSHD, contains // TODO - discover what data the first chunk, HSHD, contains
// it might be useful here. // it might be useful here.
ptr += 8 + READ_BE_UINT32_UNALIGNED(ptr+12); ptr += 8 + READ_BE_UINT32(ptr+12);
if (READ_UINT32_UNALIGNED(ptr) != MKID('SDAT')) if (READ_UINT32(ptr) != MKID('SDAT'))
return; // abort return; // abort
size = READ_BE_UINT32_UNALIGNED(ptr+4) - 8; size = READ_BE_UINT32(ptr+4) - 8;
// FIXME - what value here ?!? 11025 is just a guess based on strings in w32 bin, prev guess 8000 // FIXME - what value here ?!? 11025 is just a guess based on strings in w32 bin, prev guess 8000
rate = 11025; rate = 11025;
@ -236,16 +236,16 @@ void Sound::playSound(int soundID) {
return; return;
} }
// XMIDI // XMIDI
else if ((READ_UINT32_UNALIGNED(ptr) == MKID('MIDI')) && (_scumm->_features & GF_HUMONGOUS)) { else if ((READ_UINT32(ptr) == MKID('MIDI')) && (_scumm->_features & GF_HUMONGOUS)) {
// Pass XMIDI on to IMuse unprocessed. // Pass XMIDI on to IMuse unprocessed.
// IMuse can handle XMIDI resources now. // IMuse can handle XMIDI resources now.
} }
else if (READ_UINT32_UNALIGNED(ptr) == MKID('ADL ')) { else if (READ_UINT32(ptr) == MKID('ADL ')) {
// played as MIDI, just to make perhaps the later use // played as MIDI, just to make perhaps the later use
// of WA possible (see "else if" with GF_OLD256 below) // of WA possible (see "else if" with GF_OLD256 below)
} }
// Support for sampled sound effects in Monkey1 and Monkey2 // Support for sampled sound effects in Monkey1 and Monkey2
else if (READ_UINT32_UNALIGNED(ptr) == MKID('SBL ')) { else if (READ_UINT32(ptr) == MKID('SBL ')) {
debug(2, "Using SBL sound effect"); debug(2, "Using SBL sound effect");
// TODO - Figuring out how the SBL chunk works. Here's // TODO - Figuring out how the SBL chunk works. Here's
@ -283,12 +283,12 @@ void Sound::playSound(int soundID) {
// I'm going to assume that the sample frequency is // I'm going to assume that the sample frequency is
// the only important difference between the two. // the only important difference between the two.
if (READ_UINT32_UNALIGNED(ptr + 8) == MKID('WVhd')) if (READ_UINT32(ptr + 8) == MKID('WVhd'))
rate = 11025; rate = 11025;
else else
rate = 8000; rate = 8000;
size = READ_BE_UINT32_UNALIGNED(ptr + 4) - 27; size = READ_BE_UINT32(ptr + 4) - 27;
// Allocate a sound buffer, copy the data into it, and play // Allocate a sound buffer, copy the data into it, and play
sound = (char *)malloc(size); sound = (char *)malloc(size);

View file

@ -558,7 +558,7 @@ void Scumm::setVerbObject(uint room, uint object, uint verb) {
} }
} else { } else {
findObjectInRoom(&foir, foImageHeader, object, room); findObjectInRoom(&foir, foImageHeader, object, room);
size = READ_BE_UINT32_UNALIGNED(foir.obim + 4); size = READ_BE_UINT32(foir.obim + 4);
createResource(rtVerb, verb, size); createResource(rtVerb, verb, size);
obimptr = getResourceAddress(rtRoom, room) - foir.roomptr + foir.obim; obimptr = getResourceAddress(rtRoom, room) - foir.roomptr + foir.obim;
memcpy(getResourceAddress(rtVerb, verb), obimptr, size); memcpy(getResourceAddress(rtVerb, verb), obimptr, size);

View file

@ -79,7 +79,7 @@ void SimonEngine::render_string(uint num_1, uint color, uint width, uint height,
*(uint16 *)(p + 4) = TO_BE_16(height); *(uint16 *)(p + 4) = TO_BE_16(height);
*(uint16 *)(p + 6) = TO_BE_16(width); *(uint16 *)(p + 6) = TO_BE_16(width);
dst += READ_BE_UINT32_UNALIGNED(p); dst += READ_BE_UINT32(p);
memset(dst, 0, count); memset(dst, 0, count);

View file

@ -175,7 +175,7 @@ void SimonEngine::dump_video_script(byte *src, bool one_opcode_only) {
do { do {
if (!(_game & GF_SIMON2)) { if (!(_game & GF_SIMON2)) {
opcode = READ_BE_UINT16_UNALIGNED(src); opcode = READ_BE_UINT16(src);
src += 2; src += 2;
} else { } else {
opcode = *src++; opcode = *src++;
@ -205,21 +205,21 @@ void SimonEngine::dump_video_script(byte *src, bool one_opcode_only) {
fprintf(_dump_file, "%d ", *src++); fprintf(_dump_file, "%d ", *src++);
break; break;
case 'd': case 'd':
fprintf(_dump_file, "%d ", READ_BE_UINT16_UNALIGNED(src)); fprintf(_dump_file, "%d ", READ_BE_UINT16(src));
src += 2; src += 2;
break; break;
case 'v': case 'v':
fprintf(_dump_file, "[%d] ", READ_BE_UINT16_UNALIGNED(src)); fprintf(_dump_file, "[%d] ", READ_BE_UINT16(src));
src += 2; src += 2;
break; break;
case 'i': case 'i':
fprintf(_dump_file, "%d ", (int16)READ_BE_UINT16_UNALIGNED(src)); fprintf(_dump_file, "%d ", (int16)READ_BE_UINT16(src));
src += 2; src += 2;
break; break;
case 'q': case 'q':
while (READ_BE_UINT16_UNALIGNED(src) != 999) { while (READ_BE_UINT16(src) != 999) {
fprintf(_dump_file, "(%d,%d) ", READ_BE_UINT16_UNALIGNED(src), fprintf(_dump_file, "(%d,%d) ", READ_BE_UINT16(src),
READ_BE_UINT16_UNALIGNED(src + 2)); READ_BE_UINT16(src + 2));
src += 4; src += 4;
} }
src++; src++;
@ -240,13 +240,13 @@ void SimonEngine::dump_vga_file(byte *vga) {
int count; int count;
pp = vga; pp = vga;
p = pp + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header *) pp)->hdr2_start); p = pp + READ_BE_UINT16(&((VgaFile1Header *) pp)->hdr2_start);
count = READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2 *) p)->id_count); count = READ_BE_UINT16(&((VgaFile1Header2 *) p)->id_count);
p = pp + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2 *) p)->id_table); p = pp + READ_BE_UINT16(&((VgaFile1Header2 *) p)->id_table);
while (--count >= 0) { while (--count >= 0) {
int id = READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x6 *) p)->id); int id = READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->id);
dump_vga_script_always(vga + READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x6 *) p)->script_offs), id / 100, id); dump_vga_script_always(vga + READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->script_offs), id / 100, id);
p += sizeof(VgaFile1Struct0x6); p += sizeof(VgaFile1Struct0x6);
} }
} }
@ -256,14 +256,14 @@ void SimonEngine::dump_vga_file(byte *vga) {
int c; int c;
bb = vga; bb = vga;
b = bb + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header *) bb)->hdr2_start); b = bb + READ_BE_UINT16(&((VgaFile1Header *) bb)->hdr2_start);
c = READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2 *) b)->unk1); c = READ_BE_UINT16(&((VgaFile1Header2 *) b)->unk1);
b = bb + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2 *) b)->unk2_offs); b = bb + READ_BE_UINT16(&((VgaFile1Header2 *) b)->unk2_offs);
while (--c >= 0) { while (--c >= 0) {
int id = READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x8 *) b)->id); int id = READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->id);
dump_vga_script_always(vga + READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x8 *) b)->script_offs), id / 100, id); dump_vga_script_always(vga + READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->script_offs), id / 100, id);
b += sizeof(VgaFile1Struct0x8); b += sizeof(VgaFile1Struct0x8);
} }
} }

View file

@ -2248,11 +2248,11 @@ void SimonEngine::set_video_mode_internal(uint mode, uint vga_res_id) {
// ensure flipping complete // ensure flipping complete
bb = _cur_vga_file_1; bb = _cur_vga_file_1;
b = bb + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header *) bb)->hdr2_start); b = bb + READ_BE_UINT16(&((VgaFile1Header *) bb)->hdr2_start);
c = READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2 *) b)->unk1); c = READ_BE_UINT16(&((VgaFile1Header2 *) b)->unk1);
b = bb + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2 *) b)->unk2_offs); b = bb + READ_BE_UINT16(&((VgaFile1Header2 *) b)->unk2_offs);
while (READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x8 *) b)->id) != vga_res_id) while (READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->id) != vga_res_id)
b += sizeof(VgaFile1Struct0x8); b += sizeof(VgaFile1Struct0x8);
if (!(_game & GF_SIMON2)) { if (!(_game & GF_SIMON2)) {
@ -2272,7 +2272,7 @@ void SimonEngine::set_video_mode_internal(uint mode, uint vga_res_id) {
vc_ptr_org = _vc_ptr; vc_ptr_org = _vc_ptr;
_vc_ptr = _cur_vga_file_1 + READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x8 *) b)->script_offs); _vc_ptr = _cur_vga_file_1 + READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->script_offs);
//dump_vga_script(_vc_ptr, num, vga_res_id); //dump_vga_script(_vc_ptr, num, vga_res_id);
run_vga_script(); run_vga_script();
_vc_ptr = vc_ptr_org; _vc_ptr = vc_ptr_org;
@ -2795,15 +2795,15 @@ void SimonEngine::timer_vga_sprites() {
_video_palette_mode = vsp->unk6; _video_palette_mode = vsp->unk6;
_vga_cur_sprite_id = vsp->id; _vga_cur_sprite_id = vsp->id;
params[0] = READ_BE_UINT16_UNALIGNED(&vsp->image); params[0] = READ_BE_UINT16(&vsp->image);
params[1] = READ_BE_UINT16_UNALIGNED(&vsp->base_color); params[1] = READ_BE_UINT16(&vsp->base_color);
params[2] = READ_BE_UINT16_UNALIGNED(&vsp->x); params[2] = READ_BE_UINT16(&vsp->x);
params[3] = READ_BE_UINT16_UNALIGNED(&vsp->y); params[3] = READ_BE_UINT16(&vsp->y);
if (_game & GF_SIMON2) { if (_game & GF_SIMON2) {
*(byte *)(&params[4]) = (byte)vsp->unk4; *(byte *)(&params[4]) = (byte)vsp->unk4;
} else { } else {
params[4] = READ_BE_UINT16_UNALIGNED(&vsp->unk4); params[4] = READ_BE_UINT16(&vsp->unk4);
} }
_vc_ptr = (byte *)params; _vc_ptr = (byte *)params;
@ -2837,7 +2837,7 @@ void SimonEngine::timer_vga_sprites_helper() {
} }
src = _vga_var7 + x * 4; src = _vga_var7 + x * 4;
decodeStripA(dst, src + READ_BE_UINT32_UNALIGNED(&*((uint32 *)src)), _vga_var5); decodeStripA(dst, src + READ_BE_UINT32(&*((uint32 *)src)), _vga_var5);
dx_unlock_2(); dx_unlock_2();
@ -2875,11 +2875,11 @@ void SimonEngine::timer_vga_sprites_2() {
if (vsp->image) if (vsp->image)
fprintf(_dump_file, "id:%5d image:%3d base-color:%3d x:%3d y:%3d flags:%x\n", fprintf(_dump_file, "id:%5d image:%3d base-color:%3d x:%3d y:%3d flags:%x\n",
vsp->id, vsp->image, vsp->base_color, vsp->x, vsp->y, vsp->unk4); vsp->id, vsp->image, vsp->base_color, vsp->x, vsp->y, vsp->unk4);
params[0] = READ_BE_UINT16_UNALIGNED(&vsp->image); params[0] = READ_BE_UINT16(&vsp->image);
params[1] = READ_BE_UINT16_UNALIGNED(&vsp->base_color); params[1] = READ_BE_UINT16(&vsp->base_color);
params[2] = READ_BE_UINT16_UNALIGNED(&vsp->x); params[2] = READ_BE_UINT16(&vsp->x);
params[3] = READ_BE_UINT16_UNALIGNED(&vsp->y); params[3] = READ_BE_UINT16(&vsp->y);
params[4] = READ_BE_UINT16_UNALIGNED(&vsp->unk4); params[4] = READ_BE_UINT16(&vsp->unk4);
_vc_ptr = (byte *)params; _vc_ptr = (byte *)params;
vc_10_draw(); vc_10_draw();
@ -3108,9 +3108,9 @@ void SimonEngine::o_pathfind(int x, int y, uint var_1, uint var_2) {
p = (uint16 *)_pathfind_array[20 - i]; p = (uint16 *)_pathfind_array[20 - i];
if (!p) if (!p)
continue; continue;
for (j = 0; READ_BE_UINT16_UNALIGNED(&p[0]) != 999; j++, p += 2) { // 0xE703 = byteswapped 999 for (j = 0; READ_BE_UINT16(&p[0]) != 999; j++, p += 2) { // 0xE703 = byteswapped 999
x_diff = abs((int)(READ_BE_UINT16_UNALIGNED(&p[0]) - x)); x_diff = abs((int)(READ_BE_UINT16(&p[0]) - x));
y_diff = abs((int)(READ_BE_UINT16_UNALIGNED(&p[1]) - 12 - y)); y_diff = abs((int)(READ_BE_UINT16(&p[1]) - 12 - y));
if (x_diff < y_diff) { if (x_diff < y_diff) {
x_diff >>= 2; x_diff >>= 2;
@ -3714,17 +3714,17 @@ void SimonEngine::start_vga_code(uint b, uint vga_res, uint vga_struct_id, uint
} }
pp = _cur_vga_file_1; pp = _cur_vga_file_1;
p = pp + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header *) pp)->hdr2_start); p = pp + READ_BE_UINT16(&((VgaFile1Header *) pp)->hdr2_start);
count = READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2 *) p)->id_count); count = READ_BE_UINT16(&((VgaFile1Header2 *) p)->id_count);
p = pp + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2 *) p)->id_table); p = pp + READ_BE_UINT16(&((VgaFile1Header2 *) p)->id_table);
for (;;) { for (;;) {
if (READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x6 *) p)->id) == vga_struct_id) { if (READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->id) == vga_struct_id) {
//dump_vga_script(pp + READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x6*)p)->script_offs), vga_res, vga_struct_id); //dump_vga_script(pp + READ_BE_UINT16(&((VgaFile1Struct0x6*)p)->script_offs), vga_res, vga_struct_id);
add_vga_timer(gss->VGA_DELAY_BASE, pp + READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x6 *) p)->script_offs), vga_struct_id, vga_res); add_vga_timer(gss->VGA_DELAY_BASE, pp + READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->script_offs), vga_struct_id, vga_res);
break; break;
} }
p += sizeof(VgaFile1Struct0x6); p += sizeof(VgaFile1Struct0x6);

View file

@ -120,7 +120,7 @@ void SimonEngine::run_vga_script() {
} }
if (!(_game & GF_SIMON2)) { if (!(_game & GF_SIMON2)) {
opcode = READ_BE_UINT16_UNALIGNED(_vc_ptr); opcode = READ_BE_UINT16(_vc_ptr);
_vc_ptr += 2; _vc_ptr += 2;
} else { } else {
opcode = *_vc_ptr++; opcode = *_vc_ptr++;
@ -144,7 +144,7 @@ int SimonEngine::vc_read_var_or_word() {
} }
uint SimonEngine::vc_read_next_word() { uint SimonEngine::vc_read_next_word() {
uint a = READ_BE_UINT16_UNALIGNED(_vc_ptr); uint a = READ_BE_UINT16(_vc_ptr);
_vc_ptr += 2; _vc_ptr += 2;
return a; return a;
} }
@ -245,15 +245,15 @@ void SimonEngine::vc_2_call() {
bb = _cur_vga_file_1; bb = _cur_vga_file_1;
b = bb + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header *) bb)->hdr2_start); b = bb + READ_BE_UINT16(&((VgaFile1Header *) bb)->hdr2_start);
b = bb + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2 *) b)->unk2_offs); b = bb + READ_BE_UINT16(&((VgaFile1Header2 *) b)->unk2_offs);
while (READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x8 *) b)->id) != num) while (READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->id) != num)
b += sizeof(VgaFile1Struct0x8); b += sizeof(VgaFile1Struct0x8);
vc_ptr_org = _vc_ptr; vc_ptr_org = _vc_ptr;
_vc_ptr = _cur_vga_file_1 + READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x8 *) b)->script_offs); _vc_ptr = _cur_vga_file_1 + READ_BE_UINT16(&((VgaFile1Struct0x8 *) b)->script_offs);
//dump_vga_script(_vc_ptr, res, num); //dump_vga_script(_vc_ptr, res, num);
run_vga_script(); run_vga_script();
@ -317,10 +317,10 @@ void SimonEngine::vc_3_new_sprite() {
} }
pp = _cur_vga_file_1; pp = _cur_vga_file_1;
p = pp + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header *) pp)->hdr2_start); p = pp + READ_BE_UINT16(&((VgaFile1Header *) pp)->hdr2_start);
p = pp + READ_BE_UINT16_UNALIGNED(&((VgaFile1Header2 *) p)->id_table); p = pp + READ_BE_UINT16(&((VgaFile1Header2 *) p)->id_table);
while (READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x6 *) p)->id) != b) while (READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->id) != b)
p += sizeof(VgaFile1Struct0x6); p += sizeof(VgaFile1Struct0x6);
#ifdef DUMP_FILE_NR #ifdef DUMP_FILE_NR
@ -343,9 +343,9 @@ void SimonEngine::vc_3_new_sprite() {
} }
#endif #endif
//dump_vga_script(_cur_vga_file_1 + READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x6*)p)->script_offs), res, b); //dump_vga_script(_cur_vga_file_1 + READ_BE_UINT16(&((VgaFile1Struct0x6*)p)->script_offs), res, b);
add_vga_timer(gss->VGA_DELAY_BASE, _cur_vga_file_1 + READ_BE_UINT16_UNALIGNED(&((VgaFile1Struct0x6 *) p)->script_offs), b, res); add_vga_timer(gss->VGA_DELAY_BASE, _cur_vga_file_1 + READ_BE_UINT16(&((VgaFile1Struct0x6 *) p)->script_offs), b, res);
} }
void SimonEngine::vc_4_dummy_op() { void SimonEngine::vc_4_dummy_op() {
@ -599,9 +599,9 @@ void SimonEngine::vc_10_draw() {
state.image = vc_read_var(-state.image); state.image = vc_read_var(-state.image);
p2 = _cur_vga_file_2 + state.image * 8; p2 = _cur_vga_file_2 + state.image * 8;
state.depack_src = _cur_vga_file_2 + READ_BE_UINT32_UNALIGNED(&*(uint32 *)p2); state.depack_src = _cur_vga_file_2 + READ_BE_UINT32(p2);
width = READ_BE_UINT16_UNALIGNED(p2 + 6) >> 4; width = READ_BE_UINT16(p2 + 6) >> 4;
height = p2[5]; height = p2[5];
flags = p2[4]; flags = p2[4];
@ -640,7 +640,7 @@ void SimonEngine::vc_10_draw() {
src = state.depack_src + _x_scroll * 4; src = state.depack_src + _x_scroll * 4;
for (w = 0; w < 40; w++) { for (w = 0; w < 40; w++) {
decodeStripA(dst, src + READ_BE_UINT32_UNALIGNED(&*(uint32 *)src), height); decodeStripA(dst, src + READ_BE_UINT32(src), height);
dst += 8; dst += 8;
src += 4; src += 4;
} }
@ -1031,7 +1031,7 @@ void SimonEngine::vc_16_sleep_on_id() {
void SimonEngine::vc_17_set_pathfind_item() { void SimonEngine::vc_17_set_pathfind_item() {
uint a = vc_read_next_word(); uint a = vc_read_next_word();
_pathfind_array[a - 1] = (uint16 *)_vc_ptr; _pathfind_array[a - 1] = (uint16 *)_vc_ptr;
while (READ_BE_UINT16_UNALIGNED(_vc_ptr) != 999) while (READ_BE_UINT16(_vc_ptr) != 999)
_vc_ptr += 4; _vc_ptr += 4;
_vc_ptr += 2; _vc_ptr += 2;
} }
@ -1483,9 +1483,9 @@ void SimonEngine::vc_48() {
vp = &_variableArray[20]; vp = &_variableArray[20];
do { do {
y2 = READ_BE_UINT16_UNALIGNED(p); y2 = READ_BE_UINT16(p);
p += step; p += step;
y1 = READ_BE_UINT16_UNALIGNED(p) - y2; y1 = READ_BE_UINT16(p) - y2;
vp[0] = y1 >> 1; vp[0] = y1 >> 1;
vp[1] = y1 - (y1 >> 1); vp[1] = y1 - (y1 >> 1);
@ -1738,11 +1738,11 @@ void SimonEngine::vc_62_palette_thing() {
_cur_vga_file_2 = vpe->vgaFile2; _cur_vga_file_2 = vpe->vgaFile2;
_video_palette_mode = vsp->unk6; _video_palette_mode = vsp->unk6;
params[0] = READ_BE_UINT16_UNALIGNED(&vsp->image); params[0] = READ_BE_UINT16(&vsp->image);
params[1] = READ_BE_UINT16_UNALIGNED(&vsp->base_color); params[1] = READ_BE_UINT16(&vsp->base_color);
params[2] = READ_BE_UINT16_UNALIGNED(&vsp->x); params[2] = READ_BE_UINT16(&vsp->x);
params[3] = READ_BE_UINT16_UNALIGNED(&vsp->y); params[3] = READ_BE_UINT16(&vsp->y);
params[4] = READ_BE_UINT16_UNALIGNED(&vsp->unk4); params[4] = READ_BE_UINT16(&vsp->unk4);
_vc_ptr = (byte *)params; _vc_ptr = (byte *)params;
vc_10_draw(); vc_10_draw();