home *** CD-ROM | disk | FTP | other *** search
- Program ExVideo;
-
- {$F+,R-,S-,I-,X+}
- {Written for Borland Pascal 7.0}
- {TP Systems, Inc.}
-
- (*
-
- A simple test program to check out VideoManager object and demonstrate
- the various screen resolutions that are possible with standard ROM based
- fonts and the special fonts that are provided with this group of files.
- With a standard VGA the following screen resolutions are possible:
-
- 80x12,14,25,26,28,29,30,31,33,35,36,38,40,43,44,50,60
- 40x21,25
-
- Some of these less than 25 row modes could be very useful for consumer
- oriented applications with touch screens in retail stores or for sight
- impaired applications. The 60 row mode is only available in graphics modes
- and 30 is available in text or graphics modes. Of course VESA supported
- SVGA modes are available in addition to all of these. VESA SVGA modes start
- with $100. OEM's may provide other special modes. To get table of OEM
- supported modes for VESA adpaters use: EXVIDEO /T.
-
- The following resolutions are avaiable with some of the VESA
- implementations:
-
- 128x48(G) 160x64(G) 80x60(T) 132x25,43(T)
-
- UserModes below is a way the user can specify special screen modes for his
- particular setup through a configuration file. The sample UserMode array
- below provides the following screen resolutions for the VESA mode $102 which
- is 800x600:
-
- 100x37,40,43,46,50,54,60,66
-
- and also these resolutions that are peculiar to the Orchid Fahrenheit 1280:
-
- 132x25,43 (these are text modes)
-
- Execute ExVideo to get the usage syntax as follows:
-
- Usage: EXVIDEO /R:Rows [options]
- where options are (hex values must use $NN, NNh or 0xNN):
- /R:Rows - this must be specified
- /M:Mode - Video mode - Rows & Cols must be specified value or 0
- /C:Cols - defaults to 80
- /A:Attr - in format used for text modes
- /G - use graphics modes if available for resolution
- otherwise only text modes will be considered
- /O:Options - options for VideoManager - see VIDEO.PAS
- /S:States - to be saved and restored - defaults to all SVGA
- /T - if VESA, just lists table of avail modes
- Limited to VGA and EGA adapters.
- Example: for 800x600 mode of SVGA
- EXVIDEO /r:40 /c:100 /g /a:$74
-
- Option Values are:
- {first 4 options are not supported on EGA}
- vmClearDisplay = $0001; {if set video display memory cleared on}
- {mode set - always cleared on EGA}
- vmPreservePalette = $0002; {if set palette is preserved on mode set}
- vmSaveStateOnInit = $0004; {if set saves initial state if possible}
- vmRestoreStateOnDone = $0008; {if set restores initial state if possible}
- vmEnableHiBackground = $0010; {if set turns blink bit off}
- vmDisregardVesa = $0020; {if set forces manager to treat display
- as standard Vga even if Vesa installed}
-
- CAUTION: VideoManager has a problem in restoring SVGA modes. I don't know
- whether this is a bug in my code or a problem with the VESA implementations
- I have tested. Any help in sorting this out would be appreciated.
-
- States Values are:
- ssHardware = $0001;
- ssBios = $0002;
- ssDac = $0004;
- ssSvga = $0008;
- ssAllVga = $0007;
- ssAllSvga = $000F;
-
- *)
-
- Uses
- OpConst,
- OpString,
- OpCrt,
- OpRoot,
- TsVga,
- TsSvga,
- Video;
-
- const
- Attr : byte = $07; {LtGrayOnBlack}
- Fore : byte = $07; {LtGray}
- Back : byte = $00; {Black}
- IsText : boolean = true;
-
- UserModes : ScreenModeArray = (
- (smVidMode: $54; smFontSize: 8; smRows: 43; smCols:132; smIsText: true;
- smPixW: 1056; smPixH: 350; smColors: 16),
- (smVidMode: $55; smFontSize: 14; smRows: 25; smCols:132; smIsText: true;
- smPixW: 1056; smPixH: 350; smColors: 16),
- (smVidMode:$102; smFontSize: 16; smRows: 37; smCols:100; smIsText: false;
- smPixW: 800; smPixH: 600; smColors: 16),
- (smVidMode:$102; smFontSize: 15; smRows: 40; smCols:100; smIsText: false;
- smPixW: 800; smPixH: 600; smColors: 16),
- (smVidMode:$102; smFontSize: 14; smRows: 43; smCols:100; smIsText: false;
- smPixW: 800; smPixH: 600; smColors: 16),
- (smVidMode:$102; smFontSize: 13; smRows: 46; smCols:100; smIsText: false;
- smPixW: 800; smPixH: 600; smColors: 16),
- (smVidMode:$102; smFontSize: 12; smRows: 50; smCols:100; smIsText: false;
- smPixW: 800; smPixH: 600; smColors: 16),
- (smVidMode:$102; smFontSize: 11; smRows: 54; smCols:100; smIsText: false;
- smPixW: 800; smPixH: 600; smColors: 16),
- (smVidMode:$102; smFontSize: 10; smRows: 60; smCols:100; smIsText: false;
- smPixW: 800; smPixH: 600; smColors: 16),
- (smVidMode:$102; smFontSize: 9; smRows: 66; smCols:100; smIsText: false;
- smPixW: 800; smPixH: 600; smColors: 16));
-
- ColTicks : string[200] =
- '1-------10--------20--------30--------40--------50--------60--------70--------80'+
- '--------90-------100-------110-------120-------130-------140-------150-------160'+
- '-------170-------180-------190-------200';
- var
- LColTicks : byte absolute ColTicks;
-
- procedure MakeCursor; assembler;
- {-Needed for alfanumeric characters in graphics mode which does not
- normally have a cursor. Not needed and should not be used in text
- mode.}
- asm
- push bx
- push cx
- push dx
- mov ah,3 {get cursor position in DX}
- mov bh,0
- int $10
- inc dl
- mov ah,2 {move cursor}
- int $10
- mov ah,$09
- mov al,$16 {small square - doesn't blink}
- mov bh,Back
- mov bl,Fore
- mov cx,1
- int $10
- pop dx
- pop cx
- pop bx
- end;
-
- procedure ClearScreen(Rows, Cols: byte); assembler;
- {-Clears screen by scrolling using current Attr and moves cursor to 0,0}
- asm
- push bx
- push cx
- push dx
- mov ah,6 {scroll current page up}
- mov al,0 {scroll distance = full screen}
- mov bh,Attr {assume text mode}
- cmp IsText,1 {is this a text mode}
- je @1 {yes}
- mov bh,Back {no so just use background}
- @1:
- mov ch,0
- mov cl,0
- dec Rows
- mov dh,Rows
- dec Cols
- mov dl,Cols
- int $10
- mov ah,2 {move cursor to 0,0}
- mov bh,0
- mov dx,0
- int $10
- pop dx
- pop cx
- pop bx
- end;
-
- procedure WriteS(S: string); assembler;
- {-Use Int10 function 13 Write String}
- asm
- push bx
- push cx
- push dx
- push es
- push bp
- mov ah,3 {get cursor position in DX}
- mov bh,0
- int $10
- les bp,S
- mov ah,$13 {write string function}
- mov al,1 {attr in BL and move cursor}
- mov bh,0 {page 0}
- mov bl,Attr {assume text mode}
- cmp IsText,1 {is this a text mode}
- je @1 {yes}
- mov bl,Fore {no so just use adjusted foreground}
- @1:
- xor cx,cx
- mov cl,Byte(es:[bp]) {length of string}
- inc bp {point to actual start of string}
- int $10
- pop bp
- pop es
- pop dx
- pop cx
- pop bx
- end;
-
- procedure WriteSLn(S: string);
- {-Same as WriteS except appends a carriage return line feed}
- begin
- S := S + ^M^J;
- WriteS(S);
- end;
-
- procedure Usage;
- begin
- WriteSLn('TP Systems, Inc. 1994 Version 1.00');
- WriteSLn('Usage: EXVIDEO [[/R:Rows /C:Cols]|/M:Mode] [options]');
- WriteSLn('where options are (hex values must use $NN, NNh or 0xNN):');
- WriteSLn(' /R:Rows - this and Cols or /M:Mode must be specified');
- WriteSLn(' /C:Cols - number of columns');
- WriteSLn(' /M:Mode - video mode - Rows & Cols must be 0 or value');
- WriteSLn(' /A:Attr - in format used for text modes');
- WriteSLn(' /G - use graphics modes if available for resolution');
- WriteSLn(' otherwise only text modes will be considered');
- WriteSLn(' /O:Options - options for VideoManager - see VIDEO.PAS');
- WriteSLn(' /S:States - to be saved and restored - defaults to all SVGA');
- WriteSLn(' /T - if VESA, just lists table of avail modes');
- WriteSLn('Limited to VGA and EGA adapters.');
- WriteSLn('Example: for 800x600 mode of SVGA');
- WriteSLn('EXVIDEO /r:40 /c:100 /g /a:$74');
- Halt;
- end;
-
- var
- StartHeap : LongInt;
-
- procedure LostHeap;
- begin
- WriteSLn('Lost heap = '+Long2Str(StartHeap-MemAvail));
- end;
-
- procedure ErrorMessage(Code: word);
- begin
- case Code of
- ecOutOfMemory : WriteSLn('Out of memory');
- ecVesaNotSupported : WriteSLn('VESA not supported');
- ecVesaFuncFailed : WriteSLn('VESA function failed');
- ecVesaModeNotSupported : WriteSLn('VESA mode not supported');
- ecVgaFuncNotSupported : WriteSLn('VGA function not supported');
- ecVgaFuncFailed : WriteSLn('VGA function failed');
- ecVgaNotActive : WriteSLn('VGA not active display');
- ecInvalidFontFile : WriteSLn('Invalid font file');
- ecScrResolNotSupported : WriteSLn('Screen resolution not supported');
- ecNotRomFont : WriteSLn('ROM font does not exist');
- ecStateNotSaved : WriteSLn('Video states not saved');
- else WriteSLn('Error code reported: '+Long2Str(Code));
- end;
- LostHeap;
- Halt;
- end;
-
- const
- Rows : byte = 0;
- Cols : byte = 0;
- TextOnly : boolean = true;
- Mode : word = 0;
- Options : word = vmClearDisplay;
- Table : boolean = false;
- States : word = ssAllSvga;
-
- var
- VM : VideoManager;
- Arg : string;
- i : byte;
- Switch : char;
- Value : word;
-
- begin {Main}
- StartHeap := MemAvail;
- if ParamCount = 0 then Usage;
-
- if (CurrentDisplay <> VGA) and (CurrentDisplay <> EGA) then Usage;
-
- {initialize variables}
- i := ParamCount;
-
- {get command line}
- while i <> 0 do begin
- Arg := ParamStr(i);
- if Arg[1] <> '/' then Usage;
- Switch := UpCase(Arg[2]);
- Arg := Copy(Arg, 4, 255);
- case Switch of
- 'R' : begin
- if not Str2Word(Arg, Value) then Usage;
- Rows := Byte(Value);
- end;
- 'C' : begin
- if not Str2Word(Arg, Value) then Usage;
- Cols := Byte(Value);
- end;
- 'M' : begin
- if not Str2Word(Arg, Mode) then Usage;
- TextOnly := false;
- end;
- 'A' : begin
- if not Str2Word(Arg, Value) then Usage;
- Attr := Byte(Value);
- end;
- 'G' : begin
- TextOnly := false;
- end;
- 'O' : begin
- if not Str2Word(Arg, Options) then Usage;
- end;
- 'S' : begin
- if not Str2Word(Arg, States) then Usage;
- end;
- 'T' : begin
- Table := true;
- end;
- else Usage;
- end;
- Dec(i);
- end;
-
- Back := Attr shr 4; {background originally in high nibble}
- Fore := Attr and $0F; {foreground in low nibble}
-
- {adjust foreground so when Xor'd with background gives normal foreground
- since will use xor feature of Int10 Write String in graphics modes}
- Fore := (Fore xor Back) or $80;
-
-
- if not VM.Init(Options, '', '', '', States, @UserModes) then
- ErrorMessage(InitStatus);
-
- with VM do begin
- if Table then begin
- if OptionIsOn(vmIsVesa) then begin
- i := 1;
- Mode := vmModeTable^[i];
- WriteSLn('Table of Available VESA Modes');
- while Mode <> $FFFF do begin
- WriteSLn(HexW(Mode));
- inc(i);
- Mode := vmModeTable^[i];
- end;
- end else begin
- WriteSLn('VESA not supported on this system');
- end;
- end else begin
- if not SetScreenResolution(Rows, Cols, Mode, true, TextOnly) then begin
- Done;
- ErrorMessage(GetStatus);
- end;
-
- with vmCurScrMode do begin
- Rows := smRows;
- Cols := smCols;
- IsText := smIsText;
- LColTicks := Cols;
- end;
-
- ClearScreen(Rows, Cols);
- WriteS(ColTicks);
- WriteSLn('2 ExVideo by TP Systems, Inc.');
- for i := 3 to Rows-3 do
- WriteSLn(Long2Str(i));
- WriteSLn(Long2Str(Rows-2)+
- ' Ascii 04 is an arrowhead:'+#4);
- WriteSLn(Long2Str(Rows-1)+
- ' Check attribute if palette preserved');
- WriteS(Long2Str(Rows)+' Press enter to exit...');
- if not vmCurScrMode.smIsText then
- MakeCursor;
- ReadLn;
- end;
- Done;
- end;
- end. {Main}