rem Slide Show ...... Rev 3.5 rem A J Tooth // June 2005 rem Revised November 2008 rem =================================================================== on error if (err=17) then quit himem=lomem + 100000000 *FLOAT 64 install @lib$+"MyUtils.bbc" install @lib$+"BMP_Utils.bbc" rem =================================================================== *REFRESH OFF rem Set up parameters and compile assembly routines proc_setup rem Get the first picture, and set the path proc_picpath(wdth%,hght%) rem Clear screen and display my icon proc_AJTicon(10,fn_adapt(1,600)) rem Set scaling for displaying pictures centrally proc_scale(xw%,yh%,wdth%,hght%,xb%,yb%,xc%,yc%) colour 132 : cls rem Display a Picture proc_gendisp(0,FulName$,xs%+xb%,ys%+yb%,xc%,yc%,ntused%,ntused%) rem Convert general picture to bitmap, and simultaneously resize proc_convert(pacb%) rem Count the number of files available proc_count *REFRESH rem Random Display of any Picture File in Folder c$="" : rem Initialise event buffer proc_loop *REFRESH ON proc_event(a$,b&) quit rem End of Program======================================================= rem--------------------------------------------------------------------- rem Setup Procedures def proc_setup local pass& rem Check the display size proc_maxim(xscreen%,yscreen%) rem Prevent the window from being resized sys "GetWindowLong", @hwnd%, -16 to ws% sys "SetWindowLong", @hwnd%, -16, ws% and not &50000 rem Change the Windows Title title$ = "SLIDE SHOW by Tony Tooth" sys "SetWindowText", @hwnd%, title$ colour 3 : colour 132,0,0,50 : colour 4,0,0,50 : colour 132 : cls BPic$=@dir$ + "BPic.jpg" rem Display a background picture proc_gendisp(0,BPic$,10,10,xscreen%-20,yscreen%-70,ntused%,ntused%) rem Displays my icon proc_AJTicon(50,fn_adapt(1,550)) colour 8,160,90,20 msg$="\8SLIDE SHOW" proc_msg("Blackadder ITC",24,"B",fn_adapt(0,350),fn_adapt(1,400),msg$) msg$="\11 Press any key or mouse button to continue and select the first picture from a collection." proc_msg("Georgia",16,"B",fn_adapt(0,100),fn_adapt(1,300),msg$) dim NameFile$(5000) dim merge% 1000 rem Display mini-window parameters xs%=int(xscreen%/4) ys%=int(yscreen%/4) xw%=int(xscreen%/2) yh%=int(yscreen%/2) rem Set up bitmaps according to parameters provided proc_BMP_Set(xw%,yh%,paca%,Wlim%,lgth%) proc_BMP_Set(xw%,yh%,pacb%,Wlim%,lgth%) proc_BMP_Set(xw%,yh%,pacwrk%,Wlim%,lgth%) rem Dual-pass assembly, in case of labels for pass&=0 to 2 step 2 proc_merge(pass&) next pass& off *REFRESH proc_event(a$,b&) endproc rem--------------------------------------------------------------------- rem Random Display of any Picture File in Folder def proc_loop local x%,y%,b&,c& repeat rem Pick a picture randomly and display it proc_PickRan b$="" if c$="" then b$=inkey$(100) c$="" if b$<>"" then rem Flush keyboard buffer *FX 21,0 repeat c$=inkey$(10) *REFRESH mouse x%,y%,b& sys "Sleep",5 if b&=1 then command$=" SCREENSAVE "+"temp.bmp"+" 0,0,"+str$(2*xscreen%)+","+str$(2*yscreen%) oscli command$ rem Set scaling for displaying pictures centrally proc_scale(xscreen%,yscreen%,wdth%,hght%,xb%,yb%,xc%,yc%) colour 132 : cls rem Display the picture full screen proc_gendisp(0,FulName$,xb%,yb%,xc%,yc%,ntused%,ntused%) repeat mouse x%,y%,c& sys "Sleep",5 *REFRESH until c&=1 command$=" DISPLAY "+"temp.bmp"+" 0,0,"+str$(2*xscreen%)+","+str$(2*yscreen%) oscli command$ *REFRESH endif until (c$<>"" or b&=4) *FX 21,0 endif *FX 21,0 until false endproc rem ======================================================================== rem Select the first picture and set the path def proc_picpath(return wdth%, return hght%) local g%,rn%,n$,Flg&,pic$,fullname$,command$,m& dim pf% 75, ff% 30, fm% 255 !pf%=76 pf%!4=@hwnd% pf%!12=ff% pf%!28=fm% pf%!32=256 pf%!52=6 $ff% ="Picture files"+chr$0+"*.bmp;*.jpg"+chr$0+chr$0 sys "GetOpenFileName", pf% to result% if result%<>0 then fullname$ = $$fm% rn%=len(fullname$) g%=0 : pic$="" repeat n$=mid$(fullname$,rn%-g%,1) if n$<>"\" then pic$=n$+pic$ : g%+=1 until n$="\" PreW$=left$(fullname$,rn%-g%) rem Change the current Directory command$="CD "+chr$(34)+PreW$+chr$(34) oscli command$ Name$=pic$ : FulName$=PreW$+Name$ rem Get picture size proc_picsize(FulName$,wdth%,hght%) endproc rem--------------------------------------------------------------------- rem Count the number of files available def proc_count local Flg&,sh% dim dir% local 317 rem Count the bitmaps sys "FindFirstFile", "*.bmp", dir% to sh% Cnt%=0 if sh%<>-1 then repeat sys "FindNextFile", sh%, dir% to Rs% Name$=$$(dir%+44) if Name$<>"temp.bmp" then Cnt%+=1 NameFile$(Cnt%)=Name$ endif until Rs%=0 sys "FindClose", sh% endif rem Count the jpgs sys "FindFirstFile", "*.jpg", dir% to sh% if sh%<>-1 then repeat sys "FindNextFile", sh%, dir% to Rs% Name$=$$(dir%+44) if Name$<>"temp.bmp" then Cnt%+=1 NameFile$(Cnt%)=Name$ endif until Rs%=0 sys "FindClose", sh% endif cls proc_back(fn_adapt(0,550),fn_adapt(1,1200),fn_adapt(0,1000),fn_adapt(1,200),150,150,150) msg$="\4There are \2"+str$(Cnt%)+"\4 pictures" proc_msg("Georgia",24,"B",fn_adapt(0,650),fn_adapt(1,1350),msg$) proc_back(fn_adapt(0,250),fn_adapt(1,50),fn_adapt(0,1600),fn_adapt(1,200),150,150,150) msg$="\1* \4Press the spacebar or rotate the mouse-wheel to halt, and again to continue." proc_msg("Georgia",12,"B",fn_adapt(0,350),fn_adapt(1,200),msg$) msg$="\1* \4Right-click the paused picture to view full-screen, and a again to return." proc_msg("Georgia",12,"B",fn_adapt(0,350),fn_adapt(1,150),msg$) rem Display the merged picture proc_disp(pacb%) *REFRESH a$=inkey$(100) endproc rem--------------------------------------------------------------------- rem Pick a picture randomly and display it def proc_PickRan local Rn%,t% Rn%=rnd(Cnt%) Name$=NameFile$(Rn%) FulName$=PreW$+Name$ gcol 4 : rectangle fill 2*xs%-10,2*ys%-10,2*xw%+20,2*yh%+20 rem Get picture size proc_picsize(FulName$,wdth%,hght%) rem Set scaling for displaying pictures centrally proc_scale(xw%,yh%,wdth%,hght%,xb%,yb%,xc%,yc%) rem Display the picture "in camera" proc_gendisp(0,FulName$,xs%+xb%,ys%+yb%,xc%,yc%,ntused%,ntused%) rem Copy pacb to paca proc_recopy(pacb%,paca%,lgth%) rem Convert general picture to bitmap, and simultaneously resize proc_convert(pacb%) for t%=1 to 40 fac=1.0*(t%/40) rem Merge the two pictures call merge% rem Display the merged picture proc_disp(pacwrk%) *REFRESH next t% endproc rem--------------------------------------------------------------------- rem Display the initial picture, as a bitmap def proc_disp(pac%) command$="MDISPLAY "+str$~pac%+" "+str$(2*xs%)+","+str$(2*ys%)+","+str$(2*xw%)+","+str$(2*yh%) oscli command$ endproc rem--------------------------------------------------------------------- rem Convert general picture to bitmap, and simultaneously resize def proc_convert(pic%) command$=" SCREENSAVE "+"temp.bmp"+" "+str$(2*xs%)+","+str$(2*ys%)+","+str$(2*xw%)+","+str$(2*yh%) oscli command$ command$=" LOAD "+"temp.bmp "+str$~pic% oscli command$ endproc rem--------------------------------------------------------------------- rem Get picture size def proc_picsize(fil$,return Ww%, return Hh%) local G%,I%,J%,K%,L%,hbm%,olpp% dim temp% local 255, bm% local 86 sys "LoadLibrary", "OLEAUT32.DLL" to oleaut32% sys "GetProcAddress", oleaut32%, "OleLoadPicturePath" to olpp% I% = &7BF80980 : rem. 128-bit iid J% = &101ABF32 K% = &AA00BB8B L% = &AB0C3000 bm%=(bm%+3)and-4 : rem Ensures bm% is a multiple of FOUR sys "MultiByteToWideChar", 0, 0, fil$, len(fil$), temp%, 256 sys olpp%, temp%, 0, 0, 0, ^I%, ^G% : rem. OleLoadPicturePath if G% = 0 error 0, "Cannot load file """+fil$+"""" sys !(!G%+12), G%, ^hbm% : rem. IPicture::get_Handle sys "GetObject", hbm%, 84, bm% Ww% = bm%!4 Hh% = bm%!8 sys !(!G%+8), G% : rem. IPicture::Release endproc rem--------------------------------------------------------------------- rem Assembly Routine for Merging def proc_merge(opt&) P%=merge% [opt opt& mov edx,0 mov [^y%],edx .yloop mov edx,0 mov [^x%],edx .xloop mov eax,[^y%] imul eax,[^Wlim%] add eax,[^x%] add eax,[^x%] add eax,[^x%] add eax,54 finit mov ebx,0 mov bl,pacb%[eax] mov [^tmp%],ebx fild dword [^tmp%] fld qword [^fac] fmulp st1,st0 mov bl,paca%[eax] mov [^tmp%],ebx fild dword [^tmp%] fld1 fld qword [^fac] fsubp st1,st0 fmulp st1,st0 faddp st1,st0 fistp dword [^tmp%] mov bl,[^tmp%] mov pacwrk%[eax],bl mov bl,pacb%[eax+1] mov [^tmp%],ebx fild dword [^tmp%] fld qword [^fac] fmulp st1,st0 mov bl,paca%[eax+1] mov [^tmp%],ebx fild dword [^tmp%] fld1 fld qword [^fac] fsubp st1,st0 fmulp st1,st0 faddp st1,st0 fistp dword [^tmp%] mov bl,[^tmp%] mov pacwrk%[eax+1],bl mov bl,pacb%[eax+2] mov [^tmp%],ebx fild dword [^tmp%] fld qword [^fac] fmulp st1,st0 mov bl,paca%[eax+2] mov [^tmp%],ebx fild dword [^tmp%] fld1 fld qword [^fac] fsubp st1,st0 fmulp st1,st0 faddp st1,st0 fistp dword [^tmp%] mov bl,[^tmp%] mov pacwrk%[eax+2],bl inc dword [^x%] mov edx,[^x%] cmp edx,[^xw%] jl near xloop inc dword [^y%] mov edx,[^y%] cmp edx,[^yh%] jl near yloop ret ] endproc rem ======================================================================