Mail Archives: djgpp/2002/01/22/00:47:06
Hi, my name is Joel, and I'm new here.
What I'd like to ask is, is it possible to DJGPP program that will stay
resident in protected mode after it ends and the computer goes back to
real mode? For instance, I made a program that has the real mode mouse
interrupt 33h call a DGJPP routine when the right mouse button is
pushed, and that routine is supposed to make the computer beep. But
when I run my program, nothing happens.
Here's my program, if anybody call tell me what I'm doing wrong, or, if
it's impossible to do what I want, I'd appreciate it. Thanks.
#include <dpmi.h>
#include <go32.h>
static __dpmi_regs callback_regs;
static _go32_dpmi_seginfo callback_info;
void New_Mouse_Handler(void);
void User_Handler(__dpmi_regs *r);
unsigned char Character = 0;
char *Mouse_Pointer, *Mouse_Background;
int Install_Mouse_Handler(unsigned mask, void
(*User_Handler)(__dpmi_regs *));
void User_Handler(__dpmi_regs *r);
main(void)
{
__dpmi_regs r;
Install_Mouse_Handler(0x2, User_Handler);
r.x.ax = 0x3100;
r.x.dx = 4;
__dpmi_int(0x21, &r);
//__dpmi_terminate_and_stay_resident(0, 4);
}
int Install_Mouse_Handler(unsigned mask, void
(*User_Handler)(__dpmi_regs *))
{
__dpmi_regs r;
callback_info.pm_offset = (long)User_Handler;
if(_go32_dpmi_allocate_real_mode_callback_retf(&callback_info,
&callback_regs))
return -1; /* failure */
r.x.ax = 0xc;
r.x.cx = mask;
r.x.es = callback_info.rm_segment;
r.x.dx = callback_info.rm_offset;
__dpmi_int(0x33, &r);
return(r.x.flags & 1) ? -1 : 0;
}
void User_Handler(__dpmi_regs *r)
{
__dpmi_regs R;
if(r->x.cx == 2) {
R.x.ax = 0x0E07;
R.x.bx = 0;
__dpmi_int(0x10, &R);
}
}
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
- Raw text -