michu
Still Fresh
hey all.. well im frustated.. i use the devkitGP2X.rar (Octoate's GP2x toolchain (2006/03/06)).. my app is working fine on windows, on my gp2x my app will freeze after 35-60 seconds after the start.. here is my code:
any hints? thanks in advance
michu
Code:
void drawSprite(SDL_Surface* imageSurface, SDL_Surface* screenSurface, int srcX, int srcY, int dstX, int dstY, int width, int height)
{
SDL_Rect srcRect;
SDL_Rect dstRect;
srcRect.x = srcX;
srcRect.y = srcY;
srcRect.w = width;
srcRect.h = height;
dstRect.x = dstX;
dstRect.y = dstY;
dstRect.w = width;
dstRect.h = height;
SDL_BlitSurface(imageSurface, &srcRect, screenSurface, &dstRect);
}
//... main()...
atexit( cleanUp );
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
returnToOS(1);
screen = SDL_SetVideoMode(SCREEN_XRES, SCREEN_YRES, 32, SDL_DOUBLEBUF | SDL_HWSURFACE);//SDL_SWSURFACE);
if (!screen)
{
fprintf(stderr, "Couldn't set video mode: %s\n", SDL_GetError());
returnToOS(1);
}
SDL_JoystickOpen(0);
SDL_ShowCursor(SDL_DISABLE);
while (!done)
{
// printf("sdl event...\n");
while( SDL_PollEvent( &event ) ){
keyHandler(event);
}
tim2 = time(NULL);
fps=(int)(frame/difftime(tim2,tim));
//rotate the car
playerCar.carRoto = rotozoomSurface(playerCar.carBitmap, playerCar.angle, 1, 1);
sprintf(HUDtext, "frame:%i, fps:%i, time:%i", frame, fps, (int)difftime(tim2,tim));
HUD = TTF_RenderText_Solid(font, HUDtext, HUDcol);
drawSprite(mapBitmap, screen, (int)mapOffsetX, (int)mapOffsetY, 0, 0, SCREEN_XRES, SCREEN_YRES);
drawSprite(playerCar.carRoto, screen, 0, 0, (int)playerCar.xpos, (int)playerCar.ypos, playerCar.carRoto->w, playerCar.carRoto->h);
drawSprite(HUD, screen, 0, 0, 0, 0, HUD->w, HUD->h);
/* if ( SDL_MUSTLOCK(screen) ) {
SDL_UnlockSurface(screen);
}
*/
SDL_Flip(screen);
frame++;
}
any hints? thanks in advance
michu