fixed ATI cursor clipping

2,4,8,24 bpp cursors
delete_cursor implemented

git-svn-id: svn://kolibrios.org@233 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2006-12-11 21:48:12 +00:00
parent 1ad99d565b
commit d510d16f49
7 changed files with 959 additions and 611 deletions

View File

@ -1282,6 +1282,7 @@ cursor_start rd 1
cursor_end rd 1
def_cursor rd 1
hw_cursor rd 1
scr_width rd 1
scr_height rd 1

View File

@ -986,7 +986,6 @@ proc read_process_memory
popad
mov eax, [r_count]
ret
endp
align 4

View File

@ -1,9 +1,6 @@
;alpha version
format MS COFF
include 'proc32.inc'
DEBUG equ 1
@ -15,6 +12,8 @@ LOAD_FROM_MEM equ 1
LOAD_INDIRECT equ 2
LOAD_SYSTEM equ 3
VIDEO_FREE equ 2
struc BITMAPINFOHEADER {
.biSize dd ? ; DWORD
.biWidth dd ? ; LONG
@ -237,11 +236,16 @@ out_size equ IOCTL.out_size
align 4
proc service_proc stdcall, ioctl:dword
; mov edi, [ioctl]
; mov eax, [edi+io_code]
mov edi, [ioctl]
mov ebx, [edi+io_code]
cmp ebx, VIDEO_FREE
jne .fail
xor eax, eax
ret
mov eax, [edi+input]
call video_free
.fail:
xor eax, eax
ret
endp
restore handle
@ -365,20 +369,42 @@ drvShowCursor:
align 4
proc drvCursorPos stdcall, hcursor:dword, x:dword, y:dword
pushfd
cli
mov eax, 80000000h
xor eax, eax
xor edx, edx
mov esi, [hcursor]
mov ebx, [x]
mov ecx, [y]
sub ebx, [esi+CURSOR.hot_x]
jnc @F
neg ebx
mov eax, ebx
shl eax, 16
xor ebx, ebx
@@:
sub ecx, [esi+CURSOR.hot_y]
jnc @F
neg ecx
mov ax, cx
mov edx, ecx
xor ecx, ecx
@@:
or eax, 0x80000000
wrr CUR_HORZ_VERT_OFF, eax
mov eax, [x]
shl eax, 16
or eax, [y]
or eax, 80000000h
wrr CUR_HORZ_VERT_POSN, eax
shl ebx, 16
mov bx, cx
or ebx, 0x80000000
wrr CUR_HORZ_VERT_POSN, ebx
mov esi, [hcursor]
mov eax, [esi+CURSOR.base]
sub eax, LFBAddress
wrr CUR_OFFSET, eax
shl edx, 8
add edx, [esi+CURSOR.base]
sub edx, LFBAddress
wrr CUR_OFFSET, edx
popfd
ret
endp
@ -412,6 +438,26 @@ proc video_alloc
ret
endp
align 4
video_free:
pushfd
cli
sub eax, LFBAddress+CURSOR_IMAGE_OFFSET
shr eax, 14
mov ebx, cursor_map
bts [ebx], eax
shr eax, 3
and eax, not 3
add eax, ebx
cmp [cursor_start], eax
ja @f
popfd
ret
@@:
mov [cursor_start], eax
popfd
ret
align 4
proc ati_cursor stdcall, hcursor:dword, src:dword, flags:dword
@ -438,8 +484,8 @@ proc ati_cursor stdcall, hcursor:dword, src:dword, flags:dword
shr ebx, 16
movzx ecx, bh
movzx edx, bl
mov [eax+CURSOR.hot_x], ecx
mov [eax+CURSOR.hot_y], edx
mov [edi+CURSOR.hot_x], ecx
mov [edi+CURSOR.hot_y], edx
xchg edi, eax
push edi
@ -479,6 +525,64 @@ proc ati_init_cursor stdcall, dst:dword, src:dword
cmp [esi+BI.biBitCount], 24
je .img_24
cmp [esi+BI.biBitCount], 8
je .img_8
cmp [esi+BI.biBitCount], 4
je .img_4
.img_2:
add eax, [esi]
mov [pQuad],eax
add eax,8
mov [pBits],eax
add eax, 128
mov [pAnd],eax
mov eax,[esi+4]
mov [width],eax
mov ebx,[esi+8]
shr ebx,1
mov [height],ebx
mov edi, pCursor
add edi, 32*31*4
mov [rBase],edi
mov esi,[pQuad]
.l21:
mov ebx, [pBits]
mov ebx, [ebx]
bswap ebx
mov eax, [pAnd]
mov eax, [eax]
bswap eax
mov [counter], 32
@@:
xor edx, edx
shl eax,1
setc dl
dec edx
xor ecx, ecx
shl ebx,1
setc cl
mov ecx, [esi+ecx*4]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
mov [edi], edx
add edi, 4
dec [counter]
jnz @B
add [pBits], 4
add [pAnd], 4
mov edi,[rBase]
sub edi,128
mov [rBase],edi
sub [height],1
jnz .l21
jmp .copy
.img_4:
add eax, [esi]
mov [pQuad],eax
@ -496,10 +600,11 @@ proc ati_init_cursor stdcall, dst:dword, src:dword
add edi, 32*31*4
mov [rBase],edi
mov esi,[pAnd]
mov esi,[pQuad]
mov ebx, [pBits]
.l1:
mov eax, [esi]
.l4:
mov eax, [pAnd]
mov eax, [eax]
bswap eax
mov [counter], 16
@@:
@ -508,11 +613,10 @@ proc ati_init_cursor stdcall, dst:dword, src:dword
setc dl
dec edx
mov ecx, [ebx]
and ecx, 0xF0
movzx ecx, byte [ebx]
and cl, 0xF0
shr ecx, 2
add ecx, [pQuad]
mov ecx, [ecx]
mov ecx, [esi+ecx]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
@ -523,11 +627,9 @@ proc ati_init_cursor stdcall, dst:dword, src:dword
setc dl
dec edx
mov ecx, [ebx]
and ecx, 0x0F
shl ecx, 2
add ecx, [pQuad]
mov ecx, [ecx]
movzx ecx, byte [ebx]
and cl, 0x0F
mov ecx, [esi+ecx*4]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
@ -538,14 +640,62 @@ proc ati_init_cursor stdcall, dst:dword, src:dword
dec [counter]
jnz @B
add esi, 4
add [pAnd], 4
mov edi,[rBase]
sub edi,128
mov [rBase],edi
sub [height],1
jnz .l1
jnz .l4
jmp .copy
.img_8:
add eax, [esi]
mov [pQuad],eax
add eax,1024
mov [pBits],eax
add eax, 1024
mov [pAnd],eax
mov eax,[esi+4]
mov [width],eax
mov ebx,[esi+8]
shr ebx,1
mov [height],ebx
mov edi, pCursor
add edi, 32*31*4
mov [rBase],edi
mov esi,[pQuad]
mov ebx, [pBits]
.l81:
mov eax, [pAnd]
mov eax, [eax]
bswap eax
mov [counter], 32
@@:
xor edx, edx
shl eax,1
setc dl
dec edx
movzx ecx, byte [ebx]
mov ecx, [esi+ecx*4]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
mov [edi], edx
inc ebx
add edi, 4
dec [counter]
jnz @B
add [pAnd], 4
mov edi,[rBase]
sub edi,128
mov [rBase],edi
sub [height],1
jnz .l81
jmp .copy
.img_24:
add eax, [esi]
mov [pQuad],eax
@ -606,7 +756,6 @@ proc ati_init_cursor stdcall, dst:dword, src:dword
add edi, 128
dec ebx
jnz @B
ret
endp
@ -814,7 +963,9 @@ sz_ati_srv db 'HWCURSOR',0
msgInit db 'detect hardware...',13,10,0
msgPCI db 'PCI accsess not supported',13,10,0
msgFail db 'device not found',13,10,0
msg_neg db 'neg ecx',13,10,0
buff db 8 dup(0)
db 13,10, 0
section '.data' data readable writable align 16

View File

@ -689,42 +689,47 @@ endp
align 4
proc init_codec
locals
counter dd ?
endl
locals
counter dd ?
endl
call reset_codec
and eax, eax
jz .err
mov edx, CTRL_STAT
call [ctrl.ctrl_read32]
test eax, CTRL_ST_CREADY
jnz .ready
xor edx, edx ;ac_reg_0
call [ctrl.codec_write16]
call reset_codec
and eax, eax
jz .err
xor eax, eax
mov edx, CODEC_REG_POWERDOWN
call [ctrl.codec_write16]
xor edx, edx ;ac_reg_0
call [ctrl.codec_write16]
mov [counter], 200 ; total 200*5 ms = 1s
xor eax, eax
mov edx, CODEC_REG_POWERDOWN
call [ctrl.codec_write16]
mov [counter], 200 ; total 200*5 ms = 1s
.wait:
mov edx, CODEC_REG_POWERDOWN
call [ctrl.codec_read16]
and eax, 0x0F
cmp eax, 0x0F
jz .ready
mov edx, CODEC_REG_POWERDOWN
call [ctrl.codec_read16]
and eax, 0x0F
cmp eax, 0x0F
je .ready
mov eax, 5000 ; wait 5 ms
call StallExec
sub [counter] , 1
jnz .wait
mov eax, 5000 ; wait 5 ms
call StallExec
sub [counter] , 1
jnz .wait
.err:
xor eax, eax ; timeout error
ret
xor eax, eax ; timeout error
ret
.ready:
call detect_codec
call detect_codec
xor eax, eax
inc eax
ret
xor eax, eax
inc eax
ret
endp
align 4
@ -804,7 +809,10 @@ proc cold_reset
counter dd ?
endl
xor eax, eax
mov edx, GLOB_CTRL
call [ctrl.ctrl_read32]
and eax, not 0x08
or eax, 0x02
mov edx, GLOB_CTRL
call [ctrl.ctrl_write32]
@ -813,13 +821,6 @@ proc cold_reset
call SysMsgBoardStr
end if
mov eax, 1000000 ; wait 1 s
call StallExec
mov eax, 2
mov edx, GLOB_CTRL
call [ctrl.ctrl_write32]
mov [counter], 10 ; total 10*100 ms = 1s
.wait:
mov eax, 100000 ; wait 100 ms
@ -836,6 +837,7 @@ proc cold_reset
mov esi, msgCRFail
call SysMsgBoardStr
end if
.fail:
stc
ret
.ok:
@ -845,9 +847,6 @@ proc cold_reset
jz .fail
clc
ret
.fail:
stc
ret
endp
align 4
@ -1034,12 +1033,12 @@ proc StallExec
mov ecx, edx ;high
rdtsc
add ebx, eax
adc ecx,edx
adc ecx, edx
@@:
rdtsc
sub eax, ebx
sbb edx, ecx
jb @B
js @B
pop eax
pop ebx

File diff suppressed because it is too large Load Diff

View File

@ -1730,7 +1730,7 @@ align 4
mousefn dd msscreen, mswin, msbutton, msset
dd app_load_cursor
dd app_set_cursor
dd msset ;app_delete_cursor
dd app_delete_cursor
readmousepos:
@ -1789,6 +1789,10 @@ app_set_cursor:
mov [esp+36], eax
ret
app_delete_cursor:
stdcall delete_cursor, ebx
mov [esp+36], eax
ret
is_input:
@ -1799,7 +1803,6 @@ is_input:
pop edx
ret
is_output:
push edx

View File

@ -3,6 +3,7 @@ LOAD_FROM_FILE equ 0
LOAD_FROM_MEM equ 1
LOAD_INDIRECT equ 2
LOAD_SYSTEM equ 3
VIDEO_FREE equ 2
struc BITMAPINFOHEADER {
.biSize dd ? ; DWORD
@ -40,6 +41,65 @@ proc vesa_init_cursor stdcall, dst:dword, src:dword
cmp [esi+BI.biBitCount], 24
je .img_24
cmp [esi+BI.biBitCount], 8
je .img_8
cmp [esi+BI.biBitCount], 4
je .img_4
.img_2:
add eax, [esi]
mov [pQuad],eax
add eax,8
mov [pBits],eax
add eax, 128
mov [pAnd],eax
mov eax,[esi+4]
mov [width],eax
mov ebx,[esi+8]
shr ebx,1
mov [height],ebx
mov edi, [dst]
add edi, 32*31*4
mov [rBase],edi
mov esi,[pQuad]
.l21:
mov ebx, [pBits]
mov ebx, [ebx]
bswap ebx
mov eax, [pAnd]
mov eax, [eax]
bswap eax
mov [counter], 32
@@:
xor edx, edx
shl eax,1
setc dl
dec edx
xor ecx, ecx
shl ebx,1
setc cl
mov ecx, [esi+ecx*4]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
mov [edi], edx
add edi, 4
dec [counter]
jnz @B
add [pBits], 4
add [pAnd], 4
mov edi,[rBase]
sub edi,128
mov [rBase],edi
sub [height],1
jnz .l21
ret
.img_4:
add eax, [esi]
mov [pQuad],eax
@ -57,10 +117,11 @@ proc vesa_init_cursor stdcall, dst:dword, src:dword
add edi, 32*31*4
mov [rBase],edi
mov esi,[pAnd]
mov esi,[pQuad]
mov ebx, [pBits]
.l1:
mov eax, [esi]
.l4:
mov eax, [pAnd]
mov eax, [eax]
bswap eax
mov [counter], 16
@@:
@ -69,11 +130,10 @@ proc vesa_init_cursor stdcall, dst:dword, src:dword
setc dl
dec edx
mov ecx, [ebx]
and ecx, 0xF0
movzx ecx, byte [ebx]
and cl, 0xF0
shr ecx, 2
add ecx, [pQuad]
mov ecx, [ecx]
mov ecx, [esi+ecx]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
@ -84,11 +144,9 @@ proc vesa_init_cursor stdcall, dst:dword, src:dword
setc dl
dec edx
mov ecx, [ebx]
and ecx, 0x0F
shl ecx, 2
add ecx, [pQuad]
mov ecx, [ecx]
movzx ecx, byte [ebx]
and cl, 0x0F
mov ecx, [esi+ecx*4]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
@ -99,12 +157,61 @@ proc vesa_init_cursor stdcall, dst:dword, src:dword
dec [counter]
jnz @B
add esi, 4
add [pAnd], 4
mov edi,[rBase]
sub edi,128
mov [rBase],edi
sub [height],1
jnz .l1
jnz .l4
ret
.img_8:
add eax, [esi]
mov [pQuad],eax
add eax,1024
mov [pBits],eax
add eax, 1024
mov [pAnd],eax
mov eax,[esi+4]
mov [width],eax
mov ebx,[esi+8]
shr ebx,1
mov [height],ebx
mov edi, [dst]
add edi, 32*31*4
mov [rBase],edi
mov esi,[pQuad]
mov ebx, [pBits]
.l81:
mov eax, [pAnd]
mov eax, [eax]
bswap eax
mov [counter], 32
@@:
xor edx, edx
shl eax,1
setc dl
dec edx
movzx ecx, byte [ebx]
mov ecx, [esi+ecx*4]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
mov [edi], edx
inc ebx
add edi, 4
dec [counter]
jnz @B
add [pAnd], 4
mov edi,[rBase]
sub edi,128
mov [rBase],edi
sub [height],1
jnz .l81
ret
.img_24:
add eax, [esi]
@ -189,6 +296,34 @@ proc alloc_cursor
ret
endp
align 4
proc free_cursor
pushfd
cli
xor edx, edx
mov ecx, CURSOR_SIZE
sub eax, cursors
div ecx
test edx, edx
jnz .exit
mov ebx, cursor_map
bts [ebx], eax
shr eax, 3
and eax, not 3
add eax, ebx
cmp [cursor_start], eax
ja @f
.exit:
popfd
ret
@@:
mov [cursor_start], eax
popfd
ret
endp
align 4
proc set_cursor stdcall, hcursor:dword
mov eax, [hcursor]
@ -281,8 +416,67 @@ proc load_cursor stdcall, src:dword, flags:dword
ret
endp
align 4
proc delete_cursor stdcall, hcursor:dword
locals
hsrv dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
mov esi, [hcursor]
cmp [esi+CURSOR.magic], 'CURS'
jne .fail
cmp [esi+CURSOR.size], CURSOR_SIZE
jne .fail
mov ebx, [CURRENT_TASK]
shl ebx, 5
mov ebx, [0x3000+ebx+4]
cmp ebx, [esi+CURSOR.pid]
jne .fail
mov ebx, [CURRENT_TASK]
shl ebx, 8
cmp esi, [ebx+PROC_BASE+APPDATA.cursor]
jne @F
mov eax, [def_cursor]
mov [ebx+PROC_BASE+APPDATA.cursor], eax
@@:
mov eax, [hw_cursor]
test eax, eax
jz @F
xor ebx, ebx
mov ecx, [esi+CURSOR.base]
mov [hsrv], eax
mov [io_code], VIDEO_FREE
mov [input], ecx
mov [inp_size], 4
mov [output], ebx
mov [out_size], ebx
lea eax, [hsrv]
stdcall srv_handler, eax
jmp .exit
@@:
stdcall kernel_free, [esi+CURSOR.base]
.exit:
mov eax, [hcursor]
call free_cursor
ret
.fail:
ret
endp
align 4
proc init_cursors
cmp [0xfe0c],word 0x13
jbe .fail
movzx eax, byte [ScreenBPP]
mov ebx, [SCR_BYTES_PER_LINE]
cmp eax, 32
@ -311,6 +505,7 @@ proc init_cursors
mov [cursor_end], edx
stdcall load_driver, drv_hw_mouse
mov [hw_cursor], eax
test eax, eax
jz .sw_mouse