#ifndef __GNUC__
#define _calpha_using_inlineasm_ 1
#else
#define _calpha_using_gccinlineasm_ 1
#ifdef _calpha_using_inlineasm_
#undef _calpha_using_inlineasm_
#endif
#endif
void __fastcall TAlpha::FillSolidColor(byte * const ptrBuffer, int Width, int Height, int iLineAdd, int iPixelAdd, COLORREF Color)
{
#ifdef _calpha_using_inlineasm_
byte *ptrDest;
register int i;
#else
#ifdef _calpha_using_gccinlineasm_
byte *ptrDest;
int i;
#else
register byte *ptrDest;
register int i;
#endif
#endif
ptrDest = ptrBuffer;
if (iPixelAdd == 0)
{
register const unsigned short int igb = ((byte)(Color>>16)) | (((byte)((WORD)Color>>8))<<8);
register const byte br = (byte)Color;
#ifdef _calpha_using_inlineasm_
#ifdef _regptrdest32_
#undef _regptrdest32_
#endif
#ifdef _regloop32_
#undef _regloop32_
#endif
#ifdef _reggreenblue16_
#undef _reggreenblue16_
#endif
#ifdef _regred8_
#undef _regred8_
#endif
#define _regptrdest32_ ebx
#define _regloop32_ ecx
#define _reggreenblue16_ dx
#define _regred8_ al
__asm
{
mov _regptrdest32_, ptrBuffer
mov _regloop32_, Width
mov _reggreenblue16_, igb
mov _regred8_, br
dec _regloop32_
@1:
mov word ptr [_regptrdest32_], _reggreenblue16_
dec _regloop32_
mov byte ptr [_regptrdest32_+02], _regred8_
add _regptrdest32_, 00000003
test _regloop32_, _regloop32_
jge short @1
}
ptrDest += Width << 1;
ptrDest += Width;
#else
i = Width - 1;
do
{
i--;
*((unsigned short int *)ptrDest) = igb;
ptrDest++;
ptrDest++;
*ptrDest++ = br;
}while(i >= 0);
#endif
}
else
{
register const unsigned short int irg = ((byte)((WORD)Color>>8)) | ((byte)Color<<8);
register const byte bb = (byte)(Color>>16);
#ifdef _calpha_using_inlineasm_
#ifdef _regptrdest32_
#undef _regptrdest32_
#endif
#ifdef _regloop32_
#undef _regloop32_
#endif
#ifdef _regredgreen16_
#undef _regredgreen16_
#endif
#ifdef _regblue8_
#undef _regblue8_
#endif
#define _regptrdest32_ ebx
#define _regloop32_ ecx
#define _regredgreen16_ dx
#define _regblue8_ al
__asm
{
mov _regptrdest32_, ptrBuffer
mov _regloop32_, Width
mov _regredgreen16_, irg
dec _regloop32_
mov _regblue8_, bb
@2:
dec _regloop32_
mov byte ptr [_regptrdest32_], _regblue8_
mov word ptr [_regptrdest32_+01], _regredgreen16_
add _regptrdest32_, 00000004
test _regloop32_, _regloop32_
jge short @2
}
ptrDest += Width << 2;
#else
i = Width - 1;
do
{
i--;
*ptrDest++ = bb;
*((unsigned short int *)ptrDest) = irg;
ptrDest += 3;
}while(i >= 0);
#endif
}
register int lr = (iPixelAdd + 3) * Width;
int ld = lr + iLineAdd;
ptrDest += iLineAdd;
i = Height;
i--;
i--;
if ((i & 1) == 0)
{
memcpy(ptrDest, ptrBuffer, lr);
ptrDest += ld;
i--;
}
#ifdef _calpha_using_inlineasm_
#ifdef _regptrdest32_
#undef _regptrdest32_
#endif
#ifdef _regadd32_
#undef _regadd32_
#endif
#ifdef _regptrdest8_
#undef _regptrdest8_
#endif
#define _regptrdest32_ edx
#define _regadd32_ eax
#define _regptrdest8_ cl
if ((lr & 1) == 1)
{
lr >>= 1;
__asm
{
cld
mov _regptrdest32_, ptrDest
mov _regadd32_, ld
}
for (; i >= 0; i--)
{
i--;
__asm
{
mov esi, ptrBuffer
mov edi, _regptrdest32_
mov _regptrdest8_, byte ptr [esi]
mov byte ptr [edi], _regptrdest8_
inc esi
inc edi
mov ecx, lr
rep movsw
add _regptrdest32_, _regadd32_
mov esi, ptrBuffer
mov edi, _regptrdest32_
mov _regptrdest8_, byte ptr [esi]
mov byte ptr [edi], _regptrdest8_
inc esi
inc edi
mov ecx, lr
rep movsw
add _regptrdest32_, _regadd32_
}
}
}
else
{
lr >>= 1;
__asm
{
cld
mov _regptrdest32_, ptrDest
mov _regadd32_, ld
}
for (; i >= 0; i--)
{
i--;
__asm
{
mov ecx, lr
mov esi, ptrBuffer
mov edi, _regptrdest32_
rep movsw
add _regptrdest32_, _regadd32_
mov ecx, lr
mov esi, ptrBuffer
mov edi, _regptrdest32_
rep movsw
add _regptrdest32_, _regadd32_
}
}
}
#else
for (; i >= 0; i--)
{
i--;
memcpy(ptrDest, ptrBuffer, lr);
ptrDest += ld;
memcpy(ptrDest, ptrBuffer, lr);
ptrDest += ld;
}
#endif
}