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

Function CelBlitSafe

Source/engine.cpp:191–222  ·  view source on GitHub ↗

* @brief Blit CEL sprite 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 */

Source from the content-addressed store, hash-verified

189 * @param nWidth Width of sprite
190 */
191void CelBlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
192{
193 int i, w;
194 BYTE width;
195 BYTE *src, *dst;
196
197 assert(pDecodeTo != NULL);
198 assert(pRLEBytes != NULL);
199 assert(gpBuffer);
200
201 src = pRLEBytes;
202 dst = pDecodeTo;
203 w = nWidth;
204
205 for (; src != &pRLEBytes[nDataSize]; dst -= BUFFER_WIDTH + w) {
206 for (i = w; i;) {
207 width = *src++;
208 if (!(width & 0x80)) {
209 i -= width;
210 if (dst < gpBufEnd && dst > gpBufStart) {
211 memcpy(dst, src, width);
212 }
213 src += width;
214 dst += width;
215 } else {
216 width = -(char)width;
217 dst += width;
218 i -= width;
219 }
220 }
221 }
222}
223
224/**
225 * @brief Same as CelClippedDraw but checks for drawing outside the buffer

Callers 6

CelBlitFrameFunction · 0.85
CelClippedDrawFunction · 0.85
CelDrawLightFunction · 0.85
CelClippedDrawLightFunction · 0.85
CelClippedDrawSafeFunction · 0.85
CelClippedBlitLightTransFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected