Browse Source

* renamed text.inc -> gtext.inc to avoid conflict with system unit
* fixed textwidth
* isgraphmode now gets properly updated, so mode restoring works
again

Jonas Maebe 26 years ago
parent
commit
47b14faf20
4 changed files with 80 additions and 13 deletions
  1. 24 4
      rtl/inc/graph/graph.inc
  2. 12 2
      rtl/inc/graph/graph.pp
  3. 13 6
      rtl/inc/graph/gtext.inc
  4. 31 1
      rtl/inc/graph/modes.inc

+ 24 - 4
rtl/inc/graph/graph.inc

@@ -1407,6 +1407,7 @@ const CrtAddress: word = 0;
     end;
     end;
     if SaveSupported then
     if SaveSupported then
       begin
       begin
+
 {$ifndef fpc}
 {$ifndef fpc}
         PtrLong:=GlobalDosAlloc(64*StateSize);  { values returned in 64-byte blocks }
         PtrLong:=GlobalDosAlloc(64*StateSize);  { values returned in 64-byte blocks }
 {$else fpc}
 {$else fpc}
@@ -1493,7 +1494,7 @@ const CrtAddress: word = 0;
       {**************************************************************}
       {**************************************************************}
 
 
 
 
- Procedure SaveStateVGA; far; 
+ Procedure SaveStateVGA; far;
   begin
   begin
     SavePtr := nil;
     SavePtr := nil;
     SaveSupported := FALSE;
     SaveSupported := FALSE;
@@ -1635,14 +1636,21 @@ const CrtAddress: word = 0;
         _graphresult := grnoinitgraph;
         _graphresult := grnoinitgraph;
         exit
         exit
       end;
       end;
+{$ifdef logging}
+    LogLn('calling RestoreVideoState at '+strf(longint(RestoreVideoState)));
+{$endif logging}
     if not assigned(RestoreVideoState) then
     if not assigned(RestoreVideoState) then
       RunError(216);
       RunError(216);
+{$ifdef logging}
+    LogLn('actual call of RestoreVideoState');
+{$endif logging}
     RestoreVideoState;
     RestoreVideoState;
 {$IFDEF DPMI}
 {$IFDEF DPMI}
     { We had copied the buffer of mode information }
     { We had copied the buffer of mode information }
     { and allocated it dynamically... now free it  }
     { and allocated it dynamically... now free it  }
     { Warning: if GetVESAInfo returned false, this buffer is not allocated!
     { Warning: if GetVESAInfo returned false, this buffer is not allocated!
       (JM)}
       (JM)}
+    isgraphmode := false;
     If hasVesa then
     If hasVesa then
       Dispose(VESAInfo.ModeList);
       Dispose(VESAInfo.ModeList);
 {$ENDIF}
 {$ENDIF}
@@ -1724,10 +1732,12 @@ const CrtAddress: word = 0;
 {$endif logging}
 {$endif logging}
      if VGADetected then
      if VGADetected then
        begin
        begin
-
+{$ifdef logging}
          SaveVideoState := SaveStateVGA;
          SaveVideoState := SaveStateVGA;
+         LogLn('Setting VGA SaveVideoState to '+strf(longint(SaveVideoState)));
          RestoreVideoState := RestoreStateVGA;
          RestoreVideoState := RestoreStateVGA;
-
+         LogLn('Setting VGA RestoreVideoState to '+strf(longint(RestoreVideoState)));
+{$endif logging}
 
 
          InitMode(mode);
          InitMode(mode);
          { now add all standard VGA modes...       }
          { now add all standard VGA modes...       }
@@ -1915,8 +1925,12 @@ const CrtAddress: word = 0;
          { otherwise, if we use the VGA BIOS only function  }
          { otherwise, if we use the VGA BIOS only function  }
          { there might be a crash under DPMI, such as in the}
          { there might be a crash under DPMI, such as in the}
          { ATI Mach64                                       }
          { ATI Mach64                                       }
+{$ifdef logging}
          SaveVideoState := SaveStateVESA;
          SaveVideoState := SaveStateVESA;
+         LogLn('Setting SaveVideoState to '+strf(longint(SaveVideoState)));
          RestoreVideoState := RestoreStateVESA;
          RestoreVideoState := RestoreStateVESA;
+         LogLn('Setting RestoreVideoState to '+strf(longint(RestoreVideoState)));
+{$endif logging}
          { now check all supported modes...}
          { now check all supported modes...}
          if SearchVESAModes(m320x200x32k) then
          if SearchVESAModes(m320x200x32k) then
            begin
            begin
@@ -2608,7 +2622,13 @@ const CrtAddress: word = 0;
 
 
 {
 {
 $Log$
 $Log$
-Revision 1.14  1999-09-18 22:21:09  jonas
+Revision 1.15  1999-09-22 13:13:34  jonas
+  * renamed text.inc -> gtext.inc to avoid conflict with system unit
+  * fixed textwidth
+  * isgraphmode now gets properly updated, so mode restoring works
+    again
+
+Revision 1.14  1999/09/18 22:21:09  jonas
   + hlinevesa256 and vlinevesa256
   + hlinevesa256 and vlinevesa256
   + support for not/xor/or/andput in vesamodes with 32k/64k colors
   + support for not/xor/or/andput in vesamodes with 32k/64k colors
   * lots of changes to avoid warnings under FPC
   * lots of changes to avoid warnings under FPC

+ 12 - 2
rtl/inc/graph/graph.pp

@@ -2754,7 +2754,7 @@ end;
   end;
   end;
 
 
 {$i fills.inc}
 {$i fills.inc}
-{$i text.inc}
+{$i gtext.inc}
 
 
 
 
   procedure InitGraph(var GraphDriver:Integer;var GraphMode:Integer;
   procedure InitGraph(var GraphDriver:Integer;var GraphMode:Integer;
@@ -2773,6 +2773,9 @@ end;
     QueryAdapterInfo;
     QueryAdapterInfo;
     if not assigned(SaveVideoState) then
     if not assigned(SaveVideoState) then
       RunError(216);
       RunError(216);
+{$ifdef logging}
+    LogLn('Calling SaveVideoState at '+strf(longint(savevideostate)));
+{$endif logging}
     SaveVideoState;
     SaveVideoState;
     InitVars;
     InitVars;
     DriverName:=InternalDriverName;   { DOS Graphics driver }
     DriverName:=InternalDriverName;   { DOS Graphics driver }
@@ -2844,6 +2847,7 @@ begin
  rewrite(debuglog);
  rewrite(debuglog);
  close(debuglog);
  close(debuglog);
 {$endif logging}
 {$endif logging}
+ isgraphmode := false;
  ModeList := nil;
  ModeList := nil;
  SaveVideoState := nil;
  SaveVideoState := nil;
  RestoreVideoState := nil;
  RestoreVideoState := nil;
@@ -2876,7 +2880,13 @@ DetectGraph
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.25  1999-09-18 22:21:10  jonas
+  Revision 1.26  1999-09-22 13:13:35  jonas
+    * renamed text.inc -> gtext.inc to avoid conflict with system unit
+    * fixed textwidth
+    * isgraphmode now gets properly updated, so mode restoring works
+      again
+
+  Revision 1.25  1999/09/18 22:21:10  jonas
     + hlinevesa256 and vlinevesa256
     + hlinevesa256 and vlinevesa256
     + support for not/xor/or/andput in vesamodes with 32k/64k colors
     + support for not/xor/or/andput in vesamodes with 32k/64k colors
     * lots of changes to avoid warnings under FPC
     * lots of changes to avoid warnings under FPC

+ 13 - 6
rtl/inc/graph/text.inc → rtl/inc/graph/gtext.inc

@@ -275,7 +275,7 @@
               move(hp[i+1],FHeader,sizeof(TFHeader));
               move(hp[i+1],FHeader,sizeof(TFHeader));
               move(hp[Prefix_Size],header,sizeof(THeader));
               move(hp[Prefix_Size],header,sizeof(THeader));
               { check if the font name is already allocated? }
               { check if the font name is already allocated? }
-              i:=Prefix_Size+sizeof(THeader);
+              i:=Prefix_Size+sizeof(THeader)+1;
               for b:=1 to installedfonts do
               for b:=1 to installedfonts do
                 begin
                 begin
                    if fonts[b].name=FHeader.Font_name then
                    if fonts[b].name=FHeader.Font_name then
@@ -323,8 +323,8 @@
          if Currenttextinfo.font=DefaultFont
          if Currenttextinfo.font=DefaultFont
             then TextHeight:=8*CurrentTextInfo.CharSize
             then TextHeight:=8*CurrentTextInfo.CharSize
             else
             else
-              TextHeight:=fonts[Currenttextinfo.font].header.org_to_cap-
-                round(fonts[Currenttextinfo.font].header.org_to_base * CurrentYRatio) ;
+              TextHeight:=Trunc((fonts[Currenttextinfo.font].header.org_to_cap-
+                fonts[Currenttextinfo.font].header.org_to_base) * CurrentYRatio);
       end;
       end;
 
 
     function TextWidth(const TextString : string) : word;
     function TextWidth(const TextString : string) : word;
@@ -340,8 +340,9 @@
                for i:=1 to length(TextString) do
                for i:=1 to length(TextString) do
                 begin
                 begin
                    c:=byte(textstring[i]);
                    c:=byte(textstring[i]);
-                   dec(c,fonts[Currenttextinfo.font].header.first_char);
-                   if (c<0) or (c>=fonts[Currenttextinfo.font].header.nr_chars) then
+{                   dec(c,fonts[Currenttextinfo.font].header.first_char);}
+                   if (c-fonts[Currenttextinfo.font].header.first_char>=
+                       fonts[Currenttextinfo.font].header.nr_chars) then
                      continue;
                      continue;
                    x:=x+byte(fonts[Currenttextinfo.font].widths[c]);
                    x:=x+byte(fonts[Currenttextinfo.font].widths[c]);
                end;
                end;
@@ -690,7 +691,13 @@
 
 
 {
 {
 $Log$
 $Log$
-Revision 1.7  1999-09-12 17:29:00  jonas
+Revision 1.1  1999-09-22 13:13:36  jonas
+  * renamed text.inc -> gtext.inc to avoid conflict with system unit
+  * fixed textwidth
+  * isgraphmode now gets properly updated, so mode restoring works
+    again
+
+Revision 1.7  1999/09/12 17:29:00  jonas
   * several changes to internalellipse to make it faster
   * several changes to internalellipse to make it faster
     and to make sure it updates the ArcCall correctly
     and to make sure it updates the ArcCall correctly
     (not yet done for width = 3)
     (not yet done for width = 3)

+ 31 - 1
rtl/inc/graph/modes.inc

@@ -33,10 +33,18 @@
     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(TModeInfo));
         move(mode, ModeList^, sizeof(TModeInfo));
       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,13 +105,26 @@
     var
     var
       list: PModeInfo;
       list: PModeInfo;
       tmp : PModeInfo;
       tmp : PModeInfo;
+{$ifdef logging}
+      c: word;
+{$endif logging}
     begin
     begin
+      exit;
+{$ifdef logging}
+      LogLn('Modelist at exit: '+strf(longint(modelist)));
+      LogLn('Modelist^.next at exit: '+strf(longint(modelist^.next)));
+      c := 1;
+{$endif logging}
         list := ModeList;
         list := ModeList;
         { go to the end of the list }
         { go to the end of the list }
         while assigned(list) do
         while assigned(list) do
         begin
         begin
           tmp := list;
           tmp := list;
           list:=list^.next;
           list:=list^.next;
+{$ifdef logging}
+          LogLn('disposing mode '+strf(c));
+          inc(c);
+{$endif logging}
           dispose(tmp);
           dispose(tmp);
         end;
         end;
     end;
     end;
@@ -291,6 +312,7 @@
         end;
         end;
       modeinfo^.InitMode;
       modeinfo^.InitMode;
       if _GraphResult <> grOk then exit;
       if _GraphResult <> grOk then exit;
+      isgraphmode := true;
       { It is very important that this call be made }
       { It is very important that this call be made }
       { AFTER the other variables have been setup.  }
       { AFTER the other variables have been setup.  }
       { Since it calls some routines which rely on  }
       { Since it calls some routines which rely on  }
@@ -312,12 +334,20 @@
   {       -                                                }
   {       -                                                }
   {********************************************************}
   {********************************************************}
      begin
      begin
+       isgraphmode := false;
        RestoreVideoState;
        RestoreVideoState;
+       isgraphmode := true;
      end;
      end;
 
 
 {
 {
 $Log$
 $Log$
-Revision 1.8  1999-09-18 22:21:11  jonas
+Revision 1.9  1999-09-22 13:13:36  jonas
+  * renamed text.inc -> gtext.inc to avoid conflict with system unit
+  * fixed textwidth
+  * isgraphmode now gets properly updated, so mode restoring works
+    again
+
+Revision 1.8  1999/09/18 22:21:11  jonas
   + hlinevesa256 and vlinevesa256
   + hlinevesa256 and vlinevesa256
   + support for not/xor/or/andput in vesamodes with 32k/64k colors
   + support for not/xor/or/andput in vesamodes with 32k/64k colors
   * lots of changes to avoid warnings under FPC
   * lots of changes to avoid warnings under FPC