Explorar el Código

* reordered some local variables (first 4 byte vars, then 2 byte vars
etc)
* font data is now disposed in exitproc, exitproc is now called
GraphExitProc (was CleanModes) and resides in graph.pp instead of in
modes.inc

Jonas Maebe hace 26 años
padre
commit
03980540bd
Se han modificado 4 ficheros con 86 adiciones y 82 borrados
  1. 54 14
      rtl/inc/graph/graph.pp
  2. 10 4
      rtl/inc/graph/gtext.inc
  3. 8 57
      rtl/inc/graph/modes.inc
  4. 14 7
      rtl/inc/graph/vesa.inc

+ 54 - 14
rtl/inc/graph/graph.pp

@@ -583,6 +583,7 @@ VAR
 
 
   SaveVideoState : SaveStateProc;
   SaveVideoState : SaveStateProc;
   RestoreVideoState: RestoreStateProc;
   RestoreVideoState: RestoreStateProc;
+  ExitSave: pointer;
 
 
 
 
 Procedure Closegraph;
 Procedure Closegraph;
@@ -2399,22 +2400,22 @@ end;
 
 
      case Fillsettings.pattern of
      case Fillsettings.pattern of
      EmptyFill :
      EmptyFill :
-           begin
-                     Currentcolor:=CurrentBkColor;
-                     for y:=y1 to y2 do
-                       Hline(x1,x2,y);
-                   end;
+       begin
+         Currentcolor:=CurrentBkColor;
+         for y:=y1 to y2 do
+           Hline(x1,x2,y);
+       end;
      SolidFill :
      SolidFill :
-           begin
-                     CurrentColor:=FillSettings.color;
-                     for y:=y1 to y2 do
-                       Hline(x1,x2,y);
-                  end;
+       begin
+         CurrentColor:=FillSettings.color;
+           for y:=y1 to y2 do
+              Hline(x1,x2,y);
+       end;
      else
      else
       Begin
       Begin
-            CurrentColor:=FillSettings.color;
+        CurrentColor:=FillSettings.color;
         for y:=y1 to y2 do
         for y:=y1 to y2 do
-                  patternline(x1,x2,y);
+          patternline(x1,x2,y);
       end;
       end;
     end;
     end;
     CurrentColor:= Origcolor;
     CurrentColor:= Origcolor;
@@ -2803,6 +2804,38 @@ end;
     GetDirectVideo := DirectVideo;
     GetDirectVideo := DirectVideo;
   end;
   end;
 
 
+ procedure GraphExitProc; {$ifndef fpc} far; {$endif fpc}
+ { deallocates all memory allocated by the graph unit }
+  var
+    list: PModeInfo;
+    tmp : PModeInfo;
+    c: graph_int;
+  begin
+   { restore old exitproc! }
+   exitproc := exitsave;
+{$ifdef testsave}
+   restorevideostate;
+{$endif testsave}
+   { release memory allocated for fonts }
+   for c := 1 to installedfonts do
+     If assigned(fonts[c].instr) Then
+       Freemem(fonts[c].instr,strlen(fonts[c].instr));
+   { release memory allocated for modelist }
+   list := ModeList;
+   while assigned(list) do
+     begin
+       tmp := list;
+       list:=list^.next;
+       dispose(tmp);
+     end;
+{$IFDEF DPMI}
+  { We had copied the buffer of mode information }
+  { and allocated it dynamically... now free it  }
+  { Warning: if GetVESAInfo returned false, this buffer is not allocated! (JM)}
+   If hasVesa then
+     Dispose(VESAInfo.ModeList);
+{$ENDIF}
+  end;
 
 
 
 
 begin
 begin
@@ -2831,7 +2864,7 @@ begin
  InstallUserFont('GOTH');
  InstallUserFont('GOTH');
  { This installs an exit procedure which cleans up the mode list...}
  { This installs an exit procedure which cleans up the mode list...}
  ExitSave := ExitProc;
  ExitSave := ExitProc;
- ExitProc := @CleanMode;
+ ExitProc := @GraphExitProc;
 {$ifdef testsave}
 {$ifdef testsave}
  savevideostate;
  savevideostate;
 {$endif testsave}
 {$endif testsave}
@@ -2843,7 +2876,14 @@ SetGraphBufSize
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.30  1999-09-27 23:34:41  peter
+  Revision 1.31  1999-09-28 13:56:25  jonas
+    * reordered some local variables (first 4 byte vars, then 2 byte vars
+      etc)
+    * font data is now disposed in exitproc, exitproc is now called
+      GraphExitProc (was CleanModes) and resides in graph.pp instead of in
+      modes.inc
+
+  Revision 1.30  1999/09/27 23:34:41  peter
     * new graph unit is default for go32v2
     * new graph unit is default for go32v2
     * removed warnings/notes
     * removed warnings/notes
 
 

+ 10 - 4
rtl/inc/graph/gtext.inc

@@ -358,17 +358,16 @@
        end;
        end;
       var
       var
          i,j,k,c       : longint;
          i,j,k,c       : longint;
-         oldvalues     : linesettingstype;
          xpos,ypos     : longint;
          xpos,ypos     : longint;
          counter       : longint;
          counter       : longint;
          FontBitmap    : TBitmapChar;
          FontBitmap    : TBitmapChar;
-         chr: char;
          cnt1,cnt2     : integer;
          cnt1,cnt2     : integer;
          cnt3,cnt4     : integer;
          cnt3,cnt4     : integer;
          charsize      : word;
          charsize      : word;
-
          WriteMode     : word;
          WriteMode     : word;
          CurX, CurY    : integer;
          CurX, CurY    : integer;
+         oldvalues     : linesettingstype;
+         chr           : char;
 
 
       begin
       begin
          { save current write mode }
          { save current write mode }
@@ -728,7 +727,14 @@
 
 
 {
 {
 $Log$
 $Log$
-Revision 1.5  1999-09-27 23:34:42  peter
+Revision 1.6  1999-09-28 13:56:29  jonas
+  * reordered some local variables (first 4 byte vars, then 2 byte vars
+    etc)
+  * font data is now disposed in exitproc, exitproc is now called
+    GraphExitProc (was CleanModes) and resides in graph.pp instead of in
+    modes.inc
+
+Revision 1.5  1999/09/27 23:34:42  peter
   * new graph unit is default for go32v2
   * new graph unit is default for go32v2
   * removed warnings/notes
   * removed warnings/notes
 
 

+ 8 - 57
rtl/inc/graph/modes.inc

@@ -18,8 +18,6 @@
 {-----------------------------------------------------------------------}
 {-----------------------------------------------------------------------}
 {                          Internal routines                            }
 {                          Internal routines                            }
 {-----------------------------------------------------------------------}
 {-----------------------------------------------------------------------}
-var
- ExitSave: pointer;
 
 
  procedure addmode(mode: TModeInfo);
  procedure addmode(mode: TModeInfo);
   {********************************************************}
   {********************************************************}
@@ -35,18 +33,10 @@ var
     if not assigned(ModeList) then
     if not assigned(ModeList) then
       begin
       begin
         new(ModeList);
         new(ModeList);
-{$ifdef logging}
-        LogLn('Modelist = '+strf(Longint(modelist)));
-        LogLn('Adding mode 1 and modelist^.next = '+strf(Longint(mode.next)));
-{$endif logging}
         move(mode, ModeList^, sizeof(Mode));
         move(mode, ModeList^, sizeof(Mode));
       end
       end
     else
     else
       begin
       begin
-{$ifdef logging}
-        LogLn('Adding another mode, modelist = '+strf(Longint(modelist)));
-        LogLn('and modelist^.next = '+strf(Longint(modelist^.next)));
-{$endif logging}
         list := ModeList;
         list := ModeList;
         { go to the end of the list }
         { go to the end of the list }
         while assigned(list^.next) do
         while assigned(list^.next) do
@@ -97,52 +87,6 @@ var
     end;
     end;
 
 
 
 
-   procedure cleanmode; {$ifndef fpc}far;{$endif fpc}
-  {********************************************************}
-  { Procedure CleanMode()                                  }
-  {--------------------------------------------------------}
-  { This routine deallocates the mode list.                }
-  { It is called as an exit procedure ONLY.                }
-  {********************************************************}
-    var
-      list: PModeInfo;
-      tmp : PModeInfo;
-{$ifdef logging}
-      c: word;
-{$endif logging}
-    begin
-{$ifdef testsave}
-      restorevideostate;
-{$endif testsave}
-      { restore old exitproc! }
-      exitproc := exitsave;
-{$ifdef logging}
-      LogLn('Modelist at exit: '+strf(longint(modelist)));
-      LogLn('Modelist^.next at exit: '+strf(longint(modelist^.next)));
-      c := 1;
-{$endif logging}
-        list := ModeList;
-        { go to the end of the list }
-        while assigned(list) do
-        begin
-          tmp := list;
-          list:=list^.next;
-{$ifdef logging}
-          LogLn('disposing mode '+strf(c));
-          inc(c);
-{$endif logging}
-          dispose(tmp);
-        end;
-{$IFDEF DPMI}
-      { We had copied the buffer of mode information }
-      { and allocated it dynamically... now free it  }
-      { Warning: if GetVESAInfo returned false, this buffer is not allocated!
-        (JM)}
-      If hasVesa then
-        Dispose(VESAInfo.ModeList);
-{$ENDIF}
-    end;
-
 {-----------------------------------------------------------------------}
 {-----------------------------------------------------------------------}
 {                          External routines                            }
 {                          External routines                            }
 {-----------------------------------------------------------------------}
 {-----------------------------------------------------------------------}
@@ -354,7 +298,14 @@ var
 
 
 {
 {
 $Log$
 $Log$
-Revision 1.11  1999-09-26 13:31:07  jonas
+Revision 1.12  1999-09-28 13:56:31  jonas
+  * reordered some local variables (first 4 byte vars, then 2 byte vars
+    etc)
+  * font data is now disposed in exitproc, exitproc is now called
+    GraphExitProc (was CleanModes) and resides in graph.pp instead of in
+    modes.inc
+
+Revision 1.11  1999/09/26 13:31:07  jonas
   * changed name of modeinfo variable to vesamodeinfo and fixed
   * changed name of modeinfo variable to vesamodeinfo and fixed
     associated errors (fillchar(modeinfo,sizeof(tmodeinfo),#0) instead
     associated errors (fillchar(modeinfo,sizeof(tmodeinfo),#0) instead
     of sizeof(TVesamodeinfo) etc)
     of sizeof(TVesamodeinfo) etc)

+ 14 - 7
rtl/inc/graph/vesa.inc

@@ -98,7 +98,7 @@ end;
 {$ifndef fpc}
 {$ifndef fpc}
     ModeSel: word;
     ModeSel: word;
     offs: longint;
     offs: longint;
-{$endif}
+{$endif fpc}
     { added... }
     { added... }
     modelist: PmodeList;
     modelist: PmodeList;
     i: longint;
     i: longint;
@@ -949,8 +949,8 @@ end;
 
 
   procedure DirectPutPixVESA32k(x, y : integer); {$ifndef fpc}far;{$endif fpc}
   procedure DirectPutPixVESA32k(x, y : integer); {$ifndef fpc}far;{$endif fpc}
   var
   var
-     col : word;
      offs : longint;
      offs : longint;
+     col : word;
   begin
   begin
      offs := longint(y) * BytesPerLine + 2*x;
      offs := longint(y) * BytesPerLine + 2*x;
      SetWriteBank(integer((offs shr 16) and $ff));
      SetWriteBank(integer((offs shr 16) and $ff));
@@ -982,8 +982,8 @@ end;
 
 
   procedure DirectPutPixVESA64k(x, y : integer); {$ifndef fpc}far;{$endif fpc}
   procedure DirectPutPixVESA64k(x, y : integer); {$ifndef fpc}far;{$endif fpc}
   var
   var
-     Col : word;
      offs : longint;
      offs : longint;
+     Col : word;
   begin
   begin
      offs := longint(y) * BytesPerLine + 2*x;
      offs := longint(y) * BytesPerLine + 2*x;
      SetWriteBank(integer(offs shr 16));
      SetWriteBank(integer(offs shr 16));
@@ -1167,7 +1167,7 @@ end;
     pal: PalRec;
     pal: PalRec;
 {$ifndef fpc}
 {$ifndef fpc}
     palptr : ^PalRec;
     palptr : ^PalRec;
-{$endif}
+{$endif fpc}
     regs : TDPMIRegisters;
     regs : TDPMIRegisters;
     RealSeg: word;
     RealSeg: word;
     ptr: longint;
     ptr: longint;
@@ -1292,8 +1292,8 @@ end;
 
 
 
 
 
 
-  Procedure GetVESARGBPalette(ColorNum: integer; Var
-      RedValue, GreenValue, BlueValue : integer); far;
+  Procedure GetVESARGBPalette(ColorNum: integer; Var RedValue, GreenValue,
+              BlueValue : integer); far;
    var
    var
     Error: boolean;
     Error: boolean;
     pal: ^palrec;
     pal: ^palrec;
@@ -1873,7 +1873,14 @@ end;
 
 
 {
 {
 $Log$
 $Log$
-Revision 1.17  1999-09-27 23:34:42  peter
+Revision 1.18  1999-09-28 13:56:31  jonas
+  * reordered some local variables (first 4 byte vars, then 2 byte vars
+    etc)
+  * font data is now disposed in exitproc, exitproc is now called
+    GraphExitProc (was CleanModes) and resides in graph.pp instead of in
+    modes.inc
+
+Revision 1.17  1999/09/27 23:34:42  peter
   * new graph unit is default for go32v2
   * new graph unit is default for go32v2
   * removed warnings/notes
   * removed warnings/notes