home *** CD-ROM | disk | FTP | other *** search
- program Ega43LineMode;
- {-EGA43.PAS, version 1.0, 2/7/86}
- {-Demonstrates use of the EGA's 43-line mode}
-
- {$C-}
-
- (*
- Notes for EGA43.PAS:
- ====================
- The routines included here should provide everything you need in order to
- deal with the EGA's 43-line mode. With them you can
-
- - test for the presence of the EGA
- - determine whether or not 43-line mode is currently in effect
- - switch in and out of 43-line mode
- - determine the size of the cursor box currently in use by the EGA
- - toggle the EGA's emulation of the CGA cursor on or off
-
- Since PC-DOS versions of Turbo Pascal prior to 3.02A do not allow text
- windows larger than 25 rows, use of these routines under Turbo 3.00B and
- 3.01A requires that you make a simple patch to the compiler (shown below).
-
- Contrary to popular fears, you don't need any special screen-writing
- routines for 43-line mode. As the demo program shows, Write and WriteLn
- (and ClrScr, and GotoXY, etc.) work fine once you've made the necessary
- preparations, and routines that write directly to video memory (such as
- those in my FASTWR.PAS and Bela Lubkin's WINDOW.PAS) behave just as they
- would in 25-line mode.
-
- Caveat:
- =======
- EgaIn43LineMode and EgaCursorSize were developed and tested only on an EGA
- clone (a Vega). Please let me know ASAP if they fail for your adapter. The
- other routines (based on code written by Kim Kokkonen) have been tested on
- a wide variety of EGA cards.
-
-
- Please refer all comments, problems, etc. to:
-
- Brian Foley [76317,3247]
- TurboPower Software
- *)
-
- (*
- Patches for Turbo 3.01A and 3.00B to allow text windows > 25 rows:
- ==================================================================
- Enter "DEBUG TURBO.COM" at the DOS prompt, then execute the four commands
- shown below. For Turbo 3.01A (with or without BCD or 8087):
-
- E 38F
- 2B
- W
- Q
-
- The patch for Turbo 3.00B (with or without BCD or 8087) is the same except
- for the first command, which should be "E 372". After the patch has been
- applied, all compiled programs will accept text windows as large as 43
- ($2B) rows.
- *)
-
- {the following global type declaration is needed by EGA43.INC:}
- type
- Registers = record
- case Integer of
- 1 : (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags : Integer);
- 2 : (AL, AH, BL, BH, CL, CH, DL, DH : Byte);
- end;
-
- (*** begin EGA43.INC ***)
-
- function EgaInstalled : Boolean;
- {-Return True if EGA is present}
- var
- Regs : Registers;
- begin
- Regs.AX := $1200;
- Regs.BX := $10;
- Regs.CX := $FFFF;
- Intr($10, Regs);
- EgaInstalled := (Regs.CX <> $FFFF);
- end;
-
- procedure SetCursor(Starting, Ending : Byte);
- {-Set the starting and ending scan lines for the cursor. Not specific to
- the EGA.}
- var
- Regs : Registers;
- begin
- Regs.AH := 1;
- Regs.CH := Starting;
- Regs.CL := Ending;
- Intr($10, Regs);
- end;
-
- procedure EgaCursorEmulation(Off : Boolean);
- {-Toggle EGA cursor emulation on or off. Due to a flaw in the EGA BIOS, a
- normal cursor (starting = 6, ending = 7) will be hidden after switching to
- 43-line mode if emulation is left on.}
- var
- Emulation : Byte absolute $40 : $87; {only bit 0 is relevant here}
- begin
- if Off then
- begin
- {turn emulation off and reset cursor}
- Emulation := Emulation or 1;
- SetCursor(5, 7); {set normal cursor}
- end
- else
- begin
- {turn emulation on and reset cursor}
- Emulation := Emulation and $FFFE;
- SetCursor(6, 7); {set normal cursor}
- end;
- end;
-
- function EgaIn43LineMode : Boolean;
- {-Return True if EGA is in 43-line mode}
- begin
- EgaIn43LineMode := (Mem[$40 : $84] = 42);
- end;
-
- procedure Ega43LineMode(On : Boolean);
- {-Toggle 43-line mode on or off}
- var
- Regs : Registers;
- begin
- Regs.AX := $1111+Ord(On); {AX of $1112 = on, $1111 = off}
- Regs.BL := 0;
- Intr($10, Regs);
- EgaCursorEmulation(On);
- end;
-
- function EgaCursorSize : Byte;
- {-Return size, in scan lines, of cursor box used by EGA}
- begin
- EgaCursorSize := Mem[$40 : $85];
- end;
-
- (*** end EGA43.INC ***)
-
- (*** Demonstration Program ***)
- var
- I : Integer;
- const
- Ega43LineModeArray : array[False..True] of string[33] =
- ('The EGA is now in 25-line mode.',
- 'The EGA is now in 43-line mode.');
-
- begin
- NormVideo;
-
- {check for presence of EGA}
- if not EgaInstalled then
- begin
- WriteLn('This program requires an EGA!');
- Halt(1);
- end;
-
- {increase window to 43 rows, switch to 43-line mode, and clear screen}
- Window(1, 1, 80, 43);
- Ega43LineMode(True);
- ClrScr;
-
- {show status info about the EGA and verify that 43-line mode works}
- WriteLn( Ega43LineModeArray[EgaIn43LineMode] );
- WriteLn('The EGA is now using a cursor that is ', EgaCursorSize,
- ' scan lines high.');
- LowVideo;
- for I := 1 to 43 do
- WriteLn('This is an example of the EGA''s 43-line mode...');
- Delay(1000);
-
- {reset for smaller window, switch to 25-line mode, and get cursor back}
- Window(1, 1, 80, 25);
- Ega43LineMode(False);
- GoToXY(1, 25); {get the cursor back on the screen}
- WriteLn;
-
- {show revised status info}
- NormVideo;
- WriteLn( Ega43LineModeArray[EgaIn43LineMode] );
- WriteLn('The EGA is now using a cursor that is ', EgaCursorSize,
- ' scan lines high.');
- end.
-