C Program Using 8086 Interrupts to Restrict Mouse Pointer Into a Circle of Given Center and Radius

C Program Using 8086 Interrupts to Restrict Mouse Pointer Into a Circle of Given Center and Radius. The mouse ponter will be restricted to a circle of user specified center and radius using the interrupt 33 of 8086 in c complier. I have tested this program in Turbo C compiler.
How to restrict mouse cursor or pointer within a user specified circle Using 8086 INT33 service interrupts arrow mice radius centre Turbo c program Turbo C++ code source code without thread screen rectangle
Mouse pointer restricted into a circle in Turbo C


#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>

void main()
 {
 int x,y,tx,ty,r;
 union REGS inreg, outreg;
 /* request auto detection */
 int gdriver = DETECT, gmode, errorcode;
 clrscr();
 /* initialize graphics and local variables */
 initgraph(&gdriver, &gmode,"C:\\TC\\BGI\\" );
 /* read result of initialization */
 errorcode = graphresult();
 if (errorcode != grOk)  /* an error occurred */
  {
  printf("Graphics error: %s\n", grapherrormsg(errorcode));
  printf("Press any key to halt:");
  getch();
  exit(1); /* terminate with an error code */
  }
 setcolor(getmaxcolor());
 printf("\nEnter the center of circle. x and y");
 scanf("%d%d",&x,&y);
 printf("\nEnter the radius of circle");
 scanf("%d",&r);
 clrscr();
 circle(x,y,r);
 inreg.x.ax=0x1;
 int86(0x33,&inreg,&outreg);
 inreg.x.ax=0x7;
 inreg.x.cx=x-r;
 inreg.x.dx=x+r;
 int86(0x33,&inreg,&outreg);
 inreg.x.ax=0x8;
 inreg.x.cx=y-r;
 inreg.x.dx=y+r;
 int86(0x33,&inreg,&outreg);
 do
 {
  inreg.x.ax=0x3;
  int86(0x33,&inreg,&outreg);
  tx=outreg.x.cx;
  ty=outreg.x.dx;
  if((tx-x)*(tx-x)+(ty-y)*(ty-y)>r*r)
   {
   if(tx<=x)
   {
   if(ty<y)
    do{tx++; ty++;}while((tx-x)*(tx-x)+(ty-y)*(ty-y)>=r*r);
   else
    do{tx++; ty--;}while((tx-x)*(tx-x)+(ty-y)*(ty-y)>=r*r);
   }
   else
   {
   if(ty<=y)
    do{tx--; ty++;}while((tx-x)*(tx-x)+(ty-y)*(ty-y)>=r*r);
   else
    do{tx--; ty--;}while((tx-x)*(tx-x)+(ty-y)*(ty-y)>=r*r);
   }
   inreg.x.ax=0x4;
   inreg.x.cx=tx;
   inreg.x.dx=ty;
   int86(0x33,&inreg,&outreg);
   }
 }while(1);
}

No comments :

Post a Comment