Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2433 → Rev 2434

/kernel/branches/Kolibri-acpi/video/cursors.inc
13,24 → 13,20
LOAD_INDIRECT equ 2
LOAD_SYSTEM equ 3
 
struc BITMAPINFOHEADER {
.biSize dd ? ; DWORD
.biWidth dd ? ; LONG
.biHeight dd ? ; LONG
.biPlanes dw ? ; WORD
.biBitCount dw ? ; WORD
.biCompression dd ? ; DWORD
.biSizeImage dd ? ; DWORD
.biXPelsPerMeter dd ? ; LONG
.biYPelsPerMeter dd ? ; LONG
.biClrUsed dd ? ; DWORD
.biClrImportant dd ? ; DWORD
}
 
virtual at 0
BI BITMAPINFOHEADER
end virtual
 
struct BITMAPINFOHEADER
Size dd ?
Width dd ?
Height dd ?
Planes dw ?
BitCount dw ?
Compression dd ?
SizeImage dd ?
XPelsPerMeter dd ?
YPelsPerMeter dd ?
ClrUsed dd ?
ClrImportant dd ?
ends
;------------------------------------------------------------------------------
align 4
proc init_cursor stdcall, dst:dword, src:dword
locals
47,13 → 43,14
add esi,[esi+18]
mov eax,esi
 
cmp [esi+BI.biBitCount], 24
cmp [esi+BITMAPINFOHEADER.BitCount], 24
je .img_24
cmp [esi+BI.biBitCount], 8
cmp [esi+BITMAPINFOHEADER.BitCount], 8
je .img_8
cmp [esi+BI.biBitCount], 4
cmp [esi+BITMAPINFOHEADER.BitCount], 4
je .img_4
 
;--------------------------------------
align 4
.img_2:
add eax, [esi]
mov [pQuad],eax
72,6 → 69,8
mov [rBase],edi
 
mov esi,[pQuad]
;--------------------------------------
align 4
.l21:
mov ebx, [pBits]
mov ebx, [ebx]
80,6 → 79,8
mov eax, [eax]
bswap eax
mov [counter], 32
;--------------------------------------
align 4
@@:
xor edx, edx
shl eax,1
107,7 → 108,8
sub [height],1
jnz .l21
ret
 
;--------------------------------------
align 4
.img_4:
add eax, [esi]
mov [pQuad],eax
127,11 → 129,15
 
mov esi,[pQuad]
mov ebx, [pBits]
;--------------------------------------
align 4
.l4:
mov eax, [pAnd]
mov eax, [eax]
bswap eax
mov [counter], 16
;--------------------------------------
align 4
@@:
xor edx, edx
shl eax,1
172,6 → 178,8
sub [height],1
jnz .l4
ret
;--------------------------------------
align 4
.img_8:
add eax, [esi]
mov [pQuad],eax
191,11 → 199,15
 
mov esi,[pQuad]
mov ebx, [pBits]
;--------------------------------------
align 4
.l81:
mov eax, [pAnd]
mov eax, [eax]
bswap eax
mov [counter], 32
;--------------------------------------
align 4
@@:
xor edx, edx
shl eax,1
221,14 → 233,16
sub [height],1
jnz .l81
ret
;--------------------------------------
align 4
.img_24:
add eax, [esi]
mov [pQuad],eax
add eax, 0xC00
mov [pAnd],eax
mov eax,[esi+BI.biWidth]
mov eax, [esi+BITMAPINFOHEADER.Width]
mov [width],eax
mov ebx,[esi+BI.biHeight]
mov ebx, [esi+BITMAPINFOHEADER.Height]
shr ebx,1
mov [height],ebx
 
238,10 → 252,14
 
mov esi,[pAnd]
mov ebx, [pQuad]
;--------------------------------------
align 4
.row_24:
mov eax, [esi]
bswap eax
mov [counter], 32
;--------------------------------------
align 4
@@:
xor edx, edx
shl eax,1
267,7 → 285,7
jnz .row_24
ret
endp
 
;------------------------------------------------------------------------------
align 4
proc set_cursor stdcall, hcursor:dword
mov eax, [hcursor]
278,6 → 296,8
mov ebx, [current_slot]
xchg eax, [ebx+APPDATA.cursor]
ret
;--------------------------------------
align 4
.fail:
mov eax, [def_cursor]
mov ebx, [current_slot]
284,7 → 304,8
xchg eax, [ebx+APPDATA.cursor]
ret
endp
 
;------------------------------------------------------------------------------
align 4
; param
; eax= pid
; ebx= src
300,7 → 321,7
push ebx
 
mov ebx, eax
mov eax, CURSOR.sizeof
mov eax, sizeof.CURSOR
call create_kernel_object
test eax, eax
jz .fail
332,22 → 353,18
 
stdcall init_cursor, eax, esi
 
mov eax, [.hcursor]
lea eax, [eax+CURSOR.list_next]
mov ecx, [.hcursor]
lea ecx, [ecx+CURSOR.list_next]
lea edx, [_display.cr_list.next]
 
pushfd
cli
mov ecx, [edx]
 
mov [eax], ecx
mov [eax+4], edx
 
mov [ecx+4], eax
mov [edx], eax
list_add ecx, edx ;list_add_tail(new, head)
popfd
 
mov eax, [.hcursor]
;--------------------------------------
align 4
.check_hw:
cmp [_display.init_cursor], 0
je .fail
357,9 → 374,13
add esp, 4
 
mov eax, [.hcursor]
;--------------------------------------
align 4
.fail:
add esp, 12
ret
;--------------------------------------
align 4
.indirect:
shr ebx, 16
movzx ecx, bh
372,7 → 393,7
cld
rep movsd
jmp .check_hw
 
;------------------------------------------------------------------------------
align 4
proc load_cursor stdcall, src:dword, flags:dword
locals
391,6 → 412,8
test eax, eax
jz .fail
mov [src], eax
;--------------------------------------
align 4
@@:
push ebx
push esi
407,16 → 430,22
cmp word [flags], LOAD_FROM_FILE
jne .exit
stdcall kernel_free, [src]
;--------------------------------------
align 4
.exit:
pop edi
pop esi
pop ebx
;--------------------------------------
align 4
.fail:
mov eax, [handle]
;--------------------------------------
align 4
.fail2:
ret
endp
 
;------------------------------------------------------------------------------
align 4
proc delete_cursor stdcall, hcursor:dword
locals
443,32 → 472,43
jne @F
mov eax, [def_cursor]
mov [ebx+APPDATA.cursor], eax
;--------------------------------------
align 4
@@:
mov eax, [hcursor]
call [eax+APPOBJ.destroy]
;--------------------------------------
align 4
.fail:
ret
endp
 
;------------------------------------------------------------------------------
align 4
; param
; eax= cursor
 
align 4
destroy_cursor:
 
push eax
stdcall kernel_free, [eax+CURSOR.base]
 
mov eax, [esp]
lea eax, [eax+CURSOR.list_next]
 
pushfd
cli
list_del eax
popfd
 
pop eax
 
call destroy_kernel_object
ret
 
;------------------------------------------------------------------------------
align 4
select_cursor:
mov eax, [esp+4]
mov [_display.cursor], eax
ret 4
 
;------------------------------------------------------------------------------
align 4
proc restore_24 stdcall, x:dword, y:dword
 
486,6 → 526,8
mov ecx, [cur.w]
lea ecx, [ecx+ecx*2]
push ecx
;--------------------------------------
align 4
@@:
mov edi, ebx
add ebx, [BytesPerScanLine]
498,11 → 540,13
pop ecx
pop edi
pop esi
;--------------------------------------
align 4
.ret:
pop ebx
ret
endp
 
;------------------------------------------------------------------------------
align 4
proc restore_32 stdcall, x:dword, y:dword
 
517,6 → 561,8
push edi
 
mov esi, cur_saved_data
;--------------------------------------
align 4
@@:
mov edi, ebx
add ebx, [BytesPerScanLine]
527,12 → 573,14
jnz @B
 
pop edi
;--------------------------------------
align 4
.ret:
pop esi
pop ebx
ret
endp
 
;------------------------------------------------------------------------------
align 4
proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword
locals
578,10 → 626,14
cmp ebx, [Screen_Max_X]
jbe @F
mov ebx, [Screen_Max_X]
;--------------------------------------
align 4
@@:
cmp edi, [Screen_Max_Y]
jbe @F
mov edi, [Screen_Max_Y]
;--------------------------------------
align 4
@@:
mov [cur.right], ebx
mov [cur.bottom], edi
597,6 → 649,8
 
mov eax, edi
mov edi, cur_saved_data
;--------------------------------------
align 4
@@:
mov esi, edx
add edx, [BytesPerScanLine]
615,6 → 669,8
mov esi, [hcursor]
mov esi, [esi+CURSOR.base]
lea edx, [esi+eax*4]
;--------------------------------------
align 4
.row:
mov ecx, [cur.w]
mov esi, edx
621,6 → 677,8
mov edi, ebx
add edx, 32*4
add ebx, [BytesPerScanLine]
;--------------------------------------
align 4
.pix:
lodsd
test eax, 0xFF000000
628,6 → 686,8
mov [edi], ax
shr eax, 16
mov [edi+2],al
;--------------------------------------
align 4
@@:
add edi, 3
dec ecx
637,8 → 697,7
jnz .row
ret
endp
 
 
;------------------------------------------------------------------------------
align 4
proc move_cursor_32 stdcall, hcursor:dword, x:dword, y:dword
locals
682,10 → 741,14
cmp ebx, [Screen_Max_X]
jbe @F
mov ebx, [Screen_Max_X]
;--------------------------------------
align 4
@@:
cmp edi, [Screen_Max_Y]
jbe @F
mov edi, [Screen_Max_Y]
;--------------------------------------
align 4
@@:
mov [cur.right], ebx
mov [cur.bottom], edi
701,6 → 764,8
 
mov eax, edi
mov edi, cur_saved_data
;--------------------------------------
align 4
@@:
mov esi, edx
add edx, [BytesPerScanLine]
718,6 → 783,8
mov esi, [hcursor]
mov esi, [esi+CURSOR.base]
lea edx, [esi+eax*4]
;--------------------------------------
align 4
.row:
mov ecx, [cur.w]
mov esi, edx
724,11 → 791,15
mov edi, ebx
add edx, 32*4
add ebx, [BytesPerScanLine]
;--------------------------------------
align 4
.pix:
lodsd
test eax, 0xFF000000
jz @F
mov [edi], eax
;--------------------------------------
align 4
@@:
add edi, 4
dec ecx
738,16 → 809,158
jnz .row
ret
endp
;------------------------------------------------------------------------------
align 4
check_mouse_area_for_getpixel_new:
; in:
; eax = x
; ebx = y
; out:
; ecx = new color
;--------------------------------------
; check for Y
cmp bx, [Y_UNDER_subtraction_CUR_hot_y]
jb .no_mouse_area
 
cmp bx, [Y_UNDER_sub_CUR_hot_y_add_curh]
jae .no_mouse_area
;--------------------------------------
; check for X
cmp ax, [X_UNDER_subtraction_CUR_hot_x]
jb .no_mouse_area
 
cmp ax, [X_UNDER_sub_CUR_hot_x_add_curh]
jae .no_mouse_area
;--------------------------------------
push eax ebx
; offset X
mov ecx, [X_UNDER_subtraction_CUR_hot_x]
sub eax, ecx ; x1
; offset Y
mov ecx, [Y_UNDER_subtraction_CUR_hot_y]
sub ebx, ecx ; y1
;--------------------------------------
; ebx = offset y
; eax = offset x
imul ebx, [cur.w] ;y
add eax, ebx
mov ebx, eax
shl eax, 2
cmp [ScreenBPP], byte 32
je @f
sub eax, ebx
;--------------------------------------
align 4
@@:
add eax, cur_saved_data
mov ecx, [eax]
and ecx, 0xffffff
add ecx, 0xff000000
pop ebx eax
ret
;--------------------------------------
align 4
.no_mouse_area:
xor ecx, ecx
ret
;-----------------------------------------------------------------------------
align 4
check_mouse_area_for_putpixel_new:
; in:
; ecx = x shl 16 + y
; eax = color
; out:
; eax = new color
;--------------------------------------
; check for Y
cmp cx, [Y_UNDER_subtraction_CUR_hot_y]
jb .no_mouse_area
 
cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
jae .no_mouse_area
 
rol ecx, 16
;--------------------------------------
; check for X
cmp cx, [X_UNDER_subtraction_CUR_hot_x]
jb .no_mouse_area
 
cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh]
jae .no_mouse_area
;--------------------------------------
align 4
.1:
push eax
; offset X
mov ax, [X_UNDER_subtraction_CUR_hot_x]
sub cx, ax ; x1
ror ecx, 16
; offset Y
mov ax, [Y_UNDER_subtraction_CUR_hot_y]
sub cx, ax ; y1
;--------------------------------------
; ecx = (offset x) shl 16 + (offset y)
push ebx
mov ebx, ecx
shr ebx, 16 ; x
and ecx, 0xffff ; y
; ecx = offset y
; ebx = offset x
mov eax, [esp + 4]
 
push ebx ecx
imul ecx, [cur.w] ;y
add ecx, ebx
mov ebx, ecx
shl ecx, 2
cmp [ScreenBPP], byte 24
je .24
and eax, 0xFFFFFF
mov [ecx + cur_saved_data], eax ;store new color to
jmp @f
;--------------------------------------
align 4
.24:
sub ecx, ebx
mov [ecx + cur_saved_data], ax ;store new color to
shr eax, 16
mov [ecx + cur_saved_data + 2], al ;store new color to
;--------------------------------------
align 4
@@:
pop ecx ebx
 
shl ecx, 5
add ecx, ebx
 
mov eax, [current_cursor]
mov eax, [eax+CURSOR.base]
lea eax, [eax+ecx*4]
mov eax, [eax]
 
pop ebx
 
test eax, 0xFF000000
jz @f
 
pop ecx
ret
;--------------------------------------
align 4
@@:
pop eax
;--------------------------------------
align 4
.no_mouse_area:
ret
;------------------------------------------------------------------------------
align 4
get_display:
mov eax, _display
ret
 
;------------------------------------------------------------------------------
align 4
init_display:
 
xor eax, eax
mov edi, _display
 
766,6 → 979,7
 
test word [SCR_MODE], 0x4000
jz .fail
; jmp .fail
 
mov ebx, restore_32
mov ecx, move_cursor_32
777,30 → 991,28
mov ecx, move_cursor_24
cmp eax, 24
jne .fail
;--------------------------------------
align 4
@@:
mov [_display.select_cursor], select_cursor
mov [_display.move_cursor], ecx
mov [_display.restore_cursor], ebx
mov [_display.check_mouse], check_mouse_area_for_putpixel_new
mov [_display.check_m_pixel], check_mouse_area_for_getpixel_new
 
stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM
mov [def_cursor], eax
ret
;--------------------------------------
align 4
.fail:
xor eax, eax
mov [_display.select_cursor], eax
mov [_display.move_cursor], eax
ret
 
 
 
 
 
 
 
 
 
 
;------------------------------------------------------------------------------
align 4
def_arrow:
file 'arrow.cur'
;------------------------------------------------------------------------------