viewport.c
changeset 856 918759cedca8
parent 849 c3407041774f
child 863 6a1444534f62
equal deleted inserted replaced
855:77d7ff319a94 856:918759cedca8
   293 	z = GetSlopeZ(a+z, b+z) >> 1;
   293 	z = GetSlopeZ(a+z, b+z) >> 1;
   294 
   294 
   295 	pt.x = a+z;
   295 	pt.x = a+z;
   296 	pt.y = b+z;
   296 	pt.y = b+z;
   297 
   297 
   298 	if ((uint)pt.x >= TILE_X_MAX*16 || (uint)pt.y >= TILE_Y_MAX*16) {
   298 	if ((uint)pt.x >= MapMaxX() * 16 || (uint)pt.y >= MapMaxY() * 16) {
   299 		pt.x = pt.y = -1;
   299 		pt.x = pt.y = -1;
   300 	}
   300 	}
   301 
   301 
   302 	return pt;
   302 	return pt;
   303 }
   303 }
  1287 		// Convert viewport coordinates to map coordinates
  1287 		// Convert viewport coordinates to map coordinates
  1288 		// Calculation is scaled by 4 to avoid rounding errors
  1288 		// Calculation is scaled by 4 to avoid rounding errors
  1289 		vx = -x + y * 2;
  1289 		vx = -x + y * 2;
  1290 		vy =  x + y * 2;
  1290 		vy =  x + y * 2;
  1291 		// clamp to size of map
  1291 		// clamp to size of map
  1292 		vx = clamp(vx, 0 * 4, TILE_X_MAX * 16 * 4);
  1292 		vx = clamp(vx, 0 * 4, MapMaxX() * 16 * 4);
  1293 		vy = clamp(vy, 0 * 4, TILE_Y_MAX * 16 * 4);
  1293 		vy = clamp(vy, 0 * 4, MapMaxY() * 16 * 4);
  1294 		// Convert map coordinates to viewport coordinates
  1294 		// Convert map coordinates to viewport coordinates
  1295 		x = (-vx + vy) / 2;
  1295 		x = (-vx + vy) / 2;
  1296 		y = ( vx + vy) / 4;
  1296 		y = ( vx + vy) / 4;
  1297 		// Set position
  1297 		// Set position
  1298 		WP(w,vp_d).scrollpos_x = x - vp->virtual_width / 2;
  1298 		WP(w,vp_d).scrollpos_x = x - vp->virtual_width / 2;