Browse Source

* LFB modes finally work! You have to add $4000 to the mode number
if you use LFB access!

Jonas Maebe 25 years ago
parent
commit
577075367d
1 changed files with 69 additions and 13 deletions
  1. 69 13
      rtl/go32v2/vesa.inc

+ 69 - 13
rtl/go32v2/vesa.inc

@@ -1193,7 +1193,7 @@ type
            if UseNoSelector then
            if UseNoSelector then
              col:=pbyte(LFBPointer+offs+LinearPageOfs)^
              col:=pbyte(LFBPointer+offs+LinearPageOfs)^
            else
            else
-             seg_move(WinReadSeg,offs+LinearPageOfs,get_ds,longint(@col),1);
+             seg_move(WinWriteSeg,offs+LinearPageOfs,get_ds,longint(@col),1);
            col := col xor byte(CurrentColor);
            col := col xor byte(CurrentColor);
          End;
          End;
        AndPut:
        AndPut:
@@ -1201,7 +1201,7 @@ type
            if UseNoSelector then
            if UseNoSelector then
              col:=pbyte(LFBPointer+offs+LinearPageOfs)^
              col:=pbyte(LFBPointer+offs+LinearPageOfs)^
            else
            else
-             seg_move(WinReadSeg,offs+LinearPageOfs,get_ds,longint(@col),1);
+             seg_move(WinWriteSeg,offs+LinearPageOfs,get_ds,longint(@col),1);
            col := col and byte(CurrentColor);
            col := col and byte(CurrentColor);
          End;
          End;
        OrPut:
        OrPut:
@@ -1209,7 +1209,7 @@ type
            if UseNoSelector then
            if UseNoSelector then
              col:=pbyte(LFBPointer+offs+LinearPageOfs)^
              col:=pbyte(LFBPointer+offs+LinearPageOfs)^
            else
            else
-             seg_move(WinReadSeg,offs+LinearPageOfs,get_ds,longint(@col),1);
+             seg_move(WinWriteSeg,offs+LinearPageOfs,get_ds,longint(@col),1);
            col := col or byte(CurrentColor);
            col := col or byte(CurrentColor);
          End
          End
        else
        else
@@ -1240,8 +1240,12 @@ type
          exit;
          exit;
      end;
      end;
      offs := longint(y) * BytesPerLine + x;
      offs := longint(y) * BytesPerLine + x;
+     {$ifdef logging}
+     logln('putpix offset: '+hexstr(offs,8)+', color: '+strf(color)+', lpo: $'+
+       hexstr(LinearPageOfs,8));
+     {$endif logging}
      if UseNoSelector then
      if UseNoSelector then
-       pbyte(LFBPointer+offs+LinearPageOfs)^:=color
+       pbyte(LFBPointer+offs+LinearPageOfs)^:=byte(color)
      else
      else
        seg_move(get_ds,longint(@color),WinWriteSeg,offs+LinearPageOfs,1);
        seg_move(get_ds,longint(@color),WinWriteSeg,offs+LinearPageOfs,1);
   end;
   end;
@@ -1254,10 +1258,14 @@ type
      X:= X + StartXViewPort;
      X:= X + StartXViewPort;
      Y:= Y + StartYViewPort;
      Y:= Y + StartYViewPort;
      offs := longint(y) * BytesPerLine + x;
      offs := longint(y) * BytesPerLine + x;
+     {$ifdef logging}
+     logln('getpix offset: '+hexstr(offs,8)+', lpo: $'+
+       hexstr(LinearPageOfs,8));
+     {$endif logging}
      if UseNoSelector then
      if UseNoSelector then
        col:=pbyte(LFBPointer+offs+LinearPageOfs)^
        col:=pbyte(LFBPointer+offs+LinearPageOfs)^
      else
      else
-       seg_move(WinReadSeg,offs+LinearPageOfs,get_ds,longint(@col),1);
+       seg_move(WinWriteSeg,offs+LinearPageOfs,get_ds,longint(@col),1);
      GetPixVESA256Linear:=col;
      GetPixVESA256Linear:=col;
   end;
   end;
 (*
 (*
@@ -1300,6 +1308,9 @@ end;
   var
   var
      offs : longint;
      offs : longint;
   begin
   begin
+{$ifdef logging}
+     logln('putpixvesa32kor64k('+strf(x)+','+strf(y)+')');
+{$endif logging}
      X:= X + StartXViewPort;
      X:= X + StartXViewPort;
      Y:= Y + StartYViewPort;
      Y:= Y + StartYViewPort;
      { convert to absolute coordinates and then verify clipping...}
      { convert to absolute coordinates and then verify clipping...}
@@ -1313,6 +1324,9 @@ end;
      Y := Y + YOffset; { adjust pixel for correct virtual page }
      Y := Y + YOffset; { adjust pixel for correct virtual page }
      offs := longint(y) * BytesPerLine + 2*x;
      offs := longint(y) * BytesPerLine + 2*x;
      SetWriteBank(integer(offs shr 16));
      SetWriteBank(integer(offs shr 16));
+{$ifdef logging}
+     logln('putpixvesa32kor64k offset: '+strf(word(offs)));
+{$endif logging}
      memW[WinWriteSeg : word(offs)] := color;
      memW[WinWriteSeg : word(offs)] := color;
   end;
   end;
 
 
@@ -1332,6 +1346,9 @@ end;
      offs : longint;
      offs : longint;
      col : word;
      col : word;
   begin
   begin
+{$ifdef logging}
+     logln('directputpixvesa32kor64k('+strf(x)+','+strf(y)+')');
+{$endif logging}
      y:= Y + YOffset;
      y:= Y + YOffset;
      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));
@@ -1356,6 +1373,9 @@ end;
            If CurrentWriteMode <> NotPut Then
            If CurrentWriteMode <> NotPut Then
              col := CurrentColor
              col := CurrentColor
            Else col := Not(CurrentColor);
            Else col := Not(CurrentColor);
+{$ifdef logging}
+           logln('directputpixvesa32kor64k offset: '+strf(word(offs)));
+{$endif logging}
            memW[WinWriteSeg : word(offs)] := Col;
            memW[WinWriteSeg : word(offs)] := Col;
          End
          End
      End;
      End;
@@ -1398,7 +1418,7 @@ end;
      if UseNoSelector then
      if UseNoSelector then
        color:=pword(LFBPointer+offs+LinearPageOfs)^
        color:=pword(LFBPointer+offs+LinearPageOfs)^
      else
      else
-       seg_move(WinReadSeg,offs+LinearPageOfs,get_ds,longint(@color),2);
+       seg_move(WinWriteSeg,offs+LinearPageOfs,get_ds,longint(@color),2);
      GetPixVESA32kor64kLinear:=color;
      GetPixVESA32kor64kLinear:=color;
   end;
   end;
 
 
@@ -1414,7 +1434,7 @@ end;
            if UseNoSelector then
            if UseNoSelector then
              col:=pword(LFBPointer+offs+LinearPageOfs)^
              col:=pword(LFBPointer+offs+LinearPageOfs)^
            else
            else
-             seg_move(WinReadSeg,offs+LinearPageOfs,get_ds,longint(@col),2);
+             seg_move(WinWriteSeg,offs+LinearPageOfs,get_ds,longint(@col),2);
            col := col xor currentcolor;
            col := col xor currentcolor;
          End;
          End;
        AndPut:
        AndPut:
@@ -1422,7 +1442,7 @@ end;
            if UseNoSelector then
            if UseNoSelector then
              col:=pword(LFBPointer+offs+LinearPageOfs)^
              col:=pword(LFBPointer+offs+LinearPageOfs)^
            else
            else
-             seg_move(WinReadSeg,offs+LinearPageOfs,get_ds,longint(@col),2);
+             seg_move(WinWriteSeg,offs+LinearPageOfs,get_ds,longint(@col),2);
            col := col and currentcolor;
            col := col and currentcolor;
          End;
          End;
        OrPut:
        OrPut:
@@ -1430,7 +1450,7 @@ end;
            if UseNoSelector then
            if UseNoSelector then
              col:=pword(LFBPointer+offs+LinearPageOfs)^
              col:=pword(LFBPointer+offs+LinearPageOfs)^
            else
            else
-             seg_move(WinReadSeg,offs+LinearPageOfs,get_ds,longint(@col),2);
+             seg_move(WinWriteSeg,offs+LinearPageOfs,get_ds,longint(@col),2);
            col := col or currentcolor;
            col := col or currentcolor;
          End
          End
        else
        else
@@ -1578,6 +1598,9 @@ end;
     begin
     begin
       if DirectColor then
       if DirectColor then
         Begin
         Begin
+{$ifdef logging}
+          logln('setvesargbpalette called with directcolor = true');
+{$endif logging}
           _GraphResult := grError;
           _GraphResult := grError;
           exit;
           exit;
         end;
         end;
@@ -1633,6 +1656,9 @@ end;
 
 
             if word(regs.eax) <> $004F then
             if word(regs.eax) <> $004F then
               begin
               begin
+{$ifdef logging}
+                logln('setvesargbpalette failed while directcolor = false!');
+{$endif logging}
                 _GraphResult := grError;
                 _GraphResult := grError;
                 exit;
                 exit;
               end;
               end;
@@ -1658,6 +1684,9 @@ end;
    begin
    begin
       if DirectColor then
       if DirectColor then
         Begin
         Begin
+{$ifdef logging}
+         logln('getvesargbpalette called with directcolor = true');
+{$endif logging}
           _GraphResult := grError;
           _GraphResult := grError;
           exit;
           exit;
         end;
         end;
@@ -1703,6 +1732,9 @@ end;
 
 
             if word(regs.eax) <> $004F then
             if word(regs.eax) <> $004F then
               begin
               begin
+{$ifdef logging}
+                logln('getvesargbpalette failed while directcolor = false!');
+{$endif logging}
                 _GraphResult := grError;
                 _GraphResult := grError;
                 exit;
                 exit;
               end
               end
@@ -1909,8 +1941,15 @@ Const
      end;
      end;
      FrameBufferLinearAddress:=Get_linear_addr(VESAModeInfo.PhysAddress and $FFFF0000,
      FrameBufferLinearAddress:=Get_linear_addr(VESAModeInfo.PhysAddress and $FFFF0000,
        VESAInfo.TotalMem shl 16);
        VESAInfo.TotalMem shl 16);
+{$ifdef logging}
+     logln('framebuffer linear address: '+hexstr(FrameBufferLinearAddress div (1024*1024),8));
+     logln('total mem shl 16: '+strf(vesainfo.totalmem shl 16));
+{$endif logging}
      if int31error<>0 then
      if int31error<>0 then
        begin
        begin
+{$ifdef logging}
+         logln('Unable to get linear address for '+hexstr(VESAModeInfo.PhysAddress,8));
+{$endif logging}
          writeln(stderr,'Unable to get linear address for ',hexstr(VESAModeInfo.PhysAddress,8));
          writeln(stderr,'Unable to get linear address for ',hexstr(VESAModeInfo.PhysAddress,8));
          exit;
          exit;
        end;
        end;
@@ -1924,17 +1963,22 @@ Const
      else
      else
        begin
        begin
          WinWriteSeg:=allocate_ldt_descriptors(1);
          WinWriteSeg:=allocate_ldt_descriptors(1);
-         WinReadSeg:=allocate_ldt_descriptors(1);
+{$ifdef logging}
+         logln('writeseg1: '+hexstr(winwriteseg,8));
+{$endif logging}
          set_segment_base_address(WinWriteSeg,FrameBufferLinearAddress);
          set_segment_base_address(WinWriteSeg,FrameBufferLinearAddress);
          set_segment_limit(WinWriteSeg,(VESAInfo.TotalMem shl 16)-1);
          set_segment_limit(WinWriteSeg,(VESAInfo.TotalMem shl 16)-1);
-         set_segment_base_address(WinReadSeg,FrameBufferLinearAddress);
-         set_segment_limit(WinReadSeg,(VESAInfo.TotalMem shl 16)-1);
+         lock_linear_region(FrameBufferLinearAddress,(VESAInfo.TotalMem shl 16));
          if int31error<>0 then
          if int31error<>0 then
            begin
            begin
+{$ifdef logging}
+             logln('Error in linear memory selectors creation');
+{$endif logging}
              writeln(stderr,'Error in linear memory selectors creation');
              writeln(stderr,'Error in linear memory selectors creation');
              exit;
              exit;
            end;
            end;
        end;
        end;
+     LinearPageOfs := 0;
      InLinear:=true;
      InLinear:=true;
      SetUpLinear:=true;
      SetUpLinear:=true;
      { WinSize:=(VGAInfo.TotalMem shl 16);
      { WinSize:=(VGAInfo.TotalMem shl 16);
@@ -2086,6 +2130,9 @@ Const
      if (VESAModeInfo.attr and modeAvail) = 0 then
      if (VESAModeInfo.attr and modeAvail) = 0 then
        begin
        begin
          SetVESAmode := FALSE;
          SetVESAmode := FALSE;
+{$ifdef logging}
+         logln('  vesa mode '+strf(mode)+' not supported!!!');
+{$endif logging}
          _GraphResult := grError;
          _GraphResult := grError;
          exit;
          exit;
        end;
        end;
@@ -2125,6 +2172,9 @@ Const
   LogLn('Window size: '+strf(VESAModeInfo.winSize)+'kb');
   LogLn('Window size: '+strf(VESAModeInfo.winSize)+'kb');
   LogLn('Bytes per line: '+strf(bytesperline));
   LogLn('Bytes per line: '+strf(bytesperline));
 {$endif logging}
 {$endif logging}
+   { Select the correct mode number if we're going to use linear access! }
+   if InLinear then
+     inc(mode,$4000);
 
 
    asm
    asm
     mov ax,4F02h
     mov ax,4F02h
@@ -2353,6 +2403,7 @@ Const
 {$endif fpc}
 {$endif fpc}
       mov  [VideoMode], al
       mov  [VideoMode], al
     end;
     end;
+(*
 {$ifdef logging}
 {$ifdef logging}
         LogLn('Prepare to save VESA video state');
         LogLn('Prepare to save VESA video state');
 {$endif logging}
 {$endif logging}
@@ -2422,6 +2473,7 @@ Const
         regs.ebx := 0;
         regs.ebx := 0;
         RealIntr($10,regs);
         RealIntr($10,regs);
       end;
       end;
+*)
   end;
   end;
 
 
  procedure RestoreStateVESA; {$ifndef fpc}far;{$endif fpc}
  procedure RestoreStateVESA; {$ifndef fpc}far;{$endif fpc}
@@ -2595,7 +2647,11 @@ Const
 
 
 (*
 (*
 $Log$
 $Log$
-Revision 1.24  2000-06-07 07:41:44  jonas
+Revision 1.25  2000-07-08 07:48:38  jonas
+  * LFB modes finally work! You have to add $4000 to the mode number
+    if you use LFB access!
+
+Revision 1.24  2000/06/07 07:41:44  jonas
   * always set SetupLinear to false at the start of the routine (there
   * always set SetupLinear to false at the start of the routine (there
     were some "exit" statements which returned without the function
     were some "exit" statements which returned without the function
     result being set otherwise)
     result being set otherwise)