הסבר על הקוד:
טוב הנה הסבר... אחד אחד union REGS r; r.x.ax=1; int86(0x33,&r,&r); בקטע הזה הפעלתי את העבר ע"י פסיקה מס´ 1 באמצעות הפונקציה int86
r.x.ax=3; while(!kbhit()){ int86(0x33,&r,&r); } בקו הנ"ל גרמתי לעכבר להיראות על גבי המסך.... הנה דוגמא קצת יותר מלאה לקוד... :
#include <graphics.h> #include <dos.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> void main(void) { int gdriver = DETECT, gmode, errorcode; initgraph(&gdriver, &gmode, ""); errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* return with error code */ } // now i will activate the mouse union REGS r; r.x.ax=1; // the int request int86(0x33,&r,&r); // this will call fot the interrupt to happen // now i will show the mouse and do some stuff r.x.ax=3; while(!kbhit()){ int86(0x33,&r,&r); if(r.x.bx&0x01) { cleardevice(); outtextxy(0,0,"Left mouse button");} if(r.x.bx&0x02) { cleardevice(); outtextxy(0,0,"Right mouse button");} }; }
תפעיל את הקוד ותדע לבד מה זה עושה... מפעיל עכבר ובודק שני כפתורים, שמאלי וימני...