MCPcopy Create free account
hub / github.com/diasurgical/devilution / Cl2ApplyTrans

Function Cl2ApplyTrans

Source/engine.cpp:1034–1069  ·  view source on GitHub ↗

* @brief Apply the color swaps to a CL2 sprite * @param p CL2 buffer * @param ttbl Palette translation table * @param nCel Frame number in CL2 file */

Source from the content-addressed store, hash-verified

1032 * @param nCel Frame number in CL2 file
1033 */
1034void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel)
1035{
1036 int i, nDataSize;
1037 char width;
1038 BYTE *dst;
1039
1040 assert(p != NULL);
1041 assert(ttbl != NULL);
1042
1043 for (i = 1; i <= nCel; i++) {
1044 dst = CelGetFrame(p, i, &nDataSize) + 10;
1045 nDataSize -= 10;
1046 while (nDataSize) {
1047 width = *dst++;
1048 nDataSize--;
1049 assert(nDataSize >= 0);
1050 if (width < 0) {
1051 width = -width;
1052 if (width > 65) {
1053 nDataSize--;
1054 assert(nDataSize >= 0);
1055 *dst = ttbl[*dst];
1056 dst++;
1057 } else {
1058 nDataSize -= width;
1059 assert(nDataSize >= 0);
1060 while (width) {
1061 *dst = ttbl[*dst];
1062 dst++;
1063 width--;
1064 }
1065 }
1066 }
1067 }
1068 }
1069}
1070
1071/**
1072 * @brief Blit CL2 sprite, to the back buffer at the given coordianates

Callers 1

InitMonsterTRNFunction · 0.85

Calls 1

CelGetFrameFunction · 0.85

Tested by

no test coverage detected