Mail Archives: djgpp/1998/01/25/19:15:40
I've been working with a mouse class I pulled from the news archives
It's been hacked by me but I left the credits I found-(not sure about
whats proper).
Anyway I install an event handler for the mouse no problem.
It works except for accessing the screenarray. The array holds who owns
that portion of the screen.
If I change the line MA=scr.screenarray[....]
to MA=1,
everything works, but if I leave that line in it reboots th computer.
Source follows(various items removed for brevity)
// "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
screen scr;
int MA;
int MC;
int MR;
enum{LB=1,MB=4,RB=2};
Regs R;
text_info info;
screen::screen(){
textmode(C4350);
.
.
.
.
gettextinfo(&info);
assert(screenarray=new int[info.screenwidth*info.screenheight]);
}
void Mouse::settrap(unsigned int mask,void (*func)(REGS *)) {
Regs r;
cb_info.pm_offset=(unsigned long)func;
mouse.handlerInstalled=1;
if(_go32_dpmi_allocate_real_mode_callback_retf(&cb_info,&cb_regs))
return;
R.x.dx=cb_info.rm_offset; R.x.es=cb_info.rm_segment;}
R.x.ax=0x0c;
R.x.cx=mask;
int86dpmi(0x33);} //This call calls int 0x31 ax=0300h
void event(REGS*R){
char events;
events=R->x.ax;
mouse.buttons=R->x.bx&7;
mouse.x=R->x.cx/8;
mouse.y=R->x.dx/8;
if(events&0x02) {
MC=mouse.ldx=mouse.x;
MR=mouse.ldy=mouse.y;
if(mouse.bd)
MA=scr.screenarray[((mouse.y-1)*scr.rows)+mouse.x]; //**********PROBLEM
LINE
// Copyright © 1997 by DJ Delorie Updated May
1997
- Raw text -