PS/2 mouse driver

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:PS/2 mouse driver

Post by Candy »

St8ic wrote: Thanks for the suggestion, Dennis, but I think I'll stick to this way :). Candy's code compiles, but hangs the OS.
me wrote:Note, this code is based on such a list of assumptions that you CAN NOT trust it to work. Read it over at least 5 times with the packet definition by hand.
::)
Maybe because Candy's code apparently has alot of assumptions that aren't true. What are some of them?
List:
- bits 7-2 of x movement are in bits 7-2 of cl
- bits 7-2 of y movement are in bits 7-2 of dl
- bits 1-0 of x movement (LSbits, not MSbits) are in 7-6 of bl
- bits 1-0 of y movement (again LSbits) are in 5-4 of bl
- the four pointers are good and constant
- I didn't make any errors
- The rest of your code works

If all of these assumptions hold it works (obviously, if neither made a mistake ::))

If it's not this, then without more code I cannot offer any more detailed help.
St8ic

Re:PS/2 mouse driver

Post by St8ic »

@Engin: That code didn't compile very well at all with nasm. I'm not in the mood to be sorting out some 60 errors right now, but thanks alot for trying to help. 'Tis very nice code! :)

As interesting a mouse driver using BIOS ints sounds, I'm thinking of succumbing to the port system. I've done everything I can for this code but it's still not working out. I'll definitly stick to unreal mode, though. Does anyone have some good docs or code for a PS/2 moue driver using ports?

Here's the final code for the int15 mouse driver. Compiles fine under nasm, but it hangs the OS. Do what ever you want with it, but PLEASE tell me if yu get it to work!

Code: Select all

_mouse:   mov ax,0xC200                ; mouse driver
          int 15
          mov ax,0xC205
          int 15
.loop:    mov ax,0xC209
          int 15
          test bl,1<<3
          mov byte [lbpress],1
          mov byte [lbpress],0
          test bl,1<<4
          mov byte [rbpress],1
          mov byte [rbpress],0
          and cl, 0FCh
          mov al, bl
          shr al, 6
          and al, 3
          add cl, al
          and dl, 0FCh
          shr bl, 4
          and bl, 3
          add dl, bl
          mov [xmovement], cl
          mov [ymovement], dl
          add [xlocation], cl
          add [ylocation], dl
          mov ah,0Ch
          mov al,0x0
          mov cx,[xlocation]
          mov dx,[ylocation]
          int 0x10
          LOOP .loop
Post Reply