www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/28/11:45:32

From: gah AT jet DOT es (Grzegorz Adam Hankiewicz)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Mouse control in TEXT mode?
Date: Thu, 28 May 1998 15:13:28 GMT
Organization: Gogosoftware
Lines: 162
Message-ID: <356d7e90.879573@news.jet.es>
References: <199805281450 DOT XAA25757 AT tiger1 DOT nownuri DOT net>
NNTP-Posting-Host: infon488.jet.es
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Thu, 28 May 1998 23:50:37 +0900 (KST), ½Å¼®¿µ
<zyrodine AT nownuri DOT net> wrote:
> But I can't find that source or doc of running in text mode.

Maybe this is not exactly what you wanted, but here you have the
routines from my text lib Wazoo. Use them as you want, they are free.
Oh, and you will have to rewrite the code to fit the long lines.

Hope it helps.

/* Routines written by Grzegorz Adam Hankiewicz. However, they were
taken
 * from a spanish magazine sometime in 1995 or so.
 * If you wanna talk to me, this is my email: gregorio AT jet DOT es
 * Or you can visit me at web.jet.es/gregorio or
welcome.to/gogosoftware
 */

#include"../wazoo.h"
#include<dos.h>

int Ax, Bx, Cx, Dx; // Internal Register. Don't touch anything !!!
char mouse_state=-2;/* Flag that shows the state of the mouse. If -2,
then
                     * the mouse was not initialized. If 0, the mouse
is
                     * hidden. If 1, the mouse is visible.
                     */

/* This is internally called from other functions. It just checks some
inte-
 * rrupt.
 */
void mouse(int servicio) {
        union REGS registros;
        registros.x.ax = servicio;
        registros.x.bx = Bx;
        registros.x.cx = Cx;
        registros.x.dx = Dx;

        int86(0x33, &registros, &registros);
        Ax = registros.x.ax;
        Bx = registros.x.bx;
        Cx = registros.x.cx;
        Dx = registros.x.dx;

}

// This initializes the mouse driver. Call this before any other
function.
int init_text_mouse(void) {
        mouse(0);
        if(!Ax) return -2;
        mouse_state = 0;
		  if(enhanced_80x25 == 1)
		        range_y(0,400);
        return Bx;
}

// Tell the mouse driver to show up and say : "Hello ..."
void show_txt_mouse(void) {
        if (!mouse_state) {
                mouse(1);
                mouse_state = 1;
                }
}

// Tell the mouse you don't like him (her?) Therefore he will hide.
void hide_txt_mouse(void) {
        if (mouse_state) {
                mouse(2);
                mouse_state = 0;
		}
}

/* The following functions return the x and y values of the mouse.
Count that
 * they always return a value in the range from 0 to 640 for x axis
and
 * from 0 to 400 for the y asix by default, so you will have to divide
or
 * multiply this value to adjust it to your own screen size
configuration.
 * For example, if you control it in 80x50 text mode, just shift the
result
 * 3 bits to the right: value = get_x()>>3 ;
 */
// This returns the x value of the mouse.
int get_x(void) {
        mouse(3);
        return Cx;
}

// This returns the y value of the mouse.
int get_y(void) {
        mouse(3);
        return Dx;
}

// Look if the left button is pressed
char get_left_button(void) {
        mouse(3);
        return Bx & 1;
}

// Look if the right button is pressed
char get_right_button(void) {
        mouse(3);
        return Bx & 2;
}

// Easy loop which just waits for the user to press the left mouse
button
void wait_left_button(void) {
        while(get_left_button()==0);
}

// Easy loop which just waits for the user to press the right mouse
button
void wait_right_button(void) {
        while(get_right_button()==0);
}

// Easy loop which just waits for the user to press both mouse buttons
void wait_both_buttons(void) {
        do mouse(3); while (Bx & 3);
}

// Easy loop which just waits for the user to release both mouse
buttons
void wait_release_buttons(void) {
	while(get_left_button()!=0);
   while(get_right_button()!=0);
}

void set_mouse(int x, int y) {
        Cx = x;
        Dx = y;
        mouse(4);
}

/* Define the x range where the mouse can be. Take note from the
remark up
 * near get_x(). The same goes here. Example : range_x(0,640);
 */
void range_x(int min, int max) {
        Cx = min;
        Dx = max;
        mouse(7);
}

// Like up but the y value. Usually a value from 0 to 400 works
nicely.
void range_y(int min, int max) {
        Cx = min;
        Dx = max;
        mouse(8);
}


- Grzegorz Adam Hankiewicz - gah AT jet DOT es - http://web.jet.es/gregorio/
- Gogosoftware - http://welcome.to/gogosoftware/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019