RPG Maker has nice feature called Autotiles. Those tiles are made so one tile can be shrinked to as small amount as 3x3 tile square plus one tile with cramped corners.

Example autotile

Top-left tile is used only as display of tile in editor, top right contains inside corners of tile. 3x3 tiles square contains outside corners, sides and middle of tile.

Here are tiles that can be made out of this:


(I'm using unofficial Polish translation of RPG Maker XP so title is because of that).

I have pretty much idea how I can break up autotiles and make all those tiles. Problem is another one - how I choose "right" tile so they'll fit together in map?

Let's assume that in following code "0" represent normal tile and "1" autotile. I want to display them properly:
Code:
0 0 0 0 0 1 0 0 0 0 0 
0 0 0 0 1 0 0 0 1 0 0
0 0 0 0 1 1 1 0 1 0 0
0 0 0 1 1 1 1 0 1 1 0
0 0 0 0 0 1 0 0 0 1 0
0 0 0 1 1 1 1 1 1 1 0
How can I achieve this?