Hi,
I'm a GNU Pascal developer. I'm not subscribed to this list, so please CC any replies to me.
As I'm concerned with many of GPC's units, I took a look at the bgi2grx unit which I understand is meant to be compatible to Borland Pascal's Graph unit.
I managed to get some sample programs originally written for BP to run with the unit under Linux (svgalib and X11), but noticed some problems with the GraphDriver/GraphMode parameters to InitGraph.
In fact, I tried various values (Detect, Vga/Vga{Lo,Med,Hi}, even Cga/CgaC0), but always got the same mode: 640x480/4 in svgalib and 640x480/<color depth of X server> under X11. That's not nice for programs that expect a certain resolution.
I think, under X11 it ought to be easy to get a window of any size, and also svgalib supports modes with lower resolutions. If the color depth seems to be the problem, I think using a higher depth should be no problem. E.g., the CGA modes have 320x200 in 4 colors. svgalib supports G320x200x256 on any card AFAIK (maybe also G320x200x16), so the library could just set this mode, map the 4 colors used by the CGA modes to the (ugly) CGA colors (see below), and just ignore the other colors. Since the unit only provides high-level access (i.e., no direct frame buffer), I think the program will not notice the difference.
Besides, is there any particular reason why the constants `Detect' and `Current_Driver' are different from the BP values? In particular `Detect' might be problematic, as I guess there are many BP programs that don't bother to use `Detect', but simply write 0. BTW, `CurrentDriver' is written without an `_' in BP.
The second point are the color constants. AFAICFO, the library uses the "default" colors, whatever these are. Under svgalib, they're probably the hardware defaults and therefore BP compatible (except for some strange modes like CGA, see above), but under X11, that's not the case. When I start the X server with 8bpp, I seem to get the palette used by the window manager etc., and in 16 or 24 bpp, I just get shades of blue (which are the first few color values).
That's problematic for programs that don't set their own palette, and e.g. just use colors 1..3 to draw some things. In 8bpp it might happen (e.g., on my system) that color 2 is black (or something very dark), so this color is just missing, and with more bpp, it's all in dark blue.
So I think, to be more compatible, the library should set the VGA default colors in InitGraph.
Frank
On Wed, 28 Jun 2000, Frank Heckenbach wrote:
[...]
In particular `Detect' might be problematic, as I guess there are many BP programs that don't bother to use `Detect', but simply write 0.
[...]
The second point are the color constants. AFAICFO, the library uses the "default" colors, whatever these are.
[...]
So I think, to be more compatible, the library should set the VGA default colors in InitGraph.
Frank,
if you really need 100% compatibility, just use TP or BP on a DOS machine. BCC2GRX (and the Pascal interface BGI22GRX) were designed to make it easy to port programs, not to allow ill formed programs to work on every platform.
Hartmut
PS: You should have found another incompability: On several systems integers are wider than 16 bit causing major trouble ;)