如何在dos

时间:2017-07-01 12:12:09

标签: c mouse interrupt dos dosbox

经过一些阅读后,我明白116处理程序应该用于鼠标,使用它之后,只有鼠标的左/右鼠标点击工作,但是当我移动鼠标时,中断不会发生。我怎样才能获得鼠标的动作? 这是我到目前为止所做的: (顺便问一下,我应该拨打原始的116 ISR,还是可选的?)

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

//Will count in milliseconds the time
volatile int timeCounter = 0;
volatile int isPressed = 0;
void exitMode();
void interrupt (*Int116Save)(void);/* Pointer to org ISR116*/
void interrupt (*Int8Save) (void); /* Pointer to org ISR8*/

void interrupt INT8_Handler(void) {
/*We always have to call the original ISR8 before editing the clock*/
/* Call original ISR8 */
    asm{
    PUSHF
    CALL DWORD PTR Int8Save;
    } 
timeCounter++;
//timeCounter = 20 is 1 second, so 1200 is 1 minute, 2400 is 2 minutes
if(timeCounter > 2400){
    printf("User is dreaming, exiting...");
    exitMode();
}
} /* END INT8 Handler */

void interrupt mouseMoved(void){
    /*We always have to call the original ISR116 before listening for a mouse input*/
    /* Call original ISR116 */
     asm{
        PUSHF
        CALL DWORD PTR Int116Save
        }
        isPressed++;
        printf("\nMouse moved\clicked...\n");
}

/*If user is dreaming for 2 minutes, we come here through the clock's handler and exit*/
void exitMode()
{
        printf("\nC: Terminating...\n");
        setvect(8, Int8Save ); /*return org ISR8*/
        setvect(116, Int116Save);/*return org ISR116*/
        exit(0);
}

void main(){
    printf("Please move/click the mouse. \n");

    //Mouse
    Int116Save=getvect(116);
    setvect(116, mouseMoved);


    //Clock
    Int8Save=getvect(8);
    setvect(8, INT8_Handler);

    //
    while(isPressed<100);

    //End the program and return the vect's as needed.
        printf("\nC: Terminating...\n");
        setvect(8, Int8Save ); /*return org ISR8*/
        setvect(116, Int116Save); /*return org ISR116*/

} 

0 个答案:

没有答案