-----------------------
The Ultima 4 EGA driver
-----------------------
The file "ega.drv" contains the EGA driver.
It's a code fragment that gets loaded into memory "as is."
It gets loaded into memory at a paragraph boundary.
The first ? words are offsets pointing to functions in the driver.
These functions must be called with a far call.

Aradindae Dragon and Wiltshire Dragon's U4 upgrade replaces ega.drv with a VGA driver.
I don't know if this VGA driver animates tiles the same way the EGA driver does.

--------------------------------------------------------
Variables (between the offset table and the acual code)
--------------------------------------------------------
0x36   dword    used by the random number generator
0x46   dword    far pointer to shapes.ega (tiles converted to EGA 4-plane format)

-------------------------------------------------------------------------------------
Animate campfire (function 0x14, offset 0xD9E to 0xE2D)
-------------------------------------------------------------------------------------
This function animates tile 0x4B (campfire/spit).

int row, col;
long fireRow;   /* only the lower 16 bits are used */
unsigned char campfireTile[16*16];
long bitMasks[8] = {0x0C00, 0x0D80, 0x1FC0, 0x1FC0, 0x0F80, 0x1FC0, 0x1240, 0x18C0};
long maskBit, rowBit;

for (row = 7; row <= 14; row++)
{
    fireRow = random();
    for (col = 0; col < 16; col++)
    {
        maskBit = (bitMasks[row-7] >> (15-col)) & 1;
        fireRowBit = (fireRow >> (15-col)) & 1;
        if (maskBit)
        {
            if (fireRowBit) { campfireTile[row*16 + col] = 4; }   /* dark red */
            else { campfireTile[row*16 + col] = 0; }   /* black */
        }
    }
}

-------------------------------------------------------------------------------------
Animate flags (function 0x18, offset 0xFFF to 0x114B)
-------------------------------------------------------------------------------------
Some tiles contain animated flags. This functions animates them, in the following order:
0x0A    town
0x0B    castle
0x10    player ship, facing west
0x12    player ship, facing east
0x0E    LB's castle, entrance

On the player ship facing north/south, the flag is not visible.
Pirate ships have flags, but they're not animated.

The tiles are animated by swapping adjacent rows:
0x0A    swap(row3,row4)
0x0B    swap(row1,row2)
0x10    swap(row2,row3)
0x12    swap(row2,row3)
0x0E    swap(row1,row2)

row0 = top row
row15 = bottom row

If all flag tiles were advanced to the next frame during each animation phase, the flag animations would look pretty monotonous. That's why the game sometimes doesn't advance a flag tile to the next frame. This is decided randomly, and on a per-tile basis (the various flag tiles are not synchronized).

-------------------------------------------------------------------------------------
Random number generator (offset 0xEC6 to 0xEED)
-------------------------------------------------------------------------------------
The random number generator is used
1. to decide whether to advance a flag tile to the next animation frame
2. to create the campfire animation
