2015-08-03 20:07:56 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; Copyright (C) KolibriOS team 2010-2015. All rights reserved. ;;
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;; VNC client for KolibriOS ;;
|
|
|
|
;; ;;
|
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2015-08-11 20:39:38 +02:00
|
|
|
pixel_to_24bpp: ; returns in ecx
|
|
|
|
|
2015-08-12 13:47:57 +02:00
|
|
|
push eax
|
|
|
|
@@:
|
|
|
|
lea eax, [esi+BYTES_PER_PIXEL]
|
|
|
|
cmp [datapointer], eax
|
|
|
|
jae @f
|
|
|
|
call read_data.more
|
|
|
|
jmp @b
|
|
|
|
@@:
|
|
|
|
|
2015-08-04 18:29:37 +02:00
|
|
|
if BITS_PER_PIXEL = 8
|
2015-08-11 20:39:38 +02:00
|
|
|
|
2015-08-12 13:47:57 +02:00
|
|
|
push ebx
|
2015-08-11 20:39:38 +02:00
|
|
|
|
|
|
|
mov bl, 36
|
2015-08-03 20:07:56 +02:00
|
|
|
mov al, [esi]
|
2015-08-11 20:39:38 +02:00
|
|
|
and al, 7
|
2015-08-03 20:07:56 +02:00
|
|
|
mul bl
|
2015-08-11 20:39:38 +02:00
|
|
|
mov ch, al ; red
|
|
|
|
|
2015-08-03 20:07:56 +02:00
|
|
|
mov al, [esi]
|
2015-08-04 18:29:37 +02:00
|
|
|
shr al, 3
|
|
|
|
and al, 7
|
2015-08-03 20:07:56 +02:00
|
|
|
mul bl
|
2015-08-04 18:29:37 +02:00
|
|
|
mov cl, al ; green
|
2015-08-11 20:39:38 +02:00
|
|
|
|
|
|
|
mov bl, 85
|
2015-08-03 20:07:56 +02:00
|
|
|
mov al, [esi]
|
2015-08-11 20:39:38 +02:00
|
|
|
shr al, 6
|
|
|
|
and al, 3
|
2015-08-03 20:07:56 +02:00
|
|
|
mul bl
|
2015-08-11 20:39:38 +02:00
|
|
|
shl ecx, 8
|
|
|
|
mov cl, al ; blue
|
|
|
|
|
2015-08-04 18:29:37 +02:00
|
|
|
inc esi
|
2015-08-12 13:47:57 +02:00
|
|
|
pop ebx
|
2015-08-11 20:39:38 +02:00
|
|
|
|
2015-08-04 18:29:37 +02:00
|
|
|
else if BITS_PER_PIXEL = 16
|
2015-08-11 20:39:38 +02:00
|
|
|
|
2015-08-04 18:29:37 +02:00
|
|
|
lodsw
|
2015-08-11 20:39:38 +02:00
|
|
|
mov cl, ah
|
|
|
|
and al, 0xf8 ; red
|
|
|
|
|
2015-08-04 18:29:37 +02:00
|
|
|
mov cx, ax
|
|
|
|
shl cx, 5
|
|
|
|
and ch, 0xfc ; green
|
2015-08-11 20:39:38 +02:00
|
|
|
shl ecx, 8
|
|
|
|
|
|
|
|
mov cl, al
|
|
|
|
shl cl, 3
|
|
|
|
and cx, 0x00f8 ; blue
|
|
|
|
|
2015-08-04 18:29:37 +02:00
|
|
|
else
|
2015-08-11 20:39:38 +02:00
|
|
|
|
2015-08-04 18:29:37 +02:00
|
|
|
xor ecx, ecx
|
|
|
|
mov cx, [esi]
|
2015-08-11 20:39:38 +02:00
|
|
|
shl ecx, 8
|
2015-08-04 18:29:37 +02:00
|
|
|
mov cl, [esi+2]
|
|
|
|
add esi, 3
|
2015-08-11 20:39:38 +02:00
|
|
|
|
2015-08-04 18:29:37 +02:00
|
|
|
end if
|
2015-08-12 13:47:57 +02:00
|
|
|
pop eax
|
2015-08-03 20:07:56 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
encoding_RRE:
|
|
|
|
|
2015-08-11 20:39:38 +02:00
|
|
|
DEBUGF 1,"RRE\n"
|
2015-08-03 20:07:56 +02:00
|
|
|
|
|
|
|
@@:
|
2015-08-11 20:39:38 +02:00
|
|
|
lea eax, [esi+4+BYTES_PER_PIXEL]
|
2015-08-03 20:07:56 +02:00
|
|
|
cmp [datapointer], eax
|
|
|
|
jae @f
|
|
|
|
call read_data.more
|
|
|
|
jmp @b
|
|
|
|
@@:
|
|
|
|
|
|
|
|
lodsd
|
|
|
|
bswap eax
|
|
|
|
mov [subrectangles], eax
|
|
|
|
|
2015-08-11 20:39:38 +02:00
|
|
|
DEBUGF 1, "%u subrectangles\n", eax
|
|
|
|
|
|
|
|
; Get background color
|
2015-08-03 20:07:56 +02:00
|
|
|
call pixel_to_24bpp
|
|
|
|
|
2015-08-11 20:39:38 +02:00
|
|
|
; Calculate first pixel pos
|
2015-08-03 20:07:56 +02:00
|
|
|
movzx eax, [screen.width]
|
|
|
|
mul [rectangle.y] ; [screen.width]*[rectangle.y]
|
|
|
|
add eax, [rectangle.x] ; [screen.width]*[rectangle.y]+[rectangle.x]
|
|
|
|
lea edi, [framebuffer_data+eax*3] ; edi = framebuffer_data+([screen.width]*[rectangle.y]+[rectangle.x])*3
|
|
|
|
|
2015-08-11 20:39:38 +02:00
|
|
|
; Calculate offset between two rows of pixels
|
2015-08-03 20:07:56 +02:00
|
|
|
movzx eax, [screen.width]
|
|
|
|
sub eax, [rectangle.width]
|
|
|
|
lea ebp, [eax*3] ; ebp = ([screen.width]-[rectangle.width])*3
|
|
|
|
|
2015-08-11 20:39:38 +02:00
|
|
|
; Draw background rectangle
|
2015-08-03 20:07:56 +02:00
|
|
|
push edi
|
|
|
|
mov eax, ecx
|
|
|
|
mov edx, [rectangle.height]
|
|
|
|
.lineloop:
|
|
|
|
mov ecx, [rectangle.width]
|
|
|
|
.pixelloop:
|
|
|
|
stosw
|
|
|
|
rol eax, 16
|
|
|
|
stosb
|
|
|
|
rol eax, 16
|
|
|
|
dec ecx
|
|
|
|
jnz .pixelloop
|
|
|
|
add edi, ebp
|
|
|
|
dec edx
|
|
|
|
jnz .lineloop
|
|
|
|
pop edi
|
|
|
|
|
2015-08-11 20:39:38 +02:00
|
|
|
; Any subrectangles at all?
|
|
|
|
cmp [subrectangles], 0
|
|
|
|
je next_rectangle
|
|
|
|
|
2015-08-03 20:07:56 +02:00
|
|
|
.subrectangle:
|
|
|
|
@@:
|
2015-08-11 20:39:38 +02:00
|
|
|
lea eax, [esi+8+BYTES_PER_PIXEL]
|
2015-08-03 20:07:56 +02:00
|
|
|
cmp [datapointer], eax
|
|
|
|
jae @f
|
|
|
|
call read_data.more
|
|
|
|
jmp @b
|
|
|
|
@@:
|
|
|
|
|
2015-08-11 20:39:38 +02:00
|
|
|
; Get subrectangle color
|
2015-08-03 20:07:56 +02:00
|
|
|
call pixel_to_24bpp
|
|
|
|
|
2015-08-11 20:39:38 +02:00
|
|
|
; Get coordinates
|
2015-08-03 20:07:56 +02:00
|
|
|
xor eax, eax
|
|
|
|
lodsw
|
|
|
|
xchg al, ah
|
|
|
|
mov [subrectangle.x], eax
|
|
|
|
lodsw
|
|
|
|
xchg al, ah
|
|
|
|
mov [subrectangle.y], eax
|
|
|
|
lodsw
|
|
|
|
xchg al, ah
|
2015-08-11 20:39:38 +02:00
|
|
|
mov [subrectangle.width], eax
|
2015-08-03 20:07:56 +02:00
|
|
|
lodsw
|
|
|
|
xchg al, ah
|
2015-08-11 20:39:38 +02:00
|
|
|
mov [subrectangle.height], eax
|
|
|
|
DEBUGF 1, "Subrectangle: x=%u y=%u width=%u height=%u\n", \
|
|
|
|
[subrectangle.x], [subrectangle.y], [subrectangle.width], [subrectangle.height]
|
2015-08-03 20:07:56 +02:00
|
|
|
|
2015-08-11 20:39:38 +02:00
|
|
|
; Calculate pos of first pixel
|
2015-08-03 20:07:56 +02:00
|
|
|
push edi
|
2015-08-11 20:39:38 +02:00
|
|
|
movzx eax, [screen.width]
|
2015-08-03 20:07:56 +02:00
|
|
|
mul [subrectangle.y]
|
|
|
|
add eax, [subrectangle.x]
|
2015-08-11 20:39:38 +02:00
|
|
|
lea eax, [eax*3]
|
2015-08-03 20:07:56 +02:00
|
|
|
add edi, eax
|
|
|
|
|
2015-08-11 20:39:38 +02:00
|
|
|
; Calculate offset between two rows of pixels
|
|
|
|
movzx eax, [screen.width]
|
|
|
|
sub eax, [subrectangle.width]
|
|
|
|
lea ebp, [eax*3] ; ebp = ([screen.width]-[rectangle.width])*3
|
|
|
|
|
|
|
|
; Draw the subrectangle
|
2015-08-03 20:07:56 +02:00
|
|
|
mov eax, ecx
|
|
|
|
mov edx, [subrectangle.height]
|
|
|
|
.lineloop2:
|
|
|
|
mov ecx, [subrectangle.width]
|
|
|
|
.pixelloop2:
|
|
|
|
stosw
|
|
|
|
rol eax, 16
|
|
|
|
stosb
|
|
|
|
rol eax, 16
|
|
|
|
dec ecx
|
|
|
|
jnz .pixelloop2
|
|
|
|
add edi, ebp
|
|
|
|
dec edx
|
|
|
|
jnz .lineloop2
|
|
|
|
pop edi
|
|
|
|
dec [subrectangles]
|
|
|
|
jnz .subrectangle
|
|
|
|
jmp next_rectangle
|