diff --git a/kernel/trunk/core/memory.inc b/kernel/trunk/core/memory.inc index 7521886130..ad73f97b59 100644 --- a/kernel/trunk/core/memory.inc +++ b/kernel/trunk/core/memory.inc @@ -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 diff --git a/kernel/trunk/core/taskman.inc b/kernel/trunk/core/taskman.inc index 4094cdbfec..10dc635caf 100644 --- a/kernel/trunk/core/taskman.inc +++ b/kernel/trunk/core/taskman.inc @@ -986,7 +986,6 @@ proc read_process_memory popad mov eax, [r_count] ret - endp align 4 diff --git a/kernel/trunk/drivers/ati2d.asm b/kernel/trunk/drivers/ati2d.asm index c602436f13..d100544e13 100644 --- a/kernel/trunk/drivers/ati2d.asm +++ b/kernel/trunk/drivers/ati2d.asm @@ -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 diff --git a/kernel/trunk/drivers/sis.asm b/kernel/trunk/drivers/sis.asm index b9588177d4..f96ea74898 100644 --- a/kernel/trunk/drivers/sis.asm +++ b/kernel/trunk/drivers/sis.asm @@ -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 diff --git a/kernel/trunk/drivers/unisound.asm b/kernel/trunk/drivers/unisound.asm index 9fbfc0c668..e07b14ee35 100644 --- a/kernel/trunk/drivers/unisound.asm +++ b/kernel/trunk/drivers/unisound.asm @@ -298,18 +298,18 @@ proc START stdcall, state:dword jne .stop if DEBUG - mov esi, msgInit + mov esi, msgInit call SysMsgBoardStr end if - call detect_controller - test eax, eax + call detect_controller + test eax, eax jz .fail if DEBUG - mov esi,[ctrl.vendor_ids] + mov esi,[ctrl.vendor_ids] call SysMsgBoardStr - mov esi, [ctrl.ctrl_ids] + mov esi, [ctrl.ctrl_ids] call SysMsgBoardStr end if @@ -328,10 +328,10 @@ proc START stdcall, state:dword jz .fail if DEBUG - mov esi, [codec.ac_vendor_ids] + mov esi, [codec.ac_vendor_ids] call SysMsgBoardStr - mov esi, [codec.chip_ids] + mov esi, [codec.chip_ids] call SysMsgBoardStr end if @@ -365,13 +365,13 @@ proc START stdcall, state:dword stdcall AttachIntHandler, ebx, ac97_irq stdcall RegService, sz_sound_srv, service_proc - ret + ret .fail: if DEBUG - mov esi, msgFail + mov esi, msgFail call SysMsgBoardStr end if - xor eax, eax + xor eax, eax ret .stop: call stop @@ -391,54 +391,54 @@ proc service_proc stdcall, ioctl:dword mov edi, [ioctl] mov eax, [edi+io_code] - cmp eax, DEV_PLAY - jne @F + cmp eax, DEV_PLAY + jne @F if DEBUG - mov esi, msgPlay + mov esi, msgPlay call SysMsgBoardStr end if - call play - ret + call play + ret @@: - cmp eax, DEV_STOP - jne @F + cmp eax, DEV_STOP + jne @F if DEBUG - mov esi, msgStop + mov esi, msgStop call SysMsgBoardStr end if - call stop - ret + call stop + ret @@: - cmp eax, DEV_CALLBACK - jne @F + cmp eax, DEV_CALLBACK + jne @F mov ebx, [edi+input] stdcall set_callback, [ebx] - ret + ret @@: - cmp eax, DEV_SET_MASTERVOL - jne @F + cmp eax, DEV_SET_MASTERVOL + jne @F mov ebx, [edi+input] stdcall set_master_vol, [ebx] - ret + ret @@: - cmp eax, DEV_GET_MASTERVOL - jne @F + cmp eax, DEV_GET_MASTERVOL + jne @F mov ebx, [edi+output] test ebx, ebx jz .fail stdcall get_master_vol, ebx - ret + ret @@: - cmp eax, DEV_GET_INFO - jne @F + cmp eax, DEV_GET_INFO + jne @F mov ebx, [edi+output] - stdcall get_dev_info, ebx - ret + stdcall get_dev_info, ebx + ret @@: .fail: - xor eax, eax - ret + xor eax, eax + ret endp restore handle @@ -451,17 +451,17 @@ restore out_size align 4 proc remap_irq ;for Intel chipsets ONLY !!! - mov eax, VALID_IRQ - bt eax, IRQ_LINE - jnc .exit + mov eax, VALID_IRQ + bt eax, IRQ_LINE + jnc .exit - mov edx, 0x4D0 - in ax,dx - bts ax, IRQ_LINE - out dx, aX + mov edx, 0x4D0 + in ax,dx + bts ax, IRQ_LINE + out dx, aX stdcall PciWrite8, dword 0, dword 0xF8, dword 0x61, dword IRQ_LINE - mov [ctrl.int_line], IRQ_LINE + mov [ctrl.int_line], IRQ_LINE .exit: ret @@ -475,129 +475,128 @@ proc ac97_irq ; call SysMsgBoardStr ; end if - mov edx, PCM_OUT_CR_REG - mov al, 0x14 - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + mov al, 0x14 + call [ctrl.ctrl_write8] - mov ax, 0x1c - mov edx, PCM_OUT_SR_REG - call [ctrl.ctrl_write16] + mov ax, 0x1c + mov edx, PCM_OUT_SR_REG + call [ctrl.ctrl_write16] - mov edx, PCM_OUT_CIV_REG - call [ctrl.ctrl_read8] + mov edx, PCM_OUT_CIV_REG + call [ctrl.ctrl_read8] - and eax, 0x1F - cmp eax, [civ_val] - je .skip + and eax, 0x1F + cmp eax, [civ_val] + je .skip - mov [civ_val], eax - dec eax - and eax, 0x1F - mov [ctrl.lvi_reg], eax + mov [civ_val], eax + dec eax + and eax, 0x1F + mov [ctrl.lvi_reg], eax - mov edx, PCM_OUT_LVI_REG - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_LVI_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - mov ax, 0x1D - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + mov ax, 0x1D + call [ctrl.ctrl_write8] - mov eax, [civ_val] - add eax, 2 - and eax, 31 - mov ebx, dword [buff_list+eax*4] + mov eax, [civ_val] + add eax, 2 + and eax, 31 + mov ebx, dword [buff_list+eax*4] - cmp [ctrl.user_callback], 0 - je @f + cmp [ctrl.user_callback], 0 + je @f - stdcall [ctrl.user_callback], ebx + stdcall [ctrl.user_callback], ebx @@: - ret + ret .skip: - mov edx, PCM_OUT_CR_REG - mov ax, 0x1D - call [ctrl.ctrl_write8] - ret + mov edx, PCM_OUT_CR_REG + mov ax, 0x1D + call [ctrl.ctrl_write8] + ret endp align 4 proc create_primary_buff stdcall KernelAlloc, 0x10000 - mov [ctrl.buffer], eax + mov [ctrl.buffer], eax - mov edi, eax - mov ecx, 0x10000/4 - xor eax, eax + mov edi, eax + mov ecx, 0x10000/4 + xor eax, eax cld - rep stosd + rep stosd stdcall GetPgAddr, [ctrl.buffer] - mov ebx, 0xC0002000 - mov ecx, 4 - mov edi, pcmout_bdl + mov ebx, 0xC0002000 + mov ecx, 4 + mov edi, pcmout_bdl @@: - mov [edi], eax - mov [edi+4], ebx + mov [edi], eax + mov [edi+4], ebx - mov [edi+32], eax - mov [edi+4+32], ebx + mov [edi+32], eax + mov [edi+4+32], ebx - mov [edi+64], eax - mov [edi+4+64], ebx + mov [edi+64], eax + mov [edi+4+64], ebx - mov [edi+96], eax - mov [edi+4+96], ebx + mov [edi+96], eax + mov [edi+4+96], ebx - mov [edi+128], eax - mov [edi+4+128], ebx + mov [edi+128], eax + mov [edi+4+128], ebx - mov [edi+160], eax - mov [edi+4+160], ebx + mov [edi+160], eax + mov [edi+4+160], ebx - mov [edi+192], eax - mov [edi+4+192], ebx + mov [edi+192], eax + mov [edi+4+192], ebx - mov [edi+224], eax - mov [edi+4+224], ebx + mov [edi+224], eax + mov [edi+4+224], ebx - add eax, 0x4000 - add edi, 8 - loop @B + add eax, 0x4000 + add edi, 8 + loop @B - mov edi, buff_list - mov eax, [ctrl.buffer] - mov ecx, 4 + mov edi, buff_list + mov eax, [ctrl.buffer] + mov ecx, 4 @@: - mov [edi], eax - mov [edi+16], eax - mov [edi+32], eax - mov [edi+48], eax - mov [edi+64], eax - mov [edi+80], eax - mov [edi+96], eax - mov [edi+112], eax + mov [edi], eax + mov [edi+16], eax + mov [edi+32], eax + mov [edi+48], eax + mov [edi+64], eax + mov [edi+80], eax + mov [edi+96], eax + mov [edi+112], eax - add eax, 0x4000 - add edi, 4 - loop @B + add eax, 0x4000 + add edi, 4 + loop @B - mov ecx, pcmout_bdl + mov ecx, pcmout_bdl stdcall GetPgAddr, ecx - and ecx, 0xFFF - add eax, ecx + and ecx, 0xFFF + add eax, ecx - mov edx, PCM_OUT_BDL - call [ctrl.ctrl_write32] + mov edx, PCM_OUT_BDL + call [ctrl.ctrl_write32] - mov eax, 16 - mov [ctrl.lvi_reg], eax - mov edx, PCM_OUT_LVI_REG - call [ctrl.ctrl_write8] - - ret + mov eax, 16 + mov [ctrl.lvi_reg], eax + mov edx, PCM_OUT_LVI_REG + call [ctrl.ctrl_write8] + ret endp align 4 @@ -608,66 +607,67 @@ proc detect_controller devfn dd ? endl - xor eax, eax - mov [bus], eax - inc eax + xor eax, eax + mov [bus], eax + inc eax call PciApi - cmp eax, -1 - je .err + cmp eax, -1 + je .err - mov [last_bus], eax + mov [last_bus], eax .next_bus: - and [devfn], 0 + and [devfn], 0 .next_dev: stdcall PciRead32, [bus], [devfn], dword 0 - test eax, eax - jz .next - cmp eax, -1 - je .next + test eax, eax + jz .next + cmp eax, -1 + je .next - mov edi, devices + mov edi, devices @@: - mov ebx, [edi] - test ebx, ebx - jz .next + mov ebx, [edi] + test ebx, ebx + jz .next - cmp eax, ebx - je .found - add edi, 12 - jmp @B + cmp eax, ebx + je .found + add edi, 12 + jmp @B -.next: inc [devfn] - cmp [devfn], 256 - jb .next_dev - mov eax, [bus] - inc eax - mov [bus], eax - cmp eax, [last_bus] - jna .next_bus - xor eax, eax - ret +.next: + inc [devfn] + cmp [devfn], 256 + jb .next_dev + mov eax, [bus] + inc eax + mov [bus], eax + cmp eax, [last_bus] + jna .next_bus + xor eax, eax + ret .found: - mov ebx, [bus] - mov [ctrl.bus], ebx + mov ebx, [bus] + mov [ctrl.bus], ebx - mov ecx, [devfn] - mov [ctrl.devfn], ecx + mov ecx, [devfn] + mov [ctrl.devfn], ecx - mov edx, eax - and edx, 0xFFFF - mov [ctrl.vendor], edx - shr eax, 16 - mov [ctrl.dev_id], eax + mov edx, eax + and edx, 0xFFFF + mov [ctrl.vendor], edx + shr eax, 16 + mov [ctrl.dev_id], eax - mov ebx, [edi+4] - mov [ctrl.ctrl_ids], ebx - mov esi, [edi+8] - mov [ctrl.ctrl_setup], esi + mov ebx, [edi+4] + mov [ctrl.ctrl_ids], ebx + mov esi, [edi+8] + mov [ctrl.ctrl_setup], esi cmp ebx, VID_INTEL jne @F - mov [ctrl.vendor_ids], msg_Intel + mov [ctrl.vendor_ids], msg_Intel ret @@: cmp ebx, VID_NVIDIA @@ -675,102 +675,102 @@ proc detect_controller mov [ctrl.vendor_ids], msg_NVidia @@: mov [ctrl.vendor_ids], 0 ;something wrong ? - ret + ret .err: - xor eax, eax - ret + xor eax, eax + ret endp align 4 proc get_LPC_bus ;for Intel chipsets ONLY !!! - locals - last_bus dd ? - bus dd ? - endl + locals + last_bus dd ? + bus dd ? + endl - xor eax, eax - mov [bus], eax - inc eax - call [PciApi] - cmp eax, -1 - je .err + xor eax, eax + mov [bus], eax + inc eax + call [PciApi] + cmp eax, -1 + je .err - mov [last_bus], eax + mov [last_bus], eax .next_bus: stdcall PciRead32, [bus], dword 0xF8, dword 0 - test eax, eax - jz .next - cmp eax, -1 - je .next + test eax, eax + jz .next + cmp eax, -1 + je .next - cmp eax, 0x24D08086 - je .found + cmp eax, 0x24D08086 + je .found .next: - mov eax, [bus] - inc eax - cmp eax, [last_bus] - mov [bus], eax - jna .next_bus + mov eax, [bus] + inc eax + cmp eax, [last_bus] + mov [bus], eax + jna .next_bus .err: - xor eax, eax - dec eax - ret + xor eax, eax + dec eax + ret .found: - mov eax, [bus] - ret + mov eax, [bus] + ret endp align 4 proc init_controller stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4 - mov ebx, eax - and eax, 0xFFFF - mov [ctrl.pci_cmd], eax - shr ebx, 16 - mov [ctrl.pci_stat], ebx + mov ebx, eax + and eax, 0xFFFF + mov [ctrl.pci_cmd], eax + shr ebx, 16 + mov [ctrl.pci_stat], ebx stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 - and eax,0xFFFE - mov [ctrl.codec_io_base], eax + and eax,0xFFFE + mov [ctrl.codec_io_base], eax stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14 - and eax, 0xFFC0 - mov [ctrl.ctrl_io_base], eax + and eax, 0xFFC0 + mov [ctrl.ctrl_io_base], eax stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18 - mov [ctrl.codec_mem_base], eax + mov [ctrl.codec_mem_base], eax stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C - mov [ctrl.ctrl_mem_base], eax + mov [ctrl.ctrl_mem_base], eax stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C - and eax, 0xFF - mov [ctrl.int_line], eax + and eax, 0xFF + mov [ctrl.int_line], eax stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41 - and eax, 0xFF - mov [ctrl.cfg_reg], eax + and eax, 0xFF + mov [ctrl.cfg_reg], eax - call [ctrl.ctrl_setup] - xor eax, eax - inc eax - ret + call [ctrl.ctrl_setup] + xor eax, eax + inc eax + ret endp align 4 proc set_ICH - mov [ctrl.codec_read16], codec_io_r16 ;virtual - mov [ctrl.codec_write16], codec_io_w16 ;virtual + mov [ctrl.codec_read16], codec_io_r16 ;virtual + mov [ctrl.codec_write16], codec_io_w16 ;virtual - mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual - mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual - mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual + mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual + mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual + mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual - mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual - mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual - mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual - ret + mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual + mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual + mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual + ret endp PG_SW equ 0x003 @@ -779,96 +779,100 @@ PG_NOCACHE equ 0x018 align 4 proc set_ICH4 stdcall AllocKernelSpace, dword 0x2000 - mov edi, eax + mov edi, eax stdcall MapPage, edi,[ctrl.codec_mem_base],PG_SW+PG_NOCACHE - mov [ctrl.codec_mem_base], edi - add edi, 0x1000 + mov [ctrl.codec_mem_base], edi + add edi, 0x1000 stdcall MapPage, edi, [ctrl.ctrl_mem_base],PG_SW+PG_NOCACHE - mov [ctrl.ctrl_mem_base], edi + mov [ctrl.ctrl_mem_base], edi - mov [ctrl.codec_read16], codec_mem_r16 ;virtual - mov [ctrl.codec_write16], codec_mem_w16 ;virtual + mov [ctrl.codec_read16], codec_mem_r16 ;virtual + mov [ctrl.codec_write16], codec_mem_w16 ;virtual - mov [ctrl.ctrl_read8 ], ctrl_mem_r8 ;virtual - mov [ctrl.ctrl_read16], ctrl_mem_r16 ;virtual - mov [ctrl.ctrl_read32], ctrl_mem_r32 ;virtual + mov [ctrl.ctrl_read8 ], ctrl_mem_r8 ;virtual + mov [ctrl.ctrl_read16], ctrl_mem_r16 ;virtual + mov [ctrl.ctrl_read32], ctrl_mem_r32 ;virtual - mov [ctrl.ctrl_write8 ], ctrl_mem_w8 ;virtual - mov [ctrl.ctrl_write16], ctrl_mem_w16 ;virtual - mov [ctrl.ctrl_write32], ctrl_mem_w32 ;virtual - ret + mov [ctrl.ctrl_write8 ], ctrl_mem_w8 ;virtual + mov [ctrl.ctrl_write16], ctrl_mem_w16 ;virtual + mov [ctrl.ctrl_write32], ctrl_mem_w32 ;virtual + ret endp align 4 proc reset_controller - xor eax, eax - mov edx, PCM_IN_CR_REG - call [ctrl.ctrl_write8] + xor eax, eax + mov edx, PCM_IN_CR_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + call [ctrl.ctrl_write8] - mov edx, MC_IN_CR_REG - call [ctrl.ctrl_write8] + mov edx, MC_IN_CR_REG + call [ctrl.ctrl_write8] - mov eax, RR - mov edx, PCM_IN_CR_REG - call [ctrl.ctrl_write8] + mov eax, RR + mov edx, PCM_IN_CR_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - call [ctrl.ctrl_write8] + mov edx, PCM_OUT_CR_REG + call [ctrl.ctrl_write8] - mov edx, MC_IN_CR_REG - call [ctrl.ctrl_write8] - - ret + mov edx, MC_IN_CR_REG + call [ctrl.ctrl_write8] + ret 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 + jz .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 proc reset_codec - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] test eax, 0x02 jz .cold @@ -876,15 +880,15 @@ proc reset_codec call warm_reset jnc .ok .cold: - call cold_reset - jnc .ok + call cold_reset + jnc .ok if DEBUG - mov esi, msgCFail + mov esi, msgCFail call SysMsgBoardStr - end if - xor eax, eax ; timeout error - ret + end if + xor eax, eax ; timeout error + ret .ok: if DEBUG mov esi, msgResetOk @@ -892,51 +896,51 @@ proc reset_codec end if xor eax, eax - inc eax - ret + inc eax + ret endp align 4 proc warm_reset - locals - counter dd ? - endl + locals + counter dd ? + endl - mov eax, 0x06 - mov edx, GLOB_CTRL - call [ctrl.ctrl_write32] + mov eax, 0x06 + mov edx, GLOB_CTRL + call [ctrl.ctrl_write32] if DEBUG - mov esi, msgWarm + mov esi, msgWarm call SysMsgBoardStr end if - mov [counter], 10 ; total 10*100 ms = 1s + mov [counter], 10 ; total 10*100 ms = 1s .wait: - mov eax, 100000 ; wait 100 ms - call StallExec + mov eax, 100000 ; wait 100 ms + call StallExec - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] - test eax, 4 - jz .ok - sub [counter], 1 - jnz .wait + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] + test eax, 4 + jz .ok + sub [counter], 1 + jnz .wait if DEBUG - mov esi, msgWRFail + mov esi, msgWRFail call SysMsgBoardStr end if - stc - ret + stc + ret .ok: - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - and eax, CTRL_ST_CREADY + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + and eax, CTRL_ST_CREADY jz .fail clc - ret + ret .fail: stc ret @@ -944,246 +948,243 @@ endp align 4 proc cold_reset - locals - counter dd ? - endl + locals + counter dd ? + endl - xor eax, eax - mov edx, GLOB_CTRL - call [ctrl.ctrl_write32] + xor eax, eax + mov edx, GLOB_CTRL + call [ctrl.ctrl_write32] if DEBUG - mov esi, msgCold + mov esi, msgCold call SysMsgBoardStr end if - mov eax, 1000000 ; wait 1 s - call StallExec + mov eax, 1000000 ; wait 1 s + call StallExec - mov eax, 2 - mov edx, GLOB_CTRL - call [ctrl.ctrl_write32] + 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: - mov eax, 100000 ; wait 100 ms - call StallExec + mov eax, 100000 ; wait 100 ms + call StallExec - mov edx, GLOB_CTRL - call [ctrl.ctrl_read32] - test eax, 4 - jz .ok - sub [counter], 1 - jnz .wait + mov edx, GLOB_CTRL + call [ctrl.ctrl_read32] + test eax, 4 + jz .ok + sub [counter], 1 + jnz .wait if DEBUG - mov esi, msgCRFail + mov esi, msgCRFail call SysMsgBoardStr end if - stc - ret + stc + ret .ok: - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - and eax, CTRL_ST_CREADY + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + and eax, CTRL_ST_CREADY jz .fail clc - ret + ret .fail: stc - ret + ret endp align 4 proc play - mov eax, 16 - mov [ctrl.lvi_reg], eax - mov edx, PCM_OUT_LVI_REG - call [ctrl.ctrl_write8] + mov eax, 16 + mov [ctrl.lvi_reg], eax + mov edx, PCM_OUT_LVI_REG + call [ctrl.ctrl_write8] - mov edx, PCM_OUT_CR_REG - mov ax, 0x1D - call [ctrl.ctrl_write8] - ret + mov edx, PCM_OUT_CR_REG + mov ax, 0x1D + call [ctrl.ctrl_write8] + ret endp align 4 proc stop mov edx, PCM_OUT_CR_REG - mov ax, 0x0 - call [ctrl.ctrl_write8] + mov ax, 0x0 + call [ctrl.ctrl_write8] mov ax, 0x1c - mov edx, PCM_OUT_SR_REG - call [ctrl.ctrl_write16] - ret + mov edx, PCM_OUT_SR_REG + call [ctrl.ctrl_write16] + ret endp align 4 proc get_dev_info stdcall, p_info:dword - virtual at esi - CTRL_INFO CTRL_INFO - end virtual + virtual at esi + CTRL_INFO CTRL_INFO + end virtual - mov esi, [p_info] - mov eax, [ctrl.int_line] - mov ebx, [ctrl.codec_io_base] - mov ecx, [ctrl.ctrl_io_base] - mov edx, [ctrl.codec_mem_base] - mov edi, [ctrl.ctrl_mem_base] + mov esi, [p_info] + mov eax, [ctrl.int_line] + mov ebx, [ctrl.codec_io_base] + mov ecx, [ctrl.ctrl_io_base] + mov edx, [ctrl.codec_mem_base] + mov edi, [ctrl.ctrl_mem_base] - mov [CTRL_INFO.irq], eax - mov [CTRL_INFO.codec_io_base], ebx - mov [CTRL_INFO.ctrl_io_base], ecx - mov [CTRL_INFO.codec_mem_base], edx - mov [CTRL_INFO.ctrl_mem_base], edi + mov [CTRL_INFO.irq], eax + mov [CTRL_INFO.codec_io_base], ebx + mov [CTRL_INFO.ctrl_io_base], ecx + mov [CTRL_INFO.codec_mem_base], edx + mov [CTRL_INFO.ctrl_mem_base], edi mov eax, [codec.chip_id] mov [CTRL_INFO.codec_id], eax - mov edx, GLOB_CTRL + mov edx, GLOB_CTRL call [ctrl.ctrl_read32] - mov [CTRL_INFO.glob_cntrl], eax + mov [CTRL_INFO.glob_cntrl], eax - mov edx, CTRL_STAT + mov edx, CTRL_STAT call [ctrl.ctrl_read32] - mov [CTRL_INFO.glob_sta], eax + mov [CTRL_INFO.glob_sta], eax - mov ebx, [ctrl.pci_cmd] - mov [CTRL_INFO.pci_cmd], ebx - - ret + mov ebx, [ctrl.pci_cmd] + mov [CTRL_INFO.pci_cmd], ebx + ret endp align 4 proc set_callback stdcall, handler:dword - mov eax, [handler] - mov [ctrl.user_callback], eax - ret + mov eax, [handler] + mov [ctrl.user_callback], eax + ret endp align 4 proc codec_read stdcall, ac_reg:dword ; reg = edx, reval = eax - mov edx, [ac_reg] + mov edx, [ac_reg] - mov ebx, edx - shr ebx, 1 - bt [codec.shadow_flag], ebx - jc .use_shadow + mov ebx, edx + shr ebx, 1 + bt [codec.shadow_flag], ebx + jc .use_shadow - call [ctrl.codec_read16] ;change edx !!! - mov ecx, eax + call [ctrl.codec_read16] ;change edx !!! + mov ecx, eax - mov edx, CTRL_STAT - call [ctrl.ctrl_read32] - test eax, CTRL_ST_RCS - jz .read_ok + mov edx, CTRL_STAT + call [ctrl.ctrl_read32] + test eax, CTRL_ST_RCS + jz .read_ok - mov edx, CTRL_STAT - call [ctrl.ctrl_write32] - xor eax,eax - not eax ;timeout - ret + mov edx, CTRL_STAT + call [ctrl.ctrl_write32] + xor eax,eax + not eax ;timeout + ret .read_ok: - mov edx, [ac_reg] - mov [codec.regs+edx], cx - bts [codec.shadow_flag], ebx - mov eax, ecx - ret + mov edx, [ac_reg] + mov [codec.regs+edx], cx + bts [codec.shadow_flag], ebx + mov eax, ecx + ret .use_shadow: - movzx eax, word [codec.regs+edx] - ret + movzx eax, word [codec.regs+edx] + ret endp align 4 proc codec_write stdcall, ac_reg:dword - push eax - call check_semafore - and eax, eax - jz .err - pop eax + push eax + call check_semafore + and eax, eax + jz .err + pop eax - mov esi, [ac_reg] - mov edx, esi - call [ctrl.codec_write16] - mov [codec.regs+esi], ax - shr esi, 1 - bts [codec.shadow_flag], esi - ret + mov esi, [ac_reg] + mov edx, esi + call [ctrl.codec_write16] + mov [codec.regs+esi], ax + shr esi, 1 + bts [codec.shadow_flag], esi + ret .err: - pop eax - ret + pop eax + ret endp align 4 proc codec_check_ready - mov edx, CTRL_ST - call [ctrl.ctrl_read32] - and eax, CTRL_ST_CREADY - jz .not_ready + mov edx, CTRL_ST + call [ctrl.ctrl_read32] + and eax, CTRL_ST_CREADY + jz .not_ready - xor eax, wax - inc eax - ret - -align 4 + xor eax, wax + inc eax + ret .not_ready: - xor eax, eax - ret + xor eax, eax + ret endp align 4 proc check_semafore - local counter:DWORD + local counter:DWORD - mov [counter], 100 + mov [counter], 100 .l1: - mov edx, CTRL_CAS - call [ctrl.ctrl_read8] - and eax, CAS_FLAG - jz .ok + mov edx, CTRL_CAS + call [ctrl.ctrl_read8] + and eax, CAS_FLAG + jz .ok - mov eax, 1 - call StallExec - sub [counter], 1 - jnz .l1 - xor eax, eax - ret + mov eax, 1 + call StallExec + sub [counter], 1 + jnz .l1 + xor eax, eax + ret align 4 .ok: - xor eax,eax - inc eax - ret + xor eax,eax + inc eax + ret endp align 4 proc StallExec - push ecx - push edx - push ebx - push eax + push ecx + push edx + push ebx + push eax - mov ecx, CPU_FREQ - mul ecx - mov ebx, eax ;low - mov ecx, edx ;high - rdtsc - add ebx, eax - adc ecx,edx + mov ecx, CPU_FREQ + mul ecx + mov ebx, eax ;low + mov ecx, edx ;high + rdtsc + add ebx, eax + adc ecx,edx @@: - rdtsc - sub eax, ebx - sbb edx, ecx - jb @B + rdtsc + sub eax, ebx + sbb edx, ecx + js @B - pop eax - pop ebx - pop edx - pop ecx - ret + pop eax + pop ebx + pop edx + pop ecx + ret endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1192,58 +1193,58 @@ endp align 4 proc codec_io_r16 - add edx, [ctrl.codec_io_base] - in ax, dx - ret + add edx, [ctrl.codec_io_base] + in ax, dx + ret endp align 4 proc codec_io_w16 - add edx, [ctrl.codec_io_base] - out dx, ax - ret + add edx, [ctrl.codec_io_base] + out dx, ax + ret endp align 4 proc ctrl_io_r8 - add edx, [ctrl.ctrl_io_base] - in al, dx - ret + add edx, [ctrl.ctrl_io_base] + in al, dx + ret endp align 4 proc ctrl_io_r16 - add edx, [ctrl.ctrl_io_base] - in ax, dx - ret + add edx, [ctrl.ctrl_io_base] + in ax, dx + ret endp align 4 proc ctrl_io_r32 - add edx, [ctrl.ctrl_io_base] - in eax, dx - ret + add edx, [ctrl.ctrl_io_base] + in eax, dx + ret endp align 4 proc ctrl_io_w8 - add edx, [ctrl.ctrl_io_base] - out dx, al - ret + add edx, [ctrl.ctrl_io_base] + out dx, al + ret endp align 4 proc ctrl_io_w16 - add edx, [ctrl.ctrl_io_base] - out dx, ax - ret + add edx, [ctrl.ctrl_io_base] + out dx, ax + ret endp align 4 proc ctrl_io_w32 - add edx, [ctrl.ctrl_io_base] - out dx, eax - ret + add edx, [ctrl.ctrl_io_base] + out dx, eax + ret endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1252,59 +1253,58 @@ endp align 4 proc codec_mem_r16 - add edx, [ctrl.codec_mem_base] - mov ax, word [edx] - ret + add edx, [ctrl.codec_mem_base] + mov ax, word [edx] + ret endp align 4 proc codec_mem_w16 - add edx, [ctrl.codec_mem_base] - mov word [edx], ax - ret + add edx, [ctrl.codec_mem_base] + mov word [edx], ax + ret endp align 4 proc ctrl_mem_r8 - add edx, [ctrl.ctrl_mem_base] - mov al, [edx] - ret + add edx, [ctrl.ctrl_mem_base] + mov al, [edx] + ret endp align 4 proc ctrl_mem_r16 - add edx, [ctrl.ctrl_mem_base] - mov ax, [edx] - ret + add edx, [ctrl.ctrl_mem_base] + mov ax, [edx] + ret endp align 4 proc ctrl_mem_r32 - add edx, [ctrl.ctrl_mem_base] - mov eax, [edx] - ret + add edx, [ctrl.ctrl_mem_base] + mov eax, [edx] + ret endp align 4 proc ctrl_mem_w8 - add edx, [ctrl.ctrl_mem_base] - mov [edx], al - - ret + add edx, [ctrl.ctrl_mem_base] + mov [edx], al + ret endp align 4 proc ctrl_mem_w16 - add edx, [ctrl.ctrl_mem_base] - mov [edx], ax - ret + add edx, [ctrl.ctrl_mem_base] + mov [edx], ax + ret endp align 4 proc ctrl_mem_w32 - add edx, [ctrl.ctrl_mem_base] - mov [edx], eax - ret + add edx, [ctrl.ctrl_mem_base] + mov [edx], eax + ret endp diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 2b91ba0a66..42e5ffff84 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -918,15 +918,15 @@ reserve_irqs_ports: mov [0x2d0000+edi+0],dword 1 mov [0x2d0000+edi+4],dword 0x0 mov [0x2d0000+edi+8],dword 0xdf - + inc dword [0x2d0000] ; 0xe5-0xff mov edi,[0x2d0000] shl edi,4 mov [0x2d0000+edi+0],dword 1 mov [0x2d0000+edi+4],dword 0xe5 mov [0x2d0000+edi+8],dword 0xff - - + + ; cmp [0xf604],byte 2 ; com1 mouse -> 0x3f0-0x3ff ; jne ripl1 ; inc dword [0x2d0000] @@ -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 diff --git a/kernel/trunk/video/cursors.inc b/kernel/trunk/video/cursors.inc index 24b7959bd3..e11c627e76 100644 --- a/kernel/trunk/video/cursors.inc +++ b/kernel/trunk/video/cursors.inc @@ -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