declare sub printf overload (x, y, s as string, c as ubyte) declare sub printf overload (x, y, s as string, c as ubyte, buffer as any ptr) declare sub memcopy (byval src as any ptr, byval dest as any ptr, byval n as uinteger, byval d as uinteger) declare sub drawin overload (x, y, x1, y1, cap as string) declare sub drawin overload (x, y, x1, y1, cap as string, buffer as any ptr) declare sub redraw () declare sub res (x, y) declare sub resize(x, y, buffer as any ptr) declare sub mktop (id) declare sub closewin (id) declare sub makewin (x, y, x1, y1, cap as string, pid) declare sub clock (id) declare sub smalldir (id) declare sub text (id) declare sub loadbmp (id) declare sub runcom (id) declare function getfiles (path as string, f() as string) declare function mousebox (x, y, x1, y1) dim shared mx, my, mb type wintype x as integer y as integer x1 as integer y1 as integer cap as string pid as integer diri as integer iptr as any ptr end type dim shared win(100) as wintype dim shared wins as integer = 0 dim shared sdir(100) as string dim shared sdirs(100) as integer dim shared sdirf(500) as string dim shared textf(100) as string dim shared textx(100) as integer dim shared texty(100) as integer dim shared textb(100) as ubyte ptr dim shared textl(100) as integer dim shared textc(100) as integer type loadbmptype iptr as any ptr x as integer y as integer end type dim shared lbmp(100) as loadbmptype dim shared bmpf(100) as string dim shared runcomx(100) as string dim shared menu1(9) as string menu1(0)="menu" menu1(1)="" menu1(2)="file man" menu1(3)="text" menu1(4)="clock" menu1(5)="run" menu1(6)="" menu1(7)="-----------" menu1(8)="options >" menu1(9)="exit" dim shared menu2(5) as string menu2(0)=" 320x240" menu2(1)="*640x480" menu2(2)=" 800x600" menu2(3)=" 1024x768" menu2(4)="" menu2(5)="bg center" dim shared bgstretch=0 dim shared bgoff=0 screenres 640, 480, 8 dim shared as integer screenw,screenh screeninfo screenw,screenh dim shared as any ptr temp1,temp2,temp3,temp4 temp1 = imagecreate(screenw,screenh) dim shared font(1040) as ubyte bload "font.dat", varptr(font(11)) dim shared s as string*2 dim shared as ushort bx,by dim shared bg as any ptr bg = imagecreate(screenw,screenh,0) if not bgoff then open "bg.bmp" for binary as #1 get #1,,s if s="BM" then get #1,19,bx get #1,23,by temp3=imagecreate(bx,by) bload "bg.bmp",temp3 if bgstretch then resize screenw,screenh,temp3 imagedestroy bg bg = temp3 else put bg,((screenw-bx)\2,(screenh-by)\2),temp3 imagedestroy temp3 end if end if close end if palette 0, &h000000 palette 15, &hffffff 'makewin 400,200,150,175,"clock",1 'makewin 100,100,150,175,"clock1",1 'makewin 0,0,150,200,"dir",2 'win(wins-1).diri=wins-1 'sdir(win(wins-1).diri)="C:\" 'sdirs(win(wins-1).diri)=0 'makewin 0,0,150,200,"dir",2 'win(wins-1).diri=wins-1 'sdir(win(wins-1).diri)="C:\font\" 'sdirs(win(wins-1).diri)=0 'makewin 50,50,200,200,"text",3 'win(wins-1).diri=wins-1 'textf(win(wins-1).diri)="C:\bensled.bas" 'textx(win(wins-1).diri)=0 'texty(win(wins-1).diri)=0 'open textf(win(wins-1).diri) for binary as #1 ' textb(win(wins-1).diri)=allocate(lof(1)) ' get #1,,*textb(win(wins-1).diri),lof(1) ' textl(win(wins-1).diri)=lof(1) 'close 'open "bg.bmp" for binary as #1 ' ' get #1,,s ' if s="BM" then ' ' get #1,19,bx ' get #1,23,by ' ' makewin 50,50,bx+2,by+27,"bmpload",4 ' win(wins-1).diri=wins-1 ' bmpf(wins-1)="bg.bmp" ' end if 'close dim key as string 'makewin 50,50,150,200,"dir",2 'win(wins-1).diri=wins-1 'sdir(win(wins-1).diri)=".\img\" 'sdirs(win(wins-1).diri)=0 screenlock put(0,0),bg,pset for i=wins-1 to 0 step -1 select case win(i).pid case 1 clock i case 2 smalldir i case 3 text i case 4 loadbmp i case 5 runcom i case else drawin 0,0,win(i).x1,win(i).y1,win(i).cap,win(i).iptr put (win(i).x,win(i).y),win(i).iptr,pset end select next screenunlock do start: getmouse mx,my,,mb 'window management for i=0 to wins-1 if mousebox(win(i).x,win(i).y,win(i).x1+win(i).x,win(i).y1+win(i).y) then if mousebox(win(i).x,win(i).y,win(i).x1+win(i).x,win(i).y+25) then if mb=1 then mktop i screenlock put(0,0),bg,pset redraw get(0,0)-(screenw-1,screenh-1),temp1 put(win(0).x,win(0).y),win(0).iptr,pset screenunlock oldx= mx-win(0).x oldy= my-win(0).y do oldmx= mx oldmy= my getmouse mx,my,,mb newx= mx-oldx newy= my-oldy if mx<>oldmx and my<>oldmy then screenlock put(0,0),temp1,pset 'put(newx,newy),temp2,pset 'line(0,0)-(639,479),0,bf 'redraw 'drawin newx,newy,win(0).x1,win(0).y1,win(0).cap put(newx,newy),win(0).iptr,pset screenunlock end if loop until mb=0 win(0).x= newx win(0).y= newy screenlock put(0,0),bg,pset redraw put(win(0).x,win(0).y),win(0).iptr,pset screenunlock exit for goto start elseif mb=2 then do getmouse mx,my,,mb loop while mb=2 closewin i screenlock put(0,0),bg,pset redraw put(win(0).x,win(0).y),win(0).iptr,pset screenunlock exit for goto start end if else if mb<>0 then mktop i screenlock put(0,0),bg,pset redraw get(0,0)-(screenw-1,screenh-1),temp1 put(win(0).x,win(0).y),win(0).iptr,pset screenunlock goto start end if exit for end if end if next 'menu if mb=2 then do getmouse mx,my,,mb loop while mb=2 l=len(menu1(0)) for i=0 to ubound(menu1) if l0 then if mousebox(ox2,oy2,ox2+x2,oy2+y2) then select case (my-oy2-5)\15 case 0 menu2(0)="*320x240" menu2(1)=" 640x480" menu2(2)=" 800x600" menu2(3)=" 1024x768" 'res 320, 240 'goto start case 1 menu2(0)=" 320x240" menu2(1)="*640x480" menu2(2)=" 800x600" menu2(3)=" 1024x768" put (ox2,oy2),temp3,pset imagedestroy temp3 res 640, 480 goto start case 2 menu2(0)=" 320x240" menu2(1)=" 640x480" menu2(2)="*800x600" menu2(3)=" 1024x768" put (ox2,oy2),temp3,pset imagedestroy temp3 res 800, 600 goto start case 3 menu2(0)=" 320x240" menu2(1)=" 640x480" menu2(2)=" 800x600" menu2(3)="*1024x768" put (ox2,oy2),temp3,pset imagedestroy temp3 res 1024, 768 goto start case 5 if mb=1 then bgstretch=not bgstretch bgoff=0 if bgstretch then menu2(5)="bg stretch" else menu2(5)="bg center" put (ox2,oy2),temp3,pset imagedestroy temp3 res screenw, screenh goto start else do getmouse mx,my,,mb loop until mb=0 menu2(5)="bg off" bgoff=-1 put (ox2,oy2),temp3,pset imagedestroy temp3 res screenw, screenh goto start end if end select end if end if loop while ((my-oy-5)\15 = ubound(menu1)-1 and mousebox(ox,oy,ox+x,oy+y)) or mousebox(ox2,oy2,ox2+x2,oy2+y2) put (ox2,oy2),temp3,pset imagedestroy temp3 end if ' 'menu selection if mb=1 and mousebox(ox,oy,ox+x,oy+y) then put (ox,oy),temp2,pset select case (my-oy-5)\15 case 2 makewin mx,my,150,200,"dir",2 win(wins-1).diri=wins-1 sdir(win(wins-1).diri)="C:\" sdirs(win(wins-1).diri)=0 mktop wins-1 screenlock put(0,0),bg,pset redraw screenunlock smalldir 0 goto start case 3 makewin 10,10,600,400,"text",3 win(wins-1).diri=wins-1 textf(win(wins-1).diri)="readme.txt" textx(win(wins-1).diri)=0 texty(win(wins-1).diri)=0 textc(win(wins-1).diri)=0 open textf(win(wins-1).diri) for binary as #1 textb(win(wins-1).diri)=allocate(lof(1)) get #1,,*textb(win(wins-1).diri),lof(1) textl(win(wins-1).diri)=lof(1) close mktop wins-1 screenlock put(0,0),bg,pset redraw screenunlock text 0 goto start case 4 makewin mx,my,150,175,"clock",1 mktop wins-1 screenlock put(0,0),bg,pset redraw screenunlock clock 0 goto start case 5 makewin mx,my,200,50,"run command",5 win(wins-1).diri=wins-1 runcomx(win(wins-1).diri)="" mktop wins-1 screenlock put(0,0),bg,pset redraw screenunlock runcom 0 goto start case ubound(menu1) end case else end select end if loop until mb<>0'while mousebox(ox,oy,ox+x,oy+y) put (ox,oy),temp2,pset imagedestroy temp2 end if 'live redrawing & application main loops select case win(0).pid case 1 clock 0 case 2 if mousebox(win(0).x,win(0).y+25,win(0).x+win(0).x1,win(0).y+win(0).y1) then j=getfiles(sdir(win(0).diri),sdirf()) do while mousebox(win(0).x,win(0).y+25,win(0).x+win(0).x1,win(0).y+win(0).y1) getmouse mx,my,,mb if mousebox(win(0).x+win(0).x1-25,win(0).y+win(0).y1-25,win(0).x+win(0).x1,win(0).y+win(0).y1) then if mb=1 then if ((win(0).y1-30)\15)+sdirs(win(0).diri)=j then exit for printf 5, 30+i*15, sdirf(i+sdirs(win(0).diri)), 15, win(0).iptr next put(win(0).x,win(0).y),win(0).iptr,pset elseif mb=2 then 'resize screenlock put(0,0),bg,pset redraw get(0,0)-(screenw-1,screenh-1),temp1 put(win(0).x,win(0).y),win(0).iptr,pset screenunlock oldy=win(0).y1-my do getmouse mx,my,,mb imagedestroy win(0).iptr if my+oldy>75 then win(0).y1=my+oldy win(0).iptr=imagecreate(win(0).x1+1,win(0).y1+1) screenlock put(0,0),temp1,pset drawin 0,0,win(0).x1,win(0).y1,sdir(win(0).diri),win(0).iptr line win(0).iptr,(150,25)-step(-25,25),15,b line win(0).iptr,-(150,win(0).y1-25),15,b line win(0).iptr,-step(-25,25),15,b for i=0 to (win(0).y1-30)\15-1 if i+sdirs(win(0).diri)>=j then exit for printf 5, 30+i*15, sdirf(i+sdirs(win(0).diri)), 15, win(0).iptr next put(win(0).x,win(0).y),win(0).iptr,pset screenunlock loop while mb=2 end if elseif mousebox(win(0).x+win(0).x1-25,win(0).y+25,win(0).x+win(0).x1,win(0).y+50) then if mb=1 then if sdirs(win(0).diri)>0 then sdirs(win(0).diri)-=1 line win(0).iptr,(1,26)-(win(0).x1-26,win(0).y1-1),0,bf for i=0 to (win(0).y1-30)\15-1 if i+sdirs(win(0).diri)>=j then exit for printf 5, 30+i*15, sdirf(i+sdirs(win(0).diri)), 15, win(0).iptr next put(win(0).x,win(0).y),win(0).iptr,pset end if elseif mousebox(win(0).x+25,win(0).y+25,win(0).x+win(0).x1-25,win(0).y+win(0).y1) then if mb=1 then do getmouse mx,my,,mb loop until mb=0 f = sdirs(win(0).diri)+(my-win(0).y-25)\15 if f < j then if sdirf(f)="..\" then if right(sdir(win(0).diri),2)<>":\" then for i=len(sdir(win(0).diri)) to 2 step -1 if mid(sdir(win(0).diri),i-1,1)="\" then exit for next if multikey(&h1d) then makewin mx,my,150,200,"dir",2 win(wins-1).diri=wins-1 sdir(win(wins-1).diri)=left(sdir(win(0).diri),i-1) sdirs(win(wins-1).diri)=0 mktop wins-1 screenlock put(0,0),bg,pset redraw smalldir 0 screenunlock else sdir(win(0).diri)=left(sdir(win(0).diri),i-1) sdirs(win(0).diri)=0 smalldir 0 end if exit select end if elseif right(sdirf(f),1)="\" then if multikey(&h1d) then makewin mx,my,150,200,"dir",2 win(wins-1).diri=wins-1 sdir(win(wins-1).diri)=sdir(win(0).diri) + sdirf(f) sdirs(win(wins-1).diri)=0 mktop wins-1 screenlock put(0,0),bg,pset redraw smalldir 0 screenunlock else sdir(win(0).diri) += sdirf(f) sdirs(win(0).diri)=0 smalldir 0 end if exit select elseif ucase(right(sdirf(f),4))=".BAS" or ucase(right(sdirf(f),4))=".TXT" then makewin mx,my,200,200,"text",3 win(wins-1).diri=wins-1 textf(win(wins-1).diri)=sdir(win(0).diri)+sdirf(f) textx(win(wins-1).diri)=0 texty(win(wins-1).diri)=0 textc(win(wins-1).diri)=0 open textf(win(wins-1).diri) for binary as #1 textb(win(wins-1).diri)=allocate(lof(1)) get #1,,*textb(win(wins-1).diri),lof(1) textl(win(wins-1).diri)=lof(1) close mktop wins-1 screenlock put(0,0),bg,pset redraw text 0 screenunlock elseif ucase(right(sdirf(f),4))=".BMP" then open sdir(win(0).diri)+sdirf(f) for binary as #1 get #1,,s if s="BM" then get #1,19,bx get #1,23,by makewin mx,my,bx+2,by+27,"bmpload",4 win(wins-1).diri=wins-1 bmpf(wins-1)=sdir(win(0).diri)+sdirf(f) end if close mktop wins-1 screenlock put(0,0),bg,pset redraw loadbmp 0 screenunlock end if end if else line win(0).iptr,(1,26)-(win(0).x1-26,win(0).y1-1),0,bf for i=0 to (win(0).y1-30)\15-1 if i+sdirs(win(0).diri)>=j then exit for if i=(my-win(0).y-25)\15 then line win(0).iptr,(0,26+i*15)-step(win(0).x1-25,15),15,bf printf 5, 30+i*15, sdirf(i+sdirs(win(0).diri)), 0, win(0).iptr else printf 5, 30+i*15, sdirf(i+sdirs(win(0).diri)), 15, win(0).iptr end if next put(win(0).x,win(0).y),win(0).iptr,pset end if else 'this may not be required, but removes the presisting white selection line win(0).iptr,(1,26)-(win(0).x1-26,win(0).y1-1),0,bf for i=0 to (win(0).y1-30)\15-1 if i+sdirs(win(0).diri)>=j then exit for printf 5, 30+i*15, sdirf(i+sdirs(win(0).diri)), 15, win(0).iptr next put(win(0).x,win(0).y),win(0).iptr,pset end if loop end if case 3 do while mousebox(win(0).x,win(0).y+25,win(0).x+win(0).x1,win(0).y+win(0).y1) getmouse mx,my,,mb if multikey(&h1f) and multikey(&h1d) then open textf(win(0).diri) for binary as #1 put #1,,textb(win(0).diri)[0],textl(win(0).diri) close locate 1,1:? "SAVED" end if key=inkey if key<>"" then select case key case chr(255)+"M" if textc(win(0).diri)0 then textc(win(0).diri)-=1 if *(textb(win(0).diri)+textc(win(0).diri))=10 then textc(win(0).diri)-=1 text 0 end if case chr(255)+"P" i=0 do i+=1 loop until *(textb(win(0).diri)+textc(win(0).diri)+i)=10 if textc(win(0).diri)+i>=textl(win(0).diri)-1 then exit select j=0 do j+=1 loop until *(textb(win(0).diri)+textc(win(0).diri)-j)=10 j-=1 for k=0 to j if *(textb(win(0).diri)+textc(win(0).diri)+i+k+1)=10 then j=k-1 exit for end if next textc(win(0).diri)+=i+j+1 text 0 case chr(255)+"H" i=0 do i+=1 if textc(win(0).diri)-i<=0 then exit select loop until *(textb(win(0).diri)+textc(win(0).diri)-i)=10 j=0 do j+=1 if textc(win(0).diri)-i-j+1<=0 then exit do loop until *(textb(win(0).diri)+textc(win(0).diri)-i-j)=10 if j>i then j-=i+1 else j=0 textc(win(0).diri)-=i+j+1 text 0 case chr(8) if textc(win(0).diri)>0 then textb(win(0).diri)=reallocate(textb(win(0).diri),textl(win(0).diri)-1) memcopy textb(win(0).diri)+textc(win(0).diri),textb(win(0).diri)+textc(win(0).diri)-1,textl(win(0).diri)-textc(win(0).diri),-1 textc(win(0).diri)-=1 textl(win(0).diri)-=1 text 0 end if case chr(13) textb(win(0).diri)=reallocate(textb(win(0).diri),textl(win(0).diri)+1) memcopy textb(win(0).diri)+textl(win(0).diri),textb(win(0).diri)+textl(win(0).diri)+1,textl(win(0).diri)-textc(win(0).diri)+1,0 *(textb(win(0).diri)+textc(win(0).diri))=10 textl(win(0).diri)+=1 textc(win(0).diri)+=1 text 0 case chr(32) to chr(128) textb(win(0).diri)=reallocate(textb(win(0).diri),textl(win(0).diri)+1) memcopy textb(win(0).diri)+textl(win(0).diri),textb(win(0).diri)+textl(win(0).diri)+1,textl(win(0).diri)-textc(win(0).diri)+1,0 *(textb(win(0).diri)+textc(win(0).diri))=asc(key) textl(win(0).diri)+=1 textc(win(0).diri)+=1 text 0 end select end if if mousebox(win(0).x+win(0).x1-25,win(0).y+win(0).y1-25,win(0).x+win(0).x1,win(0).y+win(0).y1) then if mb=1 then screenlock put(0,0),bg,pset redraw get(0,0)-(screenw-1,screenh-1),temp1 put(win(0).x,win(0).y),win(0).iptr,pset screenunlock oldx=win(0).x1-mx oldy=win(0).y1-my do getmouse mx,my,,mb if mx+oldx>100 then win(0).x1=mx+oldx if my+oldy>100 then win(0).y1=my+oldy imagedestroy win(0).iptr win(0).iptr=imagecreate(win(0).x1+1,win(0).y1+1) screenlock put(0,0),temp1,pset text 0 'drawin win(0).x,win(0).y,win(0).x1,win(0).y1,"Test" screenunlock loop while mb=1 end if elseif mousebox(win(0).x+win(0).x1-25,win(0).y+25,win(0).x+win(0).x1,win(0).y+50) then if mb=1 then if texty(win(0).diri) > 0 then texty(win(0).diri)-=1 text 0 end if end if elseif mousebox(win(0).x+win(0).x1-25,win(0).y+win(0).y1-50,win(0).x+win(0).x1,win(0).y+win(0).y1-25) then if mb=1 then texty(win(0).diri)+=1 text 0 end if elseif mousebox(win(0).x,win(0).y+win(0).y1-25,win(0).x+25,win(0).y+win(0).y1) then if mb=1 then if textx(win(0).diri) > 0 then textx(win(0).diri)-=1 text 0 end if end if elseif mousebox(win(0).x+win(0).x1-50,win(0).y+win(0).y1-25,win(0).x+win(0).x1-25,win(0).y+win(0).y1) then if mb=1 then textx(win(0).diri)+=1 text 0 end if end if loop case 4 do while mousebox(win(0).x,win(0).y+26,win(0).x+win(0).x1,win(0).y+win(0).y1) getmouse mx,my,,mb if mb=1 then screenlock put(0,0),bg,pset redraw get(0,0)-(screenw-1,screenh-1),temp1 put(win(0).x,win(0).y),win(0).iptr,pset screenunlock oldx=win(0).x1-mx oldy=win(0).y1-my do getmouse mx,my,,mb if mx+oldx>100 then win(0).x1=mx+oldx if my+oldy>100 then win(0).y1=my+oldy imagedestroy win(0).iptr win(0).iptr=imagecreate(win(0).x1+1,win(0).y1+1) screenlock put(0,0),temp1,pset resize win(0).x1-2,win(0).y1-27,lbmp(win(0).diri).iptr drawin 0,0,win(0).x1,win(0).y1,bmpf(win(0).diri)+" "+str(win(0).x1-2)+"x"+str(win(0).y1-27),win(0).iptr put win(0).iptr,(1,26),lbmp(win(0).diri).iptr,pset put (win(0).x,win(0).y),win(0).iptr,pset screenunlock loop while mb=1 elseif mb=2 then open bmpf(win(0).diri) for binary as #1 get #1,,s if s="BM" then get #1,19,bx get #1,23,by win(0).x1=bx+2 win(0).y1=by+27 imagedestroy win(0).iptr win(0).iptr=imagecreate(win(0).x1+1,win(0).y1+1) screenlock put(0,0),bg,pset redraw loadbmp 0 screenunlock end if close end if loop case 5 'do while mousebox(win(0).x,win(0).y+25,win(0).x+win(0).x1,win(0).y+win(0).y1) getmouse mx,my,,mb key=inkey if key<>"" then select case key case chr(13) dim as string exe,args runcomx(win(0).diri)=runcomx(win(0).diri)+chr(32) exe= mid(runcomx(win(0).diri),1,instr(runcomx(win(0).diri),chr(32))) args=right(runcomx(win(0).diri),len(runcomx(win(0).diri))-instr(runcomx(win(0).diri),chr(32))) x=exec(exe,args) res screenw,screenh case chr(8) if len(runcomx(win(0).diri))>=1 then runcomx(win(0).diri)=left(runcomx(win(0).diri),len(runcomx(win(0).diri))-1) runcom 0 end if case chr(32) to chr(128) runcomx(win(0).diri)=runcomx(win(0).diri)+key runcom 0 end select end if 'loop case else end select loop until inp(&h60)=1 end sub printf(x, y, s as string, c as ubyte) dim sptr as ubyte ptr = sadd(s) dim vptr as ubyte ptr = screenptr 'dim w as integer 'screeninfo w o=y*screenw+x l=((len(s)) shl 3)-1 j=0 for y1=0 to 10 i=0 for x1=0 to l if font(11*(*(sptr+(x1 shr 3))-32)+y1) and (1 shl (7-(x1 and 7))) then *(vptr+o+j+i)=c i+=1 next j+=screenw next end sub sub printf(x, y, s as string, c as ubyte, buffer as any ptr) dim sptr as ubyte ptr = sadd(s) dim vptr as ubyte ptr = buffer dim w as integer if imageinfo(buffer, w) then exit sub o=y*w+x l=((len(s)) shl 3)-1 j=0 for y1=0 to 10 i=0 for x1=0 to l if font(11*(*(sptr+(x1 shr 3))-32)+y1) and (1 shl (7-(x1 and 7))) then *(vptr+o+j+i)=c i+=1 next j+=w next end sub function getfiles(path as string, f() as string) dim s as string = dir(path+"*.*", &h10) for i=0 to ubound(f) s=dir() if s="" then exit for f(i)=s+"\" next s = dir(path+"*.*", not &h10) for i=i to ubound(f) if s="" then exit for f(i)=s s=dir() next getfiles = i end function function mousebox(x, y, x1, y1) if mx>=x then if mx<=x1 then if my>=y then if my<=y1 then mousebox=-1 end function sub makewin(x, y, x1, y1, cap as string, pid) win(wins).x=x win(wins).y=y win(wins).x1=x1 win(wins).y1=y1 win(wins).cap=cap win(wins).pid=pid win(wins).iptr=imagecreate(x1+1, y1+1) wins=wins+1 end sub sub mktop(id) dim temp as wintype = win(id) for i=id-1 to 0 step -1 win(i+1)=win(i) next win(0)=temp end sub sub closewin(id) imagedestroy win(id).iptr for i=id to wins win(i)=win(i+1) next if win(id).pid=3 then deallocate textb(win(id).diri) end if wins=wins-1 end sub sub drawin(x, y, x1, y1, cap as string) line(x,y)-step(x1,y1),0,bf line(x,y)-step(x1,y1),15,b line(x,y)-step(x1,25),15,b if (len(cap)*8)>(x1-10) then printf x+5,y+8,left(cap, (x1-10) shr 3),15 else printf x+5,y+8,cap,15 end sub sub drawin (x, y, x1, y1, cap as string, buffer as any ptr) line buffer,(x,y)-step(x1,y1),0,bf line buffer,(x,y)-step(x1,y1),15,b line buffer,(x,y)-step(x1,25),15,b if (len(cap)*8)>(x1-10) then printf x+5,x+8,left(cap, (x1-10) shr 3),15,buffer else printf x+5,y+8,cap,15,buffer end sub sub redraw() for i=wins-1 to 1 step -1 'drawin win(i).x,win(i).y,win(i).x1,win(i).y1,win(i).cap put(win(i).x,win(i).y),win(i).iptr,pset next end sub sub clock(id) drawin 0,0,win(id).x1,win(id).y1,time,win(id).iptr dim pi as single =3.1415926*2 circle win(id).iptr,(75,100),70,15 dim i as single j=0 for i=0 to pi step pi/60 if j mod 5 = 0 then r=58 else r=62 j=j+1 line win(id).iptr,(65*cos(i)+75,65*sin(i)+100)-(r*cos(i)+75,r*sin(i)+100),15 next sec=val(right(time,2)) min=val(mid(time,4,2)) hou=val(left(time,2)) line win(id).iptr,(75,100)-(70*cos(sec*pi/60-pi/4)+75,70*sin(sec*pi/60-pi/4)+100),15,,&h5555 line win(id).iptr,(75,100)-(64*cos(min*pi/60-pi/4)+75,64*sin(min*pi/60-pi/4)+100),15 hou=5*hou+(5*min)/60 line win(id).iptr,(75,100)-(20*cos(hou*pi/60-pi/4)+75,20*sin(hou*pi/60-pi/4)+100),15 put(win(id).x,win(id).y),win(id).iptr,pset end sub sub smalldir(id) drawin 0,0,win(id).x1,win(id).y1,sdir(win(id).diri),win(id).iptr line win(id).iptr,(150,25)-step(-25,25),15,b line win(id).iptr,-(150,win(id).y1-25),15,b line win(id).iptr,-step(-25,25),15,b j=getfiles(sdir(win(id).diri),sdirf()) for i=0 to (win(id).y1-30)\15-1 if i+sdirs(win(id).diri)>=j then exit for printf 5, 30+i*15, sdirf(i+sdirs(win(id).diri)), 15, win(id).iptr next put(win(id).x,win(id).y),win(id).iptr,pset end sub sub text(id) drawin 0,0,win(id).x1,win(id).y1,textf(win(id).diri),win(id).iptr line win(id).iptr,(win(id).x1-25,25)-step(25,25),15,b line win(id).iptr,-step(-25,win(id).y1-100),15,b line win(id).iptr,-step(25,25),15,b line win(id).iptr,-step(-25,25),15,b line win(id).iptr,-step(-25,-25),15,b line win(id).iptr,-(25,win(id).y1-25),15,b line win(id).iptr,-step(-25,25),15,b x=0 y=0 xx=textx(win(id).diri) yy=texty(win(id).diri) for i=0 to textl(win(id).diri)-2 if y>=yy then exit for if (*(textb(win(id).diri)+i))=10 then y=y+1 next y=0 for i=i to textl(win(id).diri)-2 if y>(win(id).y1-55)\15-1 then exit for if i=textc(win(id).diri) and x<(win(id).x1-30)\8 then line win(id).iptr,(x*8+4,y*15+30)-step(5,15),15,b if (*(textb(win(id).diri)+i))=10 then x=0 y=y+1 else if x<(win(id).x1-30)\8 then if *(textb(win(id).diri)+i)>=32 and *(textb(win(id).diri)+i)<=128 then 'draw string win(id).iptr,(5+x*8,30+y*15),chr(*(textb(win(id).diri)+i)),15 printf x*8+5,y*15+30,chr(*(textb(win(id).diri)+i)),15,win(id).iptr end if end if x=x+1 end if next 'if texty(win(id).diri)>y then texty(win(id).diri)=y put(win(id).x,win(id).y),win(id).iptr,pset end sub sub loadbmp(id) w=win(id).x1-2 h=win(id).y1-27 lbmp(win(id).diri).iptr=imagecreate(w,h) bload bmpf(win(id).diri),lbmp(win(id).diri).iptr palette 0, &h000000 palette 15, &hffffff drawin 0,0,win(id).x1,win(id).y1,bmpf(win(id).diri)+" "+str(w)+"x"+str(h),win(id).iptr put win(id).iptr,(1,26),lbmp(win(id).diri).iptr,pset put(win(id).x,win(id).y),win(id).iptr,pset end sub sub res (x, y) screenres x, y, 8 screeninfo screenw,screenh imagedestroy temp1 temp1 = imagecreate(screenw,screenh) imagedestroy bg bg = imagecreate(screenw,screenh,0) if not bgoff then open "bg.bmp" for binary as #1 get #1,,s if s="BM" then get #1,19,bx get #1,23,by temp4=imagecreate(bx,by) bload "bg.bmp",temp4 if bgstretch then resize screenw,screenh,temp4 imagedestroy bg bg = temp4 else put bg,((screenw-bx)\2,(screenh-by)\2),temp4 imagedestroy temp4 end if end if close end if palette 0, &h000000 palette 15, &hffffff put(0,0),bg redraw put(win(0).x,win(0).y),win(0).iptr,pset end sub sub resize (x, y, buffer as any ptr) dim as integer w,h,k,l dim as single p,q dim as ubyte ptr addr1,addr2 temp2=imagecreate(x,y) if imageinfo(temp2,,,,,addr2) then exit sub if imageinfo(buffer,w,h,,,addr1) then exit sub p=w/x q=h/y k=0 for j=0 to y-1 k=w*cint(j*q) for i=0 to x-1 *(addr2+l+i)=*(addr1+k+cint(i*p)) next l=l+x next imagedestroy buffer buffer=temp2 end sub sub memcopy (byval src as any ptr, byval dest as any ptr, byval n as uinteger, byval d as uinteger) asm mov esi,[src] mov edi,[dest] cmp dword ptr [d],0 je here cld mov eax,[n] mov ecx,eax shr ecx,2 rep movsd and eax,3 mov ecx,eax rep movsb jmp there here: std mov ecx,[n] rep movsb there: end asm end sub sub runcom (id) drawin 0,0,win(id).x1,win(id).y1,win(id).cap,win(id).iptr if len(runcomx(win(id).diri))>23 then printf 5,35,right(runcomx(win(id).diri),23),15,win(id).iptr line win(id).iptr,(5+23*8,30)-step(5,15),15,b else printf 5,35,runcomx(win(id).diri),15,win(id).iptr line win(id).iptr,(5+len(runcomx(win(id).diri))*8,30)-step(5,15),15,b end if put (win(id).x,win(id).y),win(id).iptr,pset end sub
Free Web Hosting