Ok, I'm struggling with calculating x/y position of tile in tileset (needed to get tile sprite) based on tile id.

To getTile(ID) function I'm passing tile id. Tiles are arranged in pretty standard tile grid, like this:

Code:
00 01 02 03 04 05 06 07
08 09 10 11 12 13 14 15
16 17 18 19 20 21 22 23
24 25 26 27 28 29 30 31
Tileset can have any amount of tiles horizontally and vertically. The problem is how to get proper x/y coordinates of specific tileid (for simplicity we assume tile size is 16).