* @brief Blit CEL sprite, and apply lighting, to the back buffer at the given coordinates, translated to a red hue * @param sx Back buffer coordinate * @param sy Back buffer coordinate * @param pCelBuff Cel data * @param nCel CEL frame number * @param nWidth Width of sprite * @param light Light shade to use */
| 139 | * @param light Light shade to use |
| 140 | */ |
| 141 | void CelDrawLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char light) |
| 142 | { |
| 143 | int nDataSize, w, idx; |
| 144 | BYTE *pRLEBytes, *dst, *tbl; |
| 145 | |
| 146 | assert(gpBuffer); |
| 147 | assert(pCelBuff != NULL); |
| 148 | |
| 149 | pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, &nDataSize); |
| 150 | dst = &gpBuffer[sx + BUFFER_WIDTH * sy]; |
| 151 | |
| 152 | idx = light4flag ? 1024 : 4096; |
| 153 | if (light == 2) |
| 154 | idx += 256; |
| 155 | if (light >= 4) |
| 156 | idx += (light - 1) << 8; |
| 157 | |
| 158 | BYTE width; |
| 159 | BYTE *end; |
| 160 | |
| 161 | tbl = &pLightTbl[idx]; |
| 162 | end = &pRLEBytes[nDataSize]; |
| 163 | |
| 164 | for (; pRLEBytes != end; dst -= BUFFER_WIDTH + nWidth) { |
| 165 | for (w = nWidth; w;) { |
| 166 | width = *pRLEBytes++; |
| 167 | if (!(width & 0x80)) { |
| 168 | w -= width; |
| 169 | while (width) { |
| 170 | *dst = tbl[*pRLEBytes]; |
| 171 | pRLEBytes++; |
| 172 | dst++; |
| 173 | width--; |
| 174 | } |
| 175 | } else { |
| 176 | width = -(char)width; |
| 177 | dst += width; |
| 178 | w -= width; |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * @brief Blit CEL sprite to the given buffer, checks for drawing outside the buffer |
no test coverage detected