GP2X Sdl App Crash After 35-60 Seconds


michu

Still Fresh
Joined
Mar 6, 2006
Messages
60
Website
www.neophob.com
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:

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
 
You init the screen at 32bit. That might be causing it hassle. Try 16. I think default may be 16bit but HW_SDL can handle 32bit. (Best to wait for someone who knows about the HW_SDL side of things)
Rotozoomer uses floats (I believe) that's heavy also, with scaling added I was locking up my pc within a very short time when I tested it.
Looks like a leak somewhere but I don't see it. Too tired atm to read it well. I'll look at it again in the morning and see if something comes up.
 
chimpoid posted on Mar 12 2006 at 02:35 AM said:
You init the screen at 32bit. That might be causing it hassle. Try 16. I think default may be 16bit but HW_SDL can handle 32bit. (Best to wait for someone who knows about the HW_SDL side of things)
Rotozoomer uses floats (I believe) that's heavy also, with scaling added I was locking up my pc within a very short time when I tested it.
Looks like a leak somewhere but I don't see it. Too tired atm to read it well. I'll look at it again in the morning and see if something comes up.
My HW SDL doesn't allow a 32-bit screen, I take a few liberties in cases like this and if you check the surface returned, you'll find it's given you a 16bit one.
Since the hardware doesn't support 32bit I should really create a shadow surface so that your app ends up with a sw surface that gets converted down on an SDL_Flip() or SDL_UpdateRects(). Thing is, the reason I wrote my HW version is to get as much speed as possible, and doing a full screen depth-reduction every frame will be quite slow.
 
Last edited by a moderator:
Back
Top