Rev 5717 | 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 | |||
5722 | hidnplayr | 15 | load_pixel_rre: ; returns in ecx |
5715 | hidnplayr | 16 | |
5716 | hidnplayr | 17 | push eax |
5722 | 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 | |
5722 | hidnplayr | 68 | else if BITS_PER_PIXEL = 24 |
5715 | hidnplayr | 69 | |
5722 | hidnplayr | 70 | mov ecx, [esi] |
71 | and ecx, 0x00ffffff |
||
5677 | hidnplayr | 72 | add esi, 3 |
5715 | hidnplayr | 73 | |
5722 | hidnplayr | 74 | else if BITS_PER_PIXEL = 32 |
75 | |||
76 | mov ecx, [esi] |
||
77 | and ecx, 0x00ffffff |
||
78 | add esi, 4 |
||
79 | |||
5677 | hidnplayr | 80 | end if |
5716 | hidnplayr | 81 | pop eax |
5668 | hidnplayr | 82 | |
83 | ret |
||
84 | |||
85 | encoding_RRE: |
||
86 | |||
5715 | hidnplayr | 87 | DEBUGF 1,"RRE\n" |
5668 | hidnplayr | 88 | |
89 | @@: |
||
5715 | hidnplayr | 90 | lea eax, [esi+4+BYTES_PER_PIXEL] |
5668 | hidnplayr | 91 | cmp [datapointer], eax |
92 | jae @f |
||
93 | call read_data.more |
||
94 | jmp @b |
||
95 | @@: |
||
96 | |||
97 | lodsd |
||
98 | bswap eax |
||
99 | mov [subrectangles], eax |
||
100 | |||
5715 | hidnplayr | 101 | DEBUGF 1, "%u subrectangles\n", eax |
102 | |||
103 | ; Get background color |
||
5722 | hidnplayr | 104 | call load_pixel_rre |
5668 | hidnplayr | 105 | |
5715 | hidnplayr | 106 | ; Calculate first pixel pos |
5668 | hidnplayr | 107 | movzx eax, [screen.width] |
108 | mul [rectangle.y] ; [screen.width]*[rectangle.y] |
||
109 | add eax, [rectangle.x] ; [screen.width]*[rectangle.y]+[rectangle.x] |
||
5722 | hidnplayr | 110 | lea edi, [framebuffer+eax*3] ; edi = framebuffer_data+([screen.width]*[rectangle.y]+[rectangle.x])*3 |
5668 | hidnplayr | 111 | |
5715 | hidnplayr | 112 | ; Calculate offset between two rows of pixels |
5668 | hidnplayr | 113 | movzx eax, [screen.width] |
114 | sub eax, [rectangle.width] |
||
115 | lea ebp, [eax*3] ; ebp = ([screen.width]-[rectangle.width])*3 |
||
116 | |||
5715 | hidnplayr | 117 | ; Draw background rectangle |
5668 | hidnplayr | 118 | push edi |
119 | mov eax, ecx |
||
120 | mov edx, [rectangle.height] |
||
121 | .lineloop: |
||
122 | mov ecx, [rectangle.width] |
||
123 | .pixelloop: |
||
124 | stosw |
||
125 | rol eax, 16 |
||
126 | stosb |
||
127 | rol eax, 16 |
||
128 | dec ecx |
||
129 | jnz .pixelloop |
||
130 | add edi, ebp |
||
131 | dec edx |
||
132 | jnz .lineloop |
||
133 | pop edi |
||
134 | |||
5715 | hidnplayr | 135 | ; Any subrectangles at all? |
136 | cmp [subrectangles], 0 |
||
137 | je next_rectangle |
||
138 | |||
5668 | hidnplayr | 139 | .subrectangle: |
140 | @@: |
||
5715 | hidnplayr | 141 | lea eax, [esi+8+BYTES_PER_PIXEL] |
5668 | hidnplayr | 142 | cmp [datapointer], eax |
143 | jae @f |
||
144 | call read_data.more |
||
145 | jmp @b |
||
146 | @@: |
||
147 | |||
5715 | hidnplayr | 148 | ; Get subrectangle color |
5722 | hidnplayr | 149 | call load_pixel_rre |
5668 | hidnplayr | 150 | |
5715 | hidnplayr | 151 | ; Get coordinates |
5668 | hidnplayr | 152 | xor eax, eax |
153 | lodsw |
||
154 | xchg al, ah |
||
155 | mov [subrectangle.x], eax |
||
156 | lodsw |
||
157 | xchg al, ah |
||
158 | mov [subrectangle.y], eax |
||
159 | lodsw |
||
160 | xchg al, ah |
||
5715 | hidnplayr | 161 | mov [subrectangle.width], eax |
5668 | hidnplayr | 162 | lodsw |
163 | xchg al, ah |
||
5715 | hidnplayr | 164 | mov [subrectangle.height], eax |
165 | DEBUGF 1, "Subrectangle: x=%u y=%u width=%u height=%u\n", \ |
||
166 | [subrectangle.x], [subrectangle.y], [subrectangle.width], [subrectangle.height] |
||
5668 | hidnplayr | 167 | |
5715 | hidnplayr | 168 | ; Calculate pos of first pixel |
5668 | hidnplayr | 169 | push edi |
5715 | hidnplayr | 170 | movzx eax, [screen.width] |
5668 | hidnplayr | 171 | mul [subrectangle.y] |
172 | add eax, [subrectangle.x] |
||
5715 | hidnplayr | 173 | lea eax, [eax*3] |
5668 | hidnplayr | 174 | add edi, eax |
175 | |||
5715 | hidnplayr | 176 | ; Calculate offset between two rows of pixels |
177 | movzx eax, [screen.width] |
||
178 | sub eax, [subrectangle.width] |
||
179 | lea ebp, [eax*3] ; ebp = ([screen.width]-[rectangle.width])*3 |
||
180 | |||
181 | ; Draw the subrectangle |
||
5668 | hidnplayr | 182 | mov eax, ecx |
183 | mov edx, [subrectangle.height] |
||
184 | .lineloop2: |
||
185 | mov ecx, [subrectangle.width] |
||
186 | .pixelloop2: |
||
187 | stosw |
||
188 | rol eax, 16 |
||
189 | stosb |
||
190 | rol eax, 16 |
||
191 | dec ecx |
||
192 | jnz .pixelloop2 |
||
193 | add edi, ebp |
||
194 | dec edx |
||
195 | jnz .lineloop2 |
||
196 | pop edi |
||
197 | dec [subrectangles] |
||
198 | jnz .subrectangle |
||
199 | jmp next_rectangle |