home *** CD-ROM | disk | FTP | other *** search
- Unit V_font_U; { VGA font unit }
- { By Joe Tamburino. This unit allows a Turbo Pascal program to use some }
- { ordinary graphics primitives with text mode. This only works with }
- { EGA, VGA, and any other video card that supports the ability to redefine }
- { text fonts (and does so using standard INT 10h calls.) }
-
- { Version 1.01. This version has many limitations; it is meant only as a }
- { demonstation of what can be done with EGA & VGA character sets. }
- { Programmers are encouraged to improve this unit as they need to. Here's }
- { a list of what the unit can and cannot do: }
-
- { - Ability to redefine up to 384 characters for graphics use. }
- { - Addresses a resolution of 640x400 points. However, only 80x25 of }
- { these points have independent attributes (each character has its own}
- { attribute, not each point). 200 and 350 lines modes are also }
- { supported. }
- { - Most graphics primitives can use half of the available text mode }
- { attributes; The forground intensity value cannot be independently }
- { selected. }
- { - DOES NOT have the ability to prevent new characters being allocated }
- { which have the same bit-pattern as existing ones. (This is a severe}
- { limitation, as most graphics primitives produce non-original chars.)}
- { - However, if a character ever becomes blank, it is replaced with the }
- { space character (32) and the old character is de-allocated. }
- { - Supports Hlin,Vlin,Pset,Line,Box,OpenBox, and Ellipse primitives. }
-
- { My address:
- Joseph J. Tamburino
- 7 Chrstopher Rd.
- Westford, MA 01886
- (508) 692-7756
- CompuServe: 70033,107
- Prodigy: NWNJ91A
- }
-
- {$R-} {$S-} {$I-}
-
- Interface
- Const
- EGA=FALSE; VGA=TRUE; { Adapter contants }
- LargestChar=511; { Largest character # }
- SmallestChar=128; { Smallest character # }
- FontSize=$1800; { 16x384 bytes }
- MaxX: integer=(639); { Largest X }
- MaxY: integer=(399); { Largest Y }
- EGA_VGA: boolean=(VGA); { Display adapter used }
-
- Var
- TotalUsed: integer; { # of characters used by V_FONT_U }
-
-
- Procedure FontInit(FontBuffer,ScrnBuffer: pointer); { Initialization }
- Procedure Pset(x,y: integer; Color: byte); { Point plot }
- Procedure Hlin(x1,y1,x2: integer; Color: byte); { Horizontal line }
- Procedure Vlin(x1,y1,y2: integer; Color: byte); { Vertical line }
- Procedure Line(x1,y1,x2,y2: integer; Color: byte); { Any line }
- Procedure Box(x1,y1,x2,y2: integer; Color: byte); { Filled box }
- Procedure OpenBox(x1,y1,x2,y2: integer; Color: byte);{Unfilled box }
- Procedure Ellipse(x,y,r1,r2: word; Color: byte); { Ellipse }
- Procedure GetScrn(Buffer: pointer); { Save screen }
- Procedure PutScrn(Buffer: pointer); { Restore screen }
- Procedure WriteFont; { Write font info }
- Procedure ClearChars(ScrnBuf: pointer); { Clear font info }
- Procedure Freeze; { Halt screen }
- Procedure Unfreeze; { Re-update raster}
- Procedure Make512chars; { Use 512-char set}
- Procedure MaskColors; { Use only 8 color}
- Procedure Make8bitChars(Lines: integer); { Use 200,350 line}
- Procedure Make9bitChars; { Use 400 lines }
-
-
- Implementation
- Uses Dos,Crt;
-
- Const
- Points: byte=(16); { # of points (bytes)/char }
- SizeFor128chars: word=(128*16); { Size for 128 characters }
-
- Var
- Buffer: pointer; { Character set - upper 384 chars }
- CharsUsed: array[SmallestChar..LargestChar] of boolean; {Allocated chars}
- ExitSave: pointer; { For exit procedure }
-
- { Everything is external; procedures reside in VGA_FONT.OBJ }
- {$L VGA_FONT }
- Procedure Line(x1,y1,x2,y2: integer; Color: byte); External;
- Procedure Freeze; External;
- Procedure Unfreeze; External;
- Procedure Ellipse(x,y,r1,r2: word; Color: byte); External;
- Procedure MaskColors; External;
- Procedure Make512chars; External;
- Procedure GetScrn(Buffer: pointer); External;
- Procedure PutScrn(Buffer: pointer); External;
- Procedure FontInit(FontBuffer,ScrnBuffer: pointer); External;
- Procedure WriteFont; External;
- Procedure ClearChars(ScrnBuf: Pointer); External;
- Procedure Pset(x,y: integer; Color: byte); External;
- Procedure Hlin(x1,y1,x2: integer; Color: byte); External;
- Procedure Vlin(x1,y1,y2: integer; Color: byte); External;
- Procedure Box(x1,y1,x2,y2: integer; Color: byte); External;
- Procedure OpenBox(x1,y1,x2,y2: integer; Color: byte); External;
- Procedure Make8bitChars(Lines: integer); External;
- Procedure Make9bitChars; External;
-
- { The exit procedure: set to default # of lines per screen: }
- {$F+}
- Procedure ExitTPC; {$F-}
- Begin
- if EGA_VGA=VGA then
- Make9BitChars
- else
- Make8BitChars(350);
- TextMode(co80);
- ExitProc:=ExitSave
- End;
-
- { The unit-initialization code simply sets up the exit procedure. Use }
- { the FontInit procedure to perform other initialization. }
- Begin
- ExitSave:=ExitProc;
- ExitProc:=@ExitTPC
- End.