Prechádzať zdrojové kódy

* 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 26 rokov pred
rodič
commit
03980540bd

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

@@ -583,6 +583,7 @@ VAR
 
   SaveVideoState : SaveStateProc;
   RestoreVideoState: RestoreStateProc;
+  ExitSave: pointer;
 
 
 Procedure Closegraph;
@@ -2399,22 +2400,22 @@ end;
 
      case Fillsettings.pattern of
      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 :
-           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
       Begin
-            CurrentColor:=FillSettings.color;
+        CurrentColor:=FillSettings.color;
         for y:=y1 to y2 do
-                  patternline(x1,x2,y);
+          patternline(x1,x2,y);
       end;
     end;
     CurrentColor:= Origcolor;
@@ -2803,6 +2804,38 @@ end;
     GetDirectVideo := DirectVideo;
   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
@@ -2831,7 +2864,7 @@ begin
  InstallUserFont('GOTH');
  { This installs an exit procedure which cleans up the mode list...}
  ExitSave := ExitProc;
- ExitProc := @CleanMode;
+ ExitProc := @GraphExitProc;
 {$ifdef testsave}
  savevideostate;
 {$endif testsave}
@@ -2843,7 +2876,14 @@ SetGraphBufSize
 
 {
   $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
     * removed warnings/notes
 

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

@@ -358,17 +358,16 @@
        end;
       var
          i,j,k,c       : longint;
-         oldvalues     : linesettingstype;
          xpos,ypos     : longint;
          counter       : longint;
          FontBitmap    : TBitmapChar;
-         chr: char;
          cnt1,cnt2     : integer;
          cnt3,cnt4     : integer;
          charsize      : word;
-
          WriteMode     : word;
          CurX, CurY    : integer;
+         oldvalues     : linesettingstype;
+         chr           : char;
 
       begin
          { save current write mode }
@@ -728,7 +727,14 @@
 
 {
 $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
   * removed warnings/notes
 

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

@@ -18,8 +18,6 @@
 {-----------------------------------------------------------------------}
 {                          Internal routines                            }
 {-----------------------------------------------------------------------}
-var
- ExitSave: pointer;
 
  procedure addmode(mode: TModeInfo);
   {********************************************************}
@@ -35,18 +33,10 @@ var
     if not assigned(ModeList) then
       begin
         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));
       end
     else
       begin
-{$ifdef logging}
-        LogLn('Adding another mode, modelist = '+strf(Longint(modelist)));
-        LogLn('and modelist^.next = '+strf(Longint(modelist^.next)));
-{$endif logging}
         list := ModeList;
         { go to the end of the list }
         while assigned(list^.next) do
@@ -97,52 +87,6 @@ var
     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                            }
 {-----------------------------------------------------------------------}
@@ -354,7 +298,14 @@ var
 
 {
 $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
     associated errors (fillchar(modeinfo,sizeof(tmodeinfo),#0) instead
     of sizeof(TVesamodeinfo) etc)

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

@@ -98,7 +98,7 @@ end;
 {$ifndef fpc}
     ModeSel: word;
     offs: longint;
-{$endif}
+{$endif fpc}
     { added... }
     modelist: PmodeList;
     i: longint;
@@ -949,8 +949,8 @@ end;
 
   procedure DirectPutPixVESA32k(x, y : integer); {$ifndef fpc}far;{$endif fpc}
   var
-     col : word;
      offs : longint;
+     col : word;
   begin
      offs := longint(y) * BytesPerLine + 2*x;
      SetWriteBank(integer((offs shr 16) and $ff));
@@ -982,8 +982,8 @@ end;
 
   procedure DirectPutPixVESA64k(x, y : integer); {$ifndef fpc}far;{$endif fpc}
   var
-     Col : word;
      offs : longint;
+     Col : word;
   begin
      offs := longint(y) * BytesPerLine + 2*x;
      SetWriteBank(integer(offs shr 16));
@@ -1167,7 +1167,7 @@ end;
     pal: PalRec;
 {$ifndef fpc}
     palptr : ^PalRec;
-{$endif}
+{$endif fpc}
     regs : TDPMIRegisters;
     RealSeg: word;
     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
     Error: boolean;
     pal: ^palrec;
@@ -1873,7 +1873,14 @@ end;
 
 {
 $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
   * removed warnings/notes