www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/29/03:00:41

From: Dennis Jan Franken <DjFranken AT df DOT allcon DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Djgpp mouse handler without asm ????
Date: Sun, 29 Sep 1996 02:23:45 +0200
Organization: 9 Plans software
Lines: 163
Message-ID: <324DC18D.516D@df.allcon.com>
References: <19960927054758 DOT AAA16113 AT ultra1 DOT inconnect DOT com>
NNTP-Posting-Host: df.allcon.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Stuart Thorpe wrote:
> 
> Have you recieved any type of an answer on this? I am tring to port my
> Watcom code over to DJGPP but I can't get my mouse routies to work, so a
> pure C way would be great.
> 
> Stuart Thorpe - sthorpe AT inconnect DOT com

Yes i have ... thanks !
But the best solution i actually found in the allegro libary ... i
though i seen how allegro does it ,but it must have been code from
a different libary %^}

> In article <32488EB9 DOT 8F4 AT df DOT allcon DOT com> you wrote:
> : Is it possible to set up a mouse handler in DJGPP without using
> : an ASM wrapper ????
> : I would need a kind of _interrupt keyword and _loadds keyword ,
> : but i guess i have to do it with some callback functions !??!?
> : Which one ? real_mode_callback doesn't seems to work ...

The greatest difference between watcom and djgpp i didn't realize
is that in djgpp the mouse handler is called in REALMODE ,unlike
in watcom . I thought this was handled by the dpmi host ,not the
dos extender ,because i used a dpmi function to install the mouse
handler ...

Anyways ,you have to use alloc_realmode_callback_retf ,not the 
alloc_callback_iret ... now it works ... below some code from
our 'gammalib' ,which will be a pretty extreme game libary .
Look at the djgpp section for the mouse handler ...
Hope this helps other poor developers like myself :^)

----

//-WATCOM handler functions-------------------------------
#ifdef __WATCOMC__

int mouse_handler_test;

#pragma off (check_stack)
void _loadds far _mouse_handler(int mask,int x,int y,int count_x,int
count_y)
{       mouse_handler_test=mask;
        input.mouse_handler(mask,x,y,count_x,count_y);
}
#pragma aux mouse_handler parm [eax][ebx][ecx][edx][edi][esi]
#pragma on (check_stack)

int old_mouse_handler_mask;
short old_mouse_handler_seg;
int old_mouse_handler_off;

void Input::install_mouse_handler()
{       REGS regs;
        SREGS sregs;
        if(~handlers_installed & MOUSE)
        {       handlers_installed|=MOUSE;
                memset(&sregs,0,sizeof(SREGS));
                regs.x.eax=0x14;
                regs.x.ecx=127;
                regs.x.edx=(int)_mouse_handler;
                sregs.es=FP_SEG(_mouse_handler);
                int386x(0x33,&regs,&regs,&sregs);
                old_mouse_handler_mask=regs.x.ecx;
                old_mouse_handler_off=regs.x.edx;
                old_mouse_handler_seg=sregs.es;
        }
}

void Input::remove_mouse_handler()
{       REGS regs;
        SREGS sregs;
        if(handlers_installed & MOUSE)
        {       handlers_installed&= ~MOUSE;
                memset(&sregs,0,sizeof(sregs));
                regs.x.eax=0xC;
                regs.x.ecx=old_mouse_handler_mask;
                regs.x.edx=old_mouse_handler_off;
                sregs.es=old_mouse_handler_seg;
                int386x(0x33,&regs,&regs,&sregs);
        }
}

void __interrupt __far (*old_key_handler)();
void __interrupt __far _key_handler()
{       input.key_handler((char)inp(0x60)); // get key from port 0x60
        cli();                          //Macro to clear interrupts
        outp(0x20,0x20);        //tell PIC that im done done
}

void Input::install_key_handler()
{       old_key_handler=_dos_getvect(9);
        _dos_setvect(9,_key_handler);
}

void Input::remove_key_handler()
{       _dos_setvect(9,old_key_handler);
}

#endif

//-DJGPP handler functions----------------
#ifdef DJGPP

_go32_dpmi_registers mouse_regs;
int old_mouse_handler_mask;
int old_mouse_handler_seg;
int old_mouse_handler_off;

int mouse_handler_test;
void _mouse_handler(/*_go32_dpmi_registers *r*/)
{       mouse_handler_test=mouse_regs.x.ax;
       
input.mouse_handler(mouse_regs.x.ax,mouse_regs.x.cx,mouse_regs.x.dx
,mouse_regs.x.di,mouse_regs.x.si);
}

void Input::install_mouse_handler()
{       SREGS sregs;
        __dpmi_regs r;
        _go32_dpmi_seginfo mouse_seginfo;
        if(~handlers_installed & MOUSE)
        {       handlers_installed|=MOUSE;
                memset(&sregs,0,sizeof(SREGS));
                mouse_seginfo.pm_offset=(int)_mouse_handler;
                mouse_seginfo.pm_selector=_my_cs;
               
_go32_dpmi_allocate_real_mode_callback_retf(&mouse_seginfo,
&mouse_regs);
                r.x.ax = 0x14;
                r.x.cx = 0x1F;
                r.x.dx = mouse_seginfo.rm_offset;
                r.x.es = mouse_seginfo.rm_segment;
                __dpmi_int(0x33,&r);

                old_mouse_handler_mask=r.x.cx;
                old_mouse_handler_off=r.x.dx;
                old_mouse_handler_seg=r.x.es;
        }
}

void Input::remove_mouse_handler()
{       __dpmi_regs r;
        if(handlers_installed & MOUSE)
        {       handlers_installed&= ~MOUSE;
                r.x.ax = 0xC;
                r.x.cx=(short)old_mouse_handler_mask;
                r.x.dx=(short)old_mouse_handler_off;
                r.x.es=(short)old_mouse_handler_seg;
                __dpmi_int(0x33, &r);
        }
}
#endif


-- 
             Dennis J. Franken ,mailto:DjFranken AT df DOT allcon DOT com
                     Nine plans ,games development

                         >>>DREAM & REALIZE<<<

http://www.bway.net/~toadeatr/    &&    http://homepages.allcon.com/~df/

- Raw text -


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