GP32 Full Screen Blit


synkro

0xdeadbeef
Joined
Aug 26, 2003
Messages
823
Location
Germany
Website
Visit site
so here is my function, with this functin it works w/o problem but not with the sdk blit functions

Code:
/*********************************************************************
 *	Inline functions to check a point is inside the screen boundary.
 *
 */
inline int withinWidth(int x)
{
	return ((unsigned int)x < WIDTH);
}

inline int withinHeight(int y)
{
	return ((unsigned int)y < HEIGHT);
}

inline int withinScreen(int x, int y)
{
	return (withinWidth(x) && withinHeight(y));
}
/**************************************************************************
 * Substitute for gp_putSprite() uses real screen coords (0,0) bottom left
 *
 * *sprite                16bit raw image data
 * sprite_x, sprite_y     sprite size in pixel
 * put_x, put_y           screen position
 * *framebuffer           target framebuffer
 */
void drawSprite(unsigned short *sprite, unsigned short sprite_x,
                unsigned short sprite_y, int put_x, int put_y,
                unsigned short *framebuffer)
{
     int xx,yy,i,tempx;
     u16   color;

     i=0;
      for (xx=0; xx<sprite_x; xx++)
      {
         tempx = put_x+xx;
         for (yy=0; yy<sprite_y; yy++)
         {
            color = sprite[i++];
            if(withinScreen(tempx, put_y+yy))
            *(framebuffer +(put_y+yy)+(240*(tempx)) ) = color;
         }
      }
}
 
So if it works without problems, what does that have to do with the official SDK? :)
 
Robert_John_Shepherd posted on May 6 2004 at 12:50 PM said:
So if it works without problems, what does that have to do with the official SDK? :)
because it drives me nuts! I dunno why....
 
Last edited by a moderator:
Should be faster when rewritten in asm..though I made an asm blitter and its quite slow :)
On the other hand, the asm PutPixel is two or three times faster than the sdk one :blink:
 
Code:
@ ******** ASMFastTransBlit(unsigned char *src, unsigned char *dst, int nbx, int nby, int height4, int trans) ********

	.ALIGN
	.GLOBAL ASMFastTransBlit
	.TYPE   ASMFastTransBlit, function
	.CODE 32

@r0 = src
@r1 = dst
@r2 = nbx
@r3 = nby

@r4 = height4
@r5 = trans
@r6 = tmp
@r7 = tmpnby

ASMFastTransBlit:

     sub	sp,sp,#8
     stmfd	r13!,{r4-r7}
     ldr	r4,[r13,#24]
     ldr	r5,[r13,#28]

_bx:
     MOV	r7,r3

     .REPT	maxh
     LDRB	r6,[r0,+r7]
     TEQ	r6,r5
     STRNEB	r6,[r1,+r7]
     SUBS	r7,r7,#1
     BMI	_sauty
     .ENDR

_sauty:
     SUB	r0,r0,r4
     SUB	r1,r1,#240
     SUBS	r2,r2,#1
     BPL	_bx

     ldmfd	r13!,{r4-r7}
     add	sp,sp,#8
     bx	lr


extern void ASMFastTransBlit(unsigned char *src, unsigned char *dst, int nbx, int nby, int height4, int trans);

Hope this helps you (don't forget to define maxh to the max height of your blitted objects, or 240).
 
Back
Top