What we do know about map data?

Today, I was inspired to attempt a program that procedurally generates unit data onto a map. Thing is, I want the program to look at the map data directly in the rom to determine what each tile actually is. That way, I can prevent scenarios where, say, a mercenary is loaded onto a mountain tile.

So how exactly does map data inserted with Tiled actually work and what can I do to “decode” it?

EDIT: So… It’s LZ77 compressed. When decompressed, the first two bytes are the map’s dimensions, and the rest are the actual tiles used. This is exactly what I needed to know! So uh… I guess nevermind. I figured it out myself.