I've been trying to covert some C code to Pascal, but I'm not sure if I got it right, at least the results seem to be completely wrong.

What can you make out of this?
Code:
/*
* Heterogeneous procedural terrain function: stats by altitude method.
* Evaluated at  point; returns value stored in  value.
*
* Parameters:
*  H determines the fractal dimension of the roughest areas
*  lacunarity is the gap between successive frequencies
*  octaves is the number of frequencies in the fBm
*  offset raises the terrain from  sea level
*/
double
Hetero_Terrain( Vector point,
double H, double lacunarity, double octaves, double offset )
{
	double value, increment, frequency, remainder, Noise3();
	int i;
	static int first = TRUE;
	static double *exponent_array;
	/* precompute and store spectral weights, for efficiency */
	if ( first ) {
		/* seize required memory for exponent_array */
		exponent_array = (double *)malloc( (octaves+1) * sizeof(double) );
		frequency = 1.0;
		for &#40;i=0; i<=octaves; i++&#41; &#123;
			/* compute weight for each frequency */
			exponent_array&#91;i&#93; = pow&#40; frequency, -H &#41;;
			frequency *= lacunarity;
		&#125;
		first = FALSE;
	&#125;
	/* first unscaled octave of function; later octaves are scaled */
	value = offset + Noise3&#40; point &#41;; point.x *= lacunarity;
	point.y *= lacunarity; point.z *= lacunarity;
	/* spectral construction inner loop, where the fractal is built */
	for &#40;1=1; i<octaves; 1++&#41; &#123;
		/* obtain displaced noise value */
		increment = Noise3&#40; point &#41; + offset;
		/* scale amplitude appropriately for this frequency */
		increment *= exponent_array&#91;i&#93;;
		/* scale increment by current  altitude of function */
		increment *= value;
		/* add increment to  value */
		value += increment;
		/* raise spatial frequency */
		point.x *= lacunarity;
		point.y *= lacunarity;
		point.z *= lacunarity;
	&#125; /* for */
	/* take care of remainder in  octaves */
	remainder = octaves - &#40;int&#41;octaves;
	if &#40; remainder &#41; &#123;
		/*  i and spatial freq. are preset in loop above */
		/* note that the main loop code is made shorter here */
		/* you may want to make that loop more like this */
		increment = &#40;Noise3&#40; point &#41; + offset&#41; * exponent_array&#91;i&#93;;
		value += remainder * increment * value;
	&#125;
	return&#40; value &#41;;
&#125; /* Hetero_Terrain&#40;&#41; */
I've converted the exponent_array table to a variable inside the class, so that's not a problem. The problem is with the variable i and that strange for (1=1; i<octaves; 1++) loop. For all that I know i is UNDEFINED when the function is executed, that should be the case with the C version too, except after that static initialization that is done when the function is called for the first time.

I just don't understand the relation of that inner loop to variable i... So how do I convert this properly?