OK, its not a documentation, because I dont read any documentation ;-( . I have only copy all interface parts with comments in one big file. Please look in the demo sources and change it to learn, how to handle. Then, you can read the comments for using and handling the functions. Or, you can get the big documenation XLIBDOC.ZIP. Many Textformats like MS-Write, WOrd, Lotus and so on. The functionsnames are not all correct, because it is for the asm/C version of XLib. The File XLib_ALL.DOC is a overview about all units ! X_MAIN.PAS Init Mode X. Firstly, you can choose between many physikaly resolution (all in X_Const) by selecting with constant like X_MODE_360x240 or value 3. Then you have to say the viruall schreenwidth. function x_set_mode(mode,logicalscrwidth:Word):Integer; Return count of avaible modi. function x_Max_Modi:Byte; Set X and Y to GetMaxX and GetMaxY in the mode Mode procedure x_Mode_Info(Mode:Byte;var X,Y:Word); set TextMode back. procedure x_Text_Mode; Set upper, left Corner of activ page. You set the variable ScreenOfs, and all graphic function draw to this new screenparams. procedure x_set_activ_start_addr(x,y:Word); Set upper, left Corner of visible pager. So you can set the visible screen. So you can draw to a other screen than the visible ! procedure x_set_visible_start_addr(x,y:Word); Set Splitscreen if line>=GetMaxY then no_splitScreen. Switch a bar from the botton screen. Now, you can draw at absolut (0,0) to the splitscreen. procedure x_set_splitscreen(Line : Word); Set Clipping window for bitmaps. All Bitmapfunction with the prefix clip will be clipet on the border of this clip_rectangle. procedure x_set_clip_rect(left,top,right,bottom:Word); Clear the whole virtuell Screen (All pages). procedure X_ClearAll; Clear from Line 1 to Line 2 procedure ClearScreen(Line1,Line2,Color:Word); Put a pixel in color on activ page. procedure PutPixel(x,y:Integer;Color:Byte); Get color from pixel at position (x,y). function GetPixel(x,y: Integer): Integer; Draw a Line. procedure Line(x1,y1,x2,y2,Color:Word); Draw a rectangle (build with normal lines - not filled ) procedure rectangle(x1,y1,x2,y2,Color:Word); Draw a tritangle (build with normal lines - not filled ) procedure triangle(x1,y1,x2,y2,x3,y3,Color:Word); Set the grafigcursor. procedure MoveTo(x,y:Integer); Draw a Line from Grafikcursor (Turtlegrafic) procedure LineTo(x,y,Color:Integer); Draw a circle. (it is a elipse, if pixel arn't square-pixel Mode_320x480) procedure x_circle(x,y,r,Color:Word); Draw a filled circle. procedure x_filled_circle(x,y,r,Color:Word); UNIT X_BREAK.PAS - Leitet Ctrl+Break auf eigene procedure P um. P muá mit {$F+} als eine far- procedure deklariert worden sein. - Init the Ctrl+Break-interrupt to your procedure. P have to far, this means enclosed by {$F+} and {$F-}. procedure InitBreak(P:BreakProc); - Fr InitBreak eine Default- procedure, um ein Programm zu beenden. default Break- procedure to end your programm. procedure MyDummy; - Setzt den alten Ctrl+Break-Vektor wieder her. (Auch in INTR-Proc. drin) Set the old Ctrl+Break. procedure RestoreBreak; UNIT X_KEYS.PAS Some importend key-codes ! const NULL = #0 ; BackSpace = #8 ; Back = #8 ; TAB = #9 ; Enter = #13; ESC = #27; Space = #32; vor alle n„chsten Codes kommt immer ein "NULL"-Zeichen ( #0 ) ! The next key-Codes are first a chr(0), following the code ! F1 = ';'; F2 = '<'; F3 = '='; F4 = '>'; F5 = '?'; F6 = '@'; F7 = 'A'; F8 = 'B'; F9 = 'C'; F10 = 'D'; links = 'K'; left = links; rechts = 'M'; right = rechts; runter = 'P'; down = runter; hoch = 'H'; up = hoch; Ende = 'O'; Home = 'G'; PgUp = 'I'; PgDown = 'Q'; Ins = 'R'; Del = 'S'; - Liest Tasten ein und bergibt diese. - Get a key, if pressed or in Buffer. function ReadKeys:Char; - Gibt true zurck, wenn Readkeys einen Wert bereit h„lt. - true, if key pressed or key from Set_Key_Makro in Buffer (see keypressed)*) function keysPressed:Boolean; - Wartet so lange, bis die entsprechende Taste gedckt wurde . - Wait, until key a is pressed. procedure Wait_Key(A:Char); - Simuliert Tastenbet„tigung (in der Reihenfolge des Strings) - Emutaled key-pressing procedure Set_Key_Makro(S:String); - Clear the Set_Key_Makro-Buffer . procedure Clear_Buffer; UNIT X_DETECT.PAS Some imported constantes. const pz8086 = 0 ; Processor pz8088 = 1 ; pzV20 = 2 ; pzV30 = 3 ; pz80186 = 4 ; pz80188 = 5 ; pz80286 = 6 ; pz80386 = 7 ; pz80486 = 8 ; cp_no = 0 ; Co-Processor cp8087 = 1 ; cp80287 = 2 ; cp80387 = 3 ; He is in all 486DX ! NONE = 0 ; Video-Card MDA = 1 ; CGA = 2 ; EGAMono = 3 ; EGAColor = 4 ; VGAMono = 5 ; VGAColor = 6 ; MCGAMono = 7 ; MCGAColor = 8 ; BUS_MOUSE = 1 ; Mouse Driver SERIAL_MOUSE = 2 ; INPORT_MOUSE = 3 ; PS2_MOUSE = 4 ; HP_MOUSE = 5 ; Return the typ of the wanted element (See in Demo3_TP) . function x_graphics_card : Word; function x_mousedriver : Boolean; function x_processor : Word; function x_coprocessor : Word; Strings for constants of pzXXX,cpXXX and Video-Modes. const pzNames : Array[0..8] of String[11] = ('Intel 8086' ,'Intel 8088','NEC V20','NEC V30','Intel 80186','Intel 80188','Intel 80286','Intel 80386','Intel 80486'); Example : WriteLn('CPU :',pzNames[GetCPU]); cpNames : Array[0..3] of String[11] = ('none','Intel 8087','Intel 80287','Intel 80387'); VideoNames : Array[0..8] of String[10] = ('NONE','MDA','CGA','EGA Mono','EGA Color','VGA Mono','VGA Color','MCGA Mono','MCGA Color'); UNIT X_POLYGO.PAS type Point = record x,y:Word; end; Draw a filled triangle to the screen. procedure x_triangle(X0,Y0,X1,Y1,X2,Y2,Color:Word); Draw a triangle to the screen - the color is declared in one vertical row. See demo in x_demo , part_D. procedure x_Coltriangle(X0,Y0,X1,Y1,X2,Y2:Word;var ColTable); Draw a filled polygon to screen. Convex polygons are not supported. procedure x_poly(Var P:Array of Point;num,Color:Word); The same like x_poly, but with colors like in x_Coltriangle. procedure x_Colpoly(Var P:Array of Point;num:Word;var ColTable); UNIT X_CONST.PAS All variables and constantes for XLib ! const AC_INDEX = $03c0; Attribute controller index register MISC_OUTPUT = $03c2; Miscellaneous Output register SC_INDEX = $03c4; Sqence Controller Index GC_INDEX = $03ce; Graphics controller Index CRTC_INDEX = $03d4; CRT Controller Index DAC_READ_INDEX = $03c7; DAC_WRITE_INDEX = $03c8; DAC_DATA = $03c9; INPUT_STATUS_0 = $03da; Input status 0 register SCREEN_SEG = $a000; segment of display memory in mode X MAP_MASK = $02; index in SC of Map Mask register READ_MAP = $04; index in GC of the Read Map register BIT_MASK = $08; index in GC of Bit Mask register OVERFLOW = $07; CRTC overflow register index MAX_SCAN_LINE = $09; CRTC maximum scan line register index ADDR_HIGH = $0c; Index of Start Address High reg in CRTC*) ADDR_LOW = $0d; Low CRTC_OFFSET = $13; CRTC offset register index UNDERLINE = $14; CRTC underline location register index*) MODE_CONTROL = $17; CRTC mode control register index LINE_COMPARE = $18; CRTC line compare reg. index (bits 0-7 of split screen scan line AC_MODE_CONTROL = $10; Index of Mode COntrol register in AC PEL_PANNING = $13; Pel panning register index in AC PATTERN_BUFFER = $0fffc; offset in screen memory of pattern buffer OK = 0; ERROR = 1; GetMaxColor = 255; X_MODE_320x200 = 0; X_MODE_320x240 = 1; X_MODE_360x200 = 2; X_MODE_360x240 = 3; X_MODE_376x282 = 4; X_MODE_320x400 = 5; X_MODE_320x480 = 6; X_MODE_360x400 = 7; X_MODE_360x480 = 8; X_MODE_360x360 = 9; X_MODE_376x308 = 10; X_MODE_376x564 = 11; X_BACKWARD = 0; X_FORWARD = 1; X_MODE_INVALID = -1; type Palette = Array[0..255,0..2] of Byte; Global variables - X_MAIN exports var InGraphics :Boolean;non zero if in X graphics mode CurrXMode :word; contains current X graphics mode id ScrnPhysicalByteWidth :word; Physical screen width in bytes ScrnPhysicalPixelWidth :word; Physical screen width in pixels ScrnPhysicalHeight :word; Physical screen height in pixels ErrorValue :byte; Error return value GetMaxX :Word absolute ScrnPhysicalPixelWidth; GetMaxY :Word absolute ScrnPhysicalHeight; SplitScrnOffs :word; Offset in VRAM of split screen SplitScrnScanLine :word; Scan line split screen starts at initially. Resizing the split scrn using the other functions does not change this value SplitScrnVisibleHeight :word; Height of the visible portion of the*) split screen. SplitScrnActive :Boolean; Page0_Offs :word; Offset in VRAM of main virt. screen Page1_Offs :word; Offset in VRAM of 2nd virt. screen Page2_Offs :Word; ScrnLogicalByteWidth :word; Virtual screen width in bytes ScrnLogicalPixelWidth :word; Virtual screen width in pixels ScrnLogicalHeight :word; Virtual screen height in pixels MaxScrollX :word; Max X position of physical screen within virtual screen MaxScrollY :word; Max Y position of physical screen within virtual screen DoubleBufferActive :word; Indicates whether double buffering is active VisiblePageIdx :word; Index number of visible page 0 or 1 VisiblePageOffs :word; Offset of Hidden Pg | only valid ScreenOfs :word absolute VisiblePageOffs; HiddenPageOffs :word; Offset of Visible Pg| for D.B. mode NonVisual_Offs :word; Offset of first non-visible VRAM BGSaveOffs :Word; TopClip :word; Clipping rectangle BottomClip :word; LeftClip :word; RightClip :word; PhysicalStartPixelX :word; Coordinates of physical (visible) PhysicalStartByteX :word; screen relative to the virtual PhysicalStartY :word; screen's U.L. corner Gray0,Gray1,Gray2,Gray3,Gray4,Gray5:Byte; procedure WaitVsyncStart; procedure WaitVsyncEnd; UNIT X_FILEIO.PAS Many function to manage filehandling very easy. First, F_Size ,F_Open_Read, F_Open_Write and F_Close are the same like the functions in unit Dos, but they support the Masterfile. If you have made ready your game, many little files are in your directory. With Make_MF you can copy into one big file, the MasterFile. After this, you add to begin of your programm Init_MasterFile(Name). Now, all F_...- function will look firstly in the filelist of MasterFile, if your wanted file is in the MasterFile. If true, your File-Variable will be set to MasterFile and Seek to begin of your file. Ok, you can't reading two file from MasterFile, but other operation will quicker ! result = 0, if Name not exist, else Size in Bytes. MasterFile supported. function F_Size(Name:String):LongInt; Open an File for Read; True,if opens. MasterFile supported. function F_Open_Read(var F:File;Name:String):Boolean; Open an File for Write. procedure F_Open_Write(var F:File;Name:String); Close an File. MasterFile supported. procedure F_Close(var F:File); Make every Char of S an Uppercase 'HaaLLoo' -> 'HAALLOO' function Upper(S:String):String; Delete and Add, if incorrect or non Ext in FileName S. Only_one_Ext('Name.TXT','DOC') -> 'NAME.DOC' Only_one_Ext('test','DaT') -> 'TEST.DAT' function Only_one_Ext(S:String;Ext:String):String; Open MasterFile and load Filelist. function Init_MasterFile(Name:String):Boolean; Close MasterFile, all function are now normal file- functions. procedure Close_MasterFile; If you dont know, how to read from F:File with BlockRead, use these functions, because the MasterFile is type File. function Read_Byte (var F:File) :Byte; Read a Byte function Read_Word (var F:File) :Word; Read a Word (2 Bytes) function Read_LongInt(var F:File) :LongInt; Read a LongInt (4 Bytes) function Read_Line (var F:File) :String; Read a String (S[0]...) function Read_String (var F:File) :String; Read a Line (Textfile) procedure Write_Line (Var F:File;S:String); Only for creating own Masterfile - please look in demo Make_MF. procedure Init_File_List; function Add_File_List(Name:String):Boolean; procedure Kill_File_List; function Get_File_item_count:Word; procedure Make_MasterFile(Name:String); UNIT X_BITMAP.PAS Bitmap procedures. (load,save,put,convert) - Planar Bitmap (pbm) functions - System Ram <-> Video Ram This module implements a set of functions to operate on planar bitmaps. Planar bitmaps as used by these functions have the following structure: BYTE 0 The bitmap width in bytes (4 pixel groups) range 1..255 BYTE 1 The bitmap height in rows range 1..255 BYTE 2..n1 The plane 0 pixels width*height bytes BYTE n1..n2 The plane 1 pixels width*height bytes BYTE n2..n3 The plane 2 pixels width*height bytes BYTE n3..n4 The plane 3 pixels width*height bytes or in Pascal : record pbm of X_Byte,Y_Pixel : Byte; Plane0,Plane1,Plane2,Plane3 : Array[1..Y_Pixel,1..X_Byte] of Byte; end; But these Stucture are not interessting, because all pbm's are used from pure asm-Procedures. These functions provide the fastest possible bitmap blts from system ram to video and further, the single bitmap is applicable to all pixel allignments. The masked functions do not need separate masks since all non zero pixels are considered to be masking pixels, hence if a pixel is 0 the corresponding screen destination pixel is left unchanged. - Linear Bitmap (lbm) can only converted from/in pbm, but the are easy to change with Turbo Pascal. record lbm of X,Y : Byte; Pixel : Array[1..Y,1..X] of Byte; end; - The VBM format implements yet another type of bitmap to complement planar and compiled bitmaps, VRAM based bitmaps. If a 4 cylinder car is analagous to planar bitmaps, that is thrifty on memory consumption but low performance and and a V8 is analagous to Compiled bitmaps, memory guzzlers that really fly, then VRAM based bitmaps are the 6 cylinder modest performers with acceptable memory consumption. To summarise their selling points, VBM's are moderately fast with fair memory consumption, and unlike compiled bitmaps, can be clipped. The disadvantages are that they are limited by the amount of free video ram and have a complex structure. The VRAM bitmap format is rather complex consisting of components stored in video ram and components in system ram working together. This complexity necessitates the existence of a creation function "x_lbm_to_vbm" which takes an input linear bitmap and generates the equivalent VBM (VRAM Bit Map). VBM structure: WORD 0 Size Total size of this VBM structure in bytes WORD 1 ImageWidth Width in bytes of the image (for all alignments) WORD 2 ImageHeight Height in scan lines of the image WORD 3 Alignment 0 ImagePtr Offset in VidRAM of this aligned image +--WORD 4 MaskPtr Offset (within this structure's DS) of | . alignment masks | . | . | WORD 9 Alignment 3 ImagePtr Offset in VidRAM of this aligned image +|--WORD 10 MaskPtr Offset (within this structure's DS) of || alignment masks || |+->BYTE 21 (WORD 11) -------+-- Image masks for alignment 0 | . | | . | | BYTE 21 + ImageWidth*ImageHeight -----+ | | . | . (similaly for alignments 1 - 2 ) | . | +-->BYTE 21 + 3*ImageWidth*ImageHeight + 1-+-- Image masks for alignment 3 . | . | BYTE 21 + 4*(ImageWidth*ImageHeight) --+ . . << Similarly for alignments 2 and 3 >> . . BYTE 21 + 4*(ImageWidth*ImageHeight) ------------- (And dont forget the corresponding data in video ram) - Screenfiles (scr) are simple Screen-Dumps. Byte 0+Byte 1 : Width in Bytes (width*4=Pixel) Byte 2+Byte 3 : Height in Pixel Byte 4 : Boolean, if True, then follow Byte 4..Byte 4+768 Palette Byte n : Plane 0 - 3 used by Gif2SCR and the procedure x_load_scr var Bitmap could be an Array of Byte or a pointer (MUST allocated !) Some of the procedure work with Heap-memory. No Size checking included ! ****************************** PBM ************************************** Put Planar Bitmap from System RAM to Pos.(X,Y). procedure x_put_pbm(X,Y:Word;var Bitmap); Put Planar Bitmap from System RAM to Pos.(X,Y) by skipping all 0-Pixel. procedure x_put_masked_pbm(X,Y:Word;var Bitmap); All put procedures with clipping. procedure x_put_pbm_clipy(X,Y:Word;Var Bitmap); procedure x_put_pbm_clipx(X,Y:Word;Var Bitmap); procedure x_put_pbm_clipxy(X,Y:Word;Var Bitmap); procedure x_put_masked_pbm_clipy(X,Y:Word;Var Bitmap); procedure x_put_masked_pbm_clipx(X,Y:Word;Var Bitmap); procedure x_put_masked_pbm_clipxy(X,Y:Word;Var Bitmap); Copy Planar Bitmap from Pos.(X1,Y1,X2,Y2) to System Ram. procedure x_get_pbm(X1,Y1,X2,Y2:Word;var Bitmap); Return the Memory for the Bitmap to store in System Ram. function x_pbm_size(x1,y1,x2,y2:Word):Word; function x_sizeof_pbm(var BitMap):Word; procedure x_get_pbm_sizeXY(var x,y:Word;var Bitmap); Save Planar Bitmap to File with Name. Name with .pbm automatical procedure x_save_pbm(var Name:String;var Bitmap); Load Planar Bitmap to File with Name. MasterFile supported procedure x_load_pbm(var Name:String;var Bitmap); Load the Bitmap and put it to Pos.(x,y) procedure x_load_put_pbm(X,Y:Word;Name:String); Get Bitmap from Screen and save it to File Name. procedure x_get_save_pbm(X1,Y1,X2,Y2:Word;Name:String); Converted Linear Bitmap to Planar Bitmap. True,if succesful. function x_lbm_to_pbm(var src_bm,dest_pbm):Boolean; Converted Planar Bitmap to Linear Bitmap. True,if succesful. function x_pbm_to_lbm(var src_pbm,dest_bm):Boolean; ****************************** LBM ***************************************) Because LBM would be very slow, it dont exist any Put-procedure. procedure x_save_lbm(var Name:String;var Bitmap); procedure x_load_lbm(var Name:String;var Bitmap); function x_lbm_size(x1,y1,x2,y2:Word):Word; function x_sizeof_lbm(var BitMap):Word; ****************************** CBM ************************************** Converted Planar Bitmap into Compiled Bitmap procedure x_pbm_to_cbm(logical_width:Word;Var pbm,cbm); Return the used size of the cbm from the source pbm. function x_sizeof_cpbm (logical_width:Word;Var pbm):Word; Put Compiled Bitmap from System RAM to Pos (X,Y) only as masked version procedure x_put_cbm(XPos,YPos:Word;Var Sprite); ******************************* IBM *************************************** Converted Planar Bitmap into Interpreted Bitmap procedure x_pbm_to_ibm(Var pbm,ibm); Return the used size of the ibm from the source pbm. function x_sizeof_ipbm (Var pbm):Word; Put Interpreted Bitmap from System RAM to Pos (X,Y) . procedure x_put_ibm(X,Y:Word;Var ibm); Put Interpreted Bitmap from System RAM to Pos (X,Y) . procedure x_put_masked_ibm(X,Y:Word;Var ibm); ****************************** VBM ************************************** Converted Linear Bitmap into Video Bitmap function x_lbm_to_vbm(Var lbm;Var VramStart:Word):Pointer; Put a VBM-Bitmap to screen. procedure x_put_masked_vbm(X,Y:Word;var SrcVBM); procedure x_put_masked_vbm_clipx(X,Y:Word;Var SrcVBM); procedure x_put_masked_vbm_clipy(X,Y:Word;Var SrcVBM); procedure x_put_masked_vbm_clipxy(X,Y:Word;Var SrcVBM); unit X_MENU.PAS procedures to make a pull-down-menu for mouse and/or keys type Menu_Typ = record ... set values to your M:Menu_Typ C1 is the upper,left Shadow C2 Background of Menu C3 is the lower,right Shadow Selected_C Color of scrollbar Text_Hi Text-Color Text_Lo Shadow of Text MouseMask look in const - part of X_Button procedure X_Init_Menu(var M:Menu_Typ; Menu-Variable C1,C2,C3,Selected_C,TextHi,TextLo:Byte; Colors MouseMask:Byte); s.X_Button After X_Init_Menu, you can add some textlines. For Color Text, see syntax in E_WriteColor in X_Text. procedure X_Add_Menu (var M:Menu_Typ;ID:ID_Typ;S:String;KeyChar:Char); Deallocate all line of M:Mynu_Typ. procedure X_Kill_Menu(var M:Menu_Typ); Draw Menu on Screen. procedure X_Show_Menu(var M:Menu_Typ;x,y:Word); return ID, if in this moment one line selected by mouse or key, other 0. function Get_Selected_MenuLine(var M:Menu_Typ):ID_Typ; wait for selecting any line and return ID, or 0 if breaked by ESC. function Wait_Selected_MenuLine(var M:Menu_Typ):ID_Typ; UNIT X_RECT.PAS rectangle solid colour fill routine. procedure x_rect_fill(X1,Y1,X2,Y2,Color:Word); procedure x_rect_fill_clipped(X1,Y1,X2,Y2,Color:Word); BOX is the same like x_rect_fill, but it's shorter to write ;-). procedure Box(x1,y1,x2,y2,Color:Word); Make a ShadowBox - used by X_Button. C1 is upper,left Angle, C3 is lower,right Angle and C3 the Box. procedure Shadow_Box(x1,y1,x2,y2,C1,C2,C3:Word); rectangle 4x4 pattern fill routine. procedure x_rect_pattern(X1,Y1,X2,Y2:Word;Var Pattern); procedure x_rect_pattern_clipped(X1,Y1,X2,Y2:Word;Var Pattern); Display memory to display memory copy routine. Left edge of source rectangle modulo 4 must equal left edge of destination rectangle modulo 4 Works on all VGAs. Ignoring activ_screen->absolute Pos. procedure x_cp_vid_rect(SrcX1,SrcY1,SrcX2,ScrY2,DestX1,DestY1:Word); Copy a rectangular region of a VGA screen, with x coordinates rounded to the nearest byte -- source and destination may overlap. procedure x_shift_rect(ScrX1,ScrY1,ScrX2,ScrY2,DestX1,DestY1:Word); UNIT X_PAL.PAS ---------------------------------------------------------------------- Read DAC palette into annotated type buffer with interrupts disabled ie BYTE colours to skip, BYTE colours to set, r1,g1,b1,r1,g2,b2...rn,gn,bn WARNING: memory for the palette buffers must all be pre-allocated Written by Themie Gouthas ---------------------------------------------------------------------- procedure x_get_pal_struc(Var PalBuff;NumColors,StartColor:Word); ---------------------------------------------------------------------- Read DAC palette into raw buffer with interrupts disabled ie BYTE r1,g1,b1,r1,g2,b2...rn,gn,bn WARNING: memory for the palette buffers must all be pre-allocated Written by Themie Gouthas ---------------------------------------------------------------------- procedure x_get_pal_raw(Var PalBuff;NumColors,StartColor:Word); ---------------------------------------------------------------------- Write DAC palette from annotated type buffer with interrupts disabled ie BYTE colours to skip, BYTE colours to set, r1,g1,b1,r1,g2,b2...rn,gn,bn If DoWait true, VSyncWait will start. Written by Themie Gouthas ---------------------------------------------------------------------- procedure x_put_pal_struc(Var CompPalBuff;DoWait:Boolean); ---------------------------------------------------------------------- Write DAC palette from annotated type buffer with interrupts disabled starting at a new palette index ie BYTE colours to skip, BYTE colours to set, r1,g1,b1,r1,g2,b2...rn,gn,bn If DoWait true, VSyncWait will start. WARNING: memory for the palette buffers must all be pre-allocated Written by Themie Gouthas ---------------------------------------------------------------------- procedure x_transpose_pal_struc(Var CompPalBuff;StartColor:Word;DoWait:Boolean); ---------------------------------------------------------------------- Write DAC palette from raw buffer with interrupts disabled ie BYTE r1,g1,b1,r1,g2,b2...rn,gn,bn If DoWait true, VSyncWait will start. Written by Themie Gouthas ---------------------------------------------------------------------- procedure x_put_pal_raw(Var PalBuff;NumColors,StartColor:Word;DoWait:Boolean); ---------------------------------------------------------------------- Set the RGB setting of a vga color Written by Themie Gouthas ---------------------------------------------------------------------- procedure x_set_rgb(ColorIndex,R,G,B:Byte); ---------------------------------------------------------------------- Rotate annotated palette buffer entries Direction : 0 = backward 1 = forward Written by Themie Gouthas ---------------------------------------------------------------------- procedure x_rot_pal_struc(Var PalBuff;Direction:Word); ---------------------------------------------------------------------- Rotate raw palette buffer Direcction : 0 = backward 1 = forward Written by Themie Gouthas ---------------------------------------------------------------------- procedure x_rot_pal_raw(Var PalBuff;Direction,NumColors:Word); ---------------------------------------------------------------------- Copy palette making intensity adjustment x_cpcontrast_pal_struc(char far *src_pal, char far *dest_pal, unsigned char Intensity) WARNING: memory for the palette buffers must all be pre-allocated Written by Themie Gouthas ---------------------------------------------------------------------- procedure x_cpcontrast_pal_struc(Var PalSrcBuff,PalDestBuff;Intensity:Byte); ---------------------------------------------------------------------- Write DAC palette from annotated type buffer with specified intensity ie BYTE colours to skip, BYTE colours to set, r1,g1,b1,r1,g2,b2...rn,gn,bn x_put_contrast_pal_struc(char far * pal, unsigned char intensity) Designed for fading in or out a palette without using an intermediate working palette buffer ! (Slow but memory efficient ... OK for small pal strucs} Written by Themie Gouthas ---------------------------------------------------------------------- procedure x_put_contrast_pal_struc(Var CompPalBuff;Intensity:Byte); This procedure set a RGB (6-7-6 Level), which are used also from some professional Programms like Photo Styler or default pal of BEX ;-) procedure x_Set_RGB_pal; Simply set_pal to set all colors are (0,0,0) . procedure x_set_Black_pal; Soften Set_Pal in Black Screen. procedure x_Dark2Pal(var Colors); Soften Set_Pal from Black Screen. procedure x_Pal2Dark(var Colors); UNIT X_MOUSE.PAS Basic Mouse Routines for Mode X documentation in german and english Es werden die letzten 42 Bytes des Bildschirmspeicher zum schnellen Zwischenschpeichern des Maushintergrunds genutzt ! The last 42 Bytes of Video-RAM are used to same the Mouse - Pointer BackGround . var ButtonStatus, MouseX, Say any time the actual Mouse-position ! MouseY : Word; OldMouseTyp, True, wenn Mausz. sonst nur zur Haelfe geht if your MousePointer only go to the hald of screen, set it to true. MouseAction :Boolean; Auf true gesetzt, wenn Maus bewegt wird Rcksetzen ist dem Programmierer berlassen. It will be true, if MousePointer moved. You can it use it, by set to false and wait. const MyMouseForm : Array[1..14] of Byte = ($01,$03,$07,$0f,$1f,$3f,$7f,$ff,$ff,$1c,$3c,$7c,0,0); - Setzt den Mauszeiger auf Unsichtbar - Hide the mousepointer procedure HideMouse; - Setzt den Mauszeiger auf sichtbar - Show the mousepointer procedure ShowMouse; - Beim Zeichnen auf activ_page muss der Mauszeiger insichtbar sein. - While drawing on activ_page mousepointer have to be hiding. - Installiert einen Maus-event fr Mode X. - Install mouseevent for mode X. procedure MyMouseInit; - Deinstalliert den Maus-event. - Deinstall the mousevent. procedure MyMouseDestroy; - Setzt einen MausCursor - eine Bitmaske. - set a mousecursor - bitmask. procedure DefineMouseCursor(var MouseDef : Array of Byte;Color : Byte); - Setzt das Mausfenster, indem sich der Mauszeiger aufhalten kann. - Set the mousewindow. Mousepointer can't leave this window. procedure SetMouseWindow(x1,y1,x2,y2:Word); - Setzt den MausZeiger auf die Position (x,y). - set the mousepointer to (x,y). procedure SetPosMouse(x,y:Integer); - Ist true, wenn die Maus unsichtbar ist. Wenn nach ShowMouse true -> ist keine Maus installiert. - Return true, if mOuse hide. function IsMouseHidden:Boolean; - Gibt true, wenn der Mauszeiger in diesem Rechteck ist. - Return true, if mousepointer in this rectangle. function InBox(x1,y1,x2,y2:Word):Boolean; X_TEXT.PAS Text procedures. Ok, we have two serveral user fonts ! How to handle ? The old 8xn-fonts width could max. 8 Pixels draw in the width. If FontType = 1, it is a 16x16-bigfont ! 8xn- normal font structure : Byte 0 : FirstChar Byte 1 : FontType=0 => 8xn Font Byte 3 : CharHeight Byte 4 : CHarWidth if zero, font will be variable Blocks from FirstChar to n : Byte0..Byte CharHeight-1 : CharacterByte horizontaly Byte CharHeight : CharWidth, if Byte 4=0 UPDATE: Variable width fonts are now available (up to 8/16 pixels max) If the Width byte in the font header is 0 then it is assumed that the font is variable width. For variable width fonts each characters data is followed by one byte representing the characters pixel width. 16xn-bigfont structure : Byte 0 : FirstChar Byte 1 : FontType=1 => 16x16 Font Byte 3 : CharHeight Byte 4 : CHarWidth if zero, font will be variable Index_Array : [FirstChar..134] : Word Bit 0..11: (0..4095) Offset to begin of Chardata if offset 0, Character not defined -> CharWidth:=0 Bit 12..15: (0..15) CharWidth Byte n..eof : all CharacterWord verticaly order by Index_Array Init the Fontpointers for ROM8x8 and ROM8x14 (font 0 and 1). procedure x_text_init; ---------------------------------------------------------------------- x_set_font - Mode X Set current font for text drawing x_set_font(FontID:Word) PARAMETERS FontID 0 = VGA ROM 8x8 1 = VGA ROM 8x14 2 = User defined bitmapped font , FontType WARNING: A user font must be registered before setting FontID 2 Written by Themie Gouthas ---------------------------------------------------------------------- procedure x_set_font(FontId:Word); ---------------------------------------------------------------------- x_register_userfont - Mode X register user font x_register_userfont(Var user_font); NOTES registering a user font deregisters the previous user font User fonts may be at most 8 or 16 pixels wide (use FEX). Written by Themie Gouthas ---------------------------------------------------------------------- procedure x_register_userfont(Var FontToRegister); ---------------------------------------------------------------------- x_char_put - Mode X Draw a text character at the specified location x_char_put(ch:Char;x,y,Color:Word) PARAMETERS ch char to draw x,y screen coords at which to draw ch Color Color of the text NOTES: Uses the current font settings. See x_Set_Font, x_text_init, x_Register_UserFont Not for userfont 16xn, see X-Char_Put16. Written by Themie Gouthas ---------------------------------------------------------------------- function x_char_put (chr:Char;x,y,Color:Word):Byte; for mode 0-2 like x_char_put, but only for 16xn-Font. Selection will make by FontType in font structure by X_Write !!! function x_Char_Put16(chr:Char;x,y,Color:Word):Byte; Returns the Font_Height+1, to make Textlines . function x_font_Height:Byte; Returns the Charwidth, calculate it if var. width. (both user fonts) function x_get_char_width(Chr:Char):Byte; Write the String S to Pos. x,y in Color . procedure x_Write(x,y:Integer;Color:Byte;s:String); simply Text ! Write Text with a Shadow , high - color of Text low - color of Shadow-Text procedure E_Write(x,y,high,low:Integer;s:String); Write a Integer using E_Write. procedure E_WriteInt(x,y,high,low:Integer;I:LongInt); Write a Real using E_Write. procedure E_WriteReal(x,y,high,low:Integer;R:Real;f1,f2:Byte); Write a Text with serverals Textcolors. New Colors are included in the String : ...®Colornumber¯... . With the character ® (ALT-174) begin the Value, and ends with ¯ (ALT-175) example '®'+str(Gray5)+'¯H®'+str(Gray3)+'¯ello' will a highlight big 'H' procedure E_WriteColor(x,y,high,low:Integer;s:String); const All_Char = 0; Only_Digit = 1; if E_Read_Mode:=Only_Digit, it gets onl digits ! Only_FileName = 2; it gets only characters for filenames ! Look in E_ReadInt for exapmle. var E_Read_Mode : Byte; Mask for E_Read. , see const here Read the String s, (edit with Backspace) in the Box between x and MaxX, - s could have some default characters - abort with ESC, S:='' - first pressed BackSpace, default S will be cleared procedure E_Read(x,y,MaxX,FontColor,BackColor:Integer;var s:String); Make a Input-Mask like : [ Filename : Oldname< ] - High,low are colors for the name-string - RHigh,RBack are the colors for the Inputstring in E_Read procedure E_Input(x,y,MaxX,High,low,RHigh,RBack:Word;S:String;var S2:String); Read a Integer/LongInt - see params in E_Read procedure E_ReadInt(x,y,MaxX,FontColor,BackColor:Integer;var I:LongInt); Make a Input-Mask for a Integer/LongInt - see params in E_Input. procedure E_InputInt(x,y,MaxX,High,low,RHigh,RBack:Word;S:String;var I:LongInt); Draw a Button , used by unit X_Button. procedure No_Button_Write(x,y,Box_Bright,Box_dark,Box_back, high,low:Integer;s:String); The same like No_Button_Write, Colors are defined by Gray0..Gray5 in X_Const. procedure No_Button_Write_Gray(x,y:Integer;S:String); Draw a Button like a pressed Button, used by Unit X_Button procedure Press_Button_Write(x,y,Box_Bright,Box_dark,Box_back, high,low:Integer;s:String); The same like Press_Button_Write, Colors are Gray0..Gray5 in X_Const. procedure Press_Button_Write_Gray(x,y:Integer;s:String); Setzt links und rechts so viele Leerzeichen, damit Breite erreicht wird. Fills on left and right space until width is reached. function center(width:Word;S:String):String; function str(X:LongInt):String; the same use like TP-str,only as function Length of the String in Pixelrows. function x_length(S:String):Word; Length of the LongInt, converted in String, in Pixelrows. function x_lengthInt(I:LongInt):Word; X_PICS X_Pics load SCR-Files (converted with the utily Gif2SCR) load/save RLE-Files RLE-procedures by Themie Gouthas SCR-procedure by CHristian Harms ****** XLIB - Mode X graphics library **************** ****** **************** ****** Written By Themie Gouthas ( C-Version ) **************** ****** Converted By Christian Harms in TP **************** X_Pics is the a old part of X_Bitmaps, who was very big and the Bitmaps are more smaller then big backgrounds. interface Load SCR_File on activ Page and set var.Pal if New_Pal in File , otherwise fill it with 0. True,if successed. function x_Load_Scr(Name:String;var P):Boolean; see comment in implementation part function x_buff_RLEncode(Var src,dest;count:Word):Word; function x_buff_RLE_size(Var src;count:Word):Word; function x_buff_RLDecode(Var src,dest):Word; function x_file_RLEncode(Var FileVar:File;Var src;Count:Word):Word; function x_file_RLDecode(Var FileVar:File;Var dest):Word;