Subversion Repositories Kolibri OS

Rev

Rev 5708 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5666 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2010-2015. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
6
;;  VNC client for KolibriOS                                       ;;
7
;;                                                                 ;;
8
;;  Written by hidnplayr@kolibrios.org                             ;;
9
;;                                                                 ;;
10
;;          GNU GENERAL PUBLIC LICENSE                             ;;
11
;;             Version 2, June 1991                                ;;
12
;;                                                                 ;;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
 
5668 hidnplayr 15
encoding_CopyRect:
5666 hidnplayr 16
 
5708 hidnplayr 17
        DEBUGF  1,"CopyRect\n"
5666 hidnplayr 18
 
19
  @@:
20
        lea     eax, [esi+4]
21
        cmp     [datapointer], eax
22
        jae     @f
23
        call    read_data.more
24
        jmp     @b
25
  @@:
26
 
27
        push    esi
28
 
29
        movzx   eax, word[esi+2]                        ; [src.y]
30
        xchg    al, ah
31
        movzx   ebx, [screen.width]
32
        mul     ebx                                     ; [screen.width]*[src.y]
33
        movzx   ebx, word[esi]                          ; [src.x]
34
        xchg    bl, bh
35
        add     eax, ebx                                ; [screen.width]*[src.y]+[src.x]
5722 hidnplayr 36
        lea     esi, [framebuffer+eax*3]                ; esi = framebuffer_data+([screen.width]*[src.y]+[src.x])*3
5666 hidnplayr 37
 
5668 hidnplayr 38
        mov     eax, [rectangle.y]
5666 hidnplayr 39
        movzx   ebx, [screen.width]
40
        mul     ebx                                     ; [screen.width]*[rectangle.y]
5708 hidnplayr 41
        add     eax, [rectangle.x]                      ; [screen.width]*[rectangle.y]+[rectangle.x]
5722 hidnplayr 42
        lea     edi, [framebuffer+eax*3]                ; edi = framebuffer_data+([screen.width]*[rectangle.y]+[rectangle.x])*3
5666 hidnplayr 43
 
44
        movzx   eax, [screen.width]
5668 hidnplayr 45
        sub     eax, [rectangle.width]
5666 hidnplayr 46
        lea     ebp, [eax*3]                            ; ebp = ([screen.width]-[rectangle.width])*3
47
 
48
        cmp     esi, edi
5708 hidnplayr 49
        ja      .not_backwards
5666 hidnplayr 50
 
5708 hidnplayr 51
; Source pixels come before destination in buffer, copy backwards.
52
        DEBUGF  1,"backwards\n"
5668 hidnplayr 53
        mov     eax, [rectangle.height]
5708 hidnplayr 54
        dec     eax
5666 hidnplayr 55
        movzx   edx, [screen.width]
56
        mul     edx
5708 hidnplayr 57
        add     eax, [rectangle.width]
58
        lea     eax, [eax*3-1]                          ; eax = (([rectangle.height]-1)*[screen.width]+[rectangle.width])*3-1
5666 hidnplayr 59
        add     esi, eax
60
        add     edi, eax
61
        neg     ebp
62
        std
5708 hidnplayr 63
  .not_backwards:
5666 hidnplayr 64
 
5708 hidnplayr 65
; Do the actual copying
66
        mov     eax, [rectangle.width]
67
        lea     eax, [eax*3]
68
        mov     ebx, eax
69
        and     eax, 11b
70
        shr     ebx, 2
5668 hidnplayr 71
        mov     edx, [rectangle.height]
5666 hidnplayr 72
  .lineloop:
5708 hidnplayr 73
        mov     ecx, eax
74
        rep movsb
75
        mov     ecx, ebx
76
        rep movsd
5666 hidnplayr 77
        add     esi, ebp
78
        add     edi, ebp
79
        dec     edx
80
        jnz     .lineloop
81
 
82
        pop     esi
83
        add     esi, 4
84
        cld
85
        jmp     next_rectangle