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:
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
.redraw:
@ -153,12 +156,12 @@ draw_gui:
mcall 4 ; OK button text
.redraw_done:
mov [update_gui], 0
and [work], not WORK_GUI
mcall 12, 2
.loop:
cmp [update_gui], 0
jne .redraw
test [work], WORK_GUI
jnz .redraw
cmp [status], STATUS_CONNECTED
je .connected
@ -227,17 +230,22 @@ draw_gui:
.login:
mov [status], STATUS_LOGIN
inc [update_gui]
or [work], WORK_GUI
jmp .loop
.cancel:
mcall 18, 18, [thread_id] ; kill thread
.ok:
cmp [status], STATUS_LIB_ERR
je .close
and [URLbox.flags], not ed_disabled
mov [USERbox.size], 0
mov [PASSbox.size], 0
mov [status], STATUS_CONNECT
inc [update_gui]
mov [name.dash], 0
mcall 71, 1, name ; reset window caption
or [work], WORK_GUI
jmp .loop
.mouse:
@ -269,6 +277,6 @@ open_connection:
mov [status], STATUS_THREAD_ERR
@@:
mov [thread_id], eax
inc [update_gui]
or [work], WORK_GUI
ret

View File

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

View File

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

View File

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

View File

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

View File

@ -87,8 +87,18 @@ STATUS_THREAD_ERR = 17
STATUS_LOGIN_FAILED = 18
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
if BITS_PER_PIXEL = 32
BYTES_PER_CPIXEL= 3
else
BYTES_PER_CPIXEL= BYTES_PER_PIXEL
end if
include "keymap.inc"
include "gui.inc"
include "network.inc"
@ -97,8 +107,63 @@ include "copyrect.inc"
include "rre.inc"
include "trle.inc"
include "zrle.inc"
include "cursor.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:
mcall 68, 11 ; init heap
@ -108,8 +173,14 @@ START:
test eax, eax
jz @f
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
cmp byte[serveraddr], 0
je @f
@ -124,7 +195,7 @@ START:
@@:
; Present the user with the GUI and wait for network connection
call draw_gui
call draw_gui.first_time
; Create main window
mcall 71, 1, name ; reset window caption (add server name)
@ -157,15 +228,17 @@ redraw:
draw_framebuffer:
DEBUGF 1, "Drawing framebuffer\n"
mcall 7, framebuffer, dword[screen], 0
mov [update_framebuffer], 0
and [work], not WORK_FRAMEBUFFER
mainloop:
cmp [status], STATUS_CONNECTED
jne draw_gui
cmp [update_framebuffer], 0
jne draw_framebuffer
test [work], WORK_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
jz redraw
@ -258,6 +331,29 @@ button:
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
include_debug_strings
@ -272,7 +368,9 @@ HandShake db "RFB 003.003", 10
ClientInit db 0 ; not shared
SetPixelFormat32 db 0 ; setPixelformat
if BITS_PER_PIXEL = 32
SetPixelFormat db 0 ; setPixelformat
db 0, 0, 0 ; padding
.bpp db 32 ; bits per pixel
.depth db 24 ; depth
@ -286,7 +384,9 @@ SetPixelFormat32 db 0 ; setPixelformat
.blue_shift db 0 ; blue-shift
db 0, 0, 0 ; padding
SetPixelFormat24 db 0 ; setPixelformat
else if BITS_PER_PIXEL = 24
SetPixelFormat db 0 ; setPixelformat
db 0, 0, 0 ; padding
.bpp db 24 ; bits per pixel
.depth db 24 ; depth
@ -300,7 +400,9 @@ SetPixelFormat24 db 0 ; setPixelformat
.blue_shift db 0 ; blue-shift
db 0, 0, 0 ; padding
SetPixelFormat16 db 0 ; setPixelformat
else if BITS_PER_PIXEL = 16
SetPixelFormat db 0 ; setPixelformat
db 0, 0, 0 ; padding
.bpp db 16 ; bits per pixel
.depth db 16 ; depth
@ -314,7 +416,9 @@ SetPixelFormat16 db 0 ; setPixelformat
.blue_shift db 0 ; blue-shift
db 0, 0, 0 ; padding
SetPixelFormat8 db 0 ; setPixelformat
else if BITS_PER_PIXEL = 8
SetPixelFormat db 0 ; setPixelformat
db 0, 0, 0 ; padding
.bpp db 8 ; bits per pixel
.depth db 8 ; depth
@ -323,18 +427,21 @@ SetPixelFormat8 db 0 ; setPixelformat
.red_max db 0, 7 ; red-max
.green_max db 0, 7 ; green-max
.blue_max db 0, 3 ; blue-max
.red_shift db 0 ; red-shift
.green_shift db 3 ; green-shift
.blue_shift db 6 ; blue-shift
.red_shift db 5 ; red-shift
.green_shift db 2 ; green-shift
.blue_shift db 0 ; blue-shift
db 0, 0, 0 ; padding
end if
SetEncodings db 2 ; setEncodings
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, 15 ; TRLE
db 0, 0, 0, 2 ; RRE
db 0, 0, 0, 1 ; Copyrect encoding
db 0xff, 0xff, 0xff, 0x11 ; Cursor pseudo encoding
db 0, 0, 0, 0 ; raw encoding
.length = $ - SetEncodings
@ -365,9 +472,8 @@ sockaddr1:
beep db 0x85, 0x25, 0x85, 0x40, 0
status dd STATUS_CONNECT
update_gui dd 0
work dd 0
mouse_dd dd 0
update_framebuffer dd 0
thread_id dd 0
deflate_buffer dd 0
@ -474,7 +580,17 @@ keymap_shift rw 128
keymap_alt rw 128
username 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

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:
mov eax, [deflate_length]
mov ecx, [esp+8]
@ -82,7 +21,6 @@ deflate_callback:
ret 8
encoding_ZRLE:
DEBUGF 2, "ZRLE\n"
@ -283,9 +221,11 @@ encoding_ZRLE:
jmp .next_tile
.rle_reload:
call load_pixel_zrle
; TODO: check for buffer underrun
;;;
; load pixel value
call load_cpixel
mov ecx, eax
; load length
xor eax, eax
@ -511,18 +451,16 @@ encoding_ZRLE:
lea eax, [eax*3]
pop edx
;;;
; TODO: check for buffer underrun
DEBUGF 1, "RAW tile\n"
.raw_line:
mov ebx, [subrectangle.width]
.raw_pixel:
call load_pixel_zrle
mov word[edi], cx
shr ecx, 16
add edi, 2
mov byte[edi], cl
inc edi
call load_cpixel
stosw
shr eax, 16
stosb
dec ebx
jnz .raw_pixel
add edi, ebp
@ -535,19 +473,21 @@ encoding_ZRLE:
; Single color tile
.solid:
DEBUGF 1, "Solid tile\n"
call load_pixel_zrle
mov eax, ecx
shr eax, 16
; TODO: check for buffer underrun
call load_cpixel
mov ecx, eax
shr ecx, 16
mov [palettesize], 1
mov [palette], ecx
mov [palette], eax
.solid_line:
mov ebx, [subrectangle.width]
.solid_pixel:
mov [edi], cx
add edi, 2
mov [edi], al
stosw
mov [edi], cl
inc edi
dec ebx
jnz .solid_pixel