For fast memory copies, you should really NOT use MemMove.
First of all because it's a trap and you get the trap dispatcher overhead
everytime you call it. If you call it 20x for the 20 lines of each of your
sprites, it's significant.
Then because it's not optimized AT ALL. You can probably implement a version
10x faster, depending on your constraints.
For example for copying the whole screen (or a number of full lines in
160x160), I use the functions below.
In any cases, you need to be HIRES-aware. Accessing and blitting directly to
screen sometimes does not work on HIRES devices. 
You need to either do the double pixelling yourself or use a 320x320
bitmaps. If you use WinCopyRectangle it will do the double pixelling for you
probably but it's still not a hyper-optimized version. I implemented my own
HIRES FastBlit function which does the double pixelling itself.
I did not try to HYPER-optimize since this was giving me enough fps for my
needs. Finally, as Aaron already said, optimizing the Blitter itself is not
enough. The rendering must ALSO be optimized.

Hope this helps.

Cordially,
Regis.


#ifndef HIRES
static asm void FastBlit(UInt8* dst, UInt8* src, UInt32 lines)
{
        link      a6,#0
        movea.l   8(a6),a1      // dst
        movea.l   12(a6),a0 // src
        move.l    16(a6),d0 // size

        movem.l         d1-d7/a2-a4, -(a7)
        
loop:
        movem.l (a0)+, d1-d7/a2-a4
        movem.l d1-d7/a2-a4, (a1)
        adda.l  #40, a1
        movem.l (a0)+, d1-d7/a2-a4
        movem.l d1-d7/a2-a4, (a1)
        adda.l  #40, a1
        movem.l (a0)+, d1-d7/a2-a4
        movem.l d1-d7/a2-a4, (a1)
        adda.l  #40, a1
        movem.l (a0)+, d1-d7/a2-a4
        movem.l d1-d7/a2-a4, (a1)
        adda.l  #40, a1

        subi.l  #1, d0
        bne.s   loop

        movem.l         (a7)+, d1-d7/a2-a4
        
        unlk      a6
        rts
}
#else // HIRES version below double pixelling. Obviously slower...
static asm void FastBlit(UInt8* dst, UInt8* src, UInt16 lines)
{
        link      a6,#0
        
        movem.l         d1-d7/a2-a3, -(a7)
                
        movea.l   8(a6),a1      // dst
        movea.l   12(a6),a0 // src
        move.w    16(a6),d0 // lines
        
loop:
        move.l  a1, a2
        move.l  #40, d1
        
loop2:
        /* Double first line */
        move.l  (a0)+, d2
        rol.l   #8, d2
        move.b  d2, (a1)+
        move.b  d2, (a1)+
        rol.l   #8, d2
        move.b  d2, (a1)+
        move.b  d2, (a1)+
        rol.l   #8, d2
        move.b  d2, (a1)+
        move.b  d2, (a1)+
        rol.l   #8, d2
        move.b  d2, (a1)+
        move.b  d2, (a1)+
        subi.l  #1, d1
        bne.s   loop2

        /* Duplicate */
        movem.l (a2)+, d1-d7/a3
        movem.l d1-d7/a3, (a1)
        adda.l  #32, a1
        movem.l (a2)+, d1-d7/a3
        movem.l d1-d7/a3, (a1)
        adda.l  #32, a1
        movem.l (a2)+, d1-d7/a3
        movem.l d1-d7/a3, (a1)
        adda.l  #32, a1
        movem.l (a2)+, d1-d7/a3
        movem.l d1-d7/a3, (a1)
        adda.l  #32, a1
        movem.l (a2)+, d1-d7/a3
        movem.l d1-d7/a3, (a1)
        adda.l  #32, a1
        movem.l (a2)+, d1-d7/a3
        movem.l d1-d7/a3, (a1)
        adda.l  #32, a1
        movem.l (a2)+, d1-d7/a3
        movem.l d1-d7/a3, (a1)
        adda.l  #32, a1
        movem.l (a2)+, d1-d7/a3
        movem.l d1-d7/a3, (a1)
        adda.l  #32, a1
        movem.l (a2)+, d1-d7/a3
        movem.l d1-d7/a3, (a1)
        adda.l  #32, a1
        movem.l (a2)+, d1-d7/a3
        movem.l d1-d7/a3, (a1)
        adda.l  #32, a1
        
        subi.l  #1, d0
        bne             loop

        movem.l         (a7)+, d1-d7/a2-a3
        
        unlk      a6
        rts
}
#endif

------------------------------------------------------------------------
Regis NICOLAS - Engineering Director, Montpellier Site
Palm Computing Europe, a PalmSource, Inc. subsidiary
 
When the finger points to the sky, the idiot looks at the finger.

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to