Peter,
You got it in the color ballpark but it's still off. I added SDL_CLS to make sure the backgound was black. Any other ideas?
' ScriptBasic GFX & DLLC - Mandelbrot
include "dllcinc.sb"
oxy = dllfile("/sb22/modules/oxygen.dll")
o2_basic = dllproc( oxy, "o2_basic i =(c*source) " )
o2_exec = dllproc( oxy, "o2_exec i =(i call) " )
o2_error = dllproc( oxy, "o2_error c*=() " )
o2_errno = dllproc( oxy, "o2_errno i =() " )
o2_len = dllproc( oxy, "o2_len i =() " )
o2_mode = dllproc( oxy, "o2_mode (i mode) " )
dllcall(o2_mode,1)
src = """
extern
function mandel(float zre,zim,sys maxiter) as sys
float mx,my,betrag
sys iter
while iter < maxiter and betrag < 4.0
iter = iter+1
tmp = mx*mx-my*my+zre
my = 2*mx*my+zim
mx = tmp
betrag = (mx*mx + my*my)
wend
return iter
end function
sub finish()
terminate
end sub
function link(sys n) as sys
select n
case 0
return @finish
case 1
return @mandel
end select
end function
end extern
addr link
"""
dllcall(o2_basic, src)
dfn = dllcall(o2_exec,0)
mandel = dllproc(dfn,"mandel i = (f zre, f zim, i maxiter)", dllcald(dfn, 1))
finish = dllproc(dfn,"finish ()", dllcald(dfn, 0))
gfx = dllfile("SDL_gfx.dll")
sdl = dllfile("sdl.dll")
SDL_INIT = dllproc(sdl, "SDL_Init i = (i flags)")
SDL_WINDOW = dllproc(sdl, "SDL_SetVideoMode i = (i width, i height, i video_bpp, i videoflags)")
SDL_SETALPHA = dllproc(sdl, "SDL_SetAlpha i = (i surface, i flag, i alpha)")
SDL_TITLE = dllproc(sdl, "SDL_WM_SetCaption (z title, z icon)")
SDL_WAIT = dllproc(sdl, "SDL_Delay (i millsecs)")
SDL_TIME = dllproc(sdl, "SDL_GetTicks i = ()")
SDL_CLIPRECT = dllproc(sdl, "SDL_SetClipRect (i surface, i* rect)")
GFX_PIXEL = dllproc(gfx, "pixelRGBA i = (i surface, i x, i y, i r, i g, i b, i a)")
SDL_FLIP = dllproc(sdl, "SDL_Flip i = (i screen)")
SDL_CLS = dllproc(sdl, "SDL_FillRect i = (i surface, i* dstrect, i color)")
GFX_PRINT = dllproc(gfx, "stringColor i = (i dst, i x, i y, c *s, i color)")
SDL_QUIT = dllproc(sdl, "SDL_Quit ()")
GLOBAL CONST SDL_INIT_VIDEO = 0x00000020
GLOBAL CONST SDL_SWSURFACE = 0x00000000
GLOBAL CONST SDL_SRCALPHA = 0x00010000
GLOBAL CONST SDL_RESIZABLE = 0x00000010
flags = SDL_SWSURFACE OR SDL_SRCALPHA OR SDL_RESIZABLE
dllcall(SDL_INIT, SDL_INIT_VIDEO)
screen = dllcall(SDL_WINDOW, 640, 480, 0, flags)
ok = dllcall(SDL_SETALPHA, screen, SDL_SRCALPHA, 0)
dllcall(SDL_TITLE, "ScriptBasic GFX & DLLC - Mandelbrot", 0)
dllcall(SDL_CLS, screen, 0, 0x000000)
ts = dllcall(SDL_TIME)
im = 510
z = 120
h = 480
w = 640
FOR y = 0 TO h -1
FOR x = 0 TO w -1
zx = 0
zy = 0
cx = (x - w / 2) / z
cy = (y - h / 2) / z
it = dllcall(mandel,cx,cy, im)
dllcall(GFX_PIXEL, screen, x, y, it * 4, it * 8, it * 12, 255)
NEXT
NEXT
te = dllcall(SDL_TIME)
dllcall(GFX_PRINT, screen, 20, 15, "Time: " & FORMAT("%.4f",(te-ts)/1000) & " Seconds." & CHR(0), 0xffffffff)
dllcall(SDL_FLIP, screen)
LINE INPUT WAIT
dllcall(SDL_QUIT)
.