A common filling algorithm is a recursive 4/8 connect one:
Code:
void fillFourConnect (int x, int y, int col)
{
int thisColour = *(0xA0000000L + x + (y * X_ROW_SIZE));
// Get this pixel^
*(0xA0000000L + x + (y * X_ROW_SIZE)) = col; // Change pixel.
if (*(0xA0000000L + x + 1 + (y * X_ROW_SIZE)) == thisColour)
fillFourConnect (x + 1, y, col);
if (*(0xA0000000L + x - 1 + (y * X_ROW_SIZE)) == thisColour)
fillFourConnect (x - 1, y, col);
if (*(0xA0000000L + x + ((y + 1) * X_ROW_SIZE)) == thisColour)
fillFourConnect (x, y + 1, col);
if (*(0xA0000000L + x + ((y - 1) * X_ROW_SIZE)) == thisColour)
fillFourConnect (x, y - 1, col);
}
*(0xA0000000L + x + ((y + 1) * X_ROW_SIZE))
is just a low level way of accessing the video buffer, feel free to use any method you choose. This method only works in mode 0x13 (standard VGA) anyway.
It's recursive (but easy) so it may put strain on your stack. Beware.