Subversion Repositories Kolibri OS

Compare Revisions

Problem with comparison.

Regard whitespace Rev HEAD → Rev 1

/trunk/hid/keyboard.inc
0,0 → 1,223
;// mike.dld [
 
VKEY_LSHIFT = 0000000000000001b
VKEY_RSHIFT = 0000000000000010b
VKEY_LCONTROL = 0000000000000100b
VKEY_RCONTROL = 0000000000001000b
VKEY_LALT = 0000000000010000b
VKEY_RALT = 0000000000100000b
VKEY_CAPSLOCK = 0000000001000000b
VKEY_NUMLOCK = 0000000010000000b
VKEY_SCRLOCK = 0000000100000000b
 
VKEY_SHIFT = 0000000000000011b
VKEY_CONTROL = 0000000000001100b
VKEY_ALT = 0000000000110000b
 
uglobal
align 4
kb_state dd 0
ext_code db 0
 
keyboard_mode db 0
keyboard_data db 0
 
altmouseb db 0
ctrl_alt_del db 0
 
kb_lights db 0
endg
 
align 4
irq1:
 
call restore_caller
 
movzx eax,word[0x3004] ; top window process
movzx eax,word[0xC400+eax*2]
shl eax,8
mov al,[0x800B4+eax]
mov [keyboard_mode],al
 
in al,0x60
mov [keyboard_data],al
 
mov ch,al
cmp al,0xE0
je @f
cmp al,0xE1
jne .normal_code
@@: mov [ext_code],al
jmp .no_key.end
.normal_code:
mov cl,[ext_code]
mov [ext_code],0
and al,0x7F
@@: cmp al,0x2A
jne @f
cmp cl,0xE0
je .no_key.end
mov eax,VKEY_LSHIFT
jmp .no_key
@@: cmp al,0x36
jne @f
cmp cl,0xE0
je .no_key.end
mov eax,VKEY_RSHIFT
jmp .no_key
@@: cmp al,0x38
jne @f
cmp cl,0xE0
je .alt.r
mov eax,VKEY_LALT
jmp .no_key
.alt.r:
mov eax,VKEY_RALT
jmp .no_key
@@: cmp al,0x1D
jne @f
cmp cl,0
jne .ctrl.r
mov eax,VKEY_LCONTROL
jmp .no_key
.ctrl.r:
cmp cl,0xE1
jne .ctrl.r.2
mov [ext_code],cl
jmp .no_key.end
.ctrl.r.2:
mov eax,VKEY_RCONTROL
jmp .no_key
@@: cmp al,0x3A
jne @f
mov bl,4
mov eax,VKEY_CAPSLOCK
jmp .no_key.xor
@@: cmp al,0x45
jne @f
cmp cl,0
jne .no_key.end
mov bl,2
mov eax,VKEY_NUMLOCK
jmp .no_key.xor
@@: cmp al,0x46
jne @f
mov bl,1
mov eax,VKEY_SCRLOCK
jmp .no_key.xor
@@:
test ch,0x80
jnz .no_key.end
movzx eax,ch ; plain key
mov bl,[keymap+eax]
mov edx,[kb_state]
test dl,VKEY_CONTROL ; ctrl alt del
jz .noctrlaltdel
test dl,VKEY_ALT
jz .noctrlaltdel
cmp bl,134+48
jne .noctrlaltdel
mov [ctrl_alt_del],1
jmp .no_key.end
.noctrlaltdel:
test dl,VKEY_CONTROL ; ctrl on ?
jz @f
sub bl,0x60
@@: test dl,VKEY_SHIFT ; shift on ?
jz @f
mov bl,[keymap_shift+eax]
@@: test dl,VKEY_ALT ; alt on ?
jz @f
mov bl,[keymap_alt+eax]
; alt mouse ?
xor edx,edx
cmp bl,178
jnz .no_alt.up
mov edx,5*65536
jmp .mouse.change
.no_alt.up:
cmp bl,177
jnz .no_alt.down
mov edx,251*65536
jmp .mouse.change
.no_alt.down:
cmp bl,176
jnz .no_alt.left
mov edx,251*256
jmp .mouse.change
.no_alt.left:
cmp bl,179
jnz .no_alt.right
mov edx,5*256
jmp .mouse.change
.no_alt.right:
cmp bl,' '
jne @f
xor [altmouseb],1
.mouse.change:
mov byte[0xF604],1; ps2 data
mov byte[0xFB00],0; ps2 chunk count
mov word[0x2E0000+4096*12],3; mouse data count
mov dl,[altmouseb]
mov [0x2E0000+4096*12+0x10],edx
mov bl,0
@@:
cmp [keyboard_mode],0 ; return from keymap
jne .no_key.end
mov [keyboard_mode_sys],0
cmp bl,0
je .no_key.end
movzx eax,byte[0xF400]
cmp al,120
jae .no_key.end
inc al
mov [0xF400],al
mov [0xF400+eax],bl
 
jmp .no_key.end
 
.no_key:
test ch,0x80
jz .no_key.down
not eax
and [kb_state],eax
jmp .no_key.end
.no_key.xor:
test ch,0x80
jnz .no_key.end
xor [kb_state],eax
xor [kb_lights],bl
call set_lights
jmp .no_key.end
.no_key.down:
or [kb_state],eax
.no_key.end:
cmp [keyboard_mode],1 ; return scancode
jne .no_scancode
mov [keyboard_mode_sys],1
movzx eax,byte[0xF400]
cmp al,120
jae .no_scancode
inc al
mov [0xF400],al
mov [0xF400+eax],ch
.no_scancode:
 
.exit.irq1:
mov [check_idle_semaphore],5
 
mov al,0x20 ; ready for next irq
out 0x20,al
 
call return_to_caller
 
jmp irq1
 
set_lights:
mov al,0xED
call kb_write
mov al,[kb_lights]
call kb_write
ret
 
;// mike.dld ]
/trunk/hid/set_dtc.inc
0,0 → 1,191
;setting date,time,clock and alarm-clock
;add sys_settime at servetable as for ex. 22 fcn:
; 22 - SETTING DATE TIME, CLOCK AND ALARM-CLOCK
; ebx =0 - set time ecx - 00SSMMHH
; ebx =1 - set date ecx=00DDMMYY
; ebx =2 - set day of week ecx- 1-7
; ebx =3 - set alarm-clock ecx - 00SSMMHH
; out: 0 -Ok 1 -wrong format 2 -battery low
sys_settime:
mov ecx,eax
cli
mov al,0x0d
out 0x70,al
in al,0x71
bt ax,7
jnc bat_low
cmp ecx,2 ;day of week
jne nosetweek
test ebx,ebx ;test day of week
je wrongtime
cmp ebx,7
ja wrongtime
mov dx,0x70
call startstopclk
dec edx
mov al,6
out dx,al
inc edx
mov al,bl
out dx,al
jmp endsettime
nosetweek: ;set date
cmp ecx,1
jne nosetdate
cmp bl,0x99 ;test year
ja wrongtime
shl ebx,4
cmp bl,0x90
ja wrongtime
cmp bh,0x99 ;test month
ja wrongtime
shr ebx,4
test bh,bh
je wrongtime
cmp bh,0x12
ja wrongtime
shl ebx,8
bswap ebx ;ebx=00YYMMDD
test bl,bl ;test day
je wrongtime
shl ebx,4
cmp bl,0x90
ja wrongtime
shr ebx,4
cmp bh,2 ;February
jne testday
cmp bl,0x29
ja wrongtime
jmp setdate
testday:
cmp bh,8
jb testday1 ;Aug-Dec
bt bx,8
jnc days31
jmp days30
testday1:
bt bx,8 ;Jan-Jul ex.Feb
jnc days30
days31:
cmp bl,0x31
ja wrongtime
jmp setdate
days30:
cmp bl,0x30
ja wrongtime
setdate:
mov dx,0x70
call startstopclk
dec edx
mov al,7 ;set days
out dx,al
inc edx
mov al,bl
out dx,al
dec edx
mov al,8 ;set months
out dx,al
inc edx
mov al,bh
out dx,al
dec edx
mov al,9 ;set years
out dx,al
inc edx
shr ebx,8
mov al,bh
out dx,al
jmp endsettime
nosetdate: ;set time or alarm-clock
cmp ecx,3
ja wrongtime
cmp bl,0x23
ja wrongtime
cmp bh,0x59
ja wrongtime
shl ebx,4
cmp bl,0x90
ja wrongtime
cmp bh,0x92
ja wrongtime
shl ebx,4
bswap ebx ;00HHMMSS
cmp bl,0x59
ja wrongtime
shl ebx,4
cmp bl,0x90
ja wrongtime
shr ebx,4
mov dx,0x70
call startstopclk
dec edx
cmp ecx,3
je setalarm
xor eax,eax ;al=0-set seconds
out dx,al
inc edx
mov al,bl
out dx,al
dec edx
mov al,2 ;set minutes
out dx,al
inc edx
mov al,bh
out dx,al
dec edx
mov al,4 ;set hours
out dx,al
inc edx
shr ebx,8
mov al,bh
out dx,al
jmp endsettime
setalarm:
mov al,1 ;set seconds for al.
out dx,al
inc edx
mov al,bl
out dx,al
dec edx
mov al,3 ;set minutes for al.
out dx,al
inc edx
mov al,bh
out dx,al
dec edx
mov al,5 ;set hours for al.
out dx,al
inc edx
shr ebx,8
mov al,bh
out dx,al
dec edx
mov al,0x0b ;enable irq's
out dx,al
inc dx
in al,dx
bts ax,5 ;set bit 5
out dx,al
endsettime:
dec edx
call startstopclk
sti
mov [esp+36],dword 0
ret
bat_low:
sti
mov [esp+36],dword 2
ret
wrongtime:
sti
mov [esp+36],dword 1
ret
startstopclk:
mov al,0x0b
out dx,al
inc dx
in al,dx
btc ax,7
out dx,al
ret