Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ukma!uflorida!beach.cis.ufl.edu!jdc From: jdc@beach.cis.ufl.edu (Jeff Capehart) Newsgroups: comp.sys.ibm.pc.programmer Subject: Re: Mouse Event Handler Questions Message-ID: <22430@uflorida.cis.ufl.EDU> Date: 23 Feb 90 23:59:45 GMT References: <29630001@hpfinote.HP.COM> Sender: news@uflorida.cis.ufl.EDU Reply-To: jdc@beach.cis.ufl.edu (Jeff Capehart) Organization: UF CIS Department Lines: 48 In a previous article jhs@hpfinote.HP.COM (John Stanback) writes: >I'm trying to install a mouse event handler function using TurboC 1.5 >with the medium memory model. The mouse handler is installed using >INT 33, function 12. The references I've seen to doing this use >an area in the PSP to store the mouse event status and access this >memory referencing _CS in the mouse handler. This seems to work in >the small memory model, but not in the medium. How can I store the >mouse event status using the medium memory model???? Also, I would >like to be able to access the programs global variables from the >mouse handler. Is this possible??? Yes, it is possible because I have done it. You may not like my solution but it works. If all you are interested in is working then listen up. The problem comes from the fact that the _PSP doesn't seem to work right in the medium and large models. And, when referencing _CS, you are in a different segment than in the small model. The example programs that came with the mouse for TurboC *CHEAT* and use small model. Anyone could do it in small model, sheesh! The main program can setup the buffer area fine in the end half of the PSP area. The interrupt handler cannot find it because it uses a different code and data segment. So, there must be someway to get it to use the same area. Well, this is exactly why you were using the PSP area in the first place. Viscous circle right? Global variables won't cut it because you get a different _DS and _CS when the interrupt handler is called. It can't find your global variables. What I decided to do was use some globally known memory locations. Since 8088 doesn't have a "zero page" like on 6502 machines, the closest thing was the Interrupt Vectors. These are modifiable and they come in groups of 4 bytes. The easiest one to pick is the "switch to Basic" interrupt. Who needs it anyways, especially if you are in TurboC anyways! heh heh. Ok, so I forget which it was, but assume it is 0000:0064 for now. Before installing the handler, make a far pointer to it MK_FP (0x0000, 0x0064) and then stuff into it the address of the PSP, or the _CS for the _MAIN. Also, in the interrupt handler, make a far pointer to it and extract the value from there. Then, make another far pointer out of THAT value and you have the address you want. You can either save the segment or both the seg & offset. Just be consistent. Be careful about what interrupt vector you steal because some of them are important. Others are not so important like the Basic interrupt. -- Jeff Capehart Internet: jdc@beach.cis.ufl.edu University of Florida UUCP: ..!uflorida!beach.cis.ufl.edu!jdc