Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. DrawLine:
  3.  
  4.       mov eax,38
  5.       mov ebx,[Line.x1]
  6.       mov ecx,[Line.y1]
  7.       mov edx,[Line.color]
  8.       shl ebx,16
  9.       shl ecx,16
  10.       add ebx,[Line.x2]
  11.       add ecx,[Line.y2]
  12.       mcall
  13.  
  14.       ret
  15.  
  16. DrawPixel:
  17.  
  18.       xor eax,eax
  19.       inc al
  20.       mov ebx,[Pixel.x]
  21.       mov ecx,[Pixel.y]
  22.       mov edx,[Pixel.color]
  23.       mcall
  24.  
  25.       ret
  26.  
  27. RectangleContour:
  28.  
  29.       mov eax,38
  30.       mov ebx,[Rectangle.x]
  31.       mov ecx,[Rectangle.y]
  32.       mov edx,[Rectangle.color]
  33.       mov esi,ebx
  34.       mov edi,ecx
  35.       shl ebx,16
  36.       shl ecx,16
  37.       add ebx,esi
  38.       add ecx,edi
  39.       add ebx,[Rectangle.width]
  40.       mcall
  41.  
  42.       mov eax,38
  43.       mov ebx,[Rectangle.x]
  44.       mov ecx,[Rectangle.y]
  45.       mov edx,[Rectangle.color]
  46.       add ecx,[Rectangle.height]
  47.       mov esi,ebx
  48.       mov edi,ecx
  49.       shl ebx,16
  50.       shl ecx,16
  51.       add ebx,esi
  52.       add ecx,edi
  53.       add ebx,[Rectangle.width]
  54.       mcall
  55.  
  56.       mov eax,38
  57.       mov ebx,[Rectangle.x]
  58.       mov ecx,[Rectangle.y]
  59.       mov edx,[Rectangle.color]
  60.       mov esi,ebx
  61.       mov edi,ecx
  62.       shl ebx,16
  63.       shl ecx,16
  64.       add ebx,esi
  65.       add ecx,edi
  66.       add ecx,[Rectangle.height]
  67.       mcall
  68.  
  69.       mov eax,38
  70.       mov ebx,[Rectangle.x]
  71.       mov ecx,[Rectangle.y]
  72.       mov edx,[Rectangle.color]
  73.       add ebx,[Rectangle.width]
  74.       mov esi,ebx
  75.       mov edi,ecx
  76.       shl ebx,16
  77.       shl ecx,16
  78.       add ebx,esi
  79.       add ecx,edi
  80.       add ecx,[Rectangle.height]
  81.       mcall
  82.  
  83.       ret
  84.  
  85. ;eax -first color
  86. ;ebx- second color
  87. ;OUT
  88. ;eax - averege color
  89. calculate_average_color:
  90.  
  91.       and eax,0xffffff
  92.       and ebx,0xffffff
  93.  
  94.       mov [b_min],al
  95.       mov [b_max],bl
  96.       shr eax,8
  97.       shr ebx,8
  98.       mov [g_min],al
  99.       mov [g_max],bl
  100.       shr eax,8
  101.       shr ebx,8
  102.       mov [r_min],al
  103.       mov [r_max],bl
  104.  
  105.       xor eax,eax
  106.       xor ebx,ebx
  107.       mov al,[r_max]
  108.       mov bl,[r_min]
  109.       add eax,ebx
  110.       shr eax,1
  111.       mov [r],al
  112.  
  113.       xor eax,eax
  114.       xor ebx,ebx
  115.       mov al,[g_max]
  116.       mov bl,[g_min]
  117.       add eax,ebx
  118.       shr eax,1
  119.       mov [g],al
  120.  
  121.       xor eax,eax
  122.       xor ebx,ebx
  123.       mov al,[b_max]
  124.       mov bl,[b_min]
  125.       add eax,ebx
  126.       shr eax,1
  127.       mov [b],al
  128.  
  129.       xor eax,eax
  130.       mov al,[r]
  131.       shl eax,8
  132.       mov al,[g]
  133.       shl eax,8
  134.       mov al,[b]
  135.  
  136.       ret
  137.  
  138. ;eax -color
  139. ;ebx- sub value
  140. ;OUT
  141. ;eax - sabved color
  142. calculate_sabved_color:
  143.  
  144.       and eax,0xffffff
  145.  
  146.       mov [b],al
  147.       shr eax,8
  148.       mov [g],al
  149.       shr eax,8
  150.       mov [r],al
  151.  
  152.       sub [r],bl
  153.       sub [g],bl
  154.       sub [b],bl
  155.  
  156.       xor eax,eax
  157.       mov al,[r]
  158.       shl eax,8
  159.       mov al,[g]
  160.       shl eax,8
  161.       mov al,[b]
  162.  
  163.       ret
  164.  
  165. DrawString:
  166.  
  167.       mov ebx,[Button.text]
  168.       call GetLengthString
  169.       mov esi,eax
  170.  
  171.       mov eax,4
  172.       mov ebx,[Font.x]
  173.       shl ebx,16
  174.       add ebx,[Font.y]
  175.       mov ecx,[Button.textcolor]
  176.       mov edx,[Button.text]
  177.       mcall
  178.  
  179.       ret
  180.  
  181. ;eax -first color
  182. ;ebx- second color
  183. ;ecx- x coordinat of rectangle
  184. ;edx- y coordinat of rectangle
  185. ;esi- rectangle size x
  186. ;edi- rectangle size y
  187.  
  188. rectangle_gradient_right:
  189.  
  190.       mov [line_coordinat_x],ecx
  191.       mov [line_coordinat_y],edx
  192.       mov [line_size_x],esi
  193.       mov [line_size_y],edi
  194.  
  195.       mov ecx,esi
  196.       mov edx,dword pointer
  197.       call gradient
  198.  
  199.       mov ecx,[line_coordinat_y]
  200.       shl ecx,16
  201.       add ecx,[line_coordinat_y]
  202.       add ecx,[line_size_y]
  203.  
  204.       mov eax,[line_size_x]
  205.       add [line_coordinat_x],eax
  206.  
  207.       mov esi,dword pointer
  208.       mov edi,[line_size_x]
  209.  
  210.       next_vertical_line_draw_right:
  211.  
  212.         mov eax,38
  213.         mov ebx,[line_coordinat_x]
  214.         shl ebx,16
  215.         add ebx,[line_coordinat_x]
  216.         mov edx,[esi]
  217.         and edx,0xffffff
  218.         mcall
  219.  
  220.         add esi,3
  221.         sub [line_coordinat_x],1
  222.  
  223.       dec edi
  224.       jnz  next_vertical_line_draw_right
  225.  
  226.       ret
  227.  
  228. ;eax -first color
  229. ;ebx- second color
  230. ;ecx- x coordinat of rectangle
  231. ;edx- y coordinat of rectangle
  232. ;esi- rectangle size x
  233. ;edi- rectangle size y
  234.  
  235. rectangle_gradient_left:
  236.  
  237.       mov [line_coordinat_x],ecx
  238.       mov [line_coordinat_y],edx
  239.       mov [line_size_x],esi
  240.       mov [line_size_y],edi
  241.  
  242.       mov ecx,esi
  243.       mov edx,dword pointer
  244.       call gradient
  245.  
  246.       mov ecx,[line_coordinat_y]
  247.       shl ecx,16
  248.       add ecx,[line_coordinat_y]
  249.       add ecx,[line_size_y]
  250.  
  251.       mov esi,dword pointer
  252.       mov edi,[line_size_x]
  253.  
  254.       next_vertical_line_draw_left:
  255.  
  256.         mov eax,38
  257.         mov ebx,[line_coordinat_x]
  258.         shl ebx,16
  259.         add ebx,[line_coordinat_x]
  260.         mov edx,[esi]
  261.         and edx,0xffffff
  262.         mcall
  263.  
  264.         add esi,3
  265.         add [line_coordinat_x],1
  266.  
  267.       dec edi
  268.       jnz  next_vertical_line_draw_left
  269.  
  270.       ret
  271.  
  272. ;eax -first color
  273. ;ebx- second color
  274. ;ecx- x coordinat of rectangle
  275. ;edx- y coordinat of rectangle
  276. ;esi- rectangle size x
  277. ;edi- rectangle size y
  278.  
  279. rectangle_gradient_up:
  280.  
  281.       mov [line_coordinat_x],ecx
  282.       mov [line_coordinat_y],edx
  283.       mov [line_size_x],esi
  284.       mov [line_size_y],edi
  285.  
  286.       mov ecx,edi
  287.       mov edx,dword pointer
  288.       call gradient
  289.  
  290.       mov ebx,[line_coordinat_x]
  291.       shl ebx,16
  292.       add ebx,[line_coordinat_x]
  293.       add ebx,[line_size_x]
  294.  
  295.       mov eax,[line_size_y]
  296.       add [line_coordinat_y],eax
  297.  
  298.       mov esi,dword pointer
  299.       mov edi,[line_size_y]
  300.  
  301.       next_horizontal_line_draw_up:
  302.  
  303.         mov eax,38
  304.         mov ecx,[line_coordinat_y]
  305.         shl ecx,16
  306.         add ecx,[line_coordinat_y]
  307.         mov edx,[esi]
  308.         and edx,0xffffff
  309.         mcall
  310.  
  311.         add esi,3
  312.         sub [line_coordinat_y],1
  313.  
  314.       dec edi
  315.       jnz  next_horizontal_line_draw_up
  316.  
  317.       ret
  318.  
  319. ;eax -first color
  320. ;ebx- second color
  321. ;ecx- x coordinat of rectangle
  322. ;edx- y coordinat of rectangle
  323. ;esi- rectangle size x
  324. ;edi- rectangle size y
  325.  
  326. rectangle_gradient_down:
  327.  
  328.       mov [line_coordinat_x],ecx
  329.       mov [line_coordinat_y],edx
  330.       mov [line_size_x],esi
  331.       mov [line_size_y],edi
  332.  
  333.       mov ecx,edi
  334.       mov edx,dword pointer
  335.       call gradient
  336.  
  337.       mov ebx,[line_coordinat_x]
  338.       shl ebx,16
  339.       add ebx,[line_coordinat_x]
  340.       add ebx,[line_size_x]
  341.  
  342.       mov esi,dword pointer
  343.       mov edi,[line_size_y]
  344.  
  345.       next_horizontal_line_draw_down:
  346.  
  347.         mov eax,38
  348.         mov ecx,[line_coordinat_y]
  349.         shl ecx,16
  350.         add ecx,[line_coordinat_y]
  351.         mov edx,[esi]
  352.         and edx,0xffffff
  353.         mcall
  354.  
  355.         add esi,3
  356.         add [line_coordinat_y],1
  357.  
  358.       dec edi
  359.       jnz  next_horizontal_line_draw_down
  360.  
  361.       ret
  362.  
  363. ;eax -first color
  364. ;ebx- second color
  365. ;ecx- length of line
  366. ;edx- pointer to memory for colors of gradient
  367.  
  368. gradient:
  369.  
  370.       mov [length],ecx
  371.  
  372.       and eax,0xffffff
  373.       and eax,0xffffff
  374.  
  375.       mov [b_min],al
  376.       mov [b_max],bl
  377.       shr eax,8
  378.       shr ebx,8
  379.       mov [g_min],al
  380.       mov [g_max],bl
  381.       shr eax,8
  382.       shr ebx,8
  383.       mov [r_min],al
  384.       mov [r_max],bl
  385.  
  386.       mov eax,[length]
  387.       dec eax
  388.       mov [v],eax
  389.       fild [v]
  390.  
  391.       xor eax,eax
  392.       mov al,[r_max]
  393.       sub al,[r_min]
  394.       mov [v],eax
  395.       fild [v]
  396.       fdiv st0,st1
  397.       fstp [step_r]
  398.  
  399.       xor eax,eax
  400.       mov al,[g_max]
  401.       sub al,[g_min]
  402.       mov [v],eax
  403.       fild [v]
  404.       fdiv st0,st1
  405.       fstp [step_g]
  406.  
  407.       xor eax,eax
  408.       mov al,[b_max]
  409.       sub al,[b_min]
  410.       mov [v],eax
  411.       fild [v]
  412.       fdiv st0,st1
  413.       fstp [step_b]
  414.  
  415.       fstp [v]
  416.  
  417.       xor eax,eax
  418.       mov al,[r_min]
  419.       mov [r],al
  420.       mov [v],eax
  421.       fild [v]
  422.       fstp [r_f]
  423.  
  424.       xor eax,eax
  425.       mov al,[g_min]
  426.       mov [g],al
  427.       mov [v],eax
  428.       fild [v]
  429.       fstp [g_f]
  430.  
  431.       xor eax,eax
  432.       mov al,[b_min]
  433.       mov [b],al
  434.       mov [v],eax
  435.       fild [v]
  436.       fstp [b_f]
  437.  
  438.       next_gradient_color_save:
  439.  
  440.         xor ebx,ebx
  441.         xor eax,eax
  442.         mov al,[r]
  443.         mov bl,al
  444.         shl eax,8
  445.         mov al,[g]
  446.         shl eax,8
  447.         mov al,[b]
  448.  
  449.         mov [edx],ax
  450.         mov [edx+2],bl
  451.  
  452.         fld [step_r]
  453.         fld [r_f]
  454.         fadd st0,st1
  455.         fst [r_f]
  456.         fistp [v]
  457.         xor eax,eax
  458.         mov eax,[v]
  459.         mov [r],al
  460.         fstp [v]
  461.  
  462.         fld [step_g]
  463.         fld [g_f]
  464.         fadd st0,st1
  465.         fst [g_f]
  466.         fistp [v]
  467.         xor eax,eax
  468.         mov eax,[v]
  469.         mov [g],al
  470.         fstp [v]
  471.  
  472.         fld [step_b]
  473.         fld [b_f]
  474.         fadd st0,st1
  475.         fst [b_f]
  476.         fistp [v]
  477.         xor eax,eax
  478.         mov eax,[v]
  479.         mov [b],al
  480.         fstp [v]
  481.  
  482.         add edx,3
  483.  
  484.       dec ecx
  485.       jnz  next_gradient_color_save
  486.  
  487.       ret
  488.  
  489. ;IN
  490. ;NON
  491. ;OUT
  492. ;variable [skin_height]
  493.  
  494. get_skin_height:
  495.  
  496.       pushad
  497.  
  498.       mov eax,48
  499.       mov ebx,4
  500.       int 0x40
  501.  
  502.       mov [skin_height],eax
  503.       popad
  504.  
  505.       ret
  506. ;eax - x
  507. ;ebx - y
  508. ;ecx - size x
  509. ;edx - size y
  510. ;esi - pointer to memory for rectangle
  511. SaveFonForRectangle:
  512.  
  513.      mov [Rectangle.x],eax
  514.      mov [Rectangle.y],ebx
  515.      mov [Rectangle.width],ecx
  516.      mov [Rectangle.height],edx
  517.      mov [PointerToMem],esi
  518.  
  519.      ;get bytes per string
  520.      mov eax,61
  521.      mov ebx,2
  522.      mcall
  523.      mov [BitsPerPixel],eax
  524.  
  525.      mov eax,61
  526.      mov ebx,3
  527.      mcall
  528.      mov [BytesPerString],eax
  529.  
  530.  
  531.      ;get window coordinats
  532.      mov eax,9
  533.      mov ebx,dword IPC_table
  534.      or ecx,-1
  535.      mcall
  536.  
  537.      mov eax,dword[IPC_table+34]
  538.      mov ebx,dword[IPC_table+38]
  539.      ;mov ecx,dword[IPC_table+42]
  540.      ;mov edx,dword[IPC_table+46]
  541.      ;mov [WindowCoordinatX],eax
  542.      ;mov [WindowCoordinatY],ebx
  543.      ;mov [WindowSizeX],ecx
  544.      ;mov [WindowSizeY],edx
  545.  
  546.      add eax,[Rectangle.x]
  547.      add ebx,[Rectangle.y]
  548.  
  549.      imul ebx,[BytesPerString]
  550.      mov esi,[Rectangle.width]
  551.  
  552.      cmp [BitsPerPixel],24
  553.      jne no_24
  554.  
  555.      lea eax,[eax+eax*2]
  556.      lea esi,[esi+esi*2]
  557.      mov edi,3
  558.      jmp exit_bits_per_pixel
  559.      no_24:
  560.  
  561.      shl eax,2
  562.      shl esi,2
  563.      mov edi,4
  564.      exit_bits_per_pixel:
  565.  
  566.      add eax,ebx
  567.  
  568.      mov ebx,[BytesPerString]
  569.      sub ebx,esi
  570.      mov [offset],ebx
  571.  
  572.      mov esi,[PointerToMem]
  573.      mov edx,[Rectangle.height]
  574.      next_string_pixels_save:
  575.  
  576.        mov ecx,[Rectangle.width]
  577.        next_pixel_save:
  578.  
  579.          mov ebx,[gs:eax]
  580.          and ebx,0xffffff
  581.          mov [esi],bx
  582.          shr ebx,16
  583.          mov [esi+2],bl
  584.  
  585.          add esi,3
  586.          add eax,edi
  587.        dec ecx
  588.        jnz next_pixel_save
  589.  
  590.        add eax,[offset]
  591.      dec edx
  592.      jnz next_string_pixels_save
  593.  
  594.      exit_:
  595.      ret
  596.