www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/25/19:15:40

From: Charles Terry <cterry AT plinetl DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: event handler
Date: Fri, 23 Jan 1998 22:25:20 -0800
Organization: All USENET -- http://www.Supernews.com
Lines: 61
Message-ID: <34C9894F.3360@plinetl.com>
Reply-To: cterry AT plinet DOT com
NNTP-Posting-Host: 10885 AT 206 DOT 168 DOT 149 DOT 189
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


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