VNC Viewer: render cursor locally, pixelcode optimizations, more efficient boundary checking, use lookup table for 8BPP, misc bugfixes.

git-svn-id: svn://kolibrios.org@5750 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2015-08-20 09:30:24 +00:00
parent 714d366ac8
commit ae13c6042f
8 changed files with 444 additions and 273 deletions

View File

@ -0,0 +1,167 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; 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 ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
encoding_cursor:
DEBUGF 1, "Set cursor: width=%u height=%u\n", [rectangle.width], [rectangle.height]
mov eax, [rectangle.width]
mul [rectangle.height]
mov ebx, eax
add ebx, 7
shr ebx, 3
mov ecx, BYTES_PER_PIXEL
mul ecx
lea ecx, [eax+ebx]
@@:
lea eax, [esi+ecx]
cmp [datapointer], eax
jae @f
call read_data.more
jmp @b
@@:
; TODO: chop larger cursor sizes to 32x32 ?
cmp [rectangle.width], 32
ja .fail
cmp [rectangle.height], 32
ja .fail
; Convert cursor image to 32*32 ARGB format
mov edi, cursor.image
mov edx, [rectangle.height]
test edx, edx
jz .zero_height
.lineloop:
mov ecx, [rectangle.width]
test ecx, ecx
jz .zero_width
.pixelloop:
call load_pixel
stosd
dec ecx
jnz .pixelloop
.zero_width:
mov ecx, 32
sub ecx, [rectangle.width]
jz @f
xor eax, eax
rep stosd
@@:
dec edx
jnz .lineloop
.zero_height:
mov ecx, 32
sub ecx, [rectangle.height]
jz @f
shl ecx, 5 ; mul 32
xor eax, eax
rep stosd
@@:
mov edi, cursor.image+3
mov edx, [rectangle.height]
test edx, edx
jz .finish
.zloop:
mov ecx, [rectangle.width]
test ecx, ecx
jz .finish
.aloop:
lodsb
mov bl, al
shl bl, 1
salc
mov byte[edi], al
add edi, 4
dec ecx
jz .n
shl bl, 1
salc
mov byte[edi], al
add edi, 4
dec ecx
jz .n
shl bl, 1
salc
mov byte[edi], al
add edi, 4
dec ecx
jz .n
shl bl, 1
salc
mov byte[edi], al
add edi, 4
dec ecx
jz .n
shl bl, 1
salc
mov byte[edi], al
add edi, 4
dec ecx
jz .n
shl bl, 1
salc
mov byte[edi], al
add edi, 4
dec ecx
jz .n
shl bl, 1
salc
mov byte[edi], al
add edi, 4
dec ecx
jz .n
shl bl, 1
salc
mov byte[edi], al
add edi, 4
dec ecx
jz .n
jmp .aloop
.n:
mov eax, 32
sub eax, [rectangle.width]
shl eax, 2
add edi, eax
dec edx
jnz .zloop
.finish:
mov eax, [rectangle.x]
mov [cursor.x], al
mov eax, [rectangle.y]
mov [cursor.y], al
or [work], WORK_CURSOR
DEBUGF 1, "Set cursor succeeded\n"
jmp next_rectangle
.fail:
add esi, ecx
DEBUGF 2, "Set cursor failed!\n"
jmp next_rectangle

View File

@ -13,6 +13,9 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
draw_gui: draw_gui:
mcall 67, 160, 160, 330, 100 ; resize and move the window
mcall 66, 1, 0 ; switch keyboard to ascii mode
.first_time:
mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_REDRAW + EVM_BUTTON + EVM_KEY mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_REDRAW + EVM_BUTTON + EVM_KEY
.redraw: .redraw:
@ -153,12 +156,12 @@ draw_gui:
mcall 4 ; OK button text mcall 4 ; OK button text
.redraw_done: .redraw_done:
mov [update_gui], 0 and [work], not WORK_GUI
mcall 12, 2 mcall 12, 2
.loop: .loop:
cmp [update_gui], 0 test [work], WORK_GUI
jne .redraw jnz .redraw
cmp [status], STATUS_CONNECTED cmp [status], STATUS_CONNECTED
je .connected je .connected
@ -227,17 +230,22 @@ draw_gui:
.login: .login:
mov [status], STATUS_LOGIN mov [status], STATUS_LOGIN
inc [update_gui] or [work], WORK_GUI
jmp .loop jmp .loop
.cancel: .cancel:
mcall 18, 18, [thread_id] ; kill thread mcall 18, 18, [thread_id] ; kill thread
.ok: .ok:
cmp [status], STATUS_LIB_ERR
je .close
and [URLbox.flags], not ed_disabled and [URLbox.flags], not ed_disabled
mov [USERbox.size], 0 mov [USERbox.size], 0
mov [PASSbox.size], 0 mov [PASSbox.size], 0
mov [status], STATUS_CONNECT mov [status], STATUS_CONNECT
inc [update_gui] mov [name.dash], 0
mcall 71, 1, name ; reset window caption
or [work], WORK_GUI
jmp .loop jmp .loop
.mouse: .mouse:
@ -269,6 +277,6 @@ open_connection:
mov [status], STATUS_THREAD_ERR mov [status], STATUS_THREAD_ERR
@@: @@:
mov [thread_id], eax mov [thread_id], eax
inc [update_gui] or [work], WORK_GUI
ret ret

View File

@ -119,7 +119,7 @@ vnc_security:
or [PASSbox.flags], ed_focus or [PASSbox.flags], ed_focus
mov [status], STATUS_REQ_LOGIN mov [status], STATUS_REQ_LOGIN
inc [update_gui] or [work], WORK_GUI
@@: @@:
mcall 5, 10 mcall 5, 10
cmp [status], STATUS_LOGIN cmp [status], STATUS_LOGIN
@ -247,15 +247,7 @@ initialize:
mov [name.dash], "-" mov [name.dash], "-"
DEBUGF 1, "Sending pixel format\n" DEBUGF 1, "Sending pixel format\n"
if BITS_PER_PIXEL = 8 mcall send, [socketnum], SetPixelFormat, 20, 0
mcall send, [socketnum], SetPixelFormat8, 20, 0
else if BITS_PER_PIXEL = 16
mcall send, [socketnum], SetPixelFormat16, 20, 0
else if BITS_PER_PIXEL = 24
mcall send, [socketnum], SetPixelFormat24, 20, 0
else
mcall send, [socketnum], SetPixelFormat32, 20, 0
end if
DEBUGF 1, "Sending encoding info\n" DEBUGF 1, "Sending encoding info\n"
mcall send, [socketnum], SetEncodings, SetEncodings.length, 0 mcall send, [socketnum], SetEncodings, SetEncodings.length, 0
@ -342,12 +334,14 @@ rectangle_loop:
je encoding_TRLE je encoding_TRLE
cmp eax, 16 cmp eax, 16
je encoding_ZRLE je encoding_ZRLE
cmp eax, 0xffffff11
je encoding_cursor
DEBUGF 2, "unknown encoding: %u\n", eax DEBUGF 2, "unknown encoding: %u\n", eax
jmp thread_loop jmp thread_loop
next_rectangle: next_rectangle:
inc [update_framebuffer] or [work], WORK_FRAMEBUFFER
dec [rectangles] dec [rectangles]
jnz rectangle_loop jnz rectangle_loop
jmp request_fbu jmp request_fbu
@ -462,30 +456,30 @@ read_data:
err_disconnected: err_disconnected:
mov [status], STATUS_DISCONNECTED mov [status], STATUS_DISCONNECTED
inc [update_gui] or [work], WORK_GUI
mcall -1 mcall -1
err_dns: err_dns:
mov [status], STATUS_DNS_ERR mov [status], STATUS_DNS_ERR
inc [update_gui] or [work], WORK_GUI
mcall -1 mcall -1
err_sock: err_sock:
; TODO: distinguish between different socket errors! ; TODO: distinguish between different socket errors!
DEBUGF 2, "Socket error: %u\n", ebx DEBUGF 2, "Socket error: %u\n", ebx
mov [status], STATUS_SOCK_ERR mov [status], STATUS_SOCK_ERR
inc [update_gui] or [work], WORK_GUI
mcall -1 mcall -1
err_connect: err_connect:
mov [status], STATUS_CONNECT_ERR mov [status], STATUS_CONNECT_ERR
inc [update_gui] or [work], WORK_GUI
mcall -1 mcall -1
ret ret
err_proto: err_proto:
mov [status], STATUS_PROTO_ERR mov [status], STATUS_PROTO_ERR
inc [update_gui] or [work], WORK_GUI
mcall -1 mcall -1
ret ret
@ -507,12 +501,12 @@ err_handshake:
mov [status], STATUS_SECURITY_ERR_C mov [status], STATUS_SECURITY_ERR_C
.no_msg: .no_msg:
inc [update_gui] or [work], WORK_GUI
mcall -1 mcall -1
ret ret
err_login: err_login:
mov [status], STATUS_LOGIN_FAILED mov [status], STATUS_LOGIN_FAILED
inc [update_gui] or [work], WORK_GUI
mcall -1 mcall -1
ret ret

View File

@ -51,29 +51,15 @@ end if
.lineloop: .lineloop:
mov ecx, [rectangle.width] mov ecx, [rectangle.width]
if BITS_PER_PIXEL = 24
lea ecx, [ecx*2+ecx]
end if
if BITS_PER_PIXEL = 8 if BITS_PER_PIXEL = 8
.pixelloop: .pixelloop:
mov bl, 85 xor eax, eax
mov al, [esi] lodsb
shr al, 6 mov eax, [lut_8bpp+eax*4]
and al, 3 stosw
mul bl shr eax, 16
stosb ; blue stosb
mov bl, 36
mov al, [esi]
shr al, 3
and al, 7
mul bl
stosb ; green
mov al, [esi]
and al, 7
mul bl
stosb ; red
inc esi
dec ecx dec ecx
jnz .pixelloop jnz .pixelloop
else if BITS_PER_PIXEL = 16 else if BITS_PER_PIXEL = 16
@ -93,6 +79,7 @@ else if BITS_PER_PIXEL = 16
dec ecx dec ecx
jnz .pixelloop jnz .pixelloop
else if BITS_PER_PIXEL = 24 else if BITS_PER_PIXEL = 24
lea ecx, [ecx*2+ecx]
rep movsb rep movsb
else if BITS_PER_PIXEL = 32 else if BITS_PER_PIXEL = 32
.pixelloop: .pixelloop:

View File

@ -12,76 +12,48 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
load_pixel_rre: ; returns in ecx load_pixel: ; returns in eax
push eax
@@:
lea eax, [esi+BYTES_PER_PIXEL]
cmp [datapointer], eax
jae @f
call read_data.more
jmp @b
@@:
if BITS_PER_PIXEL = 8 if BITS_PER_PIXEL = 8
push ebx xor eax, eax
lodsb
mov bl, 36 mov eax, [lut_8bpp+eax*4]
mov al, [esi]
and al, 7
mul bl
mov ch, al ; red
mov al, [esi]
shr al, 3
and al, 7
mul bl
mov cl, al ; green
mov bl, 85
mov al, [esi]
shr al, 6
and al, 3
mul bl
shl ecx, 8
mov cl, al ; blue
inc esi
pop ebx
else if BITS_PER_PIXEL = 16 else if BITS_PER_PIXEL = 16
push ebx
lodsw lodsw
mov cl, ah mov bx, ax
and al, 0xf8 ; red shl bx, 5
and bh, 0xfc ; green
mov cx, ax mov bl, ah
shl cx, 5 and bl, 0xf8 ; red
and ch, 0xfc ; green shl ebx, 8
shl ecx, 8
mov cl, al mov bl, al
shl cl, 3 shl bl, 3
and cx, 0x00f8 ; blue and bl, 0xf8 ; blue
mov eax, ebx
pop ebx
else if BITS_PER_PIXEL = 24 else if BITS_PER_PIXEL = 24
mov ecx, [esi] mov eax, [esi]
and ecx, 0x00ffffff and eax, 0x00ffffff
add esi, 3 add esi, 3
else if BITS_PER_PIXEL = 32 else if BITS_PER_PIXEL = 32
mov ecx, [esi] lodsd
and ecx, 0x00ffffff
add esi, 4
end if end if
pop eax
ret ret
encoding_RRE: encoding_RRE:
DEBUGF 1,"RRE\n" DEBUGF 1,"RRE\n"
@ -100,9 +72,6 @@ encoding_RRE:
DEBUGF 1, "%u subrectangles\n", eax DEBUGF 1, "%u subrectangles\n", eax
; Get background color
call load_pixel_rre
; Calculate first pixel pos ; Calculate first pixel pos
movzx eax, [screen.width] movzx eax, [screen.width]
mul [rectangle.y] ; [screen.width]*[rectangle.y] mul [rectangle.y] ; [screen.width]*[rectangle.y]
@ -114,9 +83,11 @@ encoding_RRE:
sub eax, [rectangle.width] sub eax, [rectangle.width]
lea ebp, [eax*3] ; ebp = ([screen.width]-[rectangle.width])*3 lea ebp, [eax*3] ; ebp = ([screen.width]-[rectangle.width])*3
; Get background color
call load_pixel
; Draw background rectangle ; Draw background rectangle
push edi push edi
mov eax, ecx
mov edx, [rectangle.height] mov edx, [rectangle.height]
.lineloop: .lineloop:
mov ecx, [rectangle.width] mov ecx, [rectangle.width]
@ -137,6 +108,7 @@ encoding_RRE:
je next_rectangle je next_rectangle
.subrectangle: .subrectangle:
push edi
@@: @@:
lea eax, [esi+8+BYTES_PER_PIXEL] lea eax, [esi+8+BYTES_PER_PIXEL]
cmp [datapointer], eax cmp [datapointer], eax
@ -146,7 +118,8 @@ encoding_RRE:
@@: @@:
; Get subrectangle color ; Get subrectangle color
call load_pixel_rre call load_pixel
push eax
; Get coordinates ; Get coordinates
xor eax, eax xor eax, eax
@ -166,7 +139,6 @@ encoding_RRE:
[subrectangle.x], [subrectangle.y], [subrectangle.width], [subrectangle.height] [subrectangle.x], [subrectangle.y], [subrectangle.width], [subrectangle.height]
; Calculate pos of first pixel ; Calculate pos of first pixel
push edi
movzx eax, [screen.width] movzx eax, [screen.width]
mul [subrectangle.y] mul [subrectangle.y]
add eax, [subrectangle.x] add eax, [subrectangle.x]
@ -179,7 +151,7 @@ encoding_RRE:
lea ebp, [eax*3] ; ebp = ([screen.width]-[rectangle.width])*3 lea ebp, [eax*3] ; ebp = ([screen.width]-[rectangle.width])*3
; Draw the subrectangle ; Draw the subrectangle
mov eax, ecx pop eax
mov edx, [subrectangle.height] mov edx, [subrectangle.height]
.lineloop2: .lineloop2:
mov ecx, [subrectangle.width] mov ecx, [subrectangle.width]
@ -196,4 +168,5 @@ encoding_RRE:
pop edi pop edi
dec [subrectangles] dec [subrectangles]
jnz .subrectangle jnz .subrectangle
jmp next_rectangle jmp next_rectangle

View File

@ -15,82 +15,63 @@
create_palette: create_palette:
push ecx edx edi push eax ecx edi
mov dl, [palettesize] movzx ecx, [palettesize]
DEBUGF 1, "Loading palette of %u colors\n", dl lea ecx, [ecx*BYTES_PER_CPIXEL]
mov edi, palette
.loop:
call load_pixel_trle
mov [edi], ecx
add edi, 4
dec dl
jnz .loop
pop edi edx ecx
ret
load_pixel_trle: ; returns in ecx
push eax
@@: @@:
lea eax, [esi+BYTES_PER_PIXEL] lea eax, [esi+ecx]
cmp [datapointer], eax cmp [datapointer], eax
jae @f jae @f
call read_data.more call read_data.more
jmp @b jmp @b
@@: @@:
DEBUGF 1, "Loading palette of %u colors\n", ecx
mov edi, palette
.loop:
call load_cpixel
stosd
dec ecx
jnz .loop
pop edi ecx eax
ret
load_cpixel: ; returns in eax
if BITS_PER_PIXEL = 8 if BITS_PER_PIXEL = 8
push ebx xor eax, eax
lodsb
mov bl, 36 mov eax, [lut_8bpp+eax*4]
mov al, [esi]
and al, 7
mul bl
mov ch, al ; red
mov al, [esi]
shr al, 3
and al, 7
mul bl
mov cl, al ; green
mov bl, 85
mov al, [esi]
shr al, 6
and al, 3
mul bl
shl ecx, 8
mov cl, al ; blue
inc esi
pop ebx
else if BITS_PER_PIXEL = 16 else if BITS_PER_PIXEL = 16
push ebx
lodsw lodsw
mov cl, ah mov bx, ax
and al, 0xf8 ; red shl bx, 5
and bh, 0xfc ; green
mov cx, ax mov bl, ah
shl cx, 5 and bl, 0xf8 ; red
and ch, 0xfc ; green shl ebx, 8
shl ecx, 8
mov cl, al mov bl, al
shl cl, 3 shl bl, 3
and cx, 0x00f8 ; blue and bl, 0xf8 ; blue
mov eax, ebx
pop ebx
else ; 32 BPP gets packed to 24 BPP else ; 32 BPP gets packed to 24 BPP
mov ecx, [esi] mov eax, [esi]
and ecx, 0x00ffffff and eax, 0x00ffffff
add esi, 3 add esi, 3
end if end if
pop eax
ret ret
@ -262,15 +243,16 @@ encoding_TRLE:
jmp .next_tile jmp .next_tile
.rle_reload: .rle_reload:
call load_pixel_trle
@@: @@:
lea eax, [esi+1] lea eax, [esi+BYTES_PER_CPIXEL+1]
cmp [datapointer], eax cmp [datapointer], eax
jae @f jae @f
call read_data.more call read_data.more
jmp @b jmp @b
@@: @@:
; load pixel value
call load_cpixel
mov ecx, eax
; load length ; load length
xor eax, eax xor eax, eax
@ -293,9 +275,9 @@ encoding_TRLE:
.reuse_palette: .reuse_palette:
cmp [palettesize], 1 cmp [palettesize], 1
jne .reuse_palette_ jne .reuse_palette_
mov ecx, [palette] mov eax, [palette]
mov eax, ecx mov ecx, eax
shr eax, 16 shr ecx, 16
jmp .solid_line jmp .solid_line
; Palette packed tile ; Palette packed tile
@ -493,30 +475,28 @@ encoding_TRLE:
push edx push edx
mov eax, [subrectangle.width] mov eax, [subrectangle.width]
mul [subrectangle.height] mul [subrectangle.height]
lea eax, [eax*3]
pop edx
@@:
push eax push eax
add eax, esi lea ecx, [eax*BYTES_PER_CPIXEL]
@@:
lea eax, [esi+ecx]
cmp [datapointer], eax cmp [datapointer], eax
jae @f jae @f
call read_data.more call read_data.more
pop eax
jmp @b jmp @b
@@: @@:
pop eax pop eax
lea eax, [eax*3]
pop edx
DEBUGF 1, "RAW tile\n" DEBUGF 1, "RAW tile\n"
.raw_line: .raw_line:
mov ebx, [subrectangle.width] mov ebx, [subrectangle.width]
.raw_pixel: .raw_pixel:
call load_pixel_trle call load_cpixel
mov word[edi], cx stosw
shr ecx, 16 shr eax, 16
add edi, 2 stosb
mov byte[edi], cl
inc edi
dec ebx dec ebx
jnz .raw_pixel jnz .raw_pixel
add edi, ebp add edi, ebp
@ -529,19 +509,25 @@ encoding_TRLE:
; Single color tile ; Single color tile
.solid: .solid:
DEBUGF 1, "Solid tile\n" DEBUGF 1, "Solid tile\n"
call load_pixel_trle @@:
mov eax, ecx lea eax, [esi+BYTES_PER_CPIXEL]
shr eax, 16 cmp [datapointer], eax
jae @f
call read_data.more
jmp @b
@@:
call load_cpixel
mov ecx, eax
shr ecx, 16
mov [palettesize], 1 mov [palettesize], 1
mov [palette], ecx mov [palette], eax
.solid_line: .solid_line:
mov ebx, [subrectangle.width] mov ebx, [subrectangle.width]
.solid_pixel: .solid_pixel:
mov [edi], cx stosw
add edi, 2 mov [edi], cl
mov [edi], al
inc edi inc edi
dec ebx dec ebx
jnz .solid_pixel jnz .solid_pixel

View File

@ -87,8 +87,18 @@ STATUS_THREAD_ERR = 17
STATUS_LOGIN_FAILED = 18 STATUS_LOGIN_FAILED = 18
STATUS_SECURITY_ERR_C = 19 STATUS_SECURITY_ERR_C = 19
WORK_FRAMEBUFFER = 1 shl 0
WORK_CURSOR = 1 shl 1
WORK_GUI = 1 shl 2
BYTES_PER_PIXEL = (BITS_PER_PIXEL + 7) / 8 BYTES_PER_PIXEL = (BITS_PER_PIXEL + 7) / 8
if BITS_PER_PIXEL = 32
BYTES_PER_CPIXEL= 3
else
BYTES_PER_CPIXEL= BYTES_PER_PIXEL
end if
include "keymap.inc" include "keymap.inc"
include "gui.inc" include "gui.inc"
include "network.inc" include "network.inc"
@ -97,8 +107,63 @@ include "copyrect.inc"
include "rre.inc" include "rre.inc"
include "trle.inc" include "trle.inc"
include "zrle.inc" include "zrle.inc"
include "cursor.inc"
include "des.inc" include "des.inc"
if BITS_PER_PIXEL = 8
create_lut:
mov edi, lut_8bpp ; 332 format
xor eax, eax
call green
add eax, 0x240000
call green
add eax, 0x250000
call green
add eax, 0x240000
call green
add eax, 0x250000
call green
add eax, 0x240000
call green
add eax, 0x250000
call green
add eax, 0x240000
call green
ret
green:
mov ah, 0
call blue
mov ah, 36
call blue
add ah, 37
call blue
add ah, 36
call blue
add ah, 37
call blue
add ah, 36
call blue
add ah, 37
call blue
add ah, 36
call blue
ret
blue:
mov al, 0
stosd
mov al, 85
stosd
mov al, 170
stosd
mov al, 255
stosd
ret
end if
START: START:
mcall 68, 11 ; init heap mcall 68, 11 ; init heap
@ -108,8 +173,14 @@ START:
test eax, eax test eax, eax
jz @f jz @f
mov [status], STATUS_LIB_ERR mov [status], STATUS_LIB_ERR
jmp draw_gui.first_time
@@: @@:
; When using 8BPP, create lookup table
if BITS_PER_PIXEL = 8
call create_lut
end if
; Check if we got a server address through parameters ; Check if we got a server address through parameters
cmp byte[serveraddr], 0 cmp byte[serveraddr], 0
je @f je @f
@ -124,7 +195,7 @@ START:
@@: @@:
; Present the user with the GUI and wait for network connection ; Present the user with the GUI and wait for network connection
call draw_gui call draw_gui.first_time
; Create main window ; Create main window
mcall 71, 1, name ; reset window caption (add server name) mcall 71, 1, name ; reset window caption (add server name)
@ -157,15 +228,17 @@ redraw:
draw_framebuffer: draw_framebuffer:
DEBUGF 1, "Drawing framebuffer\n" DEBUGF 1, "Drawing framebuffer\n"
mcall 7, framebuffer, dword[screen], 0 mcall 7, framebuffer, dword[screen], 0
mov [update_framebuffer], 0 and [work], not WORK_FRAMEBUFFER
mainloop: mainloop:
cmp [status], STATUS_CONNECTED cmp [status], STATUS_CONNECTED
jne draw_gui jne draw_gui
cmp [update_framebuffer], 0 test [work], WORK_FRAMEBUFFER
jne draw_framebuffer jnz draw_framebuffer
test [work], WORK_CURSOR
jnz update_cursor
mcall 23, 10 ; Check for event with 0,1s timeout mcall 23, 10 ; Check for event with 0,1s timeout
dec eax dec eax
jz redraw jz redraw
@ -258,6 +331,29 @@ button:
mcall -1 mcall -1
update_cursor:
; load cursor
mov dx, word[cursor.y]
shl edx, 16
mov dx, 2
mcall 37, 4, cursor.image
test eax, eax
jz .fail
; set cursor
mov ecx, eax
mcall 37, 5
; delete previously set cursor
mov ecx, eax
mcall 37, 6
.fail:
and [work], not WORK_CURSOR
jmp mainloop
; DATA AREA ; DATA AREA
include_debug_strings include_debug_strings
@ -272,7 +368,9 @@ HandShake db "RFB 003.003", 10
ClientInit db 0 ; not shared ClientInit db 0 ; not shared
SetPixelFormat32 db 0 ; setPixelformat if BITS_PER_PIXEL = 32
SetPixelFormat db 0 ; setPixelformat
db 0, 0, 0 ; padding db 0, 0, 0 ; padding
.bpp db 32 ; bits per pixel .bpp db 32 ; bits per pixel
.depth db 24 ; depth .depth db 24 ; depth
@ -286,7 +384,9 @@ SetPixelFormat32 db 0 ; setPixelformat
.blue_shift db 0 ; blue-shift .blue_shift db 0 ; blue-shift
db 0, 0, 0 ; padding db 0, 0, 0 ; padding
SetPixelFormat24 db 0 ; setPixelformat else if BITS_PER_PIXEL = 24
SetPixelFormat db 0 ; setPixelformat
db 0, 0, 0 ; padding db 0, 0, 0 ; padding
.bpp db 24 ; bits per pixel .bpp db 24 ; bits per pixel
.depth db 24 ; depth .depth db 24 ; depth
@ -300,7 +400,9 @@ SetPixelFormat24 db 0 ; setPixelformat
.blue_shift db 0 ; blue-shift .blue_shift db 0 ; blue-shift
db 0, 0, 0 ; padding db 0, 0, 0 ; padding
SetPixelFormat16 db 0 ; setPixelformat else if BITS_PER_PIXEL = 16
SetPixelFormat db 0 ; setPixelformat
db 0, 0, 0 ; padding db 0, 0, 0 ; padding
.bpp db 16 ; bits per pixel .bpp db 16 ; bits per pixel
.depth db 16 ; depth .depth db 16 ; depth
@ -314,7 +416,9 @@ SetPixelFormat16 db 0 ; setPixelformat
.blue_shift db 0 ; blue-shift .blue_shift db 0 ; blue-shift
db 0, 0, 0 ; padding db 0, 0, 0 ; padding
SetPixelFormat8 db 0 ; setPixelformat else if BITS_PER_PIXEL = 8
SetPixelFormat db 0 ; setPixelformat
db 0, 0, 0 ; padding db 0, 0, 0 ; padding
.bpp db 8 ; bits per pixel .bpp db 8 ; bits per pixel
.depth db 8 ; depth .depth db 8 ; depth
@ -323,18 +427,21 @@ SetPixelFormat8 db 0 ; setPixelformat
.red_max db 0, 7 ; red-max .red_max db 0, 7 ; red-max
.green_max db 0, 7 ; green-max .green_max db 0, 7 ; green-max
.blue_max db 0, 3 ; blue-max .blue_max db 0, 3 ; blue-max
.red_shift db 0 ; red-shift .red_shift db 5 ; red-shift
.green_shift db 3 ; green-shift .green_shift db 2 ; green-shift
.blue_shift db 6 ; blue-shift .blue_shift db 0 ; blue-shift
db 0, 0, 0 ; padding db 0, 0, 0 ; padding
end if
SetEncodings db 2 ; setEncodings SetEncodings db 2 ; setEncodings
db 0 ; padding db 0 ; padding
db 0, 4 ; number of encodings db 0, 5 ; number of encodings
; db 0, 0, 0, 16 ; ZRLE ; db 0, 0, 0, 16 ; ZRLE
db 0, 0, 0, 15 ; TRLE db 0, 0, 0, 15 ; TRLE
db 0, 0, 0, 2 ; RRE db 0, 0, 0, 2 ; RRE
db 0, 0, 0, 1 ; Copyrect encoding db 0, 0, 0, 1 ; Copyrect encoding
db 0xff, 0xff, 0xff, 0x11 ; Cursor pseudo encoding
db 0, 0, 0, 0 ; raw encoding db 0, 0, 0, 0 ; raw encoding
.length = $ - SetEncodings .length = $ - SetEncodings
@ -365,9 +472,8 @@ sockaddr1:
beep db 0x85, 0x25, 0x85, 0x40, 0 beep db 0x85, 0x25, 0x85, 0x40, 0
status dd STATUS_CONNECT status dd STATUS_CONNECT
update_gui dd 0 work dd 0
mouse_dd dd 0 mouse_dd dd 0
update_framebuffer dd 0
thread_id dd 0 thread_id dd 0
deflate_buffer dd 0 deflate_buffer dd 0
@ -474,7 +580,17 @@ keymap_shift rw 128
keymap_alt rw 128 keymap_alt rw 128
username rb 128 username rb 128
password rb 128 password rb 128
keys rd 32*2 ; DES keys for VNC authentication keys rd 32*2 ; DES keys for VNC authentication
cursor:
.y db ?
.x db ?
.image rd 32*32
align 4
if BITS_PER_PIXEL = 8
lut_8bpp rd 256
end if
sz_err_security_c rb 512+1 sz_err_security_c rb 512+1

View File

@ -13,67 +13,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
load_pixel_zrle: ; returns in ecx
push eax
; TODO: check for buffer underrun!
if BITS_PER_PIXEL = 8
push ebx
mov bl, 36
mov al, [esi]
and al, 7
mul bl
mov ch, al ; red
mov al, [esi]
shr al, 3
and al, 7
mul bl
mov cl, al ; green
mov bl, 85
mov al, [esi]
shr al, 6
and al, 3
mul bl
shl ecx, 8
mov cl, al ; blue
inc esi
pop ebx
else if BITS_PER_PIXEL = 16
lodsw
mov cl, ah
and al, 0xf8 ; red
mov cx, ax
shl cx, 5
and ch, 0xfc ; green
shl ecx, 8
mov cl, al
shl cl, 3
and cx, 0x00f8 ; blue
else ; 32 BPP gets packed to 24 BPP
mov ecx, [esi]
and ecx, 0x00ffffff
add esi, 3
end if
pop eax
ret
deflate_callback: deflate_callback:
mov eax, [deflate_length] mov eax, [deflate_length]
mov ecx, [esp+8] mov ecx, [esp+8]
@ -82,7 +21,6 @@ deflate_callback:
ret 8 ret 8
encoding_ZRLE: encoding_ZRLE:
DEBUGF 2, "ZRLE\n" DEBUGF 2, "ZRLE\n"
@ -283,9 +221,11 @@ encoding_ZRLE:
jmp .next_tile jmp .next_tile
.rle_reload: .rle_reload:
call load_pixel_zrle ; TODO: check for buffer underrun
;;; ; load pixel value
call load_cpixel
mov ecx, eax
; load length ; load length
xor eax, eax xor eax, eax
@ -511,18 +451,16 @@ encoding_ZRLE:
lea eax, [eax*3] lea eax, [eax*3]
pop edx pop edx
;;; ; TODO: check for buffer underrun
DEBUGF 1, "RAW tile\n" DEBUGF 1, "RAW tile\n"
.raw_line: .raw_line:
mov ebx, [subrectangle.width] mov ebx, [subrectangle.width]
.raw_pixel: .raw_pixel:
call load_pixel_zrle call load_cpixel
mov word[edi], cx stosw
shr ecx, 16 shr eax, 16
add edi, 2 stosb
mov byte[edi], cl
inc edi
dec ebx dec ebx
jnz .raw_pixel jnz .raw_pixel
add edi, ebp add edi, ebp
@ -535,19 +473,21 @@ encoding_ZRLE:
; Single color tile ; Single color tile
.solid: .solid:
DEBUGF 1, "Solid tile\n" DEBUGF 1, "Solid tile\n"
call load_pixel_zrle
mov eax, ecx ; TODO: check for buffer underrun
shr eax, 16
call load_cpixel
mov ecx, eax
shr ecx, 16
mov [palettesize], 1 mov [palettesize], 1
mov [palette], ecx mov [palette], eax
.solid_line: .solid_line:
mov ebx, [subrectangle.width] mov ebx, [subrectangle.width]
.solid_pixel: .solid_pixel:
mov [edi], cx stosw
add edi, 2 mov [edi], cl
mov [edi], al
inc edi inc edi
dec ebx dec ebx
jnz .solid_pixel jnz .solid_pixel