Can you post your init code?
Here is the full code. Sorry, itis a little large, but so everybody can
look for some mistake.
[…]
if ((screen=SDL_SetVideoMode(640,480,0,SDL_DOUBLEBUF)) == NULL ) {
fprintf(stderr, “Couldn’t set 640x480 video mode: %s\n”,SDL_GetError());
exit(2);
}
Looks OK so far, I think, although some error checking might be a good idea.
(SDL parachute deployed first time I tried it here, as the background image
file was missing. 
And yeah, it flickers here too, even though I’m sure this target cannot do
double buffering with h/w page flipping.
Double buffered and no special deepth requirement; you should get a hardware
surface if possible.
//Create a surface to save background
saved=SDL_CreateRGBSurface(SDL_HWSURFACE,sp->w,sp->h,sp->format->BitsPerPix
el,0,0,0,0); area.w=sp->w;
area.h=sp->h,
area.x=1;
area.y=1;
//Save background area
SDL_BlitSurface(screen, &area, saved, NULL);
Not that it should cause a problem here, but this generally isn’t a very good
idea. Don’t ever blit from VRAM unless you’re sure it’s done by the GPU
and not the CPU. Reading VRAM with the CPU is very, very slow on pretty much
all modern hardware.
It’s usually better and simpler (for many reasons) to remove sprites by
painting over them using the background rendering code. Very simple if you’re
using a single background image, but it’s rather doable with tiles as well.
Have a look at the tile rendering “engines” of scrolling examples 2 & 3; they
should be fairly easy to use in that way, I think.
(Speaking of which; maybe I should try it myself - would make another nice
example, and would increase the probability of that Project Spitfire port
ever being done… 
// Then put image
SDL_BlitSurface(sp, NULL, screen, &area);
// And update screen area using fastest method
if ((screen->flags & SDL_DOUBLEBUF) != SDL_DOUBLEBUF)
SDL_UpdateRects(screen,1,&area); else SDL_Flip(screen);
end=0;
alpha=SDL_ALPHA_OPAQUE;
while (end!=1) {
//First, restore saved area
if (SDL_PollEvent(&event)>0) {
//there is an event waiting
if (event.type==SDL_KEYDOWN) {
// a key was pressed
//so, restore the screen
SDL_BlitSurface(saved, NULL, screen, &area);
if ((screen->flags & SDL_DOUBLEBUF) != SDL_DOUBLEBUF)
SDL_UpdateRects(screen,1,&area); else SDL_Flip(screen);
[…input…]
SDL_BlitSurface(screen, &area, saved, NULL);
SDL_BlitSurface(sp, NULL, screen, &area);
if ((screen->flags & SDL_DOUBLEBUF) != SDL_DOUBLEBUF)
SDL_UpdateRects(screen,1,&area); else SDL_Flip(screen);
Uh oh.
There’s your problem! You flip twice per loop.
That is, what you’re doing here is basically
while(running)
{
remove the sprite;
make the change visible; //(no sprite!)
poll user input;
update coordinates;
render the sprite;
make the change visible; //(ok; sprite is there)
}
(Ok, I left out the fact that your “engine” stalls when there’s no user
input. My example above demonstrates a more appropriate way of doing it for
games; it will spin even if there’s no input, so that the control system can
keep animations and stuff going at all times.)
Now, if you don’t flip twice, you run into a classical double buffering
problem; your buffers will get out of sync. The solution is to have one
backsave buffer for each screen buffer, along with the coordinates needed to
do the restore blits. Workable, but not trivial. (Yes, this is one of the
reasons why I don’t like the “backsave” method. As to another reason; think
about multiple sprites that are allowed to overlap…)
//David Olofson — Programmer, Reologica Instruments AB
.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |
--------------------------------------> david at linuxdj.com -'On Thursday 21 June 2001 23:20, Roger D. Vargas wrote:
On Wed, 20 Jun 2001, David Olofson wrote: