code: protected int getIndex (int x, int y)
      {
          // check to see if the index lies in one of the "fat" rows
          if (((x + y) & 1) == (vwidth & 1)) {
  
              int col = (vwidth + x - y) >> 1;
              int row = x - col;
              if ((col < 0) || (col > vwidth) ||
                  (row < 0) || (row >= vheight)) {
                  return -1; // out of view
              }
  
              return (vwidth + 1) * row + col;
  
          } else {
              // the index must be in a "thin" row
              int col = (vwidth + x - y - 1) >> 1;
              int row = x - col;
              if ((col < 0) || (col >= vwidth) ||
                  (row < 0) || (row > vheight)) {
                  return -1; // out of view
              }
  
              // we store the all the fat rows first, then all the thin
              // rows, the '(vwidth + 1) * vheight' is the size of all
              // the fat rows.
              return row * vwidth + col + (vwidth + 1) * vheight;
          }
      }
docs: Get the index into the baseTileIds[] for the specified
  x and y coordinates, or return -1 if the specified coordinates
  are outside of the viewable area.
  
  Assumption: The viewable area is centered and aligned as far
  to the top of the isometric scene as possible, such that
  the upper-left corner is at the point where the tiles
  (0, vwid) and (0, vwid-1) touch. The upper-right corner
  is at the point where the tiles (vwid-1, 0) and (vwid, 0)
  touch.
  
  The viewable area is made up of "fat" rows and "thin" rows. The
  fat rows display one more tile than the thin rows because their
  first and last tiles are halfway off the viewable area. The thin
  rows are fully contained within the viewable area except for the
  first and last thin rows, which display only their bottom and top
  halves, respectively. Note that #fatrows == #thinrows - 1;