I don't realy understand this. I'm new to Pascal tho I've programmed in C for quite some time.
I have a unit that dose some _basic_ mode 13h graphics stuff. In it is an off-screen buffer created my allocating a type defined as:
type mode13VideoBuffer = array[1..64000] of char;
var gBuffer"^mode13VideoBuffer;
I have 2 procedures that set up the video mode (by calling some external C functions) and allocate this buffer.
procedure InitGraphics; begin {set video mode and other initalization stuff} new(gBuffer); end;
procedure TextMode; begin {reset the display and clean up video stuff} dispose(gBuffer); end;
All my graphic functions draw to this buffer. To get it to the screen I have a procedre that calls an external C function: procedure gUpdate; begin screenblit( gBuffer); end;
It is in this C function that I crash. Here's the screenblit function: //uses libc.a functions void screenblit( unsigned char* buf) { short video = __dpmi_segment_to_descriptor(0xa000); movedata(_my_ds(), (int)buf, video, 0, 320*200); }
This only crashes when I pass it a pointer from my unit. I can do the exact same allocation from the main program file and it will work OK.
Am I getting confused on how pointers work in C and how they work in Pascal (I thought that they were pretty much the same except for type checking and "true" dynamic allocation)?
This how I compile and link: I create a lib from the compiled .o files from my units. I then compile my test program linking in the lib: gpc -g -o gtest.exe gtest.pas -lglib ^^^^ This is my lib NOTE: I can get this system to work in C by replicating the units in .h and .c files and linking the object files on the commanline.
HELP?
-SC