home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / GRAPHICS.SWG / 0001_BGI Get-Put Unit.pas next >
Encoding:
Pascal/Delphi Source File  |  1996-02-21  |  6.1 KB  |  130 lines

  1. {This 2 procedures work with standard VGA (640x480x16). I did this about
  2.  4 years ago to get higher speed of handling images. There are two
  3.  restictions: 1. only NormalPut is done. (no such parameter for PutImageX8)
  4.               2. the x-position must be X mod 8 = 0.
  5.  For static images I use them often, because they are more than 4 times
  6.  faster then the BGI originals. The function ImageSize can be used to get the
  7.  required size of image.
  8.  
  9.  Dec. 13, 1995, Udo Juerss, 57078 Siegen, Germany, CompuServe [101364,526]}
  10.  
  11. procedure GetImageX8(X1,Y1,X2,Y2:Integer; var OP); assembler;
  12. var
  13.   XLen,YLen : Word;
  14.  
  15. asm
  16.     push ds                              {Verwendete Segmentregister sichern}
  17.     push es
  18.     les  di,[OP]                                  {ES:DI = Zeiger auf Bitmap}
  19.     mov  ax,X2
  20.     mov  bx,X1
  21.     and  ax,0FFF8h
  22.     add  ax,8
  23.     and  bx,0FFF8h
  24.     sub  ax,bx                                 {AX = horizontale Punktanzahl}
  25.     push ax
  26.     stosw      {Als Information f|r GetImage diesen Wert in Bitmap speichern}
  27.     mov  ax,Y2
  28.     sub  ax,Y1                                   {AX = vertikale Punktanzahl}
  29.     mov  YLen,ax                            {F|r spdteren Zdhlwert speichern}
  30.     stosw      {Als Information f|r GetImage diesen Wert in Bitmap speichern}
  31.     pop  ax
  32.     shr  ax,3
  33.     mov  XLen,ax
  34.     mov  bx,X1
  35.     shr  bx,3
  36.     mov  si,Y1
  37.     shl  si,4
  38.     mov  cx,si
  39.     shl  si,2
  40.     add  si,cx
  41.     add  si,bx                                   {SI = BPR * Y1 + (X1 shl 8)}
  42.     mov  ds,SegA000                                   {DS = Video Basissegment}
  43.     mov  dx,03CEh                     {DX = Graphics Controller Command Port}
  44.     mov  al,4                                    {Read-Map Register anwdhlen}
  45.     out  dx,al
  46.     inc  dx                              {DX = Graphics Controller Data Port}
  47.     mov  bx,YLen                                         {BX = Anzahl Zeilen}
  48.     mov  cx,XLen                                         {CX = Anzahl  Bytes}
  49.  
  50. @1: mov  al,3                                       {Maske f|r Plane 3 laden}
  51.  
  52. @2: out  dx,al                            {Plane f|r Lesezugriff selektieren}
  53.     push si                                   {Quelloffset auf Stack sichern}
  54.     push cx                                {Repetierzdhler auf Stack sichern}
  55.     rep  movsb                                        {Kopiervorgang starten}
  56.     pop  cx                                      {Repetierzdhler zur|ckholen}
  57.     pop  si                                         {Quelloffset zur|ckholen}
  58.     dec  al                                {AL = AL - 1 ndchste untere Plane}
  59.     jnl  @2                           {Wenn AL nicht < 0, dann weiter bei @2}
  60.     add  si,80                         {Quelloffset auf ndchste Zeile setzen}
  61.     dec  bx                                              {Vertikalzdhler - 1}
  62.     jnl  @1                              {Wenn nicht < 0, dann ndchste Zeile}
  63.  
  64.     pop  es                          {Verwendete Segmentregister zur|ckholen}
  65.     pop  ds
  66. end;
  67. {---------------------------------------------------------------------------}
  68.  
  69. procedure PutImageX8(XOfs,YOfs:Integer; var IP); assembler;
  70. var
  71.   XLen,YLen : Word;
  72.  
  73. asm
  74.     push  ds                             {Verwendete Segmentregister sichern}
  75.     push  es
  76.  
  77.     mov  es,SegA000                          {Basis Videosegment A000h laden}
  78.  
  79.     push ds                                                      {DS sichern}
  80.     lds  si,[IP]                                  {DS:SI = Zeiger auf Bitmap}
  81.     lodsw                                {1. Wort = Anzahl Punkte horizontal}
  82.     shr  ax,3                    {AX = Anzahl Bytes von horizontalen Punkten}
  83.     mov  XLen,ax             {Laufvariable f|r Anzahl horizontale Scanzyklen}
  84.     lodsw                         {2. Wort = Anzahl Zeilen (Punkte vertikal)}
  85.     mov  YLen,ax              {Laufvariable f|r Anzahl vertikaler Scanzyklen}
  86.     mov  di,ds                                           {DS in DI speichern}
  87.     pop  ds                         {DS zur|ckholen um Maskenarrays zu laden}
  88.     mov  ax,YOfs
  89.     shl  ax,4
  90.     mov  bx,ax
  91.     shl  ax,2
  92.     add  ax,bx
  93.     mov  bx,XOfs                  {CX = Offset linker Punkt vom Zeilenanfang}
  94.     shr  bx,3
  95.     add  ax,bx                                  {Speicheradresse von 1.Punkt}
  96.     mov  ds,di                                       {DI wieder zur|ck in DS}
  97.     mov  di,ax      {Zielregister auf Speicheradresse von 1.Punkt einstellen}
  98.  
  99.     mov  dx,03C4h                               {DX = Sequenzer Command Port}
  100.     mov  al,2                                {Das Map-Mask Register anwdhlen}
  101.     out  dx,al
  102.     inc  dx                                        {DX = Sequnezer Data Port}
  103.  
  104.     mov  bx,YLen                                         {BX = Anzahl Zeilen}
  105.     mov  cx,XLen                                         {CX = Anzahl  Bytes}
  106.  
  107. @1: mov  al,8                       {Maske f|r 3. Plane im Map-Mask Register}
  108.  
  109. @2: out  dx,al
  110.     push di                                           {Quelloffset auf Stack}
  111.     push cx                                       {Laufregister CX auf Stack}
  112.     rep  movsb                                        {Kopiervorgang starten}
  113.     pop  cx                                        {Laufregister zur|ckholen}
  114.     pop  di                                         {Quelloffset zur|ckholen}
  115.     shr  al,1                              {Maske f|r ndchste Plane erzeugen}
  116.     jnz  @2            {Wenn AL > 0, dann die gleiche Zeile nochmal kopieren}
  117.     add  di,80                            {Offset f|r ndchste Zeile addieren}
  118.     dec  bx                                   {Vertikalzdhler dekrementieren}
  119.     jnl  @1                           {Wenn BX nicht < 0, dann weiter bei @1}
  120.  
  121.     dec  dx                                     {DX = Sequenzer Command Port}
  122.     mov  ax,0F02h         {Map-Mask Register Normalzustand alle Planes aktiv}
  123.     out  dx,ax
  124.  
  125.     pop  es                                     {Segmentregister zur|ckholen}
  126.     pop  ds
  127.  
  128. end;
  129. {---------------------------------------------------------------------------}
  130.