Subversion Repositories Kolibri OS

Rev

Rev 129 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;-----------------------------------------------------------------------------
  2. func vm_mike_draw_rect.15 ;///////////////////////////////////////////////////
  3. ;-----------------------------------------------------------------------------
  4. ; eax - x start
  5. ; ebx - y start
  6. ; ecx - x end
  7. ; edx - y end
  8. ; edi - color
  9. ;-----------------------------------------------------------------------------
  10. ;- eax(ebx) [x start]*65536 + [x size]
  11. ;- ebx(ecx) [y start]*65536 + [y size]
  12. ;- ecx(edx) color 0x00RRGGBB
  13. ;-----------------------------------------------------------------------------
  14. begin
  15.         pushad
  16.         cli
  17.         jif     eax,e,ecx,.exit
  18.         jif     ebx,e,edx,.exit
  19.  
  20.         call    get_cursor_rect
  21.  
  22.         mov     ebp,[TASK_BASE]
  23.         movsx   esi,word[ebp-CURRENT_TASK+0]
  24.         add     eax,esi
  25.         add     ecx,esi
  26.         movsx   esi,word[ebp-CURRENT_TASK+4]
  27.         add     ebx,esi
  28.         add     edx,esi
  29. ;       add     eax,[ebp-CURRENT_TASK+0]
  30. ;       add     ebx,[ebp-CURRENT_TASK+4]
  31. ;       add     ecx,[ebp-CURRENT_TASK+0]
  32. ;       add     edx,[ebp-CURRENT_TASK+4]
  33.  
  34.         push    eax
  35.         mov     eax,edi
  36.         shr     eax,3
  37.         shl     ax,3
  38.         shr     eax,3
  39.         shl     al,3
  40.         shr     eax,3
  41.         mov     di,ax
  42.         pop     eax
  43.  
  44.         mov     esi,[CURRENT_TASK]
  45.         mov     esi,[CLIP_RECTS+esi*4]
  46.         mov     ebp,[esi]
  47.         or      ebp,ebp
  48.         jz      .exit
  49.         add     esi,4
  50.   .nx:  jif     ecx,l,[rr.left],.skip
  51.         jif     eax,ge,[rr.right],.skip
  52.         jif     edx,l,[rr.top],.skip
  53.         jif     ebx,ge,[rr.bottom],.skip
  54.         pushad
  55.         jif     eax,ge,[rr.left],@f
  56.         mov     eax,[rr.left]
  57.     @@: jif     ebx,ge,[rr.top],@f
  58.         mov     ebx,[rr.top]
  59.     @@: jif     ecx,l,[rr.right],@f
  60.         mov     ecx,[rr.right]
  61.     @@: jif     edx,l,[rr.bottom],@f
  62.         mov     edx,[rr.bottom]
  63.     @@: call    is_intersect_rc
  64.         jc      .put
  65.         cmp     byte[MOUSE_VISIBLE],0
  66.         je      .put
  67.         call    [SF.draw_mouse_under]
  68.         mov     byte[MOUSE_VISIBLE],0
  69.   .put: mov     ebp,[BytesPerScanLine]
  70.         imul    ebp,ebx
  71.         lea     ebp,[ebp+eax*2]
  72.         add     ebp,[LFBAddress]
  73.   .xxx: push    eax ebp
  74.     @@: push    ebp
  75.         call    [set_bank]
  76.         mov     [ebp],di
  77.         pop     ebp
  78. ;       mov     [ebp],di
  79.         add     ebp,2
  80.         inc     eax
  81.         cmp     eax,ecx
  82.         jl      @b
  83.         pop     ebp eax
  84.         add     ebp,[BytesPerScanLine]
  85.         inc     ebx
  86.         cmp     ebx,edx
  87.         jl      .xxx
  88.         popad
  89.   .skip:
  90.         add     esi,SR
  91.         dec     ebp
  92.         jnz     .nx
  93.  
  94.   .exit:
  95.         sti
  96.         popad
  97.         retn
  98. endf
  99.  
  100. ;-----------------------------------------------------------------------------
  101. func vm_mike_draw_line.15 ;///////////////////////////////////////////////////
  102. ;-----------------------------------------------------------------------------
  103. ; eax(ebx)  [x start] shl 16 + [x end]
  104. ; ebx(ecx)  [y start] shl 16 + [y end]
  105. ; ecx(edx)  colour 0x00RRGGBB
  106. ; edi = 0x00000001 force
  107. ;-----------------------------------------------------------------------------
  108. begin
  109.         pushad
  110.         cli
  111.  
  112.         call    get_cursor_rect
  113.  
  114.         mov     eax,ecx
  115.         shr     ecx,3
  116.         shl     cx,3
  117.         shr     ecx,3
  118.         shl     cl,3
  119.         shr     ecx,3
  120.         and     eax,0x01000000
  121.         or      ecx,eax
  122.  
  123.         movsx   eax,word[esp+4*7]  ; x end
  124.         cmp     ax,[esp+4*7+2]     ; x start
  125.         je      dl.15.vert_line
  126.         movsx   eax,word[esp+4*4]  ; y end
  127.         cmp     ax,[esp+4*4+2]     ; y start
  128.         je      dl.15.horz_line
  129.  
  130.         sti
  131.         popad
  132.         retn
  133.  
  134.   dl.15.vert_line:
  135.         test    edi,1
  136.         jnz     .forced
  137.         mov     esi,[CURRENT_TASK]
  138.         mov     esi,[CLIP_RECTS+esi*4]
  139.         mov     edi,[esi]
  140.         or      edi,edi
  141.         jz      .exit
  142.         add     esi,4
  143.   .nx:  movsx   ebx,word[esp+4*4+2]  ; y start
  144.         movsx   edx,word[esp+4*4]    ; y end
  145.         cmp     ebx,edx
  146.         je      .exit
  147.         jl      @f
  148.         xchg    ebx,edx
  149.     @@: jif     eax,l,[rr.left],.skip
  150.         jif     eax,ge,[rr.right],.skip
  151.         jif     edx,l,[rr.top],.skip
  152.         jif     ebx,ge,[rr.bottom],.skip
  153.         jif     ebx,ge,[rr.top],@f
  154.         mov     ebx,[rr.top]
  155.     @@: jif     edx,l,[rr.bottom],@f
  156.         mov     edx,[rr.bottom]
  157.         dec     edx
  158.   .draw:
  159.     @@: call    is_intersect_vln
  160.         jc      .put
  161.         cmp     byte[MOUSE_VISIBLE],0
  162.         je      .put
  163.         call    [SF.draw_mouse_under]
  164.         mov     byte[MOUSE_VISIBLE],0
  165.   .put: mov     ebp,[BytesPerScanLine]
  166.         imul    ebp,ebx
  167.         lea     ebp,[ebp+eax*2]
  168.         add     ebp,[LFBAddress]
  169.     @@: push    ebp
  170.         call    [set_bank]
  171.         test    ecx,0x01000000
  172.         jz      .dr
  173.         mov     cx,[ebp]
  174.         not     cx
  175.   .dr:  mov     [ebp],cx
  176.         pop     ebp
  177. ;       test    ecx,0x01000000
  178. ;       jz      .dr
  179. ;       mov     cx,[ebp]
  180. ;       not     cx
  181. ;  .dr: mov     [ebp],cx
  182.         add     ebp,[BytesPerScanLine]
  183.         inc     ebx
  184.         cmp     ebx,edx
  185.         jle     @b
  186.   .skip:
  187.         add     esi,SR
  188.         dec     edi
  189.         jnz     .nx
  190.   .exit:
  191.         sti
  192.         popad
  193.         retn
  194.   .forced:
  195.         jif     eax,l,[viewport.left],.exit
  196.         jif     eax,ge,[viewport.right],.exit
  197.         movsx   ebx,word[esp+4*4+2]  ; y start
  198.         movsx   edx,word[esp+4*4]    ; y end
  199.         jif     ebx,e,edx,.exit
  200.         jl      @f
  201.         xchg    ebx,edx
  202.     @@: jif     edx,l,[viewport.top],.exit
  203.         jif     ebx,ge,[viewport.bottom],.exit
  204.         jif     ebx,ge,[viewport.top],@f
  205.         mov     ebx,[viewport.top]
  206.     @@: jif     edx,l,[viewport.bottom],@f
  207.         mov     edx,[viewport.bottom]
  208.         dec     edx
  209.     @@: mov     edi,1
  210.         jmp     .draw
  211.  
  212.   dl.15.horz_line:
  213.         test    edi,1
  214.         jnz     .forced
  215.         mov     esi,[CURRENT_TASK]
  216.         mov     esi,[CLIP_RECTS+esi*4]
  217.         mov     edi,[esi]
  218.         or      edi,edi
  219.         jz      .exit
  220.         add     esi,4
  221.   .nx:  movsx   ebx,word[esp+4*7+2]  ; x start
  222.         movsx   edx,word[esp+4*7]    ; x end
  223.         cmp     ebx,edx
  224.         je      .exit
  225.         jl      @f
  226.         xchg    ebx,edx
  227.     @@: jif     eax,l,[rr.top],.skip
  228.         jif     eax,ge,[rr.bottom],.skip
  229.         jif     edx,l,[rr.left],.skip
  230.         jif     ebx,ge,[rr.right],.skip
  231.         jif     ebx,ge,[rr.left],@f
  232.         mov     ebx,[rr.left]
  233.     @@: jif     edx,l,[rr.right],@f
  234.         mov     edx,[rr.right]
  235.         dec     edx
  236.   .draw:
  237.     @@: call    is_intersect_hln
  238.         jc      .put
  239.         cmp     byte[MOUSE_VISIBLE],0
  240.         je      .put
  241.         call    [SF.draw_mouse_under]
  242.         mov     byte[MOUSE_VISIBLE],0
  243.   .put: mov     ebp,[BytesPerScanLine]
  244.         imul    ebp,eax
  245.         lea     ebp,[ebp+ebx*2]
  246.         add     ebp,[LFBAddress]
  247.     @@: push    ebp
  248.         call    [set_bank]
  249.         test    ecx,0x01000000
  250.         jz      .dr
  251.         mov     cx,[ebp]
  252.         not     cx
  253.   .dr:  mov     [ebp],cx
  254.         pop     ebp
  255. ;       test    ecx,0x01000000
  256. ;       jz      .dr
  257. ;       mov     cx,[ebp]
  258. ;       not     cx
  259. ;  .dr: mov     [ebp],cx
  260.         add     ebp,2
  261.         inc     ebx
  262.         cmp     ebx,edx
  263.         jle     @b
  264.   .skip:
  265.         add     esi,SR
  266.         dec     edi
  267.         jnz     .nx
  268.   .exit:
  269.         sti
  270.         popad
  271.         retn
  272.   .forced:
  273.         jif     eax,l,[viewport.top],.exit
  274.         jif     eax,ge,[viewport.bottom],.exit
  275.         movsx   ebx,word[esp+4*7+2]  ; x start
  276.         movsx   edx,word[esp+4*7]    ; x end
  277.         cmp     ebx,edx
  278.         je      .exit
  279.         jl      @f
  280.         xchg    ebx,edx
  281.     @@: jif     edx,l,[viewport.left],.exit
  282.         jif     ebx,ge,[viewport.right],.exit
  283.         jif     ebx,ge,[viewport.left],@f
  284.         mov     ebx,[viewport.left]
  285.     @@: jif     edx,l,[viewport.right],@f
  286.         mov     edx,[viewport.right]
  287.         dec     edx
  288.     @@: mov     edi,1
  289.         jmp     .draw
  290. endf
  291.  
  292. ;-----------------------------------------------------------------------------
  293. func vm_mike_put_pixel.15 ;///////////////////////////////////////////////////
  294. ;-----------------------------------------------------------------------------
  295. ; eax = x coordinate
  296. ; ebx = y coordinate
  297. ; ecx = ?? RR GG BB    ; 0x01000000 negation
  298. ; edi = 0x00000001 force
  299. ;-----------------------------------------------------------------------------
  300. begin
  301.         pushad
  302.         cli
  303.         mov     edx,[BytesPerScanLine]
  304.         imul    edx,ebx
  305.         lea     edx,[edx+eax*2]
  306.         add     edx,[LFBAddress]
  307.         test    edi,1
  308.         jnz     .forced
  309.         mov     esi,[CURRENT_TASK]
  310.         mov     esi,[CLIP_RECTS+esi*4]
  311.         mov     edi,[esi]
  312.         or      edi,edi
  313.         jz      .exit
  314.         add     esi,4
  315.     @@: jif     eax,l,[rr.left],.skip
  316.         jif     eax,ge,[rr.right],.skip
  317.         jif     ebx,l,[rr.top],.skip
  318.         jif     ebx,ge,[rr.bottom],.skip
  319.         call    get_cursor_rect
  320.         call    is_intersect_pt
  321.         jc      .put
  322.         cmp     byte[MOUSE_VISIBLE],0
  323.         je      .put
  324.         call    [SF.draw_mouse_under]
  325.         mov     byte[MOUSE_VISIBLE],0
  326.   .put: push    edx
  327.         call    [set_bank]
  328.         pop     edx
  329.         test    ecx,0x01000000
  330.         jz      .lp1
  331.         not     word[ebp]
  332.         jmp     .exit
  333.   .lp1: shr     ecx,3
  334.         shl     cx,3
  335.         shr     ecx,3
  336.         shl     cl,3
  337.         shr     ecx,3
  338.         mov     [ebp],cx
  339.   .exit:
  340.         sti
  341.         popad
  342.         retn
  343.   .skip:
  344.         add     esi,SR
  345.         dec     edi
  346.         jnz     @b
  347.         jmp     .exit
  348.   .forced:
  349.         jif     eax,l,[viewport.left],.exit
  350.         jif     ebx,l,[viewport.top],.exit
  351.         jif     eax,ge,[viewport.right],.exit
  352.         jif     ebx,ge,[viewport.bottom],.exit
  353.         push    edx
  354.         call    [set_bank]
  355.         pop     edx
  356.         test    ecx,0x01000000
  357.         jz      @f
  358.         not     word[ebp]
  359.         jmp     .exit
  360.     @@: shr     ecx,3
  361.         shl     cx,3
  362.         shr     ecx,3
  363.         shl     cl,3
  364.         shr     ecx,3
  365.         mov     [ebp],cx
  366.         jmp     .exit
  367. endf
  368.  
  369. ;-----------------------------------------------------------------------------
  370. func vm_mike_get_pixel.15 ;///////////////////////////////////////////////////
  371. ;-----------------------------------------------------------------------------
  372. ; eax = x coordinate
  373. ; ebx = y coordinate
  374. ;-----------------------------------------------------------------------------
  375. begin
  376.         pushad
  377.         cli
  378.  
  379.         imul    ebx,[BytesPerScanLine]
  380.         shl     eax,1
  381.         add     eax,ebx
  382.         add     eax,[LFBAddress]
  383.         push    eax
  384.         call    [set_bank]
  385.         pop     eax
  386.         movzx   eax,word[ebp]
  387.  
  388.         shl     eax,3
  389.         shr     al,3
  390.         shl     eax,3
  391.         shr     ax,3
  392.         shl     eax,3
  393.  
  394.         and     eax,0x00FFFFFF
  395.         mov     [esp+4*6],eax
  396.  
  397.         sti
  398.         popad
  399.         retn
  400. endf
  401.  
  402. ;-----------------------------------------------------------------------------
  403. func vm_mike_put_image.15 ;///////////////////////////////////////////////////
  404. ;-----------------------------------------------------------------------------
  405. ; eax(ebx) pointer to image in memory - RRGGBBRRGGBB..
  406. ; ebx(ecx) image size [x]*65536+[y]
  407. ; ecx(edx) image position in window [x]*65536+[y]
  408. ; ret: eax 0 succesful, 1 overlapped
  409. ;-----------------------------------------------------------------------------
  410. begin
  411.         mov     eax,ebx
  412.         mov     ebx,ecx
  413.         mov     ecx,edx
  414.   .direct:
  415.         pushad
  416.         cli
  417.         jif     ebx,z,0x0000FFFF,.exit,test
  418.         jif     ebx,z,0xFFFF0000,.exit,test
  419.  
  420.         call    get_cursor_rect
  421.  
  422.         mov     ebp,eax
  423.         movsx   eax,word[esp+4*6+2]
  424.         movsx   ebx,word[esp+4*6]
  425.         movsx   ecx,word[esp+4*4+2]
  426.         movsx   edx,word[esp+4*4]
  427.         lea     edi,[ecx*3]
  428.         push    edi
  429.         add     ecx,eax
  430.         add     edx,ebx
  431.         mov     edi,[TASK_BASE]
  432.         movsx   esi,word[edi-CURRENT_TASK+0]
  433.         add     eax,esi
  434.         add     ecx,esi
  435.         movsx   esi,word[edi-CURRENT_TASK+4]
  436.         add     ebx,esi
  437.         add     edx,esi
  438. ;       add     eax,[esi-CURRENT_TASK+0]
  439. ;       add     ebx,[esi-CURRENT_TASK+4]
  440. ;       add     ecx,[esi-CURRENT_TASK+0]
  441. ;       add     edx,[esi-CURRENT_TASK+4]
  442.  
  443.         mov     esi,[CURRENT_TASK]
  444.         mov     esi,[CLIP_RECTS+esi*4]
  445.         mov     edi,[esi]
  446.         or      edi,edi
  447.         jz      .exit
  448.         add     esi,4
  449.         cld
  450.   .nx:  jif     ecx,l,[rr.left],.skip
  451.         jif     eax,ge,[rr.right],.skip
  452.         jif     edx,l,[rr.top],.skip
  453.         jif     ebx,ge,[rr.bottom],.skip
  454.         pushad
  455.         jif     eax,ge,[rr.left],@f
  456.         mov     eax,[rr.left]
  457.     @@: jif     ebx,ge,[rr.top],@f
  458.         mov     ebx,[rr.top]
  459.     @@: jif     ecx,l,[rr.right],@f
  460.         mov     ecx,[rr.right]
  461.     @@: jif     edx,l,[rr.bottom],@f
  462.         mov     edx,[rr.bottom]
  463.     @@: call    is_intersect_rc
  464.         jc      .put
  465.         cmp     byte[MOUSE_VISIBLE],0
  466.         je      .put
  467.         call    [SF.draw_mouse_under]
  468.         mov     byte[MOUSE_VISIBLE],0
  469.   .put: mov     esi,ebx
  470.         sub     esi,[esp+4*4]
  471.         imul    esi,[esp+4*8]
  472.         mov     edi,eax
  473.         sub     edi,[esp+4*7]
  474.         lea     edi,[edi*3]
  475.         add     esi,edi
  476.         add     esi,ebp
  477.         mov     edi,[BytesPerScanLine]
  478.         imul    edi,ebx
  479.         lea     edi,[edi+eax*2]
  480.         add     edi,[LFBAddress]
  481.   .xxx: push    eax esi edi eax
  482.     @@: lodsd
  483.         shr     eax,3
  484.         shl     ax,3
  485.         shr     eax,3
  486.         shl     al,3
  487.         shr     eax,3
  488.  
  489.         push    ebp edi
  490.         call    [set_bank]
  491.         mov     [ebp],ax
  492.         pop     edi ebp
  493.         add     edi,2
  494.  
  495.         dec     esi
  496.         inc     dword[esp]
  497.         cmp     [esp],ecx
  498.         jl      @b
  499.         pop     eax edi esi eax
  500.         add     esi,[esp+4*8]
  501.         add     edi,[BytesPerScanLine]
  502.         inc     ebx
  503.         cmp     ebx,edx
  504.         jl      .xxx
  505.         popad
  506.   .skip:
  507.         add     esi,SR
  508.         dec     edi
  509.         jnz     .nx
  510.  
  511.   .exit:
  512.         add     esp,4
  513.         sti
  514.         popad
  515.         xor     eax,eax
  516.         retn
  517. endf
  518.  
  519. ;-----------------------------------------------------------------------------
  520. func vm_mike_draw_bg.15 ;/////////////////////////////////////////////////////
  521. ;-----------------------------------------------------------------------------
  522. begin
  523.         pushad
  524.  
  525.         cmp     byte[bg_type],BGT_TILE
  526.         je      .tiled
  527.  
  528.         mov     eax,[bg_width]
  529.         cmp     eax,[ScreenWidth]
  530.         jne     @f
  531.         mov     eax,[bg_height]
  532.         cmp     eax,[ScreenHeight]
  533.         je      .tiled
  534.     @@:
  535.         imul    eax,[bg_width],3
  536.         mov     [bg_BytesPerScanLine],eax
  537.  
  538.         mov     eax,[viewport.left]
  539.         mov     ebx,[viewport.top]
  540.         mov     ecx,[viewport.right]
  541.         mov     edx,[viewport.bottom]
  542.  
  543.         cmp     [bg_width],1
  544.         jne     @f
  545.         cmp     [bg_height],1
  546.         je      .color
  547.     @@:
  548.         cli
  549.  
  550.         call    [SF.draw_mouse_under]
  551.         mov     byte[MOUSE_VISIBLE],0
  552.  
  553.         mov     esi,[CLIP_RECTS+4]
  554.         mov     ebp,[esi]
  555.         or      ebp,ebp
  556.         jz      .exit
  557.         add     esi,4
  558.   .nx:  jif     ecx,l,[rr.left],.skip
  559.         jif     eax,ge,[rr.right],.skip
  560.         jif     edx,l,[rr.top],.skip
  561.         jif     ebx,ge,[rr.bottom],.skip
  562.         pushad
  563.         jif     eax,ge,[rr.left],@f
  564.         mov     eax,[rr.left]
  565.     @@: jif     ebx,ge,[rr.top],@f
  566.         mov     ebx,[rr.top]
  567.     @@: jif     ecx,l,[rr.right],@f
  568.         mov     ecx,[rr.right]
  569.     @@: jif     edx,l,[rr.bottom],@f
  570.         mov     edx,[rr.bottom]
  571.     @@: ;call   is_intersect_rc
  572.         ;jc     .put
  573.         ;cmp    [mouse_invisible],0
  574.         ;jne    .put
  575.         ;call   [SF.draw_mouse_under]
  576.         ;mov    [mouse_invisible],1
  577.   .put: mov     ebp,[BytesPerScanLine]
  578.         imul    ebp,ebx
  579.         lea     ebp,[ebp+eax*2]
  580.         add     ebp,[LFBAddress]
  581.   .xxx: push    eax ebp
  582.     @@: push    ebp
  583.         call    [set_bank]
  584.         push    eax edx
  585.         mul     [bg_width]
  586.         div     dword[ScreenWidth]
  587.         lea     edi,[eax*3]
  588.         mov     eax,ebx
  589.         mul     [bg_height]
  590.         div     dword[ScreenHeight]
  591.         mul     [bg_BytesPerScanLine]
  592.         add     edi,eax
  593.         add     edi,IMG_BACKGROUND
  594.         mov     eax,[edi]
  595.         shr     eax,3
  596.         shl     ax,3
  597.         shr     eax,3
  598.         shl     al,3
  599.         shr     eax,3
  600.         mov     [ebp],ax
  601.         pop     edx eax
  602.         pop     ebp
  603.         inc     ebp
  604.         inc     ebp
  605.         inc     eax
  606.         cmp     eax,ecx
  607.         jl      @b
  608.         pop     ebp eax
  609.         add     ebp,[BytesPerScanLine]
  610.         inc     ebx
  611.         cmp     ebx,edx
  612.         jl      .xxx
  613.         popad
  614.   .skip:
  615.         add     esi,SR
  616.         dec     ebp
  617.         jnz     .nx
  618.  
  619.   .exit:
  620.         sti
  621.         popad
  622.         retn
  623.  
  624.   .tiled:
  625.         mov     eax,IMG_BACKGROUND
  626.         mov     ebx,[bg_width-2]
  627.         mov     bx,word[bg_height]
  628.         xor     ecx,ecx
  629.   .lp1: push    eax
  630.         call    vm_mike_put_image.15.direct
  631.         pop     eax
  632.         rol     ecx,16
  633.         add     cx,word[bg_width]
  634.         cmp     cx,word[ScreenWidth]
  635.         jae     @f
  636.         rol     ecx,16
  637.         jmp     .lp1
  638.     @@: shr     ecx,16
  639.         add     ecx,[bg_height]
  640.         cmp     ecx,[ScreenHeight]
  641.         jb      .lp1
  642.         popad
  643.         retn
  644.  
  645.   .color:
  646.         mov     edi,[IMG_BACKGROUND]
  647.         and     edi,0x00FFFFFF
  648.         call    vm_mike_draw_rect.15
  649.         popad
  650.         retn
  651. endf