home *** CD-ROM | disk | FTP | other *** search
- /* ==( dos/mouse.c )== */
- /* ----------------------------------------------- */
- /* Pro-C Copyright (C) 1989 - 1990 Vestronix Inc. */
- /* Modification to this source is not supported */
- /* by Vestronix Inc. */
- /* All Rights Reserved */
- /* ----------------------------------------------- */
- /* Written Bob 3-Oct-89 */
- /* Modified Geo 18-Apr-90 See comments below */
- /* ----------------------------------------------- */
- /* %W% (%H% %T%) */
-
- /*
- * Modifications
- *
- * 18-Apr-90 Geo - Merged for physical/logical split
- * 3-Oct-89 Bob - Written
- */
-
- # include <stdio.h>
- # include <bench.h>
-
- # ifdef MOUSE
-
- # include "pregs.h"
-
- /* Local access << extern in huge model */
- static char local_mouse = 0;
-
- /*
- * Initialize the mouse (if present)
- * sets mouse_present accordingly
- */
- void mouse_init()
- {
- RegStorage;
-
- /*
- * check memory position for int 0x33 here
- */
- Regs_ax = 0x21;
-
- Mouse();
-
- local_mouse = (char)Regs_ax;
- mouse_num_buttons = Regs_bx;
-
- if (local_mouse == 0x21)
- local_mouse = 0;
-
- mouse_present = local_mouse;
- }
-
- /*
- * Reset mouse (and get status)
- */
- void mouse_end()
- {
- RegStorage;
-
- if (!local_mouse)
- return;
-
- mouse_cursor(OFF);
- Regs_ax = 0x0;
-
- Mouse();
- }
-
- /*
- * Switch mouse cursor on or off
- */
- void mouse_cursor(on_off)
- int on_off;
- {
- RegStorage;
-
- if (!local_mouse)
- return;
-
- /* Geo says what about (0 + 1) == off and (1 + 1) == on ? */
- Regs_ax = on_off ? 1 : 2;
-
- Mouse();
- }
-
- /*
- * Get mouse position (and button status)
- */
- int mouse_position(x, y)
- unsigned int *x, *y;
- {
- RegStorage;
-
- if (!local_mouse)
- return(0);
-
- Regs_ax = 3;
-
- Mouse();
-
- *x = Regs_cx;
- *y = Regs_dx;
- return(Regs_bx);
- }
-
- /*
- * Set mouse pointer position
- */
- void mouse_set_position(x, y)
- unsigned int x,y;
- {
- RegStorage;
-
- if (!local_mouse)
- return;
-
- Regs_cx = (x - 1) * mouse_x_divisor;
- Regs_dx = (y - 1) * mouse_y_divisor;
- Regs_ax = 4;
-
- Mouse();
- }
-
- /*
- * Get button release information
- */
- void mouse_button_release(button, x , y)
- int button;
- unsigned int *x, *y;
- {
- RegStorage;
-
- if (!local_mouse)
- return;
-
- Regs_bx = button;
- Regs_ax = 6;
-
- Mouse();
-
- mouse_up_down = Regs_ax;
- *x = Regs_cx;
- *y = Regs_dx;
- }
-
- # endif
-