DEFINITION MODULE Console; (* Version 1.0 *)

(************************************************************************)
(* COPYRIGHT 1988 by David Albert                                       *)
(* You may use this module in any of your work and distribute it freely *)
(* Provided that:    1) The copyright notice is not changed or removed  *)
(*                   2) The module is not modified                      *)
(*                   3) Under NO conditions is this module to be sold   *)
(************************************************************************)

(* CONSOLE uses BIOS calls to provide advanced screen handling.         *)

CONST ScreenSizeX = 80;
      ScreenSizeY = 25;

VAR   CurWindow   : RECORD
                       X1, Y1, X2, Y2,
                       Attribute       : CARDINAL;
                    END;

PROCEDURE ClearScreen();              (* Clear entire screen              *)
PROCEDURE ClearEOL();                 (* Clear from cursor to end of line *)
PROCEDURE GetVidMode() : CARDINAL;    (* Returns current video mode       *)
PROCEDURE GetVidCh() : CARDINAL;      (* Returns char+attr at current X,Y *)
PROCEDURE GotoXY (X,Y : CARDINAL);    (* Place cursor at location X,Y     *)
PROCEDURE Highlight();                (* Turns highlighting on            *)
PROCEDURE Inverse();                  (* Turns inverse video on           *)
PROCEDURE KeyPressed() : BOOLEAN;     (* True if a key has been pressed   *)
PROCEDURE Normal();                   (* Sets Video back to Normal        *)
PROCEDURE PutChar (Ch:CHAR;Num:CARDINAL); (* Puts num chars at X,Y        *)
PROCEDURE PutVidCh(ChAttr:CARDINAL);  (* Put char+attr at current X,Y     *)
PROCEDURE Read(VAR Ch : CHAR);        (* Read a character from the kbd    *)
PROCEDURE ScrollDown(Lines:CARDINAL); (* Scroll screen down               *)
PROCEDURE ScrollUp(Lines : CARDINAL); (* Scroll screen up                 *)
PROCEDURE SetCursorSize(Top, Bottom : CARDINAL);
PROCEDURE SetVidMode(Mode:CARDINAL);  (* Sets new video mode              *)
PROCEDURE WhereX () : CARDINAL;       (* Returns current X pos of cursor  *)
PROCEDURE WhereY () : CARDINAL;       (* Returns current Y pos of cursor  *)
PROCEDURE Window(X1,Y1,X2,Y2:CARDINAL); (* Defines current window         *)
PROCEDURE WriteChar (Ch : CHAR);      (* Write a char and bump cursor     *)
PROCEDURE Write(Ch : CHAR);           (* Write a char in current window   *)
PROCEDURE WriteLn();                  (* Advance cursor to next line col 1*)
PROCEDURE WriteString(S:ARRAY OF CHAR); (* Write a string using Write     *)
PROCEDURE StealWrite();               (* Redirs Writes to use above proc. *)
PROCEDURE ReturnWrite();              (* Returns writes to previous Write *)
END Console.

