home *** CD-ROM | disk | FTP | other *** search
- { This section of code is a modification of Lane Ferris' StayWndo.xxx
- procedures which will allow Lane's memory resident features to save
- and restore windows as well as to save and restore the orginal video
- mode.
-
- Advantages: - When used to replace StayWndo.xxx will restore
- the orginal DOS video mode and screen prior to
- the TSR code being activated. This includes
- graphics, 40col, monochrome, etc.
-
- Disadvantages -Does not allow for dimensioning of windows,
- it would be very difficult, if not impossible
- to save a graphics screen and have a textmode
- (or apparent texmode) overlay it. As such the
- mkwin procedure here only requires you send it
- a foreground and background color, no dimensions
- or borders as does the orginal mkwin.
-
- -Only allows for one active window at a time,
- however I suppose if you need more, you could
- also include the orginal mkwin procedure with
- some slight mods and procedure name changes and
- you could then have multiple windows. (I don't
- need this for my applications so I haven't
- really investigated the possibility)
-
- Good luck, I would appreciate any comments or suggestions.
- -- Bill Dino [76317,1205]
-
- }
-
-
- Const
-
- InitDone :boolean = false ; { Initialization switch }
-
- On = True ;
- Off = False ;
- VideoEnable = $08; { Video Signal Enable Bit }
-
- Type
- Imagetype = array [1..16383] of char; { Screen Image in the heap }
- Monotype = array [1..4096] of char; { save smaller for mono }
- Screens = record { Save Screen Information }
- Image: Imagetype; { Saved screen Image }
- monoimage: monotype;
- x,y: integer; { Saved cursor position }
- mode: integer; { Saved original mode }
- end;
-
-
- Var
-
-
- Monobuffer :Monotype absolute $B000:$0000; {Monochrome Adapter Memory}
- Colorbuffer :Imagetype absolute $B800:$0000; {Color Adapter Memory }
- CrtAdapter :integer absolute $0040:$0063; { Current Display Adapter }
- VideoMode :byte absolute $0040:$0065; { Video Port Mode byte }
- Video_Buffer:integer; { Record the current Video}
- x,y :integer;
- originalscreen: screens;
-
- {--------------------------------------------------------------------}
- { set the video mode to the that passed in the <MODE> parameter }
- {--------------------------------------------------------------------}
-
- { mode 0 -- color graphics,40 col, b&w
- mode 1 -- color graphics,40 col, color
- mode 2 -- color graphics,80 col, b&w
- mode 3 -- color graphics,80 col, color
- mode 4 -- color graphics,graphics mode, 320 x 200, color
- mode 5 -- color graphics,graphics mode, 320 x 200, b&w
- mode 6 -- color graphics,graphics mode, 640 x 200, b&w
- mode 7 -- monochrome adapter
- }
-
- procedure setmode(mode:integer);
-
-
- type
- packs= record
- ax,bx,cx,dx,bp,si,di,ds,es,flags:integer;
- end;
-
-
- var
-
- results:packs;
-
- begin
- fillchar(results,sizeof(results),0);
- results.ax:=$0000+mode; { service code 00 sets the current mode }
- intr($10,results);
- end;
-
- {--------------------------------------------------------------------}
- { check the current video mode and report ok if not in graphics }
- {--------------------------------------------------------------------}
-
-
- procedure check_video_mode(var goodmode:boolean;var currentmode:integer);
-
-
- type
- packs= record
- ax,bx,cx,dx,bp,si,di,ds,es,flags:integer;
- end;
-
-
- var
-
- results:packs;
-
- begin
- fillchar(results,sizeof(results),0);
- results.ax:=$0f00; { service code 15 reads the current mode }
- intr($10,results);
- currentmode:=lo(results.ax); { the lo byte returns the video mode }
- case currentmode of
- 0..7 : goodmode:=true;
- else goodmode:=false;
- end;
- end;
-
-
- {------------------------------------------------------------------}
- { Turn the Video On/Off to avoid Read/Write snow }
- {------------------------------------------------------------------}
- Procedure Video (Switch:boolean);
- Begin
- If (Switch = Off) then
- Port[CrtAdapter+4] := (VideoMode - VideoEnable)
- else Port[CrtAdapter+4] := (VideoMode or VideoEnable);
- End;
-
- {------------------------------------------------------------------}
- { MkWin Make a Window }
- {------------------------------------------------------------------}
- procedure MkWin( FG, BG :integer);
-
- var
- goodmode:boolean;
- old_mode:integer;
-
-
- begin
- check_video_mode(goodmode,old_mode);
- video(off);
- with originalscreen do
- begin
- case old_mode of
- 0..3 : begin
- image:=colorbuffer;
- x:=wherex;
- y:=wherey;
- end;
- 4..6 : image:=colorbuffer;
- 7: begin
- monoimage:=monobuffer;
- x:=wherex;
- y:=wherey;
- fg:=white;
- bg:=black;
- end;
- end; {case}
- mode:=old_mode {store the old mode in the original screen type}
- end; {with}
-
-
- if old_mode<>7 then setmode(3);
- video(on);
- clrscr;
- textcolor(fg);
- textbackground(bg);
- end;
-
- {------------------------------------------------------------------}
- { Remove Window }
- {------------------------------------------------------------------}
-
- Procedure RmWin;
-
- begin
- clrscr;
- video(off);
- with originalscreen do
- begin
- setmode(mode);
- video(off);
- if mode=7 then monobuffer:=monoimage else colorbuffer:=image;
- case originalscreen.mode of
- 0..3,7: gotoxy(originalscreen.x,originalscreen.y);
- end;
- video(on);
- end; {with}
- end;
- {------------------------------------------------------------------}
- .y);
- end;
-