Index: qemu/hw/pixel_ops.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ qemu/hw/pixel_ops.h 2007-06-07 19:45:57.000000000 +0000 @@ -0,0 +1,49 @@ +static inline unsigned int rgb_to_pixel8(unsigned int r, unsigned int g, + unsigned int b) +{ +#ifdef WORDS_BIGENDIAN + return ((b >> 5) << 5) | ((g >> 5) << 2) | (r >> 6); +#else + return ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6); +#endif +} + +static inline unsigned int rgb_to_pixel15(unsigned int r, unsigned int g, + unsigned int b) +{ +#ifdef WORDS_BIGENDIAN + return ((b >> 3) << 10) | ((g >> 3) << 5) | (r >> 3); +#else + return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3); +#endif +} + +static inline unsigned int rgb_to_pixel16(unsigned int r, unsigned int g, + unsigned int b) +{ +#ifdef WORDS_BIGENDIAN + return ((b >> 3) << 11) | ((g >> 2) << 5) | (r >> 3); +#else + return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); +#endif +} + +static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, + unsigned int b) +{ +#ifdef WORDS_BIGENDIAN + return (b << 16) | (g << 8) | r; +#else + return (r << 16) | (g << 8) | b; +#endif +} + +static inline unsigned int rgb_to_pixel32bgr(unsigned int r, unsigned int g, + unsigned int b) +{ +#ifdef WORDS_BIGENDIAN + return (r << 16) | (g << 8) | b; +#else + return (b << 16) | (g << 8) | r; +#endif +} Index: qemu/hw/tcx.c =================================================================== --- qemu.orig/hw/tcx.c 2007-06-07 19:35:27.000000000 +0000 +++ qemu/hw/tcx.c 2007-06-07 19:38:28.000000000 +0000 @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include "vl.h" +#include "pixel_ops.h" #define MAXX 1024 #define MAXY 768 @@ -47,27 +48,6 @@ static void tcx_invalidate_display(void *opaque); static void tcx24_invalidate_display(void *opaque); -/* XXX: unify with vga draw line functions */ -static inline unsigned int rgb_to_pixel8(unsigned int r, unsigned int g, unsigned b) -{ - return ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6); -} - -static inline unsigned int rgb_to_pixel15(unsigned int r, unsigned int g, unsigned b) -{ - return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3); -} - -static inline unsigned int rgb_to_pixel16(unsigned int r, unsigned int g, unsigned b) -{ - return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); -} - -static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, unsigned b) -{ - return (r << 16) | (g << 8) | b; -} - static void update_palette_entries(TCXState *s, int start, int end) { int i; Index: qemu/hw/vga.c =================================================================== --- qemu.orig/hw/vga.c 2007-06-07 19:36:38.000000000 +0000 +++ qemu/hw/vga.c 2007-06-07 19:41:42.000000000 +0000 @@ -23,6 +23,7 @@ */ #include "vl.h" #include "vga_int.h" +#include "pixel_ops.h" //#define DEBUG_VGA //#define DEBUG_VGA_MEM @@ -812,31 +813,6 @@ typedef void vga_draw_line_func(VGAState *s1, uint8_t *d, const uint8_t *s, int width); -static inline unsigned int rgb_to_pixel8(unsigned int r, unsigned int g, unsigned b) -{ - return ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6); -} - -static inline unsigned int rgb_to_pixel15(unsigned int r, unsigned int g, unsigned b) -{ - return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3); -} - -static inline unsigned int rgb_to_pixel16(unsigned int r, unsigned int g, unsigned b) -{ - return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); -} - -static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, unsigned b) -{ - return (r << 16) | (g << 8) | b; -} - -static inline unsigned int rgb_to_pixel32bgr(unsigned int r, unsigned int g, unsigned b) -{ - return (b << 16) | (g << 8) | r; -} - #define DEPTH 8 #include "vga_template.h" Index: qemu/Makefile.target =================================================================== --- qemu.orig/Makefile.target 2007-06-07 19:47:46.000000000 +0000 +++ qemu/Makefile.target 2007-06-07 19:50:35.000000000 +0000 @@ -592,6 +592,10 @@ signal.o: signal.c $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $< +vga.o: pixel_ops.h + +tcx.o: pixel_ops.h + ifeq ($(TARGET_BASE_ARCH), i386) op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h endif