home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
educatin
/
k-ching.lbr
/
KSCREEN.MZD
/
KSCREEN.MOD
Wrap
Text File
|
1987-12-04
|
4KB
|
138 lines
IMPLEMENTATION MODULE KScreen;
FROM Terminal IMPORT WriteChar;
FROM SYSTEM IMPORT OUT;
(*
TYPE
VideoAttribute =
(HiInverse,Dim,Flash,Underline,Cursor,LoInverse,Normal);
*)
PROCEDURE SetVideo(Attribute: VideoAttribute; Switch: BOOLEAN);
(* Turns various Kaypro-specific options on and off, according to Switch.
Normal,FALSE will undo everything except the Cursor attribute --
Normal,TRUE will undo everything and turn the cursor ON.
SetVideo uses the standard Write procedure and does not affect
cursor position.*)
CONST
ESC = 33C;
B = 'B';
C = 'C';
VAR x: CARDINAL;
BEGIN
IF ORD(Attribute)<=4 THEN
WriteChar(ESC);
IF Switch THEN WriteChar(B) ELSE WriteChar(C); END;
WriteChar(CHR(ORD(Attribute)+48));
ELSIF ORD(Attribute)=5 THEN
WriteChar(ESC);
IF Switch THEN WriteChar(B) ELSE WriteChar(C);END;
WriteChar('0');
WriteChar(ESC);
IF Switch THEN WriteChar(B) ELSE WriteChar(C);END;
WriteChar('1');
ELSIF ORD(Attribute)=6 THEN
FOR x := 48 TO 51 DO
WriteChar(ESC);
WriteChar(C);
WriteChar(CHR(x));
END;
IF Switch THEN
WriteChar(ESC);WriteChar(B);WriteChar('4');
END;
END;
END SetVideo;
PROCEDURE DrawLine
(fromX, fromY, toX, toY: CARDINAL; DrawEr: BOOLEAN);
(* Draws or Erases a line from X,Y to X,Y according to whether the fifth
parameter, DrawEr is True or False [ie TRUE will Draw].
Due to the "Step" nature of mapping linear equations with integer co-ords
the line x1,y1,x2,y2 <> x2,y2,x1,y1! Rather it is its mirror image.
To ensure consistant results, be sure to always specify line co-ords in
the same order, particularly when erasing a previously drawn line.
If ANY of the CO-ORDS is outside accepted range, nothing happens!*)
CONST ESC = 33C;
BEGIN
IF (fromX>=0) AND (fromY>=0) AND (toX>=0) AND (toY>=0)
AND (fromX<160) AND (fromY<100) AND (toX<160) AND (toY<100)
THEN
WriteChar(ESC);
IF DrawEr THEN WriteChar('L') ELSE WriteChar('D'); END;
WriteChar(CHR(fromY+32));
WriteChar(CHR(fromX+32));
WriteChar(CHR(toY+32));
WriteChar(CHR(toX+32));
END;
END DrawLine;
PROCEDURE Pixel(xpos,ypos: CARDINAL; DrawErase: BOOLEAN);
(* Draws or Erases a pixel at the screen co-ord given by [xpos,,ypos] if
DrawErase is TRUE or FALSE. This procedure will only place a pixel on the
screen if that character position is BLANK [ie occupied by a space].
If Xpos or Ypos is outside the normal screen range of 0..159,0..99
it will be drawn, but at MOD160 or MOD100, respectively. *)
BEGIN
xpos:= xpos MOD 160 + 32;
ypos:= ypos MOD 100 + 32;
WriteChar(33C); (*ESC*)
IF DrawErase THEN WriteChar('*') ELSE WriteChar(' '); END;
WriteChar(CHR(ypos));
WriteChar(CHR(xpos));
END Pixel;
PROCEDURE GCharWrite(GraphicsCharacter: CHAR);
(* WRITES the 8-bit graphics character specified by the ordinal value of
GraphicsCharacter at the present cursor position. GraphicsCharacter must be
in the normal CHAR range of 0..255 and is composed of 8 pixels which are
turned on according to the following bitmap:
2 1
8 4
32 16
128 64
*)
VAR x: CARDINAL;
BEGIN
x:= ORD(GraphicsCharacter);
IF x = 0 THEN WriteChar(' ');
ELSIF x = 255 THEN
SetVideo(LoInverse,TRUE);
WriteChar(' ');
SetVideo(LoInverse,FALSE);
ELSIF (x>0) AND (x<128) THEN
SetVideo(Dim,TRUE);
WriteChar(CHR(x+128));
SetVideo(Dim,FALSE);
ELSE (*x>=128 and x<255*)
x:= 255+(128-x);
SetVideo(LoInverse,TRUE);
WriteChar(CHR(x));
SetVideo(LoInverse,FALSE);
END;
END GCharWrite;
PROCEDURE BlinkBlock(Blink,Block:BOOLEAN);
VAR x: INTEGER;
BEGIN
IF Blink AND Block THEN x:=-32;
ELSIF Blink AND NOT Block THEN x:=-17;
ELSIF NOT Blink AND NOT Block THEN x:=15;
ELSE (* NOT Blink AND Block *) x:=0;
END;
OUT(28,10);
OUT(29,x);
END BlinkBlock;
END KScreen.