Hey what am I doing?! I totally have the function you're looking for!
but use this overload for simplicity:
ALLEGRO_BITMAP *create_masked_bitmap(ALLEGRO_BITMAP *top_image, ALLEGRO_BITMAP *bottom_image)
I haven't used it in a while (blending methods changed slightly in subsequent versions of allegro) but I just tested it and it seemed to work. This image shows a mask image (top_image), a texture image (bottom_image), and the example program putting the two together on a blue background.
If you go to the header file here, you'll see there are variants of the function, too. You can apply use your own blending modes, and/or transforms to the top/bottom images, and/or supply your own surface bitmap so that it's not created each time. There isn't a variant for looping the texture on the bottom to fit the mask, but you could use draw_textured_rectangle or draw_offset_textured_rectangle for that here).
All of this is still in the works, I don't have docs for this stuff, yet.
I guess I'm having trouble understanding when alpha moves
It's very confusing. Back when I was working on this function, I had a program that generated all possible blends (hundreds of images, if I recall) just so I could find the correct blending sequence & bitmap order I was looking for. Which bitmap do you draw on the surface? Which one do you draw on top of that? Does it read the surface or the drawn bitmap? ALLEGRO_BLEND_MODE_WHUT?
F it. Just brute force.