Video Control
Published By | Date | Version | Knowledge Level | Keywords |
---|---|---|---|---|
Sprezzatura Ltd | 01 JUL 1992 | 2.12+ | EXPERT | VIDEO, VCARD, GET_VID_INFO, VIDEOCONFIG, VIDCTRL, @CTRHIGH, @CTRMAXHIGH, INIT.STATUS, VIDEO.RW |
With the advent of more sophisticated video control (with 43 and 50 line support) and with yet more sophistication to come (with the rumoured 132 column support) it is instructive to examine the system routines and control records provided for the manipulation of the video screen. One thing that it is timeous to point out is that whilst some of these routines (such as VCARD) provide information that is accessible elsewhere, the use of calls to standardised routines (such as GET_VID_INFO) is encouraged by RevTI as it permits the construction of software "black boxes" which can be radically changed on the inside without changing the result returned to the calling program.
VIDEOCONFIG
There is a record in the SYSTEM file which contains the setup information required when configuring the video mode. It has five multi-valued fields as follows
<1> | Video Mode - this is the numeric value used by VIDCTRL (q.v.) when resetting the video mode. |
<2> | Description of the video mode |
<3> | Screen width in this mode |
<4> | Screen depth in this mode |
<5> | Type of card mode will work with. Setting a VGA card to an EGA mode and vice versa does not work. This value records the kind of video card (as returned by VCARD (q.v.) which the video mode is designed for. |
VCARD
Called subroutine taking (and returning) one parameter, the kind of video card installed. Calling syntax is X = "" ; CALL VCARD(X). Types identified in Technical Bulletin 74 are, 0 - MDA, 1 - CGA, 2 - EGA, 3 - PGA, 4 - VGA, 5 - MCGA, 6 - Unknown.
GET_VID_INFO
This is a function taking one parameter - the branch, returning a result of the information being asked for. The branches and returned results are as follows
Branch | Return Value |
---|---|
1 | Video mode |
0 - Normal text mode | |
1 - 25 line EGA Mode | |
2 - 43 line EGA mode | |
3 - 25 line VGA mode | |
4 - 43 line VGA mode | |
5 - 50 line VGA mode | |
6 - 16 line VGA mode | |
2 | CRT Width |
3 | CRT Height |
4 | Video Card type - same as results of VCARD. |
5 | Unknown - always returns 0 on test machine. |
6 | Starting address of Video RAM, returned as a two byte number, in low byte high byte order. Normally this would return CHAR(0) : CHAR(184), in other words (0 + 256 * 184) = 47104=B800. |
VIDCTRL
This assembler subroutine controls the video setting of the screen and can be used to "flip" modes in real time. It takes 5 parameters, of which only the first two and the last one seem to be used. As it is an assembler routine it is difficult to be able to state with any confidence exactly what all calls do, however there seem to be three major kinds of call, with each kind taking a specific action modifier. The calling sequence is therefore
VidCtrl( Action, Mode, UK1, UK2, Flag)
where
Action | Is the action to take, having the value of the video card type for modes 0 and 2, and the video mode to change to for mode 1. |
Mode | Is the type of operation to be performed 0 Reset video card to default settings 1 Change video mode 2 Possibly initialise card - does not seem to be required. |
UK | Unknown |
Flag | Result of operation. |
Using this routine permits the programmer to reset the screen into an alternative video mode. Note that when this is done there are several caveats to be aware of :-
- Changing the screen size necessitates the changing of the status line location. This is done by resetting @CRTHIGH and @CRTMAXHIGH to the appropriate size and the calling the system routine INIT.STATUS.
- When video modes change, the screen is left blank. A background must therefore be filled in using Video.RW. In the code that follows the default background of \B01B\ is used. If you do not use the default and you wish to construct a generic routine, you will have to extract the correct settings from the environment.
- As mentioned in the discussion of VIDEOCONFIG, certain video modes do not work with certain video cards. The program following makes no allowance for this, but for genericism it could be coded to check the current video card against the requested mode by examining the VIDEOCONFIG record.
- As we wish to return to the normal status line when leaving the temporarily chosen mode, it is necessary to capture the screen image before the new mode is invoked, and restore this image upon return.
The code following represents a generic routine for calling a window from a menu and having that window appear in a non-default video mode. It may be called directly as a subroutine, or via catalyst using * to separate the arguments. The arguments are the window name and the mode to use. The mode can be the number or the text equivalent.
Subroutine Call_Window(Window, Mode) Declare Subroutine VidCtrl, Catalyst, Video.Rw Declare Function Guar_Assign, Get_Vid_Info Mode = Guar_Assign(Mode) If Index(Window, "*", 1) Then Mode = Window[-1, "B*"] Window = Window[1,"*"] End VidCard = "" ; Call VCard(VidCard) ModeNums = "0,1,2,3,4,5,6" Names = "TEXT,EGA25,EGA43,VGA25,VGA45,VGA50,VGA16" ModeHigh = "25,25,43,25,45,50,16" GoSub Save Locate Mode In ModeNums Using "," Setting Pos Then DoIt = 1 End Else Locate Mode In Names Using "," Setting Pos Then DoIt = 1 End End If DoIt Then GoSub SetUp Catalyst("W", Window) GoSub Restore End Return SetUp: Flag = "" ; VidCtrl(VidCard, 0, "", "", Flag) Flag = "" VidCtrl(Field(ModeNums,",",Pos), 1, "", "", Flag) @CrtMaxHigh = Field(ModeHigh, ",", Pos) @CrtHigh = @CrtMaxHigh Video.RW(0,0,(@CrtWide-1),(@CrtHigh-1),"C",\B01B\) Call Init.Status Return Save: SaveMode = Get_Vid_Info(1) SaveHigh = @CrtHigh SaveMaxHigh = @CrtMaxHigh Video.RW(0,0,@CrtWide-1,@CrtMaxHigh-1,"R",Image) Return Restore: Flag = "" ; VidCtrl(VidCard, 0, "", "", Flag) Flag = "" ; VidCtrl(SaveMode, 1, "", "", Flag) @CrtMaxHigh = SaveMaxHigh @CrtHigh = SaveHigh Call Init.Status Video.RW(0,0,@CrtWide-1,@CrtMaxHigh-1,"W", Image) Return
(Volume 4, Issue 3, Pages 8-10)