Browse Source

* GetScanLine16 changed so that it reads video memory in 16-bit words, instead
of 32-bit longints, because 16-bit generates more efficient code on the i8086

git-svn-id: trunk@40996 -

nickysn 6 years ago
parent
commit
5ba5b871bf
1 changed files with 39 additions and 43 deletions
  1. 39 43
      packages/graph/src/msdos/graph.pp

+ 39 - 43
packages/graph/src/msdos/graph.pp

@@ -1749,7 +1749,7 @@ end;
 
 
 Procedure GetScanLine16(x1, x2, y: smallint; var data);
 Procedure GetScanLine16(x1, x2, y: smallint; var data);
 
 
-var dummylong: longint;
+var dummy: word;
     Offset, count, count2, amount, index: word;
     Offset, count, count2, amount, index: word;
     plane: byte;
     plane: byte;
 Begin
 Begin
@@ -1762,17 +1762,17 @@ Begin
 {$ifdef logging}
 {$ifdef logging}
   LogLn('Offset: '+HexStr(offset,4)+' - ' + strf(offset));
   LogLn('Offset: '+HexStr(offset,4)+' - ' + strf(offset));
 {$Endif logging}
 {$Endif logging}
-  { first get enough pixels so offset is 32bit aligned }
+  { first get enough pixels so offset is 16bit aligned }
   amount := 0;
   amount := 0;
   index := 0;
   index := 0;
-  If ((x1 and 31) <> 0) Or
-     ((x2-x1+1) < 32) Then
+  If ((x1 and 15) <> 0) Or
+     ((x2-x1+1) < 16) Then
     Begin
     Begin
-      If ((x2-x1+1) >= 32+32-(x1 and 31)) Then
-        amount := 32-(x1 and 31)
+      If ((x2-x1+1) >= 16+16-(x1 and 15)) Then
+        amount := 16-(x1 and 15)
       Else amount := x2-x1+1;
       Else amount := x2-x1+1;
 {$ifdef logging}
 {$ifdef logging}
-      LogLn('amount to align to 32bits or to get all: ' + strf(amount));
+      LogLn('amount to align to 16bits or to get all: ' + strf(amount));
 {$Endif logging}
 {$Endif logging}
       For count := 0 to amount-1 do
       For count := 0 to amount-1 do
         WordArray(Data)[Count] := getpixel16(x1-StartXViewPort+Count,y);
         WordArray(Data)[Count] := getpixel16(x1-StartXViewPort+Count,y);
@@ -1791,46 +1791,42 @@ Begin
   { first get everything from plane 3 (4th plane) }
   { first get everything from plane 3 (4th plane) }
   PortW[$3ce] := $0304;
   PortW[$3ce] := $0304;
   Count := 0;
   Count := 0;
-  For Count := 1 to (amount shr 5) Do
+  For Count := 1 to (amount shr 4) Do
     Begin
     Begin
-      dummylong := MemL[SegA000:offset+(Count-1)*4];
-      dummylong :=
-        ((dummylong and $ff) shl 24) or
-        ((dummylong and $ff00) shl 8) or
-        ((dummylong and $ff0000) shr 8) or
-        ((dummylong and $ff000000) shr 24);
-      For Count2 := 31 downto 0 Do
+      dummy := MemW[SegA000:offset+(Count-1)*2];
+      dummy :=
+        ((dummy and $ff) shl 8) or
+        ((dummy and $ff00) shr 8);
+      For Count2 := 15 downto 0 Do
         Begin
         Begin
-          WordArray(Data)[index+Count2] := DummyLong and 1;
-          DummyLong := DummyLong shr 1;
+          WordArray(Data)[index+Count2] := Dummy and 1;
+          Dummy := Dummy shr 1;
         End;
         End;
-      Inc(Index, 32);
+      Inc(Index, 16);
     End;
     End;
 { Now get the data from the 3 other planes }
 { Now get the data from the 3 other planes }
   plane := 3;
   plane := 3;
   Repeat
   Repeat
-    Dec(Index,Count*32);
+    Dec(Index,Count*16);
     Dec(plane);
     Dec(plane);
     Port[$3cf] := plane;
     Port[$3cf] := plane;
     Count := 0;
     Count := 0;
-    For Count := 1 to (amount shr 5) Do
+    For Count := 1 to (amount shr 4) Do
       Begin
       Begin
-        dummylong := MemL[SegA000:offset+(Count-1)*4];
-        dummylong :=
-          ((dummylong and $ff) shl 24) or
-          ((dummylong and $ff00) shl 8) or
-          ((dummylong and $ff0000) shr 8) or
-          ((dummylong and $ff000000) shr 24);
-        For Count2 := 31 downto 0 Do
+        dummy := MemW[SegA000:offset+(Count-1)*2];
+        dummy :=
+          ((dummy and $ff) shl 8) or
+          ((dummy and $ff00) shr 8);
+        For Count2 := 15 downto 0 Do
           Begin
           Begin
             WordArray(Data)[index+Count2] :=
             WordArray(Data)[index+Count2] :=
-              (WordArray(Data)[index+Count2] shl 1) or (DummyLong and 1);
-            DummyLong := DummyLong shr 1;
+              (WordArray(Data)[index+Count2] shl 1) or (Dummy and 1);
+            Dummy := Dummy shr 1;
           End;
           End;
-        Inc(Index, 32);
+        Inc(Index, 16);
       End;
       End;
   Until plane = 0;
   Until plane = 0;
-  amount := amount and 31;
+  amount := amount and 15;
   Dec(index);
   Dec(index);
 {$ifdef Logging}
 {$ifdef Logging}
   LogLn('Last array index written to: '+strf(index));
   LogLn('Last array index written to: '+strf(index));
@@ -1841,32 +1837,32 @@ Begin
     WordArray(Data)[index+Count] := getpixel16(x1+index+Count,y);
     WordArray(Data)[index+Count] := getpixel16(x1+index+Count,y);
 {$ifdef logging}
 {$ifdef logging}
   inc(x1,startXViewPort);
   inc(x1,startXViewPort);
-  LogLn('First 32 bytes gotten with getscanline16: ');
-  If x2-x1+1 >= 32 Then
-    Count2 := 32
+  LogLn('First 16 bytes gotten with getscanline16: ');
+  If x2-x1+1 >= 16 Then
+    Count2 := 16
   Else Count2 := x2-x1+1;
   Else Count2 := x2-x1+1;
   For Count := 0 to Count2-1 Do
   For Count := 0 to Count2-1 Do
     Log(strf(WordArray(Data)[Count])+' ');
     Log(strf(WordArray(Data)[Count])+' ');
   LogLn('');
   LogLn('');
-  If x2-x1+1 >= 32 Then
+  If x2-x1+1 >= 16 Then
     Begin
     Begin
-      LogLn('Last 32 bytes gotten with getscanline16: ');
-      For Count := 31 downto 0 Do
+      LogLn('Last 16 bytes gotten with getscanline16: ');
+      For Count := 15 downto 0 Do
       Log(strf(WordArray(Data)[x2-x1-Count])+' ');
       Log(strf(WordArray(Data)[x2-x1-Count])+' ');
     End;
     End;
   LogLn('');
   LogLn('');
   GetScanLineDefault(x1-StartXViewPort,x2-StartXViewPort,y,Data);
   GetScanLineDefault(x1-StartXViewPort,x2-StartXViewPort,y,Data);
-  LogLn('First 32 bytes gotten with getscanlinedef: ');
-  If x2-x1+1 >= 32 Then
-    Count2 := 32
+  LogLn('First 16 bytes gotten with getscanlinedef: ');
+  If x2-x1+1 >= 16 Then
+    Count2 := 16
   Else Count2 := x2-x1+1;
   Else Count2 := x2-x1+1;
   For Count := 0 to Count2-1 Do
   For Count := 0 to Count2-1 Do
     Log(strf(WordArray(Data)[Count])+' ');
     Log(strf(WordArray(Data)[Count])+' ');
   LogLn('');
   LogLn('');
-  If x2-x1+1 >= 32 Then
+  If x2-x1+1 >= 16 Then
     Begin
     Begin
-      LogLn('Last 32 bytes gotten with getscanlinedef: ');
-      For Count := 31 downto 0 Do
+      LogLn('Last 16 bytes gotten with getscanlinedef: ');
+      For Count := 15 downto 0 Do
       Log(strf(WordArray(Data)[x2-x1-Count])+' ');
       Log(strf(WordArray(Data)[x2-x1-Count])+' ');
     End;
     End;
   LogLn('');
   LogLn('');