[fpc-pascal] Converting a graphical DOS program to fpc

Nikolay Nikolov nickysn at users.sourceforge.net
Tue Jul 6 14:50:46 CEST 2010

On 07/01/2010 05:46 AM, Simon Webster wrote:
> Dear Free Pascallers,
> I'm wanting to convert a Turbo Pascal program to fpc, to run
> (ultimately) under linux, although I'm actually developing on a mac,
> and using virtualbox to run ubuntu. The program in question is a
> relatively large non OOP program which makes substantial use of BGI
> graphics. I'm wondering what would be the best/easiest way of
> achieving this?
> I tried using the graph unit&  svgalib under a virtualized ubuntu, but
> even the simplest test program (InitGraph, putpixel, CloseGraph)
> produces a runtime error 216. Even if I got this working, I get the
> feeling that directly bashing the graphics hardware in such a
> primitive way is not the best way to go.
> Ideally I would like to be able to just open a large window that I can
> use as a bitmap for all my graphics drawing, ideally using graph unit
> syntax compatible functions. What's the simplest way to do this - I
> tried looking in the documentation but don't really know where to
> start. Do I need to use 'Lazarus' if I want to open a window? I've no
> experience with Delphi or Object Pascal so that whole aspect of fpc is
> completely alien to me.
> Many thanks in advance for any help,
> Simon
You can check out the latest development version of ptcpas, which has a 
BGI-compatible graph unit, called ptcgraph, implemented on top of 
ptcpas. It's heavily based on the fpc graph unit, namely it uses the 
same platform-independent .inc files, where all the drawing algorithms 
are implemented. Ptcgraph currently works under X11 and Windows - both 
windowed and fullscreen. (ptcpas also supports DOS, but ptcgraph does 
not support it yet, due to lack of threading support)

It's still a work in progress and I started to work on it only recently, 
so it's not completely finished yet - only 16-colour (or less) modes are 
supported as of now, but I can easily add 256-colour and 65536-colour. 
(however the original BGI drivers that came with Turbo Pascal 7 only 
supported up to 16-colours, so that's why I'm focusing on it now)

The example programs from TP7 - bgidemo.pas and arty.pas run perfectly 
with ptcgraph.

The PTCPas website is:

Since ptcgraph is new, it's still not included in the latest stable 
release of ptcpas, so you need to get the latest development version via 

svn co https://ptcpas.svn.sourceforge.net/svnroot/ptcpas/trunk ptcpas

More information about the fpc-pascal mailing list