diff -ur ScummVM+orig/scummvm/common/scummsys.h ScummVM+hack/scummvm/common/scummsys.h
old
|
new
|
|
368 | 368 | #define MKID_BE(a) (a) |
369 | 369 | //#define MKID_BE(a) SWAP_BYTES(a) |
370 | 370 | |
371 | | FORCEINLINE uint32 FROM_LE_32(uint32 a) { |
372 | | return ((a >> 24) & 0xFF) + ((a >> 8) & 0xFF00) + (( a<< 8) & 0xFF0000) \ |
373 | | + ((a<<24)&0xFF000000); |
374 | | } |
375 | | |
376 | | FORCEINLINE uint16 FROM_LE_16(uint16 a) { |
377 | | return ((a >> 8) & 0xFF) + ((a << 8) & 0xFF00); |
| 371 | FORCEINLINE uint READ_LE_UINT16(const void *ptr) { |
| 372 | const byte *b = (const byte *)ptr; |
| 373 | return (b[1] << 8) + b[0]; |
378 | 374 | } |
379 | 375 | |
380 | | #define TO_LE_32 FROM_LE_32 |
381 | | #define TO_LE_16 FROM_LE_16 |
| 376 | #if defined(SCUMM_NEED_ALIGNMENT) |
| 377 | FORCEINLINE uint READ_BE_UINT16(const void *ptr) { |
| 378 | return (((const byte *)ptr)[0] << 8)|((const byte *)ptr)[1]; |
| 379 | } |
| 380 | #else |
| 381 | FORCEINLINE uint READ_BE_UINT16(const void *ptr) { |
| 382 | return *(const uint16 *)(ptr); |
| 383 | } |
| 384 | #endif |
382 | 385 | |
383 | 386 | FORCEINLINE uint32 READ_LE_UINT32(const void *ptr) { |
384 | 387 | const byte *b = (const byte *)ptr; |
385 | 388 | return (b[3] << 24) + (b[2] << 16) + (b[1] << 8) + (b[0]); |
386 | 389 | } |
387 | 390 | |
388 | | FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) { |
389 | | return *(const uint32 *)(ptr); |
390 | | } |
| 391 | #if defined(SCUMM_NEED_ALIGNMENT) |
| 392 | FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) { |
| 393 | const byte *b = (const byte*)ptr; |
| 394 | return (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + (b[3]); |
| 395 | } |
| 396 | #else |
| 397 | FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) { |
| 398 | return *(const uint32 *)(ptr); |
| 399 | } |
| 400 | #endif |
391 | 401 | |
392 | | FORCEINLINE uint READ_LE_UINT16(const void *ptr) { |
393 | | const byte *b = (const byte *)ptr; |
394 | | return (b[1] << 8) + b[0]; |
395 | | } |
| 402 | #define READ_BE_UINT32_UNALIGNED READ_BE_UINT32 |
| 403 | #define READ_BE_UINT16_UNALIGNED READ_BE_UINT16 |
396 | 404 | |
397 | | FORCEINLINE uint READ_BE_UINT16(const void *ptr) { |
398 | | return *(const uint16 *)(ptr); |
399 | | } |
| 405 | #define READ_UINT32_UNALIGNED READ_BE_UINT32_UNALIGNED |
400 | 406 | |
401 | | FORCEINLINE uint READ_BE_UINT16_UNALIGNED(const void *ptr) { |
402 | | return (((const byte *)ptr)[0] << 8)|((const byte *)ptr)[1]; |
| 407 | FORCEINLINE uint32 FROM_LE_32(uint32 a) { |
| 408 | return ((a >> 24) & 0xFF) + ((a >> 8) & 0xFF00) + (( a<< 8) & 0xFF0000) \ |
| 409 | + ((a<<24)&0xFF000000); |
403 | 410 | } |
404 | 411 | |
405 | | FORCEINLINE uint32 READ_BE_UINT32_UNALIGNED(const void *ptr) { |
406 | | const byte *b = (const byte*)ptr; |
407 | | return (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + (b[3]); |
| 412 | FORCEINLINE uint16 FROM_LE_16(uint16 a) { |
| 413 | return ((a >> 8) & 0xFF) + ((a << 8) & 0xFF00); |
408 | 414 | } |
409 | 415 | |
410 | | #define READ_UINT32_UNALIGNED READ_BE_UINT32_UNALIGNED |
| 416 | #define TO_LE_32 FROM_LE_32 |
| 417 | #define TO_LE_16 FROM_LE_16 |
411 | 418 | |
412 | 419 | #define TO_BE_32(a) (a) |
413 | 420 | #define TO_BE_16(a) (a) |