ID:263795
 
Code:
proc
diamondsquare(size,maxrep)
var
xx
yy
list/points[4][2]
list/points2[4][2]
sx
sy
x1
x2
y1
y2
halfsize
range=400
setp(1,1, 125)
setp(maxrep-1, 1, 125)
setp(1, maxrep-1, 125)
setp(size-1, maxrep-1, 125)
while(size>=1)
for(xx=1, xx<=maxrep-1, xx+=size)
for(yy=1, yy<=maxrep-1, yy+=size)
sx=xx+(size>>1)
sy=yy+(size>>1)
points[1][1]=xx
points[1][2]=yy
points[2][1]=xx+size
points[2][2]=yy
points[3][1]=xx
points[3][2]=yy+size
points[4][1]=xx+size
points[4][2]=yy+size
diamondpoints(sx,sy,points,range,maxrep,maxrep)
for(xx=1, xx<=maxrep, xx+=size)
for(yy=1, yy<=maxrep, yy+=size)
halfsize=size>>1
x1=xx+halfsize
x2=xx
y1=yy
y2=yy+halfsize
points[1][1]=x1-halfsize
points[1][2]=y1
points[2][1]=x1
points[2][2]=y1-halfsize
points[3][1]=x1+halfsize
points[3][2]=y1
points[4][1]=x1
points[4][2]=y1+halfsize

points2[1][1]=x2-halfsize
points2[1][2]=y2
points2[2][1]=x2
points2[2][2]=y2-halfsize
points2[3][1]=x2+halfsize
points2[3][2]=y2
points2[4][1]=x2
points2[4][2]=y2+halfsize
diamondpoints(x1,y1,points,range,maxrep,maxrep)
diamondpoints(x2,y2,points2,range,maxrep,maxrep)
range/=2
size=(size>>1)
diamondpoints(xx,yy,list/points,range,width,height)
var/c=0
var/i
for(i=1, i<=4, i+=1)
if(points[i][1]<1)
points[i][1]+=(width-1)
else if(points[i][1]>width)
points[i][1]-=(width-1)
else if(points[i][2]<1)
points[i][2]+=height-1
else if(points[i][2]>height)
points[i][2]-=height-1
c+=round(pix[points[i][1]][points[i][2]]/4)
c+=round(rand(-range/2,range/1.3))


Problem description:
The problem is simple. Regardless of what I try that code always returns a runtime error of "runtime error: list index out of bounds". And I can't see why it is returning that error at all, because the code works perfectly fine.

With debugging enabled it is pinpointing things down to this specific line in the code
diamondpoints(xx,yy,list/points,range,width,height)
And I'd guess it has something to do with the list/points part of the code and maybe there is some correct way of using multi-dimensional lists as an argument that don't know about?
So... Does anyone have any idea of what could be wrong with the code?

EDIT: Ignore this, I managed to fix the problem.