' JAPI 2.0 DLLC
include "dllcinc.sb"
japi = dllfile("japi.dll")
j_start = dllproc(japi, "j_start i = ()")
j_frame = dllproc(japi, "j_frame i = (c * label)")
j_menubar = dllproc(japi, "j_menubar i = ( i obj)")
j_menu = dllproc(japi, "j_menu i = (i obj, c *label)")
j_menuitem = dllproc(japi, "j_menuitem i = (i obj, c *label)")
j_canvas = dllproc(japi, "j_canvas i = (i obj, i width , i height)")
j_setpos = dllproc(japi, "j_setpos (i obj, i xpos, i ypos)")
j_pack = dllproc(japi, "j_pack (i obj)")
j_show = dllproc(japi, "j_show (i obj)")
j_getaction = dllproc(japi, "j_getaction i = ()")
j_nextaction = dllproc(japi, "j_nextaction i = ()")
j_setcolor = dllproc(japi, "j_setcolor (i obj, i r, i g, i b)")
j_drawpixel = dllproc(japi, "j_drawpixel (i obj, i x, i y)")
j_quit = dllproc(japi, "j_quit ()")
CONST J_TRUE = 1
CONST J_FALSE = 0
xstart = -1.8
xend = 0.8
ystart = -1.0
yend = 1.0
hoehe = 240
breite = 320
if (dllcall(j_start) = J_FALSE) then
print("JAPI interface failed to start.\n")
end
endif
jframe = dllcall(j_frame,"JAPI 2.0 DLLC")
menubar = dllcall(j_menubar,jframe)
jfile = dllcall(j_menu,menubar,"File")
calc = dllcall(j_menu,menubar,"Calc")
quit = dllcall(j_menuitem,jfile,"Quit")
start = dllcall(j_menuitem,calc,"Start")
jstop = dllcall(j_menuitem,calc,"Stop")
canvas = dllcall(j_canvas,jframe,breite,hoehe)
dllcall(j_setpos,canvas,10,60)
dllcall(j_pack,jframe)
dllcall(j_show,jframe)
obj = 0
do_work = 0
while((obj <> jframe) and (obj <> quit))
if(do_work = 1) then
obj = dllcall(j_getaction)
else
obj = dllcall(j_nextaction)
endif
if(obj = start) then
x = -1
y = -1
do_work = 1
st = dllsecs()
endif
if(obj = jstop) then
do_work = 0
endif
if(do_work = 1) then
x = (x+1) % breite
if(x = 0) then
y = (y+1) % hoehe
endif
if((x = breite-1) and (y = hoehe-1)) then
do_work = 0
PRINT format("%g",dllsecs() - st),"\n"
else
zre = xstart + x*(xend-xstart)/breite
zim = ystart + y*(yend-ystart)/hoehe
it = mandel(zre,zim,512)
dllcall(j_setcolor,canvas,it*11,it*13,it*17)
dllcall(j_drawpixel,canvas,x,y)
endif
endif
wend
dllcall(j_quit)
function mandel(zre,zim,maxiter)
mx = 0.0
my = 0.0
iter=0
betrag=0.0
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
mandel=iter
end function
' JAPI 2.0 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))
japi = dllfile("japi.dll")
j_start = dllproc(japi, "j_start i = ()")
j_frame = dllproc(japi, "j_frame i = (c * label)")
j_menubar = dllproc(japi, "j_menubar i = ( i obj)")
j_menu = dllproc(japi, "j_menu i = (i obj, c *label)")
j_menuitem = dllproc(japi, "j_menuitem i = (i obj, c *label)")
j_canvas = dllproc(japi, "j_canvas i = (i obj, i width , i height)")
j_setpos = dllproc(japi, "j_setpos (i obj, i xpos, i ypos)")
j_pack = dllproc(japi, "j_pack (i obj)")
j_show = dllproc(japi, "j_show (i obj)")
j_getaction = dllproc(japi, "j_getaction i = ()")
j_nextaction = dllproc(japi, "j_nextaction i = ()")
j_setcolor = dllproc(japi, "j_setcolor (i obj, i r, i g, i b)")
j_drawpixel = dllproc(japi, "j_drawpixel (i obj, i x, i y)")
j_quit = dllproc(japi, "j_quit ()")
CONST J_TRUE = 1
CONST J_FALSE = 0
xstart = -1.8
xend = 0.8
ystart = -1.0
yend = 1.0
hoehe = 240
breite = 320
if (dllcall(j_start) = J_FALSE) then
print("JAPI interface failed to start.\n")
end
endif
jframe = dllcall(j_frame,"JAPI 2.0 DLLC JIT")
menubar = dllcall(j_menubar,jframe)
jfile = dllcall(j_menu,menubar,"File")
calc = dllcall(j_menu,menubar,"Calc")
quit = dllcall(j_menuitem,jfile,"Quit")
start = dllcall(j_menuitem,calc,"Start")
jstop = dllcall(j_menuitem,calc,"Stop")
canvas = dllcall(j_canvas,jframe,breite,hoehe)
dllcall(j_setpos,canvas,10,60)
dllcall(j_pack,jframe)
dllcall(j_show,jframe)
obj = 0
do_work = 0
while((obj <> jframe) and (obj <> quit))
if(do_work = 1) then
obj = dllcall(j_getaction)
else
obj = dllcall(j_nextaction)
endif
if(obj = start) then
x = -1
y = -1
do_work = 1
st = dllsecs()
endif
if(obj = jstop) then
do_work = 0
endif
if(do_work = 1) then
x = (x+1) % breite
if(x = 0) then
y = (y+1) % hoehe
endif
if((x = breite-1) and (y = hoehe-1)) then
do_work = 0
PRINT format("%g",dllsecs() - st),"\n"
else
zre = xstart + x*(xend-xstart)/breite
zim = ystart + y*(yend-ystart)/hoehe
it = dllcall(mandel,zre,zim,512)
dllcall(j_setcolor,canvas,it*11,it*13,it*17)
dllcall(j_drawpixel,canvas,x,y)
endif
endif
wend
dllcall(Finish)
dllcall(j_quit)
dllfile
Is the aim to get programs compiled for android via java, or I guess for any java supported platform?