Subversion Repositories Kolibri OS

Rev

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

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