* @brief Blit CL2 sprite to the given buffer * @param pDecodeTo The output buffer * @param pRLEBytes CL2 pixel stream (run-length encoded) * @param nDataSize Size of CL2 in bytes * @param nWidth Width of sprite */
| 1102 | * @param nWidth Width of sprite |
| 1103 | */ |
| 1104 | void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) |
| 1105 | { |
| 1106 | int w; |
| 1107 | char width; |
| 1108 | BYTE fill; |
| 1109 | BYTE *src, *dst; |
| 1110 | |
| 1111 | src = pRLEBytes; |
| 1112 | dst = pDecodeTo; |
| 1113 | w = nWidth; |
| 1114 | |
| 1115 | while (nDataSize) { |
| 1116 | width = *src++; |
| 1117 | nDataSize--; |
| 1118 | if (width < 0) { |
| 1119 | width = -width; |
| 1120 | if (width > 65) { |
| 1121 | width -= 65; |
| 1122 | nDataSize--; |
| 1123 | fill = *src++; |
| 1124 | if (dst < gpBufEnd && dst > gpBufStart) { |
| 1125 | w -= width; |
| 1126 | while (width) { |
| 1127 | *dst = fill; |
| 1128 | dst++; |
| 1129 | width--; |
| 1130 | } |
| 1131 | if (!w) { |
| 1132 | w = nWidth; |
| 1133 | dst -= BUFFER_WIDTH + w; |
| 1134 | } |
| 1135 | continue; |
| 1136 | } |
| 1137 | } else { |
| 1138 | nDataSize -= width; |
| 1139 | if (dst < gpBufEnd && dst > gpBufStart) { |
| 1140 | w -= width; |
| 1141 | while (width) { |
| 1142 | *dst = *src; |
| 1143 | src++; |
| 1144 | dst++; |
| 1145 | width--; |
| 1146 | } |
| 1147 | if (!w) { |
| 1148 | w = nWidth; |
| 1149 | dst -= BUFFER_WIDTH + w; |
| 1150 | } |
| 1151 | continue; |
| 1152 | } else { |
| 1153 | src += width; |
| 1154 | } |
| 1155 | } |
| 1156 | } |
| 1157 | while (width) { |
| 1158 | if (width > w) { |
| 1159 | dst += w; |
| 1160 | width -= w; |
| 1161 | w = 0; |
no outgoing calls
no test coverage detected