home *** CD-ROM | disk | FTP | other *** search
/ Intermedia 1998 January / inter1_98.iso / www / rozi / FLI_2.ZIP / FLISAM.PAS < prev    next >
Pascal/Delphi Source File  |  1995-03-17  |  5KB  |  391 lines

  1. {$a+,b-,d-,e-,f-,g+,i+,l+,n-,o-,r-,s+,v+,x-}
  2. {$m  16384,0,655360}
  3. unit flisam;
  4. interface
  5. procedure fli(name:string;sname:string);
  6. implementation
  7. uses
  8. samples;
  9. type
  10. fliheader= record
  11. size      :longint;
  12. htype     :word;
  13. framecount:word;
  14. width     :word;
  15. height    :word;
  16. bitsperpixel:word;
  17. flags     :integer;
  18. speed     :integer;
  19. nexthead  :longint;
  20. framesintable:longint;
  21. hfile:integer;
  22. hframe1offset:longint;
  23. strokes:longint;
  24. session:longint;
  25. reserved:array[1..88] of byte;
  26. end;
  27. frameheader=record
  28. size:longint;
  29. ftype:word;
  30. chunks:word;
  31. expand:array[1..8] of byte;
  32. end;
  33. chunkheader=record
  34. size:longint;
  35. id:word;
  36. end;
  37. buffer=array[1..65535] of byte;
  38.  
  39. rgb=record
  40. r,g,b:byte;
  41. end;
  42. paltype=array[0..255] of rgb;
  43. var
  44. buf:^buffer;
  45. pal:^paltype;
  46. h:fliheader;
  47.  
  48. samp:array[1..2] of sample_info;
  49.  
  50. fh:frameheader;
  51. ch:chunkheader;
  52. i,j:word;
  53. speed:word;
  54. f:file;
  55. fname:string;
  56. firstframe:longint;
  57. function setgraphmode:word;assembler;
  58. asm
  59. mov ax,0013h
  60. int 10h
  61. mov ah,0fh
  62. int 10h
  63. xor ah,ah
  64. end;
  65. procedure settextmode;assembler;
  66. asm
  67. mov ax,0003h
  68. int 10h;
  69. end;
  70.  
  71. procedure waitforscreen;assembler;
  72. asm
  73. mov dx,3dah
  74. @wait1:
  75. in al,dx
  76. test al,8
  77. jnz @wait1
  78. @wait2:
  79. in al,dx
  80. test al,8
  81. jz @wait2
  82. end;
  83.  
  84. procedure waiting;assembler;
  85. asm
  86. mov cx,speed
  87. jcxz @end
  88. dec cx
  89. @wait:
  90. call waitforscreen
  91. loop @wait
  92. @end:
  93. end;
  94.  
  95. procedure decodefli_color;assembler;
  96.  
  97. asm
  98. les ax,pal
  99. mov bx,es
  100. mov dx,ax
  101. and ax,15
  102. mov di,ax
  103. shr dx,4
  104. add bx,dx
  105. push ds
  106. lds ax,buf
  107. mov bx,ds
  108. mov dx,ax
  109. and ax,15
  110. mov si,ax
  111. shr dx,4
  112. add bx,dx
  113. mov ds,bx
  114. cld
  115. lodsw
  116. mov bx,ax
  117. test bx,bx
  118. jmp @endu
  119. @u:
  120. lodsb
  121. add di,ax
  122. add di,ax
  123. add di,ax
  124. lodsb
  125. or al,al
  126. jnz @u2
  127. mov ax,256
  128. @u2:
  129. mov cx,ax
  130. add cx,ax
  131. add cx,ax
  132. rep movsb
  133. dec bx
  134. @endu:
  135. jnz @u
  136. sub di,768
  137. mov si,di
  138. push es
  139. pop ds
  140. mov cx,256
  141. mov bl,0
  142. @setpal:
  143. mov dx,3c8h
  144. mov al,bl
  145. out dx,al
  146. inc dx
  147. lodsb
  148. out dx,al
  149. lodsb
  150. out dx,al
  151. lodsb
  152. out dx,al
  153. inc bl
  154. loop @setpal
  155. pop ds
  156. end;
  157.  
  158. procedure decodefli_black; assembler;
  159.  
  160. asm
  161. mov cx,32000
  162. mov ax,0a000h
  163. mov es,ax
  164. xor ax,ax
  165. mov di,ax
  166. rep stosw
  167. call waiting
  168. end;
  169.  
  170. procedure decodefli_brun;assembler;
  171. var
  172. linecount:word;
  173.  
  174. asm
  175. call waitforscreen
  176. mov linecount,200
  177. mov ax,0a000h
  178. mov es,ax
  179. xor di,di
  180. push ds
  181. lds ax,buf
  182. mov bx,ds
  183. mov dx,ax
  184. and ax,15
  185. mov si,ax
  186. shr dx,4
  187. add bx,dx
  188. mov ds,bx
  189. cld
  190. mov dx,di
  191. xor ah,ah
  192. @linelp:
  193. mov di,dx
  194. lodsb
  195. mov bl,al
  196. test bl,bl
  197. jmp @endulcloop
  198. @ulcloop:
  199. lodsb
  200. test al,al
  201. js @ucopy
  202. mov cx,ax
  203. lodsb
  204. rep stosb
  205. dec bl
  206. jnz @ulcloop
  207. jmp @ulcout
  208. @ucopy:
  209. neg al
  210. mov cx,ax
  211. rep movsb
  212. dec bl
  213. @endulcloop:
  214. jnz @ulcloop
  215. @ulcout:
  216. add dx,320
  217. dec linecount
  218. jnz @linelp
  219. pop ds
  220. call waiting
  221. end;
  222.  
  223.  
  224. procedure decodefli_lc;assembler;
  225.  
  226. var
  227. linecount:word;
  228.  
  229. asm
  230. call waitforscreen
  231. mov ax,0a000h
  232. mov es,ax
  233. xor di,di
  234. push ds
  235. lds ax,buf
  236. mov bx,ds
  237. mov dx,ax
  238. and ax,15
  239. mov si,ax
  240. shr dx,4
  241. add bx,dx
  242. mov ds,bx
  243. cld
  244. lodsw
  245. mov dx,320
  246. mul dx
  247. add di,ax
  248. lodsw
  249. mov linecount,ax
  250. mov dx,di
  251. xor ah,ah
  252. @linelp:
  253. mov di,dx
  254. lodsb
  255. mov bl,al
  256. test bl,bl
  257. jmp @endulcloop
  258. @ulcloop:
  259. lodsb
  260. add di,ax
  261. lodsb
  262. test al,al
  263. js @ulcrun
  264. mov cx,ax
  265. rep movsb
  266. dec bl
  267. jnz @ulcloop
  268. jmp @ulcout
  269. @ulcrun:
  270. neg al
  271. mov cx,ax
  272. lodsb
  273. rep stosb
  274. dec bl
  275. @endulcloop:
  276. jnz @ulcloop
  277. @ulcout:
  278. add dx,320
  279. dec linecount
  280. jnz @linelp
  281. pop ds
  282. call waiting
  283. end;
  284.  
  285. procedure decodefli_copy;assembler;
  286.  
  287. asm
  288. call waitforscreen
  289. mov ax,0a000h
  290. mov es,ax
  291. xor di,di
  292. push ds
  293. lds ax,buf
  294. mov bx,ds
  295. mov dx,ax
  296. and ax,15
  297. mov si,ax
  298. shr dx,4
  299. add bx,dx
  300. mov ds,bx
  301. mov cx,32000
  302. rep movsw
  303. pop ds
  304. call waiting
  305. end;
  306.  
  307. procedure fli(name:string;sname:string);
  308.  
  309. begin
  310. load_sample(sname,8000,samp[1]);
  311.  
  312. fname:=name;
  313. if fname='' then
  314. begin
  315. writeln(' '); halt(1);
  316. end;
  317. if pos('.',fname)=0 then fname:=fname+'.fli';
  318. assign(f,fname);
  319. {$i-} reset(f,1); {$i+}
  320. if ioresult<>0 then begin
  321. writeln('brak tego pliku');
  322. halt(2);
  323. end;
  324. {$i-} blockread(f,h,sizeof(h)); {$i+}
  325. if ioresult<>0 then begin
  326. writeln('blad odczytu');
  327. halt(3);
  328. end;
  329. if h.htype<>$af11 then begin
  330. writeln('fli');
  331. close(f);
  332. halt(4);
  333. end;
  334. if setgraphmode<>$13 then begin
  335. writeln('potrzebna vga');
  336. halt(5);
  337. end;
  338. new(buf);new(pal);
  339. speed:=h.speed;
  340. firstframe:=filepos(f);
  341.  
  342. for i:=1 to h.framecount do begin
  343. {$i-} blockread(f,fh,sizeof(fh)); {$i+}
  344. if fh.ftype<>$f1fa then begin
  345. close(F); halt(4);
  346. end;
  347. if fh.chunks>0 then
  348. for j:=1 to fh.chunks do begin
  349. {$i-} blockread(f,ch,sizeof(ch)); {$i+}
  350. {$i-} blockread(f,buf^,ch.size-sizeof(ch)); {$i+}
  351.  
  352. case ch.id of
  353. 11:decodefli_color;
  354. 12:decodefli_lc;
  355. 13:decodefli_black;
  356. 15:decodefli_brun;
  357. 16:decodefli_copy;
  358. end;
  359. end else waiting;
  360. end;
  361. seek(f,firstframe);
  362. repeat
  363.  
  364.      play_sample(samp[1],4);
  365.      repeat
  366. if port[$60]=1 then begin
  367. port[$60]:=0;
  368. stop_playing;
  369. close(f);
  370. free_sample(samp[1]);
  371.  
  372. dispose(pal); dispose(buf);
  373. settextmode;
  374.  
  375. exit;
  376. end;
  377.  
  378. until not(sample_is_playing);
  379.  
  380. stop_playing;
  381. until port[$60]=1;
  382. close(f);
  383.  
  384. dispose(pal); dispose(buf);
  385. settextmode;
  386. exit;
  387. end;
  388. end.
  389.  
  390.  
  391.