[Scummvm-git-logs] scummvm master -> 8f9d49960ab966ef78461db0db4cdb65013553ef
AndywinXp
noreply at scummvm.org
Fri Nov 18 12:53:19 UTC 2022
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1e51c121bd SCUMM: reuse majmin codec for smap
24d5420aae SCUMM: simplify majmin bitstream reading
fe15712547 SCUMM: relabel codec47 initialization
8f9d49960a SCUMM: Align variable name styling in codec47
Commit: 1e51c121bd5003a0d26642087c9c39375e5b60f2
https://github.com/scummvm/scummvm/commit/1e51c121bd5003a0d26642087c9c39375e5b60f2
Author: BLooperZ (blooperz at users.noreply.github.com)
Date: 2022-11-18T13:53:12+01:00
Commit Message:
SCUMM: reuse majmin codec for smap
Changed paths:
engines/scumm/akos.cpp
engines/scumm/akos.h
engines/scumm/gfx.cpp
engines/scumm/gfx.h
diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp
index c4b6eb3cf09..74f004dedb3 100644
--- a/engines/scumm/akos.cpp
+++ b/engines/scumm/akos.cpp
@@ -995,80 +995,11 @@ byte AkosRenderer::paintCelCDATRLE(int xmoveCur, int ymoveCur) {
return 0;
}
-void AkosRenderer::majMinCodecSetupBitReader(const byte *src) {
- _majMinData.repeatMode = false;
- _majMinData.numBits = 16;
- _majMinData.mask = (1 << *src) - 1;
- _majMinData.shift = *(src);
- _majMinData.color = *(src + 1);
- _majMinData.bits = (*(src + 2) | *(src + 3) << 8);
- _majMinData.dataPtr = src + 4;
-}
-
-#define MAJMIN_FILL_BITS() \
- if (_majMinData.numBits <= 8) { \
- _majMinData.bits |= (*_majMinData.dataPtr++) << _majMinData.numBits; \
- _majMinData.numBits += 8; \
- }
-
-#define MAJMIN_EAT_BITS(n) \
- _majMinData.numBits -= (n); \
- _majMinData.bits >>= (n);
-
-
-void AkosRenderer::majMinCodecSkipData(int32 numbytes) {
- majMinCodecDecodeLine(nullptr, numbytes, 0);
-}
-
-void AkosRenderer::majMinCodecDecodeLine(byte *buf, int32 numbytes, int32 dir) {
- uint16 bits, tmp_bits;
-
- while (numbytes != 0) {
- if (buf) {
- *buf = _majMinData.color;
- buf += dir;
- }
-
- if (!_majMinData.repeatMode) {
- MAJMIN_FILL_BITS()
- bits = _majMinData.bits & 3;
- if (bits & 1) {
- MAJMIN_EAT_BITS(2)
- if (bits & 2) {
- tmp_bits = _majMinData.bits & 7;
- MAJMIN_EAT_BITS(3)
- if (tmp_bits != 4) {
- // A color change
- _majMinData.color += (tmp_bits - 4);
- } else {
- // Color does not change, but rather identical pixels get repeated
- _majMinData.repeatMode = true;
- MAJMIN_FILL_BITS()
- _majMinData.repeatCount = (_majMinData.bits & 0xff) - 1;
- MAJMIN_EAT_BITS(8)
- MAJMIN_FILL_BITS()
- }
- } else {
- MAJMIN_FILL_BITS()
- _majMinData.color = ((byte)_majMinData.bits) & _majMinData.mask;
- MAJMIN_EAT_BITS(_majMinData.shift)
- MAJMIN_FILL_BITS()
- }
- } else {
- MAJMIN_EAT_BITS(1);
- }
- } else {
- if (--_majMinData.repeatCount == 0) {
- _majMinData.repeatMode = false;
- }
- }
- numbytes--;
- }
-}
-
void AkosRenderer::majMinCodecDecompress(byte *dest, int32 pitch, const byte *src, int32 width, int32 height, int32 dir,
int32 numSkipBefore, int32 numSkipAfter, byte transparency, int maskLeft, int maskTop, int zBuf) {
- byte *tmpBuf = _majMinData.buffer;
+
+ MajMinCodec majMin;
+ byte *tmpBuf = majMin._majMinData.buffer;
int maskPitch;
byte *maskPtr;
const byte maskBit = revBitMask(maskLeft & 7);
@@ -1078,10 +1009,10 @@ void AkosRenderer::majMinCodecDecompress(byte *dest, int32 pitch, const byte *sr
tmpBuf += (width - 1);
}
- majMinCodecSetupBitReader(src);
+ majMin.setupBitReader(*src, src + 1);
if (numSkipBefore != 0) {
- majMinCodecSkipData(numSkipBefore);
+ majMin.skipData(numSkipBefore);
}
maskPitch = _numStrips;
@@ -1091,13 +1022,13 @@ void AkosRenderer::majMinCodecDecompress(byte *dest, int32 pitch, const byte *sr
assert(height > 0);
assert(width > 0);
while (height--) {
- majMinCodecDecodeLine(tmpBuf, width, dir);
- bompApplyMask(_majMinData.buffer, maskPtr, maskBit, width, transparency);
+ majMin.decodeLine(tmpBuf, width, dir);
+ bompApplyMask(majMin._majMinData.buffer, maskPtr, maskBit, width, transparency);
bool HE7Check = (_vm->_game.heversion == 70);
- bompApplyShadow(_shadowMode, _shadowTable, _majMinData.buffer, dest, width, transparency, HE7Check);
+ bompApplyShadow(_shadowMode, _shadowTable, majMin._majMinData.buffer, dest, width, transparency, HE7Check);
if (numSkipAfter != 0) {
- majMinCodecSkipData(numSkipAfter);
+ majMin.skipData(numSkipAfter);
}
dest += pitch;
maskPtr += maskPitch;
diff --git a/engines/scumm/akos.h b/engines/scumm/akos.h
index f35cc918c94..33cc3165bc4 100644
--- a/engines/scumm/akos.h
+++ b/engines/scumm/akos.h
@@ -89,17 +89,6 @@ protected:
const byte *_rgbs; // Raw costume RGB colors (HE specific)
const uint8 *_xmap; // shadow color table (HE specific)
- struct {
- bool repeatMode;
- int repeatCount;
- byte mask;
- byte color;
- byte shift;
- uint16 bits;
- byte numBits;
- const byte *dataPtr;
- byte buffer[336];
- } _majMinData;
public:
AkosRenderer(ScummEngine *scumm) : BaseCostumeRenderer(scumm) {
@@ -132,9 +121,6 @@ protected:
byte paintCelCDATRLE(int xMoveCur, int yMoveCur);
byte paintCelMajMin(int xMoveCur, int yMoveCur);
byte paintCelTRLE(int xMoveCur, int yMoveCur);
- void majMinCodecSetupBitReader(const byte *src);
- void majMinCodecSkipData(int32 numSkip);
- void majMinCodecDecodeLine(byte *buf, int32 numBytes, int32 dir);
void majMinCodecDecompress(byte *dest, int32 pitch, const byte *src, int32 t_width, int32 t_height, int32 dir, int32 numSkipBefore, int32 numSkipAfter, byte transparency, int maskLeft, int maskTop, int zBuf);
void markRectAsDirty(Common::Rect rect);
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index 66e621514f4..ced82439c93 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -3783,55 +3783,24 @@ void Gdi::drawStrip3DO(byte *dst, int dstPitch, const byte *src, int height, con
} while (0)
void Gdi::drawStripComplex(byte *dst, int dstPitch, const byte *src, int height, const bool transpCheck) const {
- byte color = *src++;
- uint bits = *src++;
- byte cl = 8;
- byte bit;
- byte incm, reps;
+ byte color;
+ MajMinCodec majMin;
- do {
- int x = 8;
- do {
- FILL_BITS;
+ majMin.setupBitReader(_decomp_shr, src);
+
+ byte lineBuffer[8];
+ memset(lineBuffer, 0, 8);
+
+ while (height--) {
+ majMin.decodeLine(lineBuffer, 8, 1);
+ for (byte i = 0; i < 8; i ++) {
+ color = lineBuffer[i];
if (!transpCheck || color != _transparentColor)
writeRoomColor(dst, color);
dst += _vm->_bytesPerPixel;
-
- againPos:
- if (!READ_BIT) {
- } else if (!READ_BIT) {
- FILL_BITS;
- color = bits & _decomp_mask;
- bits >>= _decomp_shr;
- cl -= _decomp_shr;
- } else {
- incm = (bits & 7) - 4;
- cl -= 3;
- bits >>= 3;
- if (incm) {
- color += incm;
- } else {
- FILL_BITS;
- reps = bits & 0xFF;
- do {
- if (!--x) {
- x = 8;
- dst += dstPitch - 8 * _vm->_bytesPerPixel;
- if (!--height)
- return;
- }
- if (!transpCheck || color != _transparentColor)
- writeRoomColor(dst, color);
- dst += _vm->_bytesPerPixel;
- } while (--reps);
- bits >>= 8;
- bits |= (*src++) << (cl - 8);
- goto againPos;
- }
- }
- } while (--x);
+ }
dst += dstPitch - 8 * _vm->_bytesPerPixel;
- } while (--height);
+ }
}
void Gdi::drawStripBasicH(byte *dst, int dstPitch, const byte *src, int height, const bool transpCheck) const {
@@ -4631,4 +4600,75 @@ void ScummEngine::updateScreenShakeEffect() {
}
}
+void MajMinCodec::setupBitReader(byte shift, const byte *src) {
+ _majMinData.repeatMode = false;
+ _majMinData.numBits = 16;
+ _majMinData.mask = (1 << shift) - 1;
+ _majMinData.shift = shift;
+ _majMinData.color = *src;
+ _majMinData.bits = (*(src + 1) | *(src + 2) << 8);
+ _majMinData.dataPtr = src + 3;
+}
+
+#define MAJMIN_FILL_BITS() \
+ if (_majMinData.numBits <= 8) { \
+ _majMinData.bits |= (*_majMinData.dataPtr++) << _majMinData.numBits; \
+ _majMinData.numBits += 8; \
+ }
+
+#define MAJMIN_EAT_BITS(n) \
+ _majMinData.numBits -= (n); \
+ _majMinData.bits >>= (n);
+
+
+void MajMinCodec::skipData(int32 numbytes) {
+ decodeLine(nullptr, numbytes, 0);
+}
+
+void MajMinCodec::decodeLine(byte *buf, int32 numbytes, int32 dir) {
+ uint16 bits, tmp_bits;
+
+ while (numbytes != 0) {
+ if (buf) {
+ *buf = _majMinData.color;
+ buf += dir;
+ }
+
+ if (!_majMinData.repeatMode) {
+ MAJMIN_FILL_BITS()
+ bits = _majMinData.bits & 3;
+ if (bits & 1) {
+ MAJMIN_EAT_BITS(2)
+ if (bits & 2) {
+ tmp_bits = _majMinData.bits & 7;
+ MAJMIN_EAT_BITS(3)
+ if (tmp_bits != 4) {
+ // A color change
+ _majMinData.color += (tmp_bits - 4);
+ } else {
+ // Color does not change, but rather identical pixels get repeated
+ _majMinData.repeatMode = true;
+ MAJMIN_FILL_BITS()
+ _majMinData.repeatCount = (_majMinData.bits & 0xff) - 1;
+ MAJMIN_EAT_BITS(8)
+ MAJMIN_FILL_BITS()
+ }
+ } else {
+ MAJMIN_FILL_BITS()
+ _majMinData.color = ((byte)_majMinData.bits) & _majMinData.mask;
+ MAJMIN_EAT_BITS(_majMinData.shift)
+ MAJMIN_FILL_BITS()
+ }
+ } else {
+ MAJMIN_EAT_BITS(1);
+ }
+ } else {
+ if (--_majMinData.repeatCount == 0) {
+ _majMinData.repeatMode = false;
+ }
+ }
+ numbytes--;
+ }
+}
+
} // End of namespace Scumm
diff --git a/engines/scumm/gfx.h b/engines/scumm/gfx.h
index bcc006faeb6..3535070f16e 100644
--- a/engines/scumm/gfx.h
+++ b/engines/scumm/gfx.h
@@ -545,6 +545,26 @@ private:
};
#endif // DISABLE_TOWNS_DUAL_LAYER_MODE
+class MajMinCodec {
+public:
+
+ struct {
+ bool repeatMode;
+ int repeatCount;
+ byte mask;
+ byte color;
+ byte shift;
+ uint16 bits;
+ byte numBits;
+ const byte *dataPtr;
+ byte buffer[336];
+ } _majMinData;
+
+ void setupBitReader(byte shift, const byte *src);
+ void skipData(int32 numSkip);
+ void decodeLine(byte *buf, int32 numBytes, int32 dir);
+};
+
} // End of namespace Scumm
#endif
Commit: 24d5420aae5d3de7a9c8df05e2dd2291c139cb92
https://github.com/scummvm/scummvm/commit/24d5420aae5d3de7a9c8df05e2dd2291c139cb92
Author: BLooperZ (blooperz at users.noreply.github.com)
Date: 2022-11-18T13:53:12+01:00
Commit Message:
SCUMM: simplify majmin bitstream reading
Changed paths:
engines/scumm/gfx.cpp
engines/scumm/gfx.h
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index ced82439c93..7ef9e5d51e9 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -4603,7 +4603,6 @@ void ScummEngine::updateScreenShakeEffect() {
void MajMinCodec::setupBitReader(byte shift, const byte *src) {
_majMinData.repeatMode = false;
_majMinData.numBits = 16;
- _majMinData.mask = (1 << shift) - 1;
_majMinData.shift = shift;
_majMinData.color = *src;
_majMinData.bits = (*(src + 1) | *(src + 2) << 8);
@@ -4620,13 +4619,19 @@ void MajMinCodec::setupBitReader(byte shift, const byte *src) {
_majMinData.numBits -= (n); \
_majMinData.bits >>= (n);
+byte MajMinCodec::readBits(byte n) {
+ MAJMIN_FILL_BITS();
+ byte _value = _majMinData.bits & ((1 << n) - 1);
+ MAJMIN_EAT_BITS(n);
+ return _value;
+}
void MajMinCodec::skipData(int32 numbytes) {
decodeLine(nullptr, numbytes, 0);
}
void MajMinCodec::decodeLine(byte *buf, int32 numbytes, int32 dir) {
- uint16 bits, tmp_bits;
+ byte diff;
while (numbytes != 0) {
if (buf) {
@@ -4635,32 +4640,20 @@ void MajMinCodec::decodeLine(byte *buf, int32 numbytes, int32 dir) {
}
if (!_majMinData.repeatMode) {
- MAJMIN_FILL_BITS()
- bits = _majMinData.bits & 3;
- if (bits & 1) {
- MAJMIN_EAT_BITS(2)
- if (bits & 2) {
- tmp_bits = _majMinData.bits & 7;
- MAJMIN_EAT_BITS(3)
- if (tmp_bits != 4) {
+ if (readBits(1)) {
+ if (readBits(1)) {
+ diff = readBits(3) - 4;
+ if (diff) {
// A color change
- _majMinData.color += (tmp_bits - 4);
+ _majMinData.color += diff;
} else {
// Color does not change, but rather identical pixels get repeated
_majMinData.repeatMode = true;
- MAJMIN_FILL_BITS()
- _majMinData.repeatCount = (_majMinData.bits & 0xff) - 1;
- MAJMIN_EAT_BITS(8)
- MAJMIN_FILL_BITS()
+ _majMinData.repeatCount = readBits(8) - 1;
}
} else {
- MAJMIN_FILL_BITS()
- _majMinData.color = ((byte)_majMinData.bits) & _majMinData.mask;
- MAJMIN_EAT_BITS(_majMinData.shift)
- MAJMIN_FILL_BITS()
+ _majMinData.color = readBits(_majMinData.shift);
}
- } else {
- MAJMIN_EAT_BITS(1);
}
} else {
if (--_majMinData.repeatCount == 0) {
diff --git a/engines/scumm/gfx.h b/engines/scumm/gfx.h
index 3535070f16e..3243f46e49e 100644
--- a/engines/scumm/gfx.h
+++ b/engines/scumm/gfx.h
@@ -551,7 +551,6 @@ public:
struct {
bool repeatMode;
int repeatCount;
- byte mask;
byte color;
byte shift;
uint16 bits;
@@ -563,6 +562,7 @@ public:
void setupBitReader(byte shift, const byte *src);
void skipData(int32 numSkip);
void decodeLine(byte *buf, int32 numBytes, int32 dir);
+ inline byte readBits(byte n);
};
} // End of namespace Scumm
Commit: fe15712547c18f91df00241b2da80806358e947a
https://github.com/scummvm/scummvm/commit/fe15712547c18f91df00241b2da80806358e947a
Author: BLooperZ (blooperz at users.noreply.github.com)
Date: 2022-11-18T13:53:12+01:00
Commit Message:
SCUMM: relabel codec47 initialization
Changed paths:
engines/scumm/smush/codec47.cpp
diff --git a/engines/scumm/smush/codec47.cpp b/engines/scumm/smush/codec47.cpp
index 196368512dd..76727f41de7 100644
--- a/engines/scumm/smush/codec47.cpp
+++ b/engines/scumm/smush/codec47.cpp
@@ -69,19 +69,25 @@ namespace Scumm {
(dst)[1] = val; \
} while (0)
-static const int8 codec47_table_small1[] = {
+#define MOTION_OFFSET_TABLE_SIZE 0xF8
+#define PROCESS_SUBBLOCKS 0xFF
+#define FILL_SINGLE_COLOR 0xFE
+#define DRAW_GLYPH 0xFD
+#define COPY_PREV_BUFFER 0xFC
+
+static const int8 codec47_glyph4_xvec[] = {
0, 1, 2, 3, 3, 3, 3, 2, 1, 0, 0, 0, 1, 2, 2, 1,
};
-static const int8 codec47_table_small2[] = {
+static const int8 codec47_glyph4_yvec[] = {
0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2,
};
-static const int8 codec47_table_big1[] = {
+static const int8 codec47_glyph8_xvec[] = {
0, 2, 5, 7, 7, 7, 7, 7, 7, 5, 2, 0, 0, 0, 0, 0,
};
-static const int8 codec47_table_big2[] = {
+static const int8 codec47_glyph8_yvec[] = {
0, 0, 0, 0, 1, 3, 4, 6, 7, 7, 7, 7, 6, 4, 3, 1,
};
@@ -139,121 +145,128 @@ static const int8 codec47_table[] = {
-6, 43, 1, 43, 0, 0, 0, 0, 0, 0
};
-void Codec47Decoder::makeTablesInterpolation(int param) {
- int32 variable1, variable2;
- int32 b1, b2;
- int32 value_table47_1_2, value_table47_1_1, value_table47_2_2, value_table47_2_1;
- int32 tableSmallBig[64], tmp, s;
- const int8 *table47_1 = nullptr, *table47_2 = nullptr;
+enum Edge {
+ kEdgeLeft,
+ kEdgeTop,
+ kEdgeRight,
+ kEdgeBottom,
+ kEdgeNone,
+};
+
+#define NGLYPHS 256
+
+void Codec47Decoder::makeTablesInterpolation(int sideLength) {
+ int32 pos, npoints;
+ int32 edge0, edge1;
+ int32 x1, x0, y1, y0;
+ int32 tableSmallBig[64], s;
+ const int8 *glyph_x = nullptr, *glyph_y = nullptr;
int32 *ptr_small_big;
byte *ptr;
int i, x, y;
- if (param == 8) {
- table47_1 = codec47_table_big1;
- table47_2 = codec47_table_big2;
+ if (sideLength == 8) {
+ glyph_x = codec47_glyph8_xvec;
+ glyph_y = codec47_glyph8_yvec;
ptr = _tableBig;
- for (i = 0; i < 256; i++) {
+ for (i = 0; i < NGLYPHS; i++) {
ptr[384] = 0;
ptr[385] = 0;
ptr += 388;
}
- } else if (param == 4) {
- table47_1 = codec47_table_small1;
- table47_2 = codec47_table_small2;
+ } else if (sideLength == 4) {
+ glyph_x = codec47_glyph4_xvec;
+ glyph_y = codec47_glyph4_yvec;
ptr = _tableSmall;
- for (i = 0; i < 256; i++) {
+ for (i = 0; i < NGLYPHS; i++) {
ptr[96] = 0;
ptr[97] = 0;
ptr += 128;
}
} else {
- error("Codec47Decoder::makeTablesInterpolation: unknown param %d", param);
+ error("Codec47Decoder::makeTablesInterpolation: unknown sideLength %d", sideLength);
}
s = 0;
for (x = 0; x < 16; x++) {
- value_table47_1_1 = table47_1[x];
- value_table47_2_1 = table47_2[x];
- for (y = 0; y < 16; y++) {
- value_table47_1_2 = table47_1[y];
- value_table47_2_2 = table47_2[y];
-
- if (value_table47_2_1 == 0) {
- b1 = 0;
- } else if (value_table47_2_1 == param - 1) {
- b1 = 1;
- } else if (value_table47_1_1 == 0) {
- b1 = 2;
- } else if (value_table47_1_1 == param - 1) {
- b1 = 3;
- } else {
- b1 = 4;
- }
+ x0 = glyph_x[x];
+ y0 = glyph_y[x];
+
+ if (y0 == 0) {
+ edge0 = kEdgeBottom;
+ } else if (y0 == sideLength - 1) {
+ edge0 = kEdgeTop;
+ } else if (x0 == 0) {
+ edge0 = kEdgeLeft;
+ } else if (x0 == sideLength - 1) {
+ edge0 = kEdgeRight;
+ } else {
+ edge0 = kEdgeNone;
+ }
- if (value_table47_2_2 == 0) {
- b2 = 0;
- } else if (value_table47_2_2 == param - 1) {
- b2 = 1;
- } else if (value_table47_1_2 == 0) {
- b2 = 2;
- } else if (value_table47_1_2 == param - 1) {
- b2 = 3;
+ for (y = 0; y < 16; y++) {
+ x1 = glyph_x[y];
+ y1 = glyph_y[y];
+
+ if (y1 == 0) {
+ edge1 = kEdgeBottom;
+ } else if (y1 == sideLength - 1) {
+ edge1 = kEdgeTop;
+ } else if (x1 == 0) {
+ edge1 = kEdgeLeft;
+ } else if (x1 == sideLength - 1) {
+ edge1 = kEdgeRight;
} else {
- b2 = 4;
+ edge1 = kEdgeNone;
}
- memset(tableSmallBig, 0, param * param * 4);
+ memset(tableSmallBig, 0, sideLength * sideLength * 4);
- variable2 = ABS(value_table47_2_2 - value_table47_2_1);
- tmp = ABS(value_table47_1_2 - value_table47_1_1);
- if (variable2 <= tmp) {
- variable2 = tmp;
- }
+ npoints = MAX(ABS(y1 - y0), ABS(x1 - x0));
- for (variable1 = 0; variable1 <= variable2; variable1++) {
- int32 variable3, variable4;
+ for (pos = 0; pos <= npoints; pos++) {
+ int32 yPoint, xPoint;
- if (variable2 > 0) {
- // Linearly interpolate between value_table47_1_1 and value_table47_1_2
- // respectively value_table47_2_1 and value_table47_2_2.
- variable4 = (value_table47_1_1 * variable1 + value_table47_1_2 * (variable2 - variable1) + variable2 / 2) / variable2;
- variable3 = (value_table47_2_1 * variable1 + value_table47_2_2 * (variable2 - variable1) + variable2 / 2) / variable2;
+ if (npoints > 0) {
+ // Linearly interpolate between x0 and x1
+ // respectively y0 and y1.
+ xPoint = (x0 * pos + x1 * (npoints - pos) + npoints / 2) / npoints;
+ yPoint = (y0 * pos + y1 * (npoints - pos) + npoints / 2) / npoints;
} else {
- variable4 = value_table47_1_1;
- variable3 = value_table47_2_1;
+ xPoint = x0;
+ yPoint = y0;
}
- ptr_small_big = &tableSmallBig[param * variable3 + variable4];
+ ptr_small_big = &tableSmallBig[sideLength * yPoint + xPoint];
*ptr_small_big = 1;
- if ((b1 == 2 && b2 == 3) || (b2 == 2 && b1 == 3) ||
- (b1 == 0 && b2 != 1) || (b2 == 0 && b1 != 1)) {
- if (variable3 >= 0) {
- i = variable3 + 1;
+ if ((edge0 == kEdgeLeft && edge1 == kEdgeRight) || (edge1 == kEdgeLeft && edge0 == kEdgeRight) ||
+ (edge0 == kEdgeBottom && edge1 != kEdgeTop) || (edge1 == kEdgeBottom && edge0 != kEdgeTop)) {
+ if (yPoint >= 0) {
+ i = yPoint + 1;
while (i--) {
*ptr_small_big = 1;
- ptr_small_big -= param;
+ ptr_small_big -= sideLength;
}
}
- } else if ((b2 != 0 && b1 == 1) || (b1 != 0 && b2 == 1)) {
- if (param > variable3) {
- i = param - variable3;
+ } else if ((edge1 != kEdgeBottom && edge0 == kEdgeTop) || (edge0 != kEdgeBottom && edge1 == kEdgeTop)) {
+ if (sideLength > yPoint) {
+ i = sideLength - yPoint;
while (i--) {
*ptr_small_big = 1;
- ptr_small_big += param;
+ ptr_small_big += sideLength;
}
}
- } else if ((b1 == 2 && b2 != 3) || (b2 == 2 && b1 != 3)) {
- if (variable4 >= 0) {
- i = variable4 + 1;
+ } else if ((edge0 == kEdgeLeft && edge1 != kEdgeRight) || (edge1 == kEdgeLeft && edge0 != kEdgeRight)) {
+ if (xPoint >= 0) {
+ i = xPoint + 1;
while (i--) {
*(ptr_small_big--) = 1;
}
}
- } else if ((b1 == 0 && b2 == 1) || (b2 == 0 && b1 == 1) ||
- (b1 == 3 && b2 != 2) || (b2 == 3 && b1 != 2)) {
- if (param > variable4) {
- i = param - variable4;
+ } else if ((edge0 == kEdgeBottom && edge1 == kEdgeTop) || (edge1 == kEdgeBottom && edge0 == kEdgeTop) ||
+ (edge0 == kEdgeRight && edge1 != kEdgeLeft) || (edge1 == kEdgeRight && edge0 != kEdgeLeft)) {
+ if (sideLength > xPoint) {
+ i = sideLength - xPoint;
while (i--) {
*(ptr_small_big++) = 1;
}
@@ -261,7 +274,7 @@ void Codec47Decoder::makeTablesInterpolation(int param) {
}
}
- if (param == 8) {
+ if (sideLength == 8) {
for (i = 64 - 1; i >= 0; i--) {
if (tableSmallBig[i] != 0) {
_tableBig[256 + s + _tableBig[384 + s]] = (byte)i;
@@ -273,7 +286,7 @@ void Codec47Decoder::makeTablesInterpolation(int param) {
}
s += 388;
}
- if (param == 4) {
+ if (sideLength == 4) {
for (i = 16 - 1; i >= 0; i--) {
if (tableSmallBig[i] != 0) {
_tableSmall[64 + s + _tableSmall[96 + s]] = (byte)i;
@@ -363,19 +376,19 @@ void Codec47Decoder::level3(byte *d_dst) {
int32 tmp;
byte code = *_d_src++;
- if (code < 0xF8) {
+ if (code < MOTION_OFFSET_TABLE_SIZE) {
tmp = _table[code] + _offset1;
COPY_2X1_LINE(d_dst, d_dst + tmp);
COPY_2X1_LINE(d_dst + _d_pitch, d_dst + _d_pitch + tmp);
- } else if (code == 0xFF) {
+ } else if (code == PROCESS_SUBBLOCKS) {
COPY_2X1_LINE(d_dst, _d_src + 0);
COPY_2X1_LINE(d_dst + _d_pitch, _d_src + 2);
_d_src += 4;
- } else if (code == 0xFE) {
+ } else if (code == FILL_SINGLE_COLOR) {
byte t = *_d_src++;
FILL_2X1_LINE(d_dst, t);
FILL_2X1_LINE(d_dst + _d_pitch, t);
- } else if (code == 0xFC) {
+ } else if (code == COPY_PREV_BUFFER) {
tmp = _offset2;
COPY_2X1_LINE(d_dst, d_dst + tmp);
COPY_2X1_LINE(d_dst + _d_pitch, d_dst + _d_pitch + tmp);
@@ -391,13 +404,13 @@ void Codec47Decoder::level2(byte *d_dst) {
byte code = *_d_src++;
int i;
- if (code < 0xF8) {
+ if (code < MOTION_OFFSET_TABLE_SIZE) {
tmp = _table[code] + _offset1;
for (i = 0; i < 4; i++) {
COPY_4X1_LINE(d_dst, d_dst + tmp);
d_dst += _d_pitch;
}
- } else if (code == 0xFF) {
+ } else if (code == PROCESS_SUBBLOCKS) {
level3(d_dst);
d_dst += 2;
level3(d_dst);
@@ -405,13 +418,13 @@ void Codec47Decoder::level2(byte *d_dst) {
level3(d_dst);
d_dst += 2;
level3(d_dst);
- } else if (code == 0xFE) {
+ } else if (code == FILL_SINGLE_COLOR) {
byte t = *_d_src++;
for (i = 0; i < 4; i++) {
FILL_4X1_LINE(d_dst, t);
d_dst += _d_pitch;
}
- } else if (code == 0xFD) {
+ } else if (code == DRAW_GLYPH) {
byte *tmp_ptr = _tableSmall + *_d_src++ * 128;
int32 l = tmp_ptr[96];
byte val = *_d_src++;
@@ -427,7 +440,7 @@ void Codec47Decoder::level2(byte *d_dst) {
*(d_dst + READ_LE_UINT16(tmp_ptr2)) = val;
tmp_ptr2++;
}
- } else if (code == 0xFC) {
+ } else if (code == COPY_PREV_BUFFER) {
tmp = _offset2;
for (i = 0; i < 4; i++) {
COPY_4X1_LINE(d_dst, d_dst + tmp);
@@ -443,18 +456,18 @@ void Codec47Decoder::level2(byte *d_dst) {
}
void Codec47Decoder::level1(byte *d_dst) {
- int32 tmp, tmp2;
+ int32 tmp;
byte code = *_d_src++;
int i;
- if (code < 0xF8) {
- tmp2 = _table[code] + _offset1;
+ if (code < MOTION_OFFSET_TABLE_SIZE) {
+ tmp = _table[code] + _offset1;
for (i = 0; i < 8; i++) {
- COPY_4X1_LINE(d_dst + 0, d_dst + tmp2);
- COPY_4X1_LINE(d_dst + 4, d_dst + tmp2 + 4);
+ COPY_4X1_LINE(d_dst + 0, d_dst + tmp);
+ COPY_4X1_LINE(d_dst + 4, d_dst + tmp + 4);
d_dst += _d_pitch;
}
- } else if (code == 0xFF) {
+ } else if (code == PROCESS_SUBBLOCKS) {
level2(d_dst);
d_dst += 4;
level2(d_dst);
@@ -462,14 +475,14 @@ void Codec47Decoder::level1(byte *d_dst) {
level2(d_dst);
d_dst += 4;
level2(d_dst);
- } else if (code == 0xFE) {
+ } else if (code == FILL_SINGLE_COLOR) {
byte t = *_d_src++;
for (i = 0; i < 8; i++) {
FILL_4X1_LINE(d_dst, t);
FILL_4X1_LINE(d_dst + 4, t);
d_dst += _d_pitch;
}
- } else if (code == 0xFD) {
+ } else if (code == DRAW_GLYPH) {
tmp = *_d_src++;
byte *tmp_ptr = _tableBig + tmp * 388;
byte l = tmp_ptr[384];
@@ -486,11 +499,11 @@ void Codec47Decoder::level1(byte *d_dst) {
*(d_dst + READ_LE_UINT16(tmp_ptr2)) = val;
tmp_ptr2++;
}
- } else if (code == 0xFC) {
- tmp2 = _offset2;
+ } else if (code == COPY_PREV_BUFFER) {
+ tmp = _offset2;
for (i = 0; i < 8; i++) {
- COPY_4X1_LINE(d_dst + 0, d_dst + tmp2);
- COPY_4X1_LINE(d_dst + 4, d_dst + tmp2 + 4);
+ COPY_4X1_LINE(d_dst + 0, d_dst + tmp);
+ COPY_4X1_LINE(d_dst + 4, d_dst + tmp + 4);
d_dst += _d_pitch;
}
} else {
@@ -505,7 +518,7 @@ void Codec47Decoder::level1(byte *d_dst) {
void Codec47Decoder::decode2(byte *dst, const byte *src, int width, int height, const byte *param_ptr) {
_d_src = src;
- _paramPtr = param_ptr - 0xf8;
+ _paramPtr = param_ptr - MOTION_OFFSET_TABLE_SIZE;
int bw = (width + 7) / 8;
int bh = (height + 7) / 8;
int next_line = width * 7;
@@ -526,8 +539,8 @@ Codec47Decoder::Codec47Decoder(int width, int height) {
_lastTableWidth = -1;
_width = width;
_height = height;
- _tableBig = (byte *)malloc(256 * 388);
- _tableSmall = (byte *)malloc(256 * 128);
+ _tableBig = (byte *)malloc(NGLYPHS * 388);
+ _tableSmall = (byte *)malloc(NGLYPHS * 128);
if ((_tableBig != nullptr) && (_tableSmall != nullptr)) {
makeTablesInterpolation(4);
makeTablesInterpolation(8);
Commit: 8f9d49960ab966ef78461db0db4cdb65013553ef
https://github.com/scummvm/scummvm/commit/8f9d49960ab966ef78461db0db4cdb65013553ef
Author: BLooperZ (blooperz at users.noreply.github.com)
Date: 2022-11-18T13:53:12+01:00
Commit Message:
SCUMM: Align variable name styling in codec47
Changed paths:
engines/scumm/smush/codec47.cpp
diff --git a/engines/scumm/smush/codec47.cpp b/engines/scumm/smush/codec47.cpp
index 76727f41de7..25e11437f97 100644
--- a/engines/scumm/smush/codec47.cpp
+++ b/engines/scumm/smush/codec47.cpp
@@ -75,23 +75,23 @@ namespace Scumm {
#define DRAW_GLYPH 0xFD
#define COPY_PREV_BUFFER 0xFC
-static const int8 codec47_glyph4_xvec[] = {
+static const int8 codec47Glyph4XVec[] = {
0, 1, 2, 3, 3, 3, 3, 2, 1, 0, 0, 0, 1, 2, 2, 1,
};
-static const int8 codec47_glyph4_yvec[] = {
+static const int8 codec47Glyph4YVec[] = {
0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2,
};
-static const int8 codec47_glyph8_xvec[] = {
+static const int8 codec47Glyph8XVec[] = {
0, 2, 5, 7, 7, 7, 7, 7, 7, 5, 2, 0, 0, 0, 0, 0,
};
-static const int8 codec47_glyph8_yvec[] = {
+static const int8 codec47Glyph8YVec[] = {
0, 0, 0, 0, 1, 3, 4, 6, 7, 7, 7, 7, 6, 4, 3, 1,
};
-static const int8 codec47_table[] = {
+static const int8 codec47Table[] = {
0, 0, -1, -43, 6, -43, -9, -42, 13, -41,
-16, -40, 19, -39, -23, -36, 26, -34, -2, -33,
4, -33, -29, -32, -9, -32, 11, -31, -16, -29,
@@ -160,14 +160,14 @@ void Codec47Decoder::makeTablesInterpolation(int sideLength) {
int32 edge0, edge1;
int32 x1, x0, y1, y0;
int32 tableSmallBig[64], s;
- const int8 *glyph_x = nullptr, *glyph_y = nullptr;
- int32 *ptr_small_big;
+ const int8 *xGlyph = nullptr, *yGlyph = nullptr;
+ int32 *ptrSmallBig;
byte *ptr;
int i, x, y;
if (sideLength == 8) {
- glyph_x = codec47_glyph8_xvec;
- glyph_y = codec47_glyph8_yvec;
+ xGlyph = codec47Glyph8XVec;
+ yGlyph = codec47Glyph8YVec;
ptr = _tableBig;
for (i = 0; i < NGLYPHS; i++) {
ptr[384] = 0;
@@ -175,8 +175,8 @@ void Codec47Decoder::makeTablesInterpolation(int sideLength) {
ptr += 388;
}
} else if (sideLength == 4) {
- glyph_x = codec47_glyph4_xvec;
- glyph_y = codec47_glyph4_yvec;
+ xGlyph = codec47Glyph4XVec;
+ yGlyph = codec47Glyph4YVec;
ptr = _tableSmall;
for (i = 0; i < NGLYPHS; i++) {
ptr[96] = 0;
@@ -189,8 +189,8 @@ void Codec47Decoder::makeTablesInterpolation(int sideLength) {
s = 0;
for (x = 0; x < 16; x++) {
- x0 = glyph_x[x];
- y0 = glyph_y[x];
+ x0 = xGlyph[x];
+ y0 = yGlyph[x];
if (y0 == 0) {
edge0 = kEdgeBottom;
@@ -205,8 +205,8 @@ void Codec47Decoder::makeTablesInterpolation(int sideLength) {
}
for (y = 0; y < 16; y++) {
- x1 = glyph_x[y];
- y1 = glyph_y[y];
+ x1 = xGlyph[y];
+ y1 = yGlyph[y];
if (y1 == 0) {
edge1 = kEdgeBottom;
@@ -236,31 +236,31 @@ void Codec47Decoder::makeTablesInterpolation(int sideLength) {
xPoint = x0;
yPoint = y0;
}
- ptr_small_big = &tableSmallBig[sideLength * yPoint + xPoint];
- *ptr_small_big = 1;
+ ptrSmallBig = &tableSmallBig[sideLength * yPoint + xPoint];
+ *ptrSmallBig = 1;
if ((edge0 == kEdgeLeft && edge1 == kEdgeRight) || (edge1 == kEdgeLeft && edge0 == kEdgeRight) ||
(edge0 == kEdgeBottom && edge1 != kEdgeTop) || (edge1 == kEdgeBottom && edge0 != kEdgeTop)) {
if (yPoint >= 0) {
i = yPoint + 1;
while (i--) {
- *ptr_small_big = 1;
- ptr_small_big -= sideLength;
+ *ptrSmallBig = 1;
+ ptrSmallBig -= sideLength;
}
}
} else if ((edge1 != kEdgeBottom && edge0 == kEdgeTop) || (edge0 != kEdgeBottom && edge1 == kEdgeTop)) {
if (sideLength > yPoint) {
i = sideLength - yPoint;
while (i--) {
- *ptr_small_big = 1;
- ptr_small_big += sideLength;
+ *ptrSmallBig = 1;
+ ptrSmallBig += sideLength;
}
}
} else if ((edge0 == kEdgeLeft && edge1 != kEdgeRight) || (edge1 == kEdgeLeft && edge0 != kEdgeRight)) {
if (xPoint >= 0) {
i = xPoint + 1;
while (i--) {
- *(ptr_small_big--) = 1;
+ *(ptrSmallBig--) = 1;
}
}
} else if ((edge0 == kEdgeBottom && edge1 == kEdgeTop) || (edge1 == kEdgeBottom && edge0 == kEdgeTop) ||
@@ -268,7 +268,7 @@ void Codec47Decoder::makeTablesInterpolation(int sideLength) {
if (sideLength > xPoint) {
i = sideLength - xPoint;
while (i--) {
- *(ptr_small_big++) = 1;
+ *(ptrSmallBig++) = 1;
}
}
}
@@ -311,8 +311,8 @@ void Codec47Decoder::makeTables47(int width) {
int32 a, c, d;
int16 tmp;
- for (int l = 0; l < ARRAYSIZE(codec47_table); l += 2) {
- _table[l / 2] = (int16)(codec47_table[l + 1] * width + codec47_table[l]);
+ for (int l = 0; l < ARRAYSIZE(codec47Table); l += 2) {
+ _table[l / 2] = (int16)(codec47Table[l + 1] * width + codec47Table[l]);
}
// Note: _table[255] is never inited; but since only the first 0xF8
// entries of it are used anyway, this doesn't matter.
More information about the Scummvm-git-logs
mailing list