Mail Archives: djgpp/1997/12/07/18:32:28
From: | "Jean-Sebastien Payette" <jeanspayette AT videotron DOT ca>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | help me with gnu ostream
|
Date: | Sun, 7 Dec 1997 13:36:57 -0500
|
Organization: | VTL
|
Lines: | 15
|
Message-ID: | <66eqb7$jh5$1@weber.videotron.net>
|
NNTP-Posting-Host: | modemcable104.147.mmtl.videotron.net
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Even if this may be for a c++ newsgroups but i'll ask here anyway as for my
question concern a gnu library
PLEASE send me a exemple on how to use ostream.h
I know how to include it and everything and that I can declare a variable as
ostream but I need to know how to change their value
It's to use as string so I can do string1 = string2 without having to bother
about GPF (damn strdup() I hate it)
OR if somebody can send me a library that make string as easy to use that
the one in borland pascal!!
he mouse to work in a program using
> DJGPP.
The main mouse driver interface is identical under DJGPP as it was under
16-bit Turbo C.
I'm attaching my 16-bit mouse driver (modified to use shorts instead of
ints [which were 16-bit under Turbo C], which was the only mod needed).
Read the info at the top of the program for some details.
--------------2E3E34F970C4
Content-Type: text/plain; charset=us-ascii; name="Mouse.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Mouse.c"
/****************************************************************************/
/*Mouse Buttons Bit-Pattern: 0=left button, 1=right button, 2=center button */
/* */
/*This is =REALLY= old code I used when I first started using the mouse in */
/*my 16-bit programs. It ported to DJGPP with minor modifications. I did */
/*not feel like cleaning up my code, so it's still in the original sloppy */
/*form I first learned to use. :) Fortunately interrupt 0x33 is one of the */
/*int86()-supported set. I tested only resetmouse(), so I'm not 100% sure */
/*that all the routines work properly in 32-bits. Regardless, use this for */
/*whatever you want. I don't need (or really want) credit for this mess. */
/****************************************************************************/
#include <dos.h>
void resetmouse(exists,buttons)
unsigned short *exists; /*Does mouse exist? (0=no, FFFF=yes */
unsigned short *buttons; /*Number of buttons on this mouse */
{
union REGS reg;
reg.x.ax=0;
int86(0x33,®,®);
*exists=reg.x.ax;
*buttons=reg.x.bx;
}
void showmouse(void)
{
union REGS reg;
reg.x.ax=1;
int86(0x33,®,®);
}
void hidemouse(void)
{
union REGS reg;
reg.x.ax=2;
int86(0x33,®,®);
}
void getposition(buttons,xcor,ycor)
unsigned short *buttons; /*Which buttons are down */
unsigned short *xcor; /*Mouse x-coordinate in pixels */
unsigned short *ycor; /*Mouse y-coordinate in pixels */
{
union REGS reg;
reg.x.ax=3;
int86(0x33,®,®);
*buttons=reg.x.bx;
*xcor=reg.x.cx;
*ycor=reg.x.dx;
}
void setposition(xcor,ycor)
unsigned short int xcor; /*Mouse x-coordinate in pixels */
unsigned short int ycor; /*Mouse y-coordinate in pixels */
{
union REGS reg;
reg.x.ax=0x0004;
reg.x.cx=xcor;
reg.x.dx=ycor;
int86(0x33,®,®);
}
void getpressinfo(button,buttons,counter,xcor,ycor)
unsigned short button; /*Button to check (see bit pattern) */
unsigned short *buttons; /*Returned mouse button status bits */
unsigned short *counter; /*Mouse button press counter */
unsigned short *xcor; /*Returned mouse x-coordinate */
unsigned short *ycor; /*Returned mouse y-coordinate */
{
union REGS reg;
reg.x.ax=5;
reg.x.bx=button;
int86(0x33,®,®);
*buttons=reg.x.ax;
*counter=reg.x.bx;
*xcor=reg.x.cx;
*ycor=reg.x.dx;
}
void getreleaseinfo(button,buttons,counter,xcor,ycor)
unsigned short button; /*Button to check (see bit pattern) */
unsigned short *buttons; /*Returned mouse button status bits */
unsigned short *counter; /*Mouse button release counter */
unsigned short *xcor; /*Returned mouse x-coordinate */
unsigned short *ycor; /*Returned mouse y-coordinate */
{
union REGS reg;
reg.x.ax=6;
reg.x.bx=button;
int86(0x33,®,®);
*buttons=reg.x.ax;
*counter=reg.x.bx;
*xcor=reg.x.cx;
*ycor=reg.x.dx;
}
void sethorizlimit(minimum,maximum)
unsigned short minimum;
unsigned short maximum;
{
union REGS reg;
reg.x.ax=7;
reg.x.cx=minimum; /*Minimum x-coordinate for mouse */
reg.x.dx=maximum; /*Maximum x-coordinate for mouse */
int86(0x33,®,®);
}
void setvertlimit(minimum,maximum)
unsigned short minimum;
unsigned short maximum;
{
union REGS reg;
reg.x.ax=8;
reg.x.cx=minimum; /*Minimum y-coordinate for mouse */
reg.x.dx=maximum; /*Maximum y-coordinate for mouse */
int86(0x33,®,®);
}
int leftmousebuttonpressed(unsigned short int buttons)
{
unsigned short int xcor=0;
unsigned short int ycor=0;
getposition(&buttons,&xcor,&ycor);
if (buttons & 1)
return(1);
return(0);
}
int rightmousebuttonpressed(unsigned short int buttons)
{
unsigned short int xcor=0;
unsigned short int ycor=0;
getposition(&buttons,&xcor,&ycor);
if (buttons & 2)
return(1);
return(0);
}
int middlemousebuttonpressed(unsigned short int buttons)
{
unsigned short int xcor=0;
unsigned short int ycor=0;
getposition(&buttons,&xcor,&ycor);
if (buttons & 4)
return(1);
return(0);
}
void releaseleftmousebutton(unsigned short int *buttons)
{
unsigned short int xcor=0;
unsigned short int ycor=0;
*buttons = 1;
while ( (*buttons) & 1)
getposition(buttons,&xcor,&ycor);
}
void releaserightmousebutton(unsigned short int *buttons)
{
unsigned short int xcor=0;
unsigned short int ycor=0;
*buttons = 2;
while ( (*buttons) & 2)
getposition(buttons,&xcor,&ycor);
}
/***************************************************************************/
/*End of mouse code. Test program follows */
/***************************************************************************/
int main(void)
{
unsigned short Exists,Buttons;
resetmouse(&Exists,&Buttons);
return 0;
}
--------------2E3E34F970C4--
- Raw text -