Subversion Repositories Kolibri OS

Rev

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