Subversion Repositories Kolibri OS

Rev

Rev 3417 | Rev 3463 | 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.  
  100. START:
  101.         mcall   68,11
  102.         mcall   66,1,1
  103.         mcall   40,0x27
  104.         call    get_communication_area
  105.        
  106.         call    get_active_pocess
  107.  
  108.         xor     eax,eax
  109.         mov     al,p_size_x
  110.         mov     [palette_SIZE_X],eax
  111.         mov     ax,p_size_y
  112.         mov     [palette_SIZE_Y],eax
  113.         mov     [tone_SIZE_X],eax
  114.         mov     [tone_SIZE_Y],eax
  115.         mov     eax,0xff0000
  116.         mov     [tone_color],eax
  117.         mov     [selected_color],eax
  118. ;--------------------------------------
  119.         mov     ecx,[palette_SIZE_Y]
  120.         imul    ecx,[palette_SIZE_X]
  121.         lea     ecx,[ecx*3]
  122.         inc     ecx     ;reserve for stosd
  123.         mcall   68,12
  124.         mov     [palette_area],eax
  125. ;--------------------------------------
  126.         call    create_palette
  127. ;--------------------------------------
  128.         mov     ecx,[tone_SIZE_Y]
  129.         imul    ecx,[tone_SIZE_X]
  130.         lea     ecx,[ecx*3]
  131.         inc     ecx     ;reserve for stosd
  132.         mcall   68,12
  133.         mov     [tone_area],eax
  134. ;--------------------------------------
  135.         call    create_tone
  136. ;---------------------------------------------------------------------
  137. align 4
  138. red:
  139.         call    draw_window
  140. ;---------------------------------------------------------------------
  141. align 4
  142. still:
  143.         mcall   10
  144.  
  145.         cmp     eax,1
  146.         je      red
  147.  
  148.         cmp     eax,2
  149.         je      key
  150.  
  151.         cmp     eax,3
  152.         jne     still
  153. ;---------------------------------------------------------------------
  154. align 4
  155. button:
  156.         mcall   17
  157.  
  158.         cmp     ah, 2
  159.         je      palette_button
  160.        
  161.         cmp     ah, 3
  162.         je      tone_button
  163.  
  164.         cmp     ah, 4
  165.         je      color_button
  166.        
  167.         cmp     ah, 1
  168.         jne     still
  169.  
  170. .exit:
  171.         mov     eax,[communication_area]
  172.         mov     [eax],word 3
  173. ; dps "CD flag value: cancel "
  174.  
  175. .exit_1:
  176.  
  177.         mov     ax,[eax]
  178.         and     eax,0xffff
  179. ; dps "CD flag value: "
  180. ; dpd eax
  181. ; newline
  182.  
  183.         mcall   -1
  184. ;---------------------------------------------------------------------
  185. align 4
  186. get_communication_area:
  187.         xor     eax,eax
  188.         mov     al,[param]
  189.         test    eax,eax
  190.         jz      @f
  191.         mcall   68,22,param,,0x01
  192.         mov     [communication_area],eax
  193. ;       movzx   ebx,word [eax+2]
  194. ;       mov     [color_dialog_type],ebx
  195.  
  196. ;       mov     ebx,[eax+4]
  197. ;       cmp     bx,word x_minimal_size ;300
  198. ;       jb      @f
  199. ;       mov     [window_x],ebx
  200. ;       mov     ebx,[eax+8]
  201. ;       cmp     bx,word y_minimal_size ;200
  202. ;       jb      @f
  203. ;       mov     [window_y],ebx
  204. @@:
  205.         ret
  206. ;---------------------------------------------------------------------
  207. align 4
  208. get_active_pocess:
  209.         mcall   9,procinfo,-1
  210.         mov     ecx,[ebx+30]    ; PID
  211.         mcall   18,21
  212.         mov     [active_process],eax    ; WINDOW SLOT
  213.         mov     ebx,[communication_area]       
  214.         test    ebx,ebx
  215.         jz      .1
  216.         mov     [ebx+12],eax    ; WINDOW SLOT to com. area
  217. .1:
  218.         ret
  219. ;---------------------------------------------------------------------
  220. align 4
  221. palette_button:
  222.         mcall   37,1
  223.         and     eax,0xffff
  224.         sub     eax,p_start_y
  225.         imul    eax,p_size_x
  226.         lea     eax,[eax+eax*2]
  227.         add     eax,[palette_area]
  228.         mov     eax,[eax]
  229.         mov     [tone_color],eax
  230.         mov     [selected_color],eax
  231.         call    create_and_draw_tone
  232.         call    draw_selected_color
  233.         jmp     still
  234. ;---------------------------------------------------------------------
  235. align 4
  236. tone_button:
  237.         mcall   37,1
  238.         mov     ebx,eax
  239.         and     eax,0xffff
  240.         shr     ebx,16
  241.         sub     eax,t_start_y
  242.         imul    eax,p_size_y
  243.         sub     ebx,t_start_x
  244.         add     eax,ebx
  245.         lea     eax,[eax+eax*2]
  246.         add     eax,[tone_area]
  247.         mov     eax,[eax]
  248.         mov     [selected_color],eax
  249.         call    draw_selected_color
  250.         jmp     still
  251. ;---------------------------------------------------------------------
  252. align 4
  253. color_button:
  254.         mov     eax,[communication_area]
  255.         mov     [eax],word 1
  256.         mov     ebx,[selected_color]
  257.         mov     [eax+20],ebx
  258. ; dps "CD flag value: OK "
  259.         jmp     button.exit_1
  260. ;---------------------------------------------------------------------
  261. align 4
  262. key:
  263.         mcall   2
  264.         jmp     still
  265. ;---------------------------------------------------------------------
  266. align 4
  267. draw_selected_color:
  268.         mcall   13,<c_start_x,c_size_x>,<c_start_y,c_size_y>,[selected_color]
  269.         mcall   8,<c_start_x,c_size_x>,<c_start_y,c_size_y>,0x60000004
  270.         ret
  271. ;---------------------------------------------------------------------
  272. align 4
  273. create_and_draw_tone:
  274.         call    create_tone
  275.         call    draw_tone
  276.         ret
  277. ;---------------------------------------------------------------------
  278. align 4
  279. draw_tone:
  280.         mcall   65,[tone_area],<[tone_SIZE_X],[tone_SIZE_Y]>,<t_start_x,t_start_y>,24
  281.         ret
  282. ;---------------------------------------------------------------------
  283. align 4
  284. draw_window:
  285.         mcall   12,1
  286.         mcall   0, <w_start_x,w_size_x>, <w_start_y,w_size_y>, 0x33AABBCC,,title
  287.         mcall   8,<p_start_x,[palette_SIZE_X]>,<p_start_y,[palette_SIZE_Y]>,0x60000002
  288.         mcall   ,<t_start_x,[tone_SIZE_X]>,<t_start_y,[tone_SIZE_Y]>,0x60000003
  289.         mcall   65,[palette_area],<[palette_SIZE_X],[palette_SIZE_Y]>,<p_start_x,p_start_y>,24
  290.         call    draw_tone
  291.         call    draw_selected_color
  292.         mcall   12,2
  293.         ret
  294. ;---------------------------------------------------------------------
  295. include 'palette.inc'
  296. ;---------------------------------------------------------------------
  297. include 'tone.inc'
  298. ;---------------------------------------------------------------------
  299. include 'i_data.inc'
  300. ;---------------------------------------------------------------------
  301. IM_END:
  302. ;---------------------------------------------------------------------
  303. include 'u_data.inc'
  304. ;---------------------------------------------------------------------
  305. I_END:
  306. ;---------------------------------------------------------------------