Mail Archives: djgpp/1997/02/28/10:47:17
------------388EFD4D1E0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
Hi all,
I have only recently installed djgpp (v2) and decided to port an
existing (very simple) graphics program to gcc using allegro 2.2.
Everything went very smoothly, however when I compiled using gcc, the
executable was 269kb compared to 24kb using Turbo C and my own pixel,
line etc functions.  I have included my source code (only short) and
would appreciate help from anyone who could explain why this occured.
Thanks
---------------------------------------------------------------------------------
#include <stdio.h>
#include <dos.h>
#include <allegro.h>
void initialise(void) {
    vline(screen,0,0,199,12);
    hline(screen,0,0,319,12);
    vline(screen,319,0,199,12);
    hline(screen,0,199,319,12);
    hline(screen,160,190,160+29,7);
}
void main(void) {
    int paddle=160;
    char c;
    int dx=1, dy=1;
    int x=160;
    int y=100;
    allegro_init();
    set_gfx_mode(GFX_VGA,320,200,0,0);
    initialise();
    do {
        if (kbhit()) {
            hline(screen,paddle,190,paddle+29,0);
            c = getch();
            switch (c)
                {  case ('a'): {
                                    paddle-=5;
                                    if (paddle<=1)
{paddle=1;}
                                    break;
                                    }
                    case ('s'): {
                                    paddle+=5;
                                    if (paddle>=289)
{paddle=289;}
                                    break;
                                    }
                    }
            hline(screen,paddle,190,paddle+29,7);
            }
            putpixel(screen,x,y,7);
            delay(10);
            putpixel(screen,x,y,0);
            x+=dx;
            if (x==318) dx=-1;
            if (x==1) dx=1;
            y+=dy;
            if (y==189 && x>=paddle && paddle>(x-30)) {dy=-1;}
            if (y==198) dy=-1;
            if (y==1) dy=1;
    } while (c != 27);
 exit(0);
}
-----------------------------------------------------------------------------
Jason Collins                        http://www.iimage.com.au
Internet Image Pty Ltd          email:jason AT iimage DOT com DOT au
------------388EFD4D1E0
Content-Transfer-Encoding: 7bit
Content-Type: text/html; charset=us-ascii
<HTML><BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000">
<DT>Hi all,</DT>
<DT> </DT>
<DT>I have only recently installed djgpp (v2) and decided to port an existing
(very simple) graphics program to gcc using allegro 2.2.  Everything
went very smoothly, however when I compiled using gcc, the executable was
269kb compared to 24kb using Turbo C and my own pixel, line etc functions. 
I have included my source code (only short) and would appreciate help from
anyone who could explain why this occured.</DT>
<DT> </DT>
<DT>Thanks</DT>
<DT> </DT>
<DT>---------------------------------------------------------------------------------</DT>
<DT> </DT>
<DT>#include <stdio.h></DT>
<DT>#include <dos.h></DT>
<DT>#include <allegro.h></DT>
<DT> </DT>
<DT>void initialise(void) {</DT>
<DT>    vline(screen,0,0,199,12);     </DT>
<DT>    hline(screen,0,0,319,12);     </DT>
<DT>    vline(screen,319,0,199,12);     </DT>
<DT>    hline(screen,0,199,319,12);     </DT>
<DT>    hline(screen,160,190,160+29,7);</DT>
<DT>}</DT>
<DT> </DT>
<DT>void main(void) {</DT>
<DT> </DT>
<DT>    int paddle=160;     </DT>
<DT>    char c;</DT>
<DT>    int dx=1, dy=1;</DT>
<DT>    int x=160;     </DT>
<DT>    int y=100;</DT>
<DT> </DT>
<DT>    allegro_init();     </DT>
<DT>    set_gfx_mode(GFX_VGA,320,200,0,0);     </DT>
<DT>    initialise();</DT>
<DT> </DT>
<DT>    do {</DT>
<DT>        if (kbhit()) {             </DT>
<DT>           
hline(screen,paddle,190,paddle+29,0);             </DT>
<DT>           
c = getch();             </DT>
<DT>           
switch (c)             </DT>
<DT>               
{  case ('a'): {</DT>
<DT>                                   
paddle-=5;                         </DT>
<DT>                                   
if (paddle<=1) {paddle=1;}                         </DT>
<DT>                                   
break;</DT>
<DT>                                   
}                </DT>
<DT>                   
case ('s'): {                         </DT>
<DT>                                   
paddle+=5;                         </DT>
<DT>                                   
if (paddle>=289) {paddle=289;}                         </DT>
<DT>                                   
break;                         </DT>
<DT>                                   
}                 </DT>
<DT>                   
}                 </DT>
<DT> </DT>
<DT>           
hline(screen,paddle,190,paddle+29,7);                 </DT>
<DT>           
}</DT>
<DT> </DT>
<DT>           
putpixel(screen,x,y,7);</DT>
<DT>           
delay(10);                 </DT>
<DT>           
putpixel(screen,x,y,0);                 </DT>
<DT> </DT>
<DT>           
x+=dx;                 </DT>
<DT>           
if (x==318) dx=-1;                 </DT>
<DT>           
if (x==1) dx=1;                 </DT>
<DT> </DT>
<DT>           
y+=dy;                 </DT>
<DT>           
if (y==189 && x>=paddle && paddle>(x-30)) {dy=-1;}</DT>
<DT>           
if (y==198) dy=-1;                 </DT>
<DT>           
if (y==1) dy=1;</DT>
<DT> </DT>
<DT>    } while (c != 27);</DT>
<DT> exit(0); </DT>
<DT> </DT>
<DT>} <BR>
----------------------------------------------------------------------------- <BR>
<BR></DT>
<DT> </DT>
<DT>Jason Collins                       
http://www.iimage.com.au<BR>
Internet Image Pty Ltd         
email:jason AT iimage DOT com DOT au<BR>
 </DT>
</BODY>
</HTML>
------------388EFD4D1E0--
- Raw text -