home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
progm
/
tptools.zip
/
FIRSTED.ZIP
/
EDSCRN1.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1987-12-21
|
10KB
|
265 lines
{ EDSCRN1.PAS
ED 4.0
Copyright (c) 1985, 87 by Borland International, Inc. }
{$I eddirect.inc}
unit EdScrn1;
{-Fast screen writing routines for FirstEd}
interface
uses
Dos, {DOS calls - standard unit}
Errors; {Runtime error handler}
const
DefNoRows = 25; {Default number of rows/physical screen}
DefNoCols = 80; {Default number of cols/physical screen}
type
CharArray = array[0..80] of Char; {Holds a line about to be written to screen}
ColorType = ( {Screen colors}
TxtColor, {Text color}
BlockColor, {Block color}
BordColor, {Window status lines}
CmdColor, {Command line color}
CursorColor, {Color for solid block cursor, if activated}
MnColor, {Normal menu color}
MfColor, {Menu frame color}
MsColor, {Selected menu item color}
MhColor, {Highlighted selection character in menu}
BoldColor, {Color for bold attribute}
DblColor, {Color for doublestrike attribute}
UndColor, {Color for underscore attribute}
SupColor, {Color for superscript attribute}
SubColor, {Color for subscript attribute}
Alt1Color, {Color for alternate 1 attribute - Compressed}
Alt2Color {Color for alternate 2 attribute - Italic}
);
{Stores screen attributes}
AttributeArray = array[ColorType] of Byte;
var
PhyScrCols : Integer; {Columns per screen row}
CtrlAttr : Byte; {Attribute used to display control characters}
Tline : CharArray; {Line of text to write to screen}
Aline : CharArray; {Line of attributes to write to screen}
CursorType : Word; {Scan lines for normal blinking cursor}
BigCursor : Word; {Scan lines for "fat" cursor used in insert mode}
LogScrRows : Integer; {No. lines/logical screen}
LogTopScr : Integer; {Physical line no. for logical line #1}
PromptRow : Integer; {Physical line for signals, etc.}
ScreenAttr : AttributeArray; {Currently selected attributes}
procedure EdFastWrite(St : string; Row, Col, Attr : Integer);
{-Writes St at Row,Col in Attr (video attribute) without snow}
procedure EdChangeAttribute(Number, Row, Col, Attr : Integer);
{-Changes Number video attributes to Attr starting at Row,Col}
procedure EdMoveToScreen(var Source, Dest; Length : Integer);
{-Moves Length words from Source to Dest (video memory) without snow}
procedure EdMoveFromScreen(var Source, Dest; Length : Integer);
{-Moves Length words from Source (video memory) to Dest without snow}
procedure EdWrline(Row : Integer);
{-General purpose text write - no character translation}
procedure EdWrlineCtrl(Row : Integer);
{-General purpose text write - ctrl chars translated}
procedure EdSetCursor(ScanLines : Word);
{-Change the scan lines of the hardware cursor}
procedure EdRestoreScreenMode;
{-Clean up screen upon exit}
{==========================================================================}
implementation
type
TAarray = array[0..160] of Char; {Combined line of char and attr for screen}
const
{Marks start of SCREEN INSTALLATION AREA}
ScreenIDstring : string[24] = 'SCREEN INSTALLATION AREA';
{Colors changeable within FirstEd}
MonoAttr : AttributeArray = (
$07, {TxtColor}
$0F, {BlockColor}
$70, {BordColor}
$07, {CmdColor}
$70, {CursorColor}
$07, {MnColor}
$0F, {MfColor}
$70, {MsColor}
$0F, {MhColor}
$0F, {BoldColor}
$0F, {DblColor}
$01, {UndColor}
$0F, {SupColor}
$0F, {SubColor}
$0F, {Alt1Color}
$0F {Alt2Color}
);
ColorAttr : AttributeArray = (
$1E, {TxtColor}
$17, {BlockColor}
$38, {BordColor}
$0F, {CmdColor}
$4A, {CursorColor}
$70, {MnColor}
$78, {MfColor}
$1F, {MsColor}
$71, {MhColor}
$1F, {BoldColor}
$14, {DblColor}
$7F, {UndColor}
$15, {SupColor}
$16, {SubColor}
$1D, {Alt1Color}
$1A {Alt2Color}
);
{Default modes - shared by all windows}
GoodColorCard : Boolean = False; {False to remove snow on color card}
var
ScreenAdr : Word; {Base address of video memory}
InitScreenMode : Byte; {The video mode on entry to program}
InitRetraceMode : Boolean; {Set if wait for retrace is needed}
EgaPresent : Boolean; {True if EGA card selected}
RetraceMode : Boolean; {Check for snow on color cards?}
PhyScrRows : Integer; {No. lines/physical screen}
{$L EDSCRN1}
procedure EdFastWrite(St : string; Row, Col, Attr : Integer); external;
procedure EdChangeAttribute(Number, Row, Col, Attr : Integer); external;
procedure EdMoveToScreen(var Source, Dest; Length : Integer); external;
procedure EdMoveFromScreen(var Source, Dest; Length : Integer); external;
procedure EdSetCursor(ScanLines : Word); external;
procedure EdMergeTA(var Sbuf); external;
procedure EdMergeTActrl(var Sbuf); external;
procedure EdWrline(Row : Integer);
{-General purpose text write - no character translation}
var
Sbuf : TAarray;
begin {EdWrline}
{Merge text and attribute lines}
EdMergeTA(Sbuf);
EdMoveToScreen(Sbuf, Mem[ScreenAdr: (PhyScrCols shl 1)*Pred(Row)], PhyScrCols);
end; {EdWrline}
procedure EdWrlineCtrl(Row : Integer);
{-General purpose text write - ctrl chars translated}
var
Sbuf : TAarray;
begin {EdWrline}
{Merge text and attribute lines, filtering control characters}
EdMergeTActrl(Sbuf);
EdMoveToScreen(Sbuf, Mem[ScreenAdr: (PhyScrCols shl 1)*Pred(Row)], PhyScrCols);
end; {EdWrline}
procedure EdRestoreScreenMode;
{-Clean up screen upon exit}
var
regs : registers;
begin {EdRestoreScreenMode}
{Restore the cursor to original scan lines}
EdSetCursor(CursorType);
{Restore the screen mode - also clears the screen}
with regs do begin
Ah := 0;
Al := InitScreenMode;
intr($10, regs);
end;
end; {EdRestoreScreenMode}
{***}
procedure EdGetScreenMode;
{-determine screen address and colors}
var
regs : registers;
function EdEgaPresent : Boolean;
{-Return True if an EGA card is installed and selected}
var
regs : registers;
begin {EdEgaPresent}
with regs do begin
Ah := $12;
Bl := $10;
Cx := $FFFF;
intr($10, regs);
EdEgaPresent := (Cx <> $FFFF);
end;
end; {EdEgaPresent}
begin {EdGetScreenMode}
PhyScrCols := DefNoCols; {Number of columns on the screen}
PromptRow := 1; {Command Line is line 1 of screen}
LogTopScr := 2; {Text windows don't use line 1 of screen}
PhyScrRows := DefNoRows;
LogScrRows := Succ(PhyScrRows-LogTopScr);
with regs do begin
{Get current screen mode}
ax := $0F00;
intr($10, regs);
InitScreenMode := Al;
{Set screen mode to appropriate 80 column mode}
Ah := 0;
case InitScreenMode of
0 : Al := 2; {Switch from BW40 to BW80}
1 : Al := 3; {Switch from CO40 to CO80}
else
Al := InitScreenMode; {Assure color burst correct}
end;
intr($10, regs);
end;
InitRetraceMode := (InitScreenMode <> 7);
EgaPresent := EdEgaPresent;
if InitRetraceMode then begin
{Color card}
ScreenAdr := $B800;
ScreenAttr := ColorAttr;
CursorType := $0607;
BigCursor := $0507;
if EgaPresent then
GoodColorCard := True;
end else begin
ScreenAdr := $B000;
ScreenAttr := MonoAttr;
CursorType := $0B0C;
BigCursor := $090C;
end;
{Attribute used to mark control characters}
CtrlAttr := ScreenAttr[BlockColor];
{Don't slow down for good color cards}
RetraceMode := InitRetraceMode and not(GoodColorCard);
end; {EdGetScreenMode}
begin
EdGetScreenMode;
end.