Subversion Repositories Kolibri OS

Rev

Rev 5677 | Rev 5716 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5668 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
 
5715 hidnplayr 15
pixel_to_24bpp:         ; returns in ecx
16
 
5677 hidnplayr 17
if BITS_PER_PIXEL = 8
5715 hidnplayr 18
 
19
        push    eax ebx
20
 
21
        mov     bl, 36
5668 hidnplayr 22
        mov     al, [esi]
5715 hidnplayr 23
        and     al, 7
5668 hidnplayr 24
        mul     bl
5715 hidnplayr 25
        mov     ch, al          ; red
26
 
5668 hidnplayr 27
        mov     al, [esi]
5677 hidnplayr 28
        shr     al, 3
29
        and     al, 7
5668 hidnplayr 30
        mul     bl
5677 hidnplayr 31
        mov     cl, al          ; green
5715 hidnplayr 32
 
33
        mov     bl, 85
5668 hidnplayr 34
        mov     al, [esi]
5715 hidnplayr 35
        shr     al, 6
36
        and     al, 3
5668 hidnplayr 37
        mul     bl
5715 hidnplayr 38
        shl     ecx, 8
39
        mov     cl, al          ; blue
40
 
5677 hidnplayr 41
        inc     esi
5715 hidnplayr 42
        pop     ebx eax
43
 
5677 hidnplayr 44
else if BITS_PER_PIXEL = 16
5715 hidnplayr 45
 
46
        push    eax
5677 hidnplayr 47
        lodsw
5715 hidnplayr 48
        mov     cl, ah
49
        and     al, 0xf8        ; red
50
 
51
        mov     cx, ax
52
        shl     cx, 5
53
        and     ch, 0xfc        ; green
54
        shl     ecx, 8
55
 
5668 hidnplayr 56
        mov     cl, al
5677 hidnplayr 57
        shl     cl, 3
58
        and     cx, 0x00f8      ; blue
5715 hidnplayr 59
        pop     eax
60
 
5677 hidnplayr 61
else
5715 hidnplayr 62
 
5677 hidnplayr 63
        xor     ecx, ecx
64
        mov     cx, [esi]
5715 hidnplayr 65
        shl     ecx, 8
5677 hidnplayr 66
        mov     cl, [esi+2]
67
        add     esi, 3
5715 hidnplayr 68
 
5677 hidnplayr 69
end if
5668 hidnplayr 70
 
71
        ret
72
 
73
encoding_RRE:
74
 
5715 hidnplayr 75
        DEBUGF  1,"RRE\n"
5668 hidnplayr 76
 
77
  @@:
5715 hidnplayr 78
        lea     eax, [esi+4+BYTES_PER_PIXEL]
5668 hidnplayr 79
        cmp     [datapointer], eax
80
        jae     @f
81
        call    read_data.more
82
        jmp     @b
83
  @@:
84
 
85
        lodsd
86
        bswap   eax
87
        mov     [subrectangles], eax
88
 
5715 hidnplayr 89
        DEBUGF  1, "%u subrectangles\n", eax
90
 
91
; Get background color
5668 hidnplayr 92
        call    pixel_to_24bpp
93
 
5715 hidnplayr 94
; Calculate first pixel pos
5668 hidnplayr 95
        movzx   eax, [screen.width]
96
        mul     [rectangle.y]                           ; [screen.width]*[rectangle.y]
97
        add     eax, [rectangle.x]                      ; [screen.width]*[rectangle.y]+[rectangle.x]
98
        lea     edi, [framebuffer_data+eax*3]           ; edi = framebuffer_data+([screen.width]*[rectangle.y]+[rectangle.x])*3
99
 
5715 hidnplayr 100
; Calculate offset between two rows of pixels
5668 hidnplayr 101
        movzx   eax, [screen.width]
102
        sub     eax, [rectangle.width]
103
        lea     ebp, [eax*3]                            ; ebp = ([screen.width]-[rectangle.width])*3
104
 
5715 hidnplayr 105
; Draw background rectangle
5668 hidnplayr 106
        push    edi
107
        mov     eax, ecx
108
        mov     edx, [rectangle.height]
109
  .lineloop:
110
        mov     ecx, [rectangle.width]
111
  .pixelloop:
112
        stosw
113
        rol     eax, 16
114
        stosb
115
        rol     eax, 16
116
        dec     ecx
117
        jnz     .pixelloop
118
        add     edi, ebp
119
        dec     edx
120
        jnz     .lineloop
121
        pop     edi
122
 
5715 hidnplayr 123
; Any subrectangles at all?
124
        cmp     [subrectangles], 0
125
        je      next_rectangle
126
 
5668 hidnplayr 127
  .subrectangle:
128
  @@:
5715 hidnplayr 129
        lea     eax, [esi+8+BYTES_PER_PIXEL]
5668 hidnplayr 130
        cmp     [datapointer], eax
131
        jae     @f
132
        call    read_data.more
133
        jmp     @b
134
  @@:
135
 
5715 hidnplayr 136
; Get subrectangle color
5668 hidnplayr 137
        call    pixel_to_24bpp
138
 
5715 hidnplayr 139
; Get coordinates
5668 hidnplayr 140
        xor     eax, eax
141
        lodsw
142
        xchg    al, ah
143
        mov     [subrectangle.x], eax
144
        lodsw
145
        xchg    al, ah
146
        mov     [subrectangle.y], eax
147
        lodsw
148
        xchg    al, ah
5715 hidnplayr 149
        mov     [subrectangle.width], eax
5668 hidnplayr 150
        lodsw
151
        xchg    al, ah
5715 hidnplayr 152
        mov     [subrectangle.height], eax
153
        DEBUGF  1, "Subrectangle: x=%u y=%u width=%u height=%u\n", \
154
        [subrectangle.x], [subrectangle.y], [subrectangle.width], [subrectangle.height]
5668 hidnplayr 155
 
5715 hidnplayr 156
; Calculate pos of first pixel
5668 hidnplayr 157
        push    edi
5715 hidnplayr 158
        movzx   eax, [screen.width]
5668 hidnplayr 159
        mul     [subrectangle.y]
160
        add     eax, [subrectangle.x]
5715 hidnplayr 161
        lea     eax, [eax*3]
5668 hidnplayr 162
        add     edi, eax
163
 
5715 hidnplayr 164
; Calculate offset between two rows of pixels
165
        movzx   eax, [screen.width]
166
        sub     eax, [subrectangle.width]
167
        lea     ebp, [eax*3]                            ; ebp = ([screen.width]-[rectangle.width])*3
168
 
169
; Draw the subrectangle
5668 hidnplayr 170
        mov     eax, ecx
171
        mov     edx, [subrectangle.height]
172
  .lineloop2:
173
        mov     ecx, [subrectangle.width]
174
  .pixelloop2:
175
        stosw
176
        rol     eax, 16
177
        stosb
178
        rol     eax, 16
179
        dec     ecx
180
        jnz     .pixelloop2
181
        add     edi, ebp
182
        dec     edx
183
        jnz     .lineloop2
184
        pop     edi
185
        dec     [subrectangles]
186
        jnz     .subrectangle
187
        jmp     next_rectangle