Mandelbrot- What am I doning wrong?

BlitzMax Forums/BlitzMax Programming/Mandelbrot- What am I doning wrong?

I have tryed to update a BB3D mandelbrot routin.
Something is screwed up...colors!!!
Where are they?

Can someone please help me?

Here is the code:
Strict

AppTitle = "Mandelbrot"

'vars
Global maxval:Float = 128.0
Global sx:Float = -2.025
Global sy:Float = -1.125
Global ex:Float = 0.6
Global ey:Float = 1.125

Global x1:Float = 640.0
Global y1:Float = 480.0
Global xy:Float = x1/y1

Global xstart:Float = sx
Global ystart:Float = sy
Global xend:Float = ex
Global yend:Float = ey

Global xzoom:Float = (xend - xstart) / x1
Global yzoom:Float = (yend - ystart) / y1
Global fac:Float = 0.99

'display
Graphics x1,y1,0

xend = xend*fac
xstart = xstart*fac
yend = yend*fac
ystart = ystart*fac

xzoom = (xend - xstart) / x1
yzoom = (yend - ystart) / y1
	
mandelbrot()
	
Flip()
FlushMem()
	
WaitKey
End

Function mandelbrot()
	Local x:Float
	Local y:Float
	
	Local h:Float
	Local old:Float
	Local b:Float
	
	For x = 0 To x1 - 1
		For y = 0 To y1 - 1
			h = DotCol(xstart + xzoom * x,ystart + yzoom * y)
			'Print h
			If h <> old
				b = 1.0 - h * h
				HSB2RGB(h,0.8,b) 
				old = h
			EndIf
			Plot x,y
		Next
	Next
EndFunction

Function DotCol(xval:Float,yval:Float)
	Local r:Float
	Local i:Float
	Local j:Float
	Local m:Float
	
	While (j < maxval) And (m < 4.0)
		j = j + 1
		m = r * r - i * i
		i = 2.0 * r * i + yval
		r = m + xval
	Wend
	'Print j
	'j = j / maxval
	Return j
EndFunction

Function HSB2RGB(hue:Float,sat:Float,bri:Float)
	Local dof:Float
	Local red:Float
	Local green:Float
	Local blue:Float
	
	If bri = 0 Then SetColor 0,0,0
	If sat = 0 Then SetColor bri*255,bri*255,bri*255
	
	
	
	
	If hue < 1.0/6.0
		dof = hue
		red = bri
		blue = bri * (1.0 - sat)
		green = blue + (bri - blue) * dof * 6.0
		SetColor red*255,green*255,blue*255
	Else
		If hue < 2.0/6.0
			dof = hue - 1.0/6.0
			green = bri
			blue = bri * (1.0 - sat)
			red = green - (bri - blue) * dof * 6.0
			SetColor red*255,green*255,blue*255
		Else
			If hue < 3.0/6.0
				dof = hue - 2.0/6.0
				green = bri
				red = bri * (1.0 - sat)
				blue = red + (bri - red) * dof * 6.0
				SetColor red*255,green*255,blue*255
			Else
				If hue < 4.0/6.0
					dof = hue - 3.0/6.0
					blue = bri
					red = bri * (1.0 - sat)
					green = blue - (bri - red) * dof * 6.0
					SetColor red*255,green*255,blue*255
				Else
					If hue < 5.0/6.0
					dof = hue - 4.0/6.0
					blue = bri
					green = bri * (1.0 - sat)
					red = green + (bri - green) * dof * 6.0
					SetColor red*255,green*255,blue*255
				Else
					dof = hue - 5.0/6.0
					red = bri
					green = bri * (1.0 - sat)
					blue = red - (bri - green) * dof * 6.0
					SetColor red*255,green*255,blue*255
				EndIf
			EndIf
		EndIf
	EndIf
EndIf
EndFunction


Regards
Sveinung