Subversion Repositories Kolibri OS

Rev

Rev 2010 | Rev 2465 | 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.         mov     eax, [TASK_BASE]
  328.  
  329.         mov     ebx, [esp+BLITTER.dst_x]
  330.         mov     ebp, [esp+BLITTER.dst_y]
  331.         add     ebx, [eax-twdw + WDATA.box.left]
  332.         add     ebp, [eax-twdw + WDATA.box.top]
  333.  
  334.         mov     ecx, ebx
  335.         add     ecx, [esp+BLITTER.w]
  336.         shl     ecx, 16
  337.         mov     cx, bp
  338.         add     ecx, [esp+BLITTER.h]
  339.  
  340.         mov     edi, ebp
  341.  
  342.         imul    edi, [_display.pitch]
  343.         imul    ebp, [_display.width]
  344.         add     ebp, ebx
  345.         add     ebp, [_WinMapAddress]
  346.  
  347.         mov     eax, [esp+BLITTER.src_y]
  348.         imul    eax, [esp+BLITTER.stride]
  349.         mov     esi, [esp+BLITTER.src_x]
  350.         lea     esi, [eax+esi*4]
  351.         add     esi, [esp+BLITTER.bitmap]
  352.  
  353.         mov     eax, ecx
  354.         mov     ecx, [esp+BLITTER.h]
  355.         mov     edx, [esp+BLITTER.w]
  356.  
  357.         test    ecx, ecx    ;FIXME check clipping
  358.         jz      .L57
  359.  
  360.         test    edx, edx
  361.         jz      .L57
  362.  
  363.         cmp     [_display.bpp], 32
  364.         jne     .core_24
  365.  
  366.         lea     edi, [edi+ebx*4]
  367.  
  368.         mov     ebx, [CURRENT_TASK]
  369. align 4
  370. .outer32:
  371.         xor     ecx, ecx
  372.  
  373. align 4
  374. .inner32:
  375.         cmp     [ebp+ecx], bl
  376.         jne     @F
  377. ;--------------------------------------
  378.         push    eax
  379.         mov     eax, [esi+ecx*4]
  380.  
  381.         push    ecx
  382.  
  383.         mov     ecx, [esp+4]
  384.         ror     ecx, 16
  385.         sub     ecx, edx
  386.         rol     ecx, 16
  387.         sub     ecx, [esp+BLITTER.h + 8]
  388.  
  389. ; check mouse area for putpixel
  390.         call    [_display.check_mouse]
  391.         pop     ecx
  392. ; store to real LFB
  393.         mov     [LFB_BASE+edi+ecx*4], eax
  394.         pop     eax
  395. ;--------------------------------------
  396. align 4
  397. @@:
  398.         inc     ecx
  399.         dec     edx
  400.         jnz     .inner32
  401.  
  402.         add     esi, [esp+BLITTER.stride]
  403.         add     edi, [_display.pitch]
  404.         add     ebp, [_display.width]
  405.  
  406.         mov     edx, [esp+BLITTER.w]
  407.         dec     [esp+BLITTER.h]
  408.         jnz     .outer32
  409.  
  410. .done:
  411.         call    [draw_pointer]
  412. .L57:
  413.         add     esp, 72
  414.         pop     ebx
  415.         pop     esi
  416.         pop     edi
  417.         pop     ebp
  418.         ret
  419.  
  420. .core_24:
  421.         lea     ebx, [ebx+ebx*2]
  422.         lea     edi, [LFB_BASE+edi+ebx]
  423.         mov     ebx, [CURRENT_TASK]
  424.  
  425. align 4
  426. .outer24:
  427.         mov     [esp+64], edi
  428.         xor     ecx, ecx
  429.  
  430. align 4
  431. .inner24:
  432.         cmp     [ebp+ecx], bl
  433.         jne     @F
  434. ;--------------------------------------
  435.         push    eax
  436.         mov     eax, [esi+ecx*4]
  437.  
  438.         lea     edi, [edi+ecx*2]
  439.  
  440.         push    ecx
  441.  
  442.         mov     ecx, [esp+4]
  443.         ror     ecx, 16
  444.         sub     ecx, edx
  445.         rol     ecx, 16
  446.         sub     ecx, [esp+BLITTER.h + 8]
  447.  
  448. ; check mouse area for putpixel
  449.         call    [_display.check_mouse]
  450.         pop     ecx
  451.  
  452.         mov     [edi+ecx], ax
  453.         shr     eax, 16
  454.         mov     [edi+ecx+2], al
  455.  
  456.         pop     eax
  457. ;--------------------------------------
  458. align 4
  459. @@:
  460.         mov     edi, [esp+64]
  461.         inc     ecx
  462.         dec     edx
  463.         jnz     .inner24
  464.  
  465.         add     esi, [esp+BLITTER.stride]
  466.         add     edi, [_display.pitch]
  467.         add     ebp, [_display.width]
  468.  
  469.         mov     edx, [esp+BLITTER.w]
  470.         dec     [esp+BLITTER.h]
  471.         jnz     .outer24
  472.  
  473.         jmp     .done
  474.