Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5749 → Rev 5750

/programs/network/vncc/cursor.inc
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
/programs/network/vncc/gui.inc
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
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
 
.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
mov [status], STATUS_THREAD_ERR
@@:
mov [thread_id], eax
inc [update_gui]
or [work], WORK_GUI
 
ret
/programs/network/vncc/network.inc
119,7 → 119,7
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
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
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,12 → 456,12
 
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:
474,18 → 468,18
; 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
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
/programs/network/vncc/raw.inc
51,29 → 51,15
 
.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
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,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
 
push ebx
xor eax, eax
lodsb
mov eax, [lut_8bpp+eax*4]
 
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 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
 
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
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
je next_rectangle
 
.subrectangle:
push edi
@@:
lea eax, [esi+8+BYTES_PER_PIXEL]
cmp [datapointer], eax
146,7 → 118,8
@@:
 
; Get subrectangle color
call load_pixel_rre
call load_pixel
push eax
 
; Get coordinates
xor eax, eax
166,7 → 139,6
[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
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
pop edi
dec [subrectangles]
jnz .subrectangle
jmp next_rectangle
jmp next_rectangle
 
/programs/network/vncc/trle.inc
15,26 → 15,12
 
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
41,56 → 27,51
jmp @b
@@:
 
if BITS_PER_PIXEL = 8
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
 
push ebx
ret
 
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
load_cpixel: ; returns in eax
 
mov bl, 85
mov al, [esi]
shr al, 6
and al, 3
mul bl
shl ecx, 8
mov cl, al ; blue
if BITS_PER_PIXEL = 8
 
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
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
.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
push edx
mov eax, [subrectangle.width]
mul [subrectangle.height]
lea eax, [eax*3]
pop edx
 
push eax
lea ecx, [eax*BYTES_PER_CPIXEL]
@@:
push eax
add eax, esi
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
; 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
/programs/network/vncc/vncc.asm
87,8 → 87,18
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 "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
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
@@:
 
; 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,13 → 228,15
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
 
258,6 → 331,29
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
 
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
.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
.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
.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
.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
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
476,6 → 582,16
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,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
ret 8
 
 
 
encoding_ZRLE:
 
DEBUGF 2, "ZRLE\n"
283,9 → 221,11
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
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
; 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