I have a program which prints the current mouse cursor position into the console.
I want to create bounds in which the mouse can go. ( 10,10) and (20,20)
So here is my code so far:
#include <stdio.h>
#include <dos.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
int x,y;
struct REGPACK reg;
void getmousepos()
{
    reg.r_ax=0x03;
    intr(0x33,®);
    x=reg.r_cx/8;
    y=reg.r_dx/8;
}
int main()
{
    clrscr();
    _setcursortype(_NOCURSOR);
    reg.r_ax=0x01;
    intr(0x33,®);
    do
    {
        getmousepos();
        printf("                        ");
        printf("                        ");
        window(1,1,79,24);
        printf("Current position : %3d, %3d",x,y);
        if(x < 10)
        //set the x cursor possition to 10
        if(x > 20)
        //set the x cursor possition to 20
        if(y < 10)
        //set the y cursor to 10
        if(y > 20)
        //set the y cursor to 20
    }while(!kbhit());
    return 1;
}
Is there any way of setting reg.r_cx and reg.r_dx registers with the cordinates i want, and then calling intr() with the proper interrupt ?
                        
You do that simply the same way as you have done it in getMouse():
Alternative you can use range limiter: