www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/03/21/03:55:23

From: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
To: DJGPP AT DELORIE DOT COM
Date: Thu, 21 Mar 1996 08:47:51 GMT
Subject: A way to define my own mouse event handler
Message-ID: <A2D7975711@fs2.mt.umist.ac.uk>

   A while ago, Eli Zaretski kindly sent me this way to define my own mouse
event handler for djgpp v1. Will it still work with v2?
#include <pc.h>
#include <dpmi.h>
#include <dos.h>
#include <go32.h>
/*-----*/
/* Simulate a software interrupt from protected mode. Like int86() but calls
   DPMI services and so doesn't need DOS extender, only a DPMI server. */
int int86dpmi(int intno) {REGS r,s; Regs S; S=R;
S.x.ss=S.x.sp=0;      /* DPMI server is to provide stack for interrupt call */
S.x.flags=0;                       /* he likeliest forgot to zero the flags */
/* I replaced the _go32_dpmi_simulate_int() call by a copy of its body here */
r.h.bl=intno; r.h.bh=0; r.x.cx=0; r.x.di=(int)&S;
if(intno==0x21 && S.x.ax==0x4b00) {                 /* call a child process */
      r.x.ax=0xff0a; int86(0x21,&r,&s);}
else {r.x.ax=0x0300; int86(0x31,&r,&s);}
R=S; return R.d.eax;}
/*-----*/
Regs cb_regs; static _go32_dpmi_seginfo cb_info; /* for callback */
/*-----*/
void Mouse::settrap(uns int mask,void (*func)(Regs *)) {
/* This is tricky in protected-mode. We must allocate a real-mode wrapper
   function which will be called by the mouse driver, and which in turn will
   switch to protected-mode and call our protected-mode handler function. */
if(!Jerry.nbuttons) return;
if(!func) {Jerry.handlerInstalled=0; /* remove handler */
    _go32_dpmi_free_real_mode_callback(&cb_info); R.x.dx=R.x.es=0;}
else { /* Allocate real-mode call-back. Find real-mode address of handler */
    cb_info.pm_offset=(uns long)func; Jerry.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=12; R.x.cx=mask; int86dpmi(0x33);}

- Raw text -


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