Re: [AD] [AL] problem with blit

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Christer Sandberg wrote:

When using 15 and 16 bit colour modes and blitting to the 3:rd last pixel
from the right edge, the last pixel column will not be be drawn. The same
happens in all screen resolutions where these colour depths are possible.
As the code below shows, it is platform independent. If changing the
destination x-position to SCREEN_W-2 or SCREEN_W-4 the problem disappears.
I'm using 3.9.37 but 3.9.36 seems to have the same problem.


Here's a patch that fixes it.
I've also taken the liberty of replacing those loop by decl %ecx / jnz pairs, which gave a 5-10% performance boost to blit (on my system at least :)



--
- Robert J Ohannessian
"Microsoft code is probably O(n^20)" (my CS prof)
http://pages.infinit.net/voidstar/
--- /home/allegro/src/i386/iblit16.s	Mon Apr  9 00:49:30 2001
+++ iblit16.s	Thu Aug  2 13:38:04 2001
@@ -324,7 +324,7 @@
    jz blit_only_one_word         /* blit only one word */
    jnc blit_longsmmx
    shrl $1, B_WIDTH              /* divide for use longs64 */
-   jz blit_only_one_long         /* blit one long and word */
+   jz blit_long_word             /* blit one long and word */
    jnc blit_even_wmmxlongs       /* blit longs64 and word */
    jmp blit_mmxlong_word         /* blit longs64 and long and word */
 blit_longsmmx:
@@ -337,10 +337,11 @@
    BLIT_LOOP(long_longsmmx, 2,
    even_llmmx_loop:
       movq %ds:(%esi), %mm0 ;
-      movq %mm0, %es:(%edi) ;
       addl $8, %esi ;
+      movq %mm0, %es:(%edi) ;
       addl $8, %edi ;
-      loop even_llmmx_loop ;
+      decl %ecx ;
+      jnz even_llmmx_loop ;
       movsl
    )
    emms
@@ -351,10 +352,11 @@
    BLIT_LOOP(word_longsmmx, 2,
    even_wlmmx_loop:
       movq %ds:(%esi), %mm0 ;
-      movq %mm0, %es:(%edi) ;
       addl $8, %esi ;
+      movq %mm0, %es:(%edi) ;
       addl $8, %edi ;
-      loop even_wlmmx_loop ;
+      decl %ecx ;
+      jnz even_wlmmx_loop ;
       movsl ;
       movsw
    )
@@ -366,10 +368,11 @@
    BLIT_LOOP(word_wlongsmmx, 2,
    even_wmmx_loop:
       movq %ds:(%esi), %mm0 ;
-      movq %mm0, %es:(%edi) ;
       addl $8, %esi ;
+      movq %mm0, %es:(%edi) ;
       addl $8, %edi ;
-      loop even_wmmx_loop ;
+      decl %ecx ;
+      jnz even_wmmx_loop ;
       movsw
    )
    emms
@@ -380,10 +383,20 @@
    BLIT_LOOP(even_longsmmx, 2,
    even_lmmx_loop:
       movq %ds:(%esi), %mm0 ;
-      movq %mm0, %es:(%edi) ;
       addl $8, %esi ;
+      movq %mm0, %es:(%edi) ;
       addl $8, %edi ;
-      loop even_lmmx_loop
+      decl %ecx ;
+      jnz even_lmmx_loop
+   )
+   emms
+   jmp blit_done
+
+   _align_
+blit_long_word:
+   BLIT_LOOP(long_word, 2,
+      movsl ;
+      movsw
    )
    emms
    jmp blit_done


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/