Browse Source

* putimage now performs the lipping itself and uses directputpixel
(note: this REQUIRES or/and/notput support in directputpixel,
this is not yet the case in the assembler versions!)
* YOffset addition moved in hlinevesa256 and vlinevesa256
because it uses still putpixel afterwards

Jonas Maebe 26 years ago
parent
commit
91fca2d81f
3 changed files with 82 additions and 36 deletions
  1. 12 5
      rtl/go32v2/graph.inc
  2. 12 9
      rtl/go32v2/vesa.inc
  3. 58 22
      rtl/inc/graph/graph.pp

+ 12 - 5
rtl/go32v2/graph.inc

@@ -7,9 +7,6 @@
 {$endif DPMI}
 
 {$ifndef fpc}
-  {$ifndef noasmgraph}
-    {$define asmgraph}
-  {$endif noasmgraph}
   {$i dpmi.inc}
 {$else fpc}
   {$asmmode intel}
@@ -588,6 +585,7 @@ End;
     PortW[$3ce] := $ff08;
     PortW[$3ce] := $0001;
 {$else asmgraph}
+{ note: still needs xor/or/and/notput support !!!!! (JM) }
     asm
   {$ifndef fpc}
       mov  es, [SegA000]
@@ -1099,6 +1097,7 @@ End;
    Mem[SegA000:offset] := dummy;
  end;
 {$else asmgraph}
+{ note: still needs or/and/notput support !!!!! (JM) }
   assembler;
     asm
   {$ifndef fpc}
@@ -1435,6 +1434,7 @@ const CrtAddress: word = 0;
    Mem[Sega000: offset] := Dummy;
  end;
 {$else asmgraph}
+{ note: still needs or/and/notput support !!!!! (JM) }
  Assembler;
  asm
    mov di,[Y]                   ; (* DI = Y coordinate                 *)
@@ -2512,7 +2512,14 @@ const CrtAddress: word = 0;
 
 {
 $Log$
-Revision 1.6  1999-12-11 23:41:39  jonas
+Revision 1.7  1999-12-12 13:34:19  jonas
+  * putimage now performs the lipping itself and uses directputpixel
+    (note: this REQUIRES or/and/notput support in directputpixel,
+    this is not yet the case in the assembler versions!)
+  * YOffset addition moved in hlinevesa256 and vlinevesa256
+    because it uses still putpixel afterwards
+
+Revision 1.6  1999/12/11 23:41:39  jonas
   * changed definition of getscanlineproc to "getscanline(x1,x2,y:
     integer; var data);" so it can be used by getimage too
   * changed getimage so it uses getscanline
@@ -2627,7 +2634,7 @@ Revision 1.10  1999/09/11 19:43:01  jonas
 Revision 1.9  1999/08/01 14:50:51  jonas
   * fixed hline16 and vline16 for notput (also TP supPorts copy, and, or, xor and
     notput for lines!!)
-  * fixed directputpixel16 to supPort all the different put types
+  * fixed directputpixel16 to support all the different put types
 
 Revision 1.8  1999/07/18 15:07:19  jonas
   + xor-, and and- orput supPort for VESA256 modes

+ 12 - 9
rtl/go32v2/vesa.inc

@@ -432,8 +432,7 @@ end;
      offs : longint;
      col : byte;
   begin
-     y := y + YOffset;
-     offs := longint(y) * BytesPerLine + x;
+     offs := (longint(y) + YOffset) * BytesPerLine + x;
      Case CurrentWriteMode of
        XorPut:
          Begin
@@ -472,7 +471,7 @@ end;
      GetPixVESA256:=mem[WinReadSeg : word(offs)];
   end;
 
-  Procedure GetScanLineVESA256(x1, x2, y: integer; var data);
+  Procedure GetScanLineVESA256(x1, x2, y: integer; var data); {$ifndef fpc}far;{$endif}
   var offs: Longint;
       l, amount, bankrest, index, pixels: longint;
       x, curbank: integer;
@@ -573,7 +572,6 @@ end;
                 StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
             exit;
       end;
-    Y:= Y + YOffset; { Adjust for correct virtual page }
     {$ifdef logging}
     LogLn('hline '+strf(x)+' - '+strf(x2)+' on '+strf(y)+' in mode '+strf(currentwritemode));
     {$endif logging}
@@ -583,7 +581,7 @@ end;
     {$endif logging}
     if HLength>0 then
       begin
-         Offs:=Longint(y)*bytesperline+x;
+         Offs:=(Longint(y)+YOffset)*bytesperline+x;
          {$ifdef logging}
          LogLn('Offs: '+strf(offs)+' -- '+hexstr(offs,8));
          {$endif logging}
@@ -849,8 +847,6 @@ end;
                 StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
             exit;
       end;
-    Y := Y + YOffset;
-    Y2 := Y2 + YOffset; { adjust for current virtual page }
     Col := Byte(CurrentColor);
     {$ifdef logging}
     LogLn('vline '+strf(y)+' - '+strf(y2)+' on '+strf(x)+' in mode '+strf(currentwritemode));
@@ -861,7 +857,7 @@ end;
     {$endif logging}
     if VLength>0 then
       begin
-         Offs:=Longint(y)*bytesperline+x;
+         Offs:=(Longint(y)+YOffset)*bytesperline+x;
          {$ifdef logging}
          LogLn('Offs: '+strf(offs)+' -- '+hexstr(offs,8));
          {$endif logging}
@@ -2373,7 +2369,14 @@ end;
 
 {
 $Log$
-Revision 1.8  1999-12-11 23:41:39  jonas
+Revision 1.9  1999-12-12 13:34:20  jonas
+  * putimage now performs the lipping itself and uses directputpixel
+    (note: this REQUIRES or/and/notput support in directputpixel,
+    this is not yet the case in the assembler versions!)
+  * YOffset addition moved in hlinevesa256 and vlinevesa256
+    because it uses still putpixel afterwards
+
+Revision 1.8  1999/12/11 23:41:39  jonas
   * changed definition of getscanlineproc to "getscanline(x1,x2,y:
     integer; var data);" so it can be used by getimage too
   * changed getimage so it uses getscanline

+ 58 - 22
rtl/inc/graph/graph.pp

@@ -187,7 +187,6 @@ Unit Graph;
 {   - optimize InternalEllipse()                         }
 {      using linear appx. of sine/cosine tables          }
 {   - justification for stroked fonts does not work      }
-{   - On Closegraph deallocate all font pointers         }
 {--------------------------------------------------------}
 
 { text.inc will crash on aligned requirement machines.          }
@@ -1956,36 +1955,66 @@ type
   pt = array[0..$fffffff] of word;
   ptw = array[0..2] of longint;
 var
-  color: word;
-  i,j: Integer;
-  Y1,X1: Integer;
   k: longint;
+  oldCurrentColor, color: word;
+  oldCurrentWriteMode, i, j, y1, x1, deltaX, deltaX1, deltaY: Integer;
 Begin
-  X1:= ptw(Bitmap)[0]+X; { get width and adjust end coordinate accordingly }
-  Y1:= ptw(Bitmap)[1]+Y; { get height and adjust end coordinate accordingly }
-  k:= 3 * Sizeof(longint) div Sizeof(word); { Three reserved longs at start of bitmap }
+{$ifdef logging}
+  LogLn('putImage at ('+strf(x)+','+strf(y)+') with width '+strf(ptw(Bitmap)[0])+
+    ' and height '+strf(ptw(Bitmap)[1]));
+  deltaY := 0;
+{$endif logging}
+  inc(x,startXViewPort);
+  inc(y,startYViewPort);
+  x1 := ptw(Bitmap)[0]+x; { get width and adjust end coordinate accordingly }
+  y1 := ptw(Bitmap)[1]+y; { get height and adjust end coordinate accordingly }
+
+  deltaX := 0;
+  deltaX1 := 0;
+  k := 3 * sizeOf(Longint) div sizeOf(Word); { Three reserved longs at start of bitmap }
+ { check which part of the image is in the viewport }
+  if clipPixels then
+    begin
+      if y < startYViewPort then
+        begin
+          deltaY := startYViewPort - y;
+          inc(k,(x1-x+1)*deltaY);
+          y := startYViewPort;
+         end;
+      if y1 > startYViewPort+viewHeight then
+        y1 := startYViewPort+viewHeight;
+      if x < startXViewPort then
+        begin
+          deltaX := startXViewPort-x;
+          x := startXViewPort;
+        end;
+      if x1 > startXViewPort + viewWidth then
+        begin
+          deltaX1 := x1 - (startXViewPort + viewWidth);
+          x1 := startXViewPort + viewWidth;
+        end;
+    end;
+{$ifdef logging}
+  LogLn('deltax: '+strf(deltax)+', deltax1: '+strf(deltax1)+',deltay: '+strf(deltay));
+{$endif logging}
+  oldCurrentColor := currentColor;
+  oldCurrentWriteMode := currentWriteMode;
+  currentWriteMode := bitBlt;
   for j:=Y to Y1 do
    Begin
+     inc(k,deltaX);
      for i:=X to X1 do
       begin
-        case BitBlt of
-{$R-}
-          CopyPut: color:= pt(Bitmap)[k];  { also = normalput }
-          XORPut: color:= pt(Bitmap)[k] XOR GetPixel(i,j);
-          OrPut: color:= pt(Bitmap)[k] OR GetPixel(i,j);
-          AndPut: color:= pt(Bitmap)[k] AND GetPixel(i,j);
-          NotPut: color:= not pt(Bitmap)[k];
-{$ifdef debug}
-{$R+}
-{$endif debug}
-        end;
-        putpixel(i,j,color);
-        Inc(k);
+        currentColor := pt(bitmap)[k];
+        directPutPixel(i,j);
+        inc(k);
      end;
+     inc(k,deltaX1);
    end;
+  currentWriteMode := oldCurrentWriteMode;
+  currentColor := oldCurrentColor;
 end;
 
-
 Procedure DefaultGetImage(X1,Y1,X2,Y2: Integer; Var Bitmap); {$ifndef fpc}far;{$endif fpc}
 type
   pt = array[0..$fffffff] of word;
@@ -3005,7 +3034,14 @@ SetGraphBufSize
 
 {
   $Log$
-  Revision 1.46  1999-12-11 23:41:38  jonas
+  Revision 1.47  1999-12-12 13:34:20  jonas
+    * putimage now performs the lipping itself and uses directputpixel
+      (note: this REQUIRES or/and/notput support in directputpixel,
+      this is not yet the case in the assembler versions!)
+    * YOffset addition moved in hlinevesa256 and vlinevesa256
+      because it uses still putpixel afterwards
+
+  Revision 1.46  1999/12/11 23:41:38  jonas
     * changed definition of getscanlineproc to "getscanline(x1,x2,y:
       integer; var data);" so it can be used by getimage too
     * changed getimage so it uses getscanline