Subversion Repositories Kolibri OS

Rev

Rev 529 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ; GIF VIEWER FOR MENUET v1.0
  2. ; Written in pure assembler by Ivushkin Andrey aka Willow
  3. ;
  4. ; Uses GIF_LITE 2.0
  5. ;
  6. ; Created:      August 31, 2004
  7. ; Last changed: August 25, 2006
  8. ;
  9. ; COMPILE WITH FASM
  10.  
  11. appname equ 'GIF  VIEWER'
  12.  
  13. ; input line dimensions
  14. INP_X equ 5 shl 16+680
  15. INP_Y equ 5 shl 16+16
  16. INP_XY equ 10 shl 16+10
  17.  
  18. use32
  19.  
  20.   org    0x0
  21.  
  22.   db     'MENUET01'
  23.   dd     0x01
  24.   dd     START
  25.   dd     I_END
  26.   dd     0x400000
  27.   dd     0x400000
  28.   dd     filename ;0x0
  29.   dd     0x0
  30.  
  31. include 'lang.inc'
  32. include '..\..\..\macros.inc' ; decrease code size (optional)
  33.  
  34. COLOR_ORDER equ PALETTE
  35. GIF_SUPPORT_INTERLACED = 1
  36. include 'gif_lite.inc'
  37.  
  38. START:
  39.     cmp [filename],byte 0
  40.     jne openfile2
  41. ;    jmp openfile2
  42. openfile:
  43.     xor  eax,eax
  44.     mov  [entered], eax
  45.     mov  [gif_img_count],eax
  46.     mov  esi,fn_input
  47.     mov  edi,filename
  48.     mov  ecx,[inp_pos]
  49.     rep  movsb
  50.     stosb
  51. openfile2:
  52.     mov  ebx,file_info
  53.     mov  eax,70
  54.     mcall
  55.     cmp  eax,6
  56.     je   temp
  57.     test eax,eax
  58.     jnz  ok2
  59. temp:
  60. ;    cmp  ebx,64
  61. ;    jbe  ok2
  62.  
  63.     xor  eax,eax
  64.     mov  [entered], eax
  65.     mov  esi,filename
  66.     mov  edi,fn_input
  67.     mov  ecx,256/4  ;[filename_len]
  68.     rep  movsd
  69.  
  70.     mov  edi,fn_input
  71.     mov  ecx,256
  72.     repne scasb
  73.     sub  edi,fn_input
  74.     mov  [inp_pos],edi
  75.  
  76. ;    test eax,eax
  77. ;    jnz  .ok2
  78. ;    cmp  ebx,64
  79. ;    jbe  .ok2
  80.     mov  esi,workarea
  81.     mov  edi,Image
  82.     call ReadGIF
  83.     test eax,eax
  84.     jz   .ok
  85.     and  [gif_img_count], 0
  86.   .ok:
  87.   ok2:
  88.     and  dword[img_index],0
  89.  
  90.     mov  ebx,3
  91.     mov  ecx,sc
  92.     mov  edx,sizeof.system_colors
  93.     mov  eax,48
  94.     mcall
  95.  
  96. red:
  97.  
  98. ;   *********************************************
  99. ;   *******  Ž…„…‹…ˆ… ˆ Ž’ˆ‘Ž‚Š€ ŽŠ€ *******
  100. ;   *********************************************
  101.  
  102. draw_window:
  103.  
  104.     mov  ebx,1
  105.     mov  eax,12
  106.     mcall
  107.  
  108.     xor  eax,eax
  109.     mov  ebx,50*65536+700
  110.     mov  ecx,50*65536+500
  111.     mov  edx,[sc.work]
  112.     or   edx,0x33000000
  113.     mov  edi,title
  114.     mcall
  115.  
  116.     call draw_input
  117.  
  118.     xor  ecx,ecx
  119.     call draw_subimage
  120.     cmp  [gif_img_count],1
  121.     jz   @f
  122.  
  123.     mov  ecx,[img_index]
  124.     call draw_subimage
  125. @@:
  126.  
  127.     mov  ebx,2
  128.     mov  eax,12
  129.     mcall
  130.  
  131. still:
  132.         cmp     [gif_img_count], 1
  133.         jbe     .infinite
  134.         mov     ebx, [cur_anim_delay]
  135.         test    ebx, ebx
  136.         jz      .infinite
  137.         mov     eax, 23
  138.         mcall
  139.         jmp     @f
  140. .infinite:
  141.         mov     eax, 10
  142.         mcall
  143. @@:
  144.         dec     eax
  145.         jz      red
  146.         dec     eax
  147.         jz      key
  148.         dec     eax
  149.         jz      button
  150.     mov  eax,[gif_img_count]
  151.     cmp  eax,1
  152.     je   still
  153.     inc  [img_index]
  154.     cmp  eax,[img_index]
  155.     jne  redsub
  156.     and  [img_index],0
  157.   redsub:
  158.     mov  ecx,[img_index]
  159.     call draw_subimage
  160.     jmp  still
  161.  
  162.   key:
  163.     mov  eax,2
  164.     mcall
  165.     cmp  ah,13
  166.     je   is_input
  167.     jmp  still
  168.  
  169.   button:
  170.     mcall 17
  171.     cmp  ah,1
  172.     jnz  wait_input
  173.  
  174.   _close:
  175.     or   eax,-1
  176.     mcall
  177.  
  178.   is_input:             ; simple input line with backspace feature
  179.     inc  [entered]      ; sorry - no cursor
  180.   wait_input:
  181.     call draw_input
  182.     mov  eax,10
  183.     mcall
  184.     cmp  al,2
  185.     jne  still
  186.     mov  edi,[inp_pos]
  187. ;    mov  eax,2
  188.     mcall
  189.     shr  eax,8
  190.     cmp  al,27
  191.     je   still
  192.     cmp  al,13
  193.     je   openfile
  194.     cmp  al,8
  195.     je   backsp
  196.     mov  [fn_input+edi],al
  197.     inc  [inp_pos]
  198.     jmp  wait_input
  199.   backsp:
  200.     test edi,edi
  201.     jz   wait_input
  202.     dec  [inp_pos]
  203.     jmp  wait_input
  204. ;    jmp  still
  205.  
  206. ;****************************************
  207. ;******* DRAW CONTENTS OF INPUT LINE ****
  208. ;****************************************
  209. draw_input:
  210.     mov  esi,0xe0e0e0
  211.     cmp  [entered],0
  212.     jne  highlight
  213.     mov  esi,0x00aabbcc
  214.   highlight:
  215.     mov  ecx,INP_Y
  216.     mov  edx,2
  217.     mov  ebx,INP_X
  218.     mov  eax,8
  219.     mcall
  220.     mov  ecx,0x00107a30
  221.     mov  edx,fn_input
  222.     mov  esi,[inp_pos]
  223.     mov  ebx,INP_XY
  224.     mov  eax,4
  225.     mcall
  226.     ret
  227.  
  228. draw_subimage:
  229.     cmp  [gif_img_count],0
  230.     jz   .enddraw
  231.     mov  esi,Image
  232.     mov  edi,gif_inf
  233.     call GetGIFinfo
  234.     test eax,eax
  235.     jz   .enddraw
  236.     mov  ecx, dword [edi+GIF_info.Width-2]
  237.     mov  cx, [edi+GIF_info.Height]
  238.     mov  ebx,eax
  239.     mov  eax, [edi+GIF_info.Delay]
  240.     mov  [cur_anim_delay],eax
  241.     mov  edx, dword [edi+GIF_info.Left-2]
  242.     mov  dx, [edi+GIF_info.Top]
  243.     add  edx,5 shl 16 +25
  244.     mov  esi, 8
  245.     mov  edi, [edi+GIF_info.Palette]
  246.     xor  ebp, ebp
  247.     mov  eax, 65
  248.     mcall
  249.   .enddraw:
  250.     ret
  251.  
  252. ; ‡¤¥áì ­ å®¤ïâáï ¤ ­­ë¥ ¯à®£à ¬¬ë:
  253.  
  254. title db appname,0               ; áâப  § £®«®¢ª 
  255.  
  256. inp_pos    dd inp_end-fn_input
  257. fn_input:
  258. ;   db '/hd/1/gif/smileys/sm100000.gif'
  259.    db '/sys/meos.gif'
  260. ;    db '/hd/1/1/tex256.gif',0
  261. ;    db '/rd/1/tex256.gif'
  262. inp_end:
  263.      rb 256-(inp_end-fn_input)
  264.  
  265. file_info:
  266.    dd 0
  267.    dd 0
  268.    dd 0
  269.    dd 0x100000;0x200000
  270.    dd workarea;0x100000
  271. I_END:  ; ª®­¥æ ¯à®£à ¬¬ë
  272. filename:
  273. ;   db '/hd/1/gif/smileys/sm112000.gif',0
  274. ;   db '/hd/1/gif/test.gif',0
  275. ;   db '/hd/1/gif/explode1.gif',0
  276. ;   db '/hd/1/gif/tapeta.gif',0
  277. ;   db '/hd/1/gif/meos.gif',0
  278.    rb 257
  279. ;filename_len dd 0
  280.  
  281. entered    rd 1
  282. sc system_colors
  283.  
  284. gif_img_count  rd 1
  285. cur_anim_delay rd 1
  286. img_index  rd 1
  287. gif_inf  GIF_info
  288.  
  289. IncludeUGlobals
  290.  
  291. workarea rb 0x100000
  292.  
  293. Image:
  294.