SDL Digest, Vol 30, Issue 60

Hello,
I doublechecked the declaration for SDL_UpperBlit and it basically
corresponds to yours

mine: function SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst:
PSDL_Surface; dstrect: PSDL_Rect): LongInt; cdecl;
suggested: function SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect;
dst: PSDL_Surface; dstrect: PSDL_Rect): integer; cdecl;

Have you verified that you got a valid pointer out of LoadImage, BTW? If

it’s not loading properly for whatever reason, it could be that you’ve got a
nil from the very beginning.

yes, i have verified the content of LoadImage’s pointer and they are all
accessible before using SDL_UpperBlit
I found out that if i try and LoadImage another texture, also that
associated pointer becomes null after a SDL_UpperBlit

p @tmpsurf
$1 =(^PSDL_SURFACE) 0xbfffe0d0
p @tmpsurf2
$2 = (^PSDL_SURFACE) 0xbfffe0cc
p tmpsurf
$3 = 0x50d13a0
p tmpsurf2
$4 = 0xa07c5f0
then after a SDL_UpperBlit using only tmpsurf
(gdb) p tmpsurf
$5 = 0x200
p tmpsurf2
$6 = 0x200

i’m really clueless, do you have any idea for this behavior?
thanks a lot
Vittorio>

Message: 3
Date: Wed, 17 Jun 2009 13:59:29 -0700 (PDT)
From: Mason Wheeler
Subject: Re: [SDL] SDL Digest, Vol 30, Issue 58
To: “A list for developers using the SDL library. (includes
SDL-announce)”
Message-ID: <694305.46036.qm at web53207.mail.re2.yahoo.com>
Content-Type: text/plain; charset=“us-ascii”

From: Vittorio G. <vitto.giova at yahoo.it>

To: sdl at lists.libsdl.org
Sent: Wednesday, June 17, 2009 1:46:54 PM
Subject: Re: [SDL] SDL Digest, Vol 30, Issue 58

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.)

I agree that’s strange! actually tmpsurf is declared in the var section
because we need to assign an image source to it

No, I meant the parameter you’re passing tmpsurf to in the header for the
blit function. It should be declared like this:

function SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst:
PSDL_Surface; dstrect: PSDL_Rect): integer; cdecl;

It should be passing your pointer by value, so it can’t be changed. If
"src" is declared as a var parameter there, it’s gonna pass by reference,
which can corrupt the pointer.

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.

Yes i check this myself with gdb, after stepping out of SDL_UpperBlit it
reports TMPSURF = 0x0 and so when trying to access tmpsurf^.w it crashes

what is really strange is that this very function works flawless in sdl-1.2

That’s some very strange behavior. What compiler are you writing for? FPC?

Could you send me your code on a private email, including the SDL header file you’re using? From what you’ve described, the behavior you’re seeing ought to be impossible. I could probably help debug this if I could play around with the debugger personally, though…

Hello,
I doublechecked the declaration for SDL_UpperBlit and it basically corresponds to yours

mine: function SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): LongInt; cdecl;
suggested: function SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): integer; cdecl;

Have you verified that you got a valid pointer out of LoadImage, BTW?
If it’s not loading properly for whatever reason, it could be that
you’ve got a nil from the very beginning.

yes, i have verified the content of LoadImage’s pointer and they are all accessible before using SDL_UpperBlit
I found out that if i try and LoadImage another texture, also that associated pointer becomes null after a SDL_UpperBlit

p @tmpsurf
$1 =(^PSDL_SURFACE) 0xbfffe0d0
p @tmpsurf2
$2 = (^PSDL_SURFACE) 0xbfffe0cc
p tmpsurf
$3 = 0x50d13a0
p tmpsurf2
$4 = 0xa07c5f0
then after a SDL_UpperBlit using only tmpsurf
(gdb) p tmpsurf
$5 = 0x200
p tmpsurf2
$6 = 0x200

i’m really clueless, do you have any idea for this behavior?
thanks a lot
VittorioFrom: vitto.giova@yahoo.it (Vittorio Giovara)
Subject: Re: [SDL] SDL Digest, Vol 30, Issue 60