' Simple Window DLLC JIT
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))
sw = dllfile("sw.dll")
Window = dllproc(sw, "Window i = (i width, i height, i mode)")
SetCaption = DLLC_Proc(sw, "SetCaption i = (c *capText)")
SetPixel = dllproc(sw, "SetPixel i = (i xPos, i yPos, i color)")
RGB = dllproc(sw, "RGB i = (i rValue, i gValue, i bValue)")
Redraw = DLLC_Proc(sw, "Redraw ( )")
WaitKey = dllproc(sw, "WaitKey i = ( )")
Quit = DLLC_Proc(sw, "Quit i = ( )")
xstart = -1.8
xend = 0.8
ystart = -1.0
yend = 1.0
hoehe = 240
breite = 320
dllcall(Window,320,240,1)
dllcall(SetCaption,"SB SW DLLC JIT")
st = dllsecs()
x = -1
y = -1
REPEAT
x = (x+1) % breite
if(x = 0) then y = (y+1) % hoehe
zre = xstart + x*(xend-xstart)/breite
zim = ystart + y*(yend-ystart)/hoehe
it = dllcall(mandel,zre,zim,512)
dllcall(SetPixel,x, y, dllcall(RGB,it*11,it*13,it*17))
dllcall(Redraw)
UNTIL ((x = breite-1) and (y = hoehe-1))
PRINT format("%g",dllsecs() - st),"\n"
dllcall(WaitKey)
dllcall(Finish)
dllcall(Quit)
dllfile