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