$NetBSD: patch-aa,v 1.1.1.1 2004/01/23 08:21:59 skrll Exp $

--- generic/fb-xlat-auto.sh.orig	Mon Sep 29 12:42:56 2003
+++ generic/fb-xlat-auto.sh
@@ -1905,50 +1905,82 @@ for src_key in ${src_all}; do
 		echo "             : ${dst_shift}));"
 
 		echo ""
-		echo "      /* put the pixel into both FIFOs again.  if"
-		echo "         dst_bipp is 24 or greater, the FIFOs can"
-		echo "         not entirely take these further pixels,"
-		echo "         so we need to shift: */"
-		echo "      if (dst_bipp >= 24) {"
-		echo "        TME_FB_XLAT_SHIFT_DST(dst_fifo0_may_be_unaligned,"
-		echo "                              dst_fifo0,"
-		echo "                              dst_fifo0_next,"
-		echo "                              dst_fifo0_bits,"
-		echo "                              dst_bipp,"
-		echo "                              dst_raw0,"
-		echo "                              dst_order);"
-		echo "        TME_FB_XLAT_SHIFT_DST(dst_fifo1_may_be_unaligned,"
-		echo "                              dst_fifo1,"
-		echo "                              dst_fifo1_next,"
-		echo "                              dst_fifo1_bits,"
-		echo "                              dst_bipp,"
-		echo "                              dst_raw1,"
-		echo "                              dst_order);"
-		echo "        dst_fifo0 |="
-		echo "          (pixel"
-		echo "           << (dst_order == TME_ENDIAN_BIG"
-		echo "               ? ((32 - dst_bipp) - ${dst_shift})"
-		echo "               : ${dst_shift}));"
-		echo "        dst_fifo1 |="
-		echo "          (pixel"
-		echo "           << (dst_order == TME_ENDIAN_BIG"
-		echo "               ? ((32 - dst_bipp) - ${dst_shift})"
-		echo "               : ${dst_shift}));"
-		echo "      }"
-		echo ""
-		echo "      /* otherwise, the FIFOs can take these further pixels: */"
-		echo "      else {"
-		echo "        dst_fifo0 |="
-		echo "          (pixel"
-		echo "           << (dst_order == TME_ENDIAN_BIG"
-		echo "               ? ((32 - dst_bipp) - (${dst_shift} + dst_bipp))"
-		echo "               : (${dst_shift} + dst_bipp)));"
-		echo "        dst_fifo1 |="
-		echo "          (pixel"
-		echo "           << (dst_order == TME_ENDIAN_BIG"
-		echo "               ? ((32 - dst_bipp) - (${dst_shift} + dst_bipp))"
-		echo "               : (${dst_shift} + dst_bipp)));"
-		echo "      }"
+		if test `expr ${dst_bipp} \>= 24` = 1; then
+		    echo "      /* put the pixel into both FIFOs again.  in"
+		    echo "         this case, dst_bipp is known to be ${dst_bipp},"
+		    echo "         meaning the FIFOs cannot entirely take these"
+		    echo "         further pixels, so we need to shift the FIFOs: */"
+		    indent0=""
+		    indent1=X
+		elif test ${dst_bipp} = 0; then
+		    echo "      /* put the pixel into both FIFOs again.  if"
+		    echo "         dst_bipp is 24 or greater, the FIFOs can"
+		    echo "         not entirely take these further pixels,"
+		    echo "         so we need to shift the FIFOs: */"
+		    echo "      if (dst_bipp >= 24) {"
+		    indent0="  "
+		    indent1="  "
+		else
+		    echo "      /* put the pixel into both FIFOs again.  in"
+		    echo "         this case, dst_bipp is known to be ${dst_bipp},"
+		    echo "         meaning the FIFOs can take these further pixels"
+		    echo "         without shifting the FIFOs, as long as we shift"
+		    echo "         the pixels one pixel further: */"
+		    indent0=X
+		    indent1=""
+		fi
+		if test "X${indent0}" != "XX"; then
+		    echo "${indent0}      TME_FB_XLAT_SHIFT_DST(dst_fifo0_may_be_unaligned,"
+		    echo "${indent0}                            dst_fifo0,"
+		    echo "${indent0}                            dst_fifo0_next,"
+		    echo "${indent0}                            dst_fifo0_bits,"
+		    echo "${indent0}                            dst_bipp,"
+		    echo "${indent0}                            dst_raw0,"
+		    echo "${indent0}                            dst_order);"
+		    echo "${indent0}      TME_FB_XLAT_SHIFT_DST(dst_fifo1_may_be_unaligned,"
+		    echo "${indent0}                            dst_fifo1,"
+		    echo "${indent0}                            dst_fifo1_next,"
+		    echo "${indent0}                            dst_fifo1_bits,"
+		    echo "${indent0}                            dst_bipp,"
+		    echo "${indent0}                            dst_raw1,"
+		    echo "${indent0}                            dst_order);"
+		    echo ""
+		    echo "${indent0}      /* now that we've shifted by dst_bipp, we can"
+		    echo "${indent0}         put the further pixels exactly where the"
+		    echo "${indent0}         first pixels went in the FIFOs: */"
+		    echo "${indent0}      dst_fifo0 |="
+		    echo "${indent0}        (pixel"
+		    echo "${indent0}         << (dst_order == TME_ENDIAN_BIG"
+		    echo "${indent0}             ? ((32 - dst_bipp) - ${dst_shift})"
+		    echo "${indent0}             : ${dst_shift}));"
+		    echo "${indent0}      dst_fifo1 |="
+		    echo "${indent0}        (pixel"
+		    echo "${indent0}         << (dst_order == TME_ENDIAN_BIG"
+		    echo "${indent0}             ? ((32 - dst_bipp) - ${dst_shift})"
+		    echo "${indent0}             : ${dst_shift}));"
+		fi
+		if test ${dst_bipp} = 0; then
+		    echo "      }"
+		    echo ""
+		    echo "      /* otherwise, the FIFOs can take these further pixels,"
+		    echo "         as long as we shift the pixels one pixel further: */"
+		    echo "      else {"
+		fi
+		if test "X${indent1}" != "XX"; then
+		    echo "${indent1}      dst_fifo0 |="
+		    echo "${indent1}        (pixel"
+		    echo "${indent1}         << (dst_order == TME_ENDIAN_BIG"
+		    echo "${indent1}             ? ((32 - dst_bipp) - (${dst_shift} + dst_bipp))"
+		    echo "${indent1}             : (${dst_shift} + dst_bipp)));"
+		    echo "${indent1}      dst_fifo1 |="
+		    echo "${indent1}        (pixel"
+		    echo "${indent1}         << (dst_order == TME_ENDIAN_BIG"
+		    echo "${indent1}             ? ((32 - dst_bipp) - (${dst_shift} + dst_bipp))"
+		    echo "${indent1}             : (${dst_shift} + dst_bipp)));"
+		fi
+		if test ${dst_bipp} = 0; then
+		    echo "      }"
+		fi
 	    fi
 
 	    echo ""
