SDL_UpperBlit returns a NULL pointer

hi
i’m experimenting SDL 1.3 with the iPhone and i found out this bug
after a texture is applied to the surface, the source surface is trashed and
when returning to the calling function it won’t be accessible anymore.

the code follows (it’s in pascal, but it’s simple)

tmpsurf:= LoadImage(Pathz[ptCurrTheme] + ‘/LandTex’, false, true, false);
r.y:= 0;
while r.y < LAND_HEIGHT do
begin
r.x:= 0;
while r.x < LAND_WIDTH do
begin
SDL_UpperBlit(tmpsurf, nil, Surface, @r);
inc(r.x, tmpsurf^.w)
end;
inc(r.y, tmpsurf^.h)
end;
SDL_FreeSurface(tmpsurf);

the program terminates when trying to access tmpsurf^.w with a
EXC_BAD_ADDRESS

the weird thing is that this very same function works with no problem when
compiled with SDL1.2 (any platform)

any pointers i could follow?
thanks for any advice
Vittorio

First off, where did you get SDL 1.3 Pascal headers from? (Do you have them? The old 1.2 versions won’t work, since the SDL_Surface struct has been altered.) I’ve been working on extending the JEDI-SDL headers for 1.3. (I assume that’s what you’re using.) Send me a
private email if you’d like a copy of my work.

Your bug is very strange. There’s no reason that SDL_UpperBlit should change the value of your surface pointer. That shouldn’t be possible if your header’s set up right. Is it declared as a var parameter in the function header? (It shouldn’t be.)

Is the function really changing the value to nil? Have you checked that out in a debugger? Have you checked the return value of the blit function? It’s more likely that you’re trying to dereference the .w location and finding something at that memory address that you shouldn’t, because the structure of SDL_Surface has been changed.>________________________________

From: Vittorio G. <vitto.giova at yahoo.it>
Subject: [SDL] SDL_UpperBlit returns a NULL pointer

hi
i’m experimenting SDL 1.3 with the iPhone and i found out this bug
after a texture is applied to the surface, the source surface is trashed and when returning to the calling function it won’t be accessible anymore.

the code follows (it’s in pascal, but it’s simple)

tmpsurf:= LoadImage(Pathz[ptCurrTheme] + ‘/LandTex’, false, true, false);
r.y:= 0;
while r.y < LAND_HEIGHT do
begin
r.x:= 0;
while r.x < LAND_WIDTH do
begin
SDL_UpperBlit(tmpsurf, nil, Surface, @r);
inc(r.x, tmpsurf^.w)
end;
inc(r.y, tmpsurf^.h)
end;
SDL_FreeSurface(tmpsurf);
the program terminates when trying to access tmpsurf^.w with a EXC_BAD_ADDRESS

the weird thing is that this very same function works with no problem when compiled with SDL1.2 (any platform)

any pointers i could follow?
thanks for any advice
Vittorio