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