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