hi,
i have done some font-functions for my game and because of that i adapted some of mirkos functions.
i wanted to cut out sprites (letters) from a big image (320x200). i began to like this whole thing and wrote a "mysprites.h", because i like to have my own functions
but the problem is a massive speed decrease by using the "new" PutSprite function and i really can't see why.
maybe some of you "real" coders can help me a little....
heres the whole mysprites.h:
edit:
oh, i have just recognized that the slowdowns in the game and the split screen are caused by this functions. if i use the "normal" gp_drawSpriteHT, i have no slowdowns and no split screen at all. -> http://www.gp32x.de/board/index.php?act=S...t=0#entry261167
i have done some font-functions for my game and because of that i adapted some of mirkos functions.
i wanted to cut out sprites (letters) from a big image (320x200). i began to like this whole thing and wrote a "mysprites.h", because i like to have my own functions
but the problem is a massive speed decrease by using the "new" PutSprite function and i really can't see why.
maybe some of you "real" coders can help me a little....
heres the whole mysprites.h:
Code:
#ifndef MYSPRITES_H
#define MYSPRITES_H
#include "string.h"
typedef struct {
u16 *source_img;
short source_x;
short source_y;
short width;
short height;
u16 trans;
} tSprite;
typedef struct {
tSprite Letter[88];
} tFont;
void SetSprite(tSprite *sprite,u16 *source_img,u16 trans,short source_x,short source_y,short width,short height)
{
sprite->source_img=source_img;
sprite->source_x=source_x;
sprite->source_y=source_y;
sprite->width=width;
sprite->height=height;
sprite->trans=trans;
}
void PutSprite(tSprite sprite,float plotx, float ploty,u16 *framebuffer)
{
SHEADER *sheader;
sheader = (SHEADER*)sprite.source_img;
u16 tiled_x = sheader->size_x;
int y,x,offset;
offset = 0;
for (y=sprite.source_y;y<sprite.height+sprite.source_y;y++)
for (x=sprite.source_x;x<sprite.width+sprite.source_x;x++)
{
if ( (x-sprite.source_x+plotx>=0) && (x-sprite.source_x+plotx<320) && (y-sprite.source_y+ploty>=0) && (y-sprite.source_y+ploty<240) )
{
u16 point = sprite.source_img[6+x+offset+(y*tiled_x)];
if (point != sprite.trans) gp_drawPixel16(x-sprite.source_x+plotx,y-sprite.source_y+ploty, point, framebuffer);
}
}
}
void FontOutXY(tFont font,short x,short y,char text[],u16 color,u16 *framebuffer)
{
short length=strlen(text);
short i;
short num=0;
short dist=0;
for (i=0;i<length;i++)
{
if (text[i]=='A') num=0;
if (text[i]=='B') num=1;
if (text[i]=='C') num=2;
if (text[i]=='D') num=3;
if (text[i]=='E') num=4;
if (text[i]=='F') num=5;
if (text[i]=='G') num=6;
if (text[i]=='H') num=7;
if (text[i]=='I') num=8;
if (text[i]=='J') num=9;
if (text[i]=='K') num=10;
if (text[i]=='L') num=11;
if (text[i]=='M') num=12;
if (text[i]=='N') num=13;
if (text[i]=='O') num=14;
if (text[i]=='P') num=15;
if (text[i]=='Q') num=16;
if (text[i]=='R') num=17;
if (text[i]=='S') num=18;
if (text[i]=='T') num=19;
if (text[i]=='U') num=20;
if (text[i]=='V') num=21;
if (text[i]=='W') num=22;
if (text[i]=='X') num=23;
if (text[i]=='Y') num=24;
if (text[i]=='Z') num=25;
if (text[i]=='0') num=26;
if (text[i]=='1') num=27;
if (text[i]=='2') num=28;
if (text[i]=='3') num=29;
if (text[i]=='4') num=30;
if (text[i]=='5') num=31;
if (text[i]=='6') num=32;
if (text[i]=='7') num=33;
if (text[i]=='8') num=34;
if (text[i]=='9') num=35;
if (text[i]=='(') num=36;
if (text[i]=='{') num=37;
if (text[i]=='[') num=38;
if (text[i]==']') num=39;
if (text[i]=='}') num=40;
if (text[i]==')') num=41;
if (text[i]=='<') num=42;
if (text[i]=='>') num=43;
if (text[i]=='.') num=44;
if (text[i]=='!') num=45;
if (text[i]==';') num=46;
if (text[i]==':') num=47;
if (text[i]=='?') num=48;
if (text[i]=='_') num=49;
if (text[i]=='=') num=50;
if (text[i]=='"') num=51;
if (text[i]=='+') num=52;
if (text[i]=='-') num=53;
if (text[i]==' ') num=54;
PutSprite(font.Letter[num],x+dist,y,framebuffer);
dist=dist+font.Letter[num].width+1;
}
}
#endif
edit:
oh, i have just recognized that the slowdowns in the game and the split screen are caused by this functions. if i use the "normal" gp_drawSpriteHT, i have no slowdowns and no split screen at all. -> http://www.gp32x.de/board/index.php?act=S...t=0#entry261167
Last edited by a moderator: