First post, by serialShinobi
- Rank
- Newbie
Hello I would like to understand how to debug a game program written in C. I am using MSVC 1.5 and for debugging I use CodeView 4.10.
I am able to use breakpoints and I will refer to my code. Also I am attaching Tomb3.C, the game I am working on. Source code is from Andre Lamothe's Tricks of the Game Programming Gurus.
My program involves PCX decoding. The main function calls a function to load a PCX and then the program crashes. If I insert a break point in this PCX Loading called function at the point where it begins to load the RGB triple for an MCGA 256 color *.PCX file. The file pointer is opened and the area of memory is loaded with the PCX image data. Then when it is time to load the palette the fseek function has a parameter -768L and SEEK_END so that the file points at the end of the image file and then reverses a number of bytes equal to the sum of the bytes of the RGB triple. A for loop to read this data then ensues.
As I mentioned the program crashes if I step past this breakpoint. I believe I need to find out some way to determine if my file pointer math is off or if the data being read by the for loop is garbage from some out of range / off by one miscalculated memory issue.
I think I need either some way to examine memory or some better way of dealing with this sort of problem. Will anyone teach me something about my options when faced with the problem I have in this situation? I have thought of giving up. But I also wondered what might be out there in the world of debugging since I have never done it and this is probably why I know so little about IBM PC Architecture and the programing of the 8086. One day I want to move on to Michael Abrash's 1995 book Zen of Graphics Programming.
line 341: fseek(fp,-768L,SEEK_END)
line 345: for (index=0, index<256; index++)
line 346: {
line 347: // get the red component
line 348: image->palette[index].red = (getc(fp) >> 2);
line 350:
line 351: // get the green component
line 352:
line 353: image->palette[index].green = (getc(fp) >> 2);
line 354:
line 355: // get the blue component
line 356:
line 357: image->palette[index].blue = (getc(fp) >> 2);
line 358:
line 359: } // end for index