* @brief Same as CelBlitLightSafe, with transparancy applied * @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 */
| 318 | * @param nWidth Width of sprite |
| 319 | */ |
| 320 | void CelBlitLightTransSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) |
| 321 | { |
| 322 | int w; |
| 323 | BOOL shift; |
| 324 | BYTE *tbl; |
| 325 | |
| 326 | assert(pDecodeTo != NULL); |
| 327 | assert(pRLEBytes != NULL); |
| 328 | assert(gpBuffer); |
| 329 | |
| 330 | int i; |
| 331 | BYTE width; |
| 332 | BYTE *src, *dst; |
| 333 | |
| 334 | src = pRLEBytes; |
| 335 | dst = pDecodeTo; |
| 336 | tbl = &pLightTbl[light_table_index * 256]; |
| 337 | w = nWidth; |
| 338 | shift = (BYTE)(size_t)dst & 1; |
| 339 | |
| 340 | for (; src != &pRLEBytes[nDataSize]; dst -= BUFFER_WIDTH + w, shift = (shift + 1) & 1) { |
| 341 | for (i = w; i;) { |
| 342 | width = *src++; |
| 343 | if (!(width & 0x80)) { |
| 344 | i -= width; |
| 345 | if (dst < gpBufEnd && dst > gpBufStart) { |
| 346 | if (((BYTE)(size_t)dst & 1) == shift) { |
| 347 | if (!(width & 1)) { |
| 348 | goto L_ODD; |
| 349 | } else { |
| 350 | src++; |
| 351 | dst++; |
| 352 | L_EVEN: |
| 353 | width >>= 1; |
| 354 | if (width & 1) { |
| 355 | dst[0] = tbl[src[0]]; |
| 356 | src += 2; |
| 357 | dst += 2; |
| 358 | } |
| 359 | width >>= 1; |
| 360 | for (; width; width--) { |
| 361 | dst[0] = tbl[src[0]]; |
| 362 | dst[2] = tbl[src[2]]; |
| 363 | src += 4; |
| 364 | dst += 4; |
| 365 | } |
| 366 | } |
| 367 | } else { |
| 368 | if (!(width & 1)) { |
| 369 | goto L_EVEN; |
| 370 | } else { |
| 371 | dst[0] = tbl[src[0]]; |
| 372 | src++; |
| 373 | dst++; |
| 374 | L_ODD: |
| 375 | width >>= 1; |
| 376 | if (width & 1) { |
| 377 | dst[1] = tbl[src[1]]; |
no outgoing calls
no test coverage detected