Browse Source

* extracted the common code for the VESA 256-colour TModeInfo initialization

git-svn-id: trunk@25701 -
nickysn 12 years ago
parent
commit
834008818f
1 changed files with 29 additions and 98 deletions
  1. 29 98
      packages/graph/src/msdos/graph.pp

+ 29 - 98
packages/graph/src/msdos/graph.pp

@@ -3167,6 +3167,30 @@ const CrtAddress: word = 0;
       mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLine16;
     end;
 
+    procedure FillCommonVESA256(var mode: TModeInfo);
+    begin
+      mode.MaxColor := 256;
+      { the ModeInfo is automatically set if the mode is supPorted }
+      { by the call to SearchVESAMode.                             }
+      mode.HardwarePages := VESAModeInfo.NumberOfPages;
+      mode.PaletteSize := mode.MaxColor;
+      mode.DirectColor := FALSE;
+      mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA256;
+      mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA256;
+      mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA256;
+      mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
+      mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
+{$ifdef fpc}
+      mode.SetAllPalette := @SetVESARGBAllPalette;
+{$endif fpc}
+      mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
+      mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
+      mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
+      mode.vline := {$ifdef fpc}@{$endif}VLineVESA256;
+      mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLineVESA256;
+//      mode.PatternLine := {$ifdef fpc}@{$endif}PatternLineVESA256;
+    end;
+
    var
     HGCDetected : Boolean;
     CGADetected : Boolean; { TRUE means real CGA, *not* EGA or VGA }
@@ -3601,31 +3625,13 @@ const CrtAddress: word = 0;
          if SearchVESAModes(m640x400x256) then
            begin
              InitMode(mode);
+             FillCommonVESA256(mode);
              mode.ModeNumber:=m640x400x256;
              mode.DriverNumber := VESA;
              mode.ModeName:='640 x 400 VESA';
-             mode.MaxColor := 256;
-             { the ModeInfo is automatically set if the mode is supPorted }
-             { by the call to SearchVESAMode.                             }
-             mode.HardwarePages := VESAModeInfo.NumberOfPages;
-             mode.PaletteSize := mode.MaxColor;
-             mode.DirectColor := FALSE;
              mode.MaxX := 639;
              mode.MaxY := 399;
-             mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA256;
-             mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA256;
-             mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA256;
-             mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
-             mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
-{$ifdef fpc}
-             mode.SetAllPalette := @SetVESARGBAllPalette;
-{$endif fpc}
              mode.InitMode := {$ifdef fpc}@{$endif}Init640x400x256;
-             mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
-             mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
-             mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
-             mode.vline := {$ifdef fpc}@{$endif}VLineVESA256;
-             mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLineVESA256;
              mode.XAspect := 8333;
              mode.YAspect := 10000;
              AddMode(mode);
@@ -3633,31 +3639,13 @@ const CrtAddress: word = 0;
          if SearchVESAModes(m640x480x256) then
            begin
              InitMode(mode);
+             FillCommonVESA256(mode);
              mode.ModeNumber:=m640x480x256;
              mode.DriverNumber := VESA;
              mode.ModeName:='640 x 480 VESA';
-             mode.MaxColor := 256;
-             { the ModeInfo is automatically set if the mode is supPorted }
-             { by the call to SearchVESAMode.                             }
-             mode.HardwarePages := VESAModeInfo.NumberOfPages;
-             mode.PaletteSize := mode.MaxColor;
              mode.MaxX := 639;
              mode.MaxY := 479;
-             mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA256;
-             mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA256;
-             mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA256;
-             mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
-             mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
-{$ifdef fpc}
-             mode.SetAllPalette := @SetVESARGBAllPalette;
-{$endif fpc}
              mode.InitMode := {$ifdef fpc}@{$endif}Init640x480x256;
-             mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
-             mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
-             mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
-             mode.vline := {$ifdef fpc}@{$endif}VLineVESA256;
-             mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLineVESA256;
-//             mode.PatternLine := {$ifdef fpc}@{$endif}PatternLineVESA256;
              mode.XAspect := 10000;
              mode.YAspect := 10000;
              AddMode(mode);
@@ -3747,32 +3735,13 @@ const CrtAddress: word = 0;
          if SearchVESAModes(m800x600x256) then
            begin
              InitMode(mode);
+             FillCommonVESA256(mode);
              mode.ModeNumber:=m800x600x256;
              mode.DriverNumber := VESA;
              mode.ModeName:='800 x 600 VESA';
-             mode.MaxColor := 256;
-             { the ModeInfo is automatically set if the mode is supPorted }
-             { by the call to SearchVESAMode.                             }
-             mode.HardwarePages := VESAModeInfo.NumberOfPages;
-             mode.PaletteSize := mode.MaxColor;
-             mode.DirectColor := FALSE;
              mode.MaxX := 799;
              mode.MaxY := 599;
-             mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA256;
-             mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA256;
-             mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA256;
-             mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
-             mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
-{$ifdef fpc}
-             mode.SetAllPalette := @SetVESARGBAllPalette;
-{$endif fpc}
              mode.InitMode := {$ifdef fpc}@{$endif}Init800x600x256;
-             mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
-             mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
-             mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
-             mode.vline := {$ifdef fpc}@{$endif}VLineVESA256;
-             mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLineVESA256;
-//             mode.PatternLine := {$ifdef fpc}@{$endif}PatternLineVESA256;
              mode.XAspect := 10000;
              mode.YAspect := 10000;
              AddMode(mode);
@@ -3862,32 +3831,13 @@ const CrtAddress: word = 0;
          if SearchVESAModes(m1024x768x256) then
            begin
              InitMode(mode);
+             FillCommonVESA256(mode);
              mode.ModeNumber:=m1024x768x256;
              mode.DriverNumber := VESA;
              mode.ModeName:='1024 x 768 VESA';
-             mode.MaxColor := 256;
-             { the ModeInfo is automatically set if the mode is supPorted }
-             { by the call to SearchVESAMode.                             }
-             mode.HardwarePages := VESAModeInfo.NumberOfPages;
-             mode.PaletteSize := mode.MaxColor;
-             mode.DirectColor := FALSE;
              mode.MaxX := 1023;
              mode.MaxY := 767;
-             mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA256;
-             mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA256;
-             mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA256;
-             mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
-             mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
-{$ifdef fpc}
-             mode.SetAllPalette := @SetVESARGBAllPalette;
-{$endif fpc}
              mode.InitMode := {$ifdef fpc}@{$endif}Init1024x768x256;
-             mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
-             mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
-             mode.vline := {$ifdef fpc}@{$endif}VLineVESA256;
-             mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
-             mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLineVESA256;
-//             mode.PatternLine := {$ifdef fpc}@{$endif}PatternLineVESA256;
              mode.XAspect := 10000;
              mode.YAspect := 10000;
              AddMode(mode);
@@ -3977,32 +3927,13 @@ const CrtAddress: word = 0;
          if SearchVESAModes(m1280x1024x256) then
            begin
              InitMode(mode);
+             FillCommonVESA256(mode);
              mode.ModeNumber:=m1280x1024x256;
              mode.DriverNumber := VESA;
              mode.ModeName:='1280 x 1024 VESA';
-             mode.MaxColor := 256;
-             { the ModeInfo is automatically set if the mode is supPorted }
-             { by the call to SearchVESAMode.                             }
-             mode.HardwarePages := VESAModeInfo.NumberOfPages;
-             mode.DirectColor := FALSE;
-             mode.PaletteSize := mode.MaxColor;
              mode.MaxX := 1279;
              mode.MaxY := 1023;
-             mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA256;
-             mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA256;
-             mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA256;
              mode.InitMode := {$ifdef fpc}@{$endif}Init1280x1024x256;
-             mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
-             mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
-{$ifdef fpc}
-             mode.SetAllPalette := @SetVESARGBAllPalette;
-{$endif fpc}
-             mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
-             mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
-             mode.vline := {$ifdef fpc}@{$endif}VLineVESA256;
-             mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
-             mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLineVESA256;
-//             mode.PatternLine := {$ifdef fpc}@{$endif}PatternLineVESA256;
              mode.XAspect := 10000;
              mode.YAspect := 10000;
              AddMode(mode);