program avi; uses crt,dos,sbplay,sbdetect,wav,graphics,global,open,text,mouse; var BASEIO,frame : word; DMA16,DMA,IRQ : byte; mode,xpos,ypos : byte; i,code : integer; exitmovie : boolean; virtualavi : pointer; oldmousex, oldmousey : word; width,height : integer; colour,r,g,b,x,y,front,back : byte; {----------------------------------------------------------------------} procedure play_movie(xpos,ypos:integer;filename:string); var Filechar, filewrite : file; filechar2 : file of integer; framerate : integer; showframe,exitplay : boolean; h,m,s,hund,temp,s2,oldh,oldm,olds,oldhund,data : word; oneframe,tenframes,sixhundframes,curframe,lastframe, forward_, reverse_, x, y,position, frame, totalframes : longint; begin if does_file_exist(filename+'.avi') then begin assign(FileChar2,filename+'.avi'); reset(FileChar2); seek(filechar2,32); read(filechar2,width); seek(filechar2,34); read(filechar2,height); close(filechar2); if (width=160) and (height=100) then begin getmem(virtualavi,(width*height)+8); clearpalettearray; load_avi_palette(filename+'.avi'); setRGB(0,0,0,0); setRGB(255,63,63,63); asminitpalette; hide_pointer; menubar(seg(mode1addr^)); PaletteGraphuser(0,172,4,64,5,1,seg(mode1addr^)); asmclsuser(253,320*162,seg(mode1addr^)+$14*9); rectangle_(xpos-1,ypos-1,width+xpos,height+ypos,255); line_(0,155,319,155,0); line_(0,156,319,156,254); OutTextXYuser(106,160,254,'PLAY STOP',seg(mode1addr^)); line_(110,156,110,170,0); line_(148,156,148,170,0); line_(188,156,188,170,0); OutTextXYuser(0,15,254,'AVI Player - Written By Franz Ayestaran',seg(mode1addr^)); line_(0,12,319,12,0); line_(0,13,319,13,254); line_(0,24,319,24,0); show_pointer; frame:=1; exitplay:=false; assign(FileChar,filename+'.avi'); reset(FileChar,1); position:=avifileposition+(320*6)-487; gettime(oldh,oldm,olds,oldhund); settime(0,0,0,0); showframe:=true; totalframes:=((filesize(filechar))-(position)) div ((width*height)+8); repeat oldmousex:=mousex; oldmousey:=mousey; Get_Pointer_location(false,69,0,false); if (Mousex=0) and (Mousey=0) and (MouseButton=1)then begin exitmovie:=true; exitplay:=true; end; if (MouseButton=1) and (mousex>148) and (mousey>155) and (mousex<185) and (mousey<169) then exitplay:=true; gettime(h,m,s,hund); oneframe:=hund div 10; tenframes:=s*10; sixhundframes:=m*600; curframe:=oneframe+tenframes+sixhundframes; if curframe>lastframe then showframe:=true; if showframe then begin seek(filechar,(position)+((curframe)*((width*height)+8))); blockread(Filechar,virtualavi^,(width*height)+8,Data); { **** correct image orientation in bitmap and write to screen **** } { ***************************************************************** } reverse_:=(width*height)+1; forward_:=0; for y := 1 to height do begin reverse_:=reverse_-width; for x:= 1 to width do begin colour:=mem[seg(virtualavi^):reverse_]; mem[$a000:forward_+(xpos)+(ypos*320)]:=colour; forward_:=forward_+1; reverse_:=reverse_+1; end; forward_:=forward_+(320-width); reverse_:=reverse_-width; end; { ***************************************************************** } colour:=mem[seg(virtualavi^):(width*height)+1]; lipsync:=true; showframe:=false; lastframe:=curframe; x:=0; y:=20; front:=254; back:=253; PutString('Frame: ',x,y,7,front,back); asmgotoxy(x+6,y); asmputchar(frame mod 10000 div 1000+48,front,back,1); asmgotoxy(x+7,y); asmputchar(frame mod 1000 div 100+48,front,back,1); asmgotoxy(x+8,y); asmputchar(frame mod 100 div 10+48,front,back,1); asmgotoxy(x+9,y); asmputchar(frame mod 10+48,front,back,1); frame:=frame+1; x:=16; PutString('Time: ',x+11,y,6,front,back); {minutes} asmgotoxy(x+16,y); asmputchar(m mod 100 div 10+48,front,back,1); asmgotoxy(x+17,y); asmputchar(m mod 10+48,front,back,1); {seconds} asmgotoxy(x+18,y); asmputchar(ord(':'),front,back,1); asmgotoxy(x+19,y); asmputchar(s mod 100 div 10+48,front,back,1); asmgotoxy(x+20,y); asmputchar(s mod 10+48,front,back,1); {hundreds} asmgotoxy(x+21,y); asmputchar(ord(':'),front,back,1); asmgotoxy(x+22,y); asmputchar(hund mod 100 div 10+48,front,back,1); asmgotoxy(x+23,y); asmputchar(hund mod 10+48,front,back,1); progress(1,195,44,5,0,totalframes,frame,253,252); end; until (eof(filechar)) or (colour<>48) or (exitplay) or (keypressed); freemem(virtualavi,(width*height)+8); close(Filechar); gettime(h,m,s,hund); settime(oldh,olds,oldm,oldhund); end; end; end; {----------------------------------------------------------------------} procedure play_once; begin lipsync:=false; if (detect_sb(BASEIO,IRQ,DMA,DMA16)) and (does_file_exist(paramstr(1)+'.wav')) then begin read_wav_header(paramstr(1)+'.wav'); Playwav(paramstr(1)+'.WAV',BASEIO,DMA16,IRQ,SPEED,STEREO,SIXTEEN_BIT); end; play_movie(xpos,ypos,paramstr(1)); if (detect_sb(BASEIO,IRQ,DMA,DMA16)) and (does_file_exist(paramstr(1)+'.wav')) and (xms_found) then Shutdownsb16; end; {----------------------------------------------------------------------} begin mode:=1; if (paramstr(1)='/?') or (paramstr(1)='') then begin writeln; Writeln('AVI Player For Dos Written by Franz Ayestaran (c)1997'); writeln('------------------'); writeln; writeln('This program plays an <.avi> file of which are 160x100 in'); writeln('size and has an embedded 256 colour optimum palette. The'); writeln('program also plays the accompaning <.wav> file if a'); writeln('Soundblaster compatible card is present.'); writeln; writeln('Usage: avi '); writeln; end; if (paramstr(1)<>'/?') and (paramstr(1)<>'') then if does_file_exist(paramstr(1)+'.avi') then begin xpos:=76; ypos:=30; asminitgraphics(1); setrgb(15,0,0,0); asminitpalette; init_mouse; set_pointer_location(20,40); play_once; repeat oldmousex:=mousex; oldmousey:=mousey; Get_Pointer_location(false,69,0,false); if (Mousex=0) and (Mousey=0) and (MouseButton=1)then exitmovie:=true; if (MouseButton=1) and (mousex>110) and (mousey>155) and (mousex<145) and (mousey<169) then play_once; if (MouseButton=2) and (mousey<193) and (mousey>9) then begin x:=9; y:=17; front:=254; back:=253; hide_pointer; colour:=asmgetpixel(mousex-1,mousey); r:=getred(colour); g:=getgreen(colour); b:=getblue(colour); putfill(313,194,318,198,colour); asmgotoxy(x+1,y); asmputchar(ord('C'),255,back,1); asmgotoxy(x+2,y); asmputchar(colour mod 1000 div 100+48,front,back,1); asmgotoxy(x+3,y); asmputchar(colour mod 100 div 10+48,front,back,1); asmgotoxy(x+4,y); asmputchar(colour mod 10+48,front,back,1); asmgotoxy(x+6,y); asmputchar(ord('R'),249,back,1); asmgotoxy(x+7,y); asmputchar(r mod 1000 div 100+48,front,back,1); asmgotoxy(x+8,y); asmputchar(r mod 100 div 10+48,front,back,1); asmgotoxy(x+9,y); asmputchar(r mod 10+48,front,back,1); asmgotoxy(x+11,y); asmputchar(ord('G'),250,back,1); asmgotoxy(x+12,y); asmputchar(g mod 1000 div 100+48,front,back,1); asmgotoxy(x+13,y); asmputchar(g mod 100 div 10+48,front,back,1); asmgotoxy(x+14,y); asmputchar(g mod 10+48,front,back,1); asmgotoxy(x+16,y); asmputchar(ord('B'),251,back,1); asmgotoxy(x+17,y); asmputchar(b mod 1000 div 100+48,front,back,1); asmgotoxy(x+18,y); asmputchar(b mod 100 div 10+48,front,back,1); asmgotoxy(x+19,y); asmputchar(b mod 10+48,front,back,1); show_pointer; end; until (exitmovie) or (keypressed); hide_pointer; fadeout(50); asmclosegraph; end else writeln('File not found!'); end.