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

Function CelBlitLightSafe

Source/engine.cpp:257–311  ·  view source on GitHub ↗

* @brief Blit CEL sprite, and apply lighting, to the given buffer, checks for drawing outside the buffer * @param pDecodeTo The output buffer * @param pRLEBytes CEL pixel stream (run-length encoded) * @param nDataSize Size of CEL in bytes * @param nWidth Width of sprite * @param tbl Palette translation table */

Source from the content-addressed store, hash-verified

255 * @param tbl Palette translation table
256 */
257void CelBlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *tbl)
258{
259 int i, w;
260 BYTE width;
261 BYTE *src, *dst;
262
263 assert(pDecodeTo != NULL);
264 assert(pRLEBytes != NULL);
265 assert(gpBuffer);
266
267 src = pRLEBytes;
268 dst = pDecodeTo;
269 if (tbl == NULL)
270 tbl = &pLightTbl[light_table_index * 256];
271 w = nWidth;
272
273 for (; src != &pRLEBytes[nDataSize]; dst -= BUFFER_WIDTH + w) {
274 for (i = w; i;) {
275 width = *src++;
276 if (!(width & 0x80)) {
277 i -= width;
278 if (dst < gpBufEnd && dst > gpBufStart) {
279 if (width & 1) {
280 dst[0] = tbl[src[0]];
281 src++;
282 dst++;
283 }
284 width >>= 1;
285 if (width & 1) {
286 dst[0] = tbl[src[0]];
287 dst[1] = tbl[src[1]];
288 src += 2;
289 dst += 2;
290 }
291 width >>= 1;
292 for (; width; width--) {
293 dst[0] = tbl[src[0]];
294 dst[1] = tbl[src[1]];
295 dst[2] = tbl[src[2]];
296 dst[3] = tbl[src[3]];
297 src += 4;
298 dst += 4;
299 }
300 } else {
301 src += width;
302 dst += width;
303 }
304 } else {
305 width = -(char)width;
306 dst += width;
307 i -= width;
308 }
309 }
310 }
311}
312
313/**
314 * @brief Same as CelBlitLightSafe, with transparancy applied

Callers 3

CelDrawLightFunction · 0.85
CelClippedDrawLightFunction · 0.85
CelClippedBlitLightTransFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected