Digging through some (very old) source code, I found this little gem:

[ftf]
//Place corners and walls depending on the pattern of walls around this wall
if ( !wall[0][0] && !wall[1][0] && !wall[2][0] && !wall[0][1] && !wall[2][1] && !wall[0][2] && !wall[1][2] && wall[2][2])
setActualTile(actualmap, amx, amy, amw, 1, 2, 11, 12);
else if ( !wall[0][0] && !wall[1][0] && wall[2][0] && !wall[0][1] && !wall[2][1] && !wall[0][2] && !wall[1][2] && !wall[2][2])
setActualTile(actualmap, amx, amy, amw, 81, 82, 91, 92);
else if ( !wall[0][0] && !wall[1][0] && !wall[2][0] && !wall[0][1] && !wall[2][1] && wall[0][2] && !wall[1][2] && !wall[2][2])
setActualTile(actualmap, amx, amy, amw, 9, 10, 19, 20);
else if ( wall[0][0] && !wall[1][0] && !wall[2][0] && !wall[0][1] && !wall[2][1] && !wall[0][2] && !wall[1][2] && !wall[2][2])
setActualTile(actualmap, amx, amy, amw, 89, 90, 99, 100);
else if ( wall[0][0] && wall[1][0] && wall[0][1] && !wall[2][1] && !wall[1][2] && !wall[2][2])
setActualTile(actualmap, amx, amy, amw, 1, 2, 11, 12);
else if ( wall[1][0] && wall[2][0] && !wall[0][1] && wall[2][1] && !wall[0][2] && !wall[1][2])
setActualTile(actualmap, amx, amy, amw, 9, 10, 19, 20);
else if ( !wall[1][0] && !wall[2][0] && wall[0][1] && !wall[2][1] && wall[0][2] && wall[1][2])
setActualTile(actualmap, amx, amy, amw, 81, 82, 91, 92);
else if ( !wall[0][0] && !wall[1][0] && !wall[0][1] && wall[2][1] && wall[1][2] && wall[2][2])
setActualTile(actualmap, amx, amy, amw, 89, 90, 99, 100);
[/ftf]

How on earth did I ever write this?