(*
 * Svgalib-Gpc - Pascal porting of Svgalib header files.
 * Copyright 1999, 2000 (C) Nicola Girardi <girardi@vicenza.linux.it>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *)

unit Vga;
{$L vga}

interface

type ByteA  = array[0..MaxInt] of Byte;
     IntA   = array[0..MaxInt] of Integer;
     PByteA = ^ByteA;
     PIntA  = ^IntA;
     PProc  = ^procedure;

(* Here are some mode constants to pass to vga_[has,set]mode functions
 *)

const TEXT_MODE = 0; (* Compatible with VGAlib v1.2 *)

(* TEXT constant has been swapped with TEXTMODE since TEXT is a Pascal Keyword
 *)

      G320x200x16 = 1;
      G640x200x16 = 2;
      G640x350x16 = 3;
      G640x480x16 = 4;
      G320x200x256 = 5;
      G320x240x256 = 6;
      G320x400x256 = 7;
      G360x480x256 = 8;
      G640x480x2 = 9;
      G640x480x256 = 10;
      G800x600x256 = 11;
      G1024x768x256 = 12;
      G1280x1024x256 = 13;

      (*Additional modes*)
      G320x200x32K = 14;
      G320x200x64K = 15;
      G320x200x16M = 16;

      G640x480x32K = 17;
      G640x480x64K = 18;
      G640x480x16M = 19;

      G800x600x32K = 20;
      G800x600x64K = 21;
      G800x600x16M = 22;

      G1024x768x32K = 23;
      G1024x768x64K = 24;
      G1024x768x16M = 25;

      G1280x1024x32K = 26;
      G1280x1024x64K = 27;
      G1280x1024x16M = 28;

      G800x600x16 = 29;
      G1024x768x16 = 30;
      G1280x1024x16 = 31;

      G720x348x2 = 32;      (* Hercules emulation mode *)
      G320x200x16M32 = 33;  (* 32-bit per pixel modes *)
      G640x480x16M32 = 34;
      G800x600x16M32 = 35;
      G1024x768x16M32 = 36;
      G1280x1024x16M32 = 37;
   
      G1152x864x16 = 38;    (* Additional resolutions *)
      G1152x864x256 = 39;
      G1152x864x32K = 40;
      G1152x864x64K = 41;
      G1152x864x16M = 42;
      G1152x864x16M32 = 43;

      G1600x1200x16 = 44;
      G1600x1200x256 = 45;
      G1600x1200x32K = 46;
      G1600x1200x64K = 47;
      G1600x1200x16M = 48;
      G1600x1200x16M32 = 49;

      G320x240x256V = 50;
      G320x240x32K = 51;
      G320x240x64K = 52;
      G320x240x16M = 53;
      G320x240x16M32 = 54;

      G400x300x256 = 55;
      G400x300x32K = 56;
      G400x300x64K = 57;
      G400x300x16M = 58;
      G400x300x16M32 = 59;

      G512x384x256 = 60;
      G512x384x32K = 61;
      G512x384x64K = 62;
      G512x384x16M = 63;
      G512x384x16M32 = 64;

      G960x720x256 = 65;
      G960x720x32K = 66;
      G960x720x64K = 67;
      G960x720x16M = 68;
      G960x720x16M32 = 69;

      G1920x1440x256 = 70;
      G1920x1440x32K = 71;
      G1920x1440x64K = 72;
      G1920x1440x16M = 73;
      G1920x1440x16M32 = 74;

(* The following modes have been introduced by SciTech Display Doctor *)

      G320x400x256V = 75;
      G320x400x32K = 76;
      G320x400x64K = 77;
      G320x400x16M = 78;
      G320x400x16M32 = 79;

      G640x400x256 = 80;
      G640x400x32K = 81;
      G640x400x64K = 82;
      G640x400x16M = 83;
      G640x400x16M32 = 84;

      G320x480x256 = 85;
      G320x480x32K = 86;
      G320x480x64K = 87;
      G320x480x16M = 88;

      G320x480x16M32 = 89;
      G720x540x256 = 90;
      G720x540x32K = 91;
      G720x540x64K = 92;
      G720x540x16M = 93;
      G720x540x16M32 = 94;

      G848x480x256 = 95;
      G848x480x32K = 96;
      G848x480x64K = 97;
      G848x480x16M = 98;
      G848x480x16M32 = 99;

      G1072x600x256 = 100;
      G1072x600x32K = 101;
      G1072x600x64K = 102;
      G1072x600x16M = 103;
      G1072x600x16M32 = 104;

      G1280x720x256 = 105;
      G1280x720x32K = 106;
      G1280x720x64K = 107;
      G1280x720x16M = 108;
      G1280x720x16M32 = 109;

      G1360x768x256 = 110;
      G1360x768x32K = 111;
      G1360x768x64K = 112;
      G1360x768x16M = 113;
      G1360x768x16M32 = 114;

      G1800x1012x256 = 115;
      G1800x1012x32K = 116;
      G1800x1012x64K = 117;
      G1800x1012x16M = 118;
      G1800x1012x16M32 = 119;

      G1920x1080x256 = 120;
      G1920x1080x32K = 121;
      G1920x1080x64K = 122;
      G1920x1080x16M = 123;
      G1920x1080x16M32 = 124;

      G2048x1152x256 = 125;
      G2048x1152x32K = 126;
      G2048x1152x64K = 127;
      G2048x1152x16M = 128;
      G2048x1152x16M32 = 129;

      G2048x1536x256 = 130;
      G2048x1536x32K = 131;
      G2048x1536x64K = 132;
      G2048x1536x16M = 133;
      G2048x1536x16M32 = 134;

      G512x480x256 = 135;
      G512x480x32K = 136;
      G512x480x64K = 137;
      G512x480x16M = 138;
      G512x480x16M32 = 139;

      G400x600x256 = 140;
      G400x600x32K = 141;
      G400x600x64K = 142;
      G400x600x16M = 143;
      G400x600x16M32 = 144;

(* __GLASTMODE would have generated GPC warnings, so it has been declared
 * as GLASTMODE_const; GLASTMODE, instead, was a #define statemente in C,
 * but is now a function in Pascal
 *)

      function GLASTMODE : Integer; asmname 'vga_lastmodenumber';
      const GLASTMODE_const = G400x600x16M32;

(* Now functions, as found in vga.h
 *)

function VgaVersion : Integer; asmname 'vga_version';

function VgaSetMode(mode: Integer) : Integer; asmname 'vga_setmode';
function VgaHasMode(mode: Integer) : Boolean; (* modified (see implementation) *)
function VgaSetFlipChar(c: Integer) : Integer; asmname 'vga_setflipchar';

function VgaClear : Integer; asmname 'vga_clear';
function VgaFlip : Integer; asmname 'vga_flip';

function VgaGetXdim : Integer; asmname 'vga_getxdim';
function VgaGetYdim : Integer; asmname 'vga_getydim';
function VgaGetColors : Integer; asmname 'vga_getcolors';

function VgaSetPalette(index, red, green, blue: Integer) : Integer; asmname 'vga_setpalette';
function VgaGetPalette(index: Integer; var red, green, blue: Integer) : Integer; asmname 'vga_getpalette';
function VgaSetPalVec(start, num: Integer; pal: PIntA) : Integer; asmname 'vga_setpalvec';
function VgaGetPalVec(start, num: Integer; pal: PIntA) : Integer; asmname 'vga_getpalvec';

function VgaScreenOff : Integer; asmname 'vga_screenoff';
function VgaScreenOn : Integer; asmname 'vga_screenon';

function VgaSetColor(color: Integer) : Integer; asmname 'vga_setcolor';
function VgaDrawPixel(x, y: Integer) : Integer; asmname 'vga_drawpixel';
function VgaDrawLine(x1, y1, x2, y2: Integer) : Integer; asmname 'vga_drawline';
function VgaDrawScanLine(line: Integer; colors: PByteA) : Integer; asmname 'vga_drawscanline';
function VgaDrawScanSegment(colors: PByteA; x, y, lenght: Integer) : Integer; asmname 'vga_drawscansegment';
function VgaGetPixel(x, y: Integer) : Integer; asmname 'vga_getpixel';
function VgaGetScanSegment(colors: PByteA; x, y, length: Integer) : Integer; asmname 'vga_getscansegment';

function VgaGetCh : Integer; asmname 'vga_getch';

function VgaDumpRegs : Integer; asmname 'vga_dumpregs';

(* Extensions to VGAlib 1.2 *)

const
      (* blit flags *)
      HAVE_BITBLIT = 1;
      HAVE_FILLBLIT = 2;
      HAVE_IMAGEBLIT = 4;
      HAVE_HLINELISTBLIT = 8;
      HAVE_BLITWAIT = 16;

      (* other flags *)
      HAVE_RWPAGE = 1;         (* vga_setreadpage() / vga_setwritepage() available *)
      IS_INTERLACED = 2;       (* mode is interlaced *)
      IS_MODEX = 4;            (* ModeX style 256 colors *)
      IS_DYNAMICMODE = 8;      (* Dynamic defined mode *)
      CAPABLE_LINEAR = 16;     (* Can go to linear addressing mode. *)
      IS_LINEAR = 32;          (* Linear addressing enabled. *)
      EXT_INFO_AVAILABLE = 64; (* Returned modeinfo contains valid extended fields *)
      RGB_MISORDERED = 128;    (* Mach32 32bpp uses 0BGR instead of BGR0. *)

      (* As of this version 1.25 also used to signal if real RGB
       * (red first in memory) is used instead of BGR (Mach32 DAC 4)
       *)
      
      HAVE_EXT_SET = 256; (* vga_ext_set available *)

type VgaModeInfo = record
                     width             : Integer;
                     height            : Integer;
                     bytesperpixel     : Integer;
                     colors            : Integer;
                     linewidth         : Integer; (* scanline width in bytes *)
                     maxlogicalwidth   : Integer; (* maximum logical scanline width *)
                     startaddressrange : Integer; (* changeable bits set *)
                     maxpixels         : Integer; (* video memory / bytesperpixel *)
                     haveblit          : Integer; (* mask of blit functions available *)
                     flags             : Integer; (* other flags *)
 
                     (* Extended fields: *)
                     chiptype          : Integer; (* Chiptype detected *)
                     memory            : Integer; (* videomemory in KB *)

                     linewidth_unit    : Integer; (* Use only a multiple of this as parameter
                                                   * for set_logicalwidth and set_displaystart
                                                   *)

                     linear_aperture   : PByteA;  (* points to mmap secondary mem aperture of
                                                   * card (NIL if unavailable)
                                                   *)

                     aperture_size     : Integer; (* size of aperture in KB if size>=videomemory. 0
                                                   * if unavailable
                                                   *)

                     set_aperture_page : ^procedure (page : Integer);

                     (* if aperture_size<videomemory select a memory page *)
                     extensions: pointer;

                     (* points to copy of eeprom for mach32 *)
                     (* depends from actual driver/chiptype.. etc. *)
                   end;

     PVgaModeinfo = ^VgaModeInfo;

function VgaGetModeInfo(mode: Integer) : PVgaModeInfo; asmname 'vga_getmodeinfo';
function VgaGetDefaultMode : Integer; asmname 'vga_getdefaultmode';
function VgaGetCurrentMode : Integer; asmname 'vga_getcurrentmode';
function VgaGetCurrentChipset : Integer; asmname 'vga_getcurrentchipset';

type LongString = String[255];

function VgaGetModeName(mode: Integer) : LongString; (* see implementation *)
function VgaGetModeNumber(name: String) : Integer; (* see implementation *)
function VgaLastModeNumber : Integer; asmname 'vga_lastmodenumber'; (* also GLASTMODE refers to this *)
function VgaGetOptMode(x, y, colors, bytesperpixel, c: Integer) : Integer; asmname 'vga_getoptmode';

function VgaGetGraphMem : PByteA; asmname 'vga_getgraphmem';

procedure VgaSetPage(p: Integer); asmname 'vga_setpage';
procedure VgaSetReadPage(p: Integer); asmname 'vga_setreadpage';
procedure VgaSetWritePage(p: Integer); asmname 'vga_setwritepage';
procedure VgaSetLogicalWidth(p: Integer); asmname 'vga_setlogicalwidth';
procedure VgaSetDisplayStart(a: Integer); asmname 'vga_setdisplaystart';
procedure VgaWaitRetrace; asmname 'vga_waitretrace';
function VgaClaimVideoMemory(n: Integer) : Integer; asmname 'vga_claimvideomemory';
procedure VgaDisableDriverReport; asmname 'vga_disabledriverreport';
function VgaSetModeX : Integer; asmname 'vga_setmodeX';
function VgaInit : Integer; asmname 'vga_init'; (* Used to return void in svgalib <= 1.12. *)

(* function vga_getmousetype : Integer; asmname 'vga_getmousetype'; *)
(* Since this was just used in vgamouse.pas for VgaMouseInit
 * there's no reason to put it even here.
 *)

function VgaGetMonitorType : Integer; asmname 'vga_getmonitortype';

(* procedure VgaSetMouseSupport(s: Integer); asmname 'vga_setmousesupport'; *)
(* This procedure was called before VgaInit() to make the mouse support
 * available via options given in /etc/vga/libvga.config. For new mouse
 * support, ses vgamouse.pas
 *)

procedure VgaLockVC; asmname 'vga_lockvc';
procedure VgaUnLockVC; asmname 'vga_unlockvc';

function VgaOkToWrite : Integer; asmname 'vga_oktowrite';

procedure VgaCopyToPlanar256(virtualp: PByteA;
                             pitch, voffset, vpitch, w, h: Integer); asmname 'vga_copytoplanar256';
procedure VgaCopyToPlanar16(virtualp: PByteA;
                            pitch, voffset, vpitch, w, h: Integer); asmname 'vga_copytoplanar16';
procedure VgaCopyToPlane(virtualp: PByteA;
                         pitch, voffset, vpitch, w, h, plane: Integer); asmname 'vga_copytoplane';
function VgaSetLinearAddressing : Integer; asmname 'vga_setlinearaddressing';
procedure VgaSafetyFork(shutdown_routine: PProc); asmname 'vga_safety_fork';

const UNDEFINED = 0;
      VGA = 1;
      ET4000 = 2;
      CIRRUS = 3;
      TVGA8900 = 4;
      OAK = 5;
      EGA = 6;
      S3 = 7;
      ET3000 = 8;
      MACH32 = 9;
      GVGA6400 = 10;
      ARK = 11;
      ATI = 12;
      ALI = 13;
      MACH64 = 14;
      CHIPS = 15;
      APM = 16;
      NV3 = 17;
      ET6000 = 18;
      VESA = 19;
      MX = 20;
      PARADISE = 21;
      RAGE = 22;
      BANSHEE = 23;
      SIS = 24;
      I740 = 25;
      NEOMAGIC = 26;

      (* Hor. sync: *)
      MON640_60 = 0;   (* 31.5 KHz (standard VGA) *)
      MON800_56 = 1;   (* 35.1 KHz (old SVGA) *)
      MON1024_43I = 2; (* 35.5 KHz (low-end SVGA, 8514) *)
      MON800_60 = 3;   (* 37.9 KHz (SVGA) *)
      MON1024_60 = 4;  (* 48.3 KHz (SVGA non-interlaced) *)
      MON1024_70 = 5;  (* 56.0 KHz (SVGA high frequency) *)
      MON1024_72 = 6;

procedure VgaSetChipset(c: Integer); asmname 'vga_setchipset';
procedure VgaSetChipsetAndFeatures(c, par1, par2: Integer); asmname 'vga_setchipsetandfeatures';
procedure VgaGetTextFont(font: pointer); asmname 'vga_gettextfont';
procedure VgaPutTextFont(font: pointer); asmname 'vga_puttextfont';
procedure VgaSetTextModeRegs(regs: pointer); asmname 'vga_settextmoderegs';
procedure VgaGetTextModeRegs(regs: pointer); asmname 'vga_gettextmoderegs';

function VgaWhite : Integer; asmname 'vga_white';
function VgaSetEGAColor(c: Integer) : Integer; asmname 'vga_setegacolor';
function VgaSetRGBColor(r, g, b: Integer) : Integer; asmname 'vga_setrgbcolor';

procedure VgaBitBlt(srcaddr, destaddr, w, h, pitch: Integer); asmname 'vga_bitblt';
procedure VgaImageBlt(srcaddr: pointer; destaddr, w, h, pitch: Integer); asmname 'vga_imageblt';

procedure VgaFillBlt(destaddr, w, h, pitch, c: Integer); asmname 'vga_fillblt';
procedure VgaHLineListBlt(ymin, n: Integer; var xmin, xmax: Integer; pitch, c: Integer); asmname 'vga_hlinelistblt';
procedure VgaBlitWait; asmname 'vga_blitwait';
function VgaExtSet(what: Cardinal; ...) : Integer; asmname 'vga_ext_set';

function VgaAccel(operation: Cardinal; ...) : Integer; asmname 'vga_accel';
function VgaAddTiming(pixelClock, HDisplay, HSyncStart, HSyncEnd,
                      HTotal, VDisplay, VSyncStart, VSyncEnd, VTotal,
                      flags: Integer) : Integer; asmname 'vga_addtiming';
function VgaChangeTiming(pixelClock, HDisplay, HSyncStart, HSyncEnd,
                         HTotal, VDisplay, VSyncStart, VSyncEnd, VTotal,
                         flags: Integer) : Integer; asmname 'vga_changetiming';
function VgaGetCurrentTiming(var pixelClock, HDisplay, HSyncStart, HSyncEnd,
                             HTotal, VDisplay, VSyncStart, VSyncEnd,
                             VTotal, flags: Integer) : Integer; asmname 'vga_getcurrenttiming';
function VgaAddMode(xdim, ydim, cols, xbytes, bytespp: Integer) : Integer; asmname 'vga_addmode';
function VgaGuessTiming(x, y, clue, arg: Integer) : Integer; asmname 'vga_guesstiming';

const
      (* Valid values for what in vga_ext_set: *)
      VGA_EXT_AVAILABLE= 0; (* supported flags *)
      VGA_EXT_SET = 1;      (* set flag(s) *)
      VGA_EXT_CLEAR = 2;    (* clear flag(s) *)
      VGA_EXT_RESET = 3;    (* set/clear flag(s) *)
      VGA_EXT_PAGE_OFFSET = 4; (* set an offset for all subsequent vga_set*page() calls *)
                               (* Like: vga_ext_set(VGA_EXT_PAGE_OFFSET, 42); *)
                               (* returns the previous offset value. *)
      VGA_EXT_FONT_SIZE = 5;   (* the (maximal) size of the font buffer *)

      (* Valid params for VGA_EXT_AVAILABLE: *)
      VGA_AVAIL_SET = 0;   (* vga_ext_set sub funcs *)
      VGA_AVAIL_ACCEL = 1; (* vga_accel sub funcs *)
      VGA_AVAIL_FLAGS = 2; (* known flags for VGA_EXT_SET *)
      VGA_AVAIL_ROP = 3;   (* vga_accel ROP sub funcs *)
      VGA_AVAIL_TRANSPARENCY = 4; (* vga_accel TRANSPARENCY sub funcs *)
      VGA_AVAIL_ROPMODES = 5;     (* vga_accel ROP modes supported funcs *)
      VGA_AVAIL_TRANSMODES = 6;   (* vga_accel TRANSPARENCY modes supported *)

      (* Known flags to vga_ext_set() *)
      VGA_CLUT8 = 1;   (* 8 bit DAC entries *)

      (* Acceleration interface. *)
      (* Accel operations. *)
      ACCEL_FILLBOX = 1;           (* Simple solid fill. *)
      ACCEL_SCREENCOPY = 2;        (* Simple screen-to-screen BLT. *)
      ACCEL_PUTIMAGE = 3;          (* Straight image transfer. *)
      ACCEL_DRAWLINE = 4;          (* General line draw. *)
      ACCEL_SETFGCOLOR = 5;        (* Set foreground color. *)
      ACCEL_SETBGCOLOR = 6;        (* Set bground color. *)
      ACCEL_SETTRANSPARENCY = 7;   (* Set transparency mode. *)
      ACCEL_SETRASTEROP = 8;       (* Set raster-operation. *)
      ACCEL_PUTBITMAP = 9;         (* Color-expand bitmap. *)
      ACCEL_SCREENCOPYBITMAP=  10; (* Color-expand from screen. *)
      ACCEL_DRAWHLINELIST = 11;    (* Draw horizontal spans. *)
      ACCEL_SETMODE = 12;          (* Set blit strategy. *)
      ACCEL_SYNC = 13;             (* Wait for blits to finish. *)
      ACCEL_SETOFFSET = 14;        (* Set screen offset *)
      ACCEL_SCREENCOPYMONO = 15;   (* Monochrome screen-to-screen BLT. *)
      ACCEL_POLYLINE = 16;         (* Draw multiple lines. *)
      ACCEL_POLYHLINE = 17;        (* Draw multiple horizontal spans. *)
      ACCEL_POLYFILLMODE = 18;     (* Set polygon mode. *)

      (* Corresponding bitmask. *)
      ACCELFLAG_FILLBOX = $1;            (* Simple solid fill.*)
      ACCELFLAG_SCREENCOPY = $2;         (* Simple screen-to-screen BLT. *)
      ACCELFLAG_PUTIMAGE = $4;           (* Straight image transfer. *)
      ACCELFLAG_DRAWLINE = $8;           (* General line draw. *)
      ACCELFLAG_SETFGCOLOR = $10;        (* Set foreground color. *)
      ACCELFLAG_SETBGCOLOR = $20;        (* Set bground color. *)
      ACCELFLAG_SETTRANSPARENCY = $40;   (* Set transparency mode. *)
      ACCELFLAG_SETRASTEROP = $80;       (* Set raster-operation. *)
      ACCELFLAG_PUTBITMAP = $100;        (* Color-expand bitmap. *)
      ACCELFLAG_SCREENCOPYBITMAP = $200; (* Color-exand from screen. *)
      ACCELFLAG_DRAWHLINELIST = $400;    (* Draw horizontal spans. *)
      ACCELFLAG_SETMODE = $800;          (* Set blit strategy. *)
      ACCELFLAG_SYNC = $1000;            (* Wait for blits to finish. *)
      ACCELFLAG_SETOFFSET = $2000;       (* Set screen offset *)
      ACCELFLAG_SCREENCOPYMONO = $4000;  (* Monochrome screen-to-screen BLT. *)
      ACCELFLAG_POLYLINE = $8000;        (* Draw multiple lines. *)
      ACCELFLAG_POLYHLINE = $10000;      (* Draw multiple horizontal spans. *)
      ACCELFLAG_POLYFILLMODE = $20000;   (* Set polygon mode. *)

      (* Mode for SetTransparency. *)
      DISABLE_TRANSPARENCY_COLOR = 0;
      ENABLE_TRANSPARENCY_COLOR = 1;
      DISABLE_BITMAP_TRANSPARENCY = 2;
      ENABLE_BITMAP_TRANSPARENCY = 3;

      (* Flags for SetMode (accelerator interface). *)
      BLITS_SYNC = 0;
      BLITS_IN_BACKGROUND = $1;

      (* Raster ops. *)
      ROP_COPY = 0;   (* Straight copy. *)
      ROP_OR = 1;     (* Source OR destination. *)
      ROP_AND = 2;    (* Source AND destination. *)
      ROP_XOR = 3;    (* Source XOR destination. *)
      ROP_INVERT = 4; (* Invert destination. *)

      (* For the poly funcs *)
      ACCEL_START = 1;
      ACCEL_END = 2;

(* vga_waitevent isn't to be written here.
 * Take a look at GNU-Pascal sources to see the implementation
 * of IOSelect, which allows to select on several files
 *)

procedure vga_runinbground(stat: Integer; ...); asmname 'vga_runinbackground';
const (* Bground running *)
      VGA_GOTOBACK = -1;
      VGA_COMEFROMBACK = -2;

function vga_runinbground_version : Integer; asmname 'vga_runinbackground_version';



IMPLEMENTATION (**********************************************************)



function VgaHasMode(mode: Integer) : Boolean;
function svgalib_vga_hasmode(mode: Integer) : Integer; asmname 'vga_hasmode';
begin
  VgaHasMode:= ( svgalib_vga_hasmode(mode) <> 0 );
end;

function VgaGetModeName(mode: Integer) : LongString;
function svgalib_vga_getmodename(mode: Integer) : CString; asmname 'vga_getmodename';
begin
  VgaGetModeName:= CString2String(svgalib_vga_getmodename(mode));
end;

function VgaGetModeNumber(name: String) : Integer; (* see implementation *)
function svgalib_vga_getmodenumber(name: CString) : Integer; asmname 'vga_getmodenumber';
begin
  VgaGetModeNumber:= svgalib_vga_getmodenumber(String2CString(name));
end;

end.


syntax highlighted by Code2HTML, v. 0.8.8b