First post, by videogamer555
I've put Turbo C 2.01 on my DosBox. However I need to know a bit more about how it works with far pointers. I can use MK_FP to initialize a variable declared as a far pointer, such as
unsigned char far *FarPointerToByte = MK_FP(segment,offset);
However, once I've initialized it, how do I update its offset (while keeping the same segment, and not having to call MK_FP again)? I need to use it in a loop to reference all the VGA ram for rapidly drawing an image (must be able to write an entire image to the screen in less then 1/30th of a second, the duration of a video frame). I've tried pokeb, which allows a segment, offset, and value to be specified on each call of the function. But that's too slow. It takes about 1/10th of a second to draw, and as such I can actually see the image before it's complete. I should be able to see a black screen before drawing the image, and then the image after it's drawn, and not see (even for a fraction of a second) a partially drawn image.
Thus I've decided to skip using pokeb, and go straight to directly writing to memory with a far pointer. However, I need to know how to (after having initialized the pointer with MK_FP) actually update the offset portion of that far pointer, so as to scan through all of VGA memory, so as to nearly instantly write a full image into VGA memory.
However, I can't figure out how to update the offset of the the pointer.
I thought I could do this:
unsigned char far *FarPointerToByte = MK_FP(segment,offset);
FarPointerToByte=FarPointerToByte+1;
But doing this gives me a "Non-portable pointer assignment" warning. It doesn't rise to the level of an error, so compiling completes, but when I run the compiled EXE file, I end up having the program lock up. Remove the line FarPointerToByte=FarPointerToByte+1; and the program completes and returns to DOS, just like it should.
I've spent well over an hour looking on Google for how to increment a Turbo C far pointer's offset, using many different search terms that I thought described my problem, and haven't found anything whatsoever. I can't even find forums where others are asking how to do this particular thing. So I've decided to post my question here. Hope you guys can help me.