/programs/network/vncc/cursor.inc |
---|
File deleted |
/programs/network/vncc/gui.inc |
---|
13,9 → 13,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
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: |
156,12 → 153,12 |
mcall 4 ; OK button text |
.redraw_done: |
and [work], not WORK_GUI |
mov [update_gui], 0 |
mcall 12, 2 |
.loop: |
test [work], WORK_GUI |
jnz .redraw |
cmp [update_gui], 0 |
jne .redraw |
cmp [status], STATUS_CONNECTED |
je .connected |
230,22 → 227,17 |
.login: |
mov [status], STATUS_LOGIN |
or [work], WORK_GUI |
inc [update_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 |
mov [name.dash], 0 |
mcall 71, 1, name ; reset window caption |
or [work], WORK_GUI |
inc [update_gui] |
jmp .loop |
.mouse: |
277,6 → 269,6 |
mov [status], STATUS_THREAD_ERR |
@@: |
mov [thread_id], eax |
or [work], WORK_GUI |
inc [update_gui] |
ret |
/programs/network/vncc/network.inc |
---|
119,7 → 119,7 |
or [PASSbox.flags], ed_focus |
mov [status], STATUS_REQ_LOGIN |
or [work], WORK_GUI |
inc [update_gui] |
@@: |
mcall 5, 10 |
cmp [status], STATUS_LOGIN |
247,7 → 247,15 |
mov [name.dash], "-" |
DEBUGF 1, "Sending pixel format\n" |
mcall send, [socketnum], SetPixelFormat, 20, 0 |
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 |
DEBUGF 1, "Sending encoding info\n" |
mcall send, [socketnum], SetEncodings, SetEncodings.length, 0 |
334,14 → 342,12 |
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: |
or [work], WORK_FRAMEBUFFER |
inc [update_framebuffer] |
dec [rectangles] |
jnz rectangle_loop |
jmp request_fbu |
456,12 → 462,12 |
err_disconnected: |
mov [status], STATUS_DISCONNECTED |
or [work], WORK_GUI |
inc [update_gui] |
mcall -1 |
err_dns: |
mov [status], STATUS_DNS_ERR |
or [work], WORK_GUI |
inc [update_gui] |
mcall -1 |
err_sock: |
468,18 → 474,18 |
; TODO: distinguish between different socket errors! |
DEBUGF 2, "Socket error: %u\n", ebx |
mov [status], STATUS_SOCK_ERR |
or [work], WORK_GUI |
inc [update_gui] |
mcall -1 |
err_connect: |
mov [status], STATUS_CONNECT_ERR |
or [work], WORK_GUI |
inc [update_gui] |
mcall -1 |
ret |
err_proto: |
mov [status], STATUS_PROTO_ERR |
or [work], WORK_GUI |
inc [update_gui] |
mcall -1 |
ret |
501,12 → 507,12 |
mov [status], STATUS_SECURITY_ERR_C |
.no_msg: |
or [work], WORK_GUI |
inc [update_gui] |
mcall -1 |
ret |
err_login: |
mov [status], STATUS_LOGIN_FAILED |
or [work], WORK_GUI |
inc [update_gui] |
mcall -1 |
ret |
/programs/network/vncc/raw.inc |
---|
51,15 → 51,29 |
.lineloop: |
mov ecx, [rectangle.width] |
if BITS_PER_PIXEL = 24 |
lea ecx, [ecx*2+ecx] |
end if |
if BITS_PER_PIXEL = 8 |
.pixelloop: |
xor eax, eax |
lodsb |
mov eax, [lut_8bpp+eax*4] |
stosw |
shr eax, 16 |
stosb |
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 |
dec ecx |
jnz .pixelloop |
else if BITS_PER_PIXEL = 16 |
79,7 → 93,6 |
dec ecx |
jnz .pixelloop |
else if BITS_PER_PIXEL = 24 |
lea ecx, [ecx*2+ecx] |
rep movsb |
else if BITS_PER_PIXEL = 32 |
.pixelloop: |
/programs/network/vncc/rre.inc |
---|
12,48 → 12,76 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
load_pixel: ; returns in eax |
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 |
@@: |
if BITS_PER_PIXEL = 8 |
xor eax, eax |
lodsb |
mov eax, [lut_8bpp+eax*4] |
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 |
push ebx |
lodsw |
mov bx, ax |
shl bx, 5 |
and bh, 0xfc ; green |
mov cl, ah |
and al, 0xf8 ; red |
mov bl, ah |
and bl, 0xf8 ; red |
shl ebx, 8 |
mov cx, ax |
shl cx, 5 |
and ch, 0xfc ; green |
shl ecx, 8 |
mov bl, al |
shl bl, 3 |
and bl, 0xf8 ; blue |
mov eax, ebx |
pop ebx |
mov cl, al |
shl cl, 3 |
and cx, 0x00f8 ; blue |
else if BITS_PER_PIXEL = 24 |
mov eax, [esi] |
and eax, 0x00ffffff |
mov ecx, [esi] |
and ecx, 0x00ffffff |
add esi, 3 |
else if BITS_PER_PIXEL = 32 |
lodsd |
mov ecx, [esi] |
and ecx, 0x00ffffff |
add esi, 4 |
end if |
pop eax |
ret |
encoding_RRE: |
DEBUGF 1,"RRE\n" |
72,6 → 100,9 |
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] |
83,11 → 114,9 |
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] |
108,7 → 137,6 |
je next_rectangle |
.subrectangle: |
push edi |
@@: |
lea eax, [esi+8+BYTES_PER_PIXEL] |
cmp [datapointer], eax |
118,8 → 146,7 |
@@: |
; Get subrectangle color |
call load_pixel |
push eax |
call load_pixel_rre |
; Get coordinates |
xor eax, eax |
139,6 → 166,7 |
[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] |
151,7 → 179,7 |
lea ebp, [eax*3] ; ebp = ([screen.width]-[rectangle.width])*3 |
; Draw the subrectangle |
pop eax |
mov eax, ecx |
mov edx, [subrectangle.height] |
.lineloop2: |
mov ecx, [subrectangle.width] |
168,5 → 196,4 |
pop edi |
dec [subrectangles] |
jnz .subrectangle |
jmp next_rectangle |
jmp next_rectangle |
/programs/network/vncc/trle.inc |
---|
15,12 → 15,26 |
create_palette: |
push eax ecx edi |
movzx ecx, [palettesize] |
lea ecx, [ecx*BYTES_PER_CPIXEL] |
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 |
ret |
load_pixel_trle: ; returns in ecx |
push eax |
@@: |
lea eax, [esi+ecx] |
lea eax, [esi+BYTES_PER_PIXEL] |
cmp [datapointer], eax |
jae @f |
call read_data.more |
27,51 → 41,56 |
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 |
if BITS_PER_PIXEL = 8 |
ret |
push ebx |
mov bl, 36 |
mov al, [esi] |
and al, 7 |
mul bl |
mov ch, al ; red |
load_cpixel: ; returns in eax |
mov al, [esi] |
shr al, 3 |
and al, 7 |
mul bl |
mov cl, al ; green |
if BITS_PER_PIXEL = 8 |
mov bl, 85 |
mov al, [esi] |
shr al, 6 |
and al, 3 |
mul bl |
shl ecx, 8 |
mov cl, al ; blue |
xor eax, eax |
lodsb |
mov eax, [lut_8bpp+eax*4] |
inc esi |
pop ebx |
else if BITS_PER_PIXEL = 16 |
push ebx |
lodsw |
mov bx, ax |
shl bx, 5 |
and bh, 0xfc ; green |
mov cl, ah |
and al, 0xf8 ; red |
mov bl, ah |
and bl, 0xf8 ; red |
shl ebx, 8 |
mov cx, ax |
shl cx, 5 |
and ch, 0xfc ; green |
shl ecx, 8 |
mov bl, al |
shl bl, 3 |
and bl, 0xf8 ; blue |
mov eax, ebx |
pop ebx |
mov cl, al |
shl cl, 3 |
and cx, 0x00f8 ; blue |
else ; 32 BPP gets packed to 24 BPP |
mov eax, [esi] |
and eax, 0x00ffffff |
mov ecx, [esi] |
and ecx, 0x00ffffff |
add esi, 3 |
end if |
pop eax |
ret |
243,16 → 262,15 |
jmp .next_tile |
.rle_reload: |
call load_pixel_trle |
@@: |
lea eax, [esi+BYTES_PER_CPIXEL+1] |
lea eax, [esi+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 |
275,9 → 293,9 |
.reuse_palette: |
cmp [palettesize], 1 |
jne .reuse_palette_ |
mov eax, [palette] |
mov ecx, eax |
shr ecx, 16 |
mov ecx, [palette] |
mov eax, ecx |
shr eax, 16 |
jmp .solid_line |
; Palette packed tile |
475,28 → 493,30 |
push edx |
mov eax, [subrectangle.width] |
mul [subrectangle.height] |
lea eax, [eax*3] |
pop edx |
@@: |
push eax |
lea ecx, [eax*BYTES_PER_CPIXEL] |
@@: |
lea eax, [esi+ecx] |
add eax, esi |
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_cpixel |
stosw |
shr eax, 16 |
stosb |
call load_pixel_trle |
mov word[edi], cx |
shr ecx, 16 |
add edi, 2 |
mov byte[edi], cl |
inc edi |
dec ebx |
jnz .raw_pixel |
add edi, ebp |
509,25 → 529,19 |
; Single color tile |
.solid: |
DEBUGF 1, "Solid tile\n" |
@@: |
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 |
call load_pixel_trle |
mov eax, ecx |
shr eax, 16 |
mov [palettesize], 1 |
mov [palette], eax |
mov [palette], ecx |
.solid_line: |
mov ebx, [subrectangle.width] |
.solid_pixel: |
stosw |
mov [edi], cl |
mov [edi], cx |
add edi, 2 |
mov [edi], al |
inc edi |
dec ebx |
jnz .solid_pixel |
/programs/network/vncc/vncc.asm |
---|
87,18 → 87,8 |
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" |
107,63 → 97,8 |
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 |
173,14 → 108,8 |
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 |
195,7 → 124,7 |
@@: |
; Present the user with the GUI and wait for network connection |
call draw_gui.first_time |
call draw_gui |
; Create main window |
mcall 71, 1, name ; reset window caption (add server name) |
228,15 → 157,13 |
draw_framebuffer: |
DEBUGF 1, "Drawing framebuffer\n" |
mcall 7, framebuffer, dword[screen], 0 |
and [work], not WORK_FRAMEBUFFER |
mov [update_framebuffer], 0 |
mainloop: |
cmp [status], STATUS_CONNECTED |
jne draw_gui |
test [work], WORK_FRAMEBUFFER |
jnz draw_framebuffer |
test [work], WORK_CURSOR |
jnz update_cursor |
cmp [update_framebuffer], 0 |
jne draw_framebuffer |
mcall 23, 10 ; Check for event with 0,1s timeout |
331,29 → 258,6 |
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 |
368,9 → 272,7 |
ClientInit db 0 ; not shared |
if BITS_PER_PIXEL = 32 |
SetPixelFormat db 0 ; setPixelformat |
SetPixelFormat32 db 0 ; setPixelformat |
db 0, 0, 0 ; padding |
.bpp db 32 ; bits per pixel |
.depth db 24 ; depth |
384,9 → 286,7 |
.blue_shift db 0 ; blue-shift |
db 0, 0, 0 ; padding |
else if BITS_PER_PIXEL = 24 |
SetPixelFormat db 0 ; setPixelformat |
SetPixelFormat24 db 0 ; setPixelformat |
db 0, 0, 0 ; padding |
.bpp db 24 ; bits per pixel |
.depth db 24 ; depth |
400,9 → 300,7 |
.blue_shift db 0 ; blue-shift |
db 0, 0, 0 ; padding |
else if BITS_PER_PIXEL = 16 |
SetPixelFormat db 0 ; setPixelformat |
SetPixelFormat16 db 0 ; setPixelformat |
db 0, 0, 0 ; padding |
.bpp db 16 ; bits per pixel |
.depth db 16 ; depth |
416,9 → 314,7 |
.blue_shift db 0 ; blue-shift |
db 0, 0, 0 ; padding |
else if BITS_PER_PIXEL = 8 |
SetPixelFormat db 0 ; setPixelformat |
SetPixelFormat8 db 0 ; setPixelformat |
db 0, 0, 0 ; padding |
.bpp db 8 ; bits per pixel |
.depth db 8 ; depth |
427,21 → 323,18 |
.red_max db 0, 7 ; red-max |
.green_max db 0, 7 ; green-max |
.blue_max db 0, 3 ; blue-max |
.red_shift db 5 ; red-shift |
.green_shift db 2 ; green-shift |
.blue_shift db 0 ; blue-shift |
.red_shift db 0 ; red-shift |
.green_shift db 3 ; green-shift |
.blue_shift db 6 ; blue-shift |
db 0, 0, 0 ; padding |
end if |
SetEncodings db 2 ; setEncodings |
db 0 ; padding |
db 0, 5 ; number of encodings |
db 0, 4 ; 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 |
472,8 → 365,9 |
beep db 0x85, 0x25, 0x85, 0x40, 0 |
status dd STATUS_CONNECT |
work dd 0 |
update_gui dd 0 |
mouse_dd dd 0 |
update_framebuffer dd 0 |
thread_id dd 0 |
deflate_buffer dd 0 |
582,16 → 476,6 |
password rb 128 |
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 |
receive_buffer rb RECEIVE_BUFFER_SIZE |
/programs/network/vncc/zrle.inc |
---|
13,6 → 13,67 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
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] |
21,6 → 82,7 |
ret 8 |
encoding_ZRLE: |
DEBUGF 2, "ZRLE\n" |
221,11 → 283,9 |
jmp .next_tile |
.rle_reload: |
; TODO: check for buffer underrun |
call load_pixel_zrle |
; load pixel value |
call load_cpixel |
mov ecx, eax |
;;; |
; load length |
xor eax, eax |
451,16 → 511,18 |
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_cpixel |
stosw |
shr eax, 16 |
stosb |
call load_pixel_zrle |
mov word[edi], cx |
shr ecx, 16 |
add edi, 2 |
mov byte[edi], cl |
inc edi |
dec ebx |
jnz .raw_pixel |
add edi, ebp |
473,21 → 535,19 |
; 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], eax |
mov [palette], ecx |
.solid_line: |
mov ebx, [subrectangle.width] |
.solid_pixel: |
stosw |
mov [edi], cl |
mov [edi], cx |
add edi, 2 |
mov [edi], al |
inc edi |
dec ebx |
jnz .solid_pixel |