Work on getting libpng to actually do something useful...
authorH. Peter Anvin <hpa@zytor.com>
Mon, 28 Aug 2006 08:50:09 +0000 (01:50 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Mon, 28 Aug 2006 08:50:09 +0000 (01:50 -0700)
com32/lib/MCONFIG
com32/lib/Makefile
com32/lib/math/pow.S [new file with mode: 0644]
com32/lib/sys/vesa/background.c

index 35d34d7..1263b51 100644 (file)
@@ -12,12 +12,18 @@ OBJCOPY     = objcopy
 
 # zlib and libpng configuration flags
 LIBFLAGS = -DDYNAMIC_CRC_TABLE -DPNG_NO_CONSOLE_IO \
-          -DPNG_NO_MNG_FEATURES -DPNG_NO_FLOATING_POINT_SUPPORTED \
-          -DPNG_NO_WRITE_FLUSH -DPNG_NO_WRITE_tIME -DPNG_NO_READ_tIME
+          -FPNG_NO_WRITE_SUPPORTED \
+          -DPNG_NO_MNG_FEATURES \
+          -DPNG_NO_READ_tIME -DPNG_NO_WRITE_tIME
+
+# We need some features in libpng which apparently aren't available in the
+# fixed-point versions.  It's OK, because we have to have a non-graphical
+# fallback anyway, just use that on old machines...
+# LIBFLAGS += -DPNG_NO_FLOATING_POINT_SUPPORTED
 
 REQFLAGS  = -g -m32 -mregparm=3 -DREGPARM=3 -D__COM32__ -I. -I./sys -I../include
 OPTFLAGS  = -Os -march=i386 -falign-functions=0 -falign-jumps=0 \
-           -falign-labels=0
+           -falign-labels=0 -ffast-math
 WARNFLAGS = -W -Wall -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
 
 CFLAGS  = -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d $(OPTFLAGS) \
index cfbeeb2..a3aaa51 100644 (file)
@@ -44,11 +44,13 @@ LIBOBJS = \
        zlib/uncompr.o zlib/deflate.o zlib/trees.o zlib/zutil.o         \
        zlib/inflate.o zlib/infback.o zlib/inftrees.o zlib/inffast.o    \
        \
-       libpng/png.o libpng/pngset.o libpng/pngrutil.o                  \
+       libpng/png.o libpng/pngset.o libpng/pngget.o libpng/pngrutil.o  \
        libpng/pngtrans.o libpng/pngwutil.o libpng/pngread.o            \
        libpng/pngrio.o libpng/pngwio.o libpng/pngwrite.o               \
        libpng/pngrtran.o libpng/pngwtran.o libpng/pngmem.o             \
-       libpng/pngerror.o libpng/pngpread.o
+       libpng/pngerror.o libpng/pngpread.o                             \
+       \
+       math/pow.o
 
 BINDIR   = /usr/bin
 LIBDIR   = /usr/lib
diff --git a/com32/lib/math/pow.S b/com32/lib/math/pow.S
new file mode 100644 (file)
index 0000000..5a124ab
--- /dev/null
@@ -0,0 +1,25 @@
+#
+# pow.S
+#
+# double pow(double base, double exponent)
+#
+
+       .text
+       .globl  pow
+       .type   pow,@function
+pow:
+       fldl    12(%esp)
+       fldl    4(%esp)
+       fyl2x
+       fld     %st(0)
+       frndint
+       fsubr   %st,%st(1)
+       fxch    %st(1)
+       f2xm1
+       fld1
+       faddp   %st,%st(1)
+       fscale
+       fstp    %st(1)
+       ret
+
+       .size   pow,.-pow
index 7de2d5a..5a34ef8 100644 (file)
@@ -55,8 +55,6 @@ int vesacon_load_background(const char *filename)
   png_infop end_ptr = NULL;
   png_color_16p image_background;
   static const png_color_16 my_background = {0,0,0,0,0};
-  double gamma;
-  const double screen_gamma = 2.2;
   png_bytep row_pointers[VIDEO_Y_SIZE];
   int passes;
   int i;
@@ -123,6 +121,11 @@ int vesacon_load_background(const char *filename)
 
   png_set_bgr(png_ptr);
 
+  if (info_ptr->bit_depth == 16)
+    png_set_strip_16(png_ptr);
+  else if (info_ptr->bit_depth < 8)
+    png_set_packing(png_ptr);
+
   if (png_get_bKGD(png_ptr, info_ptr, &image_background))
     png_set_background(png_ptr, image_background,
                       PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
@@ -130,17 +133,6 @@ int vesacon_load_background(const char *filename)
     png_set_background(png_ptr, &my_background,
                       PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
     
-
-  if (info_ptr->bit_depth == 16)
-    png_set_strip_16(png_ptr);
-  else if (info_ptr->bit_depth < 8)
-    png_set_packing(png_ptr);
-
-  if (png_get_gAMA(png_ptr, info_ptr, &gamma))
-    png_set_gamma(png_ptr, screen_gamma, gamma);
-  else
-    png_set_gamma(png_ptr, screen_gamma, 0.45455);
-
   /* Whew!  Now we should get the stuff we want... */
   for (i = 0; i < info_ptr->height; i++)
     row_pointers[i] = (png_bytep *)__vesacon_background[i];