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 cursor_end rd 1
def_cursor rd 1 def_cursor rd 1
hw_cursor rd 1
scr_width rd 1 scr_width rd 1
scr_height rd 1 scr_height rd 1

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -918,15 +918,15 @@ reserve_irqs_ports:
mov [0x2d0000+edi+0],dword 1 mov [0x2d0000+edi+0],dword 1
mov [0x2d0000+edi+4],dword 0x0 mov [0x2d0000+edi+4],dword 0x0
mov [0x2d0000+edi+8],dword 0xdf mov [0x2d0000+edi+8],dword 0xdf
inc dword [0x2d0000] ; 0xe5-0xff inc dword [0x2d0000] ; 0xe5-0xff
mov edi,[0x2d0000] mov edi,[0x2d0000]
shl edi,4 shl edi,4
mov [0x2d0000+edi+0],dword 1 mov [0x2d0000+edi+0],dword 1
mov [0x2d0000+edi+4],dword 0xe5 mov [0x2d0000+edi+4],dword 0xe5
mov [0x2d0000+edi+8],dword 0xff mov [0x2d0000+edi+8],dword 0xff
; cmp [0xf604],byte 2 ; com1 mouse -> 0x3f0-0x3ff ; cmp [0xf604],byte 2 ; com1 mouse -> 0x3f0-0x3ff
; jne ripl1 ; jne ripl1
; inc dword [0x2d0000] ; inc dword [0x2d0000]
@ -1730,7 +1730,7 @@ align 4
mousefn dd msscreen, mswin, msbutton, msset mousefn dd msscreen, mswin, msbutton, msset
dd app_load_cursor dd app_load_cursor
dd app_set_cursor dd app_set_cursor
dd msset ;app_delete_cursor dd app_delete_cursor
readmousepos: readmousepos:
@ -1789,6 +1789,10 @@ app_set_cursor:
mov [esp+36], eax mov [esp+36], eax
ret ret
app_delete_cursor:
stdcall delete_cursor, ebx
mov [esp+36], eax
ret
is_input: is_input:
@ -1799,7 +1803,6 @@ is_input:
pop edx pop edx
ret ret
is_output: is_output:
push edx push edx

View File

@ -3,6 +3,7 @@ LOAD_FROM_FILE equ 0
LOAD_FROM_MEM equ 1 LOAD_FROM_MEM equ 1
LOAD_INDIRECT equ 2 LOAD_INDIRECT equ 2
LOAD_SYSTEM equ 3 LOAD_SYSTEM equ 3
VIDEO_FREE equ 2
struc BITMAPINFOHEADER { struc BITMAPINFOHEADER {
.biSize dd ? ; DWORD .biSize dd ? ; DWORD
@ -40,6 +41,65 @@ proc vesa_init_cursor stdcall, dst:dword, src:dword
cmp [esi+BI.biBitCount], 24 cmp [esi+BI.biBitCount], 24
je .img_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: .img_4:
add eax, [esi] add eax, [esi]
mov [pQuad],eax mov [pQuad],eax
@ -57,10 +117,11 @@ proc vesa_init_cursor stdcall, dst:dword, src:dword
add edi, 32*31*4 add edi, 32*31*4
mov [rBase],edi mov [rBase],edi
mov esi,[pAnd] mov esi,[pQuad]
mov ebx, [pBits] mov ebx, [pBits]
.l1: .l4:
mov eax, [esi] mov eax, [pAnd]
mov eax, [eax]
bswap eax bswap eax
mov [counter], 16 mov [counter], 16
@@: @@:
@ -69,11 +130,10 @@ proc vesa_init_cursor stdcall, dst:dword, src:dword
setc dl setc dl
dec edx dec edx
mov ecx, [ebx] movzx ecx, byte [ebx]
and ecx, 0xF0 and cl, 0xF0
shr ecx, 2 shr ecx, 2
add ecx, [pQuad] mov ecx, [esi+ecx]
mov ecx, [ecx]
and ecx, edx and ecx, edx
and edx, 0xFF000000 and edx, 0xFF000000
or edx, ecx or edx, ecx
@ -84,11 +144,9 @@ proc vesa_init_cursor stdcall, dst:dword, src:dword
setc dl setc dl
dec edx dec edx
mov ecx, [ebx] movzx ecx, byte [ebx]
and ecx, 0x0F and cl, 0x0F
shl ecx, 2 mov ecx, [esi+ecx*4]
add ecx, [pQuad]
mov ecx, [ecx]
and ecx, edx and ecx, edx
and edx, 0xFF000000 and edx, 0xFF000000
or edx, ecx or edx, ecx
@ -99,12 +157,61 @@ proc vesa_init_cursor stdcall, dst:dword, src:dword
dec [counter] dec [counter]
jnz @B jnz @B
add esi, 4 add [pAnd], 4
mov edi,[rBase] mov edi,[rBase]
sub edi,128 sub edi,128
mov [rBase],edi mov [rBase],edi
sub [height],1 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 ret
.img_24: .img_24:
add eax, [esi] add eax, [esi]
@ -189,6 +296,34 @@ proc alloc_cursor
ret ret
endp 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 align 4
proc set_cursor stdcall, hcursor:dword proc set_cursor stdcall, hcursor:dword
mov eax, [hcursor] mov eax, [hcursor]
@ -281,8 +416,67 @@ proc load_cursor stdcall, src:dword, flags:dword
ret ret
endp 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 align 4
proc init_cursors proc init_cursors
cmp [0xfe0c],word 0x13
jbe .fail
movzx eax, byte [ScreenBPP] movzx eax, byte [ScreenBPP]
mov ebx, [SCR_BYTES_PER_LINE] mov ebx, [SCR_BYTES_PER_LINE]
cmp eax, 32 cmp eax, 32
@ -311,6 +505,7 @@ proc init_cursors
mov [cursor_end], edx mov [cursor_end], edx
stdcall load_driver, drv_hw_mouse stdcall load_driver, drv_hw_mouse
mov [hw_cursor], eax
test eax, eax test eax, eax
jz .sw_mouse jz .sw_mouse