Subversion Repositories Kolibri OS

Rev

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

  1.  
  2.  
  3.  
  4. struc BLITTER
  5. {
  6.    .dc.xmin    rd  1   ;   0
  7.    .dc.ymin    rd  1   ;   4
  8.    .dc.xmax    rd  1   ;   8
  9.    .dc.ymax    rd  1   ;  12
  10.  
  11.    .sc:
  12.    .sc.xmin    rd  1   ;  16
  13.    .sc.ymin    rd  1   ;  20
  14.    .sc.xmax    rd  1   ;  24
  15.    .sc.ymax    rd  1   ;  28
  16.  
  17.    .dst_x      rd  1   ;  32
  18.    .dst_y      rd  1   ;  36
  19.    .src_x      rd  1   ;  40
  20.    .src_y      rd  1   ;  44
  21.    .w          rd  1   ;  48
  22.    .h          rd  1   ;  52
  23.  
  24.    .bitmap     rd  1   ;  56
  25.    .stride     rd  1   ;  60
  26.  
  27. }
  28.  
  29. virtual at 0
  30.   BLITTER BLITTER
  31. end virtual
  32.  
  33.  
  34. align 4
  35.  
  36. __L1OutCode:
  37.         push    ebx
  38.         mov     ebx, 8
  39.         cmp     edx, [eax]
  40.         jl      .L2
  41.         xor     ebx, ebx
  42.         cmp     edx, [eax+8]
  43.         setg    bl
  44.         sal     ebx, 2
  45. .L2:
  46.         cmp     ecx, [eax+4]
  47.         jge     .L3
  48.         or      ebx, 1
  49.         jmp     .L4
  50.  
  51. .L3:
  52.         cmp     ecx, [eax+12]
  53.         jle     .L4
  54.         or      ebx, 2
  55. .L4:
  56.         mov     eax, ebx
  57.         pop     ebx
  58.         ret
  59.  
  60. align 4
  61. block_clip:
  62.         push    ebp
  63.         push    edi
  64.         push    esi
  65.         push    ebx
  66.         sub     esp, 4
  67.  
  68.         mov     ebx, eax
  69.         mov     [esp], edx
  70.         mov     ebp, ecx
  71.         mov     ecx, [ecx]
  72.         mov     edx, [edx]
  73.         call    __L1OutCode
  74.  
  75.         mov     esi, eax
  76.         mov     edx, [esp+28]
  77.         mov     ecx, [edx]
  78. .L21:
  79.         mov     eax, [esp+24]
  80.         mov     edx, [eax]
  81.         mov     eax, ebx
  82.         call    __L1OutCode
  83.  
  84.         mov     edi, eax
  85. .L20:
  86.         mov     eax, edi
  87.         and     eax, esi
  88.         jne     .L9
  89.         cmp     esi, edi
  90.         je      .L9
  91.         test    esi, esi
  92.         jne     .L10
  93.         test    edi, 1
  94.         je      .L11
  95.         mov     eax, [ebx+4]
  96.         jmp     .L25
  97. .L11:
  98.         test    edi, 2
  99.         je      .L13
  100.         mov     eax, [ebx+12]
  101. .L25:
  102.         mov     edx, [esp+28]
  103.         jmp     .L22
  104. .L13:
  105.         test    edi, 4
  106.         je      .L14
  107.         mov     eax, [ebx+8]
  108.         jmp     .L26
  109. .L14:
  110.         and     edi, 8
  111.         je      .L12
  112.         mov     eax, [ebx]
  113. .L26:
  114.         mov     edx, [esp+24]
  115. .L22:
  116.         mov     [edx], eax
  117. .L12:
  118.         mov     eax, [esp+28]
  119.         mov     ecx, [eax]
  120.         jmp     .L21
  121. .L10:
  122.         test    esi, 1
  123.         je      .L16
  124.         mov     eax, [ebx+4]
  125.         jmp     .L23
  126. .L16:
  127.         test    esi, 2
  128.         je      .L18
  129.         mov     eax, [ebx+12]
  130. .L23:
  131.         mov     [ebp+0], eax
  132.         jmp     .L17
  133. .L18:
  134.         test    esi, 4
  135.         je      .L19
  136.         mov     eax, [ebx+8]
  137.         jmp     .L24
  138. .L19:
  139.         and     esi, 8
  140.         je      .L17
  141.         mov     eax, [ebx]
  142. .L24:
  143.         mov     edx, [esp]
  144.         mov     [edx], eax
  145. .L17:
  146.         mov     ecx, [ebp+0]
  147.         mov     eax, [esp]
  148.         mov     edx, [eax]
  149.         mov     eax, ebx
  150.         call    __L1OutCode
  151.         mov     esi, eax
  152.         jmp     .L20
  153. .L9:
  154.         add     esp, 4
  155.         pop     ebx
  156.         pop     esi
  157.         pop     edi
  158.         pop     ebp
  159.         ret
  160.  
  161. align 4
  162. blit_clip:
  163.  
  164. .sx0   equ 36
  165. .sy0   equ 32
  166. .sx1   equ 28
  167. .sy1   equ 24
  168.  
  169. .dx0   equ 20
  170. .dy0   equ 16
  171. .dx1   equ 12
  172. .dy1   equ 8
  173.  
  174.  
  175.         push    edi
  176.         push    esi
  177.         push    ebx
  178.         sub     esp, 40
  179.  
  180.         mov     ebx, ecx
  181.         mov     edx, [ecx+BLITTER.src_x]
  182.         mov     [esp+.sx0], edx
  183.         mov     eax, [ecx+BLITTER.src_y]
  184.         mov     [esp+.sy0], eax
  185.         add     edx, [ecx+BLITTER.w]
  186.         dec     edx
  187.         mov     [esp+.sx1], edx
  188.         add     eax, [ecx+BLITTER.h]
  189.         dec     eax
  190.         mov     [esp+.sy1], eax
  191.  
  192.         lea     ecx, [esp+.sy0]
  193.         lea     edx, [esp+.sx0]
  194.         lea     eax, [ebx+BLITTER.sc]
  195.         lea     esi, [esp+.sy1]
  196.  
  197.         mov     [esp+4], esi
  198.         lea     esi, [esp+.sx1]
  199.         mov     [esp], esi
  200.         call    block_clip
  201.  
  202.         mov     esi, 1
  203.         test    eax, eax
  204.         jne     .L28
  205.  
  206.         mov     edi, [esp+.sx0]
  207.         mov     edx, [ebx+BLITTER.dst_x]
  208.         add     edx, edi
  209.         sub     edx, [ebx+BLITTER.src_x]
  210.         mov     [esp+.dx0], edx
  211.  
  212.         mov     ecx, [esp+.sy0]
  213.         mov     eax, [ebx+BLITTER.dst_y]
  214.         add     eax, ecx
  215.         sub     eax, [ebx+BLITTER.src_y]
  216.         mov     [esp+.dy0], eax
  217.         sub     edx, edi
  218.         add     edx, [esp+.sx1]
  219.         mov     [esp+.dx1], edx
  220.  
  221.         sub     eax, ecx
  222.         add     eax, [esp+.sy1]
  223.         mov     [esp+.dy1], eax
  224.  
  225.         lea     ecx, [esp+.dy0]
  226.         lea     edx, [esp+.dx0]
  227.         lea     eax, [esp+.dy1]
  228.         mov     [esp+4], eax
  229.         lea     eax, [esp+.dx1]
  230.         mov     [esp], eax
  231.         mov     eax, ebx
  232.         call    block_clip
  233.         test    eax, eax
  234.         jne     .L28
  235.  
  236.         mov     edx, [esp+.dx0]
  237.         mov     eax, [esp+.dx1]
  238.         inc     eax
  239.         sub     eax, edx
  240.         mov     [ebx+BLITTER.w], eax
  241.  
  242.         mov     eax, [esp+.dy0]
  243.         mov     ecx, [esp+.dy1]
  244.         inc     ecx
  245.         sub     ecx, eax
  246.         mov     [ebx+BLITTER.h], ecx
  247.  
  248.         mov     ecx, [ebx+BLITTER.src_x]
  249.         add     ecx, edx
  250.         sub     ecx, [ebx+BLITTER.dst_x]
  251.         mov     [ebx+BLITTER.src_x], ecx
  252.  
  253.         mov     ecx, [ebx+BLITTER.src_y]
  254.         add     ecx, eax
  255.         sub     ecx, [ebx+BLITTER.dst_y]
  256.         mov     [ebx+BLITTER.src_y], ecx
  257.         mov     [ebx+BLITTER.dst_x], edx
  258.         mov     [ebx+BLITTER.dst_y], eax
  259.         xor     esi, esi
  260. .L28:
  261.         mov     eax, esi
  262.         add     esp, 40
  263.         pop     ebx
  264.         pop     esi
  265.         pop     edi
  266.  
  267.  
  268. purge .sx0
  269. purge .sy0
  270. purge .sx1
  271. purge .sy1
  272.  
  273. purge .dx0
  274. purge .dy0
  275. purge .dx1
  276. purge .dy1
  277.  
  278.         ret
  279.  
  280.  
  281.  
  282. align 4
  283.  
  284. blit_32:
  285.         push    ebp
  286.         push    edi
  287.         push    esi
  288.         push    ebx
  289.         sub     esp, 72
  290.  
  291.         mov     eax, [TASK_BASE]
  292.         mov     ebx, [eax-twdw + WDATA.box.width]
  293.         mov     edx, [eax-twdw + WDATA.box.height]
  294.  
  295.         xor     eax, eax
  296.  
  297.         mov     [esp+BLITTER.dc.xmin], eax
  298.         mov     [esp+BLITTER.dc.ymin], eax
  299.         mov     [esp+BLITTER.dc.xmax], ebx
  300.         mov     [esp+BLITTER.dc.ymax], edx
  301.  
  302.         mov     [esp+BLITTER.sc.xmin], eax
  303.         mov     [esp+BLITTER.sc.ymin], eax
  304.         mov     eax, [ecx+24]
  305.         dec     eax
  306.         mov     [esp+BLITTER.sc.xmax], eax
  307.         mov     eax, [ecx+28]
  308.         dec     eax
  309.         mov     [esp+BLITTER.sc.ymax], eax
  310.  
  311.         mov     eax, [ecx]
  312.         mov     [esp+BLITTER.dst_x], eax
  313.         mov     eax, [ecx+4]
  314.         mov     [esp+BLITTER.dst_y], eax
  315.  
  316.         mov     eax, [ecx+16]
  317.         mov     [esp+BLITTER.src_x], eax
  318.         mov     eax, [ecx+20]
  319.         mov     [esp+BLITTER.src_y], eax
  320.         mov     eax, [ecx+8]
  321.         mov     [esp+BLITTER.w], eax
  322.         mov     eax, [ecx+12]
  323.         mov     [esp+BLITTER.h], eax
  324.  
  325.  
  326.         mov     eax, [ecx+32]
  327.         mov     [esp+56], eax
  328.         mov     eax, [ecx+36]
  329.         mov     [esp+60], eax
  330.  
  331.         mov     ecx, esp
  332.         call    blit_clip
  333.         test    eax, eax
  334.         jne     .L57
  335.  
  336.         inc     [mouse_pause]
  337.         call    [_display.disable_mouse]
  338.  
  339.         mov     eax, [TASK_BASE]
  340.  
  341.         mov     ebx, [esp+BLITTER.dst_x]
  342.         mov     ebp, [esp+BLITTER.dst_y]
  343.         add     ebx, [eax-twdw + WDATA.box.left]
  344.         add     ebp, [eax-twdw + WDATA.box.top]
  345.         mov     edi, ebp
  346.  
  347.         imul    edi, [_display.pitch]
  348.         imul    ebp, [_display.width]
  349.         add     ebp, ebx
  350.         add     ebp, [_WinMapAddress]
  351.  
  352.         mov     eax, [esp+BLITTER.src_y]
  353.         imul    eax, [esp+BLITTER.stride]
  354.         mov     esi, [esp+BLITTER.src_x]
  355.         lea     esi, [eax+esi*4]
  356.         add     esi, [esp+BLITTER.bitmap]
  357.  
  358.         mov     ecx, [esp+BLITTER.h]
  359.         mov     edx, [esp+BLITTER.w]
  360.  
  361.         test    ecx, ecx    ;FIXME check clipping
  362.         jz      .L57
  363.  
  364.         test    edx, edx
  365.         jz      .L57
  366.  
  367.         cmp     [_display.bpp], 32
  368.         jne     .core_24
  369.  
  370.         lea     edi, [edi+ebx*4]
  371.  
  372.         mov     ebx, [CURRENT_TASK]
  373.  
  374. align 4
  375. .outer32:
  376.         xor     ecx, ecx
  377.  
  378. align 4
  379. .inner32:
  380.         cmp     [ebp+ecx], bl
  381.         jne     @F
  382.  
  383.         mov     eax, [esi+ecx*4]
  384.         mov     [LFB_BASE+edi+ecx*4], eax
  385. @@:
  386.         inc     ecx
  387.         dec     edx
  388.         jnz     .inner32
  389.  
  390.         add     esi, [esp+BLITTER.stride]
  391.         add     edi, [_display.pitch]
  392.         add     ebp, [_display.width]
  393.  
  394.         mov     edx, [esp+BLITTER.w]
  395.         dec     [esp+BLITTER.h]
  396.         jnz     .outer32
  397.  
  398. .done:
  399.         dec     [mouse_pause]
  400.         call    [draw_pointer]
  401. .L57:
  402.         add     esp, 72
  403.         pop     ebx
  404.         pop     esi
  405.         pop     edi
  406.         pop     ebp
  407.         ret
  408.  
  409. .core_24:
  410.         lea     ebx, [ebx+ebx*2]
  411.         lea     edi, [LFB_BASE+edi+ebx]
  412.         mov     ebx, [CURRENT_TASK]
  413.  
  414. align 4
  415. .outer24:
  416.         mov     [esp+64], edi
  417.         xor     ecx, ecx
  418.  
  419. align 4
  420. .inner24:
  421.         cmp     [ebp+ecx], bl
  422.         jne     @F
  423.  
  424.         mov     eax, [esi+ecx*4]
  425.  
  426.         lea     edi, [edi+ecx*2]
  427.         mov     [edi+ecx], ax
  428.         shr     eax, 16
  429.         mov     [edi+ecx+2], al
  430. @@:
  431.         mov     edi, [esp+64]
  432.         inc     ecx
  433.         dec     edx
  434.         jnz     .inner24
  435.  
  436.         add     esi, [esp+BLITTER.stride]
  437.         add     edi, [_display.pitch]
  438.         add     ebp, [_display.width]
  439.  
  440.         mov     edx, [esp+BLITTER.w]
  441.         dec     [esp+BLITTER.h]
  442.         jnz     .outer24
  443.  
  444.         jmp     .done
  445.