Graphics in Pascal

Mon, 20 Jan 1997 01:10:05 +0100 (MET)


Brin wrote:
>   I wrote the following small program to try out some graphics
> routines [...]

There is already BGI2GRX, a "Graph" compatible Unit, based on 
GRX20 and BCC2GRX, written by Sven Hilscher.

> [...] Here is the program, any idea to
> what I am doing wrong!

The problem is that you are confusing some sizes of data types:

> {****************************************************************}
> Program Mode13h;
> type
>   {Define some 'terms'}
>   byte  = __byte__ integer;       {8 bit unsigned integer}
                                             signed

>   word  = __unsigned__ integer;   {16 bit unsigned integer}
                                     32

>   Long = __longlong__ integer;    {64 bit signed integer}
                   correct, but used in wrong context (see below)

If you correct them, your program runs fine.

Below are the correct sizes for Intel X86 platforms.  (I am
thinking about implementing the identifiers below into GPC's
standard vocabulary.)

Type
  ByteInt   = __byte__ Integer;       (* 8 bit signed Integer    *)
  Byte      = __unsigned__ ByteInt;   (* 8 bit unsigned Integer  *)
  ShortInt  = __short__ Integer;      (* 16 bit signed Integer   *)
  ShortWord = __unsigned__ ShortInt;  (* 16 bit unsigned Integer *)
  (* Integer = __long__ Integer *)    (* 32 bit signed Integer   *)
  Word      = __unsigned Integer;     (* 32 bit unsigned Integer *)
  LongInt   = __longlong__ Integer;   (* 64 bit signed Integer   *)
  LongWord  = __unsigned__ LongInt;

In addition, "unsigned long" in C has 32 bits, not 64:

> {routines taken from include/sys/farptr.h}
> {Puts a byte}
> procedure _farnspokeb(offset: Long ; value: byte);External;C;    
> {Gets a byte}               
> function _farnspeekb(offset: Long ; value: byte):byte;External;C;

                            (* Here's ^^^^^^^^^^^ another error ;*)

    Procedure FarNoSelectorPokeByte ( Offset: Word; value: Byte );
    AsmName '_farnspokeb';  (* ;-) *)
 
    Function FarNoSelectorPeekByte ( Offset: Word ): Byte;
    AsmName '_farnspeekb';  (* (-; *)

Hope this helps,

    Peter

      e-mail:  peter.gerwinski@uni-essen.de
home address:  D\"usseldorfer Str. 35, 45145 Essen, Germany
         WWW:  http://agnes.dida.physik.uni-essen.de/~peter/


Peter Gerwinski (peter@agnes.dida.physik.uni-essen.de)

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