home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ECO30603.ZIP / ECO30603.LZH / ECOLIBII / ECO_FAST.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-09-25  |  15.9 KB  |  461 lines

  1. (*
  2.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  3.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  4.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  5.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  6.     ▓▓▓▓▓▓▓▓·──                                              ──·▓▓▓▓▓▓▓▓▓▓▓
  7.     ▓▓▓▓▓▓▓▓│                                                  │░░▓▓▓▓▓▓▓▓▓
  8.     ▓▓▓▓▓▓▓▓   Unit was conceived, designed and written         ░░▓▓▓▓▓▓▓▓▓
  9.     ▓▓▓▓▓▓▓▓   by Floor A.C. Naaijkens for                      ░░▓▓▓▓▓▓▓▓▓
  10.     ▓▓▓▓▓▓▓▓   UltiHouse Software / The ECO Group.              ░░▓▓▓▓▓▓▓▓▓
  11.     ▓▓▓▓▓▓▓▓                                                    ░░▓▓▓▓▓▓▓▓▓
  12.     ▓▓▓▓▓▓▓▓   (C) MCMXCII by EUROCON PANATIONAL CORPORATION.   ░░▓▓▓▓▓▓▓▓▓
  13.     ▓▓▓▓▓▓▓▓   All Rights Reserved for The ECO Group.           ░░▓▓▓▓▓▓▓▓▓
  14.     ▓▓▓▓▓▓▓▓                                                    ░░▓▓▓▓▓▓▓▓▓
  15.     ▓▓▓▓▓▓▓▓│                                                  │░░▓▓▓▓▓▓▓▓▓
  16.     ▓▓▓▓▓▓▓▓·──                                              ──·░░▓▓▓▓▓▓▓▓▓
  17.     ▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓▓▓▓▓
  18.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  19.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  20.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  21. *)
  22. {$S-,R-,V-,D-}
  23. unit eco_fast;
  24. interface
  25. uses
  26.   dos
  27.  
  28.   ;
  29.  
  30.  
  31. type
  32.   _vectoraddr = record _ofs: word; _seg : word end;
  33.   _scnpos = record _ch : char; _attr : byte end;
  34.   _scnimage    = array[1..4000] of _scnpos;
  35.   _scnimageptr = ^_scnimage;
  36.   str80 = string[80];
  37.   _monitortype = (
  38.     _nomonitor,
  39.     _monomonitor,      { monochrome monitor             }
  40.     _colormonitor,     { color monitor (composite also) }
  41.     _enhancedmonitor,  { ega rnhanced color monitor     }
  42.     _anmonomonitor,    { ps/2 analog monochrome monitor }
  43.     _ancolormonitor    { ps/2 analog color monitor      }
  44.   );
  45.  
  46.  
  47. const
  48.   _hidemouse : boolean = true;
  49.   _video = $10;
  50.   fcol: byte = 7;
  51.   bcol: byte = 0;
  52.   bt_double    = 15;     bt_single    =   0;
  53.   black        = 00;     blue         = 01;
  54.   green        = 02;     cyan         = 03;
  55.   red          = 04;     magenta      = 05;
  56.   brown        = 06;     lightgray    = 07;
  57.   darkgray     = 08;     lightblue    = 09;
  58.   lightgreen   = 10;     lightcyan    = 11;
  59.   lightred     = 12;     lightmagenta = 13;
  60.   yellow       = 14;     white        = 15;
  61.   blink        = 128;
  62.  
  63.   _unknown     = $7f;
  64.   _absent      = 0;                 { no adapter installed           }
  65.   _mono        = 1;                 { monochrome type adapter        }
  66.   _color       = 2;                 { color type adapter             }
  67.  
  68.   _biosseg     = $0040;             { segment of bios/dos communica- }
  69.  
  70.  
  71. var
  72.   baseofscreen : word;                    {base address of video memory}
  73.   vseg : word;
  74.   vofs : word;
  75.   rows : word;
  76.   cols : word;
  77.  
  78.   _scnloc         : _scnimageptr;    { screen adapter memory location }
  79.   _curcolumns     : byte;            { number of screen columns       }
  80.   _currows        : byte;            { number of screen rows          }
  81.   _curmode        : byte;            { current video display mode     }
  82.   _curdevice      : byte;            { _mono or _color device         }
  83.   _curmonitor     : _monitortype;    { monitor attached to _curdevice }
  84.   _maxdisplaypage : byte;            { maximum display page number    }
  85.   _curdisplaypage : byte;            { current video display page     }
  86.   _curactivepage  : byte;            { current video active page      }
  87.   _monoadapter    : byte;            { monochrome adapter             }
  88.   _coloradapter   : byte;            { color/graphics adapter         }
  89.   _egaadapter     : byte;            { ega adapter                    }
  90.   _hercadapter    : byte;            { hercules mono graphics card    }
  91.   _vgaadapter     : byte;            { ps/2 video graphics array      }
  92.   _mcgaadapter    : byte;            { ps/2 model 30 adapter          }
  93.   _scrolltab      : word;            { spaces to skip for tab scroll  }
  94.   _tabincr        : word;            { tab increment for _txbufscn    }
  95.   _bufindent      : word;            { left margin for _txbufscn      }
  96.  
  97.   {scnstate_         : scnstat_;    }  { bios video save information    }
  98.   {availcolormodes_  : videomodes_; }  { modes available on color device}
  99.   {availmonomodes_   : videomodes_; }  { modes available on mono device }
  100.   {availcolorrows_   : legalrows_;  }  { rows available on color device }
  101.   {availmonorows_    : legalrows_;  }  { rows available on mono device  }
  102.   {dualdisplay_      : boolean;     }  { two adapters present           }
  103.   egamonitor_       : _monitortype;  { monitor attached: ega          }
  104.   analogmonitor_    : _monitortype;  { monitor attached: vga/mcga     }
  105.   egamemory_        : word;          { 64, 128, 192, or 256 (k)       }
  106.   maxscanline_      : byte;          { current character set size     }
  107.  
  108.  
  109.  
  110. function  at(f, b: byte): byte;
  111. procedure __scn(col, row, attr: byte; st: str80);
  112. procedure __vid(col, row:       byte; st: str80);
  113. procedure changeattr(col,row,attr: byte; number: word);
  114. function  get_video_mode: byte;
  115.  
  116. { extended functions, just like in eco_vid, but for small use }
  117. procedure __attrib(x1, y1, x2, y2, f, b: byte);
  118. procedure __bandwin(del: boolean; x1,y1,x2,y2,f,b,bt: byte);
  119. procedure __betwscn(x1, x2, y, f, b: byte; st: string);
  120. procedure __boxscn(x1,y1,x2,y2,boxtype,fore,back : byte);
  121. procedure __clrscn(x1, y1, x2, y2, f, b: byte; c: char);
  122. procedure __cls;
  123. procedure __copyscn(x1, y1, x2, y2, x, y: byte);
  124. function  __rep(n: byte; character: char): string;
  125. function  __retdvscn(var mode, cols, rows, activepage, displaypage: byte): byte;
  126. procedure __vert(x, y, f, b: byte; s: string);
  127. procedure __write(col, row, f, b: byte; st: str80);
  128.  
  129.  
  130. implementation
  131.  
  132.  
  133.  
  134.   function __rep(n: byte; character: char): string;
  135.   var tempstr: string;
  136.   begin
  137.     if n = 0 then tempstr := '' else begin
  138.       if (n > 255) then n := 1; fillchar(tempstr,n+1,character);
  139.       tempstr[0] := chr(n);
  140.     end; __rep := tempstr;
  141.   end;
  142.  
  143.  
  144.   {$F+}
  145.   {$L ECO_FAST.OBJ}
  146.   function at(f,b:byte): byte; begin at := (b shl 4) or f end;
  147.   procedure __scn(col,row,attr:byte; st: str80); external;
  148.   procedure __vid(col,row:     byte; st: str80); external;
  149.   procedure changeattr(col,row,attr:byte; number:word); external;
  150.   procedure __speedscn(
  151.     sourceptr,targetptr : pointer;
  152.         count,option,attribute : word;
  153.         wait : boolean
  154.   ); external;
  155.   {$F-}
  156.  
  157.  
  158.   function __retdvscn(var mode, cols, rows, activepage, displaypage: byte): byte;
  159.   var
  160.     reg         : registers;
  161.     charheight  : word;
  162.  
  163.   begin
  164.     with reg do begin
  165.       ax := $0f00; intr(_video,reg); mode := al; cols := ah; activepage := bh
  166.     end;
  167.     if (mode = 7) then begin
  168.       _curdevice := _mono;
  169.       _scnloc    := ptr($b000,$0000)
  170.     end else if (mode < 13) then begin
  171.       _curdevice := _color;
  172.       _scnloc    := ptr($b000,$8000)
  173.     end else begin
  174.       if (mode = 15) then _curdevice := _mono else _curdevice := _color;
  175.       _scnloc := ptr($a000,$0000)
  176.     end;
  177.     with reg do begin
  178.       es := _vectoraddr(_scnloc)._seg;
  179.       di := _vectoraddr(_scnloc)._ofs;
  180.       ah := $fe;
  181.       intr(_video,reg);
  182.       inline($fb);
  183.       _scnloc := ptr(es,di)
  184.     end;
  185.     if ((_curdevice = _hercadapter) or (_curdevice = _monoadapter)) then begin
  186.       _curmonitor := _monomonitor;
  187.       charheight  := 14
  188.     end else if (_curdevice = _coloradapter) then begin
  189.       _curmonitor := _colormonitor;
  190.       charheight  := 8
  191.     end else if (
  192.       _curdevice = _egaadapter
  193.     ) then _curmonitor := egamonitor_ else if (
  194.       (_curdevice = _vgaadapter) or
  195.       (_curdevice = _mcgaadapter)
  196.     ) then _curmonitor := analogmonitor_ else _curmonitor := _nomonitor;
  197.     if (
  198.       (_egaadapter = _curdevice) or (_mcgaadapter = _curdevice) or
  199.       (_vgaadapter = _curdevice)
  200.     ) then with reg do begin
  201.       ax := $1130;
  202.       bx := 0;
  203.       intr(_video,reg);
  204.       rows := dl + 1;
  205.       charheight := cx
  206.     end else rows := 25;
  207.     case mode of
  208.       4..6,8..10,17..19: _maxdisplaypage := 0;
  209.       0,1: if (rows = 50) then _maxdisplaypage := 6 else _maxdisplaypage := 7;
  210.       2,3,7: begin
  211.         if (_curdevice = _mono) then _maxdisplaypage := 0 else
  212.           _maxdisplaypage := 3;
  213.         if (_curdevice = _vgaadapter) then case rows of
  214.           25    : _maxdisplaypage := 7;
  215.           43,50 : _maxdisplaypage := 3
  216.         end;
  217.         if (_curdevice = _egaadapter) then begin
  218.           if (egamemory_ > 64) then _maxdisplaypage := 7 else
  219.             _maxdisplaypage := 3;
  220.           if (rows = 43) then _maxdisplaypage := _maxdisplaypage div 2
  221.         end
  222.       end;
  223.       13: begin
  224.         _maxdisplaypage := 7;
  225.         if (_egaadapter = _curdevice) then if (egamemory_ = 64) then
  226.           _maxdisplaypage := 1 else if (egamemory_ = 128) then
  227.           _maxdisplaypage := 3;
  228.       end;
  229.       14: begin
  230.         _maxdisplaypage := 3;
  231.         if (_egaadapter = _curdevice) then if (egamemory_ = 64) then
  232.           _maxdisplaypage := 0 else if (egamemory_ = 128) then
  233.           _maxdisplaypage := 1
  234.       end;
  235.       15..16: begin
  236.         _maxdisplaypage := 1;
  237.         if (_egaadapter = _curdevice) then if (egamemory_ = 64) then
  238.           _maxdisplaypage := 0;
  239.       end;
  240.     end;
  241.  
  242.     displaypage    := _curdisplaypage;
  243.     _curmode       := mode;
  244.     _currows       := rows;
  245.     _curcolumns    := cols;
  246.     _curactivepage := activepage;
  247.     maxscanline_   := charheight - 1;
  248.     __retdvscn     := _curdevice
  249.   end;
  250.  
  251.  
  252.   function get_video_mode:byte;
  253.   var regs : registers;
  254.   begin
  255.    with regs do begin
  256.      ax := $0f00; intr($10,regs); get_video_mode := al;
  257.    end; {with}
  258.   end; {of proc video_mode}
  259.  
  260.  
  261.   procedure __movescn(
  262.     x1, y1, x2, y2: byte; bufferptr: pointer; toscreen: boolean
  263.   );
  264.   var
  265.     bufptr      : _scnimageptr absolute bufferptr;
  266.     scnptr      : _scnimageptr;
  267.     pagelength  : word absolute _biosseg:$004c;
  268.     offset      : word;                { offset into video buffer       }
  269.     width       : word;                { width, in pairs, of each line  }
  270.     delta       : word;                { increment between data lines   }
  271.     lines       : word;                { number of lines to access      }
  272.     wait        : boolean;
  273.     i,j,k       : word;
  274.  
  275.   begin {__movescn}
  276.     if ((_curmode > 3) and (_curmode <> 7)) then exit; { not textmode }
  277.     if (x1 < 1) then x1 := 1 else if (x1 > _curcolumns) then x1 := _curcolumns;
  278.     if (y1 < 1) then y1 := 1 else if (y1 > _currows) then y1 := _currows;
  279.     if (x2 < x1) then x2 := x1 else if (x2>_curcolumns) then x2 := _curcolumns;
  280.     if (y2 < y1) then y2 := y1 else if (y2 > _currows) then y2 := _currows;
  281.     offset := ((y1 - 1) * _curcolumns) + x1;
  282.     width  := x2 - x1 + 1; delta  := _curcolumns - x2 + x1 - 1;
  283.     lines  := y2 - y1 + 1;
  284.     if (_curdisplaypage <> 0) then scnptr := ptr(
  285.       _vectoraddr(_scnloc)._seg,
  286.      _vectoraddr(_scnloc)._ofs + (pagelength * _curdisplaypage)
  287.     ) else scnptr := _scnloc;
  288.     wait := false;
  289.  
  290.     j := offset; k := 1;
  291.     for i := 1 to lines do begin
  292.       if (toscreen) then __speedscn(
  293.         @bufptr^[k], @scnptr^[j], width, 2, 0, wait
  294.       ) else __speedscn(
  295.         @scnptr^[j], @bufptr^[k], width, 3, 0, wait
  296.       );
  297.       inc(j,width + delta);
  298.       inc(k,width);
  299.     end
  300.   end; { __movescn }
  301.  
  302.  
  303.  
  304.   procedure __boxscn(x1,y1,x2,y2,boxtype,fore,back : byte);
  305.   const
  306.     corners : array[1..4,0..3] of char = (
  307.       (#218,#214,#213,#201),   { top left corner        }
  308.       (#191,#184,#183,#187),   { top right corner       }
  309.       (#192,#211,#212,#200),   { bottom left    }
  310.       (#217,#189,#190,#188)    { bottom right   }
  311.     );
  312.  
  313.     lines : array[1..2,0..1] of char = (
  314.       (#196,#205),                 { horizontal         }
  315.       (#179,#186)
  316.     );                             { vertical           }
  317.  
  318.  
  319.   var
  320.     boxcorner     : array[1..4] of char;
  321.     boxline       : array[1..4] of char;
  322.     boxchar       : char;
  323.     horchars      : byte;
  324.     verchars      : byte;
  325.     i             : word;
  326.     cursoron      : boolean;
  327.     x,y,xtop,xbot : byte;
  328.  
  329.   begin
  330.     if (boxtype > 15) then begin
  331.       boxchar := chr(boxtype);
  332.       fillchar(boxcorner,4,boxchar);
  333.       fillchar(boxline,4,boxchar)
  334.     end else begin
  335.       boxcorner[1] := corners[1,(boxtype and 3)];
  336.       boxcorner[2] := corners[2,((boxtype shr 1) and 3)];
  337.       boxcorner[3] := corners[3,
  338.           ((boxtype and 1) or ( 2 * ((boxtype shr 3) and 1)))];
  339.       boxcorner[4] := corners[4,((boxtype shr 2) and 3)];
  340.       boxline[1]   := lines[1,((boxtype shr 1) and 1)];
  341.       boxline[2]   := lines[1,((boxtype shr 3) and 1)];
  342.       boxline[3]   := lines[2,(boxtype and 1)];
  343.       boxline[4]   := lines[2,((boxtype shr 2) and 1)]
  344.     end;
  345.     horchars := x2 - x1 - 1; verchars := y2 - y1 - 1;
  346.     __write(x1, y1, fore, back, boxcorner[1]);
  347.     if (horchars > 0) then __write(x1 + 1, y1, fore, back, __rep(horchars, boxline[1]));
  348.     __write(x2, y1, fore, back, boxcorner[2]);
  349.     for i := 1 to verchars do begin
  350.       __write(x1, y1 + i, fore, back, boxline[3]);
  351.       __write(x2, y1 + i, fore, back, boxline[4])
  352.     end;
  353.     __write(x1, y2, fore, back, boxcorner[3]);
  354.     if (horchars > 0) then __write(
  355.       x1 + 1, y2, fore,back, __rep(horchars, boxline[2])
  356.     );
  357.     __write(x2, y2, fore, back, boxcorner[4]);
  358.   end;   { __boxscn }
  359.  
  360.  
  361.   procedure __write(col, row, f, b: byte; st: str80);
  362.   begin
  363.     __scn(col, row, at(f, b), st);
  364.   end;
  365.  
  366.  
  367.   procedure __attrib(x1, y1, x2, y2, f, b: byte);
  368.   var i: byte;
  369.   begin
  370.     for i := y1 to y2 do changeattr(x1, i, at(f, b), succ(x2-x1))
  371.   end;
  372.  
  373.  
  374.  
  375.   procedure __bandwin(del: boolean; x1, y1, x2, y2, f, b, bt: byte);
  376.   var
  377.     br, ht,
  378.     vt, mih,
  379.     miv      : byte;
  380.  
  381.   begin
  382.     if del then begin
  383.       miv := y1 + (y2-y1) div 2; mih := x1 + (x2-x1) div 2;
  384.       if y2-y1>5 then vt := 2 else vt := 1;
  385.       if x2-x1>20 then ht := 5 else ht := 3;
  386.       __clrscn(mih - ht, miv - vt + 1, mih + ht, miv + vt, f, b, ' ');
  387.       __boxscn(mih - ht, miv - vt + 1, mih + ht, miv + vt, 15, f, b);
  388.     end;
  389.     if bt=1 then br := 00 else br := 15;
  390.     if _currows = 25 then begin
  391.       __attrib(x1-1, y2+2, x2+5, y2+2, lightgray, black);
  392.       __attrib(x2+2, y1, x2+5, y2+2, lightgray, black);
  393.       __clrscn(x1-3, y1-1, x2+3, y2+1, f, b, ' ');
  394.     end else begin
  395.       __attrib(x1, y2+2, x2+2, y2+2, lightgray, black);
  396.       __attrib(x2+1, y1, x2+2, y2+2, lightgray, black);
  397.       __clrscn(x1-1, y1-1, x2+1, y2+1, f, b, ' ');
  398.     end;
  399.     __boxscn(x1, y1, x2, y2, br, f, b);
  400.   end;
  401.  
  402.  
  403.   procedure __vert(x, y, f, b: byte; s: string);
  404.   var i: byte;
  405.   begin
  406.     for i := 1 to length(s) do __write(x, y + i - 1, f, b, s[i]);
  407.   end;
  408.  
  409.  
  410.   procedure __betwscn(x1, x2, y, f, b: byte; st: string);
  411.   var x : integer;
  412.  
  413.   begin
  414.     if length(st) >= x2 - x1 + 1 then __write(x1, y, f, b, st) else begin
  415.       x := x1 + (x2 - x1 + 1 - length(st)) div 2;
  416.       __write(x, y, f, b, st);
  417.     end;
  418.   end;
  419.  
  420.  
  421.   procedure __clrscn(x1, y1, x2, y2, f, b: byte; c: char);
  422.   var
  423.     y      : integer;
  424.  
  425.   begin
  426.     if x2 > 80 then x2 := 80;
  427.     for y := y1 to y2 do __write(x1, y, f, b, __rep(x2-x1+1, c));
  428.   end;
  429.  
  430.  
  431.  
  432.   procedure __cls;
  433.   begin
  434.     __clrscn(1, 1, _curcolumns, _currows, 7, 0, ' ');
  435.   end;
  436.  
  437.  
  438.   procedure __copyscn(x1, y1, x2, y2, x, y: byte);
  439.   var buffer: _scnimage;
  440.   begin
  441.     __movescn(x1, y1, x2, y2, @buffer, false);
  442.     __movescn(x, y, x+x2-x1, y+y2-y1, @buffer, true);
  443.   end;
  444.  
  445.  
  446.   procedure initquickwriteunit;
  447.   begin
  448.     if get_video_mode = 7 then baseofscreen := $b000 else baseofscreen := $b800;
  449.     vseg := baseofscreen; vofs := 0;
  450.   end;
  451.  
  452.  
  453. begin
  454.   initquickwriteunit;
  455.   _curdisplaypage := 0;
  456.   _curdevice := __retdvscn(
  457.     _curmode,_curcolumns,_currows,
  458.         _curactivepage,_curdisplaypage
  459.   );
  460. end.
  461.