Start with the basic terrain tiles. The graphics of the basic tiles are actually centered on the corner of each in-game terain tile. In other words, the .pcx tiles are really transitions between the terrain types. More in a bit.
The basic tiles are in the form zABC where:
z=w or x, a w indicating that all terrain types in the file are water, x indicating that all types are land and/or coast. An L prefix indicates landmark terrain.
ABC are the three types of terrain in the file. For example, xdgp would mean that the four terrain types surrounding the corner are either desert, grassland, or plains. Note that this restricts the number of terrain types in any four-tile diamond to three, and if there are only one or two terrain types in a diamond, there may be multiple files the map generator can choose from (I don't know the underlying algorithm).
The values for ABC are as follows:
d=desert
g=grassland
p=plains
t=tundra
c=coast
s=sea
o=ocean
Note that some .pcx files have the same type more than once, such as xggc or wooo. This means that the computer recognizes several different subtypes and allows for a greater variety of some basic terrain. This is why a single tile grass island comes in two different sizes with the basic graphics.
How does the ABC come into play? Since there are 3 different types in each file, and four positions, the total number of possibilities is 3^4=81. The .pcx file is a 9x9 grid. Use the following to determine what terrain types should be bordering for a particular corner:
1
3 9
27
where the number indicates how frequently the type cycles through each position, counting from left to right. In other words, the graphic located in the 3rd column, 4th row would be of the following format:
C
A A
B
If the file were xdgc, the terrain to the north would be coast, desert to the east and west, and grassland to the south.
That covers the basic tiles.
What happened to hills, mountains, forests, jungles, and marshes? These are all overlays. They are centered on the tile, rather than on the corner. I am not entirely sure yet on how map generator picks which forest or jungle graphic, aside from generally that the larger graphics are reserved for the middle of a forest; obviously, I need to investigate further. There are different files for the forest based on underlying terrain, but they are rather explicit.
Okay, but why are hills and mountains overlays? They actually use a grassland tile as their base terrain, and then overlay with the appropriate graphic, which is dependent upon if there is another elevated terrain tile in the diagonal directions. In other words, it forms a chain if there is another hill or mountain to the NE, NW, SE, or SW. Use the following to figure out what is where (similar to the zABC, except turned 45 degrees and only two choices per direction):
2 1
4 8
In other words, if a hill had elevated terrain to the NE, SE, and SW, the graphic for that hill would be found in the 3rd column, 4th row. The top left spot is for when the hill is isolated, the bottom left for when it is surrounded. Terrain to the N, S, E, and W is ignored.
Rivers and floodplains are done similiarly, except located at the corners of terrain tiles. River is drawn on top of floodplain. mtnRivers is for when a river starts in elevated terrain, delta for when it ends on coast.
That's most of what you need to know.