Subversion Repositories Kolibri OS

Rev

Rev 3424 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;*****************************************************************************
  2. ; Macro for use Color Dialog - for Kolibri OS
  3. ; Copyright (c) 2013, Marat Zakiyanov aka Mario79, aka Mario
  4. ; All rights reserved.
  5. ;
  6. ; Redistribution and use in source and binary forms, with or without
  7. ; modification, are permitted provided that the following conditions are met:
  8. ;        * Redistributions of source code must retain the above copyright
  9. ;          notice, this list of conditions and the following disclaimer.
  10. ;        * Redistributions in binary form must reproduce the above copyright
  11. ;          notice, this list of conditions and the following disclaimer in the
  12. ;          documentation and/or other materials provided with the distribution.
  13. ;        * Neither the name of the <organization> nor the
  14. ;          names of its contributors may be used to endorse or promote products
  15. ;          derived from this software without specific prior written permission.
  16. ;
  17. ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
  18. ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. ; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  21. ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. ;*****************************************************************************
  28. ;---------------------------------------------------------------------
  29. ;Some documentation for memory
  30. ;
  31. ;area name db 'FFFFFFFF_color_dialog',0 ; FFFFFFFF = PID
  32. ;
  33. ; communication area data
  34. ; flag  ; +0
  35. ; dw 0   ; 0 - empty, 1 - OK, color selected
  36. ;          2 - use another method/not found program, 3 - cancel
  37. ;
  38. ; type of dialog:  0-Palette&Tone
  39. ; dw 0 ; +2
  40. ;
  41. ; window X size ; +4
  42. ; dw 0
  43. ;
  44. ; window X position ; +6
  45. ; dw 0
  46. ;
  47. ; window y size ; +8
  48. ; dw 0
  49. ;
  50. ; window Y position ; +10
  51. ; dw 0
  52. ;
  53. ; ColorDialog WINDOW SLOT ; +12
  54. ; dd 0
  55. ;
  56. ; Color type ; +16
  57. ; dd 0
  58. ;
  59. ; Color value ; +20
  60. ; dd 0
  61. ;---------------------------------------------------------------------
  62. ;*****************************************************************************
  63. macro   ColorDialog_exit
  64. {
  65. popa
  66. ret 4
  67. }
  68. ;*****************************************************************************
  69. macro   use_ColorDialog
  70. {
  71. ColorDialog:
  72. cd_type                 equ dword [ebp] ; 0-Palette&Tone
  73. cd_procinfo             equ dword [ebp+4] ; Process info area for function 9
  74. cd_com_area_name        equ dword [ebp+8] ; Name for shared area
  75. cd_com_area             equ dword [ebp+12] ; Adress of shared area
  76. cd_start_path           equ dword [ebp+16] ; Location path to ColorDialog
  77. cd_draw_window          equ dword [ebp+20] ; Adress of procedure - draw_window
  78. cd_status               equ dword [ebp+24] ; 0-Cancel, 1-Get color OK, 2-Use alternatives
  79. cd_x_size               equ [ebp+28] ; Window X size
  80. cd_x_start              equ [ebp+30] ; Window X position
  81. cd_y_size               equ [ebp+32] ; Window y size
  82. cd_y_start              equ [ebp+34] ; Window Y position
  83. cd_color_type           equ [ebp+36] ; 0- RGB, 1 or other - reserved
  84. cd_color                equ [ebp+40] ; Selected color
  85. ;*****************************************************************************
  86. .init:
  87.         pusha
  88.         mov   ebp,dword [esp+36]
  89.         mcall   9,cd_procinfo,-1
  90.         mov     ebx,[ebx+30]
  91.         mov     edi,cd_com_area_name
  92.         add     edi,7
  93.         std
  94.         mov     ecx,4
  95. @@:
  96.         mov     al,bl
  97.         and     al,1111b
  98.         add     al,0x30
  99.         stosb
  100.         mov     al,bl
  101.         shr     al,4
  102.         and     al,1111b
  103.         add     al,0x30
  104.         stosb
  105.         shr     ebx,8
  106.         dec     ecx
  107.         jnz     @r
  108.         cld
  109.        
  110.         mcall   68,22,cd_com_area_name,4096,0x09
  111.         mov     cd_com_area,eax
  112.        
  113. ColorDialog_exit
  114. ;*****************************************************************************
  115. ;*****************************************************************************
  116. .start:
  117.         pusha
  118.         mov   ebp,dword [esp+36]
  119.        
  120.         mov     eax,cd_com_area
  121.         test    eax,eax
  122.         jz      .1
  123.         mov     ebx,cd_type
  124.         mov     [eax+2],bx
  125.        
  126.         mov     [eax],word 2    ; start ColorDialog
  127.  
  128.         pusha
  129.         mcall   9,cd_procinfo,-1
  130.  
  131.         mov     eax,[ebx+42] ;main window x size
  132.         shr     eax,1
  133.         add     eax,[ebx+34] ; main window x start
  134.         mov     cx,cd_x_size
  135.         shr     cx,1
  136.         sub     ax,cx
  137.         test    ax,cx
  138.         test    eax,0x8000
  139.         jz      @f
  140.         xor     eax,eax
  141. @@:
  142.         mov     cd_x_start,ax
  143.  
  144.         mov     eax,[ebx+46] ;main window y size
  145.         shr     eax,1
  146.         add     eax,[ebx+38] ; main window y start
  147.         mov     cx,cd_y_size
  148.         shr     cx,1
  149.         sub     ax,cx
  150.         test    eax,0x8000
  151.         jz      @f
  152.         xor     eax,eax
  153. @@:
  154.         mov     cd_y_start,ax
  155.         popa
  156.  
  157.         mov     ebx,dword cd_x_size
  158.         mov     [eax+4],ebx
  159.         mov     ebx,dword cd_y_size
  160.         mov     [eax+8],ebx
  161.        
  162. ;----------------------------------------------
  163.         mov     ebx,cd_procinfo
  164.         xor     eax,eax
  165.         mov     edi,ebx
  166.         mov     ecx,6
  167.         cld
  168.         rep     stosd
  169.         mov     [ebx],dword 7
  170.         mov     eax,cd_com_area_name
  171.         mov     [ebx+8],eax
  172.         mov     eax,cd_start_path
  173.         mov     [ebx+21],eax
  174.         mcall   70
  175.  
  176.         shr     eax,31
  177.         test    eax,eax
  178.         jnz     .1
  179. ;----------------------------------------------
  180. .still:
  181. ; The main window of application sometimes
  182. ; is not present the really. For this reason
  183. ; not use func 10 and 23, because event 1
  184. ; is not cleared without call of func 0.
  185. ; In this case is suitable only func 5 and 11,
  186. ; or 68.1 and 11 for better response.
  187.         mcall   68,1
  188.         mcall   5,10 ; because OS uses a new scheduler for kernel(SVN r.3534)
  189.         mcall   11
  190.         cmp     eax,1
  191.         je      .draw
  192.         cmp     eax,2
  193.         je      .key
  194.         cmp     eax,3
  195.         je      .button
  196.         jmp     .no_draw
  197. .key:
  198.         mcall   2
  199.         jmp     .no_draw
  200. .button:
  201.         mcall   17
  202.         jmp     .no_draw
  203. ;----------------------------------------------
  204. .draw:
  205.         pusha
  206.         call    cd_draw_window
  207.         popa
  208. ;----------------------------------------------
  209.         pusha
  210.         call    .prepare_PID
  211.         jz      @f
  212.  
  213.         mov     ecx,eax ; WINDOW SLOT
  214.         mcall   18,7
  215.         cmp     eax,ecx ; compare ACTIVE and WINDOW SLOT
  216.         jne     @f
  217.  
  218.         mov     eax,cd_com_area
  219.         mov     ecx,[eax+12]
  220.         test    ecx,ecx
  221.         jz      @f
  222.         mcall   18,3
  223. @@:
  224.         popa
  225. ;----------------------------------------------
  226. .no_draw:
  227.         mov     eax,cd_com_area
  228.         movzx   ebx,word [eax]
  229.         test    ebx,ebx
  230.         jz      .still
  231.         cmp     ebx,3
  232.         je      .2
  233.         cmp     ebx,1
  234.         jne     .still
  235. ;----------------------------------------------
  236. ; copy color type and value from shared area
  237.         mov     eax,cd_com_area
  238.         mov     ebx,[eax+16]
  239.         mov     cd_color_type,ebx
  240.         mov     ebx,[eax+20]
  241.         mov     cd_color,ebx
  242.  
  243.         mov     cd_status,1
  244. ;----------------------------------------------
  245.         jmp     .3
  246. .2:
  247.         mov     cd_status,0
  248.         jmp     .3
  249. .1:
  250.         mov     cd_status,2
  251. .3:
  252.         mov     eax,cd_com_area
  253.         mov     ebx,[eax+4]
  254.         mov     cd_x_size,ebx
  255.         mov     ebx,[eax+8]
  256.         mov     cd_y_size, ebx
  257.  
  258.         call    .prepare_PID
  259.         jz      @f
  260.         mov     ecx,eax ; WINDOW SLOT
  261.         mcall   18,3
  262. @@:
  263. ColorDialog_exit
  264. ;----------------------------------------------
  265. .prepare_PID:
  266.         mcall   9,cd_procinfo,-1
  267.         mov     ecx,[ebx+30]    ; PID
  268.         mcall   18,21
  269.         test    eax,eax
  270.         ret
  271. ;----------------------------------------------
  272. }
  273. ;*****************************************************************************