--- Eterm-0.9.3-orig/src/mmx_cmod.S 2004-01-11 15:13:02.000000000 -0700 +++ Eterm-0.9.3/src/mmx_cmod.S 2005-04-23 04:06:31.000000000 -0600 @@ -45,6 +45,8 @@ .type shade_ximage_16_mmx,@function .global shade_ximage_32_mmx .type shade_ximage_32_mmx,@function +.global shade_ximage_24_mmx + .type shade_ximage_24_mmx,@function .bss .text @@ -483,4 +485,54 @@ 3: LEAVE + +shade_ximage_24_mmx: + ENTER + + leal (%esi, %ebx, 3), %esi + negl %ebx + jz 3f + + movd rm, %mm4 + movd gm, %mm5 + movd bm, %mm6 + psllq $32, %mm4 + psllq $16, %mm5 + por %mm6, %mm4 + por %mm5, %mm4 + + pcmpeqw %mm6, %mm6 + psllw $15, %mm6 /* 80 00 80 00 80 00 80 00 */ + movq %mm6, %mm5 + pmulhw %mm4, %mm5 /* Get correction factor */ +1: + movl %ebx, %ecx +2: + movd (%esi, %ecx, 3), %mm1 /* 00 rr gg bb */ + movd %mm1, %mm2 /* we need 8 bits of this later */ + pxor %mm0, %mm0 + punpcklbw %mm1, %mm0 /* 00 00 rr 00 gg 00 bb 00 */ + pxor %mm6, %mm0 /* Flip sign */ + + pmulhw %mm4, %mm0 /* 00 00 xx rr xx gg xx bb */ + psubw %mm5, %mm0 /* Correct range */ + packuswb %mm0, %mm0 /* 00 rr gg bb 00 rr gg bb */ + + pand 0xFF000000, %mm2 /* FF 00 00 00 */ + por %mm2, %mm0 /* 8 old bits + 24 new ones */ + + movd %mm0, (%esi, %ecx, 3) /* This will be fine as long as nothing jacks with the */ + /* byte following the imagemap in memory between the */ + /* time it was read and now (only for the last pixel) */ + /* Eterm is not threaded so no problem */ + incl %ecx + jnz 2b + + addl bpl, %esi + decl %edx + jnz 1b +3: + LEAVE + + #endif /* HAVE_MMX */