🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

gcc svgadisplaypcx.c pcx.c svgacommon.o -o pcx -lvgagl -lvga

Started by
10 comments, last by 3d Wolf 23 years, 8 months ago
My pcx viewer/loader is not working (From the tutorial of http://sunsite.dk/lgdc/articles.php3?mode=body&articleid=13) I have the pcx on my computer , my compile line = gcc svgadisplaypcx.c pcx.c svgacommon.o -o pcx -lvgagl -lvga , it compile''s but the error when i run it is have is Usage : filename.pcx
Advertisement
It looks like it''s compiling and running fine, but when you''re running it you''re not supplying it with the command line argument for the pcx file to be loaded.
What must i do to make it ?
pcx filename.pcx

[edit]
(that's the way it appears, anyway.. that you need to give the program a .pcx file as a command line parameter. you were just typing pcx before, right?)

------------------------
IUnknown *pUnkOuter

"Try the best you can
try the best you can
the best you can is good enough"
--Radiohead

Edited by - pUnkOuter on October 23, 2000 1:50:03 PM
------------------------IUnknown *pUnkOuter"Try the best you cantry the best you canthe best you can is good enough" --Radiohead
It''s working now , I must run it like this :
./pcx filename.pcx
but I want to code the pcx in my code , now it''s more like a pcx viewer, In the future I want to make games, sow I want the pcx in my code (coded in my code).
Now i can load a pcx , i must start it with ./pcx FILENAME.PCX
I want to start it with ./pcx You can see the tutorial at http://sunsite.dk/lgdc/articles.php3?mode=body&articleid=13.
Any reply ? I want to start it with ./pcx
now I must start it with ./pcx filename.pcx
What are you trying to do?

You have to start it like so: ./pcx, but you want to start it like so: ./pcx? They both look the same to me
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
I have to start it like so: ./pcx filename.pcx , but I want to start it like so: ./pcx?
I cannnot make a game when the user must start the game like this :
./game a.pcx b.pcx c.pcx sword.pcx gun.pcx user.pcx
I want to start it like this
./game

here are the code''s of the pcx viewer/loader :

pcx.c :

#include
#include
#include


typedef struct
{
char signature;
char version;
char encoding;
char bytes_per_pixel;
unsigned short int xmin;
unsigned short int ymin;
unsigned short int xmax;
unsigned short int ymax;
unsigned short int vres;
unsigned short int hres;
char palette[48];
char reserved;
char color_layers;
unsigned short int bytes_per_line;
unsigned short int palette_type;
char unused[58];
}PCX_Header;


void readpcximage(FILE * file,void * target,int size)
{
unsigned char buf;
unsigned int counter;
int i=0;
while(i<=size) /* Image not entirely read? */
{
/* Get one byte */
fread(&buf,1,1,file);
/* Check the 2 most significant bits */
if ((buf&192)==192)
{
/* We have 11xxxxxx */
counter=(buf&63); /* Number of times to repeat next byte */
fread(&buf,1,1,file); /* Get next byte */
for(;counter>0;counter--) /* and copy it counter times */
{
((char*)target)=buf;
i++; /* increase the number of bytes written */
}
}
else
{
/* Just copy the byte */
((char*)target)=buf;<br> i++; /* Increase the number of bytes written */<br> }<br> }<br>}<br><br><br>void *readpcx(FILE *file, char *palette,unsigned short int *length, unsigned short int *height)<br>/* Returns NULL if failed, otherwise a pointer to the loaded image */<br>{<br>PCX_Header header;<br>void *target;<br>fseek(file,0,SEEK_SET);<br>fread(&header,sizeof(PCX_Header),1,file); /* read the header */<br>/* Check if this file is in pcx format */<br>if((header.signature!=0x0a)||(header.version!=5))<br> return(NULL);<br>else<br>{/* it is! */<br>/* Return height and length */<br> *length=header.xmax+1-header.xmin;<br> *height=header.ymax+1-header.ymin;<br>/* Allocate the sprite buffer */<br>target=(void *)malloc((*length)*(*height));<br>/* Read the image */<br>readpcximage(file,target,(*length)*(*height));<br>fseek(file,-768,SEEK_END);<br>/* Get the palette */<br>fread(palette,1,768,file);<br>/* PCX succesfully read! */<br>return(target);<br>}<br>}<br>svgadisplaypcx.c :<br><br>#include <stdio.h><br>#include <vga.h><br>#include <vgagl.h><br><br><br>void *readpcx(FILE *file, char *palette,unsigned short int *length, unsigned short int *height);<br><br><br>void init_svgalib (GraphicsContext *physicalscreen);<br>void exit_svgalib();<br><br><br>GraphicsContext physicalscreen;<br><br><br>int main(int argc, char **argv)<br>{<br>FILE *file;<br>void *image;<br>int i;<br>unsigned short int length, height;<br>unsigned char palette[768];<br>if (argc!=2)<br>{<br> printf("Usage: svgadisplaypcx filename.pcx.\n");<br> return(1);<br>}<br>if ((file=fopen(argv[1],"r"))==NULL) {<br> printf("Can''t open file!\n");<br> return(1);<br>}<br>if ((image=readpcx(file,palette,&length,&height))==NULL)<br>{<br> printf("Error loading file!\n");<br> return(1);<br>}<br>fclose(file);<br>printf("Image is %dx%d sized.\n",length,height);<br>if((length>320)||(height>200)) {<br> printf("Image is too big!\n");<br>return(1);<br>}<br>for (i=0;i<768;i++) palette=palette>>2;<br>init_svgalib(&physicalscreen);<br>gl_setpalette(palette);<br>gl_clearscreen(0);<br>gl_putbox(0,0,length,height,image);<br>vga_waitretrace();<br>gl_copyscreen(&physicalscreen);<br>getchar();<br>exit_svgalib();<br>return(0);<br>} <img src="smile.gif" width=15 height=15 align=middle><br> </i>

This topic is closed to new replies.

Advertisement