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