Browse Source

+ added missing detectMode stuff for -dnewmodes

Jonas Maebe 25 years ago
parent
commit
6cb27b64e6
2 changed files with 61 additions and 34 deletions
  1. 56 32
      rtl/inc/graph/graph.inc
  2. 5 2
      rtl/inc/graph/graphh.inc

+ 56 - 32
rtl/inc/graph/graph.inc

@@ -2142,8 +2142,8 @@ end;
 {$i fills.inc}
 {$i gtext.inc}
 
-
-  procedure DetectGraph(var GraphDriver:smallint;var GraphMode:smallint);
+  procedure internDetectGraph(var GraphDriver, GraphMode:smallint;
+    calledFromInitGraph: boolean);
   var LoMode, HiMode: smallint;
       CpyMode: smallint;
       CpyDriver: smallint;
@@ -2151,36 +2151,51 @@ end;
     HiMode := -1;
     LoMode := -1;
 {$ifdef newmodes}
-    { Search lowest supported bitDepth }
-    graphdriver := D1bit;
-    while (graphDriver <= highNewDriver) and
-          (hiMode = -1) do
+    if not calledFromInitGraph or
+       (graphDriver < lowNewDriver) or
+       (graphDriver > highNewDriver) then
       begin
-        getModeRange(graphDriver,loMode,hiMode);
-        inc(graphDriver);
-      end;
-    dec(graphdriver);
-    if hiMode = -1 then
+        { Search lowest supported bitDepth }
+        graphdriver := D1bit;
+        while (graphDriver <= highNewDriver) and
+              (hiMode = -1) do
+          begin
+            getModeRange(graphDriver,loMode,hiMode);
+            inc(graphDriver);
+          end;
+        dec(graphdriver);
+        if hiMode = -1 then
+          begin
+            _GraphResult := grNotDetected;
+            exit;
+          end;
+        CpyMode := 0;
+        repeat
+           GetModeRange(GraphDriver,LoMode,HiMode);
+           { save the highest mode possible...}
+           {$ifdef logging}
+           logln('Found driver '+strf(graphdriver)+' with modes '+
+                  strf(lomode)+' - '+strf(himode));
+           {$endif logging}
+           if HiMode <> -1 then
+             begin
+               CpyMode:=HiMode;
+               CpyDriver:=GraphDriver;
+             end;
+           { go to next driver if it exists...}
+           Inc(graphDriver);
+        until (graphDriver > highNewDriver);
+      end
+    else
       begin
-        _GraphResult := grNotDetected;
-        exit;
+        cpyMode := 0;
+        getModeRange(graphDriver,loMode,hiMode);
+        if hiMode <> -1 then
+          begin
+            cpyDriver := graphDriver;
+            cpyMode := hiMode;
+          end;
       end;
-    CpyMode := 0;
-    repeat
-       GetModeRange(GraphDriver,LoMode,HiMode);
-       { save the highest mode possible...}
-       {$ifdef logging}
-       logln('Found driver '+strf(graphdriver)+' with modes '+
-              strf(lomode)+' - '+strf(himode));
-       {$endif logging}
-       if HiMode <> -1 then
-         begin
-           CpyMode:=HiMode;
-           CpyDriver:=GraphDriver;
-         end;
-       { go to next driver if it exists...}
-       Inc(graphDriver);
-    until (graphDriver > highNewDriver);
     if cpyMode = 0 then
       begin
         _GraphResult := grNotDetected;
@@ -2218,6 +2233,11 @@ end;
     GraphMode := CpyMode;
   end;
 
+  procedure detectGraph(var GraphDriver: smallint; var GraphMode:smallint);
+  begin
+    internDetectGraph(graphDriver,graphMode,false);
+  end;
+
   procedure InitGraph(var GraphDriver:smallint;var GraphMode:smallint;
     const PathToDriver:String);
   const
@@ -2237,9 +2257,10 @@ end;
       RunError(216);
     DriverName:=InternalDriverName;   { DOS Graphics driver }
 
-    if (Graphdriver=Detect) then
+    if (Graphdriver=Detect) or
+       (GraphMode = detectMode) then
       begin
-        DetectGraph(GraphDriver,GraphMode);
+        internDetectGraph(GraphDriver,GraphMode,true);
         If _GraphResult = grNotDetected then Exit;
 
         { _GraphResult is now already set to grOK by DetectGraph }
@@ -2370,7 +2391,10 @@ begin
 end;
 {
   $Log$
-  Revision 1.33  2000-06-17 19:09:22  jonas
+  Revision 1.34  2000-06-18 06:11:20  jonas
+    + added missing detectMode stuff for -dnewmodes
+
+  Revision 1.33  2000/06/17 19:09:22  jonas
     * new platform independent mode handling (between -dnewmodes)
 
   Revision 1.32  2000/06/07 07:33:42  jonas

+ 5 - 2
rtl/inc/graph/graphh.inc

@@ -337,7 +337,6 @@ type
 
 {$ifdef newmodes}
 
-       detectDriver = 30000;
        D1bit = 11;
        D2bit = 12;
        D4bit = 13;
@@ -368,6 +367,7 @@ type
        { consecutive mode number for that, so they are generated on-the-fly }
        { starting from 1)                                                   }
 
+       detectMode = 30000;
        m320x200 = 30001;
        m512x384 = 30002; { mac resolution }
        m640x200 = 30003; { vga resolution }
@@ -793,7 +793,10 @@ Function GetDriverName: string;
 
 {
   $Log$
-  Revision 1.6  2000-06-17 19:09:23  jonas
+  Revision 1.7  2000-06-18 06:11:21  jonas
+    + added missing detectMode stuff for -dnewmodes
+
+  Revision 1.6  2000/06/17 19:09:23  jonas
     * new platform independent mode handling (between -dnewmodes)
 
   Revision 1.5  2000/06/17 11:16:07  sg