I've made modifications in allegro to eliminate the power-of-two-sized
restriction to patterned drawing modes. I've also created new drawing modes:

DRAW_MODE_SPRITE_PATTERN - It's the fusion of DRAW_MODE_COPY_PATTERN and 
  DRAW_MODE_MASKED_PATTERN modes, if the pixel of the pattern is the mask, it
  will be skiped, like DRAW_MODE_MASKED_PATTERN, but if it isn't, the pixel
  from the pattern will be ploted, like DRAW_MODE_COPY_PATTERN.

DRAW_MODE_AND - It's like the DRAW_MODE_XOR drawing mode, but instead of
  XOR'ing the pixel, this will AND the pixel.

DRAW_MODE_OR - It's like the DRAW_MODE_XOR drawing mode too, but instead of
  XOR'ing the pixel, this will OR the pixel.

Changed files:

  \include\draw.h -> Slightly modified (three lines) to define the new drawing
      modes.

  \src\c\cdefs8.h -> Modified the PATTERN_LINE() and GET_PATTERN_PIXEL()
      macros to eliminate the power-of-two-sized restriction.

  \src\c\cdefs15.h -> Modified the PATTERN_LINE() and GET_PATTERN_PIXEL()
      macros to eliminate the power-of-two-sized restriction.

  \src\c\cdefs16.h -> Modified the PATTERN_LINE() and GET_PATTERN_PIXEL()
      macros to eliminate the power-of-two-sized restriction.

  \src\c\cdefs24.h -> Modified the PATTERN_LINE() and GET_PATTERN_PIXEL()
      macros to eliminate the power-of-two-sized restriction.

  \src\c\cdefs32.h -> Modified the PATTERN_LINE() and GET_PATTERN_PIXEL()
      macros to eliminate the power-of-two-sized restriction.

  \src\c\cgfx.h -> Modified the behavior of the FUNC_LINEAR_PUTPIXEL() and
      FUNC_LINEAR_HLINE() functions (or maybe macros :-) to understand the new
      drawing modes and eliminate the power-of-two-sized restriction.

  \src\i386\igfx8.s -> Modified the behavior of _linear_putpixel8() and
      _linear_hline8() functions to understand the new drawing modes and
      eliminate the power-of-two-sized restriction.

  \src\i386\igfx15.s -> Modified the behavior of _linear_putpixel15() and
      _linear_hline15() functions to understand the new drawing modes and
      eliminate the power-of-two-sized restriction.

  \src\i386\igfx16.s -> Modified the behavior of _linear_putpixel16() and
      _linear_hline16() functions to understand the new drawing modes and
      eliminate the power-of-two-sized restriction.

  \src\i386\igfx24.s -> Modified the behavior of _linear_putpixel24() and
      _linear_hline24() functions to understand the new drawing modes and
      eliminate the power-of-two-sized restriction.

  \src\i386\igfx32.s -> Modified the behavior of _linear_putpixel32() and
      _linear_hline32() functions to understand the new drawing modes and
      eliminate the power-of-two-sized restriction.

  \src\misc\modexgfx.s -> Modified the behavior of _x_putpixel() and
      _x_hline() functions to understand the new drawing modes and eliminate
      the power-of-two-sized restriction.

  \src\gfx.c -> Modified the behavior of the drawing_mode() function to
      eliminate the power-of-two-sized restriction.

  \src\i386\asmdefs.inc -> Modified the LOOKUP_PATTERN_POS() macro to
      eliminate the power-of-two-sized restriction. I've needed to create the
      DO_PATTERN_MOD() and INC_PATTERN_MOD() macros too for this work.

  \src\misc\asmdef.c -> Slightly modified (three lines) to understand the new
      drawing modes.

  \src\spline.c -> Slightly modified (two lines) the _soft_spline() function
      to understand the new DRAW_MODE_OR and DRAW_MODE_AND modes.

  \src\scene3d.c -> Slightly modified (one line) the init_poly() function to
      understand the DRAW_MODE_SPRITE_PATTERN mode.

  I could change the \tests\test.c, but i think that it's still too soon for
  that.

Compatibility issues:

  The behavior of the drawing_mode() function has changed, it doesn't anymore
  round the size of the pattern to a power of two. Maybe this function should
  be called drawing_mode_ex() and the old one should be deprecated? Or not?

Performance issues:

  Since the code can't just do a simple AND anymore to get the position in a
  patterned drawing mode, the code to keep the position inside the pattern is
  a bit more complex, but notably slower for putpixels. For hlines it's just a
  bit slower. Otimizations would be welcome. (Sorry i'm just a begginer in
  assembler :-)

  The macro DO_PATTERN_MOD() is used twice by the macro LOOKUP_PATTERN_POS(),
  (both in \src\i386\asmdefs.inc), and it is a good target to otimizations.
  The macro LOOKUP_PATTERN_POS() is used for each putpixel and hline-like
  functions implemented in assembler. So for each one, DO_PATTERN_MOD() is
  used twice too. The hline-like functions uses the macro INC_PATTERN_MOD()
  for each pixel in patterned modes, so it would be a nice place to otimize,
  but i really think that it isn't anymore otimizable.

  The macros PATTERN_LINE() and GET_PATTERN_PIXEL() in the \src\c\cdefs*.h
  files should be otimized too, if possible.

By Victor Williams Stafusa da Silva - vwss1984 at yahoo dot com dot br