generalnmx
Playful/Fascist Mod
My BitBlt function runs VERY slow compared to Gamepark's SDK version (my FPS drops from about 9 to 1). Do I just need to go down to ASM, or is there anything else I can do to get a sizable speed increase? I'm still using Gamepark's SDK for flipping the surface, of course.
	
	
	
		
				
			
		Code:
	
	/* Creates a single pixel on the screen with the given colour 
 * x  	on screen
 * y  	on screen
 * colour  16-bit colour of pixel
 */
void_ IGfxDrawPixel(const_int32 x, const_int32 y, const_ushort16 colour)
{
	ushort16 *fbuffer;
	if ( !((x<0) || (x>319) || (y<0) || (y>239)) ) { /* check bounds */
  fbuffer = (ushort16*)(gpFramebuffer[pgFlip].ptbuffer); /* the framebuffer is actually 16-bit in 16-bit mode */
  *(fbuffer + (x*240) + (239-y)) = colour;	/* the framebuffer is structured oddly, so we need to index this way */
	} /* end if */
} /* end of IGfxDrawPixel() */
/* Draws a single image from inside an array of (an) image(s) on the screen without transparency
 *
 *      pixelArray              array of pixel data (where the image is stored)
 *  indX    	index into array for X (where to find the image in the array)
 *  indY    	index into array for Y
 *  xScreen    	x on screen
 *  yScreen    	y on screen
 *  imageWidth    width of the image inside the array (use arrayWidth and arrayHeight for total array size)
 *  imageHeight    height of the image inside the array
 *      arrayWidth    width of pixel array (total size of array is width * height)
 *      arrayHeight    height of pixel array
 *  transColour    16-bit colour of transparency (bit to skip)
 */
void_ IGfxDrawImage(ushort16* pixelArray,
    	const_int32 xScreen, const_int32 yScreen,
    	const_uint32 indX, const_uint32 indY,
    	const_uint32 imageWidth, const_uint32 imageHeight,
    	const_uint32 arrayWidth, const_uint32 arrayHeight)
{
	uint32 x,y;
	ushort16 colour;
	if (pixelArray) /* sanity check */
	{
  for (x = 0; x < imageWidth; x++) {
  	for (y = 0; y < imageHeight; y++) {
    colour = *(pixelArray+ ((indX+x) + ((indY+y) * arrayWidth)));
    IGfxDrawPixel(x+xScreen,y+yScreen,colour);
  	} /* end for */
  } /* end for */
	} /* end if */
} /* end of IGfxDrawImage() */
	
	