Subversion Repositories Kolibri OS

Rev

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

  1. ;   Picture browser by lisovin@26.ru
  2. ;   Modified by Ivan Poddubny - v.0.3
  3. ;   Modified by Diamond - v.0.4
  4. ;   Modified by Mario79 - v.0.5  18.07.08 Dinamic Allocation Memory
  5. ;   Compile with FASM for Menuet
  6.  
  7. ;******************************************************************************
  8.     use32
  9.     org    0x0
  10.     db     'MENUET01'              ; 8 byte id
  11.     dd     0x01                    ; header version
  12.     dd     START                   ; start of code
  13.     dd     IM_END                  ; size of image
  14.     dd     I_END ;0x300000                 ; memory for app
  15.     dd     I_END ;0x300000                 ; esp
  16.     dd     temp_area , 0x0         ; I_Param , I_Icon
  17.  
  18. include    'lang.inc'
  19. include    '..\..\..\macros.inc'
  20. ;include    'macros.inc'
  21. ;******************************************************************************
  22.  
  23. START:                          ; start of execution
  24.         mcall   68, 11
  25. ; check for parameters
  26.    cmp   dword [temp_area],'BOOT'
  27.    jne   .no_boot
  28.    call  load_image
  29.    call  convert
  30.    call  background
  31.    or    eax,-1
  32.    mcall
  33.  .no_boot:
  34.  
  35.    cmp   byte [temp_area],0
  36.    jz    .no_param
  37.    mov   edi,string      ; clear string
  38.    mov   ecx,256/4       ;   length of a string
  39.    xor   eax,eax         ;   symbol <0>
  40.    rep   stosd
  41.  
  42.    mov   edi,temp_area   ; look for <0> in temp_area
  43.    mov   esi,edi
  44.    mov   ecx,257         ;   strlen
  45.    repne scasb
  46.         lea     ecx, [edi-temp_area]
  47.  
  48.    mov   edi,string
  49.    rep   movsb           ; copy string from temp_area to "string" (filename)
  50.  
  51.    call  load_image
  52.    call  convert
  53.  
  54.  .no_param:
  55.  
  56.  
  57.    or  ecx,-1           ; get information about me
  58.    call getappinfo
  59.  
  60.    mov  edx,[process_info+30] ; ⥯¥àì ¢ edx ­ è ¨¤¥­â¨ä¨ª â®à
  61.    mov  ecx,eax
  62.  
  63.   @@:
  64.    call getappinfo
  65.    cmp  edx,[process_info+30]
  66.    je   @f  ; ¥á«¨ ­ è PID ᮢ¯ « á PID à áᬠâਢ ¥¬®£® ¯à®æ¥áá , ¬ë ­ è«¨ ᥡï
  67.    dec  ecx ; ¨­ ç¥ ᬮâਬ á«¥¤ãî騩 ¯à®æ¥áá
  68.    jne  @b  ; ¢®§¢à é ¥¬áï, ¥á«¨ ­¥ ¢á¥ ¯à®æ¥ááë à áᬮâ७ë
  69.   @@:
  70.  
  71. ; ⥯¥àì ¢ ecx ­®¬¥à ¯à®æ¥áá 
  72.     mov  [process],ecx
  73.  
  74. draw_still:
  75.     call draw_window
  76.  
  77. still:
  78.  
  79.     mov  eax,10                 ; wait here for event
  80.     mcall
  81.  
  82.         dec     eax
  83.         jz      red
  84.         dec     eax
  85.         jnz     button
  86.  
  87.   key:                          ; key
  88.     mov  al,2
  89.     mcall
  90.     mov  al,ah
  91.     cmp  al,6
  92.     je   kfile
  93.     cmp  al,15
  94.     je   kopen
  95.     cmp  al,9
  96.     je   kinfo
  97.     cmp  al,2
  98.     je   kbgrd
  99.     jmp  still
  100.  
  101.   red:
  102.         test    byte [status], 4
  103.         jz      draw_still
  104.         mov     al, 18
  105.         mov     ebx, 3
  106.         mov     ecx, [process]
  107.         mcall
  108.         and     byte [status], not 4
  109.         jmp     still
  110.  
  111.   button:                       ; button
  112.     mov  eax,17                 ; get id
  113.     mcall
  114.  
  115.     cmp  ah,1                   ; button id=1 ?
  116.     jne  noclose
  117.  
  118.     mov  eax,-1                 ; close this program
  119.     mcall
  120.   noclose:
  121.     cmp  ah,2
  122.     jne  nofile
  123.   kfile:
  124.         test    byte [status], 1
  125.         jnz     still
  126.         or      byte [status], 1
  127.     mov  eax,51
  128.     mov  ebx,1
  129.     mov  ecx,thread1
  130.     mov  edx,thread   ;0x29fff0
  131.     mcall
  132.     jmp  still
  133.   nofile:
  134.     cmp  ah,3
  135.     jne  noopen
  136.  
  137.  kopen:
  138.     mov ecx,-1
  139.     call getappinfo
  140.     mov eax,[image_file]
  141.     mov ebx,dword [eax+42]
  142.     mov ecx,dword [eax+46]
  143.     add ebx,10*65536-15
  144.     add ecx,50*65536-55
  145.     mov edx,0xffffff
  146.     mov eax,13
  147.     mcall
  148.  
  149.     call load_image
  150.  
  151.   open1:
  152.     mov eax,[image_file]
  153.     cmp [eax],word 'BM'
  154.     jne  still
  155.     call convert
  156.     call drawimage
  157.     jmp  still
  158.   noopen:
  159.  
  160.     cmp  ah,4
  161.     jne  noinfo
  162.   kinfo:
  163.         test    byte [status], 2
  164.         jnz     still
  165.         or      byte [status], 2
  166.     mov  eax,51
  167.     mov  ebx,1
  168.     mov  ecx,thread2
  169.     mov  edx,thread-512  ;0x2afff0
  170.     mcall
  171.     jmp  still
  172.   noinfo:
  173.  
  174. ; “‘’€Ž‚ˆ’œ ”Ž
  175.     cmp  ah,5
  176.     jne  still
  177.   kbgrd:
  178.         test    byte [status], 8
  179.         jnz     still
  180.         or      byte [status], 8
  181.     mov  eax,51
  182.     mov  ebx,1
  183.     mov  ecx,thread3
  184.     mov  edx,thread-512*2  ;0x2bfff0
  185.     mcall
  186.     jmp  still
  187.     ;call background
  188.  
  189.  getappinfo:
  190.     mov  eax,9
  191.     mov  ebx,process_info
  192.     mcall
  193.     ret
  194.  
  195.  
  196. load_image:
  197.           mov   [fileinfo+0],dword 5
  198.           mov   [fileinfo+12],dword 0
  199.           mov   [fileinfo+16],dword process_info
  200.  
  201.     cmp  [image_file],0
  202.     je    @f
  203.     mov   ecx,[image_file]
  204.      mcall 68, 13,
  205.  
  206. @@:
  207.           mcall 70, fileinfo
  208.  
  209.           mov   [fileinfo+0],dword 0
  210.           mov   [fileinfo+12],dword 512
  211.           mov   [fileinfo+16],dword process_info+40
  212.  
  213.           mcall 70, fileinfo
  214.  
  215.           mov   ecx,[process_info+32]
  216.           mov   [fileinfo+12],ecx
  217.  
  218.     mov  eax,[process_info+40+28]
  219.  
  220.         cmp     eax, 24
  221.         jz      .convert24
  222.         cmp     eax, 8
  223.         jz      .convert8
  224.         cmp     eax, 4
  225.         jz      .convert4
  226.      shl  ecx,2
  227. .convert4:
  228.      shl  ecx,1
  229. .convert8:
  230.      lea  ecx,[ecx*3]
  231. .convert24:
  232.      shl  ecx,1
  233. @@:
  234.  
  235.           mcall 68, 12
  236.  
  237.  
  238.           mov   [fileinfo+16],eax
  239.           mov   [image_file],eax
  240.  
  241.           mcall 70, fileinfo
  242.  
  243.     mov  eax,[image_file]
  244.     mov  ebx,[eax+22]
  245.     mov  eax,[eax+18]
  246.         test    ebx, ebx
  247.         jns     @f
  248.         neg     ebx
  249. @@:
  250.     add  eax,20
  251.     cmp  eax,210
  252.     jae  @f
  253.     mov  eax,210
  254. @@:
  255.     add  ebx,58
  256.     cmp  ebx,56
  257.     jae  @f
  258.     mov  ebx,56
  259. @@:
  260.     mov  [wnd_width],eax
  261.     mov  [wnd_height],ebx
  262.     test [bWasDraw],1
  263.     jz   @f
  264.     mov  esi,ebx
  265.     mov  edx,eax
  266.     mcall 67,-1,-1
  267. @@:
  268.     ret
  269.  
  270.  
  271.   drawimage:
  272.     mov  eax,[image_file]
  273.     cmp  [eax],word 'BM'
  274.     jne  nodrawimage
  275.         mov     ecx, dword [eax+18-2]
  276.         mov     cx, [eax+22]
  277.         test    cx, cx
  278.         jns     @f
  279.         neg     cx
  280. @@:
  281.     mov  edx,10*65536+50
  282.     mcall 7,[soi]
  283.   nodrawimage:
  284.     ret
  285.  
  286. ; “‘’€Ž‚ˆ’œ ”Ž
  287.   background:
  288.     mov  eax,[image_file]
  289.     cmp  [eax],word 'BM'
  290.     jne  @f
  291.     mov  ecx,[eax+18] ; è¨à¨­ 
  292.     mov  edx,[eax+22] ; ¢ëá®â 
  293.     mcall 15,1
  294.  
  295.     mov  esi, ecx
  296.     imul esi, edx
  297.         lea     esi, [esi+esi*2]
  298.     mov  ebx,5
  299.     mov  ecx,[soi]
  300.     xor  edx,edx
  301. ;;;    mov  esi, ;640*480*3
  302.     mcall
  303.  
  304.     dec  ebx    ;tile/stretch
  305.     mov  ecx,dword [bgrmode]
  306.     mcall
  307.  
  308.     dec  ebx
  309.     mcall
  310.    @@:
  311.     ret
  312.  
  313. convert:
  314.         mov     ecx, [image_file]  ;I_END
  315.         add     ecx, [ecx+2]
  316.         mov     [soi], ecx
  317.         mov     eax,[image_file]
  318.         mov     ebp, [eax+18]
  319.         lea     ebp, [ebp*3]    ; ebp = size of output scanline
  320.         mov     eax, [eax+22]
  321.         dec     eax
  322.         mul     ebp
  323.         add     eax, ecx
  324.         mov     edi, eax        ; edi points to last scanline
  325.         mov     esi, [image_file]  ;I_END
  326.         add     esi, [esi+10]
  327. ;        mov     ebx, I_END+54
  328.         mov     ebx,[image_file]
  329.         mov     edx, [ebx+22]
  330.         add     ebx,54
  331.         lea     eax, [ebp*2]
  332.         mov     [delta], eax
  333.         test    edx, edx
  334.         jz      .ret
  335.         jns     @f
  336.         neg     edx
  337.         and     [delta], 0
  338.         mov     edi, ecx
  339. @@:
  340. ;        movzx   eax, word [I_END+28]
  341.         mov     eax,[image_file]
  342.         movzx   eax,word [eax+28]
  343.         cmp     eax, 24
  344.         jz      convert24
  345.         cmp     eax, 8
  346.         jz      convert8
  347.         cmp     eax, 4
  348.         jz      convert4
  349.         dec     eax
  350.         jz      convert1
  351. .ret:
  352.         ret
  353. convert24:
  354.         mov     ecx, ebp
  355.         rep     movsb
  356.         sub     edi, [delta]
  357.         mov     eax, ebp
  358.         neg     eax
  359.         and     eax, 3
  360.         add     esi, eax
  361.         dec     edx
  362.         jnz     convert24
  363.         ret
  364. convert8:
  365.         push    edi
  366.         add     [esp], ebp
  367. .loopi:
  368.         xor     eax, eax
  369.         lodsb
  370. ;        cmp     dword [I_END+30], 1
  371.         push    eax
  372.         mov     eax,[image_file]
  373.         cmp     dword [eax+30],1
  374.         pop     eax
  375.         jnz     .nocompressed
  376. .compressed:
  377.         mov     ecx, eax
  378.         jecxz   .special
  379.         lodsb
  380.         mov     eax, [ebx+eax*4]
  381. @@:
  382.         call    putpixel
  383.         loop    @b
  384.         jmp     .loopi
  385. .nocompressed:
  386.         mov     eax, [ebx+eax*4]
  387.         call    putpixel
  388. .loopicont:
  389.         cmp     edi, [esp]
  390.         jnz     .loopi
  391. .next:
  392.         pop     edi
  393.         sub     edi, [delta]
  394.         mov     eax, ebp
  395.         and     eax, 3
  396.         add     esi, eax
  397.         dec     edx
  398.         jnz     convert8
  399.         ret
  400. .special:
  401.         lodsb
  402.         test    al, al
  403.         jz      .next
  404.         cmp     al, 2
  405.         jbe     .end
  406.         mov     ecx, eax
  407.         push    ecx
  408. @@:
  409.         xor     eax, eax
  410.         lodsb
  411.         mov     eax, [ebx+eax*4]
  412.         call    putpixel
  413.         loop    @b
  414.         pop     ecx
  415.         and     ecx, 1
  416.         add     esi, ecx
  417.         jmp     .loopi
  418. .end:
  419.         pop     edi
  420.         ret
  421. convert4:
  422.         push    edi
  423.         add     [esp], ebp
  424. .loopi:
  425.         xor     eax, eax
  426.         lodsb
  427.         shr     eax, 4
  428.         mov     eax, [ebx+eax*4]
  429.         call    putpixel
  430.         cmp     edi, [esp]
  431.         jz      .loopidone
  432.         mov     al, [esi-1]
  433.         and     eax, 0xF
  434.         mov     eax, [ebx+eax*4]
  435.         stosd
  436.         dec     edi
  437.         cmp     edi, [esp]
  438.         jnz     .loopi
  439. .loopidone:
  440.         pop     edi
  441.         sub     edi, [delta]
  442.         call    align_input
  443.         dec     edx
  444.         jnz     convert4
  445.         ret
  446. convert1:
  447.         push    edi
  448.         add     [esp], ebp
  449. .loopi:
  450.         lodsb
  451.         mov     ecx, 8
  452. .loopii:
  453.         add     al, al
  454.         push    eax
  455.         setc    al
  456.         movzx   eax, al
  457.         mov     eax, [ebx+eax*4]
  458.         call    putpixel
  459.         pop     eax
  460.         cmp     edi, [esp]
  461.         loopnz  .loopii
  462.         jnz     .loopi
  463.         pop     edi
  464.         sub     edi, [delta]
  465.         call    align_input
  466.         dec     edx
  467.         jnz     convert1
  468.         ret
  469.  
  470. align_input:
  471.         push    esi
  472.         push    eax
  473.         mov     eax,[image_file]
  474.         sub     esi,eax    ;I_END
  475.         sub     esi,[eax+10]
  476.         pop     eax
  477.         neg     esi
  478.         and     esi, 3
  479.         add     [esp], esi
  480.         pop     esi
  481.         ret
  482.  
  483. putpixel:
  484.         push    eax
  485.         stosw
  486.         shr     eax, 16
  487.         stosb
  488.         pop     eax
  489.         ret
  490.  
  491. ;   *********************************************
  492. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  493. ;   *********************************************
  494.  
  495.  
  496. draw_window:
  497.     or   [bWasDraw],1
  498.  
  499.     mov  eax,12                    ; function 12:tell os about windowdraw
  500.     mov  ebx,1                     ; 1, start of draw
  501.     mcall
  502.  
  503.                                    ; DRAW WINDOW
  504.     xor  eax,eax                   ; function 0 : define and draw window
  505. ;    mov  ebx,350                   ; [x start] *65536 + [x size]
  506. ;    mov  ecx,400                   ; [y start] *65536 + [y size]
  507.     mov  ebx,0*65536
  508.     mov  ecx,0*65536
  509.     add  ebx,[wnd_width]
  510.     add  ecx,[wnd_height]
  511.     mov  edx,0x03ffffff            ; color of work area RRGGBB,8->color gl
  512.     mcall
  513.  
  514.     mov  eax,8
  515.     mov  ebx,10*65536+46
  516.     mov  ecx,25*65536+20
  517.     mov  edx,2
  518.     mov  esi,0x780078
  519.   newbutton:
  520.     mcall
  521.     add  ebx,48*65536
  522.     inc  edx
  523.     cmp  edx,6
  524.     jb   newbutton
  525.  
  526.                                    ; WINDOW LABEL
  527.     mov  eax,4                     ; function 4 : write text to window
  528.     mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
  529.     mov  ecx,0x10ddeeff            ; font 1 & color ( 0xF0RRGGBB )
  530.     mov  edx,labelt                ; pointer to text beginning
  531.     mov  esi,12                    ; text length
  532.     mcall
  533.  
  534.     mov  ebx,14*65536+32
  535.     mov  edx,buttext
  536.     mov  esi,26
  537.     mcall
  538.  
  539.     call drawimage
  540.  
  541.     mov  eax,12                    ; function 12:tell os about windowdraw
  542.     mov  ebx,2                     ; 2, end of draw
  543.     mcall
  544.  
  545.     ret
  546.  
  547.  
  548. ; DATA AREA
  549.  
  550. labelt:
  551.          db 'MeView v.0.4'
  552.  
  553. lsz buttext,\
  554.     en,   ' FILE   OPEN   INFO   BGRD',\
  555.     ru,   ' ”€‰‹  Ž’Š   ˆ”Ž   ”Ž  ',\
  556.     de,   'DATEI OEFNEN  INFO   HGRD'
  557.  
  558. thread1:                        ; start of thread1
  559.  
  560.      call draw_window1
  561.  
  562. still1:
  563.  
  564.     mov  eax,10                 ; wait here for event
  565.     mcall
  566.  
  567.     cmp  eax,1                  ; redraw request ?
  568.     je   thread1
  569.     cmp  eax,2                  ; key in buffer ?
  570.     je   key1
  571.     cmp  eax,3                  ; button in buffer ?
  572.     je   button1
  573.  
  574.     jmp  still1
  575.  
  576.   key1:                         ; key
  577.     mcall
  578.     cmp  ah,179
  579.     jne  noright
  580.     mov  eax,[pos]
  581.     cmp  eax,41
  582.     ja   still1
  583.     inc  eax
  584.     mov  [pos],eax
  585.     call drawstring
  586.     jmp  still1
  587.   noright:
  588.     cmp  ah,176
  589.     jne  noleft
  590.     mov  eax,[pos]
  591.     test eax,eax
  592.     je   still1
  593.     dec  eax
  594.     mov  [pos],eax
  595.     call drawstring
  596.     jmp  still1
  597.   noleft:
  598.     cmp  ah,182        ;del
  599.     jne  nodelet
  600.     call shiftback
  601.     call drawstring
  602.     jmp  still1
  603.   nodelet:
  604.     cmp  ah,8          ;zaboy
  605.     jne  noback
  606.     mov  eax,[pos]
  607.     test eax,eax
  608.     je   still1
  609.     dec  eax
  610.     mov  [pos],eax
  611.     call shiftback
  612.     call drawstring
  613.     jmp  still1
  614.   noback:
  615.     cmp  ah,13
  616.     jne  noenter
  617.   enter1:
  618.     mov  al,byte ' '
  619.     mov  edi,string
  620.     mov  ecx,43
  621.     cld
  622.     repne scasb
  623.     dec  edi
  624.     mov  byte [edi],0
  625.     jmp  close1
  626.   noenter:
  627.     cmp  ah,27
  628.     jne  noesc
  629.     jmp  enter1
  630.   noesc:
  631.     cmp  dword [pos],42
  632.     jae  still1
  633.  
  634.     mov  edi,string
  635.     add  edi,42
  636.     mov  esi,edi
  637.     dec  esi
  638.     mov  ecx,42
  639.     sub  ecx,[pos]
  640.     std
  641.     rep  movsb
  642.  
  643.     shr  eax,8
  644.     mov  esi,string
  645.     add  esi,[pos]
  646.     mov  byte [esi],al
  647.     inc  dword [pos]
  648.     call drawstring
  649.  
  650.     jmp  still1
  651.  
  652.   button1:                      ; button
  653.     mov  eax,17                 ; get id
  654.     mcall
  655.  
  656.     cmp  ah,1                   ; button id=1 ?
  657.     jne  noclose1
  658.     jmp  enter1
  659.   close1:
  660.     bts  dword [status],2
  661.     btr  dword [status],0
  662.     mov  eax,-1                 ; close this program
  663.     mcall
  664.   noclose1:
  665.     cmp  ah,2
  666.     jne  nosetcur
  667.     mov  eax,37
  668.     mov  ebx,1
  669.     mcall
  670.     shr  eax,16
  671.     sub  eax,21
  672.     xor  edx,edx
  673.     mov  ebx,6
  674.     div  ebx
  675.     mov  [pos],eax
  676.     call drawstring
  677.     jmp  still1
  678.   nosetcur:
  679.     jmp  still1
  680.  
  681.  
  682.   shiftback:
  683.     mov  edi,string
  684.     add  edi,[pos]
  685.     mov  esi,edi
  686.     inc  esi
  687.     mov  ecx,43
  688.     sub  ecx,[pos]
  689.     cld
  690.     rep movsb
  691.     ret
  692.  
  693. ;   *********************************************
  694. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  695. ;   *********************************************
  696.  
  697.  
  698. draw_window1:
  699.  
  700.  
  701.     mov  eax,12                    ; function 12:tell os about windowdraw
  702.     mov  ebx,1                     ; 1, start of draw
  703.     mcall
  704.  
  705.                                    ; DRAW WINDOW
  706.     xor  eax,eax                   ; function 0 : define and draw window
  707.     mov  ebx,100*65536+300         ; [x start] *65536 + [x size]
  708.     mov  ecx,100*65536+80          ; [y start] *65536 + [y size]
  709.     mov  edx,0x03780078            ; color of work area RRGGBB,8->color gl
  710.     mcall
  711.  
  712.                                    ; WINDOW LABEL
  713.     mov  eax,4                     ; function 4 : write text to window
  714.     mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
  715.     mov  ecx,0x10ddeeff            ; font 1 & color ( 0xF0RRGGBB )
  716.     mov  edx,labelt1               ; pointer to text beginning
  717.     mov  esi,labelt1.size          ; text length
  718.     mcall
  719.  
  720.     call drawstring
  721.  
  722.     mov  eax,12                    ; function 12:tell os about windowdraw
  723.     mov  ebx,2                     ; 2, end of draw
  724.     mcall
  725.  
  726.     ret
  727.  
  728.  drawstring:
  729.     pusha
  730.     mov  eax,8             ;invisible button
  731.     mov  ebx,21*65536+258
  732.     mov  ecx,40*65536+15
  733.     mov  edx,0x60000002
  734.     mcall
  735.  
  736.     mov  eax,13             ;bar
  737.     mov  edx,0xe0e0e0
  738.     mcall
  739.     push eax                ;cursor
  740.     mov  eax,6*65536
  741.     mul  dword [pos]
  742.     add  eax,21*65536+6
  743.     mov  ebx,eax
  744.     pop  eax
  745.     mov  edx,0x6a73d0
  746.     mcall
  747.     mov  eax,4              ;path
  748.     mov  ebx,21*65536+44
  749.     xor  ecx,ecx
  750.     mov  edx,string
  751.     mov  esi,43
  752.     mcall
  753.  
  754.  
  755.     popa
  756.     ret
  757.  
  758. ; DATA AREA
  759.  
  760. lsz labelt1,\
  761.    en,  'File',\
  762.    ru,  '” ©«',\
  763.    de,  'Datei'
  764.  
  765. thread2:                          ; start of info thread
  766.  
  767.      call draw_window2
  768.  
  769. still2:
  770.  
  771.     mov  eax,10                 ; wait here for event
  772.     mcall
  773.  
  774.     cmp  eax,1                  ; redraw request ?
  775.     je   thread2
  776.     cmp  eax,2                  ; key in buffer ?
  777.     je   close2
  778.     cmp  eax,3                  ; button in buffer ?
  779.     je   button2
  780.  
  781.     jmp  still2
  782.  
  783.   button2:                       ; button
  784.     mov  eax,17                 ; get id
  785.     mcall
  786.  
  787.     cmp  ah,1                   ; button id=1 ?
  788.     jne  noclose2
  789.   close2:
  790.     btr dword [status],1
  791.     bts dword [status],2
  792.     mov  eax,-1                 ; close this program
  793.     mcall
  794.   noclose2:
  795.  
  796.     jmp  still2
  797.  
  798.  
  799.  
  800.  
  801. ;   *********************************************
  802. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  803. ;   *********************************************
  804.  
  805.  
  806. draw_window2:
  807.  
  808.  
  809.     mov  eax,12                    ; function 12:tell os about windowdraw
  810.     mov  ebx,1                     ; 1, start of draw
  811.     mcall
  812.  
  813.                                    ; DRAW WINDOW
  814.     xor  eax,eax                   ; function 0 : define and draw window
  815.     mov  ebx,100*65536+330         ; [x start] *65536 + [x size]
  816.     mov  ecx,100*65536+90          ; [y start] *65536 + [y size]
  817.     mov  edx,0x03780078            ; color of work area RRGGBB,8->color gl
  818.     mcall
  819.  
  820.                                    ; WINDOW LABEL
  821.     mov  eax,4                     ; function 4 : write text to window
  822.     mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
  823.     mov  ecx,0x10ddeeff            ; font 1 & color ( 0xF0RRGGBB )
  824.     mov  edx,labelt2               ; pointer to text beginning
  825.     mov  esi,labelt2.size          ; text length
  826.     mcall
  827.  
  828.     mov  ebx,10*65536+30
  829.     mov  edx,string
  830.     mov  esi,43
  831.     mcall
  832.     mov  edx,fitext
  833.     mov  esi,14
  834.     add  ebx,70*65536+10
  835.  followstring:
  836.     mcall
  837.     add  ebx,10
  838.     add  edx,esi
  839.     cmp  ebx,80*65536+70
  840.     jbe  followstring
  841.     mov  eax,47
  842.     mov  edx,200*65536+40
  843.     mov  esi,ecx
  844.     mov  ecx,[image_file]
  845.     push ecx
  846.     mov  ecx, [ecx+2]
  847.     call digitcorrect
  848.     mcall
  849.     add  edx,10
  850.     pop  ecx
  851.     push ecx
  852.     mov  ecx, [ecx+18]
  853.     call digitcorrect
  854.     mcall
  855.     add  edx,10
  856.     pop  ecx
  857.     push ecx
  858.     mov  ecx, [ecx+22]
  859.     call digitcorrect
  860.     mcall
  861.     add  edx,10
  862.     pop  ecx
  863.     movzx ecx,word [ecx+28]
  864.     call digitcorrect
  865.     mcall
  866.  
  867.     mov  eax,12                    ; function 12:tell os about windowdraw
  868.     mov  ebx,2                     ; 2, end of draw
  869.     mcall
  870.  
  871.     ret
  872.  
  873.  digitcorrect:
  874.     xor  ebx,ebx
  875.     mov  bh,6
  876.     cmp  ecx,99999
  877.     ja   c_end
  878.     dec  bh
  879.     cmp  ecx,9999
  880.     ja   c_end
  881.     dec  bh
  882.     cmp  ecx,999
  883.     ja   c_end
  884.     dec  bh
  885.     cmp  ecx,99
  886.     ja   c_end
  887.     dec  bh
  888.     cmp  ecx,9
  889.     ja   c_end
  890.     dec  bh
  891.  c_end:
  892.     bswap ebx
  893.     ret
  894.  
  895.  
  896. ; DATA AREA
  897.  
  898. lsz labelt2,\
  899.     en,   'File info',\
  900.     ru,   'ˆ­ä®à¬ æ¨ï ® ä ©«¥',\
  901.     de,   'Dateiinfo'
  902.  
  903. lsz fitext,\
  904.      en, 'FILE SIZE     ',\
  905.      en, 'X SIZE        ',\
  906.      en, 'Y SIZE        ',\
  907.      en, 'BITS PER PIXEL',\
  908.                           \
  909.      ru, ' §¬¥à ä ©«   ',\
  910.      ru, '˜¨à¨­         ',\
  911.      ru, '‚ëá®â         ',\
  912.      ru, '¨â ­  ¯¨ªá¥« ',\
  913.                           \
  914.      de, 'FATEIGROESSE  ',\
  915.      de, 'X GROESSE     ',\
  916.      de, 'Y GROESSE     ',\
  917.      de, 'BITS PER PIXEL'
  918.  
  919. thread3:                          ; start of bgrd thread
  920.  
  921.      call draw_window3
  922.  
  923. still3:
  924.  
  925.     mov  eax,10                 ; wait here for event
  926.     mcall
  927.  
  928.     cmp  eax,1                  ; redraw request ?
  929.     je   thread3
  930.     cmp  eax,2                  ; key in buffer ?
  931.     je   key3
  932.     cmp  eax,3                  ; button in buffer ?
  933.     je   button3
  934.  
  935.     jmp  still3
  936.  
  937.   key3:
  938.     mcall
  939.     cmp  ah,27
  940.     je   close3
  941.     cmp  ah,13
  942.     je   kok
  943.     cmp  ah,178 ;up
  944.     jne  nofup
  945.     cmp  dword [bgrmode],1
  946.     je   fdn
  947.   fup:
  948.     dec dword [bgrmode]
  949.     jmp  flagcont
  950.   nofup:
  951.     cmp  ah,177 ;down
  952.     jne  still3
  953.     cmp dword [bgrmode],2
  954.     je   fup
  955.   fdn:
  956.     inc dword [bgrmode]
  957.     jmp  flagcont
  958.  
  959.  
  960.   button3:                       ; button
  961.     mov  eax,17                 ; get id
  962.     mcall
  963.  
  964.     cmp  ah,1                   ; button id=1 ?
  965.     jne  noclose3
  966.   close3:
  967.     btr dword [status],3
  968.     bts dword [status],2
  969.     mov  eax,-1                 ; close this program
  970.     mcall
  971.   noclose3:
  972.     cmp  ah,4
  973.     jne  nook
  974.    kok:
  975.     call background
  976.     jmp  close3
  977.   nook:
  978.     cmp  ah,2
  979.     jb   still3
  980.     cmp  ah,3
  981.     ja   still3
  982.     dec  ah
  983.     mov byte [bgrmode],ah
  984.    flagcont:
  985.     call drawflags
  986.     jmp  still3
  987.  
  988.  
  989.  
  990.  
  991. ;   *********************************************
  992. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  993. ;   *********************************************
  994.  
  995.  
  996. draw_window3:
  997.  
  998.  
  999.     mov  eax,12                    ; function 12:tell os about windowdraw
  1000.     mov  ebx,1                     ; 1, start of draw
  1001.     mcall
  1002.  
  1003.                                    ; DRAW WINDOW
  1004.     xor  eax,eax                   ; function 0 : define and draw window
  1005.     mov  ebx,100*65536+200         ; [x start] *65536 + [x size]
  1006.     mov  ecx,100*65536+100         ; [y start] *65536 + [y size]
  1007.     mov  edx,0x03780078            ; color of work area RRGGBB,8->color gl
  1008.     mcall
  1009.  
  1010.     mov  eax,8
  1011.     mov  ebx,70*65536+40
  1012.     mov  ecx,70*65536+20
  1013.     mov  edx,4
  1014.     mov  esi,0xac0000
  1015.     mcall
  1016.  
  1017.                                    ; WINDOW LABEL
  1018.     mov  eax,4                     ; function 4 : write text to window
  1019.     mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
  1020.     mov  ecx,0x10ddeeff            ; font 1 & color ( 0xF0RRGGBB )
  1021.     mov  edx,labelt3               ; pointer to text beginning
  1022.     mov  esi,labelt3.size          ; text length
  1023.     mcall
  1024.     add  ebx,38*65536+20
  1025.     mov  ecx,0xddeeff
  1026.     mov  edx, bgrdtext
  1027.     mov  esi, bgrdtext.size
  1028.     mcall
  1029.     add  ebx,40*65536+15
  1030.     mov  edx, tiled
  1031.     mov  esi, tiled.size
  1032.     mcall
  1033.     add  ebx,15
  1034.     mov  edx, stretch
  1035.     mov  esi, stretch.size ;7
  1036.     mcall
  1037.     add  ebx,18
  1038.     mov  edx, ok_btn
  1039.     mov  esi, ok_btn.size ;2
  1040.     mcall
  1041.  
  1042.     call drawflags
  1043.  
  1044.     mov  eax,12                    ; function 12:tell os about windowdraw
  1045.     mov  ebx,2                     ; 2, end of draw
  1046.     mcall
  1047.  
  1048.     ret
  1049.  
  1050.  drawflags:
  1051.     mov  eax,8
  1052.     mov  ebx,70*65536+10
  1053.     mov  ecx,40*65536+10
  1054.     mov  edx,2
  1055.     mov  esi,0xe0e0e0
  1056.     mcall
  1057.     add  ecx,15*65536
  1058.     inc  edx
  1059.     mcall
  1060.     mov  eax,4
  1061.     mov  ebx,73*65536+42
  1062.     xor  ecx,ecx
  1063.     mov  edx,vflag
  1064.     mov  esi,1
  1065.     cmp  dword [bgrmode],1
  1066.     je   nodownflag
  1067.     add  ebx,15
  1068.  nodownflag:
  1069.     mcall
  1070.     ret
  1071.  
  1072.  
  1073. ; DATA AREA
  1074. status   dd 0  ;bit0=1 if file thread is created
  1075. soi      dd 0
  1076. delta   dd      0
  1077. process  dd 0
  1078.  
  1079. bWasDraw db 0
  1080. vflag: db 'x'
  1081. bgrmode: dd 1
  1082.  
  1083. wnd_width dd 210
  1084. wnd_height dd 53
  1085.  
  1086. lsz labelt3,\
  1087.     en,   'Background set',\
  1088.     ru,   "“áâ ­®¢ª  ä®­ ",\
  1089.     de,   'Hintergrund gesetzt'
  1090.  
  1091. lsz bgrdtext,\
  1092.     en, 'SET AS BACKGROUND:',\
  1093.     ru, '’¨¯ ®¡®¥¢:',\
  1094.     de, 'ALS HINTERGRUND'
  1095.  
  1096. lsz tiled,\
  1097.     en, 'TILED',\
  1098.     ru, '§ ¬®áâ¨âì',\
  1099.     de, 'GEKACHELT'
  1100.  
  1101. lsz stretch,\
  1102.     en, 'STRETCH',\
  1103.     ru, 'à áâï­ãâì',\
  1104.     de, 'GESTRECKT'
  1105.  
  1106. lsz ok_btn,\
  1107.     en, 'Ok',\
  1108.     ru, 'Ok',\
  1109.     de, 'Ok'
  1110.  
  1111. image_file dd 0
  1112. ;image_file_size dd 0
  1113.  
  1114. pos: dd 6
  1115.  
  1116. ;fileinfo:
  1117. ;     dd 0
  1118. ;     dd 0
  1119. ;     dd 0
  1120. ;     dd 0x290000-I_END
  1121. ;     dd I_END
  1122.  
  1123. fileinfo:
  1124.      dd 5
  1125.      dd 0
  1126.      dd 0
  1127.      dd 0               ;x290000-I_END
  1128.      dd process_info    ;I_END
  1129. string:
  1130.         db      '/sys/bgr.bmp',0
  1131.  
  1132. IM_END:
  1133.         rb      string+257-$
  1134.  
  1135. process_info:
  1136. temp_area:
  1137. rb 1024*4
  1138. rb 1024*2
  1139. ;rb 0x10000
  1140. thread:
  1141. rb 512
  1142. I_END:
  1143.