void create_color_table(COLOR_MAP *table, const PALETTE pal, void (*blend)(PALETTE pal, int x, int y, RGB *rgb), void (*callback)(int pos));
Your blend routine will be passed a pointer to the palette and the two indices of the colors which are to be combined, and should fill in the RGB structure with the desired result in 0-63 format. Allegro will then search the palette for the closest match to the RGB color that you requested, so it doesn't matter if the palette has no exact match for this color.
If the callback function is not NULL, it will be called 256 times during the calculation, allowing you to display a progress indicator. Example:
COLOR_MAP greyscale_table; ... void return_grey_color(const PALETTE pal, int x, int y, RGB *rgb) { ... } ... /* Build a color lookup table for greyscale effect. */ create_color_table(&greyscale_table, pal, return_grey_color, NULL);