Browse Source

* fix GraphUpdateScreen procedure

pierre 23 years ago
parent
commit
e78911a9f3
2 changed files with 110 additions and 28 deletions
  1. 55 14
      fv/gfvgraph.pas
  2. 55 14
      fvision/gfvgraph.pas

+ 55 - 14
fv/gfvgraph.pas

@@ -225,6 +225,8 @@ CONST
 {$ifdef USE_VIDEO_API}
 {$ifdef USE_VIDEO_API}
    SysFontWidth   : Integer = 8;                      { System font width }
    SysFontWidth   : Integer = 8;                      { System font width }
    SysFontHeight  : Integer = 16;                     { System font height }
    SysFontHeight  : Integer = 16;                     { System font height }
+   TextScreenWidth : Integer = 80;
+   TextScreenHeight : Integer = 25;
 {$endif USE_VIDEO_API}
 {$endif USE_VIDEO_API}
 
 
 {$ifdef DEBUG}
 {$ifdef DEBUG}
@@ -338,6 +340,29 @@ BEGIN
 {$IFDEF GRAPH_API}
 {$IFDEF GRAPH_API}
    End Else Begin                                     { GRAPHICS MODE GFV }
    End Else Begin                                     { GRAPHICS MODE GFV }
      Graph.SetViewPort(X1, Y1, X2, Y2, Clip);         { Call graph proc }
      Graph.SetViewPort(X1, Y1, X2, Y2, Clip);         { Call graph proc }
+     X1:=X1 div SysFontWidth;
+     X2:=X2 div SysFontWidth;
+     Y1:=Y1 div SysFontHeight;
+     Y2:=Y2 div SysFontHeight;
+     If (X1 < 0) Then X1 := 0;                        { X1 negative fix }
+     If (X1 >SysScreenWidth) Then
+       X1 := SysScreenWidth;                             { X1 off screen fix }
+     If (Y1 < 0) Then Y1 := 0;                        { Y1 negative fix }
+     If (Y1 > SysScreenHeight) Then
+       Y1 := SysScreenHeight;                            { Y1 off screen fix }
+     If (X2 < 0) Then X2 := 0;                        { X2 negative fix }
+     If (X2 > SysScreenWidth) Then
+       X2 := SysScreenWidth;                             { X2 off screen fix }
+     If (Y2 < 0) Then Y2 := 0;                        { Y2 negative fix }
+     If (Y2 > SysScreenHeight) Then
+       Y2 := SysScreenHeight;                            { Y2 off screen fix }
+     ViewPort.X1 := X1;                               { Set X1 port value }
+     ViewPort.Y1 := Y1;                               { Set Y1 port value }
+     ViewPort.X2 := X2;                               { Set X2 port value }
+     ViewPort.Y2 := Y2;                               { Set Y2 port value }
+     ViewPort.Clip := Clip;                           { Set port clip value }
+     Cxp := X1;                                       { Set current x pos }
+     Cyp := Y1;                                       { Set current y pos }
    End;
    End;
 {$ENDIF GRAPH_API}
 {$ENDIF GRAPH_API}
 END;
 END;
@@ -427,6 +452,8 @@ var
    SavedColor,SavedBkColor : longint;
    SavedColor,SavedBkColor : longint;
    CurColor,CurBkColor : longint;
    CurColor,CurBkColor : longint;
    NextColor,NextBkColor : longint;
    NextColor,NextBkColor : longint;
+   StoreFillSettings: FillSettingsType;
+
 
 
 begin
 begin
 {$IFDEF GRAPH_API}
 {$IFDEF GRAPH_API}
@@ -454,38 +481,49 @@ begin
       SavedBkColor:=Graph.GetBkColor;
       SavedBkColor:=Graph.GetBkColor;
       CurColor:=SavedColor;
       CurColor:=SavedColor;
       CurBkColor:=SavedBkColor;
       CurBkColor:=SavedBkColor;
-      for y := 0 to ScreenHeight - 1 do
+      Graph.GetFillSettings(StoreFillSettings);
+      Graph.SetFillStyle(EmptyFill,0);
+      for y := 0 to TextScreenHeight - 1 do
         begin
         begin
-           for x := 0  to ScreenWidth - 1 do
+           for x := 0  to TextScreenWidth - 1 do
              begin
              begin
-               i:=y*ScreenWidth+x;
+               i:=y*TextScreenWidth+x;
                if OldVideoBuf^[i]<>VideoBuf^[i] then
                if OldVideoBuf^[i]<>VideoBuf^[i] then
                  begin
                  begin
                    ch:=chr(VideoBuf^[i] and $ff);
                    ch:=chr(VideoBuf^[i] and $ff);
                    if ch<>#0 then
                    if ch<>#0 then
                      begin
                      begin
-                       Attr:=VideoBuf^[i] shr 16;
+                       Attr:=VideoBuf^[i] shr 8;
                        NextColor:=Attr and $f;
                        NextColor:=Attr and $f;
-                       NextBkColor:=(Attr and $70) shr 8;
+                       NextBkColor:=(Attr and $70) shr 4;
+                       if NextBkColor<>CurBkColor then
+                         begin
+                           Graph.SetBkColor(NextBkColor);
+                           CurBkColor:=NextBkColor;
+                         end;
+
+                       Graph.Bar(x*SysFontWidth,y*SysFontHeight,(x+1)*SysFontWidth,(y+1)*SysFontHeight);
                        if NextColor<>CurColor then
                        if NextColor<>CurColor then
                          begin
                          begin
-                           SetColor(NextColor);
+                           Graph.SetColor(NextColor);
                            CurColor:=NextColor;
                            CurColor:=NextColor;
                          end;
                          end;
-                       if NextBkColor<>CurBkColor then
+                       { SetBkColor does change the palette index 0 entry...
+                         which leads to troubles if we want to write in dark }
+                       if (CurColor=0) then
                          begin
                          begin
-                           SetBkColor(NextBkColor);
-                           CurBkColor:=NextBkColor;
+                           Graph.SetBkColor(0);
+                           CurBkColor:=0;
                          end;
                          end;
-                       Bar(x*SysFontWidth,y*SysFontHeight,(x+1)*SysFontWidth,(y+1)*SysFontHeight);
-                       OutTextXY(x*SysFontWidth,y*SysFontHeight,ch);
+                       Graph.OutTextXY(x*SysFontWidth,y*SysFontHeight,ch);
                      end;
                      end;
                    OldVideoBuf^[i]:=VideoBuf^[i];
                    OldVideoBuf^[i]:=VideoBuf^[i];
                  end;
                  end;
              end;
              end;
         end;
         end;
-      SetColor(SavedColor);
-      SetBkColor(SavedBkColor);
+      Graph.SetFillStyle(StoreFillSettings.pattern,StoreFillSettings.color);
+      Graph.SetColor(SavedColor);
+      Graph.SetBkColor(SavedBkColor);
     end;
     end;
 {$else not USE_VIDEO_API}
 {$else not USE_VIDEO_API}
   RunError(219);
   RunError(219);
@@ -497,7 +535,10 @@ end;
 END.
 END.
 {
 {
  $Log$
  $Log$
- Revision 1.12  2002-05-28 19:42:32  pierre
+ Revision 1.13  2002-05-29 19:35:31  pierre
+  * fix GraphUpdateScreen procedure
+
+ Revision 1.12  2002/05/28 19:42:32  pierre
   * fix non graphic mode compilation
   * fix non graphic mode compilation
 
 
  Revision 1.11  2002/05/28 19:13:44  pierre
  Revision 1.11  2002/05/28 19:13:44  pierre

+ 55 - 14
fvision/gfvgraph.pas

@@ -225,6 +225,8 @@ CONST
 {$ifdef USE_VIDEO_API}
 {$ifdef USE_VIDEO_API}
    SysFontWidth   : Integer = 8;                      { System font width }
    SysFontWidth   : Integer = 8;                      { System font width }
    SysFontHeight  : Integer = 16;                     { System font height }
    SysFontHeight  : Integer = 16;                     { System font height }
+   TextScreenWidth : Integer = 80;
+   TextScreenHeight : Integer = 25;
 {$endif USE_VIDEO_API}
 {$endif USE_VIDEO_API}
 
 
 {$ifdef DEBUG}
 {$ifdef DEBUG}
@@ -338,6 +340,29 @@ BEGIN
 {$IFDEF GRAPH_API}
 {$IFDEF GRAPH_API}
    End Else Begin                                     { GRAPHICS MODE GFV }
    End Else Begin                                     { GRAPHICS MODE GFV }
      Graph.SetViewPort(X1, Y1, X2, Y2, Clip);         { Call graph proc }
      Graph.SetViewPort(X1, Y1, X2, Y2, Clip);         { Call graph proc }
+     X1:=X1 div SysFontWidth;
+     X2:=X2 div SysFontWidth;
+     Y1:=Y1 div SysFontHeight;
+     Y2:=Y2 div SysFontHeight;
+     If (X1 < 0) Then X1 := 0;                        { X1 negative fix }
+     If (X1 >SysScreenWidth) Then
+       X1 := SysScreenWidth;                             { X1 off screen fix }
+     If (Y1 < 0) Then Y1 := 0;                        { Y1 negative fix }
+     If (Y1 > SysScreenHeight) Then
+       Y1 := SysScreenHeight;                            { Y1 off screen fix }
+     If (X2 < 0) Then X2 := 0;                        { X2 negative fix }
+     If (X2 > SysScreenWidth) Then
+       X2 := SysScreenWidth;                             { X2 off screen fix }
+     If (Y2 < 0) Then Y2 := 0;                        { Y2 negative fix }
+     If (Y2 > SysScreenHeight) Then
+       Y2 := SysScreenHeight;                            { Y2 off screen fix }
+     ViewPort.X1 := X1;                               { Set X1 port value }
+     ViewPort.Y1 := Y1;                               { Set Y1 port value }
+     ViewPort.X2 := X2;                               { Set X2 port value }
+     ViewPort.Y2 := Y2;                               { Set Y2 port value }
+     ViewPort.Clip := Clip;                           { Set port clip value }
+     Cxp := X1;                                       { Set current x pos }
+     Cyp := Y1;                                       { Set current y pos }
    End;
    End;
 {$ENDIF GRAPH_API}
 {$ENDIF GRAPH_API}
 END;
 END;
@@ -427,6 +452,8 @@ var
    SavedColor,SavedBkColor : longint;
    SavedColor,SavedBkColor : longint;
    CurColor,CurBkColor : longint;
    CurColor,CurBkColor : longint;
    NextColor,NextBkColor : longint;
    NextColor,NextBkColor : longint;
+   StoreFillSettings: FillSettingsType;
+
 
 
 begin
 begin
 {$IFDEF GRAPH_API}
 {$IFDEF GRAPH_API}
@@ -454,38 +481,49 @@ begin
       SavedBkColor:=Graph.GetBkColor;
       SavedBkColor:=Graph.GetBkColor;
       CurColor:=SavedColor;
       CurColor:=SavedColor;
       CurBkColor:=SavedBkColor;
       CurBkColor:=SavedBkColor;
-      for y := 0 to ScreenHeight - 1 do
+      Graph.GetFillSettings(StoreFillSettings);
+      Graph.SetFillStyle(EmptyFill,0);
+      for y := 0 to TextScreenHeight - 1 do
         begin
         begin
-           for x := 0  to ScreenWidth - 1 do
+           for x := 0  to TextScreenWidth - 1 do
              begin
              begin
-               i:=y*ScreenWidth+x;
+               i:=y*TextScreenWidth+x;
                if OldVideoBuf^[i]<>VideoBuf^[i] then
                if OldVideoBuf^[i]<>VideoBuf^[i] then
                  begin
                  begin
                    ch:=chr(VideoBuf^[i] and $ff);
                    ch:=chr(VideoBuf^[i] and $ff);
                    if ch<>#0 then
                    if ch<>#0 then
                      begin
                      begin
-                       Attr:=VideoBuf^[i] shr 16;
+                       Attr:=VideoBuf^[i] shr 8;
                        NextColor:=Attr and $f;
                        NextColor:=Attr and $f;
-                       NextBkColor:=(Attr and $70) shr 8;
+                       NextBkColor:=(Attr and $70) shr 4;
+                       if NextBkColor<>CurBkColor then
+                         begin
+                           Graph.SetBkColor(NextBkColor);
+                           CurBkColor:=NextBkColor;
+                         end;
+
+                       Graph.Bar(x*SysFontWidth,y*SysFontHeight,(x+1)*SysFontWidth,(y+1)*SysFontHeight);
                        if NextColor<>CurColor then
                        if NextColor<>CurColor then
                          begin
                          begin
-                           SetColor(NextColor);
+                           Graph.SetColor(NextColor);
                            CurColor:=NextColor;
                            CurColor:=NextColor;
                          end;
                          end;
-                       if NextBkColor<>CurBkColor then
+                       { SetBkColor does change the palette index 0 entry...
+                         which leads to troubles if we want to write in dark }
+                       if (CurColor=0) then
                          begin
                          begin
-                           SetBkColor(NextBkColor);
-                           CurBkColor:=NextBkColor;
+                           Graph.SetBkColor(0);
+                           CurBkColor:=0;
                          end;
                          end;
-                       Bar(x*SysFontWidth,y*SysFontHeight,(x+1)*SysFontWidth,(y+1)*SysFontHeight);
-                       OutTextXY(x*SysFontWidth,y*SysFontHeight,ch);
+                       Graph.OutTextXY(x*SysFontWidth,y*SysFontHeight,ch);
                      end;
                      end;
                    OldVideoBuf^[i]:=VideoBuf^[i];
                    OldVideoBuf^[i]:=VideoBuf^[i];
                  end;
                  end;
              end;
              end;
         end;
         end;
-      SetColor(SavedColor);
-      SetBkColor(SavedBkColor);
+      Graph.SetFillStyle(StoreFillSettings.pattern,StoreFillSettings.color);
+      Graph.SetColor(SavedColor);
+      Graph.SetBkColor(SavedBkColor);
     end;
     end;
 {$else not USE_VIDEO_API}
 {$else not USE_VIDEO_API}
   RunError(219);
   RunError(219);
@@ -497,7 +535,10 @@ end;
 END.
 END.
 {
 {
  $Log$
  $Log$
- Revision 1.12  2002-05-28 19:42:32  pierre
+ Revision 1.13  2002-05-29 19:35:31  pierre
+  * fix GraphUpdateScreen procedure
+
+ Revision 1.12  2002/05/28 19:42:32  pierre
   * fix non graphic mode compilation
   * fix non graphic mode compilation
 
 
  Revision 1.11  2002/05/28 19:13:44  pierre
  Revision 1.11  2002/05/28 19:13:44  pierre