delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/02/00:05:54.1

From: Endlisnis <s257m AT unb DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Graphics with allegro
Date: Tue, 02 Mar 1999 00:01:46 -0400
Organization: BrunNet
Lines: 54
Message-ID: <36DB62AA.4180D1DB@unb.ca>
References: <36DA9998 DOT 6FA1AE42 AT bellsouth DOT net> <36daed12 DOT 442025 AT 158 DOT 152 DOT 254 DOT 68>
NNTP-Posting-Host: ftnts3c17.brunnet.net
Mime-Version: 1.0
X-Mailer: Mozilla 4.04 [en] (Win95; U)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Kevin wrote:

> Hi, Ringo,
> I'm only a beginer withe Allegro, but this is fairly simple, It sets
> the graphics to 640 * 400 * 8bpp and then draws a bitmap of a circle,
> then the bitmap of the circle moves from the bottom right of the
> screen to the top left,

[.... some stuff omitted ...]

>         // blit the sprite on to the back buffer.
>         blit(ball, buffer, 0,0, i,i--, 51,51);

    I don't think this produces the exact result you want.  I don't use
Allegro but, I can tell you that [in DJGPP] using "i" and "i--" like you do
will result in different values.  That explanation may not be very clear, but
you have to remember that the parameters are actually calculated backwards
(because this is the way they are put on the stack, even this shouldn't be
relied on if you want to make portable code).
This program may illustrate the issue more clearly:
-----------------------------
#include <stdio.h>
void a(int b, int c);

int main(int argc, char *argv[])
{int aa=0;
 a(aa,aa--);
 printf("in main: aa=%d",aa);
 return 0;
}

void a(int b, int c)
{printf("in a: b=%d c=%d\n", b, c);
 }
----------------------------
Produces this output:
in a: b=-1 c=0
in main: aa=-1
----------------------------
If you changed this line to:
 blit(ball, buffer, 0,0, i--,i, 51,51);
it would give you what you expected [when used in DJGPP].  But, again, this is
compiler specific.

--
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT GeoCities DOT com
          Endlisnis AT BrunNet DOT Net
          Endlisnis AT HotMail DOT com




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019