CD_OUT_SRC/CD_RATON.CPP
2021-09-03 17:50:32 +02:00

216 lines
7.6 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

///////////////////////////////////////////////////////////////////////////
///// Nombre: Craton.cpp ///
///// Modulo: Perteneciente a JD_FONTS.CPP ///
//// Descripci¢n: Utilidades para el manejo del raton ///
//// ///
//// Autor: ( Ver Pc-Mania n§ 20 ) ///
//// Autor puntero del raton: Jos David Guilln Dominguez ///
//// Fecha: ( Desconocida ) ///
//// ///
//// Compilador Borland C++ 3.0 ( Creaci¢n original en Turbo C 2.0 ) ///
///////////////////////////////////////////////////////////////////////////
#include <dos.h>
#include <conio.h>
void desactiva_raton(void);
void activa_raton(void);
void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py);
void Anclar_Raton(void);
int Espera_Tecla_o_Raton(void);
int raton=0;
int x_raton;
int y_raton;
int boton_izq;
int boton_der;
extern int PunteroRaton;
int dir_raton [32+32] = {
// 0x3FFF, /*± ± 1 1 1 1 1 1 1 1 1 1 1 1 1 1*/
// 0x1FFF, /*± Û ± 1 1 1 1 1 1 1 1 1 1 1 1 1*/
// 0x0FFF, /*± Û Û ± 1 1 1 1 1 1 1 1 1 1 1 1*/
// 0x07FF, /*± Û Û Û ± 1 1 1 1 1 1 1 1 1 1 1*/
// 0x03FF, /*± Û Û Û Û ± 1 1 1 1 1 1 1 1 1 1*/
// 0x07FF, /*± ± Û Û ± 1 1 1 1 1 1 1 1 1 1 1*/
// 0xC3FF, /*1 1 ± Û Û ± 1 1 1 1 1 1 1 1 1 1*/
0x007F, /*± ± ± ± ± ± ± ± ± 1 1 1 1 1 1 1*/
0x00FF, /*± Û Û Û Û Û Û ± 1 1 1 1 1 1 1 1*/
0x01FF, /*± Û Û Û Û Û ± 1 1 1 1 1 1 1 1 1*/
0x01FF, /*± Û Û Û Û Û ± 1 1 1 1 1 1 1 1 1*/
0x00FF, /*± Û Û Û Û Û Û ± 1 1 1 1 1 1 1 1*/
0x007F, /*± Û Û ± ± Û Û Û ± 1 1 1 1 1 1 1*/
0x18FF, /*± ± ± 1 1 ± Û ± 1 1 1 1 1 1 1 1*/
// 0xFC7F, /*1 1 1 1 1 1 ± Û ± 1 1 1 1 1 1 1*/
// 0xF83F, /*1 1 1 1 1 ± Û Û Û ± 1 1 1 1 1 1*/
// 0xF01F, /*1 1 1 1 ± Û Û Û Û Û ± 1 1 1 1 1*/
// 0xE00F, /*1 1 1 ± Û Û Û Û Û Û Û ± 1 1 1 1*/
// 0xE00F, /*1 1 1 ± ± ± Û Û Û ± ± ± 1 1 1 1*/
// 0xF83F, /*1 1 1 1 1 ± Û Û Û ± 1 1 1 1 1 1*/
// 0xF83F, /*1 1 1 1 1 ± ± ± ± ± 1 1 1 1 1 1*/
0x800F, /*1 ± ± ± ± ± ± ± ± ± ± ± 1 1 1 1*/
0x8083, /*1 ± Û Û Û Û Û ± ± Û Û Û ± ± 1 1*/
0x8001, /*1 ± ± ± ± ± Û ± ± Û ± ± Û ± ± 1*/
0xF810, /*1 1 1 1 1 ± Û ± ± Û ± 1 ± Û ± 1*/
0x8810, /*1 ± ± ± 1 ± Û ± ± Û ± 1 ± Û ± 1*/
0x8811, /*1 ± Û ± 1 ± Û ± ± Û ± 1 ± Û ± 1*/
0x8003, /*1 ± Û ± ± ± Û ± ± Û ± ± Û ± 1 1*/
0x8007, /*1 ± Û Û Û Û Û ± ± Û Û Û ± 1 1 1*/
0x800F, /*1 ± ± ± ± ± ± ± ± ± ± ± 1 1 1 1*/
// 0x0000, /*0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0*/
// 0x4000, /*0 Û 0 0 0 0 0 0 0 0 0 0 0 0 0 0*/
// 0x6000, /*0 Û Û 0 0 0 0 0 0 0 0 0 0 0 0 0*/
// 0x7000, /*0 Û Û Û 0 0 0 0 0 0 0 0 0 0 0 0*/
// 0x7800, /*0 Û Û Û Û 0 0 0 0 0 0 0 0 0 0 0*/
// 0x3000, /*0 0 Û Û 0 0 0 0 0 0 0 0 0 0 0 0*/
// 0x1800, /*0 0 0 Û Û 0 0 0 0 0 0 0 0 0 0 0*/
0x0000, /*0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0*/
0x7E00, /*0 Û Û Û Û Û Û 0 0 0 0 0 0 0 0 0*/
0x7C00, /*0 Û Û Û Û Û 0 0 0 0 0 0 0 0 0 0*/
0x7C00, /*0 Û Û Û Û Û 0 0 0 0 0 0 0 0 0 0*/
0x7E00, /*0 Û Û Û Û Û Û 0 0 0 0 0 0 0 0 0*/
0x6700, /*0 Û Û 0 0 Û Û Û 0 0 0 0 0 0 0 0*/
0x0200, /*0 0 0 0 0 0 Û 0 0 0 0 0 0 0 0 0*/
// 0x0100, /*0 0 0 0 0 0 0 Û 0 0 0 0 0 0 0 0*/
// 0x0380, /*0 0 0 0 0 0 Û Û Û 0 0 0 0 0 0 0*/
// 0x07C0, /*0 0 0 0 0 Û Û Û Û Û 0 0 0 0 0 0*/
// 0x0FE0, /*0 0 0 0 Û Û Û Û Û Û Û 0 0 0 0 0*/
// 0x0380, /*0 0 0 0 0 0 Û Û Û 0 0 0 0 0 0 0*/
// 0x0380, /*0 0 0 0 0 0 Û Û Û 0 0 0 0 0 0 0*/
// 0x0000, /*0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0*/
0x0000, /*0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0*/
0x3E70, /*0 0 Û Û Û Û Û 0 0 Û Û Û 0 0 0 0*/
0x0248, /*0 0 0 0 0 0 Û 0 0 Û 0 0 Û 0 0 0*/
0x0244, /*0 0 0 0 0 0 Û 0 0 Û 0 0 0 Û 0 0*/
0x0242, /*0 0 0 0 0 0 Û 0 0 Û 0 0 0 Û 0 0*/
0x2244, /*0 0 Û 0 0 0 Û 0 0 Û 0 0 0 Û 0 0*/
0x2248, /*0 0 Û 0 0 0 Û 0 0 Û 0 0 Û 0 0 0*/
0x3E70, /*0 0 Û Û Û Û Û 0 0 Û Û Û 0 0 0 0*/
0x0000 /*0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0*/
};
void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py)
{
struct SREGS seg;
union REGS ent, sal;
long dir;
ent.x.ax = 0;
int86(0x33, &ent, &sal); /* averigua si hay rat¢n conectado */
raton = sal.x.ax; /* indica a la variable global el estado
del raton */
if(raton!=0) {
ent.x.ax = 15;
ent.x.cx = 5;
ent.x.dx = 11;
int86(0x33, &ent, &sal); /* fija la raz¢n mickey/pixel */
ent.x.ax = 7;
ent.x.cx = x1;
ent.x.dx = x2;
int86(0x33, &ent, &sal); /* fija la posici¢n m x. y m¡n. horizontal */
ent.x.ax = 8;
ent.x.cx = y1;
ent.x.dx = y2;
int86(0x33, &ent, &sal); /* fija la posici¢n m x. y m¡n. vertical */
if(!PunteroRaton) {
dir = (long)dir_raton;
ent.x.ax = 9;
ent.x.bx = 0;
ent.x.cx = 0;
ent.x.dx = (int) dir;
seg.es = (int) (dir >> 16);
int86x(0x33, &ent, &sal, &seg); /* asigna un cursor diferente */
}
ent.x.ax = 4;
ent.x.cx = px;
x_raton=ent.x.cx >> 1;
ent.x.dx = py;
y_raton=ent.x.dx;
int86(0x33, &ent, &sal); /* fija la posici¢n del rat¢n */
ent.x.ax = 1;
int86(0x33, &ent, &sal); /* muestra el puntero del rat¢n */
}
}
void activa_raton(void)
{
union REGS ent, sal;
ent.x.ax = 1;
int86(0x33, &ent, &sal);
}
void desactiva_raton(void)
{
union REGS ent, sal;
ent.x.ax = 2;
int86(0x33, &ent, &sal);
}
void Anclar_Raton(void){
union REGS ent, sal;
do {
ent.x.ax = 3;
int86(0x33, &ent, &sal);
boton_izq = sal.x.bx & 1;
boton_der = (sal.x.bx >> 1) & 1;
} while(boton_izq==1 || boton_der==1);
}
int Espera_Tecla_o_Raton(void){
union REGS ent, sal;
ent.x.ax = 3;
do{
int86(0x33, &ent, &sal); // lee posici¢n y estados del bot¢n
boton_izq = sal.x.bx & 1;
boton_der = (sal.x.bx >> 1) & 1;
x_raton = sal.x.cx;
y_raton = sal.x.dx;
}while( boton_izq == 0 && boton_der == 0 && kbhit()==0 );
/////////////////////////////////////////
// RETURN Derecho Izquierdo //
// //
// 0 0 0 //
// 1 1 0 //
// 2 0 1 //
// 3 1 1 //
// //
/////////////////////////////////////////
int Que;
if ( boton_der==0 && boton_izq==0 ) Que = 0;
if ( boton_der==1 && boton_izq==0 ) Que = 1;
if ( boton_der==0 && boton_izq==1 ) Que = 2;
if ( boton_der==1 && boton_izq==1 ) Que = 3;
return Que;
}