Pointer & GPC question..._(re)

Tue, 19 Aug 1997 00:02:26 +0200 (MEST)


According to Orlando Llanes:
> 
> Do you have access to these machines for beta-testing?

Yup.

> That reminds me, are
> there definitions for the environment GPC is compiling for? For example:
> [...]

Yes:

    (*$ifdef __MSDOS__ *)  (* The definitions are case-sensitive *)
       ...
    (*$else *) (*$ifdef __osf__ *)  (* One operating system for the Alpha *)
       ...
    (*$else *) (*$ifdef __linux__ *)  (* Another operating system for *)
      (*$ifdef __i386__ *)            (* the Alpha - or for the i386+ *)
        ...
      (*$else *) (*$ifdef __alpha__ *)
        ...
      (*$endif *)
    (*$endif *) (*$endif *) (*$endif *)


> How do I set a pointer to point to the VGA (for example) in a way that can
> be ported to at least Linux?

No way.

For DJGPP, see the GPC FAQ and the DJGPP FAQ.  The "best" way for direct
memory access IMHO is to use assembler.  You can use the following function
to convert a segment address to a selector:

    Function SegToSel ( Seg: ShortWord ) Sel: Word;

    begin (* SegToSel *)
      asm ( 'int $0x31'
            : '=a' ( Sel )
            : 'a' ( 2 ), 'b' ( Seg )
            : '%eax', '%ebx', '%ecx', '%edx', '%esi', '%edi', '%ebp' );
    end (* SegToSel *);

For Linux, better don't access memory directly.  Instead, use (S)VGALIB or
some other well-documented interface to graphics mode.

> I'm going to start work again on my game lib
> (graphics part), and M13h would be a start :) Another thing is how do I
> modify the contents referenced by the pointer? Writing a byte so it's
> portable, writing a word so it's portable, etc. My ultimate goal is to port
> this lib to PMode DOS, Mac, '95, Linux, X, and whatever other platform I
> can get my grubby hands on, but I'll settle for PMode DOS for now :)

Sounds good.  Do you consider to put it under the GNU Library General
Public License?

For DJGPP, there is a game library called `Allegro' for GNU C.
To use it with GNU Pascal, you only need to translate the C header
files to a Unit with empty implementation part.  I think, `Allegro' is
under the GNU LGPL, so it is available in source code.  Maybe it's a
good starting point for you to write such a Unit to use `Allegro'
with GPC?

For an example what I mean, look at Sven's excellent `BGI2GRX' Unit,
also known as GPC's `Graph' Unit.

Greetings,

    Peter

 Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer
peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201]
 maintainer GNU Pascal [970714] - http://home.pages.de/~gnu-pascal/ [970125]


Peter Gerwinski (peter@agnes.dida.physik.NO-SPAM-PLEASE.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es