delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/14/09:31:14

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Problems using allegro
Date: 14 Mar 1997 06:26:29 GMT
Organization: The National Capital FreeNet
Lines: 92
Message-ID: <5gar2l$dgf@freenet-news.carleton.ca>
References: <19970312 DOT 054752 DOT 7495 DOT 0 DOT fwec AT juno DOT com>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet2.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Mark T Logan (fwec AT juno DOT com) writes:
> Hello.
> 
> I have written a fairly simple program to translate TGA files to
> PCX files using allegro.  It crashes.  Here is my source code.
> 
> -----------------------------------------------------------------------------------
> #include <allegro.h>
> #include <string.h>
> #include <iostream.h>
> #include <dir.h>
> #include <dos.h>
> 
> int main(int argc, char *argv[])
> {
>  char infile[13];
>  char outfile[13];
> 
>  ffblk fileinfo;
> 
>  PALETTE pal;
>  BITMAP *bitin;
> 
>  if(argc != 3) // check the command line arguments.
>   {
>    cout << "wrong number of args.";
>    return 0;
>   }
> 
>  strcpy(infile, argv[1]);   // copy the arguments into the file name
> strings
>  strcpy(outfile, argv[2]);
> 
>  if(findfirst(infile, &fileinfo, 0)) // make sure that the infile exists!
>   {
>    cout << "\nFile does not exist, or is a hidden or system file\n";
>    return 0;
>   }
> 
>  bitin = load_tga(infile, pal); // load the TGA file
> 
>  save_pcx(outfile, bitin, pal); // save it as a pcx file
> }
> --------------------------------------------------------------------------------------
> 
> This is the command line I used to compile it.
> 
>  9:32p c:\gnu\bin>gcc -g -o trans trans.cpp -lalleg -lgpp -lc
> 
> This is the dump(symified) that is printed out after I run the program
> 
>  9:33p c:\gnu\bin>trans out.tga out.pcx
> Exiting due to signal SIGSEGV
> Page fault at eip=00002c5a, error=0004
> eax=00000000 ebx=00085000 ecx=00000000 edx=00031c00 esi=00030d70
> edi=000381e0
> ebp=000781b8 esp=00077c2c cs=00a7 ds=00af es=00af fs=008f gs=00bf ss=00af
> Call frame traceback EIPs:
>   0x00002c5a   _save_pcx+254
>   0x00021c87   ___crt1_startup+115
> 
> I have no idea what is causing this.  I'm guessing it's something silly I
> did wrong because
> I have had no trouble with any of these functions in the past when they
> were used by
> themselves.  (although this is the first time I've used load_tga);
> 
>  out.tga is a file that exists in the current directory.
> It was created by Polyray version 1.6

First of all, try compiling with +g and without -fomit-frame-pointer. The
latter speeds code up by freeing a *whole 32 bit register* BUT it leads to
stack traces like above, where only the last two or three calls are
displayed. To diagnose this I would have to see what function launched
save_pcx. The obvious culprit, save_pcx used with an unitnitialized or a
NULL (alloc failure?) BITMAP *, I assume you already checked for before
coming here. (I would be stymied for about three milliseconds by that type
of thing.) Presumably the problem lies further back than that.

Also, if Shawn is reading this and I suspect he greps the headers for
"allegro" daily, if he gets this thing working you two could collaborate
and put TGA read/write in Allegro. (PNG would be nice too... and so would
either GIF or JPG, since those ar the only image formats standard in web
browsers now. I haven't a clue why the superior PNG format hasn't been
adopted by browser makers though...)

--
    .*.  Where feelings are concerned, answers are rarely simple [GeneDeWeese]
 -()  <  When I go to the theater, I always go straight to the "bag and mix"
    `*'  bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh

- Raw text -


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