Some research on how the tilesets are parsed. If anyone has already written a detailed tutorial on this (cause I'm sure some people want to create their own auto-tiles for VX or VXA), post the link.
It looks like each autotile layer (A1 through A5) have to be dealt with individually.

These are the numbers for A1, corresponding to the tile ID.
tile ID 0 are the 3 blocks in the top-left.
tile ID 1 is the 3 blocks just below that.
tile ID 2 is the single block.
Same with tile ID 3.
When I say "block", I mean the group of tiles that are associated with a single tile ID.
You can see that it goes top-down left-right
But then the other 3 quadrants are left-right top-down.
Like what? Why did they decide to even order it like this? Is there a nice formula that you can use to determine the coords? Doesn't seem like it. At the very least, we can at least hardcode each case, so if you see autotile ID 0, then it's (0, 0), while autotile ID 1 is (0, 96).
Would've been so much easier if I could just check whether it's even or odd. Well, I guess I could; I just have to check whether it's 0-3 or 4-15 just to separate the outlier.
I guess that's what I'll be doing to at least get a working implementation of the script.
The tile ids are fortunately cumulative, but...
CODE
A1 => 0 to 15
A2 => 16 to 47
A3 => 48 to 79
A4 => 80 to 119
A5 => 120 to ???
The fact that each layer has different number of tiles makes it more annoying.
I also have no idea how the layer 0 and layer 1 tile id's are assigned.
Layer 0 is the very bottom tile.
Layer 1 is the tile that is used just above it. So for example, tile ID 1 looks like it's got a bunch of transparent parts, but it actually uses tile ID 0 for layer 0 and tile ID 1 for layer 1.
Is it hardcoded?
For A2, I'm glad it is much more reasonable.
No silly random outlier to make things complicated.

Each block is 64x96, and the row/column is determined by the tile id. So A2 is easy to draw.
Similarly, A3 also uses a sequential order, with 64x64 blocks.
A4 is also sequential, but the block sizes are different.
Every odd row (1, 3, 5, 7), the block sizes are 64x96
Every even row (2, 4, 6, 8), the block sizes are 64x64
A5 has id's less than 2048.
The first one starts with 1536.
The last one is 1663
So the algorithm for map-drawing is roughly
QUOTE
Draw layer 0 tiles. Use auto-tile ID'ing to check which tileset it is. If it's less than 2048, then run some other formula to check which A5 tile it is.
Draw layer 1 tiles. Use auto-tile ID'ing to check which tileset it is. If it's less than 2048, then run some other formula to check which A5 tile it is.
Draw layer 2 tiles. Use tile formula to determine which tileset it is.
Draw sprites. Use sprite formula along with name and index to determine which character sheet to use.
For auto-tiles, determine which tileset is used (A1 to A5) and then for each category, run its own formula based on the dimensions given to determine where the origin should be.
The last problem now is the fact that auto-tiles behave differently depending on adjacent tiles. Don't know how it checks for this.
....
It might be useful to know how tilesets B through E are arranged as well.
Even if the id's go from 0 to 255, 256 to 511, etc (256 icons per sheet), it is not arranged left-right top-bottom.
Instead, they decided to go
CODE
0 1 2 3 4 5 6 7 128 129 130 ...
8 9 ...
Probably cause they wanted to have 8 icons per row and also wanted to have a 512x512 sheet...?
Well, that is only a minor issue but it helps me visualize how I might write the formulas cause I'm not much of a math person.
Fortunately the A tilesets don't cut it up ...