Lprint #08
28 июня 1997

Mouse Driver - On driver support Kemston Mouse.

<b>Mouse Driver</b> - On driver support Kemston Mouse.
                         Mouse driver

(C) Alexander Nikiforov MDM 271-15-83


   Hi world! I decided then to tell a little about the driver 
support kempston mouse. This idea came to me after seeing the 
newspaper BODY, in which SATSOFT can not (or will not?) Do

normal working mouse driver.

   Kempston mouse connects to port # DF:
    # FADF - state of the mouse buttons:
            bit 0 - the left button,
            bit 1 - right button
            bit 2 - the middle button.
    # FBDF - X-coordinate of the mouse
    # FFDF - Y-coordinate of the mouse

   Port status and # FBDF # FFDF itself changes when the mouse 
moves. The senior five bits port # FADF not used and installed 
One unit in, and the three least significant bits indicate the 
status of the buttons: 0 - button is not pressed, 1 - is 
pressed. But the buttons are not so simple. The fact that in 
mice, which are sold in Minsk Stinger, not used the third 
button. Therefore, if you intend to use the program the third 
button, then duplicate it by pressing two extreme buttons 
simultaneously (ie, simultaneously pressing the left and right 
mouse button should cause the same effect as the third button). 
Likewise there is no consensus which bit (0 or 1) should be 
responsible for the left button, but some of the right. I have 
zero bits - the left button (supports FUT and ZX-WORD), while 
the someone maybe it's the right button (support UFO 2, BLACK

Raven (demo), MINESWEEPER). It is therefore recommended to make 
the driver auto-sensing buttons fire, ie the first click gets a 
shot (as done in the ZX-FORMAT, ZxNews in this room LPRINT'a). 
Or do both fire button (MOVE, ENERGY, old numbers LPRINT / my 
Viewer /). 

   And now the actual driver with a small comment.


   Program check kempston mouse. If you have a mouse
not that of the three ports should be read by the same number of
(Usually 0 or 255). If you have a Bat, the probability of 
matching all three numbers is virtually zero (the only option 
when it is high - it is when you turn the complex into a 
network and still never touched a mouse, in this case of all 
three ports will be read number 255). The truth is possible 
that option, that Your machine unstable data bus and then from 
all three ports are different numbers. For this case, I check 
out the older five bits port buttons # FADF and if they are not 
equal One unit, so there is no Bat. Also in Petersburg's 
programs before checking the availability of a mouse in the 
ports and # 5F # 7F entered byte # 90. Why need it, I do not 
know, but just in case the Board to perform this procedure. But 
in any case, it is recommended that manual enable / disable 
kempston mouse. 

; Check kempston mouse
INIT LD A, # 90;??
    OUT (# 7F), A;???
    OUT (# 5F), A;???
    LD BC, # FADF
    IN A, (C); reads the A state of the port # FADF
    PUSH AF; and save it on the stack
    AND # F8; Checking senior five bits to 1
    CP # F8
    CALL NZ, NOTMOUS; Call Subroutine disable mouse
    INC B
    IN L, (C); reads the L state of the port # FBDF
    LD B, # FF
    IN H, (C); reads the state of the port H # FFDF
    POP AF; Restore A register
    CP L; check for coincidence of
    JR NZ, $ +6; If the bytes are different, then YESMOUSE
    CP H; If you are the same, checking on
    CALL Z, NOTMOUS; If Sopa again, then off. mouse
YESMOUS ... ; Kempston mouse present


   To start the program after the cursor appears in the right 
place at the screen rather than the devil knows where, call 
this subroutine (just call her after the manual switching the 
mouse to cursor jumping to an unknown destination):


; Restoration coordinates
MXY LD A, # FB; Read the state of X-coordinates
    IN A, (# DF); mouse and
    LD (MOUSE_X +1), A; bring it to a label MOUSE_X
    LD A, # FF; Read the state of Y-coordinate
    IN A, (# DF); mouse and
    LD (MOUSE_Y +1), A; bring it to a label MOUSE_Y
    RET


   This program is used to poll the mouse buttons. Then I think 
everything so it is understandable, but the comments all the 
same bet. 

; Check the status of mouse buttons
FIRE LD A, # FA; Reading the status byte keys
    IN A, (# DF)
    RRA; Test pressing the left button
    JP NC, L_BUT; If pressed, the label preyti L_BUT
    RRA; Test pressing the right buttons
    JP NC, R_BUT; If pressed, the label preyti R_BUT
    ... ; Buttons are pressed (the third button
            ; Not used)


   Well, the survey programm mouse movements. I use this 
program as follows: first wash your cursor on the screen, the 
caller MOVE, which changes the X and Y, and the typing cursor 
(All it occurs naturally in the termination). In its programs, I

increment the displacement of the mouse twice, so that the 
cursor moved faster. If you do not need it, then remove the 
command ADD A, A. 

; Mouse movements. X = 0-255, Y = 0-191
MOVE LD A, # FB
    IN A, (# DF); Read the state of X-coordinates of the mouse
MOUSE_X LD E, 0; In case E the previous X-coordinate
    LD (MOUSE_X +1), A; Save the new coordinate
    SUB E; Check whether the changed X-coordinate
    CALL NZ, MOVE_X; If so, call podprog. MOVE_X
    LD A, # FF
    IN A, (# DF); Read the state of Y-coordinates of the mouse
MOUSE_Y LD E, 0; In case E the previous Y-coordinate
    LD (MOUSE_Y +1), A; Save the new coordinate
    SUB E; Check whether the changed Y-coordinate
    CALL NZ, MOVE_Y; If so, call podprog. MOVE_Y
    ...

MOVE_Y JP M, MOUSE_D; If the flag S = 1, then moving the mouse; 
Ghali down, or up MOUSE_U ADD A, A; Increase mixing twice

    LD D, A; save it in reg. D
    LD A, (Y_COORD); Take the current Y-coordinate of the cursor
    SUB D; reduces its
    JR NC, $ +3; If the result was less than 0
    XOR A; then reset the Y-coordinate
    LD (Y_COORD), A; Writes a new Y-coordinate of the cursor
    RET
MOUSE_D NEG; Here is a mixture of normal appearance
    ADD A, A; Increase mixing twice
    LD D, A; save it in reg. D
    LD A, (Y_COORD); Take the current Y-coordinate of the cursor
    ADD A, D; increases its
    JR C, MM_2; If the result was more than 255,
    CP 192; or greater than 191, then
    JR C, $ +4
MM_2 LD A, 191; change it to 191
    LD (Y_COORD), A; Writes a new Y-coordinate of the cursor
    RET
MOUSE_L NEG; Here is a mixture of normal appearance
    ADD A, A; Increase mixing twice
    LD D, A; save it in reg. D
    LD A, (X_COORD); We take the current X-coordinate of the 
cursor     SUB D; reduces its

    JR NC, $ +3; If the result was less than 0
    XOR A; then reset the X-coordinate
    LD (X_COORD), A; Writes a new X-coordinate of the cursor
    RET
MOVE_X JP M, MOUSE_L; If the flag S = 1, then moving the mouse; 
Ghali left, or right MOUSE_R ADD A, A; Increase mixing twice

    LD D, A; save it in reg. D
    LD A, (X_COORD); We take the current X-coordinate of the 
cursor     ADD A, D; increases its

    JR NC, $ +4; If the result was more than 255,
    LD A, 255, then change it to 255
    LD (X_COORD), A; Writes a new X-coordinate of the cursor
    RET


   Well that's all. I do not know how many of you have 
understood all of this opus, but I hope that at least most. 

   P.S. Special message for SATSOFT: Just try now to release a 
buggy driver BODY mouse. : -> 

   P.P.S. This driver will stay all week on my server - FASA 
BBS, named mouse.H (format ALASM3.8) 





Other articles:

Mouse Driver - On driver support Kemston Mouse.

Entry - The new hull was extremely uncomfortable.

Let's take - User Pasha with a story about yourself.

Discussion - IBM is the BEST ?

computer pirates - Mitnick: perpetrator or victim.

News nedili - Coming soon bbsTOP # 5.

Advertising messagi - Advertise with humor.

Talents - Topics for the essay.

Smile - Wellness holiday home in new products.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Over the hill - On Samara Personalities: Alien Factory, Speed Co, Stars of Keladan, Shaitan.
From the authors - A delay in the release of issue of the newspaper ...

В этот день...   29 April