DJGPP Program Error, Help!!!

Started by
7 comments, last by Corrosive 24 years ago
Hi, i´mprogramming with Delorie Djgpp 2.0 i think... Well, i´m making an pcx reader function with 13h mode and the code is all right, there is no error messages with the compilations, but when i try to run the program, this return an error message about SIGSEGV and shows up various registers and values in hexadecimal... I really don´t know what to do anymore Please help!!! Thanks!
To code is to make things come to life ;)
Advertisement
Did you access the videomemory just the way you did in Borland (I assume that you''d changed compiler from borland to DJGPP)?
Remember that DJGPP is protected mode. That means you can''t just write on random addresses (including the videomemory). Try to use the dosmemput() function instead.
You are right about the change of Borland to DJGPP, but i know that it´s protected mode, i use djgpp_nearptr_enable instead of dosmemput(); There is some other thing missing
in the code, but i just don´t know what...

I have teste all my functions and i see that the piece of code that bugs is the load_pcx function, in the exact time i try to put the rle data into a buffer to copy to vbuffer later... It recuses to put rle data in a buffer.. i use like this...


count=0;
while(count<=xsize*ysize){
data=getc(fp) // fp is the pointer to file...
if(data>=192 && data<=255){
num_bytes=data-192;
data=getc(fp);
while(num_bytes-->0)
image->buffer[count++]=data;
}
else
{
image->buffer[count++]=data;
}
}

this is the part that don´t work, i think, because the program tilts before any data is placed in the video memory...

i test it with the step over function avaliable in Rhide for djgpp!!!

Please help!!!

thanks!
To code is to make things come to life ;)
I''m assuming that image->buffer is dynamically allocated. In RHGDB, check the value of image->buffer when you''re about to write to it. Make sure it isn''t a NULL-pointer.
Also, you might wanna test if ''fp == NULL'' since the file might not exist or something...
The fp isn´t NULL because i verify it when i load it with a function like:

if(fp=fopen(name)==NULL)
exit(1);

I will try to see if the image->buffer isn´t a NULL pointer, but i think it´s not because i declare buffer as unsigned char like "unsigned char buffer"(no pointer)..

and i made an struct to hold the buffer with the pointer directed to image!!! I hope you will understand what i´m saying!!! The error make´s no sense because i test all the code piece by piece and the only thing that cause the bug is the part with image->buffer...

More ideas to help me out of this problem are welcome...

Thanks and keep trying!!!
To code is to make things come to life ;)
if i understand your last post correctly, you declared buffer as an unsigned char? not a pointer or an array? if that''s true, then trying to access buffer[ (anything) ] should give you some kind of compilation error..
so i''ll assume you declared it as an array. SIGSEV is just a Segmentation Fault (in unix terms), it almost always means an error of some type with pointers or arrays (which are pretty much the same thing)..

every time i''ve gotten a SIGSEV, it was from trying to access memory i didn''t have access to.. so perhaps in your while loop you''re going beyond the bounds of image->buffer?
that''s the only thing i can think of at the moment..
Thank´s for the advice!!!

I will try to verify this doing some like:

printf("\n%d\n", sizeof(image->buffer));


to verify the size of buffer and the size of the contents i´m trying to put inside it.. I will give a report about the results.. While i try this, if someone has other idea about what is this problem, go thinking about...

Thanks!
To code is to make things come to life ;)
Interesting thing i got here folks!!!

When i print in the screen the size of image-buffer the number 4 appear!!! And other curious thing is that the Nplanes var in the pcx header file is equal to 0, but it had to be 1 at least since the file i ´m trying to load is a 8 bit 256 color pcx...

The error keep boring me... i can´t resolve that yet...

Still in need of help!!!

Thanks!
To code is to make things come to life ;)

This topic is closed to new replies.

Advertisement