BlitterRLE8.inl
Go to the documentation of this file.00001 //*** BlitterRLE8.inl *** 00002 00003 #include "BlitterRLE8.h" 00004 #include "ColorHelper.h" 00005 #include "StandardLibrary.h" 00006 00007 00008 //*** Opaque_Unclipped_Unmasked *** 00009 00010 void BlitterRLE8::Opaque_Unclipped_Unmasked(unsigned char* opaqueData, int activeWidth, int activeHeight, unsigned short* palette, unsigned short* data, int backBufferDelta,int x, int y) 00011 { 00012 unsigned char* dataRLE=opaqueData; 00013 for (int yi=0; yi<activeHeight; ++yi) 00014 { 00015 int xi=0; 00016 while (xi<activeWidth) 00017 { 00018 // Get run length 00019 int len=*dataRLE; 00020 ++dataRLE; 00021 00022 RunLength_Opaque_Unclipped_Unmasked(len,data,&dataRLE,palette); 00023 len&=0x7f; 00024 data+=len; 00025 00026 xi+=len; 00027 } 00028 00029 data+=backBufferDelta; 00030 } 00031 } 00032 00033 00034 //*** Opaque_Unclipped_Masked *** 00035 00036 void BlitterRLE8::Opaque_Unclipped_Masked(unsigned char* opaqueData, int activeWidth, int activeHeight, unsigned short* palette, unsigned short* data, int backBufferDelta,int x, int y) 00037 { 00038 unsigned char* dataRLE=opaqueData; 00039 for (int yi=0; yi<activeHeight; ++yi) 00040 { 00041 int xi=0; 00042 while (xi<activeWidth) 00043 { 00044 // Get run length 00045 int len=*dataRLE; 00046 ++dataRLE; 00047 00048 RunLength_Opaque_Unclipped_Masked(len,data,&dataRLE,palette); 00049 len&=0x7f; 00050 data+=len; 00051 00052 xi+=len; 00053 } 00054 data+=backBufferDelta; 00055 } 00056 } 00057 00058 //*** Opaque_Unclipped_Unmasked_Transparent *** 00059 00060 void BlitterRLE8::Opaque_Unclipped_Unmasked_Transparent(unsigned char* opaqueData, int activeWidth, int activeHeight, unsigned short* palette, unsigned short* data, int backBufferDelta,int x, int y, unsigned char alpha) 00061 { 00062 unsigned char* dataRLE=opaqueData; 00063 for (int yi=0; yi<activeHeight; ++yi) 00064 { 00065 int xi=0; 00066 while (xi<activeWidth) 00067 { 00068 // Get run length 00069 int len=*dataRLE; 00070 ++dataRLE; 00071 00072 RunLength_Opaque_Unclipped_Unmasked_Transparent(len,data,&dataRLE,palette,alpha); 00073 len&=0x7f; 00074 data+=len; 00075 00076 xi+=len; 00077 } 00078 00079 data+=backBufferDelta; 00080 } 00081 } 00082 00083 00084 00085 00086 //*** Opaque_Unclipped_Masked_Transparent *** 00087 00088 void BlitterRLE8::Opaque_Unclipped_Masked_Transparent(unsigned char* opaqueData, int activeWidth, int activeHeight, unsigned short* palette, unsigned short* data, int backBufferDelta,int x, int y, unsigned char alpha) 00089 { 00090 unsigned char* dataRLE=opaqueData; 00091 for (int yi=0; yi<activeHeight; ++yi) 00092 { 00093 int xi=0; 00094 while (xi<activeWidth) 00095 { 00096 // Get run length 00097 int len=*dataRLE; 00098 ++dataRLE; 00099 00100 RunLength_Opaque_Unclipped_MaskedTransparent(len,data,&dataRLE,palette,alpha); 00101 len&=0x7f; 00102 data+=len; 00103 00104 xi+=len; 00105 } 00106 data+=backBufferDelta; 00107 } 00108 } 00109 00110 00111 //*** Opaque_Clipped_Unmasked *** 00112 00113 void BlitterRLE8::Opaque_Clipped_Unmasked(unsigned char* opaqueData, int activeWidth, int activeHeight, unsigned short* palette, unsigned short* data, int backBufferDelta,int x, int y, int xStart, int yStart, int xEnd, int yEnd) 00114 { 00115 unsigned char* dataRLE=opaqueData; 00116 00117 // Skip clipped rows 00118 for (int i=0; i<yStart; i++) 00119 { 00120 int xi=0; 00121 while (xi<activeWidth) 00122 { 00123 // Get run length 00124 int len=*dataRLE; 00125 ++dataRLE; 00126 00127 IgnoreOpaque(len,&dataRLE); 00128 len&=0x7f; 00129 00130 xi+=len; 00131 } 00132 } 00133 00134 data+=yStart*(backBufferDelta+activeWidth); 00135 00136 for (int yi=yStart; yi<(activeHeight-yEnd); yi++) 00137 { 00138 int xi=0; 00139 while (xi<activeWidth) 00140 { 00141 // Get run length 00142 int len=*dataRLE; 00143 ++dataRLE; 00144 00145 // Are we on the edge? 00146 int runLength=(len&0x7f); 00147 if (xi<xStart || (xi+runLength)>(activeWidth-xEnd)) 00148 { 00149 // yes, on the edge, but is the whole segment off screen? 00150 if ((xi+runLength)<xStart || xi>(activeWidth-xEnd)) 00151 { 00152 // Yes, whole segment is out of view, so ignore 00153 IgnoreOpaque(len,&dataRLE); 00154 } 00155 else 00156 { 00157 // No, only part of the segment is out of view, so need to draw with clipping 00158 int clipStart=xStart-xi; 00159 int clipEnd=(activeWidth-xEnd)-xi; 00160 RunLength_Opaque_Clipped_Masked(len,data,&dataRLE,palette,clipStart,clipEnd); 00161 // Yes, we use the masked version here, because it doesn't give enough speed benefit to have a special 00162 // unmasked version of the clipped one 00163 } 00164 } 00165 else // nope, not near edge, so just barge ahead 00166 { 00167 RunLength_Opaque_Unclipped_Unmasked(len,data,&dataRLE,palette); 00168 } 00169 00170 len&=0x7f; 00171 data+=len; 00172 00173 xi+=len; 00174 } 00175 data+=backBufferDelta; 00176 } 00177 } 00178 00179 00180 //*** Opaque_Clipped_Masked *** 00181 00182 void BlitterRLE8::Opaque_Clipped_Masked(unsigned char* opaqueData, int activeWidth, int activeHeight, unsigned short* palette, unsigned short* data, int backBufferDelta,int x, int y, int xStart, int yStart, int xEnd, int yEnd) 00183 { 00184 if (yStart>activeHeight-yEnd) 00185 return; 00186 if (xStart>activeWidth-xEnd) 00187 return; 00188 unsigned char* dataRLE=opaqueData; 00189 00190 // Skip clipped rows 00191 for (int i=0; i<yStart; i++) 00192 { 00193 int xi=0; 00194 while (xi<activeWidth) 00195 { 00196 // Get run length 00197 int len=*dataRLE; 00198 ++dataRLE; 00199 00200 IgnoreOpaque(len,&dataRLE); 00201 len&=0x7f; 00202 00203 xi+=len; 00204 } 00205 } 00206 00207 data+=yStart*(backBufferDelta+activeWidth); 00208 00209 for (int yi=yStart; yi<(activeHeight-yEnd); ++yi) 00210 { 00211 int xi=0; 00212 while (xi<activeWidth) 00213 { 00214 // Get run length 00215 int len=*dataRLE; 00216 ++dataRLE; 00217 00218 // Are we on the edge? 00219 int runLength=(len&0x7f); 00220 if (xi<xStart || (xi+runLength)>(activeWidth-xEnd)) 00221 { 00222 // yes, on the edge, but is the whole segment off screen? 00223 if ((xi+runLength)<xStart || xi>(activeWidth-xEnd)) 00224 { 00225 // Yes, whole segment is out of view, so ignore 00226 IgnoreOpaque(len,&dataRLE); 00227 } 00228 else 00229 { 00230 // No, only part of the segment is out of view, so need to draw with clipping 00231 int clipStart=xStart-xi; 00232 int clipEnd=(activeWidth-xEnd)-xi; 00233 00234 RunLength_Opaque_Clipped_Masked(len,data,&dataRLE,palette,clipStart,clipEnd); 00235 } 00236 } 00237 else // nope, not near edge, so just barge ahead 00238 { 00239 RunLength_Opaque_Unclipped_Masked(len,data,&dataRLE,palette); 00240 } 00241 00242 len&=0x7f; 00243 data+=len; 00244 00245 xi+=len; 00246 } 00247 data+=backBufferDelta; 00248 } 00249 } 00250 00251 00252 //*** Opaque_Clipped_Unmasked_Transparent *** 00253 00254 void BlitterRLE8::Opaque_Clipped_Unmasked_Transparent(unsigned char* opaqueData, int activeWidth, int activeHeight, unsigned short* palette, unsigned short* data, int backBufferDelta,int x, int y, int xStart, int yStart, int xEnd, int yEnd,unsigned char alpha) 00255 { 00256 unsigned char* dataRLE=opaqueData; 00257 00258 // Skip clipped rows 00259 for (int i=0; i<yStart; i++) 00260 { 00261 int xi=0; 00262 while (xi<activeWidth) 00263 { 00264 // Get run length 00265 int len=*dataRLE; 00266 ++dataRLE; 00267 00268 IgnoreOpaque(len,&dataRLE); 00269 len&=0x7f; 00270 00271 xi+=len; 00272 } 00273 } 00274 00275 data+=yStart*(backBufferDelta+activeWidth); 00276 00277 for (int yi=yStart; yi<(activeHeight-yEnd); yi++) 00278 { 00279 int xi=0; 00280 while (xi<activeWidth) 00281 { 00282 // Get run length 00283 int len=*dataRLE; 00284 ++dataRLE; 00285 00286 // Are we on the edge? 00287 int runLength=(len&0x7f); 00288 if (xi<xStart || (xi+runLength)>(activeWidth-xEnd)) 00289 { 00290 // yes, on the edge, but is the whole segment off screen? 00291 if ((xi+runLength)<xStart || xi>(activeWidth-xEnd)) 00292 { 00293 // Yes, whole segment is out of view, so ignore 00294 IgnoreOpaque(len,&dataRLE); 00295 } 00296 else 00297 { 00298 // No, only part of the segment is out of view, so need to draw with clipping 00299 int clipStart=xStart-xi; 00300 int clipEnd=(activeWidth-xEnd)-xi; 00301 RunLength_Opaque_Clipped_Masked_Transparent(len,data,&dataRLE,palette,clipStart,clipEnd,alpha); 00302 // Yes, we use the masked version here, because it doesn't give enough speed benefit to 00303 // have a special unmasked version of the clipped one 00304 } 00305 } 00306 else // nope, not near edge, so just barge ahead 00307 { 00308 RunLength_Opaque_Unclipped_Unmasked_Transparent(len,data,&dataRLE,palette,alpha); 00309 } 00310 00311 len&=0x7f; 00312 data+=len; 00313 00314 xi+=len; 00315 } 00316 data+=backBufferDelta; 00317 } 00318 } 00319 00320 00321 //*** Opaque_Clipped_Masked_Transparent *** 00322 00323 void BlitterRLE8::Opaque_Clipped_Masked_Transparent(unsigned char* opaqueData, int activeWidth, int activeHeight, unsigned short* palette, unsigned short* data, int backBufferDelta,int x, int y, int xStart, int yStart, int xEnd, int yEnd, unsigned char alpha) 00324 { 00325 if (yStart>activeHeight-yEnd) 00326 return; 00327 if (xStart>activeWidth-xEnd) 00328 return; 00329 unsigned char* dataRLE=opaqueData; 00330 00331 // Skip clipped rows 00332 for (int i=0; i<yStart; i++) 00333 { 00334 int xi=0; 00335 while (xi<activeWidth) 00336 { 00337 // Get run length 00338 int len=*dataRLE; 00339 ++dataRLE; 00340 00341 IgnoreOpaque(len,&dataRLE); 00342 len&=0x7f; 00343 00344 xi+=len; 00345 } 00346 } 00347 00348 data+=yStart*(backBufferDelta+activeWidth); 00349 00350 for (int yi=yStart; yi<(activeHeight-yEnd); ++yi) 00351 { 00352 int xi=0; 00353 while (xi<activeWidth) 00354 { 00355 // Get run length 00356 int len=*dataRLE; 00357 ++dataRLE; 00358 00359 // Are we on the edge? 00360 int runLength=(len&0x7f); 00361 if (xi<xStart || (xi+runLength)>(activeWidth-xEnd)) 00362 { 00363 // yes, on the edge, but is the whole segment off screen? 00364 if ((xi+runLength)<xStart || xi>(activeWidth-xEnd)) 00365 { 00366 // Yes, whole segment is out of view, so ignore 00367 IgnoreOpaque(len,&dataRLE); 00368 } 00369 else 00370 { 00371 // No, only part of the segment is out of view, so need to draw with clipping 00372 int clipStart=xStart-xi; 00373 int clipEnd=(activeWidth-xEnd)-xi; 00374 00375 RunLength_Opaque_Clipped_Masked_Transparent(len,data,&dataRLE,palette,clipStart,clipEnd,alpha); 00376 } 00377 } 00378 else // nope, not near edge, so just barge ahead 00379 { 00380 RunLength_Opaque_Unclipped_MaskedTransparent(len,data,&dataRLE,palette,alpha); 00381 } 00382 00383 len&=0x7f; 00384 data+=len; 00385 00386 xi+=len; 00387 } 00388 data+=backBufferDelta; 00389 } 00390 } 00391 00392 00393 00394 //*** Alpha_Unclipped *** 00395 00396 void BlitterRLE8::Alpha_Unclipped(unsigned char* alphaData, int activeWidth, int activeHeight, unsigned short* palette, unsigned short* data, int backBufferDelta,int x, int y) 00397 { 00398 unsigned char* dataRLE=alphaData; 00399 for (int yi=0; yi<activeHeight; ++yi) 00400 { 00401 int xi=0; 00402 while (xi<activeWidth) 00403 { 00404 // Get run length 00405 unsigned int len=*dataRLE; 00406 ++dataRLE; 00407 if (len&0x80) 00408 { 00409 len&=0x7f; 00410 // Unique values 00411 for (unsigned int i=0; i<len; ++i) 00412 { 00413 unsigned char alpha=*dataRLE; 00414 ++dataRLE; 00415 if (alpha!=0) 00416 { 00417 *data=AlphaBlend16(*data,palette[*dataRLE],alpha); 00418 //Blend(data,palette[*dataRLE],alpha); 00419 } 00420 ++dataRLE; 00421 ++data; 00422 } 00423 } 00424 else 00425 { 00426 unsigned char alpha=*dataRLE; 00427 ++dataRLE; 00428 if (alpha!=0) 00429 { 00430 unsigned short color=palette[*dataRLE]; 00431 ++dataRLE; 00432 00433 for (unsigned int i=0; i<len; ++i) 00434 { 00435 *data=AlphaBlend16(*data,color,alpha); 00436 //Blend(data,color,alpha); 00437 ++data; 00438 } 00439 } 00440 else 00441 { 00442 ++dataRLE; 00443 data+=len; 00444 } 00445 } 00446 xi+=len; 00447 } 00448 data+=backBufferDelta; 00449 } 00450 } 00451 00452 00453 //*** Alpha_Clipped *** 00454 00455 void BlitterRLE8::Alpha_Clipped(unsigned char* alphaData, int activeWidth, int activeHeight, unsigned short* palette, unsigned short* data, int backBufferDelta,int x, int y, int xStart, int yStart, int xEnd, int yEnd) 00456 { 00457 unsigned char* dataRLE=alphaData; 00458 00459 // Skip clipped rows 00460 for (int i=0; i<yStart; i++) 00461 { 00462 int xi=0; 00463 while (xi<activeWidth) 00464 { 00465 // Get run length 00466 int len=*dataRLE; 00467 ++dataRLE; 00468 00469 IgnoreAlpha(len,&dataRLE); 00470 len&=0x7f; 00471 00472 xi+=len; 00473 } 00474 } 00475 00476 data+=yStart*(backBufferDelta+activeWidth); 00477 00478 for (int yi=yStart; yi<activeHeight-yEnd; ++yi) 00479 { 00480 int xi=0; 00481 while (xi<activeWidth) 00482 { 00483 // Get run length 00484 int len=*dataRLE; 00485 ++dataRLE; 00486 if (len&0x80) 00487 { 00488 len&=0x7f; 00489 // Unique values 00490 for (int i=0; i<len; ++i) 00491 { 00492 unsigned char alpha=*dataRLE; 00493 ++dataRLE; 00494 if (alpha!=0 && (xi+i)>=xStart && (xi+i)<=(activeWidth-xEnd)) 00495 { 00496 *data=AlphaBlend16(*data,palette[*dataRLE],alpha); 00497 //Blend(data,palette[*dataRLE],alpha); 00498 } 00499 ++dataRLE; 00500 ++data; 00501 } 00502 } 00503 else 00504 { 00505 unsigned char alpha=*dataRLE; 00506 ++dataRLE; 00507 if (alpha!=0) 00508 { 00509 unsigned short color=palette[*dataRLE]; 00510 ++dataRLE; 00511 00512 for (int i=0; i<len; ++i) 00513 { 00514 if ((xi+i)>=xStart && (xi+i)<=(activeWidth-xEnd)) 00515 { 00516 *data=AlphaBlend16(*data,color,alpha); 00517 //Blend(data,color,alpha); 00518 } 00519 ++data; 00520 } 00521 } 00522 else 00523 { 00524 ++dataRLE; 00525 data+=len; 00526 } 00527 } 00528 xi+=len; 00529 } 00530 data+=backBufferDelta; 00531 } 00532 } 00533 00534 00535 //*** Alpha_Unclipped_Transparent *** 00536 00537 void BlitterRLE8::Alpha_Unclipped_Transparent(unsigned char* alphaData, int activeWidth, int activeHeight, unsigned short* palette, unsigned short* data, int backBufferDelta,int x, int y, unsigned char transparency) 00538 { 00539 unsigned char* dataRLE=alphaData; 00540 for (int yi=0; yi<activeHeight; ++yi) 00541 { 00542 int xi=0; 00543 while (xi<activeWidth) 00544 { 00545 // Get run length 00546 unsigned int len=*dataRLE; 00547 ++dataRLE; 00548 if (len&0x80) 00549 { 00550 len&=0x7f; 00551 // Unique values 00552 for (unsigned int i=0; i<len; ++i) 00553 { 00554 unsigned char alpha=*dataRLE; 00555 alpha=(unsigned char)(((unsigned int)alpha*(unsigned int)transparency)>>8); 00556 ++dataRLE; 00557 if (alpha!=0) 00558 { 00559 *data=AlphaBlend16(*data,palette[*dataRLE],alpha); 00560 //Blend(data,palette[*dataRLE],alpha); 00561 } 00562 ++dataRLE; 00563 ++data; 00564 } 00565 } 00566 else 00567 { 00568 unsigned char alpha=*dataRLE; 00569 alpha=(unsigned char)(((unsigned int)alpha*(unsigned int)transparency)>>8); 00570 ++dataRLE; 00571 if (alpha!=0) 00572 { 00573 unsigned short color=palette[*dataRLE]; 00574 ++dataRLE; 00575 00576 for (unsigned int i=0; i<len; ++i) 00577 { 00578 *data=AlphaBlend16(*data,color,alpha); 00579 //Blend(data,color,alpha); 00580 ++data; 00581 } 00582 } 00583 else 00584 { 00585 ++dataRLE; 00586 data+=len; 00587 } 00588 } 00589 xi+=len; 00590 } 00591 data+=backBufferDelta; 00592 } 00593 } 00594 00595 00596 00597 //*** Alpha_Clipped_Transparent *** 00598 00599 void BlitterRLE8::Alpha_Clipped_Transparent(unsigned char* alphaData, int activeWidth, int activeHeight, unsigned short* palette, unsigned short* data, int backBufferDelta,int x, int y, int xStart, int yStart, int xEnd, int yEnd, unsigned char transparency) 00600 { 00601 unsigned char* dataRLE=alphaData; 00602 00603 // Skip clipped rows 00604 for (int i=0; i<yStart; i++) 00605 { 00606 int xi=0; 00607 while (xi<activeWidth) 00608 { 00609 // Get run length 00610 int len=*dataRLE; 00611 ++dataRLE; 00612 00613 IgnoreAlpha(len,&dataRLE); 00614 len&=0x7f; 00615 00616 xi+=len; 00617 } 00618 } 00619 00620 data+=yStart*(backBufferDelta+activeWidth); 00621 00622 for (int yi=yStart; yi<activeHeight-yEnd; ++yi) 00623 { 00624 int xi=0; 00625 while (xi<activeWidth) 00626 { 00627 // Get run length 00628 int len=*dataRLE; 00629 ++dataRLE; 00630 if (len&0x80) 00631 { 00632 len&=0x7f; 00633 // Unique values 00634 for (int i=0; i<len; ++i) 00635 { 00636 unsigned char alpha=*dataRLE; 00637 alpha=(unsigned char)(((unsigned int)alpha*(unsigned int)transparency)>>8); 00638 ++dataRLE; 00639 if (alpha!=0 && (xi+i)>=xStart && (xi+i)<=(activeWidth-xEnd)) 00640 { 00641 *data=AlphaBlend16(*data,palette[*dataRLE],alpha); 00642 //Blend(data,palette[*dataRLE],alpha); 00643 } 00644 ++dataRLE; 00645 ++data; 00646 } 00647 } 00648 else 00649 { 00650 unsigned char alpha=*dataRLE; 00651 alpha=(unsigned char)(((unsigned int)alpha*(unsigned int)transparency)>>8); 00652 ++dataRLE; 00653 if (alpha!=0) 00654 { 00655 unsigned short color=palette[*dataRLE]; 00656 ++dataRLE; 00657 00658 for (int i=0; i<len; ++i) 00659 { 00660 if ((xi+i)>=xStart && (xi+i)<=(activeWidth-xEnd)) 00661 { 00662 *data=AlphaBlend16(*data,color,alpha); 00663 //Blend(data,color,alpha); 00664 } 00665 ++data; 00666 } 00667 } 00668 else 00669 { 00670 ++dataRLE; 00671 data+=len; 00672 } 00673 } 00674 xi+=len; 00675 } 00676 data+=backBufferDelta; 00677 } 00678 } 00679 00680 00681 //*** Fill *** 00682 00683 void BlitterRLE8::Fill(unsigned short* data, unsigned short color, int len) 00684 { 00685 for (int i=0; i<len; ++i) 00686 { 00687 *data=color; 00688 data++; 00689 } 00690 } 00691 00692 00693 //*** Blend *** 00694 /* 00695 void BlitterRLE8::Blend(unsigned short* destination, unsigned int color, unsigned int alpha) 00696 { 00697 if (alpha==255) 00698 { 00699 *destination=(unsigned short)color; 00700 } 00701 else 00702 { 00703 unsigned int inva=255-alpha; 00704 unsigned int s=*destination; 00705 unsigned int sr=(s & 0xf800)>>11; 00706 unsigned int sg=(s & 0x7e0)>>5; 00707 unsigned int sb=(s & 0x1f); 00708 unsigned int dr=(color & 0xf800)>>11; 00709 unsigned int dg=(color & 0x7e0)>>5; 00710 unsigned int db=(color & 0x1f); 00711 unsigned int r=((sr*inva)+dr*alpha)>>8; 00712 unsigned int g=((sg*inva)+dg*alpha)>>8; 00713 unsigned int b=((sb*inva)+db*alpha)>>8; 00714 unsigned int c=(r<<11)|(g<<5)|b; 00715 *destination=(unsigned short)c; 00716 } 00717 } 00718 */ 00719 00720 //*** FillTransparent *** 00721 00722 void BlitterRLE8::FillTransparent(unsigned short* data, unsigned short color, int len, unsigned char alpha) 00723 { 00724 for (int i=0; i<len; ++i) 00725 { 00726 *data=AlphaBlend16(*data,color,alpha); 00727 // Blend(data,color,alpha); 00728 data++; 00729 } 00730 } 00731 00732 00733 //*** BurstFill *** 00734 00735 // This is to make sure we fill on 4 byte alignment as much as possible 00736 void BlitterRLE8::BurstFill(unsigned short* data, unsigned short color, int len) 00737 { 00738 int len2=len; 00739 00740 00741 #pragma warning (push) 00742 #pragma warning( disable: 4311) 00743 #ifdef _WIN32 00744 if (((int)data)!=(((int)data)&(0xfffffffc))) 00745 #else 00746 if (((long long)data)!=(((long long)data)&(0xfffffffffffffffc))) 00747 #endif 00748 #pragma warning (pop) 00749 { 00750 *data=color; 00751 ++data; 00752 --len2; 00753 if (len2==1) 00754 { 00755 *data=color; 00756 ++data; 00757 --len2; 00758 } 00759 } 00760 if (len2) 00761 { 00762 unsigned int color32=color | (color<<16); 00763 int halflen=len2/2; 00764 unsigned int* data32=reinterpret_cast<unsigned int*>(data); 00765 for (int i=0; i<halflen; ++i) 00766 { 00767 *data32=color32; 00768 ++data32; 00769 } 00770 data=reinterpret_cast<unsigned short*>(data32); 00771 if (len2-halflen*2) 00772 { 00773 *data=color; 00774 ++data; 00775 } 00776 } 00777 } 00778 00779 00780 //*** RunLength_Opaque_Unclipped_Unmasked *** 00781 00782 void BlitterRLE8::RunLength_Opaque_Unclipped_Unmasked(int len,unsigned short* data, unsigned char** source, unsigned short* palette) 00783 { 00784 unsigned char* dataRLE=*source; 00785 if (len&0x80) 00786 { 00787 len&=0x7f; 00788 // Unique values 00789 for (int i=0; i<len; ++i) 00790 { 00791 *data=palette[*dataRLE]; 00792 ++data; 00793 ++(dataRLE); 00794 } 00795 } 00796 else 00797 { 00798 // Run of values 00799 #ifdef _DEBUG 00800 Fill(data,palette[*dataRLE],len); 00801 #else 00802 BurstFill(data,palette[*dataRLE],len); 00803 #endif 00804 ++(dataRLE); 00805 } 00806 *source=dataRLE; 00807 } 00808 00809 00810 //*** RunLength_Opaque_Unclipped_Masked *** 00811 00812 void BlitterRLE8::RunLength_Opaque_Unclipped_Masked(int len,unsigned short* data, unsigned char** source, unsigned short* palette) 00813 { 00814 unsigned char* dataRLE=*source; 00815 if (len&0x80) 00816 { 00817 len&=0x7f; 00818 // Unique values 00819 for (int i=0; i<len; ++i) 00820 { 00821 if ((*dataRLE)<255) 00822 { 00823 *data=palette[*dataRLE]; 00824 } 00825 ++data; 00826 ++(dataRLE); 00827 } 00828 } 00829 else 00830 { 00831 // Run of values 00832 if ((*dataRLE)<255) 00833 { 00834 #ifdef _DEBUG 00835 Fill(data,palette[*dataRLE],len); 00836 #else 00837 BurstFill(data,palette[*dataRLE],len); 00838 #endif 00839 } 00840 ++(dataRLE); 00841 } 00842 *source=dataRLE; 00843 } 00844 00845 00846 //*** RunLength_Opaque_Unclipped_Unmasked_Transparent *** 00847 00848 void BlitterRLE8::RunLength_Opaque_Unclipped_Unmasked_Transparent(int len,unsigned short* data, unsigned char** source, unsigned short* palette, unsigned char alpha) 00849 { 00850 unsigned char* dataRLE=*source; 00851 if (len&0x80) 00852 { 00853 len&=0x7f; 00854 // Unique values 00855 for (int i=0; i<len; ++i) 00856 { 00857 *data=AlphaBlend16(*data,palette[*dataRLE],alpha); 00858 // Blend(data,palette[*dataRLE],alpha); 00859 ++data; 00860 ++(dataRLE); 00861 } 00862 } 00863 else 00864 { 00865 // Run of values 00866 FillTransparent(data,palette[*dataRLE],len,alpha); 00867 ++(dataRLE); 00868 } 00869 *source=dataRLE; 00870 } 00871 00872 00873 //*** RunLength_Opaque_Unclipped_MaskedTransparent *** 00874 00875 void BlitterRLE8::RunLength_Opaque_Unclipped_MaskedTransparent(int len,unsigned short* data, unsigned char** source, unsigned short* palette, unsigned char alpha) 00876 { 00877 unsigned char* dataRLE=*source; 00878 if (len&0x80) 00879 { 00880 len&=0x7f; 00881 // Unique values 00882 for (int i=0; i<len; ++i) 00883 { 00884 if ((*dataRLE)<255) 00885 { 00886 *data=AlphaBlend16(*data,palette[*dataRLE],alpha); 00887 // Blend(data,palette[*dataRLE],alpha); 00888 } 00889 ++data; 00890 ++(dataRLE); 00891 } 00892 } 00893 else 00894 { 00895 // Run of values 00896 if ((*dataRLE)<255) 00897 { 00898 FillTransparent(data,palette[*dataRLE],len,alpha); 00899 } 00900 ++(dataRLE); 00901 } 00902 *source=dataRLE; 00903 } 00904 00905 00906 //*** RunLength_Opaque_Clipped_Masked *** 00907 00908 void BlitterRLE8::RunLength_Opaque_Clipped_Masked(int len,unsigned short* data, unsigned char** source, unsigned short* palette, int clipStart, int clipEnd) 00909 { 00910 unsigned char* dataRLE=*source; 00911 int x=0; 00912 if (len&0x80) 00913 { 00914 len&=0x7f; 00915 // Unique values 00916 for (int i=0; i<len; ++i) 00917 { 00918 if ((*dataRLE)<255 && x>=clipStart && x<=clipEnd) 00919 *data=palette[*dataRLE]; 00920 ++x; 00921 ++data; 00922 ++(dataRLE); 00923 } 00924 } 00925 else 00926 { 00927 // Run of values 00928 int colorIndex=*dataRLE; 00929 if(colorIndex<255) 00930 { 00931 unsigned short color=palette[colorIndex]; 00932 for (int i=0; i<len; ++i) 00933 { 00934 if (colorIndex<255 && x>=clipStart && x<=clipEnd) 00935 { 00936 *data=color; 00937 } 00938 ++x; 00939 ++data; 00940 } 00941 } 00942 else 00943 { 00944 x+=len; 00945 data+=len; 00946 } 00947 00948 ++(dataRLE); 00949 } 00950 *source=dataRLE; 00951 } 00952 00953 00954 //*** RunLength_Opaque_Clipped_Masked_Transparent *** 00955 00956 void BlitterRLE8::RunLength_Opaque_Clipped_Masked_Transparent(int len,unsigned short* data, unsigned char** source, unsigned short* palette, int clipStart, int clipEnd, unsigned char alpha) 00957 { 00958 unsigned char* dataRLE=*source; 00959 int x=0; 00960 if (len&0x80) 00961 { 00962 len&=0x7f; 00963 // Unique values 00964 for (int i=0; i<len; ++i) 00965 { 00966 if ((*dataRLE)<255 && x>=clipStart && x<=clipEnd) 00967 { 00968 *data=AlphaBlend16(*data,palette[*dataRLE],alpha); 00969 //Blend(data,palette[*dataRLE],alpha); 00970 } 00971 ++x; 00972 ++data; 00973 ++(dataRLE); 00974 } 00975 } 00976 else 00977 { 00978 // Run of values 00979 int colorIndex=*dataRLE; 00980 if(colorIndex<255) 00981 { 00982 unsigned short color=palette[colorIndex]; 00983 for (int i=0; i<len; ++i) 00984 { 00985 if (colorIndex<255 && x>=clipStart && x<=clipEnd) 00986 { 00987 *data=AlphaBlend16(*data,color,alpha); 00988 // Blend(data,color,alpha); 00989 } 00990 ++x; 00991 ++data; 00992 } 00993 } 00994 else 00995 { 00996 x+=len; 00997 data+=len; 00998 } 00999 01000 ++(dataRLE); 01001 } 01002 *source=dataRLE; 01003 } 01004 01005 01006 //*** IgnoreOpaque *** 01007 01008 void BlitterRLE8::IgnoreOpaque(int len, unsigned char** source) 01009 { 01010 unsigned char* dataRLE=*source; 01011 if (len&0x80) 01012 { 01013 len&=0x7f; 01014 dataRLE+=len; 01015 } 01016 else 01017 { 01018 ++dataRLE; 01019 } 01020 *source=dataRLE; 01021 } 01022 01023 01024 //*** IgnoreAlpha *** 01025 01026 void BlitterRLE8::IgnoreAlpha(int len, unsigned char** source) 01027 { 01028 unsigned char* dataRLE=*source; 01029 if (len&0x80) 01030 { 01031 len&=0x7f; 01032 dataRLE+=len*2; 01033 } 01034 else 01035 { 01036 dataRLE+=2; 01037 } 01038 *source=dataRLE; 01039 } 01040 01041
Reproduction/republishing of any material on this site without permission is strictly prohibited.
