Re: [AD] bmp_write15(), _[get|put]pixel15()

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Eric Botcazou wrote:
[snip]
>>I think we could avoid some code duplication
in e.g. the rotation scanline drawers by merging 15 and 16 bit versions.
We could let each platform define a macro PIXEL_15_EQUALS_16 or
something similar, and check it so that it still works in possible future
ports. OK?


That sounds sensible to me, as long as the interface is not modified.

Good, here's a proposed patch. Feel free to think of a better name
instead of ALLEGRO_PIXEL_15_EQUALS_16. Should I commit it?

--
Sven Sandberg   svsa1977@xxxxxxxxxx   home.student.uu.se/svsa1977
Index: src/rotate.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/rotate.c,v
retrieving revision 1.12
diff -u -r1.12 rotate.c
--- src/rotate.c	1 Dec 2001 13:32:51 -0000	1.12
+++ src/rotate.c	11 May 2002 00:00:18 -0000
@@ -111,8 +111,12 @@
 #ifdef ALLEGRO_COLOR16
    SCANLINE_DRAWER(15, c = ((unsigned short *)spr_line[l_spr_y>>16])
 			   [l_spr_x>>16])
-   SCANLINE_DRAWER(16, c = ((unsigned short *)spr_line[l_spr_y>>16])
-			   [l_spr_x>>16])
+   #ifdef ALLEGRO_PIXEL_15_EQUALS_16
+      #define draw_scanline_16 draw_scanline_15
+   #else
+      SCANLINE_DRAWER(16, c = ((unsigned short *)spr_line[l_spr_y>>16])
+		              [l_spr_x>>16])
+   #endif
 #endif
 
 #ifdef ALLEGRO_COLOR24
Index: include/allegro/internal/alconfig.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/internal/alconfig.h,v
retrieving revision 1.5
diff -u -r1.5 alconfig.h
--- include/allegro/internal/alconfig.h	12 Apr 2002 13:45:31 -0000	1.5
+++ include/allegro/internal/alconfig.h	11 May 2002 00:00:18 -0000
@@ -255,6 +255,9 @@
    #define bmp_read16(addr)            (*((unsigned short *)(addr)))
    #define bmp_read32(addr)            (*((unsigned long  *)(addr)))
 
+   /* bmp_read15/bmp_write15 are equivalent to bmp_read16/bmp_write16 */
+   #define ALLEGRO_PIXEL_15_EQUALS_16
+
    #ifdef ALLEGRO_LITTLE_ENDIAN
 
       AL_INLINE(void, bmp_write24, (unsigned long addr, int c),
Index: include/allegro/platform/aldjgpp.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/platform/aldjgpp.h,v
retrieving revision 1.4
diff -u -r1.4 aldjgpp.h
--- include/allegro/platform/aldjgpp.h	12 Apr 2002 13:45:32 -0000	1.4
+++ include/allegro/platform/aldjgpp.h	11 May 2002 00:00:18 -0000
@@ -74,6 +74,9 @@
 #define bmp_read32(addr)            _farnspeekl(addr)
 #define bmp_read24(addr)            (_farnspeekl(addr) & 0xFFFFFF)
 
+/* bmp_read15 and bmp_write15 are equivalent to bmp_read16 and bmp_write16 */
+#define ALLEGRO_PIXEL_15_EQUALS_16
+
 #ifndef AL_INLINE
 extern __inline__  /* special bodge because AL_INLINE isn't defined yet */
 #endif


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/