Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help allocating a far pointer on Borland C++ 3.0

Tags:

I am writing a DOS game framework to learn C better and a general interest in programming on old hardware (especially on the system I grew up with).

I am trying to implement a double buffer system but I am having trouble allocating a far pointer to a 320*200 array.

At first I was trying to use malloc but found out it can only allocate under 64kb. I read that you need to use farmalloc (malloc returns NULL) and it allocated correctly. However, when _fmemset or _fmemcpy is run.... the whole system freezes.

backBuffer = (unsigned char far*) farmalloc(64000);

when it is time to swap buffers I use

_fmemcpy(VGA, backBuffer, 64000);

Program is using the small memory model.