Subversion Repositories Kolibri OS

Rev

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