Mouse driver ps2 (help) (solved)
-
- Posts: 6
- Joined: Sun Feb 25, 2007 5:16 pm
Mouse driver ps2 (help) (solved)
...
Last edited by grunge_asm on Sat Mar 10, 2007 3:12 pm, edited 2 times in total.
-
- Posts: 6
- Joined: Sun Feb 25, 2007 5:16 pm
...
Hi All
I have changed the code for load mouse out DOS... but not success... this is source with run in DOS:
And this is my code changed for run out DOS (when I run it... not run correct)
All help for correct the bug is welcome... or reply for why the bug is occurred.... thanks for all...
grunge
I have changed the code for load mouse out DOS... but not success... this is source with run in DOS:
Code: Select all
ORG 100h
Jmp InstallMouse ; Load the mouse
MainCode: ; Use the mouse loaded
Mov AX,12h
Int 10h
MainLoop: ; My Main Loop, show pixel with mouse coordinates
Call get_pos
Mov AH,0Ch
Mov CX,CX
Mov DX,DX
Mov AL,15
Int 10h
Xor AX,AX
Mov AH,11h
Int 16h
Jnz Exit
Jmp MainLoop
Exit: ; Exit code
Mov AX,3h
Int 10h
Mov AX,0x4C00
Int 21h
InstallMouse: ; Load mouse in DOS, create one int
mov bl,0adh
call keyboard_cmd
call keyboard_read ; Pac 1
call keyboard_read ; Pac 2
call keyboard_read ; Pac 3
mov bl,0aeh
call keyboard_cmd
mov al,20h
out 0a0h,al
out 20h,al
mov ax,0x2574
mov dx,mouse_code
int 21h
cli
mov bl,0a8h
call keyboard_cmd
mov bl,20h
call keyboard_cmd
call keyboard_read
or al,2
mov bl,60h
push ax
call keyboard_cmd
pop ax
call keyboard_write
mov bl,0d4h
call keyboard_cmd
mov al,0f4h
call keyboard_write
Jmp MainCode ; Return to MainCode (mouse loaded, then: use mouse ;) )
mouse_code: ; Mouse codes
push ax
push bx
push cx
push dx
push di
push si
push es
push ds
push cs
pop ds
mov bl,0adh
call keyboard_cmd
call keyboard_read ; for first byte
call keyboard_read
cbw
add word [pos_x],ax
mov ax,word [x_min]
cmp word [pos_x],ax
jg .goodhor1
mov word [pos_x],ax
.goodhor1:
mov ax,word [x_max]
cmp word [pos_x],ax
jle .goodhor2
mov word [pos_x],ax
.goodhor2:
call keyboard_read
neg al
cbw
add word [pos_y],ax
mov ax,[y_min]
cmp word [pos_y],ax
jg .goodver1
mov word [pos_y],ax
.goodver1:
mov ax,word [y_max]
cmp word [pos_y],ax
jle no_show
mov word [pos_y],ax
no_show:
mov bl,0aeh
call keyboard_cmd
mov al,20h
out 0a0h,al
out 20h,al
pop ds
pop es
pop si
pop di
pop dx
pop cx
pop bx
pop ax
iret
get_pos:
mov cx,word [pos_x]
mov dx,word [pos_y]
ret
;------------------------------------------------------------------------
pos_x dw 0
pos_y dw 0
x_max dw 639
x_min dw 0
y_max dw 479
y_min dw 0
keyboard_read:
push cx
push dx
xor cx,cx
key_read_loop:
in al,64h
test al,1
jnz key_read_ready
loop key_read_loop
mov ah,1
jmp key_read_exit
key_read_ready:
push cx
mov cx,32
key_read_delay:
loop key_read_delay
pop cx
in al,60h
xor ah,ah
key_read_exit:
pop dx
pop cx
ret
keyboard_write:
push cx
push dx
mov dl,al
xor cx,cx
kbd_wrt_loop1:
in al,64h
test al,20h
jz kbd_wrt_ok1
loop kbd_wrt_loop1
mov ah,1
jmp kbd_wrt_exit
kbd_wrt_ok1:
in al,60h
xor cx,cx
kbd_wrt_loop:
in al,64h
test al,2
jz kbd_wrt_ok
loop kbd_wrt_loop
mov ah,1
jmp kbd_wrt_exit
kbd_wrt_ok:
mov al,dl
out 60h,al
xor cx,cx
kbd_wrt_loop3:
in al,64h
test al,2
jz kbd_wrt_ok3
loop kbd_wrt_loop3
mov ah,1
jmp kbd_wrt_exit
kbd_wrt_ok3:
mov ah,8
kbd_wrt_loop4:
xor cx,cx
kbd_wrt_loop5:
in al,64h
test al,1
jnz kbd_wrt_ok4
loop kbd_wrt_loop5
dec ah
jnz kbd_wrt_loop4
kbd_wrt_ok4:
xor ah,ah
kbd_wrt_exit:
pop dx
pop cx
ret
keyboard_cmd:
xor cx,cx
cmd_wait:
in al,64h
test al,2
jz cmd_send
loop cmd_wait
jmp cmd_error
cmd_send:
mov al,bl
out 64h,al
xor cx,cx
cmd_accept:
in al,64h
test al,2
jz cmd_ok
loop cmd_accept
cmd_error:
mov ah,1
jmp cmd_exit
cmd_ok:
xor ah,ah
cmd_exit:
ret
Code: Select all
ORG 100h
Jmp InstallMouse ; Load the mouse
MainCode: ; Use the mouse loaded
Mov AX,12h
Int 10h
MainLoop: ; My Main Loop, show pixel with mouse coordinates
Call mouse_code
Call get_pos
Mov AH,0Ch
Mov CX,CX
Mov DX,DX
Mov AL,15
Int 10h
Xor AX,AX
Mov AH,11h
Int 16h
Jnz Exit
Jmp MainLoop
Exit: ; Exit code
Mov AX,3h
Int 10h
Jmp $
InstallMouse: ; Load mouse in DOS, create one int
mov bl,0adh
call keyboard_cmd
call keyboard_read ; Pac 1
call keyboard_read ; Pac 2
call keyboard_read ; Pac 3
mov bl,0aeh
call keyboard_cmd
mov al,20h
out 0a0h,al
out 20h,al
; mov ax,0x2574
; mov dx,mouse_code
; int 21h
cli
mov bl,0a8h
call keyboard_cmd
mov bl,20h
call keyboard_cmd
call keyboard_read
or al,2
mov bl,60h
push ax
call keyboard_cmd
pop ax
call keyboard_write
mov bl,0d4h
call keyboard_cmd
mov al,0f4h
call keyboard_write
Jmp MainCode ; Return to MainCode (mouse loaded, then: use mouse ;) )
mouse_code: ; Mouse codes
push ax
push bx
push cx
push dx
push di
push si
push es
push ds
push cs
pop ds
mov bl,0adh
call keyboard_cmd
call keyboard_read ; for first byte
call keyboard_read
cbw
add word [pos_x],ax
mov ax,word [x_min]
cmp word [pos_x],ax
jg .goodhor1
mov word [pos_x],ax
.goodhor1:
mov ax,word [x_max]
cmp word [pos_x],ax
jle .goodhor2
mov word [pos_x],ax
.goodhor2:
call keyboard_read
neg al
cbw
add word [pos_y],ax
mov ax,[y_min]
cmp word [pos_y],ax
jg .goodver1
mov word [pos_y],ax
.goodver1:
mov ax,word [y_max]
cmp word [pos_y],ax
jle no_show
mov word [pos_y],ax
no_show:
mov bl,0aeh
call keyboard_cmd
mov al,20h
out 0a0h,al
out 20h,al
pop ds
pop es
pop si
pop di
pop dx
pop cx
pop bx
pop ax
; iret
ret
get_pos:
mov cx,word [pos_x]
mov dx,word [pos_y]
ret
;------------------------------------------------------------------------
pos_x dw 0
pos_y dw 0
x_max dw 639
x_min dw 0
y_max dw 479
y_min dw 0
keyboard_read:
push cx
push dx
xor cx,cx
key_read_loop:
in al,64h
test al,1
jnz key_read_ready
loop key_read_loop
mov ah,1
jmp key_read_exit
key_read_ready:
push cx
mov cx,32
key_read_delay:
loop key_read_delay
pop cx
in al,60h
xor ah,ah
key_read_exit:
pop dx
pop cx
ret
keyboard_write:
push cx
push dx
mov dl,al
xor cx,cx
kbd_wrt_loop1:
in al,64h
test al,20h
jz kbd_wrt_ok1
loop kbd_wrt_loop1
mov ah,1
jmp kbd_wrt_exit
kbd_wrt_ok1:
in al,60h
xor cx,cx
kbd_wrt_loop:
in al,64h
test al,2
jz kbd_wrt_ok
loop kbd_wrt_loop
mov ah,1
jmp kbd_wrt_exit
kbd_wrt_ok:
mov al,dl
out 60h,al
xor cx,cx
kbd_wrt_loop3:
in al,64h
test al,2
jz kbd_wrt_ok3
loop kbd_wrt_loop3
mov ah,1
jmp kbd_wrt_exit
kbd_wrt_ok3:
mov ah,8
kbd_wrt_loop4:
xor cx,cx
kbd_wrt_loop5:
in al,64h
test al,1
jnz kbd_wrt_ok4
loop kbd_wrt_loop5
dec ah
jnz kbd_wrt_loop4
kbd_wrt_ok4:
xor ah,ah
kbd_wrt_exit:
pop dx
pop cx
ret
keyboard_cmd:
xor cx,cx
cmd_wait:
in al,64h
test al,2
jz cmd_send
loop cmd_wait
jmp cmd_error
cmd_send:
mov al,bl
out 64h,al
xor cx,cx
cmd_accept:
in al,64h
test al,2
jz cmd_ok
loop cmd_accept
cmd_error:
mov ah,1
jmp cmd_exit
cmd_ok:
xor ah,ah
cmd_exit:
ret
grunge
-
- Posts: 6
- Joined: Sun Feb 25, 2007 5:16 pm
The bug is when I run the source 2 out (not one int DOS)... the mouse reads is not correct(AX = mouse coord... but in pure mode it not correct)... but if I change for run with DOS int (source 1) the mouse reads is correct... my mouse is ps2... the bug must be in read the mouse without one Int(DOS)... why... the source 1 create one DOS int for the mouse codes... and the source 2 no... is in pure mode.... Thanks...
grunge
grunge
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Well, the DOS ints have been tried and tested. There's a high chance that they'll work. On the other hand, your code may not work. I have a similar problem, where the status byte gets mixed in with the movement data. I guess one of the ways you could test for this is find out which bytes are only 1 or 0 (the status byte isn't) or something like that.
I have tested your code and on my test PC (win98) the Dos ver does not even work ?,
Also code like this:
what is that for ?.
Also if i was you, i would code a text ver using a space block etc, untill you get it working then, move to mode 12h.
Also code like this:
Code: Select all
mov dx,dx
mov cx,cx
Also if i was you, i would code a text ver using a space block etc, untill you get it working then, move to mode 12h.
-
- Posts: 6
- Joined: Sun Feb 25, 2007 5:16 pm
Hi All
pcmattman
thanks for yours sugestion... I go work for disable mouse and read byte mouse code correct (0 1)....
Dex
The DOS version (source 1) run correct... but when I change for not run in DOS (source 2) the mouse reads is not correct...
This code is only for remenber the coords (pixel)...
and is for remender the result of mouse position:
mode 12h is for happy work .... and is easy to look the cursor working... thanks
I go work for yours suggestion...
Thanks for all
grunge
pcmattman
thanks for yours sugestion... I go work for disable mouse and read byte mouse code correct (0 1)....
Dex
The DOS version (source 1) run correct... but when I change for not run in DOS (source 2) the mouse reads is not correct...
Code: Select all
Mov DX,DX
Mov CX,CX
and is for remender the result of mouse position:
Code: Select all
get_pos:
mov cx,word [pos_x]
mov dx,word [pos_y]
ret
mode 12h is for happy work .... and is easy to look the cursor working... thanks
I go work for yours suggestion...
Thanks for all
grunge
-
- Posts: 6
- Joined: Sun Feb 25, 2007 5:16 pm
Hi all
I correct the mouse driver...
source1 (DOS)
I have changed it for create one "Set Interrupt vector" without DOS, I only changed it... now... mouse runs correct in pure code!!!
Thanks for all help...
grunge
I correct the mouse driver...
source1 (DOS)
Code: Select all
mov ax,0x2574
mov dx,mouse_code
int 21h
Thanks for all help...
grunge