Sprite Scaling Routines

Courtesy of Jim Haskell (jimhaskell@yahoo.com)
[routines slightly modified (and bugfixed) to fit the needs]
New (faster) routines by Julien Richard-Foy (julien.rf@wanadoo.fr) are on the way.


void ScaleSprite8_OR(unsigned char *sprite,unsigned char *dest,short x0,short y0,short sizex,short sizey);

void ScaleSprite16_OR(unsigned short *sprite,unsigned char *dest,short x0,short y0,short sizex,short sizey);

void ScaleSprite32_OR(unsigned long *sprite,unsigned char *dest,short x0,short y0,short sizex,short sizey);

void ScaleSprite64_OR(unsigned long long *sprite,unsigned char *dest,short x0,short y0,short sizex,short sizey);

ScaleSpriteX_OR scales a square input sprite with a width of X pixels or less and then draws the scaled sprite on the screen using OR logic. x0 and y0 are the coordinates of the upper left corner of the sprite. sizex and sizey are the desired dimensions of the scaled sprite. sprite is a pointer to the array of unsigned numbers of type equal to X (i.e. for X=8 type is unsigned char; for X=16 type is unsigned short; for X=32 type is unsigned long; and for X=64 type is unsigned long long) which define the shape of the sprite (line by line). dest is the pointer to a video plane of size 240 x 128 pixels. If you want to draw the sprite to the normal video plane you can use constant LCD_MEM for dest. If you are using grayscales use function GrayGetPlane to retrieve the pointer to the video planes.



void ScaleSprite8_AND(unsigned char *sprite,unsigned char *dest,short x0,short y0,short sizex,short sizey);

void ScaleSprite16_AND(unsigned short *sprite,unsigned char *dest,short x0,short y0,short sizex,short sizey);

void ScaleSprite32_AND(unsigned long *sprite,unsigned char *dest,short x0,short y0,short sizex,short sizey);

void ScaleSprite64_AND(unsigned long long *sprite,unsigned char *dest,short x0,short y0,short sizex,short sizey);

ScaleSpriteX_AND scales a square input sprite with a width of X pixels or less and then draws the scaled sprite on the screen using AND logic. x0 and y0 are the coordinates of the upper left corner of the sprite. sizex and sizey are the desired dimensions of the scaled sprite. sprite is a pointer to the array of unsigned numbers of type equal to X (i.e. for X=8 type is unsigned char; for X=16 type is unsigned short; for X=32 type is unsigned long; and for X=64 type is unsigned long long) which define the shape of the sprite (line by line). dest is the pointer to a video plane of size 240 x 128 pixels. If you want to draw the sprite to the normal video plane you can use constant LCD_MEM for dest. If you are using grayscales use function GrayGetPlane to retrieve the pointer to the video planes.



void ScaleSprite8_XOR(unsigned char *sprite,unsigned char *dest,short x0,short y0,short sizex,short sizey);

void ScaleSprite16_XOR(unsigned short *sprite,unsigned char *dest,short x0,short y0,short sizex,short sizey);

void ScaleSprite32_XOR(unsigned long *sprite,unsigned char *dest,short x0,short y0,short sizex,short sizey);

void ScaleSprite64_XOR(unsigned long long *sprite,unsigned char *dest,short x0,short y0,short sizex,short sizey);

ScaleSpriteX_XOR scales a square input sprite with a width of X pixels or less and then draws the scaled sprite on the screen using XOR logic. x0 and y0 are the coordinates of the upper left corner of the sprite. sizex and sizey are the desired dimensions of the scaled sprite. sprite is a pointer to the array of unsigned numbers of type equal to X (i.e. for X=8 type is unsigned char; for X=16 type is unsigned short; for X=32 type is unsigned long; and for X=64 type is unsigned long long) which define the shape of the sprite (line by line). dest is the pointer to a video plane of size 240 x 128 pixels. If you want to draw the sprite to the normal video plane you can use constant LCD_MEM for dest. If you are using grayscales use function GrayGetPlane to retrieve the pointer to the video planes.



void DoubleSpriteDimensionsX8_R(register short h asm("%d0"),register unsigned char* src asm("%a0"),register short bytewidth asm("%d1"),register unsigned char* dest asm("%a1")) __attribute__((__regparm__(4)));

void DoubleSpriteDimensions16x16_R(register unsigned short* src asm("%a0"),register unsigned long* dest asm("%a1")) __attribute__((__regparm__(2)));

DoubleSpriteDimensionsX8_R is a fast alternative to ScaleSprite routines if the scale factor is 2. DoubleSpriteDimensions16x16_R was designed specifically for the "AMS native comment format" icon type available since TIGCC 0.95.