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

Function CelDrawLightRedSafe

Source/engine.cpp:436–483  ·  view source on GitHub ↗

* @brief Same as CelDrawLightRed but checks for drawing outside the buffer * @param sx Back buffer coordinate * @param sy Back buffer coordinate * @param pCelBuff Cel data * @param nCel CEL frame number * @param nWidth Width of cel * @param light Light shade to use */

Source from the content-addressed store, hash-verified

434 * @param light Light shade to use
435 */
436void CelDrawLightRedSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char light)
437{
438 int nDataSize, w, idx;
439 BYTE *pRLEBytes, *dst, *tbl;
440
441 assert(gpBuffer);
442 assert(pCelBuff != NULL);
443
444 pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, &nDataSize);
445 dst = &gpBuffer[sx + BUFFER_WIDTH * sy];
446
447 idx = light4flag ? 1024 : 4096;
448 if (light == 2)
449 idx += 256;
450 if (light >= 4)
451 idx += (light - 1) << 8;
452
453 tbl = &pLightTbl[idx];
454
455 BYTE width;
456 BYTE *end;
457
458 end = &pRLEBytes[nDataSize];
459
460 for (; pRLEBytes != end; dst -= BUFFER_WIDTH + nWidth) {
461 for (w = nWidth; w;) {
462 width = *pRLEBytes++;
463 if (!(width & 0x80)) {
464 w -= width;
465 if (dst < gpBufEnd && dst > gpBufStart) {
466 while (width) {
467 *dst = tbl[*pRLEBytes];
468 pRLEBytes++;
469 dst++;
470 width--;
471 }
472 } else {
473 pRLEBytes += width;
474 dst += width;
475 }
476 } else {
477 width = -(char)width;
478 dst += width;
479 w -= width;
480 }
481 }
482 }
483}
484
485/**
486 * @brief Blit to a buffer at given coordinates

Callers 1

Calls 1

CelGetFrameClippedFunction · 0.85

Tested by

no test coverage detected