--- title: "Use a Mouse on Any Hardware: Implementing the Mouse on a Z80 System" type: "article" slug: "use-a-mouse-on-any-hardware-implementing-the-mouse-on-a-z80-system" url: "http://localhost/article/use-a-mouse-on-any-hardware-implementing-the-mouse-on-a-z80-system/" markdown_url: "http://localhost/article/use-a-mouse-on-any-hardware-implementing-the-mouse-on-a-z80-system.md" published_at: "2026-11-09T22:33:04+00:00" modified_at: "2026-11-09T22:33:04+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "The Logimouse® R7 and C7 mice ( Logitech, Inc., 6505 Kaiser Dr., Fremont, CA 94555, ( 415 ) 795-8500 ) are widely available and interface via a standard RS-232 serial port. It seemed that this mouse could be easily used with my Z-80 system. After some experimentation, this proved to be true. The Logimouse R7,…" post_tag: - name: "C (programming language)" slug: "c-programming-language" taxonomy: "post_tag" url: "http://localhost/tag/c-programming-language/" - name: "CP/M" slug: "cp-m" taxonomy: "post_tag" url: "http://localhost/tag/cp-m/" - name: "Full Text" slug: "fulltext" taxonomy: "post_tag" url: "http://localhost/tag/fulltext/" - name: "Machine language programming" slug: "machine-language" taxonomy: "post_tag" url: "http://localhost/tag/machine-language/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" indiv: - name: "Richard Rodman" slug: "richard-rodman" taxonomy: "indiv" url: "http://localhost/indiv/richard-rodman/" publication: "Update Magazine" publication_r: id: 10283 title: "Update Magazine" type: "periodical" url: "http://localhost/periodical/update-magazine/" authors: "Richard Rodman" issues_articles: - id: 26490 title: "Update April 1995" type: "issue" url: "http://localhost/issue/ts-2068-up-date-april-1995/" pages: "18-20" pubdate: "April 1995" archive_link: false volumeissue: "vn" --- # Use a Mouse on Any Hardware: Implementing the Mouse on a Z80 System The Logimouse® R7 and C7 mice ( Logitech, Inc., 6505 Kaiser Dr., Fremont, CA 94555, ( 415 ) 795-8500 ) are widely available and interface via a standard RS-232 serial port. It seemed that this mouse could be easily used with my Z-80 system. After some experimentation, this proved to be true. The Logimouse R7, which I used, has an external power supply connecting to a DB-25 female connector. Data comes out on pin 3; pin 7 is grounded. I’m not sure if it’s necessary to drive DTR on pin 20, but I did. The Logimouse C7 does not require an external power supply. The mouse is held in the hand with the cord proceeding away, in the opposite direction from the arm. The palm rests on the flat area on the top of the mouse, and the fingers operate 3 buttons on the far end of the mouse. This is important—the directions “up,” “down,” “left” and “right” below depend on this orientation. The mouse sends data in 5-byte packets at 1200 baud. The first byte of the packet has bit 7 set, and bits 0, 1, and 2 set or reset according to the status of the 3 mouse buttons. Bit 0 will be 0 if the right button is down, or 1 if it is up. Bit 1 contains the status of the middle button, and bit 2 that of the left button. Bits 3 through 6 are all zero. The second and fourth bytes are movement values in the horizontal or X direction ( left to right ). A value which is negative indicates motion to the left; a value which is positive indicates movement to the right. The third and fifth bytes are movement values in the vertical or Y direction ( up and down ). A value which is negative indicates motion downward ( toward the user ); a value which is positive indicates motion upward ( away from the user ). The program given in the Listing is written in Software Toolworks C for CP/M. It tracks the movement of the mouse with the cursor of a video terminal, and displays the status of the three buttons in the lower right corner of the screen. The program has in-line assembly code for a Z80-CTC and a Z80-SIO working together. To modify for other serial port hardware, modify the routines minit( ), mstat( ) and minput( ). Since I couldn’t determine the reason for the two movement values in each direction, I simply added them. This gives values in each direction of – 256 to + 254. This value, once calculated, needs to be scaled to the resolution of your display, so that moving the mouse produces proportional movement on the screen. Because I was using a normal 80 by 24 video terminal, I scaled the horizontal values by multiplying by 80 and dividing by 256, the vertical values by multiplying by 24 and dividing by 256. The resulting movement values are added to the current X and Y cursor position. If you use a graphics display, multiply by your actual horizontal and vertical resolutions instead. Remember to insure that the X and Y values don’t exceed the dimensions of the display. You may desire to divide by a value less or greater than 256. Smaller values make the mouse respond with greater movement; larger values with less movement. The “best” value would be a value which allows accurate positioning of the cursor anywhere, without requiring the user to constantly “row” the mouse ( repeatedly rolling the mouse, then picking it up and moving it back without rolling ). Since you have control of this parameter, you can make your targets large and your divisor small, and eliminate the rowing for all but the most crowded of desks. Another point to remember: The mouse is a *relative* movement device. It does not keep track of its absolute position. Therefore, your program can only follow it when it actively examines the serial port. I suggest checking for characters periodically, and processing the mouse movement whenever a packet is waiting. This can be done by converting the main( ) in the listing into a function, and removing the while( 1 ) loop. This function then should be called periodically to update the mouse position while other program activity is going on. [![MOUSE.C listing (part 1)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-1-1-647x1024.png)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-1-1.png)MOUSE.C listing (part 1) [![MOUSE.C listing (part 2)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-2-2-546x1024.png)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-2-2.png)MOUSE.C listing (part 2) [![MOUSE.C listing (part 3, in-line Z80 SIO/CTC assembly)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-3-1024x840.png)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-3.png)MOUSE.C listing (part 3, in-line Z80 SIO/CTC assembly) *** ### Program for serial Logimouse on Z80 (July 1995) [![MOUSE.C listing, Z80 mnemonic version (part 1)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-4-1-795x1024.png)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-4-1.png)MOUSE.C listing, Z80 mnemonic version (part 1) [![MOUSE.C listing, Z80 mnemonic version (part 2)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-5-2-787x1024.png)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-5-2.png)MOUSE.C listing, Z80 mnemonic version (part 2) [![MOUSE.C listing, Z80 mnemonic version (part 3, SIO/CTC routines)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-6-671x1024.png)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-6.png)MOUSE.C listing, Z80 mnemonic version (part 3, SIO/CTC routines) [![MOUSE.C listing, Z80 mnemonic version (part 4)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-7-4-1024x622.png)](http://localhost/wp-content/uploads/2026/11/update-new-use-a-mouse-on-any-hardware-7-4.png)MOUSE.C listing, Z80 mnemonic version (part 4)