Subversion Repositories Kolibri OS

Rev

Rev 3427 | Rev 3469 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;*****************************************************************************
  2. ; 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.   use32
  63.   org    0x0
  64.  
  65.   db     'MENUET01'
  66.   dd     0x01
  67.   dd     START
  68.   dd     IM_END
  69.   dd     I_END
  70.   dd     stacktop
  71.   dd     param
  72.   dd     0x0
  73. ;---------------------------------------------------------------------
  74. include '../../macros.inc'
  75. ;include 'lang.inc'
  76. ;include 'debug.inc'
  77. ;---------------------------------------------------------------------
  78. p_start_x = 10
  79. p_start_y = 10
  80.  
  81. p_size_x = 20
  82. p_size_y = 256
  83. ;--------------------------------------
  84. t_start_x = 40
  85. t_start_y = 10
  86. ;--------------------------------------
  87. w_start_x = 200
  88. w_start_y = 200
  89.  
  90. w_size_x = 400
  91. w_size_y = 350
  92. ;--------------------------------------
  93. c_start_x = t_start_x + p_size_y + 10
  94. c_start_y = 10
  95.  
  96. c_size_x = 40
  97. c_size_y = 20
  98. ;---------------------------------------------------------------------
  99. x_minimal_size equ 350
  100. y_minimal_size equ 250
  101. ;---------------------------------------------------------------------
  102. START:
  103.         mcall   68,11
  104.         mcall   66,1,1
  105.         mcall   40,0x27
  106.         call    get_communication_area
  107.        
  108.         call    get_active_pocess
  109.  
  110.         xor     eax,eax
  111.         mov     al,p_size_x
  112.         mov     [palette_SIZE_X],eax
  113.         mov     ax,p_size_y
  114.         mov     [palette_SIZE_Y],eax
  115.         mov     [tone_SIZE_X],eax
  116.         mov     [tone_SIZE_Y],eax
  117.         mov     eax,0xff0000
  118.         mov     [tone_color],eax
  119.         mov     [selected_color],eax
  120. ;--------------------------------------
  121.         mov     ecx,[palette_SIZE_Y]
  122.         imul    ecx,[palette_SIZE_X]
  123.         lea     ecx,[ecx*3]
  124.         inc     ecx     ;reserve for stosd
  125.         mcall   68,12
  126.         mov     [palette_area],eax
  127. ;--------------------------------------
  128.         call    create_palette
  129. ;--------------------------------------
  130.         mov     ecx,[tone_SIZE_Y]
  131.         imul    ecx,[tone_SIZE_X]
  132.         lea     ecx,[ecx*3]
  133.         inc     ecx     ;reserve for stosd
  134.         mcall   68,12
  135.         mov     [tone_area],eax
  136. ;--------------------------------------
  137.         call    create_tone
  138. ;---------------------------------------------------------------------
  139. align 4
  140. red:
  141.         call    draw_window
  142. ;---------------------------------------------------------------------
  143. align 4
  144. still:
  145.         mcall   10
  146.  
  147.         cmp     eax,1
  148.         je      red
  149.  
  150.         cmp     eax,2
  151.         je      key
  152.  
  153.         cmp     eax,3
  154.         jne     still
  155. ;---------------------------------------------------------------------
  156. align 4
  157. button:
  158.         mcall   17
  159.  
  160.         cmp     ah, 2
  161.         je      palette_button
  162.        
  163.         cmp     ah, 3
  164.         je      tone_button
  165.  
  166.         cmp     ah, 4
  167.         je      color_button
  168.        
  169.         cmp     ah, 1
  170.         jne     still
  171.  
  172. .exit:
  173.         mov     eax,[communication_area]
  174.         mov     [eax],word 3
  175. ; dps "CD flag value: cancel "
  176.  
  177. .exit_1:
  178.  
  179.         mov     ax,[eax]
  180.         and     eax,0xffff
  181. ; dps "CD flag value: "
  182. ; dpd eax
  183. ; newline
  184.  
  185.         call    get_window_param
  186.         mov     ebx,[communication_area]
  187.         mov     ecx,procinfo
  188. ;       mov     eax,[window_x]
  189.         mov     eax,[ecx+34]
  190.         shl     eax,16
  191.         add     eax,[ecx+42]
  192.         mov     [ebx+4],eax
  193. ;       mov     eax,[window_y]
  194.         mov     eax,[ecx+38]
  195.         shl     eax,16
  196.         add     eax,[ecx+46]
  197.         mov     [ebx+8],eax
  198.  
  199.         mcall   -1
  200. ;---------------------------------------------------------------------
  201. get_window_param:
  202.         mcall   9,procinfo,-1
  203.         mov     eax,[ebx+66]
  204.         inc     eax
  205. ;       mov     [window_high],eax
  206.         mov     eax,[ebx+62]
  207.         inc     eax
  208. ;       mov     [window_width],eax
  209.         mov     eax,[ebx+70]
  210. ;       mov     [window_status],eax
  211.         ret
  212. ;---------------------------------------------------------------------
  213. align 4
  214. get_communication_area:
  215.         xor     eax,eax
  216.         mov     al,[param]
  217.         test    eax,eax
  218.         jz      @f
  219.         mcall   68,22,param,,0x01
  220.         mov     [communication_area],eax
  221. ;       movzx   ebx,word [eax+2]
  222. ;       mov     [color_dialog_type],ebx
  223.  
  224.         mov     ebx,[eax+4]
  225.         cmp     bx,word x_minimal_size ;300
  226.         jb      @f
  227.         mov     [window_x],ebx
  228.         mov     ebx,[eax+8]
  229.         cmp     bx,word y_minimal_size ;200
  230.         jb      @f
  231.         mov     [window_y],ebx
  232. @@:
  233.         ret
  234. ;---------------------------------------------------------------------
  235. align 4
  236. get_active_pocess:
  237.         mcall   9,procinfo,-1
  238.         mov     ecx,[ebx+30]    ; PID
  239.         mcall   18,21
  240.         mov     [active_process],eax    ; WINDOW SLOT
  241.         mov     ebx,[communication_area]       
  242.         test    ebx,ebx
  243.         jz      .1
  244.         mov     [ebx+12],eax    ; WINDOW SLOT to com. area
  245. .1:
  246.         ret
  247. ;---------------------------------------------------------------------
  248. align 4
  249. palette_button:
  250.         mcall   37,1
  251.         and     eax,0xffff
  252.         sub     eax,p_start_y
  253.         imul    eax,p_size_x
  254.         lea     eax,[eax+eax*2]
  255.         add     eax,[palette_area]
  256.         mov     eax,[eax]
  257.         mov     [tone_color],eax
  258.         mov     [selected_color],eax
  259.         call    create_and_draw_tone
  260.         call    draw_selected_color
  261.         jmp     still
  262. ;---------------------------------------------------------------------
  263. align 4
  264. tone_button:
  265.         mcall   37,1
  266.         mov     ebx,eax
  267.         and     eax,0xffff
  268.         shr     ebx,16
  269.         sub     eax,t_start_y
  270.         imul    eax,p_size_y
  271.         sub     ebx,t_start_x
  272.         add     eax,ebx
  273.         lea     eax,[eax+eax*2]
  274.         add     eax,[tone_area]
  275.         mov     eax,[eax]
  276.         mov     [selected_color],eax
  277.         call    draw_selected_color
  278.         jmp     still
  279. ;---------------------------------------------------------------------
  280. align 4
  281. color_button:
  282.         mov     eax,[communication_area]
  283.         mov     [eax],word 1
  284.         mov     ebx,[selected_color]
  285.         and     ebx,0xffffff
  286.         mov     [eax+20],ebx
  287. ; dps "CD flag value: OK "
  288.         jmp     button.exit_1
  289. ;---------------------------------------------------------------------
  290. align 4
  291. key:
  292.         mcall   2
  293.         jmp     still
  294. ;---------------------------------------------------------------------
  295. align 4
  296. draw_selected_color:
  297.         mcall   13,<c_start_x,c_size_x>,<c_start_y,c_size_y>,[selected_color]
  298.         mcall   8,<c_start_x,c_size_x>,<c_start_y,c_size_y>,0x60000004
  299.         ret
  300. ;---------------------------------------------------------------------
  301. align 4
  302. create_and_draw_tone:
  303.         call    create_tone
  304.         call    draw_tone
  305.         ret
  306. ;---------------------------------------------------------------------
  307. align 4
  308. draw_tone:
  309.         mcall   65,[tone_area],<[tone_SIZE_X],[tone_SIZE_Y]>,<t_start_x,t_start_y>,24
  310.         ret
  311. ;---------------------------------------------------------------------
  312. align 4
  313. draw_window:
  314.         mcall   12,1
  315. ;       mcall   0, <w_start_x,w_size_x>, <w_start_y,w_size_y>, 0x33AABBCC,,title
  316.         mcall   0,[window_x],[window_y], 0x33AABBCC,,title
  317.         mcall   8,<p_start_x,[palette_SIZE_X]>,<p_start_y,[palette_SIZE_Y]>,0x60000002
  318.         mcall   ,<t_start_x,[tone_SIZE_X]>,<t_start_y,[tone_SIZE_Y]>,0x60000003
  319.         mcall   65,[palette_area],<[palette_SIZE_X],[palette_SIZE_Y]>,<p_start_x,p_start_y>,24
  320.         call    draw_tone
  321.         call    draw_selected_color
  322.         mcall   12,2
  323.         ret
  324. ;---------------------------------------------------------------------
  325. include 'palette.inc'
  326. ;---------------------------------------------------------------------
  327. include 'tone.inc'
  328. ;---------------------------------------------------------------------
  329. include 'i_data.inc'
  330. ;---------------------------------------------------------------------
  331. IM_END:
  332. ;---------------------------------------------------------------------
  333. include 'u_data.inc'
  334. ;---------------------------------------------------------------------
  335. I_END:
  336. ;---------------------------------------------------------------------