diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index 5d20c74307..c4ddc6af3b 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -325,7 +325,7 @@ macro irqh [num] jmp irq_c } -irqh 2,3,4,5,7,8,9,10,11,12,14,15 +irqh 2,5,7,8,9,10,11,14,15 irq_c: push ds es @@ -344,15 +344,57 @@ p_irq6: mov ds, ax mov es, ax call fdc_irq - - mov [check_idle_semaphore],5 - mov al, 0x20 - out 0x20, al - + call ready_for_next_irq pop es ds popad iret +p_irq3: + pushad + push ds es + mov ax, os_data + mov ds, ax + mov es, ax + call check_mouse_data_com2 + pop es ds + popad + iret + +p_irq4: + pushad + push ds es + mov ax, os_data + mov ds, ax + mov es, ax + call check_mouse_data_com1 + pop es ds + popad + iret + +p_irq12: + pushad + push ds es + mov ax, os_data + mov ds, ax + mov es, ax + call check_mouse_data_ps2 + pop es ds + popad + iret + +ready_for_next_irq: + mov [check_idle_semaphore],5 + mov al, 0x20 + out 0x20, al + ret + +ready_for_next_irq_1: + mov [check_idle_semaphore],5 + mov al, 0x20 + out 0xa0,al + out 0x20, al + ret + irqD: pushad push ds es @@ -773,7 +815,7 @@ terminate: ; terminate application pusha ; remove all port reservations - + mov [deleted_process],esi mov edx,esi shl edx, 5 ;imul edx,0x20 add edx,0x3000 @@ -829,7 +871,13 @@ terminate: ; terminate application ; movzx ecx,word [dlxe] ; movzx edx,word [dlye] call calculatescreen - + cli + mov eax,[deleted_process] + cmp eax,[active_process] + jne no_activate_process + call read_active_process_stack + no_activate_process: + sti xor eax, eax xor esi, esi call redrawscreen @@ -838,19 +886,44 @@ terminate: ; terminate application mov [0xfff5],byte 0 ; draw mouse mov [application_table_status],0 - mov esi,process_terminated call sys_msg_board_str - -;* start code - fix error redraw for terminate (2) - Mario79 -; cmp [draw_present],1 -; je no_draw_background_temp -; mov [0xfff0],byte 1 -;no_draw_background_temp: -; mov [draw_present],0 ret -;draw_present db 0 -;* end code - fix error redraw for terminate (2) - Mario79 + +save_active_process_stack: + cmp [active_proc_stack_coun],0xa400+0x400-4 + jne @f + mov [active_proc_stack_coun],0xa400-4 + @@: + push eax + push ebx + mov eax,[active_process] + shl eax,5 + add eax,0x3000 + mov [eax-twdw+31],byte 1 + add [active_proc_stack_coun],4 + mov eax,[active_process] + mov ebx,[active_proc_stack_coun] + mov [ebx],eax + pop ebx + pop eax + ret + +read_active_process_stack: + cmp [active_proc_stack_coun],0xa400-4 + jne @f + mov [active_proc_stack_coun],0xa400+0x400-4 + @@: + push eax + push ebx + mov ebx,[active_proc_stack_coun] + mov eax,[ebx] + mov [0xff01],eax ; activate + sub [active_proc_stack_coun],4 + mov [active_process_flag],1 + pop ebx + pop eax + ret iglobal boot_sched_1 db 'Building gdt tss pointer',0 diff --git a/kernel/trunk/detect/commouse.inc b/kernel/trunk/detect/commouse.inc index 6af8a2168c..1275d4e453 100644 --- a/kernel/trunk/detect/commouse.inc +++ b/kernel/trunk/detect/commouse.inc @@ -7,9 +7,28 @@ ; Автор исходного текста Кулаков Владимир Геннадьевич. ; Адаптация и доработка Mario79 -MSMouseSearch: +Detect_COM_Mouse: pusha -; ПОИСК МЫШИ ЧЕРЕЗ COM-ПОРТЫ + call MSMouseSearch + cmp AL,'M' + jne @f + mov [com1_mouse_detected],1 + mov esi,boot_setmouse_type+22 + call boot_log + @@: + sub [COMPortBaseAddr],100h + call MSMouseSearch + cmp AL,'M' + jne @f + mov [com2_mouse_detected],1 + mov esi,boot_setmouse_type+44 + call boot_log + @@: + popa + jmp end_detecting_mouse + +MSMouseSearch: + ; ПОИСК МЫШИ ЧЕРЕЗ COM-ПОРТЫ MouseSearch: ; Устанавливаем скорость ; приема/передачи 1200 бод @@ -48,7 +67,7 @@ dT_1: dec ecx cmp ecx,0 jne dT_1 - mov ecx,0xffff + mov ecx,0xffff ; Включить питание мыши mov AL,11b ;установить DTR и RTS out DX,AL @@ -70,46 +89,19 @@ WaitData: ; Ввести данные mov DX,[COMPortBaseAddr] in AL,DX - ; Устройство является мышью? - cmp AL,'M' - je EndDetect NoMouse: - inc [COMPortNum] - cmp [COMPortNum],1 - ja EndDetect - sub [COMPortBaseAddr],100h - jmp MouseSearch + ret iglobal COMPortBaseAddr dw 3F8h -COMPortNum dw 0 +;COMPortNum dw 0 endg iglobal -boot_setmouse_type db 'No COM mouse, set PS2',0 +boot_setmouse_type db 'Detected - PS2 mouse',0 db 'Detected - COM1 mouse',0 db 'Detected - COM2 mouse',0 - endg -EndDetect: - cmp [COMPortNum],0 ;номер порта меньше 0? - jl ComMouseNotFound ;мышь не найдена - cmp [COMPortNum],1 ;номер порта больше 1? - ja ComMouseNotFound ;мышь не найдена - mov ax,[COMPortNum] - add al,2 - jmp set_detecting_mouse - ComMouseNotFound: - mov al,1 - set_detecting_mouse: - mov [0xF604],al - dec al - movzx eax,al - imul eax,22 - mov esi,boot_setmouse_type - add esi,eax - call boot_log - popa - +end_detecting_mouse: diff --git a/kernel/trunk/detect/ps2mouse.inc b/kernel/trunk/detect/ps2mouse.inc new file mode 100644 index 0000000000..1929b640ed --- /dev/null +++ b/kernel/trunk/detect/ps2mouse.inc @@ -0,0 +1,65 @@ +MouseSearch_PS2: + + pusha + + mov bl,0xa8 ; enable mouse cmd + call kb_cmd + cmp ah,1 + je @@DataInputError + + mov bl,0xd4 ; for mouse + call kb_cmd + cmp ah,1 + je @@DataInputError + mov al,0xeb ; + call kb_write + cmp ah,1 + je @@DataInputError + call kb_read ; Acknowledge + call kb_read + mov [ps2_mouse_detected],0 + test al,8 + jz @f + mov [ps2_mouse_detected],1 + @@: + call kb_read ; + call kb_read ; + + mov bl,0x20 ; get command byte + call kb_cmd + cmp ah,1 + je @@DataInputError + call kb_read + cmp ah,1 + je @@DataInputError + or al,3 ; enable interrupt + mov bl,0x60 ; write command + push eax + call kb_cmd + pop eax + call kb_write + cmp ah,1 + je @@DataInputError + + mov bl,0xd4 ; for mouse + call kb_cmd + cmp ah,1 + je @@DataInputError + mov al,0xf4 ; enable mouse device + call kb_write + cmp ah,1 + je @@DataInputError + call kb_read ; read status return + cmp ah,1 + je @@DataInputError + cmp AL,0FAh + jnz @@DataInputError ;нет подтверждения + +@@DataInputError: + cmp [ps2_mouse_detected],0 + je @f + mov esi,boot_setmouse_type + call boot_log + @@: + popa + diff --git a/kernel/trunk/gui/button.inc b/kernel/trunk/gui/button.inc index 3027d12dd7..31bc317b6f 100644 --- a/kernel/trunk/gui/button.inc +++ b/kernel/trunk/gui/button.inc @@ -532,7 +532,6 @@ checkbuttons: call checkidle - call check_mouse_data call [draw_pointer] pushad @@ -552,53 +551,52 @@ checkbuttons: buttonid dd 0x0 ;here a will backup the eax value afterbuttonid: - pusha - mov eax,[buttonid] - ; mouse x >= button x ? - movzx ebx,word [eax+0] - shl ebx,5 - add ebx,window_data - movzx ecx,word [ebx+0] ; window x start - movzx edx,word [eax+4] ; button x start - add edx,ecx - mov cx,[0xfb0a] - cmp edx,ecx - jg no_on_button ;if we release the pointer out of the button area + pusha + ; mouse x >= button x ? + movzx ebx,word [eax+0] + shl ebx,5 + add ebx,window_data + movzx ecx,word [ebx+0] ; window x start + movzx edx,word [eax+4] ; button x start + add edx,ecx + mov cx,[0xfb0a] + cmp edx,ecx + jg no_on_button ;if we release the pointer out of the button area - movzx ebx,word [eax+6] ; button x size - add edx,ebx - cmp ecx,edx - jg no_on_button + movzx ebx,word [eax+6] ; button x size + add edx,ebx + cmp ecx,edx + jg no_on_button - ; mouse y >= button y ? - movzx ebx,word [eax+0] - shl ebx,5 - add ebx,window_data - movzx ecx,word [ebx+4] ; window y start - movzx edx,word [eax+8] ; button y start - add edx,ecx - mov cx,[0xfb0c] - cmp edx,ecx - jg no_on_button + ; mouse y >= button y ? + movzx ebx,word [eax+0] + shl ebx,5 + add ebx,window_data + movzx ecx,word [ebx+4] ; window y start + movzx edx,word [eax+8] ; button y start + add edx,ecx + mov cx,[0xfb0c] + cmp edx,ecx + jg no_on_button - movzx ebx,word [eax+10] ; button y size - add edx,ebx - cmp ecx,edx - jg no_on_button - popa - mov [0xf500],byte 1 ; no of buttons in buffer - pop ebx - mov [0xf501],ebx ; lets put the button id in buffer - push ebx - pusha - jmp yes_on_button + movzx ebx,word [eax+10] ; button y size + add edx,ebx + cmp ecx,edx + jg no_on_button + popa + mov [0xf500],byte 1 ; no of buttons in buffer + pop ebx + mov [0xf501],ebx ; lets put the button id in buffer + push ebx + pusha + jmp yes_on_button no_on_button: - mov [0xf500],byte 0 ; no of buttons in buffer + mov [0xf500],byte 0 ; no of buttons in buffer yes_on_button: - mov [0xfb44],byte 0 ; mouse down -> do not draw - popa - pop ebx - popa - ret -;..................................... end 2/2 : modified by vhanla ................................ + mov [0xfb44],byte 0 ; mouse down -> do not draw + popa + pop ebx + popa + ret +;..................................... end 2/2 : modified by vhanla ................................ diff --git a/kernel/trunk/gui/skincode.inc b/kernel/trunk/gui/skincode.inc index e8bb48ac6c..66047e45bd 100644 --- a/kernel/trunk/gui/skincode.inc +++ b/kernel/trunk/gui/skincode.inc @@ -170,28 +170,76 @@ load_default_skin: mov edi, eax mov esi, 0x90000 call bmp2raw + mov eax, [0x90000+bmp_header.height] + mov [_skinh], eax + popad + ret -; mov eax, [0x90000+bmp_header.height] -; imul eax, [0x90000+bmp_header.width] -; imul eax, 3 -; add eax, raw_data ; now eax points to the last line of image - -; mov ecx, [eax] -; mov [_coloroutborder], ecx -; mov [_colorborder], ecx -; sub eax, 2*3 -; mov ecx, [eax] -; mov [_colorframe], ecx +load_default_skin_1: + pushad + mov eax, _fileleft_1 + call load_bmp_file + mov eax, [0x90000+bmp_header.width] + mov [_skinleftw], eax + mov [_skinleft_1], 0 + mov edi, raw_data+1000h + mov [_refleft_1], edi + mov esi, 0x90000 + call bmp2raw + mov eax, [_bmp_bpl] + imul eax, [0x90000+bmp_header.height] + push eax + mov eax, _filebase_1 + call load_bmp_file + mov eax, [0x90000+bmp_header.width] + mov [_skinbasew], eax + mov eax, [_skinleftw] + mov [_skinbase], eax + pop eax + add eax, [_refleft_1] + ; align to 32-byte boundary + test eax, 11111b + jz @f + shr eax, 5 + inc eax + shl eax, 5 + @@: + ; save base address + mov [_refbase_1], eax + ; convert + mov edi, eax + mov esi, 0x90000 + call bmp2raw + mov eax, [_bmp_bpl] + imul eax, [0x90000+bmp_header.height] + push eax + mov eax, _fileoper_1 + call load_bmp_file + mov eax, [0x90000+bmp_header.width] + mov [_skinoperw], eax + neg eax + mov [_skinoper], eax + pop eax + add eax, [_refbase_1] + ; align to 32-byte boundary + test eax, 11111b + jz @f + shr eax, 5 + inc eax + shl eax, 5 + @@: + mov [_refoper_1], eax + mov edi, eax + mov esi, 0x90000 + call bmp2raw mov eax, [0x90000+bmp_header.height] mov [_skinh], eax popad ret - - drawwindow_IV: pusha @@ -241,7 +289,15 @@ drawwindow_IV: mov ecx,[_skinleftw] shl ecx,16 add ecx,[_skinh] + + cmp [aw_yes],1 +; cmp [esp+32+4+2], word 1 + jne @f mov ebx,[_refleft] + jmp no_aw_3 + @@: + mov ebx,[_refleft_1] + no_aw_3: call sys_putimage mov esi,[esp] @@ -256,7 +312,14 @@ drawwindow_IV: inc eax + cmp [aw_yes],1 +; cmp [esp+32+4+2], word 1 + jne @f mov ebx,[_refbase] + jmp no_aw_2 + @@: + mov ebx,[_refbase_1] + no_aw_2: mov ecx,[_skinbasew] shl ecx,16 add ecx,[_skinh] @@ -281,7 +344,14 @@ drawwindow_IV: sub edx,[_skinoperw] inc edx shl edx,16 + cmp [aw_yes],1 +; cmp [esp+32+4+2], word 1 + jne @f mov ebx,[_refoper] + jmp no_aw_1 + @@: + mov ebx,[_refoper_1] + no_aw_1: mov ecx,[_skinoperw] shl ecx,16 add ecx,[_skinh] @@ -383,6 +453,7 @@ drawwindow_IV: add esp,4 popa + ret diff --git a/kernel/trunk/gui/skindata.inc b/kernel/trunk/gui/skindata.inc index a76961c122..76761de8bc 100644 --- a/kernel/trunk/gui/skindata.inc +++ b/kernel/trunk/gui/skindata.inc @@ -32,6 +32,9 @@ iglobal _fileleft db 'LEFT.BMP ' _filebase db 'BASE.BMP ' _fileoper db 'OPER.BMP ' + _fileleft_1 db 'LEFT_1.BMP ' + _filebase_1 db 'BASE_1.BMP ' + _fileoper_1 db 'OPER_1.BMP ' endg uglobal @@ -39,6 +42,10 @@ uglobal _refbase dd 0 _refleft dd 0 _skinleft dd 0 - _skinwinw dd 0 +; _skinwinw dd 0 + _refoper_1 dd 0 + _refbase_1 dd 0 + _refleft_1 dd 0 + _skinleft_1 dd 0 endg diff --git a/kernel/trunk/gui/window.inc b/kernel/trunk/gui/window.inc index 9a17bcb992..f03d3fa30f 100644 --- a/kernel/trunk/gui/window.inc +++ b/kernel/trunk/gui/window.inc @@ -401,7 +401,6 @@ check_window_move_request: mov ecx,10 ; wait 1/10 second wmrl3: - call check_mouse_data call [draw_pointer] mov eax,1 call delay_hs @@ -722,8 +721,7 @@ windowactivate: ; esi = abs mem position in stack 0xC400+ pushad - - push esi + push esi movzx eax, word [esi] ; ax <- process no movzx eax, word [0xC000+eax*2] ; ax <- position in window stack @@ -749,7 +747,22 @@ windowactivate: mov [0xC000+eax*2], bx ; this is the last (and the upper) ;* start code - get active process (4) - Mario79 - mov [active_process],eax + cli + cmp [active_process_flag],1 + jne @f + mov [active_process_flag],0 + jmp end_save_active_process + @@: + call save_active_process_stack + end_save_active_process: + mov [active_process],eax + push eax + mov eax,[active_process] + shl eax,5 + add eax,0x3000 + mov [eax-twdw+31],byte 1 + pop eax + sti ;* end code - get active process (4) - Mario79 ; update on screen -window stack @@ -763,10 +776,8 @@ windowactivate: mov [ebx*2 + 0xC400], si jmp waloop2 wacont2: - mov [0xf400], byte 0 ; empty keyboard buffer mov [0xf500], byte 0 ; empty button buffer - popad ret @@ -902,8 +913,8 @@ waredraw: ; if redraw necessary at activate .waitflagdown: dec ecx jz .nowait - mov eax, 2 - call delay_hs +; mov eax, 2 +; call delay_hs cmp [edi+31], byte 0 ; wait flag to drop jnz .waitflagdown .nowait: @@ -950,8 +961,8 @@ checkwindows: call waredraw ;* start code - get active process (2) - Mario79 - mov eax,[0xff01] - mov [active_process],eax +; mov eax,[0xff01] +; mov [active_process],eax ;* end code - get active process (2) - Mario79 mov [0xff01],dword 0 ; activated @@ -1163,7 +1174,6 @@ checkwindows: mov [0xfff4],byte 0 - call check_mouse_data call [draw_pointer] pushad @@ -1460,7 +1470,6 @@ checkwindows: mov ecx,100 ; wait to avoid mouse residuals waitre2: - call check_mouse_data mov [0xfff5],byte 1 call checkidle cmp [edi+31],byte 0 diff --git a/kernel/trunk/hid/m_com1.inc b/kernel/trunk/hid/m_com1.inc new file mode 100644 index 0000000000..9978b73cb0 --- /dev/null +++ b/kernel/trunk/hid/m_com1.inc @@ -0,0 +1,118 @@ +; Номер принимаемого от мыши байта +MouseByteNumber DB 0 +; Трехбайтовая структура данных, передаваемая мышью +FirstByte DB 0 +SecondByte DB 0 +ThirdByte DB 0 + +;*************************************** +;* НОВЫЙ ОБРАБОТЧИК ПРЕРЫВАНИЯ ОТ МЫШИ * +;*************************************** +check_mouse_data_com1: + cmp [com1_mouse_detected],0 + je @@EndMouseInterrupt +; Проверить наличие данных + mov DX,3F8h ;[COMPortBaseAddr] + add DX,5 ;xFDh + in AL,DX + test AL,1 ;Данные готовы? + jz @@Error +; Ввести данные + mov DX,3F8h ;[COMPortBaseAddr] ;xF8h + in AL,DX +; Сбросить старший незначащий бит + and AL,01111111b + +; Определить порядковый номер принимаемого байта + cmp [MouseByteNumber],0 + je @@FirstByte + cmp [MouseByteNumber],1 + je @@SecondByte + cmp [MouseByteNumber],2 + je @@ThirdByte + jmp @@Error + +; Сохранить первый байт данных +@@FirstByte: + test AL,1000000b ;Первый байт посылки? + jz @@Error + mov [FirstByte],AL + inc [MouseByteNumber] ;увеличить счетчик + jmp @@EndMouseInterrupt +; Сохранить второй байт данных +@@SecondByte: + test AL,1000000b + jnz @@Error + mov [SecondByte],AL + inc [MouseByteNumber] ;увеличить счетчик + jmp @@EndMouseInterrupt +; Сохранить третий байт данных +@@ThirdByte: + test AL,1000000b + jnz @@Error + mov [ThirdByte],AL ;увеличить счетчик + mov [MouseByteNumber],0 +; (Пакет данных от мыши принят полностью). +; Записать новое значение состояния кнопок мыши + mov al,[FirstByte] ;[0xfb01] + mov ah,al + shr al,3 + and al,2 + shr ah,5 + and ah,1 + add al,ah + mov [0xfb40],al + mov [mouse_active],1 +; Прибавить перемещение по X к координате X + mov AL,[FirstByte] + shl AL,6 + or AL,[SecondByte] + cbw + shl ax,1 + add AX,[0xFB0A] ;[XCoordinate] + ; Курсор не должен выходить за левую или + ; правую границу экрана + js @@X1 + cmp AX,[0xFE00] ;ScreenLength + jb @@X2 + ; Установить координату X по правой границе + mov AX,[0xFE00] ;ScreenLength-1 + dec ax + jmp @@X2 +@@X1: + ; Установить координату X по левой границе + xor AX,AX +@@X2: + mov [0xFB0A],AX ;[XCoordinate] + ; Прибавить перемещение по Y к координате Y + mov AL,[FirstByte] + and AL,00001100b + shl AL,4 + or AL,[ThirdByte] + cbw + shl ax,1 + add AX,[0xFB0C] ;[YCoordinate] + ; Курсор не должен выходить за верхнюю или + ; нижнюю границу экрана + js @@Y1 + cmp AX,[0xFE04] ;ScreenHeigth + jb @@Y2 + ; Установить координату X по нижней границе + mov AX,[0xFE04] ;ScreenHeigth-1 + dec ax + jmp @@Y2 +@@Y1: + ; Установить координату X по верхней границе + xor AX,AX +@@Y2: + mov [0xFB0C],AX ;[YCoordinate] + jmp @@EndMouseInterrupt + +@@Error: +; Произошел сбой в порядке передачи информации от +; мыши, обнулить счетчик байтов пакета данных + mov [MouseByteNumber],0 +@@EndMouseInterrupt: + call ready_for_next_irq + ret + diff --git a/kernel/trunk/hid/m_com2.inc b/kernel/trunk/hid/m_com2.inc new file mode 100644 index 0000000000..ddb327807a --- /dev/null +++ b/kernel/trunk/hid/m_com2.inc @@ -0,0 +1,118 @@ +; Номер принимаемого от мыши байта +MouseByteNumber_1 DB 0 +; Трехбайтовая структура данных, передаваемая мышью +FirstByte_1 DB 0 +SecondByte_1 DB 0 +ThirdByte_1 DB 0 + +;*************************************** +;* НОВЫЙ ОБРАБОТЧИК ПРЕРЫВАНИЯ ОТ МЫШИ * +;*************************************** +check_mouse_data_com2: + cmp [com2_mouse_detected],0 + je @@EndMouseInterrupt_1 +; Проверить наличие данных + mov DX,2F8h ;[COMPortBaseAddr] + add DX,5 ;xFDh + in AL,DX + test AL,1 ;Данные готовы? + jz @@Error_1 +; Ввести данные + mov DX,2F8h ;[COMPortBaseAddr] ;xF8h + in AL,DX +; Сбросить старший незначащий бит + and AL,01111111b + +; Определить порядковый номер принимаемого байта + cmp [MouseByteNumber_1],0 + je @@FirstByte_1 + cmp [MouseByteNumber_1],1 + je @@SecondByte_1 + cmp [MouseByteNumber_1],2 + je @@ThirdByte_1 + jmp @@Error_1 + +; Сохранить первый байт данных +@@FirstByte_1: + test AL,1000000b ;Первый байт посылки? + jz @@Error_1 + mov [FirstByte_1],AL + inc [MouseByteNumber_1] ;увеличить счетчик + jmp @@EndMouseInterrupt_1 +; Сохранить второй байт данных +@@SecondByte_1: + test AL,1000000b + jnz @@Error_1 + mov [SecondByte_1],AL + inc [MouseByteNumber_1] ;увеличить счетчик + jmp @@EndMouseInterrupt_1 +; Сохранить третий байт данных +@@ThirdByte_1: + test AL,1000000b + jnz @@Error_1 + mov [ThirdByte_1],AL ;увеличить счетчик + mov [MouseByteNumber_1],0 +; (Пакет данных от мыши принят полностью). +; Записать новое значение состояния кнопок мыши + mov al,[FirstByte_1] ;[0xfb01] + mov ah,al + shr al,3 + and al,2 + shr ah,5 + and ah,1 + add al,ah + mov [0xfb40],al + mov [mouse_active],1 +; Прибавить перемещение по X к координате X + mov AL,[FirstByte_1] + shl AL,6 + or AL,[SecondByte_1] + cbw + shl ax,1 + add AX,[0xFB0A] ;[XCoordinate] + ; Курсор не должен выходить за левую или + ; правую границу экрана + js @@X1_1 + cmp AX,[0xFE00] ;ScreenLength + jb @@X2_1 + ; Установить координату X по правой границе + mov AX,[0xFE00] ;ScreenLength-1 + dec ax + jmp @@X2_1 +@@X1_1: + ; Установить координату X по левой границе + xor AX,AX +@@X2_1: + mov [0xFB0A],AX ;[XCoordinate] + ; Прибавить перемещение по Y к координате Y + mov AL,[FirstByte_1] + and AL,00001100b + shl AL,4 + or AL,[ThirdByte_1] + cbw + shl ax,1 + add AX,[0xFB0C] ;[YCoordinate] + ; Курсор не должен выходить за верхнюю или + ; нижнюю границу экрана + js @@Y1_1 + cmp AX,[0xFE04] ;ScreenHeigth + jb @@Y2_1 + ; Установить координату X по нижней границе + mov AX,[0xFE04] ;ScreenHeigth-1 + dec ax + jmp @@Y2_1 +@@Y1_1: + ; Установить координату X по верхней границе + xor AX,AX +@@Y2_1: + mov [0xFB0C],AX ;[YCoordinate] + jmp @@EndMouseInterrupt_1 + +@@Error_1: +; Произошел сбой в порядке передачи информации от +; мыши, обнулить счетчик байтов пакета данных + mov [MouseByteNumber_1],0 +@@EndMouseInterrupt_1: + call ready_for_next_irq + ret + diff --git a/kernel/trunk/hid/m_ps2.inc b/kernel/trunk/hid/m_ps2.inc new file mode 100644 index 0000000000..4f6da69546 --- /dev/null +++ b/kernel/trunk/hid/m_ps2.inc @@ -0,0 +1,157 @@ +; Номер принимаемого от мыши байта +MouseByteNumber_2 DB 0 +; Трехбайтовая структура данных, передаваемая мышью +FirstByte_2 DB 0 +SecondByte_2 DB 0 +ThirdByte_2 DB 0 + +;************************************** +;* ОБРАБОТЧИК ПРЕРЫВАНИЯ ОТ МЫШИ PS/2 * +;************************************** +check_mouse_data_ps2: + cmp [ps2_mouse_detected],0 + je @@EndMouseInterrupt_2 + call Wait8042BufferEmpty ;очистка буфера + in AL,0x60 ;получить скэн-код +; Выбирать порядковый номер принимаемого байта + cmp [MouseByteNumber_2],0 + je @@SaveFirstByte + cmp [MouseByteNumber_2],1 + je @@SaveSecondByte + cmp [MouseByteNumber_2],2 + je @@SaveThirdByte + jmp @@Error_2 +; Записать первый байт посылки +@@SaveFirstByte: + test AL,1000b ;первый байт посылки? + jz @@Error_2 ;сбой синхронизации + mov [FirstByte_2],AL + inc [MouseByteNumber_2] + jmp @@EndMouseInterrupt_2 +; Записать второй байт посылки +@@SaveSecondByte: + mov [SecondByte_2],AL + inc [MouseByteNumber_2] + jmp @@EndMouseInterrupt_2 +; Записать третий байт посылки +@@SaveThirdByte: + mov [ThirdByte_2],AL + mov [MouseByteNumber_2],0 +; (пакет данных от мыши принят полностью) +; Записать новое значение байта состояния кнопок + mov al,[FirstByte_2] ;[0xfb01] + and eax,3 + mov [0xfb40],al + mov [mouse_active],1 +; Вычислить новую X-координату курсора + ; Занести в AX перемещение по X + mov AH,0 ;дублируем знак во все разряды AH + mov AL,[FirstByte_2] + test AL,10000b + jz @@M0 + mov AH,0FFh + ; Занести в AL младший байт +@@M0: + mov AL,[SecondByte_2] + shl ax,1 + ; Вычислить новое значение координаты + ; курсора по X + add AX,[0xFB0A] ;[XCoordinate] + cmp AX,0 + jge @@M1 + mov AX,0 + jmp @@M2 +@@M1: + cmp AX,[0xFE00] ;ScreenLength + jl @@M2 + mov AX,[0xFE00] ;ScreenLength-1 + dec ax +@@M2: + mov [0xFB0A],AX ;[XCoordinate] + +; Вычисляем новую Y-координату курсора + ; Занести в AX перемещение по Y + mov AH,0 ;дублируем знак во все разряды AH + mov AL,[FirstByte_2] + test AL,100000b + jz @@M3 + mov AH,0FFh + ; Занести в AL младший байт +@@M3: + mov AL,[ThirdByte_2] + shl ax,1 + ; Вычислить новое значение координаты курсора + ; по Y (Y-координата мыши PS/2 направлена + ; противоположно экранной) + neg AX + add AX,[0xFB0C] ;[YCoordinate] + cmp AX,0 + jge @@M4 + mov AX,0 + jmp @@M5 +@@M4: + cmp AX,[0xFE04] ;ScreenHeigth + jl @@M5 + mov AX,[0xFE04] ;ScreenHeigth-1 + dec ax +@@M5: + mov [0xFB0C],AX ;[YCoordinate] + +; Показать курсор в новой позиции + jmp @@EndMouseInterrupt_2 + +; Обнаружен сбой в порядке передачи информации от мыши +@@Error_2: + mov [MouseByteNumber_2],0 +; Нормальное завершение прерывания +@@EndMouseInterrupt_2: + call ready_for_next_irq_1 + ret + +;*********************************************** +;* ОЖИДАНИЕ ОЧИСТКИ ВХОДНОГО БУФЕРА I8042 * +;* При выходе из процедуры: * +;* флаг ZF установлен - нормальное завершение, * +;* флаг ZF сброшен - ошибка тайм-аута. * +;*********************************************** +Wait8042BufferEmpty: +; push CX +; mov CX,0FFFFh ;задать число циклов ожидания +;@@kb: +; in AL,64h ;получить статус +; test AL,10b ;буфер i8042 свободен? +; loopnz @@kb ;если нет, то цикл +; pop CX + push ecx + xor ecx,ecx + @@: + in al,64h + test al,00000010b + loopnz @b + pop ecx + ;Если при выходе из подпрограммы сброшен + ;флаг ZF - ошибка + ret ;возврат в подпрограмму + +;*************************************** +;* ОЖИДАНИЕ ПОСТУПЛЕНИЯ ДАННЫХ ОТ МЫШИ * +;*************************************** +WaitMouseData: +; push CX +; mov CX,0FFFFh ;задать число циклов ожидания +;@@mouse: +; in AL,64h ;опросить регистр статуса +; test AL,100000b ;данные поступили? +; loopz @@mouse ;если нет, то цикл +; pop CX + push ecx + mov ECX,0FFFFh + @@: + in al,64h + test al,100000b + loopz @b + pop ecx + ;Если при выходе из подпрограммы установлен + ;флаг ZF - ошибка + ret + diff --git a/kernel/trunk/hid/mousedrv.inc b/kernel/trunk/hid/mousedrv.inc new file mode 100644 index 0000000000..8b6e819291 --- /dev/null +++ b/kernel/trunk/hid/mousedrv.inc @@ -0,0 +1,408 @@ +; check mouse +; +; +; FB00 -> FB0F mouse memory 00 chunk count - FB0A-B x - FB0C-D y +; FB10 -> FB17 mouse color mem +; FB21 x move +; FB22 y move +; FB30 color temp +; FB28 high bits temp +; FB4A -> FB4D FB4A-B x-under - FB4C-D y-under +; FC00 -> FCFE com1/ps2 buffer +; FCFF com1/ps2 buffer count starting from FC00 + +uglobal + mousecount dd 0x0 + mousedata dd 0x0 +endg + +include 'm_ps2.inc' +include 'm_com1.inc' +include 'm_com2.inc' + + +;test_mario79: +; push esi +; push eax +; mov [write_error_to],process_test_m79+43 +; movzx eax,al ;[DevErrorCode] +; call writehex +; mov esi,process_test_m79 +; call sys_msg_board_str +; pop eax +; pop esi +; ret +;process_test_m79 db 'K : Process - test Mario79 error 00000000',13,10,0 + +draw_mouse_under: + + ; return old picture + + pushad + + xor ecx,ecx + xor edx,edx + + ;cli ; !!!**** + align 4 + mres: + + movzx eax,word [0xfb4a] + movzx ebx,word [0xfb4c] + + add eax,ecx + add ebx,edx + + push ecx + push edx + push eax + push ebx + + mov eax,edx + shl eax,6 + shl ecx,2 + add eax,ecx + add eax,mouseunder + mov ecx,[eax] + + pop ebx + pop eax + + ;;;push edi + mov edi, 1 ;force + call [putpixel] + ;;;pop edi + + pop edx + pop ecx + + inc ecx + cmp ecx, 16 + jnz mres + xor ecx, ecx + inc edx + cmp edx, 24 + jnz mres + ;sti ; !!!**** + + popad + + ret + +save_draw_mouse: + pushad + ; save & draw + + mov [0xfb4a],ax + mov [0xfb4c],bx + push eax + push ebx + mov ecx,0 + mov edx,0 + + ;cli ; !!!**** + align 4 + drm: + + push eax + push ebx + push ecx + push edx + + ; helloworld + push ecx +; push eax ebx ecx + add eax,ecx ; save picture under mouse + add ebx,edx + push ecx + call getpixel + mov [0xfb30],ecx + pop ecx + mov eax,edx + shl eax,6 + shl ecx,2 + add eax,ecx + add eax,mouseunder + mov ebx,[0xfb30] + mov [eax],ebx +; pop ecx ebx eax + pop ecx + + mov edi,edx ; y cycle + shl edi,4 ; *16 bytes per row + add edi,ecx ; x cycle + mov esi, edi + add edi, esi + add edi, esi ; *3 + add edi,[0xf200] ; we have our str address + mov esi, edi + add esi, 16*24*3 + push ecx + mov ecx, [0xfb30] + call combine_colors + mov [0xfb10], ecx + pop ecx + + + pop edx + pop ecx + pop ebx + pop eax + + add eax,ecx ; we have x coord+cycle + add ebx,edx ; and y coord+cycle + +; push ecx edi + push ecx + mov ecx, [0xfb10] + mov edi, 1 + call [putpixel] + pop ecx +; pop edi ecx + +; mnext: + + mov ebx,[esp+0] ; pure y coord again + mov eax,[esp+4] ; and x + + inc ecx ; +1 cycle + cmp ecx,16 ; if more than 16 + jnz drm + xor ecx, ecx + inc edx + cmp edx,24 + jnz drm + + pop ebx + pop eax + + ;sti ; !!!**** + popad + ret + + +combine_colors: + + ; in + ; ecx - color ( 00 RR GG BB ) + ; edi - ref to new color byte + ; esi - ref to alpha byte + ; + ; out + ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) ) + + push eax + push ebx + push edx + push ecx + xor ecx, ecx + ; byte 2 + mov eax, 0xff + sub al, [esi+0] + mov ebx, [esp] + shr ebx, 16 + and ebx, 0xff + mul ebx + shr eax, 8 + add ecx, eax +; xor eax, eax +; xor ebx, ebx +; mov al, [edi+0] +; mov bl, [esi+0] + movzx eax, byte [edi+0] + movzx ebx, byte [esi+0] + mul ebx + shr eax, 8 + add ecx, eax + shl ecx, 8 + ; byte 1 + mov eax, 0xff + sub al, [esi+1] + mov ebx, [esp] + shr ebx, 8 + and ebx, 0xff + mul ebx + shr eax, 8 + add ecx, eax +; xor eax, eax +; xor ebx, ebx +; mov al, [edi+1] +; mov bl, [esi+1] + movzx eax, byte [edi+1] + movzx ebx, byte [esi+1] + mul ebx + shr eax, 8 + add ecx, eax + shl ecx, 8 + ; byte 2 + mov eax, 0xff + sub al, [esi+2] + mov ebx, [esp] + and ebx, 0xff + mul ebx + shr eax, 8 + add ecx, eax +; xor eax, eax +; xor ebx, ebx +; mov al, [edi+2] +; mov bl, [esi+2] + movzx eax, byte [edi+2] + movzx ebx, byte [esi+2] + mul ebx + shr eax, 8 + add ecx, eax + + pop eax + pop edx + pop ebx + pop eax + ret + + +__sys_disable_mouse: + + cli + pushad + cmp dword [0xf204],dword 0 + jne no_mouse_disable + + cmp [0x3000],dword 1 + je disable_m + + mov edx,[0x3000] + shl edx,5 + add edx,window_data + + movzx eax, word [0xfb0a] + movzx ebx, word [0xfb0c] + + mov ecx,[0xfe00] + inc ecx + imul ecx,ebx + add ecx,eax + add ecx, display_data + + movzx eax, byte [edx+twdw+0xe] + + movzx ebx, byte [ecx] + cmp eax,ebx + je yes_mouse_disable + movzx ebx, byte [ecx+16] + cmp eax,ebx + je yes_mouse_disable + +; mov ebx,[0xfe00] +; inc ebx +; imul ebx,10 +; add ecx,ebx +; movzx ebx, byte [ecx] +; cmp eax,ebx +; je yes_mouse_disable + + mov ebx,[0xfe00] + inc ebx + imul ebx,10 + add ecx,ebx + movzx ebx, byte [ecx] + cmp eax,ebx + je yes_mouse_disable + + movzx ebx, byte [ecx+16] + cmp eax,ebx + je yes_mouse_disable + + jmp no_mouse_disable + + yes_mouse_disable: + + mov edx,[0x3000] + shl edx,5 + add edx,window_data + + movzx eax, word [0xfb0a] + movzx ebx, word [0xfb0c] + + mov ecx,[edx+0] ; mouse inside the area ? + add eax,14 + cmp eax,ecx + jb no_mouse_disable + sub eax,14 + + add ecx,[edx+8] + cmp eax,ecx + jg no_mouse_disable + + mov ecx,[edx+4] + add ebx,20 + cmp ebx,ecx + jb no_mouse_disable + sub ebx,20 + + add ecx,[edx+12] + cmp ebx,ecx + jg no_mouse_disable + + disable_m: + cmp dword [0xf204],dword 0 + jne @f + call draw_mouse_under +; @@: + mov [0xf204],dword 1 +; inc dword [0xf204] + @@: + + no_mouse_disable: + popad + sti + ret + +__sys_draw_pointer: + cli + pushad + m_pause_1: + cmp [mouse_pause],0 + je @f +; call change_task +; jmp m_pause_1 + jmp nodmp + @@: +; cli + cmp dword [0xf204],dword 0 ; mouse visible ? + je chms00 + + mov [0xf204], dword 0 + movzx ebx,word [0xfb0c] + movzx eax,word [0xfb0a] + call save_draw_mouse + + nodmu2: + popad + sti + ret + + chms00: + + movzx ecx,word [0xfb4a] + movzx edx,word [0xfb4c] + + movzx ebx,word [0xfb0c] + movzx eax,word [0xfb0a] + + cmp eax,ecx + jne redrawmouse + + cmp ebx,edx + jne redrawmouse + + jmp nodmp + + redrawmouse: + + call draw_mouse_under + call save_draw_mouse + + nodmp: + + popad + sti + ret diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index da59722c4f..fb44e2dfc7 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -86,7 +86,7 @@ drawbar dd __sys_drawbar putpixel dd __sys_putpixel ; } mike.dld -version db 'Kolibri OS version 0.5.2.1 ',13,10,13,10,0 +version db 'Kolibri OS version 0.5.2.9 ',13,10,13,10,0 ;dd endofcode-0x10000 ;db 'Boot02' @@ -582,6 +582,12 @@ include 'vmodeld.inc' ; mov cr4,eax ; fail_fpu: +;The CPU to this moment should be already in PM, +;and bit MP of the register cr0 should be installed in 1. +finit ;reset of the FPU (finit, instead of fninit) +fsetpm ;enable PM of the FPU +finit ;reset the registers, contents which are still equal RM +;Now FPU too in PM ; DETECT DEVICES mov esi,boot_devices @@ -599,9 +605,6 @@ include 'vmodeld.inc' mov al,0x2e ; msb out 0x40,al -;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -;include 'detect/commouse.inc' -;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ; SET MOUSE mov esi,boot_setmouse @@ -710,6 +713,7 @@ include 'vmodeld.inc' ; LOAD DEFAULT SKIN call load_default_skin + call load_default_skin_1 ; MTRR'S @@ -748,11 +752,12 @@ include 'vmodeld.inc' call kb_write ; wait until 8042 is ready - mov ecx,0 - @@: - in al,64h - and al,00000010b - loopnz @b +; xor ecx,ecx +; @@: +; in al,64h +; and al,00000010b +; loopnz @b + call Wait8042BufferEmpty ; mov al, 0xED ; svetodiody - only for testing! ; call kb_write @@ -807,29 +812,28 @@ include 'vmodeld.inc' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; -; MAIN OS LOOP ; +; MAIN OS LOOP START ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; align 32 osloop: - call check_mouse_data call [draw_pointer] - call checkbuttons call main_loop_sys_getkey call checkwindows call check_window_move_request - call checkmisc call checkEgaCga - call stack_handler - call checkidle call check_fdd_motor_status jmp osloop - +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; ; +; MAIN OS LOOP END ; +; ; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; checkidle: pushad @@ -1039,14 +1043,14 @@ checkEgaCga: cnvl: pushad - mov ecx,[0xfb0a] - cmp ecx,[novesachecksum] - jne novesal - popad - ret +; mov ecx,[0xfb0a] +; cmp ecx,[novesachecksum] +; jne novesal +; popad +; ret novesal: - mov [novesachecksum],ecx +; mov [novesachecksum],ecx mov ecx,0 movzx eax,word [0xfb0c] cmp eax,100 @@ -2043,6 +2047,7 @@ sys_midi: detect_devices: ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! include 'detect/commouse.inc' +include 'detect/ps2mouse.inc' ;include 'detect/dev_fd.inc' ;include 'detect/dev_hdcd.inc' ;include 'detect/sear_par.inc' @@ -2120,8 +2125,10 @@ sys_system: ; i.e. if window is not already active ;* start code - get active process (1) - Mario79 + cli mov [window_minimize],2 - mov [active_process],edi +; mov [active_process],edi + sti ;* end code - get active process (1) - Mario79 mov [0xff01],edi ; activate @@ -2146,7 +2153,6 @@ sys_system: ;!!!!!!!!!!!!!!!!!!!!!!!! include 'blkdev/rdsave.inc' ;!!!!!!!!!!!!!!!!!!!!!!!! -;* start code - get active process (2) - Mario79 cmp eax,7 jnz nogetactiveprocess mov eax,[active_process] @@ -2244,7 +2250,6 @@ nosys_wait_retrace: mov [esp+36],dword 0 ret no_mouse_centered: -;* end code - get active process (2) - Mario79 cmp eax,16 jnz no_get_free_space mov eax,[MEM_FreeSpace] @@ -2266,7 +2271,7 @@ keyboard_mode_sys db 0 iglobal version_inf: - db 0,5,2,1 ; version 0.5.2.1 + db 0,5,2,9 ; version 0.5.2.9 db UID_KOLIBRI db 'Kolibri',0 version_end: @@ -2789,29 +2794,52 @@ sys_drawwindow: cmp edi,0 ; type I - original style jne nosyswI + inc [mouse_pause] call sys_set_window call drawwindow_I + dec [mouse_pause] ret nosyswI: cmp edi,1 ; type II - only reserve area, no draw jne nosyswII + inc [mouse_pause] call sys_set_window call sys_window_mouse + dec [mouse_pause] ret nosyswII: cmp edi,2 ; type III - new style jne nosyswIII + inc [mouse_pause] call sys_set_window call drawwindow_III + dec [mouse_pause] ret nosyswIII: cmp edi,3 ; type IV - skinned window jne nosyswIV + + cli + mov edi,[0x3010] + sub edi,0x3000 + shr edi,5 + cmp edi,[active_process] + jne @f + mov [aw_yes],1 + jmp aw_yes_end + @@: + mov [aw_yes],0 + aw_yes_end: + sti + + inc [mouse_pause] call sys_set_window - call drawwindow_IV + call drawwindow_IV + dec [mouse_pause] + mov [aw_yes],0 ret nosyswIV: @@ -3258,708 +3286,6 @@ redrawscreen: ret -; check mouse -; -; -; FB00 -> FB0F mouse memory 00 chunk count - FB0A-B x - FB0C-D y -; FB10 -> FB17 mouse color mem -; FB21 x move -; FB22 y move -; FB30 color temp -; FB28 high bits temp -; FB4A -> FB4D FB4A-B x-under - FB4C-D y-under -; FC00 -> FCFE com1/ps2 buffer -; FCFF com1/ps2 buffer count starting from FC00 - -uglobal - mousecount dd 0x0 - mousedata dd 0x0 -endg - - -check_mouse_data: - - pushad - - cmp [0xF604],byte 1 - jne no_ps2_mouse - mov [mousecount],dword 0x2e0000+12*4096 - mov [mousedata],dword 0x2e0000+12*4096+0x10 - jmp uusicheckmouse -no_ps2_mouse: - cmp [0xF604],byte 2 - jne no_com1_mouse - mov [mousecount],dword 0x2e0000+4*4096 - mov [mousedata],dword 0x2e0000+4*4096+0x10 - jmp uusicheckmouse -no_com1_mouse: - mov [mousecount],dword 0x2e0000+3*4096 - mov [mousedata],dword 0x2e0000+3*4096+0x10 - - uusicheckmouse: - - mov ebx,[mousecount] ; anything at buffer for mouse - cmp dword [ebx], 0 ; !!! - jz checkmouseret - - ; first byte of comX or ps2 ? - - cmp [0xF604],byte 1 - je ps2mousefirst - - ; ****************************************** - ; *********** COMX mouse driver ************ - ; ****************************************** - - com1mousefirst: - - mov edi,[mousedata] - mov dl,byte [edi] ; first com1 ? - test dl,64 - jz @f - mov [0xfb00],byte 0 ; zero mouse block count - @@: - xor ebx,ebx - - mov bl,[0xfb00] - inc bl - mov [0xfb00],bl - mov eax,0xfb00 - add eax,ebx - mov edi,[mousedata] - mov dl,byte [edi] - mov [eax],byte dl - cmp bl,3 ; three ? - jnz decm - - ; buttons - -;* change right and left button by places - start code - Mario79 - mov al,[0xfb01] - mov ah,al - shr al,3 - and al,2 - shr ah,5 - and ah,1 - add al,ah -;* change right and left button by places - end code - Mario79 - - mov [0xfb40],al - - ; com1 mouse - ; x - - mov dl,[0xfb01] ; x high bits - movzx eax,dl - and al,3 - shl al,6 - mov dl,byte[0xfb02] ; x low bits - add al,dl - mov [0xfb21],byte al - movzx ebx,word[0xfb0a] - - mov al,byte [0xfb01] ; + or - ? - test al,2 - jz x_add - - x_sub: ; x- - sub bx,255 - sub bx,255 - x_add: ; x+ - movzx eax,byte [0xfb21] - add bx,ax - add bx,ax - push ebx - mov [0xfb00],byte 0 - - ; y - - - my_event: - - mov dl,[0xfb01] ; y high bits - movzx eax,dl - and al,12 - shl al,4 - mov dl,byte[0xfb03] ; y low bits - add al,dl - mov [0xfb22],byte al - movzx ebx,word[0xfb0c] - - mov al,byte [0xfb01] ; + or - ? - test al,8 - je y_add - - y_sub: ; y- - sub bx,255 - sub bx,255 - y_add: ; y+ - movzx eax,byte [0xfb22] - add bx,ax - add bx,ax - push ebx - mov [0xfb00],byte 0 - jmp mdraw - - ; end of com1 mouse - - - ; ****************************************** - ; ******** PS2 MOUSE DRIVER ************** - ; ****************************************** - - ps2mousefirst: - - movzx edx,byte [0x2E0000+4096*12+0x10] ; first ps2 ? - cmp edx,40 - jne @f - mov [0xfb00],byte 0 ; zero mouse block count - @@: - - movzx ebx,byte [0xfb00] - add ebx,1 - mov [0xfb00],bl - mov eax,0xfb00 - add eax,ebx - mov dl,byte [0x2E0000+4096*12+0x10] - mov [eax],byte dl - - cmp bl,3 ; full packet of three bytes ? - jnz decm - - mov [0xfb00],byte 0 ; zero mouse block count - - ; buttons - - movzx eax,byte [0xfb01] - and eax,3 - mov [0xfb40],al - - ; x - - movzx eax,word [0xfb0a] - movzx edx,byte [0xfb02] - cmp edx,128 - jb ps2xp - shl edx,1 - add eax,edx - cmp eax,512 - jge ps2xsok - xor eax, eax - jmp ps2xready - ps2xsok: - sub eax,512 - jmp ps2xready - ps2xp: - shl edx,1 - add eax,edx - jmp ps2xready - ps2xready: - push eax - - ; y - - movzx eax,word [0xfb0c] - movzx edx,byte [0xfb03] - cmp edx,128 - jb ps2yp - add eax,512 - shl edx,1 - sub eax,edx - jmp ps2yready - ps2yp: - shl edx,1 - cmp edx,eax - jb ps201 - mov edx,eax - ps201: - sub eax,edx - jmp ps2yready - ps2yready: - push eax - - ;jmp mdraw - - ; end of ps2 mouse - - - ; **************************** - ; ***** CHECK FOR LIMITS ***** - ; **************************** - - mdraw: - - cmp [0xfb44],byte 0 - jne mousedraw4 - cmp [0xfb40],byte 0 - je mousedraw4 - mov [0xfff5],byte 1 - - mousedraw4: - - pop ebx - pop eax - - mov [mouse_active],1 - -; mov dx,0 ; smaller than zero - xor dx,dx - cmp bx,dx - jge mnb11 -; mov bx,0 - xor bx,bx - mnb11: - mov [0xfb0c],word bx - -; mov dx,0 - xor dx,dx - cmp ax,dx - jge mnb22 -; mov ax,0 - xor ax,ax - mnb22: - mov [0xfb0a],word ax - - mov edx,[0xfe04] ; bigger than maximum - cmp ebx,edx - jb mnb1 - mov bx,[0xfe04] - mnb1: - mov [0xfb0c],word bx - - mov edx,[0xfe00] - cmp eax,edx - jb mnb2 - mov ax,[0xfe00] - mnb2: - mov [0xfb0a],word ax - - - ; **** NEXT DATA BYTE FROM MOUSE BUFFER **** - - decm: - - mov edi,[mousecount] ; decrease counter - dec dword [edi] - - mov esi,[mousedata] - mov edi,esi - inc esi -; mov ecx,250 - mov ecx,[mousecount] - mov ecx,[ecx] - cld - rep movsb - - jmp uusicheckmouse - - checkmouseret: - - cmp [0xfb44],byte 0 - jne cmret - - cmp [0xfb40],byte 0 - je cmret - - mov [0xfff4],byte 0 - mov [0xfff5],byte 0 - - cmret: - - popad - - ret - - -draw_mouse_under: - - ; return old picture -; cli - - pushad - - xor ecx,ecx - xor edx,edx - - ;cli ; !!!**** - align 4 - mres: - - movzx eax,word [0xfb4a] - movzx ebx,word [0xfb4c] - - add eax,ecx - add ebx,edx - - push ecx - push edx - push eax - push ebx - - mov eax,edx - shl eax,6 - shl ecx,2 - add eax,ecx - add eax,mouseunder - mov ecx,[eax] - - pop ebx - pop eax - - ;;;push edi - mov edi,1 ;force - call [putpixel] - ;;;pop edi - - pop edx - pop ecx - - inc ecx - cmp ecx, 16 - jnz mres - xor ecx, ecx - inc edx - cmp edx, 24 - jnz mres - ;sti ; !!!**** - - popad - -; sti - - ret - - -save_draw_mouse: - - ; save & draw -; cli - - mov [0xfb4a],ax - mov [0xfb4c],bx - push eax - push ebx - mov ecx,0 - mov edx,0 - - ;cli ; !!!**** - - drm: - - push eax - push ebx - push ecx - push edx - - ; helloworld - push eax ebx ecx - add eax,ecx ; save picture under mouse - add ebx,edx - push ecx - call getpixel - mov [0xfb30],ecx - pop ecx - mov eax,edx - shl eax,6 - shl ecx,2 - add eax,ecx - add eax,mouseunder - mov ebx,[0xfb30] - mov [eax],ebx - pop ecx ebx eax - - mov edi,edx ; y cycle - shl edi,4 ; *16 bytes per row - add edi,ecx ; x cycle - mov esi, edi - add edi, esi - add edi, esi ; *3 - add edi,[0xf200] ; we have our str address - mov esi, edi - add esi, 16*24*3 - push ecx - mov ecx, [0xfb30] - call combine_colors - mov [0xfb10], ecx - pop ecx - - - pop edx - pop ecx - pop ebx - pop eax - - add eax,ecx ; we have x coord+cycle - add ebx,edx ; and y coord+cycle - - push ecx edi - mov ecx, [0xfb10] - mov edi, 1 - call [putpixel] - pop edi ecx - - mnext: - - mov ebx,[esp+0] ; pure y coord again - mov eax,[esp+4] ; and x - - inc ecx ; +1 cycle - cmp ecx,16 ; if more than 16 - jnz drm - xor ecx, ecx - inc edx - cmp edx,24 - jnz drm - - pop ebx - pop eax - -; sti ; !!!**** - - ret - - -combine_colors: - - ; in - ; ecx - color ( 00 RR GG BB ) - ; edi - ref to new color byte - ; esi - ref to alpha byte - ; - ; out - ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) ) - - push eax - push ebx - push edx - push ecx - xor ecx, ecx - ; byte 2 - mov eax, 0xff - sub al, [esi+0] - mov ebx, [esp] - shr ebx, 16 - and ebx, 0xff - mul ebx - shr eax, 8 - add ecx, eax -; xor eax, eax -; xor ebx, ebx -; mov al, [edi+0] -; mov bl, [esi+0] - movzx eax, byte [edi+0] - movzx ebx, byte [esi+0] - mul ebx - shr eax, 8 - add ecx, eax - shl ecx, 8 - ; byte 1 - mov eax, 0xff - sub al, [esi+1] - mov ebx, [esp] - shr ebx, 8 - and ebx, 0xff - mul ebx - shr eax, 8 - add ecx, eax -; xor eax, eax -; xor ebx, ebx -; mov al, [edi+1] -; mov bl, [esi+1] - movzx eax, byte [edi+1] - movzx ebx, byte [esi+1] - mul ebx - shr eax, 8 - add ecx, eax - shl ecx, 8 - ; byte 2 - mov eax, 0xff - sub al, [esi+2] - mov ebx, [esp] - and ebx, 0xff - mul ebx - shr eax, 8 - add ecx, eax -; xor eax, eax -; xor ebx, ebx -; mov al, [edi+2] -; mov bl, [esi+2] - movzx eax, byte [edi+2] - movzx ebx, byte [esi+2] - mul ebx - shr eax, 8 - add ecx, eax - - pop eax - pop edx - pop ebx - pop eax - ret - - -__sys_disable_mouse: - - pushad - - cmp [0x3000],dword 1 - je disable_m - - mov edx,[0x3000] - shl edx,5 - add edx,window_data - - movzx eax, word [0xfb0a] - movzx ebx, word [0xfb0c] - - mov ecx,[0xfe00] - inc ecx - imul ecx,ebx - add ecx,eax - add ecx, display_data - - movzx eax, byte [edx+twdw+0xe] - - movzx ebx, byte [ecx] - cmp eax,ebx - je yes_mouse_disable - movzx ebx, byte [ecx+16] - cmp eax,ebx - je yes_mouse_disable - - mov ebx,[0xfe00] - inc ebx - imul ebx,10 - add ecx,ebx - - movzx ebx, byte [ecx] - cmp eax,ebx - je yes_mouse_disable - - mov ebx,[0xfe00] - inc ebx - imul ebx,10 - add ecx,ebx - - movzx ebx, byte [ecx] - cmp eax,ebx - je yes_mouse_disable - movzx ebx, byte [ecx+16] - cmp eax,ebx - je yes_mouse_disable - - jmp no_mouse_disable - - yes_mouse_disable: - - mov edx,[0x3000] - shl edx,5 - add edx,window_data - - movzx eax, word [0xfb0a] - movzx ebx, word [0xfb0c] - - mov ecx,[edx+0] ; mouse inside the area ? - add eax,14 - cmp eax,ecx - jb no_mouse_disable - sub eax,14 - - add ecx,[edx+8] - cmp eax,ecx - jg no_mouse_disable - - mov ecx,[edx+4] - add ebx,20 - cmp ebx,ecx - jb no_mouse_disable - sub ebx,20 - - add ecx,[edx+12] - cmp ebx,ecx - jg no_mouse_disable - - disable_m: - - cmp dword [0xf204],dword 0 - jne @f - call draw_mouse_under - @@: - - mov [0xf204],dword 1 - - no_mouse_disable: - - popad - - ret - - - -__sys_draw_pointer: - cli - - pushad - - cmp dword [0xf204],dword 0 ; mouse visible ? - je chms00 - - dec dword [0xf204] - - cmp [0xf204],dword 0 - jnz nodmu2 - - movzx ebx,word [0xfb0c] - movzx eax,word [0xfb0a] - call save_draw_mouse - - popad - sti - ret - - nodmu2: - - popad - sti - ret - - chms00: - -; popad - -; pushad - -; cmp [0xf204],dword 0 -; jne nodmp - - movzx ecx,word [0xfb4a] - movzx edx,word [0xfb4c] - - movzx ebx,word [0xfb0c] - movzx eax,word [0xfb0a] - - cmp eax,ecx - jne redrawmouse - - cmp ebx,edx - jne redrawmouse - - jmp nodmp - - redrawmouse: - - - call draw_mouse_under -redrawmouse_1: - call save_draw_mouse - - nodmp: - - popad - sti - ret - - - calculatebackground: ; background ; all black @@ -4451,15 +3777,17 @@ reserve_free_irq: drawbackground: - + inc [mouse_pause] cmp [0xfe0c],word 0x12 jne dbrv12 cmp [display_data-12],dword 1 jne bgrstr12 call vga_drawbackground_tiled + dec [mouse_pause] ret bgrstr12: call vga_drawbackground_stretch + dec [mouse_pause] ret dbrv12: @@ -4468,25 +3796,27 @@ drawbackground: cmp [0xfe0c],word 0x13 je dbrv20 call vesa12_drawbackground + dec [mouse_pause] ret dbrv20: cmp [display_data-12],dword 1 jne bgrstr call vesa20_drawbackground_tiled + dec [mouse_pause] ret bgrstr: call vesa20_drawbackground_stretch + dec [mouse_pause] ret -sys_putimage: +sys_putimage: cmp [0xfe0c],word 0x12 jne spiv20 call vga_putimage ret spiv20: - cmp [0xfe0c],word 0100000000000000b jge piv20 cmp [0xfe0c],word 0x13 @@ -4506,23 +3836,23 @@ sys_putimage: ; edi color __sys_drawbar: - - cmp [0xfe0c],word 0x12 - jne sdbv20 - call vga_drawbar - ret + inc [mouse_pause] + cmp [0xfe0c],word 0x12 + jne sdbv20 + call vga_drawbar + dec [mouse_pause] + ret sdbv20: - cmp [0xfe0c],word 0100000000000000b jge dbv20 cmp [0xfe0c],word 0x13 je dbv20 call vesa12_drawbar + dec [mouse_pause] ret - dbv20: - call vesa20_drawbar + dec [mouse_pause] ret @@ -4641,25 +3971,23 @@ setmouse: ; set mousepicture -pointer mov [0xf200],dword mousepointer cli - mov bl,0xa8 ; enable mouse cmd - call kb_cmd - call kb_read ; read status - - mov bl,0x20 ; get command byte - call kb_cmd - call kb_read - or al,3 ; enable interrupt - mov bl,0x60 ; write command - push eax - call kb_cmd - pop eax - call kb_write - - mov bl,0xd4 ; for mouse - call kb_cmd - mov al,0xf4 ; enable mouse device - call kb_write - call kb_read ; read status return +; mov bl,0xa8 ; enable mouse cmd +; call kb_cmd +; call kb_read ; read status +; mov bl,0x20 ; get command byte +; call kb_cmd +; call kb_read +; or al,3 ; enable interrupt +; mov bl,0x60 ; write command +; push eax +; call kb_cmd +; pop eax +; call kb_write +; mov bl,0xd4 ; for mouse +; call kb_cmd +; mov al,0xf4 ; enable mouse device +; call kb_write +; call kb_read ; read status return ; com1 mouse enable @@ -5121,8 +4449,9 @@ syscall_setpixel: ; SetPixel mov edx,[0x3010] add eax,[edx-twdw] add ebx,[edx-twdw+4] - xor edi,edi ; no force - call [disable_mouse] +; xor edi,edi ; no force + mov edi,1 +; call [disable_mouse] jmp [putpixel] align 4 @@ -5557,6 +4886,13 @@ uglobal ;* start code - get process (3) - Mario79 active_process dd 0 +active_process_flag db 0 +aw_yes db 0 +deleted_process dd 0 +mouse_pause dd 0 +ps2_mouse_detected db 0 +com1_mouse_detected db 0 +com2_mouse_detected db 0 ;* end code - get active process (3) - Mario79 wraw_bacground_select db 0 @@ -5574,6 +4910,7 @@ iglobal keyboard dd 0x1 sound_dma dd 0x1 syslang dd 0x1 + active_proc_stack_coun dd 0xa400-4 endg IncludeIGlobals diff --git a/kernel/trunk/kernel32.inc b/kernel/trunk/kernel32.inc index c4335773c6..a042b5511c 100644 --- a/kernel/trunk/kernel32.inc +++ b/kernel/trunk/kernel32.inc @@ -96,6 +96,7 @@ include "blkdev/cdrom.inc" ; Character devices include "hid/keyboard.inc" +include "hid/mousedrv.inc" ; setting date,time,clock and alarm-clock diff --git a/kernel/trunk/memmap.inc b/kernel/trunk/memmap.inc index a0bfab5170..f08f9b3f92 100644 --- a/kernel/trunk/memmap.inc +++ b/kernel/trunk/memmap.inc @@ -54,11 +54,15 @@ ; 6000 -> 68FF free ; 6900 -> 6EFF saved picture under mouse pointer ; -; 6F00 -> 7FFF free +; 6F00 -> 6FFF free +; +; 7000 -> 7FFF used CD driver ; ; 8000 -> A3FF used FLOPPY driver ; -; A400 -> B0FF free +; A400 -> A7FF used active process stack +; +; A800 -> B0FF free ; B100 -> B2FF IDT diff --git a/kernel/trunk/scin_v2.7z b/kernel/trunk/scin_v2.7z new file mode 100644 index 0000000000..ff3a5dc9f0 Binary files /dev/null and b/kernel/trunk/scin_v2.7z differ diff --git a/kernel/trunk/video/vesa20.inc b/kernel/trunk/video/vesa20.inc index 4985bb8c5f..e35a73f875 100644 --- a/kernel/trunk/video/vesa20.inc +++ b/kernel/trunk/video/vesa20.inc @@ -325,6 +325,7 @@ __sys_putpixel: call dword [0xe020] ; call the real put_pixel function .exit: popad + ret align 4 @@ -376,7 +377,7 @@ ret align 4 __sys_draw_line: - + inc [mouse_pause] call [disable_mouse] ; draw a line @@ -512,6 +513,7 @@ align 4 .exit: add esp, 6*4 popa + dec [mouse_pause] ret @@ -587,6 +589,7 @@ align 4 ; edx ye ; edi color vesa20_drawbar: + pushad call [disable_mouse] @@ -616,6 +619,7 @@ vesa20_drawbar: popad xor eax, eax inc eax + ret @@: cmp ebx, [drbar.bar_sx] @@ -632,6 +636,7 @@ vesa20_drawbar: popad xor eax, eax inc eax + ret @@: cmp ebx, [drbar.bar_sy] @@ -775,6 +780,7 @@ draw_bar_end_32: add esp, drbar.stack_data popad xor eax, eax + ret diff --git a/kernel/trunk/video/vga.inc b/kernel/trunk/video/vga.inc index 8ef2471d33..e237545bea 100644 --- a/kernel/trunk/video/vga.inc +++ b/kernel/trunk/video/vga.inc @@ -57,7 +57,8 @@ paletteVGA: vga_putimage: - +; pushad + call [disable_mouse] push ebp ; push esi ; push edi ; @@ -225,7 +226,10 @@ pimvga: pop edi pop esi pop ebp - + +; call [draw_pointer] +; call [disable_mouse] +; popad ret @@ -251,7 +255,7 @@ VGA_putpixel: and ecx,0x07 ; bit no. (modulo 8) setvgapixel: - + cli ; edi = address, eax = 24bit colour, ecx = bit no. (modulo 8) push eax @@ -300,11 +304,13 @@ p13cont: mov al,[edi] ; dummy read mov [edi],dl + sti ret vga_drawbar: - +; pushad + call [disable_mouse] sub edx,ebx ; edx:=Yend-Ystart=H sub ecx,eax ; ecx:=Xend-Xstat=B @@ -492,12 +498,12 @@ vga_drawbar: ;pop edx ;pop ecx - +; popad ret vga_drawbackground_tiled: - + call [disable_mouse] push ebp push eax push ebx @@ -639,7 +645,7 @@ vga_drawbackground_tiled: vga_drawbackground_stretch: - + call [disable_mouse] push ebp push eax