[Scummvm-git-logs] scummvm master -> b4cebc67c40c81f75f7af9889b4183e240f0e095
peterkohaut
peterkohaut at users.noreply.github.com
Sat Mar 6 17:24:23 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b4cebc67c4 TINSEL: Removed binary literals
Commit: b4cebc67c40c81f75f7af9889b4183e240f0e095
https://github.com/scummvm/scummvm/commit/b4cebc67c40c81f75f7af9889b4183e240f0e095
Author: Peter Kohaut (peter.kohaut at gmail.com)
Date: 2021-03-06T18:12:29+01:00
Commit Message:
TINSEL: Removed binary literals
Changed paths:
engines/tinsel/bmv.cpp
engines/tinsel/graphics.cpp
engines/tinsel/object.cpp
diff --git a/engines/tinsel/bmv.cpp b/engines/tinsel/bmv.cpp
index b6b7a6debf..4b46e7639e 100644
--- a/engines/tinsel/bmv.cpp
+++ b/engines/tinsel/bmv.cpp
@@ -273,11 +273,10 @@ static uint32 DecodeVLE(const byte **src, uint32* hasHi, uint32 *nibbleHi) {
uint32 byte = **src;
++(*src);
- length |= (byte & 0b1111) << bitshift;
+ length |= (byte & 0x0F) << bitshift;
bitshift += 2;
- if (byte & 0b1100) // end
- {
+ if (byte & 0x0C) { // end if any of 0b1100 bits are set
*nibbleHi = byte >> 4;
*hasHi = 1;
break;
@@ -285,11 +284,10 @@ static uint32 DecodeVLE(const byte **src, uint32* hasHi, uint32 *nibbleHi) {
byte >>= 4;
- length |= (byte & 0b1111) << bitshift;
+ length |= (byte & 0x0F) << bitshift;
bitshift += 2;
- if (byte & 0b1100) // end
- {
+ if (byte & 0x0C) { // end if any of 0b1100 bits are set
break;
}
}
@@ -313,7 +311,7 @@ void BMVPlayer::t3DoOperation(BMV_OP op, uint32 len, const byte **src, byte **ds
*src += 1;
byte += 1; // everything is shifted by one for some reason
- byte = ((byte & 0b11) << 6) | (byte >> 2); // bits are swizzled 12345678 -> 34567812; ROL(x, 2)
+ byte = ((byte & 0x03) << 6) | (byte >> 2); // bits are swizzled 12345678 -> 34567812; ROL(x, 2)
uint16 color = 0;
if (byte < 7) {
@@ -402,10 +400,10 @@ void BMVPlayer::t3PrepBMV(const byte *src, uint32 len, int32 deltaOffset) {
uint16 word = READ_LE_UINT16(src); // this might not be aligned properly in memory on some architectures
src += 2;
- count = word & 0b0000111111111111; // 0 - 4095 (0xFFF)
- skip = (byte << 4) | ((word & 0b1111000000000000) >> 12); // 0 - 2207 (0x89F)
+ count = word & 0x0FFF; // 0 - 4095 (0xFFF)
+ skip = (byte << 4) | ((word & 0xF000) >> 12); // 0 - 2207 (0x89F)
} else {
- count = (byte & 0b111) + 1; // 1 - 8
+ count = (byte & 0x7) + 1; // 1 - 8
skip = (byte >> 3) - 0x11; // 1 - 14
}
@@ -436,8 +434,8 @@ void BMVPlayer::t3PrepBMV(const byte *src, uint32 len, int32 deltaOffset) {
uint32 length = 0;
- if ((hiNibble & 0b1100) == 0) { // length might use more than one byte and there might be an inner loop
- if ((loNibble & 0b1100) == 0) { // variable length encoding
+ if ((hiNibble & 0x0C) == 0) { // length might use more than one byte and there might be an inner loop
+ if ((loNibble & 0x0C) == 0) { // variable length encoding
uint32 hasHi = 0;
BMV_NEXT_OP(op, loNibble);
@@ -449,7 +447,7 @@ void BMVPlayer::t3PrepBMV(const byte *src, uint32 len, int32 deltaOffset) {
if (!hasHi) {
continue; // outer loop
- } else if ((hiNibble & 0b1100) != 0) { // process remaining nibble
+ } else if ((hiNibble & 0x0C) != 0) { // process remaining nibble
BMV_NEXT_OP(op, hiNibble);
length = (hiNibble >> 1) - 1;
t3DoOperation(op, length, &src, &dst, deltaOffset);
@@ -469,14 +467,14 @@ void BMVPlayer::t3PrepBMV(const byte *src, uint32 len, int32 deltaOffset) {
byte = *src;
++src;
- loNibble = byte & 0xF;
+ loNibble = byte & 0x0F;
hiNibble = byte >> 4;
- if ((loNibble & 0b1100) == 0) {
+ if ((loNibble & 0x0C) == 0) {
uint32 hasHi = 0;
length += (loNibble << 1); // process lo nibble
length += (hiNibble << 3); // process hi nibble
- if ((hiNibble & 0b1100) == 0) { // continue if there is more
+ if ((hiNibble & 0x0C) == 0) { // continue if there is more
length += DecodeVLE(&src, &hasHi, &hiNibble) << 5; // hiNibble is overriden
}
length -= 1;
@@ -490,14 +488,14 @@ void BMVPlayer::t3PrepBMV(const byte *src, uint32 len, int32 deltaOffset) {
t3DoOperation(op, length, &src, &dst, deltaOffset);
}
- if ((hiNibble & 0b1100) != 0) {
+ if ((hiNibble & 0x0C) != 0) {
BMV_NEXT_OP(op, hiNibble);
length = (hiNibble >> 1) - 1;
t3DoOperation(op, length, &src, &dst, deltaOffset);
break; // finish inner loop
}
}
- } else if ((loNibble & 0b1100) == 0) { // one operation with length 7-30
+ } else if ((loNibble & 0x0C) == 0) { // one operation with length 7-30
BMV_NEXT_OP(op, loNibble);
length = (loNibble >> 1); // note that upper two bit are always 0
length += (hiNibble << 1) - 1;
diff --git a/engines/tinsel/graphics.cpp b/engines/tinsel/graphics.cpp
index f0f84a5bf8..da64931436 100644
--- a/engines/tinsel/graphics.cpp
+++ b/engines/tinsel/graphics.cpp
@@ -46,13 +46,13 @@ extern uint8 g_transPalette[MAX_COLORS];
// using ScummVM pixel format functions is too slow on some ports because of runtime overhead, let the compiler do the optimizations instead
static inline void t3getRGB(uint16 color, uint8 &r, uint8 &g, uint8 &b) {
- r = (color >> 11) & 0b011111;
- g = (color >> 5) & 0b111111;
- b = (color ) & 0b011111;
+ r = (color >> 11) & 0x1F;
+ g = (color >> 5) & 0x3F;
+ b = (color ) & 0x1F;
}
static inline uint16 t3getColor(uint8 r, uint8 g, uint8 b) {
- return ((r & 0b011111) << 11) | ((g & 0b111111) << 5) | (b & 0b011111);
+ return ((r & 0x1F) << 11) | ((g & 0x3F) << 5) | (b & 0x1F);
}
/**
@@ -650,7 +650,7 @@ static void t3WrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP) {
runLength = MIN(runLength, pObj->width - rightClip - x);
for (int xp = 0; xp < runLength; ++xp) {
- if (color != 0b1111100000011111) {
+ if (color != 0xF81F) { // "zero" for Tinsel 3 - magenta in 565
WRITE_UINT16(tempP, color);
}
tempP += (horizFlipped ? -2 : 2);
@@ -669,7 +669,7 @@ static void t3WrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP) {
if ((yClip == 0) && (x < (pObj->width - rightClip))) {
uint16 color = READ_LE_UINT16(srcP);
- if (color != 0b1111100000011111) {
+ if (color != 0xF81F) { // "zero" for Tinsel 3 - magenta in 565
WRITE_UINT16(tempP, color);
}
@@ -705,7 +705,7 @@ static void t3WrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP) {
uint16 color = READ_LE_UINT16(srcP);
srcP += 2;
- if (color != 0b1111100000011111) { // "zero" for Tinsel 3 - magenta in 565
+ if (color != 0xF81F) { // "zero" for Tinsel 3 - magenta in 565
WRITE_UINT16(tempP, color);
}
@@ -756,7 +756,7 @@ static void t3TransWNZ(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP) {
srcP += pObj->leftClip * 2;
for (int x = 0; x < pObj->width; ++x) {
uint32 color = READ_LE_UINT16(srcP); //uint32 for checking overflow in blending
- if (color != 0b1111100000011111) { // "zero" for Tinsel 3 - magenta in 565
+ if (color != 0xF81F) { // "zero" for Tinsel 3 - magenta in 565
uint8 srcR, srcG, srcB;
t3getRGB(color, srcR, srcG, srcB);
@@ -779,17 +779,17 @@ static void t3TransWNZ(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP) {
// }
// color &= 0b1111011111011111;
color = t3getColor(
- MIN(srcR + dstR, 0b011111),
- MIN(srcG + dstG, 0b111111),
- MIN(srcB + dstB, 0b011111)
+ MIN(srcR + dstR, 0x1F),
+ MIN(srcG + dstG, 0x3F),
+ MIN(srcB + dstB, 0x1F)
);
} else {
// original algo looks simple but does not check for overflow
// color += (dstColor & 0b1111011111011111) >> 1;
color = t3getColor(
- MIN(srcR + (dstR / 2), 0b011111),
- MIN(srcG + (dstG / 2), 0b111111),
- MIN(srcB + (dstB / 2), 0b011111)
+ MIN(srcR + (dstR / 2), 0x1F),
+ MIN(srcG + (dstG / 2), 0x3F),
+ MIN(srcB + (dstB / 2), 0x1F)
);
}
WRITE_UINT16(tempP, color);
diff --git a/engines/tinsel/object.cpp b/engines/tinsel/object.cpp
index d71fa6875e..166d850973 100644
--- a/engines/tinsel/object.cpp
+++ b/engines/tinsel/object.cpp
@@ -387,7 +387,7 @@ OBJECT *InitObject(const OBJ_INIT *pInitTbl) {
} else {
const IMAGE_T3 *pImgT3 = (const IMAGE_T3 *)pImg;
- if ((pImgT3->colorFlags & 0b110U) == 0) {
+ if ((pImgT3->colorFlags & 0x0C) == 0) { // bits 0b1100 are used to select blending mode
pObj->flags = pObj->flags & ~DMA_GHOST;
} else {
assert((pObj->flags & DMA_WNZ) != 0);
More information about the Scummvm-git-logs
mailing list