rem My Utilities Library Procedure rem A J Tooth // July 2007 rem Fullscreen def proc_fullscreen(return xscreen%,return yscreen%) sys "GetSystemMetrics", 0 to xscreen% sys "GetSystemMetrics", 1 to yscreen% sys "SetWindowLong",@hwnd%,-16,&16000000 sys "SetWindowPos",@hwnd%,-1,0,0,xscreen%,yscreen%,0 vdu 23,22,xscreen%;yscreen%;8,16,16,1 : rem Set fullscreen mode mouse off : off : rem Turns off the Mouse Pointer and the Cursor endproc rem ============================================================= rem Revert to normal windowed display def proc_revert(return xscreen%,return yscreen%,Fx%,Fy%) sys "GetSystemMetrics", 0 to xscreen% sys "GetSystemMetrics", 1 to yscreen% sys "SetWindowLong",@hwnd%,-16,&16CF0000 sys "SetWindowPos",@hwnd%,0,0,0,xscreen%,yscreen%,0 sys "MoveWindow", @hwnd%, 0, 0, xscreen%, yscreen%,1 vdu 26 vdu 23,22,xscreen%-Fx%;yscreen%-Fy%;8,16,16,1 : rem Reset mode 22 mouse on : off rem Cursor remains OFF endproc rem =============================================================== rem Maximise windowed display def proc_maxim(return xscreen%,return yscreen%) sys "GetSystemMetrics", 0 to xscreen% sys "GetSystemMetrics", 1 to yscreen% sys "SetWindowLong",@hwnd%,-16,&16CF0000 sys "SetWindowPos",@hwnd%,0,0,0,xscreen%,yscreen%,0 sys "MoveWindow", @hwnd%, 0, 0, xscreen%, yscreen%,1 vdu 26 vdu 23,22,xscreen%;yscreen%;8,16,16,1 : rem Reset mode 22 mouse on : off rem Cursor remains OFF endproc rem =============================================================== rem Wait for a mouse or keyboard event def proc_event(return a$,return b&) local x,y rem Debounce repeat mouse x,y,b& a$=inkey$(0) until (b&=0 and a$="") rem Event repeat a$=inkey$(1) mouse x,y,b& until (a$<>"" or b&<>0) endproc rem =============================================================== rem Check for a mouse click def proc_mclick(return b&) : local x,y repeat mouse x,y,b& sys "Sleep",10 until b&=0 repeat mouse x,y,b& sys "Sleep",10 until b&<>0 endproc rem ============================================================= rem Adapt screen parameters def fn_adapt(XY&,Num%) local res% case XY& of when 0: res%=int(Num%*xscreen%/1024) when 1: res%=int(Num%*yscreen%/768) endcase =res% rem ================================================================================ rem Displays my Icon in .exe version def proc_AJTicon(i%,j%) : local w%,h%,hm%,hicon% sys "GetModuleHandle", 0 to hm% sys "LoadImage", hm%, "BBCWin", 1, 32, 32, 0 to hicon% w% = 32 h% = 32 sys "DrawIconEx", @memhdc%, i%, j%, hicon%, w%, h%, 0, 0, 3 sys "InvalidateRect", @hwnd%, 0, 0 endproc rem =========================================================================== rem Prints the backdrop for a screen message def proc_back(Xs%,Ys%,Ws%,Hs%,Rr&,Gg&,Bb&) local h&,Rf&,Gf&,Bf& for h&=0 to 30 Rf&=int(Rr&*h&/30) : Gf&=int(Gg&*h&/30) : Bf&=int(Bb&*h&/30) colour 0,Rf&,Gf&,Bf& : gcol 0 rectangle fill Xs%+h&,Ys%+h&,Ws%-2*h&,Hs%-2*h& next h& colour 0,0,0,0 endproc rem ======================================================================== rem Prints a coloured button to the screen def proc_box(Mul&,Xpos%,Ypos%,Msg$,re&,gr&,bl&) local h& for h&=0 to 30 colour 2,Mul&*h&*re&,Mul&*h&*gr&,Mul&*h&*bl& gcol 2 : rectangle fill (Xpos%+2*h&),(Ypos%+2*h&),(150-4*h&),(150-4*h&) next h& gcol 6 : move (Xpos%+40),(Ypos%+90) : print;Msg$; endproc rem ======================================================================== rem Display message at graphics position Xs%,Ys% def proc_msg(Font$,Sz&,Styl$,Xs%,Ys%,M$) local a%, lg%, ch$, ct$, cl&, cv$ Font$=Font$+","+str$(Sz&) if Styl$<>"" then Font$=Font$+","+Styl$ command$="FONT "+Font$ oscli command$ vdu 5 lg%=len(M$) a%=0 move Xs%,Ys% repeat a%+=1 ch$=mid$(M$,a%,1) if ch$="\" then a%+=1 ct$=mid$(M$,a%,1) case ct$ of when "0","2","3","4","5","6","7","8","9" : cl&=eval(ct$) : gcol cl& when "1" : cv$=mid$(M$,a%+1,1) case cv$ of when "0","1","2","3","4","5" : cl&=eval(ct$+cv$) : gcol cl& : a%+=1 otherwise cl&=eval(ct$) : gcol cl& endcase when "n" : Ys%-=30 : move Xs%,Ys% otherwise print;"\"+ct$; endcase else print;ch$; endif until a%=lg% vdu 4 endproc rem ======================================================================== rem Save the result def proc_ByteSave(Start%,NumBytes%,PrE$,Nm$) local pass&,fil$,gg&,w% private Bsave%,P%,itmp%,loop if Bsave%=0 then dim P% 200, itmp% 3 for pass&=0 to 2 step 2 [opt pass& .Bsave% mov ebx,0 mov bl,[^gg&] mov edx,0 mov [^w%],edx .loop mov al,Start%[edx] call "osbput" inc dword [^w%] mov edx,[^w%] cmp edx,[^NumBytes%] jl loop ret ] next pass& endif fil$=PrE$+Nm$ : rem Name with path of combined file gg&=openout fil$ call Bsave% close #gg& colour 132 : colour 3: print tab(1,1);"File saved as: ";fil$ endproc rem ==================================================================== rem Get screen metrics def proc_metrics(return xscreen%,return yscreen%) sys "GetSystemMetrics", 0 to xscreen% sys "GetSystemMetrics", 1 to yscreen% endproc rem ==================================================================== rem Get a reference for a selected button def fn_getbut(Font$,Sz&,Styl$,Butt{},Xbut%,Ybut1%,Ybutd%,Numbut&) local cc&,a&,a$ for a&=1 to Numbut& if Butt.state&(a&)=1 then proc_button(Xbut%,Ybut1%,Ybutd%,a&,1,1,1) else proc_button(Xbut%,Ybut1%,Ybutd%,a&,1,0,0) endif proc_butmsg(Font$,Sz&,Styl$,Xbut%,Ybut1%,Ybutd%,a&,Butt.ch$(a&)) next a& rem Check which button is pressed cc&=fn_butchk(Numbut&,Xbut%,Ybut1%,Ybutd%,Butt{}) rem Chosen button turns GREEN proc_button(Xbut%,Ybut1%,Ybutd%,cc&,0,1,0) a$=inkey$(50) =cc& rem ================================================================== rem Display a selection button def proc_button(Xp%,Yp%,Yd%,A&,R&,G&,B&) local d&,rd&,gd&,bd& for d&=25 to 1 step-1 rd&=R&*int(255*(1-d&/25)) : gd&=G&*int(255*(1-d&/25)) : bd&=B&*int(255*(1-d&/25)) colour 5,rd&,gd&,bd& : gcol 5 circle fill Xp%,Yp%-Yd%*(A&-1),d& next d& endproc rem ================================================================== rem Display a button message alongside the button def proc_butmsg(Ft$,Sz&,Sl$,Xt%,Yt%,Ytd%,A&,Msg$) proc_msg(Ft$,Sz&,Sl$,Xt%+100,Yt%+20-Ytd%*(A&-1),Msg$) endproc rem ================================================================== rem Check which button pressed def fn_butchk(Numbut&,Xt%,Yt1%,Ytd%,Butt{}) local x%,y%,b&,cd&,ct&,a& cd&=0 : mouse on 136 repeat ct&=0 mouse x%,y%,b& sys "Sleep",10 for a&=0 to Numbut&-1 if x%>(Xt%-25) and x%<(Xt%+25) and y%>(Yt1%-Ytd%*a&-25) and y%<(Yt1%-Ytd%*a&+25) then ct&=a&+1 : if Butt.state&(a&+1)=1 then mouse on 137 endif next a& if ct&=0 then mouse on 136 if (ct&>0 and b&=4 and Butt.state&(ct&)=1) then cd&=ct& until cd&>0 Butt.state&(cd&)=2 : rem Identify selected button within structure =cd& rem ================================================================== rem Copy a fixed number of bytes to another location def proc_recopy(Source%,Dest%,NumBytes%) private Recopy%,P% if Recopy%=0 then dim P% 100 [opt 2 .Recopy% mov esi,[^Source%] mov edi,[^Dest%] mov ecx,[^NumBytes%] cld rep movsb ret ] endif call Recopy% endproc rem ===================================================================