Subversion Repositories Kolibri OS

Rev

Rev 3417 | 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.   use32
  29.   org    0x0
  30.  
  31.   db     'MENUET01'
  32.   dd     0x01
  33.   dd     START
  34.   dd     IM_END
  35.   dd     I_END
  36.   dd     stacktop
  37.   dd     0x0
  38.   dd     0x0
  39. ;---------------------------------------------------------------------
  40. include '../../macros.inc'
  41. ;include 'lang.inc'
  42. ;---------------------------------------------------------------------
  43. p_start_x = 10
  44. p_start_y = 10
  45.  
  46. p_size_x = 20
  47. p_size_y = 256
  48. ;--------------------------------------
  49. t_start_x = 40
  50. t_start_y = 10
  51. ;--------------------------------------
  52. w_start_x = 200
  53. w_start_y = 200
  54.  
  55. w_size_x = 400
  56. w_size_y = 350
  57. ;--------------------------------------
  58. c_start_x = t_start_x + p_size_y + 10
  59. c_start_y = 10
  60.  
  61. c_size_x = 40
  62. c_size_y = 20
  63. ;---------------------------------------------------------------------
  64.  
  65. START:
  66.         mcall   68,11
  67.  
  68.         xor     eax,eax
  69.         mov     al,p_size_x
  70.         mov     [palette_SIZE_X],eax
  71.         mov     ax,p_size_y
  72.         mov     [palette_SIZE_Y],eax
  73.         mov     [tone_SIZE_X],eax
  74.         mov     [tone_SIZE_Y],eax
  75.         mov     eax,0xff0000
  76.         mov     [tone_color],eax
  77.         mov     [selected_color],eax
  78. ;--------------------------------------
  79.         mov     ecx,[palette_SIZE_Y]
  80.         imul    ecx,[palette_SIZE_X]
  81.         lea     ecx,[ecx*3]
  82.         inc     ecx     ;reserve for stosd
  83.         mcall   68,12
  84.         mov     [palette_area],eax
  85. ;--------------------------------------
  86.         call    create_palette
  87. ;--------------------------------------
  88.         mov     ecx,[tone_SIZE_Y]
  89.         imul    ecx,[tone_SIZE_X]
  90.         lea     ecx,[ecx*3]
  91.         inc     ecx     ;reserve for stosd
  92.         mcall   68,12
  93.         mov     [tone_area],eax
  94. ;--------------------------------------
  95.         call    create_tone
  96. ;---------------------------------------------------------------------
  97. align 4
  98. red:
  99.         call    draw_window
  100. ;---------------------------------------------------------------------
  101. align 4
  102. still:
  103.         mcall   10
  104.  
  105.         cmp     eax,1
  106.         je      red
  107.  
  108.         cmp     eax,2
  109.         je      key
  110.  
  111.         cmp     eax,3
  112.         jne     still
  113. ;---------------------------------------------------------------------
  114. align 4
  115. button:
  116.         mcall   17
  117.  
  118.         cmp     ah, 2
  119.         je      palette_button
  120.        
  121.         cmp     ah, 3
  122.         je      tone_button
  123.        
  124.         cmp     ah, 1
  125.         jne     still
  126.  
  127. .exit:
  128.         mcall   -1
  129. ;---------------------------------------------------------------------
  130. align 4
  131. palette_button:
  132.         mcall   37,1
  133.         and     eax,0xffff
  134.         sub     eax,p_start_y
  135.         imul    eax,p_size_x
  136.         dec     eax
  137.         lea     eax,[eax+eax*2]
  138.         add     eax,[palette_area]
  139.         mov     eax,[eax]
  140.         mov     [tone_color],eax
  141.         mov     [selected_color],eax
  142.         call    create_and_draw_tone
  143.         call    draw_selected_color
  144.         jmp     still
  145. ;---------------------------------------------------------------------
  146. align 4
  147. tone_button:
  148.         mcall   37,1
  149.         mov     ebx,eax
  150.         and     eax,0xffff
  151.         shr     ebx,16
  152.         sub     eax,t_start_y
  153.         imul    eax,p_size_y
  154.         sub     ebx,t_start_x
  155.         add     eax,ebx
  156.         lea     eax,[eax+eax*2]
  157.         add     eax,[tone_area]
  158.         mov     eax,[eax]
  159.         mov     [selected_color],eax
  160.         call    draw_selected_color
  161.         jmp     still
  162. ;---------------------------------------------------------------------
  163. align 4
  164. key:
  165.         mcall   2
  166.         jmp     still
  167. ;---------------------------------------------------------------------
  168. align 4
  169. draw_selected_color:
  170.         mcall   13,<c_start_x,c_size_x>,<c_start_y,c_size_y>,[selected_color]
  171.         ret
  172. ;---------------------------------------------------------------------
  173. align 4
  174. create_and_draw_tone:
  175.         call    create_tone
  176.         call    draw_tone
  177.         ret
  178. ;---------------------------------------------------------------------
  179. align 4
  180. draw_tone:
  181.         mcall   65,[tone_area],<[tone_SIZE_X],[tone_SIZE_Y]>,<t_start_x,t_start_y>,24
  182.         ret
  183. ;---------------------------------------------------------------------
  184. align 4
  185. draw_window:
  186.         mcall   12,1
  187.         mcall   0, <w_start_x,w_size_x>, <w_start_y,w_size_y>, 0x33AABBCC,,title
  188.         mcall   8,<p_start_x,[palette_SIZE_X]>,<p_start_y,[palette_SIZE_Y]>,0x60000002
  189.         mcall   ,<t_start_x,[tone_SIZE_X]>,<t_start_y,[tone_SIZE_Y]>,0x60000003
  190.         mcall   65,[palette_area],<[palette_SIZE_X],[palette_SIZE_Y]>,<p_start_x,p_start_y>,24
  191.         call    draw_tone
  192.         call    draw_selected_color
  193.         mcall   12,2
  194.         ret
  195. ;---------------------------------------------------------------------
  196. include 'palette.inc'
  197. ;---------------------------------------------------------------------
  198. include 'tone.inc'
  199. ;---------------------------------------------------------------------
  200. include 'i_data.inc'
  201. ;---------------------------------------------------------------------
  202. IM_END:
  203. ;---------------------------------------------------------------------
  204. include 'u_data.inc'
  205. ;---------------------------------------------------------------------
  206. I_END:
  207. ;---------------------------------------------------------------------